@synerise/ds-core 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +181 -0
- package/dist/i18n/es.json +350 -24
- package/dist/i18n/index.d.ts +425 -23
- package/dist/i18n/pt.json +87 -11
- 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 +740 -0
- 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 +14 -7
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export type BreakpointKey = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
|
|
2
|
+
export type BreakpointsData = Record<BreakpointKey, {
|
|
3
|
+
min: number;
|
|
4
|
+
max: number;
|
|
5
|
+
}>;
|
|
2
6
|
export declare const breakpoints: BreakpointsData;
|
|
3
7
|
export default breakpoints;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Dayjs } from 'dayjs';
|
|
2
|
+
import { type Moment } from 'moment';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { type DateToFormatOptions } from '../types';
|
|
5
|
+
export type FormattedDateProps = {
|
|
6
|
+
value: Date | Moment | Dayjs;
|
|
7
|
+
options?: DateToFormatOptions;
|
|
8
|
+
};
|
|
9
|
+
export declare const FormattedDate: React.FC<FormattedDateProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDataFormat } from '../hooks';
|
|
3
|
+
export var FormattedDate = function FormattedDate(_ref) {
|
|
4
|
+
var value = _ref.value,
|
|
5
|
+
options = _ref.options;
|
|
6
|
+
var _useDataFormat = useDataFormat(),
|
|
7
|
+
formatValue = _useDataFormat.formatValue;
|
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, options));
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Dayjs } from 'dayjs';
|
|
2
|
+
import { type Moment } from 'moment';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { type DateToFormatOptions } from '../types';
|
|
5
|
+
export type FormattedTimeProps = {
|
|
6
|
+
value: Date | Moment | Dayjs;
|
|
7
|
+
options?: DateToFormatOptions;
|
|
8
|
+
};
|
|
9
|
+
export declare const FormattedDateTime: React.FC<FormattedTimeProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 React from 'react';
|
|
3
|
+
import { DATETIME } from '../constants';
|
|
4
|
+
import { useDataFormat } from '../hooks';
|
|
5
|
+
export var FormattedDateTime = function FormattedDateTime(_ref) {
|
|
6
|
+
var value = _ref.value,
|
|
7
|
+
options = _ref.options;
|
|
8
|
+
var _useDataFormat = useDataFormat(),
|
|
9
|
+
formatValue = _useDataFormat.formatValue;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
11
|
+
targetFormat: DATETIME
|
|
12
|
+
})));
|
|
13
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDataFormat } from '../hooks';
|
|
3
|
+
export var FormattedNumber = function FormattedNumber(_ref) {
|
|
4
|
+
var value = _ref.value,
|
|
5
|
+
options = _ref.options;
|
|
6
|
+
var _useDataFormat = useDataFormat(),
|
|
7
|
+
formatValue = _useDataFormat.formatValue;
|
|
8
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, options));
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Dayjs } from 'dayjs';
|
|
2
|
+
import { type Moment } from 'moment';
|
|
3
|
+
import { type DateToFormatOptions } from '../types';
|
|
4
|
+
export type FormattedRelativeDateTimeProps = {
|
|
5
|
+
value: Date | Moment | Dayjs;
|
|
6
|
+
withoutSuffix?: boolean;
|
|
7
|
+
options?: DateToFormatOptions;
|
|
8
|
+
};
|
|
9
|
+
export declare const FormattedRelativeDateTimeTo: ({ value, withoutSuffix, options, }: FormattedRelativeDateTimeProps) => JSX.Element;
|
|
10
|
+
export declare const FormattedRelativeDateTimeFrom: ({ value, withoutSuffix, options, }: FormattedRelativeDateTimeProps) => JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 React from 'react';
|
|
3
|
+
import { RELATIVE_FROM, RELATIVE_FROM_WITHOUT_SUFFIX, RELATIVE_TO, RELATIVE_TO_WITHOUT_SUFFIX } from '../constants';
|
|
4
|
+
import { useDataFormat } from '../hooks';
|
|
5
|
+
export var FormattedRelativeDateTimeTo = function FormattedRelativeDateTimeTo(_ref) {
|
|
6
|
+
var value = _ref.value,
|
|
7
|
+
withoutSuffix = _ref.withoutSuffix,
|
|
8
|
+
options = _ref.options;
|
|
9
|
+
var _useDataFormat = useDataFormat(),
|
|
10
|
+
formatValue = _useDataFormat.formatValue;
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
12
|
+
targetFormat: withoutSuffix ? RELATIVE_TO_WITHOUT_SUFFIX : RELATIVE_TO
|
|
13
|
+
})));
|
|
14
|
+
};
|
|
15
|
+
export var FormattedRelativeDateTimeFrom = function FormattedRelativeDateTimeFrom(_ref2) {
|
|
16
|
+
var value = _ref2.value,
|
|
17
|
+
withoutSuffix = _ref2.withoutSuffix,
|
|
18
|
+
options = _ref2.options;
|
|
19
|
+
var _useDataFormat2 = useDataFormat(),
|
|
20
|
+
formatValue = _useDataFormat2.formatValue;
|
|
21
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
22
|
+
targetFormat: withoutSuffix ? RELATIVE_FROM_WITHOUT_SUFFIX : RELATIVE_FROM
|
|
23
|
+
})));
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Dayjs } from 'dayjs';
|
|
2
|
+
import { type Moment } from 'moment';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { type DateToFormatOptions } from '../types';
|
|
5
|
+
export type FormattedTimeProps = {
|
|
6
|
+
value: Date | Moment | Dayjs;
|
|
7
|
+
options?: DateToFormatOptions;
|
|
8
|
+
};
|
|
9
|
+
export declare const FormattedTime: React.FC<FormattedTimeProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 React from 'react';
|
|
3
|
+
import { TIME } from '../constants';
|
|
4
|
+
import { useDataFormat } from '../hooks';
|
|
5
|
+
export var FormattedTime = function FormattedTime(_ref) {
|
|
6
|
+
var value = _ref.value,
|
|
7
|
+
options = _ref.options;
|
|
8
|
+
var _useDataFormat = useDataFormat(),
|
|
9
|
+
formatValue = _useDataFormat.formatValue;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
11
|
+
targetFormat: TIME
|
|
12
|
+
})));
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FormattedDate } from './FormattedDate';
|
|
2
|
+
export { FormattedDateTime } from './FormattedDateTime';
|
|
3
|
+
export { FormattedNumber } from './FormattedNumber';
|
|
4
|
+
export { FormattedTime } from './FormattedTime';
|
|
5
|
+
export { FormattedRelativeDateTimeFrom, FormattedRelativeDateTimeTo, } from './FormattedRelativeDateTime';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FormattedDate } from './FormattedDate';
|
|
2
|
+
export { FormattedDateTime } from './FormattedDateTime';
|
|
3
|
+
export { FormattedNumber } from './FormattedNumber';
|
|
4
|
+
export { FormattedTime } from './FormattedTime';
|
|
5
|
+
export { FormattedRelativeDateTimeFrom, FormattedRelativeDateTimeTo } from './FormattedRelativeDateTime';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type FormatDateOptions, type FormatNumberOptions } from 'react-intl';
|
|
2
|
+
import { type DateConstantsTargetFormat, type DateTargetFormat, type Delimiter, type NamingConvention, type NumberTargetFormat } from '../types';
|
|
3
|
+
export declare const DEFAULT_FORMAT_NUMBER_OPTIONS: FormatNumberOptions;
|
|
4
|
+
export declare const DEFAULT_FORMAT_DATE_OPTIONS: FormatDateOptions;
|
|
5
|
+
export declare const DEFAULT_FORMAT_TIME_OPTIONS: FormatDateOptions;
|
|
6
|
+
export declare const DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS: FormatDateOptions;
|
|
7
|
+
export declare const DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS: FormatDateOptions;
|
|
8
|
+
export declare const DEFAULT_FORMAT_MONTH_LONG_OPTIONS: FormatDateOptions;
|
|
9
|
+
export declare const DEFAULT_FORMAT_MONTH_SHORT_OPTIONS: FormatDateOptions;
|
|
10
|
+
export declare const DATE: DateTargetFormat;
|
|
11
|
+
export declare const TIME: DateTargetFormat;
|
|
12
|
+
export declare const DATETIME: DateTargetFormat;
|
|
13
|
+
export declare const RELATIVE_FROM: DateTargetFormat;
|
|
14
|
+
export declare const RELATIVE_TO: DateTargetFormat;
|
|
15
|
+
export declare const RELATIVE_FROM_WITHOUT_SUFFIX: DateTargetFormat;
|
|
16
|
+
export declare const RELATIVE_TO_WITHOUT_SUFFIX: DateTargetFormat;
|
|
17
|
+
export declare const WEEKDAY_LONG: DateTargetFormat;
|
|
18
|
+
export declare const WEEKDAY_SHORT: DateTargetFormat;
|
|
19
|
+
export declare const MONTH_LONG: DateTargetFormat;
|
|
20
|
+
export declare const MONTH_SHORT: DateTargetFormat;
|
|
21
|
+
export declare const COMPACT_LARGER_NUMBER: NumberTargetFormat;
|
|
22
|
+
export declare const COMPACT_DECIMAL_LARGER_NUMBER: NumberTargetFormat;
|
|
23
|
+
export declare const LARGER_NUMBER_LIMIT = 999;
|
|
24
|
+
export declare const UPPER_CASE: NamingConvention;
|
|
25
|
+
export declare const UPPER_FIRST: NamingConvention;
|
|
26
|
+
export declare const LOWER_CASE: NamingConvention;
|
|
27
|
+
export declare const LOWER_FIRST: NamingConvention;
|
|
28
|
+
export declare const US_THOUSAND_DELIMITER: Delimiter;
|
|
29
|
+
export declare const US_DECIMAL_DELIMITER: Delimiter;
|
|
30
|
+
export declare const EU_THOUSAND_DELIMITER: Delimiter;
|
|
31
|
+
export declare const EU_DECIMAL_DELIMITER: Delimiter;
|
|
32
|
+
export declare const DATE_CONSTANTS_TARGET_FORMATS: DateConstantsTargetFormat[];
|
|
33
|
+
export declare const MONTHS_LONG: DateConstantsTargetFormat;
|
|
34
|
+
export declare const MONTHS_SHORT: DateConstantsTargetFormat;
|
|
35
|
+
export declare const WEEKDAYS_LONG: DateConstantsTargetFormat;
|
|
36
|
+
export declare const WEEKDAYS_SHORT: DateConstantsTargetFormat;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export var DEFAULT_FORMAT_NUMBER_OPTIONS = {
|
|
2
|
+
maximumFractionDigits: 2,
|
|
3
|
+
useGrouping: true
|
|
4
|
+
};
|
|
5
|
+
export var DEFAULT_FORMAT_DATE_OPTIONS = {
|
|
6
|
+
year: 'numeric',
|
|
7
|
+
month: 'numeric',
|
|
8
|
+
day: 'numeric'
|
|
9
|
+
};
|
|
10
|
+
export var DEFAULT_FORMAT_TIME_OPTIONS = {
|
|
11
|
+
hour: 'numeric',
|
|
12
|
+
minute: 'numeric'
|
|
13
|
+
};
|
|
14
|
+
export var DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS = {
|
|
15
|
+
weekday: 'long'
|
|
16
|
+
};
|
|
17
|
+
export var DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS = {
|
|
18
|
+
weekday: 'short'
|
|
19
|
+
};
|
|
20
|
+
export var DEFAULT_FORMAT_MONTH_LONG_OPTIONS = {
|
|
21
|
+
month: 'long'
|
|
22
|
+
};
|
|
23
|
+
export var DEFAULT_FORMAT_MONTH_SHORT_OPTIONS = {
|
|
24
|
+
month: 'short'
|
|
25
|
+
};
|
|
26
|
+
export var DATE = 'date';
|
|
27
|
+
export var TIME = 'time';
|
|
28
|
+
export var DATETIME = 'datetime';
|
|
29
|
+
export var RELATIVE_FROM = 'relative-from';
|
|
30
|
+
export var RELATIVE_TO = 'relative-to';
|
|
31
|
+
export var RELATIVE_FROM_WITHOUT_SUFFIX = 'relative-from-without-suffix';
|
|
32
|
+
export var RELATIVE_TO_WITHOUT_SUFFIX = 'relative-to-without-suffix';
|
|
33
|
+
export var WEEKDAY_LONG = 'weekday-long';
|
|
34
|
+
export var WEEKDAY_SHORT = 'weekday-short';
|
|
35
|
+
export var MONTH_LONG = 'month-long';
|
|
36
|
+
export var MONTH_SHORT = 'month-short';
|
|
37
|
+
export var COMPACT_LARGER_NUMBER = 'compact-larger-number';
|
|
38
|
+
export var COMPACT_DECIMAL_LARGER_NUMBER = 'compact-decimal-larger-number';
|
|
39
|
+
export var LARGER_NUMBER_LIMIT = 999;
|
|
40
|
+
export var UPPER_CASE = 'upperCase';
|
|
41
|
+
export var UPPER_FIRST = 'upperFirst';
|
|
42
|
+
export var LOWER_CASE = 'lowerCase';
|
|
43
|
+
export var LOWER_FIRST = 'lowerFirst';
|
|
44
|
+
export var US_THOUSAND_DELIMITER = ',';
|
|
45
|
+
export var US_DECIMAL_DELIMITER = '.';
|
|
46
|
+
export var EU_THOUSAND_DELIMITER = ' ';
|
|
47
|
+
export var EU_DECIMAL_DELIMITER = ',';
|
|
48
|
+
export var DATE_CONSTANTS_TARGET_FORMATS = ['months-long', 'months-short', 'weekdays-long', 'weekdays-short'];
|
|
49
|
+
export var MONTHS_LONG = 'months-long';
|
|
50
|
+
export var MONTHS_SHORT = 'months-short';
|
|
51
|
+
export var WEEKDAYS_LONG = 'weekdays-long';
|
|
52
|
+
export var WEEKDAYS_SHORT = 'weekdays-short';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type IntlShape } from 'react-intl';
|
|
2
|
+
import { type DataFormatConfig, type DataFormatNotationType } from '../types';
|
|
3
|
+
export declare const EU_NOTATION: DataFormatNotationType;
|
|
4
|
+
export declare const US_NOTATION: DataFormatNotationType;
|
|
5
|
+
export declare const DEFAULT_DATA_FORMAT_NOTATION: DataFormatNotationType;
|
|
6
|
+
export declare const DEFAULT_DATA_FORMAT_CONFIG: DataFormatConfig;
|
|
7
|
+
export declare const DEFAULT_DATA_FORMAT_INTL: IntlShape;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createIntl } from 'react-intl';
|
|
2
|
+
export var EU_NOTATION = 'EU';
|
|
3
|
+
export var US_NOTATION = 'US';
|
|
4
|
+
export var DEFAULT_DATA_FORMAT_NOTATION = EU_NOTATION;
|
|
5
|
+
export var DEFAULT_DATA_FORMAT_CONFIG = {
|
|
6
|
+
startWeekDayNotation: DEFAULT_DATA_FORMAT_NOTATION,
|
|
7
|
+
dateFormatNotation: DEFAULT_DATA_FORMAT_NOTATION,
|
|
8
|
+
timeFormatNotation: DEFAULT_DATA_FORMAT_NOTATION,
|
|
9
|
+
numberFormatNotation: DEFAULT_DATA_FORMAT_NOTATION,
|
|
10
|
+
applyTimeZoneOffset: false
|
|
11
|
+
};
|
|
12
|
+
export var DEFAULT_DATA_FORMAT_INTL = createIntl({
|
|
13
|
+
locale: 'pl'
|
|
14
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DateTimePartFormat } from '../types';
|
|
2
|
+
export declare const WEEKDAY: Intl.DateTimeFormatPartTypes;
|
|
3
|
+
export declare const MONTH: Intl.DateTimeFormatPartTypes;
|
|
4
|
+
export declare const LONG: DateTimePartFormat;
|
|
5
|
+
export declare const SHORT: DateTimePartFormat;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DEFAULT_DATA_FORMAT_CONFIG, DEFAULT_DATA_FORMAT_INTL, DEFAULT_DATA_FORMAT_NOTATION, EU_NOTATION, US_NOTATION, } from './dataFormatConfig.constants';
|
|
2
|
+
export { DEFAULT_FORMAT_DATE_OPTIONS, DEFAULT_FORMAT_TIME_OPTIONS, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DATE, TIME, RELATIVE_TO, RELATIVE_FROM, RELATIVE_TO_WITHOUT_SUFFIX, RELATIVE_FROM_WITHOUT_SUFFIX, DATETIME, WEEKDAY_LONG, WEEKDAY_SHORT, MONTH_LONG, MONTH_SHORT, UPPER_CASE, UPPER_FIRST, LOWER_CASE, LOWER_FIRST, US_THOUSAND_DELIMITER, US_DECIMAL_DELIMITER, EU_THOUSAND_DELIMITER, EU_DECIMAL_DELIMITER, DATE_CONSTANTS_TARGET_FORMATS, MONTHS_LONG, MONTHS_SHORT, WEEKDAYS_LONG, WEEKDAYS_SHORT, COMPACT_LARGER_NUMBER, COMPACT_DECIMAL_LARGER_NUMBER, LARGER_NUMBER_LIMIT, DEFAULT_FORMAT_NUMBER_OPTIONS, } from './dataFormat.constants';
|
|
3
|
+
export { WEEKDAY, MONTH, LONG, SHORT } from './dateTimeParts.constants';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { DEFAULT_DATA_FORMAT_CONFIG, DEFAULT_DATA_FORMAT_INTL, DEFAULT_DATA_FORMAT_NOTATION, EU_NOTATION, US_NOTATION } from './dataFormatConfig.constants';
|
|
2
|
+
export { DEFAULT_FORMAT_DATE_OPTIONS, DEFAULT_FORMAT_TIME_OPTIONS, DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS, DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS, DEFAULT_FORMAT_MONTH_LONG_OPTIONS, DEFAULT_FORMAT_MONTH_SHORT_OPTIONS, DATE, TIME, RELATIVE_TO, RELATIVE_FROM, RELATIVE_TO_WITHOUT_SUFFIX, RELATIVE_FROM_WITHOUT_SUFFIX, DATETIME, WEEKDAY_LONG, WEEKDAY_SHORT, MONTH_LONG, MONTH_SHORT, UPPER_CASE, UPPER_FIRST, LOWER_CASE, LOWER_FIRST, US_THOUSAND_DELIMITER, US_DECIMAL_DELIMITER, EU_THOUSAND_DELIMITER, EU_DECIMAL_DELIMITER, DATE_CONSTANTS_TARGET_FORMATS, MONTHS_LONG, MONTHS_SHORT, WEEKDAYS_LONG, WEEKDAYS_SHORT, COMPACT_LARGER_NUMBER, COMPACT_DECIMAL_LARGER_NUMBER, LARGER_NUMBER_LIMIT, DEFAULT_FORMAT_NUMBER_OPTIONS } from './dataFormat.constants';
|
|
3
|
+
export { WEEKDAY, MONTH, LONG, SHORT } from './dateTimeParts.constants';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { DEFAULT_DATA_FORMAT_INTL } from '../constants';
|
|
3
|
+
export var DataFormatIntlsContext = /*#__PURE__*/createContext({
|
|
4
|
+
timeFormatIntl: DEFAULT_DATA_FORMAT_INTL,
|
|
5
|
+
numberFormatIntl: DEFAULT_DATA_FORMAT_INTL,
|
|
6
|
+
dateFormatIntl: DEFAULT_DATA_FORMAT_INTL
|
|
7
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import { type UseDataFormatProps } from '../hooks';
|
|
3
|
+
export type WithDataFormatProps = UseDataFormatProps;
|
|
4
|
+
export declare const withDataFormat: <Props extends object>(WrappedComponent: ComponentType<Props>) => ComponentType<Omit<Props, keyof UseDataFormatProps>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
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 React from 'react';
|
|
3
|
+
import { useDataFormat } from '../hooks';
|
|
4
|
+
export var withDataFormat = function withDataFormat(WrappedComponent) {
|
|
5
|
+
return function (props) {
|
|
6
|
+
var dataFormatProps = useDataFormat();
|
|
7
|
+
var newProps = _extends({}, props, dataFormatProps);
|
|
8
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, newProps);
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useDataFormatConfig } from './useDataFormatConfig';
|
|
2
|
+
export { useDataFormat, type UseDataFormatProps } from './useDataFormat';
|
|
3
|
+
export { useDataFormatUtils } from './useDataFormatUtils';
|
|
4
|
+
export { useSingleIntl } from './useSingleIntl';
|
|
5
|
+
export { useDataFormatIntls } from './useDataFormatIntls';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useDataFormatConfig } from './useDataFormatConfig';
|
|
2
|
+
export { useDataFormat } from './useDataFormat';
|
|
3
|
+
export { useDataFormatUtils } from './useDataFormatUtils';
|
|
4
|
+
export { useSingleIntl } from './useSingleIntl';
|
|
5
|
+
export { useDataFormatIntls } from './useDataFormatIntls';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Delimiter, type OverloadFormatMultipleValues, type OverloadFormatValue, type OverloadGetConstants } from '../types';
|
|
2
|
+
export type UseDataFormatProps = {
|
|
3
|
+
firstDayOfWeek: number;
|
|
4
|
+
isSundayFirstWeekDay: boolean;
|
|
5
|
+
is12HoursClock: boolean;
|
|
6
|
+
formatValue: OverloadFormatValue;
|
|
7
|
+
formatMultipleValues: OverloadFormatMultipleValues;
|
|
8
|
+
getConstants: OverloadGetConstants;
|
|
9
|
+
thousandDelimiter: Delimiter;
|
|
10
|
+
decimalDelimiter: Delimiter;
|
|
11
|
+
};
|
|
12
|
+
export declare const useDataFormat: () => UseDataFormatProps;
|
|
@@ -0,0 +1,96 @@
|
|
|
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 { isDayjs } from 'dayjs';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
|
+
import { DATE_CONSTANTS_TARGET_FORMATS } from '../constants';
|
|
6
|
+
import { getConstantDatesAndFormattingOptions } from '../utils';
|
|
7
|
+
import { isValidDate } from '../utils/date.utils';
|
|
8
|
+
import { useDataFormatConfig } from './useDataFormatConfig';
|
|
9
|
+
import { useDataFormatIntls } from './useDataFormatIntls';
|
|
10
|
+
import { useDataFormatUtils } from './useDataFormatUtils';
|
|
11
|
+
export var useDataFormat = function useDataFormat() {
|
|
12
|
+
var _useDataFormatIntls = useDataFormatIntls(),
|
|
13
|
+
numberFormatIntl = _useDataFormatIntls.numberFormatIntl,
|
|
14
|
+
timeFormatIntl = _useDataFormatIntls.timeFormatIntl,
|
|
15
|
+
dateFormatIntl = _useDataFormatIntls.dateFormatIntl;
|
|
16
|
+
var _useDataFormatConfig = useDataFormatConfig(),
|
|
17
|
+
startWeekDayNotation = _useDataFormatConfig.startWeekDayNotation,
|
|
18
|
+
timeFormatNotation = _useDataFormatConfig.timeFormatNotation,
|
|
19
|
+
numberFormatNotation = _useDataFormatConfig.numberFormatNotation;
|
|
20
|
+
var _useDataFormatUtils = useDataFormatUtils(),
|
|
21
|
+
getFirstDayOfWeekFromNotation = _useDataFormatUtils.getFirstDayOfWeekFromNotation,
|
|
22
|
+
getIs12HoursClockFromNotation = _useDataFormatUtils.getIs12HoursClockFromNotation,
|
|
23
|
+
getFormattedNumber = _useDataFormatUtils.getFormattedNumber,
|
|
24
|
+
getFormattedDate = _useDataFormatUtils.getFormattedDate,
|
|
25
|
+
getFormattedDateFromMoment = _useDataFormatUtils.getFormattedDateFromMoment,
|
|
26
|
+
getFormattedDateFromDayjs = _useDataFormatUtils.getFormattedDateFromDayjs,
|
|
27
|
+
getFormattedValueUsingCommonOptions = _useDataFormatUtils.getFormattedValueUsingCommonOptions,
|
|
28
|
+
getThousandDelimiterFromNotation = _useDataFormatUtils.getThousandDelimiterFromNotation,
|
|
29
|
+
getDecimalDelimiterFromNotation = _useDataFormatUtils.getDecimalDelimiterFromNotation;
|
|
30
|
+
var firstDayOfWeek = useMemo(function () {
|
|
31
|
+
return getFirstDayOfWeekFromNotation(startWeekDayNotation);
|
|
32
|
+
}, [startWeekDayNotation, getFirstDayOfWeekFromNotation]);
|
|
33
|
+
var isSundayFirstWeekDay = useMemo(function () {
|
|
34
|
+
return firstDayOfWeek === 0;
|
|
35
|
+
}, [firstDayOfWeek]);
|
|
36
|
+
var is12HoursClock = useMemo(function () {
|
|
37
|
+
return getIs12HoursClockFromNotation(timeFormatNotation);
|
|
38
|
+
}, [timeFormatNotation, getIs12HoursClockFromNotation]);
|
|
39
|
+
var formatValue = useCallback(
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
function (value, options) {
|
|
42
|
+
var result = '';
|
|
43
|
+
if (value instanceof moment) {
|
|
44
|
+
result = getFormattedDateFromMoment(value, dateFormatIntl, timeFormatIntl, options);
|
|
45
|
+
}
|
|
46
|
+
if (isDayjs(value)) {
|
|
47
|
+
result = getFormattedDateFromDayjs(value, dateFormatIntl, timeFormatIntl, options);
|
|
48
|
+
}
|
|
49
|
+
if (value instanceof Date) {
|
|
50
|
+
if (!isValidDate(value)) {
|
|
51
|
+
console.warn('invalid date', value);
|
|
52
|
+
return value.toString();
|
|
53
|
+
}
|
|
54
|
+
result = getFormattedDate(value, dateFormatIntl, timeFormatIntl, options);
|
|
55
|
+
}
|
|
56
|
+
if (typeof value === 'number') {
|
|
57
|
+
result = getFormattedNumber(value, numberFormatIntl, options);
|
|
58
|
+
}
|
|
59
|
+
if (typeof value === 'string') {
|
|
60
|
+
result = value;
|
|
61
|
+
}
|
|
62
|
+
return getFormattedValueUsingCommonOptions(result, options);
|
|
63
|
+
}, [numberFormatIntl, dateFormatIntl, timeFormatIntl, getFormattedDate, getFormattedDateFromMoment, getFormattedNumber, getFormattedDateFromDayjs, getFormattedValueUsingCommonOptions]);
|
|
64
|
+
var formatMultipleValues = useCallback(
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
function (values, options) {
|
|
67
|
+
return values.map(function (value) {
|
|
68
|
+
return formatValue(value, options);
|
|
69
|
+
});
|
|
70
|
+
}, [formatValue]);
|
|
71
|
+
var getConstants = useCallback(function (targetFormat, options, customStartDate, customEndDate, interval) {
|
|
72
|
+
if (DATE_CONSTANTS_TARGET_FORMATS.includes(targetFormat)) {
|
|
73
|
+
var _getConstantDatesAndF = getConstantDatesAndFormattingOptions(targetFormat, isSundayFirstWeekDay, customStartDate, customEndDate, interval),
|
|
74
|
+
constantDates = _getConstantDatesAndF.constantDates,
|
|
75
|
+
defaultOptions = _getConstantDatesAndF.defaultOptions;
|
|
76
|
+
return formatMultipleValues(constantDates, _extends({}, defaultOptions, options));
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}, [formatMultipleValues, isSundayFirstWeekDay]);
|
|
80
|
+
var thousandDelimiter = useMemo(function () {
|
|
81
|
+
return getThousandDelimiterFromNotation(numberFormatNotation);
|
|
82
|
+
}, [numberFormatNotation, getThousandDelimiterFromNotation]);
|
|
83
|
+
var decimalDelimiter = useMemo(function () {
|
|
84
|
+
return getDecimalDelimiterFromNotation(numberFormatNotation);
|
|
85
|
+
}, [numberFormatNotation, getDecimalDelimiterFromNotation]);
|
|
86
|
+
return {
|
|
87
|
+
firstDayOfWeek: firstDayOfWeek,
|
|
88
|
+
isSundayFirstWeekDay: isSundayFirstWeekDay,
|
|
89
|
+
is12HoursClock: is12HoursClock,
|
|
90
|
+
formatValue: formatValue,
|
|
91
|
+
formatMultipleValues: formatMultipleValues,
|
|
92
|
+
getConstants: getConstants,
|
|
93
|
+
thousandDelimiter: thousandDelimiter,
|
|
94
|
+
decimalDelimiter: decimalDelimiter
|
|
95
|
+
};
|
|
96
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Dayjs } from 'dayjs';
|
|
2
|
+
import { type Moment } from 'moment';
|
|
3
|
+
import { type IntlShape } from 'react-intl';
|
|
4
|
+
import { type CommonFormatOptions, type DataFormatNotationType, type DateToFormatOptions, type Delimiter, type NumberToFormatOptions } from '../types';
|
|
5
|
+
export declare const useDataFormatUtils: () => {
|
|
6
|
+
getLocaleFromNotation: (notation?: DataFormatNotationType) => string;
|
|
7
|
+
getFirstDayOfWeekFromNotation: (notation?: DataFormatNotationType) => number;
|
|
8
|
+
getIs12HoursClockFromNotation: (notation?: DataFormatNotationType) => boolean;
|
|
9
|
+
getFormattedNumber: (value: number, numberFormatIntl: IntlShape, options?: NumberToFormatOptions) => string;
|
|
10
|
+
getFormattedDate: (value: Date, dateFormatIntl: IntlShape, timeFormatIntl: IntlShape, options?: DateToFormatOptions) => string;
|
|
11
|
+
getFormattedDateFromMoment: (value: Moment, dateFormatIntl: IntlShape, timeFormatIntl: IntlShape, options?: DateToFormatOptions) => string;
|
|
12
|
+
getFormattedDateFromDayjs: (value: Dayjs, dateFormatIntl: IntlShape, timeFormatIntl: IntlShape, options?: DateToFormatOptions) => string;
|
|
13
|
+
getFormattedValueUsingCommonOptions: (value: string, options?: CommonFormatOptions) => string;
|
|
14
|
+
getThousandDelimiterFromNotation: (notation?: DataFormatNotationType) => Delimiter;
|
|
15
|
+
getDecimalDelimiterFromNotation: (notation?: DataFormatNotationType) => Delimiter;
|
|
16
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useIntl } from 'react-intl';
|
|
5
|
+
import { DATE, DATETIME, EU_DECIMAL_DELIMITER, EU_NOTATION, EU_THOUSAND_DELIMITER, MONTH_LONG, MONTH_SHORT, RELATIVE_FROM, RELATIVE_FROM_WITHOUT_SUFFIX, RELATIVE_TO, RELATIVE_TO_WITHOUT_SUFFIX, TIME, US_DECIMAL_DELIMITER, US_NOTATION, US_THOUSAND_DELIMITER, WEEKDAY_LONG, WEEKDAY_SHORT } from '../constants';
|
|
6
|
+
import { addPrefix, addSuffix, changeNamingConvention, convertDateToDateString, convertDateToDateTimeString, convertDateToMonthLongString, convertDateToMonthShortString, convertDateToRelativeFromString, convertDateToRelativeToString, convertDateToTimeString, convertDateToWeekdayLongString, convertDateToWeekdayShortString, convertNumberString } from '../utils';
|
|
7
|
+
import { getLocalDateInTimeZone } from '../utils/timeZone.utils';
|
|
8
|
+
import { useDataFormatConfig } from './useDataFormatConfig';
|
|
9
|
+
export var useDataFormatUtils = function useDataFormatUtils() {
|
|
10
|
+
var languageIntl = useIntl();
|
|
11
|
+
var _useDataFormatConfig = useDataFormatConfig(),
|
|
12
|
+
numberFormatNotation = _useDataFormatConfig.numberFormatNotation,
|
|
13
|
+
applyTimeZoneOffset = _useDataFormatConfig.applyTimeZoneOffset;
|
|
14
|
+
var getLocaleFromNotation = useCallback(function (notation) {
|
|
15
|
+
switch (notation) {
|
|
16
|
+
case EU_NOTATION:
|
|
17
|
+
return 'pl';
|
|
18
|
+
case US_NOTATION:
|
|
19
|
+
return 'en-US';
|
|
20
|
+
default:
|
|
21
|
+
return 'pl';
|
|
22
|
+
}
|
|
23
|
+
}, []);
|
|
24
|
+
var getFirstDayOfWeekFromNotation = useCallback(function (notation) {
|
|
25
|
+
switch (notation) {
|
|
26
|
+
case EU_NOTATION:
|
|
27
|
+
return 1;
|
|
28
|
+
case US_NOTATION:
|
|
29
|
+
return 0;
|
|
30
|
+
default:
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
var getThousandDelimiterFromNotation = useCallback(function (notation) {
|
|
35
|
+
return notation === US_NOTATION ? US_THOUSAND_DELIMITER : EU_THOUSAND_DELIMITER;
|
|
36
|
+
}, []);
|
|
37
|
+
var getDecimalDelimiterFromNotation = useCallback(function (notation) {
|
|
38
|
+
return notation === US_NOTATION ? US_DECIMAL_DELIMITER : EU_DECIMAL_DELIMITER;
|
|
39
|
+
}, []);
|
|
40
|
+
var getIs12HoursClockFromNotation = useCallback(function (notation) {
|
|
41
|
+
return notation === US_NOTATION;
|
|
42
|
+
}, []);
|
|
43
|
+
var getFormattedNumber = useCallback(function (value, numberFormatIntl, options) {
|
|
44
|
+
var thousandDelimiter = getThousandDelimiterFromNotation(numberFormatNotation);
|
|
45
|
+
var decimalDelimiter = getDecimalDelimiterFromNotation(numberFormatNotation);
|
|
46
|
+
return convertNumberString(value, numberFormatIntl, languageIntl, thousandDelimiter, decimalDelimiter, options);
|
|
47
|
+
}, [languageIntl, numberFormatNotation, getThousandDelimiterFromNotation, getDecimalDelimiterFromNotation]);
|
|
48
|
+
var _useIntl = useIntl(),
|
|
49
|
+
globalTimeZone = _useIntl.timeZone;
|
|
50
|
+
var getFormattedDate = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
|
|
51
|
+
var _value$toString;
|
|
52
|
+
var valueInTimezone = globalTimeZone && applyTimeZoneOffset ? getLocalDateInTimeZone(value.toISOString(), globalTimeZone) : value;
|
|
53
|
+
if ((options == null ? void 0 : options.targetFormat) === DATETIME) {
|
|
54
|
+
return convertDateToDateTimeString(valueInTimezone, dateFormatIntl, timeFormatIntl, languageIntl, options);
|
|
55
|
+
}
|
|
56
|
+
if ((options == null ? void 0 : options.targetFormat) === TIME) {
|
|
57
|
+
return convertDateToTimeString(valueInTimezone, timeFormatIntl, options);
|
|
58
|
+
}
|
|
59
|
+
if ((options == null ? void 0 : options.targetFormat) === RELATIVE_TO) {
|
|
60
|
+
return convertDateToRelativeToString(value);
|
|
61
|
+
}
|
|
62
|
+
if ((options == null ? void 0 : options.targetFormat) === RELATIVE_TO_WITHOUT_SUFFIX) {
|
|
63
|
+
return convertDateToRelativeToString(value, true);
|
|
64
|
+
}
|
|
65
|
+
if ((options == null ? void 0 : options.targetFormat) === RELATIVE_FROM) {
|
|
66
|
+
return convertDateToRelativeFromString(value);
|
|
67
|
+
}
|
|
68
|
+
if ((options == null ? void 0 : options.targetFormat) === RELATIVE_FROM_WITHOUT_SUFFIX) {
|
|
69
|
+
return convertDateToRelativeFromString(value, true);
|
|
70
|
+
}
|
|
71
|
+
if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_LONG) {
|
|
72
|
+
return convertDateToWeekdayLongString(valueInTimezone, dateFormatIntl, languageIntl, options);
|
|
73
|
+
}
|
|
74
|
+
if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_SHORT) {
|
|
75
|
+
return convertDateToWeekdayShortString(valueInTimezone, dateFormatIntl, languageIntl, options);
|
|
76
|
+
}
|
|
77
|
+
if ((options == null ? void 0 : options.targetFormat) === MONTH_LONG) {
|
|
78
|
+
return convertDateToMonthLongString(valueInTimezone, dateFormatIntl, languageIntl, options);
|
|
79
|
+
}
|
|
80
|
+
if ((options == null ? void 0 : options.targetFormat) === MONTH_SHORT) {
|
|
81
|
+
return convertDateToMonthShortString(valueInTimezone, dateFormatIntl, languageIntl, options);
|
|
82
|
+
}
|
|
83
|
+
if ((options == null ? void 0 : options.targetFormat) === DATE || !(options != null && options.targetFormat)) {
|
|
84
|
+
return convertDateToDateString(valueInTimezone, dateFormatIntl, languageIntl, options);
|
|
85
|
+
}
|
|
86
|
+
return (_value$toString = value == null ? void 0 : value.toString()) != null ? _value$toString : '';
|
|
87
|
+
}, [globalTimeZone, applyTimeZoneOffset, languageIntl]);
|
|
88
|
+
var getFormattedDateFromMoment = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
|
|
89
|
+
return getFormattedDate(moment(value).toDate(), dateFormatIntl, timeFormatIntl, options);
|
|
90
|
+
}, [getFormattedDate]);
|
|
91
|
+
var getFormattedDateFromDayjs = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
|
|
92
|
+
return getFormattedDate(dayjs(value).toDate(), dateFormatIntl, timeFormatIntl, options);
|
|
93
|
+
}, [getFormattedDate]);
|
|
94
|
+
var getFormattedValueUsingCommonOptions = useCallback(function (value, options) {
|
|
95
|
+
var result = value;
|
|
96
|
+
result = addPrefix(result, options);
|
|
97
|
+
result = addSuffix(result, options);
|
|
98
|
+
result = changeNamingConvention(result, options);
|
|
99
|
+
return result;
|
|
100
|
+
}, []);
|
|
101
|
+
return {
|
|
102
|
+
getLocaleFromNotation: getLocaleFromNotation,
|
|
103
|
+
getFirstDayOfWeekFromNotation: getFirstDayOfWeekFromNotation,
|
|
104
|
+
getIs12HoursClockFromNotation: getIs12HoursClockFromNotation,
|
|
105
|
+
getFormattedNumber: getFormattedNumber,
|
|
106
|
+
getFormattedDate: getFormattedDate,
|
|
107
|
+
getFormattedDateFromMoment: getFormattedDateFromMoment,
|
|
108
|
+
getFormattedDateFromDayjs: getFormattedDateFromDayjs,
|
|
109
|
+
getFormattedValueUsingCommonOptions: getFormattedValueUsingCommonOptions,
|
|
110
|
+
getThousandDelimiterFromNotation: getThousandDelimiterFromNotation,
|
|
111
|
+
getDecimalDelimiterFromNotation: getDecimalDelimiterFromNotation
|
|
112
|
+
};
|
|
113
|
+
};
|