@doujins/payments-ui 0.1.14 → 0.1.16
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.cjs +320 -242
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +160 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React4 = require('react');
|
|
4
4
|
var reactQuery = require('@tanstack/react-query');
|
|
5
5
|
var walletAdapterReact = require('@solana/wallet-adapter-react');
|
|
6
6
|
var walletAdapterReactUi = require('@solana/wallet-adapter-react-ui');
|
|
@@ -48,7 +48,7 @@ function _interopNamespace(e) {
|
|
|
48
48
|
return Object.freeze(n);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
52
52
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
53
53
|
var clsx2__default = /*#__PURE__*/_interopDefault(clsx2);
|
|
54
54
|
var countryList__default = /*#__PURE__*/_interopDefault(countryList);
|
|
@@ -521,7 +521,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
);
|
|
524
|
-
var Button =
|
|
524
|
+
var Button = React4__namespace.forwardRef(
|
|
525
525
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
526
526
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
527
527
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -535,7 +535,7 @@ var Button = React15__namespace.forwardRef(
|
|
|
535
535
|
}
|
|
536
536
|
);
|
|
537
537
|
Button.displayName = "Button";
|
|
538
|
-
var Input =
|
|
538
|
+
var Input = React4__namespace.forwardRef(
|
|
539
539
|
({ className, type, ...props }, ref) => {
|
|
540
540
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
541
541
|
"input",
|
|
@@ -555,7 +555,7 @@ Input.displayName = "Input";
|
|
|
555
555
|
var labelVariants = classVarianceAuthority.cva(
|
|
556
556
|
"text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
557
557
|
);
|
|
558
|
-
var Label =
|
|
558
|
+
var Label = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
559
559
|
LabelPrimitive__namespace.Root,
|
|
560
560
|
{
|
|
561
561
|
ref,
|
|
@@ -564,9 +564,9 @@ var Label = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
564
564
|
}
|
|
565
565
|
));
|
|
566
566
|
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
567
|
-
var Select =
|
|
567
|
+
var Select = SelectPrimitive__namespace.Root;
|
|
568
568
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
569
|
-
var SelectTrigger =
|
|
569
|
+
var SelectTrigger = React4__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
570
570
|
SelectPrimitive__namespace.Trigger,
|
|
571
571
|
{
|
|
572
572
|
ref,
|
|
@@ -582,7 +582,7 @@ var SelectTrigger = React15__namespace.forwardRef(({ className, children, ...pro
|
|
|
582
582
|
}
|
|
583
583
|
));
|
|
584
584
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
585
|
-
var SelectScrollUpButton =
|
|
585
|
+
var SelectScrollUpButton = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
586
586
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
587
587
|
{
|
|
588
588
|
ref,
|
|
@@ -595,7 +595,7 @@ var SelectScrollUpButton = React15__namespace.forwardRef(({ className, ...props
|
|
|
595
595
|
}
|
|
596
596
|
));
|
|
597
597
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
598
|
-
var SelectScrollDownButton =
|
|
598
|
+
var SelectScrollDownButton = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
599
599
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
600
600
|
{
|
|
601
601
|
ref,
|
|
@@ -608,33 +608,61 @@ var SelectScrollDownButton = React15__namespace.forwardRef(({ className, ...prop
|
|
|
608
608
|
}
|
|
609
609
|
));
|
|
610
610
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
611
|
-
var SelectContent =
|
|
612
|
-
|
|
613
|
-
{
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
|
|
611
|
+
var SelectContent = React4__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => {
|
|
612
|
+
const viewportRef = React4__namespace.useRef(null);
|
|
613
|
+
const contentRef = React4__namespace.useCallback((node) => {
|
|
614
|
+
if (node) {
|
|
615
|
+
node.style.setProperty("max-height", "40vh", "important");
|
|
616
|
+
const anchorWidth = window.getComputedStyle(node).getPropertyValue("--radix-popper-anchor-width");
|
|
617
|
+
if (anchorWidth) {
|
|
618
|
+
node.style.setProperty("width", anchorWidth, "important");
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}, []);
|
|
622
|
+
const combinedRef = React4__namespace.useCallback((node) => {
|
|
623
|
+
contentRef(node);
|
|
624
|
+
if (typeof ref === "function") {
|
|
625
|
+
ref(node);
|
|
626
|
+
} else if (ref) {
|
|
627
|
+
ref.current = node;
|
|
628
|
+
}
|
|
629
|
+
}, [contentRef, ref]);
|
|
630
|
+
React4__namespace.useEffect(() => {
|
|
631
|
+
if (viewportRef.current) {
|
|
632
|
+
viewportRef.current.style.setProperty("max-height", "40vh", "important");
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
636
|
+
SelectPrimitive__namespace.Content,
|
|
637
|
+
{
|
|
638
|
+
ref: combinedRef,
|
|
639
|
+
className: cn(
|
|
640
|
+
"relative z-50 min-w-[8rem] overflow-hidden rounded-md border border-white/20 bg-background-regular text-foreground shadow-lg backdrop-blur-xl data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
641
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
642
|
+
className
|
|
643
|
+
),
|
|
644
|
+
position,
|
|
645
|
+
...props,
|
|
646
|
+
children: [
|
|
647
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectScrollUpButton, {}),
|
|
648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
+
SelectPrimitive__namespace.Viewport,
|
|
650
|
+
{
|
|
651
|
+
ref: viewportRef,
|
|
652
|
+
className: cn(
|
|
653
|
+
"p-1 overflow-y-auto",
|
|
654
|
+
position === "popper" && "w-full min-w-[var(--radix-select-trigger-width)]"
|
|
655
|
+
),
|
|
656
|
+
children
|
|
657
|
+
}
|
|
658
|
+
),
|
|
659
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectScrollDownButton, {})
|
|
660
|
+
]
|
|
661
|
+
}
|
|
662
|
+
) });
|
|
663
|
+
});
|
|
636
664
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
637
|
-
var SelectLabel =
|
|
665
|
+
var SelectLabel = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
638
666
|
SelectPrimitive__namespace.Label,
|
|
639
667
|
{
|
|
640
668
|
ref,
|
|
@@ -643,7 +671,7 @@ var SelectLabel = React15__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
643
671
|
}
|
|
644
672
|
));
|
|
645
673
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
646
|
-
var SelectItem =
|
|
674
|
+
var SelectItem = React4__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
647
675
|
SelectPrimitive__namespace.Item,
|
|
648
676
|
{
|
|
649
677
|
ref,
|
|
@@ -659,7 +687,7 @@ var SelectItem = React15__namespace.forwardRef(({ className, children, ...props
|
|
|
659
687
|
}
|
|
660
688
|
));
|
|
661
689
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
662
|
-
var SelectSeparator =
|
|
690
|
+
var SelectSeparator = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
663
691
|
SelectPrimitive__namespace.Separator,
|
|
664
692
|
{
|
|
665
693
|
ref,
|
|
@@ -695,8 +723,8 @@ var CardDetailsForm = ({
|
|
|
695
723
|
submitDisabled = false
|
|
696
724
|
}) => {
|
|
697
725
|
const { config } = usePaymentContext();
|
|
698
|
-
const defaultValuesKey =
|
|
699
|
-
const mergedDefaults =
|
|
726
|
+
const defaultValuesKey = React4.useMemo(() => JSON.stringify(defaultValues ?? {}), [defaultValues]);
|
|
727
|
+
const mergedDefaults = React4.useMemo(
|
|
700
728
|
() => ({
|
|
701
729
|
...defaultBillingDetails,
|
|
702
730
|
...defaultValues,
|
|
@@ -704,20 +732,21 @@ var CardDetailsForm = ({
|
|
|
704
732
|
}),
|
|
705
733
|
[defaultValuesKey, config.defaultUser?.email]
|
|
706
734
|
);
|
|
707
|
-
const [firstName, setFirstName] =
|
|
708
|
-
const [lastName, setLastName] =
|
|
709
|
-
const [address1, setAddress1] =
|
|
710
|
-
const [city, setCity] =
|
|
711
|
-
const [stateRegion, setStateRegion] =
|
|
712
|
-
const [postalCode, setPostalCode] =
|
|
713
|
-
const [country, setCountry] =
|
|
714
|
-
const [email, setEmail] =
|
|
715
|
-
const [
|
|
716
|
-
const [
|
|
717
|
-
const [
|
|
735
|
+
const [firstName, setFirstName] = React4.useState(mergedDefaults.firstName);
|
|
736
|
+
const [lastName, setLastName] = React4.useState(mergedDefaults.lastName);
|
|
737
|
+
const [address1, setAddress1] = React4.useState(mergedDefaults.address1);
|
|
738
|
+
const [city, setCity] = React4.useState(mergedDefaults.city);
|
|
739
|
+
const [stateRegion, setStateRegion] = React4.useState(mergedDefaults.stateRegion ?? "");
|
|
740
|
+
const [postalCode, setPostalCode] = React4.useState(mergedDefaults.postalCode);
|
|
741
|
+
const [country, setCountry] = React4.useState(mergedDefaults.country);
|
|
742
|
+
const [email, setEmail] = React4.useState(mergedDefaults.email ?? "");
|
|
743
|
+
const [isEditingEmail, setIsEditingEmail] = React4.useState(false);
|
|
744
|
+
const [localError, setLocalError] = React4.useState(null);
|
|
745
|
+
const [isTokenizing, setIsTokenizing] = React4.useState(false);
|
|
746
|
+
const [collectReady, setCollectReady] = React4.useState(
|
|
718
747
|
typeof window !== "undefined" && Boolean(window.CollectJS)
|
|
719
748
|
);
|
|
720
|
-
|
|
749
|
+
React4.useEffect(() => {
|
|
721
750
|
if (collectReady) return;
|
|
722
751
|
let active = true;
|
|
723
752
|
waitForCollectJs().then((instance) => {
|
|
@@ -729,13 +758,13 @@ var CardDetailsForm = ({
|
|
|
729
758
|
active = false;
|
|
730
759
|
};
|
|
731
760
|
}, [collectReady]);
|
|
732
|
-
|
|
761
|
+
React4.useEffect(() => {
|
|
733
762
|
if (!visible) {
|
|
734
763
|
setLocalError(null);
|
|
735
764
|
setIsTokenizing(false);
|
|
736
765
|
}
|
|
737
766
|
}, [visible]);
|
|
738
|
-
|
|
767
|
+
React4.useEffect(() => {
|
|
739
768
|
if (!visible) return;
|
|
740
769
|
setFirstName(mergedDefaults.firstName);
|
|
741
770
|
setLastName(mergedDefaults.lastName);
|
|
@@ -746,7 +775,7 @@ var CardDetailsForm = ({
|
|
|
746
775
|
setCountry(mergedDefaults.country);
|
|
747
776
|
setEmail(mergedDefaults.email ?? "");
|
|
748
777
|
}, [defaultValuesKey, mergedDefaults, visible]);
|
|
749
|
-
|
|
778
|
+
React4.useEffect(() => {
|
|
750
779
|
if (!onBillingChange) return;
|
|
751
780
|
onBillingChange({
|
|
752
781
|
firstName,
|
|
@@ -785,7 +814,7 @@ var CardDetailsForm = ({
|
|
|
785
814
|
}
|
|
786
815
|
return sanitized;
|
|
787
816
|
};
|
|
788
|
-
|
|
817
|
+
React4.useEffect(() => {
|
|
789
818
|
if (!collectReady || typeof window === "undefined" || !window.CollectJS || !visible) {
|
|
790
819
|
return;
|
|
791
820
|
}
|
|
@@ -845,8 +874,7 @@ var CardDetailsForm = ({
|
|
|
845
874
|
visible
|
|
846
875
|
]);
|
|
847
876
|
const validate = () => {
|
|
848
|
-
|
|
849
|
-
if (!firstName.trim() || !lastName.trim() || !address1.trim() || !city.trim() || !postalCode.trim() || !country.trim() || emailRequired && !email.trim()) {
|
|
877
|
+
if (!firstName.trim() || !lastName.trim() || !address1.trim() || !city.trim() || !postalCode.trim() || !country.trim() || !email.trim()) {
|
|
850
878
|
setLocalError("Please complete all required billing fields.");
|
|
851
879
|
return false;
|
|
852
880
|
}
|
|
@@ -865,7 +893,8 @@ var CardDetailsForm = ({
|
|
|
865
893
|
};
|
|
866
894
|
const errorMessage = localError ?? externalError;
|
|
867
895
|
const collectFieldClass = "relative flex h-9 w-full items-center overflow-hidden rounded-md border border-white/30 bg-transparent px-3 text-sm text-foreground";
|
|
868
|
-
const
|
|
896
|
+
const hasDefaultEmail = Boolean(defaultValues?.email || config.defaultUser?.email);
|
|
897
|
+
const showEmailInput = !hasDefaultEmail || isEditingEmail;
|
|
869
898
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
870
899
|
"form",
|
|
871
900
|
{
|
|
@@ -900,18 +929,47 @@ var CardDetailsForm = ({
|
|
|
900
929
|
)
|
|
901
930
|
] })
|
|
902
931
|
] }),
|
|
903
|
-
|
|
932
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
904
933
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "email", children: "Email" }),
|
|
905
|
-
/* @__PURE__ */ jsxRuntime.
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
934
|
+
showEmailInput ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center", children: [
|
|
935
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
936
|
+
Input,
|
|
937
|
+
{
|
|
938
|
+
id: "email",
|
|
939
|
+
type: "email",
|
|
940
|
+
value: email,
|
|
941
|
+
onChange: (e) => setEmail(e.target.value),
|
|
942
|
+
required: true,
|
|
943
|
+
className: "flex-1"
|
|
944
|
+
}
|
|
945
|
+
),
|
|
946
|
+
hasDefaultEmail && /* @__PURE__ */ jsxRuntime.jsx(
|
|
947
|
+
Button,
|
|
948
|
+
{
|
|
949
|
+
type: "button",
|
|
950
|
+
variant: "ghost",
|
|
951
|
+
size: "sm",
|
|
952
|
+
onClick: () => {
|
|
953
|
+
setIsEditingEmail(false);
|
|
954
|
+
setEmail(mergedDefaults.email ?? "");
|
|
955
|
+
},
|
|
956
|
+
className: "px-3 text-xs text-muted-foreground hover:text-foreground",
|
|
957
|
+
children: "Cancel"
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between h-9 w-full rounded-md border border-white/30 bg-transparent px-3 text-sm text-foreground", children: [
|
|
961
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: email }),
|
|
962
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
963
|
+
"button",
|
|
964
|
+
{
|
|
965
|
+
type: "button",
|
|
966
|
+
onClick: () => setIsEditingEmail(true),
|
|
967
|
+
className: "text-muted-foreground hover:text-foreground transition-colors",
|
|
968
|
+
"aria-label": "Edit email",
|
|
969
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pencil, { className: "h-4 w-4" })
|
|
970
|
+
}
|
|
971
|
+
)
|
|
972
|
+
] })
|
|
915
973
|
] }),
|
|
916
974
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
917
975
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "address1", children: "Address" }),
|
|
@@ -967,7 +1025,7 @@ var CardDetailsForm = ({
|
|
|
967
1025
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Country" }),
|
|
968
1026
|
/* @__PURE__ */ jsxRuntime.jsxs(Select, { value: country, onValueChange: setCountry, children: [
|
|
969
1027
|
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select a country" }) }),
|
|
970
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, {
|
|
1028
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: countries.map((option) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: option.code, children: option.name }, option.code)) })
|
|
971
1029
|
] })
|
|
972
1030
|
] })
|
|
973
1031
|
] }),
|
|
@@ -1073,7 +1131,7 @@ var badgeVariants = classVarianceAuthority.cva(
|
|
|
1073
1131
|
function Badge({ className, variant, ...props }) {
|
|
1074
1132
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
1075
1133
|
}
|
|
1076
|
-
var ScrollArea =
|
|
1134
|
+
var ScrollArea = React4__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1077
1135
|
ScrollAreaPrimitive__namespace.Root,
|
|
1078
1136
|
{
|
|
1079
1137
|
ref,
|
|
@@ -1087,7 +1145,7 @@ var ScrollArea = React15__namespace.forwardRef(({ className, children, ...props
|
|
|
1087
1145
|
}
|
|
1088
1146
|
));
|
|
1089
1147
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
1090
|
-
var ScrollBar =
|
|
1148
|
+
var ScrollBar = React4__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1091
1149
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
1092
1150
|
{
|
|
1093
1151
|
ref,
|
|
@@ -1113,7 +1171,7 @@ var StoredPaymentMethods = ({
|
|
|
1113
1171
|
onMethodSelect
|
|
1114
1172
|
}) => {
|
|
1115
1173
|
const { listQuery } = usePaymentMethods();
|
|
1116
|
-
const payments =
|
|
1174
|
+
const payments = React4.useMemo(() => listQuery.data?.data ?? [], [listQuery.data]);
|
|
1117
1175
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: listQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
|
|
1118
1176
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1119
1177
|
" Loading cards..."
|
|
@@ -1172,7 +1230,7 @@ function TabsList({
|
|
|
1172
1230
|
{
|
|
1173
1231
|
"data-slot": "tabs-list",
|
|
1174
1232
|
className: cn(
|
|
1175
|
-
"bg-
|
|
1233
|
+
"bg-transparent border border-white/30 text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-1",
|
|
1176
1234
|
className
|
|
1177
1235
|
),
|
|
1178
1236
|
...props
|
|
@@ -1183,12 +1241,32 @@ function TabsTrigger({
|
|
|
1183
1241
|
className,
|
|
1184
1242
|
...props
|
|
1185
1243
|
}) {
|
|
1244
|
+
const triggerRef = React4__namespace.useRef(null);
|
|
1245
|
+
React4__namespace.useEffect(() => {
|
|
1246
|
+
const element = triggerRef.current;
|
|
1247
|
+
if (!element) return;
|
|
1248
|
+
const updateStyles = () => {
|
|
1249
|
+
const isActive = element.getAttribute("data-state") === "active";
|
|
1250
|
+
if (isActive) {
|
|
1251
|
+
element.style.setProperty("background-color", "rgba(255, 255, 255, 0.3)", "important");
|
|
1252
|
+
element.style.setProperty("border-color", "transparent", "important");
|
|
1253
|
+
} else {
|
|
1254
|
+
element.style.removeProperty("background-color");
|
|
1255
|
+
element.style.removeProperty("border-color");
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
updateStyles();
|
|
1259
|
+
const observer = new MutationObserver(updateStyles);
|
|
1260
|
+
observer.observe(element, { attributes: true, attributeFilter: ["data-state"] });
|
|
1261
|
+
return () => observer.disconnect();
|
|
1262
|
+
}, []);
|
|
1186
1263
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1187
1264
|
TabsPrimitive__namespace.Trigger,
|
|
1188
1265
|
{
|
|
1266
|
+
ref: triggerRef,
|
|
1189
1267
|
"data-slot": "tabs-trigger",
|
|
1190
1268
|
className: cn(
|
|
1191
|
-
"data-[state=active]:
|
|
1269
|
+
"data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/70 inline-flex h-[calc(100%-0.5rem)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow,background-color,border-color] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1192
1270
|
className
|
|
1193
1271
|
),
|
|
1194
1272
|
...props
|
|
@@ -1210,19 +1288,19 @@ function TabsContent({
|
|
|
1210
1288
|
}
|
|
1211
1289
|
var usePaymentNotifications = () => {
|
|
1212
1290
|
const { config } = usePaymentContext();
|
|
1213
|
-
const notifyStatus =
|
|
1291
|
+
const notifyStatus = React4.useCallback(
|
|
1214
1292
|
(status, context) => {
|
|
1215
1293
|
config.callbacks?.onStatusChange?.({ status, context });
|
|
1216
1294
|
},
|
|
1217
1295
|
[config.callbacks]
|
|
1218
1296
|
);
|
|
1219
|
-
const notifySuccess =
|
|
1297
|
+
const notifySuccess = React4.useCallback(
|
|
1220
1298
|
(payload) => {
|
|
1221
1299
|
config.callbacks?.onSuccess?.(payload ?? {});
|
|
1222
1300
|
},
|
|
1223
1301
|
[config.callbacks]
|
|
1224
1302
|
);
|
|
1225
|
-
const notifyError =
|
|
1303
|
+
const notifyError = React4.useCallback(
|
|
1226
1304
|
(error) => {
|
|
1227
1305
|
config.callbacks?.onError?.(
|
|
1228
1306
|
typeof error === "string" ? new Error(error) : error
|
|
@@ -1240,17 +1318,17 @@ var useSolanaQrPayment = (options) => {
|
|
|
1240
1318
|
const { priceId, selectedToken, onSuccess, onError } = options;
|
|
1241
1319
|
const { client } = usePaymentContext();
|
|
1242
1320
|
const tokenSymbol = selectedToken?.symbol ?? null;
|
|
1243
|
-
const onSuccessRef =
|
|
1244
|
-
const onErrorRef =
|
|
1245
|
-
const [intent, setIntent] =
|
|
1246
|
-
const [qrDataUri, setQrDataUri] =
|
|
1247
|
-
const [isLoading, setIsLoading] =
|
|
1248
|
-
const [error, setError] =
|
|
1249
|
-
const [timeRemaining, setTimeRemaining] =
|
|
1250
|
-
const [refreshNonce, setRefreshNonce] =
|
|
1251
|
-
const pollRef =
|
|
1252
|
-
const countdownRef =
|
|
1253
|
-
const clearTimers =
|
|
1321
|
+
const onSuccessRef = React4.useRef(onSuccess);
|
|
1322
|
+
const onErrorRef = React4.useRef(onError);
|
|
1323
|
+
const [intent, setIntent] = React4.useState(null);
|
|
1324
|
+
const [qrDataUri, setQrDataUri] = React4.useState(null);
|
|
1325
|
+
const [isLoading, setIsLoading] = React4.useState(false);
|
|
1326
|
+
const [error, setError] = React4.useState(null);
|
|
1327
|
+
const [timeRemaining, setTimeRemaining] = React4.useState(0);
|
|
1328
|
+
const [refreshNonce, setRefreshNonce] = React4.useState(0);
|
|
1329
|
+
const pollRef = React4.useRef(null);
|
|
1330
|
+
const countdownRef = React4.useRef(null);
|
|
1331
|
+
const clearTimers = React4.useCallback(() => {
|
|
1254
1332
|
if (pollRef.current) {
|
|
1255
1333
|
clearInterval(pollRef.current);
|
|
1256
1334
|
pollRef.current = null;
|
|
@@ -1260,12 +1338,12 @@ var useSolanaQrPayment = (options) => {
|
|
|
1260
1338
|
countdownRef.current = null;
|
|
1261
1339
|
}
|
|
1262
1340
|
}, []);
|
|
1263
|
-
|
|
1341
|
+
React4.useEffect(() => {
|
|
1264
1342
|
return () => {
|
|
1265
1343
|
clearTimers();
|
|
1266
1344
|
};
|
|
1267
1345
|
}, [clearTimers]);
|
|
1268
|
-
const resetState =
|
|
1346
|
+
const resetState = React4.useCallback(
|
|
1269
1347
|
(message) => {
|
|
1270
1348
|
clearTimers();
|
|
1271
1349
|
setIntent(null);
|
|
@@ -1275,13 +1353,13 @@ var useSolanaQrPayment = (options) => {
|
|
|
1275
1353
|
},
|
|
1276
1354
|
[clearTimers]
|
|
1277
1355
|
);
|
|
1278
|
-
|
|
1356
|
+
React4.useEffect(() => {
|
|
1279
1357
|
onSuccessRef.current = onSuccess;
|
|
1280
1358
|
}, [onSuccess]);
|
|
1281
|
-
|
|
1359
|
+
React4.useEffect(() => {
|
|
1282
1360
|
onErrorRef.current = onError;
|
|
1283
1361
|
}, [onError]);
|
|
1284
|
-
const handleError =
|
|
1362
|
+
const handleError = React4.useCallback(
|
|
1285
1363
|
(message, notifyParent = false) => {
|
|
1286
1364
|
console.error("[payments-ui] Solana Pay QR error:", message);
|
|
1287
1365
|
clearTimers();
|
|
@@ -1292,7 +1370,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1292
1370
|
},
|
|
1293
1371
|
[clearTimers, resetState]
|
|
1294
1372
|
);
|
|
1295
|
-
const handleSuccess =
|
|
1373
|
+
const handleSuccess = React4.useCallback(
|
|
1296
1374
|
(status) => {
|
|
1297
1375
|
clearTimers();
|
|
1298
1376
|
resetState(null);
|
|
@@ -1306,7 +1384,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1306
1384
|
},
|
|
1307
1385
|
[clearTimers, resetState]
|
|
1308
1386
|
);
|
|
1309
|
-
const pollStatus =
|
|
1387
|
+
const pollStatus = React4.useCallback(
|
|
1310
1388
|
async (reference) => {
|
|
1311
1389
|
try {
|
|
1312
1390
|
const status = await client.getSolanaPayStatus(reference);
|
|
@@ -1325,7 +1403,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1325
1403
|
},
|
|
1326
1404
|
[handleError, handleSuccess, client]
|
|
1327
1405
|
);
|
|
1328
|
-
const startCountdown =
|
|
1406
|
+
const startCountdown = React4.useCallback(
|
|
1329
1407
|
(expiresAt, reference) => {
|
|
1330
1408
|
const updateTime = () => {
|
|
1331
1409
|
const remaining = Math.max(0, Math.floor(expiresAt - Date.now() / 1e3));
|
|
@@ -1340,7 +1418,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1340
1418
|
},
|
|
1341
1419
|
[handleError, pollStatus]
|
|
1342
1420
|
);
|
|
1343
|
-
const renderQr =
|
|
1421
|
+
const renderQr = React4.useCallback(async (qrIntent) => {
|
|
1344
1422
|
try {
|
|
1345
1423
|
const dataUri = await QRCode__default.default.toDataURL(qrIntent.url, {
|
|
1346
1424
|
width: 320,
|
|
@@ -1356,7 +1434,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1356
1434
|
handleError("Unable to render QR code");
|
|
1357
1435
|
}
|
|
1358
1436
|
}, [handleError]);
|
|
1359
|
-
|
|
1437
|
+
React4.useEffect(() => {
|
|
1360
1438
|
let cancelled = false;
|
|
1361
1439
|
const generateIntent = async () => {
|
|
1362
1440
|
clearTimers();
|
|
@@ -1420,7 +1498,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1420
1498
|
tokenSymbol,
|
|
1421
1499
|
refreshNonce
|
|
1422
1500
|
]);
|
|
1423
|
-
const refresh =
|
|
1501
|
+
const refresh = React4.useCallback(() => {
|
|
1424
1502
|
setRefreshNonce((value) => value + 1);
|
|
1425
1503
|
}, []);
|
|
1426
1504
|
return {
|
|
@@ -1432,7 +1510,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1432
1510
|
refresh
|
|
1433
1511
|
};
|
|
1434
1512
|
};
|
|
1435
|
-
var Card =
|
|
1513
|
+
var Card = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1436
1514
|
"div",
|
|
1437
1515
|
{
|
|
1438
1516
|
ref,
|
|
@@ -1444,7 +1522,7 @@ var Card = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
1444
1522
|
}
|
|
1445
1523
|
));
|
|
1446
1524
|
Card.displayName = "Card";
|
|
1447
|
-
var CardHeader =
|
|
1525
|
+
var CardHeader = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1448
1526
|
"div",
|
|
1449
1527
|
{
|
|
1450
1528
|
ref,
|
|
@@ -1453,7 +1531,7 @@ var CardHeader = React15__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1453
1531
|
}
|
|
1454
1532
|
));
|
|
1455
1533
|
CardHeader.displayName = "CardHeader";
|
|
1456
|
-
var CardTitle =
|
|
1534
|
+
var CardTitle = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1457
1535
|
"div",
|
|
1458
1536
|
{
|
|
1459
1537
|
ref,
|
|
@@ -1465,7 +1543,7 @@ var CardTitle = React15__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1465
1543
|
}
|
|
1466
1544
|
));
|
|
1467
1545
|
CardTitle.displayName = "CardTitle";
|
|
1468
|
-
var CardDescription =
|
|
1546
|
+
var CardDescription = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1469
1547
|
"div",
|
|
1470
1548
|
{
|
|
1471
1549
|
ref,
|
|
@@ -1474,9 +1552,9 @@ var CardDescription = React15__namespace.forwardRef(({ className, ...props }, re
|
|
|
1474
1552
|
}
|
|
1475
1553
|
));
|
|
1476
1554
|
CardDescription.displayName = "CardDescription";
|
|
1477
|
-
var CardContent =
|
|
1555
|
+
var CardContent = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
1478
1556
|
CardContent.displayName = "CardContent";
|
|
1479
|
-
var CardFooter =
|
|
1557
|
+
var CardFooter = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1480
1558
|
"div",
|
|
1481
1559
|
{
|
|
1482
1560
|
ref,
|
|
@@ -1491,7 +1569,7 @@ var QRCodePayment = ({
|
|
|
1491
1569
|
onPaymentError,
|
|
1492
1570
|
onPaymentSuccess
|
|
1493
1571
|
}) => {
|
|
1494
|
-
const handleQrSuccess =
|
|
1572
|
+
const handleQrSuccess = React4__namespace.default.useCallback(
|
|
1495
1573
|
(paymentId, txId) => {
|
|
1496
1574
|
if (!paymentId && !txId) {
|
|
1497
1575
|
onPaymentError("Missing payment confirmation details");
|
|
@@ -1600,16 +1678,16 @@ var PaymentStatus = ({
|
|
|
1600
1678
|
};
|
|
1601
1679
|
var useSupportedTokens = () => {
|
|
1602
1680
|
const { client } = usePaymentContext();
|
|
1603
|
-
const [tokens, setTokens] =
|
|
1604
|
-
const [isLoading, setIsLoading] =
|
|
1605
|
-
const [error, setError] =
|
|
1606
|
-
const [lastFetched, setLastFetched] =
|
|
1681
|
+
const [tokens, setTokens] = React4.useState([]);
|
|
1682
|
+
const [isLoading, setIsLoading] = React4.useState(false);
|
|
1683
|
+
const [error, setError] = React4.useState(null);
|
|
1684
|
+
const [lastFetched, setLastFetched] = React4.useState(null);
|
|
1607
1685
|
const CACHE_DURATION = 5 * 60 * 1e3;
|
|
1608
|
-
const tokensRef =
|
|
1609
|
-
const lastFetchedRef =
|
|
1686
|
+
const tokensRef = React4.useRef(tokens);
|
|
1687
|
+
const lastFetchedRef = React4.useRef(lastFetched);
|
|
1610
1688
|
tokensRef.current = tokens;
|
|
1611
1689
|
lastFetchedRef.current = lastFetched;
|
|
1612
|
-
const fetchSupportedTokens =
|
|
1690
|
+
const fetchSupportedTokens = React4.useCallback(async () => {
|
|
1613
1691
|
if (tokensRef.current.length > 0 && lastFetchedRef.current && Date.now() - lastFetchedRef.current < CACHE_DURATION) {
|
|
1614
1692
|
return tokensRef.current;
|
|
1615
1693
|
}
|
|
@@ -1636,50 +1714,50 @@ var useSupportedTokens = () => {
|
|
|
1636
1714
|
setIsLoading(false);
|
|
1637
1715
|
}
|
|
1638
1716
|
}, [client]);
|
|
1639
|
-
|
|
1717
|
+
React4.useEffect(() => {
|
|
1640
1718
|
if (tokens.length === 0) {
|
|
1641
1719
|
fetchSupportedTokens();
|
|
1642
1720
|
}
|
|
1643
1721
|
}, [tokens.length, fetchSupportedTokens]);
|
|
1644
|
-
const getTokenBySymbol =
|
|
1722
|
+
const getTokenBySymbol = React4.useCallback(
|
|
1645
1723
|
(symbol) => {
|
|
1646
1724
|
return tokens.find((token) => token.symbol === symbol);
|
|
1647
1725
|
},
|
|
1648
1726
|
[tokens]
|
|
1649
1727
|
);
|
|
1650
|
-
const getTokenByMint =
|
|
1728
|
+
const getTokenByMint = React4.useCallback(
|
|
1651
1729
|
(mintAddress) => {
|
|
1652
1730
|
return tokens.find((token) => token.mint === mintAddress);
|
|
1653
1731
|
},
|
|
1654
1732
|
[tokens]
|
|
1655
1733
|
);
|
|
1656
|
-
const isTokenSupported =
|
|
1734
|
+
const isTokenSupported = React4.useCallback(
|
|
1657
1735
|
(symbol) => {
|
|
1658
1736
|
return tokens.some((token) => token.symbol === symbol);
|
|
1659
1737
|
},
|
|
1660
1738
|
[tokens]
|
|
1661
1739
|
);
|
|
1662
|
-
const getUSDCToken =
|
|
1740
|
+
const getUSDCToken = React4.useCallback(() => {
|
|
1663
1741
|
return getTokenBySymbol("USDC");
|
|
1664
1742
|
}, [getTokenBySymbol]);
|
|
1665
|
-
const getPYUSDToken =
|
|
1743
|
+
const getPYUSDToken = React4.useCallback(() => {
|
|
1666
1744
|
return getTokenBySymbol("PYUSD");
|
|
1667
1745
|
}, [getTokenBySymbol]);
|
|
1668
|
-
const getSOLToken =
|
|
1746
|
+
const getSOLToken = React4.useCallback(() => {
|
|
1669
1747
|
return getTokenBySymbol("SOL");
|
|
1670
1748
|
}, [getTokenBySymbol]);
|
|
1671
|
-
const getStablecoins =
|
|
1749
|
+
const getStablecoins = React4.useCallback(() => {
|
|
1672
1750
|
return tokens.filter((token) => ["USDC", "PYUSD"].includes(token.symbol));
|
|
1673
1751
|
}, [tokens]);
|
|
1674
|
-
const refreshTokens =
|
|
1752
|
+
const refreshTokens = React4.useCallback(async () => {
|
|
1675
1753
|
setLastFetched(null);
|
|
1676
1754
|
return await fetchSupportedTokens();
|
|
1677
1755
|
}, [fetchSupportedTokens]);
|
|
1678
|
-
const isCacheStale =
|
|
1756
|
+
const isCacheStale = React4.useCallback(() => {
|
|
1679
1757
|
if (!lastFetched) return true;
|
|
1680
1758
|
return Date.now() - lastFetched > CACHE_DURATION;
|
|
1681
1759
|
}, [lastFetched]);
|
|
1682
|
-
const getTokenDisplayInfo =
|
|
1760
|
+
const getTokenDisplayInfo = React4.useCallback((token) => {
|
|
1683
1761
|
return {
|
|
1684
1762
|
...token,
|
|
1685
1763
|
displayName: `${token.name} (${token.symbol})`,
|
|
@@ -1687,7 +1765,7 @@ var useSupportedTokens = () => {
|
|
|
1687
1765
|
decimalPlaces: token.decimals
|
|
1688
1766
|
};
|
|
1689
1767
|
}, []);
|
|
1690
|
-
const getTokenPrice =
|
|
1768
|
+
const getTokenPrice = React4.useCallback(
|
|
1691
1769
|
(symbol) => {
|
|
1692
1770
|
const token = getTokenBySymbol(symbol);
|
|
1693
1771
|
if (!token) return 0;
|
|
@@ -1696,7 +1774,7 @@ var useSupportedTokens = () => {
|
|
|
1696
1774
|
},
|
|
1697
1775
|
[getTokenBySymbol]
|
|
1698
1776
|
);
|
|
1699
|
-
const calculateTokenAmount =
|
|
1777
|
+
const calculateTokenAmount = React4.useCallback(
|
|
1700
1778
|
(usdAmount, tokenSymbol) => {
|
|
1701
1779
|
const token = getTokenBySymbol(tokenSymbol);
|
|
1702
1780
|
const price = getTokenPrice(tokenSymbol);
|
|
@@ -1707,7 +1785,7 @@ var useSupportedTokens = () => {
|
|
|
1707
1785
|
},
|
|
1708
1786
|
[getTokenBySymbol, getTokenPrice]
|
|
1709
1787
|
);
|
|
1710
|
-
const formatTokenAmount =
|
|
1788
|
+
const formatTokenAmount = React4.useCallback(
|
|
1711
1789
|
(amount, tokenSymbol) => {
|
|
1712
1790
|
const token = getTokenBySymbol(tokenSymbol);
|
|
1713
1791
|
if (!token) return "0";
|
|
@@ -1748,28 +1826,28 @@ var SolanaPaymentView = ({
|
|
|
1748
1826
|
onClose
|
|
1749
1827
|
}) => {
|
|
1750
1828
|
const { notifyStatus, notifyError, notifySuccess } = usePaymentNotifications();
|
|
1751
|
-
const [paymentState, setPaymentState] =
|
|
1752
|
-
const [errorMessage, setErrorMessage] =
|
|
1753
|
-
const [transactionId, setTransactionId] =
|
|
1754
|
-
const [tokenAmount, setTokenAmount] =
|
|
1755
|
-
const [selectedTokenSymbol, setSelectedTokenSymbol] =
|
|
1829
|
+
const [paymentState, setPaymentState] = React4.useState("selecting");
|
|
1830
|
+
const [errorMessage, setErrorMessage] = React4.useState(null);
|
|
1831
|
+
const [transactionId, setTransactionId] = React4.useState(null);
|
|
1832
|
+
const [tokenAmount, setTokenAmount] = React4.useState(0);
|
|
1833
|
+
const [selectedTokenSymbol, setSelectedTokenSymbol] = React4.useState(null);
|
|
1756
1834
|
const {
|
|
1757
1835
|
tokens,
|
|
1758
1836
|
isLoading: tokensLoading,
|
|
1759
1837
|
error: tokensError
|
|
1760
1838
|
} = useSupportedTokens();
|
|
1761
|
-
const selectedToken =
|
|
1839
|
+
const selectedToken = React4.useMemo(() => {
|
|
1762
1840
|
if (!tokens.length) return null;
|
|
1763
1841
|
const explicit = tokens.find((token) => token.symbol === selectedTokenSymbol);
|
|
1764
1842
|
return explicit || tokens[0];
|
|
1765
1843
|
}, [tokens, selectedTokenSymbol]);
|
|
1766
|
-
|
|
1844
|
+
React4.useEffect(() => {
|
|
1767
1845
|
if (!selectedTokenSymbol && tokens.length) {
|
|
1768
1846
|
const defaultToken = tokens.find((token) => token.symbol === "SOL") || tokens[0];
|
|
1769
1847
|
setSelectedTokenSymbol(defaultToken.symbol);
|
|
1770
1848
|
}
|
|
1771
1849
|
}, [tokens, selectedTokenSymbol]);
|
|
1772
|
-
const handlePaymentSuccess =
|
|
1850
|
+
const handlePaymentSuccess = React4.useCallback(
|
|
1773
1851
|
(result, txId) => {
|
|
1774
1852
|
const resolvedTx = txId || (typeof result === "string" ? result : result.transaction_id);
|
|
1775
1853
|
setTransactionId(resolvedTx);
|
|
@@ -1797,7 +1875,7 @@ var SolanaPaymentView = ({
|
|
|
1797
1875
|
},
|
|
1798
1876
|
[notifyStatus, notifySuccess, onSuccess]
|
|
1799
1877
|
);
|
|
1800
|
-
const handlePaymentError =
|
|
1878
|
+
const handlePaymentError = React4.useCallback(
|
|
1801
1879
|
(error) => {
|
|
1802
1880
|
setPaymentState("error");
|
|
1803
1881
|
setErrorMessage(error);
|
|
@@ -1807,22 +1885,22 @@ var SolanaPaymentView = ({
|
|
|
1807
1885
|
},
|
|
1808
1886
|
[notifyError, notifyStatus, onError]
|
|
1809
1887
|
);
|
|
1810
|
-
const resetState =
|
|
1888
|
+
const resetState = React4.useCallback(() => {
|
|
1811
1889
|
setPaymentState("selecting");
|
|
1812
1890
|
setErrorMessage(null);
|
|
1813
1891
|
setTransactionId(null);
|
|
1814
1892
|
}, []);
|
|
1815
|
-
const handleRetry =
|
|
1893
|
+
const handleRetry = React4.useCallback(() => {
|
|
1816
1894
|
resetState();
|
|
1817
1895
|
}, [resetState]);
|
|
1818
|
-
const handleClose =
|
|
1896
|
+
const handleClose = React4.useCallback(() => {
|
|
1819
1897
|
if (paymentState === "processing" || paymentState === "confirming") {
|
|
1820
1898
|
return;
|
|
1821
1899
|
}
|
|
1822
1900
|
resetState();
|
|
1823
1901
|
onClose?.();
|
|
1824
1902
|
}, [paymentState, onClose, resetState]);
|
|
1825
|
-
|
|
1903
|
+
React4.useEffect(() => {
|
|
1826
1904
|
if (!selectedToken || usdAmount === 0) {
|
|
1827
1905
|
setTokenAmount(0);
|
|
1828
1906
|
return;
|
|
@@ -1834,7 +1912,7 @@ var SolanaPaymentView = ({
|
|
|
1834
1912
|
}
|
|
1835
1913
|
setTokenAmount(usdAmount / price);
|
|
1836
1914
|
}, [usdAmount, selectedToken]);
|
|
1837
|
-
const handleTokenChange =
|
|
1915
|
+
const handleTokenChange = React4.useCallback((value) => {
|
|
1838
1916
|
setSelectedTokenSymbol(value);
|
|
1839
1917
|
}, []);
|
|
1840
1918
|
const renderBody = () => {
|
|
@@ -1940,20 +2018,20 @@ var PaymentExperience = ({
|
|
|
1940
2018
|
const showNewCard = enableNewCard && Boolean(onNewCardPayment);
|
|
1941
2019
|
const showStored = enableStoredMethods && Boolean(onSavedMethodPayment);
|
|
1942
2020
|
const defaultTab = showStored ? "saved" : "new";
|
|
1943
|
-
const [activeTab, setActiveTab] =
|
|
1944
|
-
const [mode, setMode] =
|
|
2021
|
+
const [activeTab, setActiveTab] = React4.useState(defaultTab);
|
|
2022
|
+
const [mode, setMode] = React4.useState(
|
|
1945
2023
|
() => initialMode === "solana" && enableSolanaPay ? "solana" : "cards"
|
|
1946
2024
|
);
|
|
1947
|
-
const [selectedMethodId, setSelectedMethodId] =
|
|
1948
|
-
const [savedStatus, setSavedStatus] =
|
|
1949
|
-
const [savedError, setSavedError] =
|
|
1950
|
-
const [newCardStatus, setNewCardStatus] =
|
|
1951
|
-
const [newCardError, setNewCardError] =
|
|
2025
|
+
const [selectedMethodId, setSelectedMethodId] = React4.useState(null);
|
|
2026
|
+
const [savedStatus, setSavedStatus] = React4.useState("idle");
|
|
2027
|
+
const [savedError, setSavedError] = React4.useState(null);
|
|
2028
|
+
const [newCardStatus, setNewCardStatus] = React4.useState("idle");
|
|
2029
|
+
const [newCardError, setNewCardError] = React4.useState(null);
|
|
1952
2030
|
const { notifyStatus, notifyError } = usePaymentNotifications();
|
|
1953
|
-
|
|
2031
|
+
React4.useEffect(() => {
|
|
1954
2032
|
setActiveTab(showStored ? "saved" : "new");
|
|
1955
2033
|
}, [showStored]);
|
|
1956
|
-
|
|
2034
|
+
React4.useEffect(() => {
|
|
1957
2035
|
if (!enableSolanaPay) {
|
|
1958
2036
|
setMode("cards");
|
|
1959
2037
|
return;
|
|
@@ -1964,12 +2042,12 @@ var PaymentExperience = ({
|
|
|
1964
2042
|
setMode("cards");
|
|
1965
2043
|
}
|
|
1966
2044
|
}, [enableSolanaPay, initialMode]);
|
|
1967
|
-
const handleMethodSelect =
|
|
2045
|
+
const handleMethodSelect = React4.useCallback((method) => {
|
|
1968
2046
|
setSelectedMethodId(method.id);
|
|
1969
2047
|
setSavedStatus("idle");
|
|
1970
2048
|
setSavedError(null);
|
|
1971
2049
|
}, []);
|
|
1972
|
-
const handleSavedPayment =
|
|
2050
|
+
const handleSavedPayment = React4.useCallback(async () => {
|
|
1973
2051
|
if (!onSavedMethodPayment || !selectedMethodId) return;
|
|
1974
2052
|
try {
|
|
1975
2053
|
setSavedStatus("processing");
|
|
@@ -1989,7 +2067,7 @@ var PaymentExperience = ({
|
|
|
1989
2067
|
notifyError(message);
|
|
1990
2068
|
}
|
|
1991
2069
|
}, [notifyError, notifyStatus, onSavedMethodPayment, selectedMethodId, usdAmount]);
|
|
1992
|
-
const handleNewCardTokenize =
|
|
2070
|
+
const handleNewCardTokenize = React4.useCallback(
|
|
1993
2071
|
async (token, billing) => {
|
|
1994
2072
|
if (!onNewCardPayment) return;
|
|
1995
2073
|
try {
|
|
@@ -2009,21 +2087,21 @@ var PaymentExperience = ({
|
|
|
2009
2087
|
},
|
|
2010
2088
|
[notifyError, notifyStatus, onNewCardPayment]
|
|
2011
2089
|
);
|
|
2012
|
-
|
|
2090
|
+
React4.useCallback(() => {
|
|
2013
2091
|
if (!enableSolanaPay) return;
|
|
2014
2092
|
setMode("solana");
|
|
2015
2093
|
}, [enableSolanaPay]);
|
|
2016
|
-
const exitSolanaView =
|
|
2094
|
+
const exitSolanaView = React4.useCallback(() => {
|
|
2017
2095
|
setMode("cards");
|
|
2018
2096
|
}, []);
|
|
2019
|
-
const handleSolanaSuccess =
|
|
2097
|
+
const handleSolanaSuccess = React4.useCallback(
|
|
2020
2098
|
(result) => {
|
|
2021
2099
|
onSolanaSuccess?.(result);
|
|
2022
2100
|
exitSolanaView();
|
|
2023
2101
|
},
|
|
2024
2102
|
[exitSolanaView, onSolanaSuccess]
|
|
2025
2103
|
);
|
|
2026
|
-
const handleSolanaError =
|
|
2104
|
+
const handleSolanaError = React4.useCallback(
|
|
2027
2105
|
(error) => {
|
|
2028
2106
|
onSolanaError?.(error);
|
|
2029
2107
|
},
|
|
@@ -2070,8 +2148,8 @@ var PaymentExperience = ({
|
|
|
2070
2148
|
};
|
|
2071
2149
|
const renderCardExperience = () => /* @__PURE__ */ jsxRuntime.jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, children: [
|
|
2072
2150
|
/* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "w-full rounded-md mb-4", children: [
|
|
2073
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className:
|
|
2074
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className:
|
|
2151
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className: "cursor-pointer", value: "saved", children: "Use saved card" }),
|
|
2152
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className: "cursor-pointer", value: "new", children: "Add new card" })
|
|
2075
2153
|
] }),
|
|
2076
2154
|
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
|
|
2077
2155
|
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "new", children: renderNewTab() })
|
|
@@ -2126,7 +2204,7 @@ var useSubscriptionActions = () => {
|
|
|
2126
2204
|
}
|
|
2127
2205
|
return priceId;
|
|
2128
2206
|
};
|
|
2129
|
-
const subscribeWithCard =
|
|
2207
|
+
const subscribeWithCard = React4.useCallback(
|
|
2130
2208
|
async ({
|
|
2131
2209
|
priceId,
|
|
2132
2210
|
processor = "nmi",
|
|
@@ -2153,7 +2231,7 @@ var useSubscriptionActions = () => {
|
|
|
2153
2231
|
},
|
|
2154
2232
|
[client]
|
|
2155
2233
|
);
|
|
2156
|
-
const subscribeWithSavedMethod =
|
|
2234
|
+
const subscribeWithSavedMethod = React4.useCallback(
|
|
2157
2235
|
async ({
|
|
2158
2236
|
priceId,
|
|
2159
2237
|
processor = "nmi",
|
|
@@ -2173,7 +2251,7 @@ var useSubscriptionActions = () => {
|
|
|
2173
2251
|
},
|
|
2174
2252
|
[client]
|
|
2175
2253
|
);
|
|
2176
|
-
const subscribeWithCCBill =
|
|
2254
|
+
const subscribeWithCCBill = React4.useCallback(
|
|
2177
2255
|
async ({
|
|
2178
2256
|
priceId,
|
|
2179
2257
|
email,
|
|
@@ -2219,15 +2297,15 @@ var SubscriptionCheckoutModal = ({
|
|
|
2219
2297
|
onSolanaError,
|
|
2220
2298
|
initialMode = "cards"
|
|
2221
2299
|
}) => {
|
|
2222
|
-
const [showSuccess, setShowSuccess] =
|
|
2223
|
-
const [idempotencyKey, setIdempotencyKey] =
|
|
2300
|
+
const [showSuccess, setShowSuccess] = React4.useState(false);
|
|
2301
|
+
const [idempotencyKey, setIdempotencyKey] = React4.useState(() => crypto.randomUUID());
|
|
2224
2302
|
const { subscribeWithCard, subscribeWithSavedMethod } = useSubscriptionActions();
|
|
2225
|
-
|
|
2303
|
+
React4.useEffect(() => {
|
|
2226
2304
|
if (open) {
|
|
2227
2305
|
setIdempotencyKey(crypto.randomUUID());
|
|
2228
2306
|
}
|
|
2229
2307
|
}, [open, priceId]);
|
|
2230
|
-
const handleClose =
|
|
2308
|
+
const handleClose = React4.useCallback(
|
|
2231
2309
|
(nextOpen) => {
|
|
2232
2310
|
onOpenChange(nextOpen);
|
|
2233
2311
|
if (!nextOpen) setShowSuccess(false);
|
|
@@ -2337,7 +2415,7 @@ var wallets = [
|
|
|
2337
2415
|
}
|
|
2338
2416
|
];
|
|
2339
2417
|
var WalletModal = ({ open, onOpenChange }) => {
|
|
2340
|
-
const [expandedWallet, setExpandedWallet] =
|
|
2418
|
+
const [expandedWallet, setExpandedWallet] = React4.useState(null);
|
|
2341
2419
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "z-[100] w-full max-w-lg max-h-[90vh] overflow-y-auto rounded-md border border-white/20 p-0 backdrop-blur-xl bg-background-regular shadow-2xl [&::-webkit-scrollbar]:hidden", children: [
|
|
2342
2420
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { className: "border-b border-white/10 bg-gradient-to-r from-primary/10 via-transparent to-transparent px-6 py-5 text-left", children: [
|
|
2343
2421
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-2 text-foreground", children: [
|
|
@@ -2393,17 +2471,17 @@ var createDialogState = () => ({
|
|
|
2393
2471
|
isOpen: false,
|
|
2394
2472
|
props: null
|
|
2395
2473
|
});
|
|
2396
|
-
var PaymentsDialogContext =
|
|
2474
|
+
var PaymentsDialogContext = React4.createContext(void 0);
|
|
2397
2475
|
var PaymentsDialogProvider = ({
|
|
2398
2476
|
children
|
|
2399
2477
|
}) => {
|
|
2400
|
-
const [checkoutState, setCheckoutState] =
|
|
2478
|
+
const [checkoutState, setCheckoutState] = React4.useState(
|
|
2401
2479
|
() => createDialogState()
|
|
2402
2480
|
);
|
|
2403
|
-
const [walletState, setWalletState] =
|
|
2481
|
+
const [walletState, setWalletState] = React4.useState(
|
|
2404
2482
|
() => createDialogState()
|
|
2405
2483
|
);
|
|
2406
|
-
const contextValue =
|
|
2484
|
+
const contextValue = React4.useMemo(() => {
|
|
2407
2485
|
const openCheckout = (options) => setCheckoutState({
|
|
2408
2486
|
isOpen: true,
|
|
2409
2487
|
props: options
|
|
@@ -2457,18 +2535,18 @@ var PaymentsDialogProvider = ({
|
|
|
2457
2535
|
] });
|
|
2458
2536
|
};
|
|
2459
2537
|
var usePaymentDialogs = () => {
|
|
2460
|
-
const context =
|
|
2538
|
+
const context = React4.useContext(PaymentsDialogContext);
|
|
2461
2539
|
if (!context) {
|
|
2462
2540
|
throw new Error("usePaymentDialogs must be used within PaymentProvider");
|
|
2463
2541
|
}
|
|
2464
2542
|
return context;
|
|
2465
2543
|
};
|
|
2466
|
-
var PaymentContext =
|
|
2544
|
+
var PaymentContext = React4.createContext(void 0);
|
|
2467
2545
|
var PaymentProvider = ({
|
|
2468
2546
|
config,
|
|
2469
2547
|
children
|
|
2470
2548
|
}) => {
|
|
2471
|
-
const queryClient =
|
|
2549
|
+
const queryClient = React4.useMemo(() => {
|
|
2472
2550
|
return new reactQuery.QueryClient({
|
|
2473
2551
|
defaultOptions: {
|
|
2474
2552
|
queries: {
|
|
@@ -2483,7 +2561,7 @@ var PaymentProvider = ({
|
|
|
2483
2561
|
}
|
|
2484
2562
|
});
|
|
2485
2563
|
}, []);
|
|
2486
|
-
const client =
|
|
2564
|
+
const client = React4.useMemo(() => {
|
|
2487
2565
|
const authProvider = config.getAuthToken ? async () => {
|
|
2488
2566
|
try {
|
|
2489
2567
|
const result = config.getAuthToken?.();
|
|
@@ -2507,12 +2585,12 @@ var PaymentProvider = ({
|
|
|
2507
2585
|
defaultHeaders: config.defaultHeaders
|
|
2508
2586
|
});
|
|
2509
2587
|
}, [config]);
|
|
2510
|
-
const solanaEndpoint =
|
|
2588
|
+
const solanaEndpoint = React4.useMemo(() => {
|
|
2511
2589
|
if (config.solana?.endpoint) return config.solana.endpoint;
|
|
2512
2590
|
const network = config.solana?.network ?? walletAdapterBase.WalletAdapterNetwork.Mainnet;
|
|
2513
2591
|
return web3_js.clusterApiUrl(network);
|
|
2514
2592
|
}, [config.solana?.endpoint, config.solana?.network]);
|
|
2515
|
-
const walletAdapters =
|
|
2593
|
+
const walletAdapters = React4.useMemo(() => {
|
|
2516
2594
|
if (config.solana?.wallets?.length) {
|
|
2517
2595
|
return config.solana.wallets;
|
|
2518
2596
|
}
|
|
@@ -2524,21 +2602,21 @@ var PaymentProvider = ({
|
|
|
2524
2602
|
];
|
|
2525
2603
|
}, [config.solana?.wallets]);
|
|
2526
2604
|
const autoConnect = config.solana?.autoConnect ?? true;
|
|
2527
|
-
const value =
|
|
2605
|
+
const value = React4.useMemo(() => {
|
|
2528
2606
|
return {
|
|
2529
2607
|
config,
|
|
2530
2608
|
client,
|
|
2531
2609
|
queryClient
|
|
2532
2610
|
};
|
|
2533
2611
|
}, [client, config, queryClient]);
|
|
2534
|
-
|
|
2612
|
+
React4.useEffect(() => {
|
|
2535
2613
|
if (!config.collectJsKey) return;
|
|
2536
2614
|
loadCollectJs(config.collectJsKey);
|
|
2537
2615
|
}, [config.collectJsKey]);
|
|
2538
2616
|
return /* @__PURE__ */ jsxRuntime.jsx(PaymentContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReact.ConnectionProvider, { endpoint: solanaEndpoint, config: { commitment: "confirmed" }, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReact.WalletProvider, { wallets: walletAdapters, autoConnect, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReactUi.WalletModalProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(PaymentsDialogProvider, { children }) }) }) }) }) });
|
|
2539
2617
|
};
|
|
2540
2618
|
var usePaymentContext = () => {
|
|
2541
|
-
const context =
|
|
2619
|
+
const context = React4.useContext(PaymentContext);
|
|
2542
2620
|
if (!context) {
|
|
2543
2621
|
throw new Error("usePaymentContext must be used within a PaymentProvider");
|
|
2544
2622
|
}
|
|
@@ -2551,7 +2629,7 @@ var SolanaPaymentSelector = ({
|
|
|
2551
2629
|
}) => {
|
|
2552
2630
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (value) => value ? void 0 : onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "w-full max-w-2xl max-h-[90vh] overflow-y-auto rounded-md border bg-background/95 p-0 shadow-2xl [&::-webkit-scrollbar]:hidden", children: /* @__PURE__ */ jsxRuntime.jsx(SolanaPaymentView, { ...props, onClose }) }) });
|
|
2553
2631
|
};
|
|
2554
|
-
var Table =
|
|
2632
|
+
var Table = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2555
2633
|
"table",
|
|
2556
2634
|
{
|
|
2557
2635
|
ref,
|
|
@@ -2560,9 +2638,9 @@ var Table = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
2560
2638
|
}
|
|
2561
2639
|
) }));
|
|
2562
2640
|
Table.displayName = "Table";
|
|
2563
|
-
var TableHeader =
|
|
2641
|
+
var TableHeader = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
2564
2642
|
TableHeader.displayName = "TableHeader";
|
|
2565
|
-
var TableBody =
|
|
2643
|
+
var TableBody = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2566
2644
|
"tbody",
|
|
2567
2645
|
{
|
|
2568
2646
|
ref,
|
|
@@ -2571,7 +2649,7 @@ var TableBody = React15__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2571
2649
|
}
|
|
2572
2650
|
));
|
|
2573
2651
|
TableBody.displayName = "TableBody";
|
|
2574
|
-
var TableFooter =
|
|
2652
|
+
var TableFooter = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2575
2653
|
"tfoot",
|
|
2576
2654
|
{
|
|
2577
2655
|
ref,
|
|
@@ -2583,7 +2661,7 @@ var TableFooter = React15__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
2583
2661
|
}
|
|
2584
2662
|
));
|
|
2585
2663
|
TableFooter.displayName = "TableFooter";
|
|
2586
|
-
var TableRow =
|
|
2664
|
+
var TableRow = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2587
2665
|
"tr",
|
|
2588
2666
|
{
|
|
2589
2667
|
ref,
|
|
@@ -2595,7 +2673,7 @@ var TableRow = React15__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
2595
2673
|
}
|
|
2596
2674
|
));
|
|
2597
2675
|
TableRow.displayName = "TableRow";
|
|
2598
|
-
var TableHead =
|
|
2676
|
+
var TableHead = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2599
2677
|
"th",
|
|
2600
2678
|
{
|
|
2601
2679
|
ref,
|
|
@@ -2607,7 +2685,7 @@ var TableHead = React15__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2607
2685
|
}
|
|
2608
2686
|
));
|
|
2609
2687
|
TableHead.displayName = "TableHead";
|
|
2610
|
-
var TableCell =
|
|
2688
|
+
var TableCell = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2611
2689
|
"td",
|
|
2612
2690
|
{
|
|
2613
2691
|
ref,
|
|
@@ -2616,7 +2694,7 @@ var TableCell = React15__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2616
2694
|
}
|
|
2617
2695
|
));
|
|
2618
2696
|
TableCell.displayName = "TableCell";
|
|
2619
|
-
var TableCaption =
|
|
2697
|
+
var TableCaption = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2620
2698
|
"caption",
|
|
2621
2699
|
{
|
|
2622
2700
|
ref,
|
|
@@ -2628,7 +2706,7 @@ TableCaption.displayName = "TableCaption";
|
|
|
2628
2706
|
var AlertDialog = AlertDialogPrimitive__namespace.Root;
|
|
2629
2707
|
var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
2630
2708
|
var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
2631
|
-
var AlertDialogOverlay =
|
|
2709
|
+
var AlertDialogOverlay = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2632
2710
|
AlertDialogPrimitive__namespace.Overlay,
|
|
2633
2711
|
{
|
|
2634
2712
|
className: cn(
|
|
@@ -2640,7 +2718,7 @@ var AlertDialogOverlay = React15__namespace.forwardRef(({ className, ...props },
|
|
|
2640
2718
|
}
|
|
2641
2719
|
));
|
|
2642
2720
|
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
2643
|
-
var AlertDialogContent =
|
|
2721
|
+
var AlertDialogContent = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
2644
2722
|
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
2645
2723
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2646
2724
|
AlertDialogPrimitive__namespace.Content,
|
|
@@ -2683,7 +2761,7 @@ var AlertDialogFooter = ({
|
|
|
2683
2761
|
}
|
|
2684
2762
|
);
|
|
2685
2763
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
2686
|
-
var AlertDialogTitle =
|
|
2764
|
+
var AlertDialogTitle = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2687
2765
|
AlertDialogPrimitive__namespace.Title,
|
|
2688
2766
|
{
|
|
2689
2767
|
ref,
|
|
@@ -2692,7 +2770,7 @@ var AlertDialogTitle = React15__namespace.forwardRef(({ className, ...props }, r
|
|
|
2692
2770
|
}
|
|
2693
2771
|
));
|
|
2694
2772
|
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
2695
|
-
var AlertDialogDescription =
|
|
2773
|
+
var AlertDialogDescription = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2696
2774
|
AlertDialogPrimitive__namespace.Description,
|
|
2697
2775
|
{
|
|
2698
2776
|
ref,
|
|
@@ -2701,7 +2779,7 @@ var AlertDialogDescription = React15__namespace.forwardRef(({ className, ...prop
|
|
|
2701
2779
|
}
|
|
2702
2780
|
));
|
|
2703
2781
|
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
2704
|
-
var AlertDialogAction =
|
|
2782
|
+
var AlertDialogAction = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2705
2783
|
AlertDialogPrimitive__namespace.Action,
|
|
2706
2784
|
{
|
|
2707
2785
|
ref,
|
|
@@ -2710,7 +2788,7 @@ var AlertDialogAction = React15__namespace.forwardRef(({ className, ...props },
|
|
|
2710
2788
|
}
|
|
2711
2789
|
));
|
|
2712
2790
|
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
2713
|
-
var AlertDialogCancel =
|
|
2791
|
+
var AlertDialogCancel = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2714
2792
|
AlertDialogPrimitive__namespace.Cancel,
|
|
2715
2793
|
{
|
|
2716
2794
|
ref,
|
|
@@ -2723,7 +2801,7 @@ var AlertDialogCancel = React15__namespace.forwardRef(({ className, ...props },
|
|
|
2723
2801
|
}
|
|
2724
2802
|
));
|
|
2725
2803
|
AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
|
|
2726
|
-
var Textarea =
|
|
2804
|
+
var Textarea = React4__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2727
2805
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2728
2806
|
"textarea",
|
|
2729
2807
|
{
|
|
@@ -2768,12 +2846,12 @@ var CancelMembershipDialog = ({
|
|
|
2768
2846
|
const { client } = usePaymentContext();
|
|
2769
2847
|
const notify = onNotify ?? notifyDefault;
|
|
2770
2848
|
const t = { ...defaultTranslations, ...customTranslations };
|
|
2771
|
-
const [cancelReason, setCancelReason] =
|
|
2772
|
-
const [isOpen, setIsOpen] =
|
|
2773
|
-
const [isReasonValid, setIsReasonValid] =
|
|
2774
|
-
const [hasInteracted, setHasInteracted] =
|
|
2775
|
-
const [isSubmitting, setIsSubmitting] =
|
|
2776
|
-
|
|
2849
|
+
const [cancelReason, setCancelReason] = React4.useState("");
|
|
2850
|
+
const [isOpen, setIsOpen] = React4.useState(false);
|
|
2851
|
+
const [isReasonValid, setIsReasonValid] = React4.useState(false);
|
|
2852
|
+
const [hasInteracted, setHasInteracted] = React4.useState(false);
|
|
2853
|
+
const [isSubmitting, setIsSubmitting] = React4.useState(false);
|
|
2854
|
+
React4.useEffect(() => {
|
|
2777
2855
|
const trimmed = cancelReason.trim();
|
|
2778
2856
|
setIsReasonValid(trimmed.length >= minReasonLength);
|
|
2779
2857
|
}, [cancelReason, minReasonLength]);
|
|
@@ -2906,9 +2984,9 @@ var BillingHistory = ({
|
|
|
2906
2984
|
const { client } = usePaymentContext();
|
|
2907
2985
|
const notify = onNotify ?? notifyDefault2;
|
|
2908
2986
|
const t = { ...defaultTranslations2, ...customTranslations };
|
|
2909
|
-
const [isExpanded, setIsExpanded] =
|
|
2910
|
-
const observerRef =
|
|
2911
|
-
const loadMoreRef =
|
|
2987
|
+
const [isExpanded, setIsExpanded] = React4.useState(false);
|
|
2988
|
+
const observerRef = React4.useRef(null);
|
|
2989
|
+
const loadMoreRef = React4.useRef(null);
|
|
2912
2990
|
const historyQuery = reactQuery.useInfiniteQuery({
|
|
2913
2991
|
queryKey: ["payments-ui", "billing-history", pageSize],
|
|
2914
2992
|
queryFn: async ({ pageParam = initialPage }) => {
|
|
@@ -2935,7 +3013,7 @@ var BillingHistory = ({
|
|
|
2935
3013
|
},
|
|
2936
3014
|
staleTime: 5 * 60 * 1e3
|
|
2937
3015
|
});
|
|
2938
|
-
|
|
3016
|
+
React4.useEffect(() => {
|
|
2939
3017
|
if (!loadMoreRef.current || !isExpanded) return;
|
|
2940
3018
|
observerRef.current = new IntersectionObserver((entries) => {
|
|
2941
3019
|
const [entry] = entries;
|
|
@@ -2950,7 +3028,7 @@ var BillingHistory = ({
|
|
|
2950
3028
|
observerRef.current?.disconnect();
|
|
2951
3029
|
};
|
|
2952
3030
|
}, [historyQuery, isExpanded, notify]);
|
|
2953
|
-
const payments =
|
|
3031
|
+
const payments = React4.useMemo(() => {
|
|
2954
3032
|
const data = historyQuery.data;
|
|
2955
3033
|
return data?.pages ?? [];
|
|
2956
3034
|
}, [historyQuery.data]);
|
|
@@ -3063,8 +3141,8 @@ var PaymentMethodsSection = ({
|
|
|
3063
3141
|
remove: (id) => client.deletePaymentMethod(id),
|
|
3064
3142
|
activate: (id) => client.activatePaymentMethod(id)
|
|
3065
3143
|
};
|
|
3066
|
-
const [isModalOpen, setIsModalOpen] =
|
|
3067
|
-
const [deletingId, setDeletingId] =
|
|
3144
|
+
const [isModalOpen, setIsModalOpen] = React4.useState(false);
|
|
3145
|
+
const [deletingId, setDeletingId] = React4.useState(null);
|
|
3068
3146
|
const notify = onNotify ?? notifyDefault3;
|
|
3069
3147
|
const t = { ...defaultTranslations3, ...customTranslations };
|
|
3070
3148
|
const queryKey = ["payments-ui", "payment-methods"];
|
|
@@ -3119,12 +3197,12 @@ var PaymentMethodsSection = ({
|
|
|
3119
3197
|
});
|
|
3120
3198
|
}
|
|
3121
3199
|
});
|
|
3122
|
-
|
|
3200
|
+
React4.useEffect(() => {
|
|
3123
3201
|
if (!isModalOpen) {
|
|
3124
3202
|
createMutation.reset();
|
|
3125
3203
|
}
|
|
3126
3204
|
}, [createMutation, isModalOpen]);
|
|
3127
|
-
const payments =
|
|
3205
|
+
const payments = React4.useMemo(() => paymentQuery.data?.data ?? [], [paymentQuery.data]);
|
|
3128
3206
|
const loading = paymentQuery.isLoading || paymentQuery.isFetching;
|
|
3129
3207
|
const buildPayload = (token, billing) => ({
|
|
3130
3208
|
payment_token: token,
|
|
@@ -3231,7 +3309,7 @@ var PaymentMethodsSection = ({
|
|
|
3231
3309
|
) })
|
|
3232
3310
|
] });
|
|
3233
3311
|
};
|
|
3234
|
-
var Checkbox =
|
|
3312
|
+
var Checkbox = React4__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3235
3313
|
CheckboxPrimitive__namespace.Root,
|
|
3236
3314
|
{
|
|
3237
3315
|
ref,
|
|
@@ -3258,9 +3336,9 @@ var initialState = {
|
|
|
3258
3336
|
termsAccepted: false
|
|
3259
3337
|
};
|
|
3260
3338
|
var WalletDialog = ({ open, onOpenChange }) => {
|
|
3261
|
-
const [form, setForm] =
|
|
3262
|
-
const [errors, setErrors] =
|
|
3263
|
-
const validators =
|
|
3339
|
+
const [form, setForm] = React4.useState(initialState);
|
|
3340
|
+
const [errors, setErrors] = React4.useState({});
|
|
3341
|
+
const validators = React4.useMemo(
|
|
3264
3342
|
() => ({
|
|
3265
3343
|
nameOnCard: (value) => !value ? "Name is required" : void 0,
|
|
3266
3344
|
cardNumber: (value) => /^\d{16}$/.test(value) ? void 0 : "Card number must be 16 digits",
|
|
@@ -3353,10 +3431,10 @@ var WalletDialog = ({ open, onOpenChange }) => {
|
|
|
3353
3431
|
var useTokenBalance = (tokens) => {
|
|
3354
3432
|
const { publicKey } = walletAdapterReact.useWallet();
|
|
3355
3433
|
const { connection } = walletAdapterReact.useConnection();
|
|
3356
|
-
const [balances, setBalances] =
|
|
3357
|
-
const [isLoading, setIsLoading] =
|
|
3358
|
-
const [error, setError] =
|
|
3359
|
-
const fetchTokenBalance =
|
|
3434
|
+
const [balances, setBalances] = React4.useState([]);
|
|
3435
|
+
const [isLoading, setIsLoading] = React4.useState(false);
|
|
3436
|
+
const [error, setError] = React4.useState(null);
|
|
3437
|
+
const fetchTokenBalance = React4.useCallback(
|
|
3360
3438
|
async (token, walletAddress) => {
|
|
3361
3439
|
try {
|
|
3362
3440
|
const mintPublicKey = new web3_js.PublicKey(token.mint);
|
|
@@ -3397,8 +3475,8 @@ var useTokenBalance = (tokens) => {
|
|
|
3397
3475
|
},
|
|
3398
3476
|
[connection]
|
|
3399
3477
|
);
|
|
3400
|
-
const tokensKey =
|
|
3401
|
-
|
|
3478
|
+
const tokensKey = React4.useMemo(() => tokens.map((t) => t.mint).join(","), [tokens]);
|
|
3479
|
+
React4.useEffect(() => {
|
|
3402
3480
|
if (!publicKey || tokens.length === 0) {
|
|
3403
3481
|
setBalances([]);
|
|
3404
3482
|
return;
|
|
@@ -3422,20 +3500,20 @@ var useTokenBalance = (tokens) => {
|
|
|
3422
3500
|
};
|
|
3423
3501
|
fetchAllBalances();
|
|
3424
3502
|
}, [publicKey, tokensKey, fetchTokenBalance]);
|
|
3425
|
-
const getTokenBalance =
|
|
3503
|
+
const getTokenBalance = React4.useCallback(
|
|
3426
3504
|
(tokenSymbol) => {
|
|
3427
3505
|
return balances.find((balance) => balance.token.symbol === tokenSymbol);
|
|
3428
3506
|
},
|
|
3429
3507
|
[balances]
|
|
3430
3508
|
);
|
|
3431
|
-
const hasSufficientBalance =
|
|
3509
|
+
const hasSufficientBalance = React4.useCallback(
|
|
3432
3510
|
(tokenSymbol, requiredAmount) => {
|
|
3433
3511
|
const balance = getTokenBalance(tokenSymbol);
|
|
3434
3512
|
return balance ? balance.uiAmount >= requiredAmount : false;
|
|
3435
3513
|
},
|
|
3436
3514
|
[getTokenBalance]
|
|
3437
3515
|
);
|
|
3438
|
-
const getFormattedBalance =
|
|
3516
|
+
const getFormattedBalance = React4.useCallback(
|
|
3439
3517
|
(tokenSymbol) => {
|
|
3440
3518
|
const balance = getTokenBalance(tokenSymbol);
|
|
3441
3519
|
if (!balance) return "0.00";
|
|
@@ -3449,7 +3527,7 @@ var useTokenBalance = (tokens) => {
|
|
|
3449
3527
|
},
|
|
3450
3528
|
[getTokenBalance]
|
|
3451
3529
|
);
|
|
3452
|
-
const refreshBalances =
|
|
3530
|
+
const refreshBalances = React4.useCallback(async () => {
|
|
3453
3531
|
if (!publicKey || tokens.length === 0) {
|
|
3454
3532
|
setBalances([]);
|
|
3455
3533
|
return;
|
|
@@ -3470,7 +3548,7 @@ var useTokenBalance = (tokens) => {
|
|
|
3470
3548
|
setIsLoading(false);
|
|
3471
3549
|
}
|
|
3472
3550
|
}, [publicKey, tokens, fetchTokenBalance]);
|
|
3473
|
-
const getTotalValue =
|
|
3551
|
+
const getTotalValue = React4.useCallback(
|
|
3474
3552
|
(priceData) => {
|
|
3475
3553
|
if (!priceData) return 0;
|
|
3476
3554
|
return balances.reduce((total, balance) => {
|
|
@@ -3509,21 +3587,21 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3509
3587
|
retryInterval = 1e4
|
|
3510
3588
|
// 10 seconds
|
|
3511
3589
|
} = options;
|
|
3512
|
-
const [status, setStatus] =
|
|
3513
|
-
const [paymentStatus, setPaymentStatus] =
|
|
3514
|
-
const [isLoading, setIsLoading] =
|
|
3515
|
-
const [error, setError] =
|
|
3516
|
-
const [retryCount, setRetryCount] =
|
|
3517
|
-
const intervalRef =
|
|
3518
|
-
const isMonitoringRef =
|
|
3519
|
-
|
|
3590
|
+
const [status, setStatus] = React4.useState(null);
|
|
3591
|
+
const [paymentStatus, setPaymentStatus] = React4.useState(null);
|
|
3592
|
+
const [isLoading, setIsLoading] = React4.useState(false);
|
|
3593
|
+
const [error, setError] = React4.useState(null);
|
|
3594
|
+
const [retryCount, setRetryCount] = React4.useState(0);
|
|
3595
|
+
const intervalRef = React4.useRef(null);
|
|
3596
|
+
const isMonitoringRef = React4.useRef(false);
|
|
3597
|
+
React4.useEffect(() => {
|
|
3520
3598
|
return () => {
|
|
3521
3599
|
if (intervalRef.current) {
|
|
3522
3600
|
clearInterval(intervalRef.current);
|
|
3523
3601
|
}
|
|
3524
3602
|
};
|
|
3525
3603
|
}, []);
|
|
3526
|
-
const checkTransactionStatus =
|
|
3604
|
+
const checkTransactionStatus = React4.useCallback(
|
|
3527
3605
|
async (signature) => {
|
|
3528
3606
|
try {
|
|
3529
3607
|
const statusResponse = await connection.getSignatureStatus(signature, {
|
|
@@ -3568,7 +3646,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3568
3646
|
},
|
|
3569
3647
|
[connection]
|
|
3570
3648
|
);
|
|
3571
|
-
const checkPaymentStatus =
|
|
3649
|
+
const checkPaymentStatus = React4.useCallback(
|
|
3572
3650
|
async (id) => {
|
|
3573
3651
|
try {
|
|
3574
3652
|
return await client.getPaymentStatus(id);
|
|
@@ -3582,7 +3660,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3582
3660
|
},
|
|
3583
3661
|
[client]
|
|
3584
3662
|
);
|
|
3585
|
-
const startMonitoring =
|
|
3663
|
+
const startMonitoring = React4.useCallback(async () => {
|
|
3586
3664
|
if (isMonitoringRef.current || !transactionId && !purchaseId) {
|
|
3587
3665
|
return;
|
|
3588
3666
|
}
|
|
@@ -3670,14 +3748,14 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3670
3748
|
retryInterval,
|
|
3671
3749
|
retryCount
|
|
3672
3750
|
]);
|
|
3673
|
-
const stopMonitoring =
|
|
3751
|
+
const stopMonitoring = React4.useCallback(() => {
|
|
3674
3752
|
if (intervalRef.current) {
|
|
3675
3753
|
clearInterval(intervalRef.current);
|
|
3676
3754
|
}
|
|
3677
3755
|
isMonitoringRef.current = false;
|
|
3678
3756
|
setIsLoading(false);
|
|
3679
3757
|
}, []);
|
|
3680
|
-
const checkStatus =
|
|
3758
|
+
const checkStatus = React4.useCallback(async () => {
|
|
3681
3759
|
if (!transactionId && !purchaseId) return;
|
|
3682
3760
|
setIsLoading(true);
|
|
3683
3761
|
setError(null);
|
|
@@ -3702,7 +3780,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3702
3780
|
setIsLoading(false);
|
|
3703
3781
|
}
|
|
3704
3782
|
}, [transactionId, purchaseId, checkTransactionStatus, checkPaymentStatus]);
|
|
3705
|
-
|
|
3783
|
+
React4.useEffect(() => {
|
|
3706
3784
|
if ((transactionId || purchaseId) && !isMonitoringRef.current) {
|
|
3707
3785
|
startMonitoring();
|
|
3708
3786
|
}
|
|
@@ -3710,7 +3788,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3710
3788
|
stopMonitoring();
|
|
3711
3789
|
};
|
|
3712
3790
|
}, [transactionId, purchaseId, startMonitoring, stopMonitoring]);
|
|
3713
|
-
const getConfirmationStatus =
|
|
3791
|
+
const getConfirmationStatus = React4.useCallback(() => {
|
|
3714
3792
|
if (paymentStatus?.status === "confirmed") return "confirmed";
|
|
3715
3793
|
if (paymentStatus?.status === "failed") return "failed";
|
|
3716
3794
|
if (status?.confirmationStatus === "finalized") return "confirmed";
|
|
@@ -3719,7 +3797,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3719
3797
|
return "failed";
|
|
3720
3798
|
return "pending";
|
|
3721
3799
|
}, [status, paymentStatus]);
|
|
3722
|
-
const getSolscanUrl =
|
|
3800
|
+
const getSolscanUrl = React4.useCallback(
|
|
3723
3801
|
(signature) => {
|
|
3724
3802
|
const txId = signature || transactionId;
|
|
3725
3803
|
if (!txId) return null;
|