@transferwise/components 0.0.0-experimental-6809bdd → 0.0.0-experimental-e153d25

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,5 +1,5 @@
1
- import { PureComponent, KeyboardEvent } from 'react';
2
- import { Size, MonthFormat, SizeSmall, SizeMedium, SizeLarge } from '../common';
1
+ import { PureComponent, type KeyboardEvent } from 'react';
2
+ import { Size, MonthFormat, type SizeSmall, type SizeMedium, type SizeLarge } from '../common';
3
3
  export interface DateLookupProps {
4
4
  id?: string;
5
5
  value: Date | null;
@@ -1 +1 @@
1
- {"version":3,"file":"DateLookup.d.ts","sourceRoot":"","sources":["../../../src/dateLookup/DateLookup.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EACL,IAAI,EACJ,WAAW,EAGX,SAAS,EACT,UAAU,EACV,SAAS,EACV,MAAM,WAAW,CAAC;AAUnB,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,GAAG,WAAW,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;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AAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,cAAM,UAAW,SAAQ,aAAa,CAAC,eAAe,EAAE,eAAe,CAAC;IAC9D,KAAK,EAAE,eAAe,GAC5B,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,YAAY;;;;;;;;;;MAUkB;IAErC,OAAO,4CAA+B;IACtC,QAAQ,4CAA+B;gBAE3B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC;IAuBtC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,eAAe;;;;;;;IAwBlF,kBAAkB,CAAC,aAAa,EAAE,eAAe;IAQjD,oBAAoB;IAKpB,IAAI,aAOF;IAEF,OAAO,aAML;IAEF,KAAK,aAMH;IAEF,aAAa,UAAW,cAAc,cAAc,CAAC,UA6CnD;IAEF,UAAU,cAAe,MAAM,eAAe,MAAM,cAAc,MAAM,UAmBtE;IAEF,OAAO,qBAAsB,MAAM,oBAAoB,MAAM,UAO3D;IAEF,UAAU,SAAU,KAAK,GAAG,OAAO,GAAG,MAAM,UAI1C;IAEF,YAAY,aAAgC;IAE5C,cAAc,aAAkC;IAEhD,aAAa,aAAiC;IAE9C,wBAAwB,iBAAkB,IAAI,UAM5C;IAEF,oBAAoB;;;eAElB;IAEF,WAAW,oCA2CT;IAEF,WAAW,aAGT;IAEF,MAAM;CA2CP;AAED,eAAe,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { WrappedComponentProps } from 'react-intl';
2
+ import { type WrappedComponentProps } from 'react-intl';
3
3
  interface DayCalendarTableProps extends WrappedComponentProps {
4
4
  selectedDate: Date | null;
5
5
  min: Date | null;
@@ -1 +1 @@
1
- {"version":3,"file":"DayCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/dayCalendar/table/DayCalendarTable.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAS/D,UAAU,qBAAsB,SAAQ,qBAAqB;IAC3D,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC;;;;AAuID,wBAA4C"}
1
+ {"version":3,"file":"DayCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/dayCalendar/table/DayCalendarTable.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAc,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AASpE,UAAU,qBAAsB,SAAQ,qBAAqB;IAC3D,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC;;;;AA0ID,wBAA4C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "0.0.0-experimental-6809bdd",
3
+ "version": "0.0.0-experimental-e153d25",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "@testing-library/react-hooks": "^8.0.0",
68
68
  "@testing-library/user-event": "^13.2.1",
69
69
  "@transferwise/icons": "^3.7.0",
70
- "@transferwise/neptune-tokens": "^8.8.1",
70
+ "@transferwise/neptune-tokens": "^8.9.2",
71
71
  "@tsconfig/recommended": "^1.0.2",
72
72
  "@types/babel__core": "^7.20.1",
73
73
  "@types/commonmark": "^0.27.9",
@@ -95,14 +95,14 @@
95
95
  "rollup": "^3.28.1",
96
96
  "storybook": "^7.6.17",
97
97
  "@transferwise/less-config": "3.1.0",
98
- "@transferwise/neptune-css": "14.9.6",
99
- "@wise/components-theming": "1.1.0"
98
+ "@transferwise/neptune-css": "0.0.0-experimental-e153d25",
99
+ "@wise/components-theming": "0.0.0-experimental-e153d25"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@transferwise/icons": "^3.7.0",
103
- "@transferwise/neptune-css": "^14.9.6",
103
+ "@transferwise/neptune-css": "0.0.0-experimental-e153d25",
104
104
  "@wise/art": "^2.7.0",
105
- "@wise/components-theming": "^1.0.0",
105
+ "@wise/components-theming": "0.0.0-experimental-e153d25",
106
106
  "react": ">=16.14",
107
107
  "react-dom": ">=16.14",
108
108
  "react-intl": "^5.10.0 || ^6"
@@ -1,23 +1,30 @@
1
- import { ReactRenderer, Story } from '@storybook/react';
1
+ import type { ReactRenderer, Story } from '@storybook/react';
2
2
  import { expect, userEvent, within } from '@storybook/test';
3
- import { PlayFunctionContext } from '@storybook/types';
3
+ import type { PlayFunctionContext } from '@storybook/types';
4
4
  import { useState } from 'react';
5
5
 
6
- import DateLookup from './DateLookup';
6
+ import DateLookup, { type DateLookupProps } from './DateLookup';
7
7
 
8
8
  export default {
9
9
  component: DateLookup,
10
10
  title: 'Forms/DateLookup/Tests',
11
11
  };
12
12
 
13
- const Template: Story<DateLookup> = () => {
14
- const [value, setValue] = useState<Date | null>(new Date(1987, 0, 10, 12, 0, 0));
13
+ const props: DateLookupProps = {
14
+ value: new Date(1987, 0, 10, 12, 0, 0),
15
+ onChange: (value: Date | null) => {
16
+ console.log(value);
17
+ },
18
+ };
19
+
20
+ const Template: Story<DateLookupProps> = (args: DateLookupProps) => {
21
+ const [value, setValue] = useState<Date | null>(args.value);
15
22
 
16
23
  return (
17
24
  <DateLookup
25
+ {...args}
18
26
  value={value}
19
27
  clearable
20
- placeholder="placeholder"
21
28
  onChange={(v) => {
22
29
  setValue(v);
23
30
  }}
@@ -26,11 +33,11 @@ const Template: Story<DateLookup> = () => {
26
33
  };
27
34
 
28
35
  export const ClearSpace = Template.bind({});
29
-
36
+ ClearSpace.args = { ...props };
30
37
  ClearSpace.play = async ({
31
38
  canvasElement,
32
39
  step,
33
- }: PlayFunctionContext<ReactRenderer, DateLookup>) => {
40
+ }: PlayFunctionContext<ReactRenderer, DateLookupProps>) => {
34
41
  const canvas = within(canvasElement);
35
42
 
36
43
  await step('space can activate clear button', async () => {
@@ -48,11 +55,11 @@ ClearSpace.play = async ({
48
55
  };
49
56
 
50
57
  export const ClearEnter = Template.bind({});
51
-
58
+ ClearEnter.args = { ...props };
52
59
  ClearEnter.play = async ({
53
60
  canvasElement,
54
61
  step,
55
- }: PlayFunctionContext<ReactRenderer, DateLookup>) => {
62
+ }: PlayFunctionContext<ReactRenderer, DateLookupProps>) => {
56
63
  const canvas = within(canvasElement);
57
64
 
58
65
  await step('enter can activate clear button', async () => {
@@ -68,3 +75,29 @@ ClearEnter.play = async ({
68
75
  await expect(placeholder).toBeInTheDocument();
69
76
  });
70
77
  };
78
+
79
+ export const FocusOnSelectedDay = Template.bind({});
80
+ FocusOnSelectedDay.args = { ...props };
81
+ FocusOnSelectedDay.play = async () => {
82
+ await userEvent.tab();
83
+ await userEvent.keyboard(' ');
84
+ };
85
+
86
+ export const FocusOnToday = Template.bind({});
87
+ FocusOnToday.args = { ...props, value: null };
88
+ FocusOnToday.play = async () => {
89
+ await userEvent.tab();
90
+ await userEvent.keyboard(' ');
91
+ };
92
+
93
+ export const FocusOnFirstNonDisabledDate = Template.bind({});
94
+ FocusOnFirstNonDisabledDate.args = {
95
+ ...props,
96
+ value: null,
97
+ min: new Date(1987, 0, 10, 12, 0, 0),
98
+ max: new Date(1987, 0, 12, 12, 0, 0),
99
+ };
100
+ FocusOnFirstNonDisabledDate.play = async () => {
101
+ await userEvent.tab();
102
+ await userEvent.keyboard(' ');
103
+ };
@@ -1,14 +1,14 @@
1
1
  import classNames from 'classnames';
2
- import { createRef, PureComponent, KeyboardEvent } from 'react';
2
+ import { createRef, PureComponent, type KeyboardEvent } from 'react';
3
3
 
4
4
  import {
5
5
  Size,
6
6
  MonthFormat,
7
7
  Position,
8
8
  Breakpoint,
9
- SizeSmall,
10
- SizeMedium,
11
- SizeLarge,
9
+ type SizeSmall,
10
+ type SizeMedium,
11
+ type SizeLarge,
12
12
  } from '../common';
13
13
  import { isWithinRange, moveToWithinRange } from '../common/dateUtils';
14
14
  import ResponsivePanel from '../common/responsivePanel';
@@ -74,8 +74,16 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
74
74
  originalDate: null,
75
75
  min: getStartOfDay(props.min),
76
76
  max: getStartOfDay(props.max),
77
- viewMonth: (props.value || new Date()).getMonth(),
78
- viewYear: (props.value || new Date()).getFullYear(),
77
+ viewMonth: (
78
+ props.value ||
79
+ ((props.min || props.max) && moveToWithinRange(new Date(), props.min, props.max)) ||
80
+ new Date()
81
+ ).getMonth(),
82
+ viewYear: (
83
+ props.value ||
84
+ ((props.min || props.max) && moveToWithinRange(new Date(), props.min, props.max)) ||
85
+ new Date()
86
+ ).getFullYear(),
79
87
  open: false,
80
88
  mode: 'day',
81
89
  isMobile: false,
@@ -206,9 +214,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
206
214
  } else {
207
215
  date = getStartOfDay(new Date());
208
216
  }
209
- if (date) {
210
- date = moveToWithinRange(date, min, max);
211
- }
217
+ date &&= moveToWithinRange(date, min, max);
212
218
  if (date?.getTime() !== selectedDate?.getTime()) {
213
219
  this.props.onChange(date);
214
220
  }
@@ -1,6 +1,6 @@
1
1
  import { formatDate } from '@transferwise/formatting';
2
2
  import { PureComponent } from 'react';
3
- import { injectIntl, WrappedComponentProps } from 'react-intl';
3
+ import { injectIntl, type WrappedComponentProps } from 'react-intl';
4
4
 
5
5
  import { getDayNames, isWithinRange } from '../../../common/dateUtils';
6
6
  import { getFocusableTime } from '../../getFocusableTime/getFocusableTime';
@@ -64,6 +64,9 @@ class DayCalendarTable extends PureComponent<DayCalendarTableProps> {
64
64
  };
65
65
 
66
66
  isDisabled = (day: number) => {
67
+ if (day === -1) {
68
+ return true;
69
+ }
67
70
  const { min, max, viewMonth, viewYear } = this.props;
68
71
  const date = new Date(viewYear, viewMonth, day);
69
72
 
@@ -72,7 +75,7 @@ class DayCalendarTable extends PureComponent<DayCalendarTableProps> {
72
75
 
73
76
  isActive = (day: number) => {
74
77
  const { selectedDate, viewMonth, viewYear } = this.props;
75
- return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
78
+ return !!(selectedDate && Number(new Date(viewYear, viewMonth, day)) === Number(selectedDate));
76
79
  };
77
80
 
78
81
  isToday = (day: number) => {
@@ -0,0 +1,21 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { ThemeProvider } from '@wise/components-theming';
3
+
4
+ import Button from '../../button';
5
+
6
+ export default {
7
+ component: ThemeProvider,
8
+ title: 'Other/ThemeProvider',
9
+ } satisfies Meta<typeof ThemeProvider>;
10
+
11
+ type Story = StoryObj<typeof ThemeProvider>;
12
+
13
+ export const PlatformTheme: Story = {
14
+ render: () => (
15
+ <>
16
+ <ThemeProvider theme="platform">
17
+ <Button>Button</Button>
18
+ </ThemeProvider>
19
+ </>
20
+ ),
21
+ };