@transferwise/components 46.100.1 → 46.101.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.
Files changed (190) hide show
  1. package/build/avatarLayout/AvatarLayout.js +1 -1
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +1 -1
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/dateLookup/DateLookup.js +3 -2
  6. package/build/dateLookup/DateLookup.js.map +1 -1
  7. package/build/dateLookup/DateLookup.mjs +3 -2
  8. package/build/dateLookup/DateLookup.mjs.map +1 -1
  9. package/build/i18n/en.json +2 -0
  10. package/build/i18n/en.json.js +2 -0
  11. package/build/i18n/en.json.js.map +1 -1
  12. package/build/i18n/en.json.mjs +2 -0
  13. package/build/i18n/en.json.mjs.map +1 -1
  14. package/build/main.css +4 -94
  15. package/build/styles/accordion/Accordion.css +27 -16
  16. package/build/styles/avatar/Avatar.css +95 -50
  17. package/build/styles/inputs/Input.css +37 -21
  18. package/build/styles/inputs/TextArea.css +35 -20
  19. package/build/styles/loader/Loader.css +4 -90
  20. package/build/styles/main.css +4 -94
  21. package/build/styles/popover/Popover.css +19 -12
  22. package/build/styles/select/Select.css +131 -68
  23. package/build/styles/switch/Switch.css +27 -16
  24. package/build/styles/tile/Tile.css +31 -18
  25. package/build/types/dateLookup/DateLookup.d.ts +2 -2
  26. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  27. package/build/types/test-utils/index.d.ts +4 -0
  28. package/build/types/test-utils/index.d.ts.map +1 -1
  29. package/build/types/test-utils/story-config.d.ts +2 -3
  30. package/build/types/test-utils/story-config.d.ts.map +1 -1
  31. package/build/types/upload/Upload.d.ts +6 -2
  32. package/build/types/upload/Upload.d.ts.map +1 -1
  33. package/build/types/upload/Upload.messages.d.ts +8 -0
  34. package/build/types/upload/Upload.messages.d.ts.map +1 -1
  35. package/build/types/uploadInput/UploadInput.d.ts +1 -1
  36. package/build/types/uploadInput/uploadButton/UploadButton.d.ts +4 -2
  37. package/build/types/uploadInput/uploadButton/UploadButton.d.ts.map +1 -1
  38. package/build/upload/Upload.js +16 -9
  39. package/build/upload/Upload.js.map +1 -1
  40. package/build/upload/Upload.messages.js +6 -0
  41. package/build/upload/Upload.messages.js.map +1 -1
  42. package/build/upload/Upload.messages.mjs +6 -0
  43. package/build/upload/Upload.messages.mjs.map +1 -1
  44. package/build/upload/Upload.mjs +16 -9
  45. package/build/upload/Upload.mjs.map +1 -1
  46. package/build/uploadInput/UploadInput.js +1 -1
  47. package/build/uploadInput/UploadInput.js.map +1 -1
  48. package/build/uploadInput/UploadInput.mjs +1 -1
  49. package/build/uploadInput/UploadInput.mjs.map +1 -1
  50. package/build/uploadInput/uploadButton/UploadButton.js +7 -4
  51. package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
  52. package/build/uploadInput/uploadButton/UploadButton.mjs +7 -4
  53. package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
  54. package/package.json +19 -27
  55. package/src/accordion/Accordion.css +27 -16
  56. package/src/accordion/Accordion.story.tsx +1 -1
  57. package/src/actionButton/ActionButton.story.tsx +3 -2
  58. package/src/actionOption/ActionOption.story.tsx +2 -2
  59. package/src/alert/Alert.story.tsx +2 -2
  60. package/src/alert/Alert.tests.story.tsx +2 -2
  61. package/src/avatar/Avatar.css +95 -50
  62. package/src/avatar/Avatar.spec.tsx +1 -1
  63. package/src/avatar/Avatar.story.tsx +3 -2
  64. package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
  65. package/src/avatarLayout/AvatarLayout.tsx +1 -1
  66. package/src/avatarView/AvatarView.story.tsx +1 -1
  67. package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
  68. package/src/badge/Badge.story.tsx +49 -28
  69. package/src/button/Button.accessibility.docs.mdx +1 -1
  70. package/src/button/Button.story.tsx +2 -2
  71. package/src/button/Button.tests.story.tsx +2 -2
  72. package/src/button/LegacyButton.story.tsx +3 -2
  73. package/src/card/Card.story.tsx +2 -2
  74. package/src/carousel/Carousel.story.tsx +1 -1
  75. package/src/checkbox/Checkbox.story.tsx +2 -2
  76. package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
  77. package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
  78. package/src/chevron/Chevron.story.tsx +1 -1
  79. package/src/chips/Chips.story.tsx +1 -1
  80. package/src/circularButton/CircularButton.story.tsx +1 -1
  81. package/src/circularButton/CircularButton.tests.story.tsx +1 -1
  82. package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
  83. package/src/common/card/Card.story.tsx +1 -1
  84. package/src/common/circle/Circle.story.tsx +2 -2
  85. package/src/common/locale/index.spec.ts +28 -16
  86. package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
  87. package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
  88. package/src/dateInput/DateInput.story.tsx +2 -2
  89. package/src/dateInput/DateInput.tests.story.tsx +2 -2
  90. package/src/dateLookup/DateLookup.spec.tsx +5 -5
  91. package/src/dateLookup/DateLookup.story.tsx +43 -71
  92. package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
  93. package/src/dateLookup/DateLookup.tsx +4 -1
  94. package/src/decision/Decision.story.tsx +24 -49
  95. package/src/definitionList/DefinitionList.story.tsx +1 -1
  96. package/src/dimmer/Dimmer.story.tsx +2 -2
  97. package/src/divider/Divider.accessibility.docs.mdx +1 -1
  98. package/src/divider/Divider.story.tsx +1 -1
  99. package/src/drawer/Drawer.story.tsx +13 -7
  100. package/src/dropFade/DropFade.story.tsx +1 -1
  101. package/src/emphasis/Emphasis.spec.tsx +8 -8
  102. package/src/emphasis/Emphasis.story.tsx +1 -1
  103. package/src/field/Field.story.tsx +3 -3
  104. package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
  105. package/src/i18n/en.json +2 -0
  106. package/src/iconButton/IconButton.story.tsx +2 -2
  107. package/src/image/Image.story.tsx +27 -54
  108. package/src/info/Info.story.tsx +2 -2
  109. package/src/inlineAlert/InlineAlert.story.tsx +1 -1
  110. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
  111. package/src/inputs/Input.css +37 -21
  112. package/src/inputs/InputGroup.story.tsx +1 -1
  113. package/src/inputs/SearchInput.story.tsx +1 -1
  114. package/src/inputs/SelectInput.docs.mdx +1 -1
  115. package/src/inputs/SelectInput.story.tsx +2 -2
  116. package/src/inputs/TextArea.css +35 -20
  117. package/src/instructionsList/InstructionsList.story.tsx +2 -2
  118. package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
  119. package/src/loader/Loader.css +4 -90
  120. package/src/loader/Loader.story.tsx +1 -1
  121. package/src/logo/Logo.story.tsx +1 -1
  122. package/src/main.css +4 -94
  123. package/src/markdown/Markdown.story.tsx +1 -1
  124. package/src/modal/Modal.story.tsx +2 -2
  125. package/src/money/Money.story.tsx +1 -1
  126. package/src/moneyInput/MoneyInput.docs.mdx +1 -1
  127. package/src/moneyInput/MoneyInput.spec.tsx +8 -5
  128. package/src/moneyInput/MoneyInput.story.tsx +2 -2
  129. package/src/moneyInput/currencyFormatting.spec.ts +1 -1
  130. package/src/navigationOption/NavigationOption.story.tsx +265 -226
  131. package/src/nudge/Nudge.story.tsx +1 -1
  132. package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
  133. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
  134. package/src/phoneNumberInput/utils/setDefaultPrefix/setDefaultPrefix.spec.ts +6 -3
  135. package/src/popover/Popover.css +19 -12
  136. package/src/popover/Popover.story.tsx +2 -2
  137. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
  138. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
  139. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
  140. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
  141. package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
  142. package/src/progress/Progress.story.tsx +1 -1
  143. package/src/progressBar/ProgressBar.story.tsx +1 -1
  144. package/src/promoCard/PromoCard.story.tsx +1 -1
  145. package/src/promoCard/PromoCardGroup.story.tsx +1 -1
  146. package/src/provider/Provider.spec.tsx +2 -2
  147. package/src/provider/Provider.story.tsx +1 -1
  148. package/src/provider/direction/DirectionProvider.spec.tsx +1 -1
  149. package/src/provider/language/LanguageProvider.spec.tsx +1 -1
  150. package/src/provider/theme/ThemeProvider.story.tsx +1 -1
  151. package/src/radio/Radio.story.tsx +59 -42
  152. package/src/radioGroup/RadioGroup.story.tsx +2 -2
  153. package/src/radioOption/RadioOption.story.tsx +73 -38
  154. package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
  155. package/src/select/Select.css +131 -68
  156. package/src/select/Select.story.tsx +385 -397
  157. package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
  158. package/src/snackbar/Snackbar.story.tsx +50 -36
  159. package/src/snackbar/Snackbar.tests.story.tsx +3 -2
  160. package/src/statusIcon/StatusIcon.docs.mdx +1 -1
  161. package/src/statusIcon/StatusIcon.spec.tsx +8 -5
  162. package/src/statusIcon/StatusIcon.story.tsx +1 -1
  163. package/src/stepper/Stepper.story.tsx +2 -2
  164. package/src/stepper/Stepper.tests.story.tsx +2 -2
  165. package/src/sticky/Sticky.story.tsx +1 -1
  166. package/src/summary/Summary.story.tsx +18 -17
  167. package/src/switch/Switch.css +27 -16
  168. package/src/switch/Switch.story.tsx +2 -2
  169. package/src/switchOption/SwitchOption.story.tsx +1 -1
  170. package/src/table/Table.story.tsx +1 -1
  171. package/src/test-utils/story-config.ts +9 -6
  172. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
  173. package/src/tile/Tile.css +31 -18
  174. package/src/tile/Tile.story.tsx +43 -43
  175. package/src/tooltip/Tooltip.story.tsx +2 -2
  176. package/src/typeahead/Typeahead.story.tsx +2 -2
  177. package/src/upload/Upload.messages.ts +8 -0
  178. package/src/upload/Upload.spec.tsx +6 -0
  179. package/src/upload/Upload.story.tsx +120 -5
  180. package/src/upload/Upload.tests.story.tsx +5 -3
  181. package/src/upload/Upload.tsx +24 -15
  182. package/src/upload/utils/isTypeValid/isTypeValid.spec.ts +3 -1
  183. package/src/uploadInput/UploadInput.story.tsx +1 -1
  184. package/src/uploadInput/UploadInput.tests.story.tsx +10 -3
  185. package/src/uploadInput/UploadInput.tsx +2 -2
  186. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +6 -0
  187. package/src/uploadInput/uploadButton/UploadButton.tsx +12 -6
  188. package/src/withId/withId.docs.mdx +1 -1
  189. package/src/withId/withId.story.tsx +1 -1
  190. package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { fn } from 'storybook/test';
