@react-fabric/date 1.0.0-beta.61 → 1.0.0-beta.62
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/dist/cjs/display/DateDuration.js +18 -3
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/esm/display/DateDuration.js +19 -4
- package/dist/esm/i18n/index.js +2 -2
- package/package.json +4 -4
- package/src/display/DateDuration.tsx +15 -3
- package/src/i18n/index.ts +2 -2
- /package/dist/cjs/i18n/{ar.json.js → ar/date.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/date.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/date.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/date.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/date.json} +0 -0
- /package/src/i18n/{en.json → en/date.json} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
5
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
5
6
|
var core = require('@react-fabric/core');
|
|
6
7
|
var utilities = require('@react-fabric/utilities');
|
|
@@ -39,11 +40,25 @@ var DateDuration = function DateDuration(_ref) {
|
|
|
39
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
41
|
var _useTranslation = reactI18next.useTranslation("date"),
|
|
41
42
|
t = _useTranslation.t;
|
|
42
|
-
var
|
|
43
|
-
|
|
43
|
+
var _useState = react.useState({}),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
interval = _useState2[0],
|
|
46
|
+
setDateInterval = _useState2[1];
|
|
47
|
+
react.useEffect(function () {
|
|
48
|
+
setDateInterval(dateFns.intervalToDuration({
|
|
44
49
|
start: new Date(date),
|
|
45
50
|
end: new Date()
|
|
46
|
-
});
|
|
51
|
+
}));
|
|
52
|
+
// update interval every minute
|
|
53
|
+
var tmr = setInterval(function () {
|
|
54
|
+
setDateInterval(dateFns.intervalToDuration({
|
|
55
|
+
start: new Date(date),
|
|
56
|
+
end: new Date()
|
|
57
|
+
}));
|
|
58
|
+
}, 60 * 1000);
|
|
59
|
+
return function () {
|
|
60
|
+
return clearInterval(tmr);
|
|
61
|
+
};
|
|
47
62
|
}, [date]);
|
|
48
63
|
var label = react.useMemo(function () {
|
|
49
64
|
var before = dateFns.isBefore(dateUtil.DateUtil.parseDate(date), new Date());
|
package/dist/cjs/i18n/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@react-fabric/core');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var date$1 = require('./ar/date.json.js');
|
|
5
|
+
var date = require('./en/date.json.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
* React Fabric
|
|
@@ -28,6 +28,6 @@ var en = require('./en.json.js');
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
core.addTranslationBundle("date", {
|
|
31
|
-
en:
|
|
32
|
-
ar:
|
|
31
|
+
en: date.default,
|
|
32
|
+
ar: date$1.default
|
|
33
33
|
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
5
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
6
|
import { Tooltip, Dropdown } from '@react-fabric/core';
|
|
6
7
|
import { Format } from '@react-fabric/utilities';
|
|
7
8
|
import classNames from 'classnames';
|
|
8
9
|
import { intervalToDuration, isBefore } from 'date-fns';
|
|
9
|
-
import { useMemo } from 'react';
|
|
10
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
10
11
|
import { useTranslation } from 'react-i18next';
|
|
11
12
|
import { DateUtil } from '../utils/dateUtil.js';
|
|
12
13
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -39,11 +40,25 @@ var DateDuration = function DateDuration(_ref) {
|
|
|
39
40
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
41
|
var _useTranslation = useTranslation("date"),
|
|
41
42
|
t = _useTranslation.t;
|
|
42
|
-
var
|
|
43
|
-
|
|
43
|
+
var _useState = useState({}),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
interval = _useState2[0],
|
|
46
|
+
setDateInterval = _useState2[1];
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
setDateInterval(intervalToDuration({
|
|
44
49
|
start: new Date(date),
|
|
45
50
|
end: new Date()
|
|
46
|
-
});
|
|
51
|
+
}));
|
|
52
|
+
// update interval every minute
|
|
53
|
+
var tmr = setInterval(function () {
|
|
54
|
+
setDateInterval(intervalToDuration({
|
|
55
|
+
start: new Date(date),
|
|
56
|
+
end: new Date()
|
|
57
|
+
}));
|
|
58
|
+
}, 60 * 1000);
|
|
59
|
+
return function () {
|
|
60
|
+
return clearInterval(tmr);
|
|
61
|
+
};
|
|
47
62
|
}, [date]);
|
|
48
63
|
var label = useMemo(function () {
|
|
49
64
|
var before = isBefore(DateUtil.parseDate(date), new Date());
|
package/dist/esm/i18n/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/date",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.62",
|
|
4
4
|
"description": "RUF: Date package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.62",
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.62",
|
|
40
40
|
"classnames": "~2.5.1",
|
|
41
41
|
"date-fns": "~4.1.0",
|
|
42
42
|
"resize-observer-polyfill": "~1.5.1"
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"node": ">=18.12.0",
|
|
52
52
|
"npm": ">=8.19.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9dce2fd9bb753d67e3f8adbf50be257b4bc64242"
|
|
55
55
|
}
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { Format } from "@react-fabric/utilities";
|
|
33
33
|
import classNames from "classnames";
|
|
34
34
|
import { intervalToDuration, isBefore } from "date-fns";
|
|
35
|
-
import { useMemo, type ElementType } from "react";
|
|
35
|
+
import { useEffect, useMemo, useState, type ElementType } from "react";
|
|
36
36
|
import { useTranslation } from "react-i18next";
|
|
37
37
|
import { type DateLike } from "../types";
|
|
38
38
|
import { DateUtil } from "../utils/dateUtil";
|
|
@@ -76,9 +76,21 @@ export const DateDuration = ({
|
|
|
76
76
|
...props
|
|
77
77
|
}: Props) => {
|
|
78
78
|
const { t } = useTranslation("date");
|
|
79
|
+
const [interval, setDateInterval] = useState<
|
|
80
|
+
ReturnType<typeof intervalToDuration>
|
|
81
|
+
>({});
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setDateInterval(
|
|
85
|
+
intervalToDuration({ start: new Date(date), end: new Date() }),
|
|
86
|
+
);
|
|
87
|
+
// update interval every minute
|
|
88
|
+
const tmr = setInterval(() => {
|
|
89
|
+
setDateInterval(
|
|
90
|
+
intervalToDuration({ start: new Date(date), end: new Date() }),
|
|
91
|
+
);
|
|
92
|
+
}, 60 * 1000);
|
|
93
|
+
return () => clearInterval(tmr);
|
|
82
94
|
}, [date]);
|
|
83
95
|
|
|
84
96
|
const label = useMemo(() => {
|
package/src/i18n/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|