@growflowstudio/billing-admin-ui 1.0.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/LICENSE +21 -0
- package/dist/index.d.mts +329 -0
- package/dist/index.d.ts +329 -0
- package/dist/index.js +2152 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2139 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present GrowFlow Studio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import { Fetcher, AdminPlan, AdminPlanPricingModel, RecurringInterval, AdminProduct, AdminInvoice } from '@growflowstudio/billing-admin-core';
|
|
4
|
+
|
|
5
|
+
interface LimitFieldConfig {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
defaultValue?: number;
|
|
9
|
+
}
|
|
10
|
+
interface FeaturesConfig {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
fetchFn?: () => Promise<{
|
|
13
|
+
features: Array<{
|
|
14
|
+
slug: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
interface PublicPlansConfig {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
fetchFn?: () => Promise<{
|
|
23
|
+
public_plan_slugs: string[];
|
|
24
|
+
}>;
|
|
25
|
+
updateFn?: (slugs: string[]) => Promise<{
|
|
26
|
+
public_plan_slugs: string[];
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configure which billing modules are enabled for this project.
|
|
31
|
+
* By default, all modules are enabled.
|
|
32
|
+
*
|
|
33
|
+
* Examples:
|
|
34
|
+
* - Booking/WineTracking: { plans: true, subscriptions: true, products: false, features: false }
|
|
35
|
+
* - SweatMate: { plans: true, subscriptions: true, products: true, features: true }
|
|
36
|
+
* - ShopBrain: all enabled (default)
|
|
37
|
+
*/
|
|
38
|
+
interface BillingModulesConfig {
|
|
39
|
+
plans?: boolean;
|
|
40
|
+
subscriptions?: boolean;
|
|
41
|
+
products?: boolean;
|
|
42
|
+
payments?: boolean;
|
|
43
|
+
invoices?: boolean;
|
|
44
|
+
features?: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface BillingAdminConfig {
|
|
47
|
+
/** Base path for billing admin API (e.g., '/api/v1/billing-admin') */
|
|
48
|
+
basePath: string;
|
|
49
|
+
/** HTTP fetcher function from the host application (handles auth) */
|
|
50
|
+
fetcher: Fetcher;
|
|
51
|
+
/** Locale for number/date formatting (default: 'it-IT') */
|
|
52
|
+
locale?: string;
|
|
53
|
+
/** Default currency (default: 'EUR') */
|
|
54
|
+
currency?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Enable/disable billing modules per project.
|
|
57
|
+
* All modules are enabled by default.
|
|
58
|
+
*/
|
|
59
|
+
modules?: BillingModulesConfig;
|
|
60
|
+
/** Plan-specific configurations */
|
|
61
|
+
plans?: {
|
|
62
|
+
/** Configurable limit fields for plan forms */
|
|
63
|
+
limitFields?: LimitFieldConfig[];
|
|
64
|
+
/** Feature selection in plan forms */
|
|
65
|
+
features?: FeaturesConfig;
|
|
66
|
+
/** Public plans toggle (ShopBrain-specific) */
|
|
67
|
+
publicPlans?: PublicPlansConfig;
|
|
68
|
+
};
|
|
69
|
+
/** Product-specific configurations */
|
|
70
|
+
products?: {
|
|
71
|
+
/** Feature linking in product forms */
|
|
72
|
+
features?: FeaturesConfig;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
declare function useBillingAdminConfig(): BillingAdminConfig;
|
|
76
|
+
/** Returns the resolved modules config (with defaults applied) */
|
|
77
|
+
declare function useEnabledModules(): Required<BillingModulesConfig>;
|
|
78
|
+
interface BillingAdminProviderProps {
|
|
79
|
+
config: BillingAdminConfig;
|
|
80
|
+
children: React$1.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
declare function BillingAdminProvider({ config, children }: BillingAdminProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
interface PlansPageProps {
|
|
85
|
+
/** Optional wrapper component for the page content */
|
|
86
|
+
wrapper?: React.ComponentType<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
}>;
|
|
89
|
+
/** Optional header component */
|
|
90
|
+
header?: React.ReactNode;
|
|
91
|
+
}
|
|
92
|
+
declare function PlansPage({ wrapper: Wrapper, header }: PlansPageProps): react_jsx_runtime.JSX.Element;
|
|
93
|
+
|
|
94
|
+
interface ProductsPageProps {
|
|
95
|
+
wrapper?: React.ComponentType<{
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
}>;
|
|
98
|
+
header?: React.ReactNode;
|
|
99
|
+
}
|
|
100
|
+
declare function ProductsPage({ wrapper: Wrapper, header }: ProductsPageProps): react_jsx_runtime.JSX.Element;
|
|
101
|
+
|
|
102
|
+
interface SubscriptionsPageProps {
|
|
103
|
+
wrapper?: React.ComponentType<{
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}>;
|
|
106
|
+
header?: React.ReactNode;
|
|
107
|
+
}
|
|
108
|
+
declare function SubscriptionsPage({ wrapper: Wrapper, header }: SubscriptionsPageProps): react_jsx_runtime.JSX.Element;
|
|
109
|
+
|
|
110
|
+
interface PaymentsPageProps {
|
|
111
|
+
wrapper?: React.ComponentType<{
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
}>;
|
|
114
|
+
header?: React.ReactNode;
|
|
115
|
+
}
|
|
116
|
+
declare function PaymentsPage({ wrapper: Wrapper, header }: PaymentsPageProps): react_jsx_runtime.JSX.Element;
|
|
117
|
+
|
|
118
|
+
interface InvoicesPageProps {
|
|
119
|
+
wrapper?: React.ComponentType<{
|
|
120
|
+
children: React.ReactNode;
|
|
121
|
+
}>;
|
|
122
|
+
header?: React.ReactNode;
|
|
123
|
+
}
|
|
124
|
+
declare function InvoicesPage({ wrapper: Wrapper, header }: InvoicesPageProps): react_jsx_runtime.JSX.Element;
|
|
125
|
+
|
|
126
|
+
interface FeaturesPageProps {
|
|
127
|
+
wrapper?: React.ComponentType<{
|
|
128
|
+
children: React.ReactNode;
|
|
129
|
+
}>;
|
|
130
|
+
header?: React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
declare function FeaturesPage({ wrapper: Wrapper, header }: FeaturesPageProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
interface PlansTableProps {
|
|
135
|
+
plans: AdminPlan[];
|
|
136
|
+
isLoading: boolean;
|
|
137
|
+
onEdit: (plan: AdminPlan) => void;
|
|
138
|
+
onDelete: (plan: AdminPlan) => void;
|
|
139
|
+
onSync: (planId: string) => void;
|
|
140
|
+
isSyncing: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare function PlansTable({ plans, isLoading, onEdit, onDelete, onSync, isSyncing, }: PlansTableProps): react_jsx_runtime.JSX.Element;
|
|
143
|
+
|
|
144
|
+
interface PlanFormData {
|
|
145
|
+
slug: string;
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
pricing_model: AdminPlanPricingModel;
|
|
149
|
+
price_monthly: string;
|
|
150
|
+
price_yearly: string;
|
|
151
|
+
currency: string;
|
|
152
|
+
trial_days: number;
|
|
153
|
+
is_active: boolean;
|
|
154
|
+
contact_sales: boolean;
|
|
155
|
+
is_public: boolean;
|
|
156
|
+
color: string;
|
|
157
|
+
limits: Record<string, number>;
|
|
158
|
+
limits_unlimited: Record<string, boolean>;
|
|
159
|
+
features: string;
|
|
160
|
+
sort_order: number;
|
|
161
|
+
}
|
|
162
|
+
declare function createDefaultPlanFormData(limitFields?: LimitFieldConfig[]): PlanFormData;
|
|
163
|
+
interface PlanFormDialogProps {
|
|
164
|
+
open: boolean;
|
|
165
|
+
onOpenChange: (open: boolean) => void;
|
|
166
|
+
formData: PlanFormData;
|
|
167
|
+
onFormDataChange: (data: Partial<PlanFormData>) => void;
|
|
168
|
+
formErrors: Record<string, string>;
|
|
169
|
+
selectedPlan: AdminPlan | null;
|
|
170
|
+
onSubmit: () => void;
|
|
171
|
+
isPending: boolean;
|
|
172
|
+
}
|
|
173
|
+
declare function PlanFormDialog({ open, onOpenChange, formData, onFormDataChange, formErrors, selectedPlan, onSubmit, isPending, }: PlanFormDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
174
|
+
|
|
175
|
+
interface LimitInputProps {
|
|
176
|
+
id: string;
|
|
177
|
+
label: string;
|
|
178
|
+
value: number;
|
|
179
|
+
isUnlimited: boolean;
|
|
180
|
+
onValueChange: (value: number) => void;
|
|
181
|
+
onUnlimitedChange: (unlimited: boolean) => void;
|
|
182
|
+
min?: number;
|
|
183
|
+
}
|
|
184
|
+
declare function LimitInput({ id, label, value, isUnlimited, onValueChange, onUnlimitedChange, min, }: LimitInputProps): react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
declare const PLAN_COLORS: readonly [{
|
|
187
|
+
readonly value: "gray";
|
|
188
|
+
readonly label: "Grigio";
|
|
189
|
+
readonly className: "bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400";
|
|
190
|
+
}, {
|
|
191
|
+
readonly value: "green";
|
|
192
|
+
readonly label: "Verde";
|
|
193
|
+
readonly className: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400";
|
|
194
|
+
}, {
|
|
195
|
+
readonly value: "blue";
|
|
196
|
+
readonly label: "Blu";
|
|
197
|
+
readonly className: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400";
|
|
198
|
+
}, {
|
|
199
|
+
readonly value: "purple";
|
|
200
|
+
readonly label: "Viola";
|
|
201
|
+
readonly className: "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";
|
|
202
|
+
}, {
|
|
203
|
+
readonly value: "amber";
|
|
204
|
+
readonly label: "Ambra";
|
|
205
|
+
readonly className: "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400";
|
|
206
|
+
}, {
|
|
207
|
+
readonly value: "red";
|
|
208
|
+
readonly label: "Rosso";
|
|
209
|
+
readonly className: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400";
|
|
210
|
+
}, {
|
|
211
|
+
readonly value: "pink";
|
|
212
|
+
readonly label: "Rosa";
|
|
213
|
+
readonly className: "bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400";
|
|
214
|
+
}, {
|
|
215
|
+
readonly value: "indigo";
|
|
216
|
+
readonly label: "Indaco";
|
|
217
|
+
readonly className: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400";
|
|
218
|
+
}];
|
|
219
|
+
type PlanColorValue = typeof PLAN_COLORS[number]['value'];
|
|
220
|
+
declare function getPlanColorClass(color: string | undefined): string;
|
|
221
|
+
|
|
222
|
+
interface ProductFormData {
|
|
223
|
+
name: string;
|
|
224
|
+
description: string;
|
|
225
|
+
price_cents: string;
|
|
226
|
+
currency: string;
|
|
227
|
+
recurring_interval: RecurringInterval | '';
|
|
228
|
+
category: string;
|
|
229
|
+
is_active: boolean;
|
|
230
|
+
sync_stripe: boolean;
|
|
231
|
+
feature_slug: string;
|
|
232
|
+
extra_data: string;
|
|
233
|
+
}
|
|
234
|
+
declare const defaultProductFormData: ProductFormData;
|
|
235
|
+
interface AvailableFeature {
|
|
236
|
+
slug: string;
|
|
237
|
+
name: string;
|
|
238
|
+
}
|
|
239
|
+
interface ProductFormDialogProps {
|
|
240
|
+
isOpen: boolean;
|
|
241
|
+
onOpenChange: (open: boolean) => void;
|
|
242
|
+
mode: 'create' | 'edit';
|
|
243
|
+
product?: AdminProduct | null;
|
|
244
|
+
features?: AvailableFeature[];
|
|
245
|
+
onSubmit: (data: ProductFormData) => void;
|
|
246
|
+
isSubmitting: boolean;
|
|
247
|
+
}
|
|
248
|
+
declare function ProductFormDialog({ isOpen, onOpenChange, mode, product, features, onSubmit, isSubmitting, }: ProductFormDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
249
|
+
|
|
250
|
+
interface InvoiceDetailsDialogProps {
|
|
251
|
+
isOpen: boolean;
|
|
252
|
+
onOpenChange: (open: boolean) => void;
|
|
253
|
+
invoice: AdminInvoice | null | undefined;
|
|
254
|
+
}
|
|
255
|
+
declare function InvoiceDetailsDialog({ isOpen, onOpenChange, invoice }: InvoiceDetailsDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
256
|
+
|
|
257
|
+
interface DeleteConfirmDialogProps {
|
|
258
|
+
isOpen: boolean;
|
|
259
|
+
onOpenChange: (open: boolean) => void;
|
|
260
|
+
title?: string;
|
|
261
|
+
description: React$1.ReactNode;
|
|
262
|
+
onConfirm: () => void;
|
|
263
|
+
isDeleting: boolean;
|
|
264
|
+
confirmLabel?: string;
|
|
265
|
+
cancelLabel?: string;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Reusable confirmation dialog for destructive actions.
|
|
269
|
+
* Uses native HTML dialog to avoid requiring shadcn AlertDialog as peer dependency.
|
|
270
|
+
* Consumer projects can override this component via the provider if needed.
|
|
271
|
+
*/
|
|
272
|
+
declare function DeleteConfirmDialog({ isOpen, onOpenChange, title, description, onConfirm, isDeleting, confirmLabel, cancelLabel, }: DeleteConfirmDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
273
|
+
|
|
274
|
+
interface CursorPaginationProps {
|
|
275
|
+
cursor: string | undefined;
|
|
276
|
+
hasMore: boolean;
|
|
277
|
+
items: Array<{
|
|
278
|
+
id: string;
|
|
279
|
+
}>;
|
|
280
|
+
onFirstPage: () => void;
|
|
281
|
+
onNextPage: (lastItemId: string) => void;
|
|
282
|
+
}
|
|
283
|
+
declare function CursorPagination({ cursor, hasMore, items, onFirstPage, onNextPage, }: CursorPaginationProps): react_jsx_runtime.JSX.Element;
|
|
284
|
+
|
|
285
|
+
interface FilterOption {
|
|
286
|
+
value: string;
|
|
287
|
+
label: string;
|
|
288
|
+
}
|
|
289
|
+
interface FilterBarProps {
|
|
290
|
+
searchPlaceholder?: string;
|
|
291
|
+
searchValue: string;
|
|
292
|
+
onSearchChange: (value: string) => void;
|
|
293
|
+
statusFilter?: string;
|
|
294
|
+
onStatusFilterChange?: (value: string) => void;
|
|
295
|
+
statusOptions?: FilterOption[];
|
|
296
|
+
onRefresh: () => void;
|
|
297
|
+
}
|
|
298
|
+
declare function FilterBar({ searchPlaceholder, searchValue, onSearchChange, statusFilter, onStatusFilterChange, statusOptions, onRefresh, }: FilterBarProps): react_jsx_runtime.JSX.Element;
|
|
299
|
+
|
|
300
|
+
interface StatusBadgeProps {
|
|
301
|
+
label: string;
|
|
302
|
+
colorClass: string;
|
|
303
|
+
className?: string;
|
|
304
|
+
}
|
|
305
|
+
declare function StatusBadge({ label, colorClass, className }: StatusBadgeProps): react_jsx_runtime.JSX.Element;
|
|
306
|
+
|
|
307
|
+
interface SkeletonRowsProps {
|
|
308
|
+
rows?: number;
|
|
309
|
+
columns?: number;
|
|
310
|
+
}
|
|
311
|
+
declare function SkeletonRows({ rows, columns }: SkeletonRowsProps): react_jsx_runtime.JSX.Element;
|
|
312
|
+
|
|
313
|
+
interface BillingNavItem {
|
|
314
|
+
key: string;
|
|
315
|
+
label: string;
|
|
316
|
+
/** Lucide icon name (consumer maps to actual icon component) */
|
|
317
|
+
icon: string;
|
|
318
|
+
/** Suggested href path (consumer can override) */
|
|
319
|
+
href: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Returns navigation items filtered by enabled modules.
|
|
323
|
+
*
|
|
324
|
+
* @param modules - The modules config from BillingAdminProvider
|
|
325
|
+
* @param basePath - Optional base path prefix (e.g., '/dashboard')
|
|
326
|
+
*/
|
|
327
|
+
declare function getBillingNavItems(modules?: BillingModulesConfig, basePath?: string): BillingNavItem[];
|
|
328
|
+
|
|
329
|
+
export { type BillingAdminConfig, BillingAdminProvider, type BillingAdminProviderProps, type BillingModulesConfig, type BillingNavItem, CursorPagination, DeleteConfirmDialog, type FeaturesConfig, FeaturesPage, type FeaturesPageProps, FilterBar, InvoiceDetailsDialog, InvoicesPage, type InvoicesPageProps, type LimitFieldConfig, LimitInput, PLAN_COLORS, PaymentsPage, type PaymentsPageProps, type PlanColorValue, type PlanFormData, PlanFormDialog, PlansPage, type PlansPageProps, PlansTable, type ProductFormData, ProductFormDialog, ProductsPage, type ProductsPageProps, type PublicPlansConfig, SkeletonRows, StatusBadge, SubscriptionsPage, type SubscriptionsPageProps, createDefaultPlanFormData, defaultProductFormData, getBillingNavItems, getPlanColorClass, useBillingAdminConfig, useEnabledModules };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
3
|
+
import { Fetcher, AdminPlan, AdminPlanPricingModel, RecurringInterval, AdminProduct, AdminInvoice } from '@growflowstudio/billing-admin-core';
|
|
4
|
+
|
|
5
|
+
interface LimitFieldConfig {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
defaultValue?: number;
|
|
9
|
+
}
|
|
10
|
+
interface FeaturesConfig {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
fetchFn?: () => Promise<{
|
|
13
|
+
features: Array<{
|
|
14
|
+
slug: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
interface PublicPlansConfig {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
fetchFn?: () => Promise<{
|
|
23
|
+
public_plan_slugs: string[];
|
|
24
|
+
}>;
|
|
25
|
+
updateFn?: (slugs: string[]) => Promise<{
|
|
26
|
+
public_plan_slugs: string[];
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configure which billing modules are enabled for this project.
|
|
31
|
+
* By default, all modules are enabled.
|
|
32
|
+
*
|
|
33
|
+
* Examples:
|
|
34
|
+
* - Booking/WineTracking: { plans: true, subscriptions: true, products: false, features: false }
|
|
35
|
+
* - SweatMate: { plans: true, subscriptions: true, products: true, features: true }
|
|
36
|
+
* - ShopBrain: all enabled (default)
|
|
37
|
+
*/
|
|
38
|
+
interface BillingModulesConfig {
|
|
39
|
+
plans?: boolean;
|
|
40
|
+
subscriptions?: boolean;
|
|
41
|
+
products?: boolean;
|
|
42
|
+
payments?: boolean;
|
|
43
|
+
invoices?: boolean;
|
|
44
|
+
features?: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface BillingAdminConfig {
|
|
47
|
+
/** Base path for billing admin API (e.g., '/api/v1/billing-admin') */
|
|
48
|
+
basePath: string;
|
|
49
|
+
/** HTTP fetcher function from the host application (handles auth) */
|
|
50
|
+
fetcher: Fetcher;
|
|
51
|
+
/** Locale for number/date formatting (default: 'it-IT') */
|
|
52
|
+
locale?: string;
|
|
53
|
+
/** Default currency (default: 'EUR') */
|
|
54
|
+
currency?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Enable/disable billing modules per project.
|
|
57
|
+
* All modules are enabled by default.
|
|
58
|
+
*/
|
|
59
|
+
modules?: BillingModulesConfig;
|
|
60
|
+
/** Plan-specific configurations */
|
|
61
|
+
plans?: {
|
|
62
|
+
/** Configurable limit fields for plan forms */
|
|
63
|
+
limitFields?: LimitFieldConfig[];
|
|
64
|
+
/** Feature selection in plan forms */
|
|
65
|
+
features?: FeaturesConfig;
|
|
66
|
+
/** Public plans toggle (ShopBrain-specific) */
|
|
67
|
+
publicPlans?: PublicPlansConfig;
|
|
68
|
+
};
|
|
69
|
+
/** Product-specific configurations */
|
|
70
|
+
products?: {
|
|
71
|
+
/** Feature linking in product forms */
|
|
72
|
+
features?: FeaturesConfig;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
declare function useBillingAdminConfig(): BillingAdminConfig;
|
|
76
|
+
/** Returns the resolved modules config (with defaults applied) */
|
|
77
|
+
declare function useEnabledModules(): Required<BillingModulesConfig>;
|
|
78
|
+
interface BillingAdminProviderProps {
|
|
79
|
+
config: BillingAdminConfig;
|
|
80
|
+
children: React$1.ReactNode;
|
|
81
|
+
}
|
|
82
|
+
declare function BillingAdminProvider({ config, children }: BillingAdminProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
interface PlansPageProps {
|
|
85
|
+
/** Optional wrapper component for the page content */
|
|
86
|
+
wrapper?: React.ComponentType<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
}>;
|
|
89
|
+
/** Optional header component */
|
|
90
|
+
header?: React.ReactNode;
|
|
91
|
+
}
|
|
92
|
+
declare function PlansPage({ wrapper: Wrapper, header }: PlansPageProps): react_jsx_runtime.JSX.Element;
|
|
93
|
+
|
|
94
|
+
interface ProductsPageProps {
|
|
95
|
+
wrapper?: React.ComponentType<{
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
}>;
|
|
98
|
+
header?: React.ReactNode;
|
|
99
|
+
}
|
|
100
|
+
declare function ProductsPage({ wrapper: Wrapper, header }: ProductsPageProps): react_jsx_runtime.JSX.Element;
|
|
101
|
+
|
|
102
|
+
interface SubscriptionsPageProps {
|
|
103
|
+
wrapper?: React.ComponentType<{
|
|
104
|
+
children: React.ReactNode;
|
|
105
|
+
}>;
|
|
106
|
+
header?: React.ReactNode;
|
|
107
|
+
}
|
|
108
|
+
declare function SubscriptionsPage({ wrapper: Wrapper, header }: SubscriptionsPageProps): react_jsx_runtime.JSX.Element;
|
|
109
|
+
|
|
110
|
+
interface PaymentsPageProps {
|
|
111
|
+
wrapper?: React.ComponentType<{
|
|
112
|
+
children: React.ReactNode;
|
|
113
|
+
}>;
|
|
114
|
+
header?: React.ReactNode;
|
|
115
|
+
}
|
|
116
|
+
declare function PaymentsPage({ wrapper: Wrapper, header }: PaymentsPageProps): react_jsx_runtime.JSX.Element;
|
|
117
|
+
|
|
118
|
+
interface InvoicesPageProps {
|
|
119
|
+
wrapper?: React.ComponentType<{
|
|
120
|
+
children: React.ReactNode;
|
|
121
|
+
}>;
|
|
122
|
+
header?: React.ReactNode;
|
|
123
|
+
}
|
|
124
|
+
declare function InvoicesPage({ wrapper: Wrapper, header }: InvoicesPageProps): react_jsx_runtime.JSX.Element;
|
|
125
|
+
|
|
126
|
+
interface FeaturesPageProps {
|
|
127
|
+
wrapper?: React.ComponentType<{
|
|
128
|
+
children: React.ReactNode;
|
|
129
|
+
}>;
|
|
130
|
+
header?: React.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
declare function FeaturesPage({ wrapper: Wrapper, header }: FeaturesPageProps): react_jsx_runtime.JSX.Element;
|
|
133
|
+
|
|
134
|
+
interface PlansTableProps {
|
|
135
|
+
plans: AdminPlan[];
|
|
136
|
+
isLoading: boolean;
|
|
137
|
+
onEdit: (plan: AdminPlan) => void;
|
|
138
|
+
onDelete: (plan: AdminPlan) => void;
|
|
139
|
+
onSync: (planId: string) => void;
|
|
140
|
+
isSyncing: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare function PlansTable({ plans, isLoading, onEdit, onDelete, onSync, isSyncing, }: PlansTableProps): react_jsx_runtime.JSX.Element;
|
|
143
|
+
|
|
144
|
+
interface PlanFormData {
|
|
145
|
+
slug: string;
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
pricing_model: AdminPlanPricingModel;
|
|
149
|
+
price_monthly: string;
|
|
150
|
+
price_yearly: string;
|
|
151
|
+
currency: string;
|
|
152
|
+
trial_days: number;
|
|
153
|
+
is_active: boolean;
|
|
154
|
+
contact_sales: boolean;
|
|
155
|
+
is_public: boolean;
|
|
156
|
+
color: string;
|
|
157
|
+
limits: Record<string, number>;
|
|
158
|
+
limits_unlimited: Record<string, boolean>;
|
|
159
|
+
features: string;
|
|
160
|
+
sort_order: number;
|
|
161
|
+
}
|
|
162
|
+
declare function createDefaultPlanFormData(limitFields?: LimitFieldConfig[]): PlanFormData;
|
|
163
|
+
interface PlanFormDialogProps {
|
|
164
|
+
open: boolean;
|
|
165
|
+
onOpenChange: (open: boolean) => void;
|
|
166
|
+
formData: PlanFormData;
|
|
167
|
+
onFormDataChange: (data: Partial<PlanFormData>) => void;
|
|
168
|
+
formErrors: Record<string, string>;
|
|
169
|
+
selectedPlan: AdminPlan | null;
|
|
170
|
+
onSubmit: () => void;
|
|
171
|
+
isPending: boolean;
|
|
172
|
+
}
|
|
173
|
+
declare function PlanFormDialog({ open, onOpenChange, formData, onFormDataChange, formErrors, selectedPlan, onSubmit, isPending, }: PlanFormDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
174
|
+
|
|
175
|
+
interface LimitInputProps {
|
|
176
|
+
id: string;
|
|
177
|
+
label: string;
|
|
178
|
+
value: number;
|
|
179
|
+
isUnlimited: boolean;
|
|
180
|
+
onValueChange: (value: number) => void;
|
|
181
|
+
onUnlimitedChange: (unlimited: boolean) => void;
|
|
182
|
+
min?: number;
|
|
183
|
+
}
|
|
184
|
+
declare function LimitInput({ id, label, value, isUnlimited, onValueChange, onUnlimitedChange, min, }: LimitInputProps): react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
declare const PLAN_COLORS: readonly [{
|
|
187
|
+
readonly value: "gray";
|
|
188
|
+
readonly label: "Grigio";
|
|
189
|
+
readonly className: "bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400";
|
|
190
|
+
}, {
|
|
191
|
+
readonly value: "green";
|
|
192
|
+
readonly label: "Verde";
|
|
193
|
+
readonly className: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400";
|
|
194
|
+
}, {
|
|
195
|
+
readonly value: "blue";
|
|
196
|
+
readonly label: "Blu";
|
|
197
|
+
readonly className: "bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400";
|
|
198
|
+
}, {
|
|
199
|
+
readonly value: "purple";
|
|
200
|
+
readonly label: "Viola";
|
|
201
|
+
readonly className: "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400";
|
|
202
|
+
}, {
|
|
203
|
+
readonly value: "amber";
|
|
204
|
+
readonly label: "Ambra";
|
|
205
|
+
readonly className: "bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400";
|
|
206
|
+
}, {
|
|
207
|
+
readonly value: "red";
|
|
208
|
+
readonly label: "Rosso";
|
|
209
|
+
readonly className: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400";
|
|
210
|
+
}, {
|
|
211
|
+
readonly value: "pink";
|
|
212
|
+
readonly label: "Rosa";
|
|
213
|
+
readonly className: "bg-pink-100 text-pink-700 dark:bg-pink-900/30 dark:text-pink-400";
|
|
214
|
+
}, {
|
|
215
|
+
readonly value: "indigo";
|
|
216
|
+
readonly label: "Indaco";
|
|
217
|
+
readonly className: "bg-indigo-100 text-indigo-700 dark:bg-indigo-900/30 dark:text-indigo-400";
|
|
218
|
+
}];
|
|
219
|
+
type PlanColorValue = typeof PLAN_COLORS[number]['value'];
|
|
220
|
+
declare function getPlanColorClass(color: string | undefined): string;
|
|
221
|
+
|
|
222
|
+
interface ProductFormData {
|
|
223
|
+
name: string;
|
|
224
|
+
description: string;
|
|
225
|
+
price_cents: string;
|
|
226
|
+
currency: string;
|
|
227
|
+
recurring_interval: RecurringInterval | '';
|
|
228
|
+
category: string;
|
|
229
|
+
is_active: boolean;
|
|
230
|
+
sync_stripe: boolean;
|
|
231
|
+
feature_slug: string;
|
|
232
|
+
extra_data: string;
|
|
233
|
+
}
|
|
234
|
+
declare const defaultProductFormData: ProductFormData;
|
|
235
|
+
interface AvailableFeature {
|
|
236
|
+
slug: string;
|
|
237
|
+
name: string;
|
|
238
|
+
}
|
|
239
|
+
interface ProductFormDialogProps {
|
|
240
|
+
isOpen: boolean;
|
|
241
|
+
onOpenChange: (open: boolean) => void;
|
|
242
|
+
mode: 'create' | 'edit';
|
|
243
|
+
product?: AdminProduct | null;
|
|
244
|
+
features?: AvailableFeature[];
|
|
245
|
+
onSubmit: (data: ProductFormData) => void;
|
|
246
|
+
isSubmitting: boolean;
|
|
247
|
+
}
|
|
248
|
+
declare function ProductFormDialog({ isOpen, onOpenChange, mode, product, features, onSubmit, isSubmitting, }: ProductFormDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
249
|
+
|
|
250
|
+
interface InvoiceDetailsDialogProps {
|
|
251
|
+
isOpen: boolean;
|
|
252
|
+
onOpenChange: (open: boolean) => void;
|
|
253
|
+
invoice: AdminInvoice | null | undefined;
|
|
254
|
+
}
|
|
255
|
+
declare function InvoiceDetailsDialog({ isOpen, onOpenChange, invoice }: InvoiceDetailsDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
256
|
+
|
|
257
|
+
interface DeleteConfirmDialogProps {
|
|
258
|
+
isOpen: boolean;
|
|
259
|
+
onOpenChange: (open: boolean) => void;
|
|
260
|
+
title?: string;
|
|
261
|
+
description: React$1.ReactNode;
|
|
262
|
+
onConfirm: () => void;
|
|
263
|
+
isDeleting: boolean;
|
|
264
|
+
confirmLabel?: string;
|
|
265
|
+
cancelLabel?: string;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Reusable confirmation dialog for destructive actions.
|
|
269
|
+
* Uses native HTML dialog to avoid requiring shadcn AlertDialog as peer dependency.
|
|
270
|
+
* Consumer projects can override this component via the provider if needed.
|
|
271
|
+
*/
|
|
272
|
+
declare function DeleteConfirmDialog({ isOpen, onOpenChange, title, description, onConfirm, isDeleting, confirmLabel, cancelLabel, }: DeleteConfirmDialogProps): react_jsx_runtime.JSX.Element | null;
|
|
273
|
+
|
|
274
|
+
interface CursorPaginationProps {
|
|
275
|
+
cursor: string | undefined;
|
|
276
|
+
hasMore: boolean;
|
|
277
|
+
items: Array<{
|
|
278
|
+
id: string;
|
|
279
|
+
}>;
|
|
280
|
+
onFirstPage: () => void;
|
|
281
|
+
onNextPage: (lastItemId: string) => void;
|
|
282
|
+
}
|
|
283
|
+
declare function CursorPagination({ cursor, hasMore, items, onFirstPage, onNextPage, }: CursorPaginationProps): react_jsx_runtime.JSX.Element;
|
|
284
|
+
|
|
285
|
+
interface FilterOption {
|
|
286
|
+
value: string;
|
|
287
|
+
label: string;
|
|
288
|
+
}
|
|
289
|
+
interface FilterBarProps {
|
|
290
|
+
searchPlaceholder?: string;
|
|
291
|
+
searchValue: string;
|
|
292
|
+
onSearchChange: (value: string) => void;
|
|
293
|
+
statusFilter?: string;
|
|
294
|
+
onStatusFilterChange?: (value: string) => void;
|
|
295
|
+
statusOptions?: FilterOption[];
|
|
296
|
+
onRefresh: () => void;
|
|
297
|
+
}
|
|
298
|
+
declare function FilterBar({ searchPlaceholder, searchValue, onSearchChange, statusFilter, onStatusFilterChange, statusOptions, onRefresh, }: FilterBarProps): react_jsx_runtime.JSX.Element;
|
|
299
|
+
|
|
300
|
+
interface StatusBadgeProps {
|
|
301
|
+
label: string;
|
|
302
|
+
colorClass: string;
|
|
303
|
+
className?: string;
|
|
304
|
+
}
|
|
305
|
+
declare function StatusBadge({ label, colorClass, className }: StatusBadgeProps): react_jsx_runtime.JSX.Element;
|
|
306
|
+
|
|
307
|
+
interface SkeletonRowsProps {
|
|
308
|
+
rows?: number;
|
|
309
|
+
columns?: number;
|
|
310
|
+
}
|
|
311
|
+
declare function SkeletonRows({ rows, columns }: SkeletonRowsProps): react_jsx_runtime.JSX.Element;
|
|
312
|
+
|
|
313
|
+
interface BillingNavItem {
|
|
314
|
+
key: string;
|
|
315
|
+
label: string;
|
|
316
|
+
/** Lucide icon name (consumer maps to actual icon component) */
|
|
317
|
+
icon: string;
|
|
318
|
+
/** Suggested href path (consumer can override) */
|
|
319
|
+
href: string;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Returns navigation items filtered by enabled modules.
|
|
323
|
+
*
|
|
324
|
+
* @param modules - The modules config from BillingAdminProvider
|
|
325
|
+
* @param basePath - Optional base path prefix (e.g., '/dashboard')
|
|
326
|
+
*/
|
|
327
|
+
declare function getBillingNavItems(modules?: BillingModulesConfig, basePath?: string): BillingNavItem[];
|
|
328
|
+
|
|
329
|
+
export { type BillingAdminConfig, BillingAdminProvider, type BillingAdminProviderProps, type BillingModulesConfig, type BillingNavItem, CursorPagination, DeleteConfirmDialog, type FeaturesConfig, FeaturesPage, type FeaturesPageProps, FilterBar, InvoiceDetailsDialog, InvoicesPage, type InvoicesPageProps, type LimitFieldConfig, LimitInput, PLAN_COLORS, PaymentsPage, type PaymentsPageProps, type PlanColorValue, type PlanFormData, PlanFormDialog, PlansPage, type PlansPageProps, PlansTable, type ProductFormData, ProductFormDialog, ProductsPage, type ProductsPageProps, type PublicPlansConfig, SkeletonRows, StatusBadge, SubscriptionsPage, type SubscriptionsPageProps, createDefaultPlanFormData, defaultProductFormData, getBillingNavItems, getPlanColorClass, useBillingAdminConfig, useEnabledModules };
|