@stokr/components-library 2.3.45 → 2.3.47

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.
@@ -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 = {
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useNewVentureForm = void 0;
7
- var _react = require("react");
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _AuthContext = require("../context/AuthContext");
9
9
  var _fetchDataPublic = _interopRequireDefault(require("../api/fetchDataPublic"));
10
10
  var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
11
11
  var _CheckboxContext = require("../context/Checkbox/CheckboxContext");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
14
+ 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
15
  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); }
14
16
  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; }
15
17
  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); } }
@@ -34,8 +36,8 @@ var initialState = {
34
36
  name: '',
35
37
  mailingList: false,
36
38
  privateInvestorList: false,
37
- mailingListText: /*#__PURE__*/React.createElement(React.Fragment, null, "You just want to be updated on the project. Subscribe here for further information going forward."),
38
- privateInvestorListText: /*#__PURE__*/React.createElement(React.Fragment, null, "You are a professional investor or an investor willing to invest in private offerings. Subscribe here to be contacted by a dedicated team to help you confirm your eligibility for this investment.", /*#__PURE__*/React.createElement("br", null), " ", /*#__PURE__*/React.createElement("br", null), "You are seeking to invest on your own initiative and any potential investments arose as a result of your direct inquiry and outreach."),
39
+ mailingListText: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "You just want to be updated on the project. Subscribe here for further information going forward."),
40
+ privateInvestorListText: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "You are a professional investor or an investor willing to invest in private offerings. Subscribe here to be contacted by a dedicated team to help you confirm your eligibility for this investment.", /*#__PURE__*/_react.default.createElement("br", null), " ", /*#__PURE__*/_react.default.createElement("br", null), "You are seeking to invest on your own initiative and any potential investments arose as a result of your direct inquiry and outreach."),
39
41
  mailingListDisabled: false,
40
42
  privateInvestorListDisabled: false,
41
43
  optionalCheckBox: false,
