@stokr/components-library 2.3.79 → 2.3.80

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.
@@ -17,7 +17,7 @@ var _formatCurrencyValue = require("../../utils/formatCurrencyValue");
17
17
  var _theme = _interopRequireDefault(require("../../styles/theme"));
18
18
  var _Icon = _interopRequireWildcard(require("../Icon/Icon.style"));
19
19
  var _styledComponents = _interopRequireDefault(require("styled-components"));
20
- const _excluded = ["data", "user", "isModalOpen", "onModalClose", "onCTAClick", "isRedemption", "noCTA", "CTAText", "additionalInfoRight", "withTimer", "error", "secondsRemaining", "modalTitle", "txTextInRed", "sendTokenTextRight", "numberOfSecuritiesText", "formatAmountInLink"];
20
+ const _excluded = ["data", "user", "isModalOpen", "onModalClose", "onCTAClick", "isRedemption", "noCTA", "CTAText", "additionalInfoRight", "withTimer", "error", "secondsRemaining", "modalTitle", "txTextInRed", "sendTokenTextRight", "numberOfSecuritiesText", "formatAmountInLink", "transactionCostMessage", "paymentLink", "showKYCWarningBox"];
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
22
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
23
23
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
@@ -48,7 +48,10 @@ const PaymentModal = _ref => {
48
48
  txTextInRed = true,
49
49
  sendTokenTextRight = /*#__PURE__*/_react.default.createElement("p", null, "Send your ", data === null || data === void 0 ? void 0 : data.tokenSymbolToSend, " to the treasury wallet below."),
50
50
  numberOfSecuritiesText = 'Redeem securities',
51
- formatAmountInLink = true
51
+ formatAmountInLink = true,
52
+ transactionCostMessage,
53
+ paymentLink: paymentLinkProp,
54
+ showKYCWarningBox = true
52
55
  } = _ref,
53
56
  props = _objectWithoutProperties(_ref, _excluded);
54
57
  const {
@@ -66,7 +69,11 @@ const PaymentModal = _ref => {
66
69
  //https://github.com/ElementsProject/elements/issues/805
67
70
  newTokenAmount = (tokenAmount * Math.pow(10, tokenDecimals - 8)).toFixed(8);
68
71
  }
69
- var paymentlink = "liquidnetwork:".concat(projectData === null || projectData === void 0 ? void 0 : projectData.companyWallet, "?amount=").concat(newTokenAmount, "&assetid=").concat(projectData === null || projectData === void 0 ? void 0 : projectData.secondaryAssetId);
72
+ const defaultPaymentLink = "liquidnetwork:".concat(projectData === null || projectData === void 0 ? void 0 : projectData.companyWallet, "?amount=").concat(newTokenAmount, "&assetid=").concat(projectData === null || projectData === void 0 ? void 0 : projectData.secondaryAssetId);
73
+ const resolvedPaymentLink = paymentLinkProp !== null && paymentLinkProp !== void 0 ? paymentLinkProp : defaultPaymentLink;
74
+ const txCostParagraphStyle = {
75
+ color: txTextInRed ? _theme.default.cWarning : 'inherit'
76
+ };
70
77
  const isKYCVerified = (user === null || user === void 0 ? void 0 : user.kyc_status) === 'Accepted';
71
78
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Modal.Modal, {
72
79
  isOpen: isModalOpen,
@@ -99,11 +106,9 @@ const PaymentModal = _ref => {
99
106
  onClick: onCTAClick
100
107
  }, CTAText))), /*#__PURE__*/_react.default.createElement(_Grid.Column, {
101
108
  part: 8
102
- }, error ? error : /*#__PURE__*/_react.default.createElement(_Text.default, null, sendTokenTextRight, /*#__PURE__*/_react.default.createElement("p", {
103
- style: {
104
- color: txTextInRed ? _theme.default.cWarning : 'inherit'
105
- }
106
- }, "We have transfered 0.00002 LBTC to cover your transaction costs."), isKYCVerified ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CryptoAddress.default
109
+ }, error ? error : /*#__PURE__*/_react.default.createElement(_Text.default, null, sendTokenTextRight, transactionCostMessage != null && transactionCostMessage !== false && (/*#__PURE__*/_react.default.isValidElement(transactionCostMessage) ? transactionCostMessage : /*#__PURE__*/_react.default.createElement("p", {
110
+ style: txCostParagraphStyle
111
+ }, transactionCostMessage)), isKYCVerified || !showKYCWarningBox ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CryptoAddress.default
107
112
  //noHead
108
113
  , {
109
114
  title: 'Treasury wallet:',
@@ -117,7 +122,7 @@ const PaymentModal = _ref => {
117
122
  noPaddingHorizontal: true,
118
123
  noPaddingBottom: true
119
124
  }, /*#__PURE__*/_react.default.createElement(_qrcode.QRCodeSVG, {
120
- value: paymentlink,
125
+ value: resolvedPaymentLink,
121
126
  size: 150
122
127
  }))) : /*#__PURE__*/_react.default.createElement("div", {
123
128
  style: {
@@ -140,7 +145,7 @@ const PaymentModal = _ref => {
140
145
  noPaddingHorizontal: true,
141
146
  noPaddingBottom: true
142
147
  }, /*#__PURE__*/_react.default.createElement(_qrcode.QRCodeSVG, {
143
- value: paymentlink,
148
+ value: resolvedPaymentLink,
144
149
  size: 150
145
150
  })))), additionalInfoRight && additionalInfoRight)))))));
