@transferwise/components 0.0.0-experimental-a41b256 → 0.0.0-experimental-840bf87
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/header/Header.js +38 -78
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +38 -75
- package/build/header/Header.mjs.map +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/build/inputs/SelectInput.js +1 -1
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +1 -1
- package/build/main.css +11 -17
- 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/header/Header.css +11 -17
- package/build/styles/main.css +11 -17
- package/build/title/Title.js +4 -6
- package/build/title/Title.js.map +1 -1
- package/build/title/Title.mjs +4 -6
- package/build/title/Title.mjs.map +1 -1
- package/build/types/header/Header.d.ts +11 -28
- 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 +0 -1
- package/build/types/index.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 +5 -5
- package/src/header/Header.css +11 -17
- package/src/header/Header.less +8 -17
- package/src/header/Header.spec.tsx +50 -68
- package/src/header/Header.story.tsx +39 -184
- package/src/header/Header.tsx +69 -122
- package/src/header/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/main.css +11 -17
- package/src/title/Title.tsx +11 -25
- package/src/header/Header.accessibility.docs.mdx +0 -85
package/build/header/Header.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
|
+
var Button_resolver = require('../button/Button.resolver.js');
|
|
6
7
|
require('../common/theme.js');
|
|
7
8
|
require('../common/direction.js');
|
|
8
9
|
require('../common/propsValues/control.js');
|
|
@@ -23,119 +24,78 @@ require('../common/propsValues/scroll.js');
|
|
|
23
24
|
require('../common/propsValues/markdownNodeType.js');
|
|
24
25
|
require('../common/fileType.js');
|
|
25
26
|
require('@transferwise/icons');
|
|
26
|
-
|
|
27
|
+
require('react');
|
|
27
28
|
require('react-intl');
|
|
28
29
|
require('../common/closeButton/CloseButton.messages.js');
|
|
29
30
|
var jsxRuntime = require('react/jsx-runtime');
|
|
30
31
|
var Link = require('../link/Link.js');
|
|
31
|
-
var Button_resolver = require('../button/Button.resolver.js');
|
|
32
32
|
var Title = require('../title/Title.js');
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
37
|
-
|
|
38
|
-
const HeaderAction = /*#__PURE__*/React__default.default.forwardRef(({
|
|
34
|
+
const HeaderAction = ({
|
|
39
35
|
action
|
|
40
|
-
}
|
|
41
|
-
const {
|
|
42
|
-
'aria-label':
|
|
43
|
-
|
|
44
|
-
onClick
|
|
45
|
-
} = action;
|
|
36
|
+
}) => {
|
|
37
|
+
const props = {
|
|
38
|
+
'aria-label': action['aria-label']
|
|
39
|
+
};
|
|
46
40
|
if ('href' in action) {
|
|
47
|
-
const {
|
|
48
|
-
href,
|
|
49
|
-
target,
|
|
50
|
-
onClick: linkOnClick
|
|
51
|
-
} = action;
|
|
52
41
|
return /*#__PURE__*/jsxRuntime.jsx(Link.default, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
children: text
|
|
42
|
+
href: action.href,
|
|
43
|
+
target: action.target,
|
|
44
|
+
onClick: action.onClick,
|
|
45
|
+
...props,
|
|
46
|
+
children: action.text
|
|
59
47
|
});
|
|
60
48
|
}
|
|
61
49
|
return /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
|
|
62
|
-
ref: ref,
|
|
63
50
|
className: "np-header__button",
|
|
64
51
|
priority: "tertiary",
|
|
65
52
|
size: "sm",
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
children: text
|
|
53
|
+
onClick: action.onClick,
|
|
54
|
+
...props,
|
|
55
|
+
children: action.text
|
|
69
56
|
});
|
|
70
|
-
}
|
|
71
|
-
HeaderAction.displayName = 'HeaderAction';
|
|
57
|
+
};
|
|
72
58
|
/**
|
|
73
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
74
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
75
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
76
|
-
* @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.
|
|
77
|
-
* @param {string} [className]
|
|
78
|
-
* @param {string} [testId]
|
|
79
59
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
60
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
61
|
+
*
|
|
82
62
|
*/
|
|
83
|
-
const Header =
|
|
84
|
-
|
|
63
|
+
const Header = ({
|
|
64
|
+
id,
|
|
85
65
|
action,
|
|
86
|
-
|
|
87
|
-
testId,
|
|
66
|
+
as = 'h5',
|
|
88
67
|
title,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const levelTypography = level === 'section' ? typography.Typography.TITLE_SUBSECTION : typography.Typography.TITLE_GROUP;
|
|
94
|
-
const headerClasses = clsx.clsx('np-header', className, {
|
|
95
|
-
'np-header--section': level === 'section',
|
|
96
|
-
'np-header__title': !action || as === 'legend'
|
|
97
|
-
});
|
|
98
|
-
const commonProps = {
|
|
99
|
-
className: headerClasses,
|
|
100
|
-
'data-testid': testId
|
|
101
|
-
};
|
|
102
|
-
React.useEffect(() => {
|
|
103
|
-
if (as === 'legend' && internalRef.current) {
|
|
104
|
-
const {
|
|
105
|
-
parentElement
|
|
106
|
-
} = internalRef.current;
|
|
107
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
108
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}, [as]);
|
|
112
|
-
if (!action || as === 'legend') {
|
|
68
|
+
className,
|
|
69
|
+
role = undefined
|
|
70
|
+
}) => {
|
|
71
|
+
if (!action) {
|
|
113
72
|
return /*#__PURE__*/jsxRuntime.jsx(Title.default, {
|
|
114
|
-
ref: internalRef,
|
|
115
73
|
as: as,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
74
|
+
id: id,
|
|
75
|
+
role: role,
|
|
76
|
+
type: typography.Typography.TITLE_GROUP,
|
|
77
|
+
className: clsx.clsx('np-header', 'np-header__title', className),
|
|
119
78
|
children: title
|
|
120
79
|
});
|
|
121
80
|
}
|
|
122
|
-
|
|
81
|
+
if (as === 'legend') {
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
84
|
+
}
|
|
123
85
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
124
|
-
|
|
125
|
-
...props,
|
|
126
|
-
ref: ref,
|
|
86
|
+
className: clsx.clsx('np-header', className),
|
|
127
87
|
children: [/*#__PURE__*/jsxRuntime.jsx(Title.default, {
|
|
128
88
|
as: as,
|
|
129
|
-
type:
|
|
89
|
+
type: typography.Typography.TITLE_GROUP,
|
|
90
|
+
id: id,
|
|
130
91
|
className: "np-header__title",
|
|
131
92
|
children: title
|
|
132
93
|
}), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
|
|
133
|
-
ref: actionRef,
|
|
134
94
|
action: action
|
|
135
95
|
})]
|
|
136
96
|
});
|
|
137
|
-
}
|
|
138
|
-
Header.displayName = 'Header';
|
|
97
|
+
};
|
|
139
98
|
|
|
99
|
+
exports.Header = Header;
|
|
140
100
|
exports.default = Header;
|
|
141
101
|
//# sourceMappingURL=Header.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.js","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\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';\nimport { HTMLAttributes } from 'react';\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' | 'header';\n title: string;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'id'>;\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 = ({\n id,\n action,\n as = 'h5',\n title,\n className,\n role = undefined,\n}: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n id={id}\n role={role}\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} id={id} 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","id","as","title","role","undefined","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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,YAAI,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,uBAAM,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;EACrBC,EAAE;EACFd,MAAM;AACNe,EAAAA,EAAE,GAAG,IAAI;EACTC,KAAK;EACLN,SAAS;AACTO,EAAAA,IAAI,GAAGC,SAAAA;AACK,CAAA,KAAI;EAChB,IAAI,CAAClB,MAAM,EAAE;IACX,oBACEE,cAAA,CAACiB,aAAK,EAAA;AACJJ,MAAAA,EAAE,EAAEA,EAAG;AACPD,MAAAA,EAAE,EAAEA,EAAG;AACPG,MAAAA,IAAI,EAAEA,IAAK;MACXG,IAAI,EAAEC,qBAAU,CAACC,WAAY;MAC7BZ,SAAS,EAAEa,SAAI,CAAC,WAAW,EAAE,kBAAkB,EAAEb,SAAS,CAAE;AAAAH,MAAAA,QAAA,EAE3DS,KAAAA;AAAK,KACD,CAAC,CAAA;AAEZ,GAAA;EAEA,IAAID,EAAE,KAAK,QAAQ,EAAE;AACnB;AACAS,IAAAA,OAAO,CAACC,IAAI,CACV,oGAAoG,CACrG,CAAA;AACH,GAAA;AAEA,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AAAKhB,IAAAA,SAAS,EAAEa,SAAI,CAAC,WAAW,EAAEb,SAAS,CAAE;IAAAH,QAAA,EAAA,cAC3CL,cAAA,CAACiB,aAAK,EAAA;AAACJ,MAAAA,EAAE,EAAEA,EAAG;MAACK,IAAI,EAAEC,qBAAU,CAACC,WAAY;AAACR,MAAAA,EAAE,EAAEA,EAAG;AAACJ,MAAAA,SAAS,EAAC,kBAAkB;AAAAH,MAAAA,QAAA,EAC9ES,KAAAA;AAAK,KACD,CACP,eAAAd,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,4 +1,5 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
+
import Button from '../button/Button.resolver.mjs';
|
|
2
3
|
import '../common/theme.mjs';
|
|
3
4
|
import '../common/direction.mjs';
|
|
4
5
|
import '../common/propsValues/control.mjs';
|
|
@@ -19,115 +20,77 @@ import '../common/propsValues/scroll.mjs';
|
|
|
19
20
|
import '../common/propsValues/markdownNodeType.mjs';
|
|
20
21
|
import '../common/fileType.mjs';
|
|
21
22
|
import '@transferwise/icons';
|
|
22
|
-
import
|
|
23
|
+
import 'react';
|
|
23
24
|
import 'react-intl';
|
|
24
25
|
import '../common/closeButton/CloseButton.messages.mjs';
|
|
25
26
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
26
27
|
import Link from '../link/Link.mjs';
|
|
27
|
-
import Button from '../button/Button.resolver.mjs';
|
|
28
28
|
import Title from '../title/Title.mjs';
|
|
29
29
|
|
|
30
|
-
const HeaderAction =
|
|
30
|
+
const HeaderAction = ({
|
|
31
31
|
action
|
|
32
|
-
}
|
|
33
|
-
const {
|
|
34
|
-
'aria-label':
|
|
35
|
-
|
|
36
|
-
onClick
|
|
37
|
-
} = action;
|
|
32
|
+
}) => {
|
|
33
|
+
const props = {
|
|
34
|
+
'aria-label': action['aria-label']
|
|
35
|
+
};
|
|
38
36
|
if ('href' in action) {
|
|
39
|
-
const {
|
|
40
|
-
href,
|
|
41
|
-
target,
|
|
42
|
-
onClick: linkOnClick
|
|
43
|
-
} = action;
|
|
44
37
|
return /*#__PURE__*/jsx(Link, {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
children: text
|
|
38
|
+
href: action.href,
|
|
39
|
+
target: action.target,
|
|
40
|
+
onClick: action.onClick,
|
|
41
|
+
...props,
|
|
42
|
+
children: action.text
|
|
51
43
|
});
|
|
52
44
|
}
|
|
53
45
|
return /*#__PURE__*/jsx(Button, {
|
|
54
|
-
ref: ref,
|
|
55
46
|
className: "np-header__button",
|
|
56
47
|
priority: "tertiary",
|
|
57
48
|
size: "sm",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
children: text
|
|
49
|
+
onClick: action.onClick,
|
|
50
|
+
...props,
|
|
51
|
+
children: action.text
|
|
61
52
|
});
|
|
62
|
-
}
|
|
63
|
-
HeaderAction.displayName = 'HeaderAction';
|
|
53
|
+
};
|
|
64
54
|
/**
|
|
65
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
66
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
67
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
68
|
-
* @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.
|
|
69
|
-
* @param {string} [className]
|
|
70
|
-
* @param {string} [testId]
|
|
71
55
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
56
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
57
|
+
*
|
|
74
58
|
*/
|
|
75
|
-
const Header =
|
|
76
|
-
|
|
59
|
+
const Header = ({
|
|
60
|
+
id,
|
|
77
61
|
action,
|
|
78
|
-
|
|
79
|
-
testId,
|
|
62
|
+
as = 'h5',
|
|
80
63
|
title,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const levelTypography = level === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;
|
|
86
|
-
const headerClasses = clsx('np-header', className, {
|
|
87
|
-
'np-header--section': level === 'section',
|
|
88
|
-
'np-header__title': !action || as === 'legend'
|
|
89
|
-
});
|
|
90
|
-
const commonProps = {
|
|
91
|
-
className: headerClasses,
|
|
92
|
-
'data-testid': testId
|
|
93
|
-
};
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
if (as === 'legend' && internalRef.current) {
|
|
96
|
-
const {
|
|
97
|
-
parentElement
|
|
98
|
-
} = internalRef.current;
|
|
99
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
100
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}, [as]);
|
|
104
|
-
if (!action || as === 'legend') {
|
|
64
|
+
className,
|
|
65
|
+
role = undefined
|
|
66
|
+
}) => {
|
|
67
|
+
if (!action) {
|
|
105
68
|
return /*#__PURE__*/jsx(Title, {
|
|
106
|
-
ref: internalRef,
|
|
107
69
|
as: as,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
70
|
+
id: id,
|
|
71
|
+
role: role,
|
|
72
|
+
type: Typography.TITLE_GROUP,
|
|
73
|
+
className: clsx('np-header', 'np-header__title', className),
|
|
111
74
|
children: title
|
|
112
75
|
});
|
|
113
76
|
}
|
|
114
|
-
|
|
77
|
+
if (as === 'legend') {
|
|
78
|
+
// eslint-disable-next-line no-console
|
|
79
|
+
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
80
|
+
}
|
|
115
81
|
return /*#__PURE__*/jsxs("div", {
|
|
116
|
-
|
|
117
|
-
...props,
|
|
118
|
-
ref: ref,
|
|
82
|
+
className: clsx('np-header', className),
|
|
119
83
|
children: [/*#__PURE__*/jsx(Title, {
|
|
120
84
|
as: as,
|
|
121
|
-
type:
|
|
85
|
+
type: Typography.TITLE_GROUP,
|
|
86
|
+
id: id,
|
|
122
87
|
className: "np-header__title",
|
|
123
88
|
children: title
|
|
124
89
|
}), /*#__PURE__*/jsx(HeaderAction, {
|
|
125
|
-
ref: actionRef,
|
|
126
90
|
action: action
|
|
127
91
|
})]
|
|
128
92
|
});
|
|
129
|
-
}
|
|
130
|
-
Header.displayName = 'Header';
|
|
93
|
+
};
|
|
131
94
|
|
|
132
|
-
export { Header as default };
|
|
95
|
+
export { Header, Header as default };
|
|
133
96
|
//# sourceMappingURL=Header.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.mjs","sources":["../../src/header/Header.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\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';\nimport { HTMLAttributes } from 'react';\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' | 'header';\n title: string;\n} & Pick<HTMLAttributes<HTMLDivElement>, 'role' | 'id'>;\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 = ({\n id,\n action,\n as = 'h5',\n title,\n className,\n role = undefined,\n}: HeaderProps) => {\n if (!action) {\n return (\n <Title\n as={as}\n id={id}\n role={role}\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} id={id} 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","id","as","title","role","undefined","Title","type","Typography","TITLE_GROUP","clsx","console","warn","_jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,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;EACrBC,EAAE;EACFd,MAAM;AACNe,EAAAA,EAAE,GAAG,IAAI;EACTC,KAAK;EACLN,SAAS;AACTO,EAAAA,IAAI,GAAGC,SAAAA;AACK,CAAA,KAAI;EAChB,IAAI,CAAClB,MAAM,EAAE;IACX,oBACEE,GAAA,CAACiB,KAAK,EAAA;AACJJ,MAAAA,EAAE,EAAEA,EAAG;AACPD,MAAAA,EAAE,EAAEA,EAAG;AACPG,MAAAA,IAAI,EAAEA,IAAK;MACXG,IAAI,EAAEC,UAAU,CAACC,WAAY;MAC7BZ,SAAS,EAAEa,IAAI,CAAC,WAAW,EAAE,kBAAkB,EAAEb,SAAS,CAAE;AAAAH,MAAAA,QAAA,EAE3DS,KAAAA;AAAK,KACD,CAAC,CAAA;AAEZ,GAAA;EAEA,IAAID,EAAE,KAAK,QAAQ,EAAE;AACnB;AACAS,IAAAA,OAAO,CAACC,IAAI,CACV,oGAAoG,CACrG,CAAA;AACH,GAAA;AAEA,EAAA,oBACEC,IAAA,CAAA,KAAA,EAAA;AAAKhB,IAAAA,SAAS,EAAEa,IAAI,CAAC,WAAW,EAAEb,SAAS,CAAE;IAAAH,QAAA,EAAA,cAC3CL,GAAA,CAACiB,KAAK,EAAA;AAACJ,MAAAA,EAAE,EAAEA,EAAG;MAACK,IAAI,EAAEC,UAAU,CAACC,WAAY;AAACR,MAAAA,EAAE,EAAEA,EAAG;AAACJ,MAAAA,SAAS,EAAC,kBAAkB;AAAAH,MAAAA,QAAA,EAC9ES,KAAAA;AAAK,KACD,CACP,eAAAd,GAAA,CAACH,YAAY,EAAA;AAACC,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/B,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
|
package/build/index.js
CHANGED
|
@@ -201,7 +201,7 @@ exports.DropFade = DropFade.default;
|
|
|
201
201
|
exports.Emphasis = Emphasis.default;
|
|
202
202
|
exports.Field = Field.Field;
|
|
203
203
|
exports.FlowNavigation = FlowNavigation.default;
|
|
204
|
-
exports.Header = Header.
|
|
204
|
+
exports.Header = Header.Header;
|
|
205
205
|
Object.defineProperty(exports, "InfoPresentation", {
|
|
206
206
|
enumerable: true,
|
|
207
207
|
get: function () { return infoPresentations.InfoPresentation; }
|
package/build/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export { default as DropFade } from './dropFade/DropFade.mjs';
|
|
|
46
46
|
export { default as Emphasis } from './emphasis/Emphasis.mjs';
|
|
47
47
|
export { Field } from './field/Field.mjs';
|
|
48
48
|
export { default as FlowNavigation } from './flowNavigation/FlowNavigation.mjs';
|
|
49
|
-
export {
|
|
49
|
+
export { Header } from './header/Header.mjs';
|
|
50
50
|
export { InfoPresentation } from './info/infoPresentations.mjs';
|
|
51
51
|
export { default as Info } from './info/Info.mjs';
|
|
52
52
|
export { default as InlineAlert } from './inlineAlert/InlineAlert.mjs';
|
|
@@ -603,7 +603,7 @@ function SelectInputGroupItemView({
|
|
|
603
603
|
needle
|
|
604
604
|
}) {
|
|
605
605
|
const headerId = React.useId();
|
|
606
|
-
const header = /*#__PURE__*/jsxRuntime.jsx(Header.
|
|
606
|
+
const header = /*#__PURE__*/jsxRuntime.jsx(Header.Header, {
|
|
607
607
|
as: "header",
|
|
608
608
|
role: "none",
|
|
609
609
|
id: headerId,
|