@stokr/components-library 2.3.46 → 2.3.48
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/components/Input/Select.js +8 -3
- package/dist/components/Text/Text.styles.js +1 -3
- package/dist/hooks/useTimer.js +119 -0
- package/dist/index.js +44 -0
- package/dist/services/TimerService.js +112 -0
- package/dist/utils/copyToClipboard.js +173 -0
- package/dist/utils/moment.js +49 -0
- package/dist/utils/scrollUtils.js +68 -2
- package/package.json +1 -1
|
@@ -10,9 +10,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _reactSelect = _interopRequireWildcard(require("react-select"));
|
|
11
11
|
var _Input = require("./Input.styles");
|
|
12
12
|
var _Select = require("./Select.styles");
|
|
13
|
+
var _excluded = ["id", "name", "label", "options", "search", "error", "touched", "value", "disabled", "menuHeight"];
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
16
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
20
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -24,6 +26,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
24
26
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
25
27
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
26
28
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
30
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
31
|
var DropdownIndicator = function DropdownIndicator(props) {
|
|
28
32
|
var selectProps = props.selectProps;
|
|
29
33
|
return /*#__PURE__*/_react.default.createElement(_reactSelect.components.DropdownIndicator, props, /*#__PURE__*/_react.default.createElement(_Select.SelectIcon, {
|
|
@@ -57,7 +61,8 @@ var Select = function Select(props) {
|
|
|
57
61
|
touched = props.touched,
|
|
58
62
|
value = props.value,
|
|
59
63
|
disabled = props.disabled,
|
|
60
|
-
menuHeight = props.menuHeight
|
|
64
|
+
menuHeight = props.menuHeight,
|
|
65
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
61
66
|
var _useState = (0, _react.useState)(!!value),
|
|
62
67
|
_useState2 = _slicedToArray(_useState, 2),
|
|
63
68
|
labelUp = _useState2[0],
|
|
@@ -101,7 +106,7 @@ var Select = function Select(props) {
|
|
|
101
106
|
active: hasFocus,
|
|
102
107
|
error: error && touched,
|
|
103
108
|
htmlFor: id
|
|
104
|
-
}, label), /*#__PURE__*/_react.default.createElement(_reactSelect.default, {
|
|
109
|
+
}, label), /*#__PURE__*/_react.default.createElement(_reactSelect.default, _extends({
|
|
105
110
|
id: id,
|
|
106
111
|
name: name,
|
|
107
112
|
options: options,
|
|
@@ -148,7 +153,7 @@ var Select = function Select(props) {
|
|
|
148
153
|
IndicatorSeparator: null,
|
|
149
154
|
MenuList: SelectMenuListWithScroll
|
|
150
155
|
}
|
|
151
|
-
}));
|
|
156
|
+
}, otherProps)));
|
|
152
157
|
};
|
|
153
158
|
exports.Select = Select;
|
|
154
159
|
Select.propTypes = {
|
|
@@ -13,7 +13,7 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
|
|
|
13
13
|
var Text = _styledComponents.default.div.withConfig({
|
|
14
14
|
displayName: "Textstyles__Text",
|
|
15
15
|
componentId: "sc-xkpyal-0"
|
|
16
|
-
})(["display:block;", " ", " ", " ", " h1{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.18;letter-spacing:0.8px;text-transform:uppercase;margin-top:1em;margin-bottom:32px;", "}h2{font-family:'Open Sans';font-weight:300;font-size:34px;line-height:1.18em;letter-spacing:1.5px;margin-top:1em;margin-bottom:0.18em;", " ", "}h4{font-family:'Open Sans';font-weight:300;font-size:17px;line-height:1.27em;letter-spacing:0.8px;margin-top:1em;margin-bottom:0.27em;opacity:0.5;", " ", "}h3{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.27em;letter-spacing:0.8px;margin-top:1em;margin-bottom:0.27em;text-transform:uppercase;", " @media screen and (max-width:991px) and (min-width:768px){", "}}h5{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.27em;letter-spacing:0.8px;text-transform:uppercase;}p{font-family:'Open Sans';font-weight:300;font-size:16px;line-height:1.5em;letter-spacing:0.6px;margin:1em 0;", " ", " a{text-decoration:underline;transition:color 0.2s;color:
|
|
16
|
+
})(["display:block;", " ", " ", " ", " h1{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.18;letter-spacing:0.8px;text-transform:uppercase;margin-top:1em;margin-bottom:32px;", "}h2{font-family:'Open Sans';font-weight:300;font-size:34px;line-height:1.18em;letter-spacing:1.5px;margin-top:1em;margin-bottom:0.18em;", " ", "}h4{font-family:'Open Sans';font-weight:300;font-size:17px;line-height:1.27em;letter-spacing:0.8px;margin-top:1em;margin-bottom:0.27em;opacity:0.5;", " ", "}h3{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.27em;letter-spacing:0.8px;margin-top:1em;margin-bottom:0.27em;text-transform:uppercase;", " @media screen and (max-width:991px) and (min-width:768px){", "}}h5{font-family:'Open Sans';font-weight:800;font-size:22px;line-height:1.27em;letter-spacing:0.8px;text-transform:uppercase;}p{font-family:'Open Sans';font-weight:300;font-size:16px;line-height:1.5em;letter-spacing:0.6px;margin:1em 0;", " ", " a{text-decoration:underline;transition:color 0.2s;color:inherit;&:hover{color:", ";}}", "}ul{margin:16px;li{font-size:14px;font-weight:300;font-style:normal;font-stretch:normal;line-height:2;letter-spacing:0.6px;}@media screen and (max-width:479px){padding-left:15px;}}> *:first-child{margin-top:0;}> *:last-child{margin-bottom:0;}"], function (_ref) {
|
|
17
17
|
var withMarginBottom = _ref.withMarginBottom;
|
|
18
18
|
return withMarginBottom && "\n margin-bottom: 32px;\n ";
|
|
19
19
|
}, function (_ref2) {
|
|
@@ -32,8 +32,6 @@ var Text = _styledComponents.default.div.withConfig({
|
|
|
32
32
|
}, _rwd.default.XLarge(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-size: 20px;\n\n ", "\n\n "])), function (props) {
|
|
33
33
|
return props.small && "\n font-size:16px;\n ";
|
|
34
34
|
}), function (props) {
|
|
35
|
-
return _theme.default.cPrimary;
|
|
36
|
-
}, function (props) {
|
|
37
35
|
return _theme.default.cText;
|
|
38
36
|
}, function (props) {
|
|
39
37
|
return props.success && "\n color: ".concat(_theme.default.cProgressDone, ";\n ");
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useTimer = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _TimerService = _interopRequireDefault(require("../services/TimerService"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
/**
|
|
20
|
+
* Enhanced timer hook that works with TimerService to avoid context re-renders
|
|
21
|
+
*/
|
|
22
|
+
var useTimer = function useTimer(timerId) {
|
|
23
|
+
var initialDuration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
24
|
+
var _useState = (0, _react.useState)(initialDuration),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
secondsRemaining = _useState2[0],
|
|
27
|
+
setSecondsRemaining = _useState2[1];
|
|
28
|
+
var _useState3 = (0, _react.useState)(false),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
hasTimerFinished = _useState4[0],
|
|
31
|
+
setHasTimerFinished = _useState4[1];
|
|
32
|
+
var _useState5 = (0, _react.useState)(false),
|
|
33
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
34
|
+
isTimerActive = _useState6[0],
|
|
35
|
+
setIsTimerActive = _useState6[1];
|
|
36
|
+
var _useState7 = (0, _react.useState)(false),
|
|
37
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
38
|
+
wasTimerStarted = _useState8[0],
|
|
39
|
+
setWasTimerStarted = _useState8[1];
|
|
40
|
+
var timerIdRef = (0, _react.useRef)(timerId);
|
|
41
|
+
var startTimer = (0, _react.useCallback)(function (duration) {
|
|
42
|
+
setIsTimerActive(true);
|
|
43
|
+
setHasTimerFinished(false);
|
|
44
|
+
setSecondsRemaining(duration);
|
|
45
|
+
setWasTimerStarted(true);
|
|
46
|
+
_TimerService.default.startTimer(timerIdRef.current, duration, function (remaining, isExpired) {
|
|
47
|
+
setSecondsRemaining(remaining);
|
|
48
|
+
if (isExpired) {
|
|
49
|
+
setHasTimerFinished(true);
|
|
50
|
+
setIsTimerActive(false);
|
|
51
|
+
}
|
|
52
|
+
}, function () {
|
|
53
|
+
setHasTimerFinished(true);
|
|
54
|
+
setIsTimerActive(false);
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
var stopTimer = (0, _react.useCallback)(function () {
|
|
58
|
+
_TimerService.default.stopTimer(timerIdRef.current);
|
|
59
|
+
setIsTimerActive(false);
|
|
60
|
+
setSecondsRemaining(0);
|
|
61
|
+
setHasTimerFinished(true);
|
|
62
|
+
}, []);
|
|
63
|
+
var pauseTimer = (0, _react.useCallback)(function () {
|
|
64
|
+
_TimerService.default.stopTimer(timerIdRef.current);
|
|
65
|
+
setIsTimerActive(false);
|
|
66
|
+
}, []);
|
|
67
|
+
var resumeTimer = (0, _react.useCallback)(function () {
|
|
68
|
+
if (!isTimerActive && secondsRemaining > 0 && !hasTimerFinished) {
|
|
69
|
+
startTimer(secondsRemaining);
|
|
70
|
+
}
|
|
71
|
+
}, [isTimerActive, secondsRemaining, hasTimerFinished, startTimer]);
|
|
72
|
+
|
|
73
|
+
// Check for existing timer on mount and sync periodically
|
|
74
|
+
(0, _react.useEffect)(function () {
|
|
75
|
+
var existingTimer = _TimerService.default.getTimerInfo(timerIdRef.current);
|
|
76
|
+
if (existingTimer) {
|
|
77
|
+
setSecondsRemaining(existingTimer.remaining);
|
|
78
|
+
setHasTimerFinished(existingTimer.isExpired);
|
|
79
|
+
setIsTimerActive(existingTimer.isActive);
|
|
80
|
+
setWasTimerStarted(true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Sync with timer service every second
|
|
84
|
+
var syncInterval = setInterval(function () {
|
|
85
|
+
var timerInfo = _TimerService.default.getTimerInfo(timerIdRef.current);
|
|
86
|
+
if (timerInfo) {
|
|
87
|
+
setSecondsRemaining(timerInfo.remaining);
|
|
88
|
+
setHasTimerFinished(timerInfo.isExpired);
|
|
89
|
+
setIsTimerActive(timerInfo.isActive);
|
|
90
|
+
} else if (wasTimerStarted) {
|
|
91
|
+
// Timer was started but now doesn't exist = it expired
|
|
92
|
+
setHasTimerFinished(true);
|
|
93
|
+
setIsTimerActive(false);
|
|
94
|
+
setSecondsRemaining(0);
|
|
95
|
+
}
|
|
96
|
+
}, 1000);
|
|
97
|
+
return function () {
|
|
98
|
+
return clearInterval(syncInterval);
|
|
99
|
+
};
|
|
100
|
+
}, [wasTimerStarted]);
|
|
101
|
+
|
|
102
|
+
// Cleanup on unmount
|
|
103
|
+
(0, _react.useEffect)(function () {
|
|
104
|
+
return function () {
|
|
105
|
+
// Don't stop timer on unmount - let it continue running
|
|
106
|
+
// This allows timer to persist across component unmounts
|
|
107
|
+
};
|
|
108
|
+
}, []);
|
|
109
|
+
return {
|
|
110
|
+
secondsRemaining: secondsRemaining,
|
|
111
|
+
hasTimerFinished: hasTimerFinished,
|
|
112
|
+
isTimerActive: isTimerActive,
|
|
113
|
+
startTimer: startTimer,
|
|
114
|
+
stopTimer: stopTimer,
|
|
115
|
+
pauseTimer: pauseTimer,
|
|
116
|
+
resumeTimer: resumeTimer
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
exports.useTimer = useTimer;
|
package/dist/index.js
CHANGED
|
@@ -1202,6 +1202,39 @@ Object.keys(_formatCurrencyValue).forEach(function (key) {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
});
|
|
1204
1204
|
});
|
|
1205
|
+
var _copyToClipboard = require("./utils/copyToClipboard");
|
|
1206
|
+
Object.keys(_copyToClipboard).forEach(function (key) {
|
|
1207
|
+
if (key === "default" || key === "__esModule") return;
|
|
1208
|
+
if (key in exports && exports[key] === _copyToClipboard[key]) return;
|
|
1209
|
+
Object.defineProperty(exports, key, {
|
|
1210
|
+
enumerable: true,
|
|
1211
|
+
get: function get() {
|
|
1212
|
+
return _copyToClipboard[key];
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
var _scrollUtils = require("./utils/scrollUtils");
|
|
1217
|
+
Object.keys(_scrollUtils).forEach(function (key) {
|
|
1218
|
+
if (key === "default" || key === "__esModule") return;
|
|
1219
|
+
if (key in exports && exports[key] === _scrollUtils[key]) return;
|
|
1220
|
+
Object.defineProperty(exports, key, {
|
|
1221
|
+
enumerable: true,
|
|
1222
|
+
get: function get() {
|
|
1223
|
+
return _scrollUtils[key];
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
var _moment = require("./utils/moment");
|
|
1228
|
+
Object.keys(_moment).forEach(function (key) {
|
|
1229
|
+
if (key === "default" || key === "__esModule") return;
|
|
1230
|
+
if (key in exports && exports[key] === _moment[key]) return;
|
|
1231
|
+
Object.defineProperty(exports, key, {
|
|
1232
|
+
enumerable: true,
|
|
1233
|
+
get: function get() {
|
|
1234
|
+
return _moment[key];
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
});
|
|
1205
1238
|
var _FA = require("./components/2FA");
|
|
1206
1239
|
Object.keys(_FA).forEach(function (key) {
|
|
1207
1240
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1410,4 +1443,15 @@ Object.keys(_ChecklistCard).forEach(function (key) {
|
|
|
1410
1443
|
return _ChecklistCard[key];
|
|
1411
1444
|
}
|
|
1412
1445
|
});
|
|
1446
|
+
});
|
|
1447
|
+
var _useTimer = require("./hooks/useTimer");
|
|
1448
|
+
Object.keys(_useTimer).forEach(function (key) {
|
|
1449
|
+
if (key === "default" || key === "__esModule") return;
|
|
1450
|
+
if (key in exports && exports[key] === _useTimer[key]) return;
|
|
1451
|
+
Object.defineProperty(exports, key, {
|
|
1452
|
+
enumerable: true,
|
|
1453
|
+
get: function get() {
|
|
1454
|
+
return _useTimer[key];
|
|
1455
|
+
}
|
|
1456
|
+
});
|
|
1413
1457
|
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
var TimerService = /*#__PURE__*/function () {
|
|
14
|
+
function TimerService() {
|
|
15
|
+
_classCallCheck(this, TimerService);
|
|
16
|
+
this.timers = new Map();
|
|
17
|
+
this.listeners = new Map();
|
|
18
|
+
}
|
|
19
|
+
_createClass(TimerService, [{
|
|
20
|
+
key: "startTimer",
|
|
21
|
+
value: function startTimer(timerId, duration, onTick, onExpire) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
// Clear existing timer if it exists
|
|
24
|
+
this.stopTimer(timerId);
|
|
25
|
+
var startTime = Date.now();
|
|
26
|
+
var endTime = startTime + duration * 1000;
|
|
27
|
+
var timer = {
|
|
28
|
+
startTime: startTime,
|
|
29
|
+
endTime: endTime,
|
|
30
|
+
duration: duration,
|
|
31
|
+
interval: null,
|
|
32
|
+
onTick: onTick,
|
|
33
|
+
onExpire: onExpire
|
|
34
|
+
};
|
|
35
|
+
this.timers.set(timerId, timer);
|
|
36
|
+
timer.interval = setInterval(function () {
|
|
37
|
+
var now = Date.now();
|
|
38
|
+
var elapsed = Math.floor((now - startTime) / 1000);
|
|
39
|
+
var remaining = Math.max(0, duration - elapsed);
|
|
40
|
+
|
|
41
|
+
// Call onTick callback with remaining time
|
|
42
|
+
if (onTick) {
|
|
43
|
+
onTick(remaining, remaining <= 0);
|
|
44
|
+
}
|
|
45
|
+
if (remaining <= 0) {
|
|
46
|
+
_this.stopTimer(timerId);
|
|
47
|
+
if (onExpire) {
|
|
48
|
+
onExpire();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, 1000);
|
|
52
|
+
|
|
53
|
+
// Initial call
|
|
54
|
+
if (onTick) {
|
|
55
|
+
onTick(duration, false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "stopTimer",
|
|
60
|
+
value: function stopTimer(timerId) {
|
|
61
|
+
var timer = this.timers.get(timerId);
|
|
62
|
+
if (timer) {
|
|
63
|
+
if (timer.interval) {
|
|
64
|
+
clearInterval(timer.interval);
|
|
65
|
+
}
|
|
66
|
+
this.timers.delete(timerId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "getTimerInfo",
|
|
71
|
+
value: function getTimerInfo(timerId) {
|
|
72
|
+
var timer = this.timers.get(timerId);
|
|
73
|
+
if (!timer) return null;
|
|
74
|
+
var now = Date.now();
|
|
75
|
+
var elapsed = Math.floor((now - timer.startTime) / 1000);
|
|
76
|
+
var remaining = Math.max(0, timer.duration - elapsed);
|
|
77
|
+
return {
|
|
78
|
+
remaining: remaining,
|
|
79
|
+
isExpired: remaining <= 0,
|
|
80
|
+
isActive: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "isTimerActive",
|
|
85
|
+
value: function isTimerActive(timerId) {
|
|
86
|
+
return this.timers.has(timerId);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Cleanup all timers
|
|
90
|
+
}, {
|
|
91
|
+
key: "cleanup",
|
|
92
|
+
value: function cleanup() {
|
|
93
|
+
this.timers.forEach(function (timer) {
|
|
94
|
+
if (timer.interval) {
|
|
95
|
+
clearInterval(timer.interval);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
this.timers.clear();
|
|
99
|
+
}
|
|
100
|
+
}]);
|
|
101
|
+
return TimerService;
|
|
102
|
+
}(); // Singleton instance
|
|
103
|
+
var timerService = new TimerService();
|
|
104
|
+
|
|
105
|
+
// Cleanup on page unload
|
|
106
|
+
if (typeof window !== 'undefined') {
|
|
107
|
+
window.addEventListener('beforeunload', function () {
|
|
108
|
+
timerService.cleanup();
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
var _default = timerService;
|
|
112
|
+
exports.default = _default;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "CopyToClipboard", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _reactCopyToClipboard.CopyToClipboard;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.withCopyToClipboard = exports.useCopyToClipboard = exports.copyTextToClipboard = void 0;
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _reactCopyToClipboard = require("react-copy-to-clipboard");
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
24
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
25
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
26
|
+
/**
|
|
27
|
+
* Utility function to copy text to clipboard
|
|
28
|
+
* @param {string} text - The text to copy to clipboard
|
|
29
|
+
* @param {Function} onCopy - Optional callback function called when copy is successful
|
|
30
|
+
* @param {Function} onError - Optional callback function called when copy fails
|
|
31
|
+
* @returns {Promise<boolean>} - Returns true if copy was successful, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
var copyTextToClipboard = /*#__PURE__*/function () {
|
|
34
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(text, onCopy, onError) {
|
|
35
|
+
var textArea, successful;
|
|
36
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
_context.prev = 0;
|
|
40
|
+
if (!(navigator.clipboard && window.isSecureContext)) {
|
|
41
|
+
_context.next = 8;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
_context.next = 4;
|
|
45
|
+
return navigator.clipboard.writeText(text);
|
|
46
|
+
case 4:
|
|
47
|
+
if (onCopy) onCopy(text, true);
|
|
48
|
+
return _context.abrupt("return", true);
|
|
49
|
+
case 8:
|
|
50
|
+
// Fallback for older browsers or non-secure contexts
|
|
51
|
+
textArea = document.createElement('textarea');
|
|
52
|
+
textArea.value = text;
|
|
53
|
+
textArea.style.position = 'fixed';
|
|
54
|
+
textArea.style.left = '-999999px';
|
|
55
|
+
textArea.style.top = '-999999px';
|
|
56
|
+
document.body.appendChild(textArea);
|
|
57
|
+
textArea.focus();
|
|
58
|
+
textArea.select();
|
|
59
|
+
successful = document.execCommand('copy');
|
|
60
|
+
document.body.removeChild(textArea);
|
|
61
|
+
if (!successful) {
|
|
62
|
+
_context.next = 23;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
if (onCopy) onCopy(text, true);
|
|
66
|
+
return _context.abrupt("return", true);
|
|
67
|
+
case 23:
|
|
68
|
+
if (onError) onError(new Error('Failed to copy text'));
|
|
69
|
+
return _context.abrupt("return", false);
|
|
70
|
+
case 25:
|
|
71
|
+
_context.next = 31;
|
|
72
|
+
break;
|
|
73
|
+
case 27:
|
|
74
|
+
_context.prev = 27;
|
|
75
|
+
_context.t0 = _context["catch"](0);
|
|
76
|
+
if (onError) onError(_context.t0);
|
|
77
|
+
return _context.abrupt("return", false);
|
|
78
|
+
case 31:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee, null, [[0, 27]]);
|
|
83
|
+
}));
|
|
84
|
+
return function copyTextToClipboard(_x, _x2, _x3) {
|
|
85
|
+
return _ref.apply(this, arguments);
|
|
86
|
+
};
|
|
87
|
+
}();
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Higher-order component that wraps a component with copy-to-clipboard functionality
|
|
91
|
+
* @param {React.Component} WrappedComponent - The component to wrap
|
|
92
|
+
* @param {Object} options - Configuration options
|
|
93
|
+
* @param {string} options.textProp - The prop name that contains the text to copy (default: 'text')
|
|
94
|
+
* @param {string} options.onCopyProp - The prop name for the onCopy callback (default: 'onCopy')
|
|
95
|
+
* @param {string} options.onErrorProp - The prop name for the onError callback (default: 'onError')
|
|
96
|
+
* @returns {React.Component} - Wrapped component with copy functionality
|
|
97
|
+
*/
|
|
98
|
+
exports.copyTextToClipboard = copyTextToClipboard;
|
|
99
|
+
var withCopyToClipboard = function withCopyToClipboard(WrappedComponent) {
|
|
100
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
101
|
+
var _options$textProp = options.textProp,
|
|
102
|
+
textProp = _options$textProp === void 0 ? 'text' : _options$textProp,
|
|
103
|
+
_options$onCopyProp = options.onCopyProp,
|
|
104
|
+
onCopyProp = _options$onCopyProp === void 0 ? 'onCopy' : _options$onCopyProp,
|
|
105
|
+
_options$onErrorProp = options.onErrorProp,
|
|
106
|
+
onErrorProp = _options$onErrorProp === void 0 ? 'onError' : _options$onErrorProp;
|
|
107
|
+
return function CopyToClipboardWrapper(props) {
|
|
108
|
+
var text = props[textProp];
|
|
109
|
+
var onCopy = props[onCopyProp];
|
|
110
|
+
var onError = props[onErrorProp];
|
|
111
|
+
var handleCopy = function handleCopy() {
|
|
112
|
+
if (text) {
|
|
113
|
+
copyTextToClipboard(text, onCopy, onError);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_reactCopyToClipboard.CopyToClipboard, {
|
|
117
|
+
text: text,
|
|
118
|
+
onCopy: handleCopy
|
|
119
|
+
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* React hook for copy-to-clipboard functionality
|
|
125
|
+
* @param {string} text - The text to copy
|
|
126
|
+
* @returns {Object} - Object containing copy function and copy state
|
|
127
|
+
*/
|
|
128
|
+
exports.withCopyToClipboard = withCopyToClipboard;
|
|
129
|
+
var useCopyToClipboard = function useCopyToClipboard(text) {
|
|
130
|
+
var _React$useState = _react.default.useState(false),
|
|
131
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
132
|
+
copied = _React$useState2[0],
|
|
133
|
+
setCopied = _React$useState2[1];
|
|
134
|
+
var copy = _react.default.useCallback( /*#__PURE__*/function () {
|
|
135
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(customText) {
|
|
136
|
+
var textToCopy, success;
|
|
137
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
138
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
textToCopy = customText || text;
|
|
141
|
+
_context2.next = 3;
|
|
142
|
+
return copyTextToClipboard(textToCopy, function () {
|
|
143
|
+
return setCopied(true);
|
|
144
|
+
}, function () {
|
|
145
|
+
return setCopied(false);
|
|
146
|
+
});
|
|
147
|
+
case 3:
|
|
148
|
+
success = _context2.sent;
|
|
149
|
+
if (success) {
|
|
150
|
+
// Reset copied state after 2 seconds
|
|
151
|
+
setTimeout(function () {
|
|
152
|
+
return setCopied(false);
|
|
153
|
+
}, 2000);
|
|
154
|
+
}
|
|
155
|
+
return _context2.abrupt("return", success);
|
|
156
|
+
case 6:
|
|
157
|
+
case "end":
|
|
158
|
+
return _context2.stop();
|
|
159
|
+
}
|
|
160
|
+
}, _callee2);
|
|
161
|
+
}));
|
|
162
|
+
return function (_x4) {
|
|
163
|
+
return _ref2.apply(this, arguments);
|
|
164
|
+
};
|
|
165
|
+
}(), [text]);
|
|
166
|
+
return {
|
|
167
|
+
copy: copy,
|
|
168
|
+
copied: copied
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// Export the original CopyToClipboard component for direct use if needed
|
|
173
|
+
exports.useCopyToClipboard = useCopyToClipboard;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
Object.defineProperty(exports, "moment", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _moment.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "momentTimezone", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _momentTimezone.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
exports.momentUtils = void 0;
|
|
20
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
21
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
// Re-export moment and moment-timezone for use in other repos
|
|
24
|
+
// Export moment as default for convenience
|
|
25
|
+
var _default = _moment.default; // Common moment utilities that might be useful across projects
|
|
26
|
+
exports.default = _default;
|
|
27
|
+
var momentUtils = {
|
|
28
|
+
/**
|
|
29
|
+
* Format a date to a readable string
|
|
30
|
+
* @param {Date|string|moment} date - The date to format
|
|
31
|
+
* @param {string} format - The format string (default: 'DD MMM YYYY')
|
|
32
|
+
* @returns {string} - Formatted date string
|
|
33
|
+
*/
|
|
34
|
+
formatDate: function formatDate(date) {
|
|
35
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'DD MMM YYYY';
|
|
36
|
+
return (0, _moment.default)(date).format(format);
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Format a date to a readable string with time
|
|
40
|
+
* @param {Date|string|moment} date - The date to format
|
|
41
|
+
* @param {string} format - The format string (default: 'DD MMM YYYY - hh:mm')
|
|
42
|
+
* @returns {string} - Formatted date string
|
|
43
|
+
*/
|
|
44
|
+
formatDateTime: function formatDateTime(date) {
|
|
45
|
+
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'DD MMM YYYY - hh:mm';
|
|
46
|
+
return (0, _moment.default)(date).format(format);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.momentUtils = momentUtils;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.scrollToElement = void 0;
|
|
7
|
+
exports.scrollToElement = exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
7
11
|
/**
|
|
8
12
|
* Scrolls to an element with cross-platform compatibility
|
|
9
13
|
* Works reliably on iOS, iPadOS, macOS, and other platforms
|
|
@@ -56,4 +60,66 @@ var scrollToElement = function scrollToElement(elementRef) {
|
|
|
56
60
|
performScroll();
|
|
57
61
|
}
|
|
58
62
|
};
|
|
59
|
-
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A custom hook that provides various scrolling utilities.
|
|
66
|
+
*/
|
|
67
|
+
exports.scrollToElement = scrollToElement;
|
|
68
|
+
var useScrollActions = function useScrollActions() {
|
|
69
|
+
/**
|
|
70
|
+
* Scrolls the window to the very top with smooth behavior.
|
|
71
|
+
*/
|
|
72
|
+
var scrollToTop = (0, _react.useCallback)(function () {
|
|
73
|
+
window.scrollTo({
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
behavior: 'smooth'
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Scrolls a specific DOM element into the viewport with smooth behavior.
|
|
82
|
+
*
|
|
83
|
+
* @param {React.RefObject<HTMLElement>} elementRef - The ref object pointing to the target DOM element.
|
|
84
|
+
* @param {ScrollIntoViewOptions} [options={ behavior: 'smooth' }] - Optional scroll options.
|
|
85
|
+
* Defaults to `{ behavior: 'smooth' }`.
|
|
86
|
+
*/
|
|
87
|
+
var scrollToElement = (0, _react.useCallback)(function (elementRef) {
|
|
88
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
89
|
+
behavior: 'smooth'
|
|
90
|
+
};
|
|
91
|
+
if (elementRef && elementRef.current) {
|
|
92
|
+
elementRef.current.scrollIntoView(options);
|
|
93
|
+
}
|
|
94
|
+
}, []); // Empty dependency array ensures this function is stable across renders.
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Scrolls the window to make a specific element visible,
|
|
98
|
+
* with an optional desired offset from the bottom of the viewport.
|
|
99
|
+
*
|
|
100
|
+
* @param {React.RefObject<HTMLElement>} elementRef - Any ref.
|
|
101
|
+
* @param {number} [desiredOffsetFromBottom=0] - The desired offset in pixels from the bottom of the viewport.
|
|
102
|
+
* Defaults to 0 if not provided.
|
|
103
|
+
*/
|
|
104
|
+
var scrollToElementWithOffset = (0, _react.useCallback)(function (elementRef) {
|
|
105
|
+
var desiredOffsetFromBottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
106
|
+
if (elementRef && elementRef.current) {
|
|
107
|
+
var targetElement = elementRef.current;
|
|
108
|
+
|
|
109
|
+
// formula that determines how much the window actually needs to scroll so that
|
|
110
|
+
// the element's bottom is at `window.innerHeight - desiredOffsetFromBottom`
|
|
111
|
+
var scrollNeeded = targetElement.getBoundingClientRect().bottom - (window.innerHeight - desiredOffsetFromBottom);
|
|
112
|
+
window.scrollBy({
|
|
113
|
+
top: scrollNeeded,
|
|
114
|
+
behavior: 'smooth'
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
return {
|
|
119
|
+
scrollToTop: scrollToTop,
|
|
120
|
+
scrollToElement: scrollToElement,
|
|
121
|
+
scrollToElementWithOffset: scrollToElementWithOffset
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
var _default = useScrollActions;
|
|
125
|
+
exports.default = _default;
|