@transferwise/components 0.0.0-experimental-8f9699a → 0.0.0-experimental-dabc13b
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/i18n/cs.json +1 -0
- package/build/i18n/de.json +1 -0
- package/build/i18n/es.json +1 -0
- package/build/i18n/fr.json +1 -0
- package/build/i18n/hu.json +1 -0
- package/build/i18n/id.json +1 -0
- package/build/i18n/it.json +1 -0
- package/build/i18n/ja.json +1 -0
- package/build/i18n/pl.json +1 -0
- package/build/i18n/pt.json +4 -3
- package/build/i18n/ro.json +4 -3
- package/build/i18n/ru.json +2 -1
- package/build/i18n/th.json +1 -0
- package/build/i18n/tr.json +1 -0
- package/build/i18n/uk.json +1 -0
- package/build/i18n/zh-CN.json +1 -0
- package/build/i18n/zh-HK.json +1 -0
- package/build/index.esm.js +99 -159
- package/build/index.esm.js.map +1 -1
- package/build/index.js +99 -159
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/chips/Chip.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/TableLink.d.ts +4 -14
- package/build/types/dateLookup/tableLink/TableLink.d.ts.map +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts +1 -1
- package/build/types/dateLookup/tableLink/index.d.ts.map +1 -1
- package/build/types/dateLookup/yearCalendar/table/YearCalendarTable.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/chips/Chip.css +1 -1
- package/src/chips/Chip.less +9 -21
- package/src/dateLookup/DateLookup.css +1 -1
- package/src/dateLookup/DateLookup.js +4 -19
- package/src/dateLookup/DateLookup.keyboardEvents.spec.js +0 -12
- package/src/dateLookup/DateLookup.less +49 -39
- package/src/dateLookup/DateLookup.story.js +7 -8
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.js +3 -28
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.spec.js +0 -25
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.js +20 -33
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.spec.js +0 -33
- package/src/dateLookup/tableLink/TableLink.js +70 -0
- package/src/dateLookup/tableLink/TableLink.spec.js +15 -6
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.js +11 -33
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.spec.js +0 -26
- package/src/i18n/cs.json +1 -0
- package/src/i18n/de.json +1 -0
- package/src/i18n/es.json +1 -0
- package/src/i18n/fr.json +1 -0
- package/src/i18n/hu.json +1 -0
- package/src/i18n/id.json +1 -0
- package/src/i18n/it.json +1 -0
- package/src/i18n/ja.json +1 -0
- package/src/i18n/pl.json +1 -0
- package/src/i18n/pt.json +4 -3
- package/src/i18n/ro.json +4 -3
- package/src/i18n/ru.json +2 -1
- package/src/i18n/th.json +1 -0
- package/src/i18n/tr.json +1 -0
- package/src/i18n/uk.json +1 -0
- package/src/i18n/zh-CN.json +1 -0
- package/src/i18n/zh-HK.json +1 -0
- package/src/main.css +1 -1
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts +0 -9
- package/build/types/dateLookup/getFocusableTime/getFocusableTime.d.ts.map +0 -1
- package/src/dateLookup/getFocusableTime/getFocusable.spec.ts +0 -40
- package/src/dateLookup/getFocusableTime/getFocusableTime.tsx +0 -14
- package/src/dateLookup/tableLink/TableLink.tsx +0 -79
- /package/src/dateLookup/tableLink/{index.ts → index.js} +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface FocusableTimeProps {
|
|
2
|
-
isActive: (time: number) => boolean;
|
|
3
|
-
isNow: (time: number) => boolean;
|
|
4
|
-
isDisabled: (time: number) => boolean;
|
|
5
|
-
timeSpan: number[];
|
|
6
|
-
}
|
|
7
|
-
export declare function getFocusableTime(props: FocusableTimeProps): number | undefined;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=getFocusableTime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFocusableTime.d.ts","sourceRoot":"","sources":["../../../../src/dateLookup/getFocusableTime/getFocusableTime.tsx"],"names":[],"mappings":"AAAA,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACjC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAM9E"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { getFocusableTime } from './getFocusableTime';
|
|
2
|
-
|
|
3
|
-
describe('getFocusableTime', () => {
|
|
4
|
-
const isActive = (value: number) => value === 2;
|
|
5
|
-
const isNow = (value: number) => value === 3;
|
|
6
|
-
const isDisabled = (value: number) => value === 4;
|
|
7
|
-
const values = [1, 2, 3, 4, 5];
|
|
8
|
-
|
|
9
|
-
it('returns first selected value', () => {
|
|
10
|
-
expect(getFocusableTime({ isActive, isNow, isDisabled, timeSpan: values })).toBe(2);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('returns first now value if nothing is selected', () => {
|
|
14
|
-
expect(getFocusableTime({ isActive: () => false, isNow, isDisabled, timeSpan: values })).toBe(
|
|
15
|
-
3,
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('returns first non disabled value when nothing is selected or now', () => {
|
|
20
|
-
expect(
|
|
21
|
-
getFocusableTime({
|
|
22
|
-
isActive: () => false,
|
|
23
|
-
isNow: () => false,
|
|
24
|
-
isDisabled,
|
|
25
|
-
timeSpan: values,
|
|
26
|
-
}),
|
|
27
|
-
).toBe(1);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns null if no selected, now, or non-disabled', () => {
|
|
31
|
-
expect(
|
|
32
|
-
getFocusableTime({
|
|
33
|
-
isActive: () => false,
|
|
34
|
-
isNow: () => false,
|
|
35
|
-
isDisabled: () => true,
|
|
36
|
-
timeSpan: values,
|
|
37
|
-
}),
|
|
38
|
-
).toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
interface FocusableTimeProps {
|
|
2
|
-
isActive: (time: number) => boolean;
|
|
3
|
-
isNow: (time: number) => boolean;
|
|
4
|
-
isDisabled: (time: number) => boolean;
|
|
5
|
-
timeSpan: number[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function getFocusableTime(props: FocusableTimeProps): number | undefined {
|
|
9
|
-
return (
|
|
10
|
-
props.timeSpan.find((time: number) => props.isActive(time)) ||
|
|
11
|
-
props.timeSpan.find((time: number) => props.isNow(time) && !props.isDisabled(time)) ||
|
|
12
|
-
props.timeSpan.find((time: number) => !props.isDisabled(time))
|
|
13
|
-
);
|
|
14
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { useEffect, useRef } from 'react';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
|
|
5
|
-
import messages from '../DateLookup.messages';
|
|
6
|
-
|
|
7
|
-
interface TableLinkProps {
|
|
8
|
-
item: number;
|
|
9
|
-
type: 'day' | 'month' | 'year';
|
|
10
|
-
title?: string;
|
|
11
|
-
longTitle?: string;
|
|
12
|
-
active: boolean;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
today: boolean;
|
|
15
|
-
autofocus?: boolean;
|
|
16
|
-
onClick: (item: number) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const TableLink = ({
|
|
20
|
-
item,
|
|
21
|
-
type,
|
|
22
|
-
title,
|
|
23
|
-
longTitle,
|
|
24
|
-
active,
|
|
25
|
-
disabled,
|
|
26
|
-
today,
|
|
27
|
-
autofocus,
|
|
28
|
-
onClick,
|
|
29
|
-
}: TableLinkProps) => {
|
|
30
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
31
|
-
const intl = useIntl();
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (autofocus) {
|
|
35
|
-
setTimeout(() => {
|
|
36
|
-
buttonRef.current?.focus();
|
|
37
|
-
}, 0);
|
|
38
|
-
}
|
|
39
|
-
}, [autofocus]);
|
|
40
|
-
|
|
41
|
-
const onCalendarClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
if (!disabled) {
|
|
44
|
-
onClick(item);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const calculateAriaLabel = () => {
|
|
49
|
-
if (active) {
|
|
50
|
-
return `${longTitle || title || ''}, ${intl.formatMessage(
|
|
51
|
-
messages.selected,
|
|
52
|
-
)} ${intl.formatMessage(messages[type])}`;
|
|
53
|
-
}
|
|
54
|
-
return longTitle || title;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<>
|
|
59
|
-
<button
|
|
60
|
-
ref={buttonRef}
|
|
61
|
-
type="button"
|
|
62
|
-
className={classNames(
|
|
63
|
-
`tw-date-lookup-${type}-option np-text-body-default-bold`,
|
|
64
|
-
{ active: !!active },
|
|
65
|
-
{ today: !!today },
|
|
66
|
-
)}
|
|
67
|
-
disabled={disabled}
|
|
68
|
-
tabIndex={autofocus ? 0 : -1}
|
|
69
|
-
aria-label={calculateAriaLabel()}
|
|
70
|
-
aria-pressed={active}
|
|
71
|
-
onClick={onCalendarClick}
|
|
72
|
-
>
|
|
73
|
-
{title || item}
|
|
74
|
-
</button>
|
|
75
|
-
</>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default TableLink;
|
|
File without changes
|