@transferwise/components 0.0.0-experimental-64ea603 → 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 -79
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +38 -76
- 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 -28
- 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 -28
- package/build/styles/main.css +11 -28
- 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 -28
- package/src/header/Header.less +7 -29
- package/src/header/Header.spec.tsx +50 -68
- package/src/header/Header.story.tsx +39 -184
- package/src/header/Header.tsx +69 -123
- package/src/header/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/main.css +11 -28
- 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,120 +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
|
-
onClick: linkOnClick,
|
|
59
|
-
children: text
|
|
42
|
+
href: action.href,
|
|
43
|
+
target: action.target,
|
|
44
|
+
onClick: action.onClick,
|
|
45
|
+
...props,
|
|
46
|
+
children: action.text
|
|
60
47
|
});
|
|
61
48
|
}
|
|
62
49
|
return /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
|
|
63
|
-
ref: ref,
|
|
64
50
|
className: "np-header__button",
|
|
65
51
|
priority: "tertiary",
|
|
66
52
|
size: "sm",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
children: text
|
|
53
|
+
onClick: action.onClick,
|
|
54
|
+
...props,
|
|
55
|
+
children: action.text
|
|
70
56
|
});
|
|
71
|
-
}
|
|
72
|
-
HeaderAction.displayName = 'HeaderAction';
|
|
57
|
+
};
|
|
73
58
|
/**
|
|
74
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
75
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
76
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
77
|
-
* @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.
|
|
78
|
-
* @param {string} [className]
|
|
79
|
-
* @param {string} [testId]
|
|
80
59
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
60
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
61
|
+
*
|
|
83
62
|
*/
|
|
84
|
-
const Header =
|
|
85
|
-
|
|
63
|
+
const Header = ({
|
|
64
|
+
id,
|
|
86
65
|
action,
|
|
87
|
-
|
|
88
|
-
testId,
|
|
66
|
+
as = 'h5',
|
|
89
67
|
title,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const levelTypography = level === 'section' ? typography.Typography.TITLE_SUBSECTION : typography.Typography.TITLE_GROUP;
|
|
95
|
-
const headerClasses = clsx.clsx('np-header', className, {
|
|
96
|
-
'np-header--section': level === 'section',
|
|
97
|
-
'np-header__title': !action || as === 'legend'
|
|
98
|
-
});
|
|
99
|
-
const commonProps = {
|
|
100
|
-
className: headerClasses,
|
|
101
|
-
'data-testid': testId
|
|
102
|
-
};
|
|
103
|
-
React.useEffect(() => {
|
|
104
|
-
if (as === 'legend' && internalRef.current) {
|
|
105
|
-
const {
|
|
106
|
-
parentElement
|
|
107
|
-
} = internalRef.current;
|
|
108
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
109
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, [as]);
|
|
113
|
-
if (!action || as === 'legend') {
|
|
68
|
+
className,
|
|
69
|
+
role = undefined
|
|
70
|
+
}) => {
|
|
71
|
+
if (!action) {
|
|
114
72
|
return /*#__PURE__*/jsxRuntime.jsx(Title.default, {
|
|
115
|
-
ref: internalRef,
|
|
116
73
|
as: as,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
74
|
+
id: id,
|
|
75
|
+
role: role,
|
|
76
|
+
type: typography.Typography.TITLE_GROUP,
|
|
77
|
+
className: clsx.clsx('np-header', 'np-header__title', className),
|
|
120
78
|
children: title
|
|
121
79
|
});
|
|
122
80
|
}
|
|
123
|
-
|
|
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
|
+
}
|
|
124
85
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
125
|
-
|
|
126
|
-
...props,
|
|
127
|
-
ref: ref,
|
|
86
|
+
className: clsx.clsx('np-header', className),
|
|
128
87
|
children: [/*#__PURE__*/jsxRuntime.jsx(Title.default, {
|
|
129
88
|
as: as,
|
|
130
|
-
type:
|
|
89
|
+
type: typography.Typography.TITLE_GROUP,
|
|
90
|
+
id: id,
|
|
131
91
|
className: "np-header__title",
|
|
132
92
|
children: title
|
|
133
93
|
}), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
|
|
134
|
-
ref: actionRef,
|
|
135
94
|
action: action
|
|
136
95
|
})]
|
|
137
96
|
});
|
|
138
|
-
}
|
|
139
|
-
Header.displayName = 'Header';
|
|
97
|
+
};
|
|
140
98
|
|
|
99
|
+
exports.Header = Header;
|
|
141
100
|
exports.default = Header;
|
|
142
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,116 +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
|
-
onClick: linkOnClick,
|
|
51
|
-
children: text
|
|
38
|
+
href: action.href,
|
|
39
|
+
target: action.target,
|
|
40
|
+
onClick: action.onClick,
|
|
41
|
+
...props,
|
|
42
|
+
children: action.text
|
|
52
43
|
});
|
|
53
44
|
}
|
|
54
45
|
return /*#__PURE__*/jsx(Button, {
|
|
55
|
-
ref: ref,
|
|
56
46
|
className: "np-header__button",
|
|
57
47
|
priority: "tertiary",
|
|
58
48
|
size: "sm",
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
children: text
|
|
49
|
+
onClick: action.onClick,
|
|
50
|
+
...props,
|
|
51
|
+
children: action.text
|
|
62
52
|
});
|
|
63
|
-
}
|
|
64
|
-
HeaderAction.displayName = 'HeaderAction';
|
|
53
|
+
};
|
|
65
54
|
/**
|
|
66
|
-
* @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.
|
|
67
|
-
* @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.
|
|
68
|
-
* @param {string} title - Required prop to set the title of the section header.
|
|
69
|
-
* @param {'group' | 'section'} [level='group'] - Optional prop to specify the level of the section header.
|
|
70
|
-
* @param {string} [className]
|
|
71
|
-
* @param {string} [testId]
|
|
72
55
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
56
|
+
* Neptune Web: https://transferwise.github.io/neptune-web/components/content/Header
|
|
57
|
+
*
|
|
75
58
|
*/
|
|
76
|
-
const Header =
|
|
77
|
-
|
|
59
|
+
const Header = ({
|
|
60
|
+
id,
|
|
78
61
|
action,
|
|
79
|
-
|
|
80
|
-
testId,
|
|
62
|
+
as = 'h5',
|
|
81
63
|
title,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const levelTypography = level === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;
|
|
87
|
-
const headerClasses = clsx('np-header', className, {
|
|
88
|
-
'np-header--section': level === 'section',
|
|
89
|
-
'np-header__title': !action || as === 'legend'
|
|
90
|
-
});
|
|
91
|
-
const commonProps = {
|
|
92
|
-
className: headerClasses,
|
|
93
|
-
'data-testid': testId
|
|
94
|
-
};
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
if (as === 'legend' && internalRef.current) {
|
|
97
|
-
const {
|
|
98
|
-
parentElement
|
|
99
|
-
} = internalRef.current;
|
|
100
|
-
if (!parentElement || parentElement.tagName.toLowerCase() !== 'fieldset') {
|
|
101
|
-
console.warn('Legends should be the first child in a fieldset, and this is not possible when including an action');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}, [as]);
|
|
105
|
-
if (!action || as === 'legend') {
|
|
64
|
+
className,
|
|
65
|
+
role = undefined
|
|
66
|
+
}) => {
|
|
67
|
+
if (!action) {
|
|
106
68
|
return /*#__PURE__*/jsx(Title, {
|
|
107
|
-
ref: internalRef,
|
|
108
69
|
as: as,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
id: id,
|
|
71
|
+
role: role,
|
|
72
|
+
type: Typography.TITLE_GROUP,
|
|
73
|
+
className: clsx('np-header', 'np-header__title', className),
|
|
112
74
|
children: title
|
|
113
75
|
});
|
|
114
76
|
}
|
|
115
|
-
|
|
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
|
+
}
|
|
116
81
|
return /*#__PURE__*/jsxs("div", {
|
|
117
|
-
|
|
118
|
-
...props,
|
|
119
|
-
ref: ref,
|
|
82
|
+
className: clsx('np-header', className),
|
|
120
83
|
children: [/*#__PURE__*/jsx(Title, {
|
|
121
84
|
as: as,
|
|
122
|
-
type:
|
|
85
|
+
type: Typography.TITLE_GROUP,
|
|
86
|
+
id: id,
|
|
123
87
|
className: "np-header__title",
|
|
124
88
|
children: title
|
|
125
89
|
}), /*#__PURE__*/jsx(HeaderAction, {
|
|
126
|
-
ref: actionRef,
|
|
127
90
|
action: action
|
|
128
91
|
})]
|
|
129
92
|
});
|
|
130
|
-
}
|
|
131
|
-
Header.displayName = 'Header';
|
|
93
|
+
};
|
|
132
94
|
|
|
133
|
-
export { Header as default };
|
|
95
|
+
export { Header, Header as default };
|
|
134
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,
|