@tactics/toddle-styleguide 0.0.7 → 0.1.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 (52) hide show
  1. package/App.d.ts +2 -0
  2. package/App.tsx +44 -1
  3. package/babel.config.js +1 -1
  4. package/index.d.ts +2 -0
  5. package/index.tsx +2 -0
  6. package/jest.config.js +22 -21
  7. package/package.json +11 -1
  8. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +16 -30
  9. package/src/components/atoms/calendar/calendar.component.d.ts +3 -2
  10. package/src/components/atoms/calendar/calendar.component.tsx +14 -6
  11. package/src/components/atoms/calendar/calendar.preview.tsx +4 -5
  12. package/src/components/atoms/calendar/calendar.test.js +3 -2
  13. package/src/components/atoms/date-input/__snapshots__/date-input.test.js.snap +101 -0
  14. package/src/components/atoms/date-input/date-input.component.d.ts +7 -0
  15. package/src/components/atoms/date-input/date-input.component.tsx +24 -0
  16. package/src/components/atoms/date-input/date-input.preview.d.ts +1 -0
  17. package/src/components/atoms/date-input/date-input.preview.tsx +60 -0
  18. package/src/components/atoms/date-input/date-input.styles.d.ts +24 -0
  19. package/src/components/atoms/date-input/date-input.styles.js +27 -0
  20. package/src/components/atoms/date-input/date-input.test.js +19 -0
  21. package/src/components/atoms/day-select/components/day/day.component.d.ts +8 -0
  22. package/src/components/atoms/day-select/components/day/day.component.tsx +42 -0
  23. package/src/components/atoms/day-select/components/day/day.styles.d.ts +37 -0
  24. package/src/components/atoms/day-select/components/day/day.styles.js +41 -0
  25. package/src/components/atoms/day-select/day-select-component.d.ts +8 -0
  26. package/src/components/atoms/day-select/day-select-component.tsx +90 -0
  27. package/src/components/atoms/day-select/day-select.preview.d.ts +1 -0
  28. package/src/components/atoms/day-select/day-select.preview.tsx +18 -0
  29. package/src/components/atoms/day-select/day-select.styles.d.ts +10 -0
  30. package/src/components/atoms/day-select/day-select.styles.js +14 -0
  31. package/src/components/atoms/filter-range/__snapshots__/filter-range.test.js.snap +184 -0
  32. package/src/components/atoms/filter-range/filter-range.component.d.ts +10 -0
  33. package/src/components/atoms/filter-range/filter-range.component.tsx +66 -0
  34. package/src/components/atoms/filter-range/filter-range.preview.d.ts +1 -0
  35. package/src/components/atoms/filter-range/filter-range.preview.tsx +48 -0
  36. package/src/components/atoms/filter-range/filter-range.styles.d.ts +32 -0
  37. package/src/components/atoms/filter-range/filter-range.styles.js +35 -0
  38. package/src/components/atoms/filter-range/filter-range.test.js +20 -0
  39. package/src/components/atoms/popover/components/modal/modal.styles.js +1 -0
  40. package/src/components/atoms/popover/popover.preview.d.ts +1 -0
  41. package/src/components/atoms/popover/popover.preview.tsx +96 -93
  42. package/src/components/atoms/select-picker/__snapshots__/select-picker.test.js.snap +353 -0
  43. package/src/components/atoms/select-picker/select-picker.component.d.ts +11 -0
  44. package/src/components/atoms/select-picker/select-picker.component.tsx +70 -0
  45. package/src/components/atoms/select-picker/select-picker.preview.d.ts +1 -0
  46. package/src/components/atoms/select-picker/select-picker.preview.tsx +63 -0
  47. package/src/components/atoms/select-picker/select-picker.styles.d.ts +33 -0
  48. package/src/components/atoms/select-picker/select-picker.styles.js +38 -0
  49. package/src/components/atoms/select-picker/select-picker.test.js +31 -0
  50. package/src/theme/scale/index.d.ts +10 -10
  51. package/src/util/date.d.ts +3 -0
  52. package/src/util/date.tsx +9 -0
