@tactics/toddle-styleguide 5.3.1 → 5.3.3

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 (178) hide show
  1. package/App.tsx +0 -19
  2. package/app.json +8 -4
  3. package/index.tsx +0 -4
  4. package/package.json +55 -27
  5. package/src/components/atoms/calendar/calendar.component.tsx +10 -6
  6. package/src/components/atoms/calendar/calendar.preview.tsx +4 -3
  7. package/src/components/molecules/amount/amount.component.tsx +5 -4
  8. package/src/components/molecules/calendar-select/calendar-select.component.d.ts +4 -4
  9. package/src/components/molecules/calendar-select/calendar-select.component.tsx +17 -16
  10. package/src/components/molecules/calendar-select/calendar-select.preview.tsx +16 -5
  11. package/src/components/molecules/date-input/date-input.component.d.ts +2 -2
  12. package/src/components/molecules/date-input/date-input.component.tsx +3 -3
  13. package/src/components/molecules/date-input/date-input.preview.tsx +5 -5
  14. package/src/components/molecules/day/day.component.d.ts +3 -3
  15. package/src/components/molecules/day/day.component.tsx +22 -17
  16. package/src/components/molecules/selectable-list-item/selectable-list-item.component.tsx +12 -7
  17. package/src/components/molecules/timestamp/timestamp.component.d.ts +2 -2
  18. package/src/components/molecules/timestamp/timestamp.component.tsx +12 -5
  19. package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.d.ts +2 -2
  20. package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.tsx +5 -5
  21. package/src/components/organisms/journal-entry/journal-entry.component.d.ts +3 -3
  22. package/src/components/organisms/journal-entry/journal-entry.component.tsx +7 -3
  23. package/src/components/organisms/journal-entry/journal-entry.preview.tsx +7 -3
  24. package/src/components/organisms/text-bubble/text-bubble.component.d.ts +2 -2
  25. package/src/components/organisms/text-bubble/text-bubble.component.tsx +6 -3
  26. package/src/components/organisms/text-bubble/text-bubble.preview.tsx +19 -7
  27. package/src/components/templates/popover-action/popover-action.component.tsx +9 -8
  28. package/src/icons/solid/cloud-download/cloud-download.icon.tsx +1 -1
  29. package/src/icons/solid/refresh/refresh-solid.icon.tsx +2 -2
  30. package/src/utilities/datetime/clock.class.tsx +14 -0
  31. package/src/utilities/datetime/dateonly.class.tsx +287 -0
  32. package/src/utilities/datetime/datetime.class.tsx +288 -0
  33. package/src/utilities/datetime/day.class.tsx +48 -0
  34. package/src/utilities/datetime/dayjs-config.ts +96 -0
  35. package/src/utilities/datetime/dayoftheweek.class.tsx +242 -0
  36. package/src/utilities/datetime/hour.class.tsx +60 -0
  37. package/src/utilities/datetime/locale.tsx +6 -0
  38. package/src/utilities/datetime/millisecond.class.tsx +48 -0
  39. package/src/utilities/datetime/minute.class.tsx +55 -0
  40. package/src/utilities/datetime/month.class.tsx +74 -0
  41. package/src/utilities/datetime/second.class.tsx +52 -0
  42. package/src/utilities/datetime/time.class.tsx +190 -0
  43. package/src/utilities/datetime/timezone.class.tsx +36 -0
  44. package/src/utilities/datetime/year.class.tsx +78 -0
  45. package/src/utilities/datetime/yearandmonth.class.tsx +80 -0
  46. package/src/components/atoms/background-gradient/__snapshots__/background-gradient.test.js.snap +0 -40
  47. package/src/components/atoms/background-gradient/background-gradient.test.js +0 -10
  48. package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +0 -6817
  49. package/src/components/atoms/calendar/calendar.test.js +0 -35
  50. package/src/components/atoms/check-switch/__snapshots__/check-switch.test.js.snap +0 -84
  51. package/src/components/atoms/check-switch/check-switch.test.js +0 -13
  52. package/src/components/atoms/heading-components/all-caps-heading/__snapshots__/all-caps-heading.test.js.snap +0 -113
  53. package/src/components/atoms/heading-components/all-caps-heading/all-caps-heading.test.js +0 -44
  54. package/src/components/atoms/heading-components/heading1/__snapshots__/heading1.test.js.snap +0 -121
  55. package/src/components/atoms/heading-components/heading1/heading1.test.js +0 -51
  56. package/src/components/atoms/heading-components/heading2/__snapshots__/heading2.test.js.snap +0 -121
  57. package/src/components/atoms/heading-components/heading2/heading2.test.js +0 -51
  58. package/src/components/atoms/heading-components/heading3/__snapshots__/heading3.test.js.snap +0 -121
  59. package/src/components/atoms/heading-components/heading3/heading3.test.js +0 -51
  60. package/src/components/atoms/heading-components/heading4/__snapshots__/heading4.test.js.snap +0 -121
  61. package/src/components/atoms/heading-components/heading4/heading4.test.js +0 -51
  62. package/src/components/atoms/image-bubble/__snapshots__/image-bubble.test.js.snap +0 -67
  63. package/src/components/atoms/image-bubble/image-bubble.test.js +0 -20
  64. package/src/components/atoms/increment-input/__snapshots__/increment-input.test.js.snap +0 -269
  65. package/src/components/atoms/increment-input/increment-input.test.js +0 -14
  66. package/src/components/atoms/logo/__snapshots__/logo.test.js.snap +0 -113
  67. package/src/components/atoms/logo/logo.test.js +0 -16
  68. package/src/components/atoms/paragraph-components/paragraph/__snapshots__/paragraph.test.js.snap +0 -121
  69. package/src/components/atoms/paragraph-components/paragraph/paragraph.test.js +0 -76
  70. package/src/components/atoms/paragraph-components/small-text/__snapshots__/small-text.test.js.snap +0 -121
  71. package/src/components/atoms/paragraph-components/small-text/small-text.test.js +0 -76
  72. package/src/components/atoms/paragraph-components/tiny-text/__snapshots__/tiny-text.test.js.snap +0 -121
  73. package/src/components/atoms/paragraph-components/tiny-text/tiny-text.test.js +0 -76
  74. package/src/components/atoms/quick-message/__snapshots__/quick-message.test.js.snap +0 -143
  75. package/src/components/atoms/quick-message/quick-message.test.js +0 -58
  76. package/src/components/atoms/split-container/__snapshots__/split-container.test.js.snap +0 -333
  77. package/src/components/atoms/split-container/split-container.test.js +0 -45
  78. package/src/components/atoms/text-input/__snapshots__/text-input.test.js.snap +0 -123
  79. package/src/components/atoms/text-input/text-input.test.js +0 -59
  80. package/src/components/molecules/avatar/__snapshots__/avatar.test.js.snap +0 -97
  81. package/src/components/molecules/avatar/avatar.test.js +0 -22
  82. package/src/components/molecules/blocked-message/__snapshots__/blocked-message.test.js.snap +0 -107
  83. package/src/components/molecules/blocked-message/blocked-message.test.js +0 -12
  84. package/src/components/molecules/button/__snapshots__/button.test.js.snap +0 -652
  85. package/src/components/molecules/button/button.test.js +0 -56
  86. package/src/components/molecules/calendar-select/__snapshots__/calendar-select.test.js.snap +0 -343
  87. package/src/components/molecules/calendar-select/calendar-select.test.js +0 -20
  88. package/src/components/molecules/cancel-link/__snapshots__/cancel-link.test.js.snap +0 -139
  89. package/src/components/molecules/cancel-link/cancel-link.test.js +0 -28
  90. package/src/components/molecules/checkbox/__snapshots__/checkbox.test.js.snap +0 -176
  91. package/src/components/molecules/checkbox/checkbox.test.js +0 -30
  92. package/src/components/molecules/contact-address/__snapshots__/contact-address.test.js.snap +0 -113
  93. package/src/components/molecules/contact-address/contact-address.test.js +0 -18
  94. package/src/components/molecules/contact-role/__snapshots__/contact-role.test.js.snap +0 -113
  95. package/src/components/molecules/contact-role/contact-role.test.js +0 -18
  96. package/src/components/molecules/date-input/__snapshots__/date-input.test.js.snap +0 -140
  97. package/src/components/molecules/date-input/date-input.test.js +0 -23
  98. package/src/components/molecules/day/__snapshots__/day.test.js.snap +0 -263
  99. package/src/components/molecules/day/day.test.js +0 -37
  100. package/src/components/molecules/default-select/__snapshots__/default-select.test.js.snap +0 -140
  101. package/src/components/molecules/default-select/default-select.test.js +0 -17
  102. package/src/components/molecules/department_logo/__snapshots__/department-logo.test.js.snap +0 -27
  103. package/src/components/molecules/department_logo/department-logo.test.js +0 -12
  104. package/src/components/molecules/failed-to-send/__snapshots__/failed-bubble.test.js.snap +0 -386
  105. package/src/components/molecules/failed-to-send/failed-bubble.test.js +0 -75
  106. package/src/components/molecules/filter-range/__snapshots__/filter-range.test.js.snap +0 -208
  107. package/src/components/molecules/filter-range/filter-range.test.js +0 -20
  108. package/src/components/molecules/filter-tab/__snapshots__/filter-tab.test.js.snap +0 -536
  109. package/src/components/molecules/filter-tab/filter-tab.test.js +0 -42
  110. package/src/components/molecules/info/__snapshots__/info.test.js.snap +0 -64
  111. package/src/components/molecules/info/info.test.js +0 -18
  112. package/src/components/molecules/language-button/__snapshots__/language-button.test.js.snap +0 -129
  113. package/src/components/molecules/language-button/language-button.test.js +0 -29
  114. package/src/components/molecules/message-input/__snapshots__/message-input.test.js.snap +0 -611
  115. package/src/components/molecules/message-input/message-input.test.js +0 -63
  116. package/src/components/molecules/more-info-button/__snapshots__/more-info-button.test.js.snap +0 -133
  117. package/src/components/molecules/more-info-button/more-info-button.test.js +0 -29
  118. package/src/components/molecules/password-input/__snapshots__/password-input.test.js.snap +0 -504
  119. package/src/components/molecules/password-input/password-input.test.js +0 -46
  120. package/src/components/molecules/pill/__snapshots__/pill.test.js.snap +0 -226
  121. package/src/components/molecules/pill/pill.test.js +0 -42
  122. package/src/components/molecules/pressable-icon/__snapshots__/pressable-icon.test.js.snap +0 -460
  123. package/src/components/molecules/pressable-icon/pressable-icon.test.js +0 -51
  124. package/src/components/molecules/quick-filter/__snapshots__/quick-filter.test.js.snap +0 -557
  125. package/src/components/molecules/quick-filter/quick-filter.test.js +0 -134
  126. package/src/components/molecules/search-input/__snapshots__/search.test.js.snap +0 -145
  127. package/src/components/molecules/search-input/search.test.js +0 -22
  128. package/src/components/molecules/select-link/__snapshots__/select-link.test.js.snap +0 -70
  129. package/src/components/molecules/select-link/select-link.test.js +0 -17
  130. package/src/components/molecules/select-list-item/__snapshots__/select-list-item.test.js.snap +0 -762
  131. package/src/components/molecules/select-list-item/select-list-item.test.js +0 -38
  132. package/src/components/molecules/select-picker/__snapshots__/select-picker.test.js.snap +0 -407
  133. package/src/components/molecules/select-picker/select-picker.test.js +0 -31
  134. package/src/components/molecules/send-bubble/__snapshots__/send-text-bubble.test.js.snap +0 -1979
  135. package/src/components/molecules/send-bubble/send-text-bubble.test.js +0 -156
  136. package/src/components/molecules/snackbar/__snapshots__/snackbar.test.js.snap +0 -557
  137. package/src/components/molecules/snackbar/snackbar.test.js +0 -35
  138. package/src/components/molecules/swipe/__snapshots__/swipe.test.js.snap +0 -340
  139. package/src/components/molecules/swipe/swipe.test.js +0 -46
  140. package/src/components/molecules/tag/__snapshots__/tag.test.js.snap +0 -139
  141. package/src/components/molecules/tag/tag.test.js +0 -34
  142. package/src/components/molecules/time-picker/__snapshots__/time-picker.test.js.snap +0 -2221
  143. package/src/components/molecules/time-picker/time-picker.test.js +0 -18
  144. package/src/components/molecules/time-tracker/__snapshots__/time-tracker.test.js.snap +0 -266
  145. package/src/components/molecules/time-tracker/time-tracker.test.js +0 -36
  146. package/src/components/molecules/timeline/__snapshots__/timeline.test.js.snap +0 -257
  147. package/src/components/molecules/timeline/timeline.test.js +0 -18
  148. package/src/components/molecules/timestamp/__snapshots__/timestamp.test.js.snap +0 -28
  149. package/src/components/molecules/timestamp/timestamp.test.js +0 -16
  150. package/src/components/molecules/wave-background/__snapshots__/wave.test.js.snap +0 -173
  151. package/src/components/molecules/wave-background/wave.test.js +0 -25
  152. package/src/components/molecules/wide-button/__snapshots__/wide-button.test.js.snap +0 -269
  153. package/src/components/molecules/wide-button/wide-button.test.js +0 -30
  154. package/src/components/organisms/child-list-item/__snapshots__/child-list-item.test.js.snap +0 -1040
  155. package/src/components/organisms/child-list-item/child-list-item.test.js +0 -75
  156. package/src/components/organisms/contact-item/__snapshots__/contact-item.test.js.snap +0 -404
  157. package/src/components/organisms/contact-item/contact-item.test.js +0 -22
  158. package/src/components/organisms/loading-indicator/__snapshots__/loading-indicator.test.js.snap +0 -474
  159. package/src/components/organisms/loading-indicator/loading-indicator.test.js +0 -41
  160. package/src/components/organisms/my-child-list-item/__snapshots__/my-child-list-item.test.js.snap +0 -293
  161. package/src/components/organisms/my-child-list-item/my-child-list-item.test.js +0 -23
  162. package/src/components/organisms/person-info-card/__snapshots__/person-info-card.test.js.snap +0 -709
  163. package/src/components/organisms/person-info-card/person-info-card.test.js +0 -85
  164. package/src/components/organisms/text-bubble/__snapshots__/text-bubble.test.js.snap +0 -3046
  165. package/src/components/organisms/text-bubble/text-bubble.test.js +0 -144
  166. package/src/utilities/toddle-datetime/interfaces/duration.interface.d.ts +0 -22
  167. package/src/utilities/toddle-datetime/interfaces/duration.interface.tsx +0 -23
  168. package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.d.ts +0 -22
  169. package/src/utilities/toddle-datetime/interfaces/toddle-datetime.interface.tsx +0 -25
  170. package/src/utilities/toddle-datetime/toddle-datetime.class.d.ts +0 -50
  171. package/src/utilities/toddle-datetime/toddle-datetime.class.tsx +0 -206
  172. package/src/utilities/toddle-datetime/toddle-datetime.preview.d.ts +0 -2
  173. package/src/utilities/toddle-datetime/toddle-datetime.preview.tsx +0 -160
  174. package/src/utilities/toddle-datetime/toddle-datetime.test.js +0 -127
  175. package/src/utilities/toddle-datetime/types/duration.type.d.ts +0 -4
  176. package/src/utilities/toddle-datetime/types/duration.type.tsx +0 -6
  177. package/src/utilities/toddle-datetime/types/toddle-datetime.type.d.ts +0 -5
  178. package/src/utilities/toddle-datetime/types/toddle-datetime.type.tsx +0 -23
