@transferwise/components 46.110.0 → 46.111.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.
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/listItem/ListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,OAAO,EAAc,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAY,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAc,KAAK,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAU,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAU,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAY5D,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,YAAY,GACZ,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,aAAa,CAAC;AAElB,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,qBAAqB,GACrB,mBAAmB,GACnB,uBAAuB,GACvB,kBAAkB,GAClB,mBAAmB,CAAC;AAExB,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,SAAS,CAAC;IAClC;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAA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AAExB,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,SAAS,CAAC;IAClC;;OAEG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAClC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ;0MAiBlB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuOf,CAAC;AA6GF,eAAe,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.110.0",
3
+ "version": "46.111.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -83,10 +83,10 @@
83
83
  "storybook": "^9.1.3",
84
84
  "storybook-addon-tag-badges": "^2.0.2",
85
85
  "storybook-addon-test-codegen": "^2.0.1",
86
- "@transferwise/neptune-css": "14.24.6",
87
- "@wise/components-theming": "1.6.4",
88
- "@wise/wds-configs": "0.0.0",
89
- "@transferwise/less-config": "3.1.2"
86
+ "@transferwise/less-config": "3.1.2",
87
+ "@transferwise/neptune-css": "14.25.0",
88
+ "@wise/components-theming": "1.7.0",
89
+ "@wise/wds-configs": "0.0.0"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@transferwise/icons": "^3.22.4",
@@ -22,7 +22,12 @@ import {
22
22
  const meta = {
23
23
  title: 'Forms/SelectInput',
24
24
  component: SelectInput,
25
-
25
+ args: {
26
+ onFilterChange: fn() satisfies Mock,
27
+ onChange: fn() satisfies Mock,
28
+ onClose: fn() satisfies Mock,
29
+ onOpen: fn() satisfies Mock,
30
+ },
26
31
  parameters: { actions: { argTypesRegex: '' } },
27
32
  } satisfies Meta<typeof SelectInput>;
28
33
  export default meta;
@@ -47,10 +52,6 @@ export const Months: Story<Month | null> = {
47
52
  value: month,
48
53
  })),
49
54
  renderValue: (month) => <SelectInputOptionContent title={month.name} />,
50
- onFilterChange: fn() satisfies Mock,
51
- onChange: fn() satisfies Mock,
52
- onClose: fn() satisfies Mock,
53
- onClear: fn() satisfies Mock,
54
55
  },
