@synerise/ds-core 1.5.1 → 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.
Files changed (97) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +181 -0
  3. package/dist/i18n/es.json +0 -1
  4. package/dist/i18n/index.d.ts +1 -1
  5. package/dist/js/DSProvider/DSProvider.d.ts +2 -2
  6. package/dist/js/DSProvider/DSProvider.js +2 -2
  7. package/dist/js/DSProvider/LocaleProvider/LocaleProvider.utils.d.ts +1 -1
  8. package/dist/js/DSProvider/ThemeProvider/breakpoints.d.ts +5 -1
  9. package/dist/js/data-format/components/FormattedDate.d.ts +9 -0
  10. package/dist/js/data-format/components/FormattedDate.js +9 -0
  11. package/dist/js/data-format/components/FormattedDateTime.d.ts +9 -0
  12. package/dist/js/data-format/components/FormattedDateTime.js +13 -0
  13. package/dist/js/data-format/components/FormattedNumber.d.ts +7 -0
  14. package/dist/js/data-format/components/FormattedNumber.js +9 -0
  15. package/dist/js/data-format/components/FormattedRelativeDateTime.d.ts +10 -0
  16. package/dist/js/data-format/components/FormattedRelativeDateTime.js +24 -0
  17. package/dist/js/data-format/components/FormattedTime.d.ts +9 -0
  18. package/dist/js/data-format/components/FormattedTime.js +13 -0
  19. package/dist/js/data-format/components/index.d.ts +5 -0
  20. package/dist/js/data-format/components/index.js +5 -0
  21. package/dist/js/data-format/constants/dataFormat.constants.d.ts +36 -0
  22. package/dist/js/data-format/constants/dataFormat.constants.js +52 -0
  23. package/dist/js/data-format/constants/dataFormatConfig.constants.d.ts +7 -0
  24. package/dist/js/data-format/constants/dataFormatConfig.constants.js +14 -0
  25. package/dist/js/data-format/constants/dateTimeParts.constants.d.ts +5 -0
  26. package/dist/js/data-format/constants/dateTimeParts.constants.js +4 -0
  27. package/dist/js/data-format/constants/index.d.ts +3 -0
  28. package/dist/js/data-format/constants/index.js +3 -0
  29. package/dist/js/data-format/contexts/DataFormatConfigContext.d.ts +2 -0
  30. package/dist/js/data-format/contexts/DataFormatConfigContext.js +3 -0
  31. package/dist/js/data-format/contexts/DataFormatIntlsContext.d.ts +2 -0
  32. package/dist/js/data-format/contexts/DataFormatIntlsContext.js +7 -0
  33. package/dist/js/data-format/contexts/index.d.ts +2 -0
  34. package/dist/js/data-format/contexts/index.js +2 -0
  35. package/dist/js/data-format/hocs/withDataFormat.d.ts +4 -0
  36. package/dist/js/data-format/hocs/withDataFormat.js +10 -0
  37. package/dist/js/data-format/hooks/index.d.ts +5 -0
  38. package/dist/js/data-format/hooks/index.js +5 -0
  39. package/dist/js/data-format/hooks/useDataFormat.d.ts +12 -0
  40. package/dist/js/data-format/hooks/useDataFormat.js +96 -0
  41. package/dist/js/data-format/hooks/useDataFormatConfig.d.ts +2 -0
  42. package/dist/js/data-format/hooks/useDataFormatConfig.js +5 -0
  43. package/dist/js/data-format/hooks/useDataFormatIntls.d.ts +2 -0
  44. package/dist/js/data-format/hooks/useDataFormatIntls.js +5 -0
  45. package/dist/js/data-format/hooks/useDataFormatUtils.d.ts +16 -0
  46. package/dist/js/data-format/hooks/useDataFormatUtils.js +113 -0
  47. package/dist/js/data-format/hooks/useSingleIntl.d.ts +4 -0
  48. package/dist/js/data-format/hooks/useSingleIntl.js +12 -0
  49. package/dist/js/data-format/index.d.ts +8 -0
  50. package/dist/js/data-format/index.js +7 -0
  51. package/dist/js/data-format/providers/DataFormatConfigProvider.d.ts +7 -0
  52. package/dist/js/data-format/providers/DataFormatConfigProvider.js +26 -0
  53. package/dist/js/data-format/types/dataFormat.types.d.ts +42 -0
  54. package/dist/js/data-format/types/dataFormat.types.js +5 -0
  55. package/dist/js/data-format/types/dataFormatConfig.types.d.ts +16 -0
  56. package/dist/js/data-format/types/dataFormatConfig.types.js +2 -0
  57. package/dist/js/data-format/types/dateTimeParts.types.d.ts +3 -0
  58. package/dist/js/data-format/types/dateTimeParts.types.js +2 -0
  59. package/dist/js/data-format/types/index.d.ts +3 -0
  60. package/dist/js/data-format/types/index.js +1 -0
  61. package/dist/js/data-format/utils/dataFormat.utils.d.ts +16 -0
  62. package/dist/js/data-format/utils/dataFormat.utils.js +119 -0
  63. package/dist/js/data-format/utils/dataFormatConfig.utils.d.ts +2 -0
  64. package/dist/js/data-format/utils/dataFormatConfig.utils.js +8 -0
  65. package/dist/js/data-format/utils/date.utils.d.ts +8 -0
  66. package/dist/js/data-format/utils/date.utils.js +50 -0
  67. package/dist/js/data-format/utils/dateTimeParts.utils.d.ts +14 -0
  68. package/dist/js/data-format/utils/dateTimeParts.utils.js +86 -0
  69. package/dist/js/data-format/utils/index.d.ts +5 -0
  70. package/dist/js/data-format/utils/index.js +5 -0
  71. package/dist/js/data-format/utils/timeZone.utils.d.ts +16 -0
  72. package/dist/js/data-format/utils/timeZone.utils.js +94 -0
  73. package/dist/js/index.d.ts +3 -0
  74. package/dist/js/index.js +4 -1
  75. package/dist/js/mediaQuery/mediaQuery.d.ts +1 -5
  76. package/dist/js/testing/index.d.ts +2 -0
  77. package/dist/js/testing/index.js +2 -0
  78. package/dist/js/testing/renderWithProvider/renderWithProvider.d.ts +10 -0
  79. package/dist/js/testing/renderWithProvider/renderWithProvider.js +28 -0
  80. package/dist/js/testing/renderWithProvider/renderWithProvider.spec.d.ts +1 -0
  81. package/dist/js/testing/sleep.d.ts +1 -0
  82. package/dist/js/testing/sleep.js +8 -0
  83. package/dist/js/toaster/Toaster.d.ts +2 -0
  84. package/dist/js/toaster/Toaster.js +8 -0
  85. package/dist/js/toaster/Toaster.types.d.ts +1 -0
  86. package/dist/js/toaster/Toaster.types.js +1 -0
  87. package/dist/js/toaster/constants.d.ts +2 -0
  88. package/dist/js/toaster/constants.js +8 -0
  89. package/dist/js/toaster/contexts/ToasterContext.d.ts +6 -0
  90. package/dist/js/toaster/contexts/ToasterContext.js +6 -0
  91. package/dist/js/toaster/hooks/useToaster.d.ts +1 -0
  92. package/dist/js/toaster/hooks/useToaster.js +5 -0
  93. package/dist/js/toaster/index.d.ts +6 -0
  94. package/dist/js/toaster/index.js +5 -0
  95. package/dist/js/toaster/providers/ToasterProvider.d.ts +6 -0
  96. package/dist/js/toaster/providers/ToasterProvider.js +17 -0
  97. package/package.json +14 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.5.2](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.5.1...@synerise/ds-core@1.5.2) (2025-09-16)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [1.5.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.5.0...@synerise/ds-core@1.5.1) (2025-08-28)
