@react-pakistan/util-functions 1.23.33 → 1.23.34

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.
Files changed (101) hide show
  1. package/api/cors/index.js +6 -6
  2. package/api/stellar-solutions/app-user/index.js +97 -38
  3. package/api/stellar-solutions/banking-detail/index.js +107 -48
  4. package/api/stellar-solutions/branch/index.js +107 -48
  5. package/api/stellar-solutions/company/index.js +124 -57
  6. package/api/stellar-solutions/company-report/index.js +48 -13
  7. package/api/stellar-solutions/contact/index.js +132 -65
  8. package/api/stellar-solutions/currency/index.js +101 -42
  9. package/api/stellar-solutions/customer/index.js +149 -74
  10. package/api/stellar-solutions/expense/index.js +132 -65
  11. package/api/stellar-solutions/expense-category/index.js +133 -66
  12. package/api/stellar-solutions/lead/index.js +132 -65
  13. package/api/stellar-solutions/menu-order/index.js +97 -38
  14. package/api/stellar-solutions/payment/index.js +135 -77
  15. package/api/stellar-solutions/payment-mode/index.js +90 -31
  16. package/api/stellar-solutions/preference/index.js +71 -28
  17. package/api/stellar-solutions/product/index.js +144 -77
  18. package/api/stellar-solutions/product-category/index.js +130 -63
  19. package/api/stellar-solutions/profile/index.js +152 -77
  20. package/api/stellar-solutions/quote-invoice/index.js +280 -201
  21. package/api/stellar-solutions/quote-invoice-report/index.js +48 -13
  22. package/api/stellar-solutions/tax/index.js +103 -44
  23. package/constants/react-pakistan.js +11 -22
  24. package/constants/social-media-sizes.js +33 -32
  25. package/general/basic-get.js +68 -6
  26. package/general/basic-post.js +55 -6
  27. package/general/camel-to-sentence-case.js +3 -3
  28. package/general/check-even-odd-length.js +1 -1
  29. package/general/create-date.js +4 -4
  30. package/general/dynamic-page-limit.js +15 -4
  31. package/general/enum-to-text.js +2 -2
  32. package/general/fetch-supabase-image.js +53 -15
  33. package/general/format-date.js +13 -12
  34. package/general/generate-blog-schema.js +10 -9
  35. package/general/generate-breadcrumb-schema.js +5 -4
  36. package/general/generate-faq-schema.js +5 -3
  37. package/general/generate-grid.js +2 -2
  38. package/general/generate-organization-schema.js +14 -13
  39. package/general/get-day-name.js +1 -1
  40. package/general/get-full-name.js +4 -1
  41. package/general/get-href.js +1 -1
  42. package/general/get-month-name.js +1 -1
  43. package/general/get-pathname.js +1 -1
  44. package/general/index.d.ts +2 -2
  45. package/general/index.js +2 -2
  46. package/general/is-next-button-disabled.js +1 -1
  47. package/general/is-odd.js +1 -1
  48. package/general/is-previous-button-disabled.js +1 -1
  49. package/general/remove-data-image-prefix.js +2 -2
  50. package/general/repeat-times.js +3 -3
  51. package/general/resolve-anchor-link.js +4 -4
  52. package/general/resolve-current-date.js +2 -2
  53. package/general/resolve-grid.js +1 -1
  54. package/general/resolve-initials.js +2 -2
  55. package/general/set-timezone.js +6 -3
  56. package/general/slugify.js +2 -2
  57. package/general/text-to-enum.js +1 -1
  58. package/general/text-to-sentence-case.js +1 -1
  59. package/general/truncate-text.js +1 -1
  60. package/general/upload-blob-to-private-supabase.d.ts +11 -0
  61. package/general/upload-blob-to-private-supabase.js +62 -0
  62. package/general/upload-blob-to-public-supabase.d.ts +11 -0
  63. package/general/upload-blob-to-public-supabase.js +62 -0
  64. package/general/upload-image-to-private-supabase.js +51 -15
  65. package/general/upload-image-to-public-supabase.js +51 -15
  66. package/general/url-to-sentence-case.js +4 -4
  67. package/general/validate-comment.js +1 -1
  68. package/general/validate-email.js +2 -2
  69. package/general/validate-name.js +1 -1
  70. package/hooks/use-change.js +14 -5
  71. package/hooks/use-debounce.js +7 -6
  72. package/hooks/use-fetch.js +82 -31
  73. package/hooks/use-force-render.js +3 -3
  74. package/hooks/use-ip-geo-location.js +57 -22
  75. package/hooks/use-is-mobile.js +6 -6
  76. package/hooks/use-position.js +16 -16
  77. package/hooks/use-sticky.js +9 -8
  78. package/hooks/use-toggle-state.js +6 -5
  79. package/hooks/use-window-event-listener.js +4 -4
  80. package/local-storage/get-storage-value.js +2 -2
  81. package/local-storage/remove-storage-value.js +1 -1
  82. package/local-storage/set-storage-value.js +1 -1
  83. package/package.json +1 -1
  84. package/storybook/generate-sitemap.js +6 -22
  85. package/storybook/preview.js +13 -2
  86. package/storybook/react-design-story-script.js +7 -11
  87. package/storybook/react-emoji-collection.js +23 -33
  88. package/storybook/react-emoji-story-script.js +9 -13
  89. package/storybook/react-emoji-story-template.js +1 -46
  90. package/storybook/react-icon-collection.js +17 -27
  91. package/storybook/react-icon-story-script.js +9 -13
  92. package/storybook/react-icon-story-template.js +1 -46
  93. package/storybook/react-logo-collection.js +17 -27
  94. package/storybook/react-logo-story-script.js +9 -13
  95. package/storybook/react-logo-story-template.js +1 -46
  96. package/storybook/responsive-component.js +11 -46
  97. package/storybook/theme.js +4 -4
  98. package/general/upload-image-blob-to-private-supabase.d.ts +0 -11
  99. package/general/upload-image-blob-to-private-supabase.js +0 -27
  100. package/general/upload-image-blob-to-public-supabase.d.ts +0 -11
  101. package/general/upload-image-blob-to-public-supabase.js +0 -27
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.uploadBlobToPublicSupabase = void 0;
41
+ var uploadBlobToPublicSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
+ var _c, data, error;
43
+ var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
44
+ return __generator(this, function (_d) {
45
+ switch (_d.label) {
46
+ case 0: return [4 /*yield*/, supabase.storage
47
+ .from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
48
+ .upload(fileRef, blob, {
49
+ cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
50
+ contentType: contentType,
51
+ upsert: upsert,
52
+ })];
53
+ case 1:
54
+ _c = _d.sent(), data = _c.data, error = _c.error;
55
+ return [2 /*return*/, {
56
+ data: data,
57
+ error: error,
58
+ }];
59
+ }
60
+ });
61
+ }); };
62
+ exports.uploadBlobToPublicSupabase = uploadBlobToPublicSupabase;
@@ -9,22 +9,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
12
39
  Object.defineProperty(exports, "__esModule", { value: true });
