react-router-scroll-to-top 1.1.2 → 1.2.1

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/README.md CHANGED
@@ -8,7 +8,6 @@
8
8
  [![GitHub Stars](https://img.shields.io/github/stars/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/stargazers)
9
9
  ![CircleCI status](https://img.shields.io/circleci/build/github/dimazuien/react-router-scroll-to-top/main?label=circleci)
10
10
  ![Code scanning](https://img.shields.io/github/workflow/status/dimazuien/react-router-scroll-to-top/CodeQL?label=code%20scanning)
11
- [![Storybook](https://img.shields.io/badge/demos-%F0%9F%9A%80-yellow.svg?label=storybook)](https://dimazuien.github.io/react-router-scroll-to-top)
12
11
 
13
12
  ScrollToTop is a React component that scrolls to the top of a page when the current location gets changed. Since React Router doesn't provide out-of-the-box support for scroll restoration due to [browsers having started handling it on their own](https://majido.github.io/scroll-restoration-proposal/history-based-api.html), this package implements a component for scrolling to the top manually as it is given in [React Router docs](https://reactrouter.com/web/guides/scroll-restoration#scroll-restoration-scroll-to-top).
14
13
 
@@ -24,7 +23,7 @@ import { ScrollToTop } from 'react-router-scroll-to-top';
24
23
  const App = () => (
25
24
  <BrowserRouter>
26
25
  <ScrollToTop />
27
- <Switch>{/* routes */}</Switch>
26
+ <Routes>{/* routes */}</Routes>
28
27
  </BrowserRouter>
29
28
  );
30
29
  ```
@@ -33,4 +32,4 @@ Read [the documentation](https://github.com/dimazuien/react-router-scroll-to-top
33
32
 
34
33
  ## Support
35
34
 
36
- If you like this package and want to support it, you can fund us on [Patreon](https://www.patreon.com/dimazuien)
35
+ If you like this package and want to support it, you can do it on [Patreon](https://www.patreon.com/dimazuien)
package/index.d.ts CHANGED
@@ -1,2 +1,23 @@
1
- export { default as ScrollToTop } from './ScrollToTop';
2
- export { default as useScrollToTop } from './useScrollToTop';
1
+ declare module 'react-router-scroll-to-top/src/ScrollToTop/index' {
2
+ import { ReactNode } from 'react';
3
+ type Props = Readonly<{
4
+ children?: ReactNode;
5
+ }>;
6
+ function ScrollToTop({ children }: Props): JSX.Element;
7
+ export default ScrollToTop;
8
+
9
+ }
10
+ declare module 'react-router-scroll-to-top/src/index' {
11
+ export { default as ScrollToTop } from 'react-router-scroll-to-top/src/ScrollToTop/index';
12
+ export { default as useScrollToTop } from 'react-router-scroll-to-top/src/useScrollToTop/index';
13
+
14
+ }
15
+ declare module 'react-router-scroll-to-top/src/useScrollToTop/index' {
16
+ const useScrollToTop: () => void;
17
+ export default useScrollToTop;
18
+
19
+ }
20
+ declare module 'react-router-scroll-to-top' {
21
+ import main = require('react-router-scroll-to-top/src/index');
22
+ export = main;
23
+ }
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["react-router-scroll-to-top"]=r():e["react-router-scroll-to-top"]=r()}(globalThis,(function(){return function(){"use strict";var e={44:function(e,r,o){var t=o(497),n=Symbol.for("react.element"),u=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,f=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};r.Fragment=u,r.jsx=function(e,r,o){var t,u={},l=null,a=null;for(t in void 0!==o&&(l=""+o),void 0!==r.key&&(l=""+r.key),void 0!==r.ref&&(a=r.ref),r)c.call(r,t)&&!i.hasOwnProperty(t)&&(u[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===u[t]&&(u[t]=r[t]);return{$$typeof:n,type:e,key:l,ref:a,props:u,_owner:f.current}}},598:function(e,r,o){e.exports=o(44)},497:function(e){e.exports=require("react")}},r={};function o(t){var n=r[t];if(void 0!==n)return n.exports;var u=r[t]={exports:{}};return e[t](u,u.exports,o),u.exports}o.d=function(e,r){for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return function(){o.r(t),o.d(t,{ScrollToTop:function(){return c},useScrollToTop:function(){return n}});var e=o(497),r=require("react-router-dom"),n=function(){var o=(0,r.useLocation)(),t=o.pathname,n=o.state;(0,e.useEffect)((function(){!1!==(null==n?void 0:n.scrollToTop)&&window.scrollTo(0,0)}),[t,n])},u=o(598),c=function(r){var o=r.children;return n(),(0,u.jsx)(u.Fragment,{children:e.Children.toArray(o)})}}(),t}()}));
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "react-router-scroll-to-top",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "React component that scrolls to the top of a page when the current location gets changed",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/dimazuien/react-router-scroll-to-top.git"
8
8
  },
9
- "homepage": "https://dimazuien.github.io/react-router-scroll-to-top",
9
+ "homepage": "https://github.com/dimazuien/react-router-scroll-to-top#readme",
10
10
  "keywords": [
11
11
  "react",
12
12
  "react router",
@@ -24,83 +24,83 @@
24
24
  "url": "https://github.com/dimazuien/react-router-scroll-to-top/issues"
25
25
  },
26
26
  "source": "src/index.ts",
27
- "main": "dist/index.js",
28
- "browser": "dist/index.js",
29
- "module": "dist/index.module.js",
30
- "unpkg": "dist/index.umd.js",
31
- "types": "index.d.ts",
27
+ "main": "lib/index.js",
32
28
  "typings": "index.d.ts",
33
29
  "files": [
34
- "dist",
35
- "index.d.ts",
36
- "ScrollToTop.d.ts",
37
- "useScrollToTop.d.ts"
30
+ "lib",
31
+ "index.d.ts"
38
32
  ],
39
33
  "sideEffects": false,
40
34
  "scripts": {
41
- "lint": "eslint './src/**/*.{js,jsx,ts,tsx}'",
35
+ "_postinstall": "husky install",
36
+ "build": "webpack",
37
+ "dts": "npx npm-dts generate -e src/index",
38
+ "lint": "eslint .",
42
39
  "test": "jest",
43
- "build": "microbundle --jsx React.createElement",
40
+ "prepublishOnly": "pinst --disable",
44
41
  "release": "semantic-release",
45
- "storybook": "start-storybook -p 6006",
46
- "storybook:build": "build-storybook",
47
- "storybook:upload": "gh-pages -d storybook-static --git \"$(which git)\""
42
+ "postpublish": "pinst --enable"
48
43
  },
49
- "dependencies": {},
50
44
  "devDependencies": {
51
- "@babel/core": "7.12.17",
52
- "@commitlint/cli": "11.0.0",
53
- "@commitlint/config-conventional": "11.0.0",
54
- "@semantic-release/changelog": "5.0.1",
55
- "@semantic-release/commit-analyzer": "8.0.1",
56
- "@semantic-release/git": "9.0.0",
57
- "@semantic-release/github": "7.2.0",
58
- "@semantic-release/npm": "7.0.9",
59
- "@semantic-release/release-notes-generator": "9.0.1",
60
- "@storybook/addon-docs": "6.1.11",
61
- "@storybook/react": "6.1.11",
62
- "@testing-library/jest-dom": "5.11.9",
63
- "@testing-library/react": "11.2.5",
64
- "@testing-library/user-event": "12.7.1",
65
- "@types/jest": "26.0.20",
66
- "@types/react": "17.0.2",
67
- "@types/react-dom": "17.0.0",
68
- "@types/react-router-dom": "5.1.7",
69
- "@types/testing-library__jest-dom": "5.9.5",
70
- "@typescript-eslint/eslint-plugin": "4.11.0",
71
- "@typescript-eslint/parser": "4.11.0",
72
- "babel-loader": "8.2.2",
73
- "commitizen": "4.2.3",
45
+ "@babel/core": "7.22.9",
46
+ "@babel/preset-env": "7.22.9",
47
+ "@babel/preset-react": "7.22.5",
48
+ "@babel/preset-typescript": "7.22.5",
49
+ "@commitlint/cli": "17.6.7",
50
+ "@commitlint/config-conventional": "17.6.7",
51
+ "@semantic-release/changelog": "6.0.3",
52
+ "@semantic-release/commit-analyzer": "10.0.1",
53
+ "@semantic-release/git": "10.0.1",
54
+ "@semantic-release/github": "9.0.4",
55
+ "@semantic-release/npm": "10.0.4",
56
+ "@semantic-release/release-notes-generator": "11.0.4",
57
+ "@testing-library/dom": "9.3.1",
58
+ "@testing-library/jest-dom": "5.17.0",
59
+ "@testing-library/react": "14.0.0",
60
+ "@testing-library/user-event": "14.4.3",
61
+ "@types/jest": "29.5.3",
62
+ "@types/react": "18.2.17",
63
+ "@types/react-dom": "18.2.7",
64
+ "@types/react-router-dom": "5.3.3",
65
+ "@types/testing-library__jest-dom": "5.14.9",
66
+ "@typescript-eslint/eslint-plugin": "6.2.0",
67
+ "@typescript-eslint/parser": "6.2.0",
68
+ "babel-loader": "9.1.3",
69
+ "commitizen": "4.3.0",
74
70
  "cz-conventional-changelog": "3.3.0",
75
- "eslint": "7.19.0",
76
- "eslint-config-airbnb": "18.2.1",
77
- "eslint-config-prettier": "7.2.0",
78
- "eslint-plugin-import": "2.22.1",
79
- "eslint-plugin-jest-dom": "3.6.5",
80
- "eslint-plugin-jsx-a11y": "6.4.1",
81
- "eslint-plugin-prettier": "3.3.1",
82
- "eslint-plugin-react": "7.22.0",
83
- "eslint-plugin-react-hooks": "4.2.0",
84
- "eslint-plugin-testing-library": "3.10.1",
85
- "gh-pages": "3.1.0",
86
- "github-markdown-css": "4.0.0",
87
- "husky": "4.3.8",
88
- "jest": "26.6.3",
89
- "lint-staged": "10.5.4",
90
- "lorem-ipsum": "2.0.3",
91
- "microbundle": "0.13.0",
92
- "prettier": "2.2.1",
93
- "react": "17.0.1",
94
- "react-dom": "17.0.1",
95
- "react-router-dom": "5.2.0",
96
- "semantic-release": "17.3.1",
97
- "ts-jest": "26.5.0",
98
- "ts-node": "9.1.1",
99
- "typescript": "4.1.3"
71
+ "eslint": "8.46.0",
72
+ "eslint-config-airbnb": "19.0.4",
73
+ "eslint-config-prettier": "8.9.0",
74
+ "eslint-plugin-import": "2.28.0",
75
+ "eslint-plugin-jest-dom": "5.0.1",
76
+ "eslint-plugin-jsx-a11y": "6.7.1",
77
+ "eslint-plugin-prettier": "5.0.0",
78
+ "eslint-plugin-react": "7.33.1",
79
+ "eslint-plugin-react-hooks": "4.6.0",
80
+ "eslint-plugin-simple-import-sort": "10.0.0",
81
+ "eslint-plugin-testing-library": "5.11.0",
82
+ "github-markdown-css": "5.2.0",
83
+ "husky": "8.0.3",
84
+ "jest": "29.6.2",
85
+ "jest-environment-jsdom": "29.6.2",
86
+ "lint-staged": "13.2.3",
87
+ "lorem-ipsum": "2.0.8",
88
+ "npm-dts": "1.3.12",
89
+ "pinst": "3.0.0",
90
+ "prettier": "3.0.0",
91
+ "react": "18.2.0",
92
+ "react-dom": "18.2.0",
93
+ "react-router-dom": "6.14.2",
94
+ "semantic-release": "21.0.7",
95
+ "ts-jest": "29.1.1",
96
+ "ts-node": "10.9.1",
97
+ "typescript": "5.1.6",
98
+ "webpack": "5.88.2",
99
+ "webpack-cli": "5.1.4"
100
100
  },
101
101
  "peerDependencies": {
102
- "react": "^16.8 || ^17",
103
- "react-dom": "^16.8 || ^17",
104
- "react-router-dom": "^5.1"
102
+ "react": "^16.8 || ^17 || ^18",
103
+ "react-dom": "^16.8 || ^17 || ^18",
104
+ "react-router-dom": "^5.1 || ^6"
105
105
  }
106
106
  }
package/CHANGELOG.md DELETED
@@ -1,19 +0,0 @@
1
- ## [1.1.2](https://github.com/dimazuien/react-router-scroll-to-top/compare/v1.1.1...v1.1.2) (2021-02-22)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * change typings path ([e39b991](https://github.com/dimazuien/react-router-scroll-to-top/commit/e39b99118ba22f3c2f77789f1f57efd742b98dce))
7
-
8
- ## [1.1.1](https://github.com/dimazuien/react-router-scroll-to-top/compare/v1.1.0...v1.1.1) (2020-12-28)
9
-
10
- ### Bug Fixes
11
-
12
- * make ScrollToTop named export (before was default) ([ddfa28a](https://github.com/dimazuien/react-router-scroll-to-top/commit/ddfa28ad099606743c155ce833069dd231ab3c29))
13
-
14
- # [1.1.0](https://github.com/dimazuien/react-router-scroll-to-top/compare/v1.0.0...v1.1.0) (2020-12-27)
15
-
16
- ### Features
17
-
18
- * add a hook ([587ce84](https://github.com/dimazuien/react-router-scroll-to-top/commit/587ce8469b62491097541687d38810870abc6ae5))
19
- * add state param that prevents scrolling to top ([a77830c](https://github.com/dimazuien/react-router-scroll-to-top/commit/a77830cef6ca582dad34f9130cb4068cb88c9f83))
package/ScrollToTop.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { FC } from 'react';
2
- declare const ScrollToTop: FC;
3
- export default ScrollToTop;
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- var e=require("react"),o=require("react-router-dom");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=r(e),n=function(){var r=o.useLocation(),t=r.state;e.useEffect(function(){!1!==(null==t?void 0:t.scrollToTop)&&window.scrollTo(0,0)},[r.pathname,t])};exports.ScrollToTop=function(e){var o=e.children;return n(),t.default.createElement(t.default.Fragment,null,o)},exports.useScrollToTop=n;
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/useScrollToTop.tsx","../src/ScrollToTop.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ntype ScrollToTopState =\n | Readonly<{\n scrollToTop?: boolean;\n }>\n | undefined;\n\nconst useScrollToTop = (): void => {\n const { pathname, state } = useLocation<ScrollToTopState>();\n\n useEffect(() => {\n if (state?.scrollToTop === false) return;\n\n window.scrollTo(0, 0);\n }, [pathname, state]);\n};\n\nexport default useScrollToTop;\n","import React, { FC } from 'react';\nimport useScrollToTop from './useScrollToTop';\n\nconst ScrollToTop: FC = ({ children }) => {\n useScrollToTop();\n\n return <>{children}</>;\n};\n\nexport default ScrollToTop;\n"],"names":["useScrollToTop","useLocation","state","useEffect","scrollToTop","window","scrollTo","pathname","children","React"],"mappings":"wIASMA,EAAiB,iBACOC,gBAAVC,IAAAA,MAElBC,YAAU,YACmB,WAAvBD,SAAAA,EAAOE,cAEXC,OAAOC,SAAS,EAAG,IAClB,GANKC,SAMML,yBCbQ,gBAAGM,IAAAA,SAGzB,OAFAR,IAEOS,gDAAGD"}
@@ -1,2 +0,0 @@
1
- import o,{useEffect as r}from"react";import{useLocation as t}from"react-router-dom";const e=()=>{const{pathname:o,state:e}=t();r(()=>{!1!==(null==e?void 0:e.scrollToTop)&&window.scrollTo(0,0)},[o,e])},l=({children:r})=>(e(),o.createElement(o.Fragment,null,r));export{l as ScrollToTop,e as useScrollToTop};
2
- //# sourceMappingURL=index.modern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/useScrollToTop.tsx","../src/ScrollToTop.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ntype ScrollToTopState =\n | Readonly<{\n scrollToTop?: boolean;\n }>\n | undefined;\n\nconst useScrollToTop = (): void => {\n const { pathname, state } = useLocation<ScrollToTopState>();\n\n useEffect(() => {\n if (state?.scrollToTop === false) return;\n\n window.scrollTo(0, 0);\n }, [pathname, state]);\n};\n\nexport default useScrollToTop;\n","import React, { FC } from 'react';\nimport useScrollToTop from './useScrollToTop';\n\nconst ScrollToTop: FC = ({ children }) => {\n useScrollToTop();\n\n return <>{children}</>;\n};\n\nexport default ScrollToTop;\n"],"names":["useScrollToTop","pathname","state","useLocation","useEffect","scrollToTop","window","scrollTo","ScrollToTop","children","React"],"mappings":"oFASMA,MAAAA,EAAiB,KACrB,MAAMC,SAAEA,EAAFC,MAAYA,GAAUC,IAE5BC,EAAU,MACmB,WAAvBF,SAAAA,EAAOG,cAEXC,OAAOC,SAAS,EAAG,IAClB,CAACN,EAAUC,KCbVM,EAAkB,EAAGC,SAAAA,MACzBT,IAEOU,gCAAGD"}
@@ -1,2 +0,0 @@
1
- import r,{useEffect as o}from"react";import{useLocation as t}from"react-router-dom";var n=function(){var r=t(),n=r.state;o(function(){!1!==(null==n?void 0:n.scrollToTop)&&window.scrollTo(0,0)},[r.pathname,n])},e=function(o){var t=o.children;return n(),r.createElement(r.Fragment,null,t)};export{e as ScrollToTop,n as useScrollToTop};
2
- //# sourceMappingURL=index.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.module.js","sources":["../src/useScrollToTop.tsx","../src/ScrollToTop.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ntype ScrollToTopState =\n | Readonly<{\n scrollToTop?: boolean;\n }>\n | undefined;\n\nconst useScrollToTop = (): void => {\n const { pathname, state } = useLocation<ScrollToTopState>();\n\n useEffect(() => {\n if (state?.scrollToTop === false) return;\n\n window.scrollTo(0, 0);\n }, [pathname, state]);\n};\n\nexport default useScrollToTop;\n","import React, { FC } from 'react';\nimport useScrollToTop from './useScrollToTop';\n\nconst ScrollToTop: FC = ({ children }) => {\n useScrollToTop();\n\n return <>{children}</>;\n};\n\nexport default ScrollToTop;\n"],"names":["useScrollToTop","useLocation","state","useEffect","scrollToTop","window","scrollTo","pathname","ScrollToTop","children","React"],"mappings":"oFASMA,IAAAA,EAAiB,iBACOC,IAAVC,IAAAA,MAElBC,EAAU,YACmB,WAAvBD,SAAAA,EAAOE,cAEXC,OAAOC,SAAS,EAAG,IAClB,GANKC,SAMML,KCbVM,EAAkB,gBAAGC,IAAAA,SAGzB,OAFAT,IAEOU,gCAAGD"}
package/dist/index.umd.js DELETED
@@ -1,2 +0,0 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("react"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-router-dom"],o):o((e||self).reactRouterScrollToTop={},e.react,e.reactRouterDom)}(this,function(e,o,t){function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(o),u=function(){var e=t.useLocation(),r=e.state;o.useEffect(function(){!1!==(null==r?void 0:r.scrollToTop)&&window.scrollTo(0,0)},[e.pathname,r])};e.ScrollToTop=function(e){var o=e.children;return u(),n.default.createElement(n.default.Fragment,null,o)},e.useScrollToTop=u});
2
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/useScrollToTop.tsx","../src/ScrollToTop.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ntype ScrollToTopState =\n | Readonly<{\n scrollToTop?: boolean;\n }>\n | undefined;\n\nconst useScrollToTop = (): void => {\n const { pathname, state } = useLocation<ScrollToTopState>();\n\n useEffect(() => {\n if (state?.scrollToTop === false) return;\n\n window.scrollTo(0, 0);\n }, [pathname, state]);\n};\n\nexport default useScrollToTop;\n","import React, { FC } from 'react';\nimport useScrollToTop from './useScrollToTop';\n\nconst ScrollToTop: FC = ({ children }) => {\n useScrollToTop();\n\n return <>{children}</>;\n};\n\nexport default ScrollToTop;\n"],"names":["useScrollToTop","useLocation","state","useEffect","scrollToTop","window","scrollTo","pathname","children","React"],"mappings":"waASMA,EAAiB,iBACOC,gBAAVC,IAAAA,MAElBC,YAAU,YACmB,WAAvBD,SAAAA,EAAOE,cAEXC,OAAOC,SAAS,EAAG,IAClB,GANKC,SAMML,mBCbQ,gBAAGM,IAAAA,SAGzB,OAFAR,IAEOS,gDAAGD"}
@@ -1,2 +0,0 @@
1
- declare const useScrollToTop: () => void;
2
- export default useScrollToTop;