@synerise/ds-core 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/i18n/en.json +2 -2
- package/dist/i18n/es.json +2 -2
- package/dist/i18n/pl.json +2 -2
- package/dist/i18n/pt.json +2 -2
- package/dist/js/data-format/components/FormattedRelativeDateTime.js +3 -1
- package/dist/js/data-format/hooks/index.d.ts +1 -0
- package/dist/js/data-format/hooks/index.js +2 -1
- package/dist/js/data-format/hooks/useDataFormatUtils.js +3 -2
- package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.d.ts +3 -0
- package/dist/js/data-format/hooks/useRelativeDateTimeUpdate.js +37 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.10.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.9.1...@synerise/ds-core@1.10.0) (2026-01-19)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **core:** refresh relative date ([23d74a6](https://github.com/synerise/synerise-design/commit/23d74a6855e082a6895d8799b61fa8b78fb27ae1))
|
|
11
|
+
|
|
12
|
+
## [1.9.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.9.0...@synerise/ds-core@1.9.1) (2026-01-07)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **core:** tz flag via prop should take precedence ([07d1ab0](https://github.com/synerise/synerise-design/commit/07d1ab0dbec9c2116b937bf8894d36a83880cf64))
|
|
17
|
+
|
|
6
18
|
# [1.9.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.8.2...@synerise/ds-core@1.9.0) (2025-12-19)
|
|
7
19
|
|
|
8
20
|
### Features
|
package/dist/i18n/en.json
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"CREATOR": "Creator",
|
|
82
82
|
"RAW_BUTTON_LABEL": "Raw",
|
|
83
83
|
"SEARCH_PLACEHOLDER": "Search",
|
|
84
|
-
"COLLECTOR_PLACEHOLDER": "
|
|
84
|
+
"COLLECTOR_PLACEHOLDER": "Separate values by {delimiterShortCut} or type {escapeShortCut} to add string containing comma",
|
|
85
85
|
"COLLECTOR_ADD": "Add",
|
|
86
86
|
"COLLECTOR_CANCEL": "Cancel",
|
|
87
87
|
"SEARCH_CLEAR_TOOLTIP": "Clear",
|
|
@@ -489,4 +489,4 @@
|
|
|
489
489
|
"NO-SEARCH-RESULTS": "No tags found"
|
|
490
490
|
}
|
|
491
491
|
}
|
|
492
|
-
}
|
|
492
|
+
}
|
package/dist/i18n/es.json
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"CREATOR": "Creador",
|
|
78
78
|
"RAW_BUTTON_LABEL": "Crudo",
|
|
79
79
|
"SEARCH_PLACEHOLDER": "Buscar",
|
|
80
|
-
"COLLECTOR_PLACEHOLDER": "
|
|
80
|
+
"COLLECTOR_PLACEHOLDER": "Separa valores por {delimiterShortCut} o escribe {escapeShortCut} para añadir una cadena con coma",
|
|
81
81
|
"COLLECTOR_ADD": "Añadir",
|
|
82
82
|
"COLLECTOR_CANCEL": "Cancelar",
|
|
83
83
|
"SEARCH_CLEAR_TOOLTIP": "Borrar",
|
|
@@ -484,4 +484,4 @@
|
|
|
484
484
|
"NO-SEARCH-RESULTS": "No se encontraron etiquetas"
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
}
|
|
487
|
+
}
|
package/dist/i18n/pl.json
CHANGED
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"CREATOR": "Kreator",
|
|
94
94
|
"RAW_BUTTON_LABEL": "Wartości",
|
|
95
95
|
"SEARCH_PLACEHOLDER": "Szukaj",
|
|
96
|
-
"COLLECTOR_PLACEHOLDER": "
|
|
96
|
+
"COLLECTOR_PLACEHOLDER": "Rozdziel wartości za pomocą {delimiterShortCut} lub wpisz {escapeShortCut}, aby dodać wartość zawierającą przecinek",
|
|
97
97
|
"COLLECTOR_ADD": "Dodaj",
|
|
98
98
|
"COLLECTOR_CANCEL": "Anuluj",
|
|
99
99
|
"SEARCH_CLEAR_TOOLTIP": "Wyczyść",
|
|
@@ -426,4 +426,4 @@
|
|
|
426
426
|
"NO-SEARCH-RESULTS": "Nie znaleziono tagów"
|
|
427
427
|
}
|
|
428
428
|
}
|
|
429
|
-
}
|
|
429
|
+
}
|
package/dist/i18n/pt.json
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"CREATOR": "Criador",
|
|
78
78
|
"RAW_BUTTON_LABEL": "Bruto",
|
|
79
79
|
"SEARCH_PLACEHOLDER": "Pesquisar",
|
|
80
|
-
"COLLECTOR_PLACEHOLDER": "
|
|
80
|
+
"COLLECTOR_PLACEHOLDER": "Separe valores por {delimiterShortCut} ou digite {escapeShortCut} para adicionar uma string contendo vírgula",
|
|
81
81
|
"COLLECTOR_ADD": "Adicionar",
|
|
82
82
|
"COLLECTOR_CANCEL": "Cancelar",
|
|
83
83
|
"SEARCH_CLEAR_TOOLTIP": "Limpar",
|
|
@@ -486,4 +486,4 @@
|
|
|
486
486
|
"NO-SEARCH-RESULTS": "Nenhuma tag encontrada"
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
}
|
|
489
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
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
2
|
import React from 'react';
|
|
3
3
|
import { RELATIVE_FROM, RELATIVE_FROM_WITHOUT_SUFFIX, RELATIVE_TO, RELATIVE_TO_WITHOUT_SUFFIX } from '../constants';
|
|
4
|
-
import { useDataFormat } from '../hooks';
|
|
4
|
+
import { useDataFormat, useRelativeDateTimeUpdate } from '../hooks';
|
|
5
5
|
export var FormattedRelativeDateTimeTo = function FormattedRelativeDateTimeTo(_ref) {
|
|
6
6
|
var value = _ref.value,
|
|
7
7
|
withoutSuffix = _ref.withoutSuffix,
|
|
8
8
|
options = _ref.options;
|
|
9
|
+
useRelativeDateTimeUpdate(value);
|
|
9
10
|
var _useDataFormat = useDataFormat(),
|
|
10
11
|
formatValue = _useDataFormat.formatValue;
|
|
11
12
|
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
@@ -16,6 +17,7 @@ export var FormattedRelativeDateTimeFrom = function FormattedRelativeDateTimeFro
|
|
|
16
17
|
var value = _ref2.value,
|
|
17
18
|
withoutSuffix = _ref2.withoutSuffix,
|
|
18
19
|
options = _ref2.options;
|
|
20
|
+
useRelativeDateTimeUpdate(value);
|
|
19
21
|
var _useDataFormat2 = useDataFormat(),
|
|
20
22
|
formatValue = _useDataFormat2.formatValue;
|
|
21
23
|
return /*#__PURE__*/React.createElement(React.Fragment, null, formatValue(value, _extends({}, options, {
|
|
@@ -3,3 +3,4 @@ export { useDataFormat, type UseDataFormatProps } from './useDataFormat';
|
|
|
3
3
|
export { useDataFormatUtils } from './useDataFormatUtils';
|
|
4
4
|
export { useSingleIntl } from './useSingleIntl';
|
|
5
5
|
export { useDataFormatIntls } from './useDataFormatIntls';
|
|
6
|
+
export { useRelativeDateTimeUpdate } from './useRelativeDateTimeUpdate';
|
|
@@ -2,4 +2,5 @@ export { useDataFormatConfig } from './useDataFormatConfig';
|
|
|
2
2
|
export { useDataFormat } from './useDataFormat';
|
|
3
3
|
export { useDataFormatUtils } from './useDataFormatUtils';
|
|
4
4
|
export { useSingleIntl } from './useSingleIntl';
|
|
5
|
-
export { useDataFormatIntls } from './useDataFormatIntls';
|
|
5
|
+
export { useDataFormatIntls } from './useDataFormatIntls';
|
|
6
|
+
export { useRelativeDateTimeUpdate } from './useRelativeDateTimeUpdate';
|
|
@@ -48,8 +48,9 @@ export var useDataFormatUtils = function useDataFormatUtils() {
|
|
|
48
48
|
var _useIntl = useIntl(),
|
|
49
49
|
globalTimeZone = _useIntl.timeZone;
|
|
50
50
|
var getFormattedDate = useCallback(function (value, dateFormatIntl, timeFormatIntl, options) {
|
|
51
|
-
var _value$toString;
|
|
52
|
-
var
|
|
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;
|
|
53
54
|
if ((options == null ? void 0 : options.targetFormat) === DATETIME) {
|
|
54
55
|
return convertDateToDateTimeString(valueInTimezone, dateFormatIntl, timeFormatIntl, languageIntl, options);
|
|
55
56
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
var getIntervalForTimeDifference = function getIntervalForTimeDifference(timeDiffMs) {
|
|
3
|
+
// https://day.js.org/docs/en/display/from-now#list-of-breakdown-range
|
|
4
|
+
var UNDER_45_MINUTES = 45 * 60 * 1000;
|
|
5
|
+
var UNDER_22_HOURS = 22 * 60 * 60 * 1000;
|
|
6
|
+
if (timeDiffMs < UNDER_45_MINUTES) {
|
|
7
|
+
return 60 * 1000; // 60 seconds
|
|
8
|
+
}
|
|
9
|
+
if (timeDiffMs < UNDER_22_HOURS) {
|
|
10
|
+
return 60 * 60 * 1000; // 60 minutes
|
|
11
|
+
}
|
|
12
|
+
return null; // no interval
|
|
13
|
+
};
|
|
14
|
+
export var useRelativeDateTimeUpdate = function useRelativeDateTimeUpdate(value) {
|
|
15
|
+
var _useState = useState(0),
|
|
16
|
+
updateTrigger = _useState[0],
|
|
17
|
+
setUpdateTrigger = _useState[1];
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
if (!(value instanceof Date)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
var timeDiffMs = Math.abs(value.getTime() - Date.now());
|
|
23
|
+
var interval = getIntervalForTimeDifference(timeDiffMs);
|
|
24
|
+
if (interval === null) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
var timeoutId = setTimeout(function () {
|
|
28
|
+
setUpdateTrigger(function (prev) {
|
|
29
|
+
return prev + 1;
|
|
30
|
+
});
|
|
31
|
+
}, interval);
|
|
32
|
+
return function () {
|
|
33
|
+
return clearTimeout(timeoutId);
|
|
34
|
+
};
|
|
35
|
+
}, [value, updateTrigger]);
|
|
36
|
+
return updateTrigger;
|
|
37
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Core Components for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"hex-rgb": "^5.0.0",
|
|
58
58
|
"less-vars-to-js": "^1.3.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "451fc5f79af6c42be89179a11374a78bdec1110f"
|
|
61
61
|
}
|