@ttoss/react-billing 0.1.1 → 0.1.3
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/README.md +74 -1
- package/dist/esm/index.js +365 -4653
- package/dist/index.d.ts +263 -4
- package/package.json +6 -3
- package/dist/index.d.cts +0 -48
- package/dist/index.js +0 -4912
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,17 @@ import { IconType } from '@ttoss/react-icons';
|
|
|
3
3
|
import { CardProps, ButtonProps } from '@ttoss/ui';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
|
|
6
|
+
type PlanCardVariantType = 'primary' | 'secondary'
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `primary`.
|
|
9
|
+
*/
|
|
10
|
+
| 'default'
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `secondary`.
|
|
13
|
+
*/
|
|
14
|
+
| 'enterprise';
|
|
15
|
+
type PlanCardVariant = PlanCardVariantType;
|
|
16
|
+
|
|
6
17
|
type PlanCardMetadataSlotParameter = {
|
|
7
18
|
name: string;
|
|
8
19
|
value: React.ReactNode;
|
|
@@ -14,14 +25,12 @@ type PlanCardMetadataSlotService = {
|
|
|
14
25
|
id?: string;
|
|
15
26
|
key?: string;
|
|
16
27
|
};
|
|
17
|
-
type PlanCardMetadataSlotVariant =
|
|
28
|
+
type PlanCardMetadataSlotVariant = PlanCardVariantType;
|
|
18
29
|
interface PlanCardMetadataSlotProps {
|
|
19
30
|
metadata: PlanCardMetadataSlotService[];
|
|
20
31
|
variant?: PlanCardMetadataSlotVariant;
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
type PlanCardVariant = 'default' | 'enterprise';
|
|
24
|
-
|
|
25
34
|
type PlanCardMetadata = PlanCardMetadataSlotService[];
|
|
26
35
|
type PlanCardPrice = {
|
|
27
36
|
value: string | number;
|
|
@@ -45,4 +54,254 @@ interface PlanCardProps extends Omit<CardProps, 'children'> {
|
|
|
45
54
|
}
|
|
46
55
|
declare const PlanCard: (props: PlanCardProps) => react_jsx_runtime.JSX.Element;
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
type SubscriptionPanelVariant = 'spotlight-accent' | 'spotlight-primary' | 'primary' | 'secondary' | 'accent';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Subscription status indicating the current state of the subscription.
|
|
61
|
+
*/
|
|
62
|
+
type SubscriptionStatus = 'active' | 'inactive' | 'cancelled';
|
|
63
|
+
/**
|
|
64
|
+
* Base metric properties shared by all metric types.
|
|
65
|
+
*/
|
|
66
|
+
interface BaseMetric {
|
|
67
|
+
/**
|
|
68
|
+
* Label displayed above the metric value.
|
|
69
|
+
*/
|
|
70
|
+
label: string;
|
|
71
|
+
/**
|
|
72
|
+
* Optional tooltip text or action handler for additional context.
|
|
73
|
+
* When a string is provided, it displays a simple tooltip.
|
|
74
|
+
* When a function is provided, it's called when the tooltip icon is clicked (e.g., to open help articles).
|
|
75
|
+
*/
|
|
76
|
+
tooltip?: string | (() => void);
|
|
77
|
+
/**
|
|
78
|
+
* Icon to display alongside the metric.
|
|
79
|
+
*/
|
|
80
|
+
icon?: IconType;
|
|
81
|
+
/**
|
|
82
|
+
* Optional click handler to make the metric card interactive.
|
|
83
|
+
*/
|
|
84
|
+
onClick?: () => void;
|
|
85
|
+
/**
|
|
86
|
+
* Optional help article action handler.
|
|
87
|
+
*/
|
|
88
|
+
helpArticleAction?: () => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Date-based metric for displaying dates like expiration or renewal.
|
|
92
|
+
*/
|
|
93
|
+
interface DateMetric extends BaseMetric {
|
|
94
|
+
type: 'date';
|
|
95
|
+
/**
|
|
96
|
+
* The date value to display.
|
|
97
|
+
*/
|
|
98
|
+
date: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional message showing remaining days.
|
|
101
|
+
*/
|
|
102
|
+
remainingDaysMessage?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Whether to show a warning indicator.
|
|
105
|
+
*/
|
|
106
|
+
isWarning?: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Percentage-based metric with progress bar.
|
|
110
|
+
*/
|
|
111
|
+
interface PercentageMetric extends BaseMetric {
|
|
112
|
+
type: 'percentage';
|
|
113
|
+
/**
|
|
114
|
+
* Current value.
|
|
115
|
+
*/
|
|
116
|
+
current: number;
|
|
117
|
+
/**
|
|
118
|
+
* Maximum value. Use null for unlimited.
|
|
119
|
+
*/
|
|
120
|
+
max: number | null;
|
|
121
|
+
/**
|
|
122
|
+
* Custom formatter for displaying values.
|
|
123
|
+
*/
|
|
124
|
+
formatValue?: (value: number) => string;
|
|
125
|
+
/**
|
|
126
|
+
* Percentage threshold at which to show an alert.
|
|
127
|
+
*/
|
|
128
|
+
showAlertThreshold?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Number-based metric for displaying counts.
|
|
132
|
+
*/
|
|
133
|
+
interface NumberMetric extends BaseMetric {
|
|
134
|
+
type: 'number';
|
|
135
|
+
/**
|
|
136
|
+
* Current value.
|
|
137
|
+
*/
|
|
138
|
+
current: number;
|
|
139
|
+
/**
|
|
140
|
+
* Maximum value. Use null for unlimited.
|
|
141
|
+
*/
|
|
142
|
+
max: number | null;
|
|
143
|
+
/**
|
|
144
|
+
* Custom formatter for displaying values.
|
|
145
|
+
*/
|
|
146
|
+
formatValue?: (value: number) => string;
|
|
147
|
+
/**
|
|
148
|
+
* Optional footer text below the metric.
|
|
149
|
+
*/
|
|
150
|
+
footerText?: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Union type for all metric types.
|
|
154
|
+
*/
|
|
155
|
+
type MetricType = DateMetric | PercentageMetric | NumberMetric;
|
|
156
|
+
/**
|
|
157
|
+
* Status badge configuration.
|
|
158
|
+
*/
|
|
159
|
+
interface SubscriptionPanelStatusBadgeProps {
|
|
160
|
+
/**
|
|
161
|
+
* The subscription status.
|
|
162
|
+
*/
|
|
163
|
+
status: SubscriptionStatus;
|
|
164
|
+
/**
|
|
165
|
+
* Billing interval (e.g., "Mensal", "Anual").
|
|
166
|
+
*/
|
|
167
|
+
interval?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Whether the subscription has a pending cancellation.
|
|
170
|
+
*/
|
|
171
|
+
hasCancellation?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Whether the subscription has a scheduled update.
|
|
174
|
+
*/
|
|
175
|
+
hasScheduledUpdate?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Feature tag displayed in the card header.
|
|
179
|
+
*/
|
|
180
|
+
interface SubscriptionPanelFeatureTag {
|
|
181
|
+
/**
|
|
182
|
+
* Label text for the feature.
|
|
183
|
+
*/
|
|
184
|
+
label: string;
|
|
185
|
+
/**
|
|
186
|
+
* Optional icon for the feature.
|
|
187
|
+
*/
|
|
188
|
+
icon?: IconType;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Action button configuration.
|
|
192
|
+
*/
|
|
193
|
+
interface SubscriptionPanelAction extends Omit<ButtonProps, 'children'> {
|
|
194
|
+
/**
|
|
195
|
+
* Button label text.
|
|
196
|
+
*/
|
|
197
|
+
label: string;
|
|
198
|
+
/**
|
|
199
|
+
* Click handler for the action.
|
|
200
|
+
*/
|
|
201
|
+
onClick: () => void;
|
|
202
|
+
/**
|
|
203
|
+
* Optional icon for the button.
|
|
204
|
+
*/
|
|
205
|
+
leftIcon?: IconType;
|
|
206
|
+
/**
|
|
207
|
+
* Whether the action is currently loading.
|
|
208
|
+
*/
|
|
209
|
+
isLoading?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Price configuration.
|
|
213
|
+
*/
|
|
214
|
+
interface SubscriptionPanelPrice {
|
|
215
|
+
/**
|
|
216
|
+
* Price value (e.g., "R$ 5,00").
|
|
217
|
+
*/
|
|
218
|
+
value: string;
|
|
219
|
+
/**
|
|
220
|
+
* Price interval (e.g., "mês", "ano").
|
|
221
|
+
*/
|
|
222
|
+
interval?: string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Main SubscriptionPanel props.
|
|
226
|
+
*/
|
|
227
|
+
interface SubscriptionPanelProps {
|
|
228
|
+
/**
|
|
229
|
+
* Visual variant for the accent bar and header icon.
|
|
230
|
+
* @default 'spotlight'
|
|
231
|
+
*/
|
|
232
|
+
variant?: SubscriptionPanelVariant;
|
|
233
|
+
/**
|
|
234
|
+
* Plan icon to display. Can be a ReactNode or an IconType string.
|
|
235
|
+
*/
|
|
236
|
+
icon?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Name of the subscription plan.
|
|
239
|
+
*/
|
|
240
|
+
planName: string;
|
|
241
|
+
/**
|
|
242
|
+
* Price configuration.
|
|
243
|
+
*/
|
|
244
|
+
price: SubscriptionPanelPrice;
|
|
245
|
+
/**
|
|
246
|
+
* Status badge configuration.
|
|
247
|
+
*/
|
|
248
|
+
status: SubscriptionPanelStatusBadgeProps;
|
|
249
|
+
/**
|
|
250
|
+
* Feature tags to display.
|
|
251
|
+
*/
|
|
252
|
+
features?: SubscriptionPanelFeatureTag[];
|
|
253
|
+
/**
|
|
254
|
+
* Action buttons.
|
|
255
|
+
*/
|
|
256
|
+
actions?: SubscriptionPanelAction[];
|
|
257
|
+
/**
|
|
258
|
+
* Metrics to display in the card.
|
|
259
|
+
*/
|
|
260
|
+
metrics?: MetricType[];
|
|
261
|
+
/**
|
|
262
|
+
* Whether the card is in a loading state.
|
|
263
|
+
*/
|
|
264
|
+
isLoading?: boolean;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* SubscriptionPanel displays comprehensive subscription information including
|
|
269
|
+
* plan details, status, actions, and various metrics.
|
|
270
|
+
*
|
|
271
|
+
* It supports three types of metrics:
|
|
272
|
+
* - **Date**: For displaying dates like expiration or renewal
|
|
273
|
+
* - **Percentage**: For usage-based metrics with progress bars
|
|
274
|
+
* - **Number**: For count-based metrics
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```tsx
|
|
278
|
+
* <SubscriptionPanel
|
|
279
|
+
* planName="Premium Plan"
|
|
280
|
+
* price={{ value: "R$ 99,00", interval: "mês" }}
|
|
281
|
+
* status={{ status: "active", interval: "Mensal" }}
|
|
282
|
+
* features={[{ label: "Feature 1" }, { label: "Feature 2" }]}
|
|
283
|
+
* actions={[
|
|
284
|
+
* { label: "Upgrade", onClick: () => {}, variant: "accent" },
|
|
285
|
+
* { label: "Cancel", onClick: () => {}, variant: "danger" },
|
|
286
|
+
* ]}
|
|
287
|
+
* metrics={[
|
|
288
|
+
* { type: "date", label: "Expira em", date: "15/01/2025", icon: "fluent:calendar-24-regular" },
|
|
289
|
+
* { type: "percentage", label: "Uso", current: 75, max: 100, icon: "fluent:data-usage-24-regular" },
|
|
290
|
+
* ]}
|
|
291
|
+
* />
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```tsx
|
|
296
|
+
* // Compact mode for smaller spaces
|
|
297
|
+
* <SubscriptionPanel
|
|
298
|
+
* planName="Basic Plan"
|
|
299
|
+
* price={{ value: "R$ 29,00", interval: "mês" }}
|
|
300
|
+
* status={{ status: "active" }}
|
|
301
|
+
* compact
|
|
302
|
+
* />
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
declare const SubscriptionPanel: ({ variant, icon, planName, price, status, features, actions, metrics, isLoading, }: SubscriptionPanelProps) => react_jsx_runtime.JSX.Element;
|
|
306
|
+
|
|
307
|
+
export { PlanCard, type PlanCardButtonProps, type PlanCardMetadata, type PlanCardMetadataSlotParameter, type PlanCardMetadataSlotProps, type PlanCardMetadataSlotService, type PlanCardMetadataSlotVariant, type PlanCardPrice, type PlanCardProps, type PlanCardVariant, SubscriptionPanel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-billing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Billing UI components for React apps.",
|
|
5
5
|
"author": "Giovane Guimarães",
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"sideEffects": false,
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@ttoss/components": "^2.11.5",
|
|
24
|
+
"@ttoss/ui": "^6.3.2",
|
|
25
|
+
"@ttoss/react-icons": "^0.5.6"
|
|
26
|
+
},
|
|
22
27
|
"peerDependencies": {
|
|
23
28
|
"react": ">=16.8.0"
|
|
24
29
|
},
|
|
@@ -29,8 +34,6 @@
|
|
|
29
34
|
"react": "^19.2.1",
|
|
30
35
|
"tsup": "^8.5.1",
|
|
31
36
|
"@ttoss/config": "^1.35.12",
|
|
32
|
-
"@ttoss/ui": "^6.3.2",
|
|
33
|
-
"@ttoss/react-icons": "^0.5.6",
|
|
34
37
|
"@ttoss/test-utils": "^4.0.2"
|
|
35
38
|
},
|
|
36
39
|
"keywords": [
|
package/dist/index.d.cts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { IconType } from '@ttoss/react-icons';
|
|
3
|
-
import { CardProps, ButtonProps } from '@ttoss/ui';
|
|
4
|
-
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
type PlanCardMetadataSlotParameter = {
|
|
7
|
-
name: string;
|
|
8
|
-
value: React.ReactNode;
|
|
9
|
-
};
|
|
10
|
-
type PlanCardMetadataSlotService = {
|
|
11
|
-
label: string;
|
|
12
|
-
icon?: IconType;
|
|
13
|
-
parameters: PlanCardMetadataSlotParameter[];
|
|
14
|
-
id?: string;
|
|
15
|
-
key?: string;
|
|
16
|
-
};
|
|
17
|
-
type PlanCardMetadataSlotVariant = 'default' | 'enterprise';
|
|
18
|
-
interface PlanCardMetadataSlotProps {
|
|
19
|
-
metadata: PlanCardMetadataSlotService[];
|
|
20
|
-
variant?: PlanCardMetadataSlotVariant;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type PlanCardVariant = 'default' | 'enterprise';
|
|
24
|
-
|
|
25
|
-
type PlanCardMetadata = PlanCardMetadataSlotService[];
|
|
26
|
-
type PlanCardPrice = {
|
|
27
|
-
value: string | number;
|
|
28
|
-
interval: string;
|
|
29
|
-
description?: string;
|
|
30
|
-
};
|
|
31
|
-
type PlanCardButtonProps = Omit<ButtonProps, 'children'> & {
|
|
32
|
-
label?: string;
|
|
33
|
-
leftIcon?: IconType;
|
|
34
|
-
};
|
|
35
|
-
interface PlanCardProps extends Omit<CardProps, 'children'> {
|
|
36
|
-
variant?: PlanCardVariant;
|
|
37
|
-
topTag?: React.ReactNode;
|
|
38
|
-
title: string;
|
|
39
|
-
subtitle?: string;
|
|
40
|
-
metadata?: PlanCardMetadata;
|
|
41
|
-
metadataVariant?: PlanCardMetadataSlotVariant;
|
|
42
|
-
price: PlanCardPrice;
|
|
43
|
-
features?: unknown[];
|
|
44
|
-
buttonProps?: PlanCardButtonProps;
|
|
45
|
-
}
|
|
46
|
-
declare const PlanCard: (props: PlanCardProps) => react_jsx_runtime.JSX.Element;
|
|
47
|
-
|
|
48
|
-
export { PlanCard, type PlanCardButtonProps, type PlanCardMetadata, type PlanCardMetadataSlotParameter, type PlanCardMetadataSlotProps, type PlanCardMetadataSlotService, type PlanCardMetadataSlotVariant, type PlanCardPrice, type PlanCardProps, type PlanCardVariant };
|