@gobizweb/core 0.0.7

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 (211) hide show
  1. package/README.md +56 -0
  2. package/assets/icons/arrow_left.svg +1 -0
  3. package/assets/icons/right_pointing.svg +1 -0
  4. package/assets/icons/thumb-up.svg +1 -0
  5. package/assets/images/server_error_dino.svg +1 -0
  6. package/assets/images/spot_hero_empty_list.svg +1 -0
  7. package/lib/bootstrap.js +39 -0
  8. package/lib/components/AccordionSelect/AccordionSelect.component.js +131 -0
  9. package/lib/components/AccordionSelect/AccordionSelect.styled.js +18 -0
  10. package/lib/components/AccordionSelect/index.js +13 -0
  11. package/lib/components/AlertBox/AlertBox.component.js +54 -0
  12. package/lib/components/AlertBox/AlertBox.styled.js +32 -0
  13. package/lib/components/AlertBox/index.js +13 -0
  14. package/lib/components/AlertDialog/AlertDialog.js +66 -0
  15. package/lib/components/AlertDialog/AlertDialog.styled.js +13 -0
  16. package/lib/components/AlertDialog/index.js +13 -0
  17. package/lib/components/Asphalt/Input.component.js +59 -0
  18. package/lib/components/Asphalt/index.js +13 -0
  19. package/lib/components/AsphaltPolyfill/AsphaltPolyfill.component.js +26 -0
  20. package/lib/components/AsphaltPolyfill/AsphaltPolyfill.loader.js +8 -0
  21. package/lib/components/AsphaltPolyfill/index.js +13 -0
  22. package/lib/components/Box/index.js +51 -0
  23. package/lib/components/Breakpoint/Breakpoint.component.js +63 -0
  24. package/lib/components/Breakpoint/index.js +13 -0
  25. package/lib/components/Button/Button.js +109 -0
  26. package/lib/components/Button/index.js +13 -0
  27. package/lib/components/Card/Card.js +75 -0
  28. package/lib/components/Card/Card.styled.js +60 -0
  29. package/lib/components/Card/index.js +13 -0
  30. package/lib/components/CardList/CardList.component.js +55 -0
  31. package/lib/components/CardList/index.js +13 -0
  32. package/lib/components/Checkbox/Checkbox.js +60 -0
  33. package/lib/components/Checkbox/index.js +13 -0
  34. package/lib/components/Container/Container.js +74 -0
  35. package/lib/components/Container/index.js +13 -0
  36. package/lib/components/DatePicker/Datepicker.component.js +57 -0
  37. package/lib/components/DatePicker/index.js +13 -0
  38. package/lib/components/Dropdown/Dropdown.component.js +63 -0
  39. package/lib/components/Dropdown/index.js +13 -0
  40. package/lib/components/EmptyState/EmptyState.component.js +47 -0
  41. package/lib/components/EmptyState/index.js +13 -0
  42. package/lib/components/ErrorModal/ErrorModal.component.js +41 -0
  43. package/lib/components/ErrorModal/ErrorModal.store.js +43 -0
  44. package/lib/components/ErrorModal/index.js +14 -0
  45. package/lib/components/ErrorScreen/ErrorScreen.js +19 -0
  46. package/lib/components/ErrorScreen/index.js +13 -0
  47. package/lib/components/FilterModal/FilterModal.js +41 -0
  48. package/lib/components/FilterModal/FilterModal.state.js +139 -0
  49. package/lib/components/FilterModal/index.js +13 -0
  50. package/lib/components/GlobalFilter/GlobalFilter.component.js +32 -0
  51. package/lib/components/GlobalFilter/GlobalFilter.component.state.js +116 -0
  52. package/lib/components/GlobalFilter/GlobalFilter.constant.js +17 -0
  53. package/lib/components/GlobalFilter/GlobalFilter.date.component.js +34 -0
  54. package/lib/components/GlobalFilter/GlobalFilter.interface.js +2 -0
  55. package/lib/components/GlobalFilter/GlobalFilter.provider.js +169 -0
  56. package/lib/components/GlobalFilter/GlobalFilter.styled.js +16 -0
  57. package/lib/components/GlobalFilter/index.js +16 -0
  58. package/lib/components/Guard/Guard.component.js +18 -0
  59. package/lib/components/Guard/index.js +13 -0
  60. package/lib/components/IframeLoader/IframeLoader.js +47 -0
  61. package/lib/components/IframeLoader/index.js +13 -0
  62. package/lib/components/Input/Input.component.js +167 -0
  63. package/lib/components/Input/index.js +13 -0
  64. package/lib/components/LanguageSwitcher/LanguageSwitcher.component.js +78 -0
  65. package/lib/components/LanguageSwitcher/LanguageSwitcher.state.js +20 -0
  66. package/lib/components/LanguageSwitcher/LanguageSwitcher.styled.js +40 -0
  67. package/lib/components/LanguageSwitcher/index.js +13 -0
  68. package/lib/components/List/List.js +46 -0
  69. package/lib/components/List/index.js +13 -0
  70. package/lib/components/ListSelector/ListSelector.component.js +22 -0
  71. package/lib/components/ListSelector/ListSelector.state.js +11 -0
  72. package/lib/components/ListSelector/ListSelector.styled.js +15 -0
  73. package/lib/components/ListSelector/index.js +13 -0
  74. package/lib/components/Loading/Loading.js +52 -0
  75. package/lib/components/Loading/Loading.styled.js +45 -0
  76. package/lib/components/Loading/index.js +13 -0
  77. package/lib/components/LoadingModule/LoadingModule.component.js +49 -0
  78. package/lib/components/LoadingModule/index.js +13 -0
  79. package/lib/components/MobileAppBar/MobileAppBar.js +90 -0
  80. package/lib/components/MobileAppBar/MobileAppBar.styled.js +36 -0
  81. package/lib/components/MobileAppBar/WithMobileAppBar.js +43 -0
  82. package/lib/components/MobileAppBar/index.js +14 -0
  83. package/lib/components/Modal/Modal.js +149 -0
  84. package/lib/components/Modal/ModalManager.context.js +6 -0
  85. package/lib/components/Modal/ModalManager.js +118 -0
  86. package/lib/components/Modal/index.js +15 -0
  87. package/lib/components/Navigation/Navigation.component.js +25 -0
  88. package/lib/components/Navigation/Navigation.provider.js +69 -0
  89. package/lib/components/Navigation/Navigation.styled.js +33 -0
  90. package/lib/components/Navigation/index.js +14 -0
  91. package/lib/components/PageTitle/PageTitle.component.js +47 -0
  92. package/lib/components/PageTitle/index.js +13 -0
  93. package/lib/components/Pagination/Pagination.component.js +49 -0
  94. package/lib/components/Pagination/index.js +13 -0
  95. package/lib/components/Radio/Radio.component.js +69 -0
  96. package/lib/components/Radio/Radio.styled.js +44 -0
  97. package/lib/components/Radio/RadioGroup.component.js +24 -0
  98. package/lib/components/Radio/RadioGroup.context.js +6 -0
  99. package/lib/components/Radio/index.js +15 -0
  100. package/lib/components/Separator/Separator.component.js +59 -0
  101. package/lib/components/Separator/index.js +13 -0
  102. package/lib/components/Skeleton/SkeletonApp.component.js +90 -0
  103. package/lib/components/Skeleton/SkeletonTable.component.js +36 -0
  104. package/lib/components/Skeleton/SkeletonText.component.js +62 -0
  105. package/lib/components/Skeleton/SkeletonWrapper.component.js +46 -0
  106. package/lib/components/Skeleton/index.js +16 -0
  107. package/lib/components/Stepper/Stepper.component.js +126 -0
  108. package/lib/components/Stepper/WithStepper.js +65 -0
  109. package/lib/components/Stepper/index.js +16 -0
  110. package/lib/components/Table/Table.component.js +71 -0
  111. package/lib/components/Table/Table.styled.js +51 -0
  112. package/lib/components/Table/index.js +13 -0
  113. package/lib/components/TableContainer/TableContainer.js +32 -0
  114. package/lib/components/TableContainer/index.js +13 -0
  115. package/lib/components/Text/Text.component.js +90 -0
  116. package/lib/components/Text/index.js +13 -0
  117. package/lib/components/Toast/Toast.component.js +65 -0
  118. package/lib/components/Toast/Toast.interface.js +2 -0
  119. package/lib/components/Toast/Toast.manager.js +61 -0
  120. package/lib/components/Toast/Toast.provider.js +85 -0
  121. package/lib/components/Toast/Toast.styled.js +18 -0
  122. package/lib/components/Toast/index.js +15 -0
  123. package/lib/components/Tours/index.js +100 -0
  124. package/lib/components/index.js +51 -0
  125. package/lib/constants/AndroidVersions.js +6 -0
  126. package/lib/constants/AppNames.js +10 -0
  127. package/lib/constants/AsphaltTheme.js +43 -0
  128. package/lib/constants/GobizApp.js +11 -0
  129. package/lib/constants/MediaQueries.js +30 -0
  130. package/lib/constants/PostalCodes.js +8382 -0
  131. package/lib/constants/PubsubEvents.js +12 -0
  132. package/lib/constants/TnCFiles.js +77 -0
  133. package/lib/constants/ValidationRegex.js +6 -0
  134. package/lib/constants/cookies.js +38 -0
  135. package/lib/constants/datetime.js +103 -0
  136. package/lib/constants/index.js +24 -0
  137. package/lib/constants/roles.js +17 -0
  138. package/lib/contexts/AppTheme.js +221 -0
  139. package/lib/decorators/utility-classes.js +78 -0
  140. package/lib/decorators/withStyles.js +73 -0
  141. package/lib/helpers/BrowserEnvironment.js +22 -0
  142. package/lib/helpers/ESQuery.js +98 -0
  143. package/lib/helpers/chart.js +251 -0
  144. package/lib/helpers/cleanObject.js +15 -0
  145. package/lib/helpers/conversion.js +4 -0
  146. package/lib/helpers/cookies.js +54 -0
  147. package/lib/helpers/copywrite.js +15 -0
  148. package/lib/helpers/currency.js +73 -0
  149. package/lib/helpers/dateFormat.js +47 -0
  150. package/lib/helpers/datePresets.js +77 -0
  151. package/lib/helpers/debounce.js +31 -0
  152. package/lib/helpers/deepMerge.js +81 -0
  153. package/lib/helpers/downloadURL.js +11 -0
  154. package/lib/helpers/enumReverseMap.js +12 -0
  155. package/lib/helpers/env.js +18 -0
  156. package/lib/helpers/fileDownloader.js +33 -0
  157. package/lib/helpers/formatNumber.js +10 -0
  158. package/lib/helpers/formatPercentage.js +13 -0
  159. package/lib/helpers/gobizApp.js +27 -0
  160. package/lib/helpers/identityValidator.js +6 -0
  161. package/lib/helpers/index.js +50 -0
  162. package/lib/helpers/json.js +17 -0
  163. package/lib/helpers/logger.js +93 -0
  164. package/lib/helpers/maskAccount.js +26 -0
  165. package/lib/helpers/numbers.js +6 -0
  166. package/lib/helpers/path.js +27 -0
  167. package/lib/helpers/paymentTypeHuman.js +62 -0
  168. package/lib/helpers/refreshConfig.js +12 -0
  169. package/lib/helpers/refreshToken.js +108 -0
  170. package/lib/helpers/safeParse.js +31 -0
  171. package/lib/helpers/scrollToTop.js +9 -0
  172. package/lib/helpers/shortID.js +17 -0
  173. package/lib/helpers/textParser.js +10 -0
  174. package/lib/helpers/time.js +54 -0
  175. package/lib/helpers/tour.js +38 -0
  176. package/lib/helpers/transform.js +24 -0
  177. package/lib/helpers/url.js +30 -0
  178. package/lib/helpers/wildcardToRegEx.js +15 -0
  179. package/lib/hooks/index.js +26 -0
  180. package/lib/hooks/useBreakpoint.js +35 -0
  181. package/lib/hooks/useCurrency.js +27 -0
  182. package/lib/hooks/useDatesFromTimeRange.js +40 -0
  183. package/lib/hooks/useEventListener.js +24 -0
  184. package/lib/hooks/useFormValidator.js +38 -0
  185. package/lib/hooks/useHttpOptions.js +104 -0
  186. package/lib/hooks/useLogger.js +57 -0
  187. package/lib/hooks/useNavigation.js +16 -0
  188. package/lib/hooks/usePhone.js +14 -0
  189. package/lib/hooks/useQueryInit.js +21 -0
  190. package/lib/hooks/useQueryParams.js +95 -0
  191. package/lib/hooks/useShowGlobalFilter.js +101 -0
  192. package/lib/hooks/useWebview.js +48 -0
  193. package/lib/hooks/useWindow.js +19 -0
  194. package/lib/models/AuthUser.model.js +159 -0
  195. package/lib/models/Outlet.model.js +274 -0
  196. package/lib/models/User.model.js +106 -0
  197. package/lib/models/index.js +15 -0
  198. package/lib/providers/Alert.provider.js +65 -0
  199. package/lib/providers/AppTheme.provider.js +75 -0
  200. package/lib/providers/Auth.provider.js +239 -0
  201. package/lib/providers/Clevertap.provider.js +117 -0
  202. package/lib/providers/GoogleAnalytics.provider.js +113 -0
  203. package/lib/providers/Host.provider.js +71 -0
  204. package/lib/providers/Language.provider.js +127 -0
  205. package/lib/providers/Logger.provider.js +32 -0
  206. package/lib/providers/MicroApp.provider.js +63 -0
  207. package/lib/providers/Outlets.provider.js +180 -0
  208. package/lib/providers/Token.provider.js +101 -0
  209. package/lib/providers/Translation.provider.js +56 -0
  210. package/lib/providers/index.js +24 -0
  211. package/package.json +47 -0
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scrollWrapperToTop = void 0;
4
+ exports.scrollWrapperToTop = function (_document) {
5
+ var _a;
6
+ if (_document === void 0) { _document = document; }
7
+ var wrapperElement = _document.getElementById("asp-app-router");
8
+ (_a = wrapperElement === null || wrapperElement === void 0 ? void 0 : wrapperElement.scrollTo) === null || _a === void 0 ? void 0 : _a.call(wrapperElement, 0, 0);
9
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shortID = void 0;
4
+ var chars = "abcdefghij";
5
+ var _uid = 0;
6
+ exports.shortID = function () {
7
+ // ensures uid consists of 5 chars
8
+ // e.g 1 => 00001, 13 => 00013, 123 => 00123 ...
9
+ var _padded = (_uid++ + "").padStart(5, "0");
10
+ // convert numbers to alphabet
11
+ // e.g 000 => aaa, 001 => aab etc.
12
+ var asAlphabet = _padded
13
+ .split("")
14
+ .map(function (index) { return chars[parseInt(index, 10)]; });
15
+ // prefix with `tjr-uid-`
16
+ return "asp-uid-" + asAlphabet.join("");
17
+ };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.textParamsParser = void 0;
4
+ exports.textParamsParser = function (text, params) {
5
+ params.forEach(function (param, index) {
6
+ var reg = new RegExp("\\$" + (index + 1), "g");
7
+ text = text.replace(reg, params[index]);
8
+ });
9
+ return text;
10
+ };
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
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 (_) 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
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.artificialUIDelay = exports.humanizeTime = void 0;
40
+ exports.humanizeTime = function (timeInSeconds) {
41
+ var seconds = (timeInSeconds % 60).toString().padStart(2, "0");
42
+ var minutes = Math.floor(timeInSeconds / 60)
43
+ .toString()
44
+ .padStart(2, "0");
45
+ return minutes + ":" + seconds;
46
+ };
47
+ exports.artificialUIDelay = function () { return __awaiter(void 0, void 0, void 0, function () {
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 600); })];
51
+ case 1: return [2 /*return*/, _a.sent()];
52
+ }
53
+ });
54
+ }); };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getTourCookie = exports.setTourCookie = exports.TourStatus = exports.TourNames = void 0;
15
+ var constants_1 = require("../constants");
16
+ var _1 = require("./");
17
+ var TourNames;
18
+ (function (TourNames) {
19
+ TourNames["UserManagement"] = "user_management";
20
+ TourNames["UsersManagementAdd"] = "users_management_add";
21
+ TourNames["PayoutList"] = "payout_list";
22
+ TourNames["Onboarding"] = "onboarding";
23
+ TourNames["Reporting"] = "reporting";
24
+ })(TourNames = exports.TourNames || (exports.TourNames = {}));
25
+ var TourStatus;
26
+ (function (TourStatus) {
27
+ TourStatus["Completed"] = "COMPLETED";
28
+ TourStatus["Started"] = "STARTED";
29
+ })(TourStatus = exports.TourStatus || (exports.TourStatus = {}));
30
+ exports.setTourCookie = function (name, status) {
31
+ var _a;
32
+ var currentStatus = _1.getCookie(constants_1.CookieNames.Tour) && JSON.parse(_1.getCookie(constants_1.CookieNames.Tour));
33
+ _1.setCookie(constants_1.CookieNames.Tour, JSON.stringify(__assign(__assign({}, currentStatus), (_a = {}, _a[name] = status, _a))), "never_expired");
34
+ };
35
+ exports.getTourCookie = function (name) {
36
+ var tourCookie = _1.getCookie(constants_1.CookieNames.Tour);
37
+ return tourCookie ? JSON.parse(tourCookie)[name] : null;
38
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kebabCaseToSnakeCase = exports.kebabCaseToCamelCase = exports.titleCase = exports.capitalizeFirstLetter = void 0;
4
+ exports.capitalizeFirstLetter = function (str) {
5
+ return str.charAt(0).toUpperCase() + str.slice(1);
6
+ };
7
+ exports.titleCase = function (str) {
8
+ var splitStr = str.toLowerCase().split(" ");
9
+ for (var i = 0; i < splitStr.length; i++) {
10
+ // You do not need to check if i is larger than splitStr length, as your for does that for you
11
+ // Assign it back to the array
12
+ splitStr[i] =
13
+ splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1);
14
+ }
15
+ // Directly return the joined string
16
+ return splitStr.join(" ");
17
+ };
18
+ exports.kebabCaseToCamelCase = function (kebabCase) {
19
+ var _a = kebabCase.split("-"), first = _a[0], rest = _a.slice(1);
20
+ return first + rest.map(exports.capitalizeFirstLetter).join("");
21
+ };
22
+ exports.kebabCaseToSnakeCase = function (kebabCase) {
23
+ return kebabCase.split("-").join("_");
24
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getQueryParam = exports.joinUrl = exports.resolveUrl = void 0;
4
+ exports.resolveUrl = function () {
5
+ var urls = [];
6
+ for (var _i = 0; _i < arguments.length; _i++) {
7
+ urls[_i] = arguments[_i];
8
+ }
9
+ var joinWithSlash = urls.join("/");
10
+ // Prefix with slash
11
+ // some/url/foo/bar -> /some/url/foo/bar
12
+ var prependSlash = "/" + joinWithSlash;
13
+ // replace duplicate slashes with a single slash
14
+ // some//url/foo//bar -> some/url/foo/bar
15
+ return prependSlash.replace(/\/+/g, "/");
16
+ };
17
+ /**
18
+ * @description Joins 2 path to be 1 url.
19
+ * @param {string} base - The base url path.
20
+ * @param {string} path - The path to be joined.
21
+ * @returns {string} Final url
22
+ */
23
+ exports.joinUrl = function (base, path) {
24
+ var baseContainsSlash = base.charAt(base.length - 1) === "/";
25
+ return ("" + base + (baseContainsSlash ? "" : "/") + path.toString()).replaceAll("%", "");
26
+ };
27
+ exports.getQueryParam = function (locationSearch, param) {
28
+ var urlParams = new URLSearchParams(locationSearch);
29
+ return urlParams.get(param) || "";
30
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.starWildcardToRegEx = exports.wildcardToRegEx = exports.wildcardTest = void 0;
4
+ exports.wildcardTest = function (wildcard, toTest) {
5
+ if (wildcard.includes(":*")) {
6
+ return exports.starWildcardToRegEx(wildcard).test(toTest);
7
+ }
8
+ return exports.wildcardToRegEx(wildcard).test(toTest);
9
+ };
10
+ exports.wildcardToRegEx = function (wildcard) {
11
+ return new RegExp("^" + wildcard + "$");
12
+ };
13
+ exports.starWildcardToRegEx = function (wildcard) {
14
+ return new RegExp("^" + wildcard.replace(":*", "[:.*]?"));
15
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./useNavigation"), exports);
14
+ __exportStar(require("./useQueryInit"), exports);
15
+ __exportStar(require("./useQueryParams"), exports);
16
+ __exportStar(require("./useShowGlobalFilter"), exports);
17
+ __exportStar(require("./useWindow"), exports);
18
+ __exportStar(require("./useEventListener"), exports);
19
+ __exportStar(require("./useWebview"), exports);
20
+ __exportStar(require("./useHttpOptions"), exports);
21
+ __exportStar(require("./useBreakpoint"), exports);
22
+ __exportStar(require("./useCurrency"), exports);
23
+ __exportStar(require("./useDatesFromTimeRange"), exports);
24
+ __exportStar(require("./useLogger"), exports);
25
+ __exportStar(require("./usePhone"), exports);
26
+ __exportStar(require("./useFormValidator"), exports);
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBreakpoint = void 0;
4
+ var react_1 = require("react");
5
+ var helpers_1 = require("../helpers");
6
+ var hooks_1 = require("../hooks");
7
+ var getDeviceScreenSize = function (width) {
8
+ if (width < 320) {
9
+ return "xs";
10
+ }
11
+ else if (width >= 320 && width < 400) {
12
+ return "s";
13
+ }
14
+ else if (width >= 400 && width < 767) {
15
+ return "m";
16
+ }
17
+ else if (width >= 767 && width < 1024) {
18
+ return "l";
19
+ }
20
+ return "xl";
21
+ };
22
+ exports.useBreakpoint = function (_window) {
23
+ if (_window === void 0) { _window = window; }
24
+ var _a = react_1.useState(function () {
25
+ return getDeviceScreenSize(_window.innerWidth);
26
+ }), breakpoint = _a[0], setBreakpoint = _a[1];
27
+ var handler = react_1.useCallback(helpers_1.debounce(function () {
28
+ setBreakpoint(getDeviceScreenSize(_window.innerWidth));
29
+ }, 200), []);
30
+ hooks_1.useEventListener("resize", handler, _window);
31
+ return {
32
+ isMobile: ["xs", "s", "m"].includes(breakpoint),
33
+ breakpoint: breakpoint,
34
+ };
35
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrency = void 0;
4
+ var providers_1 = require("../providers");
5
+ var helpers_1 = require("../helpers");
6
+ exports.useCurrency = function (options) {
7
+ var _a;
8
+ var authUser = providers_1.useAuth().authUser;
9
+ var activeCountry = (_a = authUser === null || authUser === void 0 ? void 0 : authUser.country) === null || _a === void 0 ? void 0 : _a.toUpperCase();
10
+ return {
11
+ currencyFormat: function (amount, country) {
12
+ if (amount === void 0) { amount = 0; }
13
+ return helpers_1.currencyFormat(amount, country || activeCountry, options);
14
+ },
15
+ currencyFormatFromString: function (amount, country) { return helpers_1.currencyFormatFromString(amount, country || activeCountry, options); },
16
+ numberFormat: function (amount, country) {
17
+ return helpers_1.numberFormat(amount, country || activeCountry);
18
+ },
19
+ currencyFormatNoDivide: function (amount, country) {
20
+ if (amount === void 0) { amount = 0; }
21
+ return helpers_1.currencyFormatNoDivide(amount, country || activeCountry);
22
+ },
23
+ localizeCopy: function (copy, country) {
24
+ return helpers_1.localizeCurrency(copy, country || activeCountry);
25
+ },
26
+ };
27
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useDatesFromTimeRange = void 0;
7
+ var react_1 = require("react");
8
+ var moment_1 = __importDefault(require("moment"));
9
+ var helpers_1 = require("../helpers");
10
+ var components_1 = require("../components");
11
+ exports.useDatesFromTimeRange = function () {
12
+ var filter = components_1.useGlobalFilter().filter;
13
+ var date_range = filter.date_range, end_time = filter.end_time, start_time = filter.start_time;
14
+ var _a = react_1.useMemo(function () {
15
+ return helpers_1.datesFromTimeRange({
16
+ timeRange: date_range,
17
+ previousStartTime: moment_1.default(start_time),
18
+ previousEndTime: moment_1.default(end_time),
19
+ });
20
+ }, [date_range, end_time, start_time]), endTime = _a.endTime, startTime = _a.startTime, compareStartTime = _a.compareStartTime;
21
+ var comparisonLabels = react_1.useMemo(function () {
22
+ switch (date_range) {
23
+ case "today":
24
+ return ["today", "yesterday"];
25
+ case "yesterday":
26
+ return ["yesterday", "previous_day"];
27
+ case "this_week":
28
+ return ["this_week", "last_week"];
29
+ case "last_week":
30
+ return ["last_week", "previous_week"];
31
+ case "this_month":
32
+ return ["this_month", "last_month"];
33
+ case "last_month":
34
+ return ["last_month", "previous_month"];
35
+ default:
36
+ return ["this_period", "previous_period"];
37
+ }
38
+ }, [date_range]);
39
+ return { endTime: endTime, startTime: startTime, compareStartTime: compareStartTime, comparisonLabels: comparisonLabels };
40
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEventListener = void 0;
4
+ var react_1 = require("react");
5
+ exports.useEventListener = function (eventName, handler, element) {
6
+ if (element === void 0) { element = window; }
7
+ var savedHandler = react_1.useRef();
8
+ react_1.useEffect(function () {
9
+ savedHandler.current = handler;
10
+ }, [handler]);
11
+ react_1.useEffect(function () {
12
+ var isSupported = element && element.addEventListener;
13
+ if (!isSupported) {
14
+ return;
15
+ }
16
+ var eventListener = function (event) {
17
+ return savedHandler.current(event);
18
+ };
19
+ element.addEventListener(eventName, eventListener);
20
+ return function () {
21
+ element.removeEventListener(eventName, eventListener);
22
+ };
23
+ }, [eventName, element]);
24
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFormValidator = void 0;
4
+ var libphonenumber_js_1 = require("libphonenumber-js");
5
+ var Auth_provider_1 = require("../providers/Auth.provider");
6
+ var ValidationRegex_1 = require("../constants/ValidationRegex");
7
+ var logger_1 = require("../helpers/logger");
8
+ /**
9
+ * Validates a text input. Should be used with react-form-hook.validate property.
10
+ * The validator function must return `true` for empty input so it doesn't conflict with the required validator.
11
+ */
12
+ exports.useFormValidator = function (country) {
13
+ var authUser = Auth_provider_1.useAuth().authUser;
14
+ var _country = (country || (authUser === null || authUser === void 0 ? void 0 : authUser.country) || "ID");
15
+ var phone = function (value) {
16
+ if (!value.length) {
17
+ return true;
18
+ }
19
+ try {
20
+ var parsed = libphonenumber_js_1.parsePhoneNumber(value, _country);
21
+ return parsed === null || parsed === void 0 ? void 0 : parsed.isPossible();
22
+ }
23
+ catch (err) {
24
+ var error = err;
25
+ if (error.name !== "ParseError") {
26
+ logger_1.Logger.error(error);
27
+ }
28
+ return false;
29
+ }
30
+ };
31
+ var email = function (value) {
32
+ return value.length ? ValidationRegex_1.ValidationRegex.email.test(value) : true;
33
+ };
34
+ return {
35
+ phone: phone,
36
+ email: email,
37
+ };
38
+ };
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
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 (_) 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
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.useHttpOptions = void 0;
40
+ var cookies_1 = require("../constants/cookies");
41
+ var BrowserEnvironment_1 = require("../helpers/BrowserEnvironment");
42
+ var cookies_2 = require("../helpers/cookies");
43
+ var deepMerge_1 = require("../helpers/deepMerge");
44
+ var Translation_provider_1 = require("../providers/Translation.provider");
45
+ var Toast_1 = require("../components/Toast");
46
+ /** @todo change refreshToken as helper again, instead of props, after migration is done */
47
+ exports.useHttpOptions = function (_a) {
48
+ var refreshToken = _a.refreshToken;
49
+ var translate = Translation_provider_1.useTranslation();
50
+ var showToast = Toast_1.useToast().showToast;
51
+ var httpOptions = {
52
+ interceptors: {
53
+ request: function (_a) {
54
+ var options = _a.options;
55
+ if (BrowserEnvironment_1.isOffline()) {
56
+ showToast({
57
+ title: translate("generic.network_offline.title"),
58
+ message: translate("generic.network_offline.message"),
59
+ color: "warning",
60
+ persistent: true,
61
+ });
62
+ return;
63
+ }
64
+ return deepMerge_1.deepMerge(options, {
65
+ headers: {
66
+ Authorization: "Bearer " + cookies_2.getCookie(cookies_1.CookieNames.AccessToken),
67
+ "Authentication-Type": "go-id",
68
+ },
69
+ });
70
+ },
71
+ },
72
+ retries: 1,
73
+ retryDelay: 100,
74
+ retryOn: function (_a) {
75
+ var response = _a.response;
76
+ return __awaiter(void 0, void 0, void 0, function () {
77
+ var requestTokenRefresh, result;
78
+ return __generator(this, function (_b) {
79
+ switch (_b.label) {
80
+ case 0:
81
+ if (!response) return [3 /*break*/, 2];
82
+ if (/^50/.test(response.status.toString())) {
83
+ showToast({
84
+ title: translate("generic.server_error.title"),
85
+ message: translate("generic.server_error.message"),
86
+ color: "warning",
87
+ persistent: true,
88
+ });
89
+ return [2 /*return*/, false];
90
+ }
91
+ requestTokenRefresh = (response === null || response === void 0 ? void 0 : response.status) === 401;
92
+ if (!requestTokenRefresh) return [3 /*break*/, 2];
93
+ return [4 /*yield*/, refreshToken()];
94
+ case 1:
95
+ result = _b.sent();
96
+ return [2 /*return*/, result];
97
+ case 2: return [2 /*return*/, false];
98
+ }
99
+ });
100
+ });
101
+ },
102
+ };
103
+ return httpOptions;
104
+ };
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
3
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
+ r[k] = a[j];
7
+ return r;
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.useLogger = void 0;
11
+ var react_1 = require("react");
12
+ var Logger_provider_1 = require("../providers/Logger.provider");
13
+ exports.useLogger = function () {
14
+ var _a;
15
+ var rootContext = react_1.useContext(Logger_provider_1.LoggerContext);
16
+ var raygunKey = rootContext.raygunKey, sendWarning = rootContext.sendWarning, raygunInstance = rootContext.raygunInstance;
17
+ var isDevOrTest = ["development", "test"].includes((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV);
18
+ var initUser = function (userId) {
19
+ raygunInstance.setUser({
20
+ identifier: userId,
21
+ isAnonymous: false,
22
+ });
23
+ };
24
+ var info = function () {
25
+ var messages = [];
26
+ for (var _i = 0; _i < arguments.length; _i++) {
27
+ messages[_i] = arguments[_i];
28
+ }
29
+ if (isDevOrTest) {
30
+ console.log.apply(console, __spreadArrays(["Logger.info"], messages));
31
+ }
32
+ };
33
+ var warn = function (content) {
34
+ if (isDevOrTest) {
35
+ var stack = new Error().stack;
36
+ console.warn("Logger.warn", { content: content, stack: stack });
37
+ }
38
+ if (!!raygunKey && sendWarning) {
39
+ raygunInstance.send({ error: content, tags: ["warning"] });
40
+ }
41
+ };
42
+ var error = function (error, tags) {
43
+ if (tags === void 0) { tags = []; }
44
+ if (isDevOrTest) {
45
+ console.error("Logger.error", error, tags);
46
+ }
47
+ if (!!raygunKey) {
48
+ raygunInstance.send({ error: error, tags: __spreadArrays(["error"], tags) });
49
+ }
50
+ };
51
+ return {
52
+ initUser: initUser,
53
+ info: info,
54
+ warn: warn,
55
+ error: error,
56
+ };
57
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNavigation = void 0;
4
+ var react_1 = require("react");
5
+ var Navigation_provider_1 = require("../components/Navigation/Navigation.provider");
6
+ exports.useNavigation = function () {
7
+ var navigationContext = Navigation_provider_1.useNavigationContext();
8
+ react_1.useEffect(function () {
9
+ return function () {
10
+ navigationContext.setPageTitle("");
11
+ navigationContext.setPrevPath("");
12
+ };
13
+ // eslint-disable-next-line react-hooks/exhaustive-deps
14
+ }, []);
15
+ return navigationContext;
16
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePhone = void 0;
4
+ var Auth_provider_1 = require("../providers/Auth.provider");
5
+ var copywrite_1 = require("../helpers/copywrite");
6
+ exports.usePhone = function () {
7
+ var authUser = Auth_provider_1.useAuth().authUser;
8
+ var activeCountry = authUser.country.toUpperCase();
9
+ return {
10
+ localizeCopy: function (copy, country) {
11
+ return copywrite_1.localizePhone(copy, country || activeCountry);
12
+ },
13
+ };
14
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useQueryInit = void 0;
7
+ var useMount_1 = __importDefault(require("react-use/lib/useMount"));
8
+ var useCookie_1 = __importDefault(require("react-use/lib/useCookie"));
9
+ var query_string_1 = __importDefault(require("query-string"));
10
+ var cookies_1 = require("../constants/cookies");
11
+ exports.useQueryInit = function () {
12
+ var _a = useCookie_1.default(cookies_1.CookieNames.APILevel), setApiLevelCookie = _a[1];
13
+ var _b = useCookie_1.default(cookies_1.CookieNames.AppID), setAppIDCookie = _b[1];
14
+ var _c = useCookie_1.default(cookies_1.CookieNames.VersionCode), setVersionCodeCookie = _c[1];
15
+ useMount_1.default(function () {
16
+ var queryParams = query_string_1.default.parse(window.location.search);
17
+ setApiLevelCookie(queryParams.api_level || "");
18
+ setAppIDCookie(queryParams.app_id || "");
19
+ setVersionCodeCookie(queryParams.version_code || "");
20
+ });
21
+ };