3
3
 
4
4
  import { Field } from '../field/Field';
5
5
  import { lorem10, storyConfig } from '../test-utils';
@@ -1,5 +1,5 @@
1
- import { action } from '@storybook/addon-actions';
2
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { action } from 'storybook/actions';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
  import { useState } from 'react';
4
4
 
5
5
  import CheckboxButton from './CheckboxButton';
@@ -1,66 +1,72 @@
1
- import { action } from '@storybook/addon-actions';
2
- import { boolean, text } from '@storybook/addon-knobs';
3
- import { Meta } from '@storybook/react';
4
- import { FastFlag as FastFlagIcon } from '@transferwise/icons';
5
1
  import { useState } from 'react';
6
-
2
+ import { action } from 'storybook/actions';
3
+ import { Meta } from '@storybook/react-webpack5';
4
+ import { FastFlag } from '@transferwise/icons';
7
5
  import { Nudge, Title, Typography } from '..';
8
-
9
- import CheckboxOption from './CheckboxOption';
6
+ import CheckboxOption, { type CheckboxOptionProps } from './CheckboxOption';
10
7
 
11
8
  const meta: Meta<typeof CheckboxOption> = {
12
9
  component: CheckboxOption,
13
10
  title: 'Option/CheckboxOption',
11
+ parameters: {
12
+ docs: {
13
+ source: { type: 'dynamic' },
14
+ },
15
+ },
14
16
  };
