@synerise/ds-core 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +181 -0
- package/dist/i18n/en.json +11 -1
- package/dist/i18n/es.json +10 -1
- package/dist/i18n/index.d.ts +51 -1
- package/dist/i18n/pl.json +11 -1
- package/dist/i18n/pt.json +11 -1
- package/dist/js/DSProvider/DSProvider.d.ts +2 -2
- package/dist/js/DSProvider/DSProvider.js +2 -2
- package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.d.ts +21 -1
- package/dist/js/DSProvider/ThemeProvider/breakpoints.d.ts +5 -1
- package/dist/js/data-format/components/FormattedDate.d.ts +9 -0
- package/dist/js/data-format/components/FormattedDate.js +9 -0
- package/dist/js/data-format/components/FormattedDateTime.d.ts +9 -0
- package/dist/js/data-format/components/FormattedDateTime.js +13 -0
- package/dist/js/data-format/components/FormattedNumber.d.ts +7 -0
- package/dist/js/data-format/components/FormattedNumber.js +9 -0
- package/dist/js/data-format/components/FormattedRelativeDateTime.d.ts +10 -0
- package/dist/js/data-format/components/FormattedRelativeDateTime.js +24 -0
- package/dist/js/data-format/components/FormattedTime.d.ts +9 -0
- package/dist/js/data-format/components/FormattedTime.js +13 -0
- package/dist/js/data-format/components/index.d.ts +5 -0
- package/dist/js/data-format/components/index.js +5 -0
- package/dist/js/data-format/constants/dataFormat.constants.d.ts +36 -0
- package/dist/js/data-format/constants/dataFormat.constants.js +52 -0
- package/dist/js/data-format/constants/dataFormatConfig.constants.d.ts +7 -0
- package/dist/js/data-format/constants/dataFormatConfig.constants.js +14 -0
- package/dist/js/data-format/constants/dateTimeParts.constants.d.ts +5 -0
- package/dist/js/data-format/constants/dateTimeParts.constants.js +4 -0
- package/dist/js/data-format/constants/index.d.ts +3 -0
- package/dist/js/data-format/constants/index.js +3 -0
- package/dist/js/data-format/contexts/DataFormatConfigContext.d.ts +2 -0
- package/dist/js/data-format/contexts/DataFormatConfigContext.js +3 -0
- package/dist/js/data-format/contexts/DataFormatIntlsContext.d.ts +2 -0
- package/dist/js/data-format/contexts/DataFormatIntlsContext.js +7 -0
- package/dist/js/data-format/contexts/index.d.ts +2 -0
- package/dist/js/data-format/contexts/index.js +2 -0
- package/dist/js/data-format/hocs/withDataFormat.d.ts +4 -0
- package/dist/js/data-format/hocs/withDataFormat.js +10 -0
- package/dist/js/data-format/hooks/index.d.ts +5 -0
- package/dist/js/data-format/hooks/index.js +5 -0
- package/dist/js/data-format/hooks/useDataFormat.d.ts +12 -0
- package/dist/js/data-format/hooks/useDataFormat.js +96 -0
- package/dist/js/data-format/hooks/useDataFormatConfig.d.ts +2 -0
- package/dist/js/data-format/hooks/useDataFormatConfig.js +5 -0
- package/dist/js/data-format/hooks/useDataFormatIntls.d.ts +2 -0
- package/dist/js/data-format/hooks/useDataFormatIntls.js +5 -0
- package/dist/js/data-format/hooks/useDataFormatUtils.d.ts +16 -0
- package/dist/js/data-format/hooks/useDataFormatUtils.js +113 -0
- package/dist/js/data-format/hooks/useSingleIntl.d.ts +4 -0
- package/dist/js/data-format/hooks/useSingleIntl.js +12 -0
- package/dist/js/data-format/index.d.ts +8 -0
- package/dist/js/data-format/index.js +7 -0
- package/dist/js/data-format/providers/DataFormatConfigProvider.d.ts +7 -0
- package/dist/js/data-format/providers/DataFormatConfigProvider.js +26 -0
- package/dist/js/data-format/types/dataFormat.types.d.ts +42 -0
- package/dist/js/data-format/types/dataFormat.types.js +5 -0
- package/dist/js/data-format/types/dataFormatConfig.types.d.ts +16 -0
- package/dist/js/data-format/types/dataFormatConfig.types.js +2 -0
- package/dist/js/data-format/types/dateTimeParts.types.d.ts +3 -0
- package/dist/js/data-format/types/dateTimeParts.types.js +2 -0
- package/dist/js/data-format/types/index.d.ts +3 -0
- package/dist/js/data-format/types/index.js +1 -0
- package/dist/js/data-format/utils/dataFormat.utils.d.ts +16 -0
- package/dist/js/data-format/utils/dataFormat.utils.js +119 -0
- package/dist/js/data-format/utils/dataFormatConfig.utils.d.ts +2 -0
- package/dist/js/data-format/utils/dataFormatConfig.utils.js +8 -0
- package/dist/js/data-format/utils/date.utils.d.ts +8 -0
- package/dist/js/data-format/utils/date.utils.js +50 -0
- package/dist/js/data-format/utils/dateTimeParts.utils.d.ts +14 -0
- package/dist/js/data-format/utils/dateTimeParts.utils.js +86 -0
- package/dist/js/data-format/utils/index.d.ts +5 -0
- package/dist/js/data-format/utils/index.js +5 -0
- package/dist/js/data-format/utils/timeZone.utils.d.ts +16 -0
- package/dist/js/data-format/utils/timeZone.utils.js +94 -0
- package/dist/js/index.d.ts +3 -0
- package/dist/js/index.js +4 -1
- package/dist/js/mediaQuery/mediaQuery.d.ts +1 -5
- package/dist/js/testing/index.d.ts +2 -0
- package/dist/js/testing/index.js +2 -0
- package/dist/js/testing/renderWithProvider/renderWithProvider.d.ts +10 -0
- package/dist/js/testing/renderWithProvider/renderWithProvider.js +28 -0
- package/dist/js/testing/renderWithProvider/renderWithProvider.spec.d.ts +1 -0
- package/dist/js/testing/sleep.d.ts +1 -0
- package/dist/js/testing/sleep.js +8 -0
- package/dist/js/toaster/Toaster.d.ts +2 -0
- package/dist/js/toaster/Toaster.js +8 -0
- package/dist/js/toaster/Toaster.types.d.ts +1 -0
- package/dist/js/toaster/Toaster.types.js +1 -0
- package/dist/js/toaster/constants.d.ts +2 -0
- package/dist/js/toaster/constants.js +8 -0
- package/dist/js/toaster/contexts/ToasterContext.d.ts +6 -0
- package/dist/js/toaster/contexts/ToasterContext.js +6 -0
- package/dist/js/toaster/hooks/useToaster.d.ts +1 -0
- package/dist/js/toaster/hooks/useToaster.js +5 -0
- package/dist/js/toaster/index.d.ts +6 -0
- package/dist/js/toaster/index.js +5 -0
- package/dist/js/toaster/providers/ToasterProvider.d.ts +6 -0
- package/dist/js/toaster/providers/ToasterProvider.js +17 -0
- package/package.json +15 -7
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import relativeTimePlugin from 'dayjs/plugin/relativeTime';
|
|
4
|
+
import { COMPACT_DECIMAL_LARGER_NUMBER, COMPACT_LARGER_NUMBER, DATE, DATETIME, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DEFAULT_FORMAT_NUMBER_OPTIONS, LARGER_NUMBER_LIMIT, LOWER_CASE, LOWER_FIRST, UPPER_CASE, UPPER_FIRST } from '../constants';
|
|
5
|
+
import { dateTimePartsToString, getDateParts, getDateTimePartsSubset, getMonthLongDateParts, getMonthShortDateParts, getTimeParts, getWeekdayLongDateParts, getWeekdayShortDateParts, numberPartsToString, translateDateTimeParts } from './dateTimeParts.utils';
|
|
6
|
+
dayjs.extend(relativeTimePlugin);
|
|
7
|
+
export var convertNumberString = function convertNumberString(value, numberFormatIntl, languageIntl, thousandDelimiter, decimalDelimiter, numberOptions) {
|
|
8
|
+
var updatedNumberOptions = numberOptions;
|
|
9
|
+
if (updatedNumberOptions != null && updatedNumberOptions.pluralOptions) {
|
|
10
|
+
return numberFormatIntl.formatPlural(value, updatedNumberOptions);
|
|
11
|
+
}
|
|
12
|
+
if ((updatedNumberOptions == null ? void 0 : updatedNumberOptions.targetFormat) === COMPACT_LARGER_NUMBER && value > LARGER_NUMBER_LIMIT) {
|
|
13
|
+
if (!updatedNumberOptions.notation) {
|
|
14
|
+
updatedNumberOptions.notation = 'compact';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if ((updatedNumberOptions == null ? void 0 : updatedNumberOptions.targetFormat) === COMPACT_DECIMAL_LARGER_NUMBER && value > LARGER_NUMBER_LIMIT) {
|
|
18
|
+
if (!updatedNumberOptions.notation) {
|
|
19
|
+
updatedNumberOptions.notation = 'compact';
|
|
20
|
+
}
|
|
21
|
+
if (!updatedNumberOptions.minimumFractionDigits && updatedNumberOptions.minimumFractionDigits !== 0) {
|
|
22
|
+
updatedNumberOptions.minimumFractionDigits = 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var numberParts = languageIntl.formatNumberToParts(value, _extends({}, DEFAULT_FORMAT_NUMBER_OPTIONS, updatedNumberOptions));
|
|
26
|
+
return numberPartsToString(numberParts, thousandDelimiter, decimalDelimiter);
|
|
27
|
+
};
|
|
28
|
+
export var convertDateToDateTimeString = function convertDateToDateTimeString(value, dateFormatIntl, timeFormatIntl, languageIntl, options) {
|
|
29
|
+
var dateParts = getDateParts(value, dateFormatIntl, options == null ? void 0 : options.dateOptions);
|
|
30
|
+
var datePartsByLanguageIntl = getDateParts(value, languageIntl, options == null ? void 0 : options.dateOptions);
|
|
31
|
+
var translatedDateParts = translateDateTimeParts(dateParts, datePartsByLanguageIntl, options);
|
|
32
|
+
var date = dateTimePartsToString(translatedDateParts);
|
|
33
|
+
var time = dateTimePartsToString(getTimeParts(value, timeFormatIntl, options == null ? void 0 : options.timeOptions));
|
|
34
|
+
return date + ", " + time;
|
|
35
|
+
};
|
|
36
|
+
export var convertDateToRelativeToString = function convertDateToRelativeToString(value, withoutSuffix) {
|
|
37
|
+
return dayjs().to(dayjs(value), withoutSuffix);
|
|
38
|
+
};
|
|
39
|
+
export var convertDateToRelativeFromString = function convertDateToRelativeFromString(value, withoutSuffix) {
|
|
40
|
+
return dayjs().from(dayjs(value), withoutSuffix);
|
|
41
|
+
};
|
|
42
|
+
export var convertDateToTimeString = function convertDateToTimeString(value, timeFormatIntl, options) {
|
|
43
|
+
return dateTimePartsToString(getTimeParts(value, timeFormatIntl, options));
|
|
44
|
+
};
|
|
45
|
+
export var convertDateToDateString = function convertDateToDateString(value, dateFormatIntl, languageIntl, options) {
|
|
46
|
+
var dateParts = getDateParts(value, dateFormatIntl, options);
|
|
47
|
+
var datePartsByLanguageIntl = getDateParts(value, languageIntl, options);
|
|
48
|
+
var translatedDateParts = translateDateTimeParts(dateParts, datePartsByLanguageIntl, options);
|
|
49
|
+
return dateTimePartsToString(translatedDateParts);
|
|
50
|
+
};
|
|
51
|
+
export var convertDateToWeekdayLongString = function convertDateToWeekdayLongString(value, dateFormatIntl, languageIntl, options) {
|
|
52
|
+
var weekdayLongDateParts = getWeekdayLongDateParts(value, dateFormatIntl, options);
|
|
53
|
+
var weekdayLongDatePartsByLanguageIntl = getWeekdayLongDateParts(value, languageIntl, options);
|
|
54
|
+
var translatedDateTimeParts = translateDateTimeParts(weekdayLongDateParts, weekdayLongDatePartsByLanguageIntl, options);
|
|
55
|
+
var reducedDateTimeParts = getDateTimePartsSubset(translatedDateTimeParts, ['weekday']);
|
|
56
|
+
return dateTimePartsToString(reducedDateTimeParts);
|
|
57
|
+
};
|
|
58
|
+
export var convertDateToWeekdayShortString = function convertDateToWeekdayShortString(value, dateFormatIntl, languageIntl, options) {
|
|
59
|
+
var weekdayShortDateParts = getWeekdayShortDateParts(value, dateFormatIntl, options);
|
|
60
|
+
var weekdayShortDatePartsByLanguageIntl = getWeekdayShortDateParts(value, languageIntl, options);
|
|
61
|
+
var translatedDateTimeParts = translateDateTimeParts(weekdayShortDateParts, weekdayShortDatePartsByLanguageIntl, options);
|
|
62
|
+
var reducedDateTimeParts = getDateTimePartsSubset(translatedDateTimeParts, ['weekday']);
|
|
63
|
+
return dateTimePartsToString(reducedDateTimeParts);
|
|
64
|
+
};
|
|
65
|
+
export var convertDateToMonthLongString = function convertDateToMonthLongString(value, dateFormatIntl, languageIntl, options) {
|
|
66
|
+
var monthLongDateParts = getMonthLongDateParts(value, dateFormatIntl, options);
|
|
67
|
+
var monthLongDatePartsByLanguageIntl = getMonthLongDateParts(value, languageIntl, options);
|
|
68
|
+
var translatedDateTimeParts = translateDateTimeParts(monthLongDateParts, monthLongDatePartsByLanguageIntl, options);
|
|
69
|
+
var reducedDateTimeParts = getDateTimePartsSubset(translatedDateTimeParts, ['month']);
|
|
70
|
+
return dateTimePartsToString(reducedDateTimeParts);
|
|
71
|
+
};
|
|
72
|
+
export var convertDateToMonthShortString = function convertDateToMonthShortString(value, dateFormatIntl, languageIntl, options) {
|
|
73
|
+
var monthShortDateParts = getMonthShortDateParts(value, dateFormatIntl, options);
|
|
74
|
+
var monthShortDatePartsByLanguageIntl = getMonthShortDateParts(value, languageIntl, options);
|
|
75
|
+
var translatedDateTimeParts = translateDateTimeParts(monthShortDateParts, monthShortDatePartsByLanguageIntl, options);
|
|
76
|
+
var reducedDateTimeParts = getDateTimePartsSubset(translatedDateTimeParts, ['month']);
|
|
77
|
+
return dateTimePartsToString(reducedDateTimeParts);
|
|
78
|
+
};
|
|
79
|
+
export var addPrefix = function addPrefix(value, options) {
|
|
80
|
+
var result = value;
|
|
81
|
+
if (options != null && options.prefix) {
|
|
82
|
+
result = (options == null ? void 0 : options.prefix) + result;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
export var addSuffix = function addSuffix(value, options) {
|
|
87
|
+
var result = value;
|
|
88
|
+
if (options != null && options.suffix) {
|
|
89
|
+
result += options == null ? void 0 : options.suffix;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
export var changeNamingConvention = function changeNamingConvention(value, options) {
|
|
94
|
+
var result = value;
|
|
95
|
+
switch (options == null ? void 0 : options.namingConvention) {
|
|
96
|
+
case UPPER_CASE:
|
|
97
|
+
result = result.toUpperCase();
|
|
98
|
+
break;
|
|
99
|
+
case UPPER_FIRST:
|
|
100
|
+
result = result.charAt(0).toUpperCase() + result.slice(1);
|
|
101
|
+
break;
|
|
102
|
+
case LOWER_CASE:
|
|
103
|
+
result = result.toLowerCase();
|
|
104
|
+
break;
|
|
105
|
+
case LOWER_FIRST:
|
|
106
|
+
result = result.charAt(0).toLowerCase() + result.slice(1);
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
export var getDefaultDataTimeOptions = function getDefaultDataTimeOptions(showTime) {
|
|
114
|
+
return {
|
|
115
|
+
targetFormat: showTime ? DATETIME : DATE,
|
|
116
|
+
dateOptions: DEFAULT_FORMAT_MONTH_SHORT_OPTIONS,
|
|
117
|
+
namingConvention: UPPER_FIRST
|
|
118
|
+
};
|
|
119
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { type DateConstantsTargetFormat, type DateToFormatOptions } from '../types';
|
|
3
|
+
export declare const getDatesRange: (start: Date, end: Date, interval: dayjs.UnitType) => Date[];
|
|
4
|
+
export declare const isValidDate: (date: Date) => boolean;
|
|
5
|
+
export declare const getConstantDatesAndFormattingOptions: (targetFormat: DateConstantsTargetFormat, isSundayFirstWeekDay: boolean, customStartDate?: Date, customEndDate?: Date, customInterval?: dayjs.UnitType) => {
|
|
6
|
+
constantDates: Date[];
|
|
7
|
+
defaultOptions: DateToFormatOptions;
|
|
8
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { MONTHS_LONG, MONTHS_SHORT, MONTH_LONG, MONTH_SHORT, UPPER_FIRST, WEEKDAYS_LONG, WEEKDAYS_SHORT, WEEKDAY_LONG, WEEKDAY_SHORT } from '../constants';
|
|
3
|
+
export var getDatesRange = function getDatesRange(start, end, interval) {
|
|
4
|
+
var startDate = dayjs(start);
|
|
5
|
+
var endDate = dayjs(end);
|
|
6
|
+
var diffInUnits = endDate.diff(startDate, interval);
|
|
7
|
+
return Array.from(Array(diffInUnits + 1).keys()).map(function (i) {
|
|
8
|
+
return startDate.add(i, interval).toDate();
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export var isValidDate = function isValidDate(date) {
|
|
12
|
+
return !isNaN(date.getTime());
|
|
13
|
+
};
|
|
14
|
+
export var getConstantDatesAndFormattingOptions = function getConstantDatesAndFormattingOptions(targetFormat, isSundayFirstWeekDay, customStartDate, customEndDate, customInterval) {
|
|
15
|
+
var startDate = new Date(2023, 0, isSundayFirstWeekDay ? 1 : 2);
|
|
16
|
+
var endDate = new Date(2023, 0, isSundayFirstWeekDay ? 1 : 2);
|
|
17
|
+
var defaultTargetFormat = MONTH_LONG;
|
|
18
|
+
var interval = 'month';
|
|
19
|
+
switch (targetFormat) {
|
|
20
|
+
case MONTHS_LONG:
|
|
21
|
+
endDate.setMonth(11);
|
|
22
|
+
interval = 'month';
|
|
23
|
+
defaultTargetFormat = MONTH_LONG;
|
|
24
|
+
break;
|
|
25
|
+
case MONTHS_SHORT:
|
|
26
|
+
endDate.setMonth(11);
|
|
27
|
+
interval = 'month';
|
|
28
|
+
defaultTargetFormat = MONTH_SHORT;
|
|
29
|
+
break;
|
|
30
|
+
case WEEKDAYS_LONG:
|
|
31
|
+
endDate.setDate(isSundayFirstWeekDay ? 7 : 8);
|
|
32
|
+
interval = 'day';
|
|
33
|
+
defaultTargetFormat = WEEKDAY_LONG;
|
|
34
|
+
break;
|
|
35
|
+
case WEEKDAYS_SHORT:
|
|
36
|
+
endDate.setDate(isSundayFirstWeekDay ? 7 : 8);
|
|
37
|
+
interval = 'day';
|
|
38
|
+
defaultTargetFormat = WEEKDAY_SHORT;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
constantDates: getDatesRange(customStartDate != null ? customStartDate : startDate, customEndDate != null ? customEndDate : endDate, customInterval != null ? customInterval : interval),
|
|
45
|
+
defaultOptions: {
|
|
46
|
+
namingConvention: UPPER_FIRST,
|
|
47
|
+
targetFormat: defaultTargetFormat
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FormatDateOptions, type IntlShape } from 'react-intl';
|
|
2
|
+
import { type DateToFormatOptions, type Delimiter } from '../types';
|
|
3
|
+
export declare const getDateParts: (value: Date, dateFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
4
|
+
export declare const getTimeParts: (value: Date, timeFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
5
|
+
export declare const getWeekdayLongDateParts: (value: Date, dateFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
6
|
+
export declare const getWeekdayShortDateParts: (value: Date, dateFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
7
|
+
export declare const getMonthLongDateParts: (value: Date, dateFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
8
|
+
export declare const getMonthShortDateParts: (value: Date, dateFormatIntl: IntlShape, option?: FormatDateOptions) => Intl.DateTimeFormatPart[];
|
|
9
|
+
export declare const getDateTimePartsSubset: (dateTimeParts: Intl.DateTimeFormatPart[], subsetTypes: Intl.DateTimeFormatPartTypes[]) => Intl.DateTimeFormatPart[];
|
|
10
|
+
export declare const nbspToSpace: (text: string) => string;
|
|
11
|
+
export declare const numberPartsToString: (numberParts: Intl.NumberFormatPart[], thousandDelimiter: Delimiter, decimalDelimiter: Delimiter) => string;
|
|
12
|
+
export declare const dateTimePartsToString: (dateTimeParts: Intl.DateTimeFormatPart[]) => string;
|
|
13
|
+
export declare const replaceDateTimeParts: (dateTimeParts: Intl.DateTimeFormatPart[], replacementDateTimeParts: Intl.DateTimeFormatPart[], replacementDateTimeFormatPartTypes: Intl.DateTimeFormatPartTypes[]) => Intl.DateTimeFormatPart[];
|
|
14
|
+
export declare const translateDateTimeParts: (dateTimeParts: Intl.DateTimeFormatPart[], dateTimePartsFromLanguageIntl: Intl.DateTimeFormatPart[], options?: DateToFormatOptions) => Intl.DateTimeFormatPart[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
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, LONG, MONTH, MONTH_LONG, MONTH_SHORT, SHORT, WEEKDAY, WEEKDAY_LONG, WEEKDAY_SHORT } from '../constants';
|
|
3
|
+
import { dateToIsoWithOffset } from './timeZone.utils';
|
|
4
|
+
export var getDateParts = function getDateParts(value, dateFormatIntl, option) {
|
|
5
|
+
return dateFormatIntl.formatDateToParts(dateToIsoWithOffset(value, dateFormatIntl), _extends({}, DEFAULT_FORMAT_DATE_OPTIONS, option));
|
|
6
|
+
};
|
|
7
|
+
export var getTimeParts = function getTimeParts(value, timeFormatIntl, option) {
|
|
8
|
+
return timeFormatIntl.formatDateToParts(dateToIsoWithOffset(value, timeFormatIntl), _extends({}, DEFAULT_FORMAT_TIME_OPTIONS, option));
|
|
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));
|
|
21
|
+
};
|
|
22
|
+
export var getDateTimePartsSubset = function getDateTimePartsSubset(dateTimeParts, subsetTypes) {
|
|
23
|
+
var resultDateTimeParts = [];
|
|
24
|
+
dateTimeParts.forEach(function (dateTimePart) {
|
|
25
|
+
if (subsetTypes.includes(dateTimePart.type)) {
|
|
26
|
+
resultDateTimeParts.push(dateTimePart);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return resultDateTimeParts;
|
|
30
|
+
};
|
|
31
|
+
export var nbspToSpace = function nbspToSpace(text) {
|
|
32
|
+
return text.replace(/ /g, ' ').replace(/\u00A0/g, ' ');
|
|
33
|
+
};
|
|
34
|
+
export var numberPartsToString = function numberPartsToString(numberParts, thousandDelimiter, decimalDelimiter) {
|
|
35
|
+
var numberPartsWithReplacedDelimiters = numberParts.map(function (numberPart) {
|
|
36
|
+
var numberPartWithReplacedDelimiters = numberPart;
|
|
37
|
+
if (numberPartWithReplacedDelimiters.type === 'group') {
|
|
38
|
+
numberPartWithReplacedDelimiters.value = thousandDelimiter;
|
|
39
|
+
}
|
|
40
|
+
if (numberPartWithReplacedDelimiters.type === 'decimal') {
|
|
41
|
+
numberPartWithReplacedDelimiters.value = decimalDelimiter;
|
|
42
|
+
}
|
|
43
|
+
return numberPartWithReplacedDelimiters;
|
|
44
|
+
});
|
|
45
|
+
var joinedNumberParts = numberPartsWithReplacedDelimiters.map(function (numberPart) {
|
|
46
|
+
return numberPart.value;
|
|
47
|
+
}).join('');
|
|
48
|
+
return nbspToSpace(joinedNumberParts);
|
|
49
|
+
};
|
|
50
|
+
export var dateTimePartsToString = function dateTimePartsToString(dateTimeParts) {
|
|
51
|
+
var joinedDateTimeParts = dateTimeParts.map(function (dateTimePart) {
|
|
52
|
+
return dateTimePart.value;
|
|
53
|
+
}).join('');
|
|
54
|
+
return nbspToSpace(joinedDateTimeParts);
|
|
55
|
+
};
|
|
56
|
+
export var replaceDateTimeParts = function replaceDateTimeParts(dateTimeParts, replacementDateTimeParts, replacementDateTimeFormatPartTypes) {
|
|
57
|
+
return dateTimeParts.map(function (dateTimePart) {
|
|
58
|
+
var dateTimePartToReplace = dateTimePart;
|
|
59
|
+
if (replacementDateTimeFormatPartTypes != null && replacementDateTimeFormatPartTypes.includes(dateTimePartToReplace.type)) {
|
|
60
|
+
var foundedReplacementDateTimePart = replacementDateTimeParts == null ? void 0 : replacementDateTimeParts.find(function (replacementDateTimePart) {
|
|
61
|
+
return replacementDateTimePart.type === dateTimePartToReplace.type;
|
|
62
|
+
});
|
|
63
|
+
if (foundedReplacementDateTimePart) {
|
|
64
|
+
dateTimePartToReplace.value = foundedReplacementDateTimePart.value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return dateTimePartToReplace;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
export var translateDateTimeParts = function translateDateTimeParts(dateTimeParts, dateTimePartsFromLanguageIntl, options) {
|
|
71
|
+
var _options$dateOptions, _options$dateOptions2;
|
|
72
|
+
var replacementDateTimeFormatPartTypes = [];
|
|
73
|
+
if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_LONG || (options == null ? void 0 : options.targetFormat) === WEEKDAY_SHORT) {
|
|
74
|
+
replacementDateTimeFormatPartTypes.push(WEEKDAY);
|
|
75
|
+
}
|
|
76
|
+
if ((options == null ? void 0 : options.targetFormat) === MONTH_LONG || (options == null ? void 0 : options.targetFormat) === MONTH_SHORT) {
|
|
77
|
+
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
78
|
+
}
|
|
79
|
+
if ((options == null || (_options$dateOptions = options.dateOptions) == null ? void 0 : _options$dateOptions.month) === LONG || (options == null || (_options$dateOptions2 = options.dateOptions) == null ? void 0 : _options$dateOptions2.month) === SHORT) {
|
|
80
|
+
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
81
|
+
}
|
|
82
|
+
if ((options == null ? void 0 : options.month) === LONG || (options == null ? void 0 : options.month) === SHORT) {
|
|
83
|
+
replacementDateTimeFormatPartTypes.push(MONTH);
|
|
84
|
+
}
|
|
85
|
+
return replaceDateTimeParts(dateTimeParts, dateTimePartsFromLanguageIntl, replacementDateTimeFormatPartTypes);
|
|
86
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getDataFormatConfigFromNotation } from './dataFormatConfig.utils';
|
|
2
|
+
export { getDateParts, getTimeParts, getWeekdayLongDateParts, getWeekdayShortDateParts, getDateTimePartsSubset, nbspToSpace, numberPartsToString, dateTimePartsToString, replaceDateTimeParts, translateDateTimeParts, getMonthLongDateParts, getMonthShortDateParts, } from './dateTimeParts.utils';
|
|
3
|
+
export { convertNumberString, convertDateToDateTimeString, convertDateToRelativeToString, convertDateToRelativeFromString, convertDateToTimeString, convertDateToDateString, convertDateToWeekdayLongString, convertDateToWeekdayShortString, convertDateToMonthLongString, convertDateToMonthShortString, addPrefix, addSuffix, changeNamingConvention, getDefaultDataTimeOptions, } from './dataFormat.utils';
|
|
4
|
+
export { getConstantDatesAndFormattingOptions } from './date.utils';
|
|
5
|
+
export { applyTimezoneOffset, currentTimeInTimezone, getValueAsLocalDate, getTimeZone, dateStringTimeZoneParts, removeTimeZoneOffset, } from './timeZone.utils';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getDataFormatConfigFromNotation } from './dataFormatConfig.utils';
|
|
2
|
+
export { getDateParts, getTimeParts, getWeekdayLongDateParts, getWeekdayShortDateParts, getDateTimePartsSubset, nbspToSpace, numberPartsToString, dateTimePartsToString, replaceDateTimeParts, translateDateTimeParts, getMonthLongDateParts, getMonthShortDateParts } from './dateTimeParts.utils';
|
|
3
|
+
export { convertNumberString, convertDateToDateTimeString, convertDateToRelativeToString, convertDateToRelativeFromString, convertDateToTimeString, convertDateToDateString, convertDateToWeekdayLongString, convertDateToWeekdayShortString, convertDateToMonthLongString, convertDateToMonthShortString, addPrefix, addSuffix, changeNamingConvention, getDefaultDataTimeOptions } from './dataFormat.utils';
|
|
4
|
+
export { getConstantDatesAndFormattingOptions } from './date.utils';
|
|
5
|
+
export { applyTimezoneOffset, currentTimeInTimezone, getValueAsLocalDate, getTimeZone, dateStringTimeZoneParts, removeTimeZoneOffset } from './timeZone.utils';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl';
|
|
2
|
+
export declare const TIMEZONE_OFFSET_REGEX: RegExp;
|
|
3
|
+
export declare const dateToIsoWithOffset: (value: Date, intlObject: IntlShape) => string;
|
|
4
|
+
export declare const applyTimezoneOffset: (date: Date | undefined, timezoneOffset: true | string | undefined, intl?: IntlShape) => string | Date | undefined;
|
|
5
|
+
export declare const removeTimeZoneOffset: (dateString: string | Date) => string;
|
|
6
|
+
export declare const extractTimeZoneOffset: (datestring: string) => string | null;
|
|
7
|
+
export declare const dateStringTimeZoneParts: (dateTimeIsoString: string) => {
|
|
8
|
+
dateTimeString: string;
|
|
9
|
+
offsetString: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const getLocalDateInTimeZone: (dateIsoString: string, timezone: string) => Date;
|
|
12
|
+
export declare function toIsoString(date: Date, timeZone?: string | undefined): string;
|
|
13
|
+
export declare const currentTimeInTimezone: (timezoneString: string) => Date;
|
|
14
|
+
export declare const dateTimeStringToLocalDate: (value?: string, timeZone?: string) => Date;
|
|
15
|
+
export declare const getValueAsLocalDate: (value?: Date | string, timeZone?: string) => Date;
|
|
16
|
+
export declare const getTimeZone: (timeZone?: boolean | string, intl?: IntlShape) => string | undefined;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { format, getTimezoneOffset, utcToZonedTime } from 'date-fns-tz';
|
|
2
|
+
export var TIMEZONE_OFFSET_REGEX = /([+-]\d\d:\d\d)|([Z])$/;
|
|
3
|
+
var defaultTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
4
|
+
export var dateToIsoWithOffset = function dateToIsoWithOffset(value, intlObject) {
|
|
5
|
+
return format(value, "yyyy-MM-dd'T'HH:mm:ssxxx", {
|
|
6
|
+
timeZone: (intlObject == null ? void 0 : intlObject.timeZone) || defaultTimezone
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export var applyTimezoneOffset = function applyTimezoneOffset(date, timezoneOffset, intl) {
|
|
10
|
+
if (!timezoneOffset) {
|
|
11
|
+
return date;
|
|
12
|
+
}
|
|
13
|
+
var timezoneString = getTimeZone(timezoneOffset, intl);
|
|
14
|
+
return toIsoString(date, timezoneString);
|
|
15
|
+
};
|
|
16
|
+
export var removeTimeZoneOffset = function removeTimeZoneOffset(dateString) {
|
|
17
|
+
var date = dateString instanceof Date ? dateString.toISOString() : dateString;
|
|
18
|
+
var finalDate = date.replace(TIMEZONE_OFFSET_REGEX, '');
|
|
19
|
+
return finalDate;
|
|
20
|
+
};
|
|
21
|
+
export var extractTimeZoneOffset = function extractTimeZoneOffset(datestring) {
|
|
22
|
+
var date = datestring.toString();
|
|
23
|
+
var found = date.match(TIMEZONE_OFFSET_REGEX);
|
|
24
|
+
return found && found[0];
|
|
25
|
+
};
|
|
26
|
+
export var dateStringTimeZoneParts = function dateStringTimeZoneParts(dateTimeIsoString) {
|
|
27
|
+
return {
|
|
28
|
+
dateTimeString: removeTimeZoneOffset(dateTimeIsoString),
|
|
29
|
+
offsetString: extractTimeZoneOffset(dateTimeIsoString)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export var getLocalDateInTimeZone = function getLocalDateInTimeZone(dateIsoString, timezone) {
|
|
33
|
+
var _dateStringTimeZonePa = dateStringTimeZoneParts(dateIsoString),
|
|
34
|
+
offsetString = _dateStringTimeZonePa.offsetString,
|
|
35
|
+
dateTimeString = _dateStringTimeZonePa.dateTimeString;
|
|
36
|
+
var localDate = new Date(dateTimeString);
|
|
37
|
+
var localTimezoneOffset = getTimezoneOffset(timezone, localDate); // +2
|
|
38
|
+
var dateTimezoneOffset = offsetString ? getTimezoneOffset(offsetString, localDate) : 0; // -4
|
|
39
|
+
|
|
40
|
+
var offsetDiff = localTimezoneOffset - dateTimezoneOffset;
|
|
41
|
+
localDate.setMilliseconds(localDate.getMilliseconds() + offsetDiff);
|
|
42
|
+
return localDate;
|
|
43
|
+
};
|
|
44
|
+
var pad = function pad(num) {
|
|
45
|
+
return (num < 10 ? '0' : '') + num;
|
|
46
|
+
};
|
|
47
|
+
export function toIsoString(date, timeZone) {
|
|
48
|
+
if (timeZone === void 0) {
|
|
49
|
+
timeZone = 'UTC';
|
|
50
|
+
}
|
|
51
|
+
if (!timeZone) {
|
|
52
|
+
return date.toISOString();
|
|
53
|
+
}
|
|
54
|
+
var timeZoneOffset = getTimezoneOffset(timeZone, date);
|
|
55
|
+
var dif = timeZoneOffset >= 0 ? '+' : '-';
|
|
56
|
+
var tzHours = pad(Math.floor(Math.abs(timeZoneOffset) / 60 / 60 / 1000));
|
|
57
|
+
var tzMinutes = pad(Math.abs(timeZoneOffset) / 60 / 1000 % 60);
|
|
58
|
+
return date.getFullYear() + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + "T" + pad(date.getHours()) + ":" + pad(date.getMinutes()) + ":" + pad(date.getSeconds()) + dif + tzHours + ":" + tzMinutes;
|
|
59
|
+
}
|
|
60
|
+
export var currentTimeInTimezone = function currentTimeInTimezone(timezoneString) {
|
|
61
|
+
var now = new Date();
|
|
62
|
+
return utcToZonedTime(now.toISOString(), timezoneString);
|
|
63
|
+
};
|
|
64
|
+
export var dateTimeStringToLocalDate = function dateTimeStringToLocalDate(value, timeZone) {
|
|
65
|
+
if (!value || !timeZone) {
|
|
66
|
+
return new Date();
|
|
67
|
+
}
|
|
68
|
+
if (timeZone !== undefined) {
|
|
69
|
+
return getLocalDateInTimeZone(value, timeZone);
|
|
70
|
+
}
|
|
71
|
+
// FIXME ????
|
|
72
|
+
return typeof value === 'string' ? new Date(value) : value;
|
|
73
|
+
};
|
|
74
|
+
export var getValueAsLocalDate = function getValueAsLocalDate(value, timeZone) {
|
|
75
|
+
if (!value) {
|
|
76
|
+
return new Date();
|
|
77
|
+
}
|
|
78
|
+
if (timeZone !== undefined) {
|
|
79
|
+
if (typeof value !== 'string') {
|
|
80
|
+
return getLocalDateInTimeZone(value.toISOString(), timeZone);
|
|
81
|
+
}
|
|
82
|
+
return getLocalDateInTimeZone(value, timeZone);
|
|
83
|
+
}
|
|
84
|
+
return typeof value === 'string' ? new Date(value) : value;
|
|
85
|
+
};
|
|
86
|
+
export var getTimeZone = function getTimeZone(timeZone, intl) {
|
|
87
|
+
if (!timeZone) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
if (timeZone === true) {
|
|
91
|
+
return (intl == null ? void 0 : intl.timeZone) || defaultTimezone;
|
|
92
|
+
}
|
|
93
|
+
return timeZone;
|
|
94
|
+
};
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as DSProvider, type DSProviderProps } from './DSProvider';
|
|
2
2
|
export { default as mediaQuery } from './mediaQuery/mediaQuery';
|
|
3
3
|
export { theme, useTheme, defaultColorsOrder, themeVariables, type ThemePropsVars, type ThemeProps, type WithTheme, type DefaultColor, } from './DSProvider/ThemeProvider/theme';
|
|
4
|
+
export * from './data-format';
|
|
5
|
+
export * from './testing';
|
|
6
|
+
export * from './toaster';
|
package/dist/js/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as DSProvider } from './DSProvider';
|
|
2
2
|
export { default as mediaQuery } from './mediaQuery/mediaQuery';
|
|
3
|
-
export { theme, useTheme, defaultColorsOrder, themeVariables } from './DSProvider/ThemeProvider/theme';
|
|
3
|
+
export { theme, useTheme, defaultColorsOrder, themeVariables } from './DSProvider/ThemeProvider/theme';
|
|
4
|
+
export * from './data-format';
|
|
5
|
+
export * from './testing';
|
|
6
|
+
export * from './toaster';
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { type FlattenSimpleInterpolation, type SimpleInterpolation } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
export type BreakpointsData = Record<BreakpointKey, {
|
|
4
|
-
min: number;
|
|
5
|
-
max: number;
|
|
6
|
-
}>;
|
|
2
|
+
import { type BreakpointKey } from '../DSProvider/ThemeProvider/breakpoints';
|
|
7
3
|
export type Media = {
|
|
8
4
|
from: BreakpointsType;
|
|
9
5
|
to: BreakpointsType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type RenderOptions, type RenderResult } from '@testing-library/react';
|
|
3
|
+
import { type DSProviderProps } from '../../DSProvider/DSProvider';
|
|
4
|
+
import { type DataFormatNotationType } from '../../data-format';
|
|
5
|
+
type Options = Omit<RenderOptions, 'queries'>;
|
|
6
|
+
declare const renderWithProvider: (node: ReactNode, options?: Options, props?: Partial<Omit<DSProviderProps, "onErrorIntl" | "dataFormatConfig">> & {
|
|
7
|
+
notation?: DataFormatNotationType;
|
|
8
|
+
applyTimeZoneOffset?: boolean;
|
|
9
|
+
}) => RenderResult;
|
|
10
|
+
export default renderWithProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var _excluded = ["notation", "applyTimeZoneOffset"];
|
|
2
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import DSProvider from '../../DSProvider/DSProvider';
|
|
7
|
+
import { getDataFormatConfigFromNotation } from '../../data-format';
|
|
8
|
+
var _renderWithProvider = function renderWithProvider(node, options, props) {
|
|
9
|
+
var _ref = props || {},
|
|
10
|
+
notation = _ref.notation,
|
|
11
|
+
applyTimeZoneOffset = _ref.applyTimeZoneOffset,
|
|
12
|
+
providerProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
13
|
+
var dataFormatConfigProps = applyTimeZoneOffset !== undefined || notation ? _extends({}, notation ? getDataFormatConfigFromNotation(notation) : {}, {
|
|
14
|
+
applyTimeZoneOffset: applyTimeZoneOffset
|
|
15
|
+
}) : {};
|
|
16
|
+
var rendered = render(/*#__PURE__*/React.createElement(DSProvider, _extends({
|
|
17
|
+
onErrorIntl: function onErrorIntl() {},
|
|
18
|
+
dataFormatConfig: dataFormatConfigProps
|
|
19
|
+
}, providerProps), node), options);
|
|
20
|
+
return _extends({}, rendered, {
|
|
21
|
+
rerender: function rerender(ui, opt) {
|
|
22
|
+
return _renderWithProvider(ui, _extends({
|
|
23
|
+
container: rendered.container
|
|
24
|
+
}, opt));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export default _renderWithProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sleep: (duration?: number) => Promise<unknown>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Toaster as BaseToaster } from 'react-hot-toast';
|
|
3
|
+
import { useToaster } from './hooks/useToaster';
|
|
4
|
+
export var Toaster = function Toaster() {
|
|
5
|
+
var _useToaster = useToaster(),
|
|
6
|
+
options = _useToaster.options;
|
|
7
|
+
return /*#__PURE__*/React.createElement(BaseToaster, options);
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { ToasterProps } from 'react-hot-toast';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useToaster: () => import("../contexts/ToasterContext").ToastContextType;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Toaster as default } from './Toaster';
|
|
2
|
+
export { TOASTER_DEFAULTS } from './constants';
|
|
3
|
+
export { ToasterContext, type ToastContextType, } from './contexts/ToasterContext';
|
|
4
|
+
export { useToaster } from './hooks/useToaster';
|
|
5
|
+
export { ToasterProvider } from './providers/ToasterProvider';
|
|
6
|
+
export type { ToasterProps } from './Toaster.types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Toaster as default } from './Toaster';
|
|
2
|
+
export { TOASTER_DEFAULTS } from './constants';
|
|
3
|
+
export { ToasterContext } from './contexts/ToasterContext';
|
|
4
|
+
export { useToaster } from './hooks/useToaster';
|
|
5
|
+
export { ToasterProvider } from './providers/ToasterProvider';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { TOASTER_DEFAULTS } from '../constants';
|
|
3
|
+
import { ToasterContext } from '../contexts/ToasterContext';
|
|
4
|
+
export var ToasterProvider = function ToasterProvider(_ref) {
|
|
5
|
+
var children = _ref.children,
|
|
6
|
+
_ref$toasterProps = _ref.toasterProps,
|
|
7
|
+
toasterProps = _ref$toasterProps === void 0 ? TOASTER_DEFAULTS : _ref$toasterProps;
|
|
8
|
+
var _useState = useState(toasterProps),
|
|
9
|
+
options = _useState[0],
|
|
10
|
+
setOptions = _useState[1];
|
|
11
|
+
return /*#__PURE__*/React.createElement(ToasterContext.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
options: options,
|
|
14
|
+
setOptions: setOptions
|
|
15
|
+
}
|
|
16
|
+
}, children);
|
|
17
|
+
};
|