@tactics/toddle-styleguide 1.1.0 → 1.1.2

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 (24) hide show
  1. package/App.tsx +8 -0
  2. package/babel.config.js +1 -0
  3. package/jest.config.js +2 -1
  4. package/package.json +7 -5
  5. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +18 -18
  6. package/src/components/atoms/footer/footer.component.d.ts +5 -2
  7. package/src/components/atoms/footer/footer.component.tsx +13 -4
  8. package/src/components/atoms/footer/footer.preview.tsx +16 -18
  9. package/src/components/atoms/heading-components/all-caps-heading/__snapshots__/all-caps-heading.test.js.snap +8 -8
  10. package/src/components/atoms/heading-components/heading.styles.js +2 -2
  11. package/src/components/molecules/calendar-select/calendar-select.component.tsx +5 -1
  12. package/src/components/molecules/filter-tab/__snapshots__/filter-tab.test.js.snap +0 -14
  13. package/src/components/molecules/filter-tab/filter-tab.styles.js +0 -2
  14. package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.d.ts +4 -1
  15. package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.tsx +4 -1
  16. package/src/utilities/toddle-datetime/toddle-datetime.class.d.ts +19 -1
  17. package/src/utilities/toddle-datetime/toddle-datetime.class.tsx +73 -1
  18. package/src/utilities/toddle-datetime/toddle-datetime.preview.d.ts +1 -0
  19. package/src/utilities/toddle-datetime/toddle-datetime.preview.tsx +116 -0
  20. package/src/utilities/toddle-datetime/toddle-datetime.test.js +15 -0
  21. package/src/utilities/toddle-datetime/types/toddle-datetime.type.d.ts +2 -0
  22. package/src/utilities/toddle-datetime/types/toddle-datetime.type.tsx +4 -0
  23. package/src/components/atoms/footer/__snapshots__/footer.test.js.snap +0 -73
  24. package/src/components/atoms/footer/footer.test.js +0 -13
package/App.tsx CHANGED
@@ -64,6 +64,7 @@ import {LanguageButtonPreview} from './src/components/molecules/language-button/
64
64
  import {ModalPreview} from './src/components/templates/modal/modal.preview';
65
65
  import {LoadingIndicatorPreview} from './src/components/organisms/loading-indicator/loading-indicator.preview';
66
66
  import {WaveBackgroundPreview} from './src/components/molecules/wave-background/wave.preview';
67
+ import {ToddleDateTimePreview} from './src/utilities/toddle-datetime/toddle-datetime.preview';
67
68
 
68
69
  const Stack = createNativeStackNavigator();
69
70
 
@@ -245,6 +246,10 @@ const HomeScreen = ({navigation}: {navigation: any}) => {
245
246
  title="Wave background"
246
247
  onPress={() => navigation.push('wave')}
247
248
  />
249
+ <ReactBtn
250
+ title="Toddle DateTime"
251
+ onPress={() => navigation.push('toddle-datetime')}
252
+ />
248
253
  </ScrollView>
249
254
  );
250
255
  };
@@ -402,6 +407,9 @@ function App() {
402
407
  <Stack.Screen name="loading-indicator" options={{headerShown: false}}>
403
408
  {() => <LoadingIndicatorPreview />}
404
409
  </Stack.Screen>
410
+ <Stack.Screen name="toddle-datetime" options={{headerShown: false}}>
411
+ {() => <ToddleDateTimePreview />}
412
+ </Stack.Screen>
405
413
  </Stack.Navigator>
406
414
  </NavigationContainer>
407
415
  </ThemeCtx.Provider>
package/babel.config.js CHANGED
@@ -2,5 +2,6 @@ module.exports = function (api) {
2
2
  api.cache(true);
3
3
  return {
4
4
  presets: ['babel-preset-expo'],
5
+ plugins: ['react-native-reanimated/plugin'],
5
6
  };
6
7
  };
package/jest.config.js CHANGED
@@ -19,7 +19,8 @@ module.exports = async () => {
19
19
  '|native-base' +
20
20
  '|@miblanchard/react-native-slider' +
21
21
  '|react-native-svg' +
22
- '|@tactics/kinderopvang-branding)',
22
+ '|@tactics/kinderopvang-branding)' +
23
+ '|react-native-reanimated',
23
24
  ],
24
25
  };
25
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -29,9 +29,10 @@
29
29
  "@react-navigation/native-stack": "^6.9.1",
30
30
  "@react-navigation/stack": "^6.3.3",
31
31
  "@tactics/kinderopvang-branding": "1.0.3",
32
- "@types/luxon": "^3.1.0",
32
+ "@testing-library/react-native": "^11.5.3",
33
+ "@types/luxon": "^3.2.0",
33
34
  "@types/xdate": "^0.8.32",
34
- "expo": "^48.0.0",
35
+ "expo": "^48.0.8",
35
36
  "expo-font": "~11.1.1",
36
37
  "expo-linear-gradient": "~12.1.2",
37
38
  "expo-status-bar": "~1.4.4",
@@ -39,7 +40,7 @@
39
40
  "jsc-android": "^250230.2.1",
40
41
  "lottie-ios": "3.4.1",
41
42
  "lottie-react-native": "5.1.4",
42
- "luxon": "^3.2.0",
43
+ "luxon": "^3.3.0",
43
44
  "react": "18.2.0",
44
45
  "react-dom": "18.2.0",
45
46
  "react-native": "0.71.3",
@@ -47,6 +48,7 @@
47
48
  "react-native-calendars": "^1.1293.0",
