@xylabs/react-scroll-to-top 4.0.3 → 4.0.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/browser/ScrollToTop.d.ts +2 -0
- package/dist/browser/ScrollToTop.d.ts.map +1 -0
- package/dist/browser/ScrollToTopButton.d.ts +7 -0
- package/dist/browser/ScrollToTopButton.d.ts.map +1 -0
- package/dist/browser/index.d.ts +3 -11
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +32 -32
- package/src/ScrollToTopButton.tsx +6 -2
- package/xy.config.ts +1 -3
|
@@ -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,7 @@
|
|
|
1
|
+
import type { 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,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C,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,CAyB9D,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const ScrollToTop: () => null;
|
|
5
|
-
|
|
6
|
-
interface ScrollToTopButtonProps extends ZoomProps {
|
|
7
|
-
anchorId: string;
|
|
8
|
-
}
|
|
9
|
-
declare const ScrollToTopButton: React.FC<ScrollToTopButtonProps>;
|
|
10
|
-
|
|
11
|
-
export { ScrollToTop, ScrollToTopButton, type ScrollToTopButtonProps };
|
|
1
|
+
export * from './ScrollToTop.tsx';
|
|
2
|
+
export * from './ScrollToTopButton.tsx';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA"}
|
|
@@ -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 {
|
|
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,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;;;ACJ3B,SACEK,KAAKC,kBAAkBC,UAAUC,YAC5B;AACP,OAAOC,WAAW;AAMX,IAAMC,oBAAsD,wBAAC,EAClEC,UAAUC,UAAU,GAAGC,MAAAA,MACxB;AACC,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,GAzBmE;","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
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/react-scroll-to-top",
|
|
3
|
+
"version": "4.0.4",
|
|
4
|
+
"description": "Common React library for all XY Labs projects that use React",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"utility",
|
|
7
|
+
"typescript",
|
|
8
|
+
"react"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://xylabs.com",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "git+https://github.com/xylabs/sdk-react/issues",
|
|
13
|
+
"email": "support@xylabs.com"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/xylabs/sdk-react.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "LGPL-3.0-only",
|
|
3
20
|
"author": {
|
|
4
|
-
"email": "support@xylabs.com",
|
|
5
21
|
"name": "XY Labs Development Team",
|
|
22
|
+
"email": "support@xylabs.com",
|
|
6
23
|
"url": "https://xylabs.com"
|
|
7
24
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/browser/index.d.ts",
|
|
30
|
+
"default": "./dist/browser/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
11
33
|
},
|
|
34
|
+
"module": "./dist/browser/index.mjs",
|
|
35
|
+
"types": "dist/browser/index.d.ts",
|
|
12
36
|
"workspaces": [
|
|
13
37
|
"packages/*"
|
|
14
38
|
],
|
|
15
|
-
"description": "Common React library for all XY Labs projects that use React",
|
|
16
39
|
"dependencies": {
|
|
17
40
|
"react-router-dom": "^6.26.1"
|
|
18
41
|
},
|
|
19
42
|
"devDependencies": {
|
|
20
|
-
"@types/react": "^18.3.
|
|
21
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.
|
|
22
|
-
"@xylabs/tsconfig-react": "^4.0.
|
|
43
|
+
"@types/react": "^18.3.4",
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.7",
|
|
45
|
+
"@xylabs/tsconfig-react": "^4.0.7",
|
|
23
46
|
"react": "^18.3.1",
|
|
24
47
|
"react-dom": "^18.3.1",
|
|
25
48
|
"typescript": "^5.5.4"
|
|
@@ -29,30 +52,7 @@
|
|
|
29
52
|
"react": "^18",
|
|
30
53
|
"react-dom": "^18"
|
|
31
54
|
},
|
|
32
|
-
"exports": {
|
|
33
|
-
".": {
|
|
34
|
-
"types": "./dist/browser/index.d.ts",
|
|
35
|
-
"default": "./dist/browser/index.mjs"
|
|
36
|
-
},
|
|
37
|
-
"./package.json": "./package.json"
|
|
38
|
-
},
|
|
39
|
-
"types": "dist/browser/index.d.ts",
|
|
40
|
-
"module": "./dist/browser/index.mjs",
|
|
41
|
-
"homepage": "https://xylabs.com",
|
|
42
|
-
"keywords": [
|
|
43
|
-
"utility",
|
|
44
|
-
"typescript",
|
|
45
|
-
"react"
|
|
46
|
-
],
|
|
47
|
-
"license": "LGPL-3.0-only",
|
|
48
55
|
"publishConfig": {
|
|
49
56
|
"access": "public"
|
|
50
|
-
}
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "git+https://github.com/xylabs/sdk-react.git"
|
|
54
|
-
},
|
|
55
|
-
"sideEffects": false,
|
|
56
|
-
"version": "4.0.3",
|
|
57
|
-
"type": "module"
|
|
57
|
+
}
|
|
58
58
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { ZoomProps } from '@mui/material'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Box, useScrollTrigger, useTheme, Zoom,
|
|
4
|
+
} from '@mui/material'
|
|
3
5
|
import React from 'react'
|
|
4
6
|
|
|
5
7
|
export interface ScrollToTopButtonProps extends ZoomProps {
|
|
6
8
|
anchorId: string
|
|
7
9
|
}
|
|
8
10
|
|
|
9
|
-
export const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({
|
|
11
|
+
export const ScrollToTopButton: React.FC<ScrollToTopButtonProps> = ({
|
|
12
|
+
children, anchorId, ...props
|
|
13
|
+
}) => {
|
|
10
14
|
const trigger = useScrollTrigger({
|
|
11
15
|
disableHysteresis: true,
|
|
12
16
|
threshold: 100,
|