@transferwise/components 0.0.0-experimental-53101fe → 0.0.0-experimental-abddca8

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 (52) hide show
  1. package/build/header/Header.js +34 -89
  2. package/build/header/Header.js.map +1 -1
  3. package/build/header/Header.mjs +31 -85
  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/title/Title.js +3 -6
  18. package/build/title/Title.js.map +1 -1
  19. package/build/title/Title.mjs +3 -6
  20. package/build/title/Title.mjs.map +1 -1
  21. package/build/typeahead/Typeahead.js +1 -1
  22. package/build/typeahead/Typeahead.js.map +1 -1
  23. package/build/typeahead/Typeahead.mjs +1 -1
  24. package/build/typeahead/Typeahead.mjs.map +1 -1
  25. package/build/typeahead/util/highlight.js +1 -1
  26. package/build/typeahead/util/highlight.js.map +1 -1
  27. package/build/typeahead/util/highlight.mjs +2 -2
  28. package/build/typeahead/util/highlight.mjs.map +1 -1
  29. package/build/types/header/Header.d.ts +10 -43
  30. package/build/types/header/Header.d.ts.map +1 -1
  31. package/build/types/header/index.d.ts +0 -1
  32. package/build/types/header/index.d.ts.map +1 -1
  33. package/build/types/index.d.ts +0 -1
  34. package/build/types/index.d.ts.map +1 -1
  35. package/build/types/link/Link.d.ts +1 -3
  36. package/build/types/link/Link.d.ts.map +1 -1
  37. package/build/types/title/Title.d.ts +4 -3
  38. package/build/types/title/Title.d.ts.map +1 -1
  39. package/package.json +3 -3
  40. package/src/header/Header.css +0 -3
  41. package/src/header/Header.less +0 -4
  42. package/src/header/Header.spec.tsx +0 -33
  43. package/src/header/Header.story.tsx +40 -62
  44. package/src/header/Header.tsx +59 -135
  45. package/src/header/index.ts +0 -1
  46. package/src/index.ts +0 -1
  47. package/src/link/Link.tsx +27 -29
  48. package/src/main.css +0 -3
  49. package/src/title/Title.tsx +11 -25
  50. package/src/typeahead/Typeahead.tsx +2 -2
  51. package/src/typeahead/util/highlight.spec.js +1 -1
  52. package/src/typeahead/util/highlight.tsx +2 -2
package/src/link/Link.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NavigateAway as NavigateAwayIcon } from '@transferwise/icons';
2
2
  import { clsx } from 'clsx';
3
- import { AnchorHTMLAttributes, forwardRef } from 'react';
3
+ import { AnchorHTMLAttributes } from 'react';
4
4
  import { useIntl } from 'react-intl';
5
5
 
6
6
  import { LinkLarge, LinkDefault } from '../common';
@@ -14,35 +14,33 @@ export type Props = AnchorHTMLAttributes<HTMLAnchorElement> & { type?: LinkLarge
14
14
  *
15
15
  * Documentation: https://transferwise.github.io/neptune-web/components/content/Link
16
16
  */
17
- const Link = forwardRef<HTMLAnchorElement, Props>(
18
- (
19
- { className, children, href, target, type, 'aria-label': ariaLabel, onClick, ...props }: Props,
20
- ref,
21
- ) => {
22
- const isBlank = target === '_blank';
17
+ const Link = ({
18
+ className,
19
+ children,
20
+ href,
21
+ target,
22
+ type,
23
+ 'aria-label': ariaLabel,
24
+ onClick,
25
+ ...props
26
+ }: Props) => {
27
+ const isBlank = target === '_blank';
23
28
 
24
- const { formatMessage } = useIntl();
29
+ const { formatMessage } = useIntl();
25
30
 
26
- return (
27
- <a
28
- ref={ref}
29
- href={href}
30
- target={target}
31
- className={clsx(
32
- 'np-link',
33
- type ? `np-text-${type}` : undefined,
34
- 'd-inline-flex',
35
- className,
36
- )}
37
- aria-label={ariaLabel}
38
- rel={isBlank ? 'noreferrer' : undefined}
39
- onClick={onClick}
40
- {...props}
41
- >
42
- {children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}
43
- </a>
44
- );
45
- },
46
- );
31
+ return (
32
+ <a
33
+ href={href}
34
+ target={target}
35
+ className={clsx('np-link', type ? `np-text-${type}` : undefined, 'd-inline-flex', className)}
36
+ aria-label={ariaLabel}
37
+ rel={isBlank ? 'noreferrer' : undefined}
38
+ onClick={onClick}
39
+ {...props}
40
+ >
41
+ {children} {isBlank && <NavigateAwayIcon title={formatMessage(messages.opensInNewTab)} />}
42
+ </a>
43
+ );
44
+ };
47
45
 
48
46
  export default Link;
package/src/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);
@@ -1,5 +1,5 @@
1
1
  import { clsx } from 'clsx';
