@transferwise/components 0.0.0-experimental-fb37b6d → 0.0.0-experimental-ad7e2f8

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.
Files changed (43) hide show
  1. package/build/header/Header.js +34 -77
  2. package/build/header/Header.js.map +1 -1
  3. package/build/header/Header.mjs +31 -73
  4. package/build/header/Header.mjs.map +1 -1
  5. package/build/index.js +1 -1
  6. package/build/index.mjs +1 -1
  7. package/build/link/Link.js +3 -5
  8. package/build/link/Link.js.map +1 -1
  9. package/build/link/Link.mjs +3 -5
  10. package/build/link/Link.mjs.map +1 -1
  11. package/build/main.css +0 -3
  12. package/build/selectOption/SelectOption.js +1 -1
  13. package/build/selectOption/SelectOption.js.map +1 -1
  14. package/build/selectOption/SelectOption.mjs +1 -1
  15. package/build/styles/header/Header.css +0 -3
  16. package/build/styles/main.css +0 -3
  17. package/build/typeahead/util/highlight.js +4 -2
  18. package/build/typeahead/util/highlight.js.map +1 -1
  19. package/build/typeahead/util/highlight.mjs +5 -3
  20. package/build/typeahead/util/highlight.mjs.map +1 -1
  21. package/build/types/header/Header.d.ts +10 -43
  22. package/build/types/header/Header.d.ts.map +1 -1
  23. package/build/types/header/index.d.ts +0 -1
  24. package/build/types/header/index.d.ts.map +1 -1
  25. package/build/types/index.d.ts +0 -1
  26. package/build/types/index.d.ts.map +1 -1
  27. package/build/types/link/Link.d.ts +1 -3
  28. package/build/types/link/Link.d.ts.map +1 -1
  29. package/build/types/typeahead/util/highlight.d.ts +1 -1
  30. package/build/types/typeahead/util/highlight.d.ts.map +1 -1
  31. package/package.json +3 -3
  32. package/src/header/Header.css +0 -3
  33. package/src/header/Header.less +0 -4
  34. package/src/header/Header.spec.tsx +0 -7
  35. package/src/header/Header.story.tsx +40 -62
  36. package/src/header/Header.tsx +59 -123
  37. package/src/header/index.ts +0 -1
  38. package/src/index.ts +0 -1
  39. package/src/link/Link.tsx +27 -29
  40. package/src/main.css +0 -3
  41. package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +1 -1
  42. package/src/typeahead/util/highlight.spec.js +1 -1
  43. package/src/typeahead/util/highlight.tsx +3 -3
@@ -1,117 +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
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
-
13
- var React__default = /*#__PURE__*/_interopDefault(React);
14
-
15
- const HeaderAction = /*#__PURE__*/React__default.default.forwardRef(({
12
+ const HeaderAction = ({
16
13
  action
17
- }, ref) => {
18
- const {
19
- 'aria-label': ariaLabel,
20
- text,
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
- ref: ref,
31
- href: href,
32
- target: target,
33
- "aria-label": ariaLabel,
34
- onClick: linkOnClick,
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
- "aria-label": ariaLabel,
44
- onClick: onClick,
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
- * @component
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 = /*#__PURE__*/React__default.default.forwardRef(({
73
- as = 'h5',
41
+ const Header = ({
74
42
  action,
75
- className,
76
- testId,
43
+ as = 'h5',
77
44
  title,
78
- variant = 'group',
79
- ...props
80
- }, ref) => {
81
- const variantClass = variant && variant !== 'group' ? `np-header--${variant}` : '';
82
- const variantTypography = variant === 'section' ? typography.Typography.TITLE_SUBSECTION : typography.Typography.TITLE_GROUP;
83
- const HeaderClasses = clsx.clsx('np-header', variantClass, className, {
84
- 'np-header__title': !action || as === 'legend'
85
- });
86
- const commonProps = {
87
- className: HeaderClasses,
88
- 'data-testid': testId
89
- };
90
- if (!action || as === 'legend') {
45
+ className
46
+ }) => {
47
+ if (!action) {
91
48
  return /*#__PURE__*/jsxRuntime.jsx(Title, {
92
49
  as: as,
93
- type: variantTypography,
94
- ...commonProps,
95
- ...props,
50
+ type: typography.Typography.TITLE_GROUP,
51
+ className: clsx.clsx('np-header', 'np-header__title', className),
96
52
  children: title
97
53
  });
98
54
  }
99
- const actionRef = /*#__PURE__*/React__default.default.createRef();
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
+ }
100
59
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
101
- ...commonProps,
102
- ...props,
103
- ref: ref,
60
+ className: clsx.clsx('np-header', className),
104
61
  children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
105
62
  as: as,
106
- type: variantTypography,
63
+ type: typography.Typography.TITLE_GROUP,
107
64
  className: "np-header__title",
108
65
  children: title
109
66
  }), /*#__PURE__*/jsxRuntime.jsx(HeaderAction, {
110
- ref: actionRef,
111
67
  action: action
112
68
  })]
113
69
  });
114
- });
70
+ };
115
71
 
