@ttoss/react-billing 0.5.12 → 0.5.13
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/index.cjs +834 -0
- package/dist/index.d.cts +459 -0
- package/dist/index.d.mts +459 -0
- package/dist/index.mjs +801 -0
- package/package.json +9 -9
- package/dist/esm/index.js +0 -710
- package/dist/index.d.ts +0 -434
package/dist/esm/index.js
DELETED
|
@@ -1,710 +0,0 @@
|
|
|
1
|
-
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
-
value,
|
|
6
|
-
configurable: true
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
// src/components/planCard/PlanCard.tsx
|
|
10
|
-
import { Box as Box4, Card } from "@ttoss/ui";
|
|
11
|
-
|
|
12
|
-
// src/components/planCard/PlanCardCtaSlot.tsx
|
|
13
|
-
import { Button, Flex } from "@ttoss/ui";
|
|
14
|
-
var PlanCardCtaSlot = /* @__PURE__ */__name(({
|
|
15
|
-
buttonProps
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
label: ctaLabel = "Assine agora",
|
|
19
|
-
sx: buttonSx,
|
|
20
|
-
leftIcon,
|
|
21
|
-
variant: buttonVariant,
|
|
22
|
-
...restButtonProps
|
|
23
|
-
} = buttonProps ?? {};
|
|
24
|
-
return /* @__PURE__ */React.createElement(Flex, {
|
|
25
|
-
sx: {
|
|
26
|
-
marginTop: "auto",
|
|
27
|
-
paddingY: "2",
|
|
28
|
-
paddingX: "6",
|
|
29
|
-
width: "full",
|
|
30
|
-
justifyContent: "center"
|
|
31
|
-
}
|
|
32
|
-
}, /* @__PURE__ */React.createElement(Button, {
|
|
33
|
-
...restButtonProps,
|
|
34
|
-
variant: buttonVariant ?? "accent",
|
|
35
|
-
leftIcon,
|
|
36
|
-
sx: {
|
|
37
|
-
width: "full",
|
|
38
|
-
justifyContent: "center",
|
|
39
|
-
fontWeight: "semibold",
|
|
40
|
-
...buttonSx
|
|
41
|
-
}
|
|
42
|
-
}, ctaLabel));
|
|
43
|
-
}, "PlanCardCtaSlot");
|
|
44
|
-
|
|
45
|
-
// src/components/planCard/PlanCardFeaturesSlot.tsx
|
|
46
|
-
import { Icon } from "@ttoss/react-icons";
|
|
47
|
-
import { Box, Flex as Flex2, Stack, Text } from "@ttoss/ui";
|
|
48
|
-
import * as React2 from "react";
|
|
49
|
-
|
|
50
|
-
// src/components/planCard/PlanCardVariants.ts
|
|
51
|
-
var normalizeVariant = /* @__PURE__ */__name(variantType => {
|
|
52
|
-
if (variantType === "default") return "primary";
|
|
53
|
-
if (variantType === "enterprise") return "secondary";
|
|
54
|
-
return variantType ?? "primary";
|
|
55
|
-
}, "normalizeVariant");
|
|
56
|
-
var getPlanCardVariantStyles = /* @__PURE__ */__name(variantType => {
|
|
57
|
-
const variant = normalizeVariant(variantType);
|
|
58
|
-
const variants = {
|
|
59
|
-
primary: {
|
|
60
|
-
// Primary is the default PlanCard styling (previously `muted`).
|
|
61
|
-
backgroundColor: "display.background.primary.default",
|
|
62
|
-
color: "display.text.primary.default",
|
|
63
|
-
secondaryColor: "display.text.secondary.default",
|
|
64
|
-
borderColor: "display.border.muted.default",
|
|
65
|
-
positiveColor: "feedback.text.positive.default"
|
|
66
|
-
},
|
|
67
|
-
secondary: {
|
|
68
|
-
// Secondary matches the old `enterprise` look.
|
|
69
|
-
backgroundColor: "display.background.primary.active",
|
|
70
|
-
color: "action.text.primary.default",
|
|
71
|
-
secondaryColor: "action.text.primary.default",
|
|
72
|
-
borderColor: "display.border.muted.default",
|
|
73
|
-
positiveColor: "action.text.primary.default"
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
return variants[variant] ?? variants.primary;
|
|
77
|
-
}, "getPlanCardVariantStyles");
|
|
78
|
-
|
|
79
|
-
// src/components/planCard/PlanCardFeaturesSlot.tsx
|
|
80
|
-
var featuresTitle = "RECURSOS";
|
|
81
|
-
var PlanCardFeaturesSlot = /* @__PURE__ */__name(({
|
|
82
|
-
features,
|
|
83
|
-
variant = "primary"
|
|
84
|
-
}) => {
|
|
85
|
-
const variantStyles = getPlanCardVariantStyles(variant);
|
|
86
|
-
const featurePositiveColor = variantStyles.positiveColor;
|
|
87
|
-
return /* @__PURE__ */React2.createElement(Box, {
|
|
88
|
-
sx: {
|
|
89
|
-
paddingY: "4",
|
|
90
|
-
paddingX: "6",
|
|
91
|
-
width: "full",
|
|
92
|
-
borderTop: "md",
|
|
93
|
-
borderBottom: "md",
|
|
94
|
-
borderColor: "display.border.muted.default"
|
|
95
|
-
}
|
|
96
|
-
}, /* @__PURE__ */React2.createElement(Stack, {
|
|
97
|
-
sx: {
|
|
98
|
-
gap: "5",
|
|
99
|
-
paddingY: "3"
|
|
100
|
-
}
|
|
101
|
-
}, /* @__PURE__ */React2.createElement(Flex2, {
|
|
102
|
-
sx: {
|
|
103
|
-
letterSpacing: "widest",
|
|
104
|
-
color: variantStyles.color
|
|
105
|
-
}
|
|
106
|
-
}, featuresTitle), /* @__PURE__ */React2.createElement(Flex2, {
|
|
107
|
-
sx: {
|
|
108
|
-
flexDirection: "column",
|
|
109
|
-
gap: "3"
|
|
110
|
-
}
|
|
111
|
-
}, features.map((feature, index) => {
|
|
112
|
-
if (/* @__PURE__ */React2.isValidElement(feature)) {
|
|
113
|
-
return /* @__PURE__ */React2.createElement(React2.Fragment, {
|
|
114
|
-
key: index
|
|
115
|
-
}, feature);
|
|
116
|
-
}
|
|
117
|
-
return /* @__PURE__ */React2.createElement(Flex2, {
|
|
118
|
-
key: index,
|
|
119
|
-
sx: {
|
|
120
|
-
fontSize: "sm",
|
|
121
|
-
color: featurePositiveColor,
|
|
122
|
-
alignItems: "center",
|
|
123
|
-
gap: "3"
|
|
124
|
-
}
|
|
125
|
-
}, /* @__PURE__ */React2.createElement(Icon, {
|
|
126
|
-
icon: "fluent:checkmark-24-filled"
|
|
127
|
-
}), /* @__PURE__ */React2.createElement(Text, {
|
|
128
|
-
sx: {
|
|
129
|
-
fontSize: "sm",
|
|
130
|
-
color: featurePositiveColor,
|
|
131
|
-
alignItems: "center"
|
|
132
|
-
}
|
|
133
|
-
}, String(feature)));
|
|
134
|
-
}))));
|
|
135
|
-
}, "PlanCardFeaturesSlot");
|
|
136
|
-
|
|
137
|
-
// src/components/planCard/PlanCardHeaderSlot.tsx
|
|
138
|
-
import { Box as Box2, Flex as Flex3, Heading, Text as Text2 } from "@ttoss/ui";
|
|
139
|
-
var PlanCardHeaderSlot = /* @__PURE__ */__name(({
|
|
140
|
-
title,
|
|
141
|
-
subtitle,
|
|
142
|
-
hasTopTag,
|
|
143
|
-
variant = "primary"
|
|
144
|
-
}) => {
|
|
145
|
-
const variantStyles = getPlanCardVariantStyles(variant);
|
|
146
|
-
return /* @__PURE__ */React.createElement(Box2, {
|
|
147
|
-
sx: {
|
|
148
|
-
paddingY: hasTopTag ? "4" : "8",
|
|
149
|
-
paddingX: "8",
|
|
150
|
-
width: "full"
|
|
151
|
-
}
|
|
152
|
-
}, /* @__PURE__ */React.createElement(Flex3, {
|
|
153
|
-
sx: {
|
|
154
|
-
flexDirection: "column",
|
|
155
|
-
gap: "2",
|
|
156
|
-
width: "full",
|
|
157
|
-
alignItems: "center"
|
|
158
|
-
}
|
|
159
|
-
}, /* @__PURE__ */React.createElement(Heading, {
|
|
160
|
-
sx: {
|
|
161
|
-
fontSize: "3xl",
|
|
162
|
-
color: variantStyles.color
|
|
163
|
-
}
|
|
164
|
-
}, title), subtitle && /* @__PURE__ */React.createElement(Text2, {
|
|
165
|
-
sx: {
|
|
166
|
-
fontSize: "sm",
|
|
167
|
-
color: variantStyles.secondaryColor
|
|
168
|
-
}
|
|
169
|
-
}, subtitle)));
|
|
170
|
-
}, "PlanCardHeaderSlot");
|
|
171
|
-
|
|
172
|
-
// src/components/planCard/PlanCardMetadataSlot.tsx
|
|
173
|
-
import { Icon as Icon2 } from "@ttoss/react-icons";
|
|
174
|
-
import { Flex as Flex4, Stack as Stack2, Text as Text3 } from "@ttoss/ui";
|
|
175
|
-
var PlanCardMetadataSlot = /* @__PURE__ */__name(({
|
|
176
|
-
metadata,
|
|
177
|
-
variant = "primary"
|
|
178
|
-
}) => {
|
|
179
|
-
const variantStyles = getPlanCardVariantStyles(variant);
|
|
180
|
-
return /* @__PURE__ */React.createElement(Stack2, {
|
|
181
|
-
sx: {
|
|
182
|
-
width: "full",
|
|
183
|
-
gap: "6"
|
|
184
|
-
}
|
|
185
|
-
}, metadata.map(service => {
|
|
186
|
-
const serviceKey = service.id ?? service.key ?? service.label;
|
|
187
|
-
return /* @__PURE__ */React.createElement(Flex4, {
|
|
188
|
-
key: serviceKey,
|
|
189
|
-
sx: {
|
|
190
|
-
gap: "3",
|
|
191
|
-
flexDirection: "column",
|
|
192
|
-
width: "full"
|
|
193
|
-
}
|
|
194
|
-
}, /* @__PURE__ */React.createElement(Flex4, {
|
|
195
|
-
sx: {
|
|
196
|
-
gap: "4",
|
|
197
|
-
alignItems: "center",
|
|
198
|
-
color: variantStyles.secondaryColor,
|
|
199
|
-
width: "full"
|
|
200
|
-
}
|
|
201
|
-
}, service.icon && /* @__PURE__ */React.createElement(Icon2, {
|
|
202
|
-
icon: service.icon
|
|
203
|
-
}), /* @__PURE__ */React.createElement(Text3, {
|
|
204
|
-
sx: {
|
|
205
|
-
color: variantStyles.secondaryColor
|
|
206
|
-
}
|
|
207
|
-
}, service.label + String.fromCharCode(58))), service.parameters.map(parameter => {
|
|
208
|
-
return /* @__PURE__ */React.createElement(Flex4, {
|
|
209
|
-
key: parameter.name,
|
|
210
|
-
sx: {
|
|
211
|
-
paddingX: "6",
|
|
212
|
-
paddingY: "4",
|
|
213
|
-
backgroundColor: "display.background.muted.default",
|
|
214
|
-
borderRadius: "lg",
|
|
215
|
-
width: "full"
|
|
216
|
-
}
|
|
217
|
-
}, /* @__PURE__ */React.createElement(Flex4, {
|
|
218
|
-
sx: {
|
|
219
|
-
width: "full",
|
|
220
|
-
display: "flex",
|
|
221
|
-
alignItems: "center",
|
|
222
|
-
justifyContent: "space-between",
|
|
223
|
-
gap: "2"
|
|
224
|
-
}
|
|
225
|
-
}, /* @__PURE__ */React.createElement(Text3, {
|
|
226
|
-
sx: {
|
|
227
|
-
fontSize: "sm",
|
|
228
|
-
textAlign: "center"
|
|
229
|
-
}
|
|
230
|
-
}, parameter.name), /* @__PURE__ */React.createElement(Text3, {
|
|
231
|
-
sx: {
|
|
232
|
-
fontWeight: "semibold",
|
|
233
|
-
fontSize: "lg"
|
|
234
|
-
}
|
|
235
|
-
}, parameter.value)));
|
|
236
|
-
}));
|
|
237
|
-
}));
|
|
238
|
-
}, "PlanCardMetadataSlot");
|
|
239
|
-
|
|
240
|
-
// src/components/planCard/PlanCardPriceSlot.tsx
|
|
241
|
-
import { Flex as Flex5, Text as Text4 } from "@ttoss/ui";
|
|
242
|
-
var PlanCardPriceSlot = /* @__PURE__ */__name(({
|
|
243
|
-
price,
|
|
244
|
-
variant = "primary"
|
|
245
|
-
}) => {
|
|
246
|
-
const variantStyles = getPlanCardVariantStyles(variant);
|
|
247
|
-
return /* @__PURE__ */React.createElement(Flex5, {
|
|
248
|
-
sx: {
|
|
249
|
-
paddingY: "6",
|
|
250
|
-
paddingX: "8",
|
|
251
|
-
width: "full",
|
|
252
|
-
alignItems: "center",
|
|
253
|
-
flexDirection: "column",
|
|
254
|
-
gap: "3"
|
|
255
|
-
}
|
|
256
|
-
}, /* @__PURE__ */React.createElement(Flex5, {
|
|
257
|
-
sx: {
|
|
258
|
-
alignItems: "baseline",
|
|
259
|
-
gap: "4",
|
|
260
|
-
justifyContent: "center"
|
|
261
|
-
}
|
|
262
|
-
}, /* @__PURE__ */React.createElement(Text4, {
|
|
263
|
-
sx: {
|
|
264
|
-
fontSize: "4xl",
|
|
265
|
-
fontWeight: "bold",
|
|
266
|
-
color: variantStyles.color
|
|
267
|
-
}
|
|
268
|
-
}, price.value), /* @__PURE__ */React.createElement(Text4, {
|
|
269
|
-
sx: {
|
|
270
|
-
fontSize: "sm",
|
|
271
|
-
color: variantStyles.secondaryColor
|
|
272
|
-
}
|
|
273
|
-
}, price.interval)), price.description && /* @__PURE__ */React.createElement(Text4, {
|
|
274
|
-
sx: {
|
|
275
|
-
fontSize: "md",
|
|
276
|
-
color: variantStyles.secondaryColor
|
|
277
|
-
}
|
|
278
|
-
}, price.description));
|
|
279
|
-
}, "PlanCardPriceSlot");
|
|
280
|
-
|
|
281
|
-
// src/components/planCard/PlanCardTopTagSlot.tsx
|
|
282
|
-
import { Box as Box3 } from "@ttoss/ui";
|
|
283
|
-
var PlanCardTopTagSlot = /* @__PURE__ */__name(({
|
|
284
|
-
children
|
|
285
|
-
}) => {
|
|
286
|
-
return /* @__PURE__ */React.createElement(Box3, {
|
|
287
|
-
sx: {
|
|
288
|
-
padding: "4"
|
|
289
|
-
}
|
|
290
|
-
}, children);
|
|
291
|
-
}, "PlanCardTopTagSlot");
|
|
292
|
-
|
|
293
|
-
// src/components/planCard/PlanCard.tsx
|
|
294
|
-
var PlanCard = /* @__PURE__ */__name(props => {
|
|
295
|
-
const {
|
|
296
|
-
variant = "primary",
|
|
297
|
-
topTag,
|
|
298
|
-
title,
|
|
299
|
-
subtitle,
|
|
300
|
-
metadata = [],
|
|
301
|
-
metadataVariant,
|
|
302
|
-
price,
|
|
303
|
-
features = [],
|
|
304
|
-
buttonProps,
|
|
305
|
-
...cardProps
|
|
306
|
-
} = props;
|
|
307
|
-
const effectiveMetadataVariant = metadataVariant ?? variant;
|
|
308
|
-
const variantStyles = getPlanCardVariantStyles(variant);
|
|
309
|
-
return /* @__PURE__ */React.createElement(Card, {
|
|
310
|
-
...cardProps,
|
|
311
|
-
sx: {
|
|
312
|
-
display: "flex",
|
|
313
|
-
flexDirection: "column",
|
|
314
|
-
width: "full",
|
|
315
|
-
maxWidth: "410px",
|
|
316
|
-
backgroundColor: variantStyles.backgroundColor,
|
|
317
|
-
borderColor: variantStyles.borderColor,
|
|
318
|
-
...cardProps.sx
|
|
319
|
-
}
|
|
320
|
-
}, topTag && /* @__PURE__ */React.createElement(PlanCardTopTagSlot, {
|
|
321
|
-
variant
|
|
322
|
-
}, topTag), /* @__PURE__ */React.createElement(PlanCardHeaderSlot, {
|
|
323
|
-
title,
|
|
324
|
-
subtitle,
|
|
325
|
-
hasTopTag: Boolean(topTag),
|
|
326
|
-
variant
|
|
327
|
-
}), metadata.length > 0 && /* @__PURE__ */React.createElement(Box4, {
|
|
328
|
-
sx: {
|
|
329
|
-
paddingY: "4",
|
|
330
|
-
paddingX: "8",
|
|
331
|
-
width: "full"
|
|
332
|
-
}
|
|
333
|
-
}, /* @__PURE__ */React.createElement(PlanCardMetadataSlot, {
|
|
334
|
-
metadata,
|
|
335
|
-
variant: effectiveMetadataVariant
|
|
336
|
-
})), /* @__PURE__ */React.createElement(PlanCardPriceSlot, {
|
|
337
|
-
price,
|
|
338
|
-
variant
|
|
339
|
-
}), features.length > 0 && /* @__PURE__ */React.createElement(PlanCardFeaturesSlot, {
|
|
340
|
-
features,
|
|
341
|
-
variant
|
|
342
|
-
}), /* @__PURE__ */React.createElement(PlanCardCtaSlot, {
|
|
343
|
-
buttonProps,
|
|
344
|
-
variant
|
|
345
|
-
}));
|
|
346
|
-
}, "PlanCard");
|
|
347
|
-
|
|
348
|
-
// src/components/plansPanel/PlansPanel.tsx
|
|
349
|
-
import { Flex as Flex6, SegmentedControl, Stack as Stack3, Text as Text5 } from "@ttoss/ui";
|
|
350
|
-
import * as React3 from "react";
|
|
351
|
-
var PlansPanel = /* @__PURE__ */__name(({
|
|
352
|
-
filters = [],
|
|
353
|
-
plans,
|
|
354
|
-
activePlanId,
|
|
355
|
-
onSelectPlan,
|
|
356
|
-
filterValues: controlledFilterValues,
|
|
357
|
-
onFilterChange
|
|
358
|
-
}) => {
|
|
359
|
-
const [internalFilterValues, setInternalFilterValues] = React3.useState(() => {
|
|
360
|
-
const initial = {};
|
|
361
|
-
for (const filter of filters) {
|
|
362
|
-
if (filter.defaultValue !== void 0) {
|
|
363
|
-
initial[filter.id] = filter.defaultValue;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
return initial;
|
|
367
|
-
});
|
|
368
|
-
const isControlled = controlledFilterValues !== void 0;
|
|
369
|
-
const activeFilterValues = isControlled ? controlledFilterValues : internalFilterValues;
|
|
370
|
-
const handleFilterChange = /* @__PURE__ */__name((id, value) => {
|
|
371
|
-
const strValue = String(value);
|
|
372
|
-
if (isControlled) {
|
|
373
|
-
onFilterChange?.(id, strValue);
|
|
374
|
-
} else {
|
|
375
|
-
setInternalFilterValues(prev => {
|
|
376
|
-
return {
|
|
377
|
-
...prev,
|
|
378
|
-
[id]: strValue
|
|
379
|
-
};
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
}, "handleFilterChange");
|
|
383
|
-
const visiblePlans = plans.filter(plan => {
|
|
384
|
-
if (!plan.filterValues || Object.keys(plan.filterValues).length === 0) {
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
return Object.entries(activeFilterValues).every(([filterId, filterValue]) => {
|
|
388
|
-
if (!plan.filterValues || !(filterId in plan.filterValues)) {
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
return plan.filterValues[filterId] === filterValue;
|
|
392
|
-
});
|
|
393
|
-
});
|
|
394
|
-
return /* @__PURE__ */React3.createElement(Stack3, {
|
|
395
|
-
sx: {
|
|
396
|
-
gap: "6",
|
|
397
|
-
width: "full",
|
|
398
|
-
alignItems: "center"
|
|
399
|
-
}
|
|
400
|
-
}, filters.length > 0 && /* @__PURE__ */React3.createElement(Stack3, {
|
|
401
|
-
sx: {
|
|
402
|
-
gap: "4",
|
|
403
|
-
alignItems: "center"
|
|
404
|
-
}
|
|
405
|
-
}, filters.map(filter => {
|
|
406
|
-
return /* @__PURE__ */React3.createElement(Stack3, {
|
|
407
|
-
key: filter.id,
|
|
408
|
-
sx: {
|
|
409
|
-
gap: "2",
|
|
410
|
-
alignItems: "center"
|
|
411
|
-
}
|
|
412
|
-
}, filter.label && /* @__PURE__ */React3.createElement(Text5, {
|
|
413
|
-
sx: {
|
|
414
|
-
fontWeight: "semibold",
|
|
415
|
-
color: "display.text.primary.default"
|
|
416
|
-
}
|
|
417
|
-
}, filter.label), /* @__PURE__ */React3.createElement(SegmentedControl, {
|
|
418
|
-
options: filter.options,
|
|
419
|
-
value: isControlled ? controlledFilterValues[filter.id] ?? filter.defaultValue : activeFilterValues[filter.id],
|
|
420
|
-
defaultValue: isControlled ? void 0 : filter.defaultValue,
|
|
421
|
-
onChange: /* @__PURE__ */__name(value => {
|
|
422
|
-
return handleFilterChange(filter.id, value);
|
|
423
|
-
}, "onChange")
|
|
424
|
-
}));
|
|
425
|
-
})), /* @__PURE__ */React3.createElement(Flex6, {
|
|
426
|
-
sx: {
|
|
427
|
-
flexWrap: "wrap",
|
|
428
|
-
gap: "4",
|
|
429
|
-
width: "full",
|
|
430
|
-
justifyContent: "center"
|
|
431
|
-
}
|
|
432
|
-
}, visiblePlans.map(plan => {
|
|
433
|
-
const isActive = plan.id === activePlanId;
|
|
434
|
-
const effectiveVariant = isActive ? "secondary" : plan.variant ?? "primary";
|
|
435
|
-
return /* @__PURE__ */React3.createElement(PlanCard, {
|
|
436
|
-
key: plan.id,
|
|
437
|
-
title: plan.title,
|
|
438
|
-
subtitle: plan.subtitle,
|
|
439
|
-
price: plan.price,
|
|
440
|
-
features: plan.features,
|
|
441
|
-
metadata: plan.metadata,
|
|
442
|
-
variant: effectiveVariant,
|
|
443
|
-
topTag: plan.topTag,
|
|
444
|
-
buttonProps: {
|
|
445
|
-
...plan.buttonProps,
|
|
446
|
-
onClick: /* @__PURE__ */__name(e => {
|
|
447
|
-
onSelectPlan?.(plan.id);
|
|
448
|
-
plan.buttonProps?.onClick?.(e);
|
|
449
|
-
}, "onClick")
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
})));
|
|
453
|
-
}, "PlansPanel");
|
|
454
|
-
|
|
455
|
-
// src/components/subscriptionPanel/SubscriptionPanel.tsx
|
|
456
|
-
import { EnhancedTitle } from "@ttoss/components/EnhancedTitle";
|
|
457
|
-
import { MetricCard } from "@ttoss/components/MetricCard";
|
|
458
|
-
import { Card as Card2, Flex as Flex8, Spinner } from "@ttoss/ui";
|
|
459
|
-
|
|
460
|
-
// src/components/subscriptionPanel/SubscriptionPanel.styles.ts
|
|
461
|
-
import { keyframes } from "@ttoss/ui";
|
|
462
|
-
var gradientFlow = keyframes({
|
|
463
|
-
"0%": {
|
|
464
|
-
backgroundPosition: "0% 50%"
|
|
465
|
-
},
|
|
466
|
-
"50%": {
|
|
467
|
-
backgroundPosition: "100% 50%"
|
|
468
|
-
},
|
|
469
|
-
"100%": {
|
|
470
|
-
backgroundPosition: "0% 50%"
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
var getAccentGradientBackground = /* @__PURE__ */__name(t => {
|
|
474
|
-
const theme = t;
|
|
475
|
-
const start = theme.colors?.action?.background?.accent?.default || theme.colors?.input?.background?.accent?.default;
|
|
476
|
-
if (!start) return void 0;
|
|
477
|
-
const middle = theme.colors?.action?.background?.accent?.active || theme.colors?.input?.background?.accent?.active || start;
|
|
478
|
-
return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
|
|
479
|
-
}, "getAccentGradientBackground");
|
|
480
|
-
var getPrimaryGradientBackground = /* @__PURE__ */__name(t => {
|
|
481
|
-
const theme = t;
|
|
482
|
-
const start = theme.colors?.action?.background?.primary?.default;
|
|
483
|
-
if (!start) return void 0;
|
|
484
|
-
const middle = theme.colors?.action?.background?.secondary?.default || start;
|
|
485
|
-
return `linear-gradient(270deg, ${start}, ${middle}, ${start})`;
|
|
486
|
-
}, "getPrimaryGradientBackground");
|
|
487
|
-
var getVariantStyles = /* @__PURE__ */__name(variantType => {
|
|
488
|
-
const variants = {
|
|
489
|
-
"spotlight-accent": {
|
|
490
|
-
backgroundColor: "input.background.accent.default",
|
|
491
|
-
color: "action.text.accent.default",
|
|
492
|
-
borderColor: "display.border.muted.default",
|
|
493
|
-
gradientBackground: getAccentGradientBackground
|
|
494
|
-
},
|
|
495
|
-
"spotlight-primary": {
|
|
496
|
-
backgroundColor: "action.background.primary.default",
|
|
497
|
-
color: "display.text.accent.default",
|
|
498
|
-
borderColor: "display.border.muted.default",
|
|
499
|
-
gradientBackground: getPrimaryGradientBackground
|
|
500
|
-
},
|
|
501
|
-
primary: {
|
|
502
|
-
backgroundColor: "action.background.primary.default",
|
|
503
|
-
color: "action.text.primary.default",
|
|
504
|
-
borderColor: "display.border.muted.default",
|
|
505
|
-
gradientBackground: void 0
|
|
506
|
-
},
|
|
507
|
-
secondary: {
|
|
508
|
-
backgroundColor: "action.background.secondary.default",
|
|
509
|
-
color: "action.text.primary.default",
|
|
510
|
-
borderColor: "display.border.muted.default",
|
|
511
|
-
gradientBackground: void 0
|
|
512
|
-
},
|
|
513
|
-
accent: {
|
|
514
|
-
backgroundColor: "action.background.accent.default",
|
|
515
|
-
color: "action.text.accent.default",
|
|
516
|
-
borderColor: "display.border.muted.default",
|
|
517
|
-
gradientBackground: void 0
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
return variants[variantType] || variants["spotlight-accent"];
|
|
521
|
-
}, "getVariantStyles");
|
|
522
|
-
var getSubscriptionPanelAccentBarSx = /* @__PURE__ */__name((variant = "spotlight-accent") => {
|
|
523
|
-
const variantStyles = getVariantStyles(variant);
|
|
524
|
-
const isSpotlight = variant.startsWith("spotlight-");
|
|
525
|
-
const gradientBg = variant === "spotlight-accent" ? getAccentGradientBackground : getPrimaryGradientBackground;
|
|
526
|
-
return {
|
|
527
|
-
height: "12px",
|
|
528
|
-
width: "full",
|
|
529
|
-
borderTopLeftRadius: "lg",
|
|
530
|
-
borderTopRightRadius: "lg",
|
|
531
|
-
backgroundColor: variantStyles.backgroundColor,
|
|
532
|
-
color: variantStyles.color,
|
|
533
|
-
borderColor: variantStyles.borderColor,
|
|
534
|
-
...(isSpotlight ? {
|
|
535
|
-
background: gradientBg,
|
|
536
|
-
backgroundSize: "400% 400%",
|
|
537
|
-
animation: `${gradientFlow} 6s ease infinite`
|
|
538
|
-
} : {})
|
|
539
|
-
};
|
|
540
|
-
}, "getSubscriptionPanelAccentBarSx");
|
|
541
|
-
var SubscriptionPanelAccentBarSx = getSubscriptionPanelAccentBarSx("spotlight-accent");
|
|
542
|
-
|
|
543
|
-
// src/components/subscriptionPanel/SubscriptionPanelActionsSlot.tsx
|
|
544
|
-
import { Icon as Icon3 } from "@ttoss/react-icons";
|
|
545
|
-
import { Button as Button2, Flex as Flex7 } from "@ttoss/ui";
|
|
546
|
-
var SubscriptionPanelActionsSlot = /* @__PURE__ */__name(({
|
|
547
|
-
actions
|
|
548
|
-
}) => {
|
|
549
|
-
if (actions.length === 0) {
|
|
550
|
-
return null;
|
|
551
|
-
}
|
|
552
|
-
return /* @__PURE__ */React.createElement(Flex7, {
|
|
553
|
-
sx: {
|
|
554
|
-
gap: "3",
|
|
555
|
-
flexDirection: ["column", "row"],
|
|
556
|
-
flexShrink: 0,
|
|
557
|
-
paddingX: "6",
|
|
558
|
-
paddingBottom: "6"
|
|
559
|
-
}
|
|
560
|
-
}, actions.map((action, index) => {
|
|
561
|
-
const {
|
|
562
|
-
label,
|
|
563
|
-
onClick,
|
|
564
|
-
leftIcon,
|
|
565
|
-
isLoading,
|
|
566
|
-
variant = "secondary",
|
|
567
|
-
disabled,
|
|
568
|
-
...buttonProps
|
|
569
|
-
} = action;
|
|
570
|
-
return /* @__PURE__ */React.createElement(Button2, {
|
|
571
|
-
key: index,
|
|
572
|
-
onClick,
|
|
573
|
-
variant,
|
|
574
|
-
disabled: disabled || isLoading,
|
|
575
|
-
leftIcon: isLoading ? void 0 : leftIcon,
|
|
576
|
-
sx: {
|
|
577
|
-
gap: "2",
|
|
578
|
-
justifyContent: "center",
|
|
579
|
-
minWidth: "fit-content"
|
|
580
|
-
},
|
|
581
|
-
...buttonProps
|
|
582
|
-
}, isLoading ? /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement(Icon3, {
|
|
583
|
-
icon: "fluent:spinner-ios-20-regular"
|
|
584
|
-
}), "Processando...") : label);
|
|
585
|
-
}));
|
|
586
|
-
}, "SubscriptionPanelActionsSlot");
|
|
587
|
-
|
|
588
|
-
// src/components/subscriptionPanel/SubscriptionPanel.tsx
|
|
589
|
-
var renderMetricCard = /* @__PURE__ */__name(params => {
|
|
590
|
-
const {
|
|
591
|
-
metric,
|
|
592
|
-
index,
|
|
593
|
-
isLoading
|
|
594
|
-
} = params;
|
|
595
|
-
return /* @__PURE__ */React.createElement(MetricCard, {
|
|
596
|
-
key: index,
|
|
597
|
-
metric,
|
|
598
|
-
isLoading
|
|
599
|
-
});
|
|
600
|
-
}, "renderMetricCard");
|
|
601
|
-
var SubscriptionPanel = /* @__PURE__ */__name(({
|
|
602
|
-
variant = "accent",
|
|
603
|
-
icon,
|
|
604
|
-
planName,
|
|
605
|
-
price,
|
|
606
|
-
status,
|
|
607
|
-
features = [],
|
|
608
|
-
actions = [],
|
|
609
|
-
metrics = [],
|
|
610
|
-
isLoading = false
|
|
611
|
-
}) => {
|
|
612
|
-
if (isLoading) {
|
|
613
|
-
return /* @__PURE__ */React.createElement(Card2, {
|
|
614
|
-
sx: {
|
|
615
|
-
width: "full",
|
|
616
|
-
height: "400px",
|
|
617
|
-
alignItems: "center",
|
|
618
|
-
justifyContent: "center"
|
|
619
|
-
}
|
|
620
|
-
}, /* @__PURE__ */React.createElement(Spinner, null));
|
|
621
|
-
}
|
|
622
|
-
return /* @__PURE__ */React.createElement(Card2, {
|
|
623
|
-
sx: {
|
|
624
|
-
width: "full"
|
|
625
|
-
}
|
|
626
|
-
}, /* @__PURE__ */React.createElement(Flex8, {
|
|
627
|
-
sx: getSubscriptionPanelAccentBarSx(variant)
|
|
628
|
-
}), /* @__PURE__ */React.createElement(Flex8, {
|
|
629
|
-
sx: {
|
|
630
|
-
width: "full",
|
|
631
|
-
paddingX: "6",
|
|
632
|
-
paddingY: "6",
|
|
633
|
-
flexDirection: "column"
|
|
634
|
-
}
|
|
635
|
-
}, /* @__PURE__ */React.createElement(Flex8, {
|
|
636
|
-
sx: {
|
|
637
|
-
paddingY: "10",
|
|
638
|
-
paddingX: "3",
|
|
639
|
-
width: "full",
|
|
640
|
-
flexDirection: ["column", "column", "row"],
|
|
641
|
-
alignItems: ["stretch", "stretch", "center"],
|
|
642
|
-
justifyContent: "space-between",
|
|
643
|
-
gap: "6",
|
|
644
|
-
borderBottom: "sm",
|
|
645
|
-
borderBottomColor: "display.border.muted.default"
|
|
646
|
-
}
|
|
647
|
-
}, /* @__PURE__ */React.createElement(EnhancedTitle, {
|
|
648
|
-
variant,
|
|
649
|
-
icon,
|
|
650
|
-
title: planName,
|
|
651
|
-
frontTitle: price.interval ? `${price.value}/${price.interval}` : price.value,
|
|
652
|
-
topBadges: [
|
|
653
|
-
// Status badge
|
|
654
|
-
...(status.status === "active" ? [{
|
|
655
|
-
label: "Ativo",
|
|
656
|
-
variant: "positive",
|
|
657
|
-
icon: "fluent:checkmark-circle-24-filled"
|
|
658
|
-
}] : status.status === "inactive" ? [{
|
|
659
|
-
label: "Inativo",
|
|
660
|
-
variant: "muted",
|
|
661
|
-
icon: "fluent:dismiss-circle-24-filled"
|
|
662
|
-
}] : [{
|
|
663
|
-
label: "Cancelado",
|
|
664
|
-
variant: "negative",
|
|
665
|
-
icon: "fluent:error-circle-24-filled"
|
|
666
|
-
}]),
|
|
667
|
-
// Interval badge
|
|
668
|
-
...(status.interval ? [{
|
|
669
|
-
label: status.interval,
|
|
670
|
-
variant: "informative"
|
|
671
|
-
}] : []),
|
|
672
|
-
// Scheduled update badge
|
|
673
|
-
...(status.hasScheduledUpdate ? [{
|
|
674
|
-
label: "Altera\xE7\xE3o Agendada",
|
|
675
|
-
variant: "informative",
|
|
676
|
-
icon: "fluent:clock-24-regular"
|
|
677
|
-
}] : []),
|
|
678
|
-
// Cancellation badge
|
|
679
|
-
...(status.hasCancellation ? [{
|
|
680
|
-
label: "Renova\xE7\xE3o Cancelada",
|
|
681
|
-
variant: "negative",
|
|
682
|
-
icon: "fluent:dismiss-circle-24-regular"
|
|
683
|
-
}] : [])],
|
|
684
|
-
bottomBadges: features.map(feature => {
|
|
685
|
-
return {
|
|
686
|
-
label: feature.label,
|
|
687
|
-
icon: typeof feature.icon === "string" ? feature.icon : "fluent:checkmark-24-filled",
|
|
688
|
-
variant: "muted"
|
|
689
|
-
};
|
|
690
|
-
})
|
|
691
|
-
}), actions.length > 0 && /* @__PURE__ */React.createElement(SubscriptionPanelActionsSlot, {
|
|
692
|
-
actions
|
|
693
|
-
})), metrics.length > 0 && /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement(Flex8, {
|
|
694
|
-
sx: {
|
|
695
|
-
paddingY: "10",
|
|
696
|
-
paddingX: "3",
|
|
697
|
-
width: "full",
|
|
698
|
-
flexWrap: "wrap",
|
|
699
|
-
gap: "10",
|
|
700
|
-
justifyContent: "center"
|
|
701
|
-
}
|
|
702
|
-
}, metrics.map((metric, index) => {
|
|
703
|
-
return renderMetricCard({
|
|
704
|
-
metric,
|
|
705
|
-
index,
|
|
706
|
-
isLoading
|
|
707
|
-
});
|
|
708
|
-
})))));
|
|
709
|
-
}, "SubscriptionPanel");
|
|
710
|
-
export { PlanCard, PlansPanel, SubscriptionPanel };
|