@openreceive/react 0.2.2 → 0.2.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/dist/index.d.ts +28 -2
- package/dist/index.js +229 -214
- package/dist/styles.css +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -447,17 +447,106 @@ function SatsDetail(props) {
|
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
449
|
|
|
450
|
-
// src/
|
|
450
|
+
// src/transaction-details.ts
|
|
451
|
+
import {
|
|
452
|
+
checkoutLabels as checkoutLabels2,
|
|
453
|
+
orClasses as orClasses2,
|
|
454
|
+
resolveTransactionDetailRows
|
|
455
|
+
} from "@openreceive/browser/headless";
|
|
451
456
|
import * as React4 from "react";
|
|
457
|
+
function TransactionDetails(props) {
|
|
458
|
+
const rows = resolveTransactionDetailRows(props.state);
|
|
459
|
+
if (rows.length === 0) return null;
|
|
460
|
+
return React4.createElement(
|
|
461
|
+
"details",
|
|
462
|
+
{
|
|
463
|
+
className: joinClassNames(orClasses2.transactionDetails, props.className),
|
|
464
|
+
open: props.open === true ? true : void 0
|
|
465
|
+
},
|
|
466
|
+
React4.createElement(
|
|
467
|
+
"summary",
|
|
468
|
+
{ className: orClasses2.transactionDetailsTitle },
|
|
469
|
+
checkoutLabels2.transactionDetails
|
|
470
|
+
),
|
|
471
|
+
React4.createElement(
|
|
472
|
+
"div",
|
|
473
|
+
{ className: orClasses2.transactionDetailsContent },
|
|
474
|
+
React4.createElement(
|
|
475
|
+
"dl",
|
|
476
|
+
{ className: orClasses2.swapDetails },
|
|
477
|
+
rows.flatMap(
|
|
478
|
+
(row) => renderTransactionDetailRow(row, {
|
|
479
|
+
clipboard: props.clipboard,
|
|
480
|
+
onError: props.onError
|
|
481
|
+
})
|
|
482
|
+
)
|
|
483
|
+
)
|
|
484
|
+
)
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
function renderTransactionDetailRow(row, options) {
|
|
488
|
+
const copyValue = row.copyValue ?? row.value;
|
|
489
|
+
return [
|
|
490
|
+
React4.createElement(
|
|
491
|
+
"dt",
|
|
492
|
+
{ key: `${row.label}-label`, className: orClasses2.swapDetailsDt },
|
|
493
|
+
row.label
|
|
494
|
+
),
|
|
495
|
+
React4.createElement(
|
|
496
|
+
"dd",
|
|
497
|
+
{ key: `${row.label}-value`, className: orClasses2.swapDetailsDd },
|
|
498
|
+
React4.createElement("code", { className: orClasses2.swapDetailsCode }, row.value),
|
|
499
|
+
React4.createElement(
|
|
500
|
+
"div",
|
|
501
|
+
{ className: orClasses2.swapDetailsActions },
|
|
502
|
+
React4.createElement(TransactionDetailCopyButton, {
|
|
503
|
+
value: copyValue,
|
|
504
|
+
clipboard: options.clipboard,
|
|
505
|
+
onError: options.onError
|
|
506
|
+
}),
|
|
507
|
+
row.href === void 0 ? null : React4.createElement(
|
|
508
|
+
"a",
|
|
509
|
+
{
|
|
510
|
+
className: orClasses2.swapDetailsLink,
|
|
511
|
+
href: row.href,
|
|
512
|
+
rel: "noreferrer",
|
|
513
|
+
target: "_blank"
|
|
514
|
+
},
|
|
515
|
+
row.hrefLabel ?? checkoutLabels2.viewOnExplorer
|
|
516
|
+
)
|
|
517
|
+
)
|
|
518
|
+
)
|
|
519
|
+
];
|
|
520
|
+
}
|
|
521
|
+
function TransactionDetailCopyButton(props) {
|
|
522
|
+
const [copied, setCopied] = useTransientValue(false);
|
|
523
|
+
const label = copied ? checkoutLabels2.copied : "Copy";
|
|
524
|
+
return React4.createElement(
|
|
525
|
+
"button",
|
|
526
|
+
{
|
|
527
|
+
className: orClasses2.detailCopy,
|
|
528
|
+
type: "button",
|
|
529
|
+
"aria-label": label,
|
|
530
|
+
title: label,
|
|
531
|
+
onClick: () => {
|
|
532
|
+
void copyText(props.value, props.clipboard).then(() => setCopied(true)).catch((error) => props.onError?.(error));
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
React4.createElement(ClipboardIcon)
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/theme.ts
|
|
540
|
+
import * as React5 from "react";
|
|
452
541
|
import {
|
|
453
542
|
OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES as OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES2,
|
|
454
543
|
OPENRECEIVE_THEME_STORAGE_KEY,
|
|
455
544
|
createThemeModel,
|
|
456
|
-
orClasses as
|
|
545
|
+
orClasses as orClasses3,
|
|
457
546
|
readThemePreference,
|
|
458
547
|
writeThemePreference
|
|
459
548
|
} from "@openreceive/browser/headless";
|
|
460
|
-
var ThemeContext =
|
|
549
|
+
var ThemeContext = React5.createContext(null);
|
|
461
550
|
var storedThemeListeners = /* @__PURE__ */ new Set();
|
|
462
551
|
var lastSetTheme = /* @__PURE__ */ new Map();
|
|
463
552
|
function notifyStoredThemeChange() {
|
|
@@ -486,9 +575,9 @@ function useLocalTheme(options = {}) {
|
|
|
486
575
|
const storageKey = options.storageKey ?? OPENRECEIVE_THEME_STORAGE_KEY;
|
|
487
576
|
const storage = options.storage;
|
|
488
577
|
const defaultTheme = options.defaultTheme;
|
|
489
|
-
const theme =
|
|
578
|
+
const theme = React5.useSyncExternalStore(
|
|
490
579
|
subscribeStoredTheme,
|
|
491
|
-
|
|
580
|
+
React5.useCallback(
|
|
492
581
|
() => readThemePreference({
|
|
493
582
|
storage,
|
|
494
583
|
storageKey,
|
|
@@ -496,7 +585,7 @@ function useLocalTheme(options = {}) {
|
|
|
496
585
|
}),
|
|
497
586
|
[storage, storageKey, defaultTheme]
|
|
498
587
|
),
|
|
499
|
-
|
|
588
|
+
React5.useCallback(
|
|
500
589
|
() => (
|
|
501
590
|
// A host-supplied storage is readable on the server (that is how SSR theming is
|
|
502
591
|
// wired); the implicit browser localStorage is not, so fall back to the default.
|
|
@@ -505,13 +594,13 @@ function useLocalTheme(options = {}) {
|
|
|
505
594
|
[storage, storageKey, defaultTheme]
|
|
506
595
|
)
|
|
507
596
|
);
|
|
508
|
-
const systemDark =
|
|
597
|
+
const systemDark = React5.useSyncExternalStore(
|
|
509
598
|
subscribeSystemDark,
|
|
510
599
|
getSystemDark,
|
|
511
600
|
getServerSystemDark
|
|
512
601
|
);
|
|
513
602
|
const themeModel = createThemeModel(theme, { systemDark });
|
|
514
|
-
const setTheme =
|
|
603
|
+
const setTheme = React5.useCallback(
|
|
515
604
|
(nextTheme) => {
|
|
516
605
|
lastSetTheme.set(storageKey, nextTheme);
|
|
517
606
|
writeThemePreference(nextTheme, {
|
|
@@ -522,7 +611,7 @@ function useLocalTheme(options = {}) {
|
|
|
522
611
|
},
|
|
523
612
|
[storage, storageKey]
|
|
524
613
|
);
|
|
525
|
-
const toggleTheme =
|
|
614
|
+
const toggleTheme = React5.useCallback(() => {
|
|
526
615
|
setTheme(themeModel.nextTheme);
|
|
527
616
|
}, [setTheme, themeModel.nextTheme]);
|
|
528
617
|
return {
|
|
@@ -539,7 +628,7 @@ function useLocalTheme(options = {}) {
|
|
|
539
628
|
};
|
|
540
629
|
}
|
|
541
630
|
function useTheme(options = {}) {
|
|
542
|
-
const scoped =
|
|
631
|
+
const scoped = React5.useContext(ThemeContext);
|
|
543
632
|
const local = useLocalTheme(options);
|
|
544
633
|
const storageKey = options.storageKey ?? OPENRECEIVE_THEME_STORAGE_KEY;
|
|
545
634
|
if (scoped !== null && options.storage === void 0 && (options.storageKey === void 0 || options.storageKey === storageKey) && options.defaultTheme === void 0) {
|
|
@@ -566,7 +655,7 @@ function ThemeToggle(props) {
|
|
|
566
655
|
const componentProps = {
|
|
567
656
|
...buttonProps,
|
|
568
657
|
"aria-label": themeModel.toggleLabel,
|
|
569
|
-
className: joinClassNames(
|
|
658
|
+
className: joinClassNames(orClasses3.themeToggle, buttonProps.className),
|
|
570
659
|
title: themeModel.toggleLabel,
|
|
571
660
|
type,
|
|
572
661
|
[OPENRECEIVE_CHECKOUT_DATA_ATTRIBUTES2.themeToggle]: "",
|
|
@@ -577,7 +666,7 @@ function ThemeToggle(props) {
|
|
|
577
666
|
if (onThemeChange === void 0) fallback.setTheme(themeModel.nextTheme);
|
|
578
667
|
}
|
|
579
668
|
};
|
|
580
|
-
return
|
|
669
|
+
return React5.createElement(ButtonComponent, componentProps, children ?? themeModel.toggleLabel);
|
|
581
670
|
}
|
|
582
671
|
function ThemeScope(props) {
|
|
583
672
|
const {
|
|
@@ -598,22 +687,22 @@ function ThemeScope(props) {
|
|
|
598
687
|
storage
|
|
599
688
|
});
|
|
600
689
|
const scopedChildren = typeof children === "function" ? children(theme) : children;
|
|
601
|
-
return
|
|
690
|
+
return React5.createElement(
|
|
602
691
|
ThemeContext.Provider,
|
|
603
692
|
{ value: theme },
|
|
604
693
|
// Variadic children, not an array: an array child needs a key on every entry.
|
|
605
|
-
|
|
694
|
+
React5.createElement(
|
|
606
695
|
Element,
|
|
607
696
|
{
|
|
608
697
|
...elementProps,
|
|
609
698
|
...theme.attributes
|
|
610
699
|
},
|
|
611
|
-
themeToggle ?
|
|
700
|
+
themeToggle ? React5.createElement(
|
|
612
701
|
"div",
|
|
613
702
|
{
|
|
614
703
|
className: topbarClassName
|
|
615
704
|
},
|
|
616
|
-
|
|
705
|
+
React5.createElement(ThemeToggle, {
|
|
617
706
|
className: themeToggleClassName,
|
|
618
707
|
theme: theme.theme,
|
|
619
708
|
resolvedTheme: theme.resolvedTheme,
|
|
@@ -627,7 +716,7 @@ function ThemeScope(props) {
|
|
|
627
716
|
}
|
|
628
717
|
|
|
629
718
|
// src/use-checkout.ts
|
|
630
|
-
import * as
|
|
719
|
+
import * as React6 from "react";
|
|
631
720
|
import {
|
|
632
721
|
copyInvoice as copyInvoiceHelper2,
|
|
633
722
|
createCheckoutController,
|
|
@@ -639,46 +728,46 @@ import {
|
|
|
639
728
|
function useCheckout(options) {
|
|
640
729
|
const checkout = options.checkout;
|
|
641
730
|
const [copied, showCopied] = useTransientValue(false);
|
|
642
|
-
const [latestSnapshot, setLatestSnapshot] =
|
|
731
|
+
const [latestSnapshot, setLatestSnapshot] = React6.useState(checkout);
|
|
643
732
|
const incomingIdentity = `${checkout.checkout_id} ${checkout.reference}`;
|
|
644
|
-
const checkoutRef =
|
|
733
|
+
const checkoutRef = React6.useRef(checkout);
|
|
645
734
|
checkoutRef.current = checkout;
|
|
646
|
-
|
|
735
|
+
React6.useEffect(() => {
|
|
647
736
|
setLatestSnapshot(checkoutRef.current);
|
|
648
737
|
}, [incomingIdentity]);
|
|
649
738
|
const snapshot = latestSnapshot;
|
|
650
|
-
const [state, setState] =
|
|
739
|
+
const [state, setState] = React6.useState(
|
|
651
740
|
() => createCheckoutState(snapshot, {
|
|
652
741
|
logger: options.logger
|
|
653
742
|
})
|
|
654
743
|
);
|
|
655
|
-
const controllerRef =
|
|
656
|
-
const onStateRef =
|
|
744
|
+
const controllerRef = React6.useRef(null);
|
|
745
|
+
const onStateRef = React6.useRef(options.onState);
|
|
657
746
|
onStateRef.current = options.onState;
|
|
658
|
-
const onSettledRef =
|
|
747
|
+
const onSettledRef = React6.useRef(options.onSettled);
|
|
659
748
|
onSettledRef.current = options.onSettled;
|
|
660
|
-
const loggerRef =
|
|
749
|
+
const loggerRef = React6.useRef(options.logger);
|
|
661
750
|
loggerRef.current = options.logger;
|
|
662
|
-
const onErrorRef =
|
|
751
|
+
const onErrorRef = React6.useRef(options.onError);
|
|
663
752
|
onErrorRef.current = options.onError;
|
|
664
|
-
const onCopyRef =
|
|
753
|
+
const onCopyRef = React6.useRef(options.onCopy);
|
|
665
754
|
onCopyRef.current = options.onCopy;
|
|
666
|
-
const onOpenWalletRef =
|
|
755
|
+
const onOpenWalletRef = React6.useRef(options.onOpenWallet);
|
|
667
756
|
onOpenWalletRef.current = options.onOpenWallet;
|
|
668
|
-
const settledAnnouncementRef =
|
|
757
|
+
const settledAnnouncementRef = React6.useRef({
|
|
669
758
|
reference: snapshot.reference,
|
|
670
759
|
fired: false
|
|
671
760
|
});
|
|
672
|
-
const logContext =
|
|
761
|
+
const logContext = React6.useMemo(() => getCheckoutLogContext(state), [state]);
|
|
673
762
|
const refreshStatus = options.polling === false ? void 0 : options.refreshStatus;
|
|
674
|
-
const refreshStatusRef =
|
|
763
|
+
const refreshStatusRef = React6.useRef(refreshStatus);
|
|
675
764
|
refreshStatusRef.current = refreshStatus;
|
|
676
765
|
const polls = refreshStatus !== void 0;
|
|
677
766
|
const prefix = options.polling === false ? void 0 : options.prefix;
|
|
678
|
-
const snapshotRef =
|
|
767
|
+
const snapshotRef = React6.useRef(snapshot);
|
|
679
768
|
snapshotRef.current = snapshot;
|
|
680
769
|
const checkoutIdentity = `${snapshot.checkout_id} ${snapshot.reference}`;
|
|
681
|
-
|
|
770
|
+
React6.useEffect(() => {
|
|
682
771
|
const controller = createCheckoutController({
|
|
683
772
|
snapshot: snapshotRef.current,
|
|
684
773
|
...polls ? {
|
|
@@ -715,7 +804,7 @@ function useCheckout(options) {
|
|
|
715
804
|
}, [checkoutIdentity, polls, prefix, options.pollIntervalMs]);
|
|
716
805
|
const publicStatus = deriveStatus(state);
|
|
717
806
|
const richStatus = createCheckoutStatusModel2(state);
|
|
718
|
-
|
|
807
|
+
React6.useEffect(() => {
|
|
719
808
|
const announced = settledAnnouncementRef.current;
|
|
720
809
|
if (announced.reference !== snapshot.reference) {
|
|
721
810
|
settledAnnouncementRef.current = {
|
|
@@ -724,7 +813,7 @@ function useCheckout(options) {
|
|
|
724
813
|
};
|
|
725
814
|
}
|
|
726
815
|
}, [snapshot.reference]);
|
|
727
|
-
|
|
816
|
+
React6.useEffect(() => {
|
|
728
817
|
const announced = settledAnnouncementRef.current;
|
|
729
818
|
if (publicStatus !== "settled" || announced.fired) return;
|
|
730
819
|
settledAnnouncementRef.current = {
|
|
@@ -733,7 +822,7 @@ function useCheckout(options) {
|
|
|
733
822
|
};
|
|
734
823
|
onSettledRef.current?.();
|
|
735
824
|
}, [publicStatus, snapshot.reference]);
|
|
736
|
-
const copyInvoice =
|
|
825
|
+
const copyInvoice = React6.useCallback(async () => {
|
|
737
826
|
try {
|
|
738
827
|
const controller = controllerRef.current;
|
|
739
828
|
if (controller === null) {
|
|
@@ -753,7 +842,7 @@ function useCheckout(options) {
|
|
|
753
842
|
throw error;
|
|
754
843
|
}
|
|
755
844
|
}, [logContext, state.invoice, options.clipboard, options.logger, showCopied]);
|
|
756
|
-
const openWallet =
|
|
845
|
+
const openWallet = React6.useCallback(() => {
|
|
757
846
|
try {
|
|
758
847
|
const controller = controllerRef.current;
|
|
759
848
|
const uri = controller === null ? openWalletHelper2({
|
|
@@ -769,7 +858,7 @@ function useCheckout(options) {
|
|
|
769
858
|
throw error;
|
|
770
859
|
}
|
|
771
860
|
}, [logContext, state.invoice, options.open, options.logger]);
|
|
772
|
-
const reloadState =
|
|
861
|
+
const reloadState = React6.useCallback(async () => {
|
|
773
862
|
try {
|
|
774
863
|
const next = await controllerRef.current?.reloadState();
|
|
775
864
|
if (next !== void 0) setState(next);
|
|
@@ -779,7 +868,7 @@ function useCheckout(options) {
|
|
|
779
868
|
}
|
|
780
869
|
}, []);
|
|
781
870
|
const retry = reloadState;
|
|
782
|
-
const cancel =
|
|
871
|
+
const cancel = React6.useCallback(() => {
|
|
783
872
|
const next = controllerRef.current?.cancel();
|
|
784
873
|
if (next !== void 0) setState(next);
|
|
785
874
|
}, []);
|
|
@@ -804,9 +893,9 @@ function useCheckout(options) {
|
|
|
804
893
|
openWallet
|
|
805
894
|
};
|
|
806
895
|
}
|
|
807
|
-
var CheckoutContext =
|
|
896
|
+
var CheckoutContext = React6.createContext(null);
|
|
808
897
|
function useCheckoutContext() {
|
|
809
|
-
const checkout =
|
|
898
|
+
const checkout = React6.useContext(CheckoutContext);
|
|
810
899
|
if (checkout === null) {
|
|
811
900
|
throw new Error("useCheckoutContext must be used within CheckoutProvider.");
|
|
812
901
|
}
|
|
@@ -816,7 +905,7 @@ function CheckoutProvider(props) {
|
|
|
816
905
|
const { children, ...options } = props;
|
|
817
906
|
const checkout = useCheckout(options);
|
|
818
907
|
const content = typeof children === "function" ? children(checkout) : children;
|
|
819
|
-
return
|
|
908
|
+
return React6.createElement(CheckoutContext.Provider, { value: checkout }, content);
|
|
820
909
|
}
|
|
821
910
|
|
|
822
911
|
// src/wizard.ts
|
|
@@ -857,16 +946,16 @@ import * as React9 from "react";
|
|
|
857
946
|
// src/provider-tutorial.ts
|
|
858
947
|
import {
|
|
859
948
|
createLightningInvoiceDecodeUrl,
|
|
860
|
-
checkoutLabels as
|
|
861
|
-
orClasses as
|
|
949
|
+
checkoutLabels as checkoutLabels3,
|
|
950
|
+
orClasses as orClasses4
|
|
862
951
|
} from "@openreceive/browser/headless";
|
|
863
|
-
import * as
|
|
952
|
+
import * as React7 from "react";
|
|
864
953
|
function renderProviderOpenAction(provider, onOpenTutorial) {
|
|
865
954
|
if (provider.tutorials.length === 0) {
|
|
866
|
-
return
|
|
955
|
+
return React7.createElement(
|
|
867
956
|
"a",
|
|
868
957
|
{
|
|
869
|
-
className:
|
|
958
|
+
className: orClasses4.providerOpen,
|
|
870
959
|
href: provider.url,
|
|
871
960
|
rel: "noreferrer",
|
|
872
961
|
target: "_blank"
|
|
@@ -874,10 +963,10 @@ function renderProviderOpenAction(provider, onOpenTutorial) {
|
|
|
874
963
|
provider.openLabel
|
|
875
964
|
);
|
|
876
965
|
}
|
|
877
|
-
return
|
|
966
|
+
return React7.createElement(
|
|
878
967
|
"button",
|
|
879
968
|
{
|
|
880
|
-
className:
|
|
969
|
+
className: orClasses4.providerOpen,
|
|
881
970
|
onClick: onOpenTutorial,
|
|
882
971
|
type: "button"
|
|
883
972
|
},
|
|
@@ -886,8 +975,8 @@ function renderProviderOpenAction(provider, onOpenTutorial) {
|
|
|
886
975
|
}
|
|
887
976
|
function ProviderTutorialModal(options) {
|
|
888
977
|
const { provider } = options;
|
|
889
|
-
const dialogRef =
|
|
890
|
-
|
|
978
|
+
const dialogRef = React7.useRef(null);
|
|
979
|
+
React7.useEffect(() => {
|
|
891
980
|
const dialog = dialogRef.current;
|
|
892
981
|
if (dialog === null) return;
|
|
893
982
|
const opener = dialog.ownerDocument.activeElement instanceof HTMLElement ? dialog.ownerDocument.activeElement : null;
|
|
@@ -925,13 +1014,13 @@ function ProviderTutorialModal(options) {
|
|
|
925
1014
|
const nextIndex = Math.min(provider.tutorials.length, stepIndex + 1);
|
|
926
1015
|
const isFinalStep = stepIndex === provider.tutorials.length;
|
|
927
1016
|
const decodeHref = createLightningInvoiceDecodeUrl(options.invoice, options.decodeLinkUrl);
|
|
928
|
-
return
|
|
1017
|
+
return React7.createElement(
|
|
929
1018
|
"div",
|
|
930
1019
|
{
|
|
931
1020
|
ref: dialogRef,
|
|
932
|
-
"aria-label": `${
|
|
1021
|
+
"aria-label": `${checkoutLabels3.tutorialTitlePrefix} ${provider.name}`,
|
|
933
1022
|
"aria-modal": true,
|
|
934
|
-
className:
|
|
1023
|
+
className: orClasses4.tutorialModal,
|
|
935
1024
|
onClick: (event) => {
|
|
936
1025
|
if (event.target === event.currentTarget) options.onClose();
|
|
937
1026
|
},
|
|
@@ -942,143 +1031,143 @@ function ProviderTutorialModal(options) {
|
|
|
942
1031
|
role: "dialog",
|
|
943
1032
|
tabIndex: -1
|
|
944
1033
|
},
|
|
945
|
-
|
|
1034
|
+
React7.createElement(
|
|
946
1035
|
"div",
|
|
947
1036
|
{
|
|
948
|
-
className:
|
|
1037
|
+
className: orClasses4.tutorialBox
|
|
949
1038
|
},
|
|
950
|
-
|
|
1039
|
+
React7.createElement(
|
|
951
1040
|
"div",
|
|
952
1041
|
{
|
|
953
|
-
className:
|
|
1042
|
+
className: orClasses4.tutorialHeader
|
|
954
1043
|
},
|
|
955
|
-
|
|
1044
|
+
React7.createElement(
|
|
956
1045
|
"div",
|
|
957
1046
|
{
|
|
958
|
-
className:
|
|
1047
|
+
className: orClasses4.tutorialTitle
|
|
959
1048
|
},
|
|
960
|
-
|
|
1049
|
+
React7.createElement("img", {
|
|
961
1050
|
alt: "",
|
|
962
|
-
className:
|
|
1051
|
+
className: orClasses4.tutorialHeaderLogo,
|
|
963
1052
|
src: provider.icon
|
|
964
1053
|
}),
|
|
965
|
-
|
|
1054
|
+
React7.createElement("h3", null, `${checkoutLabels3.tutorialTitlePrefix} ${provider.name}`)
|
|
966
1055
|
),
|
|
967
|
-
|
|
1056
|
+
React7.createElement(
|
|
968
1057
|
"button",
|
|
969
1058
|
{
|
|
970
|
-
"aria-label":
|
|
971
|
-
className:
|
|
1059
|
+
"aria-label": checkoutLabels3.tutorialClose,
|
|
1060
|
+
className: orClasses4.tutorialClose,
|
|
972
1061
|
onClick: options.onClose,
|
|
973
1062
|
type: "button"
|
|
974
1063
|
},
|
|
975
1064
|
"X"
|
|
976
1065
|
)
|
|
977
1066
|
),
|
|
978
|
-
stepIndex === 0 ?
|
|
1067
|
+
stepIndex === 0 ? React7.createElement(
|
|
979
1068
|
"div",
|
|
980
1069
|
{
|
|
981
|
-
className:
|
|
1070
|
+
className: orClasses4.tutorialIntro
|
|
982
1071
|
},
|
|
983
|
-
|
|
1072
|
+
React7.createElement("img", {
|
|
984
1073
|
alt: "",
|
|
985
|
-
className:
|
|
1074
|
+
className: orClasses4.tutorialProviderLogo,
|
|
986
1075
|
src: provider.icon
|
|
987
1076
|
}),
|
|
988
|
-
|
|
1077
|
+
React7.createElement(
|
|
989
1078
|
"p",
|
|
990
1079
|
null,
|
|
991
|
-
`${
|
|
1080
|
+
`${checkoutLabels3.tutorialIntroPrefix} ${provider.name}.`
|
|
992
1081
|
),
|
|
993
|
-
|
|
994
|
-
|
|
1082
|
+
React7.createElement("p", null, checkoutLabels3.tutorialIntroCopy),
|
|
1083
|
+
React7.createElement(
|
|
995
1084
|
"button",
|
|
996
1085
|
{
|
|
997
|
-
className:
|
|
1086
|
+
className: orClasses4.tutorialCopy,
|
|
998
1087
|
onClick: () => void options.onCopy(),
|
|
999
1088
|
type: "button"
|
|
1000
1089
|
},
|
|
1001
|
-
|
|
1090
|
+
checkoutLabels3.copyInvoice
|
|
1002
1091
|
),
|
|
1003
|
-
decodeHref === void 0 ? null :
|
|
1092
|
+
decodeHref === void 0 ? null : React7.createElement(
|
|
1004
1093
|
"a",
|
|
1005
1094
|
{
|
|
1006
|
-
className:
|
|
1095
|
+
className: orClasses4.tutorialCopy,
|
|
1007
1096
|
href: decodeHref,
|
|
1008
1097
|
rel: "noreferrer",
|
|
1009
1098
|
target: "_blank"
|
|
1010
1099
|
},
|
|
1011
|
-
|
|
1100
|
+
checkoutLabels3.decodeInvoice
|
|
1012
1101
|
),
|
|
1013
|
-
options.copied ?
|
|
1102
|
+
options.copied ? React7.createElement(
|
|
1014
1103
|
"p",
|
|
1015
1104
|
{
|
|
1016
|
-
className:
|
|
1105
|
+
className: orClasses4.tutorialCopyMessage
|
|
1017
1106
|
},
|
|
1018
|
-
|
|
1107
|
+
checkoutLabels3.tutorialCopiedContinue
|
|
1019
1108
|
) : null
|
|
1020
|
-
) :
|
|
1021
|
-
|
|
1109
|
+
) : React7.createElement(
|
|
1110
|
+
React7.Fragment,
|
|
1022
1111
|
null,
|
|
1023
|
-
|
|
1112
|
+
React7.createElement(
|
|
1024
1113
|
"div",
|
|
1025
1114
|
{
|
|
1026
|
-
className:
|
|
1115
|
+
className: orClasses4.tutorialFrame
|
|
1027
1116
|
},
|
|
1028
|
-
|
|
1117
|
+
React7.createElement("img", {
|
|
1029
1118
|
alt: tutorial?.caption ?? "",
|
|
1030
|
-
className:
|
|
1119
|
+
className: orClasses4.tutorialImage,
|
|
1031
1120
|
src: tutorial?.image ?? ""
|
|
1032
1121
|
})
|
|
1033
1122
|
),
|
|
1034
|
-
|
|
1123
|
+
React7.createElement(
|
|
1035
1124
|
"p",
|
|
1036
1125
|
{
|
|
1037
|
-
className:
|
|
1126
|
+
className: orClasses4.tutorialCaption
|
|
1038
1127
|
},
|
|
1039
1128
|
tutorial?.caption ?? ""
|
|
1040
1129
|
)
|
|
1041
1130
|
),
|
|
1042
|
-
|
|
1131
|
+
React7.createElement(
|
|
1043
1132
|
"div",
|
|
1044
1133
|
{
|
|
1045
1134
|
"aria-hidden": "true",
|
|
1046
|
-
className:
|
|
1135
|
+
className: orClasses4.tutorialSteps
|
|
1047
1136
|
},
|
|
1048
1137
|
Array.from(
|
|
1049
1138
|
{ length: totalSteps },
|
|
1050
|
-
(_, index) =>
|
|
1051
|
-
className: index === stepIndex ?
|
|
1139
|
+
(_, index) => React7.createElement("span", {
|
|
1140
|
+
className: index === stepIndex ? orClasses4.tutorialStepActive : orClasses4.tutorialStep,
|
|
1052
1141
|
key: index
|
|
1053
1142
|
})
|
|
1054
1143
|
)
|
|
1055
1144
|
),
|
|
1056
|
-
|
|
1145
|
+
React7.createElement(
|
|
1057
1146
|
"p",
|
|
1058
1147
|
{
|
|
1059
|
-
className:
|
|
1148
|
+
className: orClasses4.tutorialProgress
|
|
1060
1149
|
},
|
|
1061
1150
|
`Step ${stepIndex + 1} of ${totalSteps}`
|
|
1062
1151
|
),
|
|
1063
|
-
|
|
1152
|
+
React7.createElement(
|
|
1064
1153
|
"div",
|
|
1065
1154
|
{
|
|
1066
|
-
className:
|
|
1155
|
+
className: orClasses4.tutorialControls
|
|
1067
1156
|
},
|
|
1068
|
-
|
|
1157
|
+
React7.createElement(
|
|
1069
1158
|
"button",
|
|
1070
1159
|
{
|
|
1071
|
-
className:
|
|
1160
|
+
className: orClasses4.btn,
|
|
1072
1161
|
disabled: stepIndex === 0,
|
|
1073
1162
|
onClick: () => options.onStep(previousIndex),
|
|
1074
1163
|
type: "button"
|
|
1075
1164
|
},
|
|
1076
|
-
|
|
1165
|
+
checkoutLabels3.tutorialBack
|
|
1077
1166
|
),
|
|
1078
|
-
|
|
1167
|
+
React7.createElement(
|
|
1079
1168
|
"button",
|
|
1080
1169
|
{
|
|
1081
|
-
className:
|
|
1170
|
+
className: orClasses4.btn,
|
|
1082
1171
|
onClick: () => {
|
|
1083
1172
|
if (isFinalStep) {
|
|
1084
1173
|
options.onClose();
|
|
@@ -1088,7 +1177,7 @@ function ProviderTutorialModal(options) {
|
|
|
1088
1177
|
},
|
|
1089
1178
|
type: "button"
|
|
1090
1179
|
},
|
|
1091
|
-
isFinalStep ?
|
|
1180
|
+
isFinalStep ? checkoutLabels3.tutorialExit : checkoutLabels3.tutorialNext
|
|
1092
1181
|
)
|
|
1093
1182
|
)
|
|
1094
1183
|
)
|
|
@@ -1109,97 +1198,6 @@ import {
|
|
|
1109
1198
|
selectCheckoutDisplayInvoice
|
|
1110
1199
|
} from "@openreceive/browser/headless";
|
|
1111
1200
|
import * as React8 from "react";
|
|
1112
|
-
|
|
1113
|
-
// src/transaction-details.ts
|
|
1114
|
-
import {
|
|
1115
|
-
checkoutLabels as checkoutLabels3,
|
|
1116
|
-
orClasses as orClasses4,
|
|
1117
|
-
resolveTransactionDetailRows
|
|
1118
|
-
} from "@openreceive/browser/headless";
|
|
1119
|
-
import * as React7 from "react";
|
|
1120
|
-
function TransactionDetails(props) {
|
|
1121
|
-
const rows = resolveTransactionDetailRows(props.state);
|
|
1122
|
-
if (rows.length === 0) return null;
|
|
1123
|
-
return React7.createElement(
|
|
1124
|
-
"details",
|
|
1125
|
-
{
|
|
1126
|
-
className: joinClassNames(orClasses4.transactionDetails, props.className),
|
|
1127
|
-
open: props.open === true ? true : void 0
|
|
1128
|
-
},
|
|
1129
|
-
React7.createElement(
|
|
1130
|
-
"summary",
|
|
1131
|
-
{ className: orClasses4.transactionDetailsTitle },
|
|
1132
|
-
checkoutLabels3.transactionDetails
|
|
1133
|
-
),
|
|
1134
|
-
React7.createElement(
|
|
1135
|
-
"div",
|
|
1136
|
-
{ className: orClasses4.transactionDetailsContent },
|
|
1137
|
-
React7.createElement(
|
|
1138
|
-
"dl",
|
|
1139
|
-
{ className: orClasses4.swapDetails },
|
|
1140
|
-
rows.flatMap(
|
|
1141
|
-
(row) => renderTransactionDetailRow(row, {
|
|
1142
|
-
clipboard: props.clipboard,
|
|
1143
|
-
onError: props.onError
|
|
1144
|
-
})
|
|
1145
|
-
)
|
|
1146
|
-
)
|
|
1147
|
-
)
|
|
1148
|
-
);
|
|
1149
|
-
}
|
|
1150
|
-
function renderTransactionDetailRow(row, options) {
|
|
1151
|
-
const copyValue = row.copyValue ?? row.value;
|
|
1152
|
-
return [
|
|
1153
|
-
React7.createElement(
|
|
1154
|
-
"dt",
|
|
1155
|
-
{ key: `${row.label}-label`, className: orClasses4.swapDetailsDt },
|
|
1156
|
-
row.label
|
|
1157
|
-
),
|
|
1158
|
-
React7.createElement(
|
|
1159
|
-
"dd",
|
|
1160
|
-
{ key: `${row.label}-value`, className: orClasses4.swapDetailsDd },
|
|
1161
|
-
React7.createElement("code", { className: orClasses4.swapDetailsCode }, row.value),
|
|
1162
|
-
React7.createElement(
|
|
1163
|
-
"div",
|
|
1164
|
-
{ className: orClasses4.swapDetailsActions },
|
|
1165
|
-
React7.createElement(TransactionDetailCopyButton, {
|
|
1166
|
-
value: copyValue,
|
|
1167
|
-
clipboard: options.clipboard,
|
|
1168
|
-
onError: options.onError
|
|
1169
|
-
}),
|
|
1170
|
-
row.href === void 0 ? null : React7.createElement(
|
|
1171
|
-
"a",
|
|
1172
|
-
{
|
|
1173
|
-
className: orClasses4.swapDetailsLink,
|
|
1174
|
-
href: row.href,
|
|
1175
|
-
rel: "noreferrer",
|
|
1176
|
-
target: "_blank"
|
|
1177
|
-
},
|
|
1178
|
-
row.hrefLabel ?? checkoutLabels3.viewOnExplorer
|
|
1179
|
-
)
|
|
1180
|
-
)
|
|
1181
|
-
)
|
|
1182
|
-
];
|
|
1183
|
-
}
|
|
1184
|
-
function TransactionDetailCopyButton(props) {
|
|
1185
|
-
const [copied, setCopied] = useTransientValue(false);
|
|
1186
|
-
const label = copied ? checkoutLabels3.copied : "Copy";
|
|
1187
|
-
return React7.createElement(
|
|
1188
|
-
"button",
|
|
1189
|
-
{
|
|
1190
|
-
className: orClasses4.detailCopy,
|
|
1191
|
-
type: "button",
|
|
1192
|
-
"aria-label": label,
|
|
1193
|
-
title: label,
|
|
1194
|
-
onClick: () => {
|
|
1195
|
-
void copyText(props.value, props.clipboard).then(() => setCopied(true)).catch((error) => props.onError?.(error));
|
|
1196
|
-
}
|
|
1197
|
-
},
|
|
1198
|
-
React7.createElement(ClipboardIcon)
|
|
1199
|
-
);
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
// src/swap.ts
|
|
1203
1201
|
function renderSwapActions(options) {
|
|
1204
1202
|
const shown = options.options.filter((option) => option.provider.length > 0);
|
|
1205
1203
|
if (!options.enabled || shown.length === 0) return null;
|
|
@@ -1553,16 +1551,18 @@ function renderSwapDepositPanel(options) {
|
|
|
1553
1551
|
);
|
|
1554
1552
|
}
|
|
1555
1553
|
function renderSwapNetworkWarning(display) {
|
|
1554
|
+
const alarm = display.depositRisk !== "pinned";
|
|
1556
1555
|
const emphasisStart = display.networkWarning.indexOf(display.networkWarningEmphasis);
|
|
1557
1556
|
const before = emphasisStart === -1 ? display.networkWarning : display.networkWarning.slice(0, emphasisStart);
|
|
1558
1557
|
const after = emphasisStart === -1 ? "" : display.networkWarning.slice(emphasisStart + display.networkWarningEmphasis.length);
|
|
1559
1558
|
return React8.createElement(
|
|
1560
1559
|
"div",
|
|
1561
1560
|
{
|
|
1562
|
-
role: "alert",
|
|
1563
|
-
|
|
1561
|
+
...alarm ? { role: "alert" } : {},
|
|
1562
|
+
"data-or-deposit-risk": display.depositRisk,
|
|
1563
|
+
className: alarm ? orClasses5.swapNetworkWarning : orClasses5.swapNetworkNotice
|
|
1564
1564
|
},
|
|
1565
|
-
React8.createElement(
|
|
1565
|
+
alarm ? React8.createElement(
|
|
1566
1566
|
"svg",
|
|
1567
1567
|
{
|
|
1568
1568
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1577,7 +1577,7 @@ function renderSwapNetworkWarning(display) {
|
|
|
1577
1577
|
strokeWidth: 2,
|
|
1578
1578
|
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
1579
1579
|
})
|
|
1580
|
-
),
|
|
1580
|
+
) : null,
|
|
1581
1581
|
React8.createElement(
|
|
1582
1582
|
"div",
|
|
1583
1583
|
{ className: orClasses5.swapNetworkWarningContent },
|
|
@@ -1967,9 +1967,12 @@ function PaymentWizard(props) {
|
|
|
1967
1967
|
const model = createPaymentWizardModel(selection);
|
|
1968
1968
|
const { wizard } = model;
|
|
1969
1969
|
const routeAssetDisplays = createWizardRouteAssetDisplays(model.routeAssets, {
|
|
1970
|
-
selectedRoute: model.selectedRoute
|
|
1970
|
+
selectedRoute: model.selectedRoute,
|
|
1971
|
+
...props.resolveAssetUrl === void 0 ? {} : { resolveAssetUrl: props.resolveAssetUrl }
|
|
1972
|
+
});
|
|
1973
|
+
const routeDisplays = createWizardRouteDisplays(wizard.routes, {
|
|
1974
|
+
...props.resolveAssetUrl === void 0 ? {} : { resolveAssetUrl: props.resolveAssetUrl }
|
|
1971
1975
|
});
|
|
1972
|
-
const routeDisplays = createWizardRouteDisplays(wizard.routes);
|
|
1973
1976
|
const showRoutePicker = routeAssetDisplays.length > 0 && (model.selectedRoute === null || routeDisplays.length === 0);
|
|
1974
1977
|
const activeTutorialProvider = activeTutorial === null ? void 0 : routeDisplays.flatMap((route) => route.providers).find((provider) => provider.id === activeTutorial.providerId);
|
|
1975
1978
|
const swapAssetOptions = swapOptions.enabled ? swapOptions.options.filter((option) => option.provider.length > 0) : [];
|
|
@@ -2071,7 +2074,8 @@ function PaymentWizard(props) {
|
|
|
2071
2074
|
void props.onRequestLightning?.();
|
|
2072
2075
|
}
|
|
2073
2076
|
},
|
|
2074
|
-
onContinueSwap: selectSwapAsset
|
|
2077
|
+
onContinueSwap: selectSwapAsset,
|
|
2078
|
+
...props.resolveAssetUrl === void 0 ? {} : { resolveAssetUrl: props.resolveAssetUrl }
|
|
2075
2079
|
}) : null,
|
|
2076
2080
|
selection.selectedMethod === null ? null : React9.createElement(
|
|
2077
2081
|
"div",
|
|
@@ -2346,7 +2350,7 @@ function renderCompactPaymentMethodSelector(options) {
|
|
|
2346
2350
|
React9.createElement("img", {
|
|
2347
2351
|
alt: "",
|
|
2348
2352
|
className: orClasses6.methodNetworkIcon,
|
|
2349
|
-
src: getNetworkIcon(option.network_label)
|
|
2353
|
+
src: getNetworkIcon(option.network_label, options.resolveAssetUrl)
|
|
2350
2354
|
})
|
|
2351
2355
|
),
|
|
2352
2356
|
React9.createElement("span", { className: "truncate" }, option.network_label),
|
|
@@ -2442,7 +2446,7 @@ function renderCompactPaymentMethodSelector(options) {
|
|
|
2442
2446
|
React9.createElement("img", {
|
|
2443
2447
|
alt: "",
|
|
2444
2448
|
className: orClasses6.methodIcon,
|
|
2445
|
-
src: getPaymentMethodIcon(method.id)
|
|
2449
|
+
src: getPaymentMethodIcon(method.id, options.resolveAssetUrl)
|
|
2446
2450
|
})
|
|
2447
2451
|
),
|
|
2448
2452
|
React9.createElement(
|
|
@@ -2497,7 +2501,7 @@ function renderCompactPaymentMethodSelector(options) {
|
|
|
2497
2501
|
}) : React9.createElement("img", {
|
|
2498
2502
|
alt: "",
|
|
2499
2503
|
className: orClasses6.methodIcon,
|
|
2500
|
-
src: getSwapOptionIcon(displayOption)
|
|
2504
|
+
src: getSwapOptionIcon(displayOption, options.resolveAssetUrl)
|
|
2501
2505
|
})
|
|
2502
2506
|
),
|
|
2503
2507
|
React9.createElement(
|
|
@@ -2890,6 +2894,7 @@ function CheckoutView(props) {
|
|
|
2890
2894
|
components,
|
|
2891
2895
|
classNames,
|
|
2892
2896
|
children,
|
|
2897
|
+
resolveAssetUrl,
|
|
2893
2898
|
className,
|
|
2894
2899
|
...sectionProps
|
|
2895
2900
|
} = props;
|
|
@@ -3033,16 +3038,25 @@ function CheckoutView(props) {
|
|
|
3033
3038
|
className: classNames?.summary,
|
|
3034
3039
|
classNames
|
|
3035
3040
|
}) : null,
|
|
3036
|
-
settled ? React10.createElement(
|
|
3037
|
-
key: "
|
|
3038
|
-
// The model IS the checkout state, so the
|
|
3039
|
-
//
|
|
3040
|
-
//
|
|
3041
|
-
//
|
|
3041
|
+
settled ? React10.createElement(TransactionDetails, {
|
|
3042
|
+
key: "transaction-details",
|
|
3043
|
+
// The model IS the checkout state, so the panel reads
|
|
3044
|
+
// the same derivation the rest of the screen does. It
|
|
3045
|
+
// used to re-flatten the snapshot separately, which
|
|
3046
|
+
// reported the displayed ATTEMPT's transaction /
|
|
3042
3047
|
// workflow state on a checkout the state already knows
|
|
3043
3048
|
// is paid.
|
|
3044
|
-
|
|
3045
|
-
|
|
3049
|
+
//
|
|
3050
|
+
// The SAME panel the swap flow renders one screen
|
|
3051
|
+
// earlier. A payer's whole evidence that they paid is a
|
|
3052
|
+
// payment hash and, on a swap, a deposit txid — so the
|
|
3053
|
+
// most keep-worthy screen gets copy buttons and
|
|
3054
|
+
// explorer links, not un-copyable text. No
|
|
3055
|
+
// `decodeLinkUrl` is passed, so the bolt11 never
|
|
3056
|
+
// reaches a third party.
|
|
3057
|
+
state: checkoutModel,
|
|
3058
|
+
className: classNames?.details,
|
|
3059
|
+
onError
|
|
3046
3060
|
}) : expired ? React10.createElement(
|
|
3047
3061
|
"div",
|
|
3048
3062
|
{
|
|
@@ -3120,7 +3134,8 @@ function CheckoutView(props) {
|
|
|
3120
3134
|
onProviderCopy,
|
|
3121
3135
|
onCopy,
|
|
3122
3136
|
onRequestLightning,
|
|
3123
|
-
onSwapStarted
|
|
3137
|
+
onSwapStarted,
|
|
3138
|
+
resolveAssetUrl
|
|
3124
3139
|
}) : null
|
|
3125
3140
|
] : customChildren
|
|
3126
3141
|
);
|