146
151
  };
package/dist/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { initFirebase } from "./firebase-config.js";
1
+ import { isValidFirebaseConfig, initFirebase } from "./firebase-config.js";
2
2
  import axiosInstance from "./model/axios.js";
3
3
  import axiosInstance$1 from "./model/axiosPublic.js";
4
4
  import { assignRuntimeConfig } from "./runtime-config.js";
@@ -12,9 +12,14 @@ function configure(config = {}) {
12
12
  if (config.baseUrlPublic != null) {
13
13
  axiosInstance$1.defaults.baseURL = config.baseUrlPublic;
14
14
  }
15
- if (config.firebase) {
16
- _lastFirebaseConfig = config.firebase;
17
- initFirebase(config.firebase);
15
+ if (Object.prototype.hasOwnProperty.call(config, "firebase")) {
16
+ const fb = config.firebase;
17
+ if (fb != null && isValidFirebaseConfig(fb)) {
18
+ _lastFirebaseConfig = fb;
19
+ initFirebase(fb);
20
+ } else {
21
+ _lastFirebaseConfig = null;
22
+ }
18
23
  }
19
24
  }
20
25
  function getLastFirebaseConfig() {
@@ -1,4 +1,3 @@
1
- import { resolveAppHref } from "./resolve-app-href.js";
2
1
  function pathnameIfSameOrigin(absoluteHref) {
3
2
  if (typeof window === "undefined" || !absoluteHref) return null;
4
3
  try {
@@ -10,16 +9,6 @@ function pathnameIfSameOrigin(absoluteHref) {
10
9
  }
11
10
  return null;
12
11
  }
13
- function navigateApp(navigate, surface, relativePath = "") {
14
- const href = resolveAppHref(surface, relativePath);
15
- if (!href) return;
16
- const internal = pathnameIfSameOrigin(href);
17
- if (internal != null && typeof navigate === "function") {
18
- navigate(internal);
19
- return;
20
- }
21
- window.location.assign(href);
22
- }
23
12
  function navigateToHref(navigate, href) {
24
13
  if (!href) return;
25
14
  const internal = pathnameIfSameOrigin(href);
@@ -30,7 +19,6 @@ function navigateToHref(navigate, href) {
30
19
  window.location.assign(href);
31
20
  }
32
21
  export {
33
- navigateApp,
34
22
  navigateToHref,
35
23
  pathnameIfSameOrigin
36
24
  };
@@ -6,8 +6,10 @@ const ENV_KEY_BY_CONFIG = {
6
6
  cookieDomain: "VITE_COOKIE_DOMAIN",
7
7
  websiteDomain: "VITE_WEBSITE_DOMAIN",
8
8
  photoApiUrl: "VITE_PHOTO_API_URL",
9
- /** `'path'` = single-origin URLs (`https://DOMAIN/dashboard`, …). Anything else = legacy subdomains (`dashboard.`, `signup.`, …). */
10
- routingMode: "VITE_ROUTING_MODE"
9
+ onboardingUrl: "VITE_ONBOARDING_URL",
10
+ dashboardUrl: "VITE_DASHBOARD_URL",
11
+ adminUrl: "VITE_ADMIN_URL",
12
+ registerUrl: "VITE_REGISTER_URL"
11
13
  };
12
14
  const FIREBASE_ENV_VARS = [
13
15
  "VITE_FIREBASE_API_KEY",
@@ -77,18 +79,20 @@ function getConfig(key) {
77
79
  if (key === "firebase") {
78
80
  return _overrides.firebase ?? buildFirebaseConfigFromEnv();
79
81
  }
80
- if (key === "appUrlPaths") {
81
- return _overrides.appUrlPaths;
82
- }
83
82
  const envName = ENV_KEY_BY_CONFIG[key];
84
83
  if (envName) {
85
84
  return _overrides[key] ?? env(envName);
86
85
  }
87
86
  return _overrides[key];
88
87
  }
88
+ function getPlatformURL() {
89
+ const domain = getConfig("websiteDomain");
90
+ return domain ? `https://${domain}` : "";
91
+ }
89
92
  export {
90
93
  assignRuntimeConfig,
91
94
  getConfig,
92
95
  getMissingRuntimeEnvVarNames,
96
+ getPlatformURL,
93
97
  resetRuntimeConfig
94
98
  };
@@ -1,28 +1,10 @@
1
- import { AppSurface } from "../routing/app-routes.js";
2
- import { AppRoute } from "../routing/app-routes.js";
3
- import { resolveAppHref } from "../routing/resolve-app-href.js";
4
- import { SURFACE_ROUTING_PATH_KEYS, getAppPublicOrigin, isAlreadyOnOnboardingFlow, isPathBasedRouting, isPathForSurface } from "../routing/resolve-app-href.js";
5
- const getOnboardingAppBaseUrl = () => resolveAppHref(AppSurface.ONBOARDING, "");
6
- const buildOnboardingUrl = (path = "") => resolveAppHref(AppSurface.ONBOARDING, path);
7
- const getDashboardBaseUrl = () => resolveAppHref(AppSurface.DASHBOARD, "");
8
- const buildDashboardUrl = (path = "") => resolveAppHref(AppSurface.DASHBOARD, path);
9
- const getAdminAppUrl = () => resolveAppHref(AppSurface.ADMIN, "");
10
- const getInvestorAppOrigin = () => resolveAppHref(AppSurface.INVESTOR_ROOT, "");
11
- const getRegisterEntryUrl = () => resolveAppHref(AppSurface.REGISTER, "");
1
+ import { getConfig } from "../runtime-config.js";
2
+ function isAlreadyOnOnboardingFlow() {
3
+ if (typeof window === "undefined") return false;
4
+ const onboardingUrl = getConfig("onboardingUrl");
5
+ if (onboardingUrl) return window.location.href.startsWith(onboardingUrl);
6
+ return window.location.hostname.startsWith("signup.");
7
+ }
12
8
  export {
13
- AppRoute,
14
- AppSurface,
15
- SURFACE_ROUTING_PATH_KEYS,
16
- buildDashboardUrl,
17
- buildOnboardingUrl,
18
- getAdminAppUrl,
19
- getAppPublicOrigin,
20
- getDashboardBaseUrl,
21
- getInvestorAppOrigin,
22
- getOnboardingAppBaseUrl,
23
- getRegisterEntryUrl,
24
- isAlreadyOnOnboardingFlow,
25
- isPathBasedRouting,
26
- isPathForSurface,
27
- resolveAppHref
9
+ isAlreadyOnOnboardingFlow
28
10
  };
@@ -0,0 +1,10 @@
1
+ function hasLoggedInSession(user) {
2
+ if (user == null || typeof user !== "object") return false;
3
+ if (user._id != null && user._id !== "") return true;
4
+ if (user.uid != null && user.uid !== "") return true;
5
+ if (user.id != null && user.id !== "") return true;
6
+ return false;
7
+ }
8
+ export {
9
+ hasLoggedInSession
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokr/components-library",
3
- "version": "2.3.79",
3
+ "version": "2.3.80",
4
4
  "description": "STOKR - Components Library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,22 +0,0 @@
1
- const AppSurface = Object.freeze({
2
- ONBOARDING: "onboarding",
3
- DASHBOARD: "dashboard",
4
- ADMIN: "admin",
5
- BACKOFFICE: "backoffice",
6
- /** Apex / public app origin (`https://{websiteDomain}`; path mode uses the same base as {@link getPlatformURL}). */
7
- INVESTOR_ROOT: "investorRoot",
8
- /** Register / sign-up entry from login flows. */
9
- REGISTER: "register",
10
- /** Default Mixpanel proxy host (subdomain or path). */
11
- ANALYTICS: "analytics"
12
- });
13
- const AppRoute = Object.freeze({
14
- WELCOME: "/welcome",
15
- RESEND_ACTIVATION: "/resend-activation-email",
16
- CHECKLIST: "/checklist",
17
- OVERVIEW: "/overview"
18
- });
19
- export {
20
- AppRoute,
21
- AppSurface
22
- };
@@ -1,149 +0,0 @@
1
- import { getPlatformURL } from "../constants/globalVariables.js";
2
- import { getConfig } from "../runtime-config.js";
3
- import { AppSurface } from "./app-routes.js";
4
- import { getAnalyticsIngestUrl, getBackofficeAppUrl } from "../utils/app-urls-analytics-backoffice.js";
5
- const DEFAULT_APP_PATHS = {
6
- onboarding: "/signin",
7
- registerEntry: "/signup",
8
- dashboard: "/dashboard",
9
- admin: "/admin"
10
- };
11
- const SURFACE_ROUTING_PATH_KEYS = Object.freeze([
12
- "onboarding",
13
- "dashboard",
14
- "admin",
15
- "registerEntry",
16
- "investorRoot"
17
- ]);
18
- function routingModeRaw() {
19
- const v = getConfig("routingMode");
20
- return typeof v === "string" ? v.trim().toLowerCase() : "";
21
- }
22
- function isPathBasedRouting() {
23
- return routingModeRaw() === "path";
24
- }
25
- function isPathForSurface(pathKey) {
26
- const per = getConfig("surfaceRoutingMode");
27
- if (!per || typeof per !== "object" || Array.isArray(per)) return isPathBasedRouting();
28
- if (!Object.prototype.hasOwnProperty.call(per, pathKey)) return isPathBasedRouting();
29
- const v = per[pathKey];
30
- if (v === "path") return true;
31
- if (v === "subdomain") return false;
32
- return isPathBasedRouting();
33
- }
34
- function mergedPaths() {
35
- const o = getConfig("appUrlPaths");
36
- if (o && typeof o === "object" && !Array.isArray(o)) {
37
- return { ...DEFAULT_APP_PATHS, ...o };
38
- }
39
- return { ...DEFAULT_APP_PATHS };
40
- }
41
- function stripTrailingSlash(s) {
42
- return String(s).replace(/\/+$/, "");
43
- }
44
- function normalizeLeading(path) {
45
- if (path == null || path === "") return "";
46
- const p = String(path);
47
- return p.startsWith("/") ? p : `/${p}`;
48
- }
49
- function isNonEmptyString(v) {
50
- return v != null && String(v).trim() !== "";
51
- }
52
- function trimmedWebsiteDomain() {
53
- const d = getConfig("websiteDomain");
54
- return isNonEmptyString(d) ? String(d).trim() : "";
55
- }
56
- function getAppPublicOrigin() {
57
- const u = getPlatformURL();
58
- if (!isNonEmptyString(u)) return "";
59
- return stripTrailingSlash(String(u).trim());
60
- }
61
- function subdomainOrigin(sub) {
62
- const domain = trimmedWebsiteDomain();
63
- if (!domain) return "";
64
- return `https://${sub}.${domain}`;
65
- }
66
- function surfaceBase(pathKey, legacySubdomain) {
67
- if (isPathForSurface(pathKey)) {
68
- const origin = getAppPublicOrigin();
69
- if (!origin) return "";
70
- const seg = stripTrailingSlash(normalizeLeading(mergedPaths()[pathKey]));
71
- return `${origin}${seg}`;
72
- }
73
- return subdomainOrigin(legacySubdomain);
74
- }
75
- function onboardingBase() {
76
- return surfaceBase("onboarding", "signup");
77
- }
78
- function dashboardBase() {
79
- return surfaceBase("dashboard", "dashboard");
80
- }
81
- function adminBase() {
82
- return surfaceBase("admin", "admin");
83
- }
84
- function investorRootBase() {
85
- if (isPathForSurface("investorRoot")) return getAppPublicOrigin() || "";
86
- const domain = trimmedWebsiteDomain();
87
- if (!domain) return "";
88
- return `https://${domain}`;
89
- }
90
- function registerEntryHref() {
91
- if (isPathForSurface("registerEntry")) {
92
- const origin = getAppPublicOrigin();
93
- if (!origin) return "";
94
- const seg = stripTrailingSlash(normalizeLeading(mergedPaths().registerEntry));
95
- return `${origin}${seg}`;
96
- }
97
- const domain = trimmedWebsiteDomain();
98
- if (!domain) return "";
99
- return `https://${domain}/signup`;
100
- }
101
- function resolveAppHref(surface, relativePath = "") {
102
- let base = "";
103
- switch (surface) {
104
- case AppSurface.ONBOARDING:
105
- base = onboardingBase();
106
- break;
107
- case AppSurface.DASHBOARD:
108
- base = dashboardBase();
109
- break;
110
- case AppSurface.ADMIN:
111
- base = adminBase();
112
- break;
113
- case AppSurface.BACKOFFICE:
114
- base = getBackofficeAppUrl("");
115
- break;
116
- case AppSurface.INVESTOR_ROOT:
117
- base = investorRootBase();
118
- break;
119
- case AppSurface.REGISTER:
120
- return registerEntryHref();
121
- case AppSurface.ANALYTICS:
122
- return getAnalyticsIngestUrl();
123
- default:
124
- return "";
125
- }
126
- const p = normalizeLeading(relativePath);
127
- if (!base) return "";
128
- const root = stripTrailingSlash(base);
129
- return p ? `${root}${p}` : root;
130
- }
131
- function isAlreadyOnOnboardingFlow() {
132
- if (typeof window === "undefined") return false;
133
- const { href, hostname } = window.location;
134
- if (isPathForSurface("onboarding")) {
135
- const base = onboardingBase();
136
- if (base && href.startsWith(base)) return true;
137
- const seg = mergedPaths().onboarding.replace(/^\//, "");
138
- return href.includes(`/${seg}/`) || href.includes(`/${seg}?`) || href.endsWith(`/${seg}`);
139
- }
140
- return Boolean(hostname?.startsWith("signup.") || href.includes("signup."));
141
- }
142
- export {
143
- SURFACE_ROUTING_PATH_KEYS,
144
- getAppPublicOrigin,
145
- isAlreadyOnOnboardingFlow,
146
- isPathBasedRouting,
147
- isPathForSurface,
148
- resolveAppHref
149
- };