@transferwise/components 46.104.0 → 46.105.1

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 (85) hide show
  1. package/build/header/Header.js +60 -43
  2. package/build/header/Header.js.map +1 -1
  3. package/build/header/Header.mjs +57 -43
  4. package/build/header/Header.mjs.map +1 -1
  5. package/build/i18n/cs.json +2 -0
  6. package/build/i18n/cs.json.js +2 -0
  7. package/build/i18n/cs.json.js.map +1 -1
  8. package/build/i18n/cs.json.mjs +2 -0
  9. package/build/i18n/cs.json.mjs.map +1 -1
  10. package/build/i18n/es.json +2 -0
  11. package/build/i18n/es.json.js +2 -0
  12. package/build/i18n/es.json.js.map +1 -1
  13. package/build/i18n/es.json.mjs +2 -0
  14. package/build/i18n/es.json.mjs.map +1 -1
  15. package/build/i18n/th.json +2 -0
  16. package/build/i18n/th.json.js +2 -0
  17. package/build/i18n/th.json.js.map +1 -1
  18. package/build/i18n/th.json.mjs +2 -0
  19. package/build/i18n/th.json.mjs.map +1 -1
  20. package/build/index.js +1 -1
  21. package/build/index.mjs +1 -1
  22. package/build/inputs/SelectInput.js +1 -1
  23. package/build/inputs/SelectInput.js.map +1 -1
  24. package/build/inputs/SelectInput.mjs +1 -1
  25. package/build/listItem/ListItem.js +4 -2
  26. package/build/listItem/ListItem.js.map +1 -1
  27. package/build/listItem/ListItem.mjs +4 -2
  28. package/build/listItem/ListItem.mjs.map +1 -1
  29. package/build/main.css +24 -22
  30. package/build/styles/header/Header.css +21 -14
  31. package/build/styles/listItem/ListItem.css +3 -8
  32. package/build/styles/listItem/ListItem.grid.css +0 -8
  33. package/build/styles/main.css +24 -22
  34. package/build/title/Title.js +10 -4
  35. package/build/title/Title.js.map +1 -1
  36. package/build/title/Title.mjs +6 -4
  37. package/build/title/Title.mjs.map +1 -1
  38. package/build/types/header/Header.d.ts +27 -11
  39. package/build/types/header/Header.d.ts.map +1 -1
  40. package/build/types/header/index.d.ts +1 -0
  41. package/build/types/header/index.d.ts.map +1 -1
  42. package/build/types/index.d.ts +1 -0
  43. package/build/types/index.d.ts.map +1 -1
  44. package/build/types/listItem/ListItem.d.ts.map +1 -1
  45. package/build/types/listItem/_stories/subcomponents.d.ts +1 -1
  46. package/build/types/listItem/_stories/subcomponents.d.ts.map +1 -1
  47. package/build/types/title/Title.d.ts +4 -5
  48. package/build/types/title/Title.d.ts.map +1 -1
  49. package/package.json +1 -1
  50. package/src/actionButton/ActionButton.story.tsx +1 -1
  51. package/src/avatar/Avatar.story.tsx +1 -1
  52. package/src/avatarWrapper/AvatarWrapper.story.tsx +1 -1
  53. package/src/badge/Badge.story.tsx +1 -1
  54. package/src/button/Button.spec.tsx +25 -1
  55. package/src/button/Button.story.tsx +1 -1
  56. package/src/button/LegacyButton.story.tsx +1 -1
  57. package/src/header/Header.accessibility.docs.mdx +85 -0
  58. package/src/header/Header.css +21 -14
  59. package/src/header/Header.less +17 -10
  60. package/src/header/Header.spec.tsx +68 -50
  61. package/src/header/Header.story.tsx +190 -36
  62. package/src/header/Header.tsx +96 -65
  63. package/src/header/index.ts +1 -0
  64. package/src/i18n/cs.json +2 -0
  65. package/src/i18n/es.json +2 -0
  66. package/src/i18n/th.json +2 -0
  67. package/src/iconButton/iconButton.spec.tsx +31 -0
  68. package/src/index.ts +1 -0
  69. package/src/listItem/Button/ListItemButton.spec.tsx +23 -1
  70. package/src/listItem/IconButton/ListItemIconButton.spec.tsx +14 -2
  71. package/src/listItem/ListItem.css +3 -8
  72. package/src/listItem/ListItem.grid.css +0 -8
  73. package/src/listItem/ListItem.grid.less +0 -8
  74. package/src/listItem/ListItem.less +4 -0
  75. package/src/listItem/ListItem.tsx +4 -2
  76. package/src/listItem/Navigation/ListItemNavigation.spec.tsx +8 -0
  77. package/src/listItem/Navigation/ListItemNavigation.story.tsx +4 -2
  78. package/src/listItem/_stories/ListItem.layout.test.story.tsx +20 -0
  79. package/src/listItem/_stories/ListItem.story.tsx +1 -1
  80. package/src/listItem/_stories/ListItem.variants.test.story.tsx +3 -0
  81. package/src/listItem/_stories/subcomponents.tsx +2 -0
  82. package/src/main.css +24 -22
  83. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +15 -4
  84. package/src/select/Select.story.tsx +1 -1
  85. package/src/title/Title.tsx +25 -12
