@transferwise/components 0.0.0-experimental-b2dc1ea → 0.0.0-experimental-1fd4714
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 +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 +1 -1
- package/build/index.mjs +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 +0 -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/header/Header.css +0 -3
- package/build/styles/main.css +0 -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/typeahead/Typeahead.js +1 -1
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +1 -1
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/typeahead/typeaheadOption/TypeaheadOption.js +6 -4
- package/build/typeahead/typeaheadOption/TypeaheadOption.js.map +1 -1
- package/build/typeahead/typeaheadOption/TypeaheadOption.mjs +7 -5
- package/build/typeahead/typeaheadOption/TypeaheadOption.mjs.map +1 -1
- package/build/typeahead/util/highlight.js +8 -3
- package/build/typeahead/util/highlight.js.map +1 -1
- package/build/typeahead/util/highlight.mjs +9 -4
- package/build/typeahead/util/highlight.mjs.map +1 -1
- 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 +0 -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/build/types/typeahead/typeaheadOption/TypeaheadOption.d.ts.map +1 -1
- package/build/types/typeahead/util/highlight.d.ts +5 -1
- package/build/types/typeahead/util/highlight.d.ts.map +1 -1
- package/package.json +1 -1
- 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 +0 -1
- package/src/link/Link.tsx +27 -29
- package/src/main.css +0 -3
- package/src/title/Title.tsx +11 -25
- package/src/typeahead/Typeahead.rtl.spec.tsx +26 -0
- package/src/typeahead/Typeahead.tsx +2 -2
- package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +5 -4
- package/src/typeahead/typeaheadOption/TypeaheadOption.tsx +7 -3
- package/src/typeahead/util/highlight.spec.js +5 -5
- package/src/typeahead/util/highlight.tsx +11 -3
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,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,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
|
@@ -176,7 +176,7 @@ exports.DropFade = DropFade;
|
|
|
176
176
|
exports.Emphasis = Emphasis;
|
|
177
177
|
exports.Field = Field.Field;
|
|
178
178
|
exports.FlowNavigation = FlowNavigation;
|
|
179
|
-
exports.Header = Header;
|
|
179
|
+
exports.Header = Header.Header;
|
|
180
180
|
exports.Image = Image.default;
|
|
181
181
|
Object.defineProperty(exports, "InfoPresentation", {
|
|
182
182
|
enumerable: true,
|
package/build/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ export { default as DropFade } from './dropFade/DropFade.mjs';
|
|
|
33
33
|
export { default as Emphasis } from './emphasis/Emphasis.mjs';
|
|
34
34
|
export { Field } from './field/Field.mjs';
|
|
35
35
|
export { default as FlowNavigation } from './flowNavigation/FlowNavigation.mjs';
|
|
36
|
-
export {
|
|
36
|
+
export { Header } from './header/Header.mjs';
|
|
37
37
|
export { default as Image } from './image/Image.mjs';
|
|
38
38
|
export { InfoPresentation } from './info/infoPresentations.mjs';
|
|
39
39
|
export { default as Info } from './info/Info.mjs';
|
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;;;;"}
|
package/build/link/Link.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { NavigateAway } from '@transferwise/icons';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import { forwardRef } from 'react';
|
|
4
3
|
import { useIntl } from 'react-intl';
|
|
5
4
|
import messages from './Link.messages.mjs';
|
|
6
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
6
|
|
|
8
|
-
const Link =
|
|
7
|
+
const Link = ({
|
|
9
8
|
className,
|
|
10
9
|
children,
|
|
11
10
|
href,
|
|
@@ -14,13 +13,12 @@ const Link = /*#__PURE__*/forwardRef(({
|
|
|
14
13
|
'aria-label': ariaLabel,
|
|
15
14
|
onClick,
|
|
16
15
|
...props
|
|
17
|
-
}
|
|
16
|
+
}) => {
|
|
18
17
|
const isBlank = target === '_blank';
|
|
19
18
|
const {
|
|
20
19
|
formatMessage
|
|
21
20
|
} = useIntl();
|
|
22
21
|
return /*#__PURE__*/jsxs("a", {
|
|
23
|
-
ref: ref,
|
|
24
22
|
href: href,
|
|
25
23
|
target: target,
|
|
26
24
|
className: clsx('np-link', type ? `np-text-${type}` : undefined, 'd-inline-flex', className),
|
|
@@ -32,7 +30,7 @@ const Link = /*#__PURE__*/forwardRef(({
|
|
|
32
30
|
title: formatMessage(messages.opensInNewTab)
|
|
33
31
|
})]
|
|
34
32
|
});
|
|
35
|
-
}
|
|
33
|
+
};
|
|
36
34
|
|
|
37
35
|
export { Link as default };
|
|
38
36
|
//# sourceMappingURL=Link.mjs.map
|
package/build/link/Link.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.mjs","sources":["../../src/link/Link.tsx"],"sourcesContent":["import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';\nimport { clsx } from 'clsx';\nimport { AnchorHTMLAttributes
|
|
1
|
+
{"version":3,"file":"Link.mjs","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,OAAO,EAAE,CAAA;AAEnC,EAAA,oBACEC,IAAA,CAAA,GAAA,EAAA;AACET,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,SAAS,EAAEY,IAAI,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,GAAA,CAACC,YAAgB,EAAA;AAACC,MAAAA,KAAK,EAAER,aAAa,CAACS,QAAQ,CAACC,aAAa,CAAA;AAAE,MAAG,CAAA;AAAA,GACxF,CAAC,CAAA;AAER;;;;"}
|
package/build/main.css
CHANGED
|
@@ -2242,9 +2242,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
2242
2242
|
-moz-column-gap: var(--size-24);
|
|
2243
2243
|
column-gap: var(--size-24);
|
|
2244
2244
|
}
|
|
2245
|
-
.np-header--section {
|
|
2246
|
-
border-bottom: none;
|
|
2247
|
-
}
|
|
2248
2245
|
.np-header__title {
|
|
2249
2246
|
color: #5d7079;
|
|
2250
2247
|
color: var(--color-content-secondary);
|
|
@@ -52,7 +52,7 @@ function SelectOption({
|
|
|
52
52
|
className: clsx.clsx({
|
|
53
53
|
'p-x-2 p-y-1': isLargeScreen
|
|
54
54
|
}),
|
|
55
|
-
children: [optionsSection.title && /*#__PURE__*/jsxRuntime.jsx(Header, {
|
|
55
|
+
children: [optionsSection.title && /*#__PURE__*/jsxRuntime.jsx(Header.Header, {
|
|
56
56
|
title: optionsSection.title
|
|
57
57
|
}), /*#__PURE__*/jsxRuntime.jsx(NavigationOptionsList, {
|
|
58
58
|
children: optionsSection.options.map((option, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectOption.js","sources":["../../src/selectOption/SelectOption.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { ActionButtonProps } from '../actionButton';\nimport { clsx } from 'clsx';\nimport Option from '../common/Option';\nimport type { OptionProps } from '../common/Option/Option';\nimport { Breakpoint, Position } from '../common';\nimport Section from '../section';\nimport Header from '../header';\nimport { HeaderProps } from '../header/Header';\nimport NavigationOption from '../navigationOption';\nimport NavigationOptionsList from '../navigationOptionsList';\nimport { useInputAttributes } from '../inputs/contexts';\nimport messages from './SelectOption.messages';\nimport { useIntl } from 'react-intl';\nimport ResponsivePanel from '../common/responsivePanel';\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport { ChevronDown, Plus } from '@transferwise/icons';\n\nexport type SelectOptiopsSection<T = unknown> = {\n title?: HeaderProps['title'];\n options: SelectOptionValue<T>[];\n};\n\nexport type SelectOptionValue<T = unknown> = Pick<\n OptionProps,\n 'media' | 'title' | 'content' | 'disabled'\n> & {\n value?: T;\n};\n\nexport type SelectOptionPlaceholder = Pick<OptionProps, 'media' | 'title' | 'content'> & {\n actionLabel?: ActionButtonProps['children'];\n};\n\nexport type SelectOptionProps<T = unknown> = {\n onChange: (selected: SelectOptionValue<T>) => void;\n selected?: SelectOptionValue<T>;\n options: SelectOptiopsSection<T>[];\n placeholder: SelectOptionPlaceholder;\n} & Omit<\n OptionProps,\n 'as' | 'title' | 'media' | 'content' | 'onClick' | 'onChange' | 'showMediaAtAllSizes' | 'decision'\n>;\n\nexport default function SelectOption<T>({\n selected = undefined,\n options,\n onChange,\n placeholder,\n disabled,\n ...props\n}: SelectOptionProps<T>) {\n const intl = useIntl();\n const rootRef = useRef(null);\n const [showOptions, setShowOptions] = useState(false);\n\n const hasSelected = selected !== undefined;\n const isLargeScreen = useScreenSize(Breakpoint.SMALL);\n\n const inputAttributes = useInputAttributes();\n const ariaLabelledBy = props['aria-labelledby'] ?? inputAttributes?.['aria-labelledby'];\n\n function handleOnClick(showOptionsStatus: boolean) {\n return () => {\n setShowOptions(showOptionsStatus);\n };\n }\n\n function handleOnChange(data: SelectOptionValue<T>) {\n return () => {\n setShowOptions(false);\n onChange(data);\n };\n }\n\n function getOptions(isLargeScreen = false) {\n return (\n <div className={clsx({ 'np-select-option-list': isLargeScreen })}>\n {options.map((optionsSection, index) => (\n <Section key={index} className={clsx({ 'p-x-2 p-y-1': isLargeScreen })}>\n {optionsSection.title && <Header title={optionsSection.title} />}\n <NavigationOptionsList>\n {optionsSection.options.map((option, index) => {\n return (\n <NavigationOption\n key={index}\n isContainerAligned={!isLargeScreen}\n showMediaCircle\n showMediaAtAllSizes\n onClick={handleOnChange(option)}\n {...option}\n />\n );\n })}\n </NavigationOptionsList>\n </Section>\n ))}\n </div>\n );\n }\n\n return (\n <>\n <Option\n ref={rootRef}\n as=\"div\"\n showMediaAtAllSizes\n disabled={disabled}\n decision={false}\n media={hasSelected ? selected.media : (placeholder.media ?? <Plus size={24} />)}\n title={(hasSelected ? selected : placeholder).title}\n content={(hasSelected ? selected : placeholder).content}\n className={clsx(\n 'np-select-option',\n 'clickable',\n hasSelected ? 'np-select-option-selected' : 'np-select-option-placeholder',\n props.className,\n )}\n button={\n <button\n {...inputAttributes}\n type=\"button\"\n disabled={disabled}\n aria-labelledby={ariaLabelledBy}\n aria-haspopup=\"dialog\"\n aria-expanded={showOptions}\n className={hasSelected ? 'btn-unstyled' : 'np-action-btn'}\n aria-label={hasSelected ? undefined : props['aria-label']}\n onClick={handleOnClick(true)}\n >\n {hasSelected ? (\n <ChevronDown title={intl.formatMessage(messages.selectedActionLabel)} />\n ) : (\n placeholder.actionLabel || intl.formatMessage(messages.actionLabel)\n )}\n </button>\n }\n />\n <ResponsivePanel\n anchorWidth\n altAxis\n anchorRef={rootRef}\n open={showOptions}\n position={Position.BOTTOM}\n onClose={handleOnClick(false)}\n >\n {getOptions(isLargeScreen)}\n </ResponsivePanel>\n </>\n );\n}\n"],"names":["SelectOption","selected","undefined","options","onChange","placeholder","disabled","props","intl","useIntl","rootRef","useRef","showOptions","setShowOptions","useState","hasSelected","isLargeScreen","useScreenSize","Breakpoint","SMALL","inputAttributes","useInputAttributes","ariaLabelledBy","handleOnClick","showOptionsStatus","handleOnChange","data","getOptions","_jsx","className","clsx","children","map","optionsSection","index","_jsxs","Section","title","Header","NavigationOptionsList","option","NavigationOption","isContainerAligned","showMediaCircle","showMediaAtAllSizes","onClick","_Fragment","Option","ref","as","decision","media","Plus","size","content","button","type","ChevronDown","formatMessage","messages","selectedActionLabel","actionLabel","ResponsivePanel","anchorWidth","altAxis","anchorRef","open","position","Position","BOTTOM","onClose"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CwB,SAAAA,YAAYA,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AE,UAAA,aAAa,EAAEd,aAAAA;AAAe,SAAA,CAAE;AAAAe,QAAAA,QAAA,GACpEE,cAAc,CAACI,KAAK,iBAAIT,cAAA,CAACU,
|
|
1
|
+
{"version":3,"file":"SelectOption.js","sources":["../../src/selectOption/SelectOption.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport { ActionButtonProps } from '../actionButton';\nimport { clsx } from 'clsx';\nimport Option from '../common/Option';\nimport type { OptionProps } from '../common/Option/Option';\nimport { Breakpoint, Position } from '../common';\nimport Section from '../section';\nimport Header from '../header';\nimport { HeaderProps } from '../header/Header';\nimport NavigationOption from '../navigationOption';\nimport NavigationOptionsList from '../navigationOptionsList';\nimport { useInputAttributes } from '../inputs/contexts';\nimport messages from './SelectOption.messages';\nimport { useIntl } from 'react-intl';\nimport ResponsivePanel from '../common/responsivePanel';\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport { ChevronDown, Plus } from '@transferwise/icons';\n\nexport type SelectOptiopsSection<T = unknown> = {\n title?: HeaderProps['title'];\n options: SelectOptionValue<T>[];\n};\n\nexport type SelectOptionValue<T = unknown> = Pick<\n OptionProps,\n 'media' | 'title' | 'content' | 'disabled'\n> & {\n value?: T;\n};\n\nexport type SelectOptionPlaceholder = Pick<OptionProps, 'media' | 'title' | 'content'> & {\n actionLabel?: ActionButtonProps['children'];\n};\n\nexport type SelectOptionProps<T = unknown> = {\n onChange: (selected: SelectOptionValue<T>) => void;\n selected?: SelectOptionValue<T>;\n options: SelectOptiopsSection<T>[];\n placeholder: SelectOptionPlaceholder;\n} & Omit<\n OptionProps,\n 'as' | 'title' | 'media' | 'content' | 'onClick' | 'onChange' | 'showMediaAtAllSizes' | 'decision'\n>;\n\nexport default function SelectOption<T>({\n selected = undefined,\n options,\n onChange,\n placeholder,\n disabled,\n ...props\n}: SelectOptionProps<T>) {\n const intl = useIntl();\n const rootRef = useRef(null);\n const [showOptions, setShowOptions] = useState(false);\n\n const hasSelected = selected !== undefined;\n const isLargeScreen = useScreenSize(Breakpoint.SMALL);\n\n const inputAttributes = useInputAttributes();\n const ariaLabelledBy = props['aria-labelledby'] ?? inputAttributes?.['aria-labelledby'];\n\n function handleOnClick(showOptionsStatus: boolean) {\n return () => {\n setShowOptions(showOptionsStatus);\n };\n }\n\n function handleOnChange(data: SelectOptionValue<T>) {\n return () => {\n setShowOptions(false);\n onChange(data);\n };\n }\n\n function getOptions(isLargeScreen = false) {\n return (\n <div className={clsx({ 'np-select-option-list': isLargeScreen })}>\n {options.map((optionsSection, index) => (\n <Section key={index} className={clsx({ 'p-x-2 p-y-1': isLargeScreen })}>\n {optionsSection.title && <Header title={optionsSection.title} />}\n <NavigationOptionsList>\n {optionsSection.options.map((option, index) => {\n return (\n <NavigationOption\n key={index}\n isContainerAligned={!isLargeScreen}\n showMediaCircle\n showMediaAtAllSizes\n onClick={handleOnChange(option)}\n {...option}\n />\n );\n })}\n </NavigationOptionsList>\n </Section>\n ))}\n </div>\n );\n }\n\n return (\n <>\n <Option\n ref={rootRef}\n as=\"div\"\n showMediaAtAllSizes\n disabled={disabled}\n decision={false}\n media={hasSelected ? selected.media : (placeholder.media ?? <Plus size={24} />)}\n title={(hasSelected ? selected : placeholder).title}\n content={(hasSelected ? selected : placeholder).content}\n className={clsx(\n 'np-select-option',\n 'clickable',\n hasSelected ? 'np-select-option-selected' : 'np-select-option-placeholder',\n props.className,\n )}\n button={\n <button\n {...inputAttributes}\n type=\"button\"\n disabled={disabled}\n aria-labelledby={ariaLabelledBy}\n aria-haspopup=\"dialog\"\n aria-expanded={showOptions}\n className={hasSelected ? 'btn-unstyled' : 'np-action-btn'}\n aria-label={hasSelected ? undefined : props['aria-label']}\n onClick={handleOnClick(true)}\n >\n {hasSelected ? (\n <ChevronDown title={intl.formatMessage(messages.selectedActionLabel)} />\n ) : (\n placeholder.actionLabel || intl.formatMessage(messages.actionLabel)\n )}\n </button>\n }\n />\n <ResponsivePanel\n anchorWidth\n altAxis\n anchorRef={rootRef}\n open={showOptions}\n position={Position.BOTTOM}\n onClose={handleOnClick(false)}\n >\n {getOptions(isLargeScreen)}\n </ResponsivePanel>\n </>\n );\n}\n"],"names":["SelectOption","selected","undefined","options","onChange","placeholder","disabled","props","intl","useIntl","rootRef","useRef","showOptions","setShowOptions","useState","hasSelected","isLargeScreen","useScreenSize","Breakpoint","SMALL","inputAttributes","useInputAttributes","ariaLabelledBy","handleOnClick","showOptionsStatus","handleOnChange","data","getOptions","_jsx","className","clsx","children","map","optionsSection","index","_jsxs","Section","title","Header","NavigationOptionsList","option","NavigationOption","isContainerAligned","showMediaCircle","showMediaAtAllSizes","onClick","_Fragment","Option","ref","as","decision","media","Plus","size","content","button","type","ChevronDown","formatMessage","messages","selectedActionLabel","actionLabel","ResponsivePanel","anchorWidth","altAxis","anchorRef","open","position","Position","BOTTOM","onClose"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CwB,SAAAA,YAAYA,CAAI;AACtCC,EAAAA,QAAQ,GAAGC,SAAS;EACpBC,OAAO;EACPC,QAAQ;EACRC,WAAW;EACXC,QAAQ;EACR,GAAGC,KAAAA;AACkB,CAAA,EAAA;AACrB,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AACtB,EAAA,MAAMC,OAAO,GAAGC,YAAM,CAAC,IAAI,CAAC,CAAA;EAC5B,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAA;AAErD,EAAA,MAAMC,WAAW,GAAGd,QAAQ,KAAKC,SAAS,CAAA;AAC1C,EAAA,MAAMc,aAAa,GAAGC,2BAAa,CAACC,qBAAU,CAACC,KAAK,CAAC,CAAA;AAErD,EAAA,MAAMC,eAAe,GAAGC,2BAAkB,EAAE,CAAA;EAC5C,MAAMC,cAAc,GAAGf,KAAK,CAAC,iBAAiB,CAAC,IAAIa,eAAe,GAAG,iBAAiB,CAAC,CAAA;EAEvF,SAASG,aAAaA,CAACC,iBAA0B,EAAA;AAC/C,IAAA,OAAO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AE7B,IAAI,CAACkD,aAAa,CAACC,qBAAQ,CAACC,mBAAmB,CAAA;AAAE,SAAA,CAAG,GAExEvD,WAAW,CAACwD,WAAW,IAAIrD,IAAI,CAACkD,aAAa,CAACC,qBAAQ,CAACE,WAAW,CAAA;OAE9D,CAAA;AACT,KAEH,CAAA,eAAAjC,cAAA,CAACkC,eAAe,EAAA;MACdC,WAAW,EAAA,IAAA;MACXC,OAAO,EAAA,IAAA;AACPC,MAAAA,SAAS,EAAEvD,OAAQ;AACnBwD,MAAAA,IAAI,EAAEtD,WAAY;MAClBuD,QAAQ,EAAEC,iBAAQ,CAACC,MAAO;AAC1BC,MAAAA,OAAO,EAAE/C,aAAa,CAAC,KAAK,CAAE;MAAAQ,QAAA,EAE7BJ,UAAU,CAACX,aAAa,CAAA;AAAC,KACX,CACnB,CAAA;AAAA,GAAA,CAAG,CAAA;AAEP;;;;"}
|
|
@@ -2,7 +2,7 @@ import { useRef, useState } from 'react';
|
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import Option from '../common/Option/Option.mjs';
|
|
4
4
|
import Section from '../section/Section.mjs';
|
|
5
|
-
import Header from '../header/Header.mjs';
|
|
5
|
+
import { Header } from '../header/Header.mjs';
|
|
6
6
|
import NavigationOption from '../navigationOption/NavigationOption.mjs';
|
|
7
7
|
import NavigationOptionList from '../navigationOptionsList/NavigationOptionsList.mjs';
|
|
8
8
|
import { useInputAttributes } from '../inputs/contexts.mjs';
|