@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.
Files changed (125) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/i18n/{en.json → en.json.d.ts} +4 -2
  3. package/dist/i18n/en.json.js +8 -0
  4. package/dist/i18n/{es.json → es.json.d.ts} +4 -2
  5. package/dist/i18n/es.json.js +8 -0
  6. package/dist/i18n/index.js +14 -11
  7. package/dist/i18n/{pl.json → pl.json.d.ts} +4 -2
  8. package/dist/i18n/pl.json.js +8 -0
  9. package/dist/i18n/{pt.json → pt.json.d.ts} +4 -2
  10. package/dist/i18n/pt.json.js +8 -0
  11. package/dist/js/DSProvider/DSProvider.d.ts +5 -6
  12. package/dist/js/DSProvider/DSProvider.js +36 -31
  13. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.d.ts +2 -2
  14. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.js +29 -38
  15. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.types.d.ts +3 -3
  16. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.types.js +1 -1
  17. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.d.ts +1 -1
  18. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.js +22 -19
  19. package/dist/js/DSProvider/LocaleProvider/antLocales.d.ts +6 -6
  20. package/dist/js/DSProvider/LocaleProvider/antLocales.js +16 -13
  21. package/dist/js/DSProvider/LocaleProvider/index.js +4 -1
  22. package/dist/js/DSProvider/ThemeProvider/ThemeProvider.d.ts +2 -2
  23. package/dist/js/DSProvider/ThemeProvider/ThemeProvider.js +14 -12
  24. package/dist/js/DSProvider/ThemeProvider/breakpoints.js +5 -2
  25. package/dist/js/DSProvider/ThemeProvider/index.js +4 -1
  26. package/dist/js/DSProvider/ThemeProvider/theme.d.ts +1 -1
  27. package/dist/js/DSProvider/ThemeProvider/theme.js +17 -17
  28. package/dist/js/DSProvider/ThemeProvider/variables.d.ts +8 -0
  29. package/dist/js/DSProvider/ThemeProvider/variables.js +531 -530
  30. package/dist/js/DSProvider/index.js +4 -1
  31. package/dist/js/DropdownContext/DropdownContext/DropdownContextProvider.d.ts +2 -2
  32. package/dist/js/DropdownContext/DropdownContext/DropdownContextProvider.js +11 -11
  33. package/dist/js/DropdownContext/DropdownContext.d.ts +1 -1
  34. package/dist/js/DropdownContext/DropdownContext.js +5 -2
  35. package/dist/js/DropdownContext/DropdownContextProvider.d.ts +2 -2
  36. package/dist/js/DropdownContext/DropdownContextProvider.js +11 -11
  37. package/dist/js/DropdownContext/index.js +8 -3
  38. package/dist/js/DropdownContext/useDropdown.d.ts +1 -1
  39. package/dist/js/DropdownContext/useDropdown.js +7 -4
  40. package/dist/js/data-format/components/FormattedDate.d.ts +4 -4
  41. package/dist/js/data-format/components/FormattedDate.js +23 -9
  42. package/dist/js/data-format/components/FormattedDateTime.d.ts +4 -4
  43. package/dist/js/data-format/components/FormattedDateTime.js +26 -12
  44. package/dist/js/data-format/components/FormattedNumber.d.ts +2 -2
  45. package/dist/js/data-format/components/FormattedNumber.js +23 -9
  46. package/dist/js/data-format/components/FormattedRelativeDateTime.d.ts +3 -3
  47. package/dist/js/data-format/components/FormattedRelativeDateTime.js +40 -21
  48. package/dist/js/data-format/components/FormattedTime.d.ts +4 -4
  49. package/dist/js/data-format/components/FormattedTime.js +26 -12
  50. package/dist/js/data-format/components/index.js +13 -5
  51. package/dist/js/data-format/constants/dataFormat.constants.d.ts +2 -2
  52. package/dist/js/data-format/constants/dataFormat.constants.js +85 -49
  53. package/dist/js/data-format/constants/dataFormatConfig.constants.d.ts +2 -2
  54. package/dist/js/data-format/constants/dataFormatConfig.constants.js +15 -8
  55. package/dist/js/data-format/constants/dateTimeParts.constants.d.ts +1 -1
  56. package/dist/js/data-format/constants/dateTimeParts.constants.js +10 -4
  57. package/dist/js/data-format/constants/index.js +48 -3
  58. package/dist/js/data-format/contexts/DataFormatConfigContext.d.ts +2 -2
  59. package/dist/js/data-format/contexts/DataFormatConfigContext.js +6 -3
  60. package/dist/js/data-format/contexts/DataFormatIntlsContext.d.ts +2 -2
  61. package/dist/js/data-format/contexts/DataFormatIntlsContext.js +7 -4
  62. package/dist/js/data-format/contexts/index.js +6 -2
  63. package/dist/js/data-format/hocs/withDataFormat.d.ts +2 -2
  64. package/dist/js/data-format/hocs/withDataFormat.js +23 -9
  65. package/dist/js/data-format/hooks/index.js +14 -6
  66. package/dist/js/data-format/hooks/useDataFormat.d.ts +1 -1
  67. package/dist/js/data-format/hooks/useDataFormat.js +93 -90
  68. package/dist/js/data-format/hooks/useDataFormatConfig.d.ts +1 -1
  69. package/dist/js/data-format/hooks/useDataFormatConfig.js +8 -4
  70. package/dist/js/data-format/hooks/useDataFormatIntls.d.ts +1 -1
  71. package/dist/js/data-format/hooks/useDataFormatIntls.js +8 -4
  72. package/dist/js/data-format/hooks/useDataFormatUtils.d.ts +4 -4
  73. package/dist/js/data-format/hooks/useDataFormatUtils.js +62 -63
  74. package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.d.ts +2 -2
  75. package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.js +19 -23
  76. package/dist/js/data-format/hooks/useSingleIntl.d.ts +1 -1
  77. package/dist/js/data-format/hooks/useSingleIntl.js +11 -8
  78. package/dist/js/data-format/index.js +83 -7
  79. package/dist/js/data-format/providers/DataFormatConfigProvider.d.ts +2 -2
  80. package/dist/js/data-format/providers/DataFormatConfigProvider.js +37 -26
  81. package/dist/js/data-format/types/dataFormat.types.d.ts +3 -3
  82. package/dist/js/data-format/types/dataFormat.types.js +1 -5
  83. package/dist/js/data-format/types/dataFormatConfig.types.d.ts +1 -1
  84. package/dist/js/data-format/types/dataFormatConfig.types.js +1 -2
  85. package/dist/js/data-format/types/dateTimeParts.types.js +1 -2
  86. package/dist/js/data-format/types/index.js +1 -1
  87. package/dist/js/data-format/utils/dataFormat.utils.d.ts +2 -2
  88. package/dist/js/data-format/utils/dataFormat.utils.js +82 -67
  89. package/dist/js/data-format/utils/dataFormatConfig.utils.d.ts +1 -1
  90. package/dist/js/data-format/utils/dataFormatConfig.utils.js +9 -8
  91. package/dist/js/data-format/utils/date.utils.d.ts +2 -2
  92. package/dist/js/data-format/utils/date.utils.js +25 -21
  93. package/dist/js/data-format/utils/dateTimeParts.utils.d.ts +2 -2
  94. package/dist/js/data-format/utils/dateTimeParts.utils.js +68 -52
  95. package/dist/js/data-format/utils/index.js +41 -5
  96. package/dist/js/data-format/utils/timeZone.utils.d.ts +1 -1
  97. package/dist/js/data-format/utils/timeZone.utils.js +59 -51
  98. package/dist/js/index.js +112 -7
  99. package/dist/js/mediaQuery/mediaQuery.d.ts +2 -2
  100. package/dist/js/mediaQuery/mediaQuery.js +15 -25
  101. package/dist/js/style.d.ts +0 -2
  102. package/dist/js/style.js +1 -2
  103. package/dist/js/testing/index.js +6 -2
  104. package/dist/js/testing/renderWithProvider/renderWithProvider.d.ts +4 -4
  105. package/dist/js/testing/renderWithProvider/renderWithProvider.js +35 -27
  106. package/dist/js/testing/sleep.js +6 -8
  107. package/dist/js/toaster/Toaster.d.ts +1 -1
  108. package/dist/js/toaster/Toaster.js +12 -8
  109. package/dist/js/toaster/Toaster.types.js +1 -1
  110. package/dist/js/toaster/constants.d.ts +1 -1
  111. package/dist/js/toaster/constants.js +7 -4
  112. package/dist/js/toaster/contexts/ToasterContext.d.ts +2 -2
  113. package/dist/js/toaster/contexts/ToasterContext.js +9 -5
  114. package/dist/js/toaster/hooks/useToaster.d.ts +1 -1
  115. package/dist/js/toaster/hooks/useToaster.js +7 -4
  116. package/dist/js/toaster/index.js +12 -5
  117. package/dist/js/toaster/providers/ToasterProvider.d.ts +2 -2
  118. package/dist/js/toaster/providers/ToasterProvider.js +17 -17
  119. package/package.json +4 -4
  120. package/dist/js/testing/renderWithProvider/renderWithProvider.spec.d.ts +0 -1
  121. package/dist/style/colors.less +0 -137
  122. package/dist/style/config.less +0 -521
  123. package/dist/style/core.less +0 -55
  124. package/dist/style/variables.less +0 -2
  125. /package/dist/{style/variables.css → assets/style/core-tn0RQdqM.css} +0 -0