@@ -1,144 +0,0 @@
1
- import React from 'react';
2
- import renderer from 'react-test-renderer';
3
- import {TextBubble} from './text-bubble.component';
4
- import {ToddleDateTime} from '../../../utilities/toddle-datetime/toddle-datetime.class';
5
-
6
- describe('test text-bubble', () => {
7
- const testDate = ToddleDateTime.fromISO('2016-05-25T09:08:34.123', {
8
- locale: 'en-GB',
9
- });
10
-
11
- it('given the visualState is ERROR return a red colored text-bubble AND white text', () => {
12
- const tree = renderer
13
- .create(
14
- <TextBubble
15
- id={'umhf34'}
16
- visualState="ERROR"
17
- bubbleAlignment="SENT"
18
- text="TEST color"
19
- timestamp={testDate}
20
- onFail={() => alert('resend the message')}
21
- onDelete={() => alert('delete the message')}
22
- onEdit={() => alert('edit the message')}
23
- sendOrReceived={true}
24
- />
25
- )
26
- .toJSON();
27
-
28
- expect(tree).toMatchSnapshot();
29
- });
30
- it('given the visualState is WARNING return an orange colored text-bubble AND white text', () => {
31
- const tree = renderer
32
- .create(
33
- <TextBubble
34
- id={'2383'}
35
- visualState="WARNING"
36
- bubbleAlignment="SENT"
37
- text="TEST color"
38
- timestamp={testDate}
39
- onFail={() => alert('resend the message')}
40
- onDelete={() => alert('delete the message')}
41
- onEdit={() => alert('edit the message')}
42
- sendOrReceived={true}
43
- />
44
- )
45
- .toJSON();
46
-
47
- expect(tree).toMatchSnapshot();
48
- });
49
- it('given the visualState is DEFAULT return a light-blue colored text-bubble AND dark green text', () => {
50
- const tree = renderer
51
- .create(
52
- <TextBubble
53
- id={'986'}
54
- visualState="DEFAULT"
55
- bubbleAlignment="SENT"
56
- text="TEST color"
57
- timestamp={testDate}
58
- onFail={() => alert('resend the message')}
59
- onDelete={() => alert('delete the message')}
60
- onEdit={() => alert('edit the message')}
61
- sendOrReceived={true}
62
- />
63
- )
64
- .toJSON();
65
-
66
- expect(tree).toMatchSnapshot();
67
- });
68
- it('given the bubbleAlignment is SENT return a text-bubble with right-bottom tip', () => {
69
- const tree = renderer
70
- .create(
71
- <TextBubble
72
- id={'30'}
73
- visualState="DEFAULT"
74
- bubbleAlignment="SENT"
75
- text="TEST Bubble"
76
- timestamp={testDate}
77
- onFail={() => alert('resend the message')}
78
- onDelete={() => alert('delete the message')}
79
- onEdit={() => alert('edit the message')}
80
- sendOrReceived={true}
81
- />
82
- )
83
- .toJSON();
84
-
85
- expect(tree).toMatchSnapshot();
86
- });
87
- it('given the visualState is RECEIVE return a text-bubble with left-bottom tip', () => {
88
- const tree = renderer
89
- .create(
90
- <TextBubble
91
- id={'12'}
92
- visualState="DEFAULT"
93
- bubbleAlignment="RECEIVE"
94
- text="TEST Bubble"
95
- timestamp={testDate}
96
- onFail={() => alert('resend the message')}
97
- onDelete={() => alert('delete the message')}
98
- onEdit={() => alert('edit the message')}
99
- sendOrReceived={true}
100
- />
101
- )
102
- .toJSON();
103
-
104
- expect(tree).toMatchSnapshot();
105
- });
106
- it('given the visualState is RECEIVE return a textBubble with left-bottom tip', () => {
107
- const tree = renderer
108
- .create(
109
- <TextBubble
110
- id={'2'}
111
- visualState="DEFAULT"
112
- bubbleAlignment="RECEIVE"
113
- text="TEST Bubble"
114
- timestamp={testDate}
115
- onFail={() => alert('resend the message')}
116
- onDelete={() => alert('delete the message')}
117
- onEdit={() => alert('edit the message')}
118
- sendOrReceived={true}
119
- />
120
- )
121
- .toJSON();
122
-
123
- expect(tree).toMatchSnapshot();
124
- });
125
- it('return a text bubble, that will be send, but does not get send due to an error. It will show the failed text bubble', () => {
126
- const tree = renderer
127
- .create(
128
- <TextBubble
129
- id={'5'}
130
- visualState="DEFAULT"
131
- bubbleAlignment="SENT"
132
- text="TEST Bubble"
133
- timestamp={testDate}
134
- onFail={() => alert('resend the message')}
135
- onDelete={() => alert('delete the message')}
136
- onEdit={() => alert('edit the message')}
137
- sendOrReceived={false}
138
- />
139
- )
140
- .toJSON();
141
-
142
- expect(tree).toMatchSnapshot();
143
- });
144
- });
@@ -1,22 +0,0 @@
1
- export interface DurationObjectUnits {
2
- years?: number | undefined;
3
- quarters?: number | undefined;
4
- months?: number | undefined;
5
- weeks?: number | undefined;
6
- days?: number | undefined;
7
- hours?: number | undefined;
8
- minutes?: number | undefined;
9
- seconds?: number | undefined;
10
- milliseconds?: number | undefined;
11
- }
12
- export interface DurationLikeObject extends DurationObjectUnits {
13
- year?: number | undefined;
14
- quarter?: number | undefined;
15
- month?: number | undefined;
16
- week?: number | undefined;
17
- day?: number | undefined;
18
- hour?: number | undefined;
19
- minute?: number | undefined;
20
- second?: number | undefined;
21
- millisecond?: number | undefined;
22
- }
@@ -1,23 +0,0 @@
1
- export interface DurationObjectUnits {
2
- years?: number | undefined;
3
- quarters?: number | undefined;
4
- months?: number | undefined;
5
- weeks?: number | undefined;
6
- days?: number | undefined;
7
- hours?: number | undefined;
8
- minutes?: number | undefined;
9
- seconds?: number | undefined;
10
- milliseconds?: number | undefined;
11
- }
12
-
13
- export interface DurationLikeObject extends DurationObjectUnits {
14
- year?: number | undefined;
15
- quarter?: number | undefined;
16
- month?: number | undefined;
17
- week?: number | undefined;
18
- day?: number | undefined;
19
- hour?: number | undefined;
20
- minute?: number | undefined;
21
- second?: number | undefined;
22
- millisecond?: number | undefined;
23
- }
@@ -1,22 +0,0 @@
1
- import { ConversionAccuracy } from '../types/toddle-datetime.type';
2
- export interface LocaleOptions {
3
- /**
4
- * @default system's locale
5
- */
6
- locale?: string | undefined;
7
- }
8
- export interface DateTimeOptions extends LocaleOptions {
9
- /**
10
- * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone.
11
- * @default local
12
- */
13
- zone?: string | undefined;
14
- /**
15
- * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one.
16
- * @default false
17
- */
18
- setZone?: boolean | undefined;
19
- }
20
- export interface DiffOptions {
21
- conversionAccuracy?: ConversionAccuracy | undefined;
22
- }
@@ -1,25 +0,0 @@
1
- import {ConversionAccuracy} from '../types/toddle-datetime.type';
2
-
3
- export interface LocaleOptions {
4
- /**
5
- * @default system's locale
6
- */
7
- locale?: string | undefined;
8
- }
9
-
10
- export interface DateTimeOptions extends LocaleOptions {
11
- /**
12
- * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone.
13
- * @default local
14
- */
15
- zone?: string | undefined;
16
- /**
17
- * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one.
18
- * @default false
19
- */
20
- setZone?: boolean | undefined;
21
- }
22
-
23
- export interface DiffOptions {
24
- conversionAccuracy?: ConversionAccuracy | undefined;
25
- }
@@ -1,50 +0,0 @@
1
- import { Duration as LuxonDuration } from 'luxon';
2
- import { LocaleOptions, DateTimeOptions, DiffOptions } from './interfaces/toddle-datetime.interface';
3
- import { DurationLike, DurationUnits } from './types/duration.type';
4
- import { DateTimeFormatOptions, DateTimeJSOptions, DateTimeUnit } from './types/toddle-datetime.type';
5
- import { DurationObjectUnits } from './interfaces/duration.interface';
6
- export declare class Duration {
7
- private duration;
8
- constructor(duration: LuxonDuration);
9
- toObject(): DurationObjectUnits;
10
- }
11
- export declare class ToddleDateTime {
12
- private dateTime;
13
- private constructor();
14
- /**
15
- * Create a ToddleDateTime for the current instant, in the system's time zone.
16
- *
17
- * Use Settings to override these default values if needed.
18
- * @example
19
- * ToddleDateTime.now().toISO() //~> now in the ISO format
20
- */
21
- static now(): ToddleDateTime;
22
- static local(opts?: DateTimeJSOptions): ToddleDateTime;
23
- static local(year: number, opts?: DateTimeJSOptions): ToddleDateTime;
24
- static local(year: number, month: number, opts?: DateTimeJSOptions): ToddleDateTime;
25
- static local(year: number, month: number, day: number, opts?: DateTimeJSOptions): ToddleDateTime;
26
- static local(year: number, month: number, day: number, hour: number, opts?: DateTimeJSOptions): ToddleDateTime;
27
- static local(year: number, month: number, day: number, hour: number, minute: number, opts?: DateTimeJSOptions): ToddleDateTime;
28
- static local(year: number, month: number, day: number, hour: number, minute: number, second: number, opts?: DateTimeJSOptions): ToddleDateTime;
29
- static local(year: number, month: number, day: number, hour: number, minute: number, second: number, milliseconds: number, opts?: DateTimeJSOptions): ToddleDateTime;
30
- static fromISO(date: string, options?: DateTimeOptions): ToddleDateTime;
31
- static fromSeconds(seconds: number, options?: DateTimeJSOptions): ToddleDateTime;
32
- static get DATE_MED(): DateTimeFormatOptions;
33
- get hour(): number;
34
- get minute(): number;
35
- get second(): number;
36
- get millisecond(): number;
37
- get day(): number;
38
- get weekdayShort(): string;
39
- plus(duration: DurationLike): ToddleDateTime;
40
- minus(duration: DurationLike): ToddleDateTime;
41
- startOf(unit: DateTimeUnit): ToddleDateTime;
42
- endOf(unit: DateTimeUnit): ToddleDateTime;
43
- toFormat(format: string, options?: LocaleOptions): string;
44
- toISO(): string | null;
45
- toISODate(): string | null;
46
- toString(): string;
47
- toLocaleString(formatOptions?: DateTimeFormatOptions, options?: LocaleOptions): string;
48
- timestamp(): number;
49
- diff(otherDateTime: ToddleDateTime, unit?: DurationUnits, options?: DiffOptions): Duration;
50
- }
@@ -1,206 +0,0 @@
1
- import {DateTime as LuxonDateTime, Duration as LuxonDuration} from 'luxon';
2
-
3
- import {
4
- LocaleOptions,
5
- DateTimeOptions,
6
- DiffOptions,
7
- } from './interfaces/toddle-datetime.interface';
8
-
9
- import {DurationLike, DurationUnits} from './types/duration.type';
10
- import {
11
- DateTimeFormatOptions,
12
- DateTimeJSOptions,
13
- DateTimeUnit,
14
- } from './types/toddle-datetime.type';
15
- import {DurationObjectUnits} from './interfaces/duration.interface';
16
-
17
- export class Duration {
18
- private duration: LuxonDuration;
19
-
20
- constructor(duration: LuxonDuration) {
21
- this.duration = duration;
22
- }
23
-
24
- toObject(): DurationObjectUnits {
25
- return this.duration.toObject();
26
- }
27
- }
28
-
29
- export class ToddleDateTime {
30
- private dateTime: LuxonDateTime;
31
-
32
- private constructor(dateTime?: LuxonDateTime) {
33
- this.dateTime = dateTime || LuxonDateTime.local();
34
- }
35
-
36
- // STATIC MEMBERS
37
- /**
38
- * Create a ToddleDateTime for the current instant, in the system's time zone.
39
- *
40
- * Use Settings to override these default values if needed.
41
- * @example
42
- * ToddleDateTime.now().toISO() //~> now in the ISO format
43
- */
44
- static now(): ToddleDateTime {
45
- return new ToddleDateTime(LuxonDateTime.local());
46
- }
47
-
48
- static local(opts?: DateTimeJSOptions): ToddleDateTime;
49
- static local(year: number, opts?: DateTimeJSOptions): ToddleDateTime;
50
- static local(
51
- year: number,
52
- month: number,
53
- opts?: DateTimeJSOptions
54
- ): ToddleDateTime;
55
- static local(
56
- year: number,
57
- month: number,
58
- day: number,
59
- opts?: DateTimeJSOptions
60
- ): ToddleDateTime;
61
- static local(
62
- year: number,
63
- month: number,
64
- day: number,
65
- hour: number,
66
- opts?: DateTimeJSOptions
67
- ): ToddleDateTime;
68
- static local(
69
- year: number,
70
- month: number,
71
- day: number,
72
- hour: number,
73
- minute: number,
74
- opts?: DateTimeJSOptions
75
- ): ToddleDateTime;
76
- static local(
77
- year: number,
78
- month: number,
79
- day: number,
80
- hour: number,
81
- minute: number,
82
- second: number,
83
- opts?: DateTimeJSOptions
84
- ): ToddleDateTime;
85
- static local(
86
- year: number,
87
- month: number,
88
- day: number,
89
- hour: number,
90
- minute: number,
91
- second: number,
92
- milliseconds: number,
93
- opts?: DateTimeJSOptions
94
- ): ToddleDateTime;
95
- static local(...args: any[]): ToddleDateTime {
96
- const dateTime = LuxonDateTime.local(...args);
97
- return new ToddleDateTime(dateTime);
98
- }
99
-
100
- static fromISO(date: string, options?: DateTimeOptions): ToddleDateTime {
101
- return new ToddleDateTime(LuxonDateTime.fromISO(date, options));
102
- }
103
-
104
- static fromSeconds(
105
- seconds: number,
106
- options?: DateTimeJSOptions
107
- ): ToddleDateTime {
108
- return new ToddleDateTime(LuxonDateTime.fromSeconds(seconds, options));
109
- }
110
-
111
- // FORMAT PRESETS
112
-
113
- static get DATE_MED(): DateTimeFormatOptions {
114
- return LuxonDateTime.DATE_MED;
115
- }
116
-
117
- // GET
118
-
119
- get hour(): number {
120
- return this.dateTime.hour;
121
- }
122
-
123
- get minute(): number {
124
- return this.dateTime.minute;
125
- }
126
-
127
- get second(): number {
128
- return this.dateTime.second;
129
- }
130
-
131
- get millisecond(): number {
132
- return this.dateTime.millisecond;
133
- }
134
-
135
- get day(): number {
136
- return this.dateTime.day;
137
- }
138
-
139
- get weekdayShort(): string {
140
- return this.dateTime.toFormat('EEE');
141
- }
142
-
143
- // TRANSFORM
144
-
145
- plus(duration: DurationLike): ToddleDateTime {
146
- return new ToddleDateTime(this.dateTime.plus(duration));
147
- }
148
-
149
- minus(duration: DurationLike): ToddleDateTime {
150
- return new ToddleDateTime(this.dateTime.minus(duration));
151
- }
152
-
153
- startOf(unit: DateTimeUnit): ToddleDateTime {
154
- this.dateTime = this.dateTime.startOf(unit);
155
- return this;
156
- }
157
-
158
- endOf(unit: DateTimeUnit): ToddleDateTime {
159
- this.dateTime = this.dateTime.endOf(unit);
160
- return this;
161
- }
162
-
163
- // OUTPUT
164
-
165
- toFormat(format: string, options?: LocaleOptions): string {
166
- return this.dateTime.toFormat(format, options);
167
- }
168
-
169
- toISO(): string | null {
170
- return this.dateTime.toISO();
171
- }
172
-
173
- toISODate(): string | null {
174
- return this.dateTime.toISODate();
175
- }
176
-
177
- toString(): string {
178
- return this.dateTime.toString();
179
- }
180
-
181
- toLocaleString(
182
- formatOptions?: DateTimeFormatOptions,
183
- options?: LocaleOptions
184
- ): string {
185
- return this.dateTime.toLocaleString(formatOptions, options);
186
- }
187
-
188
- timestamp(): number {
189
- return this.dateTime.toUnixInteger();
190
- }
191
-
192
- // COMPARE
193
-
194
- diff(
195
- otherDateTime: ToddleDateTime,
196
- unit?: DurationUnits,
197
- options?: DiffOptions
198
- ): Duration {
199
- const luxonDuration = this.dateTime.diff(
200
- otherDateTime.dateTime,
201
- unit,
202
- options
203
- );
204
- return new Duration(luxonDuration);
205
- }
206
- }
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ToddleDateTimePreview: ({}: {}) => React.JSX.Element;
@@ -1,160 +0,0 @@
1
- import React from 'react';
2
- import {ToddleDateTime} from './toddle-datetime.class';
3
- import {ScrollView, View} 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 timestamp = 1688729520;
11
-
12
- return (
13
- <View
14
- style={{
15
- marginTop: 24,
16
- alignContent: 'center',
17
- justifyContent: 'center',
18
- paddingBottom: 100,
19
- }}
20
- >
21
- <Heading2 bold={true} textAlign={'center'} addStyle={{marginBottom: 50}}>
22
- ToddleDateTime
23
- </Heading2>
24
- <Heading4 addStyle={{paddingHorizontal: 16, marginBottom: 24}}>
25
- ToddleDateTime is a wrapper around Luxon, and provides less
26
- functionality. This can and or will expand through time. You can find
27
- the implemented methods below:
28
- </Heading4>
29
- <ScrollView contentContainerStyle={{padding: 16}}>
30
- <Heading4 bold={true}>.now()</Heading4>
31
- <Paragraph addStyle={{marginBottom: 12}}>
32
- Create a DateTime for the current instant, in the system's time zone.
33
- </Paragraph>
34
-
35
- <Heading4 bold={true}>
36
- .fromISO(date: string, options?: DateTimeOptions)
37
- </Heading4>
38
- <Paragraph addStyle={{marginBottom: 12}}>
39
- Create a ToddleDateTime from an ISO 8601 string
40
- </Paragraph>
41
-
42
- <Heading4 bold={true}>.local()</Heading4>
43
- <Paragraph addStyle={{marginBottom: 12}}>
44
- Create a local ToddleDateTime
45
- </Paragraph>
46
-
47
- <Heading4 bold={true}>.timestamp()</Heading4>
48
- <Paragraph>
49
- Returns the epoch milliseconds of this ToddleDateTime.
50
- </Paragraph>
51
- <Paragraph addStyle={{marginBottom: 12}}>
52
- {fromISO.timestamp()}
53
- </Paragraph>
54
-
55
- <Heading4 bold={true}>.fromSeconds(seconds, options?)</Heading4>
56
- <Paragraph addStyle={{marginBottom: 12}}>
57
- Create a ToddleDateTime from a number of seconds since the epoch
58
- (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
59
- </Paragraph>
60
-
61
- <Heading4 bold={true}>.DATE_MED()</Heading4>
62
- <Paragraph addStyle={{marginBottom: 12}}>
63
- ToddleDateTime.toLocaleString format like 'Oct 14, 1983'
64
- </Paragraph>
65
-
66
- <Heading4 bold={true}>.hour()</Heading4>
67
- <Paragraph addStyle={{marginBottom: 12}}>
68
- Get the hour of the day (0-23)
69
- </Paragraph>
70
-
71
- <Heading4 bold={true}>.minute()</Heading4>
72
- <Paragraph addStyle={{marginBottom: 12}}>
73
- Get the minute of the hour (0-59).
74
- </Paragraph>
75
-
76
- <Heading4 bold={true}>.second()</Heading4>
77
- <Paragraph addStyle={{marginBottom: 12}}>
78
- Get the second of the minute (0-59).
79
- </Paragraph>
80
-
81
- <Heading4 bold={true}>.millisecond()</Heading4>
82
- <Paragraph addStyle={{marginBottom: 12}}>
83
- Get the millisecond of the second (0-999).
84
- </Paragraph>
85
-
86
- <Heading4 bold={true}>.day()</Heading4>
87
- <Paragraph addStyle={{marginBottom: 12}}>
88
- Get the day of the month (1-30ish).
89
- </Paragraph>
90
-
91
- <Heading4 bold={true}>.weekdayShort()</Heading4>
92
- <Paragraph addStyle={{marginBottom: 12}}>
93
- Get the human readable short weekday, such as 'Mon'. Defaults to the
94
- system's locale if no locale has been specified
95
- </Paragraph>
96
-
97
- <Heading4 bold={true}>.plus(duration)</Heading4>
98
- <Paragraph addStyle={{marginBottom: 12}}>
99
- {`Adding hours, minutes, seconds, or milliseconds increases the timestamp by the right number of milliseconds. Adding days, months, or years shifts the calendar, accounting for DSTs and leap years along the way. Thus, dt.plus({ hours: 24 }) may result in a different time than dt.plus({ days: 1 }) if there's a DST shift in between.`}
100
- </Paragraph>
101
-
102
- <Heading4 bold={true}>.minus(duration)</Heading4>
103
- <Paragraph addStyle={{marginBottom: 12}}>
104
- See ToddleDateTime plus()
105
- </Paragraph>
106
-
107
- <Heading4 bold={true}>.startOf(unit)</Heading4>
108
- <Paragraph addStyle={{marginBottom: 12}}>
109
- "Set" this ToddleDateTime to the beginning of the given unit.
110
- </Paragraph>
111
-
112
- <Heading4 bold={true}>.endOf(unit)</Heading4>
113
- <Paragraph addStyle={{marginBottom: 12}}>
114
- "Set" this ToddleDateTime to the end (meaning the last millisecond) of
115
- a unit of time
116
- </Paragraph>
117
-
118
- <Heading4 bold={true}>.toFormat(format, options?)</Heading4>
119
- <Paragraph addStyle={{marginBottom: 12}}>
120
- Returns a string representation of this ToddleDateTime formatted
121
- according to the specified format string.
122
- </Paragraph>
123
-
124
- <Heading4 bold={true}>.toISO()</Heading4>
125
- <Paragraph addStyle={{marginBottom: 12}}>
126
- Returns an ISO 8601-compliant string representation of this
127
- ToddleDateTime
128
- </Paragraph>
129
-
130
- <Heading4 bold={true}>.toISODate()</Heading4>
131
- <Paragraph addStyle={{marginBottom: 12}}>
132
- Returns an ISO 8601-compliant string representation of this
133
- ToddleDateTime's date component
134
- </Paragraph>
135
-
136
- <Heading4 bold={true}>.toString()</Heading4>
137
- <Paragraph addStyle={{marginBottom: 12}}>
138
- Returns a string representation of this DateTime appropriate for
139
- debugging
140
- </Paragraph>
141
-
142
- <Heading4 bold={true}>
143
- .toLocaleString(formatOptions?, options?)
144
- </Heading4>
145
- <Paragraph addStyle={{marginBottom: 12}}>
146
- Returns a localized string representing this date.
147
- </Paragraph>
148
-
149
- <Heading4 bold={true}>.timestamp()</Heading4>
150
- <Paragraph addStyle={{marginBottom: 12}}>
151
- Returns the epoch seconds (as a whole number) of this ToddleDateTime.{' '}
152
- </Paragraph>
153
- <Heading4 bold={true}>.diff(otherDateTime, unit?, options?)</Heading4>
154
- <Paragraph addStyle={{marginBottom: 12}}>
155
- Return the difference between two ToddleDateTimes as a Duration.
156
- </Paragraph>
157
- </ScrollView>
158
- </View>
159
- );
160
- };