@reevit/react 0.3.8 → 0.4.0
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.js +96 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -7
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +152 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1382,6 +1382,87 @@ function loadStripeScript() {
|
|
|
1382
1382
|
});
|
|
1383
1383
|
return stripeScriptPromise;
|
|
1384
1384
|
}
|
|
1385
|
+
var getReevitStripeAppearance = () => {
|
|
1386
|
+
const isDarkMode = typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches;
|
|
1387
|
+
return {
|
|
1388
|
+
theme: isDarkMode ? "night" : "stripe",
|
|
1389
|
+
variables: {
|
|
1390
|
+
colorPrimary: isDarkMode ? "#fafafa" : "#171717",
|
|
1391
|
+
colorBackground: isDarkMode ? "#171717" : "#ffffff",
|
|
1392
|
+
colorText: isDarkMode ? "#fafafa" : "#171717",
|
|
1393
|
+
colorTextSecondary: isDarkMode ? "#a3a3a3" : "#737373",
|
|
1394
|
+
colorTextPlaceholder: isDarkMode ? "#737373" : "#a3a3a3",
|
|
1395
|
+
colorDanger: "#dc2626",
|
|
1396
|
+
fontFamily: '"Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
|
|
1397
|
+
fontSizeBase: "14px",
|
|
1398
|
+
fontSizeSm: "12px",
|
|
1399
|
+
fontSizeLg: "16px",
|
|
1400
|
+
fontWeightNormal: "400",
|
|
1401
|
+
fontWeightMedium: "500",
|
|
1402
|
+
fontWeightBold: "600",
|
|
1403
|
+
borderRadius: "10px",
|
|
1404
|
+
spacingUnit: "4px",
|
|
1405
|
+
spacingGridRow: "16px",
|
|
1406
|
+
spacingGridColumn: "16px"
|
|
1407
|
+
},
|
|
1408
|
+
rules: {
|
|
1409
|
+
".Input": {
|
|
1410
|
+
border: isDarkMode ? "1px solid rgba(255, 255, 255, 0.1)" : "1px solid #e5e5e5",
|
|
1411
|
+
boxShadow: "none",
|
|
1412
|
+
padding: "12px 14px",
|
|
1413
|
+
fontSize: "14px",
|
|
1414
|
+
backgroundColor: isDarkMode ? "#262626" : "#ffffff"
|
|
1415
|
+
},
|
|
1416
|
+
".Input:focus": {
|
|
1417
|
+
border: isDarkMode ? "1px solid #a3a3a3" : "1px solid #737373",
|
|
1418
|
+
boxShadow: "none",
|
|
1419
|
+
backgroundColor: isDarkMode ? "#262626" : "#fafafa"
|
|
1420
|
+
},
|
|
1421
|
+
".Input--invalid": {
|
|
1422
|
+
border: "1px solid #dc2626",
|
|
1423
|
+
boxShadow: "none"
|
|
1424
|
+
},
|
|
1425
|
+
".Label": {
|
|
1426
|
+
fontSize: "12px",
|
|
1427
|
+
fontWeight: "500",
|
|
1428
|
+
marginBottom: "6px",
|
|
1429
|
+
color: isDarkMode ? "#a3a3a3" : "#737373",
|
|
1430
|
+
textTransform: "none",
|
|
1431
|
+
letterSpacing: "0.02em"
|
|
1432
|
+
},
|
|
1433
|
+
".Tab": {
|
|
1434
|
+
border: isDarkMode ? "1px solid rgba(255, 255, 255, 0.1)" : "1px solid #e5e5e5",
|
|
1435
|
+
backgroundColor: "transparent",
|
|
1436
|
+
borderRadius: "10px",
|
|
1437
|
+
padding: "12px 14px"
|
|
1438
|
+
},
|
|
1439
|
+
".Tab:hover": {
|
|
1440
|
+
border: isDarkMode ? "1px solid #a3a3a3" : "1px solid #737373",
|
|
1441
|
+
backgroundColor: isDarkMode ? "#262626" : "#fafafa"
|
|
1442
|
+
},
|
|
1443
|
+
".Tab--selected": {
|
|
1444
|
+
border: isDarkMode ? "1px solid #fafafa" : "1px solid #171717",
|
|
1445
|
+
backgroundColor: isDarkMode ? "#262626" : "#fafafa"
|
|
1446
|
+
},
|
|
1447
|
+
".TabIcon": {
|
|
1448
|
+
marginRight: "8px"
|
|
1449
|
+
},
|
|
1450
|
+
".Block": {
|
|
1451
|
+
border: isDarkMode ? "1px solid rgba(255, 255, 255, 0.1)" : "1px solid #e5e5e5",
|
|
1452
|
+
borderRadius: "10px",
|
|
1453
|
+
backgroundColor: isDarkMode ? "#262626" : "#ffffff",
|
|
1454
|
+
padding: "12px 14px"
|
|
1455
|
+
},
|
|
1456
|
+
".CheckboxInput": {
|
|
1457
|
+
border: isDarkMode ? "1px solid rgba(255, 255, 255, 0.1)" : "1px solid #e5e5e5"
|
|
1458
|
+
},
|
|
1459
|
+
".CheckboxInput--checked": {
|
|
1460
|
+
backgroundColor: isDarkMode ? "#fafafa" : "#171717",
|
|
1461
|
+
borderColor: isDarkMode ? "#fafafa" : "#171717"
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
};
|
|
1385
1466
|
function StripeBridge({
|
|
1386
1467
|
publishableKey,
|
|
1387
1468
|
clientSecret,
|
|
@@ -1409,9 +1490,10 @@ function StripeBridge({
|
|
|
1409
1490
|
throw new Error("Stripe not available");
|
|
1410
1491
|
}
|
|
1411
1492
|
stripeRef.current = window.Stripe(publishableKey);
|
|
1493
|
+
const stripeAppearance = appearance || getReevitStripeAppearance();
|
|
1412
1494
|
elementsRef.current = stripeRef.current.elements({
|
|
1413
1495
|
clientSecret,
|
|
1414
|
-
appearance:
|
|
1496
|
+
appearance: stripeAppearance
|
|
1415
1497
|
});
|
|
1416
1498
|
paymentElementRef.current = elementsRef.current.create("payment");
|
|
1417
1499
|
if (containerRef.current) {
|
|
@@ -1481,6 +1563,12 @@ function StripeBridge({
|
|
|
1481
1563
|
setIsSubmitting(false);
|
|
1482
1564
|
}
|
|
1483
1565
|
}, [onSuccess, onError]);
|
|
1566
|
+
const formattedAmount = new Intl.NumberFormat("en-US", {
|
|
1567
|
+
style: "currency",
|
|
1568
|
+
currency: currency.toUpperCase(),
|
|
1569
|
+
minimumFractionDigits: 2,
|
|
1570
|
+
maximumFractionDigits: 2
|
|
1571
|
+
}).format(amount / 100);
|
|
1484
1572
|
return /* @__PURE__ */ jsxs("div", { className: "reevit-stripe-bridge", children: [
|
|
1485
1573
|
isLoading && /* @__PURE__ */ jsxs("div", { className: "reevit-stripe-loading", children: [
|
|
1486
1574
|
/* @__PURE__ */ jsx("div", { className: "reevit-spinner" }),
|
|
@@ -1494,8 +1582,8 @@ function StripeBridge({
|
|
|
1494
1582
|
style: { display: isLoading ? "none" : "block", minHeight: "200px" }
|
|
1495
1583
|
}
|
|
1496
1584
|
),
|
|
1497
|
-
error && /* @__PURE__ */ jsx("div", { className: "reevit-stripe-error", children: /* @__PURE__ */ jsx("p", { children: error }) }),
|
|
1498
|
-
/* @__PURE__ */ jsxs("div", { className: "reevit-stripe-actions", children: [
|
|
1585
|
+
error && !isLoading && /* @__PURE__ */ jsx("div", { className: "reevit-stripe-error", children: /* @__PURE__ */ jsx("p", { children: error }) }),
|
|
1586
|
+
!isLoading && /* @__PURE__ */ jsxs("div", { className: "reevit-stripe-actions", children: [
|
|
1499
1587
|
/* @__PURE__ */ jsx(
|
|
1500
1588
|
"button",
|
|
1501
1589
|
{
|
|
@@ -1503,11 +1591,12 @@ function StripeBridge({
|
|
|
1503
1591
|
className: "reevit-submit-btn",
|
|
1504
1592
|
onClick: handleSubmit,
|
|
1505
1593
|
disabled: isLoading || isSubmitting,
|
|
1506
|
-
children: isSubmitting ? /* @__PURE__ */
|
|
1594
|
+
children: isSubmitting ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1595
|
+
/* @__PURE__ */ jsx("span", { className: "reevit-spinner", style: { width: "16px", height: "16px" } }),
|
|
1596
|
+
/* @__PURE__ */ jsx("span", { children: "Processing..." })
|
|
1597
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1507
1598
|
"Pay ",
|
|
1508
|
-
|
|
1509
|
-
" ",
|
|
1510
|
-
(amount / 100).toFixed(2)
|
|
1599
|
+
formattedAmount
|
|
1511
1600
|
] })
|
|
1512
1601
|
}
|
|
1513
1602
|
),
|