@hero-design/rn 8.33.2 → 8.34.1
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/.turbo/turbo-build.log +1 -1
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +797 -488
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +800 -489
- package/package.json +8 -5
- package/rollup.config.js +2 -0
- package/src/components/Calendar/__tests__/index.spec.tsx +47 -0
- package/src/components/Calendar/index.tsx +161 -59
- package/src/components/Carousel/CardCarousel.tsx +2 -0
- package/src/components/DatePicker/DatePickerAndroid.tsx +4 -1
- package/src/components/DatePicker/DatePickerCalendar.tsx +18 -1
- package/src/components/DatePicker/DatePickerIOS.tsx +4 -1
- package/src/components/DatePicker/__tests__/DatePickerCalendar.spec.tsx +39 -0
- package/src/components/DatePicker/types.ts +8 -0
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +2 -0
- package/src/components/Modal/ModalContentWrapper.tsx +112 -0
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +135 -0
- package/src/components/Modal/ModalPresenter/index.tsx +9 -0
- package/src/components/Modal/ModalProvider.tsx +8 -0
- package/src/components/Modal/__tests__/ModalContentWrapper.spec.tsx +25 -0
- package/src/components/Modal/__tests__/ModalPresenter.spec.tsx +57 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalContentWrapper.spec.tsx.snap +35 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalPresenter.spec.tsx.snap +55 -0
- package/src/components/Modal/__tests__/index.spec.tsx +50 -0
- package/src/components/Modal/index.tsx +121 -0
- package/src/components/PinInput/index.tsx +2 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +5 -2
- package/src/components/Toast/ToastContainer.tsx +2 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +2 -0
- package/src/theme/components/calendar.ts +2 -0
- package/testUtils/setup.tsx +43 -0
- package/types/components/Calendar/index.d.ts +13 -1
- package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
- package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
- package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
- package/types/components/DatePicker/types.d.ts +8 -0
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Modal/ModalContentWrapper.d.ts +16 -0
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +34 -0
- package/types/components/Modal/ModalPresenter/index.d.ts +3 -0
- package/types/components/Modal/ModalProvider.d.ts +5 -0
- package/types/components/Modal/index.d.ts +33 -0
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/types/index.d.ts +2 -1
- package/types/theme/components/calendar.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.34.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,12 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.
|
|
24
|
+
"@hero-design/colors": "8.34.1",
|
|
25
|
+
"@hero-design/react-native-month-year-picker": "^8.34.1",
|
|
25
26
|
"date-fns": "^2.16.1",
|
|
26
27
|
"events": "^3.2.0",
|
|
27
28
|
"hero-editor": "^1.9.21"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
31
|
+
"@hero-design/react-native-month-year-picker": "^8.34.1",
|
|
30
32
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
31
33
|
"@react-native-community/slider": "4.1.12",
|
|
32
34
|
"react": "18.0.0",
|
|
@@ -34,6 +36,7 @@
|
|
|
34
36
|
"react-native-gesture-handler": "^1.10.3 | ~2.5.0",
|
|
35
37
|
"react-native-linear-gradient": "^2.6.2",
|
|
36
38
|
"react-native-pager-view": "^5.4.25",
|
|
39
|
+
"react-native-root-siblings": "^4.1.1",
|
|
37
40
|
"react-native-safe-area-context": "^3.0.2",
|
|
38
41
|
"react-native-vector-icons": "^9.1.0",
|
|
39
42
|
"react-native-webview": "^11.2.5"
|
|
@@ -45,7 +48,7 @@
|
|
|
45
48
|
"@babel/preset-typescript": "^7.17.12",
|
|
46
49
|
"@babel/runtime": "^7.18.9",
|
|
47
50
|
"@emotion/jest": "^11.9.3",
|
|
48
|
-
"@hero-design/eslint-plugin": "8.
|
|
51
|
+
"@hero-design/eslint-plugin": "8.34.1",
|
|
49
52
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
50
53
|
"@react-native-community/slider": "4.1.12",
|
|
51
54
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -61,10 +64,10 @@
|
|
|
61
64
|
"@types/react-native": "^0.67.7",
|
|
62
65
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
63
66
|
"babel-plugin-inline-import": "^3.0.0",
|
|
64
|
-
"eslint-config-hd": "8.
|
|
67
|
+
"eslint-config-hd": "8.34.1",
|
|
65
68
|
"eslint-plugin-import": "^2.27.5",
|
|
66
69
|
"jest": "^27.3.1",
|
|
67
|
-
"prettier-config-hd": "8.
|
|
70
|
+
"prettier-config-hd": "8.34.1",
|
|
68
71
|
"react": "18.0.0",
|
|
69
72
|
"react-native": "0.69.7",
|
|
70
73
|
"react-native-gesture-handler": "~2.5.0",
|
package/rollup.config.js
CHANGED
|
@@ -92,4 +92,51 @@ describe('Calendar', () => {
|
|
|
92
92
|
fireEvent.press(getByText('26'));
|
|
93
93
|
expect(onChange).toBeCalledWith(new Date(2022, 10, 26));
|
|
94
94
|
});
|
|
95
|
+
|
|
96
|
+
it('disables onTitlePress when onMonthChange is passed', () => {
|
|
97
|
+
const onTitlePress = jest.fn();
|
|
98
|
+
const { getByTestId } = renderWithTheme(
|
|
99
|
+
<Calendar
|
|
100
|
+
value={new Date(2022, 10, 5)}
|
|
101
|
+
visibleDate={new Date(2022, 10, 5)}
|
|
102
|
+
onTitlePress={onTitlePress}
|
|
103
|
+
minDate={new Date(2022, 10, 3)}
|
|
104
|
+
maxDate={new Date(2022, 10, 27)}
|
|
105
|
+
onMonthChange={jest.fn()}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
fireEvent.press(getByTestId('calendar-month-picker'));
|
|
110
|
+
expect(onTitlePress).toHaveBeenCalledTimes(0);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it.each`
|
|
114
|
+
platform
|
|
115
|
+
${'ios'}
|
|
116
|
+
${'android'}
|
|
117
|
+
`('renders correct picker on $platform', ({ platform }) => {
|
|
118
|
+
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
|
|
119
|
+
OS: platform,
|
|
120
|
+
select: () => null,
|
|
121
|
+
}));
|
|
122
|
+
|
|
123
|
+
const { getByTestId, queryByText } = renderWithTheme(
|
|
124
|
+
<Calendar
|
|
125
|
+
value={new Date(2022, 10, 5)}
|
|
126
|
+
visibleDate={new Date(2022, 10, 5)}
|
|
127
|
+
minDate={new Date(2022, 10, 3)}
|
|
128
|
+
maxDate={new Date(2022, 10, 27)}
|
|
129
|
+
onMonthChange={jest.fn()}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
fireEvent.press(getByTestId('calendar-month-picker'));
|
|
134
|
+
|
|
135
|
+
// Pickers are mocked at packages/rn/testUtils/setup.tsx
|
|
136
|
+
if (platform === 'ios') {
|
|
137
|
+
expect(queryByText('IOS picker')).toBeDefined();
|
|
138
|
+
} else {
|
|
139
|
+
expect(queryByText('Android picker')).toBeDefined();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
95
142
|
});
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
MonthYearPickerDialogueAndroid,
|
|
3
|
+
MonthYearPickerViewIOS,
|
|
4
|
+
} from '@hero-design/react-native-month-year-picker';
|
|
2
5
|
import format from 'date-fns/fp/format';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Platform, TouchableOpacity } from 'react-native';
|
|
8
|
+
import { useTheme } from '../../theme';
|
|
9
|
+
import { noop } from '../../utils/functions';
|
|
10
|
+
import Box from '../Box';
|
|
3
11
|
import ContentNavigator from '../ContentNavigator';
|
|
12
|
+
import Icon from '../Icon';
|
|
4
13
|
import Typography from '../Typography';
|
|
14
|
+
import CalendarRowItem from './CalendarRowItem';
|
|
5
15
|
import {
|
|
6
16
|
StyledCalendarDayNameCell,
|
|
7
17
|
StyledCalendarHeader,
|
|
@@ -10,9 +20,7 @@ import {
|
|
|
10
20
|
StyledContainer,
|
|
11
21
|
StyledDisabledCalendarRowItem,
|
|
12
22
|
} from './StyledCalendar';
|
|
13
|
-
import CalendarRowItem from './CalendarRowItem';
|
|
14
23
|
import { getValidDate, initArray, isEqDate } from './helpers';
|
|
15
|
-
import { noop } from '../../utils/functions';
|
|
16
24
|
|
|
17
25
|
const DAYS_OF_WEEK = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
|
|
18
26
|
// Sunday first column => 0
|
|
@@ -68,6 +76,18 @@ export interface CalendarProps {
|
|
|
68
76
|
* Testing id of the component.
|
|
69
77
|
*/
|
|
70
78
|
testID?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Callback when header month is changed, passing this prop will disable onTitlePress.
|
|
81
|
+
*/
|
|
82
|
+
onMonthChange?: (date: Date) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Label for the confirm button of the month picker, Android only.
|
|
85
|
+
*/
|
|
86
|
+
monthPickerConfirmLabel?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Label for the cancel button of the month picker, Android only.
|
|
89
|
+
*/
|
|
90
|
+
monthPickerCancelLabel?: string;
|
|
71
91
|
}
|
|
72
92
|
|
|
73
93
|
const Calendar = ({
|
|
@@ -81,7 +101,11 @@ const Calendar = ({
|
|
|
81
101
|
maxDate,
|
|
82
102
|
markedDates = [],
|
|
83
103
|
testID,
|
|
104
|
+
onMonthChange = noop,
|
|
105
|
+
monthPickerConfirmLabel,
|
|
106
|
+
monthPickerCancelLabel,
|
|
84
107
|
}: CalendarProps) => {
|
|
108
|
+
const theme = useTheme();
|
|
85
109
|
const currentMonth = visibleDate.getMonth();
|
|
86
110
|
const currentYear = visibleDate.getFullYear();
|
|
87
111
|
const now = new Date();
|
|
@@ -92,6 +116,10 @@ const Calendar = ({
|
|
|
92
116
|
}),
|
|
93
117
|
{}
|
|
94
118
|
);
|
|
119
|
+
const [monthPickerVisible, setMonthPickerVisible] = React.useState(false);
|
|
120
|
+
const [contentHeight, setContentHeight] = React.useState(0);
|
|
121
|
+
|
|
122
|
+
const useMonthPicker = onMonthChange !== noop;
|
|
95
123
|
|
|
96
124
|
const firstDateOfMonth = new Date(currentYear, currentMonth, 1);
|
|
97
125
|
const lastDateOfMonth = new Date(currentYear, currentMonth + 1, 0);
|
|
@@ -152,70 +180,144 @@ const Calendar = ({
|
|
|
152
180
|
<StyledContainer testID={testID}>
|
|
153
181
|
<StyledCalendarHeader>
|
|
154
182
|
<ContentNavigator
|
|
155
|
-
value={
|
|
183
|
+
value={
|
|
184
|
+
!useMonthPicker ? (
|
|
185
|
+
format('MMMM yyyy', visibleDate)
|
|
186
|
+
) : (
|
|
187
|
+
<TouchableOpacity
|
|
188
|
+
testID="calendar-month-picker"
|
|
189
|
+
onPress={() => setMonthPickerVisible(!monthPickerVisible)}
|
|
190
|
+
>
|
|
191
|
+
<Box
|
|
192
|
+
flexDirection="row"
|
|
193
|
+
justifyContent="center"
|
|
194
|
+
alignItems="center"
|
|
195
|
+
>
|
|
196
|
+
<Typography.Title
|
|
197
|
+
level="h5"
|
|
198
|
+
style={{
|
|
199
|
+
textAlign: 'center',
|
|
200
|
+
marginRight:
|
|
201
|
+
theme.__hd__.calendar.space.headerMarginRight,
|
|
202
|
+
}}
|
|
203
|
+
>
|
|
204
|
+
{format('MMMM yyyy', visibleDate)}
|
|
205
|
+
</Typography.Title>
|
|
206
|
+
|
|
207
|
+
<Icon
|
|
208
|
+
icon={monthPickerVisible ? 'arrow-up' : 'arrow-down'}
|
|
209
|
+
size="small"
|
|
210
|
+
/>
|
|
211
|
+
</Box>
|
|
212
|
+
</TouchableOpacity>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
156
215
|
onPreviousPress={onPreviousPress}
|
|
157
216
|
onNextPress={onNextPress}
|
|
158
|
-
onPress={onTitlePress}
|
|
217
|
+
onPress={useMonthPicker ? undefined : onTitlePress}
|
|
159
218
|
previousDisabled={disablePrevButton}
|
|
160
219
|
nextDisabled={disableNextButton}
|
|
161
220
|
fontSize="large"
|
|
162
221
|
/>
|
|
163
222
|
</StyledCalendarHeader>
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
223
|
+
{Platform.OS === 'ios' && monthPickerVisible ? (
|
|
224
|
+
<Box style={{ overflow: 'hidden' }}>
|
|
225
|
+
<MonthYearPickerViewIOS
|
|
226
|
+
value={value}
|
|
227
|
+
minimumDate={minDate}
|
|
228
|
+
maximumDate={maxDate}
|
|
229
|
+
onChange={onMonthChange}
|
|
230
|
+
style={{
|
|
231
|
+
height:
|
|
232
|
+
contentHeight +
|
|
233
|
+
theme.__hd__.calendar.space.iosPickerMarginVertical * 2,
|
|
234
|
+
marginVertical:
|
|
235
|
+
-theme.__hd__.calendar.space.iosPickerMarginVertical,
|
|
236
|
+
}}
|
|
237
|
+
/>
|
|
238
|
+
</Box>
|
|
239
|
+
) : (
|
|
240
|
+
<Box
|
|
241
|
+
onLayout={
|
|
242
|
+
Platform.OS === 'ios'
|
|
243
|
+
? (e) => setContentHeight(e.nativeEvent.layout.height)
|
|
244
|
+
: undefined
|
|
245
|
+
}
|
|
246
|
+
>
|
|
247
|
+
<StyledCalendarRow>
|
|
248
|
+
{DAYS_OF_WEEK.map((day) => (
|
|
249
|
+
<StyledCalendarRowItem key={day}>
|
|
250
|
+
<StyledCalendarDayNameCell>
|
|
251
|
+
<Typography.Body variant="small">{day}</Typography.Body>
|
|
252
|
+
</StyledCalendarDayNameCell>
|
|
253
|
+
</StyledCalendarRowItem>
|
|
254
|
+
))}
|
|
255
|
+
</StyledCalendarRow>
|
|
256
|
+
<StyledCalendarRow>
|
|
257
|
+
{daysOfPreviousMonth.map((date) =>
|
|
258
|
+
date ? (
|
|
259
|
+
<CalendarRowItem
|
|
260
|
+
key={date.toDateString()}
|
|
261
|
+
date={date}
|
|
262
|
+
isCurrent={isEqDate(now, date)}
|
|
263
|
+
isSelected={isEqDate(value, date)}
|
|
264
|
+
onPress={() => onChange?.(date)}
|
|
265
|
+
textIntent="subdued"
|
|
266
|
+
marked={parsedMaskedDate[date.toDateString()]}
|
|
267
|
+
/>
|
|
268
|
+
) : (
|
|
269
|
+
<StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
|
|
270
|
+
)
|
|
271
|
+
)}
|
|
272
|
+
{daysOfCurrentMonth.map((date) =>
|
|
273
|
+
date ? (
|
|
274
|
+
<CalendarRowItem
|
|
275
|
+
key={date.toDateString()}
|
|
276
|
+
date={date}
|
|
277
|
+
isCurrent={isEqDate(now, date)}
|
|
278
|
+
isSelected={isEqDate(value, date)}
|
|
279
|
+
onPress={() => onChange?.(date)}
|
|
280
|
+
marked={parsedMaskedDate[date.toDateString()]}
|
|
281
|
+
/>
|
|
282
|
+
) : (
|
|
283
|
+
<StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
|
|
284
|
+
)
|
|
285
|
+
)}
|
|
286
|
+
{daysOfNextMonth.map((date) =>
|
|
287
|
+
date ? (
|
|
288
|
+
<CalendarRowItem
|
|
289
|
+
key={date.toDateString()}
|
|
290
|
+
date={date}
|
|
291
|
+
isCurrent={isEqDate(now, date)}
|
|
292
|
+
isSelected={isEqDate(value, date)}
|
|
293
|
+
onPress={() => onChange?.(date)}
|
|
294
|
+
textIntent="subdued"
|
|
295
|
+
marked={parsedMaskedDate[date.toDateString()]}
|
|
296
|
+
/>
|
|
297
|
+
) : (
|
|
298
|
+
<StyledDisabledCalendarRowItem testID="calendar-disabled-cell" />
|
|
299
|
+
)
|
|
300
|
+
)}
|
|
301
|
+
</StyledCalendarRow>
|
|
302
|
+
|
|
303
|
+
{Platform.OS === 'android' && monthPickerVisible && (
|
|
304
|
+
<MonthYearPickerDialogueAndroid
|
|
305
|
+
doneButtonLabel={monthPickerConfirmLabel}
|
|
306
|
+
cancelButtonLabel={monthPickerCancelLabel}
|
|
307
|
+
value={value}
|
|
308
|
+
minimumDate={minDate}
|
|
309
|
+
maximumDate={maxDate}
|
|
310
|
+
onChange={(action, date) => {
|
|
311
|
+
setMonthPickerVisible(false);
|
|
312
|
+
|
|
313
|
+
if (action === 'dateSetAction' && !!date) {
|
|
314
|
+
onMonthChange(date);
|
|
315
|
+
}
|
|
316
|
+
}}
|
|
213
317
|
/>
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
)}
|
|
218
|
-
</StyledCalendarRow>
|
|
318
|
+
)}
|
|
319
|
+
</Box>
|
|
320
|
+
)}
|
|
219
321
|
</StyledContainer>
|
|
220
322
|
);
|
|
221
323
|
};
|
|
@@ -20,7 +20,10 @@ const DatePickerAndroid = ({
|
|
|
20
20
|
helpText,
|
|
21
21
|
style,
|
|
22
22
|
testID,
|
|
23
|
-
}: Omit<
|
|
23
|
+
}: Omit<
|
|
24
|
+
DatePickerProps,
|
|
25
|
+
'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
|
|
26
|
+
>) => {
|
|
24
27
|
const [open, setOpen] = useState(false);
|
|
25
28
|
|
|
26
29
|
const displayValue = value ? formatDate(displayFormat, value) : '';
|
|
@@ -13,7 +13,17 @@ const InternalCalendar = ({
|
|
|
13
13
|
maxDate,
|
|
14
14
|
value,
|
|
15
15
|
onChange,
|
|
16
|
-
|
|
16
|
+
monthPickerConfirmLabel,
|
|
17
|
+
monthPickerCancelLabel,
|
|
18
|
+
}: Pick<
|
|
19
|
+
CalendarProps,
|
|
20
|
+
| 'minDate'
|
|
21
|
+
| 'maxDate'
|
|
22
|
+
| 'value'
|
|
23
|
+
| 'onChange'
|
|
24
|
+
| 'monthPickerConfirmLabel'
|
|
25
|
+
| 'monthPickerCancelLabel'
|
|
26
|
+
>) => {
|
|
17
27
|
const [visibleDate, setVisibleDate] = useState(value || new Date());
|
|
18
28
|
const [selectingDate, setSelectingDate] = useState<Date>(value || new Date());
|
|
19
29
|
return (
|
|
@@ -39,6 +49,9 @@ const InternalCalendar = ({
|
|
|
39
49
|
}
|
|
40
50
|
minDate={minDate}
|
|
41
51
|
maxDate={maxDate}
|
|
52
|
+
onMonthChange={(date) => setVisibleDate(date)}
|
|
53
|
+
monthPickerConfirmLabel={monthPickerConfirmLabel}
|
|
54
|
+
monthPickerCancelLabel={monthPickerCancelLabel}
|
|
42
55
|
/>
|
|
43
56
|
);
|
|
44
57
|
};
|
|
@@ -58,6 +71,8 @@ const DatePickerCalendar = ({
|
|
|
58
71
|
helpText,
|
|
59
72
|
style,
|
|
60
73
|
testID,
|
|
74
|
+
monthPickerConfirmLabel,
|
|
75
|
+
monthPickerCancelLabel,
|
|
61
76
|
}: Omit<DatePickerProps, 'variant'>) => {
|
|
62
77
|
const [open, setOpen] = useState(false);
|
|
63
78
|
|
|
@@ -101,6 +116,8 @@ const DatePickerCalendar = ({
|
|
|
101
116
|
maxDate={maxDate}
|
|
102
117
|
value={value}
|
|
103
118
|
onChange={setSelectingDate}
|
|
119
|
+
monthPickerConfirmLabel={monthPickerConfirmLabel}
|
|
120
|
+
monthPickerCancelLabel={monthPickerCancelLabel}
|
|
104
121
|
/>
|
|
105
122
|
</BottomSheet>
|
|
106
123
|
</TouchableOpacity>
|
|
@@ -41,7 +41,10 @@ const DatePickerIOS = ({
|
|
|
41
41
|
helpText,
|
|
42
42
|
style,
|
|
43
43
|
testID,
|
|
44
|
-
}: Omit<
|
|
44
|
+
}: Omit<
|
|
45
|
+
DatePickerProps,
|
|
46
|
+
'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'
|
|
47
|
+
>) => {
|
|
45
48
|
const [selectingDate, setSelectingDate] = useState<Date>(
|
|
46
49
|
getInitialDateValue(value || new Date(), minDate, maxDate)
|
|
47
50
|
);
|
|
@@ -58,4 +58,43 @@ describe('DatePickerCalendar', () => {
|
|
|
58
58
|
|
|
59
59
|
expect(getByText('This is help text')).toBeTruthy();
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
it.each`
|
|
63
|
+
platform
|
|
64
|
+
${'ios'}
|
|
65
|
+
${'android'}
|
|
66
|
+
`('renders month year picker when pressing on title', ({ platform }) => {
|
|
67
|
+
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
|
|
68
|
+
OS: platform,
|
|
69
|
+
select: () => null,
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
const { queryByText, getByText, getByTestId } = renderWithTheme(
|
|
73
|
+
<DatePickerCalendar
|
|
74
|
+
value={new Date('December 21, 1995')}
|
|
75
|
+
label="Start date"
|
|
76
|
+
confirmLabel="Confirm"
|
|
77
|
+
helpText="This is help text"
|
|
78
|
+
onChange={jest.fn()}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
fireEvent.press(getByText('Start date'));
|
|
83
|
+
fireEvent.press(getByText('December 1995'));
|
|
84
|
+
|
|
85
|
+
if (platform === 'ios') {
|
|
86
|
+
expect(queryByText('IOS picker')).toBeDefined();
|
|
87
|
+
} else {
|
|
88
|
+
expect(queryByText('Android picker')).toBeDefined();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Selecting month
|
|
92
|
+
fireEvent(
|
|
93
|
+
getByTestId('calendar'),
|
|
94
|
+
'onMonthChange',
|
|
95
|
+
new Date('January 17, 1993')
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(queryByText('January 1993')).toBeDefined();
|
|
99
|
+
});
|
|
61
100
|
});
|
|
@@ -64,4 +64,12 @@ export interface DatePickerProps {
|
|
|
64
64
|
* Testing id of the component.
|
|
65
65
|
*/
|
|
66
66
|
testID?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Calendar variant prop. Label for the confirm button of the month picker, Android only.
|
|
69
|
+
*/
|
|
70
|
+
monthPickerConfirmLabel?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Calendar variant prop. Label for the cancel button of the month picker, Android only.
|
|
73
|
+
*/
|
|
74
|
+
monthPickerCancelLabel?: string;
|
|
67
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"ai-outlined":59183,"alignment-2-outlined":59184,"alignment-outlined":59185,"all-caps":59186,"arrow-down":59187,"arrow-downwards":59188,"arrow-left":59189,"arrow-leftwards":59190,"arrow-right":59191,"arrow-rightwards":59192,"arrow-up":59193,"arrow-upwards":59194,"article-outlined":59195,"at-sign":59196,"auto-graph-outlined":59197,"beer-outlined":59198,"bell-active-outlined":59199,"bell-outlined":59200,"bell-slash-outlined":59201,"billing-outlined":59202,"body-outlined":59203,"bold":59204,"book-outlined":59205,"bookmark-added-outlined":59206,"bookmark-outlined":59207,"box-check-outlined":59208,"box-outlined":59209,"bullet-points":59210,"cake-outlined":59211,"calendar-dates-outlined":59212,"calendar-star-outlined":59213,"call-split-outlined":
|
|
1
|
+
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bolt":59011,"bookmark-added":59012,"bookmark":59013,"box-check":59014,"box":59015,"bpay":59016,"buildings":59017,"cake":59018,"calendar-clock":59019,"calendar":59020,"candy-box-menu":59021,"caret-down-small":59022,"caret-down":59023,"caret-left-small":59024,"caret-left":59025,"caret-right-small":59026,"caret-right":59027,"caret-up-small":59028,"caret-up":59029,"check-radio":59030,"circle-add":59031,"circle-cancel":59032,"circle-check":59033,"circle-down":59034,"circle-info":59035,"circle-left":59036,"circle-ok":59037,"circle-pencil":59038,"circle-question":59039,"circle-remove":59040,"circle-right":59041,"circle-up":59042,"circle-warning":59043,"clock-3":59044,"clock":59045,"cloud-download":59046,"cloud-upload":59047,"cog":59048,"coin":59049,"contacts":59050,"credit-card":59051,"diamond":59052,"direction-arrows":59053,"directory":59054,"document":59055,"dollar-coin-shine":59056,"double-buildings":59057,"edit-template":59058,"envelope":59059,"exclude":59060,"expense":59061,"eye-circle":59062,"eye-invisible":59063,"eye":59064,"face-meh":59065,"face-sad":59066,"face-smiley":59067,"feed":59068,"feedbacks":59069,"file-certified":59070,"file-clone":59071,"file-copy":59072,"file-csv":59073,"file-dispose":59074,"file-doc":59075,"file-excel":59076,"file-export":59077,"file-lock":59078,"file-pdf":59079,"file-powerpoint":59080,"file-search":59081,"file-secured":59082,"file-sheets":59083,"file-slide":59084,"file-verified":59085,"file-word":59086,"file":59087,"filter":59088,"folder-user":59089,"folder":59090,"format-bold":59091,"format-heading1":59092,"format-heading2":59093,"format-italic":59094,"format-list-bulleted":59095,"format-list-numbered":59096,"format-underlined":59097,"funnel-filter":59098,"global-dollar":59099,"globe":59100,"graduation-cap":59101,"graph":59102,"happy-sun":59103,"health-bag":59104,"heart":59105,"home":59106,"image":59107,"import":59108,"incident-siren":59109,"instapay":59110,"list":59111,"loading-2":59112,"loading":59113,"location":59114,"lock":59115,"looks-one":59116,"looks-two":59117,"media-content":59118,"menu":59119,"money-notes":59120,"moneybag":59121,"moon":59122,"multiple-stars":59123,"multiple-users":59124,"node":59125,"open-folder":59126,"paperclip":59127,"payment-summary":59128,"pencil":59129,"phone":59130,"piggy-bank":59131,"plane-up":59132,"plane":59133,"play-circle":59134,"print":59135,"raising-hands":59136,"reply-arrow":59137,"reply":59138,"reschedule":59139,"rostering":59140,"save":59141,"schedule-send":59142,"schedule":59143,"search-person":59144,"send":59145,"speaker-active":59146,"speaker":59147,"star-award":59148,"star-badge":59149,"star-circle":59150,"star-medal":59151,"star":59152,"steps-circle":59153,"stopwatch":59154,"suitcase":59155,"surfing":59156,"survey":59157,"swag-pillar-benefit":59158,"swag-pillar-career":59159,"swag-pillar-money":59160,"swag-pillar-work":59161,"swag":59162,"switch":59163,"tag":59164,"target":59165,"teams":59166,"timesheet":59167,"touch-id":59168,"trash-bin":59169,"unlock":59170,"user":59171,"video-1":59172,"video-2":59173,"wallet":59174,"warning":59175,"activate-outlined":59176,"add-credit-card-outlined":59177,"add-person-outlined":59178,"add-section-outlined":59179,"add-time-outlined":59180,"add":59181,"adjustment-outlined":59182,"ai-outlined":59183,"alignment-2-outlined":59184,"alignment-outlined":59185,"all-caps":59186,"arrow-down":59187,"arrow-downwards":59188,"arrow-left":59189,"arrow-leftwards":59190,"arrow-right":59191,"arrow-rightwards":59192,"arrow-up":59193,"arrow-upwards":59194,"article-outlined":59195,"at-sign":59196,"auto-graph-outlined":59197,"beer-outlined":59198,"bell-active-outlined":59199,"bell-outlined":59200,"bell-slash-outlined":59201,"billing-outlined":59202,"body-outlined":59203,"bold":59204,"book-outlined":59205,"bookmark-added-outlined":59206,"bookmark-outlined":59207,"box-check-outlined":59208,"box-outlined":59209,"bullet-points":59210,"cake-outlined":59211,"calendar-dates-outlined":59212,"calendar-star-outlined":59213,"call-outlined":59214,"call-split-outlined":59215,"camera-outlined":59216,"cancel":59217,"car-forward-outlined":59218,"charging-station-outlined":59219,"chat-bubble-outlined":59220,"chat-unread-outlined":59221,"checkmark":59222,"circle-add-outlined":59223,"circle-cancel-outlined":59224,"circle-down-outlined":59225,"circle-info-outlined":59226,"circle-left-outlined":59227,"circle-ok-outlined":59228,"circle-question-outlined":59229,"circle-remove-outlined":59230,"circle-right-outlined":59231,"circle-up-outlined":59232,"circle-warning-outlined":59233,"clock-2-outlined":59234,"clock-outlined":59235,"cog-outlined":59236,"coin-outlined":59237,"coin-super-outlined":59238,"comment-outlined":59239,"contacts-outlined":59240,"contacts-user-outlined":59241,"credit-card-outlined":59242,"cup-outlined":59243,"dentistry-outlined":59244,"direction-arrows-outlined":59245,"directory-outlined":59246,"document-outlined":59247,"dollar-box-outlined":59248,"dollar-card-outlined":59249,"dollar-coin-shine-outlined":59250,"dollar-credit-card-outlined":59251,"dollar-sign":59252,"double-buildings-outlined":59253,"double-left-arrows":59254,"double-right-arrows":59255,"download-box-outlined":59256,"download-outlined":59257,"edit-template-outlined":59258,"email-outlined":59259,"enter-arrow":59260,"envelope-outlined":59261,"expense-outlined":59262,"explore-outlined":59263,"extension-outlined":59264,"external-link":59265,"eye-invisible-outlined":59266,"eye-outlined":59267,"face-id":59268,"face-meh-outlined":59269,"face-open-smiley-outlined":59270,"face-sad-outlined":59271,"face-smiley-outlined":59272,"fastfood-outlined":59273,"feed-outlined":59274,"file-certified-outlined":59275,"file-clone-outlined":59276,"file-copy-outlined":59277,"file-dispose-outlined":59278,"file-dollar-certified-outlined":59279,"file-dollar-outlined":59280,"file-download-outlined":59281,"file-export-outlined":59282,"file-lock-outlined":59283,"file-outlined":59284,"file-search-outlined":59285,"file-secured-outlined":59286,"file-statutory-outlined":59287,"file-verified-outlined":59288,"filter-outlined":59289,"folder-outlined":59290,"folder-user-outlined":59291,"form-outlined":59292,"funnel-filter-outline":59293,"graph-outlined":59294,"hand-holding-user-outlined":59295,"happy-sun-outlined":59296,"health-bag-outlined":59297,"heart-outlined":59298,"home-active-outlined":59299,"home-outlined":59300,"id-card-outlined":59301,"image-outlined":59302,"import-outlined":59303,"instapay-outlined":59304,"italic":59305,"link-1":59306,"link-2":59307,"list-outlined":59308,"live-help-outlined":59309,"location-on-outlined":59310,"location-outlined":59311,"lock-outlined":59312,"locked-file-outlined":59313,"log-out":59314,"mail-outlined":59315,"media-content-outlined":59316,"menu-close":59317,"menu-expand":59318,"menu-fold-outlined":59319,"menu-unfold-outlined":59320,"moneybag-outlined":59321,"moon-outlined":59322,"more-horizontal":59323,"more-vertical":59324,"multiple-folders-outlined":59325,"multiple-users-outlined":59326,"near-me-outlined":59327,"node-outlined":59328,"number-points":59329,"number":59330,"overview-outlined":59331,"payment-summary-outlined":59332,"payslip-outlined":59333,"pencil-outlined":59334,"percentage":59335,"phone-outlined":59336,"piggy-bank-outlined":59337,"plane-outlined":59338,"play-circle-outlined":59339,"print-outlined":59340,"qr-code-outlined":59341,"qualification-outlined":59342,"re-assign":59343,"redeem":59344,"refresh":59345,"remove":59346,"reply-outlined":59347,"restart":59348,"return-arrow":59349,"rostering-outlined":59350,"save-outlined":59351,"schedule-outlined":59352,"search-outlined":59353,"search-secured-outlined":59354,"send-outlined":59355,"share-1":59356,"share-2":59357,"share-outlined":59358,"show-chart-outlined":59359,"single-down-arrow":59360,"single-left-arrow":59361,"single-right-arrow":59362,"single-up-arrow":59363,"speaker-active-outlined":59364,"speaker-outlined":59365,"star-circle-outlined":59366,"star-outlined":59367,"stopwatch-outlined":59368,"strikethrough":59369,"styler-outlined":59370,"suitcase-clock-outlined":59371,"suitcase-outlined":59372,"survey-outlined":59373,"switch-outlined":59374,"sync":59375,"tag-outlined":59376,"target-outlined":59377,"tennis-outlined":59378,"ticket-outlined":59379,"timesheet-outlined":59380,"today-outlined":59381,"transfer":59382,"trash-bin-outlined":59383,"umbrela-outlined":59384,"unavailable":59385,"underline":59386,"union-outlined":59387,"unlock-outlined":59388,"upload-outlined":59389,"user-circle-outlined":59390,"user-gear-outlined":59391,"user-outlined":59392,"user-rectangle-outlined":59393,"video-1-outlined":59394,"video-2-outlined":59395,"volunteer-outlined":59396,"wallet-outlined":59397}
|
|
@@ -214,6 +214,7 @@ const IconList = [
|
|
|
214
214
|
'cake-outlined',
|
|
215
215
|
'calendar-dates-outlined',
|
|
216
216
|
'calendar-star-outlined',
|
|
217
|
+
'call-outlined',
|
|
217
218
|
'call-split-outlined',
|
|
218
219
|
'camera-outlined',
|
|
219
220
|
'cancel',
|
|
@@ -314,6 +315,7 @@ const IconList = [
|
|
|
314
315
|
'lock-outlined',
|
|
315
316
|
'locked-file-outlined',
|
|
316
317
|
'log-out',
|
|
318
|
+
'mail-outlined',
|
|
317
319
|
'media-content-outlined',
|
|
318
320
|
'menu-close',
|
|
319
321
|
'menu-expand',
|