@react-fabric/date 1.0.0-beta.60 → 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/components/DateHeader.js +4 -4
- package/dist/cjs/display/DateDuration.js +18 -3
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/esm/components/DateHeader.js +5 -5
- package/dist/esm/display/DateDuration.js +19 -4
- package/dist/esm/i18n/index.js +2 -2
- package/package.json +4 -4
- package/src/components/DateHeader.tsx +5 -5
- 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
|
@@ -86,7 +86,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
86
86
|
"data-page": page,
|
|
87
87
|
children: [startPage !== undefined && /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
88
88
|
icon: {
|
|
89
|
-
icon:
|
|
89
|
+
icon: "icon-[mdi--chevron-double-left]",
|
|
90
90
|
rtlFlip: true
|
|
91
91
|
},
|
|
92
92
|
size: "sm",
|
|
@@ -99,7 +99,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
99
99
|
}
|
|
100
100
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
101
101
|
icon: {
|
|
102
|
-
icon:
|
|
102
|
+
icon: "icon-[mdi--chevron-left]",
|
|
103
103
|
rtlFlip: true
|
|
104
104
|
},
|
|
105
105
|
size: "sm",
|
|
@@ -119,7 +119,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
119
119
|
children: headLabel
|
|
120
120
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
121
121
|
icon: {
|
|
122
|
-
icon:
|
|
122
|
+
icon: "icon-[mdi--chevron-right]",
|
|
123
123
|
rtlFlip: true
|
|
124
124
|
},
|
|
125
125
|
size: "sm",
|
|
@@ -132,7 +132,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
132
132
|
}
|
|
133
133
|
}), endPage !== undefined && /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
134
134
|
icon: {
|
|
135
|
-
icon:
|
|
135
|
+
icon: "icon-[mdi--chevron-double-right]",
|
|
136
136
|
rtlFlip: true
|
|
137
137
|
},
|
|
138
138
|
size: "sm",
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { Button
|
|
4
|
+
import { Button } from '@react-fabric/core';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { addDays, isBefore, isAfter } from 'date-fns';
|
|
7
7
|
import i18next from 'i18next';
|
|
@@ -86,7 +86,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
86
86
|
"data-page": page,
|
|
87
87
|
children: [startPage !== undefined && /*#__PURE__*/jsx(Button, {
|
|
88
88
|
icon: {
|
|
89
|
-
icon:
|
|
89
|
+
icon: "icon-[mdi--chevron-double-left]",
|
|
90
90
|
rtlFlip: true
|
|
91
91
|
},
|
|
92
92
|
size: "sm",
|
|
@@ -99,7 +99,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
99
99
|
}
|
|
100
100
|
}), /*#__PURE__*/jsx(Button, {
|
|
101
101
|
icon: {
|
|
102
|
-
icon:
|
|
102
|
+
icon: "icon-[mdi--chevron-left]",
|
|
103
103
|
rtlFlip: true
|
|
104
104
|
},
|
|
105
105
|
size: "sm",
|
|
@@ -119,7 +119,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
119
119
|
children: headLabel
|
|
120
120
|
}), /*#__PURE__*/jsx(Button, {
|
|
121
121
|
icon: {
|
|
122
|
-
icon:
|
|
122
|
+
icon: "icon-[mdi--chevron-right]",
|
|
123
123
|
rtlFlip: true
|
|
124
124
|
},
|
|
125
125
|
size: "sm",
|
|
@@ -132,7 +132,7 @@ var DateHeader = function DateHeader(props) {
|
|
|
132
132
|
}
|
|
133
133
|
}), endPage !== undefined && /*#__PURE__*/jsx(Button, {
|
|
134
134
|
icon: {
|
|
135
|
-
icon:
|
|
135
|
+
icon: "icon-[mdi--chevron-double-right]",
|
|
136
136
|
rtlFlip: true
|
|
137
137
|
},
|
|
138
138
|
size: "sm",
|
|
@@ -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
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { Button
|
|
24
|
+
import { Button } from "@react-fabric/core";
|
|
25
25
|
import classNames from "classnames";
|
|
26
26
|
import { addDays, isAfter, isBefore } from "date-fns";
|
|
27
27
|
import i18next from "i18next";
|
|
@@ -166,7 +166,7 @@ export const DateHeader = (props: Props) => {
|
|
|
166
166
|
<div className="flex flex-nowrap items-center area-head" data-page={page}>
|
|
167
167
|
{startPage !== undefined && (
|
|
168
168
|
<Button
|
|
169
|
-
icon={{ icon:
|
|
169
|
+
icon={{ icon: "icon-[mdi--chevron-double-left]", rtlFlip: true }}
|
|
170
170
|
size="sm"
|
|
171
171
|
variant="link"
|
|
172
172
|
aria-label="start"
|
|
@@ -176,7 +176,7 @@ export const DateHeader = (props: Props) => {
|
|
|
176
176
|
/>
|
|
177
177
|
)}
|
|
178
178
|
<Button
|
|
179
|
-
icon={{ icon:
|
|
179
|
+
icon={{ icon: "icon-[mdi--chevron-left]", rtlFlip: true }}
|
|
180
180
|
size="sm"
|
|
181
181
|
variant="link"
|
|
182
182
|
aria-label="prev"
|
|
@@ -195,7 +195,7 @@ export const DateHeader = (props: Props) => {
|
|
|
195
195
|
{headLabel}
|
|
196
196
|
</div>
|
|
197
197
|
<Button
|
|
198
|
-
icon={{ icon:
|
|
198
|
+
icon={{ icon: "icon-[mdi--chevron-right]", rtlFlip: true }}
|
|
199
199
|
size="sm"
|
|
200
200
|
variant="link"
|
|
201
201
|
aria-label="next"
|
|
@@ -205,7 +205,7 @@ export const DateHeader = (props: Props) => {
|
|
|
205
205
|
/>
|
|
206
206
|
{endPage !== undefined && (
|
|
207
207
|
<Button
|
|
208
|
-
icon={{ icon:
|
|
208
|
+
icon={{ icon: "icon-[mdi--chevron-double-right]", rtlFlip: true }}
|
|
209
209
|
size="sm"
|
|
210
210
|
variant="link"
|
|
211
211
|
aria-label="end"
|
|
@@ -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
|