@synerise/ds-core 1.11.0 → 1.11.1
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/CHANGELOG.md +4 -0
- package/dist/i18n/{en.json → en.json.d.ts} +4 -2
- package/dist/i18n/en.json.js +8 -0
- package/dist/i18n/{es.json → es.json.d.ts} +4 -2
- package/dist/i18n/es.json.js +8 -0
- package/dist/i18n/index.js +14 -11
- package/dist/i18n/{pl.json → pl.json.d.ts} +4 -2
- package/dist/i18n/pl.json.js +8 -0
- package/dist/i18n/{pt.json → pt.json.d.ts} +4 -2
- package/dist/i18n/pt.json.js +8 -0
- package/dist/js/DSProvider/DSProvider.d.ts +5 -6
- package/dist/js/DSProvider/DSProvider.js +36 -31
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.d.ts +2 -2
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.js +29 -38
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.types.d.ts +3 -3
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.types.js +1 -1
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.d.ts +1 -1
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.js +22 -19
- package/dist/js/DSProvider/LocaleProvider/antLocales.d.ts +6 -6
- package/dist/js/DSProvider/LocaleProvider/antLocales.js +16 -13
- package/dist/js/DSProvider/LocaleProvider/index.js +4 -1
- package/dist/js/DSProvider/ThemeProvider/ThemeProvider.d.ts +2 -2
- package/dist/js/DSProvider/ThemeProvider/ThemeProvider.js +14 -12
- package/dist/js/DSProvider/ThemeProvider/breakpoints.js +5 -2
- package/dist/js/DSProvider/ThemeProvider/index.js +4 -1
- package/dist/js/DSProvider/ThemeProvider/theme.d.ts +1 -1
- package/dist/js/DSProvider/ThemeProvider/theme.js +17 -17
- package/dist/js/DSProvider/ThemeProvider/variables.d.ts +8 -0
- package/dist/js/DSProvider/ThemeProvider/variables.js +531 -530
- package/dist/js/DSProvider/index.js +4 -1
- package/dist/js/DropdownContext/DropdownContext/DropdownContextProvider.d.ts +2 -2
- package/dist/js/DropdownContext/DropdownContext/DropdownContextProvider.js +11 -11
- package/dist/js/DropdownContext/DropdownContext.d.ts +1 -1
- package/dist/js/DropdownContext/DropdownContext.js +5 -2
- package/dist/js/DropdownContext/DropdownContextProvider.d.ts +2 -2
- package/dist/js/DropdownContext/DropdownContextProvider.js +11 -11
- package/dist/js/DropdownContext/index.js +8 -3
- package/dist/js/DropdownContext/useDropdown.d.ts +1 -1
- package/dist/js/DropdownContext/useDropdown.js +7 -4
- package/dist/js/data-format/components/FormattedDate.d.ts +4 -4
- package/dist/js/data-format/components/FormattedDate.js +23 -9
- package/dist/js/data-format/components/FormattedDateTime.d.ts +4 -4
- package/dist/js/data-format/components/FormattedDateTime.js +26 -12
- package/dist/js/data-format/components/FormattedNumber.d.ts +2 -2
- package/dist/js/data-format/components/FormattedNumber.js +23 -9
- package/dist/js/data-format/components/FormattedRelativeDateTime.d.ts +3 -3
- package/dist/js/data-format/components/FormattedRelativeDateTime.js +40 -21
- package/dist/js/data-format/components/FormattedTime.d.ts +4 -4
- package/dist/js/data-format/components/FormattedTime.js +26 -12
- package/dist/js/data-format/components/index.js +13 -5
- package/dist/js/data-format/constants/dataFormat.constants.d.ts +2 -2
- package/dist/js/data-format/constants/dataFormat.constants.js +85 -49
- package/dist/js/data-format/constants/dataFormatConfig.constants.d.ts +2 -2
- package/dist/js/data-format/constants/dataFormatConfig.constants.js +15 -8
- package/dist/js/data-format/constants/dateTimeParts.constants.d.ts +1 -1
- package/dist/js/data-format/constants/dateTimeParts.constants.js +10 -4
- package/dist/js/data-format/constants/index.js +48 -3
- package/dist/js/data-format/contexts/DataFormatConfigContext.d.ts +2 -2
- package/dist/js/data-format/contexts/DataFormatConfigContext.js +6 -3
- package/dist/js/data-format/contexts/DataFormatIntlsContext.d.ts +2 -2
- package/dist/js/data-format/contexts/DataFormatIntlsContext.js +7 -4
- package/dist/js/data-format/contexts/index.js +6 -2
- package/dist/js/data-format/hocs/withDataFormat.d.ts +2 -2
- package/dist/js/data-format/hocs/withDataFormat.js +23 -9
- package/dist/js/data-format/hooks/index.js +14 -6
- package/dist/js/data-format/hooks/useDataFormat.d.ts +1 -1
- package/dist/js/data-format/hooks/useDataFormat.js +93 -90
- package/dist/js/data-format/hooks/useDataFormatConfig.d.ts +1 -1
- package/dist/js/data-format/hooks/useDataFormatConfig.js +8 -4
- package/dist/js/data-format/hooks/useDataFormatIntls.d.ts +1 -1
- package/dist/js/data-format/hooks/useDataFormatIntls.js +8 -4
- package/dist/js/data-format/hooks/useDataFormatUtils.d.ts +4 -4
- package/dist/js/data-format/hooks/useDataFormatUtils.js +62 -63
- package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.d.ts +2 -2
- package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.js +19 -23
- package/dist/js/data-format/hooks/useSingleIntl.d.ts +1 -1
- package/dist/js/data-format/hooks/useSingleIntl.js +11 -8
- package/dist/js/data-format/index.js +83 -7
- package/dist/js/data-format/providers/DataFormatConfigProvider.d.ts +2 -2
- package/dist/js/data-format/providers/DataFormatConfigProvider.js +37 -26
- package/dist/js/data-format/types/dataFormat.types.d.ts +3 -3
- package/dist/js/data-format/types/dataFormat.types.js +1 -5
- package/dist/js/data-format/types/dataFormatConfig.types.d.ts +1 -1
- package/dist/js/data-format/types/dataFormatConfig.types.js +1 -2
- package/dist/js/data-format/types/dateTimeParts.types.js +1 -2
- package/dist/js/data-format/types/index.js +1 -1
- package/dist/js/data-format/utils/dataFormat.utils.d.ts +2 -2
- package/dist/js/data-format/utils/dataFormat.utils.js +82 -67
- package/dist/js/data-format/utils/dataFormatConfig.utils.d.ts +1 -1
- package/dist/js/data-format/utils/dataFormatConfig.utils.js +9 -8
- package/dist/js/data-format/utils/date.utils.d.ts +2 -2
- package/dist/js/data-format/utils/date.utils.js +25 -21
- package/dist/js/data-format/utils/dateTimeParts.utils.d.ts +2 -2
- package/dist/js/data-format/utils/dateTimeParts.utils.js +68 -52
- package/dist/js/data-format/utils/index.js +41 -5
- package/dist/js/data-format/utils/timeZone.utils.d.ts +1 -1
- package/dist/js/data-format/utils/timeZone.utils.js +59 -51
- package/dist/js/index.js +112 -7
- package/dist/js/mediaQuery/mediaQuery.d.ts +2 -2
- package/dist/js/mediaQuery/mediaQuery.js +15 -25
- package/dist/js/style.d.ts +0 -2
- package/dist/js/style.js +1 -2
- package/dist/js/testing/index.js +6 -2
- package/dist/js/testing/renderWithProvider/renderWithProvider.d.ts +4 -4
- package/dist/js/testing/renderWithProvider/renderWithProvider.js +35 -27
- package/dist/js/testing/sleep.js +6 -8
- package/dist/js/toaster/Toaster.d.ts +1 -1
- package/dist/js/toaster/Toaster.js +12 -8
- package/dist/js/toaster/Toaster.types.js +1 -1
- package/dist/js/toaster/constants.d.ts +1 -1
- package/dist/js/toaster/constants.js +7 -4
- package/dist/js/toaster/contexts/ToasterContext.d.ts +2 -2
- package/dist/js/toaster/contexts/ToasterContext.js +9 -5
- package/dist/js/toaster/hooks/useToaster.d.ts +1 -1
- package/dist/js/toaster/hooks/useToaster.js +7 -4
- package/dist/js/toaster/index.js +12 -5
- package/dist/js/toaster/providers/ToasterProvider.d.ts +2 -2
- package/dist/js/toaster/providers/ToasterProvider.js +17 -17
- package/package.json +4 -4
- package/dist/js/testing/renderWithProvider/renderWithProvider.spec.d.ts +0 -1
- package/dist/style/colors.less +0 -137
- package/dist/style/config.less +0 -521
- package/dist/style/core.less +0 -55
- package/dist/style/variables.less +0 -2
- /package/dist/{style/variables.css → assets/style/core-tn0RQdqM.css} +0 -0
|
@@ -1,65 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
import { DEFAULT_FORMAT_DATE_OPTIONS, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DEFAULT_FORMAT_TIME_OPTIONS, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export var getWeekdayLongDateParts = function getWeekdayLongDateParts(value, dateFormatIntl, option) {
|
|
11
|
-
return dateFormatIntl.formatDateToParts(value, _extends({}, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, option));
|
|
12
|
-
};
|
|
13
|
-
export var getWeekdayShortDateParts = function getWeekdayShortDateParts(value, dateFormatIntl, option) {
|
|
14
|
-
return dateFormatIntl.formatDateToParts(value, _extends({}, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS, option));
|
|
15
|
-
};
|
|
16
|
-
export var getMonthLongDateParts = function getMonthLongDateParts(value, dateFormatIntl, option) {
|
|
17
|
-
return dateFormatIntl.formatDateToParts(value, _extends({}, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, option));
|
|
18
|
-
};
|
|
19
|
-
export var getMonthShortDateParts = function getMonthShortDateParts(value, dateFormatIntl, option) {
|
|
20
|
-
return dateFormatIntl.formatDateToParts(value, _extends({}, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, option));
|
|
1
|
+
import "../constants/dataFormatConfig.constants.js";
|
|
2
|
+
import { DEFAULT_FORMAT_DATE_OPTIONS, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DEFAULT_FORMAT_TIME_OPTIONS, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS, WEEKDAY_LONG, WEEKDAY_SHORT, MONTH_LONG, MONTH_SHORT } from "../constants/dataFormat.constants.js";
|
|
3
|
+
import { LONG, SHORT, WEEKDAY, MONTH } from "../constants/dateTimeParts.constants.js";
|
|
4
|
+
import { dateToIsoWithOffset } from "./timeZone.utils.js";
|
|
5
|
+
const getDateParts = (value, dateFormatIntl, option) => {
|
|
6
|
+
return dateFormatIntl.formatDateToParts(dateToIsoWithOffset(value, dateFormatIntl), {
|
|
7
|
+
...DEFAULT_FORMAT_DATE_OPTIONS,
|
|
8
|
+
...option
|
|
9
|
+
});
|
|
21
10
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
const getTimeParts = (value, timeFormatIntl, option) => timeFormatIntl.formatDateToParts(dateToIsoWithOffset(value, timeFormatIntl), {
|
|
12
|
+
...DEFAULT_FORMAT_TIME_OPTIONS,
|
|
13
|
+
...option
|
|
14
|
+
});
|
|
15
|
+
const getWeekdayLongDateParts = (value, dateFormatIntl, option) => dateFormatIntl.formatDateToParts(value, {
|
|
16
|
+
...DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS,
|
|
17
|
+
...option
|
|
18
|
+
});
|
|
19
|
+
const getWeekdayShortDateParts = (value, dateFormatIntl, option) => dateFormatIntl.formatDateToParts(value, {
|
|
20
|
+
...DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS,
|
|
21
|
+
...option
|
|
22
|
+
});
|
|
23
|
+
const getMonthLongDateParts = (value, dateFormatIntl, option) => dateFormatIntl.formatDateToParts(value, {
|
|
24
|
+
...DEFAULT_FORMAT_MONTH_LONG_OPTIONS,
|
|
25
|
+
...option
|
|
26
|
+
});
|
|
27
|
+
const getMonthShortDateParts = (value, dateFormatIntl, option) => dateFormatIntl.formatDateToParts(value, {
|
|
28
|
+
...DEFAULT_FORMAT_MONTH_SHORT_OPTIONS,
|
|
29
|
+
...option
|
|
30
|
+
});
|
|
31
|
+
const getDateTimePartsSubset = (dateTimeParts, subsetTypes) => {
|
|
32
|
+
const resultDateTimeParts = [];
|
|
33
|
+
dateTimeParts.forEach((dateTimePart) => {
|
|
25
34
|
if (subsetTypes.includes(dateTimePart.type)) {
|
|
26
35
|
resultDateTimeParts.push(dateTimePart);
|
|
27
36
|
}
|
|
28
37
|
});
|
|
29
38
|
return resultDateTimeParts;
|
|
30
39
|
};
|
|
31
|
-
|
|
32
|
-
return text.replace(/ /g,
|
|
40
|
+
const nbspToSpace = (text) => {
|
|
41
|
+
return text.replace(/ /g, " ").replace(/\u00A0/g, " ");
|
|
33
42
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (numberPartWithReplacedDelimiters.type ===
|
|
43
|
+
const numberPartsToString = (numberParts, thousandDelimiter, decimalDelimiter) => {
|
|
44
|
+
const numberPartsWithReplacedDelimiters = numberParts.map((numberPart) => {
|
|
45
|
+
const numberPartWithReplacedDelimiters = numberPart;
|
|
46
|
+
if (numberPartWithReplacedDelimiters.type === "group") {
|
|
38
47
|
numberPartWithReplacedDelimiters.value = thousandDelimiter;
|
|
39
48
|
}
|
|
40
|
-
if (numberPartWithReplacedDelimiters.type ===
|
|
49
|
+
if (numberPartWithReplacedDelimiters.type === "decimal") {
|
|
41
50
|
numberPartWithReplacedDelimiters.value = decimalDelimiter;
|
|
42
51
|
}
|
|
43
52
|
return numberPartWithReplacedDelimiters;
|
|
44
53
|
});
|
|
45
|
-
|
|
46
|
-
return numberPart.value;
|
|
47
|
-
}).join('');
|
|
54
|
+
const joinedNumberParts = numberPartsWithReplacedDelimiters.map((numberPart) => numberPart.value).join("");
|
|
48
55
|
return nbspToSpace(joinedNumberParts);
|
|
49
56
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return dateTimePart.value;
|
|
53
|
-
}).join('');
|
|
57
|
+
const dateTimePartsToString = (dateTimeParts) => {
|
|
58
|
+
const joinedDateTimeParts = dateTimeParts.map((dateTimePart) => dateTimePart.value).join("");
|
|
54
59
|
return nbspToSpace(joinedDateTimeParts);
|
|
55
60
|
};
|
|
56
|
-
|
|
57
|
-
return dateTimeParts.map(
|
|
58
|
-
|
|
59
|
-
if (replacementDateTimeFormatPartTypes
|
|
60
|
-
|
|
61
|
-
return replacementDateTimePart.type === dateTimePartToReplace.type;
|
|
62
|
-
});
|
|
61
|
+
const replaceDateTimeParts = (dateTimeParts, replacementDateTimeParts, replacementDateTimeFormatPartTypes) => {
|
|
62
|
+
return dateTimeParts.map((dateTimePart) => {
|
|
63
|
+
const dateTimePartToReplace = dateTimePart;
|
|
64
|
+
if (replacementDateTimeFormatPartTypes?.includes(dateTimePartToReplace.type)) {
|
|
65
|
+
const foundedReplacementDateTimePart = replacementDateTimeParts?.find((replacementDateTimePart) => replacementDateTimePart.type === dateTimePartToReplace.type);
|
|
63
66
|
if (foundedReplacementDateTimePart) {
|
|
64
67
|
dateTimePartToReplace.value = foundedReplacementDateTimePart.value;
|
|
65
68
|
}
|
|
@@ -67,20 +70,33 @@ export var replaceDateTimeParts = function replaceDateTimeParts(dateTimeParts, r
|
|
|
67
70
|
return dateTimePartToReplace;
|
|
68
71
|
});
|
|
69
72
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_LONG || (options == null ? void 0 : options.targetFormat) === WEEKDAY_SHORT) {
|
|
73
|
+
const translateDateTimeParts = (dateTimeParts, dateTimePartsFromLanguageIntl, options) => {
|
|
74
|
+
const replacementDateTimeFormatPartTypes = [];
|
|
75
|
+
if (options?.targetFormat === WEEKDAY_LONG || options?.targetFormat === WEEKDAY_SHORT) {
|
|
74
76
|
replacementDateTimeFormatPartTypes.push(WEEKDAY);
|
|
75
77
|
}
|
|
76
|
-
if (
|
|
78
|
+
if (options?.targetFormat === MONTH_LONG || options?.targetFormat === MONTH_SHORT) {
|
|
77
79
|
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
78
80
|
}
|
|
79
|
-
if (
|
|
81
|
+
if (options?.dateOptions?.month === LONG || options?.dateOptions?.month === SHORT) {
|
|
80
82
|
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
81
83
|
}
|
|
82
|
-
if (
|
|
84
|
+
if (options?.month === LONG || options?.month === SHORT) {
|
|
83
85
|
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
84
86
|
}
|
|
85
87
|
return replaceDateTimeParts(dateTimeParts, dateTimePartsFromLanguageIntl, replacementDateTimeFormatPartTypes);
|
|
86
|
-
};
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
dateTimePartsToString,
|
|
91
|
+
getDateParts,
|
|
92
|
+
getDateTimePartsSubset,
|
|
93
|
+
getMonthLongDateParts,
|
|
94
|
+
getMonthShortDateParts,
|
|
95
|
+
getTimeParts,
|
|
96
|
+
getWeekdayLongDateParts,
|
|
97
|
+
getWeekdayShortDateParts,
|
|
98
|
+
nbspToSpace,
|
|
99
|
+
numberPartsToString,
|
|
100
|
+
replaceDateTimeParts,
|
|
101
|
+
translateDateTimeParts
|
|
102
|
+
};
|
|
@@ -1,5 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { getDataFormatConfigFromNotation } from "./dataFormatConfig.utils.js";
|
|
2
|
+
import { dateTimePartsToString, getDateParts, getDateTimePartsSubset, getMonthLongDateParts, getMonthShortDateParts, getTimeParts, getWeekdayLongDateParts, getWeekdayShortDateParts, nbspToSpace, numberPartsToString, replaceDateTimeParts, translateDateTimeParts } from "./dateTimeParts.utils.js";
|
|
3
|
+
import { addPrefix, addSuffix, changeNamingConvention, convertDateToDateString, convertDateToDateTimeString, convertDateToMonthLongString, convertDateToMonthShortString, convertDateToRelativeFromString, convertDateToRelativeToString, convertDateToTimeString, convertDateToWeekdayLongString, convertDateToWeekdayShortString, convertNumberString, getDefaultDataTimeOptions } from "./dataFormat.utils.js";
|
|
4
|
+
import { getConstantDatesAndFormattingOptions } from "./date.utils.js";
|
|
5
|
+
import { applyTimezoneOffset, currentTimeInTimezone, dateStringTimeZoneParts, getTimeZone, getValueAsLocalDate, removeTimeZoneOffset } from "./timeZone.utils.js";
|
|
6
|
+
export {
|
|
7
|
+
addPrefix,
|
|
8
|
+
addSuffix,
|
|
9
|
+
applyTimezoneOffset,
|
|
10
|
+
changeNamingConvention,
|
|
11
|
+
convertDateToDateString,
|
|
12
|
+
convertDateToDateTimeString,
|
|
13
|
+
convertDateToMonthLongString,
|
|
14
|
+
convertDateToMonthShortString,
|
|
15
|
+
convertDateToRelativeFromString,
|
|
16
|
+
convertDateToRelativeToString,
|
|
17
|
+
convertDateToTimeString,
|
|
18
|
+
convertDateToWeekdayLongString,
|
|
19
|
+
convertDateToWeekdayShortString,
|
|
20
|
+
convertNumberString,
|
|
21
|
+
currentTimeInTimezone,
|
|
22
|
+
dateStringTimeZoneParts,
|
|
23
|
+
dateTimePartsToString,
|
|
24
|
+
getConstantDatesAndFormattingOptions,
|
|
25
|
+
getDataFormatConfigFromNotation,
|
|
26
|
+
getDateParts,
|
|
27
|
+
getDateTimePartsSubset,
|
|
28
|
+
getDefaultDataTimeOptions,
|
|
29
|
+
getMonthLongDateParts,
|
|
30
|
+
getMonthShortDateParts,
|
|
31
|
+
getTimeParts,
|
|
32
|
+
getTimeZone,
|
|
33
|
+
getValueAsLocalDate,
|
|
34
|
+
getWeekdayLongDateParts,
|
|
35
|
+
getWeekdayShortDateParts,
|
|
36
|
+
nbspToSpace,
|
|
37
|
+
numberPartsToString,
|
|
38
|
+
removeTimeZoneOffset,
|
|
39
|
+
replaceDateTimeParts,
|
|
40
|
+
translateDateTimeParts
|
|
41
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntlShape } from 'react-intl';
|
|
2
2
|
export declare const TIMEZONE_OFFSET_REGEX: RegExp;
|
|
3
3
|
export declare const dateToIsoWithOffset: (value: Date, intlObject: IntlShape) => string;
|
|
4
4
|
export declare const applyTimezoneOffset: (date: Date | undefined, timezoneOffset: true | string | undefined, intl?: IntlShape) => string | Date | undefined;
|
|
@@ -1,94 +1,102 @@
|
|
|
1
|
-
import { format, getTimezoneOffset
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { utcToZonedTime, format, getTimezoneOffset } from "date-fns-tz";
|
|
2
|
+
const TIMEZONE_OFFSET_REGEX = /([+-]\d\d:\d\d)|([Z])$/;
|
|
3
|
+
const defaultTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
4
|
+
const dateToIsoWithOffset = (value, intlObject) => {
|
|
5
5
|
return format(value, "yyyy-MM-dd'T'HH:mm:ssxxx", {
|
|
6
|
-
timeZone:
|
|
6
|
+
timeZone: intlObject?.timeZone || defaultTimezone
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
const applyTimezoneOffset = (date, timezoneOffset, intl) => {
|
|
10
10
|
if (!timezoneOffset) {
|
|
11
11
|
return date;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const timezoneString = getTimeZone(timezoneOffset, intl);
|
|
14
14
|
return toIsoString(date, timezoneString);
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const removeTimeZoneOffset = (dateString) => {
|
|
17
|
+
const date = dateString instanceof Date ? dateString.toISOString() : dateString;
|
|
18
|
+
const finalDate = date.replace(TIMEZONE_OFFSET_REGEX, "");
|
|
19
19
|
return finalDate;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const extractTimeZoneOffset = (datestring) => {
|
|
22
|
+
const date = datestring.toString();
|
|
23
|
+
const found = date.match(TIMEZONE_OFFSET_REGEX);
|
|
24
24
|
return found && found[0];
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
const dateStringTimeZoneParts = (dateTimeIsoString) => {
|
|
27
27
|
return {
|
|
28
28
|
dateTimeString: removeTimeZoneOffset(dateTimeIsoString),
|
|
29
29
|
offsetString: extractTimeZoneOffset(dateTimeIsoString)
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
offsetString
|
|
35
|
-
dateTimeString
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
const getLocalDateInTimeZone = (dateIsoString, timezone) => {
|
|
33
|
+
const {
|
|
34
|
+
offsetString,
|
|
35
|
+
dateTimeString
|
|
36
|
+
} = dateStringTimeZoneParts(dateIsoString);
|
|
37
|
+
const localDate = new Date(dateTimeString);
|
|
38
|
+
const localTimezoneOffset = getTimezoneOffset(timezone, localDate);
|
|
39
|
+
const dateTimezoneOffset = offsetString ? getTimezoneOffset(offsetString, localDate) : 0;
|
|
40
|
+
const offsetDiff = localTimezoneOffset - dateTimezoneOffset;
|
|
41
41
|
localDate.setMilliseconds(localDate.getMilliseconds() + offsetDiff);
|
|
42
42
|
return localDate;
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
export function toIsoString(date, timeZone) {
|
|
48
|
-
if (timeZone === void 0) {
|
|
49
|
-
timeZone = 'UTC';
|
|
50
|
-
}
|
|
44
|
+
const pad = (num) => (num < 10 ? "0" : "") + num;
|
|
45
|
+
function toIsoString(date, timeZone = "UTC") {
|
|
51
46
|
if (!timeZone) {
|
|
52
47
|
return date.toISOString();
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return date.getFullYear()
|
|
49
|
+
const timeZoneOffset = getTimezoneOffset(timeZone, date);
|
|
50
|
+
const dif = timeZoneOffset >= 0 ? "+" : "-";
|
|
51
|
+
const tzHours = pad(Math.floor(Math.abs(timeZoneOffset) / 60 / 60 / 1e3));
|
|
52
|
+
const tzMinutes = pad(Math.abs(timeZoneOffset) / 60 / 1e3 % 60);
|
|
53
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}${dif}${tzHours}:${tzMinutes}`;
|
|
59
54
|
}
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const currentTimeInTimezone = (timezoneString) => {
|
|
56
|
+
const now = /* @__PURE__ */ new Date();
|
|
62
57
|
return utcToZonedTime(now.toISOString(), timezoneString);
|
|
63
58
|
};
|
|
64
|
-
|
|
59
|
+
const dateTimeStringToLocalDate = (value, timeZone) => {
|
|
65
60
|
if (!value || !timeZone) {
|
|
66
|
-
return new Date();
|
|
61
|
+
return /* @__PURE__ */ new Date();
|
|
67
62
|
}
|
|
68
|
-
if (timeZone !==
|
|
63
|
+
if (timeZone !== void 0) {
|
|
69
64
|
return getLocalDateInTimeZone(value, timeZone);
|
|
70
65
|
}
|
|
71
|
-
|
|
72
|
-
return typeof value === 'string' ? new Date(value) : value;
|
|
66
|
+
return typeof value === "string" ? new Date(value) : value;
|
|
73
67
|
};
|
|
74
|
-
|
|
68
|
+
const getValueAsLocalDate = (value, timeZone) => {
|
|
75
69
|
if (!value) {
|
|
76
|
-
return new Date();
|
|
70
|
+
return /* @__PURE__ */ new Date();
|
|
77
71
|
}
|
|
78
|
-
if (timeZone !==
|
|
79
|
-
if (typeof value !==
|
|
72
|
+
if (timeZone !== void 0) {
|
|
73
|
+
if (typeof value !== "string") {
|
|
80
74
|
return getLocalDateInTimeZone(value.toISOString(), timeZone);
|
|
81
75
|
}
|
|
82
76
|
return getLocalDateInTimeZone(value, timeZone);
|
|
83
77
|
}
|
|
84
|
-
return typeof value ===
|
|
78
|
+
return typeof value === "string" ? new Date(value) : value;
|
|
85
79
|
};
|
|
86
|
-
|
|
80
|
+
const getTimeZone = (timeZone, intl) => {
|
|
87
81
|
if (!timeZone) {
|
|
88
|
-
return
|
|
82
|
+
return void 0;
|
|
89
83
|
}
|
|
90
84
|
if (timeZone === true) {
|
|
91
|
-
return
|
|
85
|
+
return intl?.timeZone || defaultTimezone;
|
|
92
86
|
}
|
|
93
87
|
return timeZone;
|
|
94
|
-
};
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
TIMEZONE_OFFSET_REGEX,
|
|
91
|
+
applyTimezoneOffset,
|
|
92
|
+
currentTimeInTimezone,
|
|
93
|
+
dateStringTimeZoneParts,
|
|
94
|
+
dateTimeStringToLocalDate,
|
|
95
|
+
dateToIsoWithOffset,
|
|
96
|
+
extractTimeZoneOffset,
|
|
97
|
+
getLocalDateInTimeZone,
|
|
98
|
+
getTimeZone,
|
|
99
|
+
getValueAsLocalDate,
|
|
100
|
+
removeTimeZoneOffset,
|
|
101
|
+
toIsoString
|
|
102
|
+
};
|
package/dist/js/index.js
CHANGED
|
@@ -1,7 +1,112 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { default as default2 } from "./DSProvider/DSProvider.js";
|
|
2
|
+
import { default as default3 } from "./mediaQuery/mediaQuery.js";
|
|
3
|
+
import { defaultColorsOrder, default as default4, themeVariables, useTheme } from "./DSProvider/ThemeProvider/theme.js";
|
|
4
|
+
import { DataFormatConfigProvider } from "./data-format/providers/DataFormatConfigProvider.js";
|
|
5
|
+
import { FormattedDate } from "./data-format/components/FormattedDate.js";
|
|
6
|
+
import { FormattedDateTime } from "./data-format/components/FormattedDateTime.js";
|
|
7
|
+
import { FormattedNumber } from "./data-format/components/FormattedNumber.js";
|
|
8
|
+
import { FormattedTime } from "./data-format/components/FormattedTime.js";
|
|
9
|
+
import { FormattedRelativeDateTimeFrom, FormattedRelativeDateTimeTo } from "./data-format/components/FormattedRelativeDateTime.js";
|
|
10
|
+
import { useDataFormatConfig } from "./data-format/hooks/useDataFormatConfig.js";
|
|
11
|
+
import { useDataFormat } from "./data-format/hooks/useDataFormat.js";
|
|
12
|
+
import { useDataFormatUtils } from "./data-format/hooks/useDataFormatUtils.js";
|
|
13
|
+
import "react-intl";
|
|
14
|
+
import { useDataFormatIntls } from "./data-format/hooks/useDataFormatIntls.js";
|
|
15
|
+
import "react";
|
|
16
|
+
import { withDataFormat } from "./data-format/hocs/withDataFormat.js";
|
|
17
|
+
import { getDataFormatConfigFromNotation } from "./data-format/utils/dataFormatConfig.utils.js";
|
|
18
|
+
import { DEFAULT_DATA_FORMAT_CONFIG, DEFAULT_DATA_FORMAT_INTL, DEFAULT_DATA_FORMAT_NOTATION, EU_NOTATION, US_NOTATION } from "./data-format/constants/dataFormatConfig.constants.js";
|
|
19
|
+
import { COMPACT_DECIMAL_LARGER_NUMBER, COMPACT_LARGER_NUMBER, DATE, DATETIME, DATE_CONSTANTS_TARGET_FORMATS, DEFAULT_FORMAT_DATE_OPTIONS, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DEFAULT_FORMAT_NUMBER_OPTIONS, DEFAULT_FORMAT_TIME_OPTIONS, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS, EU_DECIMAL_DELIMITER, EU_THOUSAND_DELIMITER, LARGER_NUMBER_LIMIT, LOWER_CASE, LOWER_FIRST, MONTHS_LONG, MONTHS_SHORT, MONTH_LONG, MONTH_SHORT, RELATIVE_FROM, RELATIVE_FROM_WITHOUT_SUFFIX, RELATIVE_TO, RELATIVE_TO_WITHOUT_SUFFIX, TIME, UPPER_CASE, UPPER_FIRST, US_DECIMAL_DELIMITER, US_THOUSAND_DELIMITER, WEEKDAYS_LONG, WEEKDAYS_SHORT, WEEKDAY_LONG, WEEKDAY_SHORT } from "./data-format/constants/dataFormat.constants.js";
|
|
20
|
+
import { LONG, MONTH, SHORT, WEEKDAY } from "./data-format/constants/dateTimeParts.constants.js";
|
|
21
|
+
import "./data-format/utils/timeZone.utils.js";
|
|
22
|
+
import { getDefaultDataTimeOptions } from "./data-format/utils/dataFormat.utils.js";
|
|
23
|
+
import "dayjs";
|
|
24
|
+
import { DataFormatConfigContext } from "./data-format/contexts/DataFormatConfigContext.js";
|
|
25
|
+
import { DataFormatIntlsContext } from "./data-format/contexts/DataFormatIntlsContext.js";
|
|
26
|
+
import { default as default5 } from "./testing/renderWithProvider/renderWithProvider.js";
|
|
27
|
+
import { sleep } from "./testing/sleep.js";
|
|
28
|
+
import "react/jsx-runtime";
|
|
29
|
+
import "react-hot-toast";
|
|
30
|
+
import { useToaster } from "./toaster/hooks/useToaster.js";
|
|
31
|
+
import { TOASTER_DEFAULTS } from "./toaster/constants.js";
|
|
32
|
+
import { ToasterContext } from "./toaster/contexts/ToasterContext.js";
|
|
33
|
+
import { ToasterProvider } from "./toaster/providers/ToasterProvider.js";
|
|
34
|
+
import { DropdownContext } from "./DropdownContext/DropdownContext.js";
|
|
35
|
+
import { DropdownContextProvider } from "./DropdownContext/DropdownContextProvider.js";
|
|
36
|
+
import { useDropdown } from "./DropdownContext/useDropdown.js";
|
|
37
|
+
export {
|
|
38
|
+
COMPACT_DECIMAL_LARGER_NUMBER,
|
|
39
|
+
COMPACT_LARGER_NUMBER,
|
|
40
|
+
DATE,
|
|
41
|
+
DATETIME,
|
|
42
|
+
DATE_CONSTANTS_TARGET_FORMATS,
|
|
43
|
+
DEFAULT_DATA_FORMAT_CONFIG,
|
|
44
|
+
DEFAULT_DATA_FORMAT_INTL,
|
|
45
|
+
DEFAULT_DATA_FORMAT_NOTATION,
|
|
46
|
+
DEFAULT_FORMAT_DATE_OPTIONS,
|
|
47
|
+
DEFAULT_FORMAT_MONTH_LONG_OPTIONS,
|
|
48
|
+
DEFAULT_FORMAT_MONTH_SHORT_OPTIONS,
|
|
49
|
+
DEFAULT_FORMAT_NUMBER_OPTIONS,
|
|
50
|
+
DEFAULT_FORMAT_TIME_OPTIONS,
|
|
51
|
+
DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS,
|
|
52
|
+
DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS,
|
|
53
|
+
default2 as DSProvider,
|
|
54
|
+
DataFormatConfigContext,
|
|
55
|
+
DataFormatConfigProvider,
|
|
56
|
+
DataFormatIntlsContext,
|
|
57
|
+
DropdownContext,
|
|
58
|
+
DropdownContextProvider,
|
|
59
|
+
EU_DECIMAL_DELIMITER,
|
|
60
|
+
EU_NOTATION,
|
|
61
|
+
EU_THOUSAND_DELIMITER,
|
|
62
|
+
FormattedDate,
|
|
63
|
+
FormattedDateTime,
|
|
64
|
+
FormattedNumber,
|
|
65
|
+
FormattedRelativeDateTimeFrom,
|
|
66
|
+
FormattedRelativeDateTimeTo,
|
|
67
|
+
FormattedTime,
|
|
68
|
+
LARGER_NUMBER_LIMIT,
|
|
69
|
+
LONG,
|
|
70
|
+
LOWER_CASE,
|
|
71
|
+
LOWER_FIRST,
|
|
72
|
+
MONTH,
|
|
73
|
+
MONTHS_LONG,
|
|
74
|
+
MONTHS_SHORT,
|
|
75
|
+
MONTH_LONG,
|
|
76
|
+
MONTH_SHORT,
|
|
77
|
+
RELATIVE_FROM,
|
|
78
|
+
RELATIVE_FROM_WITHOUT_SUFFIX,
|
|
79
|
+
RELATIVE_TO,
|
|
80
|
+
RELATIVE_TO_WITHOUT_SUFFIX,
|
|
81
|
+
SHORT,
|
|
82
|
+
TIME,
|
|
83
|
+
TOASTER_DEFAULTS,
|
|
84
|
+
ToasterContext,
|
|
85
|
+
ToasterProvider,
|
|
86
|
+
UPPER_CASE,
|
|
87
|
+
UPPER_FIRST,
|
|
88
|
+
US_DECIMAL_DELIMITER,
|
|
89
|
+
US_NOTATION,
|
|
90
|
+
US_THOUSAND_DELIMITER,
|
|
91
|
+
WEEKDAY,
|
|
92
|
+
WEEKDAYS_LONG,
|
|
93
|
+
WEEKDAYS_SHORT,
|
|
94
|
+
WEEKDAY_LONG,
|
|
95
|
+
WEEKDAY_SHORT,
|
|
96
|
+
defaultColorsOrder,
|
|
97
|
+
getDataFormatConfigFromNotation,
|
|
98
|
+
getDefaultDataTimeOptions,
|
|
99
|
+
default3 as mediaQuery,
|
|
100
|
+
default5 as renderWithProvider,
|
|
101
|
+
sleep,
|
|
102
|
+
default4 as theme,
|
|
103
|
+
themeVariables,
|
|
104
|
+
useDataFormat,
|
|
105
|
+
useDataFormatConfig,
|
|
106
|
+
useDataFormatIntls,
|
|
107
|
+
useDataFormatUtils,
|
|
108
|
+
useDropdown,
|
|
109
|
+
useTheme,
|
|
110
|
+
useToaster,
|
|
111
|
+
withDataFormat
|
|
112
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { FlattenSimpleInterpolation, SimpleInterpolation } from 'styled-components';
|
|
2
|
+
import { BreakpointKey } from '../DSProvider/ThemeProvider/breakpoints';
|
|
3
3
|
export type Media = {
|
|
4
4
|
from: BreakpointsType;
|
|
5
5
|
to: BreakpointsType;
|
|
@@ -1,36 +1,26 @@
|
|
|
1
|
-
import { css } from
|
|
2
|
-
import breakpoints from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
for (var _len = arguments.length, interpolations = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
6
|
-
interpolations[_key - 1] = arguments[_key];
|
|
7
|
-
}
|
|
8
|
-
return css(["@media (min-width:", "em){", ";}"], breakpoints[label].max / 16, css.apply(void 0, [strings].concat(interpolations)));
|
|
9
|
-
};
|
|
1
|
+
import { css } from "styled-components";
|
|
2
|
+
import { breakpoints } from "../DSProvider/ThemeProvider/breakpoints.js";
|
|
3
|
+
const MEDIA_FROM = Object.keys(breakpoints).reduce((acc, label) => {
|
|
4
|
+
const mediaTemplateFunction = (strings, ...interpolations) => css(["@media (min-width:", "em){", ";}"], breakpoints[label].max / 16, css(strings, ...interpolations));
|
|
10
5
|
acc[label] = mediaTemplateFunction;
|
|
11
6
|
return acc;
|
|
12
7
|
}, {});
|
|
13
|
-
|
|
14
|
-
acc[label] =
|
|
15
|
-
for (var _len2 = arguments.length, interpolations = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
16
|
-
interpolations[_key2 - 1] = arguments[_key2];
|
|
17
|
-
}
|
|
18
|
-
return css(["@media (max-width:", "em){", ";}"], breakpoints[label].max / 16, css.apply(void 0, [strings].concat(interpolations)));
|
|
19
|
-
};
|
|
8
|
+
const MEDIA_TO = Object.keys(breakpoints).reduce((acc, label) => {
|
|
9
|
+
acc[label] = (strings, ...interpolations) => css(["@media (max-width:", "em){", ";}"], breakpoints[label].max / 16, css(strings, ...interpolations));
|
|
20
10
|
return acc;
|
|
21
11
|
}, {});
|
|
22
|
-
|
|
23
|
-
acc[label] =
|
|
24
|
-
for (var _len3 = arguments.length, interpolations = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
25
|
-
interpolations[_key3 - 1] = arguments[_key3];
|
|
26
|
-
}
|
|
27
|
-
return css(["@media (min-width:", "em) and (max-width:", "em){", ";}"], breakpoints[label].min / 16, breakpoints[label].max / 16, css.apply(void 0, [strings].concat(interpolations)));
|
|
28
|
-
};
|
|
12
|
+
const MEDIA_ONLY = Object.keys(breakpoints).reduce((acc, label) => {
|
|
13
|
+
acc[label] = (strings, ...interpolations) => css(["@media (min-width:", "em) and (max-width:", "em){", ";}"], breakpoints[label].min / 16, breakpoints[label].max / 16, css(strings, ...interpolations));
|
|
29
14
|
return acc;
|
|
30
15
|
}, {});
|
|
31
|
-
|
|
16
|
+
const mediaQuery = {
|
|
32
17
|
from: MEDIA_FROM,
|
|
33
18
|
to: MEDIA_TO,
|
|
34
19
|
only: MEDIA_ONLY
|
|
35
20
|
};
|
|
36
|
-
export
|
|
21
|
+
export {
|
|
22
|
+
MEDIA_FROM,
|
|
23
|
+
MEDIA_ONLY,
|
|
24
|
+
MEDIA_TO,
|
|
25
|
+
mediaQuery as default
|
|
26
|
+
};
|
package/dist/js/style.d.ts
CHANGED
package/dist/js/style.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "../style/variables.css";
|
|
1
|
+
import "./../style/core.css";
|
package/dist/js/testing/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { default as default2 } from "./renderWithProvider/renderWithProvider.js";
|
|
2
|
+
import { sleep } from "./sleep.js";
|
|
3
|
+
export {
|
|
4
|
+
default2 as renderWithProvider,
|
|
5
|
+
sleep
|
|
6
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
3
|
+
import { DSProviderProps } from '../../DSProvider/DSProvider';
|
|
4
|
+
import { DataFormatNotationType } from '../../data-format';
|
|
5
5
|
type Options = Omit<RenderOptions, 'queries'>;
|
|
6
6
|
declare const renderWithProvider: (node: ReactNode, options?: Options, props?: Partial<Omit<DSProviderProps, "onErrorIntl" | "dataFormatConfig">> & {
|
|
7
7
|
notation?: DataFormatNotationType;
|