116
- module.exports = Header;
72
+ exports.Header = Header;
73
+ exports.default = Header;
117
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 Button from '../button';\nimport Title from '../title';\nimport React, { FunctionComponent } from 'react';\n\n/**\n * Base properties for an action, including ARIA label and text.\n */\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\n/**\n * Properties for a button action, extending the base action properties.\n */\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\n/**\n * Properties for a link action, extending the base action properties.\n */\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of an `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /** Option prop to specify DOM render element of the title */\n as?: Heading | 'legend';\n\n /** Optional prop to specify classNames onto the Header */\n className?: string;\n\n /** Optional prop to specify the ID used for testing */\n testId?: string;\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the variant of the Header */\n variant?: 'section' | 'group';\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef(\n (\n { action }: { action: ButtonActionProps | LinkActionProps },\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n ) => {\n const { 'aria-label': ariaLabel, text, onClick } = action;\n\n if ('href' in action) {\n const { href, target, onClick: linkOnClick } = action;\n return (\n <Link\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={href}\n target={target}\n aria-label={ariaLabel}\n onClick={linkOnClick}\n >\n {text}\n </Link>\n );\n }\n\n return (\n <Button\n ref={ref as React.Ref<HTMLButtonElement>}\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n aria-label={ariaLabel}\n onClick={onClick}\n >\n {text}\n </Button>\n );\n },\n);\n\n/**\n * Header component\n *\n * The header component is used to render a section header with an optional action button or link.\n * The header component can be rendered as a `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, or `legend` element.\n *\n * @component\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [variant='group'] - Optional prop to specify the variant of the section header.\n * @param {string} [className] - Optional prop to specify classNames onto the Header.\n * @param {string} [testId] - Optional prop to specify the ID used for testing.\n *\n * @example\n * // Example usage:\n * import Header from './Header';\n *\n * function App() {\n * return (\n * <Header title=\"Header\" />\n * );\n * }\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, variant = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const variantClass = variant && variant !== 'group' ? `np-header--${variant}` : '';\n const variantTypography =\n variant === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;\n const HeaderClasses = clsx('np-header', variantClass, className, {\n 'np-header__title': !action || as === 'legend',\n });\n\n const commonProps = {\n className: HeaderClasses,\n 'data-testid': testId,\n };\n\n if (!action || as === 'legend') {\n return (\n <Title as={as} type={variantTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n const actionRef = React.createRef<HTMLButtonElement | HTMLAnchorElement>();\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={variantTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction ref={actionRef} action={action} />\n </div>\n );\n },\n);\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","ariaLabel","text","onClick","href","target","linkOnClick","_jsx","Link","children","Button","className","priority","size","Header","as","testId","title","variant","props","variantClass","variantTypography","Typography","TITLE_SUBSECTION","TITLE_GROUP","HeaderClasses","clsx","commonProps","Title","type","actionRef","createRef","_jsxs"],"mappings":";;;;;;;;;;;;;;AAwDA,MAAMA,YAAY,gBAAGC,sBAAK,CAACC,UAAU,CACnC,CACE;AAAEC,EAAAA,MAAAA;AAAM,CAAmD,EAC3DC,GAAqD,KACnD;EACF,MAAM;AAAE,IAAA,YAAY,EAAEC,SAAS;IAAEC,IAAI;AAAEC,IAAAA,OAAAA;AAAO,GAAE,GAAGJ,MAAM,CAAA;EAEzD,IAAI,MAAM,IAAIA,MAAM,EAAE;IACpB,MAAM;MAAEK,IAAI;MAAEC,MAAM;AAAEF,MAAAA,OAAO,EAAEG,WAAAA;AAAW,KAAE,GAAGP,MAAM,CAAA;IACrD,oBACEQ,cAAA,CAACC,IAAI,EAAA;AACHR,MAAAA,GAAG,EAAEA,GAAoC;AACzCI,MAAAA,IAAI,EAAEA,IAAK;AACXC,MAAAA,MAAM,EAAEA,MAAO;AACf,MAAA,YAAA,EAAYJ,SAAU;AACtBE,MAAAA,OAAO,EAAEG,WAAY;AAAAG,MAAAA,QAAA,EAEpBP,IAAAA;AAAI,KACD,CAAC,CAAA;AAEX,GAAA;EAEA,oBACEK,cAAA,CAACG,MAAM,EAAA;AACLV,IAAAA,GAAG,EAAEA,GAAoC;AACzCW,IAAAA,S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A,GAAMR,KAAK;AAAAV,MAAAA,QAAA,EAC/DQ,KAAAA;AAAK,KACD,CAAC,CAAA;AAEZ,GAAA;AAEA,EAAA,MAAMa,SAAS,gBAAGjC,sBAAK,CAACkC,SAAS,EAAyC,CAAA;AAE1E,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AAAA,IAAA,GAASL,WAAW;AAAA,IAAA,GAAMR,KAAK;AAAEnB,IAAAA,GAAG,EAAEA,GAAiC;IAAAS,QAAA,EAAA,cACrEF,cAAA,CAACqB,KAAK,EAAA;AAACb,MAAAA,EAAE,EAAEA,EAAG;AAACc,MAAAA,IAAI,EAAER,iBAAkB;AAACV,MAAAA,SAAS,EAAC,kBAAkB;AAAAF,MAAAA,QAAA,EACjEQ,KAAAA;AAAK,KACD,CACP,eAAAV,cAAA,CAACX,YAAY,EAAA;AAACI,MAAAA,GAAG,EAAE8B,SAAU;AAAC/B,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/C,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV,CAAC;;;;"}
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,IAA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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 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 = /*#__PURE__*/React__default.forwardRef(({
8
+ const HeaderAction = ({
10
9
  action
11
- }, ref) => {
12
- const {
13
- 'aria-label': ariaLabel,
14
- text,
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
- ref: ref,
25
- href: href,
26
- target: target,
27
- "aria-label": ariaLabel,
28
- onClick: linkOnClick,
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
- "aria-label": ariaLabel,
38
- onClick: onClick,
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
- * @example
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 = /*#__PURE__*/React__default.forwardRef(({
67
- as = 'h5',
37
+ const Header = ({
68
38
  action,
69
- className,
70
- testId,
39
+ as = 'h5',
71
40
  title,
72
- variant = 'group',
73
- ...props
74
- }, ref) => {
75
- const variantClass = variant && variant !== 'group' ? `np-header--${variant}` : '';
76
- const variantTypography = variant === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;
77
- const HeaderClasses = clsx('np-header', variantClass, className, {
78
- 'np-header__title': !action || as === 'legend'
79
- });
80
- const commonProps = {
81
- className: HeaderClasses,
82
- 'data-testid': testId
83
- };
84
- if (!action || as === 'legend') {
41
+ className
42
+ }) => {
43
+ if (!action) {
85
44
  return /*#__PURE__*/jsx(Title, {
86
45
  as: as,
87
- type: variantTypography,
88
- ...commonProps,
89
- ...props,
46
+ type: Typography.TITLE_GROUP,
47
+ className: clsx('np-header', 'np-header__title', className),
90
48
  children: title
91
49
  });
92
50
  }
93
- const actionRef = /*#__PURE__*/React__default.createRef();
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
+ }
94
55
  return /*#__PURE__*/jsxs("div", {
95
- ...commonProps,
96
- ...props,
97
- ref: ref,
56
+ className: clsx('np-header', className),
98
57
  children: [/*#__PURE__*/jsx(Title, {
99
58
  as: as,
100
- type: variantTypography,
59
+ type: Typography.TITLE_GROUP,
101
60
  className: "np-header__title",
102
61
  children: title
103
62
  }), /*#__PURE__*/jsx(HeaderAction, {
104
- ref: actionRef,
105
63
  action: action
106
64
  })]
107
65
  });
108
- });
66
+ };
109
67
 
110
- export { Header as default };
68
+ export { Header, Header as default };
111
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 Button from '../button';\nimport Title from '../title';\nimport React, { FunctionComponent } from 'react';\n\n/**\n * Base properties for an action, including ARIA label and text.\n */\ntype ActionProps = AriaLabelProperty & {\n text: string;\n};\n\n/**\n * Properties for a button action, extending the base action properties.\n */\ntype ButtonActionProps = ActionProps & ActionButtonProps;\n\n/**\n * Properties for a link action, extending the base action properties.\n */\ntype LinkActionProps = ActionProps & LinkProps;\n\nexport interface HeaderProps extends CommonProps {\n /**\n * Optional prop to define the action for the header. If the `href` property\n * is provided, a `Link` will be rendered instead of an `ActionButton`.\n */\n action?: ButtonActionProps | LinkActionProps;\n\n /** Option prop to specify DOM render element of the title */\n as?: Heading | 'legend';\n\n /** Optional prop to specify classNames onto the Header */\n className?: string;\n\n /** Optional prop to specify the ID used for testing */\n testId?: string;\n\n /** Required prop to set the title of the Header. */\n title: string;\n\n /** Optional prop to specify the variant of the Header */\n variant?: 'section' | 'group';\n}\n\n/**\n * Renders a header action which can be either a button or a link.\n *\n * @param {Object} props - The properties object.\n * @param {ButtonActionProps | LinkActionProps} props.action - The action object which can be either a button or a link.\n * @returns {JSX.Element} The rendered header action component.\n */\nconst HeaderAction = React.forwardRef(\n (\n { action }: { action: ButtonActionProps | LinkActionProps },\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n ) => {\n const { 'aria-label': ariaLabel, text, onClick } = action;\n\n if ('href' in action) {\n const { href, target, onClick: linkOnClick } = action;\n return (\n <Link\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={href}\n target={target}\n aria-label={ariaLabel}\n onClick={linkOnClick}\n >\n {text}\n </Link>\n );\n }\n\n return (\n <Button\n ref={ref as React.Ref<HTMLButtonElement>}\n className=\"np-header__button\"\n priority=\"tertiary\"\n size=\"sm\"\n aria-label={ariaLabel}\n onClick={onClick}\n >\n {text}\n </Button>\n );\n },\n);\n\n/**\n * Header component\n *\n * The header component is used to render a section header with an optional action button or link.\n * The header component can be rendered as a `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, or `legend` element.\n *\n * @component\n * @param {ButtonActionProps | LinkActionProps} [action] - Optional prop to specify the action button or link.\n * @param {Heading | 'legend'} [as='h5'] - Optional prop to override the heading element rendered for the title.\n * @param {string} title - Required prop to set the title of the section header.\n * @param {'group' | 'section'} [variant='group'] - Optional prop to specify the variant of the section header.\n * @param {string} [className] - Optional prop to specify classNames onto the Header.\n * @param {string} [testId] - Optional prop to specify the ID used for testing.\n *\n * @example\n * // Example usage:\n * import Header from './Header';\n *\n * function App() {\n * return (\n * <Header title=\"Header\" />\n * );\n * }\n */\nconst Header: FunctionComponent<HeaderProps> = React.forwardRef(\n (\n { as = 'h5', action, className, testId, title, variant = 'group', ...props },\n ref: React.Ref<HTMLDivElement | HTMLHeadingElement | HTMLLegendElement>,\n ) => {\n const variantClass = variant && variant !== 'group' ? `np-header--${variant}` : '';\n const variantTypography =\n variant === 'section' ? Typography.TITLE_SUBSECTION : Typography.TITLE_GROUP;\n const HeaderClasses = clsx('np-header', variantClass, className, {\n 'np-header__title': !action || as === 'legend',\n });\n\n const commonProps = {\n className: HeaderClasses,\n 'data-testid': testId,\n };\n\n if (!action || as === 'legend') {\n return (\n <Title as={as} type={variantTypography} {...commonProps} {...props}>\n {title}\n </Title>\n );\n }\n\n const actionRef = React.createRef<HTMLButtonElement | HTMLAnchorElement>();\n\n return (\n <div {...commonProps} {...props} ref={ref as React.Ref<HTMLDivElement>}>\n <Title as={as} type={variantTypography} className=\"np-header__title\">\n {title}\n </Title>\n <HeaderAction ref={actionRef} action={action} />\n </div>\n );\n },\n);\n\nexport default Header;\n"],"names":["HeaderAction","React","forwardRef","action","ref","ariaLabel","text","onClick","href","target","linkOnClick","_jsx","Link","children","Button","className","priority","size","Header","as","testId","title","variant","props","variantClass","variantTypography","Typography","TITLE_SUBSECTION","TITLE_GROUP","HeaderClasses","clsx","commonProps","Title","type","actionRef","createRef","_jsxs"],"mappings":";;;;;;;;AAwDA,MAAMA,YAAY,gBAAGC,cAAK,CAACC,UAAU,CACnC,CACE;AAAEC,EAAAA,MAAAA;AAAM,CAAmD,EAC3DC,GAAqD,KACnD;EACF,MAAM;AAAE,IAAA,YAAY,EAAEC,SAAS;IAAEC,IAAI;AAAEC,IAAAA,OAAAA;AAAO,GAAE,GAAGJ,MAAM,CAAA;EAEzD,IAAI,MAAM,IAAIA,MAAM,EAAE;IACpB,MAAM;MAAEK,IAAI;MAAEC,MAAM;AAAEF,MAAAA,OAAO,EAAEG,WAAAA;AAAW,KAAE,GAAGP,MAAM,CAAA;IACrD,oBACEQ,GAAA,CAACC,IAAI,EAAA;AACHR,MAAAA,GAAG,EAAEA,GAAoC;AACzCI,MAAAA,IAAI,EAAEA,IAAK;AACXC,MAAAA,MAAM,EAAEA,MAAO;AACf,MAAA,YAAA,EAAYJ,SAAU;AACtBE,MAAAA,OAAO,EAAEG,WAAY;AAAAG,MAAAA,QAAA,EAEpBP,IAAAA;AAAI,KACD,CAAC,CAAA;AAEX,GAAA;EAEA,oBACEK,GAAA,CAACG,MAAM,EAAA;AACLV,IAAAA,GAAG,EAAEA,GAAoC;AACzCW,IAAAA,SAAS,EAAC,mBAAmB;AAC7BC,IAAAA,QAAQ,EAAC,UAAU;AACnBC,IAAAA,IAAI,EAAC,IAAI;AACT,IAAA,YAAA,EAAYZ,SAAU;AACtBE,IAAAA,OAAO,EAAEA,OAAQ;AAAAM,IAAAA,QAAA,EAEhBP,IAAAA;AAAI,GACC,CAAC,CAAA;AAEb,CAAC,CACF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACH,MAAMY,MAAM,gBAAmCjB,cAAK,CAACC,UAAU,CAC7D,CACE;AAAEiB,EAAAA,EAAE,G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AAEA,EAAG;AAACc,MAAAA,IAAI,EAAER,iBAAkB;AAACV,MAAAA,SAAS,EAAC,kBAAkB;AAAAF,MAAAA,QAAA,EACjEQ,KAAAA;AAAK,KACD,CACP,eAAAV,GAAA,CAACX,YAAY,EAAA;AAACI,MAAAA,GAAG,EAAE8B,SAAU;AAAC/B,MAAAA,MAAM,EAAEA,MAAAA;AAAO,KAC/C,CAAA,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV,CAAC;;;;"}
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 { default as Header } from './header/Header.mjs';
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';
@@ -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 = /*#__PURE__*/React.forwardRef(({
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
- }, ref) => {
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
@@ -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, forwardRef } 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 = forwardRef<HTMLAnchorElement, Props>(\n (\n { className, children, href, target, type, 'aria-label': ariaLabel, onClick, ...props }: Props,\n ref,\n ) => {\n const isBlank = target === '_blank';\n\n const { formatMessage } = useIntl();\n\n return (\n <a\n ref={ref}\n href={href}\n target={target}\n className={clsx(\n 'np-link',\n type ? `np-text-${type}` : undefined,\n 'd-inline-flex',\n className,\n )}\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);\n\nexport default Link;\n"],"names":["Link","forwardRef","className","children","href","target","type","ariaLabel","onClick","props","ref","isBlank","formatMessage","useIntl","_jsxs","clsx","undefined","rel","_jsx","NavigateAwayIcon","title","messages","opensInNewTab"],"mappings":";;;;;;;;;AAgBA,MAAMA,IAAI,gBAAGC,gBAAU,CACrB,CACE;EAAEC,SAAS;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,MAAM;EAAEC,IAAI;AAAE,EAAA,YAAY,EAAEC,SAAS;EAAEC,OAAO;EAAE,GAAGC,KAAAA;AAAc,CAAA,EAC9FC,GAAG,KACD;AACF,EAAA,MAAMC,OAAO,GAAGN,MAAM,KAAK,QAAQ,CAAA;EAEnC,MAAM;AAAEO,IAAAA,aAAAA;GAAe,GAAGC,iBAAO,EAAE,CAAA;AAEnC,EAAA,oBACEC,eAAA,CAAA,GAAA,EAAA;AACEJ,IAAAA,GAAG,EAAEA,GAAI;AACTN,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,SAAS,EAAEa,SAAI,CACb,SAAS,EACTT,IAAI,GAAG,CAAA,QAAA,EAAWA,IAAI,CAAA,CAAE,GAAGU,SAAS,EACpC,eAAe,EACfd,SAAS,CACT;AACF,IAAA,YAAA,EAAYK,SAAU;AACtBU,IAAAA,GAAG,EAAEN,OAAO,GAAG,YAAY,GAAGK,SAAU;AACxCR,IAAAA,OAAO,EAAEA,OAAQ;AAAA,IAAA,GACbC,KAAK;IAAAN,QAAA,EAAA,CAERA,QAAQ,EAAE,GAAA,EAACQ,OAAO,iBAAIO,cAAA,CAACC,kBAAgB,EAAA;AAACC,MAAAA,KAAK,EAAER,aAAa,CAACS,aAAQ,CAACC,aAAa,CAAA;AAAE,MAAG,CAAA;AAAA,GACxF,CAAC,CAAA;AAER,CAAC;;;;"}
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;;;;"}
@@ -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 = /*#__PURE__*/forwardRef(({
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
- }, ref) => {
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
@@ -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, forwardRef } 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 = forwardRef<HTMLAnchorElement, Props>(\n (\n { className, children, href, target, type, 'aria-label': ariaLabel, onClick, ...props }: Props,\n ref,\n ) => {\n const isBlank = target === '_blank';\n\n const { formatMessage } = useIntl();\n\n return (\n <a\n ref={ref}\n href={href}\n target={target}\n className={clsx(\n 'np-link',\n type ? `np-text-${type}` : undefined,\n 'd-inline-flex',\n className,\n )}\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);\n\nexport default Link;\n"],"names":["Link","forwardRef","className","children","href","target","type","ariaLabel","onClick","props","ref","isBlank","formatMessage","useIntl","_jsxs","clsx","undefined","rel","_jsx","NavigateAwayIcon","title","messages","opensInNewTab"],"mappings":";;;;;;;AAgBA,MAAMA,IAAI,gBAAGC,UAAU,CACrB,CACE;EAAEC,SAAS;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,MAAM;EAAEC,IAAI;AAAE,EAAA,YAAY,EAAEC,SAAS;EAAEC,OAAO;EAAE,GAAGC,KAAAA;AAAc,CAAA,EAC9FC,GAAG,KACD;AACF,EAAA,MAAMC,OAAO,GAAGN,MAAM,KAAK,QAAQ,CAAA;EAEnC,MAAM;AAAEO,IAAAA,aAAAA;GAAe,GAAGC,OAAO,EAAE,CAAA;AAEnC,EAAA,oBACEC,IAAA,CAAA,GAAA,EAAA;AACEJ,IAAAA,GAAG,EAAEA,GAAI;AACTN,IAAAA,IAAI,EAAEA,IAAK;AACXC,IAAAA,MAAM,EAAEA,MAAO;AACfH,IAAAA,SAAS,EAAEa,IAAI,CACb,SAAS,EACTT,IAAI,GAAG,CAAA,QAAA,EAAWA,IAAI,CAAA,CAAE,GAAGU,SAAS,EACpC,eAAe,EACfd,SAAS,CACT;AACF,IAAA,YAAA,EAAYK,SAAU;AACtBU,IAAAA,GAAG,EAAEN,OAAO,GAAG,YAAY,GAAGK,SAAU;AACxCR,IAAAA,OAAO,EAAEA,OAAQ;AAAA,IAAA,GACbC,KAAK;IAAAN,QAAA,EAAA,CAERA,QAAQ,EAAE,GAAA,EAACQ,OAAO,iBAAIO,GAAA,CAACC,YAAgB,EAAA;AAACC,MAAAA,KAAK,EAAER,aAAa,CAACS,QAAQ,CAACC,aAAa,CAAA;AAAE,MAAG,CAAA;AAAA,GACxF,CAAC,CAAA;AAER,CAAC;;;;"}
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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"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,MAAK;MACVX,cAAc,CAACW,iBAAiB,CAAC,CAAA;KAClC,CAAA;AACH,GAAA;EAEA,SAASC,cAAcA,CAACC,IAA0B,EAAA;AAChD,IAAA,OAAO,MAA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AAa,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';
@@ -14,9 +14,6 @@
14
14
  -moz-column-gap: var(--size-24);
15
15
  column-gap: var(--size-24);
16
16
  }
17
- .np-header--section {
18
- border-bottom: none;
19
- }
20
17
  .np-header__title {
21
18
  color: #5d7079;
22
19
  color: var(--color-content-secondary);
@@ -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);