@schematichq/schematic-components 0.7.12 → 0.7.13
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/schematic-components.cjs.js +87 -58
- package/dist/schematic-components.esm.js +87 -58
- package/package.json +10 -10
|
@@ -16416,7 +16416,7 @@ var en_default = {
|
|
|
16416
16416
|
Monthly: "Monthly",
|
|
16417
16417
|
Next: "Next",
|
|
16418
16418
|
"No limit": "No limit",
|
|
16419
|
-
"No payment method
|
|
16419
|
+
"No payment method added yet": "No payment method added yet",
|
|
16420
16420
|
"Not ready to cancel?": "Not ready to cancel?",
|
|
16421
16421
|
"On demand": "On demand",
|
|
16422
16422
|
"One time ": "One time",
|
|
@@ -16439,6 +16439,7 @@ var en_default = {
|
|
|
16439
16439
|
"See less": "See less",
|
|
16440
16440
|
"See more": "See more",
|
|
16441
16441
|
"Select add-ons": "Select add-ons",
|
|
16442
|
+
"Select existing payment method": "Select existing payment method",
|
|
16442
16443
|
"Select payment method": "Select payment method",
|
|
16443
16444
|
"Select plan": "Select plan",
|
|
16444
16445
|
"Select quantity": "Select quantity",
|
|
@@ -17147,7 +17148,7 @@ var EmbedProvider = ({
|
|
|
17147
17148
|
(0, import_react11.useEffect)(() => {
|
|
17148
17149
|
if (accessToken) {
|
|
17149
17150
|
const { headers = {} } = apiConfig ?? {};
|
|
17150
|
-
headers["X-Schematic-Components-Version"] = "0.7.
|
|
17151
|
+
headers["X-Schematic-Components-Version"] = "0.7.13";
|
|
17151
17152
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
17152
17153
|
const config = new Configuration({
|
|
17153
17154
|
...apiConfig,
|
|
@@ -20961,7 +20962,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20961
20962
|
const contentRef = (0, import_react26.useRef)(null);
|
|
20962
20963
|
const checkoutRef = (0, import_react26.useRef)(null);
|
|
20963
20964
|
const [charges, setCharges] = (0, import_react26.useState)();
|
|
20964
|
-
const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
|
|
20965
|
+
const [paymentMethodId, setPaymentMethodId] = (0, import_react26.useState)(
|
|
20966
|
+
(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
|
|
20967
|
+
);
|
|
20965
20968
|
const [isLoading, setIsLoading] = (0, import_react26.useState)(false);
|
|
20966
20969
|
const [error, setError] = (0, import_react26.useState)();
|
|
20967
20970
|
const [promoCode, setPromoCode] = (0, import_react26.useState)();
|
|
@@ -21451,6 +21454,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21451
21454
|
const [message, setMessage] = (0, import_react27.useState)(null);
|
|
21452
21455
|
const [isLoading, setIsLoading] = (0, import_react27.useState)(false);
|
|
21453
21456
|
const [isConfirmed, setIsConfirmed] = (0, import_react27.useState)(false);
|
|
21457
|
+
const [isComplete, setIsComplete] = (0, import_react27.useState)(false);
|
|
21454
21458
|
const handleSubmit = async (event) => {
|
|
21455
21459
|
event.preventDefault();
|
|
21456
21460
|
if (!api || !stripe || !elements) {
|
|
@@ -21493,12 +21497,20 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21493
21497
|
overflowY: "auto"
|
|
21494
21498
|
},
|
|
21495
21499
|
children: [
|
|
21496
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21500
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21501
|
+
import_react_stripe_js.PaymentElement,
|
|
21502
|
+
{
|
|
21503
|
+
id: "payment-element",
|
|
21504
|
+
onChange: (event) => {
|
|
21505
|
+
setIsComplete(event.complete);
|
|
21506
|
+
}
|
|
21507
|
+
}
|
|
21508
|
+
) }),
|
|
21497
21509
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
21498
21510
|
Button,
|
|
21499
21511
|
{
|
|
21500
21512
|
id: "submit",
|
|
21501
|
-
disabled: isLoading || !stripe || !elements || isConfirmed,
|
|
21513
|
+
disabled: isLoading || !stripe || !elements || isConfirmed || !isComplete,
|
|
21502
21514
|
style: { flexShrink: 0 },
|
|
21503
21515
|
$color: "primary",
|
|
21504
21516
|
$isLoading: isLoading,
|
|
@@ -23041,7 +23053,7 @@ var PaymentElement2 = ({
|
|
|
23041
23053
|
};
|
|
23042
23054
|
var EmptyPaymentElement = () => {
|
|
23043
23055
|
const theme = nt();
|
|
23044
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method
|
|
23056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Flex, { $alignItems: "center", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method added yet") }) }) }) });
|
|
23045
23057
|
};
|
|
23046
23058
|
var getPaymentMethodData = ({
|
|
23047
23059
|
accountLast4,
|
|
@@ -23383,7 +23395,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
23383
23395
|
}
|
|
23384
23396
|
stripe._registerWrapper({
|
|
23385
23397
|
name: "stripe-js",
|
|
23386
|
-
version: "7.
|
|
23398
|
+
version: "7.2.0",
|
|
23387
23399
|
startTime
|
|
23388
23400
|
});
|
|
23389
23401
|
};
|
|
@@ -23458,7 +23470,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
23458
23470
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
23459
23471
|
var expectedVersion = RELEASE_TRAIN;
|
|
23460
23472
|
if (isTestKey && version !== expectedVersion) {
|
|
23461
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
23473
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
23462
23474
|
}
|
|
23463
23475
|
var stripe = maybeStripe.apply(void 0, args);
|
|
23464
23476
|
registerWrapper(stripe, startTime);
|
|
@@ -23523,12 +23535,7 @@ var PaymentMethodDetails = ({
|
|
|
23523
23535
|
const [stripe, setStripe] = (0, import_react38.useState)(null);
|
|
23524
23536
|
const [setupIntent, setSetupIntent] = (0, import_react38.useState)();
|
|
23525
23537
|
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
|
|
23526
|
-
const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(
|
|
23527
|
-
(0, import_react38.useEffect)(() => {
|
|
23528
|
-
setPaymentMethod(
|
|
23529
|
-
data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
|
|
23530
|
-
);
|
|
23531
|
-
}, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
|
|
23538
|
+
const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
|
|
23532
23539
|
const monthsToExpiration = (0, import_react38.useMemo)(() => {
|
|
23533
23540
|
let expiration;
|
|
23534
23541
|
if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
|
|
@@ -23542,33 +23549,25 @@ var PaymentMethodDetails = ({
|
|
|
23542
23549
|
}
|
|
23543
23550
|
return expiration;
|
|
23544
23551
|
}, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
|
|
23545
|
-
(0, import_react38.useEffect)(() => {
|
|
23546
|
-
if (!stripe && setupIntent?.publishableKey) {
|
|
23547
|
-
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23548
|
-
}
|
|
23549
|
-
}, [stripe, setupIntent?.publishableKey]);
|
|
23550
23552
|
const createSetupIntent = (0, import_react38.useCallback)(async () => {
|
|
23551
23553
|
if (!api || !data.component?.id) {
|
|
23552
23554
|
return;
|
|
23553
23555
|
}
|
|
23554
23556
|
try {
|
|
23555
23557
|
setIsLoading(true);
|
|
23556
|
-
const
|
|
23558
|
+
const response = await api.getSetupIntent({
|
|
23557
23559
|
componentId: data.component.id
|
|
23558
23560
|
});
|
|
23559
|
-
setSetupIntent(
|
|
23560
|
-
setShowPaymentForm(true);
|
|
23561
|
+
setSetupIntent(response.data);
|
|
23561
23562
|
} catch {
|
|
23562
23563
|
setError(
|
|
23563
23564
|
t2("Error initializing payment method change. Please try again.")
|
|
23564
23565
|
);
|
|
23565
23566
|
} finally {
|
|
23567
|
+
setShowPaymentForm(true);
|
|
23566
23568
|
setIsLoading(false);
|
|
23567
23569
|
}
|
|
23568
23570
|
}, [t2, api, data.component?.id]);
|
|
23569
|
-
const dropDownDifferentPaymentMethods = (0, import_react38.useCallback)(() => {
|
|
23570
|
-
setShowDifferentPaymentMethods((state) => !state);
|
|
23571
|
-
}, []);
|
|
23572
23571
|
const updatePaymentMethod = (0, import_react38.useCallback)(
|
|
23573
23572
|
async (externalId) => {
|
|
23574
23573
|
if (!api || !externalId) {
|
|
@@ -23645,33 +23644,43 @@ var PaymentMethodDetails = ({
|
|
|
23645
23644
|
},
|
|
23646
23645
|
[api, data, setData, t2]
|
|
23647
23646
|
);
|
|
23647
|
+
(0, import_react38.useEffect)(() => {
|
|
23648
|
+
if (!stripe && setupIntent?.publishableKey) {
|
|
23649
|
+
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23650
|
+
}
|
|
23651
|
+
}, [stripe, setupIntent?.publishableKey]);
|
|
23652
|
+
(0, import_react38.useEffect)(() => {
|
|
23653
|
+
if (!setupIntent && (!paymentMethod || showPaymentForm)) {
|
|
23654
|
+
createSetupIntent();
|
|
23655
|
+
}
|
|
23656
|
+
}, [setupIntent, paymentMethod, showPaymentForm, createSetupIntent]);
|
|
23648
23657
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $position: "relative", children: [
|
|
23649
|
-
|
|
23658
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23650
23659
|
Flex,
|
|
23651
23660
|
{
|
|
23652
23661
|
$position: "absolute",
|
|
23653
|
-
$
|
|
23654
|
-
$height: "100%",
|
|
23662
|
+
$zIndex: isLoading ? 1 : 0,
|
|
23655
23663
|
$justifyContent: "center",
|
|
23656
23664
|
$alignItems: "center",
|
|
23657
|
-
$
|
|
23658
|
-
$
|
|
23659
|
-
$
|
|
23660
|
-
$opacity: 0.5,
|
|
23661
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl" })
|
|
23665
|
+
$width: "100%",
|
|
23666
|
+
$height: "100%",
|
|
23667
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Loader, { $color: theme.primary, $size: "2xl", $isLoading: isLoading })
|
|
23662
23668
|
}
|
|
23663
23669
|
),
|
|
23664
23670
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23665
23671
|
Flex,
|
|
23666
23672
|
{
|
|
23673
|
+
$position: "relative",
|
|
23674
|
+
$zIndex: isLoading ? 0 : 1,
|
|
23667
23675
|
$flexDirection: "column",
|
|
23668
|
-
$flexGrow:
|
|
23676
|
+
$flexGrow: 1,
|
|
23669
23677
|
$gap: "1rem",
|
|
23678
|
+
$overflow: "auto",
|
|
23670
23679
|
$padding: "2rem 2.5rem 2rem 2.5rem",
|
|
23680
|
+
$visibility: isLoading ? "hidden" : "visible",
|
|
23671
23681
|
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
|
|
23672
|
-
$overflow: "auto",
|
|
23673
23682
|
children: [
|
|
23674
|
-
showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.
|
|
23683
|
+
setupIntent && showPaymentForm ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23675
23684
|
import_react_stripe_js2.Elements,
|
|
23676
23685
|
{
|
|
23677
23686
|
stripe,
|
|
@@ -23700,16 +23709,32 @@ var PaymentMethodDetails = ({
|
|
|
23700
23709
|
},
|
|
23701
23710
|
clientSecret: setupIntent?.setupIntentClientSecret
|
|
23702
23711
|
},
|
|
23703
|
-
children:
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23709
|
-
|
|
23712
|
+
children: [
|
|
23713
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23714
|
+
PaymentForm,
|
|
23715
|
+
{
|
|
23716
|
+
onConfirm: async (paymentMethodId) => {
|
|
23717
|
+
await updatePaymentMethod(paymentMethodId);
|
|
23718
|
+
setShowPaymentForm(false);
|
|
23719
|
+
setShowDifferentPaymentMethods(false);
|
|
23720
|
+
}
|
|
23710
23721
|
}
|
|
23711
|
-
|
|
23712
|
-
|
|
23722
|
+
),
|
|
23723
|
+
paymentMethod && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23724
|
+
Text,
|
|
23725
|
+
{
|
|
23726
|
+
onClick: () => {
|
|
23727
|
+
setShowPaymentForm(false);
|
|
23728
|
+
setShowDifferentPaymentMethods(false);
|
|
23729
|
+
},
|
|
23730
|
+
$font: theme.typography.link.fontFamily,
|
|
23731
|
+
$size: theme.typography.link.fontSize,
|
|
23732
|
+
$weight: theme.typography.link.fontWeight,
|
|
23733
|
+
$color: theme.typography.link.color,
|
|
23734
|
+
children: t2("Select existing payment method")
|
|
23735
|
+
}
|
|
23736
|
+
) })
|
|
23737
|
+
]
|
|
23713
23738
|
}
|
|
23714
23739
|
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $gap: "2rem", children: [
|
|
23715
23740
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
@@ -23724,7 +23749,9 @@ var PaymentMethodDetails = ({
|
|
|
23724
23749
|
(data.company?.paymentMethods || []).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
23725
23750
|
Text,
|
|
23726
23751
|
{
|
|
23727
|
-
onClick:
|
|
23752
|
+
onClick: () => {
|
|
23753
|
+
setShowDifferentPaymentMethods((prev2) => !prev2);
|
|
23754
|
+
},
|
|
23728
23755
|
$font: theme.typography.link.fontFamily,
|
|
23729
23756
|
$size: theme.typography.link.fontSize,
|
|
23730
23757
|
$weight: theme.typography.link.fontWeight,
|
|
@@ -23747,18 +23774,20 @@ var PaymentMethodDetails = ({
|
|
|
23747
23774
|
]
|
|
23748
23775
|
}
|
|
23749
23776
|
) }),
|
|
23750
|
-
showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.
|
|
23751
|
-
(
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23777
|
+
showDifferentPaymentMethods && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Flex, { $flexDirection: "column", $overflowY: "hidden", children: [
|
|
23778
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Flex, { $flexDirection: "column", $overflowY: "scroll", children: (data.company?.paymentMethods.filter(
|
|
23779
|
+
(pm) => pm.id !== paymentMethod?.id
|
|
23780
|
+
) || []).map((paymentMethod2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23781
|
+
PaymentListElement,
|
|
23782
|
+
{
|
|
23783
|
+
paymentMethod: paymentMethod2,
|
|
23784
|
+
setDefault: updatePaymentMethod,
|
|
23785
|
+
handleDelete: deletePaymentMethod
|
|
23786
|
+
},
|
|
23787
|
+
paymentMethod2.id
|
|
23788
|
+
)) }),
|
|
23789
|
+
(!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
|
|
23790
|
+
] })
|
|
23762
23791
|
] }),
|
|
23763
23792
|
!isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
23764
23793
|
Text,
|
|
@@ -16363,7 +16363,7 @@ var en_default = {
|
|
|
16363
16363
|
Monthly: "Monthly",
|
|
16364
16364
|
Next: "Next",
|
|
16365
16365
|
"No limit": "No limit",
|
|
16366
|
-
"No payment method
|
|
16366
|
+
"No payment method added yet": "No payment method added yet",
|
|
16367
16367
|
"Not ready to cancel?": "Not ready to cancel?",
|
|
16368
16368
|
"On demand": "On demand",
|
|
16369
16369
|
"One time ": "One time",
|
|
@@ -16386,6 +16386,7 @@ var en_default = {
|
|
|
16386
16386
|
"See less": "See less",
|
|
16387
16387
|
"See more": "See more",
|
|
16388
16388
|
"Select add-ons": "Select add-ons",
|
|
16389
|
+
"Select existing payment method": "Select existing payment method",
|
|
16389
16390
|
"Select payment method": "Select payment method",
|
|
16390
16391
|
"Select plan": "Select plan",
|
|
16391
16392
|
"Select quantity": "Select quantity",
|
|
@@ -17094,7 +17095,7 @@ var EmbedProvider = ({
|
|
|
17094
17095
|
useEffect2(() => {
|
|
17095
17096
|
if (accessToken) {
|
|
17096
17097
|
const { headers = {} } = apiConfig ?? {};
|
|
17097
|
-
headers["X-Schematic-Components-Version"] = "0.7.
|
|
17098
|
+
headers["X-Schematic-Components-Version"] = "0.7.13";
|
|
17098
17099
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
17099
17100
|
const config = new Configuration({
|
|
17100
17101
|
...apiConfig,
|
|
@@ -20918,7 +20919,9 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
20918
20919
|
const contentRef = useRef5(null);
|
|
20919
20920
|
const checkoutRef = useRef5(null);
|
|
20920
20921
|
const [charges, setCharges] = useState8();
|
|
20921
|
-
const [paymentMethodId, setPaymentMethodId] = useState8(
|
|
20922
|
+
const [paymentMethodId, setPaymentMethodId] = useState8(
|
|
20923
|
+
(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod)?.externalId
|
|
20924
|
+
);
|
|
20922
20925
|
const [isLoading, setIsLoading] = useState8(false);
|
|
20923
20926
|
const [error, setError] = useState8();
|
|
20924
20927
|
const [promoCode, setPromoCode] = useState8();
|
|
@@ -21412,6 +21415,7 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21412
21415
|
const [message, setMessage] = useState9(null);
|
|
21413
21416
|
const [isLoading, setIsLoading] = useState9(false);
|
|
21414
21417
|
const [isConfirmed, setIsConfirmed] = useState9(false);
|
|
21418
|
+
const [isComplete, setIsComplete] = useState9(false);
|
|
21415
21419
|
const handleSubmit = async (event) => {
|
|
21416
21420
|
event.preventDefault();
|
|
21417
21421
|
if (!api || !stripe || !elements) {
|
|
@@ -21454,12 +21458,20 @@ var PaymentForm = ({ onConfirm }) => {
|
|
|
21454
21458
|
overflowY: "auto"
|
|
21455
21459
|
},
|
|
21456
21460
|
children: [
|
|
21457
|
-
/* @__PURE__ */ jsx21(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx21(
|
|
21461
|
+
/* @__PURE__ */ jsx21(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx21(
|
|
21462
|
+
PaymentElement,
|
|
21463
|
+
{
|
|
21464
|
+
id: "payment-element",
|
|
21465
|
+
onChange: (event) => {
|
|
21466
|
+
setIsComplete(event.complete);
|
|
21467
|
+
}
|
|
21468
|
+
}
|
|
21469
|
+
) }),
|
|
21458
21470
|
/* @__PURE__ */ jsx21(
|
|
21459
21471
|
Button,
|
|
21460
21472
|
{
|
|
21461
21473
|
id: "submit",
|
|
21462
|
-
disabled: isLoading || !stripe || !elements || isConfirmed,
|
|
21474
|
+
disabled: isLoading || !stripe || !elements || isConfirmed || !isComplete,
|
|
21463
21475
|
style: { flexShrink: 0 },
|
|
21464
21476
|
$color: "primary",
|
|
21465
21477
|
$isLoading: isLoading,
|
|
@@ -23002,7 +23014,7 @@ var PaymentElement2 = ({
|
|
|
23002
23014
|
};
|
|
23003
23015
|
var EmptyPaymentElement = () => {
|
|
23004
23016
|
const theme = nt();
|
|
23005
|
-
return /* @__PURE__ */ jsx32(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ jsx32(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ jsx32(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx32(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method
|
|
23017
|
+
return /* @__PURE__ */ jsx32(Text, { $font: theme.typography.text.fontFamily, $size: 16, children: /* @__PURE__ */ jsx32(Flex, { $flexDirection: "row", $alignItems: "center", children: /* @__PURE__ */ jsx32(Flex, { $alignItems: "center", children: /* @__PURE__ */ jsx32(Box, { $lineHeight: "1", $marginRight: "4px", children: t("No payment method added yet") }) }) }) });
|
|
23006
23018
|
};
|
|
23007
23019
|
var getPaymentMethodData = ({
|
|
23008
23020
|
accountLast4,
|
|
@@ -23344,7 +23356,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
|
|
|
23344
23356
|
}
|
|
23345
23357
|
stripe._registerWrapper({
|
|
23346
23358
|
name: "stripe-js",
|
|
23347
|
-
version: "7.
|
|
23359
|
+
version: "7.2.0",
|
|
23348
23360
|
startTime
|
|
23349
23361
|
});
|
|
23350
23362
|
};
|
|
@@ -23419,7 +23431,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
|
|
|
23419
23431
|
var version = runtimeVersionToUrlVersion(maybeStripe.version);
|
|
23420
23432
|
var expectedVersion = RELEASE_TRAIN;
|
|
23421
23433
|
if (isTestKey && version !== expectedVersion) {
|
|
23422
|
-
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.
|
|
23434
|
+
console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.2.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
|
|
23423
23435
|
}
|
|
23424
23436
|
var stripe = maybeStripe.apply(void 0, args);
|
|
23425
23437
|
registerWrapper(stripe, startTime);
|
|
@@ -23484,12 +23496,7 @@ var PaymentMethodDetails = ({
|
|
|
23484
23496
|
const [stripe, setStripe] = useState15(null);
|
|
23485
23497
|
const [setupIntent, setSetupIntent] = useState15();
|
|
23486
23498
|
const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState15(false);
|
|
23487
|
-
const [paymentMethod, setPaymentMethod] = useState15(
|
|
23488
|
-
useEffect6(() => {
|
|
23489
|
-
setPaymentMethod(
|
|
23490
|
-
data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
|
|
23491
|
-
);
|
|
23492
|
-
}, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
|
|
23499
|
+
const [paymentMethod, setPaymentMethod] = useState15(data.subscription?.paymentMethod || data.company?.defaultPaymentMethod);
|
|
23493
23500
|
const monthsToExpiration = useMemo13(() => {
|
|
23494
23501
|
let expiration;
|
|
23495
23502
|
if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
|
|
@@ -23503,33 +23510,25 @@ var PaymentMethodDetails = ({
|
|
|
23503
23510
|
}
|
|
23504
23511
|
return expiration;
|
|
23505
23512
|
}, [paymentMethod?.cardExpYear, paymentMethod?.cardExpMonth]);
|
|
23506
|
-
useEffect6(() => {
|
|
23507
|
-
if (!stripe && setupIntent?.publishableKey) {
|
|
23508
|
-
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23509
|
-
}
|
|
23510
|
-
}, [stripe, setupIntent?.publishableKey]);
|
|
23511
23513
|
const createSetupIntent = useCallback10(async () => {
|
|
23512
23514
|
if (!api || !data.component?.id) {
|
|
23513
23515
|
return;
|
|
23514
23516
|
}
|
|
23515
23517
|
try {
|
|
23516
23518
|
setIsLoading(true);
|
|
23517
|
-
const
|
|
23519
|
+
const response = await api.getSetupIntent({
|
|
23518
23520
|
componentId: data.component.id
|
|
23519
23521
|
});
|
|
23520
|
-
setSetupIntent(
|
|
23521
|
-
setShowPaymentForm(true);
|
|
23522
|
+
setSetupIntent(response.data);
|
|
23522
23523
|
} catch {
|
|
23523
23524
|
setError(
|
|
23524
23525
|
t2("Error initializing payment method change. Please try again.")
|
|
23525
23526
|
);
|
|
23526
23527
|
} finally {
|
|
23528
|
+
setShowPaymentForm(true);
|
|
23527
23529
|
setIsLoading(false);
|
|
23528
23530
|
}
|
|
23529
23531
|
}, [t2, api, data.component?.id]);
|
|
23530
|
-
const dropDownDifferentPaymentMethods = useCallback10(() => {
|
|
23531
|
-
setShowDifferentPaymentMethods((state) => !state);
|
|
23532
|
-
}, []);
|
|
23533
23532
|
const updatePaymentMethod = useCallback10(
|
|
23534
23533
|
async (externalId) => {
|
|
23535
23534
|
if (!api || !externalId) {
|
|
@@ -23606,33 +23605,43 @@ var PaymentMethodDetails = ({
|
|
|
23606
23605
|
},
|
|
23607
23606
|
[api, data, setData, t2]
|
|
23608
23607
|
);
|
|
23608
|
+
useEffect6(() => {
|
|
23609
|
+
if (!stripe && setupIntent?.publishableKey) {
|
|
23610
|
+
setStripe(loadStripe(setupIntent.publishableKey));
|
|
23611
|
+
}
|
|
23612
|
+
}, [stripe, setupIntent?.publishableKey]);
|
|
23613
|
+
useEffect6(() => {
|
|
23614
|
+
if (!setupIntent && (!paymentMethod || showPaymentForm)) {
|
|
23615
|
+
createSetupIntent();
|
|
23616
|
+
}
|
|
23617
|
+
}, [setupIntent, paymentMethod, showPaymentForm, createSetupIntent]);
|
|
23609
23618
|
return /* @__PURE__ */ jsxs26(Flex, { $position: "relative", children: [
|
|
23610
|
-
|
|
23619
|
+
/* @__PURE__ */ jsx34(
|
|
23611
23620
|
Flex,
|
|
23612
23621
|
{
|
|
23613
23622
|
$position: "absolute",
|
|
23614
|
-
$
|
|
23615
|
-
$height: "100%",
|
|
23623
|
+
$zIndex: isLoading ? 1 : 0,
|
|
23616
23624
|
$justifyContent: "center",
|
|
23617
23625
|
$alignItems: "center",
|
|
23618
|
-
$
|
|
23619
|
-
$
|
|
23620
|
-
$
|
|
23621
|
-
$opacity: 0.5,
|
|
23622
|
-
children: /* @__PURE__ */ jsx34(Loader, { $color: theme.primary, $size: "2xl" })
|
|
23626
|
+
$width: "100%",
|
|
23627
|
+
$height: "100%",
|
|
23628
|
+
children: /* @__PURE__ */ jsx34(Loader, { $color: theme.primary, $size: "2xl", $isLoading: isLoading })
|
|
23623
23629
|
}
|
|
23624
23630
|
),
|
|
23625
23631
|
/* @__PURE__ */ jsxs26(
|
|
23626
23632
|
Flex,
|
|
23627
23633
|
{
|
|
23634
|
+
$position: "relative",
|
|
23635
|
+
$zIndex: isLoading ? 0 : 1,
|
|
23628
23636
|
$flexDirection: "column",
|
|
23629
|
-
$flexGrow:
|
|
23637
|
+
$flexGrow: 1,
|
|
23630
23638
|
$gap: "1rem",
|
|
23639
|
+
$overflow: "auto",
|
|
23631
23640
|
$padding: "2rem 2.5rem 2rem 2.5rem",
|
|
23641
|
+
$visibility: isLoading ? "hidden" : "visible",
|
|
23632
23642
|
$backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.025)" : "hsla(0, 0%, 100%, 0.025)",
|
|
23633
|
-
$overflow: "auto",
|
|
23634
23643
|
children: [
|
|
23635
|
-
showPaymentForm ? /* @__PURE__ */
|
|
23644
|
+
setupIntent && showPaymentForm ? /* @__PURE__ */ jsxs26(
|
|
23636
23645
|
Elements,
|
|
23637
23646
|
{
|
|
23638
23647
|
stripe,
|
|
@@ -23661,16 +23670,32 @@ var PaymentMethodDetails = ({
|
|
|
23661
23670
|
},
|
|
23662
23671
|
clientSecret: setupIntent?.setupIntentClientSecret
|
|
23663
23672
|
},
|
|
23664
|
-
children:
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23673
|
+
children: [
|
|
23674
|
+
/* @__PURE__ */ jsx34(
|
|
23675
|
+
PaymentForm,
|
|
23676
|
+
{
|
|
23677
|
+
onConfirm: async (paymentMethodId) => {
|
|
23678
|
+
await updatePaymentMethod(paymentMethodId);
|
|
23679
|
+
setShowPaymentForm(false);
|
|
23680
|
+
setShowDifferentPaymentMethods(false);
|
|
23681
|
+
}
|
|
23671
23682
|
}
|
|
23672
|
-
|
|
23673
|
-
|
|
23683
|
+
),
|
|
23684
|
+
paymentMethod && /* @__PURE__ */ jsx34(Box, { children: /* @__PURE__ */ jsx34(
|
|
23685
|
+
Text,
|
|
23686
|
+
{
|
|
23687
|
+
onClick: () => {
|
|
23688
|
+
setShowPaymentForm(false);
|
|
23689
|
+
setShowDifferentPaymentMethods(false);
|
|
23690
|
+
},
|
|
23691
|
+
$font: theme.typography.link.fontFamily,
|
|
23692
|
+
$size: theme.typography.link.fontSize,
|
|
23693
|
+
$weight: theme.typography.link.fontWeight,
|
|
23694
|
+
$color: theme.typography.link.color,
|
|
23695
|
+
children: t2("Select existing payment method")
|
|
23696
|
+
}
|
|
23697
|
+
) })
|
|
23698
|
+
]
|
|
23674
23699
|
}
|
|
23675
23700
|
) : /* @__PURE__ */ jsxs26(Flex, { $flexDirection: "column", $gap: "2rem", children: [
|
|
23676
23701
|
/* @__PURE__ */ jsx34(
|
|
@@ -23685,7 +23710,9 @@ var PaymentMethodDetails = ({
|
|
|
23685
23710
|
(data.company?.paymentMethods || []).length > 0 && /* @__PURE__ */ jsx34(Box, { children: /* @__PURE__ */ jsxs26(
|
|
23686
23711
|
Text,
|
|
23687
23712
|
{
|
|
23688
|
-
onClick:
|
|
23713
|
+
onClick: () => {
|
|
23714
|
+
setShowDifferentPaymentMethods((prev2) => !prev2);
|
|
23715
|
+
},
|
|
23689
23716
|
$font: theme.typography.link.fontFamily,
|
|
23690
23717
|
$size: theme.typography.link.fontSize,
|
|
23691
23718
|
$weight: theme.typography.link.fontWeight,
|
|
@@ -23708,18 +23735,20 @@ var PaymentMethodDetails = ({
|
|
|
23708
23735
|
]
|
|
23709
23736
|
}
|
|
23710
23737
|
) }),
|
|
23711
|
-
showDifferentPaymentMethods && /* @__PURE__ */
|
|
23712
|
-
(
|
|
23713
|
-
|
|
23714
|
-
|
|
23715
|
-
|
|
23716
|
-
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
|
|
23720
|
-
|
|
23721
|
-
|
|
23722
|
-
|
|
23738
|
+
showDifferentPaymentMethods && /* @__PURE__ */ jsxs26(Flex, { $flexDirection: "column", $overflowY: "hidden", children: [
|
|
23739
|
+
/* @__PURE__ */ jsx34(Flex, { $flexDirection: "column", $overflowY: "scroll", children: (data.company?.paymentMethods.filter(
|
|
23740
|
+
(pm) => pm.id !== paymentMethod?.id
|
|
23741
|
+
) || []).map((paymentMethod2) => /* @__PURE__ */ jsx34(
|
|
23742
|
+
PaymentListElement,
|
|
23743
|
+
{
|
|
23744
|
+
paymentMethod: paymentMethod2,
|
|
23745
|
+
setDefault: updatePaymentMethod,
|
|
23746
|
+
handleDelete: deletePaymentMethod
|
|
23747
|
+
},
|
|
23748
|
+
paymentMethod2.id
|
|
23749
|
+
)) }),
|
|
23750
|
+
(!setupIntent || !paymentMethod || showDifferentPaymentMethods) && /* @__PURE__ */ jsx34(Button, { onClick: createSetupIntent, $size: "lg", children: t2("Add new payment method") })
|
|
23751
|
+
] })
|
|
23723
23752
|
] }),
|
|
23724
23753
|
!isLoading && error && /* @__PURE__ */ jsx34(Box, { children: /* @__PURE__ */ jsx34(
|
|
23725
23754
|
Text,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schematichq/schematic-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"main": "dist/schematic-components.cjs.js",
|
|
5
5
|
"module": "dist/schematic-components.esm.js",
|
|
6
6
|
"types": "dist/schematic-components.d.ts",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"tsc": "npx tsc"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stripe/stripe-js": "^7.
|
|
33
|
+
"@stripe/stripe-js": "^7.2.0",
|
|
34
34
|
"classnames": "^2.5.1",
|
|
35
|
-
"i18next": "^25.0.
|
|
35
|
+
"i18next": "^25.0.1",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"pako": "^2.1.0",
|
|
38
38
|
"pluralize": "^8.0.0",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@craftjs/core": "^0.2.12",
|
|
45
|
-
"@eslint/css": "^0.
|
|
46
|
-
"@eslint/js": "^9.
|
|
47
|
-
"@eslint/json": "^0.
|
|
45
|
+
"@eslint/css": "^0.7.0",
|
|
46
|
+
"@eslint/js": "^9.25.1",
|
|
47
|
+
"@eslint/json": "^0.12.0",
|
|
48
48
|
"@eslint/markdown": "^6.3.0",
|
|
49
|
-
"@microsoft/api-extractor": "^7.52.
|
|
49
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
50
50
|
"@openapitools/openapi-generator-cli": "^2.19.1",
|
|
51
51
|
"@stripe/react-stripe-js": "^3.6.0",
|
|
52
52
|
"@types/jest": "^29.5.14",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@types/react-dom": "^19.1.2",
|
|
58
58
|
"esbuild": "^0.25.2",
|
|
59
59
|
"esbuild-jest": "^0.5.0",
|
|
60
|
-
"eslint": "^9.
|
|
61
|
-
"eslint-import-resolver-typescript": "^4.3.
|
|
60
|
+
"eslint": "^9.25.1",
|
|
61
|
+
"eslint-import-resolver-typescript": "^4.3.4",
|
|
62
62
|
"eslint-plugin-import": "^2.31.0",
|
|
63
63
|
"eslint-plugin-react": "^7.37.5",
|
|
64
64
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"react-dom": "^19.1.0",
|
|
74
74
|
"ts-jest": "^29.3.2",
|
|
75
75
|
"typescript": "^5.8.3",
|
|
76
|
-
"typescript-eslint": "^8.
|
|
76
|
+
"typescript-eslint": "^8.31.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@stripe/react-stripe-js": ">=3",
|