package/src/main.css CHANGED
@@ -2433,30 +2433,37 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2433
2433
  fill: var(--color-interactive-primary);
2434
2434
  }
2435
2435
  .np-header {
2436
- display: flex;
2437
- justify-content: space-between;
2438
- align-items: flex-end;
2436
+ display: grid;
2437
+ grid-template-columns: 1fr auto;
2438
+ grid-column-gap: 24px;
2439
+ grid-column-gap: var(--size-24);
2440
+ -moz-column-gap: 24px;
2441
+ column-gap: 24px;
2442
+ -moz-column-gap: var(--size-24);
2443
+ column-gap: var(--size-24);
2444
+ align-items: center;
2445
+ margin-bottom: 8px;
2446
+ margin-bottom: var(--size-8);
2439
2447
  max-width: 100%;
2440
2448
  padding: 8px 0;
2441
2449
  padding: var(--size-8) 0;
2450
+ width: 100%;
2451
+ }
2452
+ .np-header--group {
2453
+ align-items: flex-end;
2442
2454
  border-bottom: 1px solid rgba(0,0,0,0.10196);
2443
2455
  border-bottom: 1px solid var(--color-border-neutral);
2444
- margin-bottom: 8px;
2445
- margin-bottom: var(--size-8);
2446
- -moz-column-gap: 24px;
2447
- column-gap: 24px;
2448
- -moz-column-gap: var(--size-24);
2449
- column-gap: var(--size-24);
2450
2456
  }
2451
2457
  .np-header__title {
2452
2458
  color: #5d7079;
2453
2459
  color: var(--color-content-secondary);
2460
+ margin: 0;
2454
2461
  }
