@transferwise/components 0.0.0-experimental-b2dc1ea → 0.0.0-experimental-4c86474
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/build/divider/Divider.js +33 -0
- package/build/divider/Divider.js.map +1 -0
- package/build/divider/Divider.mjs +31 -0
- package/build/divider/Divider.mjs.map +1 -0
- package/build/header/Header.js +34 -89
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +31 -85
- package/build/header/Header.mjs.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/index.mjs +2 -1
- package/build/index.mjs.map +1 -1
- package/build/link/Link.js +3 -5
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +3 -5
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +24 -3
- package/build/selectOption/SelectOption.js +1 -1
- package/build/selectOption/SelectOption.js.map +1 -1
- package/build/selectOption/SelectOption.mjs +1 -1
- package/build/styles/divider/Divider.css +24 -0
- package/build/styles/header/Header.css +0 -3
- package/build/styles/main.css +24 -3
- package/build/title/Title.js +3 -6
- package/build/title/Title.js.map +1 -1
- package/build/title/Title.mjs +3 -6
- package/build/title/Title.mjs.map +1 -1
- package/build/types/divider/Divider.d.ts +42 -0
- package/build/types/divider/Divider.d.ts.map +1 -0
- package/build/types/divider/index.d.ts +3 -0
- package/build/types/divider/index.d.ts.map +1 -0
- package/build/types/header/Header.d.ts +10 -34
- package/build/types/header/Header.d.ts.map +1 -1
- package/build/types/header/index.d.ts +0 -1
- package/build/types/header/index.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/link/Link.d.ts +1 -3
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/title/Title.d.ts +4 -3
- package/build/types/title/Title.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/divider/Divider.css +24 -0
- package/src/divider/Divider.less +31 -0
- package/src/divider/Divider.spec.tsx +85 -0
- package/src/divider/Divider.story.tsx +29 -0
- package/src/divider/Divider.tsx +72 -0
- package/src/divider/index.ts +2 -0
- package/src/header/Header.css +0 -3
- package/src/header/Header.less +0 -4
- package/src/header/Header.spec.tsx +0 -33
- package/src/header/Header.story.tsx +40 -54
- package/src/header/Header.tsx +60 -126
- package/src/header/index.ts +0 -1
- package/src/index.ts +2 -1
- package/src/link/Link.tsx +27 -29
- package/src/main.css +24 -3
- package/src/main.less +1 -0
- package/src/ssr.spec.js +1 -0
- package/src/title/Title.tsx +11 -25
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
const Divider = ({
|
|
8
|
+
as = 'hr',
|
|
9
|
+
className,
|
|
10
|
+
testId,
|
|
11
|
+
variant = 'section',
|
|
12
|
+
...props
|
|
13
|
+
}) => {
|
|
14
|
+
const Element = as;
|
|
15
|
+
const variantClass = variant && variant !== 'section' ? `wds-Divider--${variant}` : '';
|
|
16
|
+
const commonProps = {
|
|
17
|
+
className: clsx.clsx('wds-Divider', variantClass, className),
|
|
18
|
+
'data-testid': testId
|
|
19
|
+
};
|
|
20
|
+
const divProps = {
|
|
21
|
+
...commonProps,
|
|
22
|
+
'aria-orientation': 'horizontal',
|
|
23
|
+
role: 'separator'
|
|
24
|
+
};
|
|
25
|
+
const componentProps = Element === 'div' ? divProps : commonProps;
|
|
26
|
+
return /*#__PURE__*/jsxRuntime.jsx(Element, {
|
|
27
|
+
...componentProps,
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = Divider;
|
|
33
|
+
//# sourceMappingURL=Divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.js","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /** Option prop to specify DOM render element */\n as?: 'hr' | 'div';\n\n /** Optional prop to specify classNames onto the Divider */\n className?: string;\n\n /** Optional prop to specify the ID used for testing */\n testId?: string;\n\n /** Optional prop to specify the variant of the Divider */\n variant?: 'content' | 'subsection' | 'section';\n}\n\n/**\n * Divider component\n *\n * The Divider component is used to visually separate different sections of content.\n * It can be rendered as a horizontal line and supports various styles such as\n * section, subsection, and content. Additionally, the Divider can include custom styles.\n *\n * @component\n * @param {'hr' | 'div'} [as='hr'] - Option prop to specify DOM render element.\n * @param {string} [className] - Optional prop to specify classNames onto the Divider.\n * @param {string} [testId] - Optional prop to specify the ID used for testing.\n * @param {'section' | 'subsection' | 'content'} [variant='section'] - Optional prop to specify the variant of the Divider.\n *\n * @example\n * // Example usage:\n * import Divider from './Divider';\n *\n * function App() {\n * return (\n * <div>\n * <p>Content above the divider</p>\n * <Divider variant=\"content\" />\n * <p>Content below the divider</p>\n * <Divider variant=\"subsection\" />\n * </div>\n * );\n * }\n */\nconst Divider: FunctionComponent<DividerProps> = ({\n as = 'hr',\n className,\n testId,\n variant = 'section',\n ...props\n}) => {\n const Element = as;\n const variantClass = variant && variant !== 'section' ? `wds-Divider--${variant}` : '';\n\n const commonProps = {\n className: clsx('wds-Divider', variantClass, className),\n 'data-testid': testId,\n };\n\n const divProps = {\n ...commonProps,\n 'aria-orientation': 'horizontal',\n role: 'separator',\n };\n\n const componentProps = Element === 'div' ? divProps : commonProps;\n\n return <Element {...componentProps} {...props} />;\n};\n\nexport default Divider;\n"],"names":["Divider","as","className","testId","variant","props","Element","variantClass","commonProps","clsx","divProps","role","componentProps","_jsx"],"mappings":";;;;;;AA6CMA,MAAAA,OAAO,GAAoCA,CAAC;AAChDC,EAAAA,EAAE,GAAG,IAAI;EACTC,SAAS;EACTC,MAAM;AACNC,EAAAA,OAAO,GAAG,SAAS;EACnB,GAAGC,KAAAA;AAAK,CACT,KAAI;EACH,MAAMC,OAAO,GAAGL,EAAE,CAAA;AAClB,EAAA,MAAMM,YAAY,GAAGH,OAAO,IAAIA,OAAO,KAAK,SAAS,GAAG,CAAgBA,aAAAA,EAAAA,OAAO,CAAE,CAAA,GAAG,EAAE,CAAA;AAEtF,EAAA,MAAMI,WAAW,GAAG;IAClBN,SAAS,EAAEO,SAAI,CAAC,aAAa,EAAEF,YAAY,EAAEL,SAAS,CAAC;AACvD,IAAA,aAAa,EAAEC,MAAAA;GAChB,CAAA;AAED,EAAA,MAAMO,QAAQ,GAAG;AACf,IAAA,GAAGF,WAAW;AACd,IAAA,kBAAkB,EAAE,YAAY;AAChCG,IAAAA,IAAI,EAAE,WAAA;GACP,CAAA;EAED,MAAMC,cAAc,GAAGN,OAAO,KAAK,KAAK,GAAGI,QAAQ,GAAGF,WAAW,CAAA;EAEjE,oBAAOK,cAAA,CAACP,OAAO,EAAA;AAAA,IAAA,GAAKM,cAAc;IAAA,GAAMP,KAAAA;AAAK,GAAC,CAAG,CAAA;AACnD;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
const Divider = ({
|
|
6
|
+
as = 'hr',
|
|
7
|
+
className,
|
|
8
|
+
testId,
|
|
9
|
+
variant = 'section',
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const Element = as;
|
|
13
|
+
const variantClass = variant && variant !== 'section' ? `wds-Divider--${variant}` : '';
|
|
14
|
+
const commonProps = {
|
|
15
|
+
className: clsx('wds-Divider', variantClass, className),
|
|
16
|
+
'data-testid': testId
|
|
17
|
+
};
|
|
18
|
+
const divProps = {
|
|
19
|
+
...commonProps,
|
|
20
|
+
'aria-orientation': 'horizontal',
|
|
21
|
+
role: 'separator'
|
|
22
|
+
};
|
|
23
|
+
const componentProps = Element === 'div' ? divProps : commonProps;
|
|
24
|
+
return /*#__PURE__*/jsx(Element, {
|
|
25
|
+
...componentProps,
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Divider as default };
|
|
31
|
+
//# sourceMappingURL=Divider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.mjs","sources":["../../src/divider/Divider.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport React, { FunctionComponent } from 'react';\n\nexport interface DividerProps {\n /** Option prop to specify DOM render element */\n as?: 'hr' | 'div';\n\n /** Optional prop to specify classNames onto the Divider */\n className?: string;\n\n /** Optional prop to specify the ID used for testing */\n testId?: string;\n\n /** Optional prop to specify the variant of the Divider */\n variant?: 'content' | 'subsection' | 'section';\n}\n\n/**\n * Divider component\n *\n * The Divider component is used to visually separate different sections of content.\n * It can be rendered as a horizontal line and supports various styles such as\n * section, subsection, and content. Additionally, the Divider can include custom styles.\n *\n * @component\n * @param {'hr' | 'div'} [as='hr'] - Option prop to specify DOM render element.\n * @param {string} [className] - Optional prop to specify classNames onto the Divider.\n * @param {string} [testId] - Optional prop to specify the ID used for testing.\n * @param {'section' | 'subsection' | 'content'} [variant='section'] - Optional prop to specify the variant of the Divider.\n *\n * @example\n * // Example usage:\n * import Divider from './Divider';\n *\n * function App() {\n * return (\n * <div>\n * <p>Content above the divider</p>\n * <Divider variant=\"content\" />\n * <p>Content below the divider</p>\n * <Divider variant=\"subsection\" />\n * </div>\n * );\n * }\n */\nconst Divider: FunctionComponent<DividerProps> = ({\n as = 'hr',\n className,\n testId,\n variant = 'section',\n ...props\n}) => {\n const Element = as;\n const variantClass = variant && variant !== 'section' ? `wds-Divider--${variant}` : '';\n\n const commonProps = {\n className: clsx('wds-Divider', variantClass, className),\n 'data-testid': testId,\n };\n\n const divProps = {\n ...commonProps,\n 'aria-orientation': 'horizontal',\n role: 'separator',\n };\n\n const componentProps = Element === 'div' ? divProps : commonProps;\n\n return <Element {...componentProps} {...props} />;\n};\n\nexport default Divider;\n"],"names":["Divider","as","className","testId","variant","props","Element","variantClass","commonProps","clsx","divProps","role","componentProps","_jsx"],"mappings":";;;;AA6CMA,MAAAA,OAAO,GAAoCA,CAAC;AAChDC,EAAAA,EAAE,GAAG,IAAI;EACTC,SAAS;EACTC,MAAM;AACNC,EAAAA,OAAO,GAAG,SAAS;EACnB,GAAGC,KAAAA;AAAK,CACT,KAAI;EACH,MAAMC,OAAO,GAAGL,EAAE,CAAA;AAClB,EAAA,MAAMM,YAAY,GAAGH,OAAO,IAAIA,OAAO,KAAK,SAAS,GAAG,CAAgBA,aAAAA,EAAAA,OAAO,CAAE,CAAA,GAAG,EAAE,CAAA;AAEtF,EAAA,MAAMI,WAAW,GAAG;IAClBN,SAAS,EAAEO,IAAI,CAAC,aAAa,EAAEF,YAAY,EAAEL,SAAS,CAAC;AACvD,IAAA,aAAa,EAAEC,MAAAA;GAChB,CAAA;AAED,EAAA,MAAMO,QAAQ,GAAG;AACf,IAAA,GAAGF,WAAW;AACd,IAAA,kBAAkB,EAAE,YAAY;AAChCG,IAAAA,IAAI,EAAE,WAAA;GACP,CAAA;EAED,MAAMC,cAAc,GAAGN,OAAO,KAAK,KAAK,GAAGI,QAAQ,GAAGF,WAAW,CAAA;EAEjE,oBAAOK,GAAA,CAACP,OAAO,EAAA;AAAA,IAAA,GAAKM,cAAc;IAAA,GAAMP,KAAAA;AAAK,GAAC,CAAG,CAAA;AACnD;;;;"}
|
package/build/header/Header.js
CHANGED
|
@@ -1,129 +1,74 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var clsx = require('clsx');
|
|
4
|
-
var Link = require('../link/Link.js');
|
|
5
6
|
var Button = require('../button/Button.js');
|
|
7
|
+
var Link = require('../link/Link.js');
|
|
6
8
|
var Title = require('../title/Title.js');
|
|
7
|
-
var React = require('react');
|
|
8
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
var typography = require('../common/propsValues/typography.js');
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
-
|
|
15
|
-
const HeaderAction = /*#__PURE__*/React__default.default.forwardRef(({
|
|
12
|
+
const HeaderAction = ({
|
|
16
13
|
action
|
|
17
|
-
}
|
|
18
|
-
const {
|
|
19
|
-
'aria-label':
|
|
20
|
-
|
|
21
|
-
onClick
|
|
22
|
-
} = action;
|
|
14
|
+
}) => {
|
|
15
|
+
const props = {
|
|
16
|
+
'aria-label': action['aria-label']
|
|
17
|
+
};
|
|
23
18
|
if ('href' in action) {
|
|
24
|
-
const {
|
|
25
|
-
href,
|
|
26
|
-
target,
|
|
27
|
-
onClick: linkOnClick
|
|
28
|
-
} = action;
|
|
29
19
|
return /*#__PURE__*/jsxRuntime.jsx(Link, {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
children: text
|
|
20
|
+
href: action.href,
|
|
21
|
+
target: action.target,
|
|
22
|
+
onClick: action.onClick,
|
|
23
|
+
...props,
|
|
24
|
+
children: action.text
|
|
36
25
|
});
|
|
37
26
|
}
|
|
38
27
|
return /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
39
|
-
ref: ref,
|
|
40
28
|
className: "np-header__button",
|
|
41
29
|
priority: "tertiary",
|
|
42
30
|
size: "sm",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
children: text
|
|
31
|
+
onClick: action.onClick,
|
|
32
|
+
...props,
|
|
33
|
+
children: action.text
|
|
46
34
|
});
|
|
47
|
-
}
|
|
35
|
+
};
|
|
48
36
|
/**
|
|
49
|
-
* Header component
|
|
50
|
-
*
|
|
51
|
-
* The header component is used to render a section header with an optional action button or link.
|
|
52
|
-
* The header component can be rendered as a `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, or `legend` element.
|
|
53
37
|
*
|
|
54
|
-
*
|
|
55
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
56
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
57
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
58
|
-
* @param {'group' | 'section'} [variant='group'] - Optional prop to specify the variant of the section header.
|
|
59
|
-
* @param {string} [className] - Optional prop to specify classNames onto the Header.
|
|
60
|
-
* @param {string} [testId] - Optional prop to specify the ID used for testing.
|
|
38
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
61
39
|
*
|
|
62
|
-
* @example
|
|
63
|
-
* // Example usage:
|
|
64
|
-
* import Header from './Header';
|
|
65
|
-
*
|
|
66
|
-
* function App() {
|
|
67
|
-
* return (
|
|
68
|
-
* <Header title="Header" />
|
|
69
|
-
* );
|
|
70
|
-
* }
|
|
71
40
|
*/
|
|
72
|
-
const Header =
|
|
73
|
-
as = 'h5',
|
|
41
|
+
const Header = ({
|
|
74
42
|
action,
|
|
75
|
-
|
|
76
|
-
testId,
|
|
43
|
+
as = 'h5',
|
|
77
44
|
title,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const internalRef = React.useRef(null);
|
|
82
|
-
const variantTypography = variant === 'section' ? typography.Typography.TITLE_SUBSECTION : typography.Typography.TITLE_GROUP;
|
|
83
|
-
const headerClasses = clsx.clsx('np-header', className, {
|
|
84
|
-
'np-header--section': variant === 'section',
|
|
85
|
-
'np-header__title': !action || as === 'legend'
|
|
86
|
-
});
|
|
87
|
-
const commonProps = {
|
|
88
|
-
className: headerClasses,
|
|
89
|
-
'data-testid': testId
|
|
90
|
-
};
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
if (as === 'legend' && internalRef.current) {
|
|
93
|
-
const {
|
|
94
|
-
parentElement
|
|
95
|
-
} = internalRef.current;
|
|
96
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
97
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}, [as]);
|
|
101
|
-
if (!action || as === 'legend') {
|
|
45
|
+
className
|
|
46
|
+
}) => {
|
|
47
|
+
if (!action) {
|
|
102
48
|
return /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
103
|
-
ref: internalRef,
|
|
104
49
|
as: as,
|
|
105
|
-
type:
|
|
106
|
-
|
|
107
|
-
...props,
|
|
50
|
+
type: typography.Typography.TITLE_GROUP,
|
|
51
|
+
className: clsx.clsx('np-header', 'np-header__title', className),
|
|
108
52
|
children: title
|
|
109
53
|
});
|
|
110
54
|
}
|
|
111
|
-
|
|
55
|
+
if (as === 'legend') {
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
58
|
+
}
|
|
112
59
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
113
|
-
|
|
114
|
-
...props,
|
|
115
|
-
ref: ref,
|
|
60
|
+
className: clsx.clsx('np-header', className),
|
|
116
61
|
children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
117
62
|
as: as,
|
|
118
|
-
type:
|
|
63
|
+
type: typography.Typography.TITLE_GROUP,
|
|
119
64
|
className: "np-header__title",
|
|
120
65
|
children: title
|
|
121
66
|
}), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
|
|
122
|
-
ref: actionRef,
|
|
123
67
|
action: action
|
|
124
68
|
})]
|
|
125
69
|
});
|
|
126
|
-
}
|
|
70
|
+
};
|
|
127
71
|
|
|
128
|
-
|
|
72
|
+
exports.Header = Header;
|
|
73
|
+
exports.default = Header;
|
|
129
74
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport
|
|
1
|
+
{"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport Button from '../button';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport type HeaderProps = CommonProps & {\n /**\n * When the `href` property is provided to the `action`, we will render a `Link` instead of a `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n /**\n * Override the heading element rendered for the title, useful to specify the semantics of your header.\n *\n * @default \"h5\"\n */\n as?: Heading | 'legend';\n title: string;\n};\n\nconst HeaderAction = ({ action }: { action: ButtonActionProps | LinkActionProps }) => {\n const props = {\n 'aria-label': action['aria-label'],\n };\n\n if ('href' in action) {\n return (\n <Link href={action.href} target={action.target} onClick={action.onClick} {...props}>\n {action.text}\n </Link>\n );\n }\n\n return (\n <Button\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n onClick={action.onClick}\n {...props}\n >\n {action.text}\n </Button>\n );\n};\n\n/**\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header\n *\n */\nexport const Header = ({ action, as = 'h5', title, className }: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n type={Typography.TITLE_GROUP}\n className={clsx('np-header', 'np-header__title', className)}\n >\n {title}\n </Title>\n );\n }\n\n if (as === 'legend') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n\n return (\n <div className={clsx('np-header', className)}>\n <Title as={as} type={Typography.TITLE_GROUP} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n};\n\nexport default Header;\n"],"names":["HeaderAction","action","props","_jsx","Link","href","target","onClick","children","text","Button","className","priority","size","Header","as","title","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;;;;;AA8BA,MAAMA,YAAY,GAAGA,CAAC;AAAEC,EAAAA,MAAAA;AAAM,CAAmD,KAAI;AACnF,EAAA,MAAMC,KAAK,GAAG;IACZ,YAAY,EAAED,MAAM,CAAC,YAAY,CAAA;GAClC,CAAA;EAED,IAAI,MAAM,IAAIA,MAAM,EAAE;IACpB,oBACEE,cAAA,CAACC,IAAI,EAAA;MAACC,IAAI,EAAEJ,MAAM,CAACI,IAAK;MAACC,MAAM,EAAEL,MAAM,CAACK,MAAO;MAACC,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,MAAA,GAAKL,KAAK;MAAAM,QAAA,EAC/EP,MAAM,CAACQ,IAAAA;AAAI,KACR,CAAC,CAAA;AAEX,GAAA;EAEA,oBACEN,cAAA,CAACO,MAAM,EAAA;AACLC,IAAAA,SAAS,EAAC,mBAAmB;AAC7BC,IAAAA,QAAQ,EAAC,UAAU;AACnBC,IAAAA,IAAI,EAAC,IAAI;IACTN,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,IAAA,GACpBL,KAAK;IAAAM,QAAA,EAERP,MAAM,CAACQ,IAAAA;AAAI,GACN,CAAC,CAAA;AAEb,CAAC,CAAA;AAED;;;;AAIG;AACI,MAAMK,MAAM,GAAGA,CAAC;EAAEb,MAAM;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEC,KAAK;AAAEL,EAAAA,SAAAA;AAAS,CAAe,KAAI;EAC7E,IAAI,CAACV,MAAM,EAAE;IACX,oBACEE,cAAA,CAACc,KAAK,EAAA;AACJF,MAAAA,EAAE,EAAEA,EAAG;MACPG,IAAI,EAAEC,qBAAU,CAACC,WAAY;MAC7BT,SAAS,EAAEU,SAAI,CAAC,WAAW,EAAE,kBAAkB,EAAEV,SAAS,CAAE;AAAAH,MAAAA,QAAA,EAE3DQ,KAAAA;AAAK,KACD,CAAC,CAAA;AAEZ,GAAA;EAEA,IAAID,EAAE,KAAK,QAAQ,EAAE;AACnB;AACAO,IAAAA,OAAO,CAACC,IAAI,CACV,oGAAoG,CACrG,CAAA;AACH,GAAA;AAEA,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AAAKb,IAAAA,SAAS,EAAEU,SAAI,CAAC,WAAW,EAAEV,SAAS,CAAE;IAAAH,QAAA,EAAA,cAC3CL,cAAA,CAACc,KAAK,EAAA;AAACF,MAAAA,EAAE,EAAEA,EAAG;MAACG,IAAI,EAAEC,qBAAU,CAACC,WAAY;AAACT,MAAAA,SAAS,EAAC,kBAAkB;AAAAH,MAAAA,QAAA,EACtEQ,KAAAA;AAAK,KACD,CACP,eAAAb,cAAA,CAACH,YAAY,EAAA;AAACC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/B,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;;"}
|
package/build/header/Header.mjs
CHANGED
|
@@ -1,123 +1,69 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import Link from '../link/Link.mjs';
|
|
3
2
|
import Button from '../button/Button.mjs';
|
|
3
|
+
import Link from '../link/Link.mjs';
|
|
4
4
|
import Title from '../title/Title.mjs';
|
|
5
|
-
import React__default, { useRef, useEffect } from 'react';
|
|
6
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
6
|
import { Typography } from '../common/propsValues/typography.mjs';
|
|
8
7
|
|
|
9
|
-
const HeaderAction =
|
|
8
|
+
const HeaderAction = ({
|
|
10
9
|
action
|
|
11
|
-
}
|
|
12
|
-
const {
|
|
13
|
-
'aria-label':
|
|
14
|
-
|
|
15
|
-
onClick
|
|
16
|
-
} = action;
|
|
10
|
+
}) => {
|
|
11
|
+
const props = {
|
|
12
|
+
'aria-label': action['aria-label']
|
|
13
|
+
};
|
|
17
14
|
if ('href' in action) {
|
|
18
|
-
const {
|
|
19
|
-
href,
|
|
20
|
-
target,
|
|
21
|
-
onClick: linkOnClick
|
|
22
|
-
} = action;
|
|
23
15
|
return /*#__PURE__*/jsx(Link, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children: text
|
|
16
|
+
href: action.href,
|
|
17
|
+
target: action.target,
|
|
18
|
+
onClick: action.onClick,
|
|
19
|
+
...props,
|
|
20
|
+
children: action.text
|
|
30
21
|
});
|
|
31
22
|
}
|
|
32
23
|
return /*#__PURE__*/jsx(Button, {
|
|
33
|
-
ref: ref,
|
|
34
24
|
className: "np-header__button",
|
|
35
25
|
priority: "tertiary",
|
|
36
26
|
size: "sm",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
children: text
|
|
27
|
+
onClick: action.onClick,
|
|
28
|
+
...props,
|
|
29
|
+
children: action.text
|
|
40
30
|
});
|
|
41
|
-
}
|
|
31
|
+
};
|
|
42
32
|
/**
|
|
43
|
-
* Header component
|
|
44
|
-
*
|
|
45
|
-
* The header component is used to render a section header with an optional action button or link.
|
|
46
|
-
* The header component can be rendered as a `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, or `legend` element.
|
|
47
|
-
*
|
|
48
|
-
* @component
|
|
49
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
50
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
51
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
52
|
-
* @param {'group' | 'section'} [variant='group'] - Optional prop to specify the variant of the section header.
|
|
53
|
-
* @param {string} [className] - Optional prop to specify classNames onto the Header.
|
|
54
|
-
* @param {string} [testId] - Optional prop to specify the ID used for testing.
|
|
55
33
|
*
|
|
56
|
-
*
|
|
57
|
-
* // Example usage:
|
|
58
|
-
* import Header from './Header';
|
|
34
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
59
35
|
*
|
|
60
|
-
* function App() {
|
|
61
|
-
* return (
|
|
62
|
-
* <Header title="Header" />
|
|
63
|
-
* );
|
|
64
|
-
* }
|
|
65
36
|
*/
|
|
66
|
-
const Header =
|
|
67
|
-
as = 'h5',
|
|
37
|
+
const Header = ({
|
|
68
38
|
action,
|
|
69
|
-
|
|
70
|
-
testId,
|
|
39
|
+
as = 'h5',
|
|
71
40
|
title,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const internalRef = useRef(null);
|
|
76
|
-
const variantTypography = variant === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;
|
|
77
|
-
const headerClasses = clsx('np-header', className, {
|
|
78
|
-
'np-header--section': variant === 'section',
|
|
79
|
-
'np-header__title': !action || as === 'legend'
|
|
80
|
-
});
|
|
81
|
-
const commonProps = {
|
|
82
|
-
className: headerClasses,
|
|
83
|
-
'data-testid': testId
|
|
84
|
-
};
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (as === 'legend' && internalRef.current) {
|
|
87
|
-
const {
|
|
88
|
-
parentElement
|
|
89
|
-
} = internalRef.current;
|
|
90
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
91
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}, [as]);
|
|
95
|
-
if (!action || as === 'legend') {
|
|
41
|
+
className
|
|
42
|
+
}) => {
|
|
43
|
+
if (!action) {
|
|
96
44
|
return /*#__PURE__*/jsx(Title, {
|
|
97
|
-
ref: internalRef,
|
|
98
45
|
as: as,
|
|
99
|
-
type:
|
|
100
|
-
|
|
101
|
-
...props,
|
|
46
|
+
type: Typography.TITLE_GROUP,
|
|
47
|
+
className: clsx('np-header', 'np-header__title', className),
|
|
102
48
|
children: title
|
|
103
49
|
});
|
|
104
50
|
}
|
|
105
|
-
|
|
51
|
+
if (as === 'legend') {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
54
|
+
}
|
|
106
55
|
return /*#__PURE__*/jsxs("div", {
|
|
107
|
-
|
|
108
|
-
...props,
|
|
109
|
-
ref: ref,
|
|
56
|
+
className: clsx('np-header', className),
|
|
110
57
|
children: [/*#__PURE__*/jsx(Title, {
|
|
111
58
|
as: as,
|
|
112
|
-
type:
|
|
59
|
+
type: Typography.TITLE_GROUP,
|
|
113
60
|
className: "np-header__title",
|
|
114
61
|
children: title
|
|
115
62
|
}), /*#__PURE__*/jsx(HeaderAction, {
|
|
116
|
-
ref: actionRef,
|
|
117
63
|
action: action
|
|
118
64
|
})]
|
|
119
65
|
});
|
|
120
|
-
}
|
|
66
|
+
};
|
|
121
67
|
|
|
122
|
-
export { Header as default };
|
|
68
|
+
export { Header, Header as default };
|
|
123
69
|
//# sourceMappingURL=Header.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.mjs","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport
|
|
1
|
+
{"version":3,"file":"Header.mjs","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport { ActionButtonProps } from '../actionButton/ActionButton';\nimport Button from '../button';\nimport { AriaLabelProperty, CommonProps, Heading, LinkProps, Typography } from '../common';\nimport Link from '../link';\nimport Title from '../title';\n\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport type HeaderProps = CommonProps & {\n /**\n * When the `href` property is provided to the `action`, we will render a `Link` instead of a `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n /**\n * Override the heading element rendered for the title, useful to specify the semantics of your header.\n *\n * @default \"h5\"\n */\n as?: Heading | 'legend';\n title: string;\n};\n\nconst HeaderAction = ({ action }: { action: ButtonActionProps | LinkActionProps }) => {\n const props = {\n 'aria-label': action['aria-label'],\n };\n\n if ('href' in action) {\n return (\n <Link href={action.href} target={action.target} onClick={action.onClick} {...props}>\n {action.text}\n </Link>\n );\n }\n\n return (\n <Button\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n onClick={action.onClick}\n {...props}\n >\n {action.text}\n </Button>\n );\n};\n\n/**\n *\n * Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header\n *\n */\nexport const Header = ({ action, as = 'h5', title, className }: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n type={Typography.TITLE_GROUP}\n className={clsx('np-header', 'np-header__title', className)}\n >\n {title}\n </Title>\n );\n }\n\n if (as === 'legend') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Legends should be the first child in a fieldset, and this is not possible when including an action',\n );\n }\n\n return (\n <div className={clsx('np-header', className)}>\n <Title as={as} type={Typography.TITLE_GROUP} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction action={action} />\n </div>\n );\n};\n\nexport default Header;\n"],"names":["HeaderAction","action","props","_jsx","Link","href","target","onClick","children","text","Button","className","priority","size","Header","as","title","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;AA8BA,MAAMA,YAAY,GAAGA,CAAC;AAAEC,EAAAA,MAAAA;AAAM,CAAmD,KAAI;AACnF,EAAA,MAAMC,KAAK,GAAG;IACZ,YAAY,EAAED,MAAM,CAAC,YAAY,CAAA;GAClC,CAAA;EAED,IAAI,MAAM,IAAIA,MAAM,EAAE;IACpB,oBACEE,GAAA,CAACC,IAAI,EAAA;MAACC,IAAI,EAAEJ,MAAM,CAACI,IAAK;MAACC,MAAM,EAAEL,MAAM,CAACK,MAAO;MAACC,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,MAAA,GAAKL,KAAK;MAAAM,QAAA,EAC/EP,MAAM,CAACQ,IAAAA;AAAI,KACR,CAAC,CAAA;AAEX,GAAA;EAEA,oBACEN,GAAA,CAACO,MAAM,EAAA;AACLC,IAAAA,SAAS,EAAC,mBAAmB;AAC7BC,IAAAA,QAAQ,EAAC,UAAU;AACnBC,IAAAA,IAAI,EAAC,IAAI;IACTN,OAAO,EAAEN,MAAM,CAACM,OAAQ;AAAA,IAAA,GACpBL,KAAK;IAAAM,QAAA,EAERP,MAAM,CAACQ,IAAAA;AAAI,GACN,CAAC,CAAA;AAEb,CAAC,CAAA;AAED;;;;AAIG;AACI,MAAMK,MAAM,GAAGA,CAAC;EAAEb,MAAM;AAAEc,EAAAA,EAAE,GAAG,IAAI;EAAEC,KAAK;AAAEL,EAAAA,SAAAA;AAAS,CAAe,KAAI;EAC7E,IAAI,CAACV,MAAM,EAAE;IACX,oBACEE,GAAA,CAACc,KAAK,EAAA;AACJF,MAAAA,EAAE,EAAEA,EAAG;MACPG,IAAI,EAAEC,UAAU,CAACC,WAAY;MAC7BT,SAAS,EAAEU,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAEV,SAAS,CAAE;AAAAH,MAAAA,QAAA,EAE3DQ,KAAAA;AAAK,KACD,CAAC,CAAA;AAEZ,GAAA;EAEA,IAAID,EAAE,KAAK,QAAQ,EAAE;AACnB;AACAO,IAAAA,OAAO,CAACC,IAAI,CACV,oGAAoG,CACrG,CAAA;AACH,GAAA;AAEA,EAAA,oBACEC,IAAA,CAAA,KAAA,EAAA;AAAKb,IAAAA,SAAS,EAAEU,IAAI,CAAC,WAAW,EAAEV,SAAS,CAAE;IAAAH,QAAA,EAAA,cAC3CL,GAAA,CAACc,KAAK,EAAA;AAACF,MAAAA,EAAE,EAAEA,EAAG;MAACG,IAAI,EAAEC,UAAU,CAACC,WAAY;AAACT,MAAAA,SAAS,EAAC,kBAAkB;AAAAH,MAAAA,QAAA,EACtEQ,KAAAA;AAAK,KACD,CACP,eAAAb,GAAA,CAACH,YAAY,EAAA;AAACC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/B,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
|
package/build/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var Decision = require('./decision/Decision.js');
|
|
|
30
30
|
var DefinitionList = require('./definitionList/DefinitionList.js');
|
|
31
31
|
var Dimmer = require('./dimmer/Dimmer.js');
|
|
32
32
|
var Display = require('./display/Display.js');
|
|
33
|
+
var Divider = require('./divider/Divider.js');
|
|
33
34
|
var Drawer = require('./drawer/Drawer.js');
|
|
34
35
|
var DropFade = require('./dropFade/DropFade.js');
|
|
35
36
|
var Emphasis = require('./emphasis/Emphasis.js');
|
|
@@ -171,12 +172,13 @@ Object.defineProperty(exports, "DecisionType", {
|
|
|
171
172
|
exports.DefinitionList = DefinitionList;
|
|
172
173
|
exports.Dimmer = Dimmer.default;
|
|
173
174
|
exports.Display = Display;
|
|
175
|
+
exports.Divider = Divider;
|
|
174
176
|
exports.Drawer = Drawer;
|
|
175
177
|
exports.DropFade = DropFade;
|
|
176
178
|
exports.Emphasis = Emphasis;
|
|
177
179
|
exports.Field = Field.Field;
|
|
178
180
|
exports.FlowNavigation = FlowNavigation;
|
|
179
|
-
exports.Header = Header;
|
|
181
|
+
exports.Header = Header.Header;
|
|
180
182
|
exports.Image = Image.default;
|
|
181
183
|
Object.defineProperty(exports, "InfoPresentation", {
|
|
182
184
|
enumerable: true,
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/index.mjs
CHANGED
|
@@ -28,12 +28,13 @@ export { default as Decision, DecisionPresentation, DecisionType } from './decis
|
|
|
28
28
|
export { default as DefinitionList } from './definitionList/DefinitionList.mjs';
|
|
29
29
|
export { default as Dimmer } from './dimmer/Dimmer.mjs';
|
|
30
30
|
export { default as Display } from './display/Display.mjs';
|
|
31
|
+
export { default as Divider } from './divider/Divider.mjs';
|
|
31
32
|
export { default as Drawer } from './drawer/Drawer.mjs';
|
|
32
33
|
export { default as DropFade } from './dropFade/DropFade.mjs';
|
|
33
34
|
export { default as Emphasis } from './emphasis/Emphasis.mjs';
|
|
34
35
|
export { Field } from './field/Field.mjs';
|
|
35
36
|
export { default as FlowNavigation } from './flowNavigation/FlowNavigation.mjs';
|
|
36
|
-
export {
|
|
37
|
+
export { Header } from './header/Header.mjs';
|
|
37
38
|
export { default as Image } from './image/Image.mjs';
|
|
38
39
|
export { InfoPresentation } from './info/infoPresentations.mjs';
|
|
39
40
|
export { default as Info } from './info/Info.mjs';
|
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/link/Link.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var icons = require('@transferwise/icons');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
|
-
var React = require('react');
|
|
6
5
|
var reactIntl = require('react-intl');
|
|
7
6
|
var Link_messages = require('./Link.messages.js');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
|
|
10
|
-
const Link =
|
|
9
|
+
const Link = ({
|
|
11
10
|
className,
|
|
12
11
|
children,
|
|
13
12
|
href,
|
|
@@ -16,13 +15,12 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
16
15
|
'aria-label': ariaLabel,
|
|
17
16
|
onClick,
|
|
18
17
|
...props
|
|
19
|
-
}
|
|
18
|
+
}) => {
|
|
20
19
|
const isBlank = target === '_blank';
|
|
21
20
|
const {
|
|
22
21
|
formatMessage
|
|
23
22
|
} = reactIntl.useIntl();
|
|
24
23
|
return /*#__PURE__*/jsxRuntime.jsxs("a", {
|
|
25
|
-
ref: ref,
|
|
26
24
|
href: href,
|
|
27
25
|
target: target,
|
|
28
26
|
className: clsx.clsx('np-link', type ? `np-text-${type}` : undefined, 'd-inline-flex', className),
|
|
@@ -34,7 +32,7 @@ const Link = /*#__PURE__*/React.forwardRef(({
|
|
|
34
32
|
title: formatMessage(Link_messages.opensInNewTab)
|
|
35
33
|
})]
|
|
36
34
|
});
|
|
37
|
-
}
|
|
35
|
+
};
|
|
38
36
|
|
|
39
37
|
module.exports = Link;
|
|
40
38
|
//# sourceMappingURL=Link.js.map
|
package/build/link/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sources":["../../src/link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { AnchorHTMLAttributes
|
|
1
|
+
{"version":3,"file":"Link.js","sources":["../../src/link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { AnchorHTMLAttributes } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport { LinkLarge, LinkDefault } from '../common';\n\nimport messages from './Link.messages';\n\nexport type Props = AnchorHTMLAttributes<HTMLAnchorElement> & { type?: LinkLarge | LinkDefault };\n\n/**\n * Standard Link component with navigate away icon\n *\n * Documentation: https://transferwise.github.io/neptune-web/components/content/Link\n */\nconst Link = ({\n className,\n children,\n href,\n target,\n type,\n 'aria-label': ariaLabel,\n onClick,\n ...props\n}: Props) => {\n const isBlank = target === '_blank';\n\n const { formatMessage } = useIntl();\n\n return (\n <a\n href={href}\n target={target}\n className={clsx('np-link', type ? `np-text-${type}` : undefined, 'd-inline-flex', className)}\n aria-label={ariaLabel}\n rel={isBlank ? 'noreferrer' : undefined}\n onClick={onClick}\n {...props}\n >\n {children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}\n </a>\n );\n};\n\nexport default Link;\n"],"names":["Link","className","children","href","target","type","ariaLabel","onClick","props","isBlank","formatMessage","useIntl","_jsxs","clsx","undefined","rel","_jsx","NavigateAwayIcon","title","messages","opensInNewTab"],"mappings":";;;;;;;;AAgBMA,MAAAA,IAAI,GAAGA,CAAC;EACZC,SAAS;EACTC,QAAQ;EACRC,IAAI;EACJC,MAAM;EACNC,IAAI;AACJ,EAAA,YAAY,EAAEC,SAAS;EACvBC,OAAO;EACP,GAAGC,KAAAA;AACG,CAAA,KAAI;AACV,EAAA,MAAMC,OAAO,GAAGL,MAAM,KAAK,QAAQ,CAAA;EAEnC,MAAM;AAAEM,IAAAA,aAAAA;GAAe,GAAGC,iBAAO,EAAE,CAAA;AAEnC,EAAA,oBACEC,eAAA,CAAA,GAAA,EAAA;AACET,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,SAAS,EAAEY,SAAI,CAAC,SAAS,EAAER,IAAI,GAAG,CAAA,QAAA,EAAWA,IAAI,CAAA,CAAE,GAAGS,SAAS,EAAE,eAAe,EAAEb,SAAS,CAAE;AAC7F,IAAA,YAAA,EAAYK,SAAU;AACtBS,IAAAA,GAAG,EAAEN,OAAO,GAAG,YAAY,GAAGK,SAAU;AACxCP,IAAAA,OAAO,EAAEA,OAAQ;AAAA,IAAA,GACbC,KAAK;IAAAN,QAAA,EAAA,CAERA,QAAQ,EAAE,GAAA,EAACO,OAAO,iBAAIO,cAAA,CAACC,kBAAgB,EAAA;AAACC,MAAAA,KAAK,EAAER,aAAa,CAACS,aAAQ,CAACC,aAAa,CAAA;AAAE,MAAG,CAAA;AAAA,GACxF,CAAC,CAAA;AAER;;;;"}
|