@not-govuk/back-link 0.14.0 → 0.15.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.
@@ -1,2 +1,2 @@
1
1
  @import "@not-govuk/sass-base";
2
- @import "govuk-frontend/dist/govuk/components/back-link";
2
+ @import "govuk-frontend/dist/govuk/components/back-link/index";
package/dist/BackLink.js CHANGED
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
+ 'use client';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.BackLink = void 0;
4
5
  const react_1 = require("react");
5
- const react_router_dom_1 = require("react-router-dom");
6
6
  const component_helpers_1 = require("@not-govuk/component-helpers");
7
7
  const link_1 = require("@not-govuk/link");
8
+ const router_1 = require("@not-govuk/router");
8
9
  require("../assets/BackLink.scss");
9
10
  const BackLink = ({ children, classBlock, classModifiers, className, href, text: _text, ...attrs }) => {
10
11
  const defaultClassBlock = 'govuk-back-link';
11
12
  const classes = (0, component_helpers_1.classBuilder)(defaultClassBlock, classBlock, classModifiers, className);
12
- const navigate = (0, react_router_dom_1.useNavigate)();
13
+ const navigate = (0, router_1.useNavigate)();
13
14
  const text = _text || children || 'Back';
14
- const goBack = () => navigate(-1);
15
+ const goBack = () => navigate && navigate(-1);
15
16
  return href ? ((0, react_1.createElement)(link_1.A, { ...attrs, classBlock: classBlock || defaultClassBlock, classModifiers: classModifiers, className: className, href: href }, text)) : ((0, react_1.createElement)("a", { ...attrs, className: classes(), href: "#", onClick: goBack }, text));
16
17
  };
17
18
  exports.BackLink = BackLink;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@not-govuk/back-link",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "A component to help users navigate back one page.",
5
5
  "main": "dist/BackLink.js",
6
6
  "sass": "assets/BackLink.scss",
@@ -14,15 +14,16 @@
14
14
  "react-components"
15
15
  ],
16
16
  "dependencies": {
17
- "@not-govuk/component-helpers": "^0.14.0",
18
- "@not-govuk/link": "^0.14.0",
19
- "@not-govuk/sass-base": "^0.14.0",
20
- "govuk-frontend": "5.6.0"
17
+ "@not-govuk/component-helpers": "^0.15.1",
18
+ "@not-govuk/link": "^0.15.1",
19
+ "@not-govuk/router": "^0.15.1",
20
+ "@not-govuk/sass-base": "^0.15.1",
21
+ "govuk-frontend": "5.7.1"
21
22
  },
22
23
  "peerDependencies": {
23
- "@not-govuk/docs-components": "^0.14.0",
24
+ "@not-govuk/docs-components": "^0.15.1",
24
25
  "@storybook/addon-docs": "^6.5.16",
25
- "react": "^16.14.0 || ^17.0.0 || ^18.0.0"
26
+ "react": "^18.3.1"
26
27
  },
27
28
  "peerDependenciesMeta": {
28
29
  "@not-govuk/docs-components": {
@@ -34,9 +35,9 @@
34
35
  },
35
36
  "devDependencies": {
36
37
  "@mdx-js/react": "1.6.22",
37
- "@not-govuk/component-test-helpers": "^0.14.0",
38
- "@not-govuk/panel": "^0.14.0",
39
- "@types/react": "18.3.8",
38
+ "@not-govuk/component-test-helpers": "^0.15.1",
39
+ "@not-govuk/panel": "^0.15.1",
40
+ "@types/react": "18.3.12",
40
41
  "jest": "29.7.0",
41
42
  "jest-environment-jsdom": "29.7.0",
42
43
  "ts-jest": "29.2.5",
package/src/BackLink.tsx CHANGED
@@ -1,7 +1,9 @@
1
+ 'use client';
2
+
1
3
  import { FC, ReactNode, createElement as h } from 'react';
2
- import { useNavigate } from 'react-router-dom';
3
4
  import { StandardProps, classBuilder } from '@not-govuk/component-helpers';
4
5
  import { A } from '@not-govuk/link';
6
+ import { useNavigate } from '@not-govuk/router';
5
7
 
6
8
  import '../assets/BackLink.scss';
7
9
 
@@ -28,7 +30,7 @@ export const BackLink: FC<BackLinkProps> = ({
28
30
  const classes = classBuilder(defaultClassBlock, classBlock, classModifiers, className);
29
31
  const navigate = useNavigate();
30
32
  const text = _text || children || 'Back';
31
- const goBack = () => navigate(-1);
33
+ const goBack = () => navigate && navigate(-1);
32
34
 
33
35
  return href ? (
34
36
  <A {...attrs}