@superlogic/spree-pay 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/{CryptoComTab-GL5DOJ2P.js → CryptoComTab-WXKBRJF3.js} +4 -4
- package/build/{CryptoTab-ODXWUOMD.js → CryptoTab-G55XLBX2.js} +7 -10
- package/build/{chunk-HZDR76ZV.js → chunk-H7S3CTS3.js} +1 -1
- package/build/{chunk-PMTKUR3L.js → chunk-QJCZPYQC.js} +5 -4
- package/build/{chunk-NOTIAH6W.js → chunk-RZ43EXC2.js} +451 -13
- package/build/index.cjs +660 -218
- package/build/index.js +10 -13
- package/package.json +5 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Iframe3ds
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QJCZPYQC.js";
|
|
4
4
|
import {
|
|
5
5
|
InfoBanner,
|
|
6
6
|
Legal,
|
|
7
7
|
SlapiPaymentService,
|
|
8
|
+
esm_default,
|
|
8
9
|
logger,
|
|
9
10
|
settlePaymentResult,
|
|
10
11
|
toPaymentError,
|
|
@@ -14,13 +15,12 @@ import {
|
|
|
14
15
|
useSpreePayRegister,
|
|
15
16
|
useSpreePaymentMethod,
|
|
16
17
|
useStaticConfig
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RZ43EXC2.js";
|
|
18
19
|
|
|
19
20
|
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
20
21
|
import { useCallback, useEffect } from "react";
|
|
21
22
|
|
|
22
23
|
// src/hooks/payments/useCryptoComPayment.ts
|
|
23
|
-
import NiceModal from "@ebay/nice-modal-react";
|
|
24
24
|
var cryptoComLogger = logger.child("crypto-com-payment");
|
|
25
25
|
var useCryptoComPayment = () => {
|
|
26
26
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
@@ -47,7 +47,7 @@ var useCryptoComPayment = () => {
|
|
|
47
47
|
let { status } = paymentResData;
|
|
48
48
|
if (paymentResData.redirectUrl) {
|
|
49
49
|
cryptoComLogger.debug("Opening CDC payment redirect", { paymentId: paymentResData.id });
|
|
50
|
-
const paymentIntent = await
|
|
50
|
+
const paymentIntent = await esm_default.show(Iframe3ds, { url: paymentResData.redirectUrl });
|
|
51
51
|
cryptoComLogger.info("CDC payment redirect completed", { paymentIntent });
|
|
52
52
|
if (paymentIntent === "success") {
|
|
53
53
|
cryptoComLogger.debug("Validating CDC payment", { paymentId: paymentResData.id });
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CheckoutButton,
|
|
3
3
|
PointsSwitch,
|
|
4
4
|
cn as cn2
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-H7S3CTS3.js";
|
|
6
6
|
import {
|
|
7
7
|
Dialog,
|
|
8
8
|
DialogContent,
|
|
@@ -11,19 +11,20 @@ import {
|
|
|
11
11
|
InfoBanner,
|
|
12
12
|
SlapiPaymentService,
|
|
13
13
|
cn,
|
|
14
|
+
esm_default,
|
|
14
15
|
logger,
|
|
15
16
|
settlePaymentResult,
|
|
16
17
|
toPaymentError,
|
|
17
18
|
useIsLoggedIn,
|
|
19
|
+
useModal,
|
|
18
20
|
useSpreePayConfig,
|
|
19
21
|
useSpreePayRegister,
|
|
20
22
|
useSpreePaymentMethod
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-RZ43EXC2.js";
|
|
22
24
|
|
|
23
25
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
24
26
|
import { useMemo as useMemo2 } from "react";
|
|
25
27
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
26
|
-
import NiceModal3 from "@ebay/nice-modal-react";
|
|
27
28
|
import { RainbowKitProvider, getDefaultConfig, lightTheme } from "@rainbow-me/rainbowkit";
|
|
28
29
|
import "@rainbow-me/rainbowkit/styles.css";
|
|
29
30
|
import { WagmiProvider } from "wagmi";
|
|
@@ -394,12 +395,8 @@ var Logos = () => {
|
|
|
394
395
|
] });
|
|
395
396
|
};
|
|
396
397
|
|
|
397
|
-
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
398
|
-
import NiceModal2 from "@ebay/nice-modal-react";
|
|
399
|
-
|
|
400
398
|
// src/modals/CryptoSelectModal.tsx
|
|
401
399
|
import { useMemo, useState as useState2 } from "react";
|
|
402
|
-
import NiceModal, { useModal } from "@ebay/nice-modal-react";
|
|
403
400
|
|
|
404
401
|
// ../ui/src/components/input.tsx
|
|
405
402
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -603,7 +600,7 @@ var useBaseTokens = () => {
|
|
|
603
600
|
|
|
604
601
|
// src/modals/CryptoSelectModal.tsx
|
|
605
602
|
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
606
|
-
var CryptoSelectModal =
|
|
603
|
+
var CryptoSelectModal = esm_default.create(() => {
|
|
607
604
|
const modal = useModal();
|
|
608
605
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
609
606
|
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
@@ -714,7 +711,7 @@ CryptoSelectModal.displayName = "CryptoSelectModal";
|
|
|
714
711
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
715
712
|
var SelectCoinButton = () => {
|
|
716
713
|
const openModal = () => {
|
|
717
|
-
|
|
714
|
+
esm_default.show(CryptoSelectModal);
|
|
718
715
|
};
|
|
719
716
|
return /* @__PURE__ */ jsx9(
|
|
720
717
|
"button",
|
|
@@ -817,7 +814,7 @@ var CryptoWrapper = () => {
|
|
|
817
814
|
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
818
815
|
}, [spreePayConfig]);
|
|
819
816
|
if (!isLoggedIn || configIsLoading || !wagmiConfig) return null;
|
|
820
|
-
return /* @__PURE__ */ jsx12(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx12(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx12(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx12(
|
|
817
|
+
return /* @__PURE__ */ jsx12(WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ jsx12(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx12(RainbowKitProvider, { theme: lightTheme({ borderRadius: "large" }), children: /* @__PURE__ */ jsx12(esm_default.Provider, { children: /* @__PURE__ */ jsx12(Crypto, {}) }) }) }) });
|
|
821
818
|
};
|
|
822
819
|
|
|
823
820
|
// src/components/CryptoTab/CryptoTab.tsx
|
|
@@ -2,12 +2,13 @@ import {
|
|
|
2
2
|
Dialog,
|
|
3
3
|
DialogContent,
|
|
4
4
|
DialogDescription,
|
|
5
|
-
DialogTitle
|
|
6
|
-
|
|
5
|
+
DialogTitle,
|
|
6
|
+
esm_default,
|
|
7
|
+
useModal
|
|
8
|
+
} from "./chunk-RZ43EXC2.js";
|
|
7
9
|
|
|
8
10
|
// src/modals/Iframe3ds.tsx
|
|
9
11
|
import { useEffect } from "react";
|
|
10
|
-
import NiceModal, { useModal } from "@ebay/nice-modal-react";
|
|
11
12
|
|
|
12
13
|
// src/services/eventBus.ts
|
|
13
14
|
var emit = (name, detail) => {
|
|
@@ -25,7 +26,7 @@ if (typeof window !== "undefined") {
|
|
|
25
26
|
|
|
26
27
|
// src/modals/Iframe3ds.tsx
|
|
27
28
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
-
var Iframe3ds =
|
|
29
|
+
var Iframe3ds = esm_default.create(({ url }) => {
|
|
29
30
|
const modal = useModal();
|
|
30
31
|
useEffect(() => {
|
|
31
32
|
return bus.on("paymentIntent", (data) => {
|
|
@@ -86,7 +86,7 @@ var settlePaymentResult = (res, fallbackMessage, failureCode = "PAYMENT_ERROR" /
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
// package.json
|
|
89
|
-
var version = "0.5.
|
|
89
|
+
var version = "0.5.4";
|
|
90
90
|
|
|
91
91
|
// src/utils/logger.ts
|
|
92
92
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
@@ -215,7 +215,7 @@ var SpreePayProvider = ({ children, env }) => {
|
|
|
215
215
|
method: null
|
|
216
216
|
});
|
|
217
217
|
const [isInternalProcessing, setInternalProcessing] = useState(false);
|
|
218
|
-
const
|
|
218
|
+
const register2 = useCallback((fn) => {
|
|
219
219
|
processRef.current = fn;
|
|
220
220
|
}, []);
|
|
221
221
|
const process = useCallback(
|
|
@@ -268,7 +268,7 @@ var SpreePayProvider = ({ children, env }) => {
|
|
|
268
268
|
enabled: Boolean(selectedPaymentMethod.method),
|
|
269
269
|
isInternalProcessing,
|
|
270
270
|
process,
|
|
271
|
-
register,
|
|
271
|
+
register: register2,
|
|
272
272
|
selectedPaymentMethod,
|
|
273
273
|
setSelectedPaymentMethod
|
|
274
274
|
};
|
|
@@ -304,8 +304,444 @@ var useSpreePayRegister = () => {
|
|
|
304
304
|
return { register: ctx.register };
|
|
305
305
|
};
|
|
306
306
|
|
|
307
|
+
// ../../node_modules/@ebay/nice-modal-react/lib/esm/index.js
|
|
308
|
+
import React, { useEffect, useCallback as useCallback2, useContext as useContext2, useReducer, useMemo } from "react";
|
|
309
|
+
var __assign = function() {
|
|
310
|
+
__assign = Object.assign || function(t) {
|
|
311
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
312
|
+
s = arguments[i];
|
|
313
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
314
|
+
t[p] = s[p];
|
|
315
|
+
}
|
|
316
|
+
return t;
|
|
317
|
+
};
|
|
318
|
+
return __assign.apply(this, arguments);
|
|
319
|
+
};
|
|
320
|
+
var __rest = function(s, e) {
|
|
321
|
+
var t = {};
|
|
322
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
323
|
+
t[p] = s[p];
|
|
324
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
325
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
326
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
327
|
+
t[p[i]] = s[p[i]];
|
|
328
|
+
}
|
|
329
|
+
return t;
|
|
330
|
+
};
|
|
331
|
+
var symModalId = /* @__PURE__ */ Symbol("NiceModalId");
|
|
332
|
+
var initialState = {};
|
|
333
|
+
var NiceModalContext = React.createContext(initialState);
|
|
334
|
+
var NiceModalIdContext = React.createContext(null);
|
|
335
|
+
var MODAL_REGISTRY = {};
|
|
336
|
+
var ALREADY_MOUNTED = {};
|
|
337
|
+
var uidSeed = 0;
|
|
338
|
+
var dispatch = function() {
|
|
339
|
+
throw new Error("No dispatch method detected, did you embed your app with NiceModal.Provider?");
|
|
340
|
+
};
|
|
341
|
+
var getUid = function() {
|
|
342
|
+
return "_nice_modal_" + uidSeed++;
|
|
343
|
+
};
|
|
344
|
+
var reducer = function(state, action) {
|
|
345
|
+
var _a, _b, _c;
|
|
346
|
+
if (state === void 0) {
|
|
347
|
+
state = initialState;
|
|
348
|
+
}
|
|
349
|
+
switch (action.type) {
|
|
350
|
+
case "nice-modal/show": {
|
|
351
|
+
var _d = action.payload, modalId = _d.modalId, args = _d.args;
|
|
352
|
+
return __assign(__assign({}, state), (_a = {}, _a[modalId] = __assign(__assign({}, state[modalId]), {
|
|
353
|
+
id: modalId,
|
|
354
|
+
args,
|
|
355
|
+
// If modal is not mounted, mount it first then make it visible.
|
|
356
|
+
// There is logic inside HOC wrapper to make it visible after its first mount.
|
|
357
|
+
// This mechanism ensures the entering transition.
|
|
358
|
+
visible: !!ALREADY_MOUNTED[modalId],
|
|
359
|
+
delayVisible: !ALREADY_MOUNTED[modalId]
|
|
360
|
+
}), _a));
|
|
361
|
+
}
|
|
362
|
+
case "nice-modal/hide": {
|
|
363
|
+
var modalId = action.payload.modalId;
|
|
364
|
+
if (!state[modalId])
|
|
365
|
+
return state;
|
|
366
|
+
return __assign(__assign({}, state), (_b = {}, _b[modalId] = __assign(__assign({}, state[modalId]), { visible: false }), _b));
|
|
367
|
+
}
|
|
368
|
+
case "nice-modal/remove": {
|
|
369
|
+
var modalId = action.payload.modalId;
|
|
370
|
+
var newState = __assign({}, state);
|
|
371
|
+
delete newState[modalId];
|
|
372
|
+
return newState;
|
|
373
|
+
}
|
|
374
|
+
case "nice-modal/set-flags": {
|
|
375
|
+
var _e = action.payload, modalId = _e.modalId, flags = _e.flags;
|
|
376
|
+
return __assign(__assign({}, state), (_c = {}, _c[modalId] = __assign(__assign({}, state[modalId]), flags), _c));
|
|
377
|
+
}
|
|
378
|
+
default:
|
|
379
|
+
return state;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
function getModal(modalId) {
|
|
383
|
+
var _a;
|
|
384
|
+
return (_a = MODAL_REGISTRY[modalId]) === null || _a === void 0 ? void 0 : _a.comp;
|
|
385
|
+
}
|
|
386
|
+
function showModal(modalId, args) {
|
|
387
|
+
return {
|
|
388
|
+
type: "nice-modal/show",
|
|
389
|
+
payload: {
|
|
390
|
+
modalId,
|
|
391
|
+
args
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function setModalFlags(modalId, flags) {
|
|
396
|
+
return {
|
|
397
|
+
type: "nice-modal/set-flags",
|
|
398
|
+
payload: {
|
|
399
|
+
modalId,
|
|
400
|
+
flags
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function hideModal(modalId) {
|
|
405
|
+
return {
|
|
406
|
+
type: "nice-modal/hide",
|
|
407
|
+
payload: {
|
|
408
|
+
modalId
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function removeModal(modalId) {
|
|
413
|
+
return {
|
|
414
|
+
type: "nice-modal/remove",
|
|
415
|
+
payload: {
|
|
416
|
+
modalId
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
var modalCallbacks = {};
|
|
421
|
+
var hideModalCallbacks = {};
|
|
422
|
+
var getModalId = function(modal) {
|
|
423
|
+
if (typeof modal === "string")
|
|
424
|
+
return modal;
|
|
425
|
+
if (!modal[symModalId]) {
|
|
426
|
+
modal[symModalId] = getUid();
|
|
427
|
+
}
|
|
428
|
+
return modal[symModalId];
|
|
429
|
+
};
|
|
430
|
+
function show(modal, args) {
|
|
431
|
+
var modalId = getModalId(modal);
|
|
432
|
+
if (typeof modal !== "string" && !MODAL_REGISTRY[modalId]) {
|
|
433
|
+
register(modalId, modal);
|
|
434
|
+
}
|
|
435
|
+
dispatch(showModal(modalId, args));
|
|
436
|
+
if (!modalCallbacks[modalId]) {
|
|
437
|
+
var theResolve_1;
|
|
438
|
+
var theReject_1;
|
|
439
|
+
var promise = new Promise(function(resolve, reject) {
|
|
440
|
+
theResolve_1 = resolve;
|
|
441
|
+
theReject_1 = reject;
|
|
442
|
+
});
|
|
443
|
+
modalCallbacks[modalId] = {
|
|
444
|
+
resolve: theResolve_1,
|
|
445
|
+
reject: theReject_1,
|
|
446
|
+
promise
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return modalCallbacks[modalId].promise;
|
|
450
|
+
}
|
|
451
|
+
function hide(modal) {
|
|
452
|
+
var modalId = getModalId(modal);
|
|
453
|
+
dispatch(hideModal(modalId));
|
|
454
|
+
delete modalCallbacks[modalId];
|
|
455
|
+
if (!hideModalCallbacks[modalId]) {
|
|
456
|
+
var theResolve_2;
|
|
457
|
+
var theReject_2;
|
|
458
|
+
var promise = new Promise(function(resolve, reject) {
|
|
459
|
+
theResolve_2 = resolve;
|
|
460
|
+
theReject_2 = reject;
|
|
461
|
+
});
|
|
462
|
+
hideModalCallbacks[modalId] = {
|
|
463
|
+
resolve: theResolve_2,
|
|
464
|
+
reject: theReject_2,
|
|
465
|
+
promise
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
return hideModalCallbacks[modalId].promise;
|
|
469
|
+
}
|
|
470
|
+
var remove = function(modal) {
|
|
471
|
+
var modalId = getModalId(modal);
|
|
472
|
+
dispatch(removeModal(modalId));
|
|
473
|
+
delete modalCallbacks[modalId];
|
|
474
|
+
delete hideModalCallbacks[modalId];
|
|
475
|
+
};
|
|
476
|
+
var setFlags = function(modalId, flags) {
|
|
477
|
+
dispatch(setModalFlags(modalId, flags));
|
|
478
|
+
};
|
|
479
|
+
function useModal(modal, args) {
|
|
480
|
+
var modals = useContext2(NiceModalContext);
|
|
481
|
+
var contextModalId = useContext2(NiceModalIdContext);
|
|
482
|
+
var modalId = null;
|
|
483
|
+
var isUseComponent = modal && typeof modal !== "string";
|
|
484
|
+
if (!modal) {
|
|
485
|
+
modalId = contextModalId;
|
|
486
|
+
} else {
|
|
487
|
+
modalId = getModalId(modal);
|
|
488
|
+
}
|
|
489
|
+
if (!modalId)
|
|
490
|
+
throw new Error("No modal id found in NiceModal.useModal.");
|
|
491
|
+
var mid = modalId;
|
|
492
|
+
useEffect(function() {
|
|
493
|
+
if (isUseComponent && !MODAL_REGISTRY[mid]) {
|
|
494
|
+
register(mid, modal, args);
|
|
495
|
+
}
|
|
496
|
+
}, [isUseComponent, mid, modal, args]);
|
|
497
|
+
var modalInfo = modals[mid];
|
|
498
|
+
var showCallback = useCallback2(function(args2) {
|
|
499
|
+
return show(mid, args2);
|
|
500
|
+
}, [mid]);
|
|
501
|
+
var hideCallback = useCallback2(function() {
|
|
502
|
+
return hide(mid);
|
|
503
|
+
}, [mid]);
|
|
504
|
+
var removeCallback = useCallback2(function() {
|
|
505
|
+
return remove(mid);
|
|
506
|
+
}, [mid]);
|
|
507
|
+
var resolveCallback = useCallback2(function(args2) {
|
|
508
|
+
var _a;
|
|
509
|
+
(_a = modalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.resolve(args2);
|
|
510
|
+
delete modalCallbacks[mid];
|
|
511
|
+
}, [mid]);
|
|
512
|
+
var rejectCallback = useCallback2(function(args2) {
|
|
513
|
+
var _a;
|
|
514
|
+
(_a = modalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.reject(args2);
|
|
515
|
+
delete modalCallbacks[mid];
|
|
516
|
+
}, [mid]);
|
|
517
|
+
var resolveHide = useCallback2(function(args2) {
|
|
518
|
+
var _a;
|
|
519
|
+
(_a = hideModalCallbacks[mid]) === null || _a === void 0 ? void 0 : _a.resolve(args2);
|
|
520
|
+
delete hideModalCallbacks[mid];
|
|
521
|
+
}, [mid]);
|
|
522
|
+
return useMemo(function() {
|
|
523
|
+
return {
|
|
524
|
+
id: mid,
|
|
525
|
+
args: modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args,
|
|
526
|
+
visible: !!(modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible),
|
|
527
|
+
keepMounted: !!(modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.keepMounted),
|
|
528
|
+
show: showCallback,
|
|
529
|
+
hide: hideCallback,
|
|
530
|
+
remove: removeCallback,
|
|
531
|
+
resolve: resolveCallback,
|
|
532
|
+
reject: rejectCallback,
|
|
533
|
+
resolveHide
|
|
534
|
+
};
|
|
535
|
+
}, [
|
|
536
|
+
mid,
|
|
537
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.args,
|
|
538
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.visible,
|
|
539
|
+
modalInfo === null || modalInfo === void 0 ? void 0 : modalInfo.keepMounted,
|
|
540
|
+
showCallback,
|
|
541
|
+
hideCallback,
|
|
542
|
+
removeCallback,
|
|
543
|
+
resolveCallback,
|
|
544
|
+
rejectCallback,
|
|
545
|
+
resolveHide
|
|
546
|
+
]);
|
|
547
|
+
}
|
|
548
|
+
var create = function(Comp) {
|
|
549
|
+
return function(_a) {
|
|
550
|
+
var _b;
|
|
551
|
+
var defaultVisible = _a.defaultVisible, keepMounted = _a.keepMounted, id = _a.id, props = __rest(_a, ["defaultVisible", "keepMounted", "id"]);
|
|
552
|
+
var _c = useModal(id), args = _c.args, show2 = _c.show;
|
|
553
|
+
var modals = useContext2(NiceModalContext);
|
|
554
|
+
var shouldMount = !!modals[id];
|
|
555
|
+
useEffect(function() {
|
|
556
|
+
if (defaultVisible) {
|
|
557
|
+
show2();
|
|
558
|
+
}
|
|
559
|
+
ALREADY_MOUNTED[id] = true;
|
|
560
|
+
return function() {
|
|
561
|
+
delete ALREADY_MOUNTED[id];
|
|
562
|
+
};
|
|
563
|
+
}, [id, show2, defaultVisible]);
|
|
564
|
+
useEffect(function() {
|
|
565
|
+
if (keepMounted)
|
|
566
|
+
setFlags(id, { keepMounted: true });
|
|
567
|
+
}, [id, keepMounted]);
|
|
568
|
+
var delayVisible = (_b = modals[id]) === null || _b === void 0 ? void 0 : _b.delayVisible;
|
|
569
|
+
useEffect(function() {
|
|
570
|
+
if (delayVisible) {
|
|
571
|
+
show2(args);
|
|
572
|
+
}
|
|
573
|
+
}, [delayVisible, args, show2]);
|
|
574
|
+
if (!shouldMount)
|
|
575
|
+
return null;
|
|
576
|
+
return React.createElement(
|
|
577
|
+
NiceModalIdContext.Provider,
|
|
578
|
+
{ value: id },
|
|
579
|
+
React.createElement(Comp, __assign({}, props, args))
|
|
580
|
+
);
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
var register = function(id, comp, props) {
|
|
584
|
+
if (!MODAL_REGISTRY[id]) {
|
|
585
|
+
MODAL_REGISTRY[id] = { comp, props };
|
|
586
|
+
} else {
|
|
587
|
+
MODAL_REGISTRY[id].props = props;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
var unregister = function(id) {
|
|
591
|
+
delete MODAL_REGISTRY[id];
|
|
592
|
+
};
|
|
593
|
+
var NiceModalPlaceholder = function() {
|
|
594
|
+
var modals = useContext2(NiceModalContext);
|
|
595
|
+
var visibleModalIds = Object.keys(modals).filter(function(id) {
|
|
596
|
+
return !!modals[id];
|
|
597
|
+
});
|
|
598
|
+
visibleModalIds.forEach(function(id) {
|
|
599
|
+
if (!MODAL_REGISTRY[id] && !ALREADY_MOUNTED[id]) {
|
|
600
|
+
console.warn("No modal found for id: " + id + ". Please check the id or if it is registered or declared via JSX.");
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
var toRender = visibleModalIds.filter(function(id) {
|
|
605
|
+
return MODAL_REGISTRY[id];
|
|
606
|
+
}).map(function(id) {
|
|
607
|
+
return __assign({ id }, MODAL_REGISTRY[id]);
|
|
608
|
+
});
|
|
609
|
+
return React.createElement(React.Fragment, null, toRender.map(function(t) {
|
|
610
|
+
return React.createElement(t.comp, __assign({ key: t.id, id: t.id }, t.props));
|
|
611
|
+
}));
|
|
612
|
+
};
|
|
613
|
+
var InnerContextProvider = function(_a) {
|
|
614
|
+
var children = _a.children;
|
|
615
|
+
var arr = useReducer(reducer, initialState);
|
|
616
|
+
var modals = arr[0];
|
|
617
|
+
dispatch = arr[1];
|
|
618
|
+
return React.createElement(
|
|
619
|
+
NiceModalContext.Provider,
|
|
620
|
+
{ value: modals },
|
|
621
|
+
children,
|
|
622
|
+
React.createElement(NiceModalPlaceholder, null)
|
|
623
|
+
);
|
|
624
|
+
};
|
|
625
|
+
var Provider = function(_a) {
|
|
626
|
+
var children = _a.children, givenDispatch = _a.dispatch, givenModals = _a.modals;
|
|
627
|
+
if (!givenDispatch || !givenModals) {
|
|
628
|
+
return React.createElement(InnerContextProvider, null, children);
|
|
629
|
+
}
|
|
630
|
+
dispatch = givenDispatch;
|
|
631
|
+
return React.createElement(
|
|
632
|
+
NiceModalContext.Provider,
|
|
633
|
+
{ value: givenModals },
|
|
634
|
+
children,
|
|
635
|
+
React.createElement(NiceModalPlaceholder, null)
|
|
636
|
+
);
|
|
637
|
+
};
|
|
638
|
+
var ModalDef = function(_a) {
|
|
639
|
+
var id = _a.id, component = _a.component;
|
|
640
|
+
useEffect(function() {
|
|
641
|
+
register(id, component);
|
|
642
|
+
return function() {
|
|
643
|
+
unregister(id);
|
|
644
|
+
};
|
|
645
|
+
}, [id, component]);
|
|
646
|
+
return null;
|
|
647
|
+
};
|
|
648
|
+
var ModalHolder = function(_a) {
|
|
649
|
+
var _b;
|
|
650
|
+
var modal = _a.modal, _c = _a.handler, handler = _c === void 0 ? {} : _c, restProps = __rest(_a, ["modal", "handler"]);
|
|
651
|
+
var mid = useMemo(function() {
|
|
652
|
+
return getUid();
|
|
653
|
+
}, []);
|
|
654
|
+
var ModalComp = typeof modal === "string" ? (_b = MODAL_REGISTRY[modal]) === null || _b === void 0 ? void 0 : _b.comp : modal;
|
|
655
|
+
if (!handler) {
|
|
656
|
+
throw new Error("No handler found in NiceModal.ModalHolder.");
|
|
657
|
+
}
|
|
658
|
+
if (!ModalComp) {
|
|
659
|
+
throw new Error("No modal found for id: " + modal + " in NiceModal.ModalHolder.");
|
|
660
|
+
}
|
|
661
|
+
handler.show = useCallback2(function(args) {
|
|
662
|
+
return show(mid, args);
|
|
663
|
+
}, [mid]);
|
|
664
|
+
handler.hide = useCallback2(function() {
|
|
665
|
+
return hide(mid);
|
|
666
|
+
}, [mid]);
|
|
667
|
+
return React.createElement(ModalComp, __assign({ id: mid }, restProps));
|
|
668
|
+
};
|
|
669
|
+
var antdModal = function(modal) {
|
|
670
|
+
return {
|
|
671
|
+
visible: modal.visible,
|
|
672
|
+
onOk: function() {
|
|
673
|
+
return modal.hide();
|
|
674
|
+
},
|
|
675
|
+
onCancel: function() {
|
|
676
|
+
return modal.hide();
|
|
677
|
+
},
|
|
678
|
+
afterClose: function() {
|
|
679
|
+
modal.resolveHide();
|
|
680
|
+
if (!modal.keepMounted)
|
|
681
|
+
modal.remove();
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
var antdDrawer = function(modal) {
|
|
686
|
+
return {
|
|
687
|
+
visible: modal.visible,
|
|
688
|
+
onClose: function() {
|
|
689
|
+
return modal.hide();
|
|
690
|
+
},
|
|
691
|
+
afterVisibleChange: function(v) {
|
|
692
|
+
if (!v) {
|
|
693
|
+
modal.resolveHide();
|
|
694
|
+
}
|
|
695
|
+
!v && !modal.keepMounted && modal.remove();
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
var muiDialog = function(modal) {
|
|
700
|
+
return {
|
|
701
|
+
open: modal.visible,
|
|
702
|
+
onClose: function() {
|
|
703
|
+
return modal.hide();
|
|
704
|
+
},
|
|
705
|
+
onExited: function() {
|
|
706
|
+
modal.resolveHide();
|
|
707
|
+
!modal.keepMounted && modal.remove();
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
var bootstrapDialog = function(modal) {
|
|
712
|
+
return {
|
|
713
|
+
show: modal.visible,
|
|
714
|
+
onHide: function() {
|
|
715
|
+
return modal.hide();
|
|
716
|
+
},
|
|
717
|
+
onExited: function() {
|
|
718
|
+
modal.resolveHide();
|
|
719
|
+
!modal.keepMounted && modal.remove();
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
var NiceModal = {
|
|
724
|
+
Provider,
|
|
725
|
+
ModalDef,
|
|
726
|
+
ModalHolder,
|
|
727
|
+
NiceModalContext,
|
|
728
|
+
create,
|
|
729
|
+
register,
|
|
730
|
+
getModal,
|
|
731
|
+
show,
|
|
732
|
+
hide,
|
|
733
|
+
remove,
|
|
734
|
+
useModal,
|
|
735
|
+
reducer,
|
|
736
|
+
antdModal,
|
|
737
|
+
antdDrawer,
|
|
738
|
+
muiDialog,
|
|
739
|
+
bootstrapDialog
|
|
740
|
+
};
|
|
741
|
+
var esm_default = NiceModal;
|
|
742
|
+
|
|
307
743
|
// src/context/StaticConfigContext.tsx
|
|
308
|
-
import { createContext as createContext2, useContext as
|
|
744
|
+
import { createContext as createContext2, useContext as useContext3, useMemo as useMemo2 } from "react";
|
|
309
745
|
|
|
310
746
|
// src/context/config.ts
|
|
311
747
|
var config = {
|
|
@@ -394,7 +830,7 @@ import { jsx as jsx2 } from "react/jsx-runtime";
|
|
|
394
830
|
var StaticConfigContext = createContext2(null);
|
|
395
831
|
var StaticConfigProvider = ({ children, props }) => {
|
|
396
832
|
const { environment, tenantId } = useSpreePayEnv();
|
|
397
|
-
const staticConfig =
|
|
833
|
+
const staticConfig = useMemo2(() => {
|
|
398
834
|
const envConfig = config[environment];
|
|
399
835
|
const isKnownTenant = tenantId in envConfig;
|
|
400
836
|
if (!isKnownTenant) {
|
|
@@ -406,11 +842,11 @@ var StaticConfigProvider = ({ children, props }) => {
|
|
|
406
842
|
const appKey = isKnownTenant ? tenantId : "moca";
|
|
407
843
|
return envConfig[appKey];
|
|
408
844
|
}, [environment, tenantId]);
|
|
409
|
-
const value =
|
|
845
|
+
const value = useMemo2(() => ({ staticConfig, appProps: props }), [staticConfig, props]);
|
|
410
846
|
return /* @__PURE__ */ jsx2(StaticConfigContext.Provider, { value, children });
|
|
411
847
|
};
|
|
412
848
|
var useStaticConfig = () => {
|
|
413
|
-
const ctx =
|
|
849
|
+
const ctx = useContext3(StaticConfigContext);
|
|
414
850
|
if (!ctx) throw new Error("useStaticConfig must be used within StaticConfigProvider");
|
|
415
851
|
return ctx;
|
|
416
852
|
};
|
|
@@ -423,16 +859,16 @@ function cn(...inputs) {
|
|
|
423
859
|
}
|
|
424
860
|
|
|
425
861
|
// src/ui/portal.ts
|
|
426
|
-
import
|
|
427
|
-
var PortalContainerContext =
|
|
862
|
+
import React2 from "react";
|
|
863
|
+
var PortalContainerContext = React2.createContext({ container: null });
|
|
428
864
|
function PortalContainerProvider({
|
|
429
865
|
container,
|
|
430
866
|
children
|
|
431
867
|
}) {
|
|
432
|
-
return
|
|
868
|
+
return React2.createElement(PortalContainerContext.Provider, { value: { container } }, children);
|
|
433
869
|
}
|
|
434
870
|
function usePortalContainer() {
|
|
435
|
-
return
|
|
871
|
+
return React2.useContext(PortalContainerContext).container;
|
|
436
872
|
}
|
|
437
873
|
|
|
438
874
|
// src/fetcher/client.ts
|
|
@@ -558,11 +994,11 @@ var useSpreePayConfig = () => {
|
|
|
558
994
|
};
|
|
559
995
|
|
|
560
996
|
// src/context/LoginStatusContext.tsx
|
|
561
|
-
import { createContext as createContext3, useContext as
|
|
997
|
+
import { createContext as createContext3, useContext as useContext4 } from "react";
|
|
562
998
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
563
999
|
var LoginStatusContext = createContext3(false);
|
|
564
1000
|
var LoginStatusProvider = ({ isLoggedIn, children }) => /* @__PURE__ */ jsx3(LoginStatusContext.Provider, { value: isLoggedIn, children });
|
|
565
|
-
var useIsLoggedIn = () =>
|
|
1001
|
+
var useIsLoggedIn = () => useContext4(LoginStatusContext);
|
|
566
1002
|
|
|
567
1003
|
// src/components/common/InfoBanner.tsx
|
|
568
1004
|
import xss from "xss";
|
|
@@ -867,6 +1303,8 @@ function DialogDescription({ className, ...props }) {
|
|
|
867
1303
|
}
|
|
868
1304
|
|
|
869
1305
|
export {
|
|
1306
|
+
useModal,
|
|
1307
|
+
esm_default,
|
|
870
1308
|
isNewCard,
|
|
871
1309
|
PaymentType,
|
|
872
1310
|
PaymentStatus,
|