7
15
 
8
16
 
package/README.md CHANGED
@@ -26,3 +26,184 @@ Bunch of components to bootstrap application.
26
26
  | defaultMessages | Object with fallback translations | object | |
27
27
  | dataFormatConfig | Object with data (dates/numbers) notations | DataFormatConfig | EU notation |
28
28
  | includeToaster | Opt out of rendering a Toaster component for rendering toasts (messages) | boolean | true |
29
+
30
+ # Data formatting
31
+
32
+ ## Usage
33
+
34
+ ### For function components:
35
+
36
+ ```tsx harmony
37
+ import React, { FC } from 'react';
38
+
39
+ import {
40
+ FormattedDate,
41
+ FormattedDateTime,
42
+ FormattedNumber,
43
+ FormattedTime,
44
+ useDataFormat,
45
+ } from '@synerise/ds-core';
46
+
47
+ const DATE = new Date('2023-06-25T15:40:00');
48
+ const DATE_TO_FORMAT = DATE; // moment(DATE) // dayjs(DATE)
49
+
50
+ export const FunctionComponent: FC = (): JSX.Element => {
51
+ const {
52
+ firstDayOfWeek,
53
+ isSundayFirstWeekDay,
54
+ is12HoursClock,
55
+ formatValue,
56
+ formatMultipleValues,
57
+ getConstants,
58
+ thousandDelimiter,
59
+ decimalDelimiter,
60
+ } = useDataFormat();
61
+
62
+ firstDayOfWeek; // Sunday = 0 // Monday = 1
63
+ isSundayFirstWeekDay; // true // false
64
+ is12HoursClock; // true // false
65
+
66
+ formatValue(1234567);
67
+ formatValue(DATE_TO_FORMAT);
68
+ formatValue(DATE_TO_FORMAT, { targetFormat: 'date' });
69
+ formatValue(DATE_TO_FORMAT, { targetFormat: 'time' });
70
+ formatValue(DATE_TO_FORMAT, { targetFormat: 'datetime' });
71
+
72
+ formatMultipleValues([1234567, 1234567]);
73
+ formatMultipleValues([DATE_TO_FORMAT, DATE_TO_FORMAT], {
74
+ targetFormat: 'datetime',
75
+ });
76
+
77
+ getConstants('months-long');
78
+ getConstants('months-short');
79
+ getConstants('weekdays-long');
80
+ getConstants('weekdays-short');
81
+ getConstants(
82
+ 'months-long',
83
+ { namingConvention: 'lowerCase' },
84
+ new Date(2022, 10),
85
+ new Date(2023, 2),
86
+ 'month',
87
+ );
88
+
89
+ thousandDelimiter; // "," // " "
90
+ decimalDelimiter; // "." // ","
91
+
92
+ return (
93
+ <>
94
+ <FormattedNumber value={1234567} options={{ unit: 'percent' }} />
95
+ <FormattedDate value={DATE_TO_FORMAT} options={{ month: 'long' }} />
96
+ <FormattedTime value={DATE_TO_FORMAT} options={{ second: 'numeric' }} />
97
+ <FormattedDateTime
98
+ value={DATE_TO_FORMAT}
99
+ options={{
100
+ dateOptions: { month: 'long' },
101
+ timeOptions: { second: 'numeric' },
102
+ }}
103
+ />
104
+ </>
105
+ );
106
+ };
107
+ ```
108
+
109
+ For class components:
110
+
111
+ ```tsx harmony
112
+ import React, { Component, FC } from 'react';
113
+ import { withDataFormat, WithDataFormatProps } from '@synerise/ds-core';
114
+
115
+ type ClassComponentProps = {
116
+ ...
117
+ } & WithDataFormatProps;
118
+
119
+ class ClassComponent extends Component<ClassComponentProps> {
120
+ constructor(props: ClassComponentProps) {
121
+ super(props);
122
+ }
123
+
124
+ render() {
125
+ const {
126
+ firstDayOfWeek,
127
+ isSundayFirstWeekDay,
128
+ is12HoursClock,
129
+ formatValue,
130
+ formatMultipleValues,
131
+ getConstants,
132
+ thousandDelimiter,
133
+ decimalDelimiter,
134
+ } = this.props;
135
+
136
+ return (
137
+ <>
138
+ <div>{formatValue(1234567)}</div>
139
+ </>
140
+ );
141
+ }
142
+ }
143
+
144
+ export default withDataFormat(ClassComponent) as FC<ClassComponentProps>;
145
+ ```
146
+
147
+ ## Examples
148
+
149
+ ### Number
150
+
151
+ The `options` object is compatible with https://formatjs.io/docs/react-intl/api#formatnumber
152
+
153
+ | Code | EU Notation | US Notation |
154
+ | ---------------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------------------- |
155
+ | formatValue(1234567) | 1 234 567 | 1,234,567 |
156
+ | formatValue(1234567.89) | 1 234 567,89 | 1,234,567.89 |
157
+ | formatValue(1234567, { minimumFractionDigits: 2 }) | 1 234 567,00 | 1,234,567.00 |
158
+ | formatValue(1234567.89, { maximumFractionDigits: 1 }) | 1 234 567,9 | 1,234,567.9 |
159
+ | formatValue(1234567.89, { style: 'currency', currency: 'USD', prefix: 'Salary: ', suffix: ' per month' })) | Salary: $1 234 567,89 per month | Salary: $1,234,567.89 per month |
160
+ | formatValue(1234, { notation: 'compact' })) | 1,2K (with PL locale: 1,2 tys.) | 1.2K (with PL locale: 1.2 tys.) |
161
+ | formatValue(1, { pluralOptions: { type: 'ordinal' } })) | one | one |
162
+
163
+ ### Date
164
+
165
+ The `options` object is compatible with https://formatjs.io/docs/react-intl/api#formatdate
166
+
167
+ | Code | EU Notation | US Notation |
168
+ | ---------------------------------------------------- | ------------ | ------------- |
169
+ | formatValue(date) | 25.06.2023 | 6/25/2023 |
170
+ | formatValue(date, { month: 'long' }) | 25 June 2023 | June 25, 2023 |
171
+ | formatValue(date, { targetFormat: 'weekday-long' }) | Sunday | Sunday |
172
+ | formatValue(date, { targetFormat: 'weekday-short' }) | Sun | Sun |
173
+ | formatValue(date, { targetFormat: 'month-long' }) | June | June |
174
+ | formatValue(date, { targetFormat: 'month-short' }) | Jun | Jun |
175
+
176
+ ### Time
177
+
178
+ The `options` object is compatible with https://formatjs.io/docs/react-intl/api#formatdate
179
+
180
+ | Code | EU Notation | US Notation |
181
+ | -------------------------------------------------------------- | ----------- | ----------- |
182
+ | formatValue(date, { targetFormat: 'time' }) | 15:40 | 3:40 PM |
183
+ | formatValue(date, { targetFormat: 'time', second: 'numeric' }) | 15:40:00 | 3:40:00 PM |
184
+
185
+ ### DateTime
186
+
187
+ The `dateOptions` object and the `timeOptions` object are compatible with https://formatjs.io/docs/react-intl/api#formatdate
188
+
189
+ | Code | EU Notation | US Notation |
190
+ | ------------------------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------- |
191
+ | formatValue(date, { targetFormat: 'datetime' }) | 25.06.2023, 15:40 | 6/25/2023, 3:40 PM |
192
+ | formatValue(date, { targetFormat: 'datetime', dateOptions: { month: 'long' }, timeOptions: { second: 'numeric' } }) | 25 June 2023, 3:40:00 PM | June 25, 2023, 3:40:00 PM |
193
+
194
+ ### formatMultipleValues
195
+
196
+ | Code | EU Notation | US Notation |
197
+ | ---------------------------------------------------------------------- | -------------------------------- | -------------------------------- |
198
+ | formatMultipleValues([1234567, 1234567], { minimumFractionDigits: 2 }) | ['1 234 567,00', '1 234 567,00'] | ['1,234,567.00', '1,234,567.00'] |
199
+ | formatMultipleValues([date, date], { targetFormat: 'month-long' }) | ['June', 'June'] | ['June', 'June'] |
200
+
201
+ ### getConstants
202
+
203
+ | Code | EU Notation | US Notation |
204
+ | ------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------ |
205
+ | getConstants('months-long') | ['January', '...', 'December'] | ['January', '...', 'December'] |
206
+ | getConstants('months-short') | ['Jan', '...', 'Dec'] | ['Jan', '...', 'Dec'] |
207
+ | getConstants('weekdays-long') | ['Monday', '...', 'Sunday'] | ['Sunday', '...', 'Saturday'] |
208
+ | getConstants('weekdays-short') | ['Mon', '...', 'Sun'] | ['Sun', '...', 'Sat'] |
209
+ | getConstants('months-long', { namingConvention: 'lowerCase' }, startDate, endDate, 'month') | ['november', '...', 'march'] | ['november', '...', 'march'] |
package/dist/i18n/es.json CHANGED
@@ -176,7 +176,6 @@
176
176
  "TITLE": "Administrar columnas",
