@transferwise/components 0.0.0-experimental-cb7b730 → 0.0.0-experimental-2ad4083

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 (139) hide show
  1. package/build/dateLookup/DateLookup.js +3 -2
  2. package/build/dateLookup/DateLookup.js.map +1 -1
  3. package/build/dateLookup/DateLookup.mjs +3 -2
  4. package/build/dateLookup/DateLookup.mjs.map +1 -1
  5. package/build/main.css +4 -95
  6. package/build/styles/accordion/Accordion.css +27 -16
  7. package/build/styles/avatar/Avatar.css +95 -50
  8. package/build/styles/dimmer/Dimmer.css +0 -1
  9. package/build/styles/inputs/Input.css +37 -21
  10. package/build/styles/inputs/TextArea.css +35 -20
  11. package/build/styles/loader/Loader.css +4 -90
  12. package/build/styles/main.css +4 -95
  13. package/build/styles/popover/Popover.css +19 -12
  14. package/build/styles/select/Select.css +131 -68
  15. package/build/styles/switch/Switch.css +27 -16
  16. package/build/styles/tile/Tile.css +31 -18
  17. package/build/types/dateLookup/DateLookup.d.ts +2 -2
  18. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  19. package/build/types/test-utils/story-config.d.ts +2 -3
  20. package/build/types/test-utils/story-config.d.ts.map +1 -1
  21. package/package.json +12 -20
  22. package/src/accordion/Accordion.css +27 -16
  23. package/src/accordion/Accordion.story.tsx +1 -1
  24. package/src/actionButton/ActionButton.story.tsx +3 -2
  25. package/src/actionOption/ActionOption.story.tsx +2 -2
  26. package/src/alert/Alert.story.tsx +2 -2
  27. package/src/alert/Alert.tests.story.tsx +2 -2
  28. package/src/avatar/Avatar.css +95 -50
  29. package/src/avatar/Avatar.story.tsx +3 -2
  30. package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
  31. package/src/avatarView/AvatarView.story.tsx +1 -1
  32. package/src/avatarWrapper/AvatarWrapper.story.tsx +3 -2
  33. package/src/badge/Badge.story.tsx +49 -28
  34. package/src/button/Button.accessibility.docs.mdx +1 -1
  35. package/src/button/Button.story.tsx +2 -2
  36. package/src/button/Button.tests.story.tsx +2 -2
  37. package/src/button/LegacyButton.story.tsx +3 -2
  38. package/src/card/Card.story.tsx +2 -2
  39. package/src/carousel/Carousel.story.tsx +1 -1
  40. package/src/checkbox/Checkbox.story.tsx +2 -2
  41. package/src/checkboxButton/CheckboxButton.story.tsx +2 -2
  42. package/src/checkboxOption/CheckboxOption.story.tsx +35 -29
  43. package/src/chevron/Chevron.story.tsx +1 -1
  44. package/src/chips/Chips.story.tsx +1 -1
  45. package/src/circularButton/CircularButton.story.tsx +1 -1
  46. package/src/circularButton/CircularButton.tests.story.tsx +1 -1
  47. package/src/common/bottomSheet/BottomSheet.story.tsx +2 -2
  48. package/src/common/card/Card.story.tsx +1 -1
  49. package/src/common/circle/Circle.story.tsx +2 -2
  50. package/src/common/responsivePanel/ResponsivePanel.spec.js +8 -29
  51. package/src/criticalBanner/CriticalCommsBanner.story.tsx +1 -1
  52. package/src/dateInput/DateInput.story.tsx +2 -2
  53. package/src/dateInput/DateInput.tests.story.tsx +2 -2
  54. package/src/dateLookup/DateLookup.story.tsx +43 -71
  55. package/src/dateLookup/DateLookup.tests.story.tsx +3 -3
  56. package/src/dateLookup/DateLookup.tsx +4 -1
  57. package/src/decision/Decision.story.tsx +24 -49
  58. package/src/definitionList/DefinitionList.story.tsx +1 -1
  59. package/src/dimmer/Dimmer.css +0 -1
  60. package/src/dimmer/Dimmer.less +0 -1
  61. package/src/dimmer/Dimmer.story.tsx +2 -2
  62. package/src/divider/Divider.accessibility.docs.mdx +1 -1
  63. package/src/divider/Divider.story.tsx +1 -1
  64. package/src/drawer/Drawer.story.tsx +13 -7
  65. package/src/dropFade/DropFade.story.tsx +1 -1
  66. package/src/emphasis/Emphasis.story.tsx +1 -1
  67. package/src/field/Field.story.tsx +3 -3
  68. package/src/flowNavigation/FlowNavigation.story.tsx +305 -260
  69. package/src/iconButton/IconButton.story.tsx +2 -2
  70. package/src/image/Image.story.tsx +27 -54
  71. package/src/info/Info.story.tsx +2 -2
  72. package/src/inlineAlert/InlineAlert.story.tsx +1 -1
  73. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +2 -2
  74. package/src/inputs/Input.css +37 -21
  75. package/src/inputs/InputGroup.story.tsx +1 -1
  76. package/src/inputs/SearchInput.story.tsx +1 -1
  77. package/src/inputs/SelectInput.docs.mdx +1 -1
  78. package/src/inputs/SelectInput.story.tsx +2 -2
  79. package/src/inputs/TextArea.css +35 -20
  80. package/src/instructionsList/InstructionsList.story.tsx +2 -2
  81. package/src/legacylistItem/LegacyListItem.story.tsx +1 -1
  82. package/src/loader/Loader.css +4 -90
  83. package/src/loader/Loader.story.tsx +1 -1
  84. package/src/logo/Logo.story.tsx +1 -1
  85. package/src/main.css +4 -95
  86. package/src/markdown/Markdown.story.tsx +1 -1
  87. package/src/modal/Modal.story.tsx +2 -2
  88. package/src/money/Money.story.tsx +1 -1
  89. package/src/moneyInput/MoneyInput.docs.mdx +1 -1
  90. package/src/moneyInput/MoneyInput.story.tsx +2 -2
  91. package/src/navigationOption/NavigationOption.story.tsx +265 -226
  92. package/src/nudge/Nudge.story.tsx +1 -1
  93. package/src/overlayHeader/OverlayHeader.story.tsx +32 -24
  94. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +1 -1
  95. package/src/popover/Popover.css +19 -12
  96. package/src/popover/Popover.story.tsx +2 -2
  97. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +2 -2
  98. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +2 -2
  99. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +2 -2
  100. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +2 -2
  101. package/src/processIndicator/ProcessIndicator.story.tsx +1 -1
  102. package/src/progress/Progress.story.tsx +1 -1
  103. package/src/progressBar/ProgressBar.story.tsx +1 -1
  104. package/src/promoCard/PromoCard.story.tsx +1 -1
  105. package/src/promoCard/PromoCardGroup.story.tsx +1 -1
  106. package/src/provider/Provider.story.tsx +1 -1
  107. package/src/provider/theme/ThemeProvider.story.tsx +1 -1
  108. package/src/radio/Radio.story.tsx +59 -42
  109. package/src/radioGroup/RadioGroup.story.tsx +2 -2
  110. package/src/radioOption/RadioOption.story.tsx +73 -38
  111. package/src/segmentedControl/SegmentedControl.story.tsx +1 -1
  112. package/src/select/Select.css +131 -68
  113. package/src/select/Select.story.tsx +385 -397
  114. package/src/slidingPanel/SlidingPanel.story.tsx +30 -13
  115. package/src/snackbar/Snackbar.story.tsx +50 -36
  116. package/src/snackbar/Snackbar.tests.story.tsx +3 -2
  117. package/src/statusIcon/StatusIcon.docs.mdx +1 -1
  118. package/src/statusIcon/StatusIcon.story.tsx +1 -1
  119. package/src/stepper/Stepper.story.tsx +2 -2
  120. package/src/stepper/Stepper.tests.story.tsx +2 -2
  121. package/src/sticky/Sticky.story.tsx +1 -1
  122. package/src/summary/Summary.story.tsx +18 -17
  123. package/src/switch/Switch.css +27 -16
  124. package/src/switch/Switch.story.tsx +2 -2
  125. package/src/switchOption/SwitchOption.story.tsx +1 -1
  126. package/src/table/Table.story.tsx +1 -1
  127. package/src/test-utils/story-config.ts +9 -6
  128. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +2 -2
  129. package/src/tile/Tile.css +31 -18
  130. package/src/tile/Tile.story.tsx +43 -43
  131. package/src/tooltip/Tooltip.story.tsx +2 -2
  132. package/src/typeahead/Typeahead.story.tsx +2 -2
  133. package/src/upload/Upload.story.tsx +2 -2
  134. package/src/upload/Upload.tests.story.tsx +2 -2
  135. package/src/uploadInput/UploadInput.story.tsx +1 -1
  136. package/src/uploadInput/UploadInput.tests.story.tsx +3 -3
  137. package/src/withId/withId.docs.mdx +1 -1
  138. package/src/withId/withId.story.tsx +1 -1
  139. package/src/common/responsivePanel/__snapshots__/ResponsivePanel.spec.js.snap +0 -21
