@schematichq/schematic-components 0.7.0 → 0.7.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.
@@ -13061,7 +13061,7 @@ var EmbedProvider = ({
13061
13061
  useEffect2(() => {
13062
13062
  if (accessToken) {
13063
13063
  const { headers = {} } = apiConfig ?? {};
13064
- headers["X-Schematic-Components-Version"] = "0.7.0";
13064
+ headers["X-Schematic-Components-Version"] = "0.7.1";
13065
13065
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13066
13066
  const config = new Configuration({
13067
13067
  ...apiConfig,
@@ -13406,10 +13406,7 @@ import { forwardRef as forwardRef3 } from "react";
13406
13406
  // src/components/ui/box/styles.ts
13407
13407
  var Box = dt.div((props) => {
13408
13408
  function reducer(acc, [key, value]) {
13409
- if (key.startsWith("$") && ![
13410
- "$viewport",
13411
- ...Object.values(TextPropNames).filter((prop) => prop !== "$color")
13412
- ].includes(key)) {
13409
+ if (key.startsWith("$") && !["$viewport"].includes(key)) {
13413
13410
  acc.push(
13414
13411
  // keys will always be CSS properties
13415
13412
  attr(camelToHyphen(key.slice(1)), value)
@@ -13532,6 +13529,7 @@ var Button2 = forwardRef(
13532
13529
  children,
13533
13530
  ...props
13534
13531
  }, ref) => {
13532
+ const theme = nt();
13535
13533
  return /* @__PURE__ */ jsxs2(
13536
13534
  Button,
13537
13535
  {
@@ -13542,7 +13540,7 @@ var Button2 = forwardRef(
13542
13540
  disabled,
13543
13541
  ...props,
13544
13542
  children: [
13545
- /* @__PURE__ */ jsx2(Loader, { $size: "sm", $isLoading: isLoading }),
13543
+ /* @__PURE__ */ jsx2(Loader, { $color: theme.primary, $size: "sm", $isLoading: isLoading }),
13546
13544
  children
13547
13545
  ]
13548
13546
  }
@@ -14050,7 +14048,7 @@ var Loader = dt.div`
14050
14048
  }
14051
14049
  return lt`
14052
14050
  border-color: ${color};
14053
- border-top-color: ${colorFn(color, 42.5)};
14051
+ border-top-color: ${colorFn(color, 0.425)};
14054
14052
  `;
14055
14053
  }}
14056
14054
 
@@ -14230,8 +14228,11 @@ var ModalHeader = ({
14230
14228
  };
14231
14229
 
14232
14230
  // src/components/ui/progress-bar/styles.ts
14233
- var Container3 = dt(Flex)`
14231
+ var Container3 = dt.div`
14234
14232
  position: relative;
14233
+ display: flex;
14234
+ align-items: center;
14235
+ gap: 1rem;
14235
14236
  `;
14236
14237
 
14237
14238
  // src/components/ui/progress-bar/ProgressBar.tsx
@@ -14261,59 +14262,51 @@ var ProgressBar = ({
14261
14262
  orange: "#DB6769",
14262
14263
  red: "#EF4444"
14263
14264
  };
14264
- return /* @__PURE__ */ jsxs4(
14265
- Container3,
14266
- {
14267
- $alignItems: "center",
14268
- $gap: `${16 / TEXT_BASE_SIZE}rem`,
14269
- ...props,
14270
- children: [
14271
- /* @__PURE__ */ jsx7(
14265
+ return /* @__PURE__ */ jsxs4(Container3, { ...props, children: [
14266
+ /* @__PURE__ */ jsx7(
14267
+ Flex,
14268
+ {
14269
+ $position: "relative",
14270
+ $alignItems: "center",
14271
+ $width: `${barWidth}`,
14272
+ $maxWidth: "100%",
14273
+ children: /* @__PURE__ */ jsx7(
14272
14274
  Flex,
14273
14275
  {
14274
14276
  $position: "relative",
14275
- $alignItems: "center",
14276
- $width: `${barWidth}`,
14277
- $maxWidth: "100%",
14277
+ $overflow: "hidden",
14278
+ $width: "100%",
14279
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
14280
+ $backgroundColor: bgColor,
14281
+ $borderRadius: "9999px",
14278
14282
  children: /* @__PURE__ */ jsx7(
14279
- Flex,
14283
+ Box,
14280
14284
  {
14281
- $position: "relative",
14282
- $overflow: "hidden",
14283
- $width: "100%",
14284
- $height: `${8 / TEXT_BASE_SIZE}rem`,
14285
- $backgroundColor: bgColor,
14286
- $borderRadius: "9999px",
14287
- children: /* @__PURE__ */ jsx7(
14288
- Box,
14289
- {
14290
- $width: `${Math.min(progress, 100)}%`,
14291
- $height: "100%",
14292
- $backgroundColor: barColorMap[color],
14293
- $borderRadius: "9999px"
14294
- }
14295
- )
14285
+ $width: `${Math.min(progress, 100)}%`,
14286
+ $height: "100%",
14287
+ $backgroundColor: barColorMap[color],
14288
+ $borderRadius: "9999px"
14296
14289
  }
14297
14290
  )
14298
14291
  }
14299
- ),
14300
- total !== 0 && /* @__PURE__ */ jsxs4(
14301
- Text,
14302
- {
14303
- $font: theme.typography.text.fontFamily,
14304
- $size: 14,
14305
- $weight: 500,
14306
- $color: theme.typography.text.color,
14307
- children: [
14308
- value,
14309
- "/",
14310
- total
14311
- ]
14312
- }
14313
14292
  )
14314
- ]
14315
- }
14316
- );
14293
+ }
14294
+ ),
14295
+ total !== 0 && /* @__PURE__ */ jsxs4(
14296
+ Text,
14297
+ {
14298
+ $font: theme.typography.text.fontFamily,
14299
+ $size: 14,
14300
+ $weight: 500,
14301
+ $color: theme.typography.text.color,
14302
+ children: [
14303
+ value,
14304
+ "/",
14305
+ total
14306
+ ]
14307
+ }
14308
+ )
14309
+ ] });
14317
14310
  };
14318
14311
 
14319
14312
  // src/components/ui/text/styles.ts
@@ -14326,8 +14319,7 @@ var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
14326
14319
  TextPropNames2["Leading"] = "$leading";
14327
14320
  return TextPropNames2;
14328
14321
  })(TextPropNames || {});
14329
- var Text = dt(Box).attrs(({ as = "span", onClick }) => ({
14330
- as,
14322
+ var Text = dt.span.attrs(({ onClick }) => ({
14331
14323
  ...onClick && { tabIndex: 0 }
14332
14324
  }))`
14333
14325
  ${({ $font }) => $font && lt`
@@ -14363,7 +14355,7 @@ import { useCallback as useCallback6, useLayoutEffect as useLayoutEffect3, useRe
14363
14355
  import { createPortal } from "react-dom";
14364
14356
 
14365
14357
  // src/components/ui/tooltip/styles.ts
14366
- var Trigger = dt(Box)``;
14358
+ var Trigger = dt.div``;
14367
14359
  var coords = (position2) => {
14368
14360
  let x2 = 0;
14369
14361
  let y2 = 0;
@@ -14430,7 +14422,7 @@ var grow = (translate) => {
14430
14422
  }
14431
14423
  `;
14432
14424
  };
14433
- var Content = dt(Box).withConfig({
14425
+ var Content = dt.div.withConfig({
14434
14426
  shouldForwardProp: (prop) => !["x", "y", "position", "zIndex"].includes(prop)
14435
14427
  })(({ x: x2, y: y2, position: position2, zIndex }) => {
14436
14428
  const translate = coords(position2);
@@ -14547,6 +14539,7 @@ var Tooltip = ({
14547
14539
  // src/components/layout/card/styles.ts
14548
14540
  var Element = dt(Box)``;
14549
14541
  var FussyChild = dt(Element)``;
14542
+ var Notice = dt(Box)``;
14550
14543
  var cardBoxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
14551
14544
  var StyledCard = dt.div(({ theme }) => {
14552
14545
  const { l: l2 } = hexToHSL(theme.card.background);
@@ -14574,6 +14567,11 @@ var StyledCard = dt.div(({ theme }) => {
14574
14567
  `}
14575
14568
  }
14576
14569
  }
14570
+
14571
+ ${Notice}:first-child {
14572
+ border-top-left-radius: ${borderRadius};
14573
+ border-top-right-radius: ${borderRadius};
14574
+ }
14577
14575
  `;
14578
14576
  });
14579
14577
 
@@ -14628,11 +14626,12 @@ Column.displayName = "Column";
14628
14626
  import { forwardRef as forwardRef5 } from "react";
14629
14627
 
14630
14628
  // src/components/layout/root/styles.ts
14631
- var Container2 = dt(Box)`
14629
+ var Container2 = dt.div`
14632
14630
  all: initial;
14633
14631
  box-sizing: border-box;
14634
14632
  display: block;
14635
14633
  font-size: ${TEXT_BASE_SIZE}px;
14634
+ line-height: 1.35;
14636
14635
  width: 100%;
14637
14636
  height: 100%;
14638
14637
 
@@ -14913,29 +14912,36 @@ var Sidebar = ({
14913
14912
  const isLightBackground = useIsLightBackground();
14914
14913
  const currentPlan = data.company?.plan;
14915
14914
  const currentAddOns = data.company?.addOns || [];
14916
- const currentUsageBasedEntitlements = data.activeUsageBasedEntitlements.reduce(
14917
- (acc, usageData) => {
14918
- const featureUsage = data.featureUsage?.features.find(
14919
- (usage2) => usage2.feature?.id === usageData.featureId
14920
- );
14921
- const allocation = featureUsage?.allocation || 0;
14922
- const usage = featureUsage?.usage || 0;
14923
- acc.push({
14924
- usageData,
14925
- allocation,
14926
- quantity: allocation ?? usage,
14927
- usage
14928
- });
14929
- return acc;
14930
- },
14931
- []
14932
- );
14933
- const payInAdvanceEntitlements = usageBasedEntitlements.filter(
14934
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
14935
- );
14936
- const payAsYouGoEntitlements = usageBasedEntitlements.filter(
14937
- ({ entitlement }) => entitlement.priceBehavior === "pay_as_you_go"
14938
- );
14915
+ const currentUsageBasedEntitlements = useMemo4(() => {
14916
+ return (data.featureUsage?.features || []).reduce(
14917
+ (acc, entitlement) => {
14918
+ if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
14919
+ const allocation = entitlement.allocation || 0;
14920
+ const usage = entitlement.usage || 0;
14921
+ acc.push({
14922
+ ...entitlement,
14923
+ allocation,
14924
+ usage,
14925
+ quantity: allocation ?? usage
14926
+ });
14927
+ }
14928
+ return acc;
14929
+ },
14930
+ []
14931
+ );
14932
+ }, [data.featureUsage?.features, planPeriod]);
14933
+ const { payAsYouGoEntitlements, payInAdvanceEntitlements } = useMemo4(() => {
14934
+ const payAsYouGoEntitlements2 = [];
14935
+ const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
14936
+ (entitlement) => {
14937
+ if (entitlement.priceBehavior === "pay_as_you_go") {
14938
+ payAsYouGoEntitlements2.push(entitlement);
14939
+ }
14940
+ return entitlement.priceBehavior === "pay_in_advance";
14941
+ }
14942
+ );
14943
+ return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
14944
+ }, [usageBasedEntitlements]);
14939
14945
  const subscriptionPrice = useMemo4(() => {
14940
14946
  let planPrice;
14941
14947
  let currency;
@@ -14952,15 +14958,17 @@ var Sidebar = ({
14952
14958
  if (planPrice) {
14953
14959
  total += planPrice;
14954
14960
  }
14955
- const addOnCost = addOns.reduce(
14956
- (sum, addOn) => sum + (getBillingPrice(
14957
- planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
14958
- )?.price ?? 0),
14959
- 0
14960
- );
14961
+ const addOnCost = addOns.reduce((sum, addOn) => {
14962
+ if (addOn.isSelected) {
14963
+ sum += getBillingPrice(
14964
+ planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
14965
+ )?.price ?? 0;
14966
+ }
14967
+ return sum;
14968
+ }, 0);
14961
14969
  total += addOnCost;
14962
14970
  const payInAdvanceCost = payInAdvanceEntitlements.reduce(
14963
- (sum, { entitlement, quantity }) => sum + quantity * (getBillingPrice(
14971
+ (sum, entitlement) => sum + entitlement.quantity * (getBillingPrice(
14964
14972
  planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
14965
14973
  )?.price ?? 0),
14966
14974
  0
@@ -15010,8 +15018,8 @@ var Sidebar = ({
15010
15018
  return acc;
15011
15019
  }, []),
15012
15020
  payInAdvance: payInAdvanceEntitlements.reduce(
15013
- (acc, { entitlement, quantity }) => {
15014
- const priceId2 = (planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice)?.priceId;
15021
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
15022
+ const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
15015
15023
  if (priceId2) {
15016
15024
  acc.push({
15017
15025
  priceId: priceId2,
@@ -15079,48 +15087,62 @@ var Sidebar = ({
15079
15087
  ({ quantity, usage }) => quantity >= usage
15080
15088
  )) && !isLoading;
15081
15089
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15082
- const changedUsageBasedEntitlements = [];
15083
- const addedUsageBasedEntitlements = usageBasedEntitlements.reduce(
15084
- (acc, selected) => {
15085
- const changed = currentUsageBasedEntitlements.find(
15086
- (current) => current.usageData.featureId === selected.entitlement.featureId && current.quantity !== selected.quantity
15087
- );
15088
- if (changed) {
15089
- changedUsageBasedEntitlements.push({
15090
- entitlement: selected.entitlement,
15091
- previous: changed,
15092
- next: {
15093
- allocation: selected.allocation,
15094
- quantity: selected.quantity,
15095
- usage: selected.usage
15096
- }
15097
- });
15098
- } else {
15099
- acc.push(selected);
15100
- }
15101
- return acc;
15102
- },
15103
- []
15104
- );
15105
- const removedUsageBasedEntitlements = currentUsageBasedEntitlements.reduce(
15106
- (acc, current) => {
15107
- const match2 = usageBasedEntitlements.every(
15108
- ({ entitlement }) => entitlement.featureId !== current.usageData.featureId
15109
- ) && data.featureUsage?.features.find(
15110
- (usage) => usage.feature?.id === current.usageData.featureId
15111
- );
15112
- if (match2) {
15113
- acc.push({
15114
- usage: match2,
15115
- allocation: current.allocation,
15116
- quantity: current.quantity
15117
- });
15118
- }
15119
- return acc;
15120
- },
15121
- []
15122
- );
15123
- const willUsageBasedEntitlementsChange = changedUsageBasedEntitlements.length > 0 || addedUsageBasedEntitlements.length > 0 || removedUsageBasedEntitlements.length > 0;
15090
+ const {
15091
+ changedUsageBasedEntitlements,
15092
+ addedUsageBasedEntitlements,
15093
+ removedUsageBasedEntitlements,
15094
+ willUsageBasedEntitlementsChange
15095
+ } = useMemo4(() => {
15096
+ const changedUsageBasedEntitlements2 = [];
15097
+ const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
15098
+ (acc, selected) => {
15099
+ const changed = currentUsageBasedEntitlements.find(
15100
+ (current) => current.entitlementId === selected.id && current.quantity !== selected.quantity
15101
+ );
15102
+ if (changed) {
15103
+ changedUsageBasedEntitlements2.push({
15104
+ previous: changed,
15105
+ next: selected
15106
+ });
15107
+ } else {
15108
+ acc.push(selected);
15109
+ }
15110
+ return acc;
15111
+ },
15112
+ []
15113
+ ) : [];
15114
+ const removedUsageBasedEntitlements2 = selectedPlan ? currentUsageBasedEntitlements.reduce(
15115
+ (acc, current) => {
15116
+ const match2 = usageBasedEntitlements.every(
15117
+ (entitlement) => entitlement.id !== current.entitlementId
15118
+ ) && data.featureUsage?.features.find(
15119
+ (usage) => usage.entitlementId === current.entitlementId
15120
+ );
15121
+ if (match2) {
15122
+ acc.push({
15123
+ ...match2,
15124
+ allocation: current.allocation,
15125
+ usage: current.usage,
15126
+ quantity: current.quantity
15127
+ });
15128
+ }
15129
+ return acc;
15130
+ },
15131
+ []
15132
+ ) : [];
15133
+ const willUsageBasedEntitlementsChange2 = changedUsageBasedEntitlements2.length > 0 || addedUsageBasedEntitlements2.length > 0 || removedUsageBasedEntitlements2.length > 0;
15134
+ return {
15135
+ changedUsageBasedEntitlements: changedUsageBasedEntitlements2,
15136
+ addedUsageBasedEntitlements: addedUsageBasedEntitlements2,
15137
+ removedUsageBasedEntitlements: removedUsageBasedEntitlements2,
15138
+ willUsageBasedEntitlementsChange: willUsageBasedEntitlementsChange2
15139
+ };
15140
+ }, [
15141
+ selectedPlan,
15142
+ data.featureUsage?.features,
15143
+ currentUsageBasedEntitlements,
15144
+ usageBasedEntitlements
15145
+ ]);
15124
15146
  const removedAddOns = currentAddOns.filter(
15125
15147
  (current) => !selectedAddOns.some((selected) => current.id === selected.id)
15126
15148
  );
@@ -15324,13 +15346,13 @@ var Sidebar = ({
15324
15346
  }
15325
15347
  ) }),
15326
15348
  removedUsageBasedEntitlements.reduce(
15327
- (acc, { allocation, quantity, usage }, index) => {
15328
- if (typeof allocation === "number" && usage.feature?.name) {
15349
+ (acc, entitlement, index) => {
15350
+ if (typeof entitlement.allocation === "number" && entitlement.feature?.name) {
15329
15351
  const {
15330
15352
  price: entitlementPrice,
15331
15353
  currency: entitlementCurrency
15332
15354
  } = getBillingPrice(
15333
- planPeriod === "year" ? usage.yearlyUsageBasedPrice : usage.monthlyUsageBasedPrice
15355
+ planPeriod === "year" ? entitlement.yearlyUsageBasedPrice : entitlement.monthlyUsageBasedPrice
15334
15356
  ) || {};
15335
15357
  acc.push(
15336
15358
  /* @__PURE__ */ jsxs8(
@@ -15350,11 +15372,14 @@ var Sidebar = ({
15350
15372
  $size: theme.typography.heading4.fontSize,
15351
15373
  $weight: theme.typography.heading4.fontWeight,
15352
15374
  $color: theme.typography.heading4.color,
15353
- children: usage.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
15354
- quantity,
15375
+ children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
15376
+ entitlement.quantity,
15355
15377
  " ",
15356
- getFeatureName(usage.feature, quantity)
15357
- ] }) : usage.feature.name
15378
+ getFeatureName(
15379
+ entitlement.feature,
15380
+ entitlement.quantity
15381
+ )
15382
+ ] }) : entitlement.feature.name
15358
15383
  }
15359
15384
  ) }),
15360
15385
  /* @__PURE__ */ jsx13(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ jsxs8(
@@ -15365,9 +15390,9 @@ var Sidebar = ({
15365
15390
  $weight: theme.typography.text.fontWeight,
15366
15391
  $color: theme.typography.text.color,
15367
15392
  children: [
15368
- usage.priceBehavior === "pay_in_advance" && /* @__PURE__ */ jsxs8(Fragment3, { children: [
15393
+ entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ jsxs8(Fragment3, { children: [
15369
15394
  formatCurrency(
15370
- (entitlementPrice ?? 0) * quantity,
15395
+ (entitlementPrice ?? 0) * entitlement.quantity,
15371
15396
  entitlementCurrency
15372
15397
  ),
15373
15398
  /* @__PURE__ */ jsxs8("sub", { children: [
@@ -15375,14 +15400,14 @@ var Sidebar = ({
15375
15400
  shortenPeriod(planPeriod)
15376
15401
  ] })
15377
15402
  ] }),
15378
- usage.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ jsxs8(Fragment3, { children: [
15403
+ entitlement.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ jsxs8(Fragment3, { children: [
15379
15404
  formatCurrency(
15380
15405
  entitlementPrice ?? 0,
15381
15406
  entitlementCurrency
15382
15407
  ),
15383
15408
  /* @__PURE__ */ jsxs8("sub", { children: [
15384
15409
  "/",
15385
- getFeatureName(usage.feature, 1)
15410
+ getFeatureName(entitlement.feature, 1)
15386
15411
  ] })
15387
15412
  ] })
15388
15413
  ]
@@ -15399,13 +15424,13 @@ var Sidebar = ({
15399
15424
  []
15400
15425
  ),
15401
15426
  changedUsageBasedEntitlements.reduce(
15402
- (acc, { entitlement, previous, next: next2 }, index) => {
15403
- if (entitlement?.feature?.name) {
15427
+ (acc, { previous, next: next2 }, index) => {
15428
+ if (next2.feature?.name) {
15404
15429
  const {
15405
15430
  price: entitlementPrice,
15406
15431
  currency: entitlementCurrency
15407
15432
  } = getBillingPrice(
15408
- planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
15433
+ planPeriod === "year" ? next2.meteredYearlyPrice : next2.meteredMonthlyPrice
15409
15434
  ) || {};
15410
15435
  acc.push(
15411
15436
  /* @__PURE__ */ jsxs8(Box, { children: [
@@ -15429,7 +15454,7 @@ var Sidebar = ({
15429
15454
  children: [
15430
15455
  previous.quantity,
15431
15456
  " ",
15432
- getFeatureName(entitlement.feature)
15457
+ getFeatureName(next2.feature)
15433
15458
  ]
15434
15459
  }
15435
15460
  ) }),
@@ -15472,7 +15497,7 @@ var Sidebar = ({
15472
15497
  children: [
15473
15498
  next2.quantity,
15474
15499
  " ",
15475
- getFeatureName(entitlement.feature)
15500
+ getFeatureName(next2.feature)
15476
15501
  ]
15477
15502
  }
15478
15503
  ) }),
@@ -15506,7 +15531,7 @@ var Sidebar = ({
15506
15531
  []
15507
15532
  ),
15508
15533
  addedUsageBasedEntitlements.reduce(
15509
- (acc, { entitlement, quantity }, index) => {
15534
+ (acc, entitlement, index) => {
15510
15535
  if (entitlement.feature?.name) {
15511
15536
  const {
15512
15537
  price: entitlementPrice,
@@ -15530,9 +15555,12 @@ var Sidebar = ({
15530
15555
  $weight: theme.typography.heading4.fontWeight,
15531
15556
  $color: theme.typography.heading4.color,
15532
15557
  children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
15533
- quantity,
15558
+ entitlement.quantity,
15534
15559
  " ",
15535
- getFeatureName(entitlement.feature, quantity)
15560
+ getFeatureName(
15561
+ entitlement.feature,
15562
+ entitlement.quantity
15563
+ )
15536
15564
  ] }) : entitlement.feature.name
15537
15565
  }
15538
15566
  ) }),
@@ -15546,7 +15574,7 @@ var Sidebar = ({
15546
15574
  children: [
15547
15575
  entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ jsxs8(Fragment3, { children: [
15548
15576
  formatCurrency(
15549
- (entitlementPrice ?? 0) * quantity,
15577
+ (entitlementPrice ?? 0) * entitlement.quantity,
15550
15578
  entitlementCurrency
15551
15579
  ),
15552
15580
  /* @__PURE__ */ jsxs8("sub", { children: [
@@ -16401,7 +16429,7 @@ var Checkout = ({
16401
16429
  $alignItems: "center",
16402
16430
  $flexGrow: 1,
16403
16431
  $marginTop: "-3.5rem",
16404
- children: /* @__PURE__ */ jsx15(Loader, { $size: "3xl" })
16432
+ children: /* @__PURE__ */ jsx15(Loader, { $color: theme.primary, $size: "3xl" })
16405
16433
  }
16406
16434
  );
16407
16435
  }
@@ -17007,7 +17035,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17007
17035
  const unitPriceFontSize = 0.875 * theme.typography.text.fontSize;
17008
17036
  const unitPriceColor = hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46);
17009
17037
  return /* @__PURE__ */ jsx18(Fragment8, { children: /* @__PURE__ */ jsx18(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce(
17010
- (acc, { entitlement, quantity, usage }, index) => {
17038
+ (acc, entitlement, index) => {
17011
17039
  if (entitlement.priceBehavior === "pay_in_advance" && entitlement.feature) {
17012
17040
  const { price, currency } = getBillingPrice(
17013
17041
  period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
@@ -17066,8 +17094,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17066
17094
  {
17067
17095
  $size: "lg",
17068
17096
  type: "number",
17069
- value: quantity,
17070
- min: usage,
17097
+ value: entitlement.quantity,
17098
+ min: entitlement.usage,
17071
17099
  autoFocus: true,
17072
17100
  onFocus: (event) => event.target.select(),
17073
17101
  onChange: (event) => {
@@ -17087,12 +17115,12 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17087
17115
  $weight: theme.typography.text.fontWeight,
17088
17116
  $color: unitPriceColor,
17089
17117
  children: [
17090
- quantity < usage && /* @__PURE__ */ jsxs13("span", { style: { color: "#DB6669" }, children: [
17118
+ entitlement.quantity < entitlement.usage && /* @__PURE__ */ jsxs13("span", { style: { color: "#DB6669" }, children: [
17091
17119
  t2("Cannot downgrade entitlement"),
17092
17120
  " "
17093
17121
  ] }),
17094
17122
  t2("Currently using", {
17095
- quantity: usage,
17123
+ quantity: entitlement.usage,
17096
17124
  unit: getFeatureName(entitlement.feature)
17097
17125
  })
17098
17126
  ]
@@ -17115,7 +17143,10 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17115
17143
  $weight: theme.typography.text.fontWeight,
17116
17144
  $color: theme.typography.text.color,
17117
17145
  children: [
17118
- formatCurrency((price ?? 0) * quantity, currency),
17146
+ formatCurrency(
17147
+ (price ?? 0) * entitlement.quantity,
17148
+ currency
17149
+ ),
17119
17150
  /* @__PURE__ */ jsxs13("sub", { children: [
17120
17151
  "/",
17121
17152
  shortenPeriod(period)
@@ -17158,6 +17189,22 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17158
17189
 
17159
17190
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
17160
17191
  import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
17192
+ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc, entitlement) => {
17193
+ if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
17194
+ const featureUsage = entitlements.find(
17195
+ (usage2) => usage2.feature?.id === entitlement.feature?.id
17196
+ );
17197
+ const allocation = featureUsage?.allocation || 0;
17198
+ const usage = featureUsage?.usage || 0;
17199
+ acc.push({
17200
+ ...entitlement,
17201
+ allocation,
17202
+ usage,
17203
+ quantity: allocation
17204
+ });
17205
+ }
17206
+ return acc;
17207
+ };
17161
17208
  var CheckoutDialog = ({ top = 0 }) => {
17162
17209
  const { t: t2 } = useTranslation();
17163
17210
  const theme = nt();
@@ -17191,34 +17238,21 @@ var CheckoutDialog = ({ top = 0 }) => {
17191
17238
  )
17192
17239
  }))
17193
17240
  );
17194
- const createActiveUsageBasedEntitlementsReducer = useCallback8(
17195
- (period = planPeriod) => (acc, entitlement) => {
17196
- if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
17197
- const featureUsage = data.featureUsage?.features.find(
17198
- (usage2) => usage2.feature?.id === entitlement.feature?.id
17199
- );
17200
- const allocation = featureUsage?.allocation ?? 0;
17201
- const usage = featureUsage?.usage ?? 0;
17202
- acc.push({
17203
- entitlement,
17204
- allocation,
17205
- quantity: allocation,
17206
- usage
17207
- });
17208
- }
17209
- return acc;
17210
- },
17211
- [planPeriod, data.featureUsage?.features]
17212
- );
17241
+ const currentEntitlements = useMemo5(() => {
17242
+ return data.featureUsage?.features || [];
17243
+ }, [data.featureUsage?.features]);
17213
17244
  const [usageBasedEntitlements, setUsageBasedEntitlements] = useState7(
17214
17245
  () => (selectedPlan?.entitlements || []).reduce(
17215
- createActiveUsageBasedEntitlementsReducer(),
17246
+ createActiveUsageBasedEntitlementsReducer(
17247
+ currentEntitlements,
17248
+ planPeriod
17249
+ ),
17216
17250
  []
17217
17251
  )
17218
17252
  );
17219
17253
  const payInAdvanceEntitlements = useMemo5(
17220
17254
  () => usageBasedEntitlements.filter(
17221
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17255
+ (entitlement) => entitlement.priceBehavior === "pay_in_advance"
17222
17256
  ),
17223
17257
  [usageBasedEntitlements]
17224
17258
  );
@@ -17310,8 +17344,8 @@ var CheckoutDialog = ({ top = 0 }) => {
17310
17344
  []
17311
17345
  ),
17312
17346
  payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
17313
- (acc, { entitlement, quantity }) => {
17314
- const priceId = (period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice)?.priceId;
17347
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
17348
+ const priceId = (period === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
17315
17349
  if (priceId) {
17316
17350
  acc.push({
17317
17351
  priceId,
@@ -17360,7 +17394,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17360
17394
  }
17361
17395
  const period = updates.period || planPeriod;
17362
17396
  const entitlements = plan.entitlements.reduce(
17363
- createActiveUsageBasedEntitlementsReducer(period),
17397
+ createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
17364
17398
  []
17365
17399
  );
17366
17400
  if (updates.plan) {
@@ -17371,16 +17405,11 @@ var CheckoutDialog = ({ top = 0 }) => {
17371
17405
  period,
17372
17406
  plan: updates.plan,
17373
17407
  payInAdvanceEntitlements: entitlements.filter(
17374
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17408
+ ({ priceBehavior }) => priceBehavior === "pay_in_advance"
17375
17409
  )
17376
17410
  });
17377
17411
  },
17378
- [
17379
- planPeriod,
17380
- selectedPlan,
17381
- createActiveUsageBasedEntitlementsReducer,
17382
- previewCheckout
17383
- ]
17412
+ [planPeriod, selectedPlan, currentEntitlements, previewCheckout]
17384
17413
  );
17385
17414
  const changePlanPeriod = useCallback8(
17386
17415
  (period) => {
@@ -17403,16 +17432,14 @@ var CheckoutDialog = ({ top = 0 }) => {
17403
17432
  (id, updatedQuantity) => {
17404
17433
  setUsageBasedEntitlements((prev2) => {
17405
17434
  const updated = prev2.map(
17406
- ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
17407
- entitlement,
17408
- allocation,
17409
- quantity: updatedQuantity,
17410
- usage
17411
- } : { entitlement, allocation, quantity, usage }
17435
+ (entitlement) => entitlement.id === id ? {
17436
+ ...entitlement,
17437
+ quantity: updatedQuantity
17438
+ } : entitlement
17412
17439
  );
17413
17440
  previewCheckout({
17414
17441
  payInAdvanceEntitlements: updated.filter(
17415
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17442
+ ({ priceBehavior }) => priceBehavior === "pay_in_advance"
17416
17443
  )
17417
17444
  });
17418
17445
  return updated;
@@ -17541,7 +17568,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17541
17568
  $size: theme.typography.heading3.fontSize,
17542
17569
  $weight: theme.typography.heading3.fontWeight,
17543
17570
  $color: theme.typography.heading3.color,
17544
- $marginBottom: "0.5rem",
17571
+ style: { marginBottom: "0.5rem" },
17545
17572
  children: activeCheckoutStage.label
17546
17573
  }
17547
17574
  ),
@@ -17820,11 +17847,11 @@ var PeriodToggle = ({
17820
17847
  children: /* @__PURE__ */ jsx22(
17821
17848
  Text,
17822
17849
  {
17823
- $flexShrink: 0,
17824
17850
  $font: theme.typography.text.fontFamily,
17825
17851
  $size: 15,
17826
17852
  $weight: option === selectedOption ? 600 : 400,
17827
17853
  $color: theme.typography.text.color,
17854
+ style: { flexShrink: 0 },
17828
17855
  children: t2("Billed", { period: adjectify(option) })
17829
17856
  }
17830
17857
  )
@@ -17884,23 +17911,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
17884
17911
  ),
17885
17912
  [data.company?.plan, planPeriod, availablePlans]
17886
17913
  );
17914
+ const currentEntitlements = data.featureUsage?.features || [];
17887
17915
  const usageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
17888
- (acc, entitlement) => {
17889
- if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.meteredMonthlyPrice || planPeriod === "year" && entitlement.meteredYearlyPrice)) {
17890
- const featureUsage = data.featureUsage?.features.find(
17891
- (usage2) => usage2.feature?.id === entitlement.feature?.id
17892
- );
17893
- const allocation = featureUsage?.allocation ?? 0;
17894
- const usage = featureUsage?.usage ?? 0;
17895
- acc.push({
17896
- entitlement,
17897
- allocation,
17898
- quantity: allocation,
17899
- usage
17900
- });
17901
- }
17902
- return acc;
17903
- },
17916
+ createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
17904
17917
  []
17905
17918
  );
17906
17919
  const addOns = useMemo7(
@@ -18223,21 +18236,18 @@ var RenderLayout = ({ children }) => {
18223
18236
  };
18224
18237
 
18225
18238
  // src/components/layout/viewport/styles.ts
18226
- var StyledViewport = dt(Box).attrs(({ theme }) => ({
18227
- $gridTemplateColumns: "repeat(1, minmax(300px, 1fr))",
18228
- $viewport: {
18229
- md: {
18230
- $gridTemplateColumns: `repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`
18231
- }
18232
- }
18233
- })).withConfig({
18239
+ var StyledViewport = dt.div.withConfig({
18234
18240
  shouldForwardProp: (prop) => !["$numberOfColumns", "numberOfColumns"].includes(prop)
18235
18241
  })`
18236
18242
  display: grid;
18237
-
18243
+ grid-template-columns: repeat(1, minmax(300px, 1fr));
18238
18244
  margin-left: auto;
18239
18245
  margin-right: auto;
18240
18246
  gap: 1rem;
18247
+
18248
+ @media (min-width: 768px) {
18249
+ grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
18250
+ }
18241
18251
  `;
18242
18252
 
18243
18253
  // src/components/layout/viewport/Viewport.tsx
@@ -18736,7 +18746,8 @@ Invoices.displayName = "Invoices";
18736
18746
  import { forwardRef as forwardRef9, useMemo as useMemo10, useRef as useRef8 } from "react";
18737
18747
 
18738
18748
  // src/components/elements/metered-features/styles.ts
18739
- var Container4 = dt(Flex)`
18749
+ var Container4 = dt.div`
18750
+ display: flex;
18740
18751
  flex-direction: column;
18741
18752
  gap: 1rem;
18742
18753
 
@@ -19545,7 +19556,7 @@ var PaymentMethodDetails = ({
19545
19556
  $zIndex: 1,
19546
19557
  $backgroundColor: "black",
19547
19558
  $opacity: 0.5,
19548
- children: /* @__PURE__ */ jsx33(Loader, { $size: "2xl" })
19559
+ children: /* @__PURE__ */ jsx33(Loader, { $color: theme.primary, $size: "2xl" })
19549
19560
  }
19550
19561
  ),
19551
19562
  /* @__PURE__ */ jsxs26(
@@ -19735,11 +19746,14 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19735
19746
  const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19736
19747
  return /* @__PURE__ */ jsxs27(Fragment11, { children: [
19737
19748
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ jsxs27(
19738
- Box,
19749
+ Notice,
19739
19750
  {
19740
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.04)" : "hsla(0, 0%, 100%, 0.04)",
19751
+ as: Flex,
19752
+ $flexDirection: "column",
19753
+ $gap: "0.5rem",
19754
+ $padding: "1.5rem",
19741
19755
  $textAlign: "center",
19742
- $padding: "1rem",
19756
+ $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19743
19757
  children: [
19744
19758
  /* @__PURE__ */ jsx34(
19745
19759
  Text,
@@ -19770,11 +19784,14 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19770
19784
  ]
19771
19785
  }
19772
19786
  ) : willSubscriptionCancel && /* @__PURE__ */ jsxs27(
19773
- Box,
19787
+ Notice,
19774
19788
  {
19775
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.04)" : "hsla(0, 0%, 100%, 0.04)",
19789
+ as: Flex,
19790
+ $flexDirection: "column",
19791
+ $gap: "0.5rem",
19792
+ $padding: "1.5rem",
19776
19793
  $textAlign: "center",
19777
- $padding: "1rem",
19794
+ $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19778
19795
  children: [
19779
19796
  /* @__PURE__ */ jsx34(
19780
19797
  Text,
@@ -19787,7 +19804,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19787
19804
  children: t2("Subscription canceled")
19788
19805
  }
19789
19806
  ),
19790
- /* @__PURE__ */ jsx34(
19807
+ billingSubscription?.cancelAt && /* @__PURE__ */ jsx34(
19791
19808
  Text,
19792
19809
  {
19793
19810
  as: "p",
@@ -19795,14 +19812,14 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
19795
19812
  $size: 0.8125 * theme.typography.text.fontSize,
19796
19813
  $weight: theme.typography.text.fontWeight,
19797
19814
  $color: theme.typography.text.color,
19798
- children: billingSubscription?.cancelAt ? t2("Access to plan will end on", {
19815
+ children: t2("Access to plan will end on", {
19799
19816
  date: toPrettyDate(
19800
19817
  new Date(billingSubscription.cancelAt * 1e3),
19801
19818
  {
19802
19819
  month: "numeric"
19803
19820
  }
19804
19821
  )
19805
- }) : ""
19822
+ })
19806
19823
  }
19807
19824
  )
19808
19825
  ]
@@ -21102,7 +21119,7 @@ var Loading = () => {
21102
21119
  $alignItems: "center",
21103
21120
  $justifyContent: "center",
21104
21121
  $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
21105
- children: /* @__PURE__ */ jsx38(Loader, { $size: "2xl", $color: "#194BFB" })
21122
+ children: /* @__PURE__ */ jsx38(Loader, { $color: "#194BFB", $size: "2xl" })
21106
21123
  }
21107
21124
  );
21108
21125
  };
@@ -21208,6 +21225,7 @@ export {
21208
21225
  MeteredFeatures,
21209
21226
  Modal,
21210
21227
  ModalHeader,
21228
+ Notice,
21211
21229
  PaymentMethod,
21212
21230
  PaymentMethodDetails,
21213
21231
  PlanManager,