177
177
  "SEARCH-PLACEHOLDER": "Buscar",
178
178
  "SEARCH-RESULTS": "Resultados de búsqueda",
179
- "NO-RESULTS": "Sin resultados",
180
179
  "VISIBLE": "Visible",
181
180
  "HIDDEN": "Oculto",
182
181
  "SAVE-VIEW": "Guardar vista",
@@ -1066,7 +1066,6 @@ declare const _default: {
1066
1066
  TITLE: string;
1067
1067
  "SEARCH-PLACEHOLDER": string;
1068
1068
  "SEARCH-RESULTS": string;
1069
- "NO-RESULTS": string;
1070
1069
  VISIBLE: string;
1071
1070
  HIDDEN: string;
1072
1071
  "SAVE-VIEW": string;
@@ -1096,6 +1095,7 @@ declare const _default: {
1096
1095
  TO: string;
1097
1096
  REMOVE: string;
1098
1097
  ADD_RANGE: string;
1098
+ "NO-RESULTS": string;
1099
1099
  ERROR_EMPTY_RANGE: string;
1100
1100
  ERROR_EMPTY_FROM_FIELD: string;
1101
1101
  ERROR_EMPTY_TO_FIELD: string;
@@ -1,7 +1,7 @@
1
1
  import React, { type PropsWithChildren } from 'react';
2
- import { type DataFormatConfigProviderProps } from '@synerise/ds-data-format';
3
- import { type ToasterProps } from '@synerise/ds-toaster';
2
+ import { type DataFormatConfigProviderProps } from '../data-format';
4
3
  import '../style';
4
+ import { type ToasterProps } from '../toaster';
5
5
  import { type LocaleProviderProps } from './LocaleProvider/LocaleProvider.types';
6
6
  import { type ThemeProviderProps } from './ThemeProvider/ThemeProvider';
7
7
  export type DSProviderProps = PropsWithChildren<LocaleProviderProps & ThemeProviderProps & DataFormatConfigProviderProps & {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { DataFormatConfigProvider } from '@synerise/ds-data-format';
3
- import Toaster, { TOASTER_DEFAULTS, ToasterProvider } from '@synerise/ds-toaster';
2
+ import { DataFormatConfigProvider } from '../data-format';
4
3
  import '../style';
4
+ import Toaster, { TOASTER_DEFAULTS, ToasterProvider } from '../toaster';
5
5
  import LocaleProvider from './LocaleProvider';
6
6
  import ThemeProvider from './ThemeProvider';
7
7
  var DSProvider = function DSProvider(_ref) {
@@ -178,7 +178,6 @@ export declare const getDSMessages: (lang: string) => {
178
178
  TITLE: string;
179
179
  "SEARCH-PLACEHOLDER": string;
180
180
  "SEARCH-RESULTS": string;
181
- "NO-RESULTS": string;
182
181
  VISIBLE: string;
183
182
  HIDDEN: string;
184
183
  "SAVE-VIEW": string;
@@ -208,6 +207,7 @@ export declare const getDSMessages: (lang: string) => {
208
207
  TO: string;
209
208
  REMOVE: string;
210
209
  ADD_RANGE: string;
210
+ "NO-RESULTS": string;
211
211
  ERROR_EMPTY_RANGE: string;
212
212
  ERROR_EMPTY_FROM_FIELD: string;
213
213
  ERROR_EMPTY_TO_FIELD: string;
@@ -1,3 +1,7 @@
1
- import { type BreakpointsData } from '../../mediaQuery/mediaQuery';
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,7 @@
1
+ import React from 'react';
2
+ import { type NumberToFormatOptions } from '../types';
3
+ export type FormattedNumberProps = {
4
+ value: number;
5
+ options?: NumberToFormatOptions;
6
+ };
7
+ export declare const FormattedNumber: React.FC<FormattedNumberProps>;
@@ -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,4 @@
1
+ export var WEEKDAY = 'weekday';
2
+ export var MONTH = 'month';
3
+ export var LONG = 'long';
4
+ export var SHORT = 'short';
@@ -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,2 @@
1
+ import { type DataFormatConfig } from '../types';
2
+ export declare const DataFormatConfigContext: import("react").Context<DataFormatConfig>;
@@ -0,0 +1,3 @@
1
+ import { createContext } from 'react';
2
+ import { DEFAULT_DATA_FORMAT_CONFIG } from '../constants';
3
+ export var DataFormatConfigContext = /*#__PURE__*/createContext(DEFAULT_DATA_FORMAT_CONFIG);
@@ -0,0 +1,2 @@
1
+ import { type DataFormatIntls } from '../types';
2
+ export declare const DataFormatIntlsContext: import("react").Context<DataFormatIntls>;
@@ -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,2 @@
1
+ export { DataFormatConfigContext } from './DataFormatConfigContext';
2
+ export { DataFormatIntlsContext } from './DataFormatIntlsContext';
@@ -0,0 +1,2 @@
1
+ export { DataFormatConfigContext } from './DataFormatConfigContext';
2
+ export { DataFormatIntlsContext } from './DataFormatIntlsContext';
@@ -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;