@@ -1,3 +1,48 @@
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';
1
+ import { DEFAULT_DATA_FORMAT_CONFIG, DEFAULT_DATA_FORMAT_INTL, DEFAULT_DATA_FORMAT_NOTATION, EU_NOTATION, US_NOTATION } from "./dataFormatConfig.constants.js";
2
+ 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 "./dataFormat.constants.js";
3
+ import { LONG, MONTH, SHORT, WEEKDAY } from "./dateTimeParts.constants.js";
4
+ export {
5
+ COMPACT_DECIMAL_LARGER_NUMBER,
6
+ COMPACT_LARGER_NUMBER,
7
+ DATE,
8
+ DATETIME,
9
+ DATE_CONSTANTS_TARGET_FORMATS,
10
+ DEFAULT_DATA_FORMAT_CONFIG,
11
+ DEFAULT_DATA_FORMAT_INTL,
12
+ DEFAULT_DATA_FORMAT_NOTATION,
13
+ DEFAULT_FORMAT_DATE_OPTIONS,
14
+ DEFAULT_FORMAT_MONTH_LONG_OPTIONS,
15
+ DEFAULT_FORMAT_MONTH_SHORT_OPTIONS,
16
+ DEFAULT_FORMAT_NUMBER_OPTIONS,
17
+ DEFAULT_FORMAT_TIME_OPTIONS,
18
+ DEFAULT_FORMAT_WEEKDAY_LONG_OPTIONS,
19
+ DEFAULT_FORMAT_WEEKDAY_SHORT_OPTIONS,
20
+ EU_DECIMAL_DELIMITER,
21
+ EU_NOTATION,
22
+ EU_THOUSAND_DELIMITER,
23
+ LARGER_NUMBER_LIMIT,
24
+ LONG,
25
+ LOWER_CASE,
26
+ LOWER_FIRST,
27
+ MONTH,
28
+ MONTHS_LONG,
29
+ MONTHS_SHORT,
30
+ MONTH_LONG,
31
+ MONTH_SHORT,
32
+ RELATIVE_FROM,
33
+ RELATIVE_FROM_WITHOUT_SUFFIX,
34
+ RELATIVE_TO,
35
+ RELATIVE_TO_WITHOUT_SUFFIX,
36
+ SHORT,
37
+ TIME,
38
+ UPPER_CASE,
39
+ UPPER_FIRST,
40
+ US_DECIMAL_DELIMITER,
41
+ US_NOTATION,
42
+ US_THOUSAND_DELIMITER,
43
+ WEEKDAY,
44
+ WEEKDAYS_LONG,
45
+ WEEKDAYS_SHORT,
46
+ WEEKDAY_LONG,
47
+ WEEKDAY_SHORT
48
+ };
@@ -1,2 +1,2 @@
1
- import { type DataFormatConfig } from '../types';
2
- export declare const DataFormatConfigContext: import("react").Context<DataFormatConfig>;
1
+ import { DataFormatConfig } from '../types';
2
+ export declare const DataFormatConfigContext: import('react').Context<DataFormatConfig>;
@@ -1,3 +1,6 @@
1
- import { createContext } from 'react';
2
- import { DEFAULT_DATA_FORMAT_CONFIG } from '../constants';
3
- export var DataFormatConfigContext = /*#__PURE__*/createContext(DEFAULT_DATA_FORMAT_CONFIG);
1
+ import { createContext } from "react";
2
+ import { DEFAULT_DATA_FORMAT_CONFIG } from "../constants/dataFormatConfig.constants.js";
3
+ const DataFormatConfigContext = createContext(DEFAULT_DATA_FORMAT_CONFIG);
4
+ export {
5
+ DataFormatConfigContext
6
+ };
@@ -1,2 +1,2 @@
1
- import { type DataFormatIntls } from '../types';
2
- export declare const DataFormatIntlsContext: import("react").Context<DataFormatIntls>;
1
+ import { DataFormatIntls } from '../types';
2
+ export declare const DataFormatIntlsContext: import('react').Context<DataFormatIntls>;
@@ -1,7 +1,10 @@
1
- import { createContext } from 'react';
2
- import { DEFAULT_DATA_FORMAT_INTL } from '../constants';
3
- export var DataFormatIntlsContext = /*#__PURE__*/createContext({
1
+ import { createContext } from "react";
2
+ import { DEFAULT_DATA_FORMAT_INTL } from "../constants/dataFormatConfig.constants.js";
3
+ const DataFormatIntlsContext = createContext({
4
4
  timeFormatIntl: DEFAULT_DATA_FORMAT_INTL,
5
5
  numberFormatIntl: DEFAULT_DATA_FORMAT_INTL,
6
6
  dateFormatIntl: DEFAULT_DATA_FORMAT_INTL
7
- });
7
+ });
8
+ export {
9
+ DataFormatIntlsContext
10
+ };
@@ -1,2 +1,6 @@
1
- export { DataFormatConfigContext } from './DataFormatConfigContext';
2
- export { DataFormatIntlsContext } from './DataFormatIntlsContext';
1
+ import { DataFormatConfigContext } from "./DataFormatConfigContext.js";
2
+ import { DataFormatIntlsContext } from "./DataFormatIntlsContext.js";
3
+ export {
4
+ DataFormatConfigContext,
5
+ DataFormatIntlsContext
6
+ };
@@ -1,4 +1,4 @@
1
- import { type ComponentType } from 'react';
2
- import { type UseDataFormatProps } from '../hooks';
1
+ import { ComponentType } from 'react';
2
+ import { UseDataFormatProps } from '../hooks';
3
3
  export type WithDataFormatProps = UseDataFormatProps;
