@transferwise/components 0.0.0-experimental-071a319 → 0.0.0-experimental-04f7ce3

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.
@@ -1,10 +1,4 @@
1
1
  export type CommonProps = {
2
- /**
3
- * Space-separated list of the case-sensitive CSS classes,
4
- * most would be applied to outermost element inside the component
5
- *
6
- * @see https://github.com/transferwise/neptune-web/blob/main/rfc/0001-always-pass-classname.md
7
- */
8
2
  className?: string;
9
3
  };
10
4
  export type AriaLabelProperty = {
@@ -1 +1 @@
1
- {"version":3,"file":"commonProps.d.ts","sourceRoot":"","sources":["../../../src/common/commonProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"commonProps.d.ts","sourceRoot":"","sources":["../../../src/common/commonProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC,yBAAyB,CAAC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9D,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-071a319",
3
+ "version": "0.0.0-experimental-04f7ce3",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -165,6 +165,7 @@ const meta: Meta<typeof Button> = {
165
165
  name: 'enum',
166
166
  value: ['lg', 'md', 'sm'],
167
167
  },
168
+ description: 'Sets the size of the button.',
168
169
  table: {
169
170
  type: {
170
171
  summary: 'ButtonSize',
@@ -176,6 +177,7 @@ const meta: Meta<typeof Button> = {
176
177
  name: 'enum',
177
178
  value: ['primary', 'secondary', 'secondary-neutral', 'tertiary'],
178
179
  },
180
+ description: 'Sets the visual hierarchy of the action.',
179
181
  table: {
180
182
  type: {
181
183
  summary: 'ButtonPriority',
@@ -195,7 +197,7 @@ const meta: Meta<typeof Button> = {
195
197
  },
196
198
  },
197
199
  disabled: {
198
- description: 'Toggles the disabled state',
200
+ description: 'Toggles the disabled state.',
199
201
  table: {
200
202
  defaultValue: { summary: 'false' },
201
203
  },
@@ -215,12 +217,13 @@ const meta: Meta<typeof Button> = {
215
217
  type: {
216
218
  name: 'string',
217
219
  },
218
- description: 'If set, the component will render as an HTML anchor.',
220
+ description: 'Renders the component as a link when provided.',
219
221
  },
220
222
  target: {
221
223
  type: {
222
224
  name: 'string',
223
225
  },
226
+ description: 'Controls where the linked document opens. Use `_blank` to open in a new tab.',
224
227
  table: {
225
228
  type: {
226
229
  summary: 'string',
@@ -248,12 +251,31 @@ const meta: Meta<typeof Button> = {
248
251
  },
249
252
  },
250
253
  children: {
254
+ description: 'Visible button label.',
251
255
  table: {
252
256
  type: {
253
257
  summary: 'ReactNode',
254
258
  },
255
259
  },
256
260
  },
261
+ id: {
262
+ description: '',
263
+ table: {
264
+ category: 'Common',
265
+ },
266
+ },
267
+ className: {
268
+ description: '',
269
+ table: {
270
+ category: 'Common',
271
+ },
272
+ },
273
+ onClick: {
274
+ description: '',
275
+ table: {
276
+ category: 'Common',
277
+ },
278
+ },
257
279
  },
258
280
  args: {
259
281
  v2: true,
@@ -2,7 +2,9 @@ import { useState, useEffect } from 'react';
2
2
  import { fn } from 'storybook/test';
3
3
  import { Meta, StoryObj } from '@storybook/react-webpack5';
4
4
 
5
+ import { storySourceWithoutNoise } from '../../.storybook/helpers';
5
6
  import CheckboxButton, { type CheckboxButtonProps } from './CheckboxButton';
7
+ import { Label } from '../label/Label';
6
8
 
7
9
  /**
8
10
  * Use <a href="?path=/docs/forms-checkbox--docs">Checkbox</a> component instead when pairing with a label. Only use CheckboxButton when you need a standalone checkbox (e.g. settings matrix) and provide an `aria-label`.
@@ -22,10 +24,34 @@ export default {
22
24
  onFocus: fn(),
23
25
  },
24
26
  argTypes: {
27
+ 'aria-label': {
28
+ description: 'Provides the accessible name when the control has no visible text label.',
29
+ },
30
+ checked: {
31
+ description: 'Controls whether the checkbox is checked.',
32
+ },
33
+ disabled: {
34
+ description: 'Toggles the disabled state.',
35
+ },
36
+ name: {
37
+ description: 'Name submitted with the form when the checkbox is checked.',
38
+ },
39
+ value: {
40
+ description: 'Value submitted with the form when the checkbox is checked.',
41
+ },
42
+ onChange: {
43
+ description: 'Called when the checked state changes.',
44
+ },
25
45
  indeterminate: {
26
46
  description:
27
47
  'Sets the native mixed state — used when some (not all) child items are selected. Clicking resolves to checked; clear `indeterminate` in `onChange` to reflect the transition.',
28
48
  },
49
+ defaultChecked: { description: '', table: { category: 'Common' } },
50
+ id: { description: '', table: { category: 'Common' } },
51
+ className: { description: '', table: { category: 'Common' } },
52
+ onBlur: { description: '', table: { category: 'Common' } },
53
+ onClick: { description: '', table: { category: 'Common' } },
54
+ onFocus: { description: '', table: { category: 'Common' } },
29
55
  },
30
56
  parameters: {
31
57
  docs: { toc: true },
@@ -40,10 +66,8 @@ const withColumnLayout = (Story: () => JSX.Element) => (
40
66
  </div>
41
67
  );
42
68
 
43
- const row = { display: 'flex', alignItems: 'center', gap: '8px' } as const;
44
-
45
69
  /** Interactive single checkbox — use the Controls panel to toggle `disabled` and `indeterminate`. */
46
- export const Playground: Story = {
70
+ export const Playground: Story = storySourceWithoutNoise({
47
71
  render: function Render(args: CheckboxButtonProps) {
48
72
  const [checked, setChecked] = useState(args.checked ?? true);
49
73
 
@@ -63,25 +87,32 @@ export const Playground: Story = {
63
87
  />
64
88
  );
65
89
  },
66
- };
90
+ });
67
91
 
68
92
  /** Disabled state — checked and unchecked. */
69
93
  export const Disabled: Story = {
70
94
  decorators: [withColumnLayout],
71
- render: () => (
95
+ render: (args) => (
72
96
  <>
73
- <div style={row}>
97
+ <div>
98
+ <Label htmlFor="disabled-unchecked">Disabled unchecked</Label>
74
99
  <CheckboxButton
100
+ id="disabled-unchecked"
75
101
  aria-label="Disabled unchecked"
76
102
  checked={false}
77
103
  disabled
78
104
  onChange={() => {}}
79
105
  />
80
- <span>Disabled unchecked</span>
81
106
  </div>
82
- <div style={row}>
83
- <CheckboxButton aria-label="Disabled checked" checked disabled onChange={() => {}} />
84
- <span>Disabled checked</span>
107
+ <div>
108
+ <Label htmlFor="disabled-checked">Disabled checked</Label>
109
+ <CheckboxButton
110
+ id="disabled-checked"
111
+ aria-label="Disabled checked"
112
+ checked
113
+ disabled
114
+ onChange={() => {}}
115
+ />
85
116
  </div>
86
117
  </>
87
118
  ),
@@ -90,25 +121,27 @@ export const Disabled: Story = {
90
121
  /** Indeterminate state — checked and unchecked. */
91
122
  export const Indeterminate: Story = {
92
123
  decorators: [withColumnLayout],
93
- render: () => (
124
+ render: (args) => (
94
125
  <>
95
- <div style={row}>
126
+ <div>
127
+ <Label htmlFor="indeterminate-unchecked">Indeterminate (unchecked)</Label>
96
128
  <CheckboxButton
129
+ id="indeterminate-unchecked"
97
130
  aria-label="Indeterminate unchecked"
98
131
  checked={false}
99
132
  indeterminate
100
133
  onChange={() => {}}
101
134
  />
102
- <span>Indeterminate (unchecked)</span>
103
135
  </div>
104
- <div style={row}>
136
+ <div>
137
+ <Label htmlFor="indeterminate-checked">Indeterminate (checked)</Label>
105
138
  <CheckboxButton
139
+ id="indeterminate-checked"
106
140
  aria-label="Indeterminate checked"
107
141
  checked
108
142
  indeterminate
109
143
  onChange={() => {}}
110
144
  />
111
- <span>Indeterminate (checked)</span>
112
145
  </div>
113
146
  </>
114
147
  ),
@@ -17,9 +17,17 @@ export default {
17
17
  onChange: fn(),
18
18
  },
19
19
  argTypes: {
20
+ 'aria-label': {
21
+ description: 'Provides the accessible name for the chip group.',
22
+ },
20
23
  chips: {
21
24
  description: 'Array of chip objects, each with a label (string) and value (string or number)',
22
25
  },
26
+ multiple: {
27
+ description:
28
+ 'Switch between filter/multi-select (true) and choice/single-select (false) modes',
29
+ },
30
+ className: { description: '', table: { category: 'Common' } },
23
31
  selected: { table: { disable: true } },
24
32
  },
25
33
  parameters: {
@@ -23,12 +23,28 @@ export default {
23
23
  disabled: false,
24
24
  },
25
25
  argTypes: {
26
+ children: {
27
+ description:
28
+ 'Visible label shown below the icon. Keep it short so it fits in the circular layout.',
29
+ },
26
30
  icon: {
31
+ description: 'Icon displayed inside the circular button.',
27
32
  options: Object.keys(Icons),
28
33
  mapping: Object.fromEntries(
29
34
  Object.entries(Icons).map(([name, Icon]) => [name, <Icon key={name} />]),
30
35
  ),
31
36
  },
37
+ priority: {
38
+ description: 'Sets the visual hierarchy of the action.',
39
+ },
40
+ type: {
41
+ description: 'Emphasises the nature of the action. Use `negative` for destructive actions.',
42
+ },
43
+ disabled: {
44
+ description: 'Toggles the disabled state.',
45
+ },
46
+ className: { description: '', table: { category: 'Common' } },
47
+ onClick: { description: '', table: { category: 'Common' } },
32
48
  },
33
49
  parameters: {
34
50
  docs: { toc: true },
@@ -1,10 +1,4 @@
1
1
  export type CommonProps = {
2
- /**
3
- * Space-separated list of the case-sensitive CSS classes,
4
- * most would be applied to outermost element inside the component
5
- *
6
- * @see https://github.com/transferwise/neptune-web/blob/main/rfc/0001-always-pass-classname.md
7
- */
8
2
  className?: string;
9
3
  };
10
4
 
@@ -27,6 +27,38 @@ export default {
27
27
  onClick: fn(),
28
28
  'aria-label': 'Action',
29
29
  },
30
+ argTypes: {
31
+ children: {
32
+ description: 'Icon rendered inside the button.',
33
+ },
34
+ 'aria-label': {
35
+ description: 'Provides the accessible name when the control has no visible text label.',
36
+ },
37
+ size: {
38
+ description: 'Sets the button diameter in pixels.',
39
+ },
40
+ priority: {
41
+ description: 'Sets the visual hierarchy of the action.',
42
+ },
43
+ type: {
44
+ description: 'Emphasises the nature of the action. Use `negative` for destructive actions.',
45
+ },
46
+ disabled: {
47
+ description: 'Toggles the disabled state.',
48
+ },
49
+ href: {
50
+ description: 'Renders the component as a link when provided.',
51
+ },
52
+ target: {
53
+ description: 'Controls where the linked document opens. Use `_blank` to open in a new tab.',
54
+ },
55
+ id: { description: '', table: { category: 'Common' } },
56
+ className: { description: '', table: { category: 'Common' } },
57
+ role: { description: '', table: { category: 'Common' } },
58
+ tabIndex: { description: '', table: { category: 'Common' } },
59
+ 'data-testid': { description: '', table: { category: 'Common' } },
60
+ onClick: { description: '', table: { category: 'Common' } },
61
+ },
30
62
  parameters: {
31
63
  docs: { toc: true },
32
64
  },
@@ -1,6 +1,7 @@
1
1
  import { useState, useEffect } from 'react';
2
2
  import { fn } from 'storybook/test';
3
3
 
4
+ import { storySourceWithoutNoise } from '../../.storybook/helpers';
4
5
  import Switch, { SwitchProps } from './Switch';
5
6
  import { Field } from '../field/Field';
6
7
  import { Meta, StoryObj } from '@storybook/react-webpack5';
@@ -21,6 +22,10 @@ const meta: Meta<typeof Switch> = {
21
22
  'aria-label': undefined,
22
23
  onClick: fn(),
23
24
  },
25
+ argTypes: {
26
+ id: { description: '', table: { category: 'Common' } },
27
+ className: { description: '', table: { category: 'Common' } },
28
+ },
24
29
  parameters: {
25
30
  docs: { toc: true },
26
31
  },
@@ -29,7 +34,7 @@ const meta: Meta<typeof Switch> = {
29
34
  export default meta;
30
35
  type Story = StoryObj<typeof Switch>;
31
36
 
32
- export const Playground: Story = {
37
+ export const Playground: Story = storySourceWithoutNoise({
33
38
  render: function Render(args: SwitchProps) {
34
39
  const [checked, setChecked] = useState(args.checked ?? false);
35
40
 
@@ -39,14 +44,18 @@ export const Playground: Story = {
39
44
 
40
45
  return (
41
46
  <Field id="playground-field" label="Switch label">
42
- <Switch {...args} checked={checked} onClick={() => setChecked((v: boolean) => !v)} />
47
+ <Switch
48
+ {...args}
49
+ checked={checked}
50
+ onClick={() => setChecked((value: boolean) => !value)}
51
+ />
43
52
  </Field>
44
53
  );
45
54
  },
46
55
  argTypes: {
47
56
  onClick: { table: { disable: true } },
48
57
  },
49
- };
58
+ });
50
59
 
51
60
  /**
52
61
  * 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 />