2455
- .np-header__button {
2456
- margin-inline: calc(16px * -1);
2457
- margin-inline: calc(var(--size-16) * -1);
2458
- margin-bottom: calc(4px * -1);
2459
- margin-bottom: calc(var(--size-4) * -1);
2462
+ .np-header__action {
2463
+ margin: 0;
2464
+ height: 20px;
2465
+ display: flex;
2466
+ align-items: center;
2460
2467
  }
2461
2468
  .tw-image {
2462
2469
  max-width: none;
@@ -2739,10 +2746,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2739
2746
  -o-object-position: bottom left;
2740
2747
  object-position: bottom left;
2741
2748
  }
2742
- .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl .wds-list-item-media {
2743
- margin-bottom: 12px;
2744
- margin-bottom: var(--size-12);
2745
- }
2746
2749
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-hasInfo-hasPrompt {
2747
2750
  grid-template-columns: 1fr auto;
2748
2751
  grid-template-rows: auto auto auto auto;
@@ -2779,10 +2782,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2779
2782
  grid-template-columns: 1fr;
2780
2783
  grid-template-areas: "media" "body" "control";
2781
2784
  }
2782
- .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl .wds-list-item-media {
2783
- margin-bottom: 12px;
2784
- margin-bottom: var(--size-12);
2785
- }
2786
2785
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-hasInfo-hasPrompt {
2787
2786
  grid-template-columns: auto auto;
2788
2787
  grid-template-rows: auto auto auto auto;
@@ -3324,6 +3323,9 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3324
3323
  margin-top: calc(4px * -1);
3325
3324
  margin-top: calc(var(--size-4) * -1);
3326
3325
  }
3326
+ .wds-list-item-additional-info button.np-link {
3327
+ text-align: start;
3328
+ }
3327
3329
  .wds-list-item-control-wrapper {
3328
3330
  grid-area: control;
3329
3331
  align-content: center;
@@ -1,10 +1,10 @@
1
- import { render, screen } from '@testing-library/react';
1
+ import { render, screen, userEvent } from '../../../test-utils';
2
2
  import PrimitiveAnchor from '..';
3
3
 
4
4
  describe('PrimitiveAnchor', () => {
5
5
  const defaultProps = {
6
6
  children: 'Click me',
7
- href: 'https://example.com',
7
+ href: '#destination',
8
8
  };
9
9
 
10
10
  const renderAnchor = (props?: Partial<typeof defaultProps>) => {
@@ -15,7 +15,7 @@ describe('PrimitiveAnchor', () => {
15
15
  renderAnchor();
16
16
  expect(screen.getByRole('link')).toBeInTheDocument();
17
17
  expect(screen.getByRole('link')).toHaveTextContent('Click me');
18
- expect(screen.getByRole('link')).toHaveAttribute('href', 'https://example.com');
18
+ expect(screen.getByRole('link')).toHaveAttribute('href', defaultProps.href);
19
19
  });
20
20
 
21
21
  it('applies the correct classes based on props', () => {
@@ -40,7 +40,7 @@ describe('PrimitiveAnchor', () => {
40
40
 
41
41
  const link = screen.getByRole('link');
42
42
  expect(link).toHaveAttribute('aria-disabled', 'true');
43
- expect(link).not.toHaveAttribute('href', 'https://example.com');
43
+ expect(link).not.toHaveAttribute('href', defaultProps.href);
44
44
  });
45
45
 
46
46
  it('sets data-testid attribute', () => {
@@ -90,4 +90,15 @@ describe('PrimitiveAnchor', () => {
90
90
  const link = screen.getByRole('link');
91
91
  expect(link).toHaveStyle('color: red');
92
92
  });
93
+
94
+ it('should respect click handlers', async () => {
95
+ const props = {
96
+ ...defaultProps,
97
+ onClick: jest.fn(),
98
+ };
99
+
100
+ renderAnchor(props);
101
+ await userEvent.click(screen.getByRole('link'));
102
+ expect(props.onClick).toHaveBeenCalledTimes(1);
103
+ });
93
104
  });
@@ -9,7 +9,7 @@ import Select, { SelectItem, SelectOptionItem } from './Select';
9
9
  const meta: Meta<typeof Select> = {
10
10
  component: Select,
11
11
  title: 'Forms/Select',
12
- tags: ['wds:deprecated'],
12
+ tags: ['deprecated'],
13
13
  argTypes: {
14
14
  id: { control: 'text' },
15
15
  size: { control: 'radio', options: ['sm', 'md', 'lg'] },
@@ -1,5 +1,5 @@
1
1
  import { clsx } from 'clsx';
2
- import { LabelHTMLAttributes, LiHTMLAttributes, ReactHTML } from 'react';
2
+ import React, { forwardRef, LabelHTMLAttributes, LiHTMLAttributes } from 'react';
3
3
 
4
4
  import { TitleTypes, Typography, Heading } from '../common';
5
5
 
@@ -25,16 +25,29 @@ type Props = LabelHTMLAttributes<HTMLHeadingElement | HTMLSpanElement | HTMLLabe
25
25
  type?: TitleTypes;
26
26
  };
27
27
 
28
- function Title({ as, type = DEFAULT_TYPE, className, ...props }: Props) {
29
- const mapping = titleTypeMapping[type];
30
- const isTypeSupported = mapping !== undefined;
31
-
32
- if (isTypeSupported) {
33
- const HeaderTag = as ?? mapping;
34
- return <HeaderTag {...props} className={clsx(`np-text-${type}`, className)} />;
35
- }
36
- const HeaderTag = as ?? titleTypeMapping[DEFAULT_TYPE];
37
- return <HeaderTag {...props} className={clsx(`np-text-${DEFAULT_TYPE}`, className)} />;
38
- }
28
+ const Title = React.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
+ );
39
52
 
40
53
  export default Title;