13
40
  exports.uploadImageToPrivateSupabase = void 0;
14
- const remove_data_image_prefix_1 = require("./remove-data-image-prefix");
15
- const uploadImageToPrivateSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
16
- const base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
17
- const buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
18
- const { data, error } = yield supabase.storage
19
- .from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
20
- .upload(fileRef, buffer, {
21
- cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
22
- contentType,
23
- upsert,
41
+ var remove_data_image_prefix_1 = require("./remove-data-image-prefix");
42
+ var uploadImageToPrivateSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
43
+ var base64StringWithoutPrefix, buffer, _c, data, error;
44
+ var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
45
+ return __generator(this, function (_d) {
46
+ switch (_d.label) {
47
+ case 0:
48
+ base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
49
+ buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
50
+ return [4 /*yield*/, supabase.storage
51
+ .from(process.env.NEXT_PUBLIC_SUPABASE_PRIVATE_BUCKET)
52
+ .upload(fileRef, buffer, {
53
+ cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
54
+ contentType: contentType,
55
+ upsert: upsert,
56
+ })];
57
+ case 1:
58
+ _c = _d.sent(), data = _c.data, error = _c.error;
59
+ if (error) {
60
+ return [2 /*return*/, error];
61
+ }
62
+ return [2 /*return*/, data];
63
+ }
24
64
  });
25
- if (error) {
26
- return error;
27
- }
28
- return data;
29
- });
65
+ }); };
30
66
  exports.uploadImageToPrivateSupabase = uploadImageToPrivateSupabase;