55
56
  render: function Render({ onChange, onClear, ...args }) {
56
57
  const [selectedMonth, setSelectedMonth] = useState<Month | null>(null);
@@ -183,7 +184,6 @@ const CurrenciesArgs = {
183
184
  filterable: true,
184
185
  filterPlaceholder: 'Type a currency / country',
185
186
  size: 'lg',
186
- onChange: fn() satisfies Mock,
187
187
  } satisfies Story<Currency>['args'];
188
188
 
189
189
  export const Currencies: Story<Currency> = {
@@ -265,7 +265,7 @@ export const MultipleCurrencies: Story<Currency, true> = {
265
265
  />
266
266
  ),
267
267
  },
268
- play: async ({ canvasElement, step }) => {
268
+ play: async ({ canvasElement, step, args }) => {
269
269
  const canvas = within(canvasElement);
270
270
 
271
271
  await step('Open the combobox', async () => {
@@ -273,6 +273,7 @@ export const MultipleCurrencies: Story<Currency, true> = {
273
273
  await userEvent.click(triggerButton);
274
274
  await wait(500);
275
275
  await userEvent.unhover(triggerButton);
276
+ await expect(args.onOpen).toHaveBeenCalledOnce();
276
277
  });
277
278
 
278
279
  await step('Select EUR option', async () => {
@@ -349,6 +350,19 @@ export const WithSelectAll: Story<Currency, true> = {
349
350
  },
350
351
  };
351
352
 
353
+ export const WithClear: Story<Currency> = {
354
+ args: {
355
+ ...CurrenciesArgs,
356
+ onClear: fn() satisfies Mock,
357
+ },
358
+ play: async ({ step }) => {
359
+ await step('Has clear button', async () => {
360
+ const clearBtn = await screen.findByRole('button', { name: 'Clear' });
361
+ await expect(clearBtn).toBeInTheDocument();
362
+ });
363
+ },
364
+ };
365
+
352
366
  export const CustomTrigger: Story<Month> = {
353
367
  args: {
354
368
  placeholder: 'Month',
@@ -367,14 +381,14 @@ export const CustomTrigger: Story<Month> = {
367
381
  <ChevronDown size={16} />
368
382
  </SelectInputTriggerButton>
369
383
  ),
370
- onChange: fn() satisfies Mock,
371
384
  },
372
- play: async ({ canvasElement, step }) => {
385
+ play: async ({ canvasElement, step, args }) => {
373
386
  const canvas = within(canvasElement);
374
387
 
375
388
  await step('Open the combobox', async () => {
376
389
  const triggerButton = canvas.getByRole('combobox');
377
390
  await userEvent.click(triggerButton);
391
+ await expect(args.onOpen).toHaveBeenCalledOnce();
378
392
  });
379
393
  },
380
394
  };
@@ -414,7 +428,6 @@ export const Advanced: Story<Month> = {
414
428
  ),
415
429
  filterable: true,
416
430
  filterPlaceholder: 'Type a month’s name',
417
- onChange: fn() satisfies Mock,
418
431
  },
419
432
  play: async ({ canvasElement, step }) => {
420
433
  const canvas = within(canvasElement);
@@ -178,6 +178,7 @@ export interface SelectInputProps<T = string, M extends boolean = false> {
178
178
  };
179
179
  onFilterChange?: (args: { query: string; queryNormalized: string | null }) => void;
180
180
  onChange?: (value: M extends true ? T[] : T) => void;
181
+ onOpen?: () => void;
181
182
  onClose?: () => void;
182
183
  onClear?: () => void;
183
184
  }
@@ -263,6 +264,7 @@ export function SelectInput<T = string, M extends boolean = false>({
263
264
  UNSAFE_triggerButtonProps,
264
265
  onFilterChange = noop,
265
266
  onChange,
267
+ onOpen,
266
268
  onClose,
267
269
  onClear,
268
270
  }: SelectInputProps<T, M>) {
@@ -273,15 +275,18 @@ export function SelectInput<T = string, M extends boolean = false>({
273
275
 
274
276
  const initialized = useRef(false);
275
277
  const handleClose = useEffectEvent(onClose ?? (() => {}));
278
+ const handleOpen = useEffectEvent(onOpen ?? (() => {}));
276
279
  useEffect(() => {
277
280
  if (initialized.current) {
278
- if (!open) {
281
+ if (open) {
282
+ handleOpen?.();
283
+ } else {
279
284
  handleClose?.();
280
285
  }
281
286
  } else {
282
287
  initialized.current = true;
283
288
  }
284
- }, [handleClose, open]);
289
+ }, [handleClose, handleOpen, open]);
285
290
 
286
291
  const [filterQuery, _setFilterQuery] = useState('');
287
292
  const deferredFilterQuery = useDeferredValue(filterQuery);
@@ -235,7 +235,8 @@ export const ListItem = ({
235
235
  [`wds-list-item-spotlight wds-list-item-spotlight-${spotlight}`]:
236
236
  isFullyInteractive && !!spotlight,
237
237
  disabled: disabled && !isPartiallyInteractive,
238
- 'disabled--has-prompt-reason': !disabledPromptMessage && disabled && !isPartiallyInteractive,
238
+ 'disabled--has-prompt-reason':
239
+ !disabledPromptMessage && disabled && !isPartiallyInteractive,
239
240
  },
240
241
  className,
241
242
  )}
@@ -0,0 +1,142 @@
1
+ import React, { ReactNode } from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react-webpack5';
3
+ import clsx from 'clsx';
4
+ import AvatarView from '../avatarView';
5
+ import Tooltip from '../tooltip';
6
+ import IconButton from '../iconButton';
7
+ import Body from '../body';
8
+
9
+ const meta: Meta = {
10
+ title: 'NeptuneCSS',
11
+ component: () => <div>NeptuneCSS Example</div>,
12
+ };
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj;
17
+
18
+ export const Colors: Story = {
19
+ render: () => {
20
+ return (
21
+ <Body>
22
+ {colorTokens.map((token) => (
23
+ <ColorToken key={token} token={token} className="m-b-2" />
24
+ ))}
25
+ </Body>
26
+ );
27
+ },
28
+ };
29
+
30
+ const colorTokens = [
31
+ '--color-content-primary',
32
+ '--color-bright-yellow',
33
+ '--color-bright-orange',
34
+ '--color-dark-purple',
35
+ '--color-dark-gold',
36
+ '--color-bright-blue',
37
+ '--color-dark-charcoal',
38
+ '--color-white',
39
+ '--color-black',
40
+ '--color-bright-green',
41
+ '--color-forest-green',
42
+ '--color-bright-pink',
43
+ '--color-dark-maroon',
44
+ '--color-content-primary',
45
+ '--color-content-secondary',
46
+ '--color-content-tertiary',
47
+ '--color-content-link',
48
+ '--color-content-link-hover',
49
+ '--color-content-link-active',
50
+ '--color-interactive-control',
51
+ '--color-interactive-control-hover',
52
+ '--color-interactive-control-active',
53
+ '--color-interactive-primary',
54
+ '--color-interactive-primary-hover',
55
+ '--color-interactive-primary-active',
56
+ '--color-interactive-secondary',
57
+ '--color-interactive-secondary-hover',
58
+ '--color-interactive-secondary-active',
59
+ '--color-interactive-accent',
60
+ '--color-interactive-accent-hover',
61
+ '--color-interactive-accent-active',
62
+ '--color-interactive-contrast',
63
+ '--color-interactive-contrast-hover',
64
+ '--color-interactive-contrast-active',
65
+ '--color-interactive-neutral',
66
+ '--color-interactive-neutral-hover',
67
+ '--color-interactive-neutral-active',
68
+ '--color-border-neutral',
69
+ '--color-border-overlay',
70
+ '--color-background-screen',
71
+ '--color-background-screen-hover',
72
+ '--color-background-screen-active',
73
+ '--color-background-elevated',
74
+ '--color-background-neutral',
75
+ '--color-background-neutral-hover',
76
+ '--color-background-neutral-active',
77
+ '--color-background-overlay',
78
+ '--color-background-surface',
79
+ '--color-sentiment-negative',
80
+ '--color-sentiment-negative-hover',
81
+ '--color-sentiment-negative-active',
82
+ '--color-sentiment-negative-primary',
83
+ '--color-sentiment-negative-primary-hover',
84
+ '--color-sentiment-negative-primary-active',
85
+ '--color-sentiment-negative-secondary',
86
+ '--color-sentiment-negative-secondary-hover',
87
+ '--color-sentiment-negative-secondary-active',
88
+ '--color-sentiment-positive',
89
+ '--color-sentiment-positive-hover',
90
+ '--color-sentiment-positive-active',
91
+ '--color-sentiment-positive-primary',
92
+ '--color-sentiment-positive-primary-hover',
93
+ '--color-sentiment-positive-primary-active',
94
+ '--color-sentiment-positive-secondary',
95
+ '--color-sentiment-positive-secondary-hover',
96
+ '--color-sentiment-positive-secondary-active',
97
+ '--color-sentiment-warning',
98
+ '--color-sentiment-warning-hover',
99
+ '--color-sentiment-warning-active',
100
+ '--color-sentiment-warning-primary',
101
+ '--color-sentiment-warning-primary-hover',
102
+ '--color-sentiment-warning-primary-active',
103
+ '--color-sentiment-warning-secondary',
104
+ '--color-sentiment-warning-secondary-hover',
105
+ '--color-sentiment-warning-secondary-active',
106
+ '--color-sentiment-warning-content',
107
+ '--color-sentiment-warning-content-hover',
108
+ '--color-sentiment-warning-content-active',
109
+ '--color-contrast',
110
+ '--color-light',
111
+ '--color-dark',
112
+ '--color-contrast-overlay',
113
+ '--color-contrast-theme',
114
+ ];
115
+
116
+ function ColorToken(props: { token: string; className?: string }) {
117
+ const color = `var(${props.token})`;
118
+ const [tooltipLabel, setTooltipLabel] = React.useState<ReactNode>('Copy Token Name');
119
+ return (
120
+ <div className={clsx('d-flex', 'align-items-center', props.className)}>
121
+ <IconButton
122
+ aria-label="Copy color"
123
+ size={72}
124
+ className="m-r-2"
125
+ onClick={async () => {
126
+ await navigator.clipboard.writeText(color);
127
+ setTooltipLabel('Copied!');
128
+ }}
129
+ >
130
+ <Tooltip label={<Body type="body-large-bold">{tooltipLabel}</Body>} position="top">
131
+ <AvatarView
132
+ size={72}
133
+ style={{ backgroundColor: color, border: 'solid 1px var(--color-border-neutral)' }}
134
+ >
135
+ {null}
136
+ </AvatarView>
137
+ </Tooltip>
138
+ </IconButton>
139
+ <code className="m-l-2">{props.token}</code>
140
+ </div>
141
+ );
142
+ }