@transferwise/components 0.0.0-experimental-ab487a4 → 0.0.0-experimental-79f845b

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 (32) hide show
  1. package/build/dateInput/DateInput.js +2 -2
  2. package/build/dateInput/DateInput.js.map +1 -1
  3. package/build/dateInput/DateInput.mjs +2 -2
  4. package/build/dateInput/DateInput.mjs.map +1 -1
  5. package/build/inputs/_BottomSheet.js +1 -29
  6. package/build/inputs/_BottomSheet.js.map +1 -1
  7. package/build/inputs/_BottomSheet.mjs +2 -30
  8. package/build/inputs/_BottomSheet.mjs.map +1 -1
  9. package/build/main.css +8 -15
  10. package/build/phoneNumberInput/PhoneNumberInput.js +1 -1
  11. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  12. package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -1
  13. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  14. package/build/styles/inputs/Input.css +5 -0
  15. package/build/styles/inputs/SelectInput.css +3 -15
  16. package/build/styles/inputs/TextArea.css +5 -0
  17. package/build/styles/main.css +8 -15
  18. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  19. package/package.json +5 -5
  20. package/src/DisabledComponents.story.tsx +156 -0
  21. package/src/dateInput/DateInput.tsx +2 -2
  22. package/src/inputs/Input.css +5 -0
  23. package/src/inputs/SelectInput.css +3 -15
  24. package/src/inputs/TextArea.css +5 -0
  25. package/src/inputs/_BottomSheet.less +3 -16
  26. package/src/inputs/_BottomSheet.tsx +3 -19
  27. package/src/inputs/_common.less +5 -0
  28. package/src/main.css +8 -15
  29. package/src/phoneNumberInput/PhoneNumberInput.tsx +1 -1
  30. package/src/common/bottomSheet/BottomSheet.test.story.tsx +0 -94
  31. package/src/inputs/SelectInput.test.story.tsx +0 -83
  32. package/src/moneyInput/MoneyInput.test.story.tsx +0 -101
