@schematichq/schematic-components 0.4.8 → 0.4.10

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.10";
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;
@@ -18214,13 +18231,11 @@ function resolveDesignProps2(props) {
18214
18231
  }
18215
18232
  };
18216
18233
  }
18217
- function formatInvoices(invoices) {
18218
- return (invoices || []).filter(
18219
- ({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
18220
- ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
18221
- ...dueDate && { date: toPrettyDate(dueDate) },
18234
+ function formatInvoices(invoices = []) {
18235
+ return invoices.filter(({ amountDue, amountPaid }) => amountDue === 0 || amountPaid > 0).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
18222
18236
  amount: formatCurrency(amountDue, currency),
18223
- url
18237
+ ...dueDate && { date: toPrettyDate(dueDate) },
18238
+ ...url && { url }
18224
18239
  }));
18225
18240
  }
18226
18241
  var InvoiceDate = ({ date, fontStyle, url }) => {
@@ -18988,7 +19003,7 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
18988
19003
  const billingSubscription = data.company?.billingSubscription;
18989
19004
  const subscriptionCurrency = billingSubscription?.currency;
18990
19005
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18991
- const showUnsubscribeBox = billingSubscription && billingSubscription.status == "cancelled";
19006
+ const showUnsubscribeBox = billingSubscription?.cancelAtPeriodEnd;
18992
19007
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18993
19008
  const todayDate = /* @__PURE__ */ new Date();
18994
19009
  const trialEndDays = Math.floor(
@@ -19058,9 +19073,12 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
19058
19073
  $weight: theme.typography.text.fontWeight,
19059
19074
  $color: theme.typography.text.color,
19060
19075
  children: billingSubscription.cancelAt ? t2("Access to plan will end on", {
19061
- date: toPrettyDate(new Date(billingSubscription.cancelAt), {
19062
- month: "numeric"
19063
- })
19076
+ date: toPrettyDate(
19077
+ new Date(billingSubscription.cancelAt * 1e3),
19078
+ {
19079
+ month: "numeric"
19080
+ }
19081
+ )
19064
19082
  }) : ""
19065
19083
  }
19066
19084
  )
@@ -19448,7 +19466,7 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
19448
19466
  $display: "grid",
19449
19467
  $gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
19450
19468
  $gap: "1rem",
19451
- children: plans.map((plan, index) => {
19469
+ children: plans.map((plan, index, self2) => {
19452
19470
  const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
19453
19471
  const count = entitlementCounts[plan.id];
19454
19472
  let isExpanded = false;
@@ -19554,6 +19572,18 @@ var PricingTable = (0, import_react37.forwardRef)(({ children, className, ...res
19554
19572
  $padding: `${0.75 * cardPadding}rem ${cardPadding}rem 0`,
19555
19573
  children: [
19556
19574
  props.plans.showEntitlements && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(Flex, { $flexDirection: "column", $gap: "1rem", $flexGrow: "1", children: [
19575
+ props.plans.showInclusionText && index > 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
19576
+ Text,
19577
+ {
19578
+ $font: theme.typography.text.fontFamily,
19579
+ $size: theme.typography.text.fontSize,
19580
+ $weight: theme.typography.text.fontWeight,
19581
+ $color: theme.typography.text.color,
19582
+ children: t2("Everything in", {
19583
+ plan: self2[index - 1].name
19584
+ })
19585
+ }
19586
+ ) }),
19557
19587
  plan.entitlements.reduce((acc, entitlement) => {
19558
19588
  let price;
19559
19589
  let currency;
@@ -20129,7 +20159,7 @@ var UnsubscribeButton = (0, import_react39.forwardRef)(({ children, className, .
20129
20159
  const props = resolveDesignProps8(rest);
20130
20160
  const { t: t2 } = useTranslation();
20131
20161
  const { data, setLayout } = useEmbed();
20132
- const disabled = !data.subscription || data.subscription.status === "cancelled";
20162
+ const disabled = !data.subscription || data.subscription.status === "cancelled" || data.subscription.cancelAtPeriodEnd;
20133
20163
  const buttonStyles = {
20134
20164
  primary: {
20135
20165
  color: "primary",
@@ -3145,11 +3145,11 @@ declare interface InvoiceResponseData {
3145
3145
  }
3146
3146
 
3147
3147
  export declare const Invoices: ForwardRefExoticComponent<ElementProps & RecursivePartial<DesignProps_2> & {
3148
- data?: ListInvoicesResponse["data"];
3148
+ data?: InvoiceResponseData[];
3149
3149
  } & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement | null>>;
3150
3150
 
3151
3151
  export declare type InvoicesProps = DesignProps_2 & {
3152
- data?: ListInvoicesResponse["data"];
3152
+ data?: InvoiceResponseData[];
3153
3153
  };
3154
3154
 
3155
3155
  declare type Json = any;
@@ -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.10";
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;
@@ -18180,13 +18197,11 @@ function resolveDesignProps2(props) {
18180
18197
  }
18181
18198
  };
18182
18199
  }
18183
- function formatInvoices(invoices) {
18184
- return (invoices || []).filter(
18185
- ({ url, amountDue, amountPaid }) => url && (amountDue === 0 || amountPaid > 0)
18186
- ).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
18187
- ...dueDate && { date: toPrettyDate(dueDate) },
18200
+ function formatInvoices(invoices = []) {
18201
+ return invoices.filter(({ amountDue, amountPaid }) => amountDue === 0 || amountPaid > 0).sort((a2, b2) => a2.dueDate && b2.dueDate ? +b2.dueDate - +a2.dueDate : 1).map(({ amountDue, dueDate, url, currency }) => ({
18188
18202
  amount: formatCurrency(amountDue, currency),
18189
- url
18203
+ ...dueDate && { date: toPrettyDate(dueDate) },
18204
+ ...url && { url }
18190
18205
  }));
18191
18206
  }
18192
18207
  var InvoiceDate = ({ date, fontStyle, url }) => {
@@ -18961,7 +18976,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18961
18976
  const billingSubscription = data.company?.billingSubscription;
18962
18977
  const subscriptionCurrency = billingSubscription?.currency;
18963
18978
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18964
- const showUnsubscribeBox = billingSubscription && billingSubscription.status == "cancelled";
18979
+ const showUnsubscribeBox = billingSubscription?.cancelAtPeriodEnd;
18965
18980
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18966
18981
  const todayDate = /* @__PURE__ */ new Date();
18967
18982
  const trialEndDays = Math.floor(
@@ -19031,9 +19046,12 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19031
19046
  $weight: theme.typography.text.fontWeight,
19032
19047
  $color: theme.typography.text.color,
19033
19048
  children: billingSubscription.cancelAt ? t2("Access to plan will end on", {
19034
- date: toPrettyDate(new Date(billingSubscription.cancelAt), {
19035
- month: "numeric"
19036
- })
19049
+ date: toPrettyDate(
19050
+ new Date(billingSubscription.cancelAt * 1e3),
19051
+ {
19052
+ month: "numeric"
19053
+ }
19054
+ )
19037
19055
  }) : ""
19038
19056
  }
19039
19057
  )
@@ -19421,7 +19439,7 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19421
19439
  $display: "grid",
19422
19440
  $gridTemplateColumns: "repeat(auto-fill, minmax(320px, 1fr))",
19423
19441
  $gap: "1rem",
19424
- children: plans.map((plan, index) => {
19442
+ children: plans.map((plan, index, self2) => {
19425
19443
  const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
19426
19444
  const count = entitlementCounts[plan.id];
19427
19445
  let isExpanded = false;
@@ -19527,6 +19545,18 @@ var PricingTable = forwardRef12(({ children, className, ...rest }, ref) => {
19527
19545
  $padding: `${0.75 * cardPadding}rem ${cardPadding}rem 0`,
19528
19546
  children: [
19529
19547
  props.plans.showEntitlements && /* @__PURE__ */ jsxs26(Flex, { $flexDirection: "column", $gap: "1rem", $flexGrow: "1", children: [
19548
+ props.plans.showInclusionText && index > 0 && /* @__PURE__ */ jsx32(Box, { $marginBottom: "1.5rem", children: /* @__PURE__ */ jsx32(
19549
+ Text,
19550
+ {
19551
+ $font: theme.typography.text.fontFamily,
19552
+ $size: theme.typography.text.fontSize,
19553
+ $weight: theme.typography.text.fontWeight,
19554
+ $color: theme.typography.text.color,
19555
+ children: t2("Everything in", {
19556
+ plan: self2[index - 1].name
19557
+ })
19558
+ }
19559
+ ) }),
19530
19560
  plan.entitlements.reduce((acc, entitlement) => {
19531
19561
  let price;
19532
19562
  let currency;
@@ -20102,7 +20132,7 @@ var UnsubscribeButton = forwardRef14(({ children, className, ...rest }, ref) =>
20102
20132
  const props = resolveDesignProps8(rest);
20103
20133
  const { t: t2 } = useTranslation();
20104
20134
  const { data, setLayout } = useEmbed();
20105
- const disabled = !data.subscription || data.subscription.status === "cancelled";
20135
+ const disabled = !data.subscription || data.subscription.status === "cancelled" || data.subscription.cancelAtPeriodEnd;
20106
20136
  const buttonStyles = {
20107
20137
  primary: {
20108
20138
  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.10",
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,7 +30,7 @@
30
30
  "tsc": "npx tsc"
31
31
  },
32
32
  "dependencies": {
33
- "@stripe/stripe-js": "^5.8.0",
33
+ "@stripe/stripe-js": "^5.9.2",
34
34
  "classnames": "^2.5.1",
35
35
  "i18next": "^24.2.2",
36
36
  "lodash": "^4.17.21",