@chayns-components/date 5.0.0-beta.920 → 5.0.0-beta.922
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/calendar/Calendar.js +17 -17
- package/lib/cjs/components/calendar/Calendar.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js +1 -0
- package/lib/cjs/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +19 -21
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +3 -3
- package/lib/cjs/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +9 -11
- package/lib/cjs/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js +2 -2
- package/lib/cjs/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/cjs/components/date-info/DateInfo.js.map +1 -1
- package/lib/cjs/hooks/useDateInfo.js +27 -72
- package/lib/cjs/hooks/useDateInfo.js.map +1 -1
- package/lib/cjs/index.js +130 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types/dateinfo.js +2 -0
- package/lib/cjs/types/dateinfo.js.map +1 -0
- package/lib/cjs/utils/calendar.js +12 -9
- package/lib/cjs/utils/calendar.js.map +1 -1
- package/lib/cjs/utils/date.js +114 -0
- package/lib/cjs/utils/date.js.map +1 -0
- package/lib/cjs/utils/dateInfo.js +99 -344
- package/lib/cjs/utils/dateInfo.js.map +1 -1
- package/lib/esm/components/calendar/Calendar.js +4 -4
- package/lib/esm/components/calendar/Calendar.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js +1 -0
- package/lib/esm/components/calendar/month-wrapper/MonthWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/Month.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js +2 -4
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/DayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/day-wrapper/day/Day.js.map +1 -1
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js +8 -10
- package/lib/esm/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.js.map +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js +1 -1
- package/lib/esm/components/calendar/month-year-pickers/MonthYearPickers.js.map +1 -1
- package/lib/esm/components/date-info/DateInfo.js.map +1 -1
- package/lib/esm/hooks/useDateInfo.js +28 -73
- package/lib/esm/hooks/useDateInfo.js.map +1 -1
- package/lib/esm/index.js +10 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types/dateinfo.js +2 -0
- package/lib/esm/types/dateinfo.js.map +1 -0
- package/lib/esm/utils/calendar.js +4 -3
- package/lib/esm/utils/calendar.js.map +1 -1
- package/lib/esm/utils/date.js +89 -0
- package/lib/esm/utils/date.js.map +1 -0
- package/lib/esm/utils/dateInfo.js +98 -339
- package/lib/esm/utils/dateInfo.js.map +1 -1
- package/lib/types/components/calendar/Calendar.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/MonthWrapper.styles.d.ts +1 -1
- package/lib/types/components/calendar/month-wrapper/month/Month.d.ts +2 -2
- package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts +2 -2
- package/lib/types/components/calendar/month-year-pickers/MonthYearPickers.d.ts +2 -2
- package/lib/types/components/date-info/DateInfo.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/OpeningInputs.styles.d.ts +1 -1
- package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts +1 -1
- package/lib/types/hooks/useDateInfo.d.ts +1 -34
- package/lib/types/index.d.ts +6 -4
- package/lib/types/types/dateinfo.d.ts +34 -0
- package/lib/types/utils/calendar.d.ts +2 -2
- package/lib/types/utils/date.d.ts +27 -0
- package/lib/types/utils/dateInfo.d.ts +10 -51
- package/package.json +3 -4
- package/lib/cjs/constants/dateInfo.js +0 -639
- package/lib/cjs/constants/dateInfo.js.map +0 -1
- package/lib/esm/constants/dateInfo.js +0 -633
- package/lib/esm/constants/dateInfo.js.map +0 -1
- package/lib/types/constants/dateInfo.d.ts +0 -23
|
@@ -1,362 +1,121 @@
|
|
|
1
|
-
import { getLanguage
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { TIME_TYPE_STRINGS } from '../constants/dateInfo';
|
|
5
|
-
export const getLanguage = () => {
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
7
|
-
switch (getChaynsLanguage().translation || getChaynsLanguage().site) {
|
|
8
|
-
case 'en':
|
|
9
|
-
return enGB;
|
|
10
|
-
case 'nl':
|
|
11
|
-
return nl;
|
|
12
|
-
case 'fr':
|
|
13
|
-
return fr;
|
|
14
|
-
case 'it':
|
|
15
|
-
return it;
|
|
16
|
-
case 'pl':
|
|
17
|
-
return pl;
|
|
18
|
-
case 'pt':
|
|
19
|
-
return pt;
|
|
20
|
-
case 'es':
|
|
21
|
-
return es;
|
|
22
|
-
case 'tr':
|
|
23
|
-
return tr;
|
|
24
|
-
case 'uk':
|
|
25
|
-
return uk;
|
|
26
|
-
default:
|
|
27
|
-
return de;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const getTimeString = _ref => {
|
|
31
|
-
let {
|
|
32
|
-
language,
|
|
33
|
-
isMorning
|
|
34
|
-
} = _ref;
|
|
35
|
-
switch (language) {
|
|
36
|
-
case 'en-GB':
|
|
37
|
-
case 'pt':
|
|
38
|
-
return isMorning ? 'AM' : 'PM';
|
|
39
|
-
case 'nl':
|
|
40
|
-
return 'uur';
|
|
41
|
-
case 'fr':
|
|
42
|
-
return 'heures';
|
|
43
|
-
case 'de':
|
|
44
|
-
return 'Uhr';
|
|
45
|
-
case 'es':
|
|
46
|
-
return 'h';
|
|
47
|
-
default:
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
export const getYearFormat = _ref2 => {
|
|
1
|
+
import { getLanguage, Language } from 'chayns-api';
|
|
2
|
+
import { isCurrentYear, isMorning, isToday, isTomorrow, isYesterday } from "./date";
|
|
3
|
+
export const getDateInfo = _ref => {
|
|
52
4
|
let {
|
|
53
5
|
date,
|
|
54
|
-
shouldShowYear
|
|
55
|
-
|
|
56
|
-
return typeof shouldShowYear === 'boolean' && !shouldShowYear || isThisYear(date) ? '' : ' yyyy';
|
|
57
|
-
};
|
|
58
|
-
export const getMonthFormat = _ref3 => {
|
|
59
|
-
let {
|
|
60
|
-
shouldUseShortText
|
|
61
|
-
} = _ref3;
|
|
62
|
-
if (shouldUseShortText) {
|
|
63
|
-
return 'LLL.';
|
|
64
|
-
}
|
|
65
|
-
return 'LLLL';
|
|
66
|
-
};
|
|
67
|
-
export const getFormattedDayOfWeek = _ref4 => {
|
|
68
|
-
let {
|
|
69
|
-
shouldShowRelativeDayOfWeek,
|
|
6
|
+
shouldShowYear,
|
|
7
|
+
shouldShowTime,
|
|
70
8
|
shouldShowDayOfWeek,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
9
|
+
shouldShowRelativeDayOfWeek,
|
|
10
|
+
shouldUseShortText
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
active: language
|
|
14
|
+
} = getLanguage();
|
|
15
|
+
let dayPart = '';
|
|
78
16
|
if (shouldShowRelativeDayOfWeek) {
|
|
17
|
+
const rtf = new Intl.RelativeTimeFormat(language, {
|
|
18
|
+
numeric: 'auto'
|
|
19
|
+
});
|
|
79
20
|
if (isToday(date)) {
|
|
80
|
-
|
|
81
|
-
case 'en-GB':
|
|
82
|
-
return 'Today, ';
|
|
83
|
-
case 'nl':
|
|
84
|
-
return 'Vandaag, ';
|
|
85
|
-
case 'fr':
|
|
86
|
-
return "Aujourd'hui, ";
|
|
87
|
-
case 'it':
|
|
88
|
-
return 'Oggi, ';
|
|
89
|
-
case 'pl':
|
|
90
|
-
return 'Dzisiaj, ';
|
|
91
|
-
case 'pt':
|
|
92
|
-
return 'Hoje, ';
|
|
93
|
-
case 'es':
|
|
94
|
-
return 'Hoy, ';
|
|
95
|
-
case 'tr':
|
|
96
|
-
return 'Bugün, ';
|
|
97
|
-
case 'uk':
|
|
98
|
-
return 'Сьогодні, ';
|
|
99
|
-
default:
|
|
100
|
-
return 'Heute, ';
|
|
101
|
-
}
|
|
21
|
+
dayPart = capitalizeFirstLetter(rtf.format(0, 'day'));
|
|
102
22
|
}
|
|
103
23
|
if (isTomorrow(date)) {
|
|
104
|
-
|
|
105
|
-
case 'en-GB':
|
|
106
|
-
return 'Tomorrow, ';
|
|
107
|
-
case 'nl':
|
|
108
|
-
return 'Morgen, ';
|
|
109
|
-
case 'fr':
|
|
110
|
-
return 'Demain, ';
|
|
111
|
-
case 'it':
|
|
112
|
-
return 'Domani, ';
|
|
113
|
-
case 'pl':
|
|
114
|
-
return 'Jutro, ';
|
|
115
|
-
case 'pt':
|
|
116
|
-
return 'Amanhã, ';
|
|
117
|
-
case 'es':
|
|
118
|
-
return 'Mañana, ';
|
|
119
|
-
case 'tr':
|
|
120
|
-
return 'Yarın, ';
|
|
121
|
-
case 'uk':
|
|
122
|
-
return 'Завтра, ';
|
|
123
|
-
default:
|
|
124
|
-
return 'Morgen, ';
|
|
125
|
-
}
|
|
24
|
+
dayPart = capitalizeFirstLetter(rtf.format(1, 'day'));
|
|
126
25
|
}
|
|
127
26
|
if (isYesterday(date)) {
|
|
128
|
-
|
|
129
|
-
case 'en-GB':
|
|
130
|
-
return 'Yesterday, ';
|
|
131
|
-
case 'nl':
|
|
132
|
-
return 'Gisteren, ';
|
|
133
|
-
case 'fr':
|
|
134
|
-
return 'Hier, ';
|
|
135
|
-
case 'it':
|
|
136
|
-
return 'Ieri, ';
|
|
137
|
-
case 'pl':
|
|
138
|
-
return 'Wczoraj, ';
|
|
139
|
-
case 'pt':
|
|
140
|
-
return 'Ontem, ';
|
|
141
|
-
case 'es':
|
|
142
|
-
return 'Ayer, ';
|
|
143
|
-
case 'tr':
|
|
144
|
-
return 'Dün, ';
|
|
145
|
-
case 'uk':
|
|
146
|
-
return 'Вчора, ';
|
|
147
|
-
default:
|
|
148
|
-
return 'Gestern, ';
|
|
149
|
-
}
|
|
27
|
+
dayPart = capitalizeFirstLetter(rtf.format(-1, 'day'));
|
|
150
28
|
}
|
|
151
29
|
}
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
30
|
+
if (!dayPart && shouldShowDayOfWeek) {
|
|
31
|
+
dayPart = date.toLocaleDateString(language, {
|
|
32
|
+
weekday: shouldUseShortText ? 'short' : 'long'
|
|
155
33
|
});
|
|
156
34
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
shouldShowTime,
|
|
164
|
-
date,
|
|
165
|
-
language
|
|
166
|
-
} = _ref5;
|
|
167
|
-
if (!shouldShowTime) {
|
|
168
|
-
return '';
|
|
35
|
+
const dateParts = {
|
|
36
|
+
day: '2-digit',
|
|
37
|
+
month: shouldUseShortText ? 'short' : 'long'
|
|
38
|
+
};
|
|
39
|
+
if (shouldShowYear && !isCurrentYear(date)) {
|
|
40
|
+
dateParts.year = 'numeric';
|
|
169
41
|
}
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
42
|
+
const timeParts = {};
|
|
43
|
+
if (shouldShowTime) {
|
|
44
|
+
timeParts.hour = '2-digit';
|
|
45
|
+
timeParts.minute = '2-digit';
|
|
173
46
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
47
|
+
let formattedTime = '';
|
|
48
|
+
if (Object.keys(timeParts).length > 0) {
|
|
49
|
+
formattedTime = `, ${date.toLocaleTimeString(language, {
|
|
50
|
+
...timeParts
|
|
51
|
+
})}`;
|
|
52
|
+
}
|
|
53
|
+
const hourWord = getTimeString({
|
|
54
|
+
language,
|
|
55
|
+
date
|
|
56
|
+
});
|
|
57
|
+
formattedTime += shouldShowTime ? ` ${hourWord}` : '';
|
|
58
|
+
const formattedDate = `${date.toLocaleDateString(language, dateParts)}${formattedTime}`;
|
|
59
|
+
return `${dayPart}${dayPart ? ', ' : ''}${formattedDate}`;
|
|
182
60
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
TimeType[TimeType["Minutes"] = 1] = "Minutes";
|
|
186
|
-
TimeType[TimeType["Hours"] = 2] = "Hours";
|
|
187
|
-
TimeType[TimeType["Days"] = 3] = "Days";
|
|
188
|
-
TimeType[TimeType["Weeks"] = 4] = "Weeks";
|
|
189
|
-
TimeType[TimeType["Months"] = 5] = "Months";
|
|
190
|
-
TimeType[TimeType["Years"] = 6] = "Years";
|
|
191
|
-
return TimeType;
|
|
192
|
-
}({});
|
|
193
|
-
export const getTimeTypeStrings = language => TIME_TYPE_STRINGS[language === 'en-GB' ? 'en' : language];
|
|
194
|
-
export const getTimeTillNow = _ref6 => {
|
|
61
|
+
const capitalizeFirstLetter = text => text.charAt(0).toUpperCase() + text.slice(1);
|
|
62
|
+
export const getTimeTillNow = _ref2 => {
|
|
195
63
|
let {
|
|
196
64
|
date,
|
|
197
65
|
currentDate,
|
|
198
|
-
language
|
|
199
|
-
} =
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
isPast: true
|
|
223
|
-
}, language)}
|
|
224
|
-
${minutes > 0 ? `${getTimeTypeStrings(language.code ?? 'de')?.and ?? ''} ${minutes} ${getFormattedPastTimeString({
|
|
225
|
-
value: minutes,
|
|
226
|
-
type: TimeType.Minutes,
|
|
227
|
-
isPast: true
|
|
228
|
-
}, language)}` : ''}`;
|
|
229
|
-
case elapsedMilliseconds < 604800000:
|
|
230
|
-
time.value = Math.floor(elapsedMilliseconds / 86400000);
|
|
231
|
-
time.type = TimeType.Days;
|
|
232
|
-
break;
|
|
233
|
-
case elapsedMilliseconds < 2592000000:
|
|
234
|
-
time.value = Math.floor(elapsedMilliseconds / 604800000);
|
|
235
|
-
time.type = TimeType.Weeks;
|
|
236
|
-
break;
|
|
237
|
-
case elapsedMilliseconds < 31536000000:
|
|
238
|
-
time.value = Math.floor(elapsedMilliseconds / 2592000000);
|
|
239
|
-
time.type = TimeType.Months;
|
|
240
|
-
break;
|
|
241
|
-
default:
|
|
242
|
-
time.value = Math.floor(elapsedMilliseconds / 31536000000);
|
|
243
|
-
time.type = TimeType.Years;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
return `${time.value} ${getFormattedPastTimeString(time, language)}`;
|
|
247
|
-
}
|
|
248
|
-
const remainingMilliseconds = date.getTime() - currentDate.getTime();
|
|
249
|
-
switch (true) {
|
|
250
|
-
case remainingMilliseconds < 60000:
|
|
251
|
-
time.value = Math.floor(remainingMilliseconds / 1000);
|
|
252
|
-
time.type = TimeType.Seconds;
|
|
253
|
-
break;
|
|
254
|
-
case remainingMilliseconds < 3600000:
|
|
255
|
-
time.value = Math.floor(remainingMilliseconds / 60000);
|
|
256
|
-
time.type = TimeType.Minutes;
|
|
257
|
-
break;
|
|
258
|
-
case remainingMilliseconds < 86400000:
|
|
259
|
-
const hours = Math.floor(remainingMilliseconds / 3600000);
|
|
260
|
-
const minutes = Math.floor(remainingMilliseconds % 3600000 / 60000);
|
|
261
|
-
return `${hours} ${getFormattedFutureTimeString({
|
|
262
|
-
value: hours,
|
|
263
|
-
type: TimeType.Hours,
|
|
264
|
-
isPast: false
|
|
265
|
-
}, language)}
|
|
266
|
-
${minutes > 0 ? `${getTimeTypeStrings(language.code ?? 'de')?.and ?? ''} ${minutes} ${getFormattedFutureTimeString({
|
|
267
|
-
value: minutes,
|
|
268
|
-
type: TimeType.Minutes,
|
|
269
|
-
isPast: false
|
|
270
|
-
}, language)}` : ''}`;
|
|
271
|
-
case remainingMilliseconds < 604800000:
|
|
272
|
-
time.value = Math.floor(remainingMilliseconds / 86400000);
|
|
273
|
-
time.type = TimeType.Days;
|
|
274
|
-
break;
|
|
275
|
-
case remainingMilliseconds < 2592000000:
|
|
276
|
-
time.value = Math.floor(remainingMilliseconds / 604800000);
|
|
277
|
-
time.type = TimeType.Weeks;
|
|
278
|
-
break;
|
|
279
|
-
case remainingMilliseconds < 31536000000:
|
|
280
|
-
time.value = Math.floor(remainingMilliseconds / 2592000000);
|
|
281
|
-
time.type = TimeType.Months;
|
|
282
|
-
break;
|
|
283
|
-
default:
|
|
284
|
-
time.value = Math.floor(remainingMilliseconds / 31536000000);
|
|
285
|
-
time.type = TimeType.Years;
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
return `${time.value} ${getFormattedFutureTimeString(time, language)}`;
|
|
289
|
-
};
|
|
290
|
-
export const getFormattedPastTimeString = (time, language) => {
|
|
291
|
-
const {
|
|
292
|
-
value,
|
|
293
|
-
type
|
|
294
|
-
} = time;
|
|
295
|
-
const timeTypeStrings = getTimeTypeStrings(language.code ?? 'de');
|
|
296
|
-
const isSingular = value === 1;
|
|
297
|
-
if (!timeTypeStrings) {
|
|
298
|
-
return '';
|
|
299
|
-
}
|
|
66
|
+
language = Language.English
|
|
67
|
+
} = _ref2;
|
|
68
|
+
const diffInSeconds = Math.floor((currentDate.getTime() - date.getTime()) / 1000);
|
|
69
|
+
const isPast = diffInSeconds > 0;
|
|
70
|
+
const units = [{
|
|
71
|
+
label: 'year',
|
|
72
|
+
seconds: 31536000
|
|
73
|
+
}, {
|
|
74
|
+
label: 'month',
|
|
75
|
+
seconds: 2592000
|
|
76
|
+
}, {
|
|
77
|
+
label: 'day',
|
|
78
|
+
seconds: 86400
|
|
79
|
+
}, {
|
|
80
|
+
label: 'hour',
|
|
81
|
+
seconds: 3600
|
|
82
|
+
}, {
|
|
83
|
+
label: 'minute',
|
|
84
|
+
seconds: 60
|
|
85
|
+
}, {
|
|
86
|
+
label: 'second',
|
|
87
|
+
seconds: 1
|
|
88
|
+
}];
|
|
89
|
+
const absDiff = Math.abs(diffInSeconds);
|
|
300
90
|
const {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
case type === TimeType.Minutes:
|
|
313
|
-
return isSingular ? minutes.singular : minutes.plural;
|
|
314
|
-
case type === TimeType.Hours:
|
|
315
|
-
return isSingular ? hours.singular : hours.plural;
|
|
316
|
-
case type === TimeType.Days:
|
|
317
|
-
return isSingular ? days.singular : days.plural;
|
|
318
|
-
case type === TimeType.Weeks:
|
|
319
|
-
return isSingular ? weeks.singular : weeks.plural;
|
|
320
|
-
case type === TimeType.Months:
|
|
321
|
-
return isSingular ? months.singular : months.plural;
|
|
322
|
-
default:
|
|
323
|
-
return isSingular ? years.singular : years.plural;
|
|
324
|
-
}
|
|
91
|
+
label,
|
|
92
|
+
seconds
|
|
93
|
+
} = units.find(u => absDiff >= u.seconds) || {
|
|
94
|
+
label: 'second',
|
|
95
|
+
seconds: 1
|
|
96
|
+
};
|
|
97
|
+
const count = Math.floor(absDiff / seconds);
|
|
98
|
+
const formatter = new Intl.RelativeTimeFormat(language, {
|
|
99
|
+
numeric: 'auto'
|
|
100
|
+
});
|
|
101
|
+
return formatter.format(isPast ? -count : count, label);
|
|
325
102
|
};
|
|
326
|
-
export const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
} =
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
hours
|
|
344
|
-
} = timeTypeStrings.future;
|
|
345
|
-
switch (true) {
|
|
346
|
-
case type === TimeType.Seconds:
|
|
347
|
-
return isSingular ? seconds.singular : seconds.plural;
|
|
348
|
-
case type === TimeType.Minutes:
|
|
349
|
-
return isSingular ? minutes.singular : minutes.plural;
|
|
350
|
-
case type === TimeType.Hours:
|
|
351
|
-
return isSingular ? hours.singular : hours.plural;
|
|
352
|
-
case type === TimeType.Days:
|
|
353
|
-
return isSingular ? days.singular : days.plural;
|
|
354
|
-
case type === TimeType.Weeks:
|
|
355
|
-
return isSingular ? weeks.singular : weeks.plural;
|
|
356
|
-
case type === TimeType.Months:
|
|
357
|
-
return isSingular ? months.singular : months.plural;
|
|
358
|
-
default:
|
|
359
|
-
return isSingular ? years.singular : years.plural;
|
|
360
|
-
}
|
|
103
|
+
export const getTimeString = _ref3 => {
|
|
104
|
+
let {
|
|
105
|
+
language,
|
|
106
|
+
date
|
|
107
|
+
} = _ref3;
|
|
108
|
+
const map = {
|
|
109
|
+
'nl': 'uur',
|
|
110
|
+
'fr': 'heures',
|
|
111
|
+
'de': 'Uhr',
|
|
112
|
+
'es': 'horas',
|
|
113
|
+
'it': 'ore',
|
|
114
|
+
'pt': 'horas',
|
|
115
|
+
'pl': 'godzina',
|
|
116
|
+
'tr': 'saat',
|
|
117
|
+
'uk': 'година'
|
|
118
|
+
};
|
|
119
|
+
return map[language ?? ''] || (isMorning(date) ? 'AM' : 'PM');
|
|
361
120
|
};
|
|
362
121
|
//# sourceMappingURL=dateInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateInfo.js","names":["getLanguage","getChaynsLanguage","format","isPast","isThisYear","isToday","isTomorrow","isYesterday","de","enGB","es","fr","it","nl","pl","pt","tr","uk","TIME_TYPE_STRINGS","translation","site","getTimeString","_ref","language","isMorning","getYearFormat","_ref2","date","shouldShowYear","getMonthFormat","_ref3","shouldUseShortText","getFormattedDayOfWeek","_ref4","shouldShowRelativeDayOfWeek","shouldShowDayOfWeek","code","locale","getFormattedTime","_ref5","shouldShowTime","timeFormat","hours","getHours","TimeType","getTimeTypeStrings","getTimeTillNow","_ref6","currentDate","time","value","type","Years","elapsedMilliseconds","getTime","Math","floor","Seconds","Minutes","minutes","getFormattedPastTimeString","Hours","and","Days","Weeks","Months","remainingMilliseconds","getFormattedFutureTimeString","timeTypeStrings","isSingular","seconds","days","weeks","months","years","past","singular","plural","future"],"sources":["../../../src/utils/dateInfo.ts"],"sourcesContent":["import { getLanguage as getChaynsLanguage } from 'chayns-api';\nimport {\n format,\n isPast,\n isThisYear,\n isToday,\n isTomorrow,\n isYesterday,\n type Locale,\n} from 'date-fns';\nimport { de, enGB, es, fr, it, nl, pl, pt, tr, uk } from 'date-fns/locale';\nimport { TIME_TYPE_STRINGS, type TimeTypeStringsRecord } from '../constants/dateInfo';\n\nexport const getLanguage = (): Locale => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n switch (getChaynsLanguage().translation || getChaynsLanguage().site) {\n case 'en':\n return enGB;\n case 'nl':\n return nl;\n case 'fr':\n return fr;\n case 'it':\n return it;\n case 'pl':\n return pl;\n case 'pt':\n return pt;\n case 'es':\n return es;\n case 'tr':\n return tr;\n case 'uk':\n return uk;\n default:\n return de;\n }\n};\n\ninterface GetTimeStringProps {\n language?: string;\n isMorning?: boolean;\n}\n\nexport const getTimeString = ({ language, isMorning }: GetTimeStringProps) => {\n switch (language) {\n case 'en-GB':\n case 'pt':\n return isMorning ? 'AM' : 'PM';\n case 'nl':\n return 'uur';\n case 'fr':\n return 'heures';\n case 'de':\n return 'Uhr';\n case 'es':\n return 'h';\n default:\n return '';\n }\n};\n\ninterface GetFormattedYearOptions {\n date: Date;\n shouldShowYear?: boolean;\n}\n\nexport const getYearFormat = ({ date, shouldShowYear }: GetFormattedYearOptions) =>\n (typeof shouldShowYear === 'boolean' && !shouldShowYear) || isThisYear(date) ? '' : ' yyyy';\n\ninterface GetFormattedMonthOptions {\n shouldUseShortText?: boolean;\n}\n\nexport const getMonthFormat = ({ shouldUseShortText }: GetFormattedMonthOptions) => {\n if (shouldUseShortText) {\n return 'LLL.';\n }\n\n return 'LLLL';\n};\n\ninterface GetFormattedDayOfWeekOptions {\n shouldShowDayOfWeek?: boolean;\n shouldShowRelativeDayOfWeek?: boolean;\n shouldUseShortText?: boolean;\n date: Date;\n language?: Locale;\n}\n\nexport const getFormattedDayOfWeek = ({\n shouldShowRelativeDayOfWeek,\n shouldShowDayOfWeek,\n shouldUseShortText,\n date,\n language,\n}: GetFormattedDayOfWeekOptions) => {\n if (!shouldShowDayOfWeek && !shouldShowRelativeDayOfWeek) {\n return '';\n }\n\n if (shouldShowRelativeDayOfWeek) {\n if (isToday(date)) {\n switch (language?.code) {\n case 'en-GB':\n return 'Today, ';\n case 'nl':\n return 'Vandaag, ';\n case 'fr':\n return \"Aujourd'hui, \";\n case 'it':\n return 'Oggi, ';\n case 'pl':\n return 'Dzisiaj, ';\n case 'pt':\n return 'Hoje, ';\n case 'es':\n return 'Hoy, ';\n case 'tr':\n return 'Bugün, ';\n case 'uk':\n return 'Сьогодні, ';\n default:\n return 'Heute, ';\n }\n }\n\n if (isTomorrow(date)) {\n switch (language?.code) {\n case 'en-GB':\n return 'Tomorrow, ';\n case 'nl':\n return 'Morgen, ';\n case 'fr':\n return 'Demain, ';\n case 'it':\n return 'Domani, ';\n case 'pl':\n return 'Jutro, ';\n case 'pt':\n return 'Amanhã, ';\n case 'es':\n return 'Mañana, ';\n case 'tr':\n return 'Yarın, ';\n case 'uk':\n return 'Завтра, ';\n default:\n return 'Morgen, ';\n }\n }\n\n if (isYesterday(date)) {\n switch (language?.code) {\n case 'en-GB':\n return 'Yesterday, ';\n case 'nl':\n return 'Gisteren, ';\n case 'fr':\n return 'Hier, ';\n case 'it':\n return 'Ieri, ';\n case 'pl':\n return 'Wczoraj, ';\n case 'pt':\n return 'Ontem, ';\n case 'es':\n return 'Ayer, ';\n case 'tr':\n return 'Dün, ';\n case 'uk':\n return 'Вчора, ';\n default:\n return 'Gestern, ';\n }\n }\n }\n\n if (shouldUseShortText) {\n return format(date, 'E, ', { locale: language });\n }\n\n return format(date, 'EEEE, ', { locale: language });\n};\n\ninterface GetFormattedTimeOptions {\n shouldShowTime?: boolean;\n date: Date;\n language: Locale;\n}\n\nexport const getFormattedTime = ({ shouldShowTime, date, language }: GetFormattedTimeOptions) => {\n if (!shouldShowTime) {\n return '';\n }\n\n let timeFormat = 'HH:mm';\n\n if (language.code === 'en-GB' || language.code === 'pt') {\n timeFormat = 'KK:mm';\n }\n\n return `, ${format(date, timeFormat)} ${getTimeString({\n language: language.code,\n isMorning: isMorning(date),\n })}`;\n};\n\nexport const isMorning = (date: Date) => {\n const hours = date.getHours();\n\n return hours >= 0 && hours < 12;\n};\n\nexport interface Time {\n value: number;\n type: TimeType;\n isPast: boolean;\n}\n\nexport enum TimeType {\n Seconds,\n Minutes,\n Hours,\n Days,\n Weeks,\n Months,\n Years,\n}\n\nexport const getTimeTypeStrings = (language: string): TimeTypeStringsRecord | undefined =>\n TIME_TYPE_STRINGS[language === 'en-GB' ? 'en' : language];\n\ninterface GetTimeTillNowOptions {\n date: Date;\n currentDate: Date;\n language: Locale;\n}\n\nexport const getTimeTillNow = ({ date, currentDate, language }: GetTimeTillNowOptions): string => {\n const time: Time = {\n value: 0,\n type: TimeType.Years,\n isPast: false,\n };\n\n if (isPast(date)) {\n const elapsedMilliseconds = currentDate.getTime() - date.getTime();\n\n switch (true) {\n case elapsedMilliseconds < 60000:\n time.value = Math.floor(elapsedMilliseconds / 1000);\n time.type = TimeType.Seconds;\n break;\n case elapsedMilliseconds < 3600000:\n time.value = Math.floor(elapsedMilliseconds / 60000);\n time.type = TimeType.Minutes;\n break;\n case elapsedMilliseconds < 86400000:\n const hours = Math.floor(elapsedMilliseconds / 3600000);\n const minutes = Math.floor((elapsedMilliseconds % 3600000) / 60000);\n return `${hours} ${getFormattedPastTimeString({ value: hours, type: TimeType.Hours, isPast: true }, language)} \n ${minutes > 0 ? `${getTimeTypeStrings(language.code ?? 'de')?.and ?? ''} ${minutes} ${getFormattedPastTimeString({ value: minutes, type: TimeType.Minutes, isPast: true }, language)}` : ''}`;\n case elapsedMilliseconds < 604800000:\n time.value = Math.floor(elapsedMilliseconds / 86400000);\n time.type = TimeType.Days;\n break;\n case elapsedMilliseconds < 2592000000:\n time.value = Math.floor(elapsedMilliseconds / 604800000);\n time.type = TimeType.Weeks;\n break;\n case elapsedMilliseconds < 31536000000:\n time.value = Math.floor(elapsedMilliseconds / 2592000000);\n time.type = TimeType.Months;\n break;\n default:\n time.value = Math.floor(elapsedMilliseconds / 31536000000);\n time.type = TimeType.Years;\n break;\n }\n\n return `${time.value} ${getFormattedPastTimeString(time, language)}`;\n }\n\n const remainingMilliseconds = date.getTime() - currentDate.getTime();\n\n switch (true) {\n case remainingMilliseconds < 60000:\n time.value = Math.floor(remainingMilliseconds / 1000);\n time.type = TimeType.Seconds;\n break;\n case remainingMilliseconds < 3600000:\n time.value = Math.floor(remainingMilliseconds / 60000);\n time.type = TimeType.Minutes;\n break;\n case remainingMilliseconds < 86400000:\n const hours = Math.floor(remainingMilliseconds / 3600000);\n const minutes = Math.floor((remainingMilliseconds % 3600000) / 60000);\n return `${hours} ${getFormattedFutureTimeString({ value: hours, type: TimeType.Hours, isPast: false }, language)} \n ${minutes > 0 ? `${getTimeTypeStrings(language.code ?? 'de')?.and ?? ''} ${minutes} ${getFormattedFutureTimeString({ value: minutes, type: TimeType.Minutes, isPast: false }, language)}` : ''}`;\n case remainingMilliseconds < 604800000:\n time.value = Math.floor(remainingMilliseconds / 86400000);\n time.type = TimeType.Days;\n break;\n case remainingMilliseconds < 2592000000:\n time.value = Math.floor(remainingMilliseconds / 604800000);\n time.type = TimeType.Weeks;\n break;\n case remainingMilliseconds < 31536000000:\n time.value = Math.floor(remainingMilliseconds / 2592000000);\n time.type = TimeType.Months;\n break;\n default:\n time.value = Math.floor(remainingMilliseconds / 31536000000);\n time.type = TimeType.Years;\n break;\n }\n\n return `${time.value} ${getFormattedFutureTimeString(time, language)}`;\n};\n\nexport const getFormattedPastTimeString = (time: Time, language: Locale): string => {\n const { value, type } = time;\n\n const timeTypeStrings = getTimeTypeStrings(language.code ?? 'de');\n const isSingular = value === 1;\n\n if (!timeTypeStrings) {\n return '';\n }\n\n const { seconds, days, weeks, months, years, minutes, hours } = timeTypeStrings.past;\n\n switch (true) {\n case type === TimeType.Seconds:\n return isSingular ? seconds.singular : seconds.plural;\n case type === TimeType.Minutes:\n return isSingular ? minutes.singular : minutes.plural;\n case type === TimeType.Hours:\n return isSingular ? hours.singular : hours.plural;\n case type === TimeType.Days:\n return isSingular ? days.singular : days.plural;\n case type === TimeType.Weeks:\n return isSingular ? weeks.singular : weeks.plural;\n case type === TimeType.Months:\n return isSingular ? months.singular : months.plural;\n default:\n return isSingular ? years.singular : years.plural;\n }\n};\n\nexport const getFormattedFutureTimeString = (time: Time, language: Locale): string => {\n const { value, type } = time;\n const timeTypeStrings = getTimeTypeStrings(language.code ?? 'de');\n const isSingular = value === 1;\n\n if (!timeTypeStrings) {\n return '';\n }\n\n const { seconds, days, weeks, months, years, minutes, hours } = timeTypeStrings.future;\n\n switch (true) {\n case type === TimeType.Seconds:\n return isSingular ? seconds.singular : seconds.plural;\n case type === TimeType.Minutes:\n return isSingular ? minutes.singular : minutes.plural;\n case type === TimeType.Hours:\n return isSingular ? hours.singular : hours.plural;\n case type === TimeType.Days:\n return isSingular ? days.singular : days.plural;\n case type === TimeType.Weeks:\n return isSingular ? weeks.singular : weeks.plural;\n case type === TimeType.Months:\n return isSingular ? months.singular : months.plural;\n default:\n return isSingular ? years.singular : years.plural;\n }\n};\n"],"mappings":"AAAA,SAASA,WAAW,IAAIC,iBAAiB,QAAQ,YAAY;AAC7D,SACIC,MAAM,EACNC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,UAAU,EACVC,WAAW,QAER,UAAU;AACjB,SAASC,EAAE,EAAEC,IAAI,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AAC1E,SAASC,iBAAiB,QAAoC,uBAAuB;AAErF,OAAO,MAAMlB,WAAW,GAAGA,CAAA,KAAc;EACrC;EACA,QAAQC,iBAAiB,CAAC,CAAC,CAACkB,WAAW,IAAIlB,iBAAiB,CAAC,CAAC,CAACmB,IAAI;IAC/D,KAAK,IAAI;MACL,OAAOX,IAAI;IACf,KAAK,IAAI;MACL,OAAOI,EAAE;IACb,KAAK,IAAI;MACL,OAAOF,EAAE;IACb,KAAK,IAAI;MACL,OAAOC,EAAE;IACb,KAAK,IAAI;MACL,OAAOE,EAAE;IACb,KAAK,IAAI;MACL,OAAOC,EAAE;IACb,KAAK,IAAI;MACL,OAAOL,EAAE;IACb,KAAK,IAAI;MACL,OAAOM,EAAE;IACb,KAAK,IAAI;MACL,OAAOC,EAAE;IACb;MACI,OAAOT,EAAE;EACjB;AACJ,CAAC;AAOD,OAAO,MAAMa,aAAa,GAAGC,IAAA,IAAiD;EAAA,IAAhD;IAAEC,QAAQ;IAAEC;EAA8B,CAAC,GAAAF,IAAA;EACrE,QAA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AAK1B,IAAI,KAAKP,QAAQ,CAACmB,IAAI;MACvB,OAAOM,UAAU,GAAGE,IAAI,CAACK,QAAQ,GAAGL,IAAI,CAACM,MAAM;IACnD,KAAK1B,IAAI,KAAKP,QAAQ,CAACoB,KAAK;MACxB,OAAOK,UAAU,GAAGG,KAAK,CAACI,QAAQ,GAAGJ,KAAK,CAACK,MAAM;IACrD,KAAK1B,IAAI,KAAKP,QAAQ,CAACqB,MAAM;MACzB,OAAOI,UAAU,GAAGI,MAAM,CAACG,QAAQ,GAAGH,MAAM,CAACI,MAAM;IACvD;MACI,OAAOR,UAAU,GAAGK,KAAK,CAACE,QAAQ,GAAGF,KAAK,CAACG,MAAM;EACzD;AACJ,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"dateInfo.js","names":["getLanguage","Language","isCurrentYear","isMorning","isToday","isTomorrow","isYesterday","getDateInfo","_ref","date","shouldShowYear","shouldShowTime","shouldShowDayOfWeek","shouldShowRelativeDayOfWeek","shouldUseShortText","active","language","dayPart","rtf","Intl","RelativeTimeFormat","numeric","capitalizeFirstLetter","format","toLocaleDateString","weekday","dateParts","day","month","year","timeParts","hour","minute","formattedTime","Object","keys","length","toLocaleTimeString","hourWord","getTimeString","formattedDate","text","charAt","toUpperCase","slice","getTimeTillNow","_ref2","currentDate","English","diffInSeconds","Math","floor","getTime","isPast","units","label","seconds","absDiff","abs","find","u","count","formatter","_ref3","map"],"sources":["../../../src/utils/dateInfo.ts"],"sourcesContent":["import {getLanguage, Language} from 'chayns-api';\nimport {UseDateInfoOptions} from '../types/dateinfo';\nimport {isCurrentYear, isMorning, isToday, isTomorrow, isYesterday} from \"./date\";\n\nexport const getDateInfo = ({\n date,\n shouldShowYear,\n shouldShowTime,\n shouldShowDayOfWeek,\n shouldShowRelativeDayOfWeek,\n shouldUseShortText,\n }: Omit<UseDateInfoOptions, 'shouldShowDateToNowDifference' & 'preText'>) => {\n const {active: language} = getLanguage();\n\n let dayPart = '';\n\n if (shouldShowRelativeDayOfWeek) {\n const rtf = new Intl.RelativeTimeFormat(language, {numeric: 'auto'});\n\n if (isToday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(0, 'day'));\n }\n\n if (isTomorrow(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(1, 'day'));\n }\n\n if (isYesterday(date)) {\n dayPart = capitalizeFirstLetter(rtf.format(-1, 'day'));\n }\n }\n\n if (!dayPart && shouldShowDayOfWeek) {\n dayPart = date.toLocaleDateString(language, {\n weekday: shouldUseShortText ? 'short' : 'long',\n });\n }\n\n const dateParts: Intl.DateTimeFormatOptions = {\n day: '2-digit',\n month: shouldUseShortText ? 'short' : 'long',\n };\n\n if (shouldShowYear && !isCurrentYear(date)) {\n dateParts.year = 'numeric';\n }\n\n const timeParts: Intl.DateTimeFormatOptions = {};\n\n if (shouldShowTime) {\n timeParts.hour = '2-digit';\n timeParts.minute = '2-digit';\n }\n\n let formattedTime = '';\n if (Object.keys(timeParts).length > 0) {\n formattedTime = `, ${date.toLocaleTimeString(language, {...timeParts})}`;\n }\n\n const hourWord = getTimeString({language, date});\n formattedTime += shouldShowTime ? ` ${hourWord}` : '';\n\n const formattedDate = `${date.toLocaleDateString(\n language,\n dateParts,\n )}${formattedTime}`;\n return `${dayPart}${dayPart ? ', ' : ''}${formattedDate}`;\n};\n\nconst capitalizeFirstLetter = (text: string): string => text.charAt(0).toUpperCase() + text.slice(1)\n\ntype RelativeTimeUnit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';\n\ninterface GetTimeTillNow {\n date: Date;\n currentDate: Date;\n language: Language;\n}\n\nexport const getTimeTillNow = ({\n date,\n currentDate,\n language = Language.English,\n }: GetTimeTillNow): string => {\n const diffInSeconds = Math.floor((currentDate.getTime() - date.getTime()) / 1000);\n const isPast = diffInSeconds > 0;\n\n const units: { label: RelativeTimeUnit; seconds: number }[] = [\n {label: 'year', seconds: 31536000},\n {label: 'month', seconds: 2592000},\n {label: 'day', seconds: 86400},\n {label: 'hour', seconds: 3600},\n {label: 'minute', seconds: 60},\n {label: 'second', seconds: 1},\n ];\n\n const absDiff = Math.abs(diffInSeconds);\n const {label, seconds} = units.find((u) => absDiff >= u.seconds) || {\n label: 'second',\n seconds: 1,\n };\n const count = Math.floor(absDiff / seconds);\n\n const formatter = new Intl.RelativeTimeFormat(language, {numeric: 'auto'});\n\n return formatter.format(isPast ? -count : count, label);\n};\n\ninterface GetTimeStringProps {\n language?: Language;\n date: Date;\n}\n\nexport const getTimeString = ({language, date}: GetTimeStringProps) => {\n const map: { [key: string]: string } = {\n 'nl': 'uur',\n 'fr': 'heures',\n 'de': 'Uhr',\n 'es': 'horas',\n 'it': 'ore',\n 'pt': 'horas',\n 'pl': 'godzina',\n 'tr': 'saat',\n 'uk': 'година'\n }\n\n return map[language ?? ''] || (isMorning(date) ? 'AM' : 'PM');\n};\n"],"mappings":"AAAA,SAAQA,WAAW,EAAEC,QAAQ,QAAO,YAAY;AAEhD,SAAQC,aAAa,EAAEC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,WAAW,QAAO,QAAQ;AAEjF,OAAO,MAAMC,WAAW,GAAGC,IAAA,IAO8E;EAAA,IAP7E;IACIC,IAAI;IACJC,cAAc;IACdC,cAAc;IACdC,mBAAmB;IACnBC,2BAA2B;IAC3BC;EACmE,CAAC,GAAAN,IAAA;EAChG,MAAM;IAACO,MAAM,EAAEC;EAAQ,CAAC,GAAGhB,WAAW,CAAC,CAAC;EAExC,IAAIiB,OAAO,GAAG,EAAE;EAEhB,IAAIJ,2BAA2B,EAAE;IAC7B,MAAMK,GAAG,GAAG,IAAIC,IAAI,CAACC,kBAAkB,CAACJ,QAAQ,EAAE;MAACK,OAAO,EAAE;IAAM,CAAC,CAAC;IAEpE,IAAIjB,OAAO,CAACK,IAAI,CAAC,EAAE;MACfQ,OAAO,GAAGK,qBAAqB,CAACJ,GAAG,CAACK,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACzD;IAEA,IAAIlB,UAAU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AAC,CAACJ,OAAO,CAAC,IAAI;IAChED,KAAK,EAAE,QAAQ;IACfC,OAAO,EAAE;EACb,CAAC;EACD,MAAMK,KAAK,GAAGX,IAAI,CAACC,KAAK,CAACM,OAAO,GAAGD,OAAO,CAAC;EAE3C,MAAMM,SAAS,GAAG,IAAI3C,IAAI,CAACC,kBAAkB,CAACJ,QAAQ,EAAE;IAACK,OAAO,EAAE;EAAM,CAAC,CAAC;EAE1E,OAAOyC,SAAS,CAACvC,MAAM,CAAC8B,MAAM,GAAG,CAACQ,KAAK,GAAGA,KAAK,EAAEN,KAAK,CAAC;AAC3D,CAAC;AAOD,OAAO,MAAMhB,aAAa,GAAGwB,KAAA,IAA0C;EAAA,IAAzC;IAAC/C,QAAQ;IAAEP;EAAwB,CAAC,GAAAsD,KAAA;EAC9D,MAAMC,GAA8B,GAAG;IACnC,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE;EACV,CAAC;EAED,OAAOA,GAAG,CAAChD,QAAQ,IAAI,EAAE,CAAC,KAAKb,SAAS,CAACM,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACjE,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Locale } from 'date-fns';
|
|
2
1
|
import { FC } from 'react';
|
|
3
2
|
import { Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../types/calendar';
|
|
4
3
|
import { CalendarType } from '../../types/calendar';
|
|
4
|
+
import { Language } from "chayns-api";
|
|
5
5
|
interface BaseProps {
|
|
6
6
|
/**
|
|
7
7
|
* An array to group dates into a category.
|
|
@@ -22,7 +22,7 @@ interface BaseProps {
|
|
|
22
22
|
/**
|
|
23
23
|
* The locale language to format the dates.
|
|
24
24
|
*/
|
|
25
|
-
locale?:
|
|
25
|
+
locale?: Language;
|
|
26
26
|
/**
|
|
27
27
|
* The maximum date that can be selected.
|
|
28
28
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Locale } from 'date-fns';
|
|
2
1
|
import { FC } from 'react';
|
|
3
2
|
import { CalendarType, Categories, CustomThumbColors, DateInterval, HighlightedDates } from '../../../types/calendar';
|
|
3
|
+
import { Language } from "chayns-api";
|
|
4
4
|
export type MonthWrapperProps = {
|
|
5
|
-
locale:
|
|
5
|
+
locale: Language;
|
|
6
6
|
highlightedDates?: HighlightedDates[];
|
|
7
7
|
onSelect: (date: Date) => void;
|
|
8
8
|
selectedDate?: Date | Date[] | DateInterval;
|
|
@@ -54,7 +54,7 @@ export declare const StyledMotionWrapper: import("styled-components/dist/types")
|
|
|
54
54
|
results?: number | undefined;
|
|
55
55
|
security?: string | undefined;
|
|
56
56
|
unselectable?: "off" | "on" | undefined;
|
|
57
|
-
inputMode?: "none" | "search" | "text" | "tel" | "url" | "email" | "
|
|
57
|
+
inputMode?: "numeric" | "none" | "search" | "text" | "tel" | "url" | "email" | "decimal" | undefined;
|
|
58
58
|
is?: string | undefined;
|
|
59
59
|
"aria-activedescendant"?: string | undefined;
|
|
60
60
|
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Locale } from 'date-fns';
|
|
2
1
|
import { FC } from 'react';
|
|
3
2
|
import { CalendarType, Categories, CustomThumbColors, DateInterval, EMonth, HighlightedDates } from '../../../../types/calendar';
|
|
3
|
+
import { Language } from "chayns-api";
|
|
4
4
|
export type MonthProps = {
|
|
5
5
|
month: EMonth;
|
|
6
6
|
year: number;
|
|
7
|
-
locale:
|
|
7
|
+
locale: Language;
|
|
8
8
|
highlightedDates?: HighlightedDates[];
|
|
9
9
|
onSelect: (date: Date) => void;
|
|
10
10
|
selectedDate?: Date | Date[] | DateInterval;
|
package/lib/types/components/calendar/month-wrapper/month/weekday-wrapper/WeekdayWrapper.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { Language } from "chayns-api";
|
|
3
3
|
export type WeekdayWrapperProps = {
|
|
4
|
-
locale?:
|
|
4
|
+
locale?: Language;
|
|
5
5
|
};
|
|
6
6
|
declare const WeekdayWrapper: FC<WeekdayWrapperProps>;
|
|
7
7
|
export default WeekdayWrapper;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Locale } from 'date-fns';
|
|
2
1
|
import { FC } from 'react';
|
|
3
2
|
import { EMonth } from '../../../types/calendar';
|
|
3
|
+
import { Language } from "chayns-api";
|
|
4
4
|
export declare enum MonthYearPickerType {
|
|
5
5
|
Month = "month",
|
|
6
6
|
Year = "year"
|
|
@@ -8,7 +8,7 @@ export declare enum MonthYearPickerType {
|
|
|
8
8
|
type MonthYearPickerProps = {
|
|
9
9
|
month: EMonth;
|
|
10
10
|
year: number;
|
|
11
|
-
locale:
|
|
11
|
+
locale: Language;
|
|
12
12
|
minDate: Date;
|
|
13
13
|
maxDate: Date;
|
|
14
14
|
setCurrentDate: (date: Date) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { UseDateInfoOptions } from '../../types/dateinfo';
|
|
3
3
|
export type DateInfoProps = UseDateInfoOptions;
|
|
4
4
|
declare const DateInfo: FC<DateInfoProps>;
|
|
5
5
|
export default DateInfo;
|
|
@@ -49,7 +49,7 @@ export declare const StyledOpeningInputs: import("styled-components/dist/types")
|
|
|
49
49
|
results?: number | undefined;
|
|
50
50
|
security?: string | undefined;
|
|
51
51
|
unselectable?: "off" | "on" | undefined;
|
|
52
|
-
inputMode?: "none" | "search" | "text" | "tel" | "url" | "email" | "
|
|
52
|
+
inputMode?: "numeric" | "none" | "search" | "text" | "tel" | "url" | "email" | "decimal" | undefined;
|
|
53
53
|
is?: string | undefined;
|
|
54
54
|
"aria-activedescendant"?: string | undefined;
|
|
55
55
|
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
package/lib/types/components/opening-times/opening-inputs/opening-input/OpeningInput.styles.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare const StyledOpeningInput: import("styled-components/dist/types").
|
|
|
46
46
|
results?: number | undefined;
|
|
47
47
|
security?: string | undefined;
|
|
48
48
|
unselectable?: "off" | "on" | undefined;
|
|
49
|
-
inputMode?: "none" | "search" | "text" | "tel" | "url" | "email" | "
|
|
49
|
+
inputMode?: "numeric" | "none" | "search" | "text" | "tel" | "url" | "email" | "decimal" | undefined;
|
|
50
50
|
is?: string | undefined;
|
|
51
51
|
"aria-activedescendant"?: string | undefined;
|
|
52
52
|
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|