@schematichq/schematic-components 2.31.1 → 2.32.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.
@@ -118,6 +118,16 @@ export declare interface DeriveInvoiceListOptions {
118
118
  format?: InvoiceFormatters;
119
119
  }
120
120
 
121
+ export declare function deriveMeteredFeatures(features: FeatureUsage[], options: DeriveMeteredFeaturesOptions): MeteredFeatureRow[];
122
+
123
+ export declare interface DeriveMeteredFeaturesOptions extends UsageLimitOptions {
124
+ locale: string;
125
+ /** Feature ids to show, in this order; every metered feature when absent. */
126
+ visibleFeatures?: string[];
127
+ /** The "credits per use" line on credit-burning features. Default true. */
128
+ showCredits?: boolean;
129
+ }
130
+
121
131
  /**
122
132
  * The default is whichever row the server marked, which already prefers the
123
133
  * subscription's method over the customer's. Nothing is promoted: a list
@@ -257,6 +267,27 @@ export declare type ElementStrings = {
257
267
  includedFeaturesHideAll: string;
258
268
  includedFeaturesExpires: string;
259
269
  includedFeaturesPerLicense: string;
270
+ meteredFeaturesLoading: string;
271
+ meteredFeaturesHeader: string;
272
+ meteredFeaturesError: string;
273
+ meteredFeaturesUnavailable: string;
274
+ meteredFeaturesUsed: string;
275
+ meteredFeaturesIncluded: string;
276
+ meteredFeaturesInUse: string;
277
+ meteredFeaturesLimitOf: string;
278
+ meteredFeaturesNoLimit: string;
279
+ meteredFeaturesAddMore: string;
280
+ meteredFeaturesAdditional: string;
281
+ meteredFeaturesTier: string;
282
+ usageByUserHeader: string;
283
+ usageByUserTotal: string;
284
+ usageByUserError: string;
285
+ usageByUserUnattributed: string;
286
+ usageByUserMore: string;
287
+ usageByUserShowTop: string;
288
+ usageByUserShowAllCount: string;
289
+ usageByUserShowAll: string;
290
+ usageByUserShowFewer: string;
260
291
  usageUnits: string;
261
292
  usagePerUnit: string;
262
293
  usagePerPackage: string;
@@ -583,8 +614,189 @@ export declare function isTieredPrice(price: MeteredPrice | undefined): boolean;
583
614
  */
584
615
  export declare function lookup(catalog: StringCatalog | undefined, key: string, vars?: StringVars, locale?: string): string | undefined;
585
616
 
