@synerise/ds-core 1.9.1 → 1.10.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.
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.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-core@1.10.0...@synerise/ds-core@1.10.1) (2026-01-29)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **toast:** wire up dismiss ([094da31](https://github.com/synerise/synerise-design/commit/094da318d43f99fb8dd64262efce6ee1c95b46a1))
11
+
12
+ # [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)
13
+
14
+ ### Features
15
+
16
+ - **core:** refresh relative date ([23d74a6](https://github.com/synerise/synerise-design/commit/23d74a6855e082a6895d8799b61fa8b78fb27ae1))
17
+
6
18
  ## [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)
7
19
 
8
20
  ### Bug Fixes
@@ -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';
@@ -0,0 +1,3 @@
1
+ import { type Dayjs } from 'dayjs';
2
+ import { type Moment } from 'moment';
3
+ export declare const useRelativeDateTimeUpdate: (value: Date | Moment | Dayjs) => number;
@@ -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
+ };
@@ -1,6 +1,9 @@
1
1
  export var TOASTER_DEFAULTS = {
2
2
  position: 'bottom-left',
3
3
  reverseOrder: false,
4
+ toastOptions: {
5
+ removeDelay: 200
6
+ },
4
7
  gutter: 8,
5
8
  containerStyle: {
6
9
  padding: '24px'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-core",
3
- "version": "1.9.1",
3
+ "version": "1.10.1",
4
4
  "description": "Core Components for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -17,20 +17,20 @@
17
17
  "access": "public"
18
18
  },
19
19
  "scripts": {
20
- "build": "npm run build:js && npm run vars && npm run copy && npm run build:css && npm run defs",
20
+ "build": "pnpm run build:js && pnpm run vars && pnpm run copy && pnpm run build:css && pnpm run defs",
21
21
  "build:css": "node ../../../scripts/style/less.js",
22
22
  "build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
23
- "build:watch": "npm run build:js -- --watch",
23
+ "build:watch": "pnpm run build:js -- --watch",
24
24
  "copy": "node ./build/copy.js",
25
25
  "defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
26
26
  "pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
27
- "prepublish": "npm run build",
27
+ "prepublish": "pnpm run build",
28
28
  "test": "jest && pnpm test:timezones",
29
29
  "test:timezone-ny": "TZ=America/New_York jest -t TimezoneTesting",
30
30
  "test:timezone-utc": "TZ=UTC jest -t TimezoneTesting",
31
31
  "test:timezone-waw": "TZ=Europe/Warsaw jest -t TimezoneTesting",
32
32
  "test:timezones": "pnpm test:timezone-utc && pnpm test:timezone-ny && pnpm test:timezone-waw",
33
- "test:watch": "npm run test -- --watchAll",
33
+ "test:watch": "pnpm run test -- --watchAll",
34
34
  "types": "tsc --noEmit",
35
35
  "check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
36
36
  "upgrade:ds": "ncu -f \"@synerise/ds-*\" -u",
@@ -57,5 +57,5 @@
57
57
  "hex-rgb": "^5.0.0",
58
58
  "less-vars-to-js": "^1.3.0"
59
59
  },
60
- "gitHead": "f38e4b2dca1d43c39af0b189c93808de62c11e9b"
60
+ "gitHead": "e1a3b7417480ba1bbf0b68becf985dd2d5f5a924"
61
61
  }