@hero-design/rn 8.35.0-alpha.4 → 8.36.0-alpha.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.
- package/.eslintrc.js +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-build:types.log +0 -8
- package/.turbo/turbo-lint.log +20 -11
- package/.turbo/turbo-test.log +0 -724
- package/es/index.js +578 -639
- package/jest.config.js +1 -1
- package/lib/index.js +588 -649
- package/package.json +9 -9
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +3 -3
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +1 -1
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +2 -2
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +4 -4
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +6 -6
- package/src/components/Calendar/__tests__/index.spec.tsx +29 -0
- package/src/components/Calendar/index.tsx +10 -1
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +75 -74
- package/src/components/Carousel/index.tsx +1 -1
- package/src/components/DatePicker/DatePickerCalendar.tsx +23 -14
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +12 -0
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +801 -1251
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +45 -35
- package/src/components/FAB/ActionGroup/index.tsx +65 -45
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +1 -1
- package/src/components/FAB/index.tsx +0 -4
- package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +4 -4
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
- package/src/components/Portal/PortalHost.tsx +24 -0
- package/src/components/Portal/PortalProvider.tsx +29 -0
- package/src/components/Portal/__tests__/PortalHost.spec.tsx +50 -0
- package/src/components/Portal/__tests__/PortalProvider.spec.tsx +24 -0
- package/src/components/Portal/__tests__/index.spec.tsx +29 -0
- package/src/components/Portal/__tests__/reducer.spec.tsx +110 -0
- package/src/components/Portal/constants.ts +10 -0
- package/src/components/Portal/contexts.ts +14 -0
- package/src/components/Portal/index.tsx +42 -0
- package/src/components/Portal/reducer.ts +106 -0
- package/src/components/Portal/types.tsx +31 -0
- package/src/components/Portal/usePortal.ts +50 -0
- package/src/components/Portal/usePortalState.ts +11 -0
- package/src/components/Progress/StyledProgressBar.tsx +1 -0
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +46 -44
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +6 -6
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +7 -7
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/Swipeable/index.tsx +6 -1
- package/src/components/Switch/SelectorSwitch/StyledSelectorSwitch.tsx +4 -7
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +3 -3
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
- package/src/components/Switch/SelectorSwitch/index.tsx +7 -15
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +21 -21
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +6 -6
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +2 -2
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
- package/src/components/Tag/StyledTag.tsx +6 -35
- package/src/components/Tag/__tests__/Tag.spec.tsx +13 -13
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +40 -79
- package/src/components/Tag/index.tsx +8 -6
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +7 -7
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +20 -20
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +1 -1
- package/src/components/Typography/Body/__tests__/__snapshots__/StyledBody.tsx.snap +1 -1
- package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Typography/Caption/__tests__/__snapshots__/StyledCaption.spec.tsx.snap +1 -1
- package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Typography/Label/__tests__/__snapshots__/StyledLabel.tsx.snap +1 -1
- package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +1 -1
- package/src/components/Typography/Title/__tests__/__snapshots__/StyledTitle.tsx.snap +3 -3
- package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/index.ts +2 -2
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +49 -46
- package/src/theme/components/button.ts +1 -1
- package/src/theme/components/progress.ts +2 -2
- package/src/theme/components/swipeable.ts +5 -1
- package/src/theme/components/switch.ts +4 -4
- package/src/theme/components/tabs.ts +1 -1
- package/src/theme/components/tag.ts +2 -2
- package/src/theme/components/typography.ts +2 -2
- package/src/theme/global/colors/__tests__/__snapshots__/eBens.spec.ts.snap +7 -7
- package/src/theme/global/colors/__tests__/__snapshots__/global.spec.ts.snap +5 -5
- package/src/theme/global/colors/__tests__/__snapshots__/jobs.spec.ts.snap +6 -6
- package/src/theme/global/colors/__tests__/__snapshots__/swag.spec.ts.snap +6 -6
- package/src/theme/global/colors/__tests__/__snapshots__/wallet.spec.ts.snap +7 -7
- package/src/theme/global/colors/__tests__/__snapshots__/work.spec.ts.snap +5 -5
- package/src/theme/global/colors/eBens.ts +2 -2
- package/src/theme/global/colors/global.ts +5 -5
- package/src/theme/global/colors/jobs.ts +1 -1
- package/src/theme/global/colors/swag.ts +1 -1
- package/src/theme/global/colors/wallet.ts +2 -2
- package/types/components/Calendar/index.d.ts +2 -1
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +7 -1
- package/types/components/FAB/index.d.ts +0 -3
- package/types/components/Portal/PortalHost.d.ts +5 -0
- package/types/components/Portal/PortalProvider.d.ts +7 -0
- package/types/components/Portal/constants.d.ts +8 -0
- package/types/components/Portal/contexts.d.ts +9 -0
- package/types/components/Portal/index.d.ts +13 -0
- package/types/components/Portal/reducer.d.ts +5 -0
- package/types/components/Portal/types.d.ts +22 -0
- package/types/components/Portal/usePortal.d.ts +8 -0
- package/types/components/Portal/usePortalState.d.ts +1 -0
- package/types/components/Swipeable/index.d.ts +1 -1
- package/types/components/Tag/StyledTag.d.ts +1 -4
- package/types/components/Tag/index.d.ts +1 -0
- package/types/index.d.ts +2 -2
- package/types/theme/components/swipeable.d.ts +3 -0
- package/types/theme/components/switch.d.ts +1 -1
- package/types/theme/components/tag.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.36.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@
|
|
25
|
-
"@hero-design/colors": "8.34.1",
|
|
24
|
+
"@hero-design/colors": "8.35.0",
|
|
26
25
|
"date-fns": "^2.16.1",
|
|
27
26
|
"events": "^3.2.0",
|
|
28
|
-
"hero-editor": "^1.9.21"
|
|
27
|
+
"hero-editor": "^1.9.21",
|
|
28
|
+
"nanoid": "^4.0.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@hero-design/react-native-month-year-picker": "^8.
|
|
31
|
+
"@hero-design/react-native-month-year-picker": "^8.35.0",
|
|
32
32
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
33
33
|
"@react-native-community/slider": "4.1.12",
|
|
34
34
|
"react": "18.0.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@babel/preset-typescript": "^7.17.12",
|
|
49
49
|
"@babel/runtime": "^7.18.9",
|
|
50
50
|
"@emotion/jest": "^11.9.3",
|
|
51
|
-
"@hero-design/eslint-plugin": "8.
|
|
52
|
-
"@hero-design/react-native-month-year-picker": "^8.
|
|
51
|
+
"@hero-design/eslint-plugin": "8.35.0",
|
|
52
|
+
"@hero-design/react-native-month-year-picker": "^8.35.0",
|
|
53
53
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
54
54
|
"@react-native-community/slider": "4.1.12",
|
|
55
55
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@types/react-native": "^0.67.7",
|
|
66
66
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
67
67
|
"babel-plugin-inline-import": "^3.0.0",
|
|
68
|
-
"eslint-config-hd": "8.
|
|
68
|
+
"eslint-config-hd": "8.35.0",
|
|
69
69
|
"eslint-plugin-import": "^2.27.5",
|
|
70
70
|
"jest": "^27.3.1",
|
|
71
|
-
"prettier-config-hd": "8.
|
|
71
|
+
"prettier-config-hd": "8.35.0",
|
|
72
72
|
"react": "18.0.0",
|
|
73
73
|
"react-native": "0.69.7",
|
|
74
74
|
"react-native-gesture-handler": "~2.5.0",
|
|
@@ -6,7 +6,7 @@ exports[`Badge has danger style when intent is danger 1`] = `
|
|
|
6
6
|
style={
|
|
7
7
|
Object {
|
|
8
8
|
"alignItems": "center",
|
|
9
|
-
"backgroundColor": "#
|
|
9
|
+
"backgroundColor": "#cb300a",
|
|
10
10
|
"borderRadius": 999,
|
|
11
11
|
"height": 20,
|
|
12
12
|
"justifyContent": "center",
|
|
@@ -59,7 +59,7 @@ exports[`Badge has info style when intent is info 1`] = `
|
|
|
59
59
|
style={
|
|
60
60
|
Object {
|
|
61
61
|
"alignItems": "center",
|
|
62
|
-
"backgroundColor": "#
|
|
62
|
+
"backgroundColor": "#355bfb",
|
|
63
63
|
"borderRadius": 999,
|
|
64
64
|
"height": 20,
|
|
65
65
|
"justifyContent": "center",
|
|
@@ -218,7 +218,7 @@ exports[`Badge has warning style when intent is warning 1`] = `
|
|
|
218
218
|
style={
|
|
219
219
|
Object {
|
|
220
220
|
"alignItems": "center",
|
|
221
|
-
"backgroundColor": "#
|
|
221
|
+
"backgroundColor": "#ac5d00",
|
|
222
222
|
"borderRadius": 999,
|
|
223
223
|
"height": 20,
|
|
224
224
|
"justifyContent": "center",
|
|
@@ -85,7 +85,7 @@ exports[`StyledLoadingIndicator has outlined-danger style 1`] = `
|
|
|
85
85
|
style={
|
|
86
86
|
Array [
|
|
87
87
|
Object {
|
|
88
|
-
"backgroundColor": "#
|
|
88
|
+
"backgroundColor": "#cb300a",
|
|
89
89
|
"borderRadius": 8,
|
|
90
90
|
"height": 12,
|
|
91
91
|
"marginBottom": 4,
|
|
@@ -145,7 +145,7 @@ exports[`StyledLoadingIndicator has text-danger style 1`] = `
|
|
|
145
145
|
style={
|
|
146
146
|
Array [
|
|
147
147
|
Object {
|
|
148
|
-
"backgroundColor": "#
|
|
148
|
+
"backgroundColor": "#cb300a",
|
|
149
149
|
"borderRadius": 8,
|
|
150
150
|
"height": 12,
|
|
151
151
|
"marginBottom": 4,
|
|
@@ -489,7 +489,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-danger
|
|
|
489
489
|
style={
|
|
490
490
|
Array [
|
|
491
491
|
Object {
|
|
492
|
-
"backgroundColor": "#
|
|
492
|
+
"backgroundColor": "#cb300a",
|
|
493
493
|
"borderRadius": 8,
|
|
494
494
|
"height": 12,
|
|
495
495
|
"marginBottom": 4,
|
|
@@ -521,7 +521,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-danger
|
|
|
521
521
|
style={
|
|
522
522
|
Array [
|
|
523
523
|
Object {
|
|
524
|
-
"backgroundColor": "#
|
|
524
|
+
"backgroundColor": "#cb300a",
|
|
525
525
|
"borderRadius": 8,
|
|
526
526
|
"height": 12,
|
|
527
527
|
"marginBottom": 4,
|
|
@@ -553,7 +553,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is outlined-danger
|
|
|
553
553
|
style={
|
|
554
554
|
Array [
|
|
555
555
|
Object {
|
|
556
|
-
"backgroundColor": "#
|
|
556
|
+
"backgroundColor": "#cb300a",
|
|
557
557
|
"borderRadius": 8,
|
|
558
558
|
"height": 12,
|
|
559
559
|
"marginBottom": 4,
|
|
@@ -831,7 +831,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-danger 1`]
|
|
|
831
831
|
style={
|
|
832
832
|
Array [
|
|
833
833
|
Object {
|
|
834
|
-
"backgroundColor": "#
|
|
834
|
+
"backgroundColor": "#cb300a",
|
|
835
835
|
"borderRadius": 8,
|
|
836
836
|
"height": 12,
|
|
837
837
|
"marginBottom": 4,
|
|
@@ -863,7 +863,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-danger 1`]
|
|
|
863
863
|
style={
|
|
864
864
|
Array [
|
|
865
865
|
Object {
|
|
866
|
-
"backgroundColor": "#
|
|
866
|
+
"backgroundColor": "#cb300a",
|
|
867
867
|
"borderRadius": 8,
|
|
868
868
|
"height": 12,
|
|
869
869
|
"marginBottom": 4,
|
|
@@ -895,7 +895,7 @@ exports[`LoadingIndicator renders correctly when themeVariant is text-danger 1`]
|
|
|
895
895
|
style={
|
|
896
896
|
Array [
|
|
897
897
|
Object {
|
|
898
|
-
"backgroundColor": "#
|
|
898
|
+
"backgroundColor": "#cb300a",
|
|
899
899
|
"borderRadius": 8,
|
|
900
900
|
"height": 12,
|
|
901
901
|
"marginBottom": 4,
|
|
@@ -15,7 +15,7 @@ exports[`UtilityButton snapshot has intent primary style 1`] = `
|
|
|
15
15
|
style={
|
|
16
16
|
Object {
|
|
17
17
|
"alignItems": "center",
|
|
18
|
-
"backgroundColor": "#
|
|
18
|
+
"backgroundColor": "#ffffff",
|
|
19
19
|
"borderRadius": 8,
|
|
20
20
|
"flexDirection": "row",
|
|
21
21
|
"justifyContent": "center",
|
|
@@ -96,7 +96,7 @@ exports[`UtilityButton snapshot has intent text style 1`] = `
|
|
|
96
96
|
style={
|
|
97
97
|
Object {
|
|
98
98
|
"alignItems": "center",
|
|
99
|
-
"backgroundColor": "#
|
|
99
|
+
"backgroundColor": "#ffffff",
|
|
100
100
|
"borderRadius": 8,
|
|
101
101
|
"flexDirection": "row",
|
|
102
102
|
"justifyContent": "center",
|
|
@@ -1161,7 +1161,7 @@ exports[`Button renders correctly 13`] = `
|
|
|
1161
1161
|
},
|
|
1162
1162
|
Array [
|
|
1163
1163
|
Object {
|
|
1164
|
-
"color": "#
|
|
1164
|
+
"color": "#cb300a",
|
|
1165
1165
|
"flexShrink": 1,
|
|
1166
1166
|
"lineHeight": 22,
|
|
1167
1167
|
"textAlign": "center",
|
|
@@ -1244,7 +1244,7 @@ exports[`Button renders correctly 14`] = `
|
|
|
1244
1244
|
style={
|
|
1245
1245
|
Array [
|
|
1246
1246
|
Object {
|
|
1247
|
-
"backgroundColor": "#
|
|
1247
|
+
"backgroundColor": "#cb300a",
|
|
1248
1248
|
"borderRadius": 8,
|
|
1249
1249
|
"height": 12,
|
|
1250
1250
|
"marginBottom": 4,
|
|
@@ -1276,7 +1276,7 @@ exports[`Button renders correctly 14`] = `
|
|
|
1276
1276
|
style={
|
|
1277
1277
|
Array [
|
|
1278
1278
|
Object {
|
|
1279
|
-
"backgroundColor": "#
|
|
1279
|
+
"backgroundColor": "#cb300a",
|
|
1280
1280
|
"borderRadius": 8,
|
|
1281
1281
|
"height": 12,
|
|
1282
1282
|
"marginBottom": 4,
|
|
@@ -1308,7 +1308,7 @@ exports[`Button renders correctly 14`] = `
|
|
|
1308
1308
|
style={
|
|
1309
1309
|
Array [
|
|
1310
1310
|
Object {
|
|
1311
|
-
"backgroundColor": "#
|
|
1311
|
+
"backgroundColor": "#cb300a",
|
|
1312
1312
|
"borderRadius": 8,
|
|
1313
1313
|
"height": 12,
|
|
1314
1314
|
"marginBottom": 4,
|
|
@@ -16,7 +16,7 @@ exports[`StyledButtonContainer has filled-danger style 1`] = `
|
|
|
16
16
|
Object {
|
|
17
17
|
"alignItems": "center",
|
|
18
18
|
"alignSelf": "stretch",
|
|
19
|
-
"backgroundColor": "#
|
|
19
|
+
"backgroundColor": "#cb300a",
|
|
20
20
|
"borderRadius": 32,
|
|
21
21
|
"flexDirection": "row",
|
|
22
22
|
"justifyContent": "center",
|
|
@@ -113,7 +113,7 @@ exports[`StyledButtonContainer has outlined-danger style 1`] = `
|
|
|
113
113
|
"alignItems": "center",
|
|
114
114
|
"alignSelf": "stretch",
|
|
115
115
|
"backgroundColor": "transparent",
|
|
116
|
-
"borderColor": "#
|
|
116
|
+
"borderColor": "#cb300a",
|
|
117
117
|
"borderRadius": 32,
|
|
118
118
|
"borderWidth": 2,
|
|
119
119
|
"flexDirection": "row",
|
|
@@ -411,7 +411,7 @@ exports[`StyledButtonIcon has outlined-danger style 1`] = `
|
|
|
411
411
|
},
|
|
412
412
|
Array [
|
|
413
413
|
Object {
|
|
414
|
-
"color": "#
|
|
414
|
+
"color": "#cb300a",
|
|
415
415
|
"fontSize": 20,
|
|
416
416
|
},
|
|
417
417
|
undefined,
|
|
@@ -480,7 +480,7 @@ exports[`StyledButtonIcon has text-danger style 1`] = `
|
|
|
480
480
|
},
|
|
481
481
|
Array [
|
|
482
482
|
Object {
|
|
483
|
-
"color": "#
|
|
483
|
+
"color": "#cb300a",
|
|
484
484
|
"fontSize": 20,
|
|
485
485
|
},
|
|
486
486
|
undefined,
|
|
@@ -696,7 +696,7 @@ exports[`StyledButtonText has outlined-danger style 1`] = `
|
|
|
696
696
|
},
|
|
697
697
|
Array [
|
|
698
698
|
Object {
|
|
699
|
-
"color": "#
|
|
699
|
+
"color": "#cb300a",
|
|
700
700
|
"flexShrink": 1,
|
|
701
701
|
"textAlign": "center",
|
|
702
702
|
},
|
|
@@ -789,7 +789,7 @@ exports[`StyledButtonText has text-danger style 1`] = `
|
|
|
789
789
|
},
|
|
790
790
|
Array [
|
|
791
791
|
Object {
|
|
792
|
-
"color": "#
|
|
792
|
+
"color": "#cb300a",
|
|
793
793
|
"flexShrink": 1,
|
|
794
794
|
"textAlign": "center",
|
|
795
795
|
},
|
|
@@ -139,4 +139,33 @@ describe('Calendar', () => {
|
|
|
139
139
|
expect(queryByText('Android picker')).toBeDefined();
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
|
+
|
|
143
|
+
it.each`
|
|
144
|
+
platform
|
|
145
|
+
${'ios'}
|
|
146
|
+
${'android'}
|
|
147
|
+
`(
|
|
148
|
+
'onToggleMonthPicker is called when toggling month year picker on $platform',
|
|
149
|
+
({ platform }) => {
|
|
150
|
+
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
|
|
151
|
+
OS: platform,
|
|
152
|
+
select: () => null,
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
const onToggleMonthPicker = jest.fn();
|
|
156
|
+
const { getByTestId } = renderWithTheme(
|
|
157
|
+
<Calendar
|
|
158
|
+
value={new Date(2022, 10, 5)}
|
|
159
|
+
visibleDate={new Date(2022, 10, 5)}
|
|
160
|
+
minDate={new Date(2022, 10, 3)}
|
|
161
|
+
maxDate={new Date(2022, 10, 27)}
|
|
162
|
+
onMonthChange={jest.fn()}
|
|
163
|
+
onToggleMonthPicker={onToggleMonthPicker}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
fireEvent.press(getByTestId('calendar-month-picker'));
|
|
168
|
+
expect(onToggleMonthPicker).toHaveBeenCalled();
|
|
169
|
+
}
|
|
170
|
+
);
|
|
142
171
|
});
|
|
@@ -80,6 +80,10 @@ export interface CalendarProps {
|
|
|
80
80
|
* Callback when header month is changed, passing this prop will disable onTitlePress.
|
|
81
81
|
*/
|
|
82
82
|
onMonthChange?: (date: Date) => void;
|
|
83
|
+
/*
|
|
84
|
+
* Callback when month picker is toggled.
|
|
85
|
+
*/
|
|
86
|
+
onToggleMonthPicker?: (visible: boolean) => void;
|
|
83
87
|
/**
|
|
84
88
|
* Label for the confirm button of the month picker, Android only.
|
|
85
89
|
*/
|
|
@@ -102,6 +106,7 @@ const Calendar = ({
|
|
|
102
106
|
markedDates = [],
|
|
103
107
|
testID,
|
|
104
108
|
onMonthChange = noop,
|
|
109
|
+
onToggleMonthPicker = noop,
|
|
105
110
|
monthPickerConfirmLabel,
|
|
106
111
|
monthPickerCancelLabel,
|
|
107
112
|
}: CalendarProps) => {
|
|
@@ -186,7 +191,10 @@ const Calendar = ({
|
|
|
186
191
|
) : (
|
|
187
192
|
<TouchableOpacity
|
|
188
193
|
testID="calendar-month-picker"
|
|
189
|
-
onPress={() =>
|
|
194
|
+
onPress={() => {
|
|
195
|
+
onToggleMonthPicker?.(!monthPickerVisible);
|
|
196
|
+
setMonthPickerVisible(!monthPickerVisible);
|
|
197
|
+
}}
|
|
190
198
|
>
|
|
191
199
|
<Box
|
|
192
200
|
flexDirection="row"
|
|
@@ -309,6 +317,7 @@ const Calendar = ({
|
|
|
309
317
|
maximumDate={maxDate}
|
|
310
318
|
onChange={(action, date) => {
|
|
311
319
|
setMonthPickerVisible(false);
|
|
320
|
+
onToggleMonthPicker?.(false);
|
|
312
321
|
|
|
313
322
|
if (action === 'dateSetAction' && !!date) {
|
|
314
323
|
onMonthChange(date);
|
|
@@ -1488,7 +1488,81 @@ exports[`Carousel should call skip call back when press skip 1`] = `
|
|
|
1488
1488
|
undefined,
|
|
1489
1489
|
]
|
|
1490
1490
|
}
|
|
1491
|
-
|
|
1491
|
+
>
|
|
1492
|
+
<View
|
|
1493
|
+
style={
|
|
1494
|
+
Array [
|
|
1495
|
+
Object {
|
|
1496
|
+
"alignItems": "center",
|
|
1497
|
+
"flexDirection": "row",
|
|
1498
|
+
},
|
|
1499
|
+
Array [
|
|
1500
|
+
Object {
|
|
1501
|
+
"paddingVertical": 8,
|
|
1502
|
+
},
|
|
1503
|
+
undefined,
|
|
1504
|
+
],
|
|
1505
|
+
]
|
|
1506
|
+
}
|
|
1507
|
+
>
|
|
1508
|
+
<View
|
|
1509
|
+
collapsable={false}
|
|
1510
|
+
style={
|
|
1511
|
+
Object {
|
|
1512
|
+
"backgroundColor": "#401960",
|
|
1513
|
+
"borderRadius": 999,
|
|
1514
|
+
"height": 8,
|
|
1515
|
+
"marginHorizontal": 8,
|
|
1516
|
+
"opacity": 1,
|
|
1517
|
+
"width": 24,
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
testID="page-control-indicator0"
|
|
1521
|
+
/>
|
|
1522
|
+
<View
|
|
1523
|
+
collapsable={false}
|
|
1524
|
+
style={
|
|
1525
|
+
Object {
|
|
1526
|
+
"backgroundColor": "#401960",
|
|
1527
|
+
"borderRadius": 999,
|
|
1528
|
+
"height": 8,
|
|
1529
|
+
"marginHorizontal": 8,
|
|
1530
|
+
"opacity": 0.5,
|
|
1531
|
+
"width": 8,
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
testID="page-control-indicator1"
|
|
1535
|
+
/>
|
|
1536
|
+
<View
|
|
1537
|
+
collapsable={false}
|
|
1538
|
+
style={
|
|
1539
|
+
Object {
|
|
1540
|
+
"backgroundColor": "#401960",
|
|
1541
|
+
"borderRadius": 999,
|
|
1542
|
+
"height": 8,
|
|
1543
|
+
"marginHorizontal": 8,
|
|
1544
|
+
"opacity": 0.5,
|
|
1545
|
+
"width": 8,
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
testID="page-control-indicator2"
|
|
1549
|
+
/>
|
|
1550
|
+
<View
|
|
1551
|
+
collapsable={false}
|
|
1552
|
+
style={
|
|
1553
|
+
Object {
|
|
1554
|
+
"backgroundColor": "#401960",
|
|
1555
|
+
"borderRadius": 999,
|
|
1556
|
+
"height": 8,
|
|
1557
|
+
"marginHorizontal": 8,
|
|
1558
|
+
"opacity": 0.5,
|
|
1559
|
+
"width": 8,
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
testID="page-control-indicator3"
|
|
1563
|
+
/>
|
|
1564
|
+
</View>
|
|
1565
|
+
</View>
|
|
1492
1566
|
<View
|
|
1493
1567
|
style={
|
|
1494
1568
|
Array [
|
|
@@ -2107,79 +2181,6 @@ exports[`Carousel should call skip call back when press skip 1`] = `
|
|
|
2107
2181
|
Skip
|
|
2108
2182
|
</Text>
|
|
2109
2183
|
</View>
|
|
2110
|
-
<View
|
|
2111
|
-
style={
|
|
2112
|
-
Array [
|
|
2113
|
-
Object {
|
|
2114
|
-
"alignItems": "center",
|
|
2115
|
-
"flexDirection": "row",
|
|
2116
|
-
},
|
|
2117
|
-
Array [
|
|
2118
|
-
Object {
|
|
2119
|
-
"paddingVertical": 8,
|
|
2120
|
-
},
|
|
2121
|
-
undefined,
|
|
2122
|
-
],
|
|
2123
|
-
]
|
|
2124
|
-
}
|
|
2125
|
-
>
|
|
2126
|
-
<View
|
|
2127
|
-
collapsable={false}
|
|
2128
|
-
style={
|
|
2129
|
-
Object {
|
|
2130
|
-
"backgroundColor": "#401960",
|
|
2131
|
-
"borderRadius": 999,
|
|
2132
|
-
"height": 8,
|
|
2133
|
-
"marginHorizontal": 8,
|
|
2134
|
-
"opacity": 1,
|
|
2135
|
-
"width": 24,
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
testID="page-control-indicator0"
|
|
2139
|
-
/>
|
|
2140
|
-
<View
|
|
2141
|
-
collapsable={false}
|
|
2142
|
-
style={
|
|
2143
|
-
Object {
|
|
2144
|
-
"backgroundColor": "#401960",
|
|
2145
|
-
"borderRadius": 999,
|
|
2146
|
-
"height": 8,
|
|
2147
|
-
"marginHorizontal": 8,
|
|
2148
|
-
"opacity": 0.5,
|
|
2149
|
-
"width": 8,
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
testID="page-control-indicator1"
|
|
2153
|
-
/>
|
|
2154
|
-
<View
|
|
2155
|
-
collapsable={false}
|
|
2156
|
-
style={
|
|
2157
|
-
Object {
|
|
2158
|
-
"backgroundColor": "#401960",
|
|
2159
|
-
"borderRadius": 999,
|
|
2160
|
-
"height": 8,
|
|
2161
|
-
"marginHorizontal": 8,
|
|
2162
|
-
"opacity": 0.5,
|
|
2163
|
-
"width": 8,
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
testID="page-control-indicator2"
|
|
2167
|
-
/>
|
|
2168
|
-
<View
|
|
2169
|
-
collapsable={false}
|
|
2170
|
-
style={
|
|
2171
|
-
Object {
|
|
2172
|
-
"backgroundColor": "#401960",
|
|
2173
|
-
"borderRadius": 999,
|
|
2174
|
-
"height": 8,
|
|
2175
|
-
"marginHorizontal": 8,
|
|
2176
|
-
"opacity": 0.5,
|
|
2177
|
-
"width": 8,
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
testID="page-control-indicator3"
|
|
2181
|
-
/>
|
|
2182
|
-
</View>
|
|
2183
2184
|
</View>
|
|
2184
2185
|
</View>
|
|
2185
2186
|
</View>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
3
1
|
import formatDate from 'date-fns/fp/format';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { Platform, TouchableOpacity, View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import BottomSheet from '../BottomSheet';
|
|
6
|
-
import TextInput from '../TextInput';
|
|
7
6
|
import Button from '../Button';
|
|
8
|
-
import type { DatePickerProps } from './types';
|
|
9
7
|
import Calendar, { CalendarProps } from '../Calendar';
|
|
8
|
+
import TextInput from '../TextInput';
|
|
9
|
+
import type { DatePickerProps } from './types';
|
|
10
10
|
|
|
11
11
|
const InternalCalendar = ({
|
|
12
12
|
minDate,
|
|
13
13
|
maxDate,
|
|
14
14
|
value,
|
|
15
15
|
onChange,
|
|
16
|
+
onToggleMonthPicker,
|
|
16
17
|
monthPickerConfirmLabel,
|
|
17
18
|
monthPickerCancelLabel,
|
|
18
19
|
}: Pick<
|
|
@@ -21,6 +22,7 @@ const InternalCalendar = ({
|
|
|
21
22
|
| 'maxDate'
|
|
22
23
|
| 'value'
|
|
23
24
|
| 'onChange'
|
|
25
|
+
| 'onToggleMonthPicker'
|
|
24
26
|
| 'monthPickerConfirmLabel'
|
|
25
27
|
| 'monthPickerCancelLabel'
|
|
26
28
|
>) => {
|
|
@@ -50,6 +52,7 @@ const InternalCalendar = ({
|
|
|
50
52
|
minDate={minDate}
|
|
51
53
|
maxDate={maxDate}
|
|
52
54
|
onMonthChange={(date) => setVisibleDate(date)}
|
|
55
|
+
onToggleMonthPicker={onToggleMonthPicker}
|
|
53
56
|
monthPickerConfirmLabel={monthPickerConfirmLabel}
|
|
54
57
|
monthPickerCancelLabel={monthPickerCancelLabel}
|
|
55
58
|
/>
|
|
@@ -75,9 +78,12 @@ const DatePickerCalendar = ({
|
|
|
75
78
|
monthPickerCancelLabel,
|
|
76
79
|
}: Omit<DatePickerProps, 'variant'>) => {
|
|
77
80
|
const [open, setOpen] = useState(false);
|
|
81
|
+
const [monthPickerVisible, setMonthPickerVisible] = useState(false);
|
|
82
|
+
const shouldHideToolbar = Platform.OS === 'ios' && monthPickerVisible;
|
|
78
83
|
|
|
79
84
|
const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
|
|
80
85
|
const displayValue = value ? formatDate(displayFormat, value) : '';
|
|
86
|
+
|
|
81
87
|
return (
|
|
82
88
|
<TouchableOpacity onPress={() => setOpen(true)} disabled={disabled}>
|
|
83
89
|
<View pointerEvents="none" testID="datePickerCalendar">
|
|
@@ -99,16 +105,18 @@ const DatePickerCalendar = ({
|
|
|
99
105
|
onRequestClose={() => setOpen(false)}
|
|
100
106
|
header={label}
|
|
101
107
|
footer={
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
shouldHideToolbar ? undefined : (
|
|
109
|
+
<Button
|
|
110
|
+
variant="text"
|
|
111
|
+
text={confirmLabel}
|
|
112
|
+
onPress={() => {
|
|
113
|
+
if (selectingDate) {
|
|
114
|
+
onChange(selectingDate);
|
|
115
|
+
}
|
|
116
|
+
setOpen(false);
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
)
|
|
112
120
|
}
|
|
113
121
|
>
|
|
114
122
|
<InternalCalendar
|
|
@@ -118,6 +126,7 @@ const DatePickerCalendar = ({
|
|
|
118
126
|
onChange={setSelectingDate}
|
|
119
127
|
monthPickerConfirmLabel={monthPickerConfirmLabel}
|
|
120
128
|
monthPickerCancelLabel={monthPickerCancelLabel}
|
|
129
|
+
onToggleMonthPicker={(visible) => setMonthPickerVisible(visible)}
|
|
121
130
|
/>
|
|
122
131
|
</BottomSheet>
|
|
123
132
|
</TouchableOpacity>
|
|
@@ -16,6 +16,16 @@ const StyledContainer = styled(View)<ViewProps>({
|
|
|
16
16
|
justifyContent: 'flex-end',
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
const StyledContainerInModal = styled(View)<ViewProps>({
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
left: 0,
|
|
22
|
+
right: 0,
|
|
23
|
+
top: 0,
|
|
24
|
+
bottom: 0,
|
|
25
|
+
alignItems: 'flex-end',
|
|
26
|
+
justifyContent: 'flex-end',
|
|
27
|
+
});
|
|
28
|
+
|
|
19
29
|
const StyledActionGroupContainer = styled(Animated.View)<
|
|
20
30
|
ComponentProps<typeof Animated.View>
|
|
21
31
|
>({
|
|
@@ -38,6 +48,7 @@ const StyledBackdrop = styled(Animated.View)<
|
|
|
38
48
|
right: 0,
|
|
39
49
|
top: 0,
|
|
40
50
|
bottom: 0,
|
|
51
|
+
opacity: 0.25,
|
|
41
52
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground,
|
|
42
53
|
}));
|
|
43
54
|
|
|
@@ -52,6 +63,7 @@ export {
|
|
|
52
63
|
StyledHeaderText,
|
|
53
64
|
StyledBackdrop,
|
|
54
65
|
StyledContainer,
|
|
66
|
+
StyledContainerInModal,
|
|
55
67
|
StyledActionGroupContainer,
|
|
56
68
|
StyledFAB,
|
|
57
69
|
};
|