@sudobility/building_blocks 0.0.30 → 0.0.31

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.
@@ -88,11 +88,21 @@ export interface SubscriptionPageFormatters {
88
88
  formatSavePercent: (percent: number) => string;
89
89
  /** Format intro price note */
90
90
  formatIntroNote: (price: string) => string;
91
+ /** Get features for a product by its identifier (required - same as pricing page) */
92
+ getProductFeatures: (productId: string) => string[];
93
+ }
94
+ /** Package ID to entitlement mapping (same as PricingPage) */
95
+ export interface EntitlementMap {
96
+ [packageId: string]: string;
97
+ }
98
+ /** Entitlement to level mapping for comparing plan tiers (same as PricingPage) */
99
+ export interface EntitlementLevels {
100
+ [entitlement: string]: number;
91
101
  }
92
102
  export interface AppSubscriptionsPageProps {
93
103
  /** Subscription context value */
94
104
  subscription: SubscriptionContextValue;
95
- /** Rate limit configuration */
105
+ /** Rate limit configuration (for displaying current usage, not for features) */
96
106
  rateLimitsConfig?: RateLimitsConfigData | null;
97
107
  /** User ID used for subscription (the selected entity's ID when logged in) */
98
108
  subscriptionUserId?: string;
@@ -100,8 +110,10 @@ export interface AppSubscriptionsPageProps {
100
110
  labels: SubscriptionPageLabels;
101
111
  /** Formatter functions for dynamic strings */
102
112
  formatters: SubscriptionPageFormatters;
103
- /** Package ID to entitlement mapping */
104
- packageEntitlementMap?: Record<string, string>;
113
+ /** Package ID to entitlement mapping (same as PricingPage) */
114
+ entitlementMap: EntitlementMap;
115
+ /** Entitlement to level mapping for comparing tiers (same as PricingPage) */
116
+ entitlementLevels: EntitlementLevels;
105
117
  /** Called when purchase succeeds */
106
118
  onPurchaseSuccess?: () => void;
107
119
  /** Called when restore succeeds */
@@ -115,5 +127,6 @@ export interface AppSubscriptionsPageProps {
115
127
  }
116
128
  /**
117
129
  * Page for managing app subscriptions.
130
+ * Uses the same entitlement mapping and features display as AppPricingPage.
118
131
  */
119
- export declare function AppSubscriptionsPage({ subscription, rateLimitsConfig, subscriptionUserId, labels, formatters, packageEntitlementMap, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, onTrack, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;
132
+ export declare function AppSubscriptionsPage({ subscription, rateLimitsConfig, subscriptionUserId, labels, formatters, entitlementMap, entitlementLevels: _entitlementLevels, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, onTrack, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.js CHANGED
@@ -4271,21 +4271,14 @@ function Yt({
4271
4271
  createContext(
4272
4272
  void 0
4273
4273
  );
4274
- const DEFAULT_PACKAGE_ENTITLEMENT_MAP = {
4275
- ultra_yearly: "bandwidth_ultra",
4276
- ultra_monthly: "bandwidth_ultra",
4277
- pro_yearly: "bandwidth_pro",
4278
- pro_monthly: "bandwidth_pro",
4279
- dev_yearly: "bandwidth_dev",
4280
- dev_monthly: "bandwidth_dev"
4281
- };
4282
4274
  function AppSubscriptionsPage({
4283
4275
  subscription,
4284
4276
  rateLimitsConfig,
4285
4277
  subscriptionUserId,
4286
4278
  labels,
4287
4279
  formatters,
4288
- packageEntitlementMap = DEFAULT_PACKAGE_ENTITLEMENT_MAP,
4280
+ entitlementMap,
4281
+ entitlementLevels: _entitlementLevels,
4289
4282
  onPurchaseSuccess,
4290
4283
  onRestoreSuccess,
4291
4284
  onError,
@@ -4450,19 +4443,6 @@ function AppSubscriptionsPage({
4450
4443
  },
4451
4444
  [formatters]
4452
4445
  );
4453
- const getRateLimitTierForProduct = useCallback(
4454
- (packageId) => {
4455
- if (!(rateLimitsConfig == null ? void 0 : rateLimitsConfig.tiers)) return void 0;
4456
- const entitlement = packageEntitlementMap[packageId];
4457
- if (entitlement) {
4458
- return rateLimitsConfig.tiers.find(
4459
- (tier) => tier.entitlement === entitlement
4460
- );
4461
- }
4462
- return rateLimitsConfig.tiers.find((tier) => tier.entitlement === "none");
4463
- },
4464
- [rateLimitsConfig, packageEntitlementMap]
4465
- );
4466
4446
  const formatRateLimit = useCallback(
4467
4447
  (limit) => {
4468
4448
  if (limit === null) return labels.unlimited;
@@ -4470,84 +4450,25 @@ function AppSubscriptionsPage({
4470
4450
  },
4471
4451
  [labels.unlimited]
4472
4452
  );
4473
- const getRateLimitFeatures = useCallback(
4474
- (packageId) => {
4475
- const tier = getRateLimitTierForProduct(packageId);
4476
- if (!tier) return [];
4477
- const features = [];
4478
- if (tier.limits.hourly !== null) {
4479
- features.push(
4480
- formatters.formatHourlyLimit(formatRateLimit(tier.limits.hourly))
4481
- );
4482
- }
4483
- if (tier.limits.daily !== null) {
4484
- features.push(
4485
- formatters.formatDailyLimit(formatRateLimit(tier.limits.daily))
4486
- );
4487
- }
4488
- if (tier.limits.monthly !== null) {
4489
- features.push(
4490
- formatters.formatMonthlyLimit(formatRateLimit(tier.limits.monthly))
4491
- );
4492
- }
4493
- if (tier.limits.hourly === null && tier.limits.daily === null && tier.limits.monthly === null) {
4494
- features.push(labels.unlimitedRequests);
4495
- }
4496
- return features;
4497
- },
4498
- [
4499
- getRateLimitTierForProduct,
4500
- formatRateLimit,
4501
- formatters,
4502
- labels.unlimitedRequests
4503
- ]
4504
- );
4505
4453
  const getProductFeatures = useCallback(
4506
4454
  (packageId) => {
4507
- return getRateLimitFeatures(packageId);
4455
+ return formatters.getProductFeatures(packageId);
4508
4456
  },
4509
- [getRateLimitFeatures]
4457
+ [formatters]
4510
4458
  );
4511
4459
  const getFreeTierFeatures = useCallback(() => {
4512
- const benefits = [...labels.freeTierFeatures];
4513
- if (rateLimitsConfig == null ? void 0 : rateLimitsConfig.tiers) {
4514
- const freeTier = rateLimitsConfig.tiers.find(
4515
- (tier) => tier.entitlement === "none"
4516
- );
4517
- if (freeTier) {
4518
- if (freeTier.limits.hourly !== null) {
4519
- benefits.push(
4520
- formatters.formatHourlyLimit(
4521
- formatRateLimit(freeTier.limits.hourly)
4522
- )
4523
- );
4524
- }
4525
- if (freeTier.limits.daily !== null) {
4526
- benefits.push(
4527
- formatters.formatDailyLimit(formatRateLimit(freeTier.limits.daily))
4528
- );
4529
- }
4530
- if (freeTier.limits.monthly !== null) {
4531
- benefits.push(
4532
- formatters.formatMonthlyLimit(
4533
- formatRateLimit(freeTier.limits.monthly)
4534
- )
4535
- );
4536
- }
4537
- }
4538
- }
4539
- return benefits;
4540
- }, [rateLimitsConfig, formatRateLimit, formatters, labels.freeTierFeatures]);
4460
+ return labels.freeTierFeatures;
4461
+ }, [labels.freeTierFeatures]);
4541
4462
  const getYearlySavingsPercent = useCallback(
4542
4463
  (yearlyPackageId) => {
4543
4464
  var _a;
4544
- const yearlyEntitlement = packageEntitlementMap[yearlyPackageId];
4465
+ const yearlyEntitlement = entitlementMap[yearlyPackageId];
4545
4466
  if (!yearlyEntitlement) return void 0;
4546
4467
  const yearlyProduct = products.find(
4547
4468
  (p) => p.identifier === yearlyPackageId
4548
4469
  );
4549
4470
  if (!yearlyProduct) return void 0;
4550
- const monthlyPackageId = (_a = Object.entries(packageEntitlementMap).find(
4471
+ const monthlyPackageId = (_a = Object.entries(entitlementMap).find(
4551
4472
  ([pkgId, ent]) => ent === yearlyEntitlement && pkgId.includes("monthly")
4552
4473
  )) == null ? void 0 : _a[0];
4553
4474
  if (!monthlyPackageId) return void 0;
@@ -4562,7 +4483,7 @@ function AppSubscriptionsPage({
4562
4483
  const savings = (annualizedMonthly - yearlyPrice) / annualizedMonthly * 100;
4563
4484
  return Math.round(savings);
4564
4485
  },
4565
- [products, packageEntitlementMap]
4486
+ [products, entitlementMap]
4566
4487
  );
4567
4488
  const billingPeriodOptions = [
4568
4489
  { value: "monthly", label: labels.billingMonthly },
@@ -4823,7 +4744,9 @@ function AppPricingPage({
4823
4744
  style: {
4824
4745
  display: "grid",
4825
4746
  gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 280px), 1fr))",
4826
- gap: "1.5rem"
4747
+ gridAutoRows: "1fr",
4748
+ gap: "1.5rem",
4749
+ overflow: "visible"
4827
4750
  },
4828
4751
  children: [
4829
4752
  /* @__PURE__ */ jsx(