@@ -9,22 +9,58 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
10
  });
11
11
  };
12
+ var __generator = (this && this.__generator) || function (thisArg, body) {
13
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
14
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
15
+ function verb(n) { return function (v) { return step([n, v]); }; }
16
+ function step(op) {
17
+ if (f) throw new TypeError("Generator is already executing.");
18
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
19
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
20
+ if (y = 0, t) op = [op[0] & 2, t.value];
21
+ switch (op[0]) {
22
+ case 0: case 1: t = op; break;
23
+ case 4: _.label++; return { value: op[1], done: false };
24
+ case 5: _.label++; y = op[1]; op = [0]; continue;
25
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
26
+ default:
27
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
28
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
29
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
30
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
31
+ if (t[2]) _.ops.pop();
32
+ _.trys.pop(); continue;
33
+ }
34
+ op = body.call(thisArg, _);
35
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
36
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
37
+ }
38
+ };
12
39
  Object.defineProperty(exports, "__esModule", { value: true });
13
40
  exports.uploadImageToPublicSupabase = void 0;
14
- const remove_data_image_prefix_1 = require("./remove-data-image-prefix");
15
- const uploadImageToPublicSupabase = (_a) => __awaiter(void 0, [_a], void 0, function* ({ blob, contentType, fileRef, supabase, upsert, }) {
16
- const base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
17
- const buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
18
- const { data, error } = yield supabase.storage
19
- .from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
20
- .upload(fileRef, buffer, {
21
- cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
22
- contentType,
23
- upsert,
41
+ var remove_data_image_prefix_1 = require("./remove-data-image-prefix");
42
+ var uploadImageToPublicSupabase = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
43
+ var base64StringWithoutPrefix, buffer, _c, data, error;
44
+ var blob = _b.blob, contentType = _b.contentType, fileRef = _b.fileRef, supabase = _b.supabase, upsert = _b.upsert;
45
+ return __generator(this, function (_d) {
46
+ switch (_d.label) {
47
+ case 0:
48
+ base64StringWithoutPrefix = (0, remove_data_image_prefix_1.removeDataImagePrefix)(blob);
49
+ buffer = Buffer.from(base64StringWithoutPrefix, 'base64');
50
+ return [4 /*yield*/, supabase.storage
51
+ .from(process.env.NEXT_PUBLIC_SUPABASE_PUBLIC_BUCKET)
52
+ .upload(fileRef, buffer, {
53
+ cacheControl: process.env.NEXT_PUBLIC_SUPABASE_CACHE_CONTROL,
54
+ contentType: contentType,
55
+ upsert: upsert,
56
+ })];
57
+ case 1:
58
+ _c = _d.sent(), data = _c.data, error = _c.error;
59
+ if (error) {
60
+ return [2 /*return*/, error];
61
+ }
62
+ return [2 /*return*/, data];
63
+ }
24
64
  });
25
- if (error) {
26
- return error;
27
- }
28
- return data;
29
- });
65
+ }); };
30
66
  exports.uploadImageToPublicSupabase = uploadImageToPublicSupabase;
