@transferwise/components 46.147.0 → 46.148.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 (124) hide show
  1. package/build/container/Container.js.map +1 -1
  2. package/build/container/Container.mjs.map +1 -1
  3. package/build/main.css +63 -6
  4. package/build/prompt/CriticalBanner/CriticalBanner.js +81 -68
  5. package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -1
  6. package/build/prompt/CriticalBanner/CriticalBanner.mjs +82 -69
  7. package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +1 -1
  8. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
  9. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
  10. package/build/styles/main.css +63 -6
  11. package/build/styles/prompt/ActionPrompt/ActionPrompt.css +2 -1
  12. package/build/styles/prompt/CriticalBanner/CriticalBanner.css +50 -1
  13. package/build/styles/prompt/InfoPrompt/InfoPrompt.css +2 -1
  14. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +2 -1
  15. package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +2 -2
  16. package/build/types/container/Container.d.ts +2 -2
  17. package/build/types/container/Container.d.ts.map +1 -1
  18. package/build/types/iconButton/IconButton.d.ts +1 -1
  19. package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +1 -1
  20. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +1 -1
  21. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
  22. package/package.json +1 -1
  23. package/src/accordion/Accordion.story.tsx +25 -0
  24. package/src/avatarLayout/AvatarLayout.story.tsx +10 -0
  25. package/src/avatarView/AvatarView.story.tsx +8 -0
  26. package/src/body/Body.story.tsx +12 -0
  27. package/src/button/_stories/Button.story.tsx +7 -1
  28. package/src/calendar/Calendar.story.tsx +19 -7
  29. package/src/carousel/Carousel.story.tsx +35 -0
  30. package/src/checkbox/Checkbox.story.tsx +20 -0
  31. package/src/checkboxButton/CheckboxButton.story.tsx +16 -0
  32. package/src/chevron/Chevron.story.tsx +6 -0
  33. package/src/chips/Chips.story.tsx +23 -0
  34. package/src/circularButton/CircularButton.story.tsx +13 -0
  35. package/src/common/baseCard/BaseCard.story.tsx +12 -0
  36. package/src/common/bottomSheet/BottomSheet.story.tsx +21 -0
  37. package/src/common/circle/Circle.story.tsx +11 -0
  38. package/src/container/Container.story.tsx +12 -0
  39. package/src/container/Container.tsx +2 -2
  40. package/src/dateInput/DateInput.story.tsx +20 -0
  41. package/src/dateLookup/DateLookup.story.tsx +23 -0
  42. package/src/decision/Decision.story.tsx +36 -0
  43. package/src/definitionList/DefinitionList.story.tsx +16 -0
  44. package/src/dimmer/Dimmer.story.tsx +24 -0
  45. package/src/display/Display.story.tsx +11 -0
  46. package/src/divider/Divider.story.tsx +6 -0
  47. package/src/drawer/Drawer.story.tsx +25 -0
  48. package/src/dropFade/DropFade.story.tsx +27 -0
  49. package/src/emphasis/Emphasis.story.tsx +10 -0
  50. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +37 -0
  51. package/src/field/Field.story.tsx +16 -0
  52. package/src/flowNavigation/FlowNavigation.story.tsx +25 -0
  53. package/src/header/Header.story.tsx +17 -0
  54. package/src/iconButton/IconButton.story.tsx +14 -0
  55. package/src/image/Image.story.tsx +11 -0
  56. package/src/info/Info.story.tsx +10 -0
  57. package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +23 -0
  58. package/src/inputs/InputGroup.story.tsx +37 -0
  59. package/src/inputs/SearchInput.story.tsx +22 -0
  60. package/src/inputs/SelectInput/_stories/SelectInput.story.tsx +42 -0
  61. package/src/inputs/TextArea.story.tsx +22 -0
  62. package/src/instructionsList/InstructionsList.story.tsx +19 -0
  63. package/src/label/Label.story.tsx +17 -0
  64. package/src/link/Link.story.tsx +11 -0
  65. package/src/list/List.story.tsx +19 -0
  66. package/src/listItem/_stories/ListItem.story.tsx +20 -0
  67. package/src/loader/Loader.story.tsx +6 -0
  68. package/src/logo/Logo.story.tsx +6 -0
  69. package/src/main.css +63 -6
  70. package/src/markdown/Markdown.story.tsx +17 -0
  71. package/src/modal/Modal.story.tsx +23 -0
  72. package/src/money/Money.story.tsx +7 -0
  73. package/src/moneyInput/MoneyInput.story.tsx +34 -0
  74. package/src/nudge/Nudge.story.tsx +17 -0
  75. package/src/overlayHeader/OverlayHeader.story.tsx +10 -0
  76. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +23 -0
  77. package/src/popover/Popover.story.tsx +12 -0
  78. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +11 -0
  79. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +11 -0
  80. package/src/processIndicator/ProcessIndicator.story.tsx +10 -0
  81. package/src/progress/Progress.story.tsx +6 -0
  82. package/src/progressBar/ProgressBar.story.tsx +12 -0
  83. package/src/promoCard/PromoCard.story.tsx +15 -0
  84. package/src/promoCard/PromoCardGroup.story.tsx +28 -0
  85. package/src/prompt/ActionPrompt/ActionPrompt.css +2 -1
  86. package/src/prompt/ActionPrompt/ActionPrompt.less +2 -1
  87. package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +31 -0
  88. package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +9 -0
  89. package/src/prompt/CriticalBanner/CriticalBanner.css +50 -1
  90. package/src/prompt/CriticalBanner/CriticalBanner.less +74 -1
  91. package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +181 -170
  92. package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +25 -6
  93. package/src/prompt/CriticalBanner/CriticalBanner.test.tsx +37 -0
  94. package/src/prompt/CriticalBanner/CriticalBanner.tsx +96 -84
  95. package/src/prompt/CriticalBanner/CriticalBanner.vars.less +1 -0
  96. package/src/prompt/InfoPrompt/InfoPrompt.css +2 -1
  97. package/src/prompt/InfoPrompt/InfoPrompt.less +2 -1
  98. package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +30 -0
  99. package/src/prompt/InlinePrompt/InlinePrompt.css +2 -1
  100. package/src/prompt/InlinePrompt/InlinePrompt.less +2 -1
  101. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +14 -0
  102. package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +2 -2
  103. package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -1
  104. package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +1 -1
  105. package/src/radio/Radio.story.tsx +34 -0
  106. package/src/radioGroup/RadioGroup.story.tsx +26 -0
  107. package/src/section/Section.story.tsx +15 -0
  108. package/src/segmentedControl/SegmentedControl.story.tsx +27 -0
  109. package/src/sentimentSurface/SentimentSurface.story.tsx +11 -0
  110. package/src/slidingPanel/SlidingPanel.story.tsx +19 -0
  111. package/src/snackbar/Snackbar.story.tsx +24 -0
  112. package/src/statusIcon/StatusIcon.story.tsx +6 -0
  113. package/src/stepper/Stepper.story.tsx +30 -0
  114. package/src/sticky/Sticky.story.tsx +22 -1
  115. package/src/switch/Switch.story.tsx +17 -0
  116. package/src/table/Table.story.tsx +32 -0
  117. package/src/tabs/Tabs.story.tsx +31 -0
  118. package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +23 -0
  119. package/src/tile/Tile.story.tsx +13 -0
  120. package/src/title/Title.story.tsx +12 -0
  121. package/src/tooltip/Tooltip.story.tsx +8 -0
  122. package/src/typeahead/Typeahead.story.tsx +33 -0
  123. package/src/upload/Upload.story.tsx +24 -0
  124. package/src/uploadInput/UploadInput.story.tsx +31 -0
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import React from 'react';
3
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
3
4
  import Sticky from './Sticky';
