@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.
@@ -2275,6 +2275,7 @@ __export(index_exports, {
2275
2275
  MeteredFeatures: () => MeteredFeatures,
2276
2276
  Modal: () => Modal,
2277
2277
  ModalHeader: () => ModalHeader,
2278
+ Notice: () => Notice,
2278
2279
  PaymentMethod: () => PaymentMethod,
2279
2280
  PaymentMethodDetails: () => PaymentMethodDetails,
2280
2281
  PlanManager: () => PlanManager,
@@ -13111,7 +13112,7 @@ var EmbedProvider = ({
13111
13112
  (0, import_react11.useEffect)(() => {
13112
13113
  if (accessToken) {
13113
13114
  const { headers = {} } = apiConfig ?? {};
13114
- headers["X-Schematic-Components-Version"] = "0.7.0";
13115
+ headers["X-Schematic-Components-Version"] = "0.7.1";
13115
13116
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
13116
13117
  const config = new Configuration({
13117
13118
  ...apiConfig,
@@ -13456,10 +13457,7 @@ var import_react20 = require("react");
13456
13457
  // src/components/ui/box/styles.ts
13457
13458
  var Box = dt.div((props) => {
13458
13459
  function reducer(acc, [key, value]) {
13459
- if (key.startsWith("$") && ![
13460
- "$viewport",
13461
- ...Object.values(TextPropNames).filter((prop) => prop !== "$color")
13462
- ].includes(key)) {
13460
+ if (key.startsWith("$") && !["$viewport"].includes(key)) {
13463
13461
  acc.push(
13464
13462
  // keys will always be CSS properties
13465
13463
  attr(camelToHyphen(key.slice(1)), value)
@@ -13582,6 +13580,7 @@ var Button2 = (0, import_react16.forwardRef)(
13582
13580
  children,
13583
13581
  ...props
13584
13582
  }, ref) => {
13583
+ const theme = nt();
13585
13584
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
13586
13585
  Button,
13587
13586
  {
@@ -13592,7 +13591,7 @@ var Button2 = (0, import_react16.forwardRef)(
13592
13591
  disabled,
13593
13592
  ...props,
13594
13593
  children: [
13595
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loader, { $size: "sm", $isLoading: isLoading }),
13594
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loader, { $color: theme.primary, $size: "sm", $isLoading: isLoading }),
13596
13595
  children
13597
13596
  ]
13598
13597
  }
@@ -14100,7 +14099,7 @@ var Loader = dt.div`
14100
14099
  }
14101
14100
  return lt`
14102
14101
  border-color: ${color};
14103
- border-top-color: ${colorFn(color, 42.5)};
14102
+ border-top-color: ${colorFn(color, 0.425)};
14104
14103
  `;
14105
14104
  }}
14106
14105
 
@@ -14280,8 +14279,11 @@ var ModalHeader = ({
14280
14279
  };
14281
14280
 
14282
14281
  // src/components/ui/progress-bar/styles.ts
14283
- var Container3 = dt(Flex)`
14282
+ var Container3 = dt.div`
14284
14283
  position: relative;
14284
+ display: flex;
14285
+ align-items: center;
14286
+ gap: 1rem;
14285
14287
  `;
14286
14288
 
14287
14289
  // src/components/ui/progress-bar/ProgressBar.tsx
@@ -14311,59 +14313,51 @@ var ProgressBar = ({
14311
14313
  orange: "#DB6769",
14312
14314
  red: "#EF4444"
14313
14315
  };
14314
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14315
- Container3,
14316
- {
14317
- $alignItems: "center",
14318
- $gap: `${16 / TEXT_BASE_SIZE}rem`,
14319
- ...props,
14320
- children: [
14321
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14316
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Container3, { ...props, children: [
14317
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14318
+ Flex,
14319
+ {
14320
+ $position: "relative",
14321
+ $alignItems: "center",
14322
+ $width: `${barWidth}`,
14323
+ $maxWidth: "100%",
14324
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14322
14325
  Flex,
14323
14326
  {
14324
14327
  $position: "relative",
14325
- $alignItems: "center",
14326
- $width: `${barWidth}`,
14327
- $maxWidth: "100%",
14328
+ $overflow: "hidden",
14329
+ $width: "100%",
14330
+ $height: `${8 / TEXT_BASE_SIZE}rem`,
14331
+ $backgroundColor: bgColor,
14332
+ $borderRadius: "9999px",
14328
14333
  children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14329
- Flex,
14334
+ Box,
14330
14335
  {
14331
- $position: "relative",
14332
- $overflow: "hidden",
14333
- $width: "100%",
14334
- $height: `${8 / TEXT_BASE_SIZE}rem`,
14335
- $backgroundColor: bgColor,
14336
- $borderRadius: "9999px",
14337
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
14338
- Box,
14339
- {
14340
- $width: `${Math.min(progress, 100)}%`,
14341
- $height: "100%",
14342
- $backgroundColor: barColorMap[color],
14343
- $borderRadius: "9999px"
14344
- }
14345
- )
14336
+ $width: `${Math.min(progress, 100)}%`,
14337
+ $height: "100%",
14338
+ $backgroundColor: barColorMap[color],
14339
+ $borderRadius: "9999px"
14346
14340
  }
14347
14341
  )
14348
14342
  }
14349
- ),
14350
- total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14351
- Text,
14352
- {
14353
- $font: theme.typography.text.fontFamily,
14354
- $size: 14,
14355
- $weight: 500,
14356
- $color: theme.typography.text.color,
14357
- children: [
14358
- value,
14359
- "/",
14360
- total
14361
- ]
14362
- }
14363
14343
  )
14364
- ]
14365
- }
14366
- );
14344
+ }
14345
+ ),
14346
+ total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
14347
+ Text,
14348
+ {
14349
+ $font: theme.typography.text.fontFamily,
14350
+ $size: 14,
14351
+ $weight: 500,
14352
+ $color: theme.typography.text.color,
14353
+ children: [
14354
+ value,
14355
+ "/",
14356
+ total
14357
+ ]
14358
+ }
14359
+ )
14360
+ ] });
14367
14361
  };
14368
14362
 
14369
14363
  // src/components/ui/text/styles.ts
@@ -14376,8 +14370,7 @@ var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
14376
14370
  TextPropNames2["Leading"] = "$leading";
14377
14371
  return TextPropNames2;
14378
14372
  })(TextPropNames || {});
14379
- var Text = dt(Box).attrs(({ as = "span", onClick }) => ({
14380
- as,
14373
+ var Text = dt.span.attrs(({ onClick }) => ({
14381
14374
  ...onClick && { tabIndex: 0 }
14382
14375
  }))`
14383
14376
  ${({ $font }) => $font && lt`
@@ -14413,7 +14406,7 @@ var import_react19 = require("react");
14413
14406
  var import_react_dom = require("react-dom");
14414
14407
 
14415
14408
  // src/components/ui/tooltip/styles.ts
14416
- var Trigger = dt(Box)``;
14409
+ var Trigger = dt.div``;
14417
14410
  var coords = (position2) => {
14418
14411
  let x2 = 0;
14419
14412
  let y2 = 0;
@@ -14480,7 +14473,7 @@ var grow = (translate) => {
14480
14473
  }
14481
14474
  `;
14482
14475
  };
14483
- var Content = dt(Box).withConfig({
14476
+ var Content = dt.div.withConfig({
14484
14477
  shouldForwardProp: (prop) => !["x", "y", "position", "zIndex"].includes(prop)
14485
14478
  })(({ x: x2, y: y2, position: position2, zIndex }) => {
14486
14479
  const translate = coords(position2);
@@ -14597,6 +14590,7 @@ var Tooltip = ({
14597
14590
  // src/components/layout/card/styles.ts
14598
14591
  var Element = dt(Box)``;
14599
14592
  var FussyChild = dt(Element)``;
14593
+ var Notice = dt(Box)``;
14600
14594
  var cardBoxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
14601
14595
  var StyledCard = dt.div(({ theme }) => {
14602
14596
  const { l: l2 } = hexToHSL(theme.card.background);
@@ -14624,6 +14618,11 @@ var StyledCard = dt.div(({ theme }) => {
14624
14618
  `}
14625
14619
  }
14626
14620
  }
14621
+
14622
+ ${Notice}:first-child {
14623
+ border-top-left-radius: ${borderRadius};
14624
+ border-top-right-radius: ${borderRadius};
14625
+ }
14627
14626
  `;
14628
14627
  });
14629
14628
 
@@ -14678,11 +14677,12 @@ Column.displayName = "Column";
14678
14677
  var import_react22 = require("react");
14679
14678
 
14680
14679
  // src/components/layout/root/styles.ts
14681
- var Container2 = dt(Box)`
14680
+ var Container2 = dt.div`
14682
14681
  all: initial;
14683
14682
  box-sizing: border-box;
14684
14683
  display: block;
14685
14684
  font-size: ${TEXT_BASE_SIZE}px;
14685
+ line-height: 1.35;
14686
14686
  width: 100%;
14687
14687
  height: 100%;
14688
14688
 
@@ -14953,29 +14953,36 @@ var Sidebar = ({
14953
14953
  const isLightBackground = useIsLightBackground();
14954
14954
  const currentPlan = data.company?.plan;
14955
14955
  const currentAddOns = data.company?.addOns || [];
14956
- const currentUsageBasedEntitlements = data.activeUsageBasedEntitlements.reduce(
14957
- (acc, usageData) => {
14958
- const featureUsage = data.featureUsage?.features.find(
14959
- (usage2) => usage2.feature?.id === usageData.featureId
14960
- );
14961
- const allocation = featureUsage?.allocation || 0;
14962
- const usage = featureUsage?.usage || 0;
14963
- acc.push({
14964
- usageData,
14965
- allocation,
14966
- quantity: allocation ?? usage,
14967
- usage
14968
- });
14969
- return acc;
14970
- },
14971
- []
14972
- );
14973
- const payInAdvanceEntitlements = usageBasedEntitlements.filter(
14974
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
14975
- );
14976
- const payAsYouGoEntitlements = usageBasedEntitlements.filter(
14977
- ({ entitlement }) => entitlement.priceBehavior === "pay_as_you_go"
14978
- );
14956
+ const currentUsageBasedEntitlements = (0, import_react23.useMemo)(() => {
14957
+ return (data.featureUsage?.features || []).reduce(
14958
+ (acc, entitlement) => {
14959
+ if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
14960
+ const allocation = entitlement.allocation || 0;
14961
+ const usage = entitlement.usage || 0;
14962
+ acc.push({
14963
+ ...entitlement,
14964
+ allocation,
14965
+ usage,
14966
+ quantity: allocation ?? usage
14967
+ });
14968
+ }
14969
+ return acc;
14970
+ },
14971
+ []
14972
+ );
14973
+ }, [data.featureUsage?.features, planPeriod]);
14974
+ const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react23.useMemo)(() => {
14975
+ const payAsYouGoEntitlements2 = [];
14976
+ const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
14977
+ (entitlement) => {
14978
+ if (entitlement.priceBehavior === "pay_as_you_go") {
14979
+ payAsYouGoEntitlements2.push(entitlement);
14980
+ }
14981
+ return entitlement.priceBehavior === "pay_in_advance";
14982
+ }
14983
+ );
14984
+ return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
14985
+ }, [usageBasedEntitlements]);
14979
14986
  const subscriptionPrice = (0, import_react23.useMemo)(() => {
14980
14987
  let planPrice;
14981
14988
  let currency;
@@ -14992,15 +14999,17 @@ var Sidebar = ({
14992
14999
  if (planPrice) {
14993
15000
  total += planPrice;
14994
15001
  }
14995
- const addOnCost = addOns.reduce(
14996
- (sum, addOn) => sum + (getBillingPrice(
14997
- planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
14998
- )?.price ?? 0),
14999
- 0
15000
- );
15002
+ const addOnCost = addOns.reduce((sum, addOn) => {
15003
+ if (addOn.isSelected) {
15004
+ sum += getBillingPrice(
15005
+ planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
15006
+ )?.price ?? 0;
15007
+ }
15008
+ return sum;
15009
+ }, 0);
15001
15010
  total += addOnCost;
15002
15011
  const payInAdvanceCost = payInAdvanceEntitlements.reduce(
15003
- (sum, { entitlement, quantity }) => sum + quantity * (getBillingPrice(
15012
+ (sum, entitlement) => sum + entitlement.quantity * (getBillingPrice(
15004
15013
  planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
15005
15014
  )?.price ?? 0),
15006
15015
  0
@@ -15050,8 +15059,8 @@ var Sidebar = ({
15050
15059
  return acc;
15051
15060
  }, []),
15052
15061
  payInAdvance: payInAdvanceEntitlements.reduce(
15053
- (acc, { entitlement, quantity }) => {
15054
- const priceId2 = (planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice)?.priceId;
15062
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
15063
+ const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
15055
15064
  if (priceId2) {
15056
15065
  acc.push({
15057
15066
  priceId: priceId2,
@@ -15119,48 +15128,62 @@ var Sidebar = ({
15119
15128
  ({ quantity, usage }) => quantity >= usage
15120
15129
  )) && !isLoading;
15121
15130
  const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
15122
- const changedUsageBasedEntitlements = [];
15123
- const addedUsageBasedEntitlements = usageBasedEntitlements.reduce(
15124
- (acc, selected) => {
15125
- const changed = currentUsageBasedEntitlements.find(
15126
- (current) => current.usageData.featureId === selected.entitlement.featureId && current.quantity !== selected.quantity
15127
- );
15128
- if (changed) {
15129
- changedUsageBasedEntitlements.push({
15130
- entitlement: selected.entitlement,
15131
- previous: changed,
15132
- next: {
15133
- allocation: selected.allocation,
15134
- quantity: selected.quantity,
15135
- usage: selected.usage
15136
- }
15137
- });
15138
- } else {
15139
- acc.push(selected);
15140
- }
15141
- return acc;
15142
- },
15143
- []
15144
- );
15145
- const removedUsageBasedEntitlements = currentUsageBasedEntitlements.reduce(
15146
- (acc, current) => {
15147
- const match2 = usageBasedEntitlements.every(
15148
- ({ entitlement }) => entitlement.featureId !== current.usageData.featureId
15149
- ) && data.featureUsage?.features.find(
15150
- (usage) => usage.feature?.id === current.usageData.featureId
15151
- );
15152
- if (match2) {
15153
- acc.push({
15154
- usage: match2,
15155
- allocation: current.allocation,
15156
- quantity: current.quantity
15157
- });
15158
- }
15159
- return acc;
15160
- },
15161
- []
15162
- );
15163
- const willUsageBasedEntitlementsChange = changedUsageBasedEntitlements.length > 0 || addedUsageBasedEntitlements.length > 0 || removedUsageBasedEntitlements.length > 0;
15131
+ const {
15132
+ changedUsageBasedEntitlements,
15133
+ addedUsageBasedEntitlements,
15134
+ removedUsageBasedEntitlements,
15135
+ willUsageBasedEntitlementsChange
15136
+ } = (0, import_react23.useMemo)(() => {
15137
+ const changedUsageBasedEntitlements2 = [];
15138
+ const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
15139
+ (acc, selected) => {
15140
+ const changed = currentUsageBasedEntitlements.find(
15141
+ (current) => current.entitlementId === selected.id && current.quantity !== selected.quantity
15142
+ );
15143
+ if (changed) {
15144
+ changedUsageBasedEntitlements2.push({
15145
+ previous: changed,
15146
+ next: selected
15147
+ });
15148
+ } else {
15149
+ acc.push(selected);
15150
+ }
15151
+ return acc;
15152
+ },
15153
+ []
15154
+ ) : [];
15155
+ const removedUsageBasedEntitlements2 = selectedPlan ? currentUsageBasedEntitlements.reduce(
15156
+ (acc, current) => {
15157
+ const match2 = usageBasedEntitlements.every(
15158
+ (entitlement) => entitlement.id !== current.entitlementId
15159
+ ) && data.featureUsage?.features.find(
15160
+ (usage) => usage.entitlementId === current.entitlementId
15161
+ );
15162
+ if (match2) {
15163
+ acc.push({
15164
+ ...match2,
15165
+ allocation: current.allocation,
15166
+ usage: current.usage,
15167
+ quantity: current.quantity
15168
+ });
15169
+ }
15170
+ return acc;
15171
+ },
15172
+ []
15173
+ ) : [];
15174
+ const willUsageBasedEntitlementsChange2 = changedUsageBasedEntitlements2.length > 0 || addedUsageBasedEntitlements2.length > 0 || removedUsageBasedEntitlements2.length > 0;
15175
+ return {
15176
+ changedUsageBasedEntitlements: changedUsageBasedEntitlements2,
15177
+ addedUsageBasedEntitlements: addedUsageBasedEntitlements2,
15178
+ removedUsageBasedEntitlements: removedUsageBasedEntitlements2,
15179
+ willUsageBasedEntitlementsChange: willUsageBasedEntitlementsChange2
15180
+ };
15181
+ }, [
15182
+ selectedPlan,
15183
+ data.featureUsage?.features,
15184
+ currentUsageBasedEntitlements,
15185
+ usageBasedEntitlements
15186
+ ]);
15164
15187
  const removedAddOns = currentAddOns.filter(
15165
15188
  (current) => !selectedAddOns.some((selected) => current.id === selected.id)
15166
15189
  );
@@ -15364,13 +15387,13 @@ var Sidebar = ({
15364
15387
  }
15365
15388
  ) }),
15366
15389
  removedUsageBasedEntitlements.reduce(
15367
- (acc, { allocation, quantity, usage }, index) => {
15368
- if (typeof allocation === "number" && usage.feature?.name) {
15390
+ (acc, entitlement, index) => {
15391
+ if (typeof entitlement.allocation === "number" && entitlement.feature?.name) {
15369
15392
  const {
15370
15393
  price: entitlementPrice,
15371
15394
  currency: entitlementCurrency
15372
15395
  } = getBillingPrice(
15373
- planPeriod === "year" ? usage.yearlyUsageBasedPrice : usage.monthlyUsageBasedPrice
15396
+ planPeriod === "year" ? entitlement.yearlyUsageBasedPrice : entitlement.monthlyUsageBasedPrice
15374
15397
  ) || {};
15375
15398
  acc.push(
15376
15399
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
@@ -15390,11 +15413,14 @@ var Sidebar = ({
15390
15413
  $size: theme.typography.heading4.fontSize,
15391
15414
  $weight: theme.typography.heading4.fontWeight,
15392
15415
  $color: theme.typography.heading4.color,
15393
- children: usage.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15394
- quantity,
15416
+ children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15417
+ entitlement.quantity,
15395
15418
  " ",
15396
- getFeatureName(usage.feature, quantity)
15397
- ] }) : usage.feature.name
15419
+ getFeatureName(
15420
+ entitlement.feature,
15421
+ entitlement.quantity
15422
+ )
15423
+ ] }) : entitlement.feature.name
15398
15424
  }
15399
15425
  ) }),
15400
15426
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
@@ -15405,9 +15431,9 @@ var Sidebar = ({
15405
15431
  $weight: theme.typography.text.fontWeight,
15406
15432
  $color: theme.typography.text.color,
15407
15433
  children: [
15408
- usage.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15434
+ entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15409
15435
  formatCurrency(
15410
- (entitlementPrice ?? 0) * quantity,
15436
+ (entitlementPrice ?? 0) * entitlement.quantity,
15411
15437
  entitlementCurrency
15412
15438
  ),
15413
15439
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
@@ -15415,14 +15441,14 @@ var Sidebar = ({
15415
15441
  shortenPeriod(planPeriod)
15416
15442
  ] })
15417
15443
  ] }),
15418
- usage.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15444
+ entitlement.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15419
15445
  formatCurrency(
15420
15446
  entitlementPrice ?? 0,
15421
15447
  entitlementCurrency
15422
15448
  ),
15423
15449
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
15424
15450
  "/",
15425
- getFeatureName(usage.feature, 1)
15451
+ getFeatureName(entitlement.feature, 1)
15426
15452
  ] })
15427
15453
  ] })
15428
15454
  ]
@@ -15439,13 +15465,13 @@ var Sidebar = ({
15439
15465
  []
15440
15466
  ),
15441
15467
  changedUsageBasedEntitlements.reduce(
15442
- (acc, { entitlement, previous, next: next2 }, index) => {
15443
- if (entitlement?.feature?.name) {
15468
+ (acc, { previous, next: next2 }, index) => {
15469
+ if (next2.feature?.name) {
15444
15470
  const {
15445
15471
  price: entitlementPrice,
15446
15472
  currency: entitlementCurrency
15447
15473
  } = getBillingPrice(
15448
- planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
15474
+ planPeriod === "year" ? next2.meteredYearlyPrice : next2.meteredMonthlyPrice
15449
15475
  ) || {};
15450
15476
  acc.push(
15451
15477
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Box, { children: [
@@ -15469,7 +15495,7 @@ var Sidebar = ({
15469
15495
  children: [
15470
15496
  previous.quantity,
15471
15497
  " ",
15472
- getFeatureName(entitlement.feature)
15498
+ getFeatureName(next2.feature)
15473
15499
  ]
15474
15500
  }
15475
15501
  ) }),
@@ -15512,7 +15538,7 @@ var Sidebar = ({
15512
15538
  children: [
15513
15539
  next2.quantity,
15514
15540
  " ",
15515
- getFeatureName(entitlement.feature)
15541
+ getFeatureName(next2.feature)
15516
15542
  ]
15517
15543
  }
15518
15544
  ) }),
@@ -15546,7 +15572,7 @@ var Sidebar = ({
15546
15572
  []
15547
15573
  ),
15548
15574
  addedUsageBasedEntitlements.reduce(
15549
- (acc, { entitlement, quantity }, index) => {
15575
+ (acc, entitlement, index) => {
15550
15576
  if (entitlement.feature?.name) {
15551
15577
  const {
15552
15578
  price: entitlementPrice,
@@ -15570,9 +15596,12 @@ var Sidebar = ({
15570
15596
  $weight: theme.typography.heading4.fontWeight,
15571
15597
  $color: theme.typography.heading4.color,
15572
15598
  children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15573
- quantity,
15599
+ entitlement.quantity,
15574
15600
  " ",
15575
- getFeatureName(entitlement.feature, quantity)
15601
+ getFeatureName(
15602
+ entitlement.feature,
15603
+ entitlement.quantity
15604
+ )
15576
15605
  ] }) : entitlement.feature.name
15577
15606
  }
15578
15607
  ) }),
@@ -15586,7 +15615,7 @@ var Sidebar = ({
15586
15615
  children: [
15587
15616
  entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
15588
15617
  formatCurrency(
15589
- (entitlementPrice ?? 0) * quantity,
15618
+ (entitlementPrice ?? 0) * entitlement.quantity,
15590
15619
  entitlementCurrency
15591
15620
  ),
15592
15621
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
@@ -16441,7 +16470,7 @@ var Checkout = ({
16441
16470
  $alignItems: "center",
16442
16471
  $flexGrow: 1,
16443
16472
  $marginTop: "-3.5rem",
16444
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { $size: "3xl" })
16473
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { $color: theme.primary, $size: "3xl" })
16445
16474
  }
16446
16475
  );
16447
16476
  }
@@ -17047,7 +17076,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17047
17076
  const unitPriceFontSize = 0.875 * theme.typography.text.fontSize;
17048
17077
  const unitPriceColor = hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46);
17049
17078
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce(
17050
- (acc, { entitlement, quantity, usage }, index) => {
17079
+ (acc, entitlement, index) => {
17051
17080
  if (entitlement.priceBehavior === "pay_in_advance" && entitlement.feature) {
17052
17081
  const { price, currency } = getBillingPrice(
17053
17082
  period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
@@ -17106,8 +17135,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17106
17135
  {
17107
17136
  $size: "lg",
17108
17137
  type: "number",
17109
- value: quantity,
17110
- min: usage,
17138
+ value: entitlement.quantity,
17139
+ min: entitlement.usage,
17111
17140
  autoFocus: true,
17112
17141
  onFocus: (event) => event.target.select(),
17113
17142
  onChange: (event) => {
@@ -17127,12 +17156,12 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17127
17156
  $weight: theme.typography.text.fontWeight,
17128
17157
  $color: unitPriceColor,
17129
17158
  children: [
17130
- quantity < usage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { color: "#DB6669" }, children: [
17159
+ entitlement.quantity < entitlement.usage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { color: "#DB6669" }, children: [
17131
17160
  t2("Cannot downgrade entitlement"),
17132
17161
  " "
17133
17162
  ] }),
17134
17163
  t2("Currently using", {
17135
- quantity: usage,
17164
+ quantity: entitlement.usage,
17136
17165
  unit: getFeatureName(entitlement.feature)
17137
17166
  })
17138
17167
  ]
@@ -17155,7 +17184,10 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17155
17184
  $weight: theme.typography.text.fontWeight,
17156
17185
  $color: theme.typography.text.color,
17157
17186
  children: [
17158
- formatCurrency((price ?? 0) * quantity, currency),
17187
+ formatCurrency(
17188
+ (price ?? 0) * entitlement.quantity,
17189
+ currency
17190
+ ),
17159
17191
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("sub", { children: [
17160
17192
  "/",
17161
17193
  shortenPeriod(period)
@@ -17198,6 +17230,22 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
17198
17230
 
17199
17231
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
17200
17232
  var import_jsx_runtime19 = require("react/jsx-runtime");
17233
+ var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc, entitlement) => {
17234
+ if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
17235
+ const featureUsage = entitlements.find(
17236
+ (usage2) => usage2.feature?.id === entitlement.feature?.id
17237
+ );
17238
+ const allocation = featureUsage?.allocation || 0;
17239
+ const usage = featureUsage?.usage || 0;
17240
+ acc.push({
17241
+ ...entitlement,
17242
+ allocation,
17243
+ usage,
17244
+ quantity: allocation
17245
+ });
17246
+ }
17247
+ return acc;
17248
+ };
17201
17249
  var CheckoutDialog = ({ top = 0 }) => {
17202
17250
  const { t: t2 } = useTranslation();
17203
17251
  const theme = nt();
@@ -17231,34 +17279,21 @@ var CheckoutDialog = ({ top = 0 }) => {
17231
17279
  )
17232
17280
  }))
17233
17281
  );
17234
- const createActiveUsageBasedEntitlementsReducer = (0, import_react26.useCallback)(
17235
- (period = planPeriod) => (acc, entitlement) => {
17236
- if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
17237
- const featureUsage = data.featureUsage?.features.find(
17238
- (usage2) => usage2.feature?.id === entitlement.feature?.id
17239
- );
17240
- const allocation = featureUsage?.allocation ?? 0;
17241
- const usage = featureUsage?.usage ?? 0;
17242
- acc.push({
17243
- entitlement,
17244
- allocation,
17245
- quantity: allocation,
17246
- usage
17247
- });
17248
- }
17249
- return acc;
17250
- },
17251
- [planPeriod, data.featureUsage?.features]
17252
- );
17282
+ const currentEntitlements = (0, import_react26.useMemo)(() => {
17283
+ return data.featureUsage?.features || [];
17284
+ }, [data.featureUsage?.features]);
17253
17285
  const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react26.useState)(
17254
17286
  () => (selectedPlan?.entitlements || []).reduce(
17255
- createActiveUsageBasedEntitlementsReducer(),
17287
+ createActiveUsageBasedEntitlementsReducer(
17288
+ currentEntitlements,
17289
+ planPeriod
17290
+ ),
17256
17291
  []
17257
17292
  )
17258
17293
  );
17259
17294
  const payInAdvanceEntitlements = (0, import_react26.useMemo)(
17260
17295
  () => usageBasedEntitlements.filter(
17261
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17296
+ (entitlement) => entitlement.priceBehavior === "pay_in_advance"
17262
17297
  ),
17263
17298
  [usageBasedEntitlements]
17264
17299
  );
@@ -17350,8 +17385,8 @@ var CheckoutDialog = ({ top = 0 }) => {
17350
17385
  []
17351
17386
  ),
17352
17387
  payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
17353
- (acc, { entitlement, quantity }) => {
17354
- const priceId = (period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice)?.priceId;
17388
+ (acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
17389
+ const priceId = (period === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
17355
17390
  if (priceId) {
17356
17391
  acc.push({
17357
17392
  priceId,
@@ -17400,7 +17435,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17400
17435
  }
17401
17436
  const period = updates.period || planPeriod;
17402
17437
  const entitlements = plan.entitlements.reduce(
17403
- createActiveUsageBasedEntitlementsReducer(period),
17438
+ createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
17404
17439
  []
17405
17440
  );
17406
17441
  if (updates.plan) {
@@ -17411,16 +17446,11 @@ var CheckoutDialog = ({ top = 0 }) => {
17411
17446
  period,
17412
17447
  plan: updates.plan,
17413
17448
  payInAdvanceEntitlements: entitlements.filter(
17414
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17449
+ ({ priceBehavior }) => priceBehavior === "pay_in_advance"
17415
17450
  )
17416
17451
  });
17417
17452
  },
17418
- [
17419
- planPeriod,
17420
- selectedPlan,
17421
- createActiveUsageBasedEntitlementsReducer,
17422
- previewCheckout
17423
- ]
17453
+ [planPeriod, selectedPlan, currentEntitlements, previewCheckout]
17424
17454
  );
17425
17455
  const changePlanPeriod = (0, import_react26.useCallback)(
17426
17456
  (period) => {
@@ -17443,16 +17473,14 @@ var CheckoutDialog = ({ top = 0 }) => {
17443
17473
  (id, updatedQuantity) => {
17444
17474
  setUsageBasedEntitlements((prev2) => {
17445
17475
  const updated = prev2.map(
17446
- ({ entitlement, allocation, quantity, usage }) => entitlement.id === id ? {
17447
- entitlement,
17448
- allocation,
17449
- quantity: updatedQuantity,
17450
- usage
17451
- } : { entitlement, allocation, quantity, usage }
17476
+ (entitlement) => entitlement.id === id ? {
17477
+ ...entitlement,
17478
+ quantity: updatedQuantity
17479
+ } : entitlement
17452
17480
  );
17453
17481
  previewCheckout({
17454
17482
  payInAdvanceEntitlements: updated.filter(
17455
- ({ entitlement }) => entitlement.priceBehavior === "pay_in_advance"
17483
+ ({ priceBehavior }) => priceBehavior === "pay_in_advance"
17456
17484
  )
17457
17485
  });
17458
17486
  return updated;
@@ -17581,7 +17609,7 @@ var CheckoutDialog = ({ top = 0 }) => {
17581
17609
  $size: theme.typography.heading3.fontSize,
17582
17610
  $weight: theme.typography.heading3.fontWeight,
17583
17611
  $color: theme.typography.heading3.color,
17584
- $marginBottom: "0.5rem",
17612
+ style: { marginBottom: "0.5rem" },
17585
17613
  children: activeCheckoutStage.label
17586
17614
  }
17587
17615
  ),
@@ -17856,11 +17884,11 @@ var PeriodToggle = ({
17856
17884
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
17857
17885
  Text,
17858
17886
  {
17859
- $flexShrink: 0,
17860
17887
  $font: theme.typography.text.fontFamily,
17861
17888
  $size: 15,
17862
17889
  $weight: option === selectedOption ? 600 : 400,
17863
17890
  $color: theme.typography.text.color,
17891
+ style: { flexShrink: 0 },
17864
17892
  children: t2("Billed", { period: adjectify(option) })
17865
17893
  }
17866
17894
  )
@@ -17920,23 +17948,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
17920
17948
  ),
17921
17949
  [data.company?.plan, planPeriod, availablePlans]
17922
17950
  );
17951
+ const currentEntitlements = data.featureUsage?.features || [];
17923
17952
  const usageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
17924
- (acc, entitlement) => {
17925
- if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.meteredMonthlyPrice || planPeriod === "year" && entitlement.meteredYearlyPrice)) {
17926
- const featureUsage = data.featureUsage?.features.find(
17927
- (usage2) => usage2.feature?.id === entitlement.feature?.id
17928
- );
17929
- const allocation = featureUsage?.allocation ?? 0;
17930
- const usage = featureUsage?.usage ?? 0;
17931
- acc.push({
17932
- entitlement,
17933
- allocation,
17934
- quantity: allocation,
17935
- usage
17936
- });
17937
- }
17938
- return acc;
17939
- },
17953
+ createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
17940
17954
  []
17941
17955
  );
17942
17956
  const addOns = (0, import_react29.useMemo)(
@@ -18259,21 +18273,18 @@ var RenderLayout = ({ children }) => {
18259
18273
  };
18260
18274
 
18261
18275
  // src/components/layout/viewport/styles.ts
18262
- var StyledViewport = dt(Box).attrs(({ theme }) => ({
18263
- $gridTemplateColumns: "repeat(1, minmax(300px, 1fr))",
18264
- $viewport: {
18265
- md: {
18266
- $gridTemplateColumns: `repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`
18267
- }
18268
- }
18269
- })).withConfig({
18276
+ var StyledViewport = dt.div.withConfig({
18270
18277
  shouldForwardProp: (prop) => !["$numberOfColumns", "numberOfColumns"].includes(prop)
18271
18278
  })`
18272
18279
  display: grid;
18273
-
18280
+ grid-template-columns: repeat(1, minmax(300px, 1fr));
18274
18281
  margin-left: auto;
18275
18282
  margin-right: auto;
18276
18283
  gap: 1rem;
18284
+
18285
+ @media (min-width: 768px) {
18286
+ grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
18287
+ }
18277
18288
  `;
18278
18289
 
18279
18290
  // src/components/layout/viewport/Viewport.tsx
@@ -18772,7 +18783,8 @@ Invoices.displayName = "Invoices";
18772
18783
  var import_react34 = require("react");
18773
18784
 
18774
18785
  // src/components/elements/metered-features/styles.ts
18775
- var Container4 = dt(Flex)`
18786
+ var Container4 = dt.div`
18787
+ display: flex;
18776
18788
  flex-direction: column;
18777
18789
  gap: 1rem;
18778
18790
 
@@ -19581,7 +19593,7 @@ var PaymentMethodDetails = ({
19581
19593
  $zIndex: 1,
19582
19594
  $backgroundColor: "black",
19583
19595
  $opacity: 0.5,
19584
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, { $size: "2xl" })
19596
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, { $color: theme.primary, $size: "2xl" })
19585
19597
  }
19586
19598
  ),
19587
19599
  /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
@@ -19771,11 +19783,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19771
19783
  const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
19772
19784
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
19773
19785
  isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
19774
- Box,
19786
+ Notice,
19775
19787
  {
19776
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.04)" : "hsla(0, 0%, 100%, 0.04)",
19788
+ as: Flex,
19789
+ $flexDirection: "column",
19790
+ $gap: "0.5rem",
19791
+ $padding: "1.5rem",
19777
19792
  $textAlign: "center",
19778
- $padding: "1rem",
19793
+ $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19779
19794
  children: [
19780
19795
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19781
19796
  Text,
@@ -19806,11 +19821,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19806
19821
  ]
19807
19822
  }
19808
19823
  ) : willSubscriptionCancel && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
19809
- Box,
19824
+ Notice,
19810
19825
  {
19811
- $backgroundColor: isLightBackground ? "hsla(0, 0%, 0%, 0.04)" : "hsla(0, 0%, 100%, 0.04)",
19826
+ as: Flex,
19827
+ $flexDirection: "column",
19828
+ $gap: "0.5rem",
19829
+ $padding: "1.5rem",
19812
19830
  $textAlign: "center",
19813
- $padding: "1rem",
19831
+ $backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
19814
19832
  children: [
19815
19833
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19816
19834
  Text,
@@ -19823,7 +19841,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19823
19841
  children: t2("Subscription canceled")
19824
19842
  }
19825
19843
  ),
19826
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19844
+ billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
19827
19845
  Text,
19828
19846
  {
19829
19847
  as: "p",
@@ -19831,14 +19849,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
19831
19849
  $size: 0.8125 * theme.typography.text.fontSize,
19832
19850
  $weight: theme.typography.text.fontWeight,
19833
19851
  $color: theme.typography.text.color,
19834
- children: billingSubscription?.cancelAt ? t2("Access to plan will end on", {
19852
+ children: t2("Access to plan will end on", {
19835
19853
  date: toPrettyDate(
19836
19854
  new Date(billingSubscription.cancelAt * 1e3),
19837
19855
  {
19838
19856
  month: "numeric"
19839
19857
  }
19840
19858
  )
19841
- }) : ""
19859
+ })
19842
19860
  }
19843
19861
  )
19844
19862
  ]
@@ -21138,7 +21156,7 @@ var Loading = () => {
21138
21156
  $alignItems: "center",
21139
21157
  $justifyContent: "center",
21140
21158
  $padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
21141
- children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { $size: "2xl", $color: "#194BFB" })
21159
+ children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { $color: "#194BFB", $size: "2xl" })
21142
21160
  }
21143
21161
  );
21144
21162
  };