@@ -202,7 +204,7 @@ var useNewVentureForm = function useNewVentureForm(project, user) {
202
204
  setUser(updatedUser);
203
205
  setFormValues(function (prev) {
204
206
  return _objectSpread(_objectSpread({}, prev), {}, {
205
- successMessage: /*#__PURE__*/React.createElement(React.Fragment, null, "Please continue onboarding, an account manager will reach out to you.", /*#__PURE__*/React.createElement("br", null), "If you are an existing account holder, kindly log in and make sure your account is fully verified."),
207
+ successMessage: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Please continue onboarding, an account manager will reach out to you.", /*#__PURE__*/_react.default.createElement("br", null), "If you are an existing account holder, kindly log in and make sure your account is fully verified."),
206
208
  errorMessage: null,
207
209
  isSubmitting: false
208
210
  });
@@ -212,9 +214,9 @@ var useNewVentureForm = function useNewVentureForm(project, user) {
212
214
  _context.prev = 17;
213
215
  _context.t0 = _context["catch"](1);
214
216
  if ((_context.t0 === null || _context.t0 === void 0 || (_error$response = _context.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 406) {
215
- errorMessage = (project === null || project === void 0 ? void 0 : project.name) === 'microstrategy' ? /*#__PURE__*/React.createElement(React.Fragment, null, "You are already added to this project.", /*#__PURE__*/React.createElement("br", null), " ", /*#__PURE__*/React.createElement("br", null)) : ((_error$response$data = _context.t0.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.substring(7)) || 'You are already added to this project.';
217
+ errorMessage = (project === null || project === void 0 ? void 0 : project.name) === 'microstrategy' ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "You are already added to this project.", /*#__PURE__*/_react.default.createElement("br", null), " ", /*#__PURE__*/_react.default.createElement("br", null)) : ((_error$response$data = _context.t0.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.substring(7)) || 'You are already added to this project.';
216
218
  } else {
217
- errorMessage = /*#__PURE__*/React.createElement(React.Fragment, null, "Something went wrong. Please try again a bit later or contact us at", ' ', /*#__PURE__*/React.createElement("a", {
219
+ errorMessage = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Something went wrong. Please try again a bit later or contact us at", ' ', /*#__PURE__*/_react.default.createElement("a", {
218
220
  href: "mailto:support@stokr.io",
219
221
  style: {
220
222
  color: 'inherit'
@@ -0,0 +1,96 @@
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
+ * Based on your existing useCooldown hook but with better state management
22
+ */
23
+ var useTimer = function useTimer(timerId) {
24
+ var initialDuration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
25
+ var _useState = (0, _react.useState)(initialDuration),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ secondsRemaining = _useState2[0],
28
+ setSecondsRemaining = _useState2[1];
29
+ var _useState3 = (0, _react.useState)(false),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ hasTimerFinished = _useState4[0],
32
+ setHasTimerFinished = _useState4[1];
33
+ var _useState5 = (0, _react.useState)(false),
34
+ _useState6 = _slicedToArray(_useState5, 2),
35
+ isTimerActive = _useState6[0],
36
+ setIsTimerActive = _useState6[1];
37
+ var timerIdRef = (0, _react.useRef)(timerId);
38
+ var startTimer = (0, _react.useCallback)(function (duration) {
39
+ setIsTimerActive(true);
40
+ setHasTimerFinished(false);
41
+ setSecondsRemaining(duration);
42
+ _TimerService.default.startTimer(timerIdRef.current, duration, function (remaining, isExpired) {
43
+ setSecondsRemaining(remaining);
44
+ if (isExpired) {
45
+ setHasTimerFinished(true);
46
+ setIsTimerActive(false);
47
+ }
48
+ }, function () {
49
+ setHasTimerFinished(true);
50
+ setIsTimerActive(false);
51
+ });
52
+ }, []);
53
+ var stopTimer = (0, _react.useCallback)(function () {
54
+ _TimerService.default.stopTimer(timerIdRef.current);
55
+ setIsTimerActive(false);
56
+ setSecondsRemaining(0);
57
+ setHasTimerFinished(true);
58
+ }, []);
59
+ var pauseTimer = (0, _react.useCallback)(function () {
60
+ _TimerService.default.stopTimer(timerIdRef.current);
61
+ setIsTimerActive(false);
62
+ }, []);
63
+ var resumeTimer = (0, _react.useCallback)(function () {
64
+ if (!isTimerActive && secondsRemaining > 0 && !hasTimerFinished) {
65
+ startTimer(secondsRemaining);
66
+ }
67
+ }, [isTimerActive, secondsRemaining, hasTimerFinished, startTimer]);
68
+
69
+ // Check for existing timer on mount
70
+ (0, _react.useEffect)(function () {
71
+ var existingTimer = _TimerService.default.getTimerInfo(timerIdRef.current);
72
+ if (existingTimer) {
73
+ setSecondsRemaining(existingTimer.remaining);
74
+ setHasTimerFinished(existingTimer.isExpired);
75
+ setIsTimerActive(existingTimer.isActive);
76
+ }
77
+ }, []);
78
+
79
+ // Cleanup on unmount
80
+ (0, _react.useEffect)(function () {
81
+ return function () {
82
+ // Don't stop timer on unmount - let it continue running
83
+ // This allows timer to persist across component unmounts
84
+ };
85
+ }, []);
86
+ return {
87
+ secondsRemaining: secondsRemaining,
88
+ hasTimerFinished: hasTimerFinished,
89
+ isTimerActive: isTimerActive,
90
+ startTimer: startTimer,
91
+ stopTimer: stopTimer,
92
+ pauseTimer: pauseTimer,
93
+ resumeTimer: resumeTimer
94
+ };
95
+ };
96
+ exports.useTimer = useTimer;
package/dist/index.js CHANGED
@@ -1202,6 +1202,28 @@ 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
+ });
1205
1227
  var _FA = require("./components/2FA");
1206
1228
  Object.keys(_FA).forEach(function (key) {
1207
1229
  if (key === "default" || key === "__esModule") return;
@@ -1410,4 +1432,15 @@ Object.keys(_ChecklistCard).forEach(function (key) {
1410
1432
  return _ChecklistCard[key];
1411
1433
  }
1412
1434
  });
1435
+ });
1436
+ var _useTimer = require("./hooks/useTimer");
1437
+ Object.keys(_useTimer).forEach(function (key) {
1438
+ if (key === "default" || key === "__esModule") return;
1439
+ if (key in exports && exports[key] === _useTimer[key]) return;
1440
+ Object.defineProperty(exports, key, {
1441
+ enumerable: true,
1442
+ get: function get() {
1443
+ return _useTimer[key];
1444
+ }
1445
+ });
1413
1446
  });
@@ -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;
@@ -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
- exports.scrollToElement = scrollToElement;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.45",
3
+ "version": "2.3.47",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",