@xylabs/react-scroll-to-top 3.4.1 → 3.4.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.cjs +36 -10
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -2
- package/dist/browser/index.d.mts +2 -2
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.mjs +51 -0
- package/dist/{node/index.js.map → browser/index.mjs.map} +1 -1
- package/dist/neutral/index.cjs +36 -10
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +2 -2
- package/dist/neutral/index.d.mts +2 -2
- package/dist/neutral/index.d.ts +2 -2
- package/dist/neutral/index.mjs +51 -0
- package/dist/{browser/index.js.map → neutral/index.mjs.map} +1 -1
- package/dist/node/index.cjs +36 -10
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.mjs +51 -0
- package/dist/{neutral/index.js.map → node/index.mjs.map} +1 -1
- package/package.json +9 -9
- package/src/index.ts +2 -2
- package/dist/browser/index.js +0 -33
- package/dist/neutral/index.js +0 -33
- package/dist/node/index.js +0 -33
package/dist/browser/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
18
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
30
|
|
|
20
31
|
// src/index.ts
|
|
@@ -28,29 +39,44 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
39
|
// src/ScrollToTop.tsx
|
|
29
40
|
var import_react = require("react");
|
|
30
41
|
var import_react_router_dom = require("react-router-dom");
|
|
31
|
-
var ScrollToTop = () => {
|
|
42
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
32
43
|
const { pathname } = (0, import_react_router_dom.useLocation)();
|
|
33
44
|
(0, import_react.useEffect)(() => {
|
|
34
45
|
window.scrollTo(0, 0);
|
|
35
|
-
}, [
|
|
46
|
+
}, [
|
|
47
|
+
pathname
|
|
48
|
+
]);
|
|
36
49
|
return null;
|
|
37
|
-
};
|
|
50
|
+
}, "ScrollToTop");
|
|
38
51
|
|
|
39
52
|
// src/ScrollToTopButton.tsx
|
|
40
53
|
var import_material = require("@mui/material");
|
|
41
|
-
var
|
|
42
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
54
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
55
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
43
56
|
const trigger = (0, import_material.useScrollTrigger)({
|
|
44
57
|
disableHysteresis: true,
|
|
45
58
|
threshold: 100
|
|
46
59
|
});
|
|
47
|
-
const handleClick = (event) => {
|
|
60
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
48
61
|
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
49
62
|
if (anchor) {
|
|
50
|
-
anchor.scrollIntoView({
|
|
63
|
+
anchor.scrollIntoView({
|
|
64
|
+
behavior: "smooth",
|
|
65
|
+
block: "center"
|
|
66
|
+
});
|
|
51
67
|
}
|
|
52
|
-
};
|
|
68
|
+
}, "handleClick");
|
|
53
69
|
const theme = (0, import_material.useTheme)();
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
|
|
70
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_material.Zoom, {
|
|
71
|
+
in: trigger,
|
|
72
|
+
...props
|
|
73
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_material.Box, {
|
|
74
|
+
zIndex: 10,
|
|
75
|
+
position: "fixed",
|
|
76
|
+
right: theme.spacing(2),
|
|
77
|
+
bottom: theme.spacing(2),
|
|
78
|
+
onClick: handleClick,
|
|
79
|
+
role: "presentation"
|
|
80
|
+
}, children));
|
|
81
|
+
}, "ScrollToTopButton");
|
|
56
82
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.tsx'\nexport * from './ScrollToTopButton.tsx'\n","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 { 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;;;;;;;;ACAA,mBAA0B;AAC1B,8BAA4B;AAIrB,IAAMA,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,QAAKC,qCAAAA;AACrBC,8BAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,sBAAiE;AACjE,IAAAK,gBAAkB;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,cAAUC,kCAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,YAAQC,0BAAAA;AAEd,SACE,8BAAAC,QAAA,cAACC,sBAAAA;IAAKC,IAAIlB;IAAU,GAAGD;KACrB,8BAAAiB,QAAA,cAACG,qBAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOR,MAAMS,QAAQ,CAAA;IAAIC,QAAQV,MAAMS,QAAQ,CAAA;IAAIE,SAASrB;IAAasB,MAAK;KAC7G7B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","import_react","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","React","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/ScrollToTop.tsx
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useLocation } from "react-router-dom";
|
|
7
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
8
|
+
const { pathname } = useLocation();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
window.scrollTo(0, 0);
|
|
11
|
+
}, [
|
|
12
|
+
pathname
|
|
13
|
+
]);
|
|
14
|
+
return null;
|
|
15
|
+
}, "ScrollToTop");
|
|
16
|
+
|
|
17
|
+
// src/ScrollToTopButton.tsx
|
|
18
|
+
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
19
|
+
import React from "react";
|
|
20
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
21
|
+
const trigger = useScrollTrigger({
|
|
22
|
+
disableHysteresis: true,
|
|
23
|
+
threshold: 100
|
|
24
|
+
});
|
|
25
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
26
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
27
|
+
if (anchor) {
|
|
28
|
+
anchor.scrollIntoView({
|
|
29
|
+
behavior: "smooth",
|
|
30
|
+
block: "center"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, "handleClick");
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Zoom, {
|
|
36
|
+
in: trigger,
|
|
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");
|
|
47
|
+
export {
|
|
48
|
+
ScrollToTop,
|
|
49
|
+
ScrollToTopButton
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 { 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":"
|
|
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 { 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,SAASA,iBAAiB;AAC1B,SAASC,mBAAmB;AAIrB,IAAMC,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,IAAKC,YAAAA;AACrBC,YAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,SAASK,KAAKC,kBAAkBC,UAAUC,YAAuB;AACjE,OAAOC,WAAW;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,UAAUC,iBAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,QAAQC,SAAAA;AAEd,SACE,sBAAA,cAACC,MAAAA;IAAKC,IAAIjB;IAAU,GAAGD;KACrB,sBAAA,cAACmB,KAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOP,MAAMQ,QAAQ,CAAA;IAAIC,QAAQT,MAAMQ,QAAQ,CAAA;IAAIE,SAASpB;IAAaqB,MAAK;KAC7G5B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["useEffect","useLocation","ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","Box","useScrollTrigger","useTheme","Zoom","React","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
18
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
30
|
|
|
20
31
|
// src/index.ts
|
|
@@ -28,29 +39,44 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
39
|
// src/ScrollToTop.tsx
|
|
29
40
|
var import_react = require("react");
|
|
30
41
|
var import_react_router_dom = require("react-router-dom");
|
|
31
|
-
var ScrollToTop = () => {
|
|
42
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
32
43
|
const { pathname } = (0, import_react_router_dom.useLocation)();
|
|
33
44
|
(0, import_react.useEffect)(() => {
|
|
34
45
|
window.scrollTo(0, 0);
|
|
35
|
-
}, [
|
|
46
|
+
}, [
|
|
47
|
+
pathname
|
|
48
|
+
]);
|
|
36
49
|
return null;
|
|
37
|
-
};
|
|
50
|
+
}, "ScrollToTop");
|
|
38
51
|
|
|
39
52
|
// src/ScrollToTopButton.tsx
|
|
40
53
|
var import_material = require("@mui/material");
|
|
41
|
-
var
|
|
42
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
54
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
55
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
43
56
|
const trigger = (0, import_material.useScrollTrigger)({
|
|
44
57
|
disableHysteresis: true,
|
|
45
58
|
threshold: 100
|
|
46
59
|
});
|
|
47
|
-
const handleClick = (event) => {
|
|
60
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
48
61
|
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
49
62
|
if (anchor) {
|
|
50
|
-
anchor.scrollIntoView({
|
|
63
|
+
anchor.scrollIntoView({
|
|
64
|
+
behavior: "smooth",
|
|
65
|
+
block: "center"
|
|
66
|
+
});
|
|
51
67
|
}
|
|
52
|
-
};
|
|
68
|
+
}, "handleClick");
|
|
53
69
|
const theme = (0, import_material.useTheme)();
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
|
|
70
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_material.Zoom, {
|
|
71
|
+
in: trigger,
|
|
72
|
+
...props
|
|
73
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_material.Box, {
|
|
74
|
+
zIndex: 10,
|
|
75
|
+
position: "fixed",
|
|
76
|
+
right: theme.spacing(2),
|
|
77
|
+
bottom: theme.spacing(2),
|
|
78
|
+
onClick: handleClick,
|
|
79
|
+
role: "presentation"
|
|
80
|
+
}, children));
|
|
81
|
+
}, "ScrollToTopButton");
|
|
56
82
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.tsx'\nexport * from './ScrollToTopButton.tsx'\n","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 { 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;;;;;;;;ACAA,mBAA0B;AAC1B,8BAA4B;AAIrB,IAAMA,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,QAAKC,qCAAAA;AACrBC,8BAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,sBAAiE;AACjE,IAAAK,gBAAkB;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,cAAUC,kCAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,YAAQC,0BAAAA;AAEd,SACE,8BAAAC,QAAA,cAACC,sBAAAA;IAAKC,IAAIlB;IAAU,GAAGD;KACrB,8BAAAiB,QAAA,cAACG,qBAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOR,MAAMS,QAAQ,CAAA;IAAIC,QAAQV,MAAMS,QAAQ,CAAA;IAAIE,SAASrB;IAAasB,MAAK;KAC7G7B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","import_react","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","React","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/dist/neutral/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/ScrollToTop.tsx
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useLocation } from "react-router-dom";
|
|
7
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
8
|
+
const { pathname } = useLocation();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
window.scrollTo(0, 0);
|
|
11
|
+
}, [
|
|
12
|
+
pathname
|
|
13
|
+
]);
|
|
14
|
+
return null;
|
|
15
|
+
}, "ScrollToTop");
|
|
16
|
+
|
|
17
|
+
// src/ScrollToTopButton.tsx
|
|
18
|
+
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
19
|
+
import React from "react";
|
|
20
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
21
|
+
const trigger = useScrollTrigger({
|
|
22
|
+
disableHysteresis: true,
|
|
23
|
+
threshold: 100
|
|
24
|
+
});
|
|
25
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
26
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
27
|
+
if (anchor) {
|
|
28
|
+
anchor.scrollIntoView({
|
|
29
|
+
behavior: "smooth",
|
|
30
|
+
block: "center"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, "handleClick");
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Zoom, {
|
|
36
|
+
in: trigger,
|
|
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");
|
|
47
|
+
export {
|
|
48
|
+
ScrollToTop,
|
|
49
|
+
ScrollToTopButton
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 { 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":"
|
|
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 { 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,SAASA,iBAAiB;AAC1B,SAASC,mBAAmB;AAIrB,IAAMC,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,IAAKC,YAAAA;AACrBC,YAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,SAASK,KAAKC,kBAAkBC,UAAUC,YAAuB;AACjE,OAAOC,WAAW;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,UAAUC,iBAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,QAAQC,SAAAA;AAEd,SACE,sBAAA,cAACC,MAAAA;IAAKC,IAAIjB;IAAU,GAAGD;KACrB,sBAAA,cAACmB,KAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOP,MAAMQ,QAAQ,CAAA;IAAIC,QAAQT,MAAMQ,QAAQ,CAAA;IAAIE,SAASpB;IAAaqB,MAAK;KAC7G5B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["useEffect","useLocation","ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","Box","useScrollTrigger","useTheme","Zoom","React","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
}
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
18
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
30
|
|
|
20
31
|
// src/index.ts
|
|
@@ -28,31 +39,46 @@ module.exports = __toCommonJS(src_exports);
|
|
|
28
39
|
// src/ScrollToTop.tsx
|
|
29
40
|
var import_react = require("react");
|
|
30
41
|
var import_react_router_dom = require("react-router-dom");
|
|
31
|
-
var ScrollToTop = () => {
|
|
42
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
32
43
|
const { pathname } = (0, import_react_router_dom.useLocation)();
|
|
33
44
|
(0, import_react.useEffect)(() => {
|
|
34
45
|
window.scrollTo(0, 0);
|
|
35
|
-
}, [
|
|
46
|
+
}, [
|
|
47
|
+
pathname
|
|
48
|
+
]);
|
|
36
49
|
return null;
|
|
37
|
-
};
|
|
50
|
+
}, "ScrollToTop");
|
|
38
51
|
|
|
39
52
|
// src/ScrollToTopButton.tsx
|
|
40
53
|
var import_material = require("@mui/material");
|
|
41
|
-
var
|
|
42
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
54
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
55
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
43
56
|
const trigger = (0, import_material.useScrollTrigger)({
|
|
44
57
|
disableHysteresis: true,
|
|
45
58
|
threshold: 100
|
|
46
59
|
});
|
|
47
|
-
const handleClick = (event) => {
|
|
60
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
48
61
|
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
49
62
|
if (anchor) {
|
|
50
|
-
anchor.scrollIntoView({
|
|
63
|
+
anchor.scrollIntoView({
|
|
64
|
+
behavior: "smooth",
|
|
65
|
+
block: "center"
|
|
66
|
+
});
|
|
51
67
|
}
|
|
52
|
-
};
|
|
68
|
+
}, "handleClick");
|
|
53
69
|
const theme = (0, import_material.useTheme)();
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
|
|
70
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_material.Zoom, {
|
|
71
|
+
in: trigger,
|
|
72
|
+
...props
|
|
73
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_material.Box, {
|
|
74
|
+
zIndex: 10,
|
|
75
|
+
position: "fixed",
|
|
76
|
+
right: theme.spacing(2),
|
|
77
|
+
bottom: theme.spacing(2),
|
|
78
|
+
onClick: handleClick,
|
|
79
|
+
role: "presentation"
|
|
80
|
+
}, children));
|
|
81
|
+
}, "ScrollToTopButton");
|
|
56
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
83
|
0 && (module.exports = {
|
|
58
84
|
ScrollToTop,
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/ScrollToTop.tsx","../../src/ScrollToTopButton.tsx"],"sourcesContent":["export * from './ScrollToTop.tsx'\nexport * from './ScrollToTopButton.tsx'\n","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 { 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;;;;;;;;ACAA,mBAA0B;AAC1B,8BAA4B;AAIrB,IAAMA,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,QAAKC,qCAAAA;AACrBC,8BAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,sBAAiE;AACjE,IAAAK,gBAAkB;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,cAAUC,kCAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,YAAQC,0BAAAA;AAEd,SACE,8BAAAC,QAAA,cAACC,sBAAAA;IAAKC,IAAIlB;IAAU,GAAGD;KACrB,8BAAAiB,QAAA,cAACG,qBAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOR,MAAMS,QAAQ,CAAA;IAAIC,QAAQV,MAAMS,QAAQ,CAAA;IAAIE,SAASrB;IAAasB,MAAK;KAC7G7B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","import_react","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","React","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/ScrollToTop.tsx
|
|
5
|
+
import { useEffect } from "react";
|
|
6
|
+
import { useLocation } from "react-router-dom";
|
|
7
|
+
var ScrollToTop = /* @__PURE__ */ __name(() => {
|
|
8
|
+
const { pathname } = useLocation();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
window.scrollTo(0, 0);
|
|
11
|
+
}, [
|
|
12
|
+
pathname
|
|
13
|
+
]);
|
|
14
|
+
return null;
|
|
15
|
+
}, "ScrollToTop");
|
|
16
|
+
|
|
17
|
+
// src/ScrollToTopButton.tsx
|
|
18
|
+
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
19
|
+
import React from "react";
|
|
20
|
+
var ScrollToTopButton = /* @__PURE__ */ __name(({ children, anchorId, ...props }) => {
|
|
21
|
+
const trigger = useScrollTrigger({
|
|
22
|
+
disableHysteresis: true,
|
|
23
|
+
threshold: 100
|
|
24
|
+
});
|
|
25
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
26
|
+
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
27
|
+
if (anchor) {
|
|
28
|
+
anchor.scrollIntoView({
|
|
29
|
+
behavior: "smooth",
|
|
30
|
+
block: "center"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, "handleClick");
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Zoom, {
|
|
36
|
+
in: trigger,
|
|
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");
|
|
47
|
+
export {
|
|
48
|
+
ScrollToTop,
|
|
49
|
+
ScrollToTopButton
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 { 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":"
|
|
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 { 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,SAASA,iBAAiB;AAC1B,SAASC,mBAAmB;AAIrB,IAAMC,cAAc,6BAAA;AACzB,QAAM,EAAEC,SAAQ,IAAKC,YAAAA;AACrBC,YAAU,MAAA;AACRC,WAAOC,SAAS,GAAG,CAAA;EACrB,GAAG;IAACJ;GAAS;AAEb,SAAO;AACT,GAP2B;;;ACL3B,SAASK,KAAKC,kBAAkBC,UAAUC,YAAuB;AACjE,OAAOC,WAAW;AAMX,IAAMC,oBAAsD,wBAAC,EAAEC,UAAUC,UAAU,GAAGC,MAAAA,MAAO;AAClG,QAAMC,UAAUC,iBAAiB;IAC/BC,mBAAmB;IACnBC,WAAW;EACb,CAAA;AAEA,QAAMC,cAAc,wBAACC,UAAAA;AACnB,UAAMC,UAAWD,MAAME,OAA0BC,iBAAiBC,UAAUC,cAAc,IAAIZ,QAAAA,EAAU;AAExG,QAAIQ,QAAQ;AACVA,aAAOK,eAAe;QAAEC,UAAU;QAAUC,OAAO;MAAS,CAAA;IAC9D;EACF,GANoB;AAQpB,QAAMC,QAAQC,SAAAA;AAEd,SACE,sBAAA,cAACC,MAAAA;IAAKC,IAAIjB;IAAU,GAAGD;KACrB,sBAAA,cAACmB,KAAAA;IAAIC,QAAQ;IAAIC,UAAS;IAAQC,OAAOP,MAAMQ,QAAQ,CAAA;IAAIC,QAAQT,MAAMQ,QAAQ,CAAA;IAAIE,SAASpB;IAAaqB,MAAK;KAC7G5B,QAAAA,CAAAA;AAIT,GAvBmE;","names":["useEffect","useLocation","ScrollToTop","pathname","useLocation","useEffect","window","scrollTo","Box","useScrollTrigger","useTheme","Zoom","React","ScrollToTopButton","children","anchorId","props","trigger","useScrollTrigger","disableHysteresis","threshold","handleClick","event","anchor","target","ownerDocument","document","querySelector","scrollIntoView","behavior","block","theme","useTheme","Zoom","in","Box","zIndex","position","right","spacing","bottom","onClick","role"]}
|
package/package.json
CHANGED
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
],
|
|
15
15
|
"description": "Common React library for all XY Labs projects that use React",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"react-router-dom": "^6.
|
|
17
|
+
"react-router-dom": "^6.26.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/react": "^18.3.3",
|
|
21
|
-
"@xylabs/ts-scripts-yarn3": "^3.
|
|
22
|
-
"@xylabs/tsconfig-react": "^3.
|
|
21
|
+
"@xylabs/ts-scripts-yarn3": "^3.15.16",
|
|
22
|
+
"@xylabs/tsconfig-react": "^3.15.16",
|
|
23
23
|
"react": "^18.3.1",
|
|
24
24
|
"react-dom": "^18.3.1",
|
|
25
|
-
"typescript": "^5.5.
|
|
25
|
+
"typescript": "^5.5.4"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@mui/material": "^5",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": {
|
|
35
35
|
"import": {
|
|
36
36
|
"types": "./dist/node/index.d.mts",
|
|
37
|
-
"default": "./dist/node/index.
|
|
37
|
+
"default": "./dist/node/index.mjs"
|
|
38
38
|
},
|
|
39
39
|
"require": {
|
|
40
40
|
"types": "./dist/node/index.d.cts",
|
|
@@ -44,20 +44,20 @@
|
|
|
44
44
|
"browser": {
|
|
45
45
|
"import": {
|
|
46
46
|
"types": "./dist/browser/index.d.mts",
|
|
47
|
-
"default": "./dist/browser/index.
|
|
47
|
+
"default": "./dist/browser/index.mjs"
|
|
48
48
|
},
|
|
49
49
|
"require": {
|
|
50
50
|
"types": "./dist/browser/index.d.cts",
|
|
51
51
|
"default": "./dist/browser/index.cjs"
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
-
"default": "./dist/browser/index.
|
|
54
|
+
"default": "./dist/browser/index.mjs"
|
|
55
55
|
},
|
|
56
56
|
"./package.json": "./package.json"
|
|
57
57
|
},
|
|
58
58
|
"types": "dist/browser/index.d.ts",
|
|
59
59
|
"main": "./dist/browser/index.cjs",
|
|
60
|
-
"module": "./dist/browser/index.
|
|
60
|
+
"module": "./dist/browser/index.mjs",
|
|
61
61
|
"homepage": "https://xylabs.com",
|
|
62
62
|
"keywords": [
|
|
63
63
|
"utility",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"url": "https://github.com/xylabs/sdk-react.git"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"version": "3.4.
|
|
76
|
+
"version": "3.4.2",
|
|
77
77
|
"type": "module"
|
|
78
78
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ScrollToTop.
|
|
2
|
-
export * from './ScrollToTopButton.
|
|
1
|
+
export * from './ScrollToTop.tsx'
|
|
2
|
+
export * from './ScrollToTopButton.tsx'
|
package/dist/browser/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// src/ScrollToTop.tsx
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLocation } from "react-router-dom";
|
|
4
|
-
var ScrollToTop = () => {
|
|
5
|
-
const { pathname } = useLocation();
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
window.scrollTo(0, 0);
|
|
8
|
-
}, [pathname]);
|
|
9
|
-
return null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/ScrollToTopButton.tsx
|
|
13
|
-
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
16
|
-
const trigger = useScrollTrigger({
|
|
17
|
-
disableHysteresis: true,
|
|
18
|
-
threshold: 100
|
|
19
|
-
});
|
|
20
|
-
const handleClick = (event) => {
|
|
21
|
-
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
22
|
-
if (anchor) {
|
|
23
|
-
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const theme = useTheme();
|
|
27
|
-
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 }) });
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
ScrollToTop,
|
|
31
|
-
ScrollToTopButton
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/dist/neutral/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// src/ScrollToTop.tsx
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLocation } from "react-router-dom";
|
|
4
|
-
var ScrollToTop = () => {
|
|
5
|
-
const { pathname } = useLocation();
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
window.scrollTo(0, 0);
|
|
8
|
-
}, [pathname]);
|
|
9
|
-
return null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/ScrollToTopButton.tsx
|
|
13
|
-
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
16
|
-
const trigger = useScrollTrigger({
|
|
17
|
-
disableHysteresis: true,
|
|
18
|
-
threshold: 100
|
|
19
|
-
});
|
|
20
|
-
const handleClick = (event) => {
|
|
21
|
-
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
22
|
-
if (anchor) {
|
|
23
|
-
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const theme = useTheme();
|
|
27
|
-
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 }) });
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
ScrollToTop,
|
|
31
|
-
ScrollToTopButton
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// src/ScrollToTop.tsx
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useLocation } from "react-router-dom";
|
|
4
|
-
var ScrollToTop = () => {
|
|
5
|
-
const { pathname } = useLocation();
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
window.scrollTo(0, 0);
|
|
8
|
-
}, [pathname]);
|
|
9
|
-
return null;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/ScrollToTopButton.tsx
|
|
13
|
-
import { Box, useScrollTrigger, useTheme, Zoom } from "@mui/material";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var ScrollToTopButton = ({ children, anchorId, ...props }) => {
|
|
16
|
-
const trigger = useScrollTrigger({
|
|
17
|
-
disableHysteresis: true,
|
|
18
|
-
threshold: 100
|
|
19
|
-
});
|
|
20
|
-
const handleClick = (event) => {
|
|
21
|
-
const anchor = (event.target.ownerDocument || document).querySelector(`#${anchorId}`);
|
|
22
|
-
if (anchor) {
|
|
23
|
-
anchor.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const theme = useTheme();
|
|
27
|
-
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 }) });
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
ScrollToTop,
|
|
31
|
-
ScrollToTopButton
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|