@zuplo/zudoku-plugin-monetization 0.0.35 → 0.0.36-pre.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.
- 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 +42 -22
- package/LICENSE.md +0 -18
|
@@ -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,46 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/zudoku-plugin-monetization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36-pre.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
7
7
|
"directory": "packages/plugin-zuplo-monetization"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
|
-
"main": "./
|
|
11
|
-
"types": "./
|
|
10
|
+
"main": "./src/index.ts",
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
|
|
15
|
-
"types": "./dist/index.d.mts"
|
|
16
|
-
}
|
|
13
|
+
".": "./src/index.ts",
|
|
14
|
+
"./pricing-ui": "./src/pricing-ui/index.ts"
|
|
17
15
|
},
|
|
18
16
|
"files": [
|
|
19
17
|
"dist"
|
|
20
18
|
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsdown",
|
|
21
|
+
"dev": "tsdown --watch",
|
|
22
|
+
"prepublishOnly": "pnpm typecheck && pnpm build",
|
|
23
|
+
"typecheck": "tsc --project tsconfig.json"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"main": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.mts",
|
|
31
|
+
"import": "./dist/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./pricing-ui": {
|
|
34
|
+
"types": "./dist/pricing-ui.d.mts",
|
|
35
|
+
"import": "./dist/pricing-ui.mjs"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
21
39
|
"dependencies": {
|
|
40
|
+
"clsx": "2.1.1",
|
|
41
|
+
"tailwind-merge": "3.5.0",
|
|
22
42
|
"tinyduration": "3.4.1"
|
|
23
43
|
},
|
|
24
44
|
"devDependencies": {
|
|
25
|
-
"@testing-library/dom": "
|
|
26
|
-
"@testing-library/jest-dom": "
|
|
27
|
-
"@testing-library/react": "
|
|
28
|
-
"@types/react": "
|
|
29
|
-
"@types/react-dom": "
|
|
30
|
-
"happy-dom": "
|
|
31
|
-
"react": "
|
|
32
|
-
"react-dom": "
|
|
33
|
-
"tsdown": "
|
|
34
|
-
"zudoku": "
|
|
45
|
+
"@testing-library/dom": "catalog:",
|
|
46
|
+
"@testing-library/jest-dom": "catalog:",
|
|
47
|
+
"@testing-library/react": "catalog:",
|
|
48
|
+
"@types/react": "catalog:",
|
|
49
|
+
"@types/react-dom": "catalog:",
|
|
50
|
+
"happy-dom": "catalog:",
|
|
51
|
+
"react": "catalog:",
|
|
52
|
+
"react-dom": "catalog:",
|
|
53
|
+
"tsdown": "catalog:",
|
|
54
|
+
"zudoku": "workspace:*"
|
|
35
55
|
},
|
|
36
56
|
"peerDependencies": {
|
|
37
57
|
"react": ">=19.2.0",
|
|
38
58
|
"react-dom": ">=19.2.0",
|
|
39
59
|
"zudoku": "*"
|
|
40
60
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"zudoku": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
45
65
|
}
|
|
46
|
-
}
|
|
66
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) Zuplo, Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
-
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
7
|
-
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
8
|
-
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
-
portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
15
|
-
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
16
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
17
|
-
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|