15
17
 
16
18
  export default meta;
17
19
 
18
- const Template = () => {
20
+ const commonArgs = {
21
+ disabled: false,
22
+ title: 'Checkbox option',
23
+ content: 'Normally, the button and icon are vertically centered.',
24
+ showMediaAtAllSizes: false,
25
+ isContainerAligned: false,
26
+ };
27
+
28
+ const renderTemplate = (args: Partial<CheckboxOptionProps> = commonArgs) => {
29
+ const mergedArgs = { ...commonArgs, ...args };
19
30
  const [checked, setChecked] = useState(true);
20
- const content = text('content', 'Normally, the button and icon are vertically centered.');
21
- const title = text('title', 'Checkbox option');
22
- const disabled = boolean('disabled', false);
23
- const showMediaAtAllSizes = boolean('showMediaAtAllSizes', false);
24
- const isContainerAligned = boolean('isContainerAligned', false);
25
31
 
26
32
  return (
27
33
  <CheckboxOption
28
34
  id="checkbox-option"
29
35
  name="checkbox-option"
30
36
  checked={checked}
31
- disabled={disabled}
32
- title={title}
33
- content={content}
34
- media={<FastFlagIcon />}
35
- showMediaAtAllSizes={showMediaAtAllSizes}
36
- isContainerAligned={isContainerAligned}
37
+ disabled={mergedArgs.disabled}
38
+ title={mergedArgs.title}
39
+ content={mergedArgs.content}
40
+ media={<FastFlag />}
41
+ showMediaAtAllSizes={mergedArgs.showMediaAtAllSizes}
42
+ isContainerAligned={mergedArgs.isContainerAligned}
37
43
  onChange={(newValue) => setChecked(newValue)}
38
44
  />
39
45
  );
40
46
  };
41
47
 
42
- export const Basic = () => {
43
- return <Template />;
48
+ export const Basic = (args: CheckboxOptionProps) => {
49
+ return renderTemplate(args);
44
50
  };
45
51
 
46
- export const Multiple = () => {
52
+ export const Multiple = (args: CheckboxOptionProps) => {
47
53
  return (
48
54
  <>
49
- <Template />
50
- <Template />
51
- <Template />
55
+ {renderTemplate(args)}
56
+ {renderTemplate(args)}
57
+ {renderTemplate(args)}
52
58
  </>
53
59
  );
54
60
  };
55
61
 
56
- export const WithContainerContent = () => (
62
+ export const WithContainerContent = (args: CheckboxOptionProps) => (
57
63
  <>
58
64
  <Title type={Typography.TITLE_SUBSECTION} className="m-b-1">
59
65
  Choose how to pay
60
66
  </Title>
61
- <Template />
62
- <Template />
63
- <Template />
67
+ {renderTemplate(args)}
68
+ {renderTemplate(args)}
69
+ {renderTemplate(args)}
64
70
  <div>
65
71
  <Nudge
66
72
  className="m-t-2"
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
3
  import Chevron from './Chevron';
4
4
 
@@ -1,4 +1,4 @@
1
- import { StoryFn, Meta } from '@storybook/react';
1
+ import { StoryFn, Meta } from '@storybook/react-webpack5';
2
2
  import { useState } from 'react';
3
3
 
4
4
  import Chips, { ChipsProps, ChipValue } from './Chips';
@@ -2,7 +2,7 @@ import * as Icons from '@transferwise/icons';
2
2
 
3
3
  import { ControlType, Priority } from '../common';
4
4
 
5
- import { Meta, StoryObj } from '@storybook/react';
5
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
6
6
  import CircularButton from './CircularButton';
7
7
  import { storyConfig } from '../test-utils';
8
8
  import Title from '../title';
@@ -1,6 +1,6 @@
1
1
  import { Freeze } from '@transferwise/icons';
2
2
 
3
- import { Meta, StoryObj } from '@storybook/react';
3
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
4
4
  import CircularButton from './CircularButton';
5
5
 
6
6
  export default {
@@ -1,5 +1,5 @@
1
- import { action } from '@storybook/addon-actions';
2
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { action } from 'storybook/actions';
2
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
3
3
  import { FastFlag } from '@transferwise/icons';
4
4
  import { useState } from 'react';
5
5
 
@@ -1,4 +1,4 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
 
3
3
  import { lorem10 } from '../../test-utils';
4
4
  import Title from '../../title';
@@ -1,8 +1,8 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { storyConfig } from '../../test-utils';
3
3
  import Circle from './Circle';
4
4
  import { Profile } from '@transferwise/icons';
5
- import { action } from '@storybook/addon-actions';
5
+ import { action } from 'storybook/actions';
6
6
  import { CircleProps } from '.';
7
7
  import Body from '../../body';
8
8
 
@@ -24,17 +24,20 @@ describe('locale utils', () => {
24
24
  ['zh_HK', 'zh'],
25
25
  ['ja-JP', 'ja'],
26
26
  ['zhHK', null],
27
- [null as any, null],
28
- [undefined as any, null],
27
+ [null, null],
28
+ [undefined, null],
29
29
  ['', null],
30
30
  [' ', null],
31
31
  ['ar-dz', null],
32
32
  ['ar-iq', null],
33
33
  ['zh-tw', 'zh'],
34
34
  ['nl-nl', 'nl'],
35
- ])('locale "%s" -> language "%s"', (locale, expectedValue) => {
36
- expect(getLangFromLocale(locale)).toBe(expectedValue);
37
- });
35
+ ])(
36
+ 'locale "%s" -> language "%s"',
37
+ (locale: string | null | undefined, expectedValue: string | null) => {
38
+ expect(getLangFromLocale(locale!)).toBe(expectedValue);
39
+ },
40
+ );
38
41
  });
39
42
 
40
43
  describe('adjustLocale', () => {
@@ -51,17 +54,20 @@ describe('locale utils', () => {
51
54
  ['zh_HK', 'zh-HK'],
52
55
  ['ja-JP', 'ja-JP'],
53
56
  ['zhHK', null],
54
- [null as any, null],
55
- [undefined as any, null],
57
+ [null, null],
58
+ [undefined, null],
56
59
  ['', null],
57
60
  [' ', null],
58
61
  ['ar-dz', 'ar-DZ'],
59
62
  ['ar-iq', 'ar-IQ'],
60
63
  ['zh-tw', 'zh-TW'],
61
64
  ['nl-nl', 'nl-NL'],
62
- ])('locale "%s" -> language "%s"', (locale, expectedValue) => {
63
- expect(adjustLocale(locale)).toBe(expectedValue);
64
- });
65
+ ])(
66
+ 'locale "%s" -> language "%s"',
67
+ (locale: string | null | undefined, expectedValue: string | null) => {
68
+ expect(adjustLocale(locale!)).toBe(expectedValue);
69
+ },
70
+ );
65
71
  });