package/App.d.ts CHANGED
@@ -1,2 +1,4 @@
1
+ import 'intl';
2
+ import 'intl/locale-data/jsonp/en';
1
3
  declare function App(): JSX.Element;
2
4
  export default App;
package/App.tsx CHANGED
@@ -3,6 +3,10 @@ import {Button as ReactBtn, ScrollView} from 'react-native';
3
3
  import {NavigationContainer} from '@react-navigation/native';
4
4
  import {createNativeStackNavigator} from '@react-navigation/native-stack';
5
5
 
6
+ // To make luxon work for Android
7
+ import 'intl';
8
+ import 'intl/locale-data/jsonp/en';
9
+
6
10
  // Components
7
11
  import {ThemeCtx} from './src/context/theme.context';
8
12
 
@@ -23,6 +27,7 @@ import {IconOutlineWhitePreview} from './src/icons/outline/outline-white.preview
23
27
  import {IconOutlineDefaultPreview} from './src/icons/outline/outline-default.preview';
24
28
  import {IconOutlineGreyPreview} from './src/icons/outline/outline-grey.preview';
25
29
  import {TagPreview} from './src/components/atoms/tag/tag.preview';
30
+ import {PopoverPreview} from './src/components/atoms/popover/popover.preview';
26
31
  import {FilterTabPreview} from './src/components/atoms/filter-tab/filter-tab.preview';
27
32
  import {ContactItemPreview} from './src/components/atoms/contact-item/contact-item.preview';
28
33
  import {SelectListItemPreview} from './src/components/atoms/select-list-item/select-list-item-preview';
@@ -33,9 +38,13 @@ import {PressableIconPreview} from './src/components/atoms/pressable-icon/pressa
33
38
  import {FormActionPreview} from './src/components/atoms/form-actions/form-action.preview';
34
39
  import {CalendarPreview} from './src/components/atoms/calendar/calendar.preview';
35
40
  import {QuickFilterPreview} from './src/components/atoms/quick-filter/quick-filter.prevriew';
41
+ import {DateInputPreview} from './src/components/atoms/date-input/date-input.preview';
36
42
  import {TextInputPreview} from './src/components/atoms/text-input/text-input.preview';
37
43
  import {ChildListItemPreview} from './src/components/atoms/child-list-item/child-list-item.preview';
38
44
  import {TimeLinePreview} from './src/components/atoms/timeline/timeline.preview';
45
+ import {SelectPickerPreview} from './src/components/atoms/select-picker/select-picker.preview';
46
+ import {FilterRangePreview} from './src/components/atoms/filter-range/filter-range.preview';
47
+ import {DaySelectPreview} from './src/components/atoms/day-select/day-select.preview';
39
48
  import {IncrementInputPreview} from './src/components/atoms/increment-input/increment-input.preview';
40
49
  import {SwipePreview} from './src/components/atoms/swipe/swipe.preview';
41
50
  import {LogoPreview} from './src/components/atoms/logo/logo.preview';
@@ -127,6 +136,19 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
127
136
  title="formAction"
128
137
  onPress={() => navigation.push('form-action')}
129
138
  />
139
+ <ReactBtn
140
+ title="Select Picker"
141
+ onPress={() => navigation.push('select-picker')}
142
+ />
143
+ <ReactBtn title="Popover" onPress={() => navigation.push('popover')} />
144
+ <ReactBtn
145
+ title="Child list item"
146
+ onPress={() => navigation.push('child-list-item')}
147
+ />
148
+ <ReactBtn
149
+ title="Filter range"
150
+ onPress={() => navigation.push('filter-range')}
151
+ />
130
152
  <ReactBtn title="Calendar" onPress={() => navigation.push('calendar')} />
131
153
  <ReactBtn
132
154
  title="quickFilter"
@@ -138,6 +160,14 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
138
160
  />
139
161
  <ReactBtn title="swiper" onPress={() => navigation.push('swiper')} />
