@transferwise/components 46.43.0 → 46.44.0

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/main.css CHANGED
@@ -657,8 +657,6 @@ div.critical-comms .critical-comms-body {
657
657
  gap: var(--size-16);
658
658
  padding: 8px;
659
659
  padding: var(--size-8);
660
- margin: 8px;
661
- margin: var(--size-8);
662
660
  }
663
661
  @media (max-width: 767px) {
664
662
  .carousel {
@@ -705,6 +703,15 @@ div.critical-comms .critical-comms-body {
705
703
  height: 280px;
706
704
  }
707
705
  }
706
+ @media (min-width: 768px) {
707
+ .carousel-wrapper {
708
+ overflow: visible;
709
+ }
710
+ .carousel {
711
+ margin: 0 calc(-1 * 8px);
712
+ margin: 0 calc(-1 * var(--size-8));
713
+ }
714
+ }
708
715
  @media (max-width: 1199px) {
709
716
  .carousel__card {
710
717
  min-width: 242px;
@@ -12,8 +12,6 @@
12
12
  gap: var(--size-16);
13
13
  padding: 8px;
14
14
  padding: var(--size-8);
15
- margin: 8px;
16
- margin: var(--size-8);
17
15
  }
18
16
  @media (max-width: 767px) {
19
17
  .carousel {
@@ -60,6 +58,15 @@
60
58
  height: 280px;
61
59
  }
62
60
  }
61
+ @media (min-width: 768px) {
62
+ .carousel-wrapper {
63
+ overflow: visible;
64
+ }
65
+ .carousel {
66
+ margin: 0 calc(-1 * 8px);
67
+ margin: 0 calc(-1 * var(--size-8));
68
+ }
69
+ }
63
70
  @media (max-width: 1199px) {
64
71
  .carousel__card {
65
72
  min-width: 242px;
@@ -657,8 +657,6 @@ div.critical-comms .critical-comms-body {
657
657
  gap: var(--size-16);
658
658
  padding: 8px;
659
659
  padding: var(--size-8);
660
- margin: 8px;
661
- margin: var(--size-8);
662
660
  }
663
661
  @media (max-width: 767px) {
664
662
  .carousel {
@@ -705,6 +703,15 @@ div.critical-comms .critical-comms-body {
705
703
  height: 280px;
706
704
  }
707
705
  }
706
+ @media (min-width: 768px) {
707
+ .carousel-wrapper {
708
+ overflow: visible;
709
+ }
710
+ .carousel {
711
+ margin: 0 calc(-1 * 8px);
712
+ margin: 0 calc(-1 * var(--size-8));
713
+ }
714
+ }
708
715
  @media (max-width: 1199px) {
709
716
  .carousel__card {
710
717
  min-width: 242px;
@@ -3,6 +3,7 @@ import type { PromoCardLinkProps } from '../promoCard/PromoCard';
3
3
  export type CarouselCardCommon = {
4
4
  id: string;
5
5
  href?: string;
6
+ hrefTarget?: HTMLAnchorElement['target'];
6
7
  onClick?: () => void;
7
8
  className?: string;
8
9
  styles?: CSSProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/carousel/Carousel.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAIxF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,kBAAkB,GAAG;IACnD,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAErC,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AACnE,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;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AI,CAAC;CACpC;AAUD,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAmSrC,CAAC;AAYF,eAAe,QAAQ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxButton.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/CheckboxButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAc,MAAM,OAAO,CAAC;AAExD,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAExE,QAAA,MAAM,cAAc,kHAgBnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"CheckboxButton.d.ts","sourceRoot":"","sources":["../../../src/checkboxButton/CheckboxButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAc,MAAM,OAAO,CAAC;AAIxD,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAExE,QAAA,MAAM,cAAc,kHAsBlB,CAAC;AAEH,eAAe,cAAc,CAAC"}
@@ -2,7 +2,8 @@ import { Sentiment } from '../common';
2
2
  export type FieldProps = {
3
3
  /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */
4
4
  id?: string | null;
5
- label: React.ReactNode;
5
+ /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */
6
+ label?: React.ReactNode;
6
7
  /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */
7
8
  hint?: React.ReactNode;
8
9
  message?: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../../src/field/Field.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAUtC,MAAM,MAAM,UAAU,GAAG;IACvB,6IAA6I;IAC7I,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,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iDZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.43.0",
3
+ "version": "46.44.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -93,8 +93,8 @@
93
93
  "rollup": "^4.17.2",
94
94
  "storybook": "^8.1.10",
95
95
  "@transferwise/less-config": "3.1.0",
96
- "@wise/components-theming": "1.3.0",
97
- "@transferwise/neptune-css": "14.12.0"
96
+ "@transferwise/neptune-css": "14.12.0",
97
+ "@wise/components-theming": "1.3.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@transferwise/icons": "^3.7.0",
@@ -12,8 +12,6 @@
12
12
  gap: var(--size-16);
13
13
  padding: 8px;
14
14
  padding: var(--size-8);
15
- margin: 8px;
16
- margin: var(--size-8);
17
15
  }
18
16
  @media (max-width: 767px) {
19
17
  .carousel {
@@ -60,6 +58,15 @@
60
58
  height: 280px;
61
59
  }
62
60
  }
61
+ @media (min-width: 768px) {
62
+ .carousel-wrapper {
63
+ overflow: visible;
64
+ }
65
+ .carousel {
66
+ margin: 0 calc(-1 * 8px);
67
+ margin: 0 calc(-1 * var(--size-8));
68
+ }
69
+ }
63
70
  @media (max-width: 1199px) {
64
71
  .carousel__card {
65
72
  min-width: 242px;
@@ -11,7 +11,6 @@
11
11
  scroll-behavior: smooth;
12
12
  gap: var(--size-16);
13
13
  padding: var(--size-8);
14
- margin: var(--size-8);
15
14
  }
16
15
 
17
16
  @media (--screen-sm-max) {
@@ -60,6 +59,16 @@
60
59
  }
61
60
  }
62
61
 
62
+ @media (--screen-md) {
63
+ .carousel-wrapper {
64
+ overflow: visible;
65
+ }
66
+
67
+ .carousel {
68
+ margin: 0 calc(-1 * var(--size-8));
69
+ }
70
+ }
71
+
63
72
 
64
73
  @media (--screen-lg-max) {
65
74
  .carousel__card {
@@ -43,6 +43,7 @@ const carouselCards: CarouselCard[] = [
43
43
  id: 'SHOP_OR_STALL',
44
44
  type: 'anchor',
45
45
  href: 'https://wise.com',
46
+ hrefTarget: '_blank',
46
47
  onClick: () => {},
47
48
  styles: {
48
49
  backgroundImage:
@@ -10,6 +10,7 @@ import PromoCard from '../promoCard/PromoCard';
10
10
  export type CarouselCardCommon = {
11
11
  id: string;
12
12
  href?: string;
13
+ hrefTarget?: HTMLAnchorElement['target'];
13
14
  onClick?: () => void;
14
15
  className?: string;
15
16
  styles?: CSSProperties;
@@ -300,6 +301,7 @@ const Carousel: React.FC<CarouselProps> = ({ header, className, cards, onClick }
300
301
  }
301
302
  }}
302
303
  href={card.href}
304
+ target={card.hrefTarget}
303
305
  rel="noreferrer"
304
306
  onKeyDown={(event) => handleOnKeyDown(event, index)}
305
307
  >
@@ -1,6 +1,7 @@
1
1
  import { render, fireEvent, screen } from '@testing-library/react';
2
2
 
3
3
  import Checkbox, { CheckboxProps } from '.';
4
+ import { Field } from '../field/Field';
4
5
 
5
6
  describe('Checkbox', () => {
6
7
  let props: CheckboxProps;
@@ -115,6 +116,18 @@ describe('Checkbox', () => {
115
116
  expect(getCheckboxContainer(container)).toHaveClass('checkbox-lg');
116
117
  });
117
118
 
119
+ it('supports `Field` for error messages', () => {
120
+ render(
121
+ <Field message="Something went wrong" sentiment="negative">
122
+ <Checkbox {...props} checked />
123
+ </Field>,
124
+ );
125
+
126
+ const checkbox = screen.getByRole('checkbox');
127
+ expect(checkbox).toBeInvalid();
128
+ expect(checkbox).toHaveAccessibleDescription('Something went wrong');
129
+ });
130
+
118
131
  const getCheckboxContainer = (container: HTMLElement) => container.querySelector('.np-checkbox');
119
132
  const getLabel = () => screen.getByText('hello').parentElement!;
120
133
  const getCheckbox = () => screen.getByRole('checkbox');
@@ -1,5 +1,7 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
+ import { fn } from '@storybook/test';
2
3
 
4
+ import { Field } from '../field/Field';
3
5
  import { lorem10, storyConfig } from '../test-utils';
4
6
 
5
7
  import Checkbox from './Checkbox';
@@ -9,6 +11,7 @@ export default {
9
11
  title: 'Forms/Checkbox',
10
12
  args: {
11
13
  label: 'This is the label',
14
+ onChange: fn(),
12
15
  },
13
16
  tags: ['autodocs'],
14
17
  } satisfies Meta<typeof Checkbox>;
@@ -37,3 +40,13 @@ export const Multiple: Story = storyConfig(
37
40
  export const MultipleMobile: Story = storyConfig(Multiple, {
38
41
  variants: ['default', 'dark', 'rtl', 'mobile'],
39
42
  });
43
+
44
+ export const WithinField = {
45
+ decorators: [
46
+ (Story) => (
47
+ <Field message="Something went wrong" sentiment="negative">
48
+ <Story />
49
+ </Field>
50
+ ),
51
+ ],
52
+ } satisfies Story;
@@ -1,12 +1,20 @@
1
1
  import classNames from 'classnames';
2
2
  import { InputHTMLAttributes, forwardRef } from 'react';
3
3
 
4
+ import { useInputAttributes } from '../inputs/contexts';
5
+
4
6
  export type CheckboxButtonProps = InputHTMLAttributes<HTMLInputElement>;
5
7
 
6
- const CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(
7
- ({ checked, className, disabled, onChange, ...rest }, reference) => (
8
+ const CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(function CheckboxButton(
9
+ { checked, className, disabled, onChange, ...rest },
10
+ reference,
11
+ ) {
12
+ const inputAttributes = useInputAttributes();
13
+
14
+ return (
8
15
  <span className={classNames('np-checkbox-button', className, disabled && 'disabled')}>
9
16
  <input
17
+ {...inputAttributes}
10
18
  {...rest}
11
19
  ref={reference}
12
20
  type="checkbox"
@@ -18,7 +26,7 @@ const CheckboxButton = forwardRef<HTMLInputElement, CheckboxButtonProps>(
18
26
  <span className="tw-checkbox-check" />
19
27
  </span>
20
28
  </span>
21
- ),
22
- );
29
+ );
30
+ });
23
31
 
24
32
  export default CheckboxButton;
@@ -14,7 +14,8 @@ import { Label } from '../label/Label';
14
14
  export type FieldProps = {
15
15
  /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */
16
16
  id?: string | null;
17
- label: React.ReactNode;
17
+ /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */
18
+ label?: React.ReactNode;
18
19
  /** @deprecated use `message` and `type={Sentiment.NEUTRAL}` prop instead */
19
20
  hint?: React.ReactNode;
20
21
  message?: React.ReactNode;
@@ -62,10 +63,15 @@ export const Field = ({
62
63
  className,
63
64
  )}
64
65
  >
65
- <Label id={labelId} htmlFor={inputId}>
66
- {label}
67
- {children}
68
- </Label>
66
+ {label != null ? (
67
+ <Label id={labelId} htmlFor={inputId}>
68
+ {label}
69
+ {children}
70
+ </Label>
71
+ ) : (
72
+ children
73
+ )}
74
+
69
75
  {message && (
70
76
  <InlineAlert type={sentiment} id={descriptionId}>
71
77
  {message}
package/src/main.css CHANGED
@@ -657,8 +657,6 @@ div.critical-comms .critical-comms-body {
657
657
  gap: var(--size-16);
658
658
  padding: 8px;
659
659
  padding: var(--size-8);
660
- margin: 8px;
661
- margin: var(--size-8);
662
660
  }
663
661
  @media (max-width: 767px) {
664
662
  .carousel {
@@ -705,6 +703,15 @@ div.critical-comms .critical-comms-body {
705
703
  height: 280px;
706
704
  }
707
705
  }
706
+ @media (min-width: 768px) {
707
+ .carousel-wrapper {
708
+ overflow: visible;
709
+ }
710
+ .carousel {
711
+ margin: 0 calc(-1 * 8px);
712
+ margin: 0 calc(-1 * var(--size-8));
713
+ }
714
+ }
708
715
  @media (max-width: 1199px) {
709
716
  .carousel__card {
710
717
  min-width: 242px;