2
- import { forwardRef, LabelHTMLAttributes, LiHTMLAttributes, ReactHTML } from 'react';
2
+ import { LabelHTMLAttributes, LiHTMLAttributes, ReactHTML } from 'react';
3
3
 
4
4
  import { TitleTypes, Typography, Heading } from '../common';
5
5
 
@@ -25,29 +25,15 @@ type Props = LabelHTMLAttributes<HTMLHeadingElement | HTMLSpanElement | HTMLLabe
25
25
  type?: TitleTypes;
26
26
  };
27
27
 
28
- const Title = forwardRef<HTMLHeadingElement | HTMLSpanElement | HTMLLabelElement, Props>(
29
- ({ as, type = DEFAULT_TYPE, className, ...props }, ref) => {
30
- const mapping = titleTypeMapping[type as keyof typeof titleTypeMapping];
31
- const isTypeSupported = mapping !== undefined;
32
- if (isTypeSupported) {
33
- const HeaderTag = as ?? mapping;
34
- return (
35
- <HeaderTag
36
- ref={ref as React.Ref<any>}
37
- {...props}
38
- className={clsx(`np-text-${type}`, className)}
39
- />
40
- );
41
- }
42
- const HeaderTag = as ?? titleTypeMapping[DEFAULT_TYPE];
43
- return (
44
- <HeaderTag
45
- ref={ref as React.Ref<any>}
46
- {...props}
47
- className={clsx(`np-text-${DEFAULT_TYPE}`, className)}
48
- />
49
- );
50
- },
51
- );
28
+ function Title({ as, type = DEFAULT_TYPE, className, ...props }: Props) {
29
+ const mapping = titleTypeMapping[type];
30
+ const isTypeSupported = mapping !== undefined;
31
+ if (isTypeSupported) {
32
+ const HeaderTag = as ?? mapping;
33
+ return <HeaderTag {...props} className={clsx(`np-text-${type}`, className)} />;
34
+ }
35
+ const HeaderTag = as ?? titleTypeMapping[DEFAULT_TYPE];
36
+ return <HeaderTag {...props} className={clsx(`np-text-${DEFAULT_TYPE}`, className)} />;
37
+ }
52
38
 
53
39
  export default Title;
@@ -406,7 +406,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
406
406
  className={clsx('dropdown btn-group btn-block', { open: dropdownOpen })}
407
407
  id={`menu-${id}`}
408
408
  >
409
- {!!optionsToRender.length && (
409
+ {(!!optionsToRender.length || footer) && (
410
410
  <ul className="dropdown-menu" role="menu">
411
411
  {optionsToRender.map((option, idx) => {
412
412
  const ref = React.createRef<HTMLLIElement>();
@@ -423,7 +423,7 @@ class Typeahead<T> extends Component<TypeaheadPropsWithInputAttributes<T>, Typea
423
423
  this.onOptionSelected(event, option);
424
424
  }}
425
425
  />
426
- )
426
+ );
427
427
  })}
428
428
  {footer}
429
429
  </ul>
@@ -21,7 +21,7 @@ describe('Typeahead input', () => {
21
21
  const label = `this is a label`;
22
22
  const result = highlight(label, query);
23
23
 
24
- expect(result).toBe(label);
24
+ expect(result).toStrictEqual(label);
25
25
  });
26
26
 
27
27
  it('highlights whole label that matches the query', () => {
@@ -4,11 +4,11 @@ export default function highlight(value: string, query: string) {
4
4
  const highlightEnd = highlightStart + query.trim().length;
5
5
  if (highlightStart !== -1) {
6
6
  return (
7
- <>
7
+ <span>
8
8
  {value.slice(0, Math.max(0, highlightStart))}
9
9
  <strong>{value.slice(highlightStart, highlightEnd)}</strong>
10
10
  {value.slice(Math.max(0, highlightEnd))}
11
- </>
11
+ </span>
12
12
  );
13
13
  }
14
14
  }