4
5
  import { allModes } from '../../.storybook/modes';
5
6
 
@@ -45,7 +46,27 @@ export default meta;
45
46
  // Represents a story object for the `Sticky` component.
46
47
  type Story = StoryObj<typeof Sticky>;
47
48
 
48
- export const Default: Story = {}; // Default story with no additional props
49
+ export const Sandbox = createSandboxStory({
50
+ code: `const App = () => {
51
+ const [open, setOpen] = React.useState(false);
52
+
53
+ return (
54
+ <>
55
+ <Button v2 onClick={() => setOpen(!open)}>
56
+ {open ? 'Close' : 'Open'} Sticky
57
+ </Button>
58
+ <Sticky open={open} position="bottom">
59
+ <div className="d-flex justify-content-start align-items-start flex-wrap p-x-4 p-y-4">
60
+ <p className="m-b-0">Sticky content pinned to the bottom.</p>
61
+ </div>
62
+ </Sticky>
63
+ </>
64
+ );
65
+ };`,
66
+ scope: globalScope,
67
+ });
68
+
69
+ export const Default: Story = {};
49
70
 
50
71
  export const PositionTop: Story = {
51
72
  args: {
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
2
2
  import { fn } from 'storybook/test';
3
3
 
4
4
  import { storySourceWithoutNoise } from '../../.storybook/helpers';
5
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
5
6
  import Switch, { SwitchProps } from './Switch';
6
7
  import { Field } from '../field/Field';
7
8
  import { Meta, StoryObj } from '@storybook/react-webpack5';
@@ -55,6 +56,22 @@ export const Playground: Story = storySourceWithoutNoise({
55
56
  },
56
57
  });
57
58
 
59
+ export const Sandbox = createSandboxStory({
60
+ code: `const App = () => {
61
+ const [checked, setChecked] = React.useState(false);
62
+
63
+ return (
64
+ <Field id="sandbox-field" label="Enable notifications">
65
+ <Switch
66
+ checked={checked}
67
+ onClick={() => setChecked((prev) => !prev)}
68
+ />
69
+ </Field>
70
+ );
71
+ };`,
72
+ scope: { ...globalScope, Switch },
73
+ });
74
+
58
75
  /**
59
76
  * Three labelling patterns: <a href="?path=/docs/forms-label--docs">Label</a>, `aria-labelledby`, and <a href="?path=/docs/forms-field--docs">Field</a>. <br />
60
77
  * Use Label for simple label-input pairs. Use `aria-labelledby` to reference existing text as the accessible name. Use Field for form layouts with labels, descriptions, and validation.
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
  import Table from './Table';
3
4
  import { TableHeaderType } from './TableHeader';
4
5
  import { TableRowType, TableRowClickableType } from './TableRow';
@@ -356,6 +357,37 @@ const tableData = {
356
357
  ] satisfies TableRowType[] | TableRowClickableType[],
357
358
  };
358
359
 
360
+ export const Sandbox = createSandboxStory({
361
+ code: `<Table
362
+ data={{
363
+ headers: [
364
+ { header: 'Employee', width: '200px' },
365
+ { header: 'Location' },
366
+ { header: 'Payment', alignment: 'right' },
367
+ ],
368
+ rows: [
369
+ {
370
+ id: 0,
371
+ cells: [
372
+ { cell: { type: 'leading', primaryText: 'Bob Brown', secondaryText: 'Engineer', avatar: { profileName: 'Bob Brown' } } },
373
+ { cell: { type: 'text', text: 'FR, Paris' } },
374
+ { cell: { type: 'currency', primaryCurrency: { amount: 12345.67, currency: 'eur' } }, alignment: 'right' },
375
+ ],
376
+ },
377
+ {
378
+ id: 1,
379
+ cells: [
380
+ { cell: { type: 'leading', primaryText: 'Jane Smith', secondaryText: 'Designer', avatar: { profileName: 'Jane Smith' } } },
381
+ { cell: { type: 'text', text: 'UK, London' } },
382
+ { cell: { type: 'currency', primaryCurrency: { amount: 34567.89, currency: 'gbp' } }, alignment: 'right' },
383
+ ],
384
+ },
385
+ ],
386
+ }}
387
+ />`,
388
+ scope: globalScope,
389
+ });
390
+
359
391
  export const Basic: Story = {
360
392
  args: {
361
393
  data: tableData,
@@ -1,4 +1,5 @@
1
1
  import { useState } from 'react';
2
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
 
3
4
  import { Width } from '../common';
4
5
 
@@ -9,6 +10,36 @@ export default {
9
10
  title: 'Navigation/Tabs',
10
11
  };
11
12
 
13
+ export const Sandbox = createSandboxStory({
14
+ code: `const App = () => {
15
+ const [selected, setSelected] = React.useState(0);
16
+
17
+ return (
18
+ <Tabs
19
+ name="tabs-sandbox"
20
+ tabs={[
21
+ {
22
+ title: 'First tab',
23
+ content: <div className="p-a-2">Content for the first tab.</div>,
24
+ },
25
+ {
26
+ title: 'Second tab',
27
+ content: <div className="p-a-2">Content for the second tab.</div>,
28
+ },
29
+ {
30
+ title: 'Third tab',
31
+ disabled: true,
32
+ content: <div className="p-a-2">This tab is disabled.</div>,
33
+ },
34
+ ]}
35
+ selected={selected}
36
+ onTabSelect={(index) => setSelected(index)}
37
+ />
38
+ );
39
+ };`,
40
+ scope: globalScope,
41
+ });
42
+
12
43
  export const Basic = () => {
13
44
  const [selected, setSelected] = useState(0);
14
45
  return (
@@ -1,6 +1,10 @@
1
1
  import { StoryObj } from '@storybook/react-webpack5';
2
2
  import { userEvent, within } from 'storybook/test';
3
3
 
4
+ import {
5
+ createSandboxStory,
6
+ globalScope,
7
+ } from '../../.storybook/components/sandbox/SandboxEditor';
4
8
  import TextareaWithDisplayFormat from './TextareaWithDisplayFormat';
5
9
  import { Field } from '../field/Field';
6
10
 
@@ -11,6 +15,25 @@ export default {
11
15
 
12
16
  type Story = StoryObj<typeof TextareaWithDisplayFormat>;
13
17
 
18
+ export const Sandbox = createSandboxStory({
19
+ code: `const App = () => {
20
+ const [value, setValue] = React.useState('');
21
+
22
+ return (
23
+ <Field label="Gift card code" id="gift-card">
24
+ <TextareaWithDisplayFormat
25
+ id="gift-card"
26
+ value={value}
27
+ maxLength={16}
28
+ displayPattern="**** - **** - ****"
29
+ onChange={(event) => setValue(event.target.value)}
30
+ />
31
+ </Field>
32
+ );
33
+ };`,
34
+ scope: globalScope,
35
+ });
36
+
14
37
  export const Basic: Story = {
15
38
  render: () => {
16
39
  const label = 'Textarea with display format';
@@ -1,5 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { action } from 'storybook/actions';
3
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
3
4
  import { Size } from '../common';
4
5
  import AvatarView from '../avatarView';
5
6
  import Tile from '.';
@@ -43,6 +44,18 @@ export default meta;
43
44
 
44
45
  type Story = StoryObj<typeof Tile>;
45
46
 
47
+ export const Sandbox = createSandboxStory({
48
+ code: `<Tile
49
+ media={<AvatarView profileName="Hank Miller" />}
50
+ title="Hank Miller"
51
+ description="Click here to send money to Mr. Miller"
52
+ href="#"
53
+ size={Size.MEDIUM}
54
+ onClick={() => console.log('clicked')}
55
+ />`,
56
+ scope: { ...globalScope, Tile },
57
+ });
58
+
46
59
  export const WithImage: Story = {};
47
60
 
48
61
  export const WithAvatar: Story = {
@@ -1,12 +1,23 @@
1
1
  import { Typography } from '../common/propsValues/typography';
2
2
 
3
3
  import Title from './Title';
4
+ import {
5
+ createSandboxStory,
6
+ globalScope,
7
+ } from '../../.storybook/components/sandbox/SandboxEditor';
4
8
 
5
9
  export default {
6
10
  component: Title,
7
11
  title: 'Typography/Title',
8
12
  };
9
13
 
14
+ export const Sandbox = createSandboxStory({
15
+ code: `<Title type="title-group">
16
+ Group Title
17
+ </Title>`,
18
+ scope: globalScope,
19
+ });
20
+
10
21
  export const Basic = () => {
11
22
  return (
12
23
  <>
@@ -26,3 +37,4 @@ export const Basic = () => {
26
37
  </>
27
38
  );
28
39
  };
40
+
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-webpack5';
2
+ import { createSandboxStory, globalScope } from '../../.storybook/components/sandbox/SandboxEditor';
2
3
  import Button from '../button';
3
4
  import Tooltip from './Tooltip';
4
5
 
@@ -20,4 +21,11 @@ export default {
20
21
 
21
22
  type Story = StoryObj<typeof Tooltip>;
22
23
 
24
+ export const Sandbox = createSandboxStory({
25
+ code: `<Tooltip label="Hey I'm the tooltip text — edit me!" position="bottom">
26
+ <Button v2 size="md">Hover me</Button>
27
+ </Tooltip>`,
28
+ scope: globalScope,
29
+ });
30
+
23
31
  export const Basic: Story = {};
@@ -3,6 +3,10 @@ import { Search as SearchIcon } from '@transferwise/icons';
3
3
  import { userEvent, within, fn } from 'storybook/test';
4
4
  import { useState } from 'react';
5
5
 
6
+ import {
7
+ createSandboxStory,
8
+ globalScope,
9
+ } from '../../.storybook/components/sandbox/SandboxEditor';
6
10
  import { Sentiment, Size } from '../common';
7
11
  import { Input } from '../inputs/Input';
8
12
  import { Field } from '../field/Field';
@@ -73,6 +77,35 @@ const meta: Meta<typeof Typeahead> = {
73
77
  };
74
78
  export default meta;
75
79
 
80
+ export const Sandbox = createSandboxStory({
81
+ code: `const App = () => {
82
+ const [options, setOptions] = React.useState([
83
+ { label: 'British pound', note: 'GBP' },
84
+ { label: 'Euro', note: 'EUR' },
85
+ { label: 'US Dollar', note: 'USD' },
86
+ { label: 'Japanese yen', note: 'JPY' },
87
+ { label: 'Australian dollar', note: 'AUD' },
88
+ ]);
89
+
90
+ return (
91
+ <Field label="Select a currency" id="typeahead-sandbox">
92
+ <Typeahead
93
+ id="typeahead-sandbox"
94
+ name="currency"
95
+ placeholder="Search currencies..."
96
+ clearable
97
+ addon={<Search size={24} />}
98
+ options={options}
99
+ onSearch={() => {
100
+ setTimeout(() => setOptions(options), 1000);
101
+ }}
102
+ />
103
+ </Field>
104
+ );
105
+ };`,
106
+ scope: globalScope,
107
+ });
108
+
76
109
  export const Basic: Story = {
77
110
  render: function Render(args) {
78
111
  const [options, setOptions] = useState([
@@ -1,6 +1,10 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-webpack5';
2
2
  import { fn } from 'storybook/test';
3
3
 
4
+ import {
5
+ createSandboxStory,
6
+ globalScope,
7
+ } from '../../.storybook/components/sandbox/SandboxEditor';
4
8
  import Upload from '.';
5
9
  import { MAX_SIZE_DEFAULT } from './Upload';
6
10
 
@@ -138,6 +142,26 @@ const meta = {
138
142
  export default meta;
139
143
  type Story = StoryObj<typeof meta>;
140
144
 
145
+ export const Sandbox = createSandboxStory({
146
+ code: `<Upload
147
+ usAccept="image/*"
148
+ usLabel="Front of your ID document"
149
+ usPlaceholder="Drag and drop file less than 5MB"
150
+ usButtonText="Or Select File"
151
+ usDropMessage="Drop file to start upload"
152
+ size="md"
153
+ httpOptions={{
154
+ url: 'https://httpbin.org/post',
155
+ method: 'POST',
156
+ }}
157
+ onStart={(file) => console.log('Upload started', file.name)}
158
+ onSuccess={(response, fileName) => console.log('Upload complete', fileName)}
159
+ onFailure={(error) => console.log('Upload failed', error)}
160
+ onCancel={() => console.log('Upload cancelled')}
161
+ />`,
162
+ scope: { ...globalScope, Upload },
163
+ });
164
+
141
165
  export const Basic: Story = {
142
166
  args: {
143
167
  usAccept: 'image/*',
@@ -1,5 +1,9 @@
1
1
  import { StoryFn, Meta } from '@storybook/react-webpack5';
2
2
 
3
+ import {
4
+ createSandboxStory,
5
+ globalScope,
6
+ } from '../../.storybook/components/sandbox/SandboxEditor';
3
7
  import { Field } from '../field/Field';
4
8
 
5
9
  import UploadInput, { UploadInputProps } from './UploadInput';
@@ -38,6 +42,33 @@ const props = {
38
42
  },
39
43
  };
40
44
 
45
+ export const Sandbox = createSandboxStory({
46
+ code: `const App = () => {
47
+ const onUploadFile = () => {
48
+ return new Promise((resolve) => {
49
+ setTimeout(() => resolve({ id: Math.round(Math.random() * 10000), url: '#' }), 2000);
50
+ });
51
+ };
52
+
53
+ const onDeleteFile = () => {
54
+ return new Promise((resolve) => {
55
+ setTimeout(() => resolve(), 1000);
56
+ });
57
+ };
58
+
59
+ return (
60
+ <Field label="Upload documents">
61
+ <UploadInput
62
+ multiple
63
+ onUploadFile={onUploadFile}
64
+ onDeleteFile={onDeleteFile}
65
+ />
66
+ </Field>
67
+ );
68
+ };`,
69
+ scope: globalScope,
70
+ });
71
+
41
72
  const Template: Story = (args: UploadInputProps) => <UploadInput {...args} />;
42
73
 
43
74
  export const SingleFile: Story = Template.bind({});