@transferwise/components 0.0.0-experimental-bb7ed4a → 0.0.0-experimental-f34234e
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/hu.json +1 -1
- package/build/index.js +213 -13
- package/build/index.js.map +1 -1
- package/build/index.mjs +214 -15
- package/build/index.mjs.map +1 -1
- package/build/main.css +126 -0
- package/build/styles/carousel/Carousel.css +126 -0
- package/build/styles/main.css +126 -0
- package/build/types/carousel/Carousel.d.ts +19 -0
- package/build/types/carousel/Carousel.d.ts.map +1 -0
- package/build/types/carousel/Carousel.test.d.ts +2 -0
- package/build/types/carousel/Carousel.test.d.ts.map +1 -0
- package/build/types/carousel/index.d.ts +3 -0
- package/build/types/carousel/index.d.ts.map +1 -0
- package/build/types/common/dateUtils/index.d.ts +0 -1
- package/build/types/common/dateUtils/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts +2 -2
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts +1 -1
- package/build/types/dateLookup/dayCalendar/table/DayCalendarTable.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/carousel/Carousel.css +126 -0
- package/src/carousel/Carousel.less +125 -0
- package/src/carousel/Carousel.story.tsx +62 -0
- package/src/carousel/Carousel.test.tsx +221 -0
- package/src/carousel/Carousel.tsx +269 -0
- package/src/carousel/index.ts +3 -0
- package/src/common/dateUtils/index.ts +0 -1
- package/src/dateLookup/DateLookup.tests.story.tsx +10 -44
- package/src/dateLookup/DateLookup.tsx +12 -9
- package/src/dateLookup/dayCalendar/table/DayCalendarTable.tsx +2 -5
- package/src/i18n/hu.json +1 -1
- package/src/index.ts +2 -0
- package/src/main.css +126 -0
- package/src/main.less +1 -0
- package/build/types/common/dateUtils/getDateView/getDateView.d.ts +0 -2
- package/build/types/common/dateUtils/getDateView/getDateView.d.ts.map +0 -1
- package/src/common/dateUtils/getDateView/getDateView.ts +0 -5
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactRenderer, Story } from '@storybook/react';
|
|
2
2
|
import { expect, userEvent, within } from '@storybook/test';
|
|
3
|
-
import
|
|
3
|
+
import { PlayFunctionContext } from '@storybook/types';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
|
|
6
|
-
import DateLookup
|
|
6
|
+
import DateLookup from './DateLookup';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
component: DateLookup,
|
|
10
10
|
title: 'Forms/DateLookup/Tests',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
value
|
|
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);
|
|
13
|
+
const Template: Story<DateLookup> = () => {
|
|
14
|
+
const [value, setValue] = useState<Date | null>(new Date(1987, 0, 10, 12, 0, 0));
|
|
22
15
|
|
|
23
16
|
return (
|
|
24
17
|
<DateLookup
|
|
25
|
-
{...args}
|
|
26
18
|
value={value}
|
|
27
|
-
placeholder="placeholder"
|
|
28
19
|
clearable
|
|
20
|
+
placeholder="placeholder"
|
|
29
21
|
onChange={(v) => {
|
|
30
22
|
setValue(v);
|
|
31
23
|
}}
|
|
@@ -34,11 +26,11 @@ const Template: Story<DateLookupProps> = (args: DateLookupProps) => {
|
|
|
34
26
|
};
|
|
35
27
|
|
|
36
28
|
export const ClearSpace = Template.bind({});
|
|
37
|
-
|
|
29
|
+
|
|
38
30
|
ClearSpace.play = async ({
|
|
39
31
|
canvasElement,
|
|
40
32
|
step,
|
|
41
|
-
}: PlayFunctionContext<ReactRenderer,
|
|
33
|
+
}: PlayFunctionContext<ReactRenderer, DateLookup>) => {
|
|
42
34
|
const canvas = within(canvasElement);
|
|
43
35
|
|
|
44
36
|
await step('space can activate clear button', async () => {
|
|
@@ -56,11 +48,11 @@ ClearSpace.play = async ({
|
|
|
56
48
|
};
|
|
57
49
|
|
|
58
50
|
export const ClearEnter = Template.bind({});
|
|
59
|
-
|
|
51
|
+
|
|
60
52
|
ClearEnter.play = async ({
|
|
61
53
|
canvasElement,
|
|
62
54
|
step,
|
|
63
|
-
}: PlayFunctionContext<ReactRenderer,
|
|
55
|
+
}: PlayFunctionContext<ReactRenderer, DateLookup>) => {
|
|
64
56
|
const canvas = within(canvasElement);
|
|
65
57
|
|
|
66
58
|
await step('enter can activate clear button', async () => {
|
|
@@ -76,29 +68,3 @@ ClearEnter.play = async ({
|
|
|
76
68
|
await expect(placeholder).toBeInTheDocument();
|
|
77
69
|
});
|
|
78
70
|
};
|
|
79
|
-
|
|
80
|
-
export const FocusOnSelectedDay = Template.bind({});
|
|
81
|
-
FocusOnSelectedDay.args = { ...props };
|
|
82
|
-
FocusOnSelectedDay.play = async () => {
|
|
83
|
-
await userEvent.tab();
|
|
84
|
-
await userEvent.keyboard(' ');
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export const FocusOnToday = Template.bind({});
|
|
88
|
-
FocusOnToday.args = { ...props, value: null };
|
|
89
|
-
FocusOnToday.play = async () => {
|
|
90
|
-
await userEvent.tab();
|
|
91
|
-
await userEvent.keyboard(' ');
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const FocusOnFirstNonDisabledDate = Template.bind({});
|
|
95
|
-
FocusOnFirstNonDisabledDate.args = {
|
|
96
|
-
...props,
|
|
97
|
-
value: null,
|
|
98
|
-
min: new Date(1987, 0, 10, 12, 0, 0),
|
|
99
|
-
max: new Date(1987, 0, 12, 12, 0, 0),
|
|
100
|
-
};
|
|
101
|
-
FocusOnFirstNonDisabledDate.play = async () => {
|
|
102
|
-
await userEvent.tab();
|
|
103
|
-
await userEvent.keyboard(' ');
|
|
104
|
-
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import { createRef, PureComponent,
|
|
2
|
+
import { createRef, PureComponent, KeyboardEvent } from 'react';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
Size,
|
|
6
6
|
MonthFormat,
|
|
7
7
|
Position,
|
|
8
8
|
Breakpoint,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
SizeSmall,
|
|
10
|
+
SizeMedium,
|
|
11
|
+
SizeLarge,
|
|
12
12
|
} from '../common';
|
|
13
|
-
import { isWithinRange, moveToWithinRange
|
|
13
|
+
import { isWithinRange, moveToWithinRange } from '../common/dateUtils';
|
|
14
14
|
import ResponsivePanel from '../common/responsivePanel';
|
|
15
15
|
|
|
16
16
|
import DateTrigger from './dateTrigger';
|
|
@@ -74,8 +74,8 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
74
74
|
originalDate: null,
|
|
75
75
|
min: getStartOfDay(props.min),
|
|
76
76
|
max: getStartOfDay(props.max),
|
|
77
|
-
viewMonth:
|
|
78
|
-
viewYear:
|
|
77
|
+
viewMonth: (props.value || new Date()).getMonth(),
|
|
78
|
+
viewYear: (props.value || new Date()).getFullYear(),
|
|
79
79
|
open: false,
|
|
80
80
|
mode: 'day',
|
|
81
81
|
isMobile: false,
|
|
@@ -97,7 +97,8 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
97
97
|
props.onChange(moveToWithinRange(selectedDate, min, max));
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
const viewDateThatIsWithinRange: Date =
|
|
100
|
+
const viewDateThatIsWithinRange: Date =
|
|
101
|
+
selectedDate || ((min || max) && moveToWithinRange(new Date(), min, max)) || new Date();
|
|
101
102
|
const viewMonth = viewDateThatIsWithinRange.getMonth();
|
|
102
103
|
const viewYear = viewDateThatIsWithinRange.getFullYear();
|
|
103
104
|
return { selectedDate, min, max, viewMonth, viewYear };
|
|
@@ -205,7 +206,9 @@ class DateLookup extends PureComponent<DateLookupProps, DateLookupState> {
|
|
|
205
206
|
} else {
|
|
206
207
|
date = getStartOfDay(new Date());
|
|
207
208
|
}
|
|
208
|
-
|
|
209
|
+
if (date) {
|
|
210
|
+
date = moveToWithinRange(date, min, max);
|
|
211
|
+
}
|
|
209
212
|
if (date?.getTime() !== selectedDate?.getTime()) {
|
|
210
213
|
this.props.onChange(date);
|
|
211
214
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatDate } from '@transferwise/formatting';
|
|
2
2
|
import { PureComponent } from 'react';
|
|
3
|
-
import { injectIntl,
|
|
3
|
+
import { injectIntl, WrappedComponentProps } from 'react-intl';
|
|
4
4
|
|
|
5
5
|
import { getDayNames, isWithinRange } from '../../../common/dateUtils';
|
|
6
6
|
import { getFocusableTime } from '../../getFocusableTime/getFocusableTime';
|
|
@@ -64,9 +64,6 @@ class DayCalendarTable extends PureComponent<DayCalendarTableProps> {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
isDisabled = (day: number) => {
|
|
67
|
-
if (day === -1) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
67
|
const { min, max, viewMonth, viewYear } = this.props;
|
|
71
68
|
const date = new Date(viewYear, viewMonth, day);
|
|
72
69
|
|
|
@@ -75,7 +72,7 @@ class DayCalendarTable extends PureComponent<DayCalendarTableProps> {
|
|
|
75
72
|
|
|
76
73
|
isActive = (day: number) => {
|
|
77
74
|
const { selectedDate, viewMonth, viewYear } = this.props;
|
|
78
|
-
return !!(selectedDate &&
|
|
75
|
+
return !!(selectedDate && +new Date(viewYear, viewMonth, day) === +selectedDate);
|
|
79
76
|
};
|
|
80
77
|
|
|
81
78
|
isToday = (day: number) => {
|
package/src/i18n/hu.json
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"neptune.Upload.psProcessingText": "Feltöltés...",
|
|
36
36
|
"neptune.Upload.usButtonText": "Vagy válaszd ki a fájlt",
|
|
37
37
|
"neptune.Upload.usDropMessage": "Húzd ide a fájlokat a feltöltéshez",
|
|
38
|
-
"neptune.Upload.usPlaceholder": "Húzz ide egy legfeljebb {maxSize}
|
|
38
|
+
"neptune.Upload.usPlaceholder": "Húzz ide egy legfeljebb {maxSize}MB méretű fájlt",
|
|
39
39
|
"neptune.UploadButton.allFileTypes": "Összes fájltípus",
|
|
40
40
|
"neptune.UploadButton.dropFiles": "Húzd a fájlokat ide a feltöltéshez",
|
|
41
41
|
"neptune.UploadButton.instructions": "{fileTypes}, legfeljebb {size}MB",
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { AvatarProps } from './avatar';
|
|
|
6
6
|
export type { ActionOptionProps } from './actionOption';
|
|
7
7
|
export type { AlertProps, AlertAction, AlertArrowPosition, AlertType } from './alert';
|
|
8
8
|
export type { BadgeProps } from './badge';
|
|
9
|
+
export type { CarouselProps } from './carousel';
|
|
9
10
|
export type { CircularButtonProps } from './circularButton';
|
|
10
11
|
export type { DecisionProps } from './decision/Decision';
|
|
11
12
|
export type { EmphasisProps } from './emphasis';
|
|
@@ -82,6 +83,7 @@ export { default as AvatarWrapper } from './avatarWrapper';
|
|
|
82
83
|
export { default as Badge } from './badge';
|
|
83
84
|
export { default as BottomSheet } from './common/bottomSheet';
|
|
84
85
|
export { default as Button } from './button';
|
|
86
|
+
export { default as Carousel } from './carousel';
|
|
85
87
|
export { default as Card } from './card';
|
|
86
88
|
export { default as BaseCard } from './common/card';
|
|
87
89
|
export { default as Checkbox } from './checkbox';
|
package/src/main.css
CHANGED
|
@@ -643,6 +643,132 @@ div.critical-comms .critical-comms-body {
|
|
|
643
643
|
border-radius: 16px 16px 0 0;
|
|
644
644
|
border-radius: var(--radius-medium) var(--radius-medium) 0 0;
|
|
645
645
|
}
|
|
646
|
+
.carousel {
|
|
647
|
+
display: flex;
|
|
648
|
+
align-items: center;
|
|
649
|
+
overflow-x: scroll;
|
|
650
|
+
overflow-y: hidden;
|
|
651
|
+
scroll-snap-type: x mandatory;
|
|
652
|
+
scroll-behavior: smooth;
|
|
653
|
+
gap: 16px;
|
|
654
|
+
gap: var(--size-16);
|
|
655
|
+
}
|
|
656
|
+
.carousel__header {
|
|
657
|
+
display: flex;
|
|
658
|
+
align-items: center;
|
|
659
|
+
overflow: hidden;
|
|
660
|
+
min-height: 32px;
|
|
661
|
+
min-height: var(--size-32);
|
|
662
|
+
padding-bottom: 16px;
|
|
663
|
+
padding-bottom: var(--size-16);
|
|
664
|
+
}
|
|
665
|
+
.carousel__card,
|
|
666
|
+
.carousel__card:hover,
|
|
667
|
+
.carousel__card:focus {
|
|
668
|
+
-webkit-text-decoration: none;
|
|
669
|
+
text-decoration: none;
|
|
670
|
+
}
|
|
671
|
+
.carousel__card {
|
|
672
|
+
position: relative;
|
|
673
|
+
text-align: left;
|
|
674
|
+
border: none;
|
|
675
|
+
overflow: hidden;
|
|
676
|
+
background: rgba(134,167,189,0.10196);
|
|
677
|
+
background: var(--color-background-neutral);
|
|
678
|
+
border-radius: 16px;
|
|
679
|
+
border-radius: var(--size-16);
|
|
680
|
+
scroll-snap-align: center;
|
|
681
|
+
-webkit-scroll-snap-align: center;
|
|
682
|
+
transition: all 0.4s;
|
|
683
|
+
}
|
|
684
|
+
@media (min-width: 1200px) {
|
|
685
|
+
.carousel__card {
|
|
686
|
+
min-width: 280px;
|
|
687
|
+
width: 280px;
|
|
688
|
+
height: 280px;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
@media (max-width: 1199px) {
|
|
692
|
+
.carousel__card {
|
|
693
|
+
min-width: 242px;
|
|
694
|
+
width: 242px;
|
|
695
|
+
height: 242px;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
@media (max-width: 767px) {
|
|
699
|
+
.carousel__card {
|
|
700
|
+
min-width: 336px;
|
|
701
|
+
width: 336px;
|
|
702
|
+
height: 336px;
|
|
703
|
+
scroll-snap-stop: always;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
.carousel__card:focus {
|
|
707
|
+
outline: 0;
|
|
708
|
+
}
|
|
709
|
+
.carousel__card:focus:after {
|
|
710
|
+
content: '';
|
|
711
|
+
position: absolute;
|
|
712
|
+
z-index: 4;
|
|
713
|
+
top: 0;
|
|
714
|
+
left: 0;
|
|
715
|
+
width: 100%;
|
|
716
|
+
height: 100%;
|
|
717
|
+
border-radius: 16px;
|
|
718
|
+
border-radius: var(--size-16);
|
|
719
|
+
box-shadow: inset 0 0 0 2px var(--ring-outline-color);
|
|
720
|
+
}
|
|
721
|
+
.carousel__card:hover {
|
|
722
|
+
background-color: var(--color-background-neutral-hover);
|
|
723
|
+
}
|
|
724
|
+
.carousel__card:focus {
|
|
725
|
+
background-color: var(--color-background-neutral-hover);
|
|
726
|
+
}
|
|
727
|
+
.carousel__card-content {
|
|
728
|
+
height: 100%;
|
|
729
|
+
font-weight: normal;
|
|
730
|
+
}
|
|
731
|
+
.carousel__scroll-button {
|
|
732
|
+
width: 32px;
|
|
733
|
+
width: var(--size-32);
|
|
734
|
+
height: 32px;
|
|
735
|
+
height: var(--size-32);
|
|
736
|
+
align-items: center;
|
|
737
|
+
justify-content: center;
|
|
738
|
+
}
|
|
739
|
+
.carousel__indicators {
|
|
740
|
+
display: flex;
|
|
741
|
+
justify-content: center;
|
|
742
|
+
padding-top: 8px;
|
|
743
|
+
padding-top: var(--size-8);
|
|
744
|
+
gap: 8px;
|
|
745
|
+
gap: var(--size-8);
|
|
746
|
+
}
|
|
747
|
+
.carousel__indicator {
|
|
748
|
+
width: 12px;
|
|
749
|
+
width: var(--size-12);
|
|
750
|
+
height: 12px;
|
|
751
|
+
height: var(--size-12);
|
|
752
|
+
border-radius: 8px;
|
|
753
|
+
border-radius: var(--size-8);
|
|
754
|
+
background: #c9cbce;
|
|
755
|
+
background: var(--color-interactive-secondary);
|
|
756
|
+
border: none;
|
|
757
|
+
-webkit-appearance: none;
|
|
758
|
+
-moz-appearance: none;
|
|
759
|
+
appearance: none;
|
|
760
|
+
transition: all 0.1s;
|
|
761
|
+
}
|
|
762
|
+
.carousel__indicator:hover {
|
|
763
|
+
width: 16px;
|
|
764
|
+
width: var(--size-16);
|
|
765
|
+
}
|
|
766
|
+
.carousel__indicator--selected,
|
|
767
|
+
.carousel__indicator--selected:hover {
|
|
768
|
+
background: var(--color-interactive-primary);
|
|
769
|
+
width: 24px;
|
|
770
|
+
width: var(--size-24);
|
|
771
|
+
}
|
|
646
772
|
.np-checkbox-button input[type="checkbox"] {
|
|
647
773
|
position: absolute;
|
|
648
774
|
width: 24px;
|
package/src/main.less
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getDateView.d.ts","sourceRoot":"","sources":["../../../../../src/common/dateUtils/getDateView/getDateView.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iBAAkB,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,IAAI,SAE3F,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { moveToWithinRange } from '../moveToWithinRange/moveToWithinRange';
|
|
2
|
-
|
|
3
|
-
export const returnDateView = (selectedDate: Date | null, min: Date | null, max: Date | null) => {
|
|
4
|
-
return selectedDate || ((min || max) && moveToWithinRange(new Date(), min, max)) || new Date();
|
|
5
|
-
};
|