@@ -1,20 +1,42 @@
1
- import { text, select } from '@storybook/addon-knobs';
2
-
1
+ import { Meta } from '@storybook/react-webpack5';
3
2
  import { default as AvatarComponent, AvatarType } from '../avatar';
4
3
  import { Size, Theme } from '../common';
5
-
6
- import Badge from './Badge';
4
+ import Badge, { type BadgeProps } from './Badge';
7
5
 
8
6
  /**
9
7
  * @deprecated use **`<AvatarView badge={..} />`** components instead
10
8
  */
11
- export default {
9
+ const meta: Meta<typeof Badge> = {
12
10
  component: Badge,
13
- title: 'Content/Badge (Deprecated)',
14
- excludeStories: ['ExampleBadgeCss'],
11
+ title: 'Content/Badge',
12
+ tags: ['deprecated'],
15
13
  };
16
14
 
17
- export const ExampleBadgeCss = {
15
+ export default meta;
16
+
17
+ /**
18
+ * Used for showing multiple components within a Canvas.
19
+ * @decorator
20
+ */
21
+ const withComponentGrid =
22
+ (maxWidth = 'auto') =>
23
+ (Story: any) => (
24
+ <div
25
+ style={{
26
+ width: '100%',
27
+ placeItems: 'center',
28
+ justifyContent: 'center',
29
+ display: 'flex',
30
+ flexWrap: 'wrap',
31
+ gap: '2rem',
32
+ maxWidth,
33
+ }}
34
+ >
35
+ <Story />
36
+ </div>
37
+ );
38
+
39
+ const ExampleBadgeStyle = {
18
40
  background: 'var(--color-content-positive)',
19
41
  width: '100%',
20
42
  height: '100%',
@@ -25,47 +47,46 @@ export const ExampleBadgeCss = {
25
47
  alignItems: 'center',
26
48
  };
27
49
 
28
- export const Avatar = () => {
29
- const BadgeText = text('BadgeText', 'B');
30
- const border = select('Border', [undefined, Theme.LIGHT, Theme.DARK], Theme.LIGHT);
31
-
32
- return (
33
- <div>
34
- <div style={{ display: 'inline', margin: 8 }}>
50
+ export const LegacyAvatarWithBadge = {
51
+ decorators: [withComponentGrid()],
52
+ parameters: {
53
+ docs: {
54
+ source: { type: 'dynamic' },
55
+ },
56
+ },
57
+ render: () => {
58
+ return (
59
+ <>
35
60
  <Badge
36
- badge={<div style={ExampleBadgeCss}>{BadgeText}</div>}
37
- border={border}
61
+ badge={<div style={ExampleBadgeStyle}>B</div>}
62
+ border={Theme.LIGHT}
38
63
  size={Size.LARGE}
39
64
  >
40
65
  <AvatarComponent type={AvatarType.INITIALS} size={Size.LARGE}>
41
66
  AA
42
67
  </AvatarComponent>
43
68
  </Badge>
44
- </div>
45
69
 
46
- <div style={{ display: 'inline', margin: 8 }}>
47
70
  <Badge
48
- badge={<div style={ExampleBadgeCss}>{BadgeText}</div>}
49
- border={border}
71
+ badge={<div style={ExampleBadgeStyle}>B</div>}
72
+ border={Theme.LIGHT}
50
73
  size={Size.MEDIUM}
51
74
  >
52
75
  <AvatarComponent type={AvatarType.INITIALS} size={Size.MEDIUM}>
53
76
  AA
54
77
  </AvatarComponent>
55
78
  </Badge>
56
- </div>
57
79
 
58
- <div style={{ display: 'inline', margin: 8 }}>
59
80
  <Badge
60
- badge={<div style={ExampleBadgeCss}>{BadgeText}</div>}
61
- border={border}
81
+ badge={<div style={ExampleBadgeStyle}>B</div>}
82
+ border={Theme.LIGHT}
62
83
  size={Size.SMALL}
63
84
  >
64
85
  <AvatarComponent type={AvatarType.INITIALS} size={Size.MEDIUM}>
65
86
  AA
66
87
  </AvatarComponent>
67
88
  </Badge>
68
- </div>
69
- </div>
70
- );
89
+ </>
90
+ );
91
+ },
71
92
  };
@@ -1,4 +1,4 @@
1
- import { Meta, Canvas, Source } from '@storybook/blocks';
1
+ import { Meta, Canvas, Source } from '@storybook/addon-docs/blocks';
2
2
  import { NavigationOption } from '..';
3
3
  import { Bulb } from '@transferwise/icons';
4
4
  import * as stories from './Button.story';
@@ -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
  import { Freeze, ArrowRight, ChevronRight } from '@transferwise/icons';
4
4
  import { Flag } from '@wise/art';
5
5
  import Button from './Button.resolver';
@@ -1,6 +1,6 @@
1
- import { Meta } from '@storybook/react';
1
+ import { Meta } from '@storybook/react-webpack5';
2
2
  import Button from './Button.resolver';
3
- import { expect, userEvent, within } from '@storybook/test';
3
+ import { expect, userEvent, within } from 'storybook/test';
4
4
  import { storyConfig } from '../test-utils';
5
5
 
6
6
  const meta: Meta<typeof Button> = {
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { userEvent, within, fn, expect } from '@storybook/test';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { userEvent, within, fn, expect } from 'storybook/test';
3
3
  import { useState } from 'react';
4
4
 
5
5
  import Button from '.';
@@ -25,6 +25,7 @@ const withContainer = (Story: any) => (
25
25
  const meta: Meta<typeof LegacyButton> = {
26
26
  component: LegacyButton,
27
27
  title: 'Actions/Button/Legacy Button',
28
+ tags: ['deprecated'],
28
29
  args: {
29
30
  size: undefined,
30
31
  priority: undefined,
@@ -1,7 +1,7 @@
1
- import { Meta, StoryObj } from '@storybook/react';
1
+ import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { FastFlag as FastFlagIcon } from '@transferwise/icons';
3
3
  import { useState } from 'react';
4
- import { fn } from '@storybook/test';
4
+ import { fn } from 'storybook/test';
5
5
 
6
6
  import Card from '.';
7
7
 
@@ -1,4 +1,4 @@
1
- import type { StoryFn } from '@storybook/react';
1
+ import type { StoryFn } from '@storybook/react-webpack5';
2
2
  import { Illustration } from '@wise/art';
3
3
  import React from 'react';
4
4
 
@@ -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
 
@@ -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';
@@ -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;