krl-alfred 1.71.3 → 1.71.4

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.
@@ -19,36 +19,31 @@ var react_1 = require("react");
19
19
  var ActionButton_styled_1 = require("./ActionButton.styled");
20
20
  var Icon_1 = __importDefault(require("../Icon/Icon"));
21
21
  var Button_1 = __importDefault(require("../Button"));
22
+ var date_fns_1 = require("date-fns");
22
23
  var ActionButton = function (props) {
23
24
  var _a = (0, react_1.useState)(0), days = _a[0], setDays = _a[1];
24
25
  var _b = (0, react_1.useState)(0), minutes = _b[0], setMinutes = _b[1];
25
26
  var _c = (0, react_1.useState)(0), hours = _c[0], setHours = _c[1];
26
27
  //const [secounds,setSecounds] = useState(0);
27
28
  var deadline = new Date(props.date).getTime();
29
+ var now = new Date().getTime();
28
30
  var count = function () {
29
- var now = new Date().getTime();
30
- var t = deadline - now;
31
- var dd = Math.floor(t / (1000 * 60 * 60 * 24));
32
- var hh = Math.floor((t % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
33
- var mm = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60));
34
- //const ss = Math.floor((t % (1000 * 60)) / 1000);
35
- setDays(dd < 10 ? "0" + dd : dd);
36
- setMinutes(mm < 10 ? "0" + mm : mm);
37
- setHours(hh < 10 ? "0" + hh : hh);
38
- //setSecounds(ss < 10 ? "0" + ss : ss)
39
- if (t < 0) {
31
+ var duration = (0, date_fns_1.intervalToDuration)({
32
+ start: deadline,
33
+ end: now
34
+ });
35
+ setDays(deadline - now > 0 ? (0, date_fns_1.differenceInDays)(deadline, now) : 0);
36
+ setMinutes(deadline - now > 0 ? duration === null || duration === void 0 ? void 0 : duration.minutes : 0);
37
+ setHours(deadline - now > 0 ? duration === null || duration === void 0 ? void 0 : duration.hours : 0);
38
+ //setSecounds(deadline - now > 0 ? duration?.seconds : 0)
39
+ if (deadline - now < 0)
40
40
  clearInterval(timer);
41
- setDays(0);
42
- setMinutes(0);
43
- setHours(0);
44
- //setSecounds(0)
45
- }
46
41
  };
47
42
  var timer = setInterval(count, 60 * 1000);
48
43
  (0, react_1.useEffect)(function () {
49
44
  count();
50
45
  }, [props.date]);
51
- return (0, jsx_runtime_1.jsxs)(ActionButton_styled_1.ActionButtonStyled, __assign({}, props, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "top", children: [(0, jsx_runtime_1.jsx)("div", { className: "icon", children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: props.icon, width: "45px", height: "45px" }) }), (0, jsx_runtime_1.jsx)("strong", { className: "title body-bold-14-17", children: props.title })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bottom", children: [(0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "timer", children: [(0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: days }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "G\u00FCn" })] }), (0, jsx_runtime_1.jsx)("div", { className: "dots caption-bold-12-15", children: ":" }), (0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: hours }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "Saat" })] }), (0, jsx_runtime_1.jsx)("div", { className: "dots caption-bold-12-15", children: ":" }), (0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: minutes }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "Dk." })] })] }), (0, jsx_runtime_1.jsx)(Button_1.default, { size: "xsmall", width: "32px", icon: "ArrowMediumRight", variant: "primary" })] })] })] }));
46
+ return (0, jsx_runtime_1.jsxs)(ActionButton_styled_1.ActionButtonStyled, __assign({}, props, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "top", children: [(0, jsx_runtime_1.jsx)("div", { className: "icon", children: (0, jsx_runtime_1.jsx)(Icon_1.default, { name: props.icon, width: "45px", height: "45px" }) }), (0, jsx_runtime_1.jsx)("strong", { className: "title body-bold-14-17", children: props.title })] }), (0, jsx_runtime_1.jsxs)("div", { className: "bottom", children: [(0, jsx_runtime_1.jsx)("div", {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "timer", children: [(0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: days }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "G\u00FCn" })] }), (0, jsx_runtime_1.jsx)("div", { className: "dots caption-bold-12-15", children: ":" }), (0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: hours.toString().padStart(2, '0') }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "Saat" })] }), (0, jsx_runtime_1.jsx)("div", { className: "dots caption-bold-12-15", children: ":" }), (0, jsx_runtime_1.jsxs)("div", { className: "box", children: [(0, jsx_runtime_1.jsx)("div", { className: "title-extra-bold-16-19", children: minutes.toString().padStart(2, '0') }), (0, jsx_runtime_1.jsx)("div", { className: "caption-regular-10-12", children: "Dk." })] })] }), (0, jsx_runtime_1.jsx)(Button_1.default, { size: "xsmall", width: "32px", icon: "ArrowMediumRight", variant: "primary" })] })] })] }));
52
47
  };
53
48
  ActionButton.defaultProps = {
54
49
  title: "Title",
@@ -22,6 +22,7 @@ exports.Default = {
22
22
  width: '311px',
23
23
  title: 'Title',
24
24
  date: date.toISOString(),
25
+ //date:"2024-09-25T14:51:41.115Z",
25
26
  icon: 'TimeCircle',
26
27
  onClick: function (e) { return console.log(e); },
27
28
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "krl-alfred",
3
- "version": "1.71.3",
3
+ "version": "1.71.4",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -23,6 +23,7 @@
23
23
  "@types/styled-components": "^5.0.1",
24
24
  "classnames": "^2.3.2",
25
25
  "css-loader": "^6.7.3",
26
+ "date-fns": "^2.30.0",
26
27
  "plop": "^3.1.2",
27
28
  "react": "^18.2.0",
28
29
  "react-circular-progressbar": "^2.1.0",