617
+ export declare interface MeteredFeatureRow {
618
+ featureId: string;
619
+ name: string;
620
+ description: string | null;
621
+ /** A schematic-icons glyph name; `null` when the feature has none. */
622
+ icon: string | null;
623
+ headline: MeteredHeadline | null;
624
+ limit: MeteredLimit | null;
625
+ /** "Resets Oct 1". */
626
+ resetsAt: string | null;
627
+ hardLimit: {
628
+ amount: number;
629
+ units: string;
630
+ } | null;
631
+ meter: MeteredMeter | null;
632
+ priceDetails: MeteredPriceDetails | null;
633
+ /** Paid in advance, so more can be bought. */
634
+ canAddMore: boolean;
635
+ /** Event-based, so its usage breaks down by user. */
636
+ hasUsageByUser: boolean;
637
+ /** The feature's names, for a host labelling amounts itself. */
638
+ unit: {
639
+ name: string;
640
+ singularName?: string;
641
+ pluralName?: string;
642
+ };
643
+ source: FeatureUsage;
644
+ }
645
+
646
+ /**
647
+ * A card per event- or trait-based feature: usage against its limit, what it
648
+ * costs, and who on the team used it.
649
+ *
650
+ * A company with no metered features renders nothing. A 404 means the
651
+ * account is not enabled for company reads, and the element says so.
652
+ */
653
+ export declare function MeteredFeatures({ addMoreTarget, addMoreUrl, className, headingLevel, locale: localeProp, onAddMore, showAllocation, showCredits, showDescription, showHardLimit, showHeader, showIcon, showMeter, showUsage, showUsageByUser, showWarningThresholdAsLimit, strings, visibleFeatures, }: MeteredFeaturesProps): JSX.Element | null;
654
+
655
+ export declare namespace MeteredFeatures {
656
+ var resources: readonly ["featureUsage"];
657
+ }
658
+
659
+ export declare interface MeteredFeaturesProps extends ElementProps {
660
+ /** The "Usage" heading above the cards. Default false, as in the embed. */
661
+ showHeader?: boolean;
662
+ /**
663
+ * Heading level. Feature names sit one level below it, or take it when the
664
+ * heading is hidden. Default 2.
665
+ */
666
+ headingLevel?: HeadingLevel;
667
+ /** Each feature's icon. Default true. */
668
+ showIcon?: boolean;
669
+ /** Each feature's description. Default true. */
670
+ showDescription?: boolean;
671
+ /** The headline: what is used, or the quantity paid for. Default true. */
672
+ showUsage?: boolean;
673
+ /** The limit line beneath it, and when usage resets. Default true. */
674
+ showAllocation?: boolean;
675
+ /** The usage meter. Default true. */
676
+ showMeter?: boolean;
677
+ /** The breakdown of usage by user, for event-based features. Default true. */
678
+ showUsageByUser?: boolean;
679
+ /** Feature ids to show, in this order; every metered feature when absent. */
680
+ visibleFeatures?: string[];
681
+ /** The "credits per use" line on credit-burning features. Default true. */
682
+ showCredits?: boolean;
683
+ /** An info tip with the hard limit on features billed past it. Default false. */
684
+ showHardLimit?: boolean;
685
+ /**
686
+ * Show an entitlement's warning threshold in place of its limit, where one
687
+ * is configured. Default false.
688
+ */
689
+ showWarningThresholdAsLimit?: boolean;
690
+ /**
691
+ * Called by "Add More" on a feature paid for in advance. With neither this
692
+ * nor `addMoreUrl`, there is no button.
693
+ */
694
+ onAddMore?: (feature: FeatureUsage) => void;
695
+ /** "Add More" links here when there is no `onAddMore`. */
696
+ addMoreUrl?: string;
697
+ /** `target` for `addMoreUrl`. */
698
+ addMoreTarget?: string;
699
+ }
700
+
701
+ /**
702
+ * `deriveMeteredFeatures`: each event- or trait-based feature as its card
703
+ * shows it. The wording is the element's, keyed by `kind`; numbers, names and
704
+ * dates are formatted here.
705
+ */
706
+ /** What is used, or, for a feature paid in advance, what was bought. */
707
+ export declare type MeteredHeadline =
708
+ /** "12 Seats" — a quantity paid for in advance. */
709
+ {
710
+ kind: "quantity";
711
+ amount: string | null;
712
+ units: string;
713
+ }
714
+ /** "1,300 API calls" + "used". */
715
+ | {
716
+ kind: "used";
717
+ amount: string;
718
+ units: string;
719
+ };
720
+
721
+ /** The line under the headline, before "Resets …". */
722
+ export declare type MeteredLimit = {
723
+ kind: "tierUpTo";
724
+ amount: string;
725
+ feature: string;
726
+ } | {
727
+ kind: "tierUnlimited";
728
+ feature: string;
729
+ }
730
+ /** "1,000 included" — an overage's soft limit. */
731
+ | {
732
+ kind: "included";
733
+ amount: string;
734
+ }
735
+ /** "9 used" — how much of a quantity paid for in advance is in use. */
736
+ | {
737
+ kind: "used";
738
+ amount: string;
739
+ }
740
+ /** What pay-as-you-go usage has cost. */
741
+ | {
742
+ kind: "cost";
743
+ cost: string;
744
+ } | {
745
+ kind: "perUse";
746
+ amount: string;
747
+ units: string;
748
+ } | {
749
+ kind: "limitOf";
750
+ amount: string;
751
+ } | {
752
+ kind: "noLimit";
753
+ };
754
+
755
+ export declare interface MeteredMeter {
756
+ value: number;
757
+ total: number;
758
+ /** 0–100. Past an overage's soft limit, the included share of all usage. */
759
+ percent: number;
760
+ tone: MeterTone;
761
+ /** Up to ten fraction digits, as is `totalText`. */
762
+ valueText: string;
763
+ totalText: string;
764
+ }
765
+
586
766
  export { MeteredPrice }
587
767
 
768
+ export declare type MeteredPriceDetails = {
769
+ kind: "overage";
770
+ /** The per-unit price past the soft limit. */
771
+ unitPrice: string;
772
+ packageSize: number;
773
+ units: string;
774
+ /** A period key, for a trait billed per period. */
775
+ period: string | null;
776
+ /** Usage past the soft limit, and what it costs. */
777
+ overage: {
778
+ amount: string;
779
+ units: string;
780
+ cost: string;
781
+ };
782
+ } | {
783
+ kind: "tier";
784
+ from: number;
785
+ /** `null` for the last, unbounded tier. */
786
+ to: number | null;
787
+ /** What the usage costs across the tiers; `null` when nothing does. */
788
+ cost: string | null;
789
+ period: string | null;
790
+ tiers: {
791
+ ranges: TierRange[];
792
+ currency: string;
793
+ mode: "graduated" | "volume" | null;
794
+ };
795
+ };
796
+
797
+ /** The fill's colour: by price for tiers and overages, else by share used. */
798
+ export declare type MeterTone = "tier" | "overage" | "ok" | "warning" | "critical";
799
+
588
800
  export { PaymentMethod }
589
801
 
590
802
  /**