140
162
  <ReactBtn title="logo" onPress={() => navigation.push('logo')} />
163
+ <ReactBtn
164
+ title="Date input"
165
+ onPress={() => navigation.push('date-input')}
166
+ />
167
+ <ReactBtn
168
+ title="daySelect"
169
+ onPress={() => navigation.push('day-select')}
170
+ />
141
171
  </ScrollView>
142
172
  );
143
173
  };
@@ -202,6 +232,7 @@ function App() {
202
232
  <Stack.Screen name="select-list-item">
203
233
  {() => <SelectListItemPreview />}
204
234
  </Stack.Screen>
235
+ <Stack.Screen name="popover">{() => <PopoverPreview />}</Stack.Screen>
205
236
  <Stack.Screen name="filter tab">
206
237
  {() => <FilterTabPreview />}
207
238
  </Stack.Screen>
@@ -215,18 +246,30 @@ function App() {
215
246
  <Stack.Screen name="form-action">
216
247
  {() => <FormActionPreview />}
217
248
  </Stack.Screen>
249
+ <Stack.Screen name="select-picker">
250
+ {() => <SelectPickerPreview />}
251
+ </Stack.Screen>
218
252
  <Stack.Screen name="calendar">
219
253
  {() => <CalendarPreview />}
220
254
  </Stack.Screen>
221
255
  <Stack.Screen name="quick-filter">
222
256
  {() => <QuickFilterPreview />}
223
257
  </Stack.Screen>
224
- <Stack.Screen name="childList">
258
+ <Stack.Screen name="date-input">
259
+ {() => <DateInputPreview />}
260
+ </Stack.Screen>
261
+ <Stack.Screen name="child-list-item">
225
262
  {() => <ChildListItemPreview />}
226
263
  </Stack.Screen>
264
+ <Stack.Screen name="filter-range">
265
+ {() => <FilterRangePreview />}
266
+ </Stack.Screen>
227
267
  <Stack.Screen name="timeline">
228
268
  {() => <TimeLinePreview />}
229
269
  </Stack.Screen>
270
+ <Stack.Screen name="day-select">
271
+ {() => <DaySelectPreview />}
272
+ </Stack.Screen>
230
273
  <Stack.Screen name="increment-input">
231
274
  {() => <IncrementInputPreview />}
232
275
  </Stack.Screen>
package/babel.config.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = function(api) {
1
+ module.exports = function (api) {
2
2
  api.cache(true);
3
3
  return {
4
4
  presets: ['babel-preset-expo'],
package/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import 'intl';
2
+ import 'intl/locale-data/jsonp/en';
1
3
  import { Avatar } from './src/components/atoms/avatar/avatar.component';
2
4
  import { Button } from './src/components/atoms/button/button.component';
3
5
  import { CancelLink } from './src/components/atoms/cancel-link/cancel-link.component';
package/index.tsx CHANGED
@@ -1,5 +1,7 @@
1
1
  // Needed to run Expo
2
2
  import registerRootComponent from 'expo/build/launch/registerRootComponent';
3
+ import 'intl';
4
+ import 'intl/locale-data/jsonp/en';
3
5
 
4
6
  import App from './App';
5
7
  registerRootComponent(App);
package/jest.config.js CHANGED
@@ -1,22 +1,23 @@
1
1
  module.exports = async () => {
2
- return {
3
- verbose: true,
4
- extensionsToTreatAsEsm: ['.ts', '.tsx'],
5
- preset: "jest-expo",
6
- transformIgnorePatterns: [
7
- "node_modules/(?!((jest-)?react-native" +
8
- "|@react-native(-community)?)" +
9
- "|expo(nent)?" +
10
- "|@expo(nent)?/.*" +
11
- "|@expo-google-fonts/.*" +
12
- "|react-navigation" +
13
- "|@react-navigation/.*" +
14
- "|@unimodules/.*" +
15
- "|unimodules" +
16
- "|sentry-expo" +
17
- "|native-base" +
18
- "|react-native-svg" +
19
- "|@tactics/kinderopvang-branding)"
20
- ]
21
- };
22
- };
2
+ return {
3
+ verbose: true,
4
+ extensionsToTreatAsEsm: ['.ts', '.tsx'],
5
+ preset: 'jest-expo',
6
+ transformIgnorePatterns: [
7
+ 'node_modules/(?!((jest-)?react-native' +
8
+ '|@react-native(-community)?)' +
9
+ '|expo(nent)?' +
10
+ '|@expo(nent)?/.*' +
11
+ '|@expo-google-fonts/.*' +
12
+ '|react-navigation' +
13
+ '|@react-navigation/.*' +
14
+ '|@unimodules/.*' +
15
+ '|unimodules' +
16
+ '|sentry-expo' +
17
+ '|native-base' +
18
+ '|@miblanchard/react-native-slider' +
19
+ '|react-native-svg' +
20
+ '|@tactics/kinderopvang-branding)',
21
+ ],
22
+ };
23
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -18,25 +18,34 @@
18
18
  "dependencies": {
19
19
  "@callstack/react-theme-provider": "^3.0.8",
20
20
  "@expo/webpack-config": "^0.17.0",
21
+ "@miblanchard/react-native-slider": "^2.1.0",
22
+ "@react-native-picker/picker": "2.4.2",
21
23
  "@react-navigation/bottom-tabs": "^6.4.0",
22
24
  "@react-navigation/drawer": "^6.5.0",
23
25
  "@react-navigation/native": "^6.0.13",
24
26
  "@react-navigation/native-stack": "^6.9.1",
25
27
  "@react-navigation/stack": "^6.3.3",
26
28
  "@tactics/kinderopvang-branding": "1.0.3",
29
+ "@types/luxon": "^3.1.0",
27
30
  "@types/xdate": "^0.8.32",
28
31
  "expo": "~46.0.16",
29
32
  "expo-font": "^10.2.1",
30
33
  "expo-linear-gradient": "~11.4.0",
31
34
  "expo-status-bar": "~1.4.0",
32
35
  "formik": "^2.2.9",
36
+ "intl": "^1.2.5",
37
+ "jsc-android": "^250230.2.1",
38
+ "luxon": "^3.1.1",
33
39
  "react": "18.0.0",
34
40
  "react-dom": "18.0.0",
35
41
  "react-native": "0.69.6",
36
42
  "react-native-calendars": "^1.1292.0",
43
+ "react-native-gesture-handler": "^2.8.0",
44
+ "react-native-picker-select": "^8.0.4",
37
45
  "react-native-safe-area-context": "4.3.1",
38
46
  "react-native-screens": "~3.15.0",
39
47
  "react-native-svg": "12.3.0",
48
+ "react-native-swipe-gestures": "^1.0.5",
40
49
  "react-native-swiper": "^1.6.0",
41
50
  "react-native-web": "~0.18.7",
42
51
  "react-test-renderer": "^18.2.0"
@@ -45,6 +54,7 @@
45
54
  "@babel/core": "^7.12.9",
46
55
  "@babel/preset-typescript": "^7.18.6",
47
56
  "@types/jest": "^29.2.1",
57
+ "@types/luxon": "^3.1.0",
48
58
  "@types/node": "^18.11.7",
49
59
  "@types/react": "^18.0.25",
50
60
  "@types/react-dom": "^18.0.8",
@@ -716,7 +716,7 @@ exports[`Test for the calendar component renders a calendar where you can select
716
716
  }
717
717
  >
718
718
  <View
719
- accessibilityLabel=" Vrijdag 2 December 2022 selected You have no entries for this day "
719
+ accessibilityLabel=" Vrijdag 2 December 2022 "
720
720
  accessibilityRole="button"
721
721
  accessibilityState={
722
722
  {
@@ -736,8 +736,6 @@ exports[`Test for the calendar component renders a calendar where you can select
736
736
  style={
737
737
  {
738
738
  "alignItems": "center",
739
- "backgroundColor": "#7B93DB",
740
- "borderRadius": 21,
741
739
  "height": 42,
742
740
  "justifyContent": "center",
743
741
  "opacity": 1,
@@ -757,9 +755,6 @@ exports[`Test for the calendar component renders a calendar where you can select
757
755
  "lineHeight": 22.4,
758
756
  "marginTop": 4,
759
757
  },
760
- {
761
- "color": "#FFFFFF",
762
- },
763
758
  ]
764
759
  }
765
760
  >
@@ -2131,7 +2126,7 @@ exports[`Test for the calendar component renders a calendar where you can select
2131
2126
  }
2132
2127
  >
2133
2128
  <View
2134
- accessibilityLabel="today Donderdag 22 December 2022 "
2129
+ accessibilityLabel=" Donderdag 22 December 2022 "
2135
2130
  accessibilityRole="button"
2136
2131
  accessibilityState={
2137
2132
  {
@@ -2151,10 +2146,6 @@ exports[`Test for the calendar component renders a calendar where you can select
2151
2146
  style={
2152
2147
  {
2153
2148
  "alignItems": "center",
2154
- "borderColor": "#7B93DB",
2155
- "borderRadius": 21,
2156
- "borderStyle": "solid",
2157
- "borderWidth": 1,
2158
2149
  "height": 42,
2159
2150
  "justifyContent": "center",
2160
2151
  "opacity": 1,
@@ -2174,9 +2165,6 @@ exports[`Test for the calendar component renders a calendar where you can select
2174
2165
  "lineHeight": 22.4,
2175
2166
  "marginTop": 4,
2176
2167
  },
2177
- {
2178
- "color": "#7B93DB",
2179
- },
2180
2168
  ]
2181
2169
  }
2182
2170
  >
@@ -2424,7 +2412,7 @@ exports[`Test for the calendar component renders a calendar where you can select
2424
2412
  }
2425
2413
  >
2426
2414
  <View
2427
- accessibilityLabel=" Maandag 26 December 2022 "
2415
+ accessibilityLabel="today Maandag 26 December 2022 selected You have no entries for this day "
2428
2416
  accessibilityRole="button"
2429
2417
  accessibilityState={
2430
2418
  {
@@ -2444,6 +2432,8 @@ exports[`Test for the calendar component renders a calendar where you can select
2444
2432
  style={
2445
2433
  {
2446
2434
  "alignItems": "center",
2435
+ "backgroundColor": "#7B93DB",
2436
+ "borderRadius": 21,
2447
2437
  "height": 42,
2448
2438
  "justifyContent": "center",
2449
2439
  "opacity": 1,
@@ -2463,6 +2453,9 @@ exports[`Test for the calendar component renders a calendar where you can select
2463
2453
  "lineHeight": 22.4,
2464
2454
  "marginTop": 4,
2465
2455
  },
2456
+ {
2457
+ "color": "#FFFFFF",
2458
+ },
2466
2459
  ]
2467
2460
  }
2468
2461
  >
@@ -3622,7 +3615,7 @@ exports[`Test for the calendar component renders a calendar where you can select
3622
3615
  }
3623
3616
  >
3624
3617
  <View
3625
- accessibilityLabel=" Vrijdag 2 December 2022 selected You have no entries for this day "
3618
+ accessibilityLabel=" Vrijdag 2 December 2022 "
3626
3619
  accessibilityRole="button"
3627
3620
  accessibilityState={
3628
3621
  {
@@ -3642,8 +3635,6 @@ exports[`Test for the calendar component renders a calendar where you can select
3642
3635
  style={
3643
3636
  {
3644
3637
  "alignItems": "center",
3645
- "backgroundColor": "#7B93DB",
3646
- "borderRadius": 21,
3647
3638
  "height": 42,
3648
3639
  "justifyContent": "center",
3649
3640
  "opacity": 1,
@@ -3663,9 +3654,6 @@ exports[`Test for the calendar component renders a calendar where you can select
3663
3654
  "lineHeight": 22.4,
3664
3655
  "marginTop": 4,
3665
3656
  },
3666
- {
3667
- "color": "#FFFFFF",
3668
- },
3669
3657
  ]
3670
3658
  }
3671
3659
  >
@@ -5037,7 +5025,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5037
5025
  }
5038
5026
  >
5039
5027
  <View
5040
- accessibilityLabel="today Donderdag 22 December 2022 "
5028
+ accessibilityLabel=" Donderdag 22 December 2022 "
5041
5029
  accessibilityRole="button"
5042
5030
  accessibilityState={
5043
5031
  {
@@ -5057,10 +5045,6 @@ exports[`Test for the calendar component renders a calendar where you can select
5057
5045
  style={
5058
5046
  {
5059
5047
  "alignItems": "center",
5060
- "borderColor": "#7B93DB",
5061
- "borderRadius": 21,
5062
- "borderStyle": "solid",
5063
- "borderWidth": 1,
5064
5048
  "height": 42,
5065
5049
  "justifyContent": "center",
5066
5050
  "opacity": 1,
@@ -5080,9 +5064,6 @@ exports[`Test for the calendar component renders a calendar where you can select
5080
5064
  "lineHeight": 22.4,
5081
5065
  "marginTop": 4,
5082
5066
  },
5083
- {
5084
- "color": "#7B93DB",
5085
- },
5086
5067
  ]
5087
5068
  }
5088
5069
  >
@@ -5330,7 +5311,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5330
5311
  }
5331
5312
  >
5332
5313
  <View
5333
- accessibilityLabel=" Maandag 26 December 2022 "
5314
+ accessibilityLabel="today Maandag 26 December 2022 selected You have no entries for this day "
5334
5315
  accessibilityRole="button"
5335
5316
  accessibilityState={
5336
5317
  {
@@ -5350,6 +5331,8 @@ exports[`Test for the calendar component renders a calendar where you can select
5350
5331
  style={
5351
5332
  {
5352
5333
  "alignItems": "center",
5334
+ "backgroundColor": "#7B93DB",
5335
+ "borderRadius": 21,
5353
5336
  "height": 42,
5354
5337
  "justifyContent": "center",
5355
5338
  "opacity": 1,
@@ -5369,6 +5352,9 @@ exports[`Test for the calendar component renders a calendar where you can select
5369
5352
  "lineHeight": 22.4,
5370
5353
  "marginTop": 4,
5371
5354
  },
5355
+ {
5356
+ "color": "#FFFFFF",
5357
+ },
5372
5358
  ]
5373
5359
  }
5374
5360
  >
@@ -1,6 +1,7 @@
1
+ import { DateTime } from 'luxon';
1
2
  declare type CalendarProps = {
2
- onDayPress: (day: string) => void;
3
- selected: string;
3
+ onDayPress: (day: DateTime) => void;
4
+ selected: DateTime;
4
5
  minDate?: string;
5
6
  maxDate?: string;
6
7
  };
@@ -3,6 +3,11 @@ import {Calendar as RNCalendar, LocaleConfig} from 'react-native-calendars/src';
3
3
  import {ThemeCtx} from '../../../context/theme.context';
4
4
  import {Stylesheet} from './calendar.styles';
5
5
  import {Icon} from '../../../icons';
6
+ import {DateTime} from 'luxon';
7
+ import {
8
+ dateTimeToStringHandler,
9
+ stringToDateTimeHandler,
10
+ } from '../../../util/date';
6
11
 
7
12
  LocaleConfig.locales['nl'] = {
8
13
  monthNames: [
@@ -48,8 +53,8 @@ LocaleConfig.locales['nl'] = {
48
53
  LocaleConfig.defaultLocale = 'nl';
49
54
 
50
55
  type CalendarProps = {
51
- onDayPress: (day: string) => void;
52
- selected: string;
56
+ onDayPress: (day: DateTime) => void;
57
+ selected: DateTime;
53
58
  minDate?: string;
54
59
  maxDate?: string;
55
60
  };
@@ -62,14 +67,17 @@ export const Calendar = ({
62
67
  }: CalendarProps) => {
63
68
  const context = useContext(ThemeCtx);
64
69
  const styles = Stylesheet(context);
65
- const initDate = new Date().toISOString().slice(0, 10);
70
+ const initDate = DateTime.now().toISO().slice(0, 10);
71
+
72
+ const today = dateTimeToStringHandler(selected);
73
+
66
74
  const marked = useMemo(
67
75
  () => ({
68
- [selected]: {
76
+ [today]: {
69
77
  selected: true,
70
78
  },
71
79
  }),
72
- [selected]
80
+ [today]
73
81
  );
74
82
 
75
83
  return (
@@ -79,7 +87,7 @@ export const Calendar = ({
79
87
  minDate={minDate}
80
88
  maxDate={maxDate}
81
89
  onDayPress={(day) => {
82
- onDayPress(day.dateString);
90
+ onDayPress(stringToDateTimeHandler(day.dateString));
83
91
  }}
84
92
  markedDates={marked}
85
93
  theme={styles.custom}
@@ -1,21 +1,20 @@
1
1
  import React from 'react';
2
2
  import {Calendar} from './calendar.component';
3
3
  import {useWindowDimensions} from 'react-native';
4
+ import {DateTime} from 'luxon';
4
5
  const {View} = require('react-native');
5
6
 
6
7
  export const CalendarPreview = ({}: {}) => {
7
8
  const full = useWindowDimensions();
8
9
  const width = full.width;
9
10
 
10
- const [selectedDay, setSelectedDay] = React.useState(
11
- new Date().toISOString().slice(0, 10)
12
- );
11
+ const [selectedDay, setSelectedDay] = React.useState(DateTime.now());
12
+
13
+ console.log(selectedDay);
13
14
 
14
15
  const calendarStartDate = '2022-09-01';
15
16
  const calendarEndDate = '2023-07-31';
16
17
 
17
- console.log(selectedDay);
18
-
19
18
  return (
20
19
  <View
21
20
  style={{
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import render from 'react-test-renderer';
3
3
  import {Calendar} from './calendar.component';
4
+ import {DateTime} from 'luxon';
4
5
 
5
6
  describe('Test for the calendar component', () => {
6
7
  it('renders a calendar where you can select a day', function () {
7
8
  const tree = render
8
9
  .create(
9
10
  <Calendar
10
- selected={'2022-12-02'}
11
+ selected={new DateTime('2022-12-02')}
11
12
  onDayPress={() => console.log('pressed day')}
12
13
  />
13
14
  )
@@ -18,7 +19,7 @@ describe('Test for the calendar component', () => {
18
19
  const tree = render
19
20
  .create(
20
21
  <Calendar
21
- selected={'2022-12-02'}
22
+ selected={new DateTime('2022-12-02')}
22
23
  onDayPress={() => console.log('pressed day')}
23
24
  minDate={'2022-01-01'}
24
25
  maxDate={'2022-12-31'}
@@ -0,0 +1,101 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Test date input component renders a date input component 1`] = `
4
+ <View
5
+ accessible={true}
6
+ collapsable={false}
7
+ focusable={true}
8
+ onBlur={[Function]}
9
+ onClick={[Function]}
10
+ onFocus={[Function]}
11
+ onResponderGrant={[Function]}
12
+ onResponderMove={[Function]}
13
+ onResponderRelease={[Function]}
14
+ onResponderTerminate={[Function]}
15
+ onResponderTerminationRequest={[Function]}
16
+ onStartShouldSetResponder={[Function]}
17
+ style={
18
+ {
19
+ "alignItems": "center",
20
+ "backgroundColor": "#FFFFFF",
21
+ "borderColor": "#E5E8EB",
22
+ "borderRadius": 8,
23
+ "borderStyle": "solid",
24
+ "borderWidth": 1,
25
+ "flexDirection": "row",
26
+ "height": 44,
27
+ "justifyContent": "space-between",
28
+ "paddingBottom": 8,
29
+ "paddingLeft": 16,
30
+ "paddingRight": 16,
31
+ "paddingTop": 8,
32
+ "width": "100%",
33
+ }
34
+ }
35
+ >
36
+ <Text
37
+ style={
38
+ {
39
+ "color": "#9AA5B1",
40
+ "fontFamily": "SourceSansPro",
41
+ "fontSize": 16,
42
+ "lineHeight": 22.4,
43
+ }
44
+ }
45
+ >
46
+ 2022-12-26
47
+ </Text>
48
+ <RNSVGSvgView
49
+ align="xMidYMid"
50
+ bbHeight="28"
51
+ bbWidth="28"
52
+ fill="none"
53
+ focusable={false}
54
+ height="28"
55
+ meetOrSlice={0}
56
+ minX={0}
57
+ minY={0}
58
+ style={
59
+ [
60
+ {
61
+ "backgroundColor": "transparent",
62
+ "borderWidth": 0,
63
+ },
64
+ {
65
+ "flex": 0,
66
+ "height": 28,
67
+ "width": 28,
68
+ },
69
+ ]
70
+ }
71
+ vbHeight={27}
72
+ vbWidth={27}
73
+ width="28"
74
+ >
75
+ <RNSVGGroup
76
+ fill={null}
77
+ propList={
78
+ [
79
+ "fill",
80
+ ]
81
+ }
82
+ >
83
+ <RNSVGPath
84
+ d="M9.16667 7.875V3.375M17.8333 7.875V3.375M8.08333 12.375H18.9167M5.91667 23.625H21.0833C22.28 23.625 23.25 22.6176 23.25 21.375V7.875C23.25 6.63236 22.28 5.625 21.0833 5.625H5.91667C4.72005 5.625 3.75 6.63236 3.75 7.875V21.375C3.75 22.6176 4.72005 23.625 5.91667 23.625Z"
85
+ propList={
86
+ [
87
+ "stroke",
88
+ "strokeWidth",
89
+ "strokeLinecap",
90
+ "strokeLinejoin",
91
+ ]
92
+ }
93
+ stroke={4280232243}
94
+ strokeLinecap={1}
95
+ strokeLinejoin={1}
96
+ strokeWidth="2"
97
+ />
98
+ </RNSVGGroup>
99
+ </RNSVGSvgView>
100
+ </View>
101
+ `;
@@ -0,0 +1,7 @@
1
+ import { DateTime } from 'luxon';
2
+ declare type DateInputProps = {
3
+ onPress: () => void;
4
+ value: DateTime;
5
+ };
6
+ export declare const DateInput: ({ onPress, value }: DateInputProps) => JSX.Element;
7
+ export {};
@@ -0,0 +1,24 @@
1
+ import React, {useContext, useState} from 'react';
2
+ import {Pressable, Text, View} from 'react-native';
3
+ import {ThemeCtx} from '../../../context/theme.context';
4
+ import {Stylesheet} from './date-input.styles';
5
+ import {Icon} from '../../../icons';
6
+ import {DateTime} from 'luxon';
7
+ import {dateTimeToStringHandler} from '../../../util/date';
8
+
9
+ type DateInputProps = {
10
+ onPress: () => void;
11
+ value: DateTime;
12
+ };
13
+
14
+ export const DateInput = ({onPress, value}: DateInputProps) => {
15
+ const context = useContext(ThemeCtx);
16
+ const styles = Stylesheet(context);
17
+
18
+ return (
19
+ <Pressable onPress={onPress} style={styles.dateInputContainer}>
20
+ <Text style={styles.text}>{dateTimeToStringHandler(value)}</Text>
21
+ <Icon.Outline.Calendar color={context.colors.ui.black} />
22
+ </Pressable>
23
+ );
24
+ };
@@ -0,0 +1 @@
1
+ export declare const DateInputPreview: ({}: {}) => JSX.Element;