4
4
  export declare const withDataFormat: <Props extends object>(WrappedComponent: ComponentType<Props>) => ComponentType<Omit<Props, keyof UseDataFormatProps>>;
@@ -1,10 +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 { 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);
1
+ import { jsx } from "react/jsx-runtime";
2
+ import "react";
3
+ import "../contexts/DataFormatConfigContext.js";
4
+ import "../contexts/DataFormatIntlsContext.js";
5
+ import { useDataFormat } from "../hooks/useDataFormat.js";
6
+ import "dayjs";
7
+ import "moment";
8
+ import "react-intl";
9
+ import "../constants/dataFormatConfig.constants.js";
10
+ import "../utils/timeZone.utils.js";
11
+ import "../utils/dataFormat.utils.js";
12
+ const withDataFormat = (WrappedComponent) => {
13
+ return (props) => {
14
+ const dataFormatProps = useDataFormat();
15
+ const newProps = {
16
+ ...props,
17
+ ...dataFormatProps
18
+ };
19
+ return /* @__PURE__ */ jsx(WrappedComponent, { ...newProps });
9
20
  };
10
- };
21
+ };
22
+ export {
23
+ withDataFormat
24
+ };
@@ -1,6 +1,14 @@
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';
6
- export { useRelativeDateTimeUpdate } from './useRelativeDateTimeUpdate';
1
+ import { useDataFormatConfig } from "./useDataFormatConfig.js";
2
+ import { useDataFormat } from "./useDataFormat.js";
3
+ import { useDataFormatUtils } from "./useDataFormatUtils.js";
4
+ import { useSingleIntl } from "./useSingleIntl.js";
5
+ import { useDataFormatIntls } from "./useDataFormatIntls.js";
6
+ import { useRelativeDateTimeUpdate } from "./useRelativeDateTimeUpdate.js";
7
+ export {
8
+ useDataFormat,
9
+ useDataFormatConfig,
10
+ useDataFormatIntls,
11
+ useDataFormatUtils,
12
+ useRelativeDateTimeUpdate,
13
+ useSingleIntl
14
+ };
@@ -1,4 +1,4 @@
1
- import { type Delimiter, type OverloadFormatMultipleValues, type OverloadFormatValue, type OverloadGetConstants } from '../types';
1
+ import { Delimiter, OverloadFormatMultipleValues, OverloadFormatValue, OverloadGetConstants } from '../types';
2
2
  export type UseDataFormatProps = {
3
3
  firstDayOfWeek: number;
4
4
  isSundayFirstWeekDay: boolean;
@@ -1,96 +1,99 @@
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();
1
+ import { isDayjs } from "dayjs";
2
+ import moment from "moment";
3
+ import { useMemo, useCallback } from "react";
4
+ import "../constants/dataFormatConfig.constants.js";
5
+ import { DATE_CONSTANTS_TARGET_FORMATS } from "../constants/dataFormat.constants.js";
6
+ import "../utils/timeZone.utils.js";
7
+ import "../utils/dataFormat.utils.js";
8
+ import { isValidDate, getConstantDatesAndFormattingOptions } from "../utils/date.utils.js";
9
+ import { useDataFormatConfig } from "./useDataFormatConfig.js";
10
+ import { useDataFormatIntls } from "./useDataFormatIntls.js";
11
+ import { useDataFormatUtils } from "./useDataFormatUtils.js";
12
+ const useDataFormat = () => {
13
+ const {
14
+ numberFormatIntl,
15
+ timeFormatIntl,
16
+ dateFormatIntl
17
+ } = useDataFormatIntls();
18
+ const {
19
+ startWeekDayNotation,
20
+ timeFormatNotation,
21
+ numberFormatNotation
22
+ } = useDataFormatConfig();
23
+ const {
24
+ getFirstDayOfWeekFromNotation,
25
+ getIs12HoursClockFromNotation,
26
+ getFormattedNumber,
27
+ getFormattedDate,
28
+ getFormattedDateFromMoment,
29
+ getFormattedDateFromDayjs,
30
+ getFormattedValueUsingCommonOptions,
31
+ getThousandDelimiterFromNotation,
32
+ getDecimalDelimiterFromNotation
33
+ } = useDataFormatUtils();
34
+ const firstDayOfWeek = useMemo(() => getFirstDayOfWeekFromNotation(startWeekDayNotation), [startWeekDayNotation, getFirstDayOfWeekFromNotation]);
35
+ const isSundayFirstWeekDay = useMemo(() => firstDayOfWeek === 0, [firstDayOfWeek]);
36
+ const is12HoursClock = useMemo(() => getIs12HoursClockFromNotation(timeFormatNotation), [timeFormatNotation, getIs12HoursClockFromNotation]);
37
+ const formatValue = useCallback(
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ (value, options) => {
40
+ let result = "";
41
+ if (value instanceof moment) {
42
+ result = getFormattedDateFromMoment(value, dateFormatIntl, timeFormatIntl, options);
53
43
  }
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) {
44
+ if (isDayjs(value)) {
45
+ result = getFormattedDateFromDayjs(value, dateFormatIntl, timeFormatIntl, options);
46
+ }
47
+ if (value instanceof Date) {
48
+ if (!isValidDate(value)) {
49
+ console.warn("invalid date", value);
50
+ return value.toString();
51
+ }
52
+ result = getFormattedDate(value, dateFormatIntl, timeFormatIntl, options);
53
+ }
54
+ if (typeof value === "number") {
55
+ result = getFormattedNumber(value, numberFormatIntl, options);
56
+ }
57
+ if (typeof value === "string") {
58
+ result = value;
59
+ }
60
+ return getFormattedValueUsingCommonOptions(result, options);
61
+ },
62
+ [numberFormatIntl, dateFormatIntl, timeFormatIntl, getFormattedDate, getFormattedDateFromMoment, getFormattedNumber, getFormattedDateFromDayjs, getFormattedValueUsingCommonOptions]
63
+ );
64
+ const formatMultipleValues = useCallback(
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
+ (values, options) => {
67
+ return values.map((value) => formatValue(value, options));
68
+ },
69
+ [formatValue]
70
+ );
71
+ const getConstants = useCallback((targetFormat, options, customStartDate, customEndDate, interval) => {
72
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));
73
+ const {
74
+ constantDates,
75
+ defaultOptions
76
+ } = getConstantDatesAndFormattingOptions(targetFormat, isSundayFirstWeekDay, customStartDate, customEndDate, interval);
77
+ return formatMultipleValues(constantDates, {
78
+ ...defaultOptions,
79
+ ...options
80
+ });
77
81
  }
78
- return undefined;
82
+ return void 0;
79
83
  }, [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]);
