@schematichq/schematic-components 0.8.0 → 0.8.1

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.
@@ -11834,6 +11834,23 @@ function ListInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
11834
11834
  };
11835
11835
  }
11836
11836
 
11837
+ // src/api/models/PreviewSubscriptionUpcomingInvoiceLineItems.ts
11838
+ function PreviewSubscriptionUpcomingInvoiceLineItemsFromJSON(json) {
11839
+ return PreviewSubscriptionUpcomingInvoiceLineItemsFromJSONTyped(json, false);
11840
+ }
11841
+ function PreviewSubscriptionUpcomingInvoiceLineItemsFromJSONTyped(json, ignoreDiscriminator) {
11842
+ if (json == null) {
11843
+ return json;
11844
+ }
11845
+ return {
11846
+ amount: json["amount"],
11847
+ description: json["description"],
11848
+ priceId: json["price_id"],
11849
+ proration: json["proration"],
11850
+ quantity: json["quantity"]
11851
+ };
11852
+ }
11853
+
11837
11854
  // src/api/models/PreviewSubscriptionFinanceResponseData.ts
11838
11855
  function PreviewSubscriptionFinanceResponseDataFromJSON(json) {
11839
11856
  return PreviewSubscriptionFinanceResponseDataFromJSONTyped(json, false);
@@ -11850,7 +11867,8 @@ function PreviewSubscriptionFinanceResponseDataFromJSONTyped(json, ignoreDiscrim
11850
11867
  periodStart: new Date(json["period_start"]),
11851
11868
  promoCodeApplied: json["promo_code_applied"],
11852
11869
  proration: json["proration"],
11853
- trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"])
11870
+ trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"]),
11871
+ upcomingInvoiceLineItems: json["upcoming_invoice_line_items"].map(PreviewSubscriptionUpcomingInvoiceLineItemsFromJSON)
11854
11872
  };
11855
11873
  }
11856
11874
 
