@hero-design/rn 7.12.0 → 7.13.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.
Files changed (42) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +4908 -4728
  3. package/lib/index.js +4907 -4726
  4. package/package.json +2 -2
  5. package/src/components/Button/Button.tsx +64 -60
  6. package/src/components/Button/StyledButton.tsx +4 -6
  7. package/src/components/Button/__tests__/StyledButton.spec.tsx +11 -4
  8. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +312 -78
  9. package/src/components/DatePicker/DatePickerAndroid.tsx +59 -0
  10. package/src/components/DatePicker/DatePickerIOS.tsx +87 -0
  11. package/src/components/DatePicker/StyledDatePicker.tsx +8 -0
  12. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +34 -0
  13. package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +39 -0
  14. package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +46 -0
  15. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +199 -0
  16. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +513 -0
  17. package/src/components/DatePicker/index.tsx +15 -0
  18. package/src/components/DatePicker/types.ts +49 -0
  19. package/src/components/TimePicker/TimePickerIOS.tsx +1 -1
  20. package/src/components/TimePicker/types.ts +1 -1
  21. package/src/index.ts +2 -0
  22. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +18 -0
  23. package/src/theme/components/button.ts +12 -0
  24. package/src/theme/components/datePicker.ts +11 -0
  25. package/src/theme/global/colors.ts +1 -0
  26. package/src/theme/index.ts +3 -0
  27. package/types/components/Button/StyledButton.d.ts +3 -3
  28. package/types/components/DatePicker/DatePickerAndroid.d.ts +3 -0
  29. package/types/components/DatePicker/DatePickerIOS.d.ts +3 -0
  30. package/types/components/DatePicker/StyledDatePicker.d.ts +8 -0
  31. package/types/components/DatePicker/__tests__/DatePicker.spec.d.ts +1 -0
  32. package/types/components/DatePicker/__tests__/DatePickerAndroid.spec.d.ts +1 -0
  33. package/types/components/DatePicker/__tests__/DatePickerIOS.spec.d.ts +1 -0
  34. package/types/components/DatePicker/index.d.ts +3 -0
  35. package/types/components/DatePicker/types.d.ts +48 -0
  36. package/types/components/TimePicker/types.d.ts +1 -1
  37. package/types/index.d.ts +2 -1
  38. package/types/theme/components/button.d.ts +12 -0
  39. package/types/theme/components/datePicker.d.ts +6 -0
  40. package/types/theme/global/colors.d.ts +1 -0
  41. package/types/theme/global/index.d.ts +1 -0
  42. package/types/theme/index.d.ts +2 -0
