@schematichq/schematic-components 0.4.8 → 0.4.9

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.
@@ -12824,7 +12824,7 @@ var EmbedProvider = ({
12824
12824
  (0, import_react11.useEffect)(() => {
12825
12825
  if (accessToken) {
12826
12826
  const { headers = {} } = apiConfig ?? {};
12827
- headers["X-Schematic-Components-Version"] = "0.4.8";
12827
+ headers["X-Schematic-Components-Version"] = "0.4.9";
12828
12828
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12829
12829
  const config = new Configuration({
12830
12830
  ...apiConfig,
@@ -13767,12 +13767,27 @@ var spin = mt`
13767
13767
  var Loader = dt.div`
13768
13768
  display: inline-block;
13769
13769
  border-style: solid;
13770
- border-color: hsla(0, 0%, 50%, 0.125);
13771
- border-top-color: ${({ theme, $color }) => $color || theme.primary};
13772
13770
  border-radius: 50%;
13773
13771
  transition: all 0.1s;
13774
13772
  animation: 1.5s linear infinite ${spin};
13775
13773
 
13774
+ ${({ $color, theme }) => {
13775
+ const { l: l2 } = hexToHSL(theme.card.background);
13776
+ let color = $color;
13777
+ let colorFn;
13778
+ if (l2 > 50) {
13779
+ color = color ?? "#000000";
13780
+ colorFn = lighten;
13781
+ } else {
13782
+ color = color ?? "#FFFFFF";
13783
+ colorFn = darken;
13784
+ }
13785
+ return lt`
13786
+ border-color: ${color};
13787
+ border-top-color: ${colorFn(color, 42.5)};
13788
+ `;
13789
+ }}
13790
+
13776
13791
  ${({ $size = "md", $isLoading = true }) => {
13777
13792
  let px;
13778
13793
  switch ($size) {
@@ -15687,16 +15702,7 @@ var Sidebar = ({
15687
15702
  trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
15688
15703
  }
15689
15704
  ),
15690
- layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
15691
- EmbedButton,
15692
- {
15693
- onClick: async () => {
15694
- unsubscribe();
15695
- },
15696
- isLoading,
15697
- children: t2("Cancel subscription")
15698
- }
15699
- ),
15705
+ layout === "unsubscribe" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(EmbedButton, { onClick: unsubscribe, isLoading, children: t2("Cancel subscription") }),
15700
15706
  !isLoading && error && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
15701
15707
  Text,
15702
15708
  {
@@ -16386,6 +16392,10 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16386
16392
  var import_react23 = require("react");
16387
16393
 
16388
16394
  // node_modules/@stripe/stripe-js/dist/index.mjs
16395
+ var RELEASE_TRAIN = "v3";
16396
+ var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
16397
+ return version === 3 ? "v3" : version;
16398
+ };
16389
16399
  var ORIGIN = "https://js.stripe.com";
16390
16400
  var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
16391
16401
  var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
@@ -16422,7 +16432,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16422
16432
  }
16423
16433
  stripe._registerWrapper({
16424
16434
  name: "stripe-js",
16425
- version: "5.9.1",
16435
+ version: "5.10.0",
16426
16436
  startTime
16427
16437
  });
16428
16438
  };
@@ -16492,6 +16502,13 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
16492
16502
  if (maybeStripe === null) {
16493
16503
  return null;
16494
16504
  }
16505
+ var pk = args[0];
16506
+ var isTestKey = pk.match(/^pk_test/);
16507
+ var version = runtimeVersionToUrlVersion(maybeStripe.version);
16508
+ var expectedVersion = RELEASE_TRAIN;
16509
+ if (isTestKey && version !== expectedVersion) {
16510
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("5.10.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16511
+ }
16495
16512
  var stripe = maybeStripe.apply(void 0, args);
16496
16513
  registerWrapper(stripe, startTime);
16497
16514
  return stripe;
@@ -18988,7 +19005,7 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
18988
19005
  const billingSubscription = data.company?.billingSubscription;
18989
19006
  const subscriptionCurrency = billingSubscription?.currency;
18990
19007
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18991
- const showUnsubscribeBox = billingSubscription && billingSubscription.status == "cancelled";
19008
+ const showUnsubscribeBox = billingSubscription?.cancelAtPeriodEnd;
18992
19009
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18993
19010
  const todayDate = /* @__PURE__ */ new Date();
18994
19011
  const trialEndDays = Math.floor(
@@ -19058,9 +19075,12 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
19058
19075
  $weight: theme.typography.text.fontWeight,
19059
19076
  $color: theme.typography.text.color,
19060
19077
  children: billingSubscription.cancelAt ? t2("Access to plan will end on", {
19061
- date: toPrettyDate(new Date(billingSubscription.cancelAt), {
19062
- month: "numeric"
19063
- })
19078
+ date: toPrettyDate(
19079
+ new Date(billingSubscription.cancelAt * 1e3),
19080
+ {
19081
+ month: "numeric"
19082
+ }
19083
+ )
19064
19084
  }) : ""
19065
19085
  }
19066
19086
  )
@@ -20129,7 +20149,7 @@ var UnsubscribeButton = (0, import_react39.forwardRef)(({ children, className, .
20129
20149
  const props = resolveDesignProps8(rest);
20130
20150
  const { t: t2 } = useTranslation();
20131
20151
  const { data, setLayout } = useEmbed();
20132
- const disabled = !data.subscription || data.subscription.status === "cancelled";
20152
+ const disabled = !data.subscription || data.subscription.status === "cancelled" || data.subscription.cancelAtPeriodEnd;
20133
20153
  const buttonStyles = {
20134
20154
  primary: {
20135
20155
  color: "primary",
@@ -12776,7 +12776,7 @@ var EmbedProvider = ({
12776
12776
  useEffect2(() => {
12777
12777
  if (accessToken) {
12778
12778
  const { headers = {} } = apiConfig ?? {};
12779
- headers["X-Schematic-Components-Version"] = "0.4.8";
12779
+ headers["X-Schematic-Components-Version"] = "0.4.9";
12780
12780
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12781
12781
  const config = new Configuration({
12782
12782
  ...apiConfig,
@@ -13719,12 +13719,27 @@ var spin = mt`
13719
13719
  var Loader = dt.div`
13720
13720
  display: inline-block;
13721
13721
  border-style: solid;
13722
- border-color: hsla(0, 0%, 50%, 0.125);
13723
- border-top-color: ${({ theme, $color }) => $color || theme.primary};
13724
13722
  border-radius: 50%;
13725
13723
  transition: all 0.1s;
13726
13724
  animation: 1.5s linear infinite ${spin};
13727
13725
 
13726
+ ${({ $color, theme }) => {
13727
+ const { l: l2 } = hexToHSL(theme.card.background);
13728
+ let color = $color;
13729
+ let colorFn;
13730
+ if (l2 > 50) {
13731
+ color = color ?? "#000000";
13732
+ colorFn = lighten;
13733
+ } else {
13734
+ color = color ?? "#FFFFFF";
13735
+ colorFn = darken;
13736
+ }
13737
+ return lt`
13738
+ border-color: ${color};
13739
+ border-top-color: ${colorFn(color, 42.5)};
13740
+ `;
13741
+ }}
13742
+
13728
13743
  ${({ $size = "md", $isLoading = true }) => {
13729
13744
  let px;
13730
13745
  switch ($size) {
@@ -15649,16 +15664,7 @@ var Sidebar = ({
15649
15664
  trialPaymentMethodRequired: data.trialPaymentMethodRequired === true
15650
15665
  }
15651
15666
  ),
15652
- layout === "unsubscribe" && /* @__PURE__ */ jsx12(
15653
- EmbedButton,
15654
- {
15655
- onClick: async () => {
15656
- unsubscribe();
15657
- },
15658
- isLoading,
15659
- children: t2("Cancel subscription")
15660
- }
15661
- ),
15667
+ layout === "unsubscribe" && /* @__PURE__ */ jsx12(EmbedButton, { onClick: unsubscribe, isLoading, children: t2("Cancel subscription") }),
15662
15668
  !isLoading && error && /* @__PURE__ */ jsx12(Box, { children: /* @__PURE__ */ jsx12(
15663
15669
  Text,
15664
15670
  {
@@ -16348,6 +16354,10 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
16348
16354
  import { useEffect as useEffect4, useState as useState6 } from "react";
16349
16355
 
16350
16356
  // node_modules/@stripe/stripe-js/dist/index.mjs
16357
+ var RELEASE_TRAIN = "v3";
16358
+ var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
16359
+ return version === 3 ? "v3" : version;
16360
+ };
16351
16361
  var ORIGIN = "https://js.stripe.com";
16352
16362
  var STRIPE_JS_URL = "".concat(ORIGIN, "/v3");
16353
16363
  var V3_URL_REGEX = /^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;
@@ -16384,7 +16394,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16384
16394
  }
16385
16395
  stripe._registerWrapper({
16386
16396
  name: "stripe-js",
16387
- version: "5.9.1",
16397
+ version: "5.10.0",
16388
16398
  startTime
16389
16399
  });
16390
16400
  };
@@ -16454,6 +16464,13 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
16454
16464
  if (maybeStripe === null) {
16455
16465
  return null;
16456
16466
  }
16467
+ var pk = args[0];
16468
+ var isTestKey = pk.match(/^pk_test/);
16469
+ var version = runtimeVersionToUrlVersion(maybeStripe.version);
16470
+ var expectedVersion = RELEASE_TRAIN;
16471
+ if (isTestKey && version !== expectedVersion) {
16472
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("5.10.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16473
+ }
16457
16474
  var stripe = maybeStripe.apply(void 0, args);
16458
16475
  registerWrapper(stripe, startTime);
16459
16476
  return stripe;
@@ -18961,7 +18978,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18961
18978
  const billingSubscription = data.company?.billingSubscription;
18962
18979
  const subscriptionCurrency = billingSubscription?.currency;
18963
18980
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18964
- const showUnsubscribeBox = billingSubscription && billingSubscription.status == "cancelled";
18981
+ const showUnsubscribeBox = billingSubscription?.cancelAtPeriodEnd;
18965
18982
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18966
18983
  const todayDate = /* @__PURE__ */ new Date();
18967
18984
  const trialEndDays = Math.floor(
@@ -19031,9 +19048,12 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19031
19048
  $weight: theme.typography.text.fontWeight,
19032
19049
  $color: theme.typography.text.color,
19033
19050
  children: billingSubscription.cancelAt ? t2("Access to plan will end on", {
19034
- date: toPrettyDate(new Date(billingSubscription.cancelAt), {
19035
- month: "numeric"
19036
- })
19051
+ date: toPrettyDate(
19052
+ new Date(billingSubscription.cancelAt * 1e3),
19053
+ {
19054
+ month: "numeric"
19055
+ }
19056
+ )
19037
19057
  }) : ""
19038
19058
  }
19039
19059
  )
@@ -20102,7 +20122,7 @@ var UnsubscribeButton = forwardRef14(({ children, className, ...rest }, ref) =>
20102
20122
  const props = resolveDesignProps8(rest);
20103
20123
  const { t: t2 } = useTranslation();
20104
20124
  const { data, setLayout } = useEmbed();
20105
- const disabled = !data.subscription || data.subscription.status === "cancelled";
20125
+ const disabled = !data.subscription || data.subscription.status === "cancelled" || data.subscription.cancelAtPeriodEnd;
20106
20126
  const buttonStyles = {
20107
20127
  primary: {
20108
20128
  color: "primary",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",