@@ -10,12 +10,12 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.urlToSentenceCase = void 0;
13
- const urlToSentenceCase = (url) => {
14
- const chunks = url.split('/');
15
- const pageName = chunks[chunks.length - 1];
13
+ var urlToSentenceCase = function (url) {
14
+ var chunks = url.split('/');
15
+ var pageName = chunks[chunks.length - 1];
16
16
  return pageName
17
17
  .split('-')
18
- .map((_str) => _str.charAt(0).toUpperCase() + _str.slice(1))
18
+ .map(function (_str) { return _str.charAt(0).toUpperCase() + _str.slice(1); })
19
19
  .join(' ');
20
20
  };
21
21
  exports.urlToSentenceCase = urlToSentenceCase;
@@ -12,7 +12,7 @@
12
12
  /** End file docs */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.validateComment = void 0;
15
- const validateComment = (comment) => {
15
+ var validateComment = function (comment) {
16
16
  if (comment.length >= 200 && comment.length < 1500) {
17
17
  return true;
18
18
  }
@@ -14,8 +14,8 @@
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.validateEmail = void 0;
16
16
  /* eslint-disable max-len, no-useless-escape */
17
- const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/gi;
18
- const validateEmail = (email) => {
17
+ var emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/gi;
18
+ var validateEmail = function (email) {
19
19
  if (email.match(emailRegex)) {
20
20
  return true;
21
21
  }
@@ -12,7 +12,7 @@
12
12
  /** End file docs */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.validateName = void 0;
15
- const validateName = (str) => {
15
+ var validateName = function (str) {
16
16
  if (str.length >= 3 && str.length < 30) {
17
17
  return true;
18
18
  }
@@ -1,14 +1,23 @@
1
1
  "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.useChange = void 0;
4
- const react_1 = require("react");
5
- const useChange = (callback, deps) => {
6
- const init = (0, react_1.useRef)(false);
7
- (0, react_1.useEffect)(() => {
13
+ var react_1 = require("react");
14
+ var useChange = function (callback, deps) {
15
+ var init = (0, react_1.useRef)(false);
16
+ (0, react_1.useEffect)(function () {
8
17
  if (init.current) {
9
18
  callback();
10
19
  }
11
20
  init.current = true;
12
- }, [init, ...deps]);
21
+ }, __spreadArray([init], deps, true));
13
22
  };
14
23
  exports.useChange = useChange;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDebounce = void 0;
4
- const react_1 = require("react");
5
- const useDebounce = (value, timeout = 500) => {
6
- const [state, setState] = (0, react_1.useState)(value);
7
- (0, react_1.useEffect)(() => {
8
- const handler = setTimeout(() => setState(value), timeout);
9
- return () => clearTimeout(handler);
4
+ var react_1 = require("react");
5
+ var useDebounce = function (value, timeout) {
6
+ if (timeout === void 0) { timeout = 500; }
7
+ var _a = (0, react_1.useState)(value), state = _a[0], setState = _a[1];
8
+ (0, react_1.useEffect)(function () {
9
+ var handler = setTimeout(function () { return setState(value); }, timeout);
10
+ return function () { return clearTimeout(handler); };
10
11
  }, [value, timeout]);
11
12
  return state;
12
13
  };
@@ -1,5 +1,16 @@
1
1
  "use strict";
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
3
14
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
15
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
16
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -9,51 +20,91 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
20
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
21
  });
11
22
  };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
30
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
12
50
  Object.defineProperty(exports, "__esModule", { value: true });
13
51
  exports.useFetch = void 0;
14
- const react_1 = require("react");
15
- const api_methods_1 = require("../constants/api-methods");
16
- const useFetch = ({ url, method, }) => {
17
- const [data, setData] = (0, react_1.useState)(null);
18
- const [loading, setLoading] = (0, react_1.useState)(null);
19
- const [error, setError] = (0, react_1.useState)(null);
20
- const fetchData = (0, react_1.useCallback)((body, cb, params) => {
21
- let fetchUrl;
52
+ var react_1 = require("react");
53
+ var api_methods_1 = require("../constants/api-methods");
54
+ var useFetch = function (_a) {
55
+ var url = _a.url, method = _a.method;
56
+ var _b = (0, react_1.useState)(null), data = _b[0], setData = _b[1];
57
+ var _c = (0, react_1.useState)(null), loading = _c[0], setLoading = _c[1];
58
+ var _d = (0, react_1.useState)(null), error = _d[0], setError = _d[1];
59
+ var fetchData = (0, react_1.useCallback)(function (body, cb, params) {
60
+ var fetchUrl;
22
61
  if ((params === null || params === void 0 ? void 0 : params.id) || (params === null || params === void 0 ? void 0 : params.email)) {
23
62
  if (params === null || params === void 0 ? void 0 : params.id) {
24
- fetchUrl = `${url}/${params === null || params === void 0 ? void 0 : params.id}`;
63
+ fetchUrl = "".concat(url, "/").concat(params === null || params === void 0 ? void 0 : params.id);
25
64
  }
26
65
  if (params === null || params === void 0 ? void 0 : params.email) {
27
- fetchUrl = `${url}/${params === null || params === void 0 ? void 0 : params.email}`;
66
+ fetchUrl = "".concat(url, "/").concat(params === null || params === void 0 ? void 0 : params.email);
28
67
  }
29
68
  }
30
69
  else {
31
70
  fetchUrl = url;
32
71
  }
33
- (() => __awaiter(void 0, void 0, void 0, function* () {
34
- try {
35
- setLoading(true);
36
- setData(null);
37
- setError(null);
38
- const response = yield fetch(fetchUrl, Object.assign({ method }, (method !== api_methods_1.API_METHODS.GET && { body })));
39
- const json = yield response.json();
40
- if (response.status === 200) {
41
- setLoading(false);
42
- setData(json.data);
43
- cb === null || cb === void 0 ? void 0 : cb(json.data);
72
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
73
+ var response, json, err_1;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0:
77
+ _a.trys.push([0, 3, , 4]);
78
+ setLoading(true);
79
+ setData(null);
80
+ setError(null);
81
+ return [4 /*yield*/, fetch(fetchUrl, __assign({ method: method }, (method !== api_methods_1.API_METHODS.GET && { body: body })))];
82
+ case 1:
83
+ response = _a.sent();
84
+ return [4 /*yield*/, response.json()];
85
+ case 2:
86
+ json = _a.sent();
87
+ if (response.status === 200) {
88
+ setLoading(false);
89
+ setData(json.data);
90
+ cb === null || cb === void 0 ? void 0 : cb(json.data);
91
+ }
92
+ return [3 /*break*/, 4];
93
+ case 3:
94
+ err_1 = _a.sent();
95
+ setLoading(false);
96
+ setError(new Error(err_1));
97
+ return [3 /*break*/, 4];
98
+ case 4: return [2 /*return*/];
44
99
  }
45
- }
46
- catch (err) {
47
- setLoading(false);
48
- setError(new Error(err));
49
- }
50
- }))();
100
+ });
101
+ }); })();
51
102
  }, [method, url]);
52
103
  return {
53
- data,
54
- loading,
55
- error,
56
- fetchData,
104
+ data: data,
105
+ loading: loading,
106
+ error: error,
107
+ fetchData: fetchData,
57
108
  };
58
109
  };
59
110
  exports.useFetch = useFetch;
@@ -9,9 +9,9 @@
9
9
  /** End file docs */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.useForceRender = void 0;
12
- const react_1 = require("react");
13
- const useForceRender = () => {
14
- const [, dispatch] = (0, react_1.useReducer)((s) => s + 1, 0);
12
+ var react_1 = require("react");
13
+ var useForceRender = function () {
14
+ var _a = (0, react_1.useReducer)(function (s) { return s + 1; }, 0), dispatch = _a[1];
15
15
  return dispatch;
16
16
  };
17
17
  exports.useForceRender = useForceRender;
@@ -8,37 +8,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
11
38
  Object.defineProperty(exports, "__esModule", { value: true });
12
39
  exports.useIPGeoLocation = void 0;
13
- const react_1 = require("react");
14
- const useIPGeoLocation = () => {
15
- const [country, setCountry] = (0, react_1.useState)(null);
16
- const [error, setError] = (0, react_1.useState)(null);
17
- const [isLoading, setIsLoading] = (0, react_1.useState)(true);
18
- const apiEndpoint = 'https://api.country.is';
19
- (0, react_1.useEffect)(() => {
40
+ var react_1 = require("react");
41
+ var useIPGeoLocation = function () {
42
+ var _a = (0, react_1.useState)(null), country = _a[0], setCountry = _a[1];
43
+ var _b = (0, react_1.useState)(null), error = _b[0], setError = _b[1];
44
+ var _c = (0, react_1.useState)(true), isLoading = _c[0], setIsLoading = _c[1];
45
+ var apiEndpoint = 'https://api.country.is';
46
+ (0, react_1.useEffect)(function () {
20
47
  if (country)
21
48
  return;
22
49
  function fetchAPI() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- setIsLoading(true);
25
- yield fetch(apiEndpoint)
26
- .then((res) => {
27
- if (!res.ok) {
28
- throw Error(res.statusText);
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0:
54
+ setIsLoading(true);
55
+ return [4 /*yield*/, fetch(apiEndpoint)
56
+ .then(function (res) {
57
+ if (!res.ok) {
58
+ throw Error(res.statusText);
59
+ }
60
+ return res.json();
61
+ })
62
+ .then(function (res) {
63
+ if (res && res.country)
64
+ setCountry(res.country);
65
+ })
66
+ .catch(function (err) { return setError(err); })
67
+ .finally(function () { return setIsLoading(false); })];
68
+ case 1:
69
+ _a.sent();
70
+ return [2 /*return*/];
29
71
  }
30
- return res.json();
31
- })
32
- .then((res) => {
33
- if (res && res.country)
34
- setCountry(res.country);
35
- })
36
- .catch((err) => setError(err))
37
- .finally(() => setIsLoading(false));
72
+ });
38
73
  });
39
74
  }
40
75
  fetchAPI();
41
76
  }, [country]);
42
- return { country, error, isLoading };
77
+ return { country: country, error: error, isLoading: isLoading };
43
78
  };
44
79
  exports.useIPGeoLocation = useIPGeoLocation;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useIsMobile = void 0;
4
- const react_1 = require("react");
5
- const useIsMobile = () => {
6
- const [isMobile, setIsMobile] = (0, react_1.useState)(false);
7
- const handleResize = () => {
4
+ var react_1 = require("react");
5
+ var useIsMobile = function () {
6
+ var _a = (0, react_1.useState)(false), isMobile = _a[0], setIsMobile = _a[1];
7
+ var handleResize = function () {
8
8
  if (window.innerWidth < 767) {
9
9
  setIsMobile(true);
10
10
  }
@@ -12,10 +12,10 @@ const useIsMobile = () => {
12
12
  setIsMobile(false);
13
13
  }
14
14
  };
15
- (0, react_1.useEffect)(() => {
15
+ (0, react_1.useEffect)(function () {
16
16
  window.addEventListener('resize', handleResize);
17
17
  handleResize();
18
- return () => window.removeEventListener('resize', handleResize);
18
+ return function () { return window.removeEventListener('resize', handleResize); };
19
19
  }, []);
20
20
  return isMobile;
21
21
  };
@@ -10,32 +10,32 @@
10
10
  /** End file docs */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.usePosition = void 0;
13
- const react_1 = require("react");
14
- const usePosition = (elementRef) => {
15
- const [x, setX] = (0, react_1.useState)({
13
+ var react_1 = require("react");
14
+ var usePosition = function (elementRef) {
15
+ var _a = (0, react_1.useState)({
16
16
  xLeft: 0,
17
17
  xRight: 0,
18
- });
19
- const [y, setY] = (0, react_1.useState)({
18
+ }), x = _a[0], setX = _a[1];
19
+ var _b = (0, react_1.useState)({
20
20
  yTop: 0,
21
21
  yBottom: 0,
22
- });
23
- const getPosition = (0, react_1.useCallback)(() => {
22
+ }), y = _b[0], setY = _b[1];
23
+ var getPosition = (0, react_1.useCallback)(function () {
24
24
  var _a, _b, _c, _d;
25
- const xLeft = ((_a = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft) || null;
26
- const xRight = ((_b = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _b === void 0 ? void 0 : _b.offsetRight) || null;
27
- const yTop = ((_c = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _c === void 0 ? void 0 : _c.offsetTop) || null;
28
- const yBottom = ((_d = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _d === void 0 ? void 0 : _d.offsetBottom) || null;
25
+ var xLeft = ((_a = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _a === void 0 ? void 0 : _a.offsetLeft) || null;
26
+ var xRight = ((_b = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _b === void 0 ? void 0 : _b.offsetRight) || null;
27
+ var yTop = ((_c = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _c === void 0 ? void 0 : _c.offsetTop) || null;
28
+ var yBottom = ((_d = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current) === null || _d === void 0 ? void 0 : _d.offsetBottom) || null;
29
29
  setX({
30
- xLeft,
31
- xRight,
30
+ xLeft: xLeft,
31
+ xRight: xRight,
32
32
  });
33
33
  setY({
34
- yTop,
35
- yBottom,
34
+ yTop: yTop,
35
+ yBottom: yBottom,
36
36
  });
37
37
  }, [elementRef, setX, setY]);
38
- (0, react_1.useEffect)(() => {
38
+ (0, react_1.useEffect)(function () {
39
39
  getPosition();
40
40
  }, [getPosition]);
41
41
  return [x, y];