@@ -1,12 +1,3 @@
1
- .wds-select-input-scroll-freeze {
2
- scroll-behavior: unset !important;
3
- height: 100vh;
4
-
5
- body{
6
- height: 100vh;
7
- }
8
- }
9
-
10
1
  .np-bottom-sheet-v2-container {
11
2
  position: relative;
12
3
  z-index: 1060;
@@ -20,8 +11,6 @@
20
11
  transition-property: opacity;
21
12
  transition-timing-function: ease-out;
22
13
  transition-duration: 300ms;
23
- will-change: transform;
24
- min-height: 100vh;
25
14
 
26
15
  &--closed {
27
16
  opacity: 0;
@@ -31,25 +20,23 @@
31
20
  .np-bottom-sheet-v2 {
32
21
  position: fixed;
33
22
  inset: 0px;
34
- bottom: env(safe-area-inset-bottom, 0);
23
+ bottom: env(keyboard-inset-height, 0px);
35
24
  margin-left: var(--size-8);
36
25
  margin-right: var(--size-8);
37
26
  margin-top: var(--size-64);
38
27
  display: flex;
39
28
  flex-direction: column;
40
29
  justify-content: flex-end;
41
- height: calc(100vh - var(--size-64) - 40px);
42
30
  }
43
31
 
44
32
  .np-bottom-sheet-v2-content {
45
33
  display: flex;
46
34
  flex-direction: column;
47
35
  overflow: auto;
48
- border-top-left-radius: var(--size-32);
49
- border-top-right-radius: var(--size-32);
36
+ border-top-left-radius: 32px; /* TODO: Tokenize */
37
+ border-top-right-radius: 32px; /* TODO: Tokenize */
50
38
  background-color: var(--color-background-elevated);
51
39
  box-shadow: 0 0 40px rgb(69 71 69 / 0.2);
52
- will-change: transform;
53
40
 
54
41
  &:focus {
55
42
  outline: none;
@@ -10,11 +10,12 @@ import { Transition } from '@headlessui/react';
10
10
  import { FocusScope } from '@react-aria/focus';
11
11
  import { ThemeProvider, useTheme } from '@wise/components-theming';
12
12
  import { clsx } from 'clsx';
13
- import { Fragment, useEffect, useState } from 'react';
13
+ import { Fragment, useState } from 'react';
14
14
 
15
- import { CloseButton , Size } from '../common';
15
+ import { CloseButton } from '../common/closeButton';
16
16
  import { useVirtualKeyboard } from '../common/hooks/useVirtualKeyboard';
17
17
  import { PreventScroll } from '../common/preventScroll/PreventScroll';
18
+ import { Size } from '../common/propsValues/size';
18
19
 
19
20
  export interface BottomSheetProps {
20
21
  open: boolean;
@@ -32,19 +33,6 @@ export interface BottomSheetProps {
32
33
  onCloseEnd?: () => void;
33
34
  }
34
35
 
35
- /**
36
- * App pages set scroll-behavior to 'smooth' which causes mobile Safari to
37
- * slow-scroll and glitch. This function temporarily disables that behaviour
38
- * while the BottomSheet is open.
39
- */
40
- const freezeScroll = (shouldFreeze = true) => {
41
- if (shouldFreeze) {
42
- document.documentElement.classList.add('wds-select-input-scroll-freeze');
43
- } else {
44
- document.documentElement.classList.remove('wds-select-input-scroll-freeze');
45
- }
46
- };
47
-
48
36
  export function BottomSheet({
49
37
  open,
50
38
  renderTrigger,
@@ -66,10 +54,6 @@ export function BottomSheet({
66
54
  },
67
55
  });
68
56
 
69
- useEffect(() => {
70
- freezeScroll(open);
71
- }, [open]);
72
-
73
57
  const dismiss = useDismiss(context);
74
58
  const role = useRole(context);
75
59
  const { getReferenceProps, getFloatingProps } = useInteractions([dismiss, role]);
@@ -15,6 +15,11 @@
15
15
  transition-timing-function: ease-in-out;
16
16
  transition-duration: 300ms;
17
17
 
18
+ .disabled &,
19
+ :disabled & {
20
+ opacity: unset;
21
+ }
22
+
18
23
  &:focus-visible {
19
24
  outline: none;
20
25
  }
package/src/main.css CHANGED
@@ -2660,6 +2660,11 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2660
2660
  transition-duration: 300ms;
2661
2661
  /* TODO: Remove these overrides once `.form-control` isn’t used anymore */
2662
2662
  }
2663
+ .disabled .np-form-control,
2664
+ :disabled .np-form-control {
2665
+ opacity: 1;
2666
+ opacity: initial;
2667
+ }
2663
2668
  .np-form-control:focus-visible {
2664
2669
  outline: none;
2665
2670
  }
@@ -3519,13 +3524,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3519
3524
  padding-inline-start: 8px;
3520
3525
  padding-inline-start: var(--size-8);
3521
3526
  }
3522
- .wds-select-input-scroll-freeze {
3523
- scroll-behavior: unset !important;
3524
- height: 100vh;
3525
- }
3526
- .wds-select-input-scroll-freeze body {
3527
- height: 100vh;
3528
- }
3529
3527
  .np-bottom-sheet-v2-container {
3530
3528
  position: relative;
3531
3529
  z-index: 1060;
@@ -3539,8 +3537,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3539
3537
  transition-property: opacity;
3540
3538
  transition-timing-function: ease-out;
3541
3539
  transition-duration: 300ms;
3542
- will-change: transform;
3543
- min-height: 100vh;
3544
3540
  }
3545
3541
  .np-bottom-sheet-v2-backdrop--closed {
3546
3542
  opacity: 0;
@@ -3548,7 +3544,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3548
3544
  .np-bottom-sheet-v2 {
3549
3545
  position: fixed;
3550
3546
  inset: 0px;
3551
- bottom: env(safe-area-inset-bottom, 0);
3547
+ bottom: env(keyboard-inset-height, 0px);
3552
3548
  margin-left: 8px;
3553
3549
  margin-left: var(--size-8);
3554
3550
  margin-right: 8px;
@@ -3558,21 +3554,18 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3558
3554
  display: flex;
3559
3555
  flex-direction: column;
3560
3556
  justify-content: flex-end;
3561
- height: calc(100vh - 64px - 40px);
3562
- height: calc(100vh - var(--size-64) - 40px);
3563
3557
  }
3564
3558
  .np-bottom-sheet-v2-content {
3565
3559
  display: flex;
3566
3560
  flex-direction: column;
3567
3561
  overflow: auto;
3568
3562
  border-top-left-radius: 32px;
3569
- border-top-left-radius: var(--size-32);
3563
+ /* TODO: Tokenize */
3570
3564
  border-top-right-radius: 32px;
3571
- border-top-right-radius: var(--size-32);
3565
+ /* TODO: Tokenize */
3572
3566
  background-color: #ffffff;
3573
3567
  background-color: var(--color-background-elevated);
3574
3568
  box-shadow: 0 0 40px rgba(69, 71, 69, 0.2);
3575
- will-change: transform;
3576
3569
  }
3577
3570
  .np-bottom-sheet-v2-content:focus {
3578
3571
  outline: none;
@@ -245,7 +245,7 @@ const PhoneNumberInput = ({
245
245
  {formatMessage(messages.phoneNumberLabel)}
246
246
  </label>
247
247
  <div className="tw-telephone__number-input">
248
- <div className={`input-group input-group-${size}`}>
248
+ <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>
249
249
  <Input
250
250
  ref={phoneNumberInputRef}
251
251
  id={ids.phoneNumber.input}
@@ -1,94 +0,0 @@
1
- import { useState } from 'react';
2
- import { Meta, StoryObj } from '@storybook/react-webpack5';
3
- import { userEvent, within } from 'storybook/test';
4
- import { lorem100, lorem500 } from '../../test-utils';
5
- import { Typography } from '../propsValues/typography';
6
- import Alert from '../../alert';
7
- import Body from '../../body';
8
- import Button from '../../button';
9
- import Title from '../../title';
10
- import BottomSheet from './BottomSheet';
11
-
12
- const wait = async (duration = 500) =>
13
- new Promise<void>((resolve) => {
14
- setTimeout(resolve, duration);
15
- });
16
-
17
- export default {
18
- component: BottomSheet,
19
- title: 'Dialogs/BottomSheet/tests',
20
- tags: ['!autodocs'],
21
- args: {
22
- open: false,
23
- },
24
- } satisfies Meta<typeof BottomSheet>;
25
-
26
- type Story = StoryObj<typeof BottomSheet>;
27
-
28
- /**
29
- * This test ensures that when the SelectInput is used within a scrollable page,
30
- * opening the dropdown does not cause any unwanted scrolling or layout shifts.
31
- * Expected preview should start with green bar at the top, with yellow section
32
- * not in the viewport.
33
- *
34
- * NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
35
- */
36
- export const SmoothScrollReset: Story = {
37
- args: {
38
- children: (
39
- <>
40
- <Title type={Typography.TITLE_SECTION}>Observe the document</Title>
41
- <Alert className="m-t-2" type="warning">
42
- Once the <code>BottomSheet</code> opens, the document underneath should be static and
43
- should not scroll.
44
- </Alert>
45
- <Body as="p">{lorem100}</Body>
46
- <Body as="p">{lorem100}</Body>
47
- </>
48
- ),
49
- },
50
- decorators: [
51
- (Story) => (
52
- <>
53
- <style>{'html { scroll-behavior: smooth; }'}</style>
54
- <div style={{ maxWidth: 500 }}>
55
- <Body>
56
- <p>{lorem100}</p>
57
- <p>{lorem100}</p>
58
- </Body>
59
- <Story />
60
- <Body as="p" className="m-t-5 disabled">
61
- {lorem500}
62
- </Body>
63
- </div>
64
- </>
65
- ),
66
- ],
67
- parameters: {
68
- chromatic: {
69
- disableSnapshot: true,
70
- },
71
- },
72
- play: async ({ canvasElement }) => {
73
- document.documentElement.scrollTop = 400;
74
- await wait(500);
75
- const canvas = within(canvasElement);
76
- await userEvent.click(canvas.getByRole('button'));
77
- },
78
- render: ({ open, ...args }) => {
79
- const [isOpen, setIsOpen] = useState(false);
80
-
81
- return (
82
- <div>
83
- <Button onClick={() => setIsOpen(true)}>Open BottomSheet</Button>
84
- <BottomSheet
85
- {...args}
86
- open={isOpen}
87
- onClose={() => {
88
- setIsOpen(false);
89
- }}
90
- />
91
- </div>
92
- );
93
- },
94
- };
@@ -1,83 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { fn, type Mock, userEvent, within } from 'storybook/test';
3
- import { allModes } from '../../.storybook/modes';
4
- import { lorem5, lorem500 } from '../test-utils';
5
- import { Field } from '../field/Field';
6
- import Body from '../body';
7
- import { SelectInput, type SelectInputProps } from './SelectInput';
8
-
9
- const meta = {
10
- title: 'Forms/SelectInput/tests',
11
- component: SelectInput,
12
- args: {
13
- onFilterChange: fn() satisfies Mock,
14
- onChange: fn() satisfies Mock,
15
- onClose: fn() satisfies Mock,
16
- onOpen: fn() satisfies Mock,
17
- },
18
- tags: ['!autodocs'],
19
- } satisfies Meta<typeof SelectInput>;
20
- export default meta;
21
-
22
- type Story<T, M extends boolean = false> = StoryObj<SelectInputProps<T, M>>;
23
-
24
- const wait = async (duration = 500) =>
25
- new Promise<void>((resolve) => {
26
- setTimeout(resolve, duration);
27
- });
28
-
29
- /**
30
- * This test ensures that when the SelectInput is used within a scrollable page,
31
- * opening the dropdown does not cause any unwanted scrolling or layout shifts.
32
- * Expected preview should start with green bar at the top, with yellow section
33
- * not in the viewport.
34
- *
35
- * NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
36
- */
37
- export const SmoothScrollReset: Story<string> = {
38
- args: {
39
- items: Array.from({ length: 15 }).map((_, id) => ({
40
- type: 'option',
41
- value: `option ${id + 1}`,
42
- })),
43
- placeholder: 'Select option',
44
- },
45
- decorators: [
46
- (Story) => (
47
- <>
48
- <style>{`html { scroll-behavior: smooth; }`}</style>
49
- <div>
50
- <div
51
- className="d-flex align-items-center justify-content-center"
52
- style={{
53
- backgroundColor: 'var(--color-bright-yellow)',
54
- height: 400,
55
- }}
56
- >
57
- This block should not be in the viewport.
58
- </div>
59
- <div style={{ height: 10, backgroundColor: 'var(--color-bright-green)' }} />
60
- <Field id="el1" label={lorem5}>
61
- <Story />
62
- </Field>
63
- <Body as="p">{lorem500}</Body>
64
- </div>
65
- </>
66
- ),
67
- ],
68
- play: async ({ canvasElement }) => {
69
- document.documentElement.scrollTop = 400;
70
- await wait();
71
- const canvas = within(canvasElement);
72
- const triggerButton = canvas.getByRole('combobox');
73
- await userEvent.click(triggerButton);
74
- },
75
- globals: {
76
- viewport: { value: allModes.largeMobile.viewport, isRotated: false },
77
- },
78
- parameters: {
79
- chromatic: {
80
- disableSnapshot: true,
81
- },
82
- },
83
- };
@@ -1,101 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
- import { userEvent, within } from 'storybook/test';
3
- import { allModes } from '../../.storybook/modes';
4
- import { lorem500 } from '../test-utils';
5
- import { Field } from '../field/Field';
6
- import Body from '../body';
7
- import MoneyInput from './MoneyInput';
8
-
9
- const meta = {
10
- title: 'Forms/MoneyInput/tests',
11
- component: MoneyInput,
12
- args: {
13
- amount: 1000,
14
- id: 'moneyInput',
15
- currencies: [
16
- {
17
- value: 'EUR',
18
- label: 'EUR',
19
- note: 'Euro',
20
- currency: 'eur',
21
- searchable: 'Spain, Germany, France, Austria',
22
- },
23
- {
24
- value: 'GBP',
25
- label: 'GBP',
26
- note: 'British pound',
27
- currency: 'gbp',
28
- searchable: 'England, Scotland, Wales',
29
- },
30
- ],
31
- selectedCurrency: {
32
- value: 'EUR',
33
- label: 'EUR',
34
- note: 'Euro',
35
- currency: 'eur',
36
- searchable: 'Spain, Germany, France, Austria',
37
- },
38
- searchPlaceholder: '',
39
- onAmountChange: () => {},
40
- onCurrencyChange: () => {},
41
- },
42
- tags: ['!autodocs'],
43
- } satisfies Meta<typeof MoneyInput>;
44
- export default meta;
45
-
46
- type Story = StoryObj<typeof MoneyInput>;
47
-
48
- const wait = async (duration = 500) =>
49
- new Promise<void>((resolve) => {
50
- setTimeout(resolve, duration);
51
- });
52
-
53
- /**
54
- * This test ensures that when the SelectInput is used within a scrollable page,
55
- * opening the dropdown does not cause any unwanted scrolling or layout shifts.
56
- * Expected preview should start with green bar at the top, with yellow section
57
- * not in the viewport.
58
- *
59
- * NB: This test is disabled in Chromatic as there's no obvious way to control <html/> element of a snapshot.
60
- */
61
- export const SmoothScrollReset: Story = {
62
- decorators: [
63
- (Story) => (
64
- <>
65
- <style>{`html { scroll-behavior: smooth; }`}</style>
66
- <div>
67
- <div
68
- className="d-flex align-items-center justify-content-center"
69
- style={{
70
- backgroundColor: 'var(--color-bright-yellow)',
71
- height: 400,
72
- }}
73
- >
74
- This block should not be in the viewport.
75
- </div>
76
- <div style={{ height: 10, backgroundColor: 'var(--color-bright-green)' }} />
77
- <Field id="el1" label="Select currency">
78
- <Story />
79
- </Field>
80
- <Body as="p">{lorem500}</Body>
81
- </div>
82
- </>
83
- ),
84
- ],
85
- play: async ({ canvasElement }) => {
86
- await wait();
87
- document.documentElement.scrollTop = 400;
88
- await wait();
89
- const canvas = within(canvasElement);
90
- const triggerButton = canvas.getByRole('combobox');
91
- await userEvent.click(triggerButton);
92
- },
93
- globals: {
94
- viewport: { value: allModes.largeMobile.viewport, isRotated: false },
95
- },
96
- parameters: {
97
- chromatic: {
98
- disableSnapshot: true,
99
- },
100
- },
101
- };