@zuplo/zudoku-plugin-monetization 0.0.35 → 0.0.36-pre.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.
- package/dist/PricingTable-DfYAmAjk.mjs +443 -0
- package/dist/index.mjs +44 -433
- package/dist/pricing-ui.d.mts +296 -0
- package/dist/pricing-ui.mjs +2 -0
- package/package.json +14 -3
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/types/PlanType.d.ts
|
|
5
|
+
type EntitlementTemplate = MeteredEntitlementTemplate | StaticEntitlementTemplate | BooleanEntitlementTemplate;
|
|
6
|
+
interface MeteredEntitlementTemplate {
|
|
7
|
+
type: "metered";
|
|
8
|
+
isSoftLimit?: boolean;
|
|
9
|
+
issueAfterReset?: number;
|
|
10
|
+
issueAfterResetPriority?: number;
|
|
11
|
+
preserveOverageAtReset?: boolean;
|
|
12
|
+
usagePeriod?: string;
|
|
13
|
+
}
|
|
14
|
+
interface StaticEntitlementTemplate {
|
|
15
|
+
type: "static";
|
|
16
|
+
config: string;
|
|
17
|
+
}
|
|
18
|
+
interface BooleanEntitlementTemplate {
|
|
19
|
+
type: "boolean";
|
|
20
|
+
}
|
|
21
|
+
interface PriceTier {
|
|
22
|
+
flatPrice?: {
|
|
23
|
+
amount: string;
|
|
24
|
+
};
|
|
25
|
+
unitPrice?: {
|
|
26
|
+
amount: string;
|
|
27
|
+
};
|
|
28
|
+
upToAmount?: string;
|
|
29
|
+
}
|
|
30
|
+
type Price = FlatPrice | UnitPrice | TieredPrice | DynamicPrice | PackagePrice;
|
|
31
|
+
interface FlatPrice {
|
|
32
|
+
type: "flat";
|
|
33
|
+
amount: string;
|
|
34
|
+
paymentTerm?: "in_advance" | "in_arrears";
|
|
35
|
+
}
|
|
36
|
+
interface UnitPrice {
|
|
37
|
+
type: "unit";
|
|
38
|
+
amount: string;
|
|
39
|
+
}
|
|
40
|
+
interface TieredPrice {
|
|
41
|
+
type: "tiered";
|
|
42
|
+
mode: "volume" | "graduated";
|
|
43
|
+
tiers: PriceTier[];
|
|
44
|
+
}
|
|
45
|
+
interface DynamicPrice {
|
|
46
|
+
type: "dynamic";
|
|
47
|
+
multiplier?: string;
|
|
48
|
+
}
|
|
49
|
+
interface PackagePrice {
|
|
50
|
+
type: "package";
|
|
51
|
+
amount: string;
|
|
52
|
+
quantityPerPackage: string;
|
|
53
|
+
minimumAmount?: string;
|
|
54
|
+
maximumAmount?: string;
|
|
55
|
+
}
|
|
56
|
+
type RateCard = FlatFeeRateCard | UsageBasedRateCard;
|
|
57
|
+
interface RateCardBase {
|
|
58
|
+
key: string;
|
|
59
|
+
name: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
metadata?: Record<string, unknown> | null;
|
|
62
|
+
featureKey?: string;
|
|
63
|
+
entitlementTemplate?: EntitlementTemplate;
|
|
64
|
+
}
|
|
65
|
+
interface UsageBasedRateCard extends RateCardBase {
|
|
66
|
+
type: "usage_based";
|
|
67
|
+
billingCadence: string;
|
|
68
|
+
price: Price | null;
|
|
69
|
+
}
|
|
70
|
+
interface FlatFeeRateCard extends RateCardBase {
|
|
71
|
+
type: "flat_fee";
|
|
72
|
+
billingCadence: string | null;
|
|
73
|
+
price: FlatPrice | null;
|
|
74
|
+
}
|
|
75
|
+
interface PlanPhase {
|
|
76
|
+
key: string;
|
|
77
|
+
name: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
duration?: string | null;
|
|
81
|
+
rateCards: RateCard[];
|
|
82
|
+
}
|
|
83
|
+
interface Quota {
|
|
84
|
+
key: string;
|
|
85
|
+
name: string;
|
|
86
|
+
limit: number;
|
|
87
|
+
period: string;
|
|
88
|
+
overagePrice?: string;
|
|
89
|
+
tierPrices?: string[];
|
|
90
|
+
}
|
|
91
|
+
interface Feature {
|
|
92
|
+
key: string;
|
|
93
|
+
name: string;
|
|
94
|
+
value?: string;
|
|
95
|
+
}
|
|
96
|
+
interface Alignment {
|
|
97
|
+
billablesMustAlign?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface ProRatingConfig {
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
mode: "prorate_prices" | "prorate_quantities";
|
|
102
|
+
}
|
|
103
|
+
interface ValidationError {
|
|
104
|
+
message: string;
|
|
105
|
+
path?: string;
|
|
106
|
+
code?: string;
|
|
107
|
+
}
|
|
108
|
+
interface PlanDefaultTaxConfig {
|
|
109
|
+
/** When set (e.g. Stripe-style `exclusive` / `inclusive`), pricing may include or exclude tax. */
|
|
110
|
+
behavior?: string;
|
|
111
|
+
}
|
|
112
|
+
interface Plan {
|
|
113
|
+
id: string;
|
|
114
|
+
key: string;
|
|
115
|
+
name: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
paymentRequired?: boolean;
|
|
118
|
+
metadata?: Record<string, unknown>;
|
|
119
|
+
version?: number;
|
|
120
|
+
currency?: string;
|
|
121
|
+
billingCadence: string;
|
|
122
|
+
defaultTaxConfig?: PlanDefaultTaxConfig;
|
|
123
|
+
status?: "draft" | "active" | "archived" | "scheduled";
|
|
124
|
+
effectiveFrom?: string;
|
|
125
|
+
effectiveTo?: string;
|
|
126
|
+
alignment?: Alignment;
|
|
127
|
+
proRatingConfig?: ProRatingConfig;
|
|
128
|
+
validationErrors?: ValidationError[] | null;
|
|
129
|
+
createdAt?: string;
|
|
130
|
+
updatedAt?: string;
|
|
131
|
+
deletedAt?: string;
|
|
132
|
+
phases: PlanPhase[];
|
|
133
|
+
monthlyPrice: string | null;
|
|
134
|
+
yearlyPrice: string | null;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/pricing-ui/FeatureItem.d.ts
|
|
138
|
+
declare const FeatureItem: ({
|
|
139
|
+
feature,
|
|
140
|
+
className
|
|
141
|
+
}: {
|
|
142
|
+
feature: Feature;
|
|
143
|
+
className?: string;
|
|
144
|
+
}) => _$react_jsx_runtime0.JSX.Element;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/pricing-ui/PlanEntitlements.d.ts
|
|
147
|
+
declare const PlanEntitlements: ({
|
|
148
|
+
phases,
|
|
149
|
+
currency,
|
|
150
|
+
billingCadence,
|
|
151
|
+
units,
|
|
152
|
+
itemClassName
|
|
153
|
+
}: {
|
|
154
|
+
phases: PlanPhase[];
|
|
155
|
+
currency?: string;
|
|
156
|
+
billingCadence?: string;
|
|
157
|
+
units?: Record<string, string>;
|
|
158
|
+
itemClassName?: string;
|
|
159
|
+
}) => _$react_jsx_runtime0.JSX.Element;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/pricing-ui/PricingCard.d.ts
|
|
162
|
+
type PricingCardProps = {
|
|
163
|
+
plan: Plan;
|
|
164
|
+
isPopular?: boolean;
|
|
165
|
+
showYearlyPrice?: boolean;
|
|
166
|
+
units?: Record<string, string>; /** CTA element rendered at the bottom of the card (e.g. a Subscribe button). */
|
|
167
|
+
action?: ReactNode;
|
|
168
|
+
className?: string;
|
|
169
|
+
};
|
|
170
|
+
declare const PricingCard: ({
|
|
171
|
+
plan,
|
|
172
|
+
isPopular,
|
|
173
|
+
showYearlyPrice,
|
|
174
|
+
units,
|
|
175
|
+
action,
|
|
176
|
+
className
|
|
177
|
+
}: PricingCardProps) => _$react_jsx_runtime0.JSX.Element | null;
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/pricing-ui/PricingTable.d.ts
|
|
180
|
+
type PricingTableProps = {
|
|
181
|
+
plans: Plan[];
|
|
182
|
+
showYearlyPrice?: boolean;
|
|
183
|
+
units?: Record<string, string>;
|
|
184
|
+
/**
|
|
185
|
+
* Render the CTA (e.g. Subscribe / Contact Sales button) for each plan.
|
|
186
|
+
* Receives the plan and whether it is the popular plan.
|
|
187
|
+
*/
|
|
188
|
+
renderAction?: (plan: Plan, isPopular: boolean) => ReactNode;
|
|
189
|
+
/**
|
|
190
|
+
* Override or wrap the rendering of each card. Receives the plan and a
|
|
191
|
+
* context with the `isPopular` flag and the default `<PricingCard>`
|
|
192
|
+
* element. Return `defaultCard` to keep behavior, wrap it (e.g. with a
|
|
193
|
+
* drag handle, kebab menu, or overlay), or return something entirely
|
|
194
|
+
* different to render a custom card for that plan.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* renderCard={(plan, { defaultCard }) => (
|
|
198
|
+
* <div className="relative">
|
|
199
|
+
* <DragHandle planId={plan.id} />
|
|
200
|
+
* {defaultCard}
|
|
201
|
+
* </div>
|
|
202
|
+
* )}
|
|
203
|
+
*/
|
|
204
|
+
renderCard?: (plan: Plan, ctx: {
|
|
205
|
+
isPopular: boolean;
|
|
206
|
+
defaultCard: ReactNode;
|
|
207
|
+
}) => ReactNode;
|
|
208
|
+
/**
|
|
209
|
+
* Predicate that decides which plan gets the "Most Popular" badge.
|
|
210
|
+
* Defaults to `plan.metadata.zuplo_most_popular === "true"`.
|
|
211
|
+
*/
|
|
212
|
+
isPopular?: (plan: Plan) => boolean; /** Render override for the empty (no plans) state. */
|
|
213
|
+
emptyState?: ReactNode; /** Show the tax legend underneath the grid when the first plan has a defaultTaxConfig.behavior. Defaults to true. */
|
|
214
|
+
showTaxLegend?: boolean;
|
|
215
|
+
className?: string;
|
|
216
|
+
cardClassName?: string;
|
|
217
|
+
};
|
|
218
|
+
declare const PricingTable: ({
|
|
219
|
+
plans,
|
|
220
|
+
showYearlyPrice,
|
|
221
|
+
units,
|
|
222
|
+
renderAction,
|
|
223
|
+
renderCard,
|
|
224
|
+
isPopular,
|
|
225
|
+
emptyState,
|
|
226
|
+
showTaxLegend,
|
|
227
|
+
className,
|
|
228
|
+
cardClassName
|
|
229
|
+
}: PricingTableProps) => _$react_jsx_runtime0.JSX.Element;
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/pricing-ui/QuotaItem.d.ts
|
|
232
|
+
declare const QuotaItem: ({
|
|
233
|
+
quota,
|
|
234
|
+
className
|
|
235
|
+
}: {
|
|
236
|
+
quota: Quota;
|
|
237
|
+
className?: string;
|
|
238
|
+
}) => _$react_jsx_runtime0.JSX.Element;
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/utils/categorizeRateCards.d.ts
|
|
241
|
+
declare const categorizeRateCards: (rateCards: RateCard[], options?: {
|
|
242
|
+
currency?: string;
|
|
243
|
+
units?: Record<string, string>;
|
|
244
|
+
planBillingCadence?: string | null;
|
|
245
|
+
}) => {
|
|
246
|
+
quotas: Quota[];
|
|
247
|
+
features: Feature[];
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/utils/formatDuration.d.ts
|
|
251
|
+
declare const formatDuration: (iso: string) => string;
|
|
252
|
+
declare const formatDurationInterval: (iso: string) => string;
|
|
253
|
+
/**
|
|
254
|
+
* Returns an adjective form suitable for possessive context
|
|
255
|
+
* e.g. "your monthly quota", "your weekly limit".
|
|
256
|
+
* Falls back to "billing period" for multi-unit cadences
|
|
257
|
+
* where "every 3 months" would be grammatically awkward.
|
|
258
|
+
*/
|
|
259
|
+
declare const formatDurationAdjective: (iso: string) => string;
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/utils/formatPrice.d.ts
|
|
262
|
+
declare const formatPrice: (amount: number, currency?: string) => string;
|
|
263
|
+
/** Amount is in the smallest currency unit (e.g. Stripe); divisor from `Intl` / ISO 4217. */
|
|
264
|
+
declare const formatMinorCurrencyAmount: (amountInMinorUnits: number, currency?: string) => string;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/utils/formatStaticEntitlementConfig.d.ts
|
|
267
|
+
declare const formatStaticEntitlementConfig: (config: string | undefined) => string | undefined;
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/utils/formatTieredPriceBreakdown.d.ts
|
|
270
|
+
type TieredPriceBreakdownTier = {
|
|
271
|
+
upToAmount?: string;
|
|
272
|
+
unitPriceAmount?: string;
|
|
273
|
+
flatPriceAmount?: string;
|
|
274
|
+
};
|
|
275
|
+
declare const formatTieredPriceBreakdown: (opts: {
|
|
276
|
+
tiers: TieredPriceBreakdownTier[];
|
|
277
|
+
currency?: string;
|
|
278
|
+
unitLabel: string;
|
|
279
|
+
includedLabel: string;
|
|
280
|
+
omitIncludedUpToAmount?: number;
|
|
281
|
+
}) => string[] | undefined;
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/utils/getPriceFromPlan.d.ts
|
|
284
|
+
declare const getPriceFromPlan: (plan: Plan) => {
|
|
285
|
+
monthly: number;
|
|
286
|
+
yearly: number;
|
|
287
|
+
};
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/utils/pricingTaxLegend.d.ts
|
|
290
|
+
type CanonicalTaxBehavior = "exclusive" | "inclusive" | "unspecified";
|
|
291
|
+
declare const planHasDefaultTaxBehavior: (plan: Plan) => boolean;
|
|
292
|
+
declare const collectDefaultTaxBehaviors: (plan: Plan) => CanonicalTaxBehavior;
|
|
293
|
+
declare const taxBehaviorLegendSentence: (behavior: string) => string | undefined;
|
|
294
|
+
declare const subscriptionTaxLegendSentence: (behavior: string) => string | undefined;
|
|
295
|
+
//#endregion
|
|
296
|
+
export { type Alignment, type BooleanEntitlementTemplate, type DynamicPrice, type EntitlementTemplate, type Feature, FeatureItem, type FlatFeeRateCard, type FlatPrice, type MeteredEntitlementTemplate, type PackagePrice, type Plan, type PlanDefaultTaxConfig, PlanEntitlements, type PlanPhase, type Price, type PriceTier, PricingCard, type PricingCardProps, PricingTable, type PricingTableProps, type ProRatingConfig, type Quota, QuotaItem, type RateCard, type StaticEntitlementTemplate, type TieredPrice, type TieredPriceBreakdownTier, type UnitPrice, type UsageBasedRateCard, type ValidationError, categorizeRateCards, collectDefaultTaxBehaviors, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPriceFromPlan, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as formatDurationAdjective, a as subscriptionTaxLegendSentence, c as PlanEntitlements, d as categorizeRateCards, f as formatTieredPriceBreakdown, g as formatDuration, h as formatPrice, i as planHasDefaultTaxBehavior, l as QuotaItem, m as formatMinorCurrencyAmount, n as PricingCard, o as taxBehaviorLegendSentence, p as formatStaticEntitlementConfig, r as collectDefaultTaxBehaviors, s as getPriceFromPlan, t as PricingTable, u as FeatureItem, v as formatDurationInterval } from "./PricingTable-DfYAmAjk.mjs";
|
|
2
|
+
export { FeatureItem, PlanEntitlements, PricingCard, PricingTable, QuotaItem, categorizeRateCards, collectDefaultTaxBehaviors, formatDuration, formatDurationAdjective, formatDurationInterval, formatMinorCurrencyAmount, formatPrice, formatStaticEntitlementConfig, formatTieredPriceBreakdown, getPriceFromPlan, planHasDefaultTaxBehavior, subscriptionTaxLegendSentence, taxBehaviorLegendSentence };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/zudoku-plugin-monetization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36-pre.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -11,14 +11,20 @@
|
|
|
11
11
|
"types": "./dist/index.d.mts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
15
|
+
"import": "./dist/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./pricing-ui": {
|
|
18
|
+
"types": "./dist/pricing-ui.d.mts",
|
|
19
|
+
"import": "./dist/pricing-ui.mjs"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
19
23
|
"dist"
|
|
20
24
|
],
|
|
21
25
|
"dependencies": {
|
|
26
|
+
"clsx": "2.1.1",
|
|
27
|
+
"tailwind-merge": "3.5.0",
|
|
22
28
|
"tinyduration": "3.4.1"
|
|
23
29
|
},
|
|
24
30
|
"devDependencies": {
|
|
@@ -38,6 +44,11 @@
|
|
|
38
44
|
"react-dom": ">=19.2.0",
|
|
39
45
|
"zudoku": "*"
|
|
40
46
|
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"zudoku": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
41
52
|
"scripts": {
|
|
42
53
|
"build": "tsdown",
|
|
43
54
|
"dev": "tsdown --watch",
|