@schematichq/schematic-components 0.7.3 → 0.7.5

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.
@@ -3017,7 +3017,7 @@ var unitlessKeys = {
3017
3017
  var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
3018
3018
  var m = "active";
3019
3019
  var y = "data-styled-version";
3020
- var v = "6.1.16";
3020
+ var v = "6.1.17";
3021
3021
  var g = "/*!sc*/\n";
3022
3022
  var S = "undefined" != typeof window && "HTMLElement" in window;
3023
3023
  var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
@@ -3026,7 +3026,7 @@ var E = /invalid hook call/i;
3026
3026
  var N = /* @__PURE__ */ new Set();
3027
3027
  var P = function(t2, n) {
3028
3028
  if (true) {
3029
- var o2 = n ? ' with the id of "'.concat(n, '"') : "", s2 = "The component ".concat(t2).concat(o2, " has been created dynamically.\n") + "You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.", i2 = console.error;
3029
+ var o2 = n ? ' with the id of "'.concat(n, '"') : "", s2 = "The component ".concat(t2).concat(o2, " has been created dynamically.\n") + "You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.\nSee https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.\n", i2 = console.error;
3030
3030
  try {
3031
3031
  var a2 = true;
3032
3032
  console.error = function(t3) {
@@ -10743,7 +10743,8 @@ function BillingProductPriceTierResponseDataFromJSONTyped(json, ignoreDiscrimina
10743
10743
  }
10744
10744
  return {
10745
10745
  flatAmount: json["flat_amount"] == null ? void 0 : json["flat_amount"],
10746
- perUnitPrice: json["per_unit_price"],
10746
+ perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
10747
+ perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
10747
10748
  upTo: json["up_to"] == null ? void 0 : json["up_to"]
10748
10749
  };
10749
10750
  }
@@ -10793,6 +10794,7 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
10793
10794
  currency: json["currency"],
10794
10795
  environmentId: json["environment_id"],
10795
10796
  externalId: json["external_id"],
10797
+ isActive: json["is_active"],
10796
10798
  name: json["name"],
10797
10799
  price: json["price"],
10798
10800
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -10852,6 +10854,7 @@ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10852
10854
  currency: json["currency"],
10853
10855
  environmentId: json["environment_id"],
10854
10856
  externalId: json["external_id"],
10857
+ isActive: json["is_active"],
10855
10858
  name: json["name"],
10856
10859
  price: json["price"],
10857
10860
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -11248,6 +11251,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11248
11251
  BillingSubscriptionViewFromJSON
11249
11252
  ),
11250
11253
  createdAt: new Date(json["created_at"]),
11254
+ defaultPaymentMethod: json["default_payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["default_payment_method"]),
11251
11255
  entityTraits: json["entity_traits"].map(
11252
11256
  EntityTraitDetailResponseDataFromJSON
11253
11257
  ),
@@ -13189,7 +13193,7 @@ var EmbedProvider = ({
13189
13193
  (0, import_react11.useEffect)(() => {
13190
13194
  if (accessToken) {
13191
13195
  const { headers = {} } = apiConfig ?? {};
13192
- headers["X-Schematic-Components-Version"] = "0.7.3";
13196
+ headers["X-Schematic-Components-Version"] = "0.7.5";
13193
13197
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13194
13198
  const config = new Configuration({
13195
13199
  ...apiConfig,
@@ -14372,14 +14376,6 @@ var ModalHeader = ({
14372
14376
  );
14373
14377
  };
14374
14378
 
14375
- // src/components/ui/progress-bar/styles.ts
14376
- var Container3 = dt.div`
14377
- position: relative;
14378
- display: flex;
14379
- align-items: center;
14380
- gap: 1rem;
14381
- `;
14382
-
14383
14379
  // src/components/ui/progress-bar/ProgressBar.tsx
14384
14380
  var import_jsx_runtime7 = require("react/jsx-runtime");
14385
14381
  var progressColorMap = [
@@ -14396,7 +14392,6 @@ var ProgressBar = ({
14396
14392
  total = 0,
14397
14393
  color = "gray",
14398
14394
  bgColor = "#F2F4F7",
14399
- barWidth = "100%",
14400
14395
  ...props
14401
14396
  }) => {
14402
14397
  const theme = nt();
@@ -14407,18 +14402,18 @@ var ProgressBar = ({
14407
14402
  orange: "#DB6769",
14408
14403
  red: "#EF4444"
14409
14404
  };
14410
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Container3, { ...props, children: [
14411
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14412
- Flex,
14413
- {
14414
- $position: "relative",
14415
- $alignItems: "center",
14416
- $width: `${barWidth}`,
14417
- $maxWidth: "100%",
14418
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14419
- Flex,
14405
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14406
+ Flex,
14407
+ {
14408
+ $position: "relative",
14409
+ $alignItems: "center",
14410
+ $gap: "1rem",
14411
+ $width: "100%",
14412
+ ...props,
14413
+ children: [
14414
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14415
+ Box,
14420
14416
  {
14421
- $position: "relative",
14422
14417
  $overflow: "hidden",
14423
14418
  $width: "100%",
14424
14419
  $height: `${8 / TEXT_BASE_SIZE}rem`,
@@ -14429,29 +14424,28 @@ var ProgressBar = ({
14429
14424
  {
14430
14425
  $width: `${Math.min(progress, 100)}%`,
14431
14426
  $height: "100%",
14432
- $backgroundColor: barColorMap[color],
14433
- $borderRadius: "9999px"
14427
+ $backgroundColor: barColorMap[color]
14434
14428
  }
14435
14429
  )
14436
14430
  }
14431
+ ),
14432
+ total && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14433
+ Text,
14434
+ {
14435
+ $font: theme.typography.text.fontFamily,
14436
+ $size: 14,
14437
+ $weight: 500,
14438
+ $color: theme.typography.text.color,
14439
+ children: [
14440
+ value,
14441
+ "/",
14442
+ total
14443
+ ]
14444
+ }
14437
14445
  )
14438
- }
14439
- ),
14440
- total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14441
- Text,
14442
- {
14443
- $font: theme.typography.text.fontFamily,
14444
- $size: 14,
14445
- $weight: 500,
14446
- $color: theme.typography.text.color,
14447
- children: [
14448
- value,
14449
- "/",
14450
- total
14451
- ]
14452
- }
14453
- )
14454
- ] });
14446
+ ]
14447
+ }
14448
+ );
14455
14449
  };
14456
14450
 
14457
14451
  // src/components/ui/text/styles.ts
@@ -14500,7 +14494,9 @@ var import_react19 = require("react");
14500
14494
  var import_react_dom = require("react-dom");
14501
14495
 
14502
14496
  // src/components/ui/tooltip/styles.ts
14503
- var Trigger = dt.div``;
14497
+ var Trigger = dt.div`
14498
+ width: 100%;
14499
+ `;
14504
14500
  var coords = (position2) => {
14505
14501
  let x2 = 0;
14506
14502
  let y2 = 0;
@@ -14656,13 +14652,15 @@ var Tooltip = ({
14656
14652
  }
14657
14653
  }, [position2]);
14658
14654
  (0, import_react19.useLayoutEffect)(() => {
14659
- updateCoords();
14660
14655
  const handleResize = (0, import_debounce.default)(updateCoords, DEBOUNCE_TIMEOUT);
14661
14656
  window.addEventListener("resize", handleResize);
14662
14657
  return () => {
14663
14658
  window.removeEventListener("resize", handleResize);
14664
14659
  };
14665
14660
  }, [updateCoords]);
14661
+ (0, import_react19.useLayoutEffect)(() => {
14662
+ updateCoords();
14663
+ }, [updateCoords, show]);
14666
14664
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
14667
14665
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
14668
14666
  Trigger,
@@ -16377,7 +16375,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
16377
16375
  };
16378
16376
 
16379
16377
  // node_modules/@stripe/stripe-js/dist/index.mjs
16380
- var RELEASE_TRAIN = "acacia";
16378
+ var RELEASE_TRAIN = "basil";
16381
16379
  var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
16382
16380
  return version === 3 ? "v3" : version;
16383
16381
  };
@@ -16417,7 +16415,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16417
16415
  }
16418
16416
  stripe._registerWrapper({
16419
16417
  name: "stripe-js",
16420
- version: "6.1.0",
16418
+ version: "7.0.0",
16421
16419
  startTime
16422
16420
  });
16423
16421
  };
@@ -16492,7 +16490,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
16492
16490
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
16493
16491
  var expectedVersion = RELEASE_TRAIN;
16494
16492
  if (isTestKey && version !== expectedVersion) {
16495
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("6.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16493
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16496
16494
  }
16497
16495
  var stripe = maybeStripe.apply(void 0, args);
16498
16496
  registerWrapper(stripe, startTime);
@@ -18940,7 +18938,7 @@ Invoices.displayName = "Invoices";
18940
18938
  var import_react35 = require("react");
18941
18939
 
18942
18940
  // src/components/elements/metered-features/styles.ts
18943
- var Container4 = dt.div`
18941
+ var Container3 = dt.div`
18944
18942
  display: flex;
18945
18943
  flex-direction: column;
18946
18944
  gap: 1rem;
@@ -19036,7 +19034,7 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
19036
19034
  if (!shouldShowFeatures) {
19037
19035
  return null;
19038
19036
  }
19039
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Container4, { ref, className, children: featureUsage.map(
19037
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Container3, { ref, className, children: featureUsage.map(
19040
19038
  ({
19041
19039
  feature,
19042
19040
  priceBehavior,
@@ -19061,8 +19059,7 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
19061
19059
  color: isOverage ? "blue" : progressColorMap[Math.floor(
19062
19060
  Math.min(usage, limit) / limit * (progressColorMap.length - 1)
19063
19061
  )],
19064
- ...isOverage && { bgColor: "#EF4444" },
19065
- $flexGrow: 1
19062
+ ...isOverage && { bgColor: "#EF4444" }
19066
19063
  }
19067
19064
  );
19068
19065
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Flex, { $flexDirection: "column-reverse", children: [
@@ -19574,8 +19571,8 @@ var PaymentMethod = (0, import_react37.forwardRef)(({ children, className, porta
19574
19571
  const props = resolveDesignProps5(rest);
19575
19572
  const { data, setLayout } = useEmbed();
19576
19573
  const paymentMethod = (0, import_react37.useMemo)(() => {
19577
- return data.subscription?.paymentMethod;
19578
- }, [data.subscription?.paymentMethod]);
19574
+ return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
19575
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19579
19576
  const monthsToExpiration = (0, import_react37.useMemo)(() => {
19580
19577
  let expiration;
19581
19578
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19633,10 +19630,10 @@ var PaymentMethodDetails = ({
19633
19630
  const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = (0, import_react38.useState)(false);
19634
19631
  const [paymentMethod, setPaymentMethod] = (0, import_react38.useState)(void 0);
19635
19632
  (0, import_react38.useEffect)(() => {
19636
- if (data.subscription?.paymentMethod) {
19637
- setPaymentMethod(data.subscription.paymentMethod);
19638
- }
19639
- }, [data.subscription?.paymentMethod]);
19633
+ setPaymentMethod(
19634
+ data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
19635
+ );
19636
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19640
19637
  const monthsToExpiration = (0, import_react38.useMemo)(() => {
19641
19638
  let expiration;
19642
19639
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19693,15 +19690,31 @@ var PaymentMethodDetails = ({
19693
19690
  if (setPaymentMethodId) {
19694
19691
  setPaymentMethodId(updatePaymentMethodResponse.data.externalId);
19695
19692
  }
19696
- if (data.subscription) {
19697
- setData({
19698
- ...data,
19693
+ setData({
19694
+ ...data,
19695
+ // Optimistic update
19696
+ // If there is subscription - we have set payment method to subscription
19697
+ ...data.subscription ? {
19699
19698
  subscription: {
19700
19699
  ...data.subscription,
19701
19700
  paymentMethod: updatePaymentMethodResponse.data
19702
19701
  }
19703
- });
19704
- }
19702
+ } : {},
19703
+ ...data.company ? {
19704
+ company: {
19705
+ ...data.company,
19706
+ paymentMethods: [
19707
+ updatePaymentMethodResponse.data,
19708
+ ...data.company?.paymentMethods || []
19709
+ ],
19710
+ // Optimistic update
19711
+ // If there is no subscription - we have updated default payment method in company
19712
+ ...data.subscription ? {} : {
19713
+ defaultPaymentMethod: updatePaymentMethodResponse.data
19714
+ }
19715
+ }
19716
+ } : {}
19717
+ });
19705
19718
  } catch {
19706
19719
  setError(t2("Error updating payment method. Please try again."));
19707
19720
  } finally {
@@ -268,6 +268,12 @@ declare interface BillingProductDetailResponseData {
268
268
  * @memberof BillingProductDetailResponseData
269
269
  */
270
270
  externalId: string;
271
+ /**
272
+ *
273
+ * @type {boolean}
274
+ * @memberof BillingProductDetailResponseData
275
+ */
276
+ isActive: boolean;
271
277
  /**
272
278
  *
273
279
  * @type {string}
@@ -462,7 +468,13 @@ declare interface BillingProductPriceTierResponseData {
462
468
  * @type {number}
463
469
  * @memberof BillingProductPriceTierResponseData
464
470
  */
465
- perUnitPrice: number;
471
+ perUnitPrice?: number | null;
472
+ /**
473
+ *
474
+ * @type {string}
475
+ * @memberof BillingProductPriceTierResponseData
476
+ */
477
+ perUnitPriceDecimal?: string | null;
466
478
  /**
467
479
  *
468
480
  * @type {number}
@@ -518,6 +530,12 @@ declare interface BillingProductResponseData {
518
530
  * @memberof BillingProductResponseData
519
531
  */
520
532
  externalId: string;
533
+ /**
534
+ *
535
+ * @type {boolean}
536
+ * @memberof BillingProductResponseData
537
+ */
538
+ isActive: boolean;
521
539
  /**
522
540
  *
523
541
  * @type {string}
@@ -1184,6 +1202,12 @@ declare interface CompanyDetailResponseData {
1184
1202
  * @memberof CompanyDetailResponseData
1185
1203
  */
1186
1204
  createdAt: Date;
1205
+ /**
1206
+ *
1207
+ * @type {PaymentMethodResponseData}
1208
+ * @memberof CompanyDetailResponseData
1209
+ */
1210
+ defaultPaymentMethod?: PaymentMethodResponseData;
1187
1211
  /**
1188
1212
  *
1189
1213
  * @type {Array<EntityTraitDetailResponseData>}
@@ -4244,7 +4268,7 @@ export declare const PricingTable: ForwardRefExoticComponent<ElementProps & Recu
4244
4268
 
4245
4269
  export declare type PricingTableProps = DesignProps_7;
4246
4270
 
4247
- export declare const ProgressBar: ({ progress, value, total, color, bgColor, barWidth, ...props }: ProgressBarProps) => JSX.Element;
4271
+ export declare const ProgressBar: ({ progress, value, total, color, bgColor, ...props }: ProgressBarProps) => JSX.Element;
4248
4272
 
4249
4273
  export declare interface ProgressBarProps extends React.ComponentPropsWithoutRef<typeof Flex> {
4250
4274
  progress: number;
@@ -4252,7 +4276,6 @@ export declare interface ProgressBarProps extends React.ComponentPropsWithoutRef
4252
4276
  total?: number | string;
4253
4277
  color?: "gray" | "blue" | "yellow" | "orange" | "red";
4254
4278
  bgColor?: string;
4255
- barWidth?: string | number;
4256
4279
  }
4257
4280
 
4258
4281
  export declare const progressColorMap: ("blue" | "red" | "yellow")[];
@@ -2964,7 +2964,7 @@ var unitlessKeys = {
2964
2964
  var f = "undefined" != typeof process && void 0 !== process.env && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || "data-styled";
2965
2965
  var m = "active";
2966
2966
  var y = "data-styled-version";
2967
- var v = "6.1.16";
2967
+ var v = "6.1.17";
2968
2968
  var g = "/*!sc*/\n";
2969
2969
  var S = "undefined" != typeof window && "HTMLElement" in window;
2970
2970
  var w = Boolean("boolean" == typeof SC_DISABLE_SPEEDY ? SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.REACT_APP_SC_DISABLE_SPEEDY && "" !== process.env.REACT_APP_SC_DISABLE_SPEEDY ? "false" !== process.env.REACT_APP_SC_DISABLE_SPEEDY && process.env.REACT_APP_SC_DISABLE_SPEEDY : "undefined" != typeof process && void 0 !== process.env && void 0 !== process.env.SC_DISABLE_SPEEDY && "" !== process.env.SC_DISABLE_SPEEDY ? "false" !== process.env.SC_DISABLE_SPEEDY && process.env.SC_DISABLE_SPEEDY : true);
@@ -2973,7 +2973,7 @@ var E = /invalid hook call/i;
2973
2973
  var N = /* @__PURE__ */ new Set();
2974
2974
  var P = function(t2, n) {
2975
2975
  if (true) {
2976
- var o2 = n ? ' with the id of "'.concat(n, '"') : "", s2 = "The component ".concat(t2).concat(o2, " has been created dynamically.\n") + "You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.", i2 = console.error;
2976
+ var o2 = n ? ' with the id of "'.concat(n, '"') : "", s2 = "The component ".concat(t2).concat(o2, " has been created dynamically.\n") + "You may see this warning because you've called styled inside another component.\nTo resolve this only create new StyledComponents outside of any render method and function component.\nSee https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.\n", i2 = console.error;
2977
2977
  try {
2978
2978
  var a2 = true;
2979
2979
  console.error = function(t3) {
@@ -10690,7 +10690,8 @@ function BillingProductPriceTierResponseDataFromJSONTyped(json, ignoreDiscrimina
10690
10690
  }
10691
10691
  return {
10692
10692
  flatAmount: json["flat_amount"] == null ? void 0 : json["flat_amount"],
10693
- perUnitPrice: json["per_unit_price"],
10693
+ perUnitPrice: json["per_unit_price"] == null ? void 0 : json["per_unit_price"],
10694
+ perUnitPriceDecimal: json["per_unit_price_decimal"] == null ? void 0 : json["per_unit_price_decimal"],
10694
10695
  upTo: json["up_to"] == null ? void 0 : json["up_to"]
10695
10696
  };
10696
10697
  }
@@ -10740,6 +10741,7 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
10740
10741
  currency: json["currency"],
10741
10742
  environmentId: json["environment_id"],
10742
10743
  externalId: json["external_id"],
10744
+ isActive: json["is_active"],
10743
10745
  name: json["name"],
10744
10746
  price: json["price"],
10745
10747
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -10799,6 +10801,7 @@ function BillingProductResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10799
10801
  currency: json["currency"],
10800
10802
  environmentId: json["environment_id"],
10801
10803
  externalId: json["external_id"],
10804
+ isActive: json["is_active"],
10802
10805
  name: json["name"],
10803
10806
  price: json["price"],
10804
10807
  priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
@@ -11195,6 +11198,7 @@ function CompanyDetailResponseDataFromJSONTyped(json, ignoreDiscriminator) {
11195
11198
  BillingSubscriptionViewFromJSON
11196
11199
  ),
11197
11200
  createdAt: new Date(json["created_at"]),
11201
+ defaultPaymentMethod: json["default_payment_method"] == null ? void 0 : PaymentMethodResponseDataFromJSON(json["default_payment_method"]),
11198
11202
  entityTraits: json["entity_traits"].map(
11199
11203
  EntityTraitDetailResponseDataFromJSON
11200
11204
  ),
@@ -13136,7 +13140,7 @@ var EmbedProvider = ({
13136
13140
  useEffect2(() => {
13137
13141
  if (accessToken) {
13138
13142
  const { headers = {} } = apiConfig ?? {};
13139
- headers["X-Schematic-Components-Version"] = "0.7.3";
13143
+ headers["X-Schematic-Components-Version"] = "0.7.5";
13140
13144
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13141
13145
  const config = new Configuration({
13142
13146
  ...apiConfig,
@@ -14319,14 +14323,6 @@ var ModalHeader = ({
14319
14323
  );
14320
14324
  };
14321
14325
 
14322
- // src/components/ui/progress-bar/styles.ts
14323
- var Container3 = dt.div`
14324
- position: relative;
14325
- display: flex;
14326
- align-items: center;
14327
- gap: 1rem;
14328
- `;
14329
-
14330
14326
  // src/components/ui/progress-bar/ProgressBar.tsx
14331
14327
  import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
14332
14328
  var progressColorMap = [
@@ -14343,7 +14339,6 @@ var ProgressBar = ({
14343
14339
  total = 0,
14344
14340
  color = "gray",
14345
14341
  bgColor = "#F2F4F7",
14346
- barWidth = "100%",
14347
14342
  ...props
14348
14343
  }) => {
14349
14344
  const theme = nt();
@@ -14354,18 +14349,18 @@ var ProgressBar = ({
14354
14349
  orange: "#DB6769",
14355
14350
  red: "#EF4444"
14356
14351
  };
14357
- return /* @__PURE__ */ jsxs4(Container3, { ...props, children: [
14358
- /* @__PURE__ */ jsx7(
14359
- Flex,
14360
- {
14361
- $position: "relative",
14362
- $alignItems: "center",
14363
- $width: `${barWidth}`,
14364
- $maxWidth: "100%",
14365
- children: /* @__PURE__ */ jsx7(
14366
- Flex,
14352
+ return /* @__PURE__ */ jsxs4(
14353
+ Flex,
14354
+ {
14355
+ $position: "relative",
14356
+ $alignItems: "center",
14357
+ $gap: "1rem",
14358
+ $width: "100%",
14359
+ ...props,
14360
+ children: [
14361
+ /* @__PURE__ */ jsx7(
14362
+ Box,
14367
14363
  {
14368
- $position: "relative",
14369
14364
  $overflow: "hidden",
14370
14365
  $width: "100%",
14371
14366
  $height: `${8 / TEXT_BASE_SIZE}rem`,
@@ -14376,29 +14371,28 @@ var ProgressBar = ({
14376
14371
  {
14377
14372
  $width: `${Math.min(progress, 100)}%`,
14378
14373
  $height: "100%",
14379
- $backgroundColor: barColorMap[color],
14380
- $borderRadius: "9999px"
14374
+ $backgroundColor: barColorMap[color]
14381
14375
  }
14382
14376
  )
14383
14377
  }
14378
+ ),
14379
+ total && /* @__PURE__ */ jsxs4(
14380
+ Text,
14381
+ {
14382
+ $font: theme.typography.text.fontFamily,
14383
+ $size: 14,
14384
+ $weight: 500,
14385
+ $color: theme.typography.text.color,
14386
+ children: [
14387
+ value,
14388
+ "/",
14389
+ total
14390
+ ]
14391
+ }
14384
14392
  )
14385
- }
14386
- ),
14387
- total !== 0 && /* @__PURE__ */ jsxs4(
14388
- Text,
14389
- {
14390
- $font: theme.typography.text.fontFamily,
14391
- $size: 14,
14392
- $weight: 500,
14393
- $color: theme.typography.text.color,
14394
- children: [
14395
- value,
14396
- "/",
14397
- total
14398
- ]
14399
- }
14400
- )
14401
- ] });
14393
+ ]
14394
+ }
14395
+ );
14402
14396
  };
14403
14397
 
14404
14398
  // src/components/ui/text/styles.ts
@@ -14447,7 +14441,9 @@ import { useCallback as useCallback6, useLayoutEffect as useLayoutEffect3, useRe
14447
14441
  import { createPortal } from "react-dom";
14448
14442
 
14449
14443
  // src/components/ui/tooltip/styles.ts
14450
- var Trigger = dt.div``;
14444
+ var Trigger = dt.div`
14445
+ width: 100%;
14446
+ `;
14451
14447
  var coords = (position2) => {
14452
14448
  let x2 = 0;
14453
14449
  let y2 = 0;
@@ -14603,13 +14599,15 @@ var Tooltip = ({
14603
14599
  }
14604
14600
  }, [position2]);
14605
14601
  useLayoutEffect3(() => {
14606
- updateCoords();
14607
14602
  const handleResize = (0, import_debounce.default)(updateCoords, DEBOUNCE_TIMEOUT);
14608
14603
  window.addEventListener("resize", handleResize);
14609
14604
  return () => {
14610
14605
  window.removeEventListener("resize", handleResize);
14611
14606
  };
14612
14607
  }, [updateCoords]);
14608
+ useLayoutEffect3(() => {
14609
+ updateCoords();
14610
+ }, [updateCoords, show]);
14613
14611
  return /* @__PURE__ */ jsxs5(Fragment2, { children: [
14614
14612
  /* @__PURE__ */ jsx8(
14615
14613
  Trigger,
@@ -16334,7 +16332,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
16334
16332
  };
16335
16333
 
16336
16334
  // node_modules/@stripe/stripe-js/dist/index.mjs
16337
- var RELEASE_TRAIN = "acacia";
16335
+ var RELEASE_TRAIN = "basil";
16338
16336
  var runtimeVersionToUrlVersion = function runtimeVersionToUrlVersion2(version) {
16339
16337
  return version === 3 ? "v3" : version;
16340
16338
  };
@@ -16374,7 +16372,7 @@ var registerWrapper = function registerWrapper2(stripe, startTime) {
16374
16372
  }
16375
16373
  stripe._registerWrapper({
16376
16374
  name: "stripe-js",
16377
- version: "6.1.0",
16375
+ version: "7.0.0",
16378
16376
  startTime
16379
16377
  });
16380
16378
  };
@@ -16449,7 +16447,7 @@ var initStripe = function initStripe2(maybeStripe, args, startTime) {
16449
16447
  var version = runtimeVersionToUrlVersion(maybeStripe.version);
16450
16448
  var expectedVersion = RELEASE_TRAIN;
16451
16449
  if (isTestKey && version !== expectedVersion) {
16452
- console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("6.1.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16450
+ console.warn("Stripe.js@".concat(version, " was loaded on the page, but @stripe/stripe-js@").concat("7.0.0", " expected Stripe.js@").concat(expectedVersion, ". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));
16453
16451
  }
16454
16452
  var stripe = maybeStripe.apply(void 0, args);
16455
16453
  registerWrapper(stripe, startTime);
@@ -18901,7 +18899,7 @@ Invoices.displayName = "Invoices";
18901
18899
  import { forwardRef as forwardRef10, useMemo as useMemo10, useRef as useRef8 } from "react";
18902
18900
 
18903
18901
  // src/components/elements/metered-features/styles.ts
18904
- var Container4 = dt.div`
18902
+ var Container3 = dt.div`
18905
18903
  display: flex;
18906
18904
  flex-direction: column;
18907
18905
  gap: 1rem;
@@ -18997,7 +18995,7 @@ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
18997
18995
  if (!shouldShowFeatures) {
18998
18996
  return null;
18999
18997
  }
19000
- return /* @__PURE__ */ jsx31(Container4, { ref, className, children: featureUsage.map(
18998
+ return /* @__PURE__ */ jsx31(Container3, { ref, className, children: featureUsage.map(
19001
18999
  ({
19002
19000
  feature,
19003
19001
  priceBehavior,
@@ -19022,8 +19020,7 @@ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
19022
19020
  color: isOverage ? "blue" : progressColorMap[Math.floor(
19023
19021
  Math.min(usage, limit) / limit * (progressColorMap.length - 1)
19024
19022
  )],
19025
- ...isOverage && { bgColor: "#EF4444" },
19026
- $flexGrow: 1
19023
+ ...isOverage && { bgColor: "#EF4444" }
19027
19024
  }
19028
19025
  );
19029
19026
  return /* @__PURE__ */ jsxs24(Flex, { $flexDirection: "column-reverse", children: [
@@ -19535,8 +19532,8 @@ var PaymentMethod = forwardRef11(({ children, className, portal, allowEdit = tru
19535
19532
  const props = resolveDesignProps5(rest);
19536
19533
  const { data, setLayout } = useEmbed();
19537
19534
  const paymentMethod = useMemo12(() => {
19538
- return data.subscription?.paymentMethod;
19539
- }, [data.subscription?.paymentMethod]);
19535
+ return data.subscription?.paymentMethod || data.company?.defaultPaymentMethod;
19536
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19540
19537
  const monthsToExpiration = useMemo12(() => {
19541
19538
  let expiration;
19542
19539
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19594,10 +19591,10 @@ var PaymentMethodDetails = ({
19594
19591
  const [showDifferentPaymentMethods, setShowDifferentPaymentMethods] = useState14(false);
19595
19592
  const [paymentMethod, setPaymentMethod] = useState14(void 0);
19596
19593
  useEffect7(() => {
19597
- if (data.subscription?.paymentMethod) {
19598
- setPaymentMethod(data.subscription.paymentMethod);
19599
- }
19600
- }, [data.subscription?.paymentMethod]);
19594
+ setPaymentMethod(
19595
+ data.subscription?.paymentMethod || data.company?.defaultPaymentMethod
19596
+ );
19597
+ }, [data.company?.defaultPaymentMethod, data.subscription?.paymentMethod]);
19601
19598
  const monthsToExpiration = useMemo13(() => {
19602
19599
  let expiration;
19603
19600
  if (typeof paymentMethod?.cardExpYear === "number" && typeof paymentMethod?.cardExpMonth === "number") {
@@ -19654,15 +19651,31 @@ var PaymentMethodDetails = ({
19654
19651
  if (setPaymentMethodId) {
19655
19652
  setPaymentMethodId(updatePaymentMethodResponse.data.externalId);
19656
19653
  }
19657
- if (data.subscription) {
19658
- setData({
19659
- ...data,
19654
+ setData({
19655
+ ...data,
19656
+ // Optimistic update
19657
+ // If there is subscription - we have set payment method to subscription
19658
+ ...data.subscription ? {
19660
19659
  subscription: {
19661
19660
  ...data.subscription,
19662
19661
  paymentMethod: updatePaymentMethodResponse.data
19663
19662
  }
19664
- });
19665
- }
19663
+ } : {},
19664
+ ...data.company ? {
19665
+ company: {
19666
+ ...data.company,
19667
+ paymentMethods: [
19668
+ updatePaymentMethodResponse.data,
19669
+ ...data.company?.paymentMethods || []
19670
+ ],
19671
+ // Optimistic update
19672
+ // If there is no subscription - we have updated default payment method in company
19673
+ ...data.subscription ? {} : {
19674
+ defaultPaymentMethod: updatePaymentMethodResponse.data
19675
+ }
19676
+ }
19677
+ } : {}
19678
+ });
19666
19679
  } catch {
19667
19680
  setError(t2("Error updating payment method. Please try again."));
19668
19681
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
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,14 +30,14 @@
30
30
  "tsc": "npx tsc"
31
31
  },
32
32
  "dependencies": {
33
- "@stripe/stripe-js": "^6.1.0",
33
+ "@stripe/stripe-js": "^7.0.0",
34
34
  "classnames": "^2.5.1",
35
35
  "i18next": "^24.2.3",
36
36
  "lodash": "^4.17.21",
37
37
  "pako": "^2.1.0",
38
38
  "pluralize": "^8.0.0",
39
39
  "react-i18next": "^15.4.1",
40
- "styled-components": "^6.1.16",
40
+ "styled-components": "^6.1.17",
41
41
  "uuid": "^11.1.0"
42
42
  },
43
43
  "devDependencies": {