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

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
@@ -6,10 +6,12 @@
6
6
  [![Open issues](https://img.shields.io/github/issues-raw/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/issues)
7
7
  [![Open pull requests](https://img.shields.io/github/issues-pr-raw/dimazuien/react-router-scroll-to-top)](https://github.com/dimazuien/react-router-scroll-to-top/pulls)
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
- ![CircleCI status](https://img.shields.io/circleci/build/github/dimazuien/react-router-scroll-to-top/main?label=circleci)
10
- ![Code scanning](https://img.shields.io/github/workflow/status/dimazuien/react-router-scroll-to-top/CodeQL?label=code%20scanning)
9
+ ![CI status](https://img.shields.io/github/actions/workflow/status/dimazuien/react-router-scroll-to-top/ci.yml?branch=main&label=ci)
10
+ ![Code scanning](https://img.shields.io/github/actions/workflow/status/dimazuien/react-router-scroll-to-top/codeql-analysis.yml?branch=main)
11
11
 
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).
12
+ ScrollToTop is a React component that scrolls to the top of the page when the location changes. It's for apps that use React Router 5.1 to 7 in declarative mode, with `<BrowserRouter>`, where React Router has no built-in scroll handling.
13
+
14
+ If your app uses a data router (`createBrowserRouter` with `<RouterProvider>`) or framework mode, use React Router's [`<ScrollRestoration>`](https://reactrouter.com/7.18.7/api/components/ScrollRestoration) instead. It also restores the scroll position when users go back or forward.
13
15
 
14
16
  ## Usage
15
17
 
@@ -29,7 +31,3 @@ const App = () => (
29
31
  ```
30
32
 
31
33
  Read [the documentation](https://github.com/dimazuien/react-router-scroll-to-top/blob/main/docs/index.md) for more details. You can also play with a [demo](https://codesandbox.io/s/react-router-scroll-to-top-n1mg3).
32
-
33
- ## Support
34
-
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,9 +1,9 @@
1
1
  declare module 'react-router-scroll-to-top/src/ScrollToTop/index' {
2
- import { ReactNode } from 'react';
2
+ import { ReactElement, ReactNode } from 'react';
3
3
  type Props = Readonly<{
4
4
  children?: ReactNode;
5
5
  }>;
6
- function ScrollToTop({ children }: Props): JSX.Element;
6
+ function ScrollToTop({ children }: Props): ReactElement;
7
7
  export default ScrollToTop;
8
8
 
9
9
  }
package/lib/index.js CHANGED
@@ -1,2 +1 @@
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}()}));
1
+ !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["react-router-scroll-to-top"]=o():e["react-router-scroll-to-top"]=o()}(globalThis,function(){return function(){"use strict";var e={d:function(o,t){for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{ScrollToTop:function(){return u},useScrollToTop:function(){return n}});var t=require("react"),r=require("react-router-dom"),n=function(){var e=(0,r.useLocation)(),o=e.pathname,n=e.state;(0,t.useEffect)(function(){!1!==(null==n?void 0:n.scrollToTop)&&window.scrollTo(0,0)},[o,n])},u=function(e){var o=e.children;return n(),(0,t.createElement)(t.Fragment,null,t.Children.toArray(o))};return o}()});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-scroll-to-top",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
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",
@@ -15,10 +15,6 @@
15
15
  "scroll to top"
16
16
  ],
17
17
  "author": "Dima Zuien",
18
- "funding": {
19
- "type": "patreon",
20
- "url": "https://www.patreon.com/dimazuien"
21
- },
22
18
  "license": "MIT",
23
19
  "bugs": {
24
20
  "url": "https://github.com/dimazuien/react-router-scroll-to-top/issues"
@@ -31,76 +27,77 @@
31
27
  "index.d.ts"
32
28
  ],
33
29
  "sideEffects": false,
30
+ "packageManager": "pnpm@12.20.0",
34
31
  "scripts": {
35
- "_postinstall": "husky install",
32
+ "prepare": "husky",
36
33
  "build": "webpack",
37
- "dts": "npx npm-dts generate -e src/index",
34
+ "dts": "npm-dts generate -e src/index --tsc=\"-p tsconfig.build.json\"",
38
35
  "lint": "eslint .",
39
36
  "test": "jest",
40
- "prepublishOnly": "pinst --disable",
41
- "release": "semantic-release",
42
- "postpublish": "pinst --enable"
37
+ "release": "semantic-release"
43
38
  },
44
39
  "devDependencies": {
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",
40
+ "@babel/core": "7.29.13",
41
+ "@babel/preset-env": "7.29.14",
42
+ "@babel/preset-react": "7.29.7",
43
+ "@babel/preset-typescript": "7.29.7",
44
+ "@commitlint/cli": "21.2.2",
45
+ "@commitlint/config-conventional": "21.2.2",
51
46
  "@semantic-release/changelog": "6.0.3",
52
- "@semantic-release/commit-analyzer": "10.0.1",
47
+ "@semantic-release/commit-analyzer": "13.0.1",
53
48
  "@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",
49
+ "@semantic-release/github": "12.0.9",
50
+ "@semantic-release/npm": "13.1.5",
51
+ "@semantic-release/release-notes-generator": "14.1.1",
52
+ "@testing-library/dom": "10.4.2",
53
+ "@testing-library/jest-dom": "6.9.1",
54
+ "@testing-library/react": "16.3.3",
55
+ "@testing-library/user-event": "14.6.7",
56
+ "@types/jest": "29.5.14",
57
+ "@types/node": "26.6.6",
58
+ "@types/react": "19.3.0",
59
+ "@types/react-dom": "19.3.0",
64
60
  "@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",
61
+ "@typescript-eslint/eslint-plugin": "7.18.0",
62
+ "@typescript-eslint/parser": "7.18.0",
63
+ "babel-loader": "10.1.1",
64
+ "commitizen": "4.3.2",
65
+ "conventional-changelog-conventionalcommits": "9.3.1",
70
66
  "cz-conventional-changelog": "3.3.0",
71
- "eslint": "8.46.0",
67
+ "eslint": "8.57.1",
72
68
  "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"
69
+ "eslint-config-prettier": "10.1.8",
70
+ "eslint-plugin-import": "2.32.0",
71
+ "eslint-plugin-jest": "27.9.0",
72
+ "eslint-plugin-jest-dom": "5.10.1",
73
+ "eslint-plugin-jsx-a11y": "6.10.2",
74
+ "eslint-plugin-prettier": "5.5.6",
75
+ "eslint-plugin-react": "7.37.5",
76
+ "eslint-plugin-react-hooks": "4.6.2",
77
+ "eslint-plugin-simple-import-sort": "14.0.0",
78
+ "eslint-plugin-testing-library": "7.16.2",
79
+ "github-markdown-css": "5.9.0",
80
+ "husky": "9.1.7",
81
+ "jest": "29.7.0",
82
+ "jest-environment-jsdom": "30.5.1",
83
+ "jest-junit": "17.0.0",
84
+ "lint-staged": "17.5.1",
85
+ "lorem-ipsum": "3.0.0",
86
+ "npm-dts": "1.3.13",
87
+ "prettier": "3.8.5",
88
+ "react": "19.3.1",
89
+ "react-dom": "19.3.1",
90
+ "react-router-dom": "7.18.6",
91
+ "semantic-release": "25.0.9",
92
+ "ts-jest": "29.4.12",
93
+ "ts-node": "10.9.2",
94
+ "typescript": "5.9.3",
95
+ "webpack": "5.110.3",
96
+ "webpack-cli": "7.2.3"
100
97
  },
101
98
  "peerDependencies": {
102
- "react": "^16.8 || ^17 || ^18",
103
- "react-dom": "^16.8 || ^17 || ^18",
104
- "react-router-dom": "^5.1 || ^6"
99
+ "react": "^16.8 || ^17 || ^18 || ^19",
100
+ "react-dom": "^16.8 || ^17 || ^18 || ^19",
101
+ "react-router-dom": "^5.1 || ^6 || ^7"
105
102
  }
106
103
  }
@@ -1,9 +0,0 @@
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
- */