@@ -13143,7 +13161,7 @@ var EmbedProvider = ({
13143
13161
  (0, import_react11.useEffect)(() => {
13144
13162
  if (accessToken) {
13145
13163
  const { headers = {} } = apiConfig ?? {};
13146
- headers["X-Schematic-Components-Version"] = "0.8.0";
13164
+ headers["X-Schematic-Components-Version"] = "0.8.1";
13147
13165
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13148
13166
  const config = new Configuration({
13149
13167
  ...apiConfig,
@@ -13223,7 +13241,7 @@ function getBillingPrice(billingPrice) {
13223
13241
  if (!billingPrice) {
13224
13242
  return;
13225
13243
  }
13226
- const price = typeof billingPrice.priceDecimal === "string" ? parseFloat(billingPrice.priceDecimal) : billingPrice.price;
13244
+ const price = typeof billingPrice.priceDecimal === "string" ? Number(billingPrice.priceDecimal) : billingPrice.price;
13227
13245
  return { ...billingPrice, price };
13228
13246
  }
13229
13247
 
@@ -13378,12 +13396,14 @@ function formatCurrency(amount, currency) {
13378
13396
  currency: resolvedCurrency,
13379
13397
  ...hasManySignificantDigits && {
13380
13398
  minimumSignificantDigits: 1
13381
- }
13399
+ },
13400
+ maximumSignificantDigits: 12
13382
13401
  }).format(dollars);
13383
13402
  } catch (error) {
13384
13403
  console.error("Error formatting currency", error);
13385
13404
  return new Intl.NumberFormat("en-US", {
13386
13405
  style: "currency",
13406
+ maximumSignificantDigits: 12,
13387
13407
  currency: resolvedCurrency
13388
13408
  }).format(amount / 100);
13389
13409
  }
@@ -16714,7 +16734,7 @@ var Plan = ({
16714
16734
  const entitlementCurrency = entitlementPriceObject?.currency;
16715
16735
  if (entitlement.priceBehavior === "overage" && entitlementPriceObject) {
16716
16736
  const { priceTier } = entitlementPriceObject;
16717
- if (priceTier.length) {
16737
+ if (priceTier.length > 1) {
16718
16738
  const lastTier = priceTier[priceTier.length - 1];
16719
16739
  const { perUnitPrice, perUnitPriceDecimal } = lastTier;
16720
16740
  entitlementPrice = perUnitPriceDecimal ? Number(perUnitPriceDecimal) : perUnitPrice ?? 0;
@@ -18299,11 +18319,21 @@ var Details = ({
18299
18319
  const { t: t2 } = useTranslation();
18300
18320
  const theme = nt();
18301
18321
  const { data } = useEmbed();
18302
- const { price, currency } = (0, import_react32.useMemo)(() => {
18303
- const { price: entitlementPrice, currency: entitlementCurrency } = getBillingPrice(
18322
+ const { price, priceDecimal, priceTier, currency } = (0, import_react32.useMemo)(() => {
18323
+ const {
18324
+ price: entitlementPrice,
18325
+ priceDecimal: entitlementPriceDecimal,
18326
+ priceTier: entitlementPriceTier,
18327
+ currency: entitlementCurrency
18328
+ } = getBillingPrice(
18304
18329
  data.company?.plan?.planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
18305
18330
  ) || {};
18306
- return { price: entitlementPrice, currency: entitlementCurrency };
18331
+ return {
18332
+ price: entitlementPrice,
18333
+ priceDecimal: entitlementPriceDecimal,
18334
+ priceTier: entitlementPriceTier,
18335
+ currency: entitlementCurrency
18336
+ };
18307
18337
  }, [
18308
18338
  data.company?.plan?.planPeriod,
18309
18339
  monthlyUsageBasedPrice,
@@ -18345,9 +18375,18 @@ var Details = ({
18345
18375
  } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18346
18376
  acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18347
18377
  } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18348
- const cost = price * (usage - softLimit);
18378
+ let overagePrice = price ?? priceDecimal;
18379
+ if (priceTier?.length === 2) {
18380
+ const lastTier = priceTier[priceTier.length - 1];
18381
+ if (lastTier.perUnitPriceDecimal) {
18382
+ overagePrice = Number(lastTier.perUnitPriceDecimal);
18383
+ } else {
18384
+ overagePrice = lastTier.perUnitPrice ?? 0;
18385
+ }
18386
+ }
18387
+ const cost = usage - softLimit < 0 ? 0 : overagePrice / 100 * (usage - softLimit);
18349
18388
  const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18350
- acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18389
+ acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(overagePrice)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18351
18390
  }
18352
18391
  return acc;
18353
18392
  }
@@ -18366,6 +18405,8 @@ var Details = ({
18366
18405
  priceBehavior,
18367
18406
  allocation,
18368
18407
  price,
18408
+ priceDecimal,
18409
+ priceTier,
18369
18410
  currency,
18370
18411
  softLimit,
18371
18412
  usage
@@ -18864,17 +18905,6 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
18864
18905
  }
18865
18906
  }
18866
18907
  }
18867
- if (isOverage) {
18868
- const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice).productId;
18869
- if (productId) {
18870
- const products = data?.subscription?.products ?? [];
18871
- const product = products.find((p2) => p2.id === productId);
18872
- if (product) {
18873
- price = product.price;
18874
- currency = product.currency;
18875
- }
18876
- }
18877
- }
18878
18908
  const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
18879
18909
  ProgressBar,
18880
18910
  {
@@ -18884,7 +18914,7 @@ var MeteredFeatures = (0, import_react35.forwardRef)(({ className, ...rest }, re
18884
18914
  color: isOverage ? "blue" : progressColorMap[Math.floor(
18885
18915
  Math.min(usage, limit) / limit * (progressColorMap.length - 1)
18886
18916
  )],
18887
- ...isOverage && { bgColor: "#EF4444" }
18917
+ ...isOverage && { bgColor: "#2563EB80" }
18888
18918
  }
18889
18919
  );
18890
18920
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Flex, { $flexDirection: "column-reverse", children: [
@@ -21195,7 +21225,8 @@ var components = {
21195
21225
  Invoices,
21196
21226
  PricingTable,
21197
21227
  UnsubscribeButton,
21198
- ButtonElement
21228
+ Button: ButtonElement,
21229
+ Text: TextElement
21199
21230
  };
21200
21231
  function createRenderer(options) {
21201
21232
  const { useFallback = false } = options || {};
@@ -4135,17 +4135,6 @@ declare interface PreviewSubscriptionChangeResponseData {
4135
4135
  usageViolations: Array<FeatureUsageResponseData>;
4136
4136
  }
4137
4137
 
4138
- /**
4139
- * Schematic API
4140
- * Schematic API
4141
- *
4142
- * The version of the OpenAPI document: 0.1
4143
- *
4144
- *
4145
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4146
- * https://openapi-generator.tech
4147
- * Do not edit the class manually.
4148
- */
4149
4138
  /**
4150
4139
  *
4151
4140
  * @export
@@ -4200,6 +4189,61 @@ declare interface PreviewSubscriptionFinanceResponseData {
4200
4189
  * @memberof PreviewSubscriptionFinanceResponseData
4201
4190
  */
4202
4191
  trialEnd?: Date | null;
4192
+ /**
4193
+ *
4194
+ * @type {Array<PreviewSubscriptionUpcomingInvoiceLineItems>}
4195
+ * @memberof PreviewSubscriptionFinanceResponseData
4196
+ */
4197
+ upcomingInvoiceLineItems: Array<PreviewSubscriptionUpcomingInvoiceLineItems>;
4198
+ }
4199
+
4200
+ /**
4201
+ * Schematic API
4202
+ * Schematic API
4203
+ *
4204
+ * The version of the OpenAPI document: 0.1
4205
+ *
4206
+ *
4207
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
4208
+ * https://openapi-generator.tech
4209
+ * Do not edit the class manually.
4210
+ */
4211
+ /**
4212
+ *
4213
+ * @export
4214
+ * @interface PreviewSubscriptionUpcomingInvoiceLineItems
4215
+ */
4216
+ declare interface PreviewSubscriptionUpcomingInvoiceLineItems {
4217
+ /**
4218
+ *
4219
+ * @type {number}
4220
+ * @memberof PreviewSubscriptionUpcomingInvoiceLineItems
4221
+ */
4222
+ amount: number;
4223
+ /**
4224
+ *
4225
+ * @type {string}
4226
+ * @memberof PreviewSubscriptionUpcomingInvoiceLineItems
4227
+ */
4228
+ description: string;
4229
+ /**
4230
+ *
4231
+ * @type {string}
4232
+ * @memberof PreviewSubscriptionUpcomingInvoiceLineItems
4233
+ */
4234
+ priceId: string;
4235
+ /**
4236
+ *
4237
+ * @type {boolean}
4238
+ * @memberof PreviewSubscriptionUpcomingInvoiceLineItems
4239
+ */
4240
+ proration: boolean;
4241
+ /**
4242
+ *
4243
+ * @type {number}
4244
+ * @memberof PreviewSubscriptionUpcomingInvoiceLineItems
4245
+ */
4246
+ quantity: number;
4203
4247
  }
4204
4248
 
4205
4249
  export declare const PricingTable: ForwardRefExoticComponent<ElementProps & RecursivePartial<DesignProps_7> & HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement | null>>;
@@ -11779,6 +11779,23 @@ function ListInvoicesResponseFromJSONTyped(json, ignoreDiscriminator) {
11779
11779
  };
11780
11780
  }
11781
11781
 
11782
+ // src/api/models/PreviewSubscriptionUpcomingInvoiceLineItems.ts
11783
+ function PreviewSubscriptionUpcomingInvoiceLineItemsFromJSON(json) {
11784
+ return PreviewSubscriptionUpcomingInvoiceLineItemsFromJSONTyped(json, false);
11785
+ }
11786
+ function PreviewSubscriptionUpcomingInvoiceLineItemsFromJSONTyped(json, ignoreDiscriminator) {
11787
+ if (json == null) {
11788
+ return json;
11789
+ }
11790
+ return {
11791
+ amount: json["amount"],
11792
+ description: json["description"],
11793
+ priceId: json["price_id"],
11794
+ proration: json["proration"],
11795
+ quantity: json["quantity"]
11796
+ };
11797
+ }
11798
+
11782
11799
  // src/api/models/PreviewSubscriptionFinanceResponseData.ts
11783
11800
  function PreviewSubscriptionFinanceResponseDataFromJSON(json) {
11784
11801
  return PreviewSubscriptionFinanceResponseDataFromJSONTyped(json, false);
@@ -11795,7 +11812,8 @@ function PreviewSubscriptionFinanceResponseDataFromJSONTyped(json, ignoreDiscrim
11795
11812
  periodStart: new Date(json["period_start"]),
11796
11813
  promoCodeApplied: json["promo_code_applied"],
11797
11814
  proration: json["proration"],
11798
- trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"])
11815
+ trialEnd: json["trial_end"] == null ? void 0 : new Date(json["trial_end"]),
11816
+ upcomingInvoiceLineItems: json["upcoming_invoice_line_items"].map(PreviewSubscriptionUpcomingInvoiceLineItemsFromJSON)
11799
11817
  };
11800
11818
  }
11801
11819
 
@@ -13088,7 +13106,7 @@ var EmbedProvider = ({
13088
13106
  useEffect2(() => {
13089
13107
  if (accessToken) {
13090
13108
  const { headers = {} } = apiConfig ?? {};
13091
- headers["X-Schematic-Components-Version"] = "0.8.0";
13109
+ headers["X-Schematic-Components-Version"] = "0.8.1";
13092
13110
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13093
13111
  const config = new Configuration({
13094
13112
  ...apiConfig,
@@ -13168,7 +13186,7 @@ function getBillingPrice(billingPrice) {
13168
13186
  if (!billingPrice) {
13169
13187
  return;
13170
13188
  }
13171
- const price = typeof billingPrice.priceDecimal === "string" ? parseFloat(billingPrice.priceDecimal) : billingPrice.price;
13189
+ const price = typeof billingPrice.priceDecimal === "string" ? Number(billingPrice.priceDecimal) : billingPrice.price;
13172
13190
  return { ...billingPrice, price };
13173
13191
  }
13174
13192
 
@@ -13323,12 +13341,14 @@ function formatCurrency(amount, currency) {
13323
13341
  currency: resolvedCurrency,
13324
13342
  ...hasManySignificantDigits && {
13325
13343
  minimumSignificantDigits: 1
13326
- }
13344
+ },
13345
+ maximumSignificantDigits: 12
13327
13346
  }).format(dollars);
13328
13347
  } catch (error) {
13329
13348
  console.error("Error formatting currency", error);
13330
13349
  return new Intl.NumberFormat("en-US", {
13331
13350
  style: "currency",
13351
+ maximumSignificantDigits: 12,
13332
13352
  currency: resolvedCurrency
13333
13353
  }).format(amount / 100);
13334
13354
  }
@@ -16669,7 +16689,7 @@ var Plan = ({
16669
16689
  const entitlementCurrency = entitlementPriceObject?.currency;
16670
16690
  if (entitlement.priceBehavior === "overage" && entitlementPriceObject) {
16671
16691
  const { priceTier } = entitlementPriceObject;
16672
- if (priceTier.length) {
16692
+ if (priceTier.length > 1) {
16673
16693
  const lastTier = priceTier[priceTier.length - 1];
16674
16694
  const { perUnitPrice, perUnitPriceDecimal } = lastTier;
16675
16695
  entitlementPrice = perUnitPriceDecimal ? Number(perUnitPriceDecimal) : perUnitPrice ?? 0;
@@ -18258,11 +18278,21 @@ var Details = ({
18258
18278
  const { t: t2 } = useTranslation();
18259
18279
  const theme = nt();
18260
18280
  const { data } = useEmbed();
18261
- const { price, currency } = useMemo8(() => {
18262
- const { price: entitlementPrice, currency: entitlementCurrency } = getBillingPrice(
18281
+ const { price, priceDecimal, priceTier, currency } = useMemo8(() => {
18282
+ const {
18283
+ price: entitlementPrice,
18284
+ priceDecimal: entitlementPriceDecimal,
18285
+ priceTier: entitlementPriceTier,
18286
+ currency: entitlementCurrency
18287
+ } = getBillingPrice(
18263
18288
  data.company?.plan?.planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
18264
18289
  ) || {};
18265
- return { price: entitlementPrice, currency: entitlementCurrency };
18290
+ return {
18291
+ price: entitlementPrice,
18292
+ priceDecimal: entitlementPriceDecimal,
18293
+ priceTier: entitlementPriceTier,
18294
+ currency: entitlementCurrency
18295
+ };
18266
18296
  }, [
18267
18297
  data.company?.plan?.planPeriod,
18268
18298
  monthlyUsageBasedPrice,
@@ -18304,9 +18334,18 @@ var Details = ({
18304
18334
  } else if (priceBehavior === "pay_as_you_go" && typeof price === "number" && typeof usage === "number") {
18305
18335
  acc += ` \u2022 ${formatCurrency(price * usage, currency)}`;
18306
18336
  } else if (priceBehavior === "overage" && typeof price === "number" && typeof usage === "number" && typeof softLimit === "number") {
18307
- const cost = price * (usage - softLimit);
18337
+ let overagePrice = price ?? priceDecimal;
18338
+ if (priceTier?.length === 2) {
18339
+ const lastTier = priceTier[priceTier.length - 1];
18340
+ if (lastTier.perUnitPriceDecimal) {
18341
+ overagePrice = Number(lastTier.perUnitPriceDecimal);
18342
+ } else {
18343
+ overagePrice = lastTier.perUnitPrice ?? 0;
18344
+ }
18345
+ }
18346
+ const cost = usage - softLimit < 0 ? 0 : overagePrice / 100 * (usage - softLimit);
18308
18347
  const period = feature.featureType === "event" && typeof data.company?.plan?.planPeriod === "string" ? `/${shortenPeriod(data.company.plan.planPeriod)}` : "";
18309
- acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(price)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18348
+ acc += cost > 0 ? ` \u2022 ${t2("Overage")}: ${formatCurrency(cost)}${period}` : ` \u2022 ${`${formatCurrency(overagePrice)}/${getFeatureName(feature, 1)}`} ${t2("overage fee")}`;
18310
18349
  }
18311
18350
  return acc;
18312
18351
  }
@@ -18325,6 +18364,8 @@ var Details = ({
18325
18364
  priceBehavior,
18326
18365
  allocation,
18327
18366
  price,
18367
+ priceDecimal,
18368
+ priceTier,
18328
18369
  currency,
18329
18370
  softLimit,
18330
18371
  usage
@@ -18823,17 +18864,6 @@ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
18823
18864
  }
18824
18865
  }
18825
18866
  }
18826
- if (isOverage) {
18827
- const productId = (yearlyUsageBasedPrice ?? monthlyUsageBasedPrice).productId;
18828
- if (productId) {
18829
- const products = data?.subscription?.products ?? [];
18830
- const product = products.find((p2) => p2.id === productId);
18831
- if (product) {
18832
- price = product.price;
18833
- currency = product.currency;
18834
- }
18835
- }
18836
- }
18837
18867
  const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ jsx30(
18838
18868
  ProgressBar,
18839
18869
  {
@@ -18843,7 +18873,7 @@ var MeteredFeatures = forwardRef10(({ className, ...rest }, ref) => {
18843
18873
  color: isOverage ? "blue" : progressColorMap[Math.floor(
18844
18874
  Math.min(usage, limit) / limit * (progressColorMap.length - 1)
18845
18875
  )],
18846
- ...isOverage && { bgColor: "#EF4444" }
18876
+ ...isOverage && { bgColor: "#2563EB80" }
18847
18877
  }
18848
18878
  );
18849
18879
  return /* @__PURE__ */ jsxs24(Flex, { $flexDirection: "column-reverse", children: [
@@ -21154,7 +21184,8 @@ var components = {
21154
21184
  Invoices,
21155
21185
  PricingTable,
21156
21186
  UnsubscribeButton,
21157
- ButtonElement
21187
+ Button: ButtonElement,
21188
+ Text: TextElement
21158
21189
  };
21159
21190
  function createRenderer(options) {
21160
21191
  const { useFallback = false } = options || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",