@@ -0,0 +1,513 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`DatePickerIOS renders correctly 1`] = `
4
+ <View
5
+ accessible={true}
6
+ focusable={true}
7
+ onClick={[Function]}
8
+ onResponderGrant={[Function]}
9
+ onResponderMove={[Function]}
10
+ onResponderRelease={[Function]}
11
+ onResponderTerminate={[Function]}
12
+ onResponderTerminationRequest={[Function]}
13
+ onStartShouldSetResponder={[Function]}
14
+ style={
15
+ Object {
16
+ "opacity": 1,
17
+ }
18
+ }
19
+ >
20
+ <View
21
+ pointerEvents="none"
22
+ testID="datePickerInputIOS"
23
+ >
24
+ <View
25
+ pointerEvents="auto"
26
+ style={
27
+ Array [
28
+ Object {
29
+ "marginVertical": 8,
30
+ "width": "100%",
31
+ },
32
+ undefined,
33
+ ]
34
+ }
35
+ >
36
+ <View
37
+ style={
38
+ Array [
39
+ Object {
40
+ "alignItems": "center",
41
+ "flexDirection": "row",
42
+ "padding": 16,
43
+ },
44
+ undefined,
45
+ ]
46
+ }
47
+ >
48
+ <View
49
+ style={
50
+ Array [
51
+ Object {
52
+ "borderColor": "#292a2b",
53
+ "borderRadius": 8,
54
+ "borderWidth": 1,
55
+ "bottom": 0,
56
+ "left": 0,
57
+ "position": "absolute",
58
+ "right": 0,
59
+ "top": 0,
60
+ },
61
+ undefined,
62
+ ]
63
+ }
64
+ themeVariant="filled"
65
+ />
66
+ <View
67
+ pointerEvents="none"
68
+ style={
69
+ Array [
70
+ Object {
71
+ "backgroundColor": "#ffffff",
72
+ "flexDirection": "row",
73
+ "left": 16,
74
+ "paddingHorizontal": 4,
75
+ "position": "absolute",
76
+ "top": -10,
77
+ "zIndex": 1,
78
+ },
79
+ undefined,
80
+ ]
81
+ }
82
+ >
83
+ <Text
84
+ style={
85
+ Array [
86
+ Object {
87
+ "color": "#292a2b",
88
+ "fontFamily": "BeVietnamPro-Regular",
89
+ "fontSize": 12,
90
+ "letterSpacing": 0.36,
91
+ "lineHeight": 20,
92
+ },
93
+ Array [
94
+ Object {
95
+ "color": "#292a2b",
96
+ },
97
+ undefined,
98
+ ],
99
+ ]
100
+ }
101
+ testID="input-label"
102
+ themeFontSize="small"
103
+ themeFontWeight="regular"
104
+ themeIntent="body"
105
+ themeVariant="filled"
106
+ >
107
+ Start date
108
+ </Text>
109
+ </View>
110
+ <View
111
+ style={
112
+ Array [
113
+ Object {
114
+ "alignItems": "center",
115
+ "alignSelf": "stretch",
116
+ "flexDirection": "row",
117
+ "flexGrow": 2,
118
+ },
119
+ undefined,
120
+ ]
121
+ }
122
+ >
123
+ <TextInput
124
+ accessibilityState={
125
+ Object {
126
+ "disabled": false,
127
+ }
128
+ }
129
+ editable={true}
130
+ onBlur={[Function]}
131
+ onChangeText={[Function]}
132
+ onFocus={[Function]}
133
+ style={
134
+ Array [
135
+ Object {
136
+ "alignSelf": "stretch",
137
+ "flexGrow": 2,
138
+ "fontSize": 14,
139
+ "marginHorizontal": 8,
140
+ "textAlignVertical": "center",
141
+ },
142
+ Object {
143
+ "color": "#292a2b",
144
+ },
145
+ ]
146
+ }
147
+ testID="text-input"
148
+ value="21/12/1995"
149
+ />
150
+ </View>
151
+ <HeroIcon
152
+ name="calendar-dates-outlined"
153
+ style={
154
+ Array [
155
+ Object {
156
+ "color": "#292a2b",
157
+ "fontSize": 16,
158
+ },
159
+ undefined,
160
+ ]
161
+ }
162
+ testID="input-suffix"
163
+ themeIntent="text"
164
+ themeSize="xsmall"
165
+ />
166
+ </View>
167
+ <View
168
+ style={
169
+ Array [
170
+ Object {
171
+ "paddingLeft": 16,
172
+ },
173
+ undefined,
174
+ ]
175
+ }
176
+ >
177
+ <View
178
+ style={
179
+ Array [
180
+ Object {
181
+ "flexDirection": "row",
182
+ "justifyContent": "space-between",
183
+ },
184
+ undefined,
185
+ ]
186
+ }
187
+ />
188
+ </View>
189
+ </View>
190
+ </View>
191
+ <RCTModalHostView
192
+ animationType="none"
193
+ hardwareAccelerated={false}
194
+ identifier={0}
195
+ onRequestClose={[Function]}
196
+ onStartShouldSetResponder={[Function]}
197
+ presentationStyle="overFullScreen"
198
+ style={
199
+ Object {
200
+ "position": "absolute",
201
+ }
202
+ }
203
+ transparent={true}
204
+ >
205
+ <View
206
+ collapsable={false}
207
+ style={
208
+ Array [
209
+ Object {
210
+ "flex": 1,
211
+ "left": 0,
212
+ "top": 0,
213
+ },
214
+ Object {
215
+ "backgroundColor": "transparent",
216
+ },
217
+ ]
218
+ }
219
+ >
220
+ <View
221
+ pointerEvents="box-none"
222
+ style={
223
+ Object {
224
+ "flex": 1,
225
+ }
226
+ }
227
+ >
228
+ <View
229
+ collapsable={true}
230
+ pointerEvents="box-none"
231
+ style={
232
+ Object {
233
+ "flex": 1,
234
+ }
235
+ }
236
+ >
237
+ <View
238
+ pointerEvents="box-none"
239
+ style={
240
+ Array [
241
+ Object {
242
+ "bottom": 0,
243
+ "flexDirection": "column-reverse",
244
+ "left": 0,
245
+ "position": "absolute",
246
+ "right": 0,
247
+ "top": 0,
248
+ },
249
+ undefined,
250
+ ]
251
+ }
252
+ >
253
+ <View
254
+ accessible={true}
255
+ collapsable={false}
256
+ focusable={true}
257
+ nativeID="animatedComponent"
258
+ onBlur={[Function]}
259
+ onClick={[Function]}
260
+ onFocus={[Function]}
261
+ onResponderGrant={[Function]}
262
+ onResponderMove={[Function]}
263
+ onResponderRelease={[Function]}
264
+ onResponderTerminate={[Function]}
265
+ onResponderTerminationRequest={[Function]}
266
+ onStartShouldSetResponder={[Function]}
267
+ style={
268
+ Object {
269
+ "backgroundColor": "#292a2b",
270
+ "bottom": 0,
271
+ "left": 0,
272
+ "opacity": 0.48,
273
+ "position": "absolute",
274
+ "right": 0,
275
+ "top": 0,
276
+ }
277
+ }
278
+ />
279
+ <View
280
+ collapsable={false}
281
+ nativeID="animatedComponent"
282
+ onLayout={[Function]}
283
+ style={
284
+ Object {
285
+ "backgroundColor": "#ffffff",
286
+ "borderTopLeftRadius": 16,
287
+ "borderTopRightRadius": 16,
288
+ "elevation": 10,
289
+ "maxHeight": "94%",
290
+ "shadowColor": "#292a2b",
291
+ "shadowOffset": Object {
292
+ "height": 3,
293
+ "width": 0,
294
+ },
295
+ "shadowOpacity": 0.27,
296
+ "shadowRadius": 4.65,
297
+ "transform": Array [
298
+ Object {
299
+ "scaleY": 0,
300
+ },
301
+ Object {
302
+ "translateY": 0,
303
+ },
304
+ ],
305
+ "width": "100%",
306
+ }
307
+ }
308
+ >
309
+ <View
310
+ style={
311
+ Array [
312
+ Object {
313
+ "flexDirection": "row",
314
+ "minHeight": 64,
315
+ },
316
+ undefined,
317
+ ]
318
+ }
319
+ >
320
+ <View
321
+ adjacentIcon={true}
322
+ style={
323
+ Array [
324
+ Object {
325
+ "flex": 1,
326
+ "justifyContent": "center",
327
+ "paddingLeft": 24,
328
+ "paddingRight": 0,
329
+ "paddingVertical": 8,
330
+ },
331
+ undefined,
332
+ ]
333
+ }
334
+ >
335
+ <Text
336
+ style={
337
+ Array [
338
+ Object {
339
+ "color": "#292a2b",
340
+ "fontFamily": "BeVietnamPro-SemiBold",
341
+ "fontSize": 16,
342
+ "letterSpacing": 0.48,
343
+ "lineHeight": 24,
344
+ },
345
+ undefined,
346
+ ]
347
+ }
348
+ themeFontSize="large"
349
+ themeFontWeight="semi-bold"
350
+ themeIntent="body"
351
+ >
352
+ Start date
353
+ </Text>
354
+ </View>
355
+ <View
356
+ style={
357
+ Array [
358
+ Object {
359
+ "alignItems": "center",
360
+ "justifyContent": "center",
361
+ "width": 72,
362
+ },
363
+ undefined,
364
+ ]
365
+ }
366
+ >
367
+ <View
368
+ accessible={true}
369
+ collapsable={false}
370
+ focusable={true}
371
+ nativeID="animatedComponent"
372
+ onClick={[Function]}
373
+ onResponderGrant={[Function]}
374
+ onResponderMove={[Function]}
375
+ onResponderRelease={[Function]}
376
+ onResponderTerminate={[Function]}
377
+ onResponderTerminationRequest={[Function]}
378
+ onStartShouldSetResponder={[Function]}
379
+ style={
380
+ Object {
381
+ "opacity": 1,
382
+ }
383
+ }
384
+ testID="bottom-sheet-close-icon"
385
+ >
386
+ <HeroIcon
387
+ name="cancel"
388
+ style={
389
+ Array [
390
+ Object {
391
+ "color": "#292a2b",
392
+ "fontSize": 24,
393
+ },
394
+ undefined,
395
+ ]
396
+ }
397
+ themeIntent="text"
398
+ themeSize="medium"
399
+ />
400
+ </View>
401
+ </View>
402
+ </View>
403
+ <View
404
+ style={
405
+ Array [
406
+ Object {
407
+ "borderBottomColor": "#dadbde",
408
+ "borderBottomWidth": 1,
409
+ "maxWidth": "100%",
410
+ },
411
+ undefined,
412
+ ]
413
+ }
414
+ />
415
+ <View
416
+ style={
417
+ Array [
418
+ Object {
419
+ "height": 176,
420
+ },
421
+ undefined,
422
+ ]
423
+ }
424
+ >
425
+ <Picker
426
+ display="spinner"
427
+ mode="date"
428
+ onChange={[Function]}
429
+ style={
430
+ Object {
431
+ "flex": 1,
432
+ }
433
+ }
434
+ testID="datePickerIOS"
435
+ value={1995-12-21T00:00:00.000Z}
436
+ />
437
+ </View>
438
+ <View>
439
+ <View
440
+ style={
441
+ Array [
442
+ Object {
443
+ "borderBottomColor": "#dadbde",
444
+ "borderBottomWidth": 1,
445
+ "maxWidth": "100%",
446
+ },
447
+ undefined,
448
+ ]
449
+ }
450
+ />
451
+ <View
452
+ style={
453
+ Array [
454
+ Object {
455
+ "alignItems": "center",
456
+ "flexDirection": "row",
457
+ "justifyContent": "flex-end",
458
+ "minHeight": 64,
459
+ "paddingHorizontal": 24,
460
+ "paddingVertical": 8,
461
+ },
462
+ undefined,
463
+ ]
464
+ }
465
+ >
466
+ <View
467
+ accessible={true}
468
+ collapsable={false}
469
+ focusable={true}
470
+ nativeID="animatedComponent"
471
+ onClick={[Function]}
472
+ onResponderGrant={[Function]}
473
+ onResponderMove={[Function]}
474
+ onResponderRelease={[Function]}
475
+ onResponderTerminate={[Function]}
476
+ onResponderTerminationRequest={[Function]}
477
+ onStartShouldSetResponder={[Function]}
478
+ style={
479
+ Object {
480
+ "opacity": 1,
481
+ }
482
+ }
483
+ >
484
+ <Text
485
+ style={
486
+ Array [
487
+ Object {
488
+ "color": "#7622d7",
489
+ "fontFamily": "BeVietnamPro-SemiBold",
490
+ "fontSize": 16,
491
+ "letterSpacing": 0.48,
492
+ "lineHeight": 24,
493
+ },
494
+ undefined,
495
+ ]
496
+ }
497
+ themeFontSize="large"
498
+ themeFontWeight="semi-bold"
499
+ themeIntent="primary"
500
+ >
501
+ Confirm
502
+ </Text>
503
+ </View>
504
+ </View>
505
+ </View>
506
+ </View>
507
+ </View>
508
+ </View>
509
+ </View>
510
+ </View>
511
+ </RCTModalHostView>
512
+ </View>
513
+ `;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Platform } from 'react-native';
3
+ import DatePickerAndroid from './DatePickerAndroid';
4
+ import DatePickerIOS from './DatePickerIOS';
5
+ import { DatePickerProps } from './types';
6
+
7
+ const DatePicker = (props: DatePickerProps) => {
8
+ if (Platform.OS === 'ios') {
9
+ return <DatePickerIOS {...props} />;
10
+ }
11
+
12
+ return <DatePickerAndroid {...props} />;
13
+ };
14
+
15
+ export default DatePicker;
@@ -0,0 +1,49 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+
3
+ export interface DatePickerProps {
4
+ /**
5
+ * Date picker input label.
6
+ */
7
+ label: string;
8
+ /**
9
+ * Current date value. Must be in correct default format or format provided via format prop.
10
+ */
11
+ value?: Date;
12
+ /**
13
+ * Input placeholder. Date format will be used as placeholder if not specified.
14
+ */
15
+ placeholder?: string;
16
+ /**
17
+ * Callback that is called when new value is selected.
18
+ */
19
+ onChange: (value: Date) => void;
20
+ /**
21
+ * Confirm label text. iOS only.
22
+ */
23
+ confirmLabel: string;
24
+ /**
25
+ * Date format. Default format is dd/MM/yyyy.
26
+ * Following date-fns's format (https://date-fns.org/v2.16.1/docs/format).
27
+ */
28
+ displayFormat?: string;
29
+ /**
30
+ * Whether the Date picker is disabled.
31
+ */
32
+ disabled?: boolean;
33
+ /**
34
+ * Error message to display.
35
+ */
36
+ error?: string;
37
+ /**
38
+ * Whether the value is required, if true, an asterisk will be appended to the label.
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * Addtional style.
43
+ */
44
+ style?: StyleProp<ViewStyle>;
45
+ /**
46
+ * Testing id of the component..
47
+ */
48
+ testID?: string;
49
+ }
@@ -22,7 +22,7 @@ const TimePickerIOS = ({
22
22
  style,
23
23
  testID,
24
24
  }: TimePickerProps) => {
25
- const [selectingDate, setSelectingDate] = useState<Date | null>(value);
25
+ const [selectingDate, setSelectingDate] = useState<Date | undefined>(value);
26
26
  const [open, setOpen] = useState(false);
27
27
 
28
28
  const is12Hour = displayFormat.includes('hh');
@@ -8,7 +8,7 @@ export interface TimePickerProps {
8
8
  /**
9
9
  * Current time value. Must be in correct default format or format provided via format prop.
10
10
  */
11
- value: Date | null;
11
+ value?: Date;
12
12
  /**
13
13
  * Input placeholder. Time format will be used as placeholder if not specified.
14
14
  */
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ import Card from './components/Card';
11
11
  import Collapse from './components/Collapse';
12
12
  import Checkbox from './components/Checkbox';
13
13
  import ContentNavigator from './components/ContentNavigator';
14
+ import DatePicker from './components/DatePicker';
14
15
  import Divider from './components/Divider';
15
16
  import Drawer from './components/Drawer';
16
17
  import FAB from './components/FAB';
@@ -47,6 +48,7 @@ export {
47
48
  Collapse,
48
49
  Checkbox,
49
50
  ContentNavigator,
51
+ DatePicker,
50
52
  Divider,
51
53
  Drawer,
52
54
  FAB,
@@ -145,6 +145,18 @@ Object {
145
145
  "pressedSecondary": "#d1d9fe",
146
146
  "primary": "#7622d7",
147
147
  "secondary": "#4568fb",
148
+ "underlayColors": Object {
149
+ "basic-transparent": "#c8a7ef",
150
+ "filled-danger": "#f2ae9d",
151
+ "filled-primary": "#c8a7ef",
152
+ "filled-secondary": "#d1d9fe",
153
+ "outlined-danger": "#fcebe7",
154
+ "outlined-primary": "#f1e9fb",
155
+ "outlined-secondary": "#ecf0ff",
156
+ "text-danger": "#fcebe7",
157
+ "text-primary": "#f1e9fb",
158
+ "text-secondary": "#ecf0ff",
159
+ },
148
160
  "utilityBackground": "#fafbfb",
149
161
  },
150
162
  "fontSize": Object {
@@ -214,6 +226,11 @@ Object {
214
226
  "valueHorizontalPadding": 8,
215
227
  },
216
228
  },
229
+ "datePicker": Object {
230
+ "sizes": Object {
231
+ "height": 176,
232
+ },
233
+ },
217
234
  "divider": Object {
218
235
  "borderWidths": Object {
219
236
  "default": 1,
@@ -742,6 +759,7 @@ Object {
742
759
  "primaryDark": "#a26fb0",
743
760
  "primaryLight": "#c8a7ef",
744
761
  "secondary": "#4568fb",
762
+ "secondaryBackground": "#ecf0ff",
745
763
  "secondaryLight": "#d1d9fe",
746
764
  "shadow": "#dadbde",
747
765
  "subduedText": "#727478",
@@ -48,6 +48,18 @@ const getButtonTheme = (theme: GlobalTheme) => {
48
48
  disabledBackground: theme.colors.disabledLightText,
49
49
  invertedText: theme.colors.invertedText,
50
50
  utilityBackground: theme.colors.backgroundLight,
51
+ underlayColors: {
52
+ 'filled-primary': theme.colors.primaryLight,
53
+ 'filled-secondary': theme.colors.secondaryLight,
54
+ 'filled-danger': theme.colors.dangerLight,
55
+ 'outlined-primary': theme.colors.primaryBackground,
56
+ 'outlined-secondary': theme.colors.secondaryBackground,
57
+ 'outlined-danger': theme.colors.dangerBackground,
58
+ 'text-primary': theme.colors.primaryBackground,
59
+ 'text-secondary': theme.colors.secondaryBackground,
60
+ 'text-danger': theme.colors.dangerBackground,
61
+ 'basic-transparent': theme.colors.primaryLight,
62
+ },
51
63
  };
52
64
 
53
65
  return {
@@ -0,0 +1,11 @@
1
+ import { scale } from '../../utils/scale';
2
+
3
+ const getDatePickerTheme = () => {
4
+ const sizes = {
5
+ height: scale(176),
6
+ };
7
+
8
+ return { sizes };
9
+ };
10
+
11
+ export default getDatePickerTheme;
@@ -9,6 +9,7 @@ const systemPalette = {
9
9
  primaryBackground: palette.violetLight90,
10
10
  secondary: palette.dodgerBlue,
11
11
  secondaryLight: palette.dodgerBlueLight75,
12
+ secondaryBackground: palette.dodgerBlueLight90,
12
13
  info: palette.dodgerBlue,
13
14
  infoMediumLight: mobilePalette.vodka,
14
15
  infoLight: palette.dodgerBlueLight75,