@schematichq/schematic-components 2.35.0 → 2.36.0

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.
@@ -11,6 +11,7 @@ import { CatalogCreditBundle } from '@schematichq/schematic-react';
11
11
  import { CatalogEntitlement } from '@schematichq/schematic-react';
12
12
  import { CatalogPlan } from '@schematichq/schematic-react';
13
13
  import { CatalogQuery } from '@schematichq/schematic-react';
14
+ import { CatalogView } from '@schematichq/schematic-react';
14
15
  import type { Checkout as Checkout_2 } from '@schematichq/schematic-react';
15
16
  import { CheckoutHandle } from '@schematichq/schematic-react';
16
17
  import { CheckoutPriceSnapshot } from '@schematichq/schematic-react';
@@ -42,6 +43,8 @@ import { MeteredPrice } from '@schematichq/schematic-react';
42
43
  import { PaymentMethod } from '@schematichq/schematic-react';
43
44
  import { PaymentMethodsHandle } from '@schematichq/schematic-react';
44
45
  import { PerLicenseCreditGrant } from '@schematichq/schematic-react';
46
+ import { PublicCatalog } from '@schematichq/schematic-react';
47
+ import { PublicCatalogPlan } from '@schematichq/schematic-react';
45
48
  import { default as React_2 } from 'react';
46
49
  import { ResourceHandle } from '@schematichq/schematic-react';
47
50
  import { ResourceState } from '@schematichq/schematic-react';
@@ -78,6 +81,8 @@ import { useTaxIds } from '@schematichq/schematic-react';
78
81
  import { useUnsubscribe } from '@schematichq/schematic-react';
79
82
  import { useUpcomingInvoice } from '@schematichq/schematic-react';
80
83
 
84
+ declare type AnyPlan = CatalogPlan | PublicCatalogPlan;
85
+
81
86
  /** A company's own automatic top-up for one of the plan's credits. */