84
+ const thousandDelimiter = useMemo(() => getThousandDelimiterFromNotation(numberFormatNotation), [numberFormatNotation, getThousandDelimiterFromNotation]);
85
+ const decimalDelimiter = useMemo(() => getDecimalDelimiterFromNotation(numberFormatNotation), [numberFormatNotation, getDecimalDelimiterFromNotation]);
86
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
87
+ firstDayOfWeek,
88
+ isSundayFirstWeekDay,
89
+ is12HoursClock,
90
+ formatValue,
91
+ formatMultipleValues,
92
+ getConstants,
93
+ thousandDelimiter,
94
+ decimalDelimiter
95
95
  };
96
- };
96
+ };
97
+ export {
98
+ useDataFormat
99
+ };
@@ -1,2 +1,2 @@
1
- import { type DataFormatConfig } from '../types';
1
+ import { DataFormatConfig } from '../types';
2
2
  export declare const useDataFormatConfig: () => DataFormatConfig;
@@ -1,5 +1,9 @@
1
- import { useContext } from 'react';
2
- import { DataFormatConfigContext } from '../contexts';
3
- export var useDataFormatConfig = function useDataFormatConfig() {
1
+ import { useContext } from "react";
2
+ import { DataFormatConfigContext } from "../contexts/DataFormatConfigContext.js";
3
+ import "../contexts/DataFormatIntlsContext.js";
4
+ const useDataFormatConfig = () => {
4
5
  return useContext(DataFormatConfigContext);
5
- };
6
+ };
7
+ export {
8
+ useDataFormatConfig
9
+ };
@@ -1,2 +1,2 @@
1
- import { type DataFormatIntls } from '../types';
1
+ import { DataFormatIntls } from '../types';
2
2
  export declare const useDataFormatIntls: () => DataFormatIntls;