66
72
 
67
73
  describe('getCountryFromLocale', () => {
@@ -75,9 +81,12 @@ describe('locale utils', () => {
75
81
  ['es_ES', 'ES'],
76
82
  ['es_E', null],
77
83
  ['es-E', null],
78
- ])('given an "%s" as a locale value it should return "%s"', (locale, expectedValue) => {
79
- expect(getCountryFromLocale(locale)).toBe(expectedValue);
80
- });
84
+ ])(
85
+ 'given an "%s" as a locale value it should return "%s"',
86
+ (locale: string, expectedValue: string | null) => {
87
+ expect(getCountryFromLocale(locale)).toBe(expectedValue);
88
+ },
89
+ );
81
90
  });
82
91
 
83
92
  describe('getDirectionFromLocale', () => {
@@ -87,8 +96,11 @@ describe('locale utils', () => {
87
96
  ['ar-AE', 'rtl'],
88
97
  ['ar_AE', 'rtl'],
89
98
  ['he', 'rtl'],
90
- ])('given an "%s" as a locale value it should return "%s"', (locale, expectedValue) => {
91
- expect(getDirectionFromLocale(locale)).toBe(expectedValue);
92
- });
99
+ ])(
100
+ 'given an "%s" as a locale value it should return "%s"',
101
+ (locale: string, expectedValue: string) => {
102
+ expect(getDirectionFromLocale(locale)).toBe(expectedValue);
103
+ },
104
+ );
93
105
  });
