@transferwise/components 0.0.0-experimental-1a3a746 → 0.0.0-experimental-3b2f02f
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.
- package/build/index.js +242 -110
- package/build/index.js.map +1 -1
- package/build/index.mjs +242 -110
- package/build/index.mjs.map +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/isWithinRange/isWithinRange.d.ts.map +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts +1 -1
- package/build/types/common/dateUtils/moveToWithinRange/moveToWithinRange.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +28 -80
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.messages.d.ts +63 -42
- package/build/types/dateLookup/DateLookup.messages.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts +22 -9
- package/build/types/dateLookup/dateHeader/DateHeader.d.ts.map +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts +1 -1
- package/build/types/dateLookup/dateHeader/index.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts +31 -13
- package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts +1 -1
- package/build/types/dateLookup/dateTrigger/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts +2 -19
- package/build/types/dateLookup/dayCalendar/DayCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +2 -12
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/getStartOfDay.d.ts.map +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts +1 -1
- package/build/types/dateLookup/getStartOfDay/index.d.ts.map +1 -1
- package/build/types/dateLookup/index.d.ts +1 -2
- package/build/types/dateLookup/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts +2 -17
- package/build/types/dateLookup/monthCalendar/MonthCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +26 -10
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts +2 -15
- package/build/types/dateLookup/yearCalendar/YearCalendar.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts +26 -10
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts +1 -1
- package/build/types/dateLookup/yearCalendar/table/index.d.ts.map +1 -1
- package/build/types/index.d.ts +0 -1
- package/build/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/dateUtils/isWithinRange/isWithinRange.spec.ts +0 -21
- package/src/common/dateUtils/isWithinRange/isWithinRange.ts +2 -2
- package/src/common/dateUtils/moveToWithinRange/moveToWithinRange.ts +2 -11
- package/src/dateLookup/{DateLookup.tsx → DateLookup.js} +69 -114
- package/src/dateLookup/DateLookup.state.spec.js +0 -7
- package/src/dateLookup/{DateLookup.story.tsx → DateLookup.story.js} +14 -13
- package/src/dateLookup/dateHeader/{DateHeader.tsx → DateHeader.js} +15 -15
- package/src/dateLookup/dateTrigger/{DateTrigger.tsx → DateTrigger.js} +32 -15
- package/src/dateLookup/dateTrigger/DateTrigger.spec.js +22 -0
- package/src/dateLookup/dayCalendar/{DayCalendar.tsx → DayCalendar.js} +21 -14
- package/src/dateLookup/dayCalendar/table/{DayCalendarTable.tsx → DayCalendarTable.js} +37 -26
- package/src/dateLookup/getStartOfDay/{getStartOfDay.tsx → getStartOfDay.js} +1 -1
- package/src/dateLookup/index.js +1 -0
- package/src/dateLookup/monthCalendar/{MonthCalendar.tsx → MonthCalendar.js} +22 -19
- package/src/dateLookup/monthCalendar/table/{MonthCalendarTable.tsx → MonthCalendarTable.js} +30 -31
- package/src/dateLookup/yearCalendar/{YearCalendar.tsx → YearCalendar.js} +21 -18
- package/src/dateLookup/yearCalendar/table/{YearCalendarTable.tsx → YearCalendarTable.js} +28 -26
- package/src/index.ts +0 -1
- package/src/inputs/InputGroup.tsx +3 -3
- package/src/dateLookup/DateLookup.tests.story.tsx +0 -71
- package/src/dateLookup/index.ts +0 -2
- /package/src/dateLookup/{DateLookup.messages.ts → DateLookup.messages.js} +0 -0
- /package/src/dateLookup/dateHeader/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dateTrigger/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dayCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/dayCalendar/table/{index.ts → index.js} +0 -0
- /package/src/dateLookup/getStartOfDay/{index.ts → index.js} +0 -0
- /package/src/dateLookup/monthCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/monthCalendar/table/{index.ts → index.js} +0 -0
- /package/src/dateLookup/yearCalendar/{index.ts → index.js} +0 -0
- /package/src/dateLookup/yearCalendar/table/{index.ts → index.js} +0 -0
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
interface YearCalendarTableProps {
|
|
3
|
-
selectedDate: Date | null;
|
|
4
|
-
min: Date | null;
|
|
5
|
-
max: Date | null;
|
|
6
|
-
viewYear: number;
|
|
7
|
-
placeholder: string;
|
|
8
|
-
onSelect: (year: number) => void;
|
|
9
|
-
}
|
|
10
|
-
declare const YearCalendarTable: ({ selectedDate, min, max, viewYear, placeholder, onSelect, }: YearCalendarTableProps) => import("react").JSX.Element;
|
|
11
1
|
export default YearCalendarTable;
|
|
2
|
+
declare function YearCalendarTable({ selectedDate, min, max, viewYear, placeholder, onSelect }: {
|
|
3
|
+
selectedDate: any;
|
|
4
|
+
min: any;
|
|
5
|
+
max: any;
|
|
6
|
+
viewYear: any;
|
|
7
|
+
placeholder: any;
|
|
8
|
+
onSelect: any;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
declare namespace YearCalendarTable {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
const selectedDate: any;
|
|
13
|
+
const min: any;
|
|
14
|
+
const max: any;
|
|
15
|
+
const viewYear: any;
|
|
16
|
+
const placeholder: any;
|
|
17
|
+
const onSelect: any;
|
|
18
|
+
}
|
|
19
|
+
namespace defaultProps {
|
|
20
|
+
const selectedDate_1: null;
|
|
21
|
+
export { selectedDate_1 as selectedDate };
|
|
22
|
+
const min_1: null;
|
|
23
|
+
export { min_1 as min };
|
|
24
|
+
const max_1: null;
|
|
25
|
+
export { max_1 as max };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
12
28
|
//# sourceMappingURL=YearCalendarTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YearCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/yearCalendar/table/YearCalendarTable.
|
|
1
|
+
{"version":3,"file":"YearCalendarTable.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/yearCalendar/table/YearCalendarTable.js"],"names":[],"mappings":";AAWA;;;;;;;gCAuDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
1
|
+
export { default } from "./YearCalendarTable";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/yearCalendar/table/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/dateLookup/yearCalendar/table/index.js"],"names":[],"mappings":""}
|
package/build/types/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export type { InfoProps } from './info';
|
|
|
12
12
|
export type { SummaryProps } from './summary';
|
|
13
13
|
export type { InputProps } from './inputs/Input';
|
|
14
14
|
export type { DateInputProps } from './dateInput';
|
|
15
|
-
export type { DateLookupProps } from './dateLookup';
|
|
16
15
|
export type { InputWithDisplayFormatProps } from './inputWithDisplayFormat';
|
|
17
16
|
export type { InputGroupProps } from './inputs/InputGroup';
|
|
18
17
|
export type { LoaderProps } from './loader';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,UAAU,EA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AY,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-3b2f02f",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"rollup": "^3.28.1",
|
|
96
96
|
"storybook": "^7.6.17",
|
|
97
97
|
"@transferwise/less-config": "3.1.0",
|
|
98
|
-
"@
|
|
99
|
-
"@
|
|
98
|
+
"@transferwise/neptune-css": "14.9.6",
|
|
99
|
+
"@wise/components-theming": "1.1.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"@transferwise/icons": "^3.7.0",
|
|
@@ -22,31 +22,10 @@ describe('isWithinRange', () => {
|
|
|
22
22
|
expect(isWithinRange(date, min, max)).toBe(false);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
it('returns false when min > date and max is undefined', () => {
|
|
26
|
-
const date = new Date('1995-12-20');
|
|
27
|
-
const min = new Date('1995-12-21');
|
|
28
|
-
const max = null;
|
|
29
|
-
expect(isWithinRange(date, min, max)).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
25
|
it('returns false when date > max', () => {
|
|
33
26
|
const date = new Date('1995-12-23');
|
|
34
27
|
const min = new Date('1995-12-20');
|
|
35
28
|
const max = new Date('1995-12-22');
|
|
36
29
|
expect(isWithinRange(date, min, max)).toBe(false);
|
|
37
30
|
});
|
|
38
|
-
|
|
39
|
-
it('returns false when date > max and min is undefined', () => {
|
|
40
|
-
const date = new Date('1995-12-23');
|
|
41
|
-
const min = null;
|
|
42
|
-
const max = new Date('1995-12-22');
|
|
43
|
-
expect(isWithinRange(date, min, max)).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('returns true when min and max are undefined', () => {
|
|
47
|
-
const date = new Date('1995-12-23');
|
|
48
|
-
const min = null;
|
|
49
|
-
const max = null;
|
|
50
|
-
expect(isWithinRange(date, min, max)).toBe(true);
|
|
51
|
-
});
|
|
52
31
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function isWithinRange(date: Date, min: Date
|
|
2
|
-
return (!min || date >= min) && (!max || date <= max);
|
|
1
|
+
export function isWithinRange(date: Date, min: Date, max: Date) {
|
|
2
|
+
return !date || ((!min || date >= min) && (!max || date <= max));
|
|
3
3
|
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { isWithinRange } from '..';
|
|
2
2
|
|
|
3
3
|
// Makes sure that date is between min and max dates, returns a cloned min or max
|
|
4
|
-
export function moveToWithinRange(date: Date, min: Date
|
|
5
|
-
|
|
6
|
-
return date;
|
|
7
|
-
}
|
|
8
|
-
if (min && date < min) {
|
|
9
|
-
return new Date(min);
|
|
10
|
-
}
|
|
11
|
-
if (max && date > max) {
|
|
12
|
-
return new Date(max);
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
4
|
+
export function moveToWithinRange(date: Date, min: Date, max: Date) {
|
|
5
|
+
return isWithinRange(date, min, max) ? date : new Date(min && date < min ? +min : +max);
|
|
15
6
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { createRef, PureComponent } from 'react';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
Size,
|
|
6
|
-
MonthFormat,
|
|
7
|
-
Position,
|
|
8
|
-
Breakpoint,
|
|
9
|
-
SizeSmall,
|
|
10
|
-
SizeMedium,
|
|
11
|
-
SizeLarge,
|
|
12
|
-
} from '../common';
|
|
5
|
+
import { Size, MonthFormat, Position, Breakpoint } from '../common';
|
|
13
6
|
import { isWithinRange, moveToWithinRange } from '../common/dateUtils';
|
|
14
7
|
import ResponsivePanel from '../common/responsivePanel';
|
|
15
8
|
|
|
@@ -25,61 +18,18 @@ const MODE = {
|
|
|
25
18
|
YEAR: 'year',
|
|
26
19
|
};
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
value: Date | null;
|
|
31
|
-
min?: Date | null;
|
|
32
|
-
max?: Date | null;
|
|
33
|
-
size?: SizeSmall | SizeMedium | SizeLarge;
|
|
34
|
-
placeholder?: string;
|
|
35
|
-
label?: string;
|
|
36
|
-
'aria-labelledby'?: string;
|
|
37
|
-
monthFormat?: `${MonthFormat}`;
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
clearable?: boolean;
|
|
40
|
-
onChange: (date: Date | null) => void;
|
|
41
|
-
onFocus?: () => void;
|
|
42
|
-
onBlur?: () => void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface DateLookupState {
|
|
46
|
-
selectedDate: Date | null;
|
|
47
|
-
originalDate: Date | null;
|
|
48
|
-
min: Date | null;
|
|
49
|
-
max: Date | null;
|
|
50
|
-
viewMonth: number;
|
|
51
|
-
viewYear: number;
|
|
52
|
-
open: boolean;
|
|
53
|
-
mode: (typeof MODE)[keyof typeof MODE];
|
|
54
|
-
isMobile: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
58
|
-
declare props: DateLookupProps &
|
|
59
|
-
Required<Pick<DateLookupProps, keyof typeof DateLookup.defaultProps>>;
|
|
60
|
-
|
|
61
|
-
static defaultProps = {
|
|
62
|
-
value: null,
|
|
63
|
-
min: null,
|
|
64
|
-
max: null,
|
|
65
|
-
size: Size.MEDIUM,
|
|
66
|
-
placeholder: '',
|
|
67
|
-
label: '',
|
|
68
|
-
monthFormat: MonthFormat.LONG,
|
|
69
|
-
disabled: false,
|
|
70
|
-
clearable: false,
|
|
71
|
-
} satisfies Partial<DateLookupProps>;
|
|
21
|
+
class DateLookup extends PureComponent {
|
|
22
|
+
element = createRef();
|
|
72
23
|
|
|
73
|
-
|
|
74
|
-
dropdown = createRef<HTMLDivElement>();
|
|
24
|
+
dropdown = createRef();
|
|
75
25
|
|
|
76
|
-
constructor(props
|
|
26
|
+
constructor(props) {
|
|
77
27
|
super(props);
|
|
78
28
|
this.state = {
|
|
79
29
|
selectedDate: getStartOfDay(props.value),
|
|
80
30
|
originalDate: null,
|
|
81
|
-
min: getStartOfDay(props.min
|
|
82
|
-
max: getStartOfDay(props.max
|
|
31
|
+
min: getStartOfDay(props.min),
|
|
32
|
+
max: getStartOfDay(props.max),
|
|
83
33
|
viewMonth: (props.value || new Date()).getMonth(),
|
|
84
34
|
viewYear: (props.value || new Date()).getFullYear(),
|
|
85
35
|
open: false,
|
|
@@ -88,41 +38,35 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
88
38
|
};
|
|
89
39
|
}
|
|
90
40
|
|
|
91
|
-
static getDerivedStateFromProps(props
|
|
41
|
+
static getDerivedStateFromProps(props, state) {
|
|
92
42
|
const propsSelected = getStartOfDay(props.value);
|
|
93
|
-
const propsMin = getStartOfDay(props.min
|
|
94
|
-
const propsMax = getStartOfDay(props.max
|
|
95
|
-
const hasSelectedChanged = state.selectedDate
|
|
96
|
-
const hasMinChanged = state.min
|
|
97
|
-
const hasMaxChanged = state.max
|
|
43
|
+
const propsMin = getStartOfDay(props.min);
|
|
44
|
+
const propsMax = getStartOfDay(props.max);
|
|
45
|
+
const hasSelectedChanged = +state.selectedDate !== +propsSelected;
|
|
46
|
+
const hasMinChanged = +state.min !== +propsMin;
|
|
47
|
+
const hasMaxChanged = +state.max !== +propsMax;
|
|
98
48
|
if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {
|
|
99
49
|
const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;
|
|
100
50
|
const min = hasMinChanged ? propsMin : state.min;
|
|
101
51
|
const max = hasMaxChanged ? propsMax : state.max;
|
|
102
|
-
|
|
52
|
+
// make sure that selected date is within allowed range
|
|
53
|
+
if (!isWithinRange(selectedDate, min, max)) {
|
|
103
54
|
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
104
55
|
return null;
|
|
105
56
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
const viewMonth = viewDateThatIsWithinRange.getMonth();
|
|
109
|
-
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
57
|
+
const viewMonth = (selectedDate || new Date()).getMonth();
|
|
58
|
+
const viewYear = (selectedDate || new Date()).getFullYear();
|
|
110
59
|
return { selectedDate, min, max, viewMonth, viewYear };
|
|
111
60
|
}
|
|
112
61
|
return null;
|
|
113
62
|
}
|
|
114
63
|
|
|
115
|
-
componentDidUpdate(previousProps
|
|
116
|
-
if (
|
|
117
|
-
this.props.value &&
|
|
118
|
-
previousProps.value &&
|
|
119
|
-
this.props.value.getTime() !== previousProps.value.getTime() &&
|
|
120
|
-
this.state.open
|
|
121
|
-
) {
|
|
64
|
+
componentDidUpdate(previousProps) {
|
|
65
|
+
if (+this.props.value !== +previousProps.value && this.state.open) {
|
|
122
66
|
this.focusOn('.active');
|
|
123
67
|
}
|
|
124
|
-
|
|
125
|
-
this.setState({ isMobile: mediaQuery.matches });
|
|
68
|
+
this.mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);
|
|
69
|
+
this.setState({ isMobile: this.mediaQuery.matches });
|
|
126
70
|
}
|
|
127
71
|
|
|
128
72
|
componentWillUnmount() {
|
|
@@ -155,7 +99,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
155
99
|
}
|
|
156
100
|
};
|
|
157
101
|
|
|
158
|
-
handleKeyDown = (event
|
|
102
|
+
handleKeyDown = (event) => {
|
|
159
103
|
const { open, originalDate } = this.state;
|
|
160
104
|
switch (event.key) {
|
|
161
105
|
case 'ArrowLeft':
|
|
@@ -202,12 +146,12 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
202
146
|
}
|
|
203
147
|
};
|
|
204
148
|
|
|
205
|
-
adjustDate = (daysToAdd
|
|
149
|
+
adjustDate = (daysToAdd, monthsToAdd, yearsToAdd) => {
|
|
206
150
|
const { selectedDate, min, max, mode, originalDate } = this.state;
|
|
207
151
|
if (originalDate === null) {
|
|
208
152
|
this.setState({ originalDate: selectedDate });
|
|
209
153
|
}
|
|
210
|
-
let date
|
|
154
|
+
let date;
|
|
211
155
|
if (selectedDate) {
|
|
212
156
|
date = new Date(
|
|
213
157
|
mode === MODE.YEAR ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),
|
|
@@ -217,16 +161,14 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
217
161
|
} else {
|
|
218
162
|
date = getStartOfDay(new Date());
|
|
219
163
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
164
|
+
date = moveToWithinRange(date, min, max);
|
|
165
|
+
if (+date !== +selectedDate) {
|
|
224
166
|
this.props.onChange(date);
|
|
225
167
|
}
|
|
226
168
|
};
|
|
227
169
|
|
|
228
|
-
focusOn = (preferredElement
|
|
229
|
-
const element = this.element.current
|
|
170
|
+
focusOn = (preferredElement, fallbackElement) => {
|
|
171
|
+
const element = this.element.current.querySelector(preferredElement);
|
|
230
172
|
if (element) {
|
|
231
173
|
element.focus();
|
|
232
174
|
} else if (fallbackElement) {
|
|
@@ -234,7 +176,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
234
176
|
}
|
|
235
177
|
};
|
|
236
178
|
|
|
237
|
-
switchMode = (mode
|
|
179
|
+
switchMode = (mode) => {
|
|
238
180
|
this.setState({ mode }, () => {
|
|
239
181
|
this.focusOn('.active', '.today');
|
|
240
182
|
});
|
|
@@ -246,7 +188,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
246
188
|
|
|
247
189
|
switchToYears = () => this.switchMode(MODE.YEAR);
|
|
248
190
|
|
|
249
|
-
handleSelectedDateUpdate = (selectedDate
|
|
191
|
+
handleSelectedDateUpdate = (selectedDate) => {
|
|
250
192
|
this.setState({ selectedDate }, () => {
|
|
251
193
|
this.props.onChange(selectedDate);
|
|
252
194
|
this.close();
|
|
@@ -265,12 +207,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
265
207
|
<div className={classNames({ 'p-a-1': !isMobile })}>
|
|
266
208
|
{mode === MODE.DAY && (
|
|
267
209
|
<DayCalendar
|
|
268
|
-
|
|
269
|
-
min={min}
|
|
270
|
-
max={max}
|
|
271
|
-
viewMonth={viewMonth}
|
|
272
|
-
viewYear={viewYear}
|
|
273
|
-
monthFormat={monthFormat}
|
|
210
|
+
{...{ selectedDate, min, max, viewMonth, viewYear, monthFormat }}
|
|
274
211
|
onSelect={this.handleSelectedDateUpdate}
|
|
275
212
|
onLabelClick={this.switchToYears}
|
|
276
213
|
onViewDateUpdate={this.handleViewDateUpdate}
|
|
@@ -278,11 +215,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
278
215
|
)}
|
|
279
216
|
{mode === MODE.MONTH && (
|
|
280
217
|
<MonthCalendar
|
|
281
|
-
|
|
282
|
-
min={min}
|
|
283
|
-
max={max}
|
|
284
|
-
viewYear={viewYear}
|
|
285
|
-
placeholder={placeholder || ''}
|
|
218
|
+
{...{ selectedDate, min, max, viewYear, placeholder }}
|
|
286
219
|
onSelect={this.switchToDays}
|
|
287
220
|
onLabelClick={this.switchToYears}
|
|
288
221
|
onViewDateUpdate={this.handleViewDateUpdate}
|
|
@@ -290,11 +223,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
290
223
|
)}
|
|
291
224
|
{mode === MODE.YEAR && (
|
|
292
225
|
<YearCalendar
|
|
293
|
-
|
|
294
|
-
min={min}
|
|
295
|
-
max={max}
|
|
296
|
-
viewYear={viewYear}
|
|
297
|
-
placeholder={placeholder || ''}
|
|
226
|
+
{...{ selectedDate, min, max, viewYear, placeholder }}
|
|
298
227
|
onSelect={this.switchToMonths}
|
|
299
228
|
onViewDateUpdate={this.handleViewDateUpdate}
|
|
300
229
|
/>
|
|
@@ -322,7 +251,7 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
322
251
|
value,
|
|
323
252
|
} = this.props;
|
|
324
253
|
return (
|
|
325
|
-
<div
|
|
254
|
+
<div // eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
326
255
|
ref={this.element}
|
|
327
256
|
id={this.props.id}
|
|
328
257
|
aria-labelledby={ariaLabelledBy}
|
|
@@ -330,14 +259,9 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
330
259
|
onKeyDown={this.handleKeyDown}
|
|
331
260
|
>
|
|
332
261
|
<DateTrigger
|
|
333
|
-
|
|
334
|
-
size={size}
|
|
335
|
-
placeholder={placeholder || ''}
|
|
336
|
-
label={label || ''}
|
|
337
|
-
monthFormat={monthFormat}
|
|
338
|
-
disabled={disabled || false}
|
|
262
|
+
{...{ selectedDate, size, placeholder, label, monthFormat, disabled }}
|
|
339
263
|
onClick={this.open}
|
|
340
|
-
onClear={!disabled && clearable && value ? this.handleClear :
|
|
264
|
+
onClear={!disabled && clearable && value ? this.handleClear : null}
|
|
341
265
|
/>
|
|
342
266
|
<ResponsivePanel
|
|
343
267
|
anchorRef={this.element}
|
|
@@ -353,4 +277,35 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
353
277
|
}
|
|
354
278
|
}
|
|
355
279
|
|
|
280
|
+
DateLookup.propTypes = {
|
|
281
|
+
id: PropTypes.string,
|
|
282
|
+
value: PropTypes.instanceOf(Date),
|
|
283
|
+
min: PropTypes.instanceOf(Date),
|
|
284
|
+
max: PropTypes.instanceOf(Date),
|
|
285
|
+
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
286
|
+
placeholder: PropTypes.string,
|
|
287
|
+
label: PropTypes.string,
|
|
288
|
+
'aria-labelledby': PropTypes.string,
|
|
289
|
+
monthFormat: PropTypes.oneOf(['long', 'short']),
|
|
290
|
+
disabled: PropTypes.bool,
|
|
291
|
+
onChange: PropTypes.func.isRequired,
|
|
292
|
+
onFocus: PropTypes.func,
|
|
293
|
+
onBlur: PropTypes.func,
|
|
294
|
+
clearable: PropTypes.bool,
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
DateLookup.defaultProps = {
|
|
298
|
+
value: null,
|
|
299
|
+
min: null,
|
|
300
|
+
max: null,
|
|
301
|
+
size: Size.MEDIUM,
|
|
302
|
+
placeholder: '',
|
|
303
|
+
label: '',
|
|
304
|
+
monthFormat: MonthFormat.LONG,
|
|
305
|
+
disabled: false,
|
|
306
|
+
onFocus: null,
|
|
307
|
+
onBlur: null,
|
|
308
|
+
clearable: false,
|
|
309
|
+
};
|
|
310
|
+
|
|
356
311
|
export default DateLookup;
|
|
@@ -66,11 +66,4 @@ describe('DateLookup state', () => {
|
|
|
66
66
|
DateLookup.getDerivedStateFromProps(props, defaultState);
|
|
67
67
|
expect(onChange).toHaveBeenCalledWith(new Date(2018, 10, 1));
|
|
68
68
|
});
|
|
69
|
-
|
|
70
|
-
it('updates viewMonth and viewYear to date within min/max on Clear', () => {
|
|
71
|
-
const props = { value: null, min: new Date(2018, 11, 26), max: new Date(2018, 11, 26) };
|
|
72
|
-
const newState = DateLookup.getDerivedStateFromProps(props, defaultState);
|
|
73
|
-
expect(newState.viewMonth).toBe(11);
|
|
74
|
-
expect(newState.viewYear).toBe(2018);
|
|
75
|
-
});
|
|
76
69
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { boolean, select,
|
|
2
|
-
import { userEvent } from '@storybook/test';
|
|
1
|
+
import { boolean, select, date, text } from '@storybook/addon-knobs';
|
|
2
|
+
import { userEvent, within } from '@storybook/test';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Size } from '../common';
|
|
@@ -13,21 +13,21 @@ export default {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const epoch = new Date('2011-01-01');
|
|
16
|
-
|
|
16
|
+
let theFuture = new Date(epoch);
|
|
17
17
|
theFuture.setUTCDate(epoch.getUTCDate() + 10);
|
|
18
|
-
|
|
18
|
+
let thePast = new Date(epoch);
|
|
19
19
|
thePast.setUTCDate(epoch.getUTCDate() - 10);
|
|
20
|
-
const size = select('size', Object.values([Size.SMALL, Size.MEDIUM, Size.LARGE]), Size.MEDIUM);
|
|
21
20
|
|
|
22
21
|
export const Basic = () => {
|
|
23
|
-
const [value, setValue] = useState
|
|
22
|
+
const [value, setValue] = useState(epoch);
|
|
24
23
|
const disabled = boolean('disabled', false);
|
|
25
24
|
const label = text('label', 'label');
|
|
26
|
-
const monthFormat = select('monthFormat', ['long', 'short']
|
|
25
|
+
const monthFormat = select('monthFormat', ['long', 'short']);
|
|
27
26
|
const placeholder = text('placeholder', 'placeholder');
|
|
27
|
+
const size = select('size', Object.values(Size), Size.MEDIUM);
|
|
28
28
|
const id = text('id', 'date-lookup');
|
|
29
29
|
|
|
30
|
-
const clearable = boolean('clearable',
|
|
30
|
+
const clearable = boolean('clearable', false);
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<DateLookup
|
|
@@ -35,7 +35,6 @@ export const Basic = () => {
|
|
|
35
35
|
id={id}
|
|
36
36
|
label={label}
|
|
37
37
|
min={thePast}
|
|
38
|
-
max={theFuture}
|
|
39
38
|
monthFormat={monthFormat}
|
|
40
39
|
placeholder={placeholder}
|
|
41
40
|
size={size}
|
|
@@ -49,9 +48,10 @@ export const Basic = () => {
|
|
|
49
48
|
);
|
|
50
49
|
};
|
|
51
50
|
|
|
52
|
-
Basic.play = async ({ canvasElement }
|
|
51
|
+
Basic.play = async ({ canvasElement }) => {
|
|
53
52
|
// testing focus state on keyboard nav
|
|
54
|
-
|
|
53
|
+
const canvas = within(canvasElement);
|
|
54
|
+
await userEvent.tab(canvas.getByRole('button'));
|
|
55
55
|
await userEvent.keyboard(' ');
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -61,11 +61,12 @@ export const Basic400Zoom = storyConfig(
|
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
export const RightAligned = () => {
|
|
64
|
-
const [value, setValue] = useState
|
|
64
|
+
const [value, setValue] = useState(epoch);
|
|
65
65
|
const disabled = boolean('disabled', false);
|
|
66
66
|
const label = text('label', 'label');
|
|
67
|
-
const monthFormat = select('monthFormat', ['long', 'short']
|
|
67
|
+
const monthFormat = select('monthFormat', ['long', 'short']);
|
|
68
68
|
const placeholder = text('placeholder', 'placeholder');
|
|
69
|
+
const size = select('size', Object.values(Size), Size.MEDIUM);
|
|
69
70
|
|
|
70
71
|
const minvalue = date('minvalue', thePast);
|
|
71
72
|
const maxvalue = date('maxvalue', theFuture);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import { useIntl } from 'react-intl';
|
|
3
4
|
|
|
4
5
|
import Chevron from '../../chevron';
|
|
@@ -9,21 +10,7 @@ import messages from '../DateLookup.messages';
|
|
|
9
10
|
|
|
10
11
|
const buttonClasses = 'btn-link p-a-0 text-no-decoration np-text-body-large-bold rounded-sm';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
label?: string;
|
|
14
|
-
onLabelClick?: () => void;
|
|
15
|
-
onPreviousClick: () => void;
|
|
16
|
-
onNextClick: () => void;
|
|
17
|
-
dateMode: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const DateHeader: React.FC<DateHeaderProps> = ({
|
|
21
|
-
label,
|
|
22
|
-
onLabelClick,
|
|
23
|
-
onPreviousClick,
|
|
24
|
-
onNextClick,
|
|
25
|
-
dateMode,
|
|
26
|
-
}) => {
|
|
13
|
+
const DateHeader = ({ label, onLabelClick, onPreviousClick, onNextClick, dateMode }) => {
|
|
27
14
|
const intl = useIntl();
|
|
28
15
|
const { isMobile } = useLayout();
|
|
29
16
|
return (
|
|
@@ -72,4 +59,17 @@ const DateHeader: React.FC<DateHeaderProps> = ({
|
|
|
72
59
|
);
|
|
73
60
|
};
|
|
74
61
|
|
|
62
|
+
DateHeader.propTypes = {
|
|
63
|
+
label: PropTypes.string,
|
|
64
|
+
onLabelClick: PropTypes.func,
|
|
65
|
+
onPreviousClick: PropTypes.func.isRequired,
|
|
66
|
+
onNextClick: PropTypes.func.isRequired,
|
|
67
|
+
dateMode: PropTypes.string,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
DateHeader.defaultProps = {
|
|
71
|
+
label: null,
|
|
72
|
+
onLabelClick: () => {},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
75
|
export default DateHeader;
|