48
49
  "react-native-gesture-handler": "~2.9.0",
49
50
  "react-native-picker-select": "^8.0.4",
51
+ "react-native-reanimated": "~2.14.4",
50
52
  "react-native-safe-area-context": "4.5.0",
51
53
  "react-native-screens": "~3.20.0",
52
54
  "react-native-svg": "13.4.0",
@@ -59,7 +61,7 @@
59
61
  "@babel/core": "^7.20.0",
60
62
  "@babel/preset-typescript": "^7.18.6",
61
63
  "@types/jest": "^29.2.1",
62
- "@types/luxon": "^3.1.0",
64
+ "@types/luxon": "^3.2.0",
63
65
  "@types/node": "^18.11.7",
64
66
  "@types/react": "~18.0.27",
65
67
  "@types/react-dom": "~18.0.10",
@@ -1383,7 +1383,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1383
1383
  }
1384
1384
  >
1385
1385
  <View
1386
- accessibilityLabel="today Vrijdag 10 Maart 2023 "
1386
+ accessibilityLabel=" Vrijdag 10 Maart 2023 "
1387
1387
  accessibilityRole="button"
1388
1388
  accessibilityState={
1389
1389
  {
@@ -1415,10 +1415,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1415
1415
  style={
1416
1416
  {
1417
1417
  "alignItems": "center",
1418
- "borderColor": "#7B93DB",
1419
- "borderRadius": 21,
1420
- "borderStyle": "solid",
1421
- "borderWidth": 1,
1422
1418
  "height": 42,
1423
1419
  "justifyContent": "center",
1424
1420
  "opacity": 1,
@@ -1438,9 +1434,6 @@ exports[`Test for the calendar component renders a calendar where you can select
1438
1434
  "lineHeight": 22.4,
1439
1435
  "marginTop": 4,
1440
1436
  },
1441
- {
1442
- "color": "#7B93DB",
1443
- },
1444
1437
  ]
1445
1438
  }
1446
1439
  >
@@ -1967,7 +1960,7 @@ exports[`Test for the calendar component renders a calendar where you can select
1967
1960
  }
1968
1961
  >
1969
1962
  <View
1970
- accessibilityLabel=" Vrijdag 17 Maart 2023 "
1963
+ accessibilityLabel="today Vrijdag 17 Maart 2023 "
1971
1964
  accessibilityRole="button"
1972
1965
  accessibilityState={
1973
1966
  {
@@ -1999,6 +1992,10 @@ exports[`Test for the calendar component renders a calendar where you can select
1999
1992
  style={
2000
1993
  {
2001
1994
  "alignItems": "center",
1995
+ "borderColor": "#7B93DB",
1996
+ "borderRadius": 21,
1997
+ "borderStyle": "solid",
1998
+ "borderWidth": 1,
2002
1999
  "height": 42,
2003
2000
  "justifyContent": "center",
2004
2001
  "opacity": 1,
@@ -2018,6 +2015,9 @@ exports[`Test for the calendar component renders a calendar where you can select
2018
2015
  "lineHeight": 22.4,
2019
2016
  "marginTop": 4,
2020
2017
  },
2018
+ {
2019
+ "color": "#7B93DB",
2020
+ },
2021
2021
  ]
2022
2022
  }
2023
2023
  >
@@ -4766,8 +4766,7 @@ exports[`Test for the calendar component renders a calendar where you can select
4766
4766
  }
4767
4767
  >
4768
4768
  <View
4769
- accessibilityLabel="today Vrijdag 10 Maart 2023 "
4770
- accessibilityRole="button"
4769
+ accessibilityLabel=" Vrijdag 10 Maart 2023 "
4771
4770
  accessibilityState={
4772
4771
  {
4773
4772
  "busy": undefined,
@@ -4798,10 +4797,6 @@ exports[`Test for the calendar component renders a calendar where you can select
4798
4797
  style={
4799
4798
  {
4800
4799
  "alignItems": "center",
4801
- "borderColor": "#7B93DB",
4802
- "borderRadius": 21,
4803
- "borderStyle": "solid",
4804
- "borderWidth": 1,
4805
4800
  "height": 42,
4806
4801
  "justifyContent": "center",
4807
4802
  "opacity": 1,
@@ -4822,7 +4817,7 @@ exports[`Test for the calendar component renders a calendar where you can select
4822
4817
  "marginTop": 4,
4823
4818
  },
4824
4819
  {
4825
- "color": "#7B93DB",
4820
+ "color": "#9AA5B1",
4826
4821
  },
4827
4822
  ]
4828
4823
  }
@@ -5362,7 +5357,8 @@ exports[`Test for the calendar component renders a calendar where you can select
5362
5357
  }
5363
5358
  >
5364
5359
  <View
5365
- accessibilityLabel=" Vrijdag 17 Maart 2023 "
5360
+ accessibilityLabel="today Vrijdag 17 Maart 2023 "
5361
+ accessibilityRole="button"
5366
5362
  accessibilityState={
5367
5363
  {
5368
5364
  "busy": undefined,
@@ -5393,6 +5389,10 @@ exports[`Test for the calendar component renders a calendar where you can select
5393
5389
  style={
5394
5390
  {
5395
5391
  "alignItems": "center",
5392
+ "borderColor": "#7B93DB",
5393
+ "borderRadius": 21,
5394
+ "borderStyle": "solid",
5395
+ "borderWidth": 1,
5396
5396
  "height": 42,
5397
5397
  "justifyContent": "center",
5398
5398
  "opacity": 1,
@@ -5413,7 +5413,7 @@ exports[`Test for the calendar component renders a calendar where you can select
5413
5413
  "marginTop": 4,
5414
5414
  },
5415
5415
  {
5416
- "color": "#9AA5B1",
5416
+ "color": "#7B93DB",
5417
5417
  },
5418
5418
  ]
5419
5419
  }
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ import { AnimateStyle } from 'react-native-reanimated';
2
4
  type FooterProps = {
3
- child: React.ReactNode;
5
+ children: React.ReactNode;
6
+ animatedStyle?: AnimateStyle<ViewStyle>;
4
7
  };
5
- declare const Footer: ({ child }: FooterProps) => JSX.Element;
8
+ declare const Footer: ({ children, animatedStyle }: FooterProps) => JSX.Element;
6
9
  export { Footer as Footer };
@@ -1,19 +1,28 @@
1
1
  import React from 'react';
2
2
  import {useContext} from 'react';
3
- import {View} from 'react-native';
3
+ import {ViewStyle} from 'react-native';
4
4
 
5
5
  import {ThemeCtx} from '../../../context/theme.context';
6
6
  import {Stylesheet} from './footer.styles';
7
+ import Animated, {AnimateStyle} from 'react-native-reanimated';
7
8
 
8
9
  type FooterProps = {
9
- child: React.ReactNode;
10
+ children: React.ReactNode;
11
+ animatedStyle?: AnimateStyle<ViewStyle>;
10
12
  };
11
13
 
12
- const Footer = ({child}: FooterProps) => {
14
+ const Footer = ({children, animatedStyle}: FooterProps) => {
13
15
  const context = useContext(ThemeCtx);
14
16
  const styles = Stylesheet(context);
15
17
 
16
- return <View style={styles.container}>{child}</View>;
18
+ return (
19
+ <Animated.View
20
+ style={[styles.container, animatedStyle]}
21
+ testID="footer-container"
22
+ >
23
+ {children}
24
+ </Animated.View>
25
+ );
17
26
  };
18
27
 
19
28
  export {Footer as Footer};
@@ -6,23 +6,21 @@ import {Button} from '../../molecules/button/button.component';
6
6
 
7
7
  export const FooterPreview = ({}: {}) => {
8
8
  return (
9
- <Footer
10
- child={
11
- <SplitContainer
12
- element1={
13
- <SelectLink
14
- label={'Selecteer alle'}
15
- onPress={() => console.log('selecteer alle')}
16
- />
17
- }
18
- element2={
19
- <Button
20
- label="Kies actie"
21
- onPress={() => console.log('element 2 pressed')}
22
- />
23
- }
24
- />
25
- }
26
- />
9
+ <Footer>
10
+ <SplitContainer
11
+ element1={
12
+ <SelectLink
13
+ label={'Selecteer alle'}
14
+ onPress={() => console.log('selecteer alle')}
15
+ />
16
+ }
17
+ element2={
18
+ <Button
19
+ label="Kies actie"
20
+ onPress={() => console.log('element 2 pressed')}
21
+ />
22
+ }
23
+ />
24
+ </Footer>
27
25
  );
28
26
  };
@@ -11,8 +11,8 @@ exports[`Test for the all caps heading component should render an all caps headi
11
11
  },
12
12
  {
13
13
  "fontFamily": "MontserratBold",
14
- "fontSize": 14,
15
- "lineHeight": 22.4,
14
+ "fontSize": 13,
15
+ "lineHeight": 20.4,
16
16
  },
17
17
  ],
18
18
  {
@@ -39,8 +39,8 @@ exports[`Test for the all caps heading component should render an all caps headi
39
39
  },
40
40
  {
41
41
  "fontFamily": "MontserratBold",
42
- "fontSize": 14,
43
- "lineHeight": 22.4,
42
+ "fontSize": 13,
43
+ "lineHeight": 20.4,
44
44
  },
45
45
  ],
46
46
  {
@@ -67,8 +67,8 @@ exports[`Test for the all caps heading component should render an all caps headi
67
67
  },
68
68
  {
69
69
  "fontFamily": "Montserrat",
70
- "fontSize": 14,
71
- "lineHeight": 22.4,
70
+ "fontSize": 13,
71
+ "lineHeight": 20.4,
72
72
  },
73
73
  ],
74
74
  {
@@ -95,8 +95,8 @@ exports[`Test for the all caps heading component should render an all caps headi
95
95
  },
96
96
  {
97
97
  "fontFamily": "Montserrat",
98
- "fontSize": 14,
99
- "lineHeight": 22.4,
98
+ "fontSize": 13,
99
+ "lineHeight": 20.4,
100
100
  },
101
101
  ],
102
102
  {
@@ -54,10 +54,10 @@ export const Stylesheet = (Context, bold, textColor, textAlign) =>
54
54
  },
55
55
  !bold
56
56
  ? {
57
- ...Font.regular,
57
+ ...Font.small,
58
58
  }
59
59
  : {
60
- ...Font.regularBold,
60
+ ...Font.smallBold,
61
61
  },
62
62
  ],
63
63
  });
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {useContext, useState} from 'react';
2
+ import {useContext, useEffect, useState} from 'react';
3
3
  import {ToddleDateTime} from '../../../utilities/toddle-datetime/toddle-datetime.class';
4
4
  import {ThemeCtx} from '../../../context/theme.context';
5
5
  import {Stylesheet} from './calendar-select.styles';
@@ -25,6 +25,10 @@ const CalendarSelect = ({
25
25
 
26
26
  const [visibleDate, setVisibleDate] = useState(startDate);
27
27
 
28
+ useEffect(() => {
29
+ setVisibleDate(startDate);
30
+ }, [startDate]);
31
+
28
32
  const onPressRight = () => {
29
33
  setVisibleDate(visibleDate.plus({days: 1}));
30
34
  };
@@ -96,8 +96,6 @@ exports[`Filter tab test renders a filter tab with 2 tabs 1`] = `
96
96
  {
97
97
  "maxHeight": 32,
98
98
  "overflow": "hidden",
99
- "textOverflow": "ellipsis",
100
- "whiteSpace": "nowrap",
101
99
  "width": "100%",
102
100
  },
103
101
  ]
@@ -167,8 +165,6 @@ exports[`Filter tab test renders a filter tab with 2 tabs 1`] = `
167
165
  {
168
166
  "maxHeight": 32,
169
167
  "overflow": "hidden",
170
- "textOverflow": "ellipsis",
171
- "whiteSpace": "nowrap",
172
168
  "width": "100%",
173
169
  },
174
170
  ]
@@ -220,8 +216,6 @@ exports[`Filter tab test renders a filter tab with 2 tabs 1`] = `
220
216
  {
221
217
  "maxHeight": 32,
222
218
  "overflow": "hidden",
223
- "textOverflow": "ellipsis",
224
- "whiteSpace": "nowrap",
225
219
  "width": "100%",
226
220
  },
227
221
  {
@@ -335,8 +329,6 @@ exports[`Filter tab test renders a filter tab with 3 tabs 1`] = `
335
329
  {
336
330
  "maxHeight": 32,
337
331
  "overflow": "hidden",
338
- "textOverflow": "ellipsis",
339
- "whiteSpace": "nowrap",
340
332
  "width": "100%",
341
333
  },
342
334
  ]
@@ -406,8 +398,6 @@ exports[`Filter tab test renders a filter tab with 3 tabs 1`] = `
406
398
  {
407
399
  "maxHeight": 32,
408
400
  "overflow": "hidden",
409
- "textOverflow": "ellipsis",
410
- "whiteSpace": "nowrap",
411
401
  "width": "100%",
412
402
  },
413
403
  ]
@@ -477,8 +467,6 @@ exports[`Filter tab test renders a filter tab with 3 tabs 1`] = `
477
467
  {
478
468
  "maxHeight": 32,
479
469
  "overflow": "hidden",
480
- "textOverflow": "ellipsis",
481
- "whiteSpace": "nowrap",
482
470
  "width": "100%",
483
471
  },
484
472
  ]
@@ -530,8 +518,6 @@ exports[`Filter tab test renders a filter tab with 3 tabs 1`] = `
530
518
  {
531
519
  "maxHeight": 32,
532
520
  "overflow": "hidden",
533
- "textOverflow": "ellipsis",
534
- "whiteSpace": "nowrap",
535
521
  "width": "100%",
536
522
  },
537
523
  {
@@ -54,7 +54,5 @@ export const Stylesheet = (Context, inRow, ElementWidth, ItemWidth) =>
54
54
  width: '100%',
55
55
  maxHeight: 32,
56
56
  overflow: 'hidden',
57
- whiteSpace: 'nowrap',
58
- textOverflow: 'ellipsis',
59
57
  },
60
58
  });
@@ -1,7 +1,10 @@
1
1
  export interface LocaleOptions {
2
+ /**
3
+ * @default system's locale
4
+ */
2
5
  locale?: string | undefined;
3
6
  }
4
- export interface DateTimeOptions {
7
+ export interface DateTimeOptions extends LocaleOptions {
5
8
  /**
6
9
  * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone.
7
10
  * @default local
@@ -1,8 +1,11 @@
1
1
  export interface LocaleOptions {
2
+ /**
3
+ * @default system's locale
4
+ */
2
5
  locale?: string | undefined;
3
6
  }
4
7
 
5
- export interface DateTimeOptions {
8
+ export interface DateTimeOptions extends LocaleOptions {
6
9
  /**
7
10
  * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone.
8
11
  * @default local
@@ -1,10 +1,25 @@
1
1
  import { LocaleOptions, DateTimeOptions } from './interfaces/toddle-datetime.interface';
2
2
  import { DurationLike } from './types/duration-like.type';
3
- import { DateTimeFormatOptions, DateTimeUnit } from './types/toddle-datetime.type';
3
+ import { DateTimeFormatOptions, DateTimeJSOptions, DateTimeUnit } from './types/toddle-datetime.type';
4
4
  export declare class ToddleDateTime {
5
5
  private dateTime;
6
6
  private constructor();
7
+ /**
8
+ * Create a ToddleDateTime for the current instant, in the system's time zone.
9
+ *
10
+ * Use Settings to override these default values if needed.
11
+ * @example
12
+ * ToddleDateTime.now().toISO() //~> now in the ISO format
13
+ */
7
14
  static now(): ToddleDateTime;
15
+ static local(opts?: DateTimeJSOptions): ToddleDateTime;
16
+ static local(year: number, opts?: DateTimeJSOptions): ToddleDateTime;
17
+ static local(year: number, month: number, opts?: DateTimeJSOptions): ToddleDateTime;
18
+ static local(year: number, month: number, day: number, opts?: DateTimeJSOptions): ToddleDateTime;
19
+ static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions): ToddleDateTime;
20
+ static local(year: number, month: number, day: number, hour: number, minute: number, opts?: DateTimeJSOptions): ToddleDateTime;
21
+ static local(year: number, month: number, day: number, hour: number, minute: number, second: number, opts?: DateTimeJSOptions): ToddleDateTime;
22
+ static local(year: number, month: number, day: number, hour: number, minute: number, second: number, milliseconds: number, opts?: DateTimeJSOptions): ToddleDateTime;
8
23
  static fromISO(date: string, options?: DateTimeOptions): ToddleDateTime;
9
24
  static get DATE_MED(): DateTimeFormatOptions;
10
25
  get day(): number;
@@ -12,8 +27,11 @@ export declare class ToddleDateTime {
12
27
  plus(duration: DurationLike): ToddleDateTime;
13
28
  minus(duration: DurationLike): ToddleDateTime;
14
29
  startOf(unit: DateTimeUnit): ToddleDateTime;
30
+ endOf(unit: DateTimeUnit): ToddleDateTime;
15
31
  toFormat(format: string, options?: LocaleOptions): string;
32
+ toISO(): string;
16
33
  toISODate(): string;
17
34
  toString(): string;
18
35
  toLocaleString(formatOptions?: DateTimeFormatOptions, options?: LocaleOptions): string;
36
+ timestamp(): number;
19
37
  }
@@ -8,6 +8,7 @@ import {
8
8
  import {DurationLike} from './types/duration-like.type';
9
9
  import {
10
10
  DateTimeFormatOptions,
11
+ DateTimeJSOptions,
11
12
  DateTimeUnit,
12
13
  } from './types/toddle-datetime.type';
13
14
 
@@ -19,11 +20,69 @@ export class ToddleDateTime {
19
20
  }
20
21
 
21
22
  // STATIC MEMBERS
22
-
23
+ /**
24
+ * Create a ToddleDateTime for the current instant, in the system's time zone.
25
+ *
26
+ * Use Settings to override these default values if needed.
27
+ * @example
28
+ * ToddleDateTime.now().toISO() //~> now in the ISO format
29
+ */
23
30
  static now(): ToddleDateTime {
24
31
  return new ToddleDateTime(LuxonDateTime.local());
25
32
  }
26
33
 
34
+ static local(opts?: DateTimeJSOptions): ToddleDateTime;
35
+ static local(year: number, opts?: DateTimeJSOptions): ToddleDateTime;
36
+ static local(
37
+ year: number,
38
+ month: number,
39
+ opts?: DateTimeJSOptions
40
+ ): ToddleDateTime;
41
+ static local(
42
+ year: number,
43
+ month: number,
44
+ day: number,
45
+ opts?: DateTimeJSOptions
46
+ ): ToddleDateTime;
47
+ static local(
48
+ year: number,
49
+ month: number,
50
+ day: number,
51
+ hour: number,
52
+ opts?: DateTimeJSOptions
53
+ ): ToddleDateTime;
54
+ static local(
55
+ year: number,
56
+ month: number,
57
+ day: number,
58
+ hour: number,
59
+ minute: number,
60
+ opts?: DateTimeJSOptions
61
+ ): ToddleDateTime;
62
+ static local(
63
+ year: number,
64
+ month: number,
65
+ day: number,
66
+ hour: number,
67
+ minute: number,
68
+ second: number,
69
+ opts?: DateTimeJSOptions
70
+ ): ToddleDateTime;
71
+ static local(
72
+ year: number,
73
+ month: number,
74
+ day: number,
75
+ hour: number,
76
+ minute: number,
77
+ second: number,
78
+ milliseconds: number,
79
+ opts?: DateTimeJSOptions
80
+ ): ToddleDateTime;
81
+ static local(...args: any[]): ToddleDateTime {
82
+ const dateTime = LuxonDateTime.local(...args);
83
+ return new ToddleDateTime(dateTime);
84
+ }
85
+
27
86
  static fromISO(date: string, options?: DateTimeOptions): ToddleDateTime {
28
87
  return new ToddleDateTime(LuxonDateTime.fromISO(date, options));
29
88
  }
@@ -59,12 +118,21 @@ export class ToddleDateTime {
59
118
  return this;
60
119
  }
61
120
 
121
+ endOf(unit: DateTimeUnit): ToddleDateTime {
122
+ this.dateTime = this.dateTime.endOf(unit);
123
+ return this;
124
+ }
125
+
62
126
  // OUTPUT
63
127
 
64
128
  toFormat(format: string, options?: LocaleOptions): string {
65
129
  return this.dateTime.toFormat(format, options);
66
130
  }
67
131
 
132
+ toISO(): string {
133
+ return this.dateTime.toISO();
134
+ }
135
+
68
136
  toISODate(): string {
69
137
  return this.dateTime.toISODate();
70
138
  }
@@ -79,4 +147,8 @@ export class ToddleDateTime {
79
147
  ): string {
80
148
  return this.dateTime.toLocaleString(formatOptions, options);
81
149
  }
150
+
151
+ timestamp(): number {
152
+ return this.dateTime.toUnixInteger();
153
+ }
82
154
  }
@@ -0,0 +1 @@
1
+ export declare const ToddleDateTimePreview: ({}: {}) => JSX.Element;
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import {ToddleDateTime} from './toddle-datetime.class';
3
+ import {View, ScrollView} from 'react-native';
4
+ import {Paragraph} from '../../components/atoms/paragraph-components';
5
+ import {Heading2, Heading4} from '../../components/atoms/heading-components';
6
+
7
+ export const ToddleDateTimePreview = ({}: {}) => {
8
+ const now = ToddleDateTime.now();
9
+ const fromISO = ToddleDateTime.fromISO('2016-05-25T09:08:34.123');
10
+ const fromISO2 = ToddleDateTime.fromISO('2022-03-14');
11
+ return (
12
+ <View
13
+ style={{
14
+ marginTop: 50,
15
+ alignContent: 'center',
16
+ justifyContent: 'center',
17
+ }}
18
+ >
19
+ <Heading2 bold={true} textAlign={'center'} addStyle={{marginBottom: 50}}>
20
+ ToddleDateTime
21
+ </Heading2>
22
+ <ScrollView contentContainerStyle={{padding: 16}}>
23
+ <Heading4 bold={true}>.now()</Heading4>
24
+ <Paragraph addStyle={{marginBottom: 12}}>{now.toString()}</Paragraph>
25
+
26
+ <Heading4 bold={true}>
27
+ .fromISO(date: string, options?: DateTimeOptions)
28
+ </Heading4>
29
+ <Paragraph addStyle={{marginBottom: 12}}>
30
+ From ISO
31
+ {'\n'}
32
+ {fromISO.toString()}
33
+ {'\n'}
34
+ {'\n'}
35
+ Date time in a zone with the fromISO method
36
+ {'\n'}
37
+ Europe/Brussels
38
+ {'\n'}
39
+ {ToddleDateTime.fromISO(fromISO.toString(), {
40
+ zone: 'Europe/Brussels',
41
+ }).toString()}
42
+ {'\n'}
43
+ {'\n'}
44
+ America/Los_Angeles
45
+ {'\n'}
46
+ {ToddleDateTime.fromISO(fromISO.toString(), {
47
+ zone: 'America/Los_Angeles',
48
+ }).toString()}
49
+ </Paragraph>
50
+
51
+ <Heading4 bold={true}>.local()</Heading4>
52
+ <Paragraph bold={true}>Create a local DateTime{'\n'}</Paragraph>
53
+ <Paragraph addStyle={{marginBottom: 12}}>
54
+ local now
55
+ {'\n'}
56
+ {ToddleDateTime.local().toISO()}
57
+ {'\n'}
58
+ {'\n'}
59
+ local now in US east coast time
60
+ {'\n'}
61
+ {ToddleDateTime.local({zone: 'America/New_York'}).toISO()}
62
+ {'\n'}
63
+ {'\n'}
64
+ year
65
+ {'\n'}
66
+ {ToddleDateTime.local(1989).toISO()}
67
+ {'\n'}
68
+ {'\n'}
69
+ year and month
70
+ {'\n'}
71
+ {ToddleDateTime.local(1989, 8).toISO()}
72
+ {'\n'}
73
+ {'\n'}
74
+ year, month and day with a French locale
75
+ {'\n'}
76
+ {ToddleDateTime.local(1989, 8, 9, {locale: 'fr'}).toISO()}
77
+ {'\n'}
78
+ {'\n'}
79
+ year, month, day and hour
80
+ {'\n'}
81
+ {ToddleDateTime.local(1989, 8, 9, 23).toISO()}
82
+ {'\n'}
83
+ {'\n'}
84
+ year, month, day and hour in UTC
85
+ {'\n'}
86
+ {ToddleDateTime.local(1989, 8, 9, 23, {zone: 'utc'}).toISO()}
87
+ {'\n'}
88
+ {'\n'}
89
+ year, month, day, hour and minutes
90
+ {'\n'}
91
+ {ToddleDateTime.local(1989, 8, 9, 23, 45).toISO()}
92
+ {'\n'}
93
+ {'\n'}
94
+ year, month, day, hour, minutes and seconds
95
+ {'\n'}
96
+ {ToddleDateTime.local(1989, 8, 9, 23, 45, 10).toISO()}
97
+ {'\n'}
98
+ {'\n'}
99
+ year, month, day, hour, minutes, seconds and milliseconds
100
+ {'\n'}
101
+ {ToddleDateTime.local(1989, 8, 9, 23, 45, 10, 782).toISO()}
102
+ {'\n'}
103
+ {'\n'}
104
+ </Paragraph>
105
+
106
+ <Heading4 bold={true}>.timestamp()</Heading4>
107
+ <Paragraph>
108
+ Returns the epoch milliseconds of this ToddleDateTime.
109
+ </Paragraph>
110
+ <Paragraph addStyle={{marginBottom: 12}}>
111
+ {fromISO.timestamp()}
112
+ </Paragraph>
113
+ </ScrollView>
114
+ </View>
115
+ );
116
+ };
@@ -71,6 +71,11 @@ describe('ToddleDateTime TRANSFORM methods', () => {
71
71
  dateTime.startOf('month');
72
72
  expect(dateTime.day).toEqual(1);
73
73
  });
74
+
75
+ it('endOf() changes the date time to the end of a unit', () => {
76
+ dateTime.endOf('year');
77
+ expect(dateTime.day).toEqual(31);
78
+ });
74
79
  });
75
80
 
76
81
  describe('ToddleDateTime OUTPUT methods', () => {
@@ -85,6 +90,11 @@ describe('ToddleDateTime OUTPUT methods', () => {
85
90
  expect(formattedDate).toMatch(dateTime.toFormat('yyyy-MM-dd'));
86
91
  });
87
92
 
93
+ it('toISO() formats the date time in ISO format', () => {
94
+ const formattedDate = dateTime.toISO();
95
+ expect(formattedDate).toMatch(dateTime.toISO());
96
+ });
97
+
88
98
  it('toISODate() formats the date time in ISO date format', () => {
89
99
  const formattedDate = dateTime.toISODate();
90
100
  expect(formattedDate).toMatch(dateTime.toISODate());
@@ -99,4 +109,9 @@ describe('ToddleDateTime OUTPUT methods', () => {
99
109
  const localeString = dateTime.toLocaleString();
100
110
  expect(localeString).toMatch(dateTime.toLocaleString());
101
111
  });
112
+
113
+ it('timestamp formats the time to a number', () => {
114
+ const timestamp = dateTime.timestamp();
115
+ expect(timestamp).toEqual(dateTime.timestamp());
116
+ });
102
117
  });
@@ -1,2 +1,4 @@
1
+ import { DateTimeOptions } from '../interfaces/toddle-datetime.interface';
1
2
  export type DateTimeFormatOptions = Intl.DateTimeFormatOptions;
2
3
  export type DateTimeUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
4
+ export type DateTimeJSOptions = Omit<DateTimeOptions, 'setZone'>;
@@ -1,3 +1,5 @@
1
+ import {DateTimeOptions} from '../interfaces/toddle-datetime.interface';
2
+
1
3
  export type DateTimeFormatOptions = Intl.DateTimeFormatOptions;
2
4
 
3
5
  export type DateTimeUnit =
@@ -10,3 +12,5 @@ export type DateTimeUnit =
10
12
  | 'minute'
11
13
  | 'second'
12
14
  | 'millisecond';
15
+
16
+ export type DateTimeJSOptions = Omit<DateTimeOptions, 'setZone'>;
@@ -1,73 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`test footer renders footer correctly 1`] = `
4
- <View
5
- style={
6
- {
7
- "alignItems": "center",
8
- "backgroundColor": "#F5F7FA",
9
- "borderTopColor": "#E5E8EB",
10
- "borderTopStyle": "solid",
11
- "borderTopWidth": 1,
12
- "bottom": 0,
13
- "flexDirection": "row",
14
- "height": 64,
15
- "justifyContent": "center",
16
- "position": "absolute",
17
- "width": "100%",
18
- }
19
- }
20
- >
21
- <RNSVGSvgView
22
- align="xMidYMid"
23
- bbHeight="24"
24
- bbWidth="24"
25
- fill="none"
26
- focusable={false}
27
- height={24}
28
- meetOrSlice={0}
29
- minX={0}
30
- minY={0}
31
- style={
32
- [
33
- {
34
- "backgroundColor": "transparent",
35
- "borderWidth": 0,
36
- },
37
- {
38
- "flex": 0,
39
- "height": 24,
40
- "width": 24,
41
- },
42
- ]
43
- }
44
- vbHeight={21}
45
- vbWidth={20}
46
- width={24}
47
- >
48
- <RNSVGGroup
49
- fill={null}
50
- propList={
51
- [
52
- "fill",
53
- ]
54
- }
55
- >
56
- <RNSVGPath
57
- d="M11 1.5C11 0.947715 10.5523 0.5 9.99998 0.5C9.44769 0.5 8.99998 0.947715 8.99998 1.5H11ZM8.99998 2.625C8.99998 3.17728 9.44769 3.625 9.99998 3.625C10.5523 3.625 11 3.17728 11 2.625H8.99998ZM16.5 14C15.9477 14 15.5 14.4477 15.5 15C15.5 15.5523 15.9477 16 16.5 16V14ZM18.6666 16C19.2189 16 19.6666 15.5523 19.6666 15C19.6666 14.4477 19.2189 14 18.6666 14V16ZM9.99998 15V14C9.44769 14 8.99998 14.4477 8.99998 15H9.99998ZM12.1666 16C12.7189 16 13.1666 15.5523 13.1666 15C13.1666 14.4477 12.7189 14 12.1666 14V16ZM8.99998 19.5C8.99998 20.0523 9.44769 20.5 9.99998 20.5C10.5523 20.5 11 20.0523 11 19.5H8.99998ZM11 7.125C11 6.57272 10.5523 6.125 9.99998 6.125C9.44769 6.125 8.99998 6.57272 8.99998 7.125H11ZM9.99998 10.5H8.99998C8.99998 11.0523 9.44769 11.5 9.99998 11.5V10.5ZM14.3333 18.5C13.781 18.5 13.3333 18.9477 13.3333 19.5C13.3333 20.0523 13.781 20.5 14.3333 20.5V18.5ZM18.6666 20.5C19.2189 20.5 19.6666 20.0523 19.6666 19.5C19.6666 18.9477 19.2189 18.5 18.6666 18.5V20.5ZM1.33331 9.5C0.781028 9.5 0.333313 9.94771 0.333313 10.5C0.333313 11.0523 0.781028 11.5 1.33331 11.5V9.5ZM5.66665 11.5C6.21893 11.5 6.66665 11.0523 6.66665 10.5C6.66665 9.94771 6.21893 9.5 5.66665 9.5V11.5ZM10.0108 11.5C10.5631 11.5 11.0108 11.0523 11.0108 10.5C11.0108 9.94771 10.5631 9.5 10.0108 9.5V11.5ZM14.3441 11.5C14.8964 11.5 15.3441 11.0523 15.3441 10.5C15.3441 9.94771 14.8964 9.5 14.3441 9.5V11.5ZM18.6666 9.5C18.1144 9.5 17.6666 9.94771 17.6666 10.5C17.6666 11.0523 18.1144 11.5 18.6666 11.5V9.5ZM18.6775 11.5C19.2298 11.5 19.6775 11.0523 19.6775 10.5C19.6775 9.94771 19.2298 9.5 18.6775 9.5V11.5ZM2.41665 2.5H4.58331V0.5H2.41665V2.5ZM4.66665 2.625V4.875H6.66665V2.625H4.66665ZM4.58331 5H2.41665V7H4.58331V5ZM2.33331 4.875V2.625H0.333313V4.875H2.33331ZM2.41665 5C2.40602 5 2.39043 4.9971 2.37093 4.97685C2.3508 4.95595 2.33331 4.92194 2.33331 4.875H0.333313C0.333313 6.0127 1.23082 7 2.41665 7V5ZM4.66665 4.875C4.66665 4.92194 4.64916 4.95595 4.62902 4.97685C4.60953 4.9971 4.59394 5 4.58331 5V7C5.76914 7 6.66665 6.0127 6.66665 4.875H4.66665ZM4.58331 2.5C4.59394 2.5 4.60953 2.5029 4.62902 2.52315C4.64916 2.54405 4.66665 2.57806 4.66665 2.625H6.66665C6.66665 1.4873 5.76914 0.5 4.58331 0.5V2.5ZM2.41665 0.5C1.23082 0.5 0.333313 1.4873 0.333313 2.625H2.33331C2.33331 2.57806 2.3508 2.54405 2.37093 2.52315C2.39043 2.5029 2.40602 2.5 2.41665 2.5V0.5ZM15.4166 2.5H17.5833V0.5H15.4166V2.5ZM17.6666 2.625V4.875H19.6666V2.625H17.6666ZM17.5833 5H15.4166V7H17.5833V5ZM15.3333 4.875V2.625H13.3333V4.875H15.3333ZM15.4166 5C15.406 5 15.3904 4.9971 15.3709 4.97685C15.3508 4.95595 15.3333 4.92194 15.3333 4.875H13.3333C13.3333 6.0127 14.2308 7 15.4166 7V5ZM17.6666 4.875C17.6666 4.92194 17.6492 4.95595 17.629 4.97685C17.6095 4.9971 17.5939 5 17.5833 5V7C18.7691 7 19.6666 6.0127 19.6666 4.875H17.6666ZM17.5833 2.5C17.5939 2.5 17.6095 2.5029 17.629 2.52315C17.6492 2.54405 17.6666 2.57806 17.6666 2.625H19.6666C19.6666 1.4873 18.7691 0.5 17.5833 0.5V2.5ZM15.4166 0.5C14.2308 0.5 13.3333 1.4873 13.3333 2.625H15.3333C15.3333 2.57806 15.3508 2.54405 15.3709 2.52315C15.3904 2.5029 15.406 2.5 15.4166 2.5V0.5ZM2.41665 16H4.58331V14H2.41665V16ZM4.66665 16.125V18.375H6.66665V16.125H4.66665ZM4.58331 18.5H2.41665V20.5H4.58331V18.5ZM2.33331 18.375V16.125H0.333313V18.375H2.33331ZM2.41665 18.5C2.40602 18.5 2.39043 18.4971 2.37093 18.4769C2.3508 18.4559 2.33331 18.4219 2.33331 18.375H0.333313C0.333313 19.5127 1.23082 20.5 2.41665 20.5V18.5ZM4.66665 18.375C4.66665 18.4219 4.64916 18.4559 4.62902 18.4769C4.60953 18.4971 4.59394 18.5 4.58331 18.5V20.5C5.76914 20.5 6.66665 19.5127 6.66665 18.375H4.66665ZM4.58331 16C4.59394 16 4.60953 16.0029 4.62902 16.0231C4.64916 16.0441 4.66665 16.0781 4.66665 16.125H6.66665C6.66665 14.9873 5.76914 14 4.58331 14V16ZM2.41665 14C1.23082 14 0.333313 14.9873 0.333313 16.125H2.33331C2.33331 16.0781 2.3508 16.0441 2.37093 16.0231C2.39043 16.0029 2.40602 16 2.41665 16V14ZM8.99998 1.5V2.625H11V1.5H8.99998ZM16.5 16H18.6666V14H16.5V16ZM9.99998 16H12.1666V14H9.99998V16ZM8.99998 15V19.5H11V15H8.99998ZM8.99998 7.125V10.5H11V7.125H8.99998ZM14.3333 20.5H18.6666V18.5H14.3333V20.5ZM1.33331 11.5H5.66665V9.5H1.33331V11.5ZM9.99998 11.5H10.0108V9.5H9.99998V11.5ZM18.6666 11.5H18.6775V9.5H18.6666V11.5ZM9.99998 11.5H14.3441V9.5H9.99998V11.5Z"
58
- fill={
59
- {
60
- "payload": 4283522924,
61
- "type": 0,
62
- }
63
- }
64
- propList={
65
- [
66
- "fill",
67
- ]
68
- }
69
- />
70
- </RNSVGGroup>
71
- </RNSVGSvgView>
72
- </View>
73
- `;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import renderer from 'react-test-renderer';
3
- import {Footer} from './footer.component';
4
- import {QrcodeIcon} from '../../../icons/outline/qrcode/qrcode.icon';
5
-
6
- describe('test footer', () => {
7
- it('renders footer correctly', () => {
8
- const tree = renderer
9
- .create(<Footer child={<QrcodeIcon color={'#515F6C'} />} />)
10
- .toJSON();
11
- expect(tree).toMatchSnapshot();
12
- });
13
- });