94
106
  });
@@ -1,32 +1,11 @@
1
1
  import { Breakpoint, Position } from '..';
2
- import { mockMatchMedia, render } from '../../test-utils';
2
+ import { mockMatchMedia, render, screen } from '../../test-utils';
3
+ import React, { forwardRef } from 'react';
3
4
 
4
5
  import ResponsivePanel from './ResponsivePanel';
5
6
 
6
7
  mockMatchMedia();
7
8
 
8
- jest.mock('../bottomSheet', () => {
9
- const { forwardRef } = require('react');
10
- return forwardRef(({ open, children }, reference) =>
11
- open ? (
12
- <div ref={reference} className="np-bottom-sheet">
13
- {children}
14
- </div>
15
- ) : null,
16
- );
17
- });
18
-
19
- jest.mock('../panel', () => {
20
- const { forwardRef } = require('react');
21
- return forwardRef(({ open, children }, reference) =>
22
- open ? (
23
- <div ref={reference} className="np-panel np-panel--open">
24
- {children}
25
- </div>
26
- ) : null,
27
- );
28
- });
29
-
30
9
  describe('ResponsivePanel', () => {
31
10
  const props = {
32
11
  arrow: true,
@@ -45,13 +24,13 @@ describe('ResponsivePanel', () => {
45
24
 
46
25
  describe('on desktop', () => {
47
26
  it('renders Panel', async () => {
48
- ({ container } = render(
27
+ render(
49
28
  <ResponsivePanel {...props} intialOpen>
50
29
  children
51
30
  </ResponsivePanel>,
52
- ));
31
+ );
53
32
 
54
- expect(container).toMatchSnapshot();
33
+ expect(screen.getByRole('dialog')).not.toHaveAttribute('aria-modal');
55
34
  });
56
35
  });
57
36
 
@@ -61,13 +40,13 @@ describe('ResponsivePanel', () => {
61
40
  });
62
41
 
63
42
  it('renders bottomSheet', async () => {
64
- ({ container } = render(
43
+ render(
65
44
  <ResponsivePanel {...props} open>
66
45
  children
67
46
  </ResponsivePanel>,
68
- ));
47
+ );
69
48
 
70
- expect(container).toMatchSnapshot();
49
+ expect(screen.getByRole('dialog')).toHaveAttribute('aria-modal');
71
50
  });
72
51
  });
73
52
  });
@@ -1,4 +1,4 @@
1
- import { Meta } from '@storybook/react';
1
+ import { Meta } from '@storybook/react-webpack5';
2
2
 
3
3
  import CriticalCommsBanner from '.';
4
4
  import { storyConfig } from '../test-utils';
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { fn } from 'storybook/test';
3
3
 
4
4
  import { DateInput } from '..';
5
5
 
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { userEvent, within, fn } from '@storybook/test';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { userEvent, within, fn } from 'storybook/test';
3
3
 
4
4
  import { DateInput, Field } from '..';
5
5
  import { lorem10, storyConfig } from '../test-utils';
@@ -42,9 +42,9 @@ describe('DateLookup', () => {
42
42
  expect(button).toHaveAttribute('aria-haspopup');
43
43
  });
44
44
 
45
- it.each([' ', '{Enter}', '{ArrowDown}', '{ArrowUp}', '{ArrowRight}', '{ArrowLeft}'])(
45
+ it.each([' ', '{Enter}', '{ArrowDown}', '{ArrowUp}', '{ArrowRight}', '{ArrowLeft}'] as const)(
46
46
  "opens with '%s' and closes with '{Escape}'",
47
- async (text) => {
47
+ async (text: string) => {
48
48
  render(<DateLookup value={initialValue} onChange={() => {}} />);
49
49
 
50
50
  await user.tab();
@@ -94,7 +94,7 @@ describe('DateLookup', () => {
94
94
  ['{ArrowRight}', +1],
95
95
  ['{ArrowUp}', -7],
96
96
  ['{ArrowDown}', +7],
97
- ])("handles '%s' to step %d day(s)", async (text, step) => {
97
+ ])("handles '%s' to step %d day(s)", async (text: string, step: number) => {
98
98
  const handleChange = jest.fn();
99
99
  await setupAndOpenWithMouse({ onChange: handleChange });
100
100
 
@@ -121,7 +121,7 @@ describe('DateLookup', () => {
121
121
  ['{ArrowRight}', +1],
122
122
  ['{ArrowUp}', -4],
123
123
  ['{ArrowDown}', +4],
124
- ])("handles '%s' to step %d year(s)", async (text, step) => {
124
+ ])("handles '%s' to step %d year(s)", async (text: string, step: number) => {
125
125
  const handleChange = jest.fn();
126
126
  await setupAndOpenWithMouse({ onChange: handleChange });
127
127
 
@@ -153,7 +153,7 @@ describe('DateLookup', () => {
153
153
  ['{ArrowRight}', +1],
154
154
  ['{ArrowUp}', -4],
155
155
  ['{ArrowDown}', +4],
156
- ])("handles '%s' to step %d month(s)", async (text, step) => {
156
+ ])("handles '%s' to step %d month(s)", async (text: string, step: number) => {
157
157
  const handleChange = jest.fn();
158
158
  await setupAndOpenWithMouse({ onChange: handleChange });
159
159
 
@@ -1,16 +1,24 @@
1
- import { boolean, select, text, date } from '@storybook/addon-knobs';
2
- import { userEvent } from '@storybook/test';
3
1
  import { useState } from 'react';
4
-
2
+ import { userEvent } from 'storybook/test';
5
3
  import { Field } from '..';
6
4
  import { Size } from '../common';
7
5
  import { storyConfig } from '../test-utils';
8
-
9
- import DateLookup from './DateLookup';
6
+ import DateLookup, { type DateLookupProps } from './DateLookup';
10
7
 
11
8
  export default {
12
9
  component: DateLookup,
13
10
  title: 'Forms/DateLookup',
11
+ argTypes: {
12
+ size: { control: 'select', options: [Size.SMALL, Size.MEDIUM, Size.LARGE] },
13
+ disabled: { control: 'boolean' },
14
+ label: { control: 'text' },
15
+ monthFormat: { control: 'select', options: ['long', 'short'] },
16
+ placeholder: { control: 'text' },
17
+ id: { control: 'text' },
18
+ clearable: { control: 'boolean' },
19
+ min: { control: 'date' },
20
+ max: { control: 'date' },
21
+ },
14
22
  };
15
23
 
16
24
  const epoch = new Date('2011-01-01');
@@ -18,92 +26,61 @@ const theFuture = new Date(epoch);
18
26
  theFuture.setUTCDate(epoch.getUTCDate() + 10);
19
27
  const thePast = new Date(epoch);
20
28
  thePast.setUTCDate(epoch.getUTCDate() - 10);
21
- const size = select('size', Object.values([Size.SMALL, Size.MEDIUM, Size.LARGE]), Size.MEDIUM);
22
29
 
23
- export const Basic = () => {
30
+ export const Basic = (args: DateLookupProps) => {
24
31
  const [value, setValue] = useState<Date | null>(epoch);
25
- const disabled = boolean('disabled', false);
26
- const label = text('label', 'label');
27
- const monthFormat = select('monthFormat', ['long', 'short'], 'long');
28
- const placeholder = text('placeholder', 'placeholder');
29
- const id = text('id', 'date-lookup');
30
-
31
- const clearable = boolean('clearable', true);
32
-
33
32
  return (
34
33
  <DateLookup
35
- disabled={disabled}
36
- id={id}
37
- label={label}
38
- min={thePast}
39
- max={theFuture}
40
- monthFormat={monthFormat}
41
- placeholder={placeholder}
42
- size={size}
34
+ {...args}
35
+ min={args.min ? new Date(args.min) : thePast}
36
+ max={args.max ? new Date(args.max) : theFuture}
43
37
  value={value}
44
- clearable={clearable}
45
- onChange={(v) => {
46
- console.log(v);
47
- setValue(v);
48
- }}
38
+ onChange={(v) => setValue(v)}
49
39
  />
50
40
  );
51
41
  };
52
-
42
+ Basic.args = {
43
+ size: Size.MEDIUM,
44
+ disabled: false,
45
+ label: 'label',
46
+ monthFormat: 'long',
47
+ placeholder: 'placeholder',
48
+ id: 'date-lookup',
49
+ clearable: true,
50
+ min: thePast,
51
+ max: theFuture,
52
+ };
53
53
  Basic.play = async ({ canvasElement }: { canvasElement: HTMLElement }) => {
54
- // testing focus state on keyboard nav
55
54
  await userEvent.tab();
56
55
  await userEvent.keyboard(' ');
57
56
  };
58
57
 
59
58
  export const Basic400Zoom = storyConfig(
60
- { render: Basic, play: Basic.play, parameters: { chromatic: { delay: 2000 } } },
59
+ {
60
+ render: Basic,
61
+ play: Basic.play,
62
+ parameters: { chromatic: { delay: 2000 } },
63
+ },
61
64
  { variants: ['400%'] },
62
65
  );
63
66
 
64
- export const WithField = () => {
67
+ export const WithField = (args: DateLookupProps) => {
65
68
  const [value, setValue] = useState<Date | null>(epoch);
66
- const disabled = boolean('disabled', false);
67
- const label = text('label', 'label');
68
- const monthFormat = select('monthFormat', ['long', 'short'], 'long');
69
- const placeholder = text('placeholder', 'Select date');
70
- const id = text('id', 'date-lookup');
71
-
72
- const clearable = boolean('clearable', true);
73
-
74
69
  return (
75
70
  <Field label="Date lookup">
76
71
  <DateLookup
77
- disabled={disabled}
78
- id={id}
79
- label={label}
80
- min={thePast}
81
- max={theFuture}
82
- monthFormat={monthFormat}
83
- placeholder={placeholder}
84
- size={size}
72
+ {...args}
73
+ min={args.min ? new Date(args.min) : thePast}
74
+ max={args.max ? new Date(args.max) : theFuture}
85
75
  value={value}
86
- clearable={clearable}
87
- onChange={(v) => {
88
- console.log(v);
89
- setValue(v);
90
- }}
76
+ onChange={(v) => setValue(v)}
91
77
  />
92
78
  </Field>
93
79
  );
94
80
  };
95
81
 
96
- export const RightAligned = () => {
82
+ export const RightAligned = (args: DateLookupProps) => {
97
83
  const [value, setValue] = useState<Date | null>(epoch);
98
- const disabled = boolean('disabled', false);
99
- const label = text('label', 'label');
100
- const monthFormat = select('monthFormat', ['long', 'short'], 'long');
101
- const placeholder = text('placeholder', 'placeholder');
102
-
103
- const minvalue = date('minvalue', thePast);
104
- const maxvalue = date('maxvalue', theFuture);
105
- const clearable = boolean('clearable', false);
106
-
107
84
  return (
108
85
  <div className="row">
109
86
  <div className="col-xs-6">
@@ -115,16 +92,11 @@ export const RightAligned = () => {
115
92
  </div>
116
93
  <div className="col-xs-6">
117
94
  <DateLookup
95
+ {...args}
118
96
  id="right-aligned"
119
- disabled={disabled}
120
- label={label}
121
- min={new Date(minvalue)}
122
- max={new Date(maxvalue)}
123
- monthFormat={monthFormat}
124
- placeholder={placeholder}
125
- size={size}
97
+ min={args.min ? new Date(args.min) : thePast}
98
+ max={args.max ? new Date(args.max) : theFuture}
126
99
  value={value}
127
- clearable={clearable}
128
100
  onChange={(v) => setValue(v)}
129
101
  />
130
102
  </div>
@@ -1,6 +1,6 @@
1
- import { StoryFn } from '@storybook/react';
2
- import { expect, userEvent, within } from '@storybook/test';
3
- import { action } from '@storybook/addon-actions';
1
+ import { StoryFn } from '@storybook/react-webpack5';
2
+ import { expect, userEvent, within } from 'storybook/test';
3
+ import { action } from 'storybook/actions';
4
4
  import { useState } from 'react';
5
5
 
6
6
  import DateLookup, { type DateLookupProps } from './DateLookup';
@@ -353,7 +353,10 @@ class DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateL
353
353
 
354
354
  export const DateLookupWithoutInputAttributes = DateLookup;
355
355
 
356
- export default withInputAttributes(
356
+ const WrappedDateLookup = withInputAttributes(
357
357
  DateLookup as React.ComponentType<DateLookupPropsWithInputAttributes>,
358
358
  { nonLabelable: true },
359
359
  );
360
+ WrappedDateLookup.displayName = 'DateLookup';
361
+
362
+ export default WrappedDateLookup;