82
87
  export declare interface AutoTopupChoice {
83
88
  enabled?: boolean;
@@ -212,6 +217,8 @@ export declare function catalogPriceName(catalog: Catalog, priceId: string | nul
212
217
 
213
218
  export { CatalogQuery }
214
219
 
220
+ export { CatalogView }
221
+
215
222
  /**
216
223
  * A purchase in a dialog: the plan and its period, add-ons, pay-in-advance
217
224
  * quantities, credit bundles and automatic top-ups, then payment. Each change
@@ -499,6 +506,15 @@ export declare interface CheckoutSelection {
499
506
  customFields?: Record<string, string>;
500
507
  }
501
508
 
509
+ /**
510
+ * The cart a card's action opens a checkout on. A checkout starts from the
511
+ * add-ons it is given, so every add-on action restates the whole list. An
512
+ * add-on chosen or changed takes the card's period, which the checkout
513
+ * applies to the whole subscription. The public catalog holds nothing, so
514
+ * its carts are only good before sign-in.
515
+ */
516
+ export declare function checkoutSelectionFor(view: PricingTableView, card: PricingCard, kind: "plan" | "addOn"): CheckoutSelection;
517
+
502
518
  export { CheckoutSelections }
503
519
 
504
520
  /**
@@ -814,6 +830,32 @@ export declare interface DerivePlanManagerOptions extends UsageLimitOptions {
814
830
  showZeroPriceAsFree?: boolean;
815
831
  }
816
832
 
833
+ export declare function derivePricingTable(view: CatalogView, options: DerivePricingTableOptions): PricingTableView;
834
+
835
+ export declare interface DerivePricingTableOptions {
836
+ locale: string;
837
+ /** The period asked for; one the catalog does not offer falls back. */
838
+ period?: PricingPeriod;
839
+ /** The currency asked for; one the catalog does not offer falls back. */
840
+ currency?: string;
841
+ /**
842
+ * The company, for the period its subscription bills in: the current
843
+ * plan is current only in that period, and it is the default one.
844
+ */
845
+ company?: Company;
846
+ /** Included credits on each card. Default true. */
847
+ showCredits?: boolean;
848
+ /** A plan priced at zero reads "Free". Default false. */
849
+ showZeroPriceAsFree?: boolean;
850
+ /**
851
+ * Show an entitlement's warning threshold in place of its limit, where one
852
+ * is configured. Default false.
853
+ */
854
+ showWarningThresholdAsLimit?: boolean;
855
+ /** For the trial countdown; the clock otherwise. */
856
+ now?: Date;
857
+ }
858
+
817
859
  /**
818
860
  * Whether there is a subscription to cancel, when access ends, and what
819
861
  * cancelling stops charging for.
@@ -1029,6 +1071,51 @@ export declare type ElementStrings = {
1029
1071
  planManagerEdit: string;
1030
1072
  planManagerSeeAll: string;
1031
1073
  planManagerHideAll: string;
1074
+ pricingTableLoading: string;
1075
+ pricingTableError: string;
1076
+ pricingTableUnavailable: string;
1077
+ pricingTablePlans: string;
1078
+ pricingTableAddOns: string;
1079
+ pricingTableCurrency: string;
1080
+ pricingTablePeriod: string;
1081
+ pricingTableBilledMonthly: string;
1082
+ pricingTableBilledQuarterly: string;
1083
+ pricingTableBilledYearly: string;
1084
+ pricingTableFree: string;
1085
+ pricingTableUsageBased: string;
1086
+ pricingTableCustomPlan: string;
1087
+ pricingTableCustomPrice: string;
1088
+ pricingTableTalkToSupport: string;
1089
+ pricingTableActive: string;
1090
+ pricingTableTrialLeft: string;
1091
+ pricingTableCurrentPlan: string;
1092
+ pricingTableChoosePlan: string;
1093
+ pricingTableOverLimit: string;
1094
+ pricingTableOverLimitDetail: string;
1095
+ pricingTableChooseAddOn: string;
1096
+ pricingTableChangeAddOn: string;
1097
+ pricingTableRemoveAddOn: string;
1098
+ pricingTableEverythingIn: string;
1099
+ pricingTableSeeAll: string;
1100
+ pricingTableHideAll: string;
1101
+ pricingTableTierBased: string;
1102
+ pricingTableThen: string;
1103
+ pricingTableCredits: string;
1104
+ pricingTableCreditsPerPeriod: string;
1105
+ pricingTableCreditsPerLicense: string;
1106
+ pricingTableCreditsPerLicensePerPeriod: string;
1107
+ pricingTableCreditsPlus: string;
1108
+ pricingTableCreditsPlusPerPeriod: string;
1109
+ pricingTableSaveYearly: string;
1110
+ pricingTableSaveQuarterly: string;
1111
+ pricingTableSavingYearly: string;
1112
+ pricingTableSavingQuarterly: string;
1113
+ pricingTableUnitsPerPeriod: string;
1114
+ pricingTablePerUnitPerPeriod: string;
1115
+ pricingTablePerPackagePerPeriod: string;
1116
+ pricingTablePerUse: string;
1117
+ pricingTableUpTo: string;
1118
+ pricingTableUpToPerPeriod: string;
1032
1119
  unsubscribeButton: string;
1033
1120
  unsubscribeTitle: string;
1034
1121
  unsubscribeAccessUntil: string;
@@ -1317,13 +1404,14 @@ export declare type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
1317
1404
  export declare function httpStatus(error: Error | undefined): number | undefined;
1318
1405
 
1319
1406
  /**
1320
- * GENERATED by scripts/inline-icons.mjs from @schematichq/schematic-icons@0.8.0.
1321
- * Do not edit; run `pnpm run icons` after bumping the package.
1322
- *
1323
- * The icon font and its glyph rules, appended to the elements stylesheet by
1324
- * `<SchematicStyles />`. Glyphs render on `.schematic-icon
1325
- * .schematic-icon--<name>`.
1407
+ * A feature's or credit's icon as the dashboard sets it: a schematic-icons
1408
+ * glyph by name, or anything else, an emoji, drawn as the text it is.
1326
1409
  */
1410
+ export declare const Icon: React_2.FC<{
1411
+ className?: string;
1412
+ name: string;
1413
+ }>;
1414
+
1327
1415
  export declare const iconsCss: string;
1328
1416
 
1329
1417
  export declare interface IncludedFeatureRow {
@@ -2083,6 +2171,329 @@ export declare function pricePeriod(price: MeteredPrice | undefined): string | n
2083
2171
  */
2084
2172
  export declare type PriceTier = MeteredPrice["priceTiers"][number];
2085
2173
 
2174
+ /** What a card's call to action does, decided by the server's standing. */
2175
+ export declare type PricingAction =
2176
+ /** The company's plan in this period: no action, "Current plan". */
2177
+ {
2178
+ kind: "current";
2179
+ }
2180
+ /** "Choose plan"; `upgrade` sits above the current plan. */
2181
+ | {
2182
+ kind: "choose";
2183
+ upgrade: boolean;
2184
+ }
2185
+ /** An add-on the company holds: "Remove add-on". */
2186
+ | {
2187
+ kind: "remove";
2188
+ }
2189
+ /** An add-on the company holds in another period: "Change add-on". */
2190
+ | {
2191
+ kind: "change";
2192
+ }
2193
+ /** Over a limit the plan would set: disabled, with the violations. */
2194
+ | {
2195
+ kind: "overLimit";
2196
+ violations: PricingViolation[];
2197
+ }
2198
+ /** A downgrade the account does not allow in self-service. */
2199
+ | {
2200
+ kind: "downgradeBlocked";
2201
+ text: string | null;
2202
+ url: string | null;
2203
+ }
2204
+ /** The company cannot check out at all: a disabled "Choose plan". */
2205
+ | {
2206
+ kind: "unavailable";
2207
+ };
2208
+
2209
+ export declare interface PricingCard {
2210
+ id: string;
2211
+ name: string;
2212
+ description: string | null;
2213
+ price: PricingPrice;
2214
+ /** The price the card's period and currency picked, for a checkout. */
2215
+ priceId: string | null;
2216
+ /** The card's period: the chosen one, or `null` for one-time. */
2217
+ period: PricingPeriod | null;
2218
+ credits: PricingCreditLine[];
2219
+ entitlements: PricingEntitlementRow[];
2220
+ /** `null` in the public catalog, where there is no company. */
2221
+ action: PricingAction | null;
2222
+ /** The company's plan in the chosen period, for the card's outline. */
2223
+ active: boolean;
2224
+ trialDays: number | null;
2225
+ source: AnyPlan;
2226
+ }
2227
+
2228
+ /** "100 AI credits per month", one per credit the plan grants and shows. */
2229
+ export declare interface PricingCreditLine {
2230
+ creditId: string;
2231
+ icon: string | null;
2232
+ amount: string;
2233
+ creditName: string;
2234
+ /** "month", "year", …; `null` for a grant that does not renew. */
2235
+ period: string | null;
2236
+ /** "seat", for a grant per license. */
2237
+ perLicense: string | null;
2238
+ /**
2239
+ * What the plan grants the company outright beside a grant per license,
2240
+ * worded under it: "Plus 100 AI credits per month for your company".
2241
+ */
2242
+ plus: {
2243
+ amount: string;
2244
+ creditName: string;
2245
+ period: string | null;
2246
+ } | null;
2247
+ }
2248
+
2249
+ export declare interface PricingCustomPlan {
2250
+ priceText: string | null;
2251
+ ctaText: string | null;
2252
+ ctaUrl: string | null;
2253
+ }
2254
+
2255
+ /** The line beneath an entitlement's text. */
2256
+ export declare type PricingEntitlementDetail =
2257
+ /** "then $0.50/API call", "/mo" for a trait feature. */
2258
+ {
2259
+ kind: "overage";
2260
+ cost: string;
2261
+ size: string | null;
2262
+ units: string;
2263
+ period: PricingPeriod | null;
2264
+ }
2265
+ /** "Tier-based", with the tiers in a tip. */
2266
+ | {
2267
+ kind: "tiered";
2268
+ };
2269
+
2270
+ export declare interface PricingEntitlementRow {
2271
+ featureId: string;
2272
+ /** A schematic-icons glyph name; `null` when the feature has none. */
2273
+ icon: string | null;
2274
+ description: string | null;
2275
+ text: PricingEntitlementText;
2276
+ detail: PricingEntitlementDetail | null;
2277
+ tiers: {
2278
+ ranges: TierRange[];
2279
+ currency: string;
2280
+ mode: "graduated" | "volume" | null;
2281
+ period: PricingPeriod | null;
2282
+ unit: string;
2283
+ } | null;
2284
+ /** The limit a priced numeric entitlement is billed up to. */
2285
+ hardLimit: {
2286
+ amount: string;
2287
+ units: string;
2288
+ } | null;
2289
+ source: CatalogEntitlement;
2290
+ }
2291
+
2292
+ /** What an entitlement grants, worded by the element. */
2293
+ export declare type PricingEntitlementText =
2294
+ /** "API calls": a boolean feature, or a tiered one. */
2295
+ {
2296
+ kind: "name";
2297
+ name: string;
2298
+ }
2299
+ /** "Unlimited API calls". */
2300
+ | {
2301
+ kind: "unlimited";
2302
+ item: string;
2303
+ }
2304
+ /** "1,000 API calls", with "per month" for a metric period. */
2305
+ | {
2306
+ kind: "units";
2307
+ amount: string;
2308
+ units: string;
2309
+ period: string | null;
2310
+ }
2311
+ /** "$0.01 per API call", with "per month" for one paid in advance. */
2312
+ | {
2313
+ kind: "perUnit";
2314
+ cost: string;
2315
+ size: string | null;
2316
+ units: string;
2317
+ period: PricingPeriod | null;
2318
+ }
2319
+ /** "4 credits per API call". */
2320
+ | {
2321
+ kind: "perUse";
2322
+ amount: string;
2323
+ credits: string;
2324
+ unit: string;
2325
+ }
2326
+ /** "Up to 25 API calls", per period when the credit renews. */
2327
+ | {
2328
+ kind: "upTo";
2329
+ amount: string;
2330
+ units: string;
2331
+ period: string | null;
2332
+ };
2333
+
2334
+ /**
2335
+ * Display parts for a pricing table: the periods and currencies on offer,
2336
+ * and a card per plan and add-on priced in the ones chosen. Numbers, names
2337
+ * and prices arrive formatted; the element owns the wording, keyed by
2338
+ * `kind`. Which plan is current, valid or trialable is the server's to say,
2339
+ * and the public catalog says none of it.
2340
+ */
2341
+ export declare type PricingPeriod = "month" | "quarter" | "year";
2342
+
2343
+ /** What a card costs in the chosen period and currency. */
2344
+ export declare type PricingPrice =
2345
+ /** "$25.00", per `period`; `null` for a one-time add-on. */
2346
+ {
2347
+ kind: "amount";
2348
+ amount: string;
2349
+ period: PricingPeriod | null;
2350
+ }
2351
+ /** Priced at zero, with `showZeroPriceAsFree`. */
2352
+ | {
2353
+ kind: "free";
2354
+ }
2355
+ /** Priced at zero, and billed by what it is used. */
2356
+ | {
2357
+ kind: "usageBased";
2358
+ };
2359
+
2360
+ /** What a card's action does: `remove` and `change` are for a held add-on. */
2361
+ export declare type PricingSelectionAction = "choose" | "remove" | "change";
2362
+
2363
+ /**
2364
+ * The catalog's plans and add-ons, priced in the period and currency the
2365
+ * reader picks.
2366
+ *
2367
+ * It reads the catalog through `useCatalog`: the public catalog until
2368
+ * someone signs in, then the company's view, which adds the current plan,
2369
+ * the plans the company cannot move to and why, and whether it can check
2370
+ * out. With a session it also waits for the company, for the period its
2371
+ * subscription bills in; a company that fails to load costs only that
2372
+ * period.
2373
+ * The table opens nothing itself: each card's action calls `onSelectPlan`.
2374
+ */
2375
+ export declare function PricingTable({ callToActionTarget, callToActionUrl, catalogId, className, currency: currencyProp, defaultCurrency, defaultPeriod, headingLevel, locale: localeProp, onCurrencyChange, onPeriodChange, onSelectPlan, period: periodProp, showAddOns, showCredits, showCurrencySelector, showDescription, showEntitlements, showFeatureDescriptions, showFeatureIcons, showHardLimit, showHeader, showInclusionText, showPeriodToggle, showPlans, showWarningThresholdAsLimit, showZeroPriceAsFree, strings, }: PricingTableProps): JSX.Element;
2376
+
2377
+ export declare namespace PricingTable {
2378
+ var resources: readonly ["catalog", "publicCatalog", "company"];
2379
+ }
2380
+
2381
+ export declare interface PricingTableProps extends ElementProps {
2382
+ /** The catalog to show; the environment's when absent. */
2383
+ catalogId?: string;
2384
+ /** Heading level of "Plans" and "Add-ons"; the cards sit one below. Default 2. */
2385
+ headingLevel?: HeadingLevel;
2386
+ /** "Plans" and "Add-ons" above their cards. Default true. */
2387
+ showHeader?: boolean;
2388
+ /** The plans, and the custom plan where the catalog offers one. Default true. */
2389
+ showPlans?: boolean;
2390
+ /** The add-ons. Default true. */
2391
+ showAddOns?: boolean;
2392
+ /** The monthly / yearly toggle, when the catalog prices in more than one. Default true. */
2393
+ showPeriodToggle?: boolean;
2394
+ /** The currency picker, when the catalog prices in more than one. Default true. */
2395
+ showCurrencySelector?: boolean;
2396
+ /** Each card's description. Default true. */
2397
+ showDescription?: boolean;
2398
+ /** Each card's features. Default true. */
2399
+ showEntitlements?: boolean;
2400
+ /** Each feature's icon. Default true. */
2401
+ showFeatureIcons?: boolean;
2402
+ /** Each feature's description. Default false. */
2403
+ showFeatureDescriptions?: boolean;
2404
+ /** "Everything in {plan}, plus" above each plan's features but the first. Default true. */
2405
+ showInclusionText?: boolean;
2406
+ /** Each plan's included credits, and "credits per use" on its features. Default true. */
2407
+ showCredits?: boolean;
2408
+ /** A plan priced at zero reads "Free". Default false. */
2409
+ showZeroPriceAsFree?: boolean;
2410
+ /** An info tip with the hard limit on features billed past it. Default false. */
2411
+ showHardLimit?: boolean;
2412
+ /**
2413
+ * Show an entitlement's warning threshold in place of its limit, where one
2414
+ * is configured. Default false.
2415
+ */
2416
+ showWarningThresholdAsLimit?: boolean;
2417
+ /** The period shown. Set it to control the toggle; leave it to let the table. */
2418
+ period?: PricingPeriod;
2419
+ /** The period first shown when `period` is not set. */
2420
+ defaultPeriod?: PricingPeriod;
2421
+ onPeriodChange?: (period: PricingPeriod) => void;
2422
+ /** The currency shown, lowercase. Set it to control the picker. */
2423
+ currency?: string;
2424
+ /** The currency first shown when `currency` is not set. */
2425
+ defaultCurrency?: string;
2426
+ onCurrencyChange?: (currency: string) => void;
2427
+ /**
2428
+ * A card's action calls this: open a checkout with the selection, or send
2429
+ * a visitor nobody has signed in as to sign up. Without it or
2430
+ * `callToActionUrl`, cards have no action.
2431
+ */
2432
+ onSelectPlan?: (selection: PricingTableSelection) => void;
2433
+ /**
2434
+ * A card's action links here when there is no `onSelectPlan`, and a
2435
+ * blocked downgrade does when the account has no link of its own.
2436
+ */
2437
+ callToActionUrl?: string;
2438
+ /** `target` for `callToActionUrl`. */
2439
+ callToActionTarget?: string;
2440
+ }
2441
+
2442
+ /** What a card's action hands the host, to open a checkout or a sign-up. */
2443
+ export declare interface PricingTableSelection {
2444
+ kind: "plan" | "addOn";
2445
+ /** `remove` and `change` are for an add-on the company holds. */
2446
+ action: PricingSelectionAction;
2447
+ /** The plan's or add-on's id. */
2448
+ id: string;
2449
+ /** The price the card shows, for a checkout's selections. */
2450
+ priceId: string | null;
2451
+ /** `null` for a one-time add-on. */
2452
+ period: PricingPeriod | null;
2453
+ currency: string;
2454
+ /** A trial the plan offers, in days. */
2455
+ trialDays: number | null;
2456
+ /**
2457
+ * The cart to open `<Checkout selection={...} />` on for this action, from
2458
+ * the catalog the table read: build it again after sign-in, since the
2459
+ * public catalog knows no add-ons the company holds.
2460
+ */
2461
+ checkout: CheckoutSelection;
2462
+ }
2463
+
2464
+ export declare interface PricingTableView {
2465
+ source: CatalogView["source"];
2466
+ /** In month, quarter, year order; empty when nothing recurs. */
2467
+ periods: PricingPeriod[];
2468
+ /** One of `periods`, or `null` when there are none. */
2469
+ period: PricingPeriod | null;
2470
+ currencies: string[];
2471
+ currency: string;
2472
+ plans: PricingCard[];
2473
+ addOns: PricingCard[];
2474
+ /** The catalog's custom-plan call to action, when it offers one. */
2475
+ customPlan: PricingCustomPlan | null;
2476
+ /**
2477
+ * What the company's plan saves over paying monthly, by period, as a
2478
+ * percentage: "16.67%". Empty in the public catalog, and without a
2479
+ * current plan priced monthly.
2480
+ */
2481
+ savings: Partial<Record<PricingPeriod, string>>;
2482
+ /** The company's trial, for the current card's badge. */
2483
+ trialDaysLeft: {
2484
+ count: number;
2485
+ days: string;
2486
+ } | null;
2487
+ /** The add-ons the company holds, shown or not; empty in the public catalog. */
2488
+ heldAddOnIds: string[];
2489
+ }
2490
+
2491
+ export declare interface PricingViolation {
2492
+ featureName: string;
2493
+ usage: string;
2494
+ limit: string | null;
2495
+ }
2496
+
2086
2497
  /** The words a problem is shown in: the host's, else the server's. */
2087
2498
  declare type ProblemFormatter = (problem: CheckoutProblem) => string | undefined;
2088
2499
 
@@ -2100,6 +2511,10 @@ export declare interface ProrationLine {
2100
2511
  amountText: string;
2101
2512
  }
2102
2513
 
2514
+ export { PublicCatalog }
2515
+
2516
+ export { PublicCatalogPlan }
2517
+
2103
2518
  export declare interface QuantityRow {
2104
2519
  featureId: string;
2105
2520
  /** The feature's name for the quantity chosen. */