@@ -1,5 +1,9 @@
1
- import { useContext } from 'react';
2
- import { DataFormatIntlsContext } from '../contexts';
3
- export var useDataFormatIntls = function useDataFormatIntls() {
1
+ import { useContext } from "react";
2
+ import "../contexts/DataFormatConfigContext.js";
3
+ import { DataFormatIntlsContext } from "../contexts/DataFormatIntlsContext.js";
4
+ const useDataFormatIntls = () => {
4
5
  return useContext(DataFormatIntlsContext);
5
- };
6
+ };
7
+ export {
8
+ useDataFormatIntls
9
+ };
@@ -1,7 +1,7 @@
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';
1
+ import { Dayjs } from 'dayjs';
2
+ import { Moment } from 'moment';
3
+ import { IntlShape } from 'react-intl';
4
+ import { CommonFormatOptions, DataFormatNotationType, DateToFormatOptions, Delimiter, NumberToFormatOptions } from '../types';
5
5
  export declare const useDataFormatUtils: () => {
6
6
  getLocaleFromNotation: (notation?: DataFormatNotationType) => string;
7
7
  getFirstDayOfWeekFromNotation: (notation?: DataFormatNotationType) => number;
@@ -1,27 +1,29 @@
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) {
1
+ import dayjs from "dayjs";
2
+ import moment from "moment";
3
+ import { useCallback } from "react";
4
+ import { useIntl } from "react-intl";
5
+ import { US_NOTATION, EU_NOTATION } from "../constants/dataFormatConfig.constants.js";
6
+ import { US_THOUSAND_DELIMITER, EU_THOUSAND_DELIMITER, US_DECIMAL_DELIMITER, EU_DECIMAL_DELIMITER, DATETIME, TIME, RELATIVE_TO, RELATIVE_TO_WITHOUT_SUFFIX, RELATIVE_FROM, RELATIVE_FROM_WITHOUT_SUFFIX, WEEKDAY_LONG, WEEKDAY_SHORT, MONTH_LONG, MONTH_SHORT, DATE } from "../constants/dataFormat.constants.js";
7
+ import { getLocalDateInTimeZone } from "../utils/timeZone.utils.js";
8
+ import { convertNumberString, convertDateToDateTimeString, convertDateToTimeString, convertDateToRelativeToString, convertDateToRelativeFromString, convertDateToWeekdayLongString, convertDateToWeekdayShortString, convertDateToMonthLongString, convertDateToMonthShortString, convertDateToDateString, addPrefix, addSuffix, changeNamingConvention } from "../utils/dataFormat.utils.js";
9
+ import { useDataFormatConfig } from "./useDataFormatConfig.js";
10
+ const useDataFormatUtils = () => {
11
+ const languageIntl = useIntl();
12
+ const {
13
+ numberFormatNotation,
14
+ applyTimeZoneOffset
15
+ } = useDataFormatConfig();
16
+ const getLocaleFromNotation = useCallback((notation) => {
15
17
  switch (notation) {
16
18
  case EU_NOTATION:
17
- return 'pl';
19
+ return "pl";
18
20
  case US_NOTATION:
19
- return 'en-US';
21
+ return "en-US";
20
22
  default:
21
- return 'pl';
23
+ return "pl";
22
24
  }
23
25
  }, []);
24
- var getFirstDayOfWeekFromNotation = useCallback(function (notation) {
26
+ const getFirstDayOfWeekFromNotation = useCallback((notation) => {
25
27
  switch (notation) {
26
28
  case EU_NOTATION:
27
29
  return 1;
@@ -31,84 +33,81 @@ export var useDataFormatUtils = function useDataFormatUtils() {
31
33
  return 1;
32
34
  }
33
35
  }, []);
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);
36
+ const getThousandDelimiterFromNotation = useCallback((notation) => notation === US_NOTATION ? US_THOUSAND_DELIMITER : EU_THOUSAND_DELIMITER, []);
37
+ const getDecimalDelimiterFromNotation = useCallback((notation) => notation === US_NOTATION ? US_DECIMAL_DELIMITER : EU_DECIMAL_DELIMITER, []);
38
+ const getIs12HoursClockFromNotation = useCallback((notation) => notation === US_NOTATION, []);
39
+ const getFormattedNumber = useCallback((value, numberFormatIntl, options) => {
40
+ const thousandDelimiter = getThousandDelimiterFromNotation(numberFormatNotation);
41
+ const decimalDelimiter = getDecimalDelimiterFromNotation(numberFormatNotation);
46
42
  return convertNumberString(value, numberFormatIntl, languageIntl, thousandDelimiter, decimalDelimiter, options);
47
43
  }, [languageIntl, numberFormatNotation, getThousandDelimiterFromNotation, getDecimalDelimiterFromNotation]);
48
- var _useIntl = useIntl(),
49
- globalTimeZone = _useIntl.timeZone;
50
- var getFormattedDate = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
51
- var _options$applyTimeZon, _value$toString;
52
- var valueInContextTimeZone = (_options$applyTimeZon = options == null ? void 0 : options.applyTimeZoneOffset) != null ? _options$applyTimeZon : applyTimeZoneOffset;
53
- var valueInTimezone = globalTimeZone && valueInContextTimeZone ? getLocalDateInTimeZone(value.toISOString(), globalTimeZone) : value;
54
- if ((options == null ? void 0 : options.targetFormat) === DATETIME) {
44
+ const {
45
+ timeZone: globalTimeZone
46
+ } = useIntl();
47
+ const getFormattedDate = useCallback((value, dateFormatIntl, timeFormatIntl, options) => {
48
+ const valueInContextTimeZone = options?.applyTimeZoneOffset ?? applyTimeZoneOffset;
49
+ const valueInTimezone = globalTimeZone && valueInContextTimeZone ? getLocalDateInTimeZone(value.toISOString(), globalTimeZone) : value;
50
+ if (options?.targetFormat === DATETIME) {
55
51
  return convertDateToDateTimeString(valueInTimezone, dateFormatIntl, timeFormatIntl, languageIntl, options);
56
52
  }
57
- if ((options == null ? void 0 : options.targetFormat) === TIME) {
53
+ if (options?.targetFormat === TIME) {
58
54
  return convertDateToTimeString(valueInTimezone, timeFormatIntl, options);
59
55
  }
60
- if ((options == null ? void 0 : options.targetFormat) === RELATIVE_TO) {
56
+ if (options?.targetFormat === RELATIVE_TO) {
61
57
  return convertDateToRelativeToString(value);
62
58
  }
63
- if ((options == null ? void 0 : options.targetFormat) === RELATIVE_TO_WITHOUT_SUFFIX) {
59
+ if (options?.targetFormat === RELATIVE_TO_WITHOUT_SUFFIX) {
64
60
  return convertDateToRelativeToString(value, true);
65
61
  }
66
- if ((options == null ? void 0 : options.targetFormat) === RELATIVE_FROM) {
62
+ if (options?.targetFormat === RELATIVE_FROM) {
67
63
  return convertDateToRelativeFromString(value);
68
64
  }
69
- if ((options == null ? void 0 : options.targetFormat) === RELATIVE_FROM_WITHOUT_SUFFIX) {
65
+ if (options?.targetFormat === RELATIVE_FROM_WITHOUT_SUFFIX) {
70
66
  return convertDateToRelativeFromString(value, true);
71
67
  }
72
- if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_LONG) {
68
+ if (options?.targetFormat === WEEKDAY_LONG) {
73
69
  return convertDateToWeekdayLongString(valueInTimezone, dateFormatIntl, languageIntl, options);
74
70
  }
75
- if ((options == null ? void 0 : options.targetFormat) === WEEKDAY_SHORT) {
71
+ if (options?.targetFormat === WEEKDAY_SHORT) {
76
72
  return convertDateToWeekdayShortString(valueInTimezone, dateFormatIntl, languageIntl, options);
77
73
  }
78
- if ((options == null ? void 0 : options.targetFormat) === MONTH_LONG) {
74
+ if (options?.targetFormat === MONTH_LONG) {
79
75
  return convertDateToMonthLongString(valueInTimezone, dateFormatIntl, languageIntl, options);
80
76
  }
81
- if ((options == null ? void 0 : options.targetFormat) === MONTH_SHORT) {
77
+ if (options?.targetFormat === MONTH_SHORT) {
82
78
  return convertDateToMonthShortString(valueInTimezone, dateFormatIntl, languageIntl, options);
83
79
  }
84
- if ((options == null ? void 0 : options.targetFormat) === DATE || !(options != null && options.targetFormat)) {
80
+ if (options?.targetFormat === DATE || !options?.targetFormat) {
85
81
  return convertDateToDateString(valueInTimezone, dateFormatIntl, languageIntl, options);
86
82
  }
87
- return (_value$toString = value == null ? void 0 : value.toString()) != null ? _value$toString : '';
83
+ return value?.toString() ?? "";
88
84
  }, [globalTimeZone, applyTimeZoneOffset, languageIntl]);
89
- var getFormattedDateFromMoment = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
85
+ const getFormattedDateFromMoment = useCallback((value, dateFormatIntl, timeFormatIntl, options) => {
90
86
  return getFormattedDate(moment(value).toDate(), dateFormatIntl, timeFormatIntl, options);
91
87
  }, [getFormattedDate]);
92
- var getFormattedDateFromDayjs = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
88
+ const getFormattedDateFromDayjs = useCallback((value, dateFormatIntl, timeFormatIntl, options) => {
93
89
  return getFormattedDate(dayjs(value).toDate(), dateFormatIntl, timeFormatIntl, options);
94
90
  }, [getFormattedDate]);
95
- var getFormattedValueUsingCommonOptions = useCallback(function (value, options) {
96
- var result = value;
91
+ const getFormattedValueUsingCommonOptions = useCallback((value, options) => {
92
+ let result = value;
97
93
  result = addPrefix(result, options);
98
94
  result = addSuffix(result, options);
99
95
  result = changeNamingConvention(result, options);
100
96
  return result;
101
97
  }, []);
102
98
  return {
103
- getLocaleFromNotation: getLocaleFromNotation,
104
- getFirstDayOfWeekFromNotation: getFirstDayOfWeekFromNotation,
105
- getIs12HoursClockFromNotation: getIs12HoursClockFromNotation,
106
- getFormattedNumber: getFormattedNumber,
107
- getFormattedDate: getFormattedDate,
108
- getFormattedDateFromMoment: getFormattedDateFromMoment,
109
- getFormattedDateFromDayjs: getFormattedDateFromDayjs,
110
- getFormattedValueUsingCommonOptions: getFormattedValueUsingCommonOptions,
111
- getThousandDelimiterFromNotation: getThousandDelimiterFromNotation,
112
- getDecimalDelimiterFromNotation: getDecimalDelimiterFromNotation
99
+ getLocaleFromNotation,
100
+ getFirstDayOfWeekFromNotation,
101
+ getIs12HoursClockFromNotation,
102
+ getFormattedNumber,
103
+ getFormattedDate,
104
+ getFormattedDateFromMoment,
105
+ getFormattedDateFromDayjs,
106
+ getFormattedValueUsingCommonOptions,
107
+ getThousandDelimiterFromNotation,
108
+ getDecimalDelimiterFromNotation
113
109
  };
114
- };
110
+ };
111
+ export {
112
+ useDataFormatUtils
113
+ };
@@ -1,3 +1,3 @@
1
- import { type Dayjs } from 'dayjs';
2
- import { type Moment } from 'moment';
1
+ import { Dayjs } from 'dayjs';
2
+ import { Moment } from 'moment';
3
3
  export declare const useRelativeDateTimeUpdate: (value: Date | Moment | Dayjs) => number;