@not-govuk/back-link 0.16.3 → 0.17.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/dist/BackLink.js +4 -4
- package/dist/BackLink.mjs +15 -0
- package/package.json +30 -19
- package/src/BackLink.tsx +0 -55
package/dist/BackLink.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
'use client';
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.BackLink = void 0;
|
|
5
|
-
const
|
|
6
|
-
const component_helpers_1 = require("@
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const component_helpers_1 = require("@react-foundry/component-helpers");
|
|
7
7
|
const link_1 = require("@not-govuk/link");
|
|
8
|
-
const router_1 = require("@
|
|
8
|
+
const router_1 = require("@react-foundry/router");
|
|
9
9
|
require("../assets/BackLink.scss");
|
|
10
10
|
const BackLink = ({ children, classBlock, classModifiers, className, href, text: _text, ...attrs }) => {
|
|
11
11
|
const defaultClassBlock = 'govuk-back-link';
|
|
@@ -13,7 +13,7 @@ const BackLink = ({ children, classBlock, classModifiers, className, href, text:
|
|
|
13
13
|
const navigate = (0, router_1.useNavigate)();
|
|
14
14
|
const text = _text || children || 'Back';
|
|
15
15
|
const goBack = () => navigate && navigate(-1);
|
|
16
|
-
return href ? ((0,
|
|
16
|
+
return href ? ((0, jsx_runtime_1.jsx)(link_1.A, { ...attrs, classBlock: classBlock || defaultClassBlock, classModifiers: classModifiers, className: className, href: href, children: text })) : ((0, jsx_runtime_1.jsx)("a", { ...attrs, className: classes(), href: "#", onClick: goBack, children: text }));
|
|
17
17
|
};
|
|
18
18
|
exports.BackLink = BackLink;
|
|
19
19
|
exports.default = exports.BackLink;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { classBuilder } from '@react-foundry/component-helpers';
|
|
4
|
+
import { A } from '@not-govuk/link';
|
|
5
|
+
import { useNavigate } from '@react-foundry/router';
|
|
6
|
+
import '../assets/BackLink.scss';
|
|
7
|
+
export const BackLink = ({ children, classBlock, classModifiers, className, href, text: _text, ...attrs }) => {
|
|
8
|
+
const defaultClassBlock = 'govuk-back-link';
|
|
9
|
+
const classes = classBuilder(defaultClassBlock, classBlock, classModifiers, className);
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
const text = _text || children || 'Back';
|
|
12
|
+
const goBack = () => navigate && navigate(-1);
|
|
13
|
+
return href ? (_jsx(A, { ...attrs, classBlock: classBlock || defaultClassBlock, classModifiers: classModifiers, className: className, href: href, children: text })) : (_jsx("a", { ...attrs, className: classes(), href: "#", onClick: goBack, children: text }));
|
|
14
|
+
};
|
|
15
|
+
export default BackLink;
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@not-govuk/back-link",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "A component to help users navigate back one page.",
|
|
5
5
|
"main": "dist/BackLink.js",
|
|
6
6
|
"sass": "assets/BackLink.scss",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"sass": "./assets/BackLink.scss",
|
|
10
|
+
"types": "./dist/BackLink.d.ts",
|
|
11
|
+
"import": "./dist/BackLink.mjs",
|
|
12
|
+
"require": "./dist/BackLink.js",
|
|
13
|
+
"default": "./dist/BackLink.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
7
16
|
"files": [
|
|
8
17
|
"/assets",
|
|
9
18
|
"/dist"
|
|
@@ -14,19 +23,19 @@
|
|
|
14
23
|
"react-components"
|
|
15
24
|
],
|
|
16
25
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"@not-govuk/sass-base": "^0.
|
|
21
|
-
"govuk
|
|
26
|
+
"@react-foundry/component-helpers": "^0.1.1",
|
|
27
|
+
"@react-foundry/router": "^0.1.1",
|
|
28
|
+
"govuk-frontend": "^5.14.0",
|
|
29
|
+
"@not-govuk/sass-base": "^0.17.0",
|
|
30
|
+
"@not-govuk/link": "^0.17.0"
|
|
22
31
|
},
|
|
23
32
|
"peerDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@storybook/addon-docs": "^
|
|
26
|
-
"react": "^
|
|
33
|
+
"@react-foundry/docs-components": "^0.1.1",
|
|
34
|
+
"@storybook/addon-docs": "^9.1.17",
|
|
35
|
+
"react": "^19.2.3"
|
|
27
36
|
},
|
|
28
37
|
"peerDependenciesMeta": {
|
|
29
|
-
"@
|
|
38
|
+
"@react-foundry/docs-components": {
|
|
30
39
|
"optional": true
|
|
31
40
|
},
|
|
32
41
|
"@storybook/addon-docs": {
|
|
@@ -34,19 +43,21 @@
|
|
|
34
43
|
}
|
|
35
44
|
},
|
|
36
45
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"jest": "29.
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"typescript": "4.9.5"
|
|
46
|
+
"@react-foundry/component-test-helpers": "0.1.1",
|
|
47
|
+
"@types/react": "19.2.9",
|
|
48
|
+
"jest": "30.2.0",
|
|
49
|
+
"jest-environment-jsdom": "30.2.0",
|
|
50
|
+
"ts-jest": "29.4.6",
|
|
51
|
+
"typescript": "5.9.3",
|
|
52
|
+
"@not-govuk/panel": "0.17.0"
|
|
45
53
|
},
|
|
46
54
|
"scripts": {
|
|
47
55
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
48
|
-
"build": "
|
|
56
|
+
"build": "npm run build:esm && npm run build:cjs",
|
|
57
|
+
"build:esm": "tsc -m es2022 && find dist -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' {} \\;",
|
|
58
|
+
"build:cjs": "tsc",
|
|
49
59
|
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
50
60
|
},
|
|
61
|
+
"module": "dist/BackLink.mjs",
|
|
51
62
|
"typings": "dist/BackLink.d.ts"
|
|
52
63
|
}
|
package/src/BackLink.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { ComponentProps, FC, ReactNode, createElement as h } from 'react';
|
|
4
|
-
import { StandardProps, classBuilder } from '@not-govuk/component-helpers';
|
|
5
|
-
import { A } from '@not-govuk/link';
|
|
6
|
-
import { useNavigate } from '@not-govuk/router';
|
|
7
|
-
|
|
8
|
-
import '../assets/BackLink.scss';
|
|
9
|
-
|
|
10
|
-
export type BackLinkProps = ComponentProps<typeof A> & {
|
|
11
|
-
children?: ReactNode
|
|
12
|
-
/** The location to link to */
|
|
13
|
-
href?: string
|
|
14
|
-
/** The text of the link */
|
|
15
|
-
text?: string
|
|
16
|
-
/** The title of the link */
|
|
17
|
-
title?: string
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const BackLink: FC<BackLinkProps> = ({
|
|
21
|
-
children,
|
|
22
|
-
classBlock,
|
|
23
|
-
classModifiers,
|
|
24
|
-
className,
|
|
25
|
-
href,
|
|
26
|
-
text: _text,
|
|
27
|
-
...attrs
|
|
28
|
-
}) => {
|
|
29
|
-
const defaultClassBlock = 'govuk-back-link';
|
|
30
|
-
const classes = classBuilder(defaultClassBlock, classBlock, classModifiers, className);
|
|
31
|
-
const navigate = useNavigate();
|
|
32
|
-
const text = _text || children || 'Back';
|
|
33
|
-
const goBack = () => navigate && navigate(-1);
|
|
34
|
-
|
|
35
|
-
return href ? (
|
|
36
|
-
<A {...attrs}
|
|
37
|
-
classBlock={classBlock || defaultClassBlock}
|
|
38
|
-
classModifiers={classModifiers}
|
|
39
|
-
className={className}
|
|
40
|
-
href={href}
|
|
41
|
-
>
|
|
42
|
-
{text}
|
|
43
|
-
</A>
|
|
44
|
-
) : (
|
|
45
|
-
<a {...attrs}
|
|
46
|
-
className={classes()}
|
|
47
|
-
href="#"
|
|
48
|
-
onClick={goBack}
|
|
49
|
-
>
|
|
50
|
-
{text}
|
|
51
|
-
</a>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default BackLink;
|