@mcp-b/react-components 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.
Files changed (203) hide show
  1. package/dist/Button-QCM8ZKgR.d.ts +98 -0
  2. package/dist/CodeBlock-CttHhWcb.js +356 -0
  3. package/dist/CodeBlock-V6pgafSS.d.ts +174 -0
  4. package/dist/Select-CRsKCJ9x.d.ts +200 -0
  5. package/dist/class-names-9UtZwb0J.js +12 -0
  6. package/dist/components/Accordion.d.ts +81 -0
  7. package/dist/components/Accordion.js +97 -0
  8. package/dist/components/AgentConnection.d.ts +69 -0
  9. package/dist/components/AgentConnection.js +176 -0
  10. package/dist/components/AlertDialog.d.ts +148 -0
  11. package/dist/components/AlertDialog.js +141 -0
  12. package/dist/components/Artifact.d.ts +128 -0
  13. package/dist/components/Artifact.js +115 -0
  14. package/dist/components/Autocomplete.d.ts +186 -0
  15. package/dist/components/Autocomplete.js +186 -0
  16. package/dist/components/Avatar.d.ts +134 -0
  17. package/dist/components/Avatar.js +118 -0
  18. package/dist/components/Badge.d.ts +68 -0
  19. package/dist/components/Badge.js +108 -0
  20. package/dist/components/Button.d.ts +2 -0
  21. package/dist/components/Button.js +73 -0
  22. package/dist/components/Card.d.ts +87 -0
  23. package/dist/components/Card.js +81 -0
  24. package/dist/components/ChainOfThought.d.ts +153 -0
  25. package/dist/components/ChainOfThought.js +157 -0
  26. package/dist/components/Checkbox.d.ts +35 -0
  27. package/dist/components/Checkbox.js +47 -0
  28. package/dist/components/CheckboxGroup.d.ts +76 -0
  29. package/dist/components/CheckboxGroup.js +69 -0
  30. package/dist/components/CodeBlock.d.ts +2 -0
  31. package/dist/components/CodeBlock.js +2 -0
  32. package/dist/components/Collapsible.d.ts +127 -0
  33. package/dist/components/Collapsible.js +103 -0
  34. package/dist/components/Combobox.d.ts +177 -0
  35. package/dist/components/Combobox.js +179 -0
  36. package/dist/components/Commit.d.ts +265 -0
  37. package/dist/components/Commit.js +282 -0
  38. package/dist/components/Context.d.ts +129 -0
  39. package/dist/components/Context.js +309 -0
  40. package/dist/components/ContextMenu.d.ts +282 -0
  41. package/dist/components/ContextMenu.js +270 -0
  42. package/dist/components/Conversation.d.ts +166 -0
  43. package/dist/components/Conversation.js +202 -0
  44. package/dist/components/Dialog.d.ts +120 -0
  45. package/dist/components/Dialog.js +114 -0
  46. package/dist/components/EnvironmentVariables.d.ts +176 -0
  47. package/dist/components/EnvironmentVariables.js +221 -0
  48. package/dist/components/Field.d.ts +281 -0
  49. package/dist/components/Field.js +274 -0
  50. package/dist/components/Fieldset.d.ts +93 -0
  51. package/dist/components/Fieldset.js +81 -0
  52. package/dist/components/FileTree.d.ts +116 -0
  53. package/dist/components/FileTree.js +310 -0
  54. package/dist/components/Form.d.ts +94 -0
  55. package/dist/components/Form.js +88 -0
  56. package/dist/components/GithubMotionMark.d.ts +13 -0
  57. package/dist/components/GithubMotionMark.js +23 -0
  58. package/dist/components/Input.d.ts +33 -0
  59. package/dist/components/Input.js +27 -0
  60. package/dist/components/Label.d.ts +44 -0
  61. package/dist/components/Label.js +41 -0
  62. package/dist/components/Menu.d.ts +395 -0
  63. package/dist/components/Menu.js +338 -0
  64. package/dist/components/Menubar.d.ts +331 -0
  65. package/dist/components/Menubar.js +299 -0
  66. package/dist/components/Message.d.ts +216 -0
  67. package/dist/components/Message.js +245 -0
  68. package/dist/components/Meter.d.ts +151 -0
  69. package/dist/components/Meter.js +121 -0
  70. package/dist/components/ModelSelector.d.ts +198 -0
  71. package/dist/components/ModelSelector.js +306 -0
  72. package/dist/components/NaniteScene.d.ts +33 -0
  73. package/dist/components/NaniteScene.js +405 -0
  74. package/dist/components/NavigationMenu.d.ts +256 -0
  75. package/dist/components/NavigationMenu.js +228 -0
  76. package/dist/components/NumberField.d.ts +159 -0
  77. package/dist/components/NumberField.js +123 -0
  78. package/dist/components/Popover.d.ts +278 -0
  79. package/dist/components/Popover.js +245 -0
  80. package/dist/components/PreviewCard.d.ts +156 -0
  81. package/dist/components/PreviewCard.js +156 -0
  82. package/dist/components/PricingPage.d.ts +209 -0
  83. package/dist/components/PricingPage.js +506 -0
  84. package/dist/components/Progress.d.ts +58 -0
  85. package/dist/components/Progress.js +51 -0
  86. package/dist/components/PromptInput.d.ts +399 -0
  87. package/dist/components/PromptInput.js +737 -0
  88. package/dist/components/Queue.d.ts +241 -0
  89. package/dist/components/Queue.js +225 -0
  90. package/dist/components/RadioGroup.d.ts +78 -0
  91. package/dist/components/RadioGroup.js +72 -0
  92. package/dist/components/Reasoning.d.ts +88 -0
  93. package/dist/components/Reasoning.js +187 -0
  94. package/dist/components/ScrollArea.d.ts +160 -0
  95. package/dist/components/ScrollArea.js +145 -0
  96. package/dist/components/Select.d.ts +2 -0
  97. package/dist/components/Select.js +260 -0
  98. package/dist/components/Separator.d.ts +45 -0
  99. package/dist/components/Separator.js +40 -0
  100. package/dist/components/Shell.d.ts +163 -0
  101. package/dist/components/Shell.js +137 -0
  102. package/dist/components/Slider.d.ts +120 -0
  103. package/dist/components/Slider.js +115 -0
  104. package/dist/components/Sources.d.ts +91 -0
  105. package/dist/components/Sources.js +121 -0
  106. package/dist/components/Stepper.d.ts +190 -0
  107. package/dist/components/Stepper.js +315 -0
  108. package/dist/components/Switch.d.ts +57 -0
  109. package/dist/components/Switch.js +55 -0
  110. package/dist/components/Tabs.d.ts +84 -0
  111. package/dist/components/Tabs.js +78 -0
  112. package/dist/components/Task.d.ts +100 -0
  113. package/dist/components/Task.js +120 -0
  114. package/dist/components/Terminal.d.ts +118 -0
  115. package/dist/components/Terminal.js +234 -0
  116. package/dist/components/TestResults.d.ts +236 -0
  117. package/dist/components/TestResults.js +346 -0
  118. package/dist/components/Toast.d.ts +192 -0
  119. package/dist/components/Toast.js +163 -0
  120. package/dist/components/Toggle.d.ts +69 -0
  121. package/dist/components/Toggle.js +66 -0
  122. package/dist/components/ToggleGroup.d.ts +69 -0
  123. package/dist/components/ToggleGroup.js +99 -0
  124. package/dist/components/Tool.d.ts +119 -0
  125. package/dist/components/Tool.js +192 -0
  126. package/dist/components/Toolbar.d.ts +162 -0
  127. package/dist/components/Toolbar.js +126 -0
  128. package/dist/components/Tooltip.d.ts +81 -0
  129. package/dist/components/Tooltip.js +74 -0
  130. package/dist/components/WebPreview.d.ts +143 -0
  131. package/dist/components/WebPreview.js +280 -0
  132. package/dist/components/useStickToBottom.d.ts +30 -0
  133. package/dist/components/useStickToBottom.js +95 -0
  134. package/dist/copy-button-BIATcZWZ.d.ts +16 -0
  135. package/dist/copy-button-BNgclDrO.js +43 -0
  136. package/dist/icons-BsWc8g4E.js +221 -0
  137. package/dist/styles/accordion.css +10 -10
  138. package/dist/styles/agent-connection.css +18 -17
  139. package/dist/styles/alert-dialog.css +48 -29
  140. package/dist/styles/artifact.css +10 -10
  141. package/dist/styles/autocomplete.css +25 -24
  142. package/dist/styles/avatar.css +96 -6
  143. package/dist/styles/badge.css +78 -14
  144. package/dist/styles/base.css +9 -9
  145. package/dist/styles/button.css +57 -38
  146. package/dist/styles/card.css +57 -10
  147. package/dist/styles/chain-of-thought.css +47 -33
  148. package/dist/styles/checkbox.css +24 -10
  149. package/dist/styles/code-block.css +22 -15
  150. package/dist/styles/collapsible.css +14 -12
  151. package/dist/styles/combobox.css +26 -25
  152. package/dist/styles/commit.css +49 -24
  153. package/dist/styles/context-menu.css +70 -16
  154. package/dist/styles/context.css +15 -15
  155. package/dist/styles/conversation.css +12 -12
  156. package/dist/styles/dialog.css +52 -16
  157. package/dist/styles/environment-variables.css +19 -19
  158. package/dist/styles/field.css +184 -22
  159. package/dist/styles/fieldset.css +5 -4
  160. package/dist/styles/file-tree.css +17 -17
  161. package/dist/styles/index.css.d.ts +1 -0
  162. package/dist/styles/input.css +45 -11
  163. package/dist/styles/label.css +21 -4
  164. package/dist/styles/menu.css +55 -32
  165. package/dist/styles/menubar.css +80 -28
  166. package/dist/styles/message.css +22 -13
  167. package/dist/styles/meter.css +8 -8
  168. package/dist/styles/model-selector.css +33 -21
  169. package/dist/styles/navigation-menu.css +26 -24
  170. package/dist/styles/number-field.css +20 -18
  171. package/dist/styles/popover.css +38 -28
  172. package/dist/styles/preview-card.css +15 -13
  173. package/dist/styles/pricing-page.css +53 -53
  174. package/dist/styles/progress.css +7 -7
  175. package/dist/styles/prompt-input.css +73 -24
  176. package/dist/styles/queue.css +58 -32
  177. package/dist/styles/radio.css +26 -11
  178. package/dist/styles/reasoning.css +15 -11
  179. package/dist/styles/scroll-area.css +6 -6
  180. package/dist/styles/scrollbars.css +4 -4
  181. package/dist/styles/select.css +84 -25
  182. package/dist/styles/separator.css +1 -1
  183. package/dist/styles/shell.css +21 -20
  184. package/dist/styles/slider.css +35 -11
  185. package/dist/styles/sources.css +20 -20
  186. package/dist/styles/stepper.css +22 -22
  187. package/dist/styles/switch.css +29 -13
  188. package/dist/styles/tabs.css +23 -16
  189. package/dist/styles/task.css +27 -23
  190. package/dist/styles/terminal.css +16 -13
  191. package/dist/styles/test-results.css +79 -32
  192. package/dist/styles/toast.css +26 -25
  193. package/dist/styles/toggle-group.css +12 -12
  194. package/dist/styles/toggle.css +29 -11
  195. package/dist/styles/tool.css +54 -32
  196. package/dist/styles/toolbar.css +30 -28
  197. package/dist/styles/tooltip.css +10 -8
  198. package/dist/styles/web-preview.css +37 -21
  199. package/dist/utils/structured-code.d.ts +10 -0
  200. package/dist/utils/structured-code.js +81 -0
  201. package/package.json +17 -8
  202. package/dist/index.d.ts +0 -7236
  203. package/dist/index.js +0 -8945
@@ -0,0 +1,506 @@
1
+ import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from "./Accordion.js";
2
+ import { Button } from "./Button.js";
3
+ import { Tooltip, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipTrigger } from "./Tooltip.js";
4
+ import { AlertDialog, AlertDialogBackdrop, AlertDialogClose, AlertDialogDescription, AlertDialogPopup, AlertDialogPortal, AlertDialogTitle } from "./AlertDialog.js";
5
+ import { Badge } from "./Badge.js";
6
+ import { Card } from "./Card.js";
7
+ import { Checkbox } from "./Checkbox.js";
8
+ import { Separator } from "./Separator.js";
9
+ import { Switch, SwitchThumb } from "./Switch.js";
10
+ import { Label } from "./Label.js";
11
+ import { ToggleGroup, ToggleGroupItem } from "./ToggleGroup.js";
12
+ import { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack } from "./Slider.js";
13
+ import { Progress, ProgressIndicator, ProgressTrack } from "./Progress.js";
14
+ import * as React from "react";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ //#region src/components/PricingPage.tsx
17
+ const CheckIcon = () => /* @__PURE__ */ jsx("svg", {
18
+ width: "16",
19
+ height: "16",
20
+ viewBox: "0 0 16 16",
21
+ fill: "none",
22
+ xmlns: "http://www.w3.org/2000/svg",
23
+ "aria-hidden": "true",
24
+ focusable: "false",
25
+ children: /* @__PURE__ */ jsx("path", {
26
+ d: "M13.5 4.5L6.5 11.5L3 8",
27
+ stroke: "currentColor",
28
+ strokeWidth: "2",
29
+ strokeLinecap: "round",
30
+ strokeLinejoin: "round"
31
+ })
32
+ });
33
+ const MinusIcon = () => /* @__PURE__ */ jsx("svg", {
34
+ width: "16",
35
+ height: "16",
36
+ viewBox: "0 0 16 16",
37
+ fill: "none",
38
+ xmlns: "http://www.w3.org/2000/svg",
39
+ "aria-hidden": "true",
40
+ focusable: "false",
41
+ children: /* @__PURE__ */ jsx("path", {
42
+ d: "M3 8H13",
43
+ stroke: "currentColor",
44
+ strokeWidth: "2",
45
+ strokeLinecap: "round"
46
+ })
47
+ });
48
+ const InfoIcon = () => /* @__PURE__ */ jsxs("svg", {
49
+ width: "14",
50
+ height: "14",
51
+ viewBox: "0 0 14 14",
52
+ fill: "none",
53
+ xmlns: "http://www.w3.org/2000/svg",
54
+ "aria-hidden": "true",
55
+ focusable: "false",
56
+ children: [/* @__PURE__ */ jsx("circle", {
57
+ cx: "7",
58
+ cy: "7",
59
+ r: "6",
60
+ stroke: "currentColor",
61
+ strokeWidth: "1.5"
62
+ }), /* @__PURE__ */ jsx("path", {
63
+ d: "M7 6V10M7 4.5V4",
64
+ stroke: "currentColor",
65
+ strokeWidth: "1.5",
66
+ strokeLinecap: "round"
67
+ })]
68
+ });
69
+ function getSavings(plan) {
70
+ const yearlyTotal = plan.yearlyPrice * 12;
71
+ return plan.monthlyPrice * 12 - yearlyTotal;
72
+ }
73
+ function formatNumber(num) {
74
+ if (num >= 1e6) return `${(num / 1e6).toFixed(1)}M`;
75
+ if (num >= 1e3) return `${(num / 1e3).toFixed(0)}K`;
76
+ return num.toString();
77
+ }
78
+ /**
79
+ * A comprehensive pricing page component that demonstrates all pricing-related
80
+ * components working together.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <PricingPage
85
+ * title="Choose your plan"
86
+ * subtitle="Start free, upgrade when you need more"
87
+ * plans={[
88
+ * { id: 'free', name: 'Free', ... },
89
+ * { id: 'pro', name: 'Pro', popular: true, ... },
90
+ * { id: 'enterprise', name: 'Enterprise', ... },
91
+ * ]}
92
+ * faq={[
93
+ * { question: 'Can I cancel anytime?', answer: 'Yes...' },
94
+ * ]}
95
+ * onSelectPlan={(planId, period) => console.log(planId, period)}
96
+ * />
97
+ * ```
98
+ */
99
+ function PricingPage({ title = "Simple, transparent pricing", subtitle, plans, faq, showUsageCalculator = false, usageTiers = [], maxUsage = 1e5, usageUnit = "API calls", onSelectPlan, onConfirmUpgrade, className = "", billingToggleVariant, productIds, currentProductId, isSubscribed = false, checkoutUrl = "/api/checkout", switchPlanUrl = "/api/switch-plan", portalUrl = "/api/portal", isLoggedIn = false, loginUrl = "/auth/login", hasPolarAccount = false, onCheckout, onSwitchPlan, onPortalRedirect }) {
100
+ const [billingPeriod, setBillingPeriod] = React.useState("monthly");
101
+ const [useSwitchToggle, setUseSwitchToggle] = React.useState(true);
102
+ const showSwitch = billingToggleVariant ? billingToggleVariant === "switch" : useSwitchToggle;
103
+ const [selectedPlan, setSelectedPlan] = React.useState(null);
104
+ const [confirmDialogOpen, setConfirmDialogOpen] = React.useState(false);
105
+ const [switching, setSwitching] = React.useState(false);
106
+ const [usage, setUsage] = React.useState(5e4);
107
+ const isYearly = billingPeriod === "yearly";
108
+ const getPrice = (plan) => {
109
+ return isYearly ? plan.yearlyPrice : plan.monthlyPrice;
110
+ };
111
+ const yearlySavingsPercent = React.useMemo(() => {
112
+ const paidPlans = plans.filter((p) => p.monthlyPrice > 0);
113
+ if (paidPlans.length === 0) return 0;
114
+ const totalPercent = paidPlans.reduce((sum, plan) => {
115
+ return sum + (plan.monthlyPrice - plan.yearlyPrice) / plan.monthlyPrice * 100;
116
+ }, 0);
117
+ return Math.round(totalPercent / paidPlans.length);
118
+ }, [plans]);
119
+ const isCurrentPlan = (plan) => {
120
+ if (!currentProductId || !productIds) return false;
121
+ const ids = productIds[plan.id];
122
+ if (!ids) return false;
123
+ return ids.monthly === currentProductId || ids.yearly === currentProductId;
124
+ };
125
+ const currentPlan = isSubscribed ? plans.find((p) => isCurrentPlan(p)) : void 0;
126
+ const getSwitchDirection = (target) => {
127
+ if (!currentPlan) return "upgrade";
128
+ const currentPrice = getPrice(currentPlan);
129
+ const targetPrice = getPrice(target);
130
+ if (targetPrice > currentPrice) return "upgrade";
131
+ if (targetPrice < currentPrice) return "downgrade";
132
+ return "switch";
133
+ };
134
+ const getProductIdForPlan = (plan) => {
135
+ if (!productIds) return void 0;
136
+ const ids = productIds[plan.id];
137
+ if (!ids) return void 0;
138
+ return isYearly ? ids.yearly : ids.monthly;
139
+ };
140
+ const doCheckout = async (productId) => {
141
+ if (onCheckout) await onCheckout(productId);
142
+ else window.location.href = `${checkoutUrl}?products=${productId}`;
143
+ };
144
+ const doSwitchPlan = async (productId) => {
145
+ if (onSwitchPlan) return onSwitchPlan(productId);
146
+ return fetch(switchPlanUrl, {
147
+ method: "POST",
148
+ headers: { "Content-Type": "application/json" },
149
+ body: JSON.stringify({ productId })
150
+ });
151
+ };
152
+ const doPortalRedirect = async () => {
153
+ if (onPortalRedirect) await onPortalRedirect();
154
+ else window.location.href = portalUrl;
155
+ };
156
+ const handleSelectPlan = (plan) => {
157
+ if (isCurrentPlan(plan)) return;
158
+ if (!isLoggedIn && plan.monthlyPrice > 0) {
159
+ const productId = getProductIdForPlan(plan);
160
+ const checkoutPath = productId ? `${checkoutUrl}?products=${productId}` : window.location.pathname;
161
+ window.location.href = `${loginUrl}?redirect=${encodeURIComponent(checkoutPath)}`;
162
+ return;
163
+ }
164
+ setSelectedPlan(plan);
165
+ setConfirmDialogOpen(true);
166
+ };
167
+ const handleConfirmUpgrade = async () => {
168
+ if (!selectedPlan) {
169
+ setConfirmDialogOpen(false);
170
+ return;
171
+ }
172
+ onConfirmUpgrade?.(selectedPlan.id, billingPeriod);
173
+ onSelectPlan?.(selectedPlan.id, billingPeriod);
174
+ if (productIds) {
175
+ const productId = getProductIdForPlan(selectedPlan);
176
+ if (!productId) return;
177
+ if (isSubscribed) {
178
+ if (!hasPolarAccount) {
179
+ await doCheckout(productId);
180
+ return;
181
+ }
182
+ setSwitching(true);
183
+ try {
184
+ const res = await doSwitchPlan(productId);
185
+ if (res.ok) {
186
+ window.location.reload();
187
+ return;
188
+ }
189
+ if (res.status === 404) {
190
+ await doCheckout(productId);
191
+ return;
192
+ }
193
+ if (res.status === 409) {
194
+ await doPortalRedirect();
195
+ return;
196
+ }
197
+ } finally {
198
+ setSwitching(false);
199
+ }
200
+ } else {
201
+ await doCheckout(productId);
202
+ return;
203
+ }
204
+ }
205
+ setConfirmDialogOpen(false);
206
+ };
207
+ const calculateUsagePrice = (currentUsage) => {
208
+ for (let i = usageTiers.length - 1; i >= 0; i--) if (currentUsage >= usageTiers[i].limit) return usageTiers[i].price;
209
+ return usageTiers[0]?.price ?? 0;
210
+ };
211
+ return /* @__PURE__ */ jsxs("div", {
212
+ className: ["pricing-page", className].filter(Boolean).join(" "),
213
+ children: [
214
+ /* @__PURE__ */ jsxs("div", {
215
+ className: "pricing-page__header",
216
+ children: [
217
+ /* @__PURE__ */ jsx("h1", {
218
+ className: "pricing-page__title",
219
+ children: title
220
+ }),
221
+ subtitle && /* @__PURE__ */ jsx("p", {
222
+ className: "pricing-page__subtitle",
223
+ children: subtitle
224
+ }),
225
+ /* @__PURE__ */ jsxs("div", {
226
+ className: "pricing-page__billing-toggle",
227
+ children: [!billingToggleVariant && /* @__PURE__ */ jsxs("div", {
228
+ className: "pricing-page__toggle-options",
229
+ children: [/* @__PURE__ */ jsx(Checkbox, {
230
+ checked: useSwitchToggle,
231
+ onCheckedChange: (checked) => setUseSwitchToggle(!!checked),
232
+ id: "toggle-type",
233
+ "aria-label": "Use switch style"
234
+ }), /* @__PURE__ */ jsx(Label, {
235
+ htmlFor: "toggle-type",
236
+ style: { fontSize: "0.75rem" },
237
+ children: "Use switch style"
238
+ })]
239
+ }), showSwitch ? /* @__PURE__ */ jsxs("div", {
240
+ className: "pricing-page__switch-container",
241
+ children: [
242
+ /* @__PURE__ */ jsx("span", {
243
+ className: `pricing-page__period-label ${!isYearly ? "pricing-page__period-label--active" : ""}`,
244
+ children: "Monthly"
245
+ }),
246
+ /* @__PURE__ */ jsx(Switch, {
247
+ checked: isYearly,
248
+ onCheckedChange: (checked) => setBillingPeriod(checked ? "yearly" : "monthly"),
249
+ "aria-label": "Toggle yearly billing",
250
+ children: /* @__PURE__ */ jsx(SwitchThumb, {})
251
+ }),
252
+ /* @__PURE__ */ jsxs("span", {
253
+ className: `pricing-page__period-label ${isYearly ? "pricing-page__period-label--active" : ""}`,
254
+ children: ["Yearly", /* @__PURE__ */ jsxs(Badge, {
255
+ color: "success",
256
+ size: "sm",
257
+ style: { marginLeft: "0.5rem" },
258
+ children: [
259
+ "Save ",
260
+ yearlySavingsPercent,
261
+ "%"
262
+ ]
263
+ })]
264
+ })
265
+ ]
266
+ }) : /* @__PURE__ */ jsxs(ToggleGroup, {
267
+ value: [billingPeriod],
268
+ onValueChange: (v) => v.length > 0 && setBillingPeriod(v[0]),
269
+ children: [/* @__PURE__ */ jsx(ToggleGroupItem, {
270
+ value: "monthly",
271
+ children: "Monthly"
272
+ }), /* @__PURE__ */ jsxs(ToggleGroupItem, {
273
+ value: "yearly",
274
+ children: ["Yearly", /* @__PURE__ */ jsxs(Badge, {
275
+ color: "success",
276
+ size: "sm",
277
+ style: { marginLeft: "0.375rem" },
278
+ children: [
279
+ "-",
280
+ yearlySavingsPercent,
281
+ "%"
282
+ ]
283
+ })]
284
+ })]
285
+ })]
286
+ })
287
+ ]
288
+ }),
289
+ /* @__PURE__ */ jsx("div", {
290
+ className: "pricing-page__plans",
291
+ children: plans.map((plan) => /* @__PURE__ */ jsxs(Card, {
292
+ hover: true,
293
+ className: `pricing-page__plan ${plan.popular ? "pricing-page__plan--popular" : ""}`,
294
+ children: [
295
+ plan.popular && /* @__PURE__ */ jsx(Badge, {
296
+ color: "success",
297
+ className: "pricing-page__popular-badge",
298
+ children: "Most Popular"
299
+ }),
300
+ /* @__PURE__ */ jsxs("div", {
301
+ className: "pricing-page__plan-header",
302
+ children: [/* @__PURE__ */ jsx("h2", {
303
+ className: "pricing-page__plan-name",
304
+ children: plan.name
305
+ }), /* @__PURE__ */ jsx("p", {
306
+ className: "pricing-page__plan-description",
307
+ children: plan.description
308
+ })]
309
+ }),
310
+ /* @__PURE__ */ jsxs("div", {
311
+ className: "pricing-page__plan-price",
312
+ children: [
313
+ /* @__PURE__ */ jsxs("span", {
314
+ className: "pricing-page__price-amount",
315
+ children: ["$", getPrice(plan)]
316
+ }),
317
+ /* @__PURE__ */ jsx("span", {
318
+ className: "pricing-page__price-period",
319
+ children: "/month"
320
+ }),
321
+ isYearly && getSavings(plan) > 0 && /* @__PURE__ */ jsxs("span", {
322
+ className: "pricing-page__price-savings",
323
+ children: [
324
+ "Save $",
325
+ getSavings(plan),
326
+ "/year"
327
+ ]
328
+ })
329
+ ]
330
+ }),
331
+ /* @__PURE__ */ jsx(Button, {
332
+ variant: isCurrentPlan(plan) ? "outline" : plan.popular ? "normal" : "outline",
333
+ className: "pricing-page__plan-cta",
334
+ onClick: () => handleSelectPlan(plan),
335
+ disabled: isCurrentPlan(plan),
336
+ children: isCurrentPlan(plan) ? "Current Plan" : isSubscribed ? getSwitchDirection(plan) === "upgrade" ? "Upgrade" : getSwitchDirection(plan) === "downgrade" ? "Downgrade" : "Switch Plan" : plan.cta || "Get Started"
337
+ }),
338
+ /* @__PURE__ */ jsx(Separator, { className: "pricing-page__features-separator" }),
339
+ /* @__PURE__ */ jsx("ul", {
340
+ className: "pricing-page__features",
341
+ children: plan.features.map((feature, index) => /* @__PURE__ */ jsxs("li", {
342
+ className: `pricing-page__feature ${!feature.included ? "pricing-page__feature--disabled" : ""}`,
343
+ children: [
344
+ /* @__PURE__ */ jsx("span", {
345
+ className: `pricing-page__feature-icon ${feature.included ? "pricing-page__feature-icon--included" : ""}`,
346
+ children: feature.included ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(MinusIcon, {})
347
+ }),
348
+ /* @__PURE__ */ jsxs("span", {
349
+ className: "pricing-page__feature-name",
350
+ children: [feature.name, feature.limit && /* @__PURE__ */ jsxs("span", {
351
+ className: "pricing-page__feature-limit",
352
+ children: [
353
+ "(",
354
+ feature.limit,
355
+ ")"
356
+ ]
357
+ })]
358
+ }),
359
+ feature.tooltip && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
360
+ className: "pricing-page__feature-info",
361
+ "aria-label": `More information about ${feature.name}`,
362
+ children: /* @__PURE__ */ jsx(InfoIcon, {})
363
+ }), /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx(TooltipPositioner, { children: /* @__PURE__ */ jsx(TooltipPopup, { children: feature.tooltip }) }) })] })
364
+ ]
365
+ }, index))
366
+ })
367
+ ]
368
+ }, plan.id))
369
+ }),
370
+ showUsageCalculator && usageTiers.length > 0 && /* @__PURE__ */ jsxs(Card, {
371
+ className: "pricing-page__calculator",
372
+ children: [
373
+ /* @__PURE__ */ jsx("h2", {
374
+ className: "pricing-page__calculator-title",
375
+ children: "Estimate your usage"
376
+ }),
377
+ /* @__PURE__ */ jsxs("p", {
378
+ className: "pricing-page__calculator-description",
379
+ children: ["Adjust the slider to see pricing based on your expected ", usageUnit]
380
+ }),
381
+ /* @__PURE__ */ jsxs(Slider, {
382
+ value: usage,
383
+ onValueChange: (v) => setUsage(Array.isArray(v) ? v[0] : v),
384
+ min: 0,
385
+ max: maxUsage,
386
+ step: Math.ceil(maxUsage / 100),
387
+ className: "pricing-page__calculator-slider",
388
+ children: [
389
+ /* @__PURE__ */ jsxs("div", {
390
+ className: "pricing-page__calculator-labels",
391
+ children: [/* @__PURE__ */ jsxs(Label, { children: ["Monthly ", usageUnit] }), /* @__PURE__ */ jsx("span", {
392
+ className: "pricing-page__calculator-value",
393
+ children: formatNumber(usage)
394
+ })]
395
+ }),
396
+ /* @__PURE__ */ jsx(SliderControl, { children: /* @__PURE__ */ jsxs(SliderTrack, { children: [/* @__PURE__ */ jsx(SliderIndicator, {}), /* @__PURE__ */ jsx(SliderThumb, { "aria-label": `Monthly ${usageUnit}` })] }) }),
397
+ /* @__PURE__ */ jsxs("div", {
398
+ className: "pricing-page__calculator-range",
399
+ children: [/* @__PURE__ */ jsx("span", { children: "0" }), /* @__PURE__ */ jsx("span", { children: formatNumber(maxUsage) })]
400
+ })
401
+ ]
402
+ }),
403
+ /* @__PURE__ */ jsx(Separator, { style: { margin: "1.5rem 0" } }),
404
+ /* @__PURE__ */ jsxs("div", {
405
+ className: "pricing-page__calculator-result",
406
+ children: [/* @__PURE__ */ jsx("span", {
407
+ className: "pricing-page__calculator-result-label",
408
+ children: "Estimated monthly cost"
409
+ }), /* @__PURE__ */ jsxs("div", {
410
+ className: "pricing-page__calculator-result-price",
411
+ children: [/* @__PURE__ */ jsxs("span", {
412
+ className: "pricing-page__calculator-amount",
413
+ children: ["$", calculateUsagePrice(usage)]
414
+ }), /* @__PURE__ */ jsx("span", {
415
+ className: "pricing-page__calculator-period",
416
+ children: "/month"
417
+ })]
418
+ })]
419
+ }),
420
+ /* @__PURE__ */ jsx("div", {
421
+ className: "pricing-page__tiers",
422
+ children: usageTiers.map((tier, index) => {
423
+ const isActive = usage >= tier.limit;
424
+ return /* @__PURE__ */ jsxs("div", {
425
+ className: "pricing-page__tier",
426
+ children: [/* @__PURE__ */ jsxs("div", {
427
+ className: "pricing-page__tier-info",
428
+ children: [/* @__PURE__ */ jsx("span", {
429
+ className: "pricing-page__tier-label",
430
+ children: tier.label
431
+ }), /* @__PURE__ */ jsxs("span", {
432
+ className: "pricing-page__tier-price",
433
+ children: [
434
+ "$",
435
+ tier.price,
436
+ "/mo"
437
+ ]
438
+ })]
439
+ }), /* @__PURE__ */ jsx(Progress, {
440
+ "aria-label": `Progress toward ${tier.label}`,
441
+ value: isActive ? 100 : tier.limit > 0 ? usage / tier.limit * 100 : 0,
442
+ color: isActive ? "success" : "primary",
443
+ children: /* @__PURE__ */ jsx(ProgressTrack, { children: /* @__PURE__ */ jsx(ProgressIndicator, {}) })
444
+ })]
445
+ }, index);
446
+ })
447
+ })
448
+ ]
449
+ }),
450
+ faq && faq.length > 0 && /* @__PURE__ */ jsxs("div", {
451
+ className: "pricing-page__faq",
452
+ children: [/* @__PURE__ */ jsx("h2", {
453
+ className: "pricing-page__faq-title",
454
+ children: "Frequently Asked Questions"
455
+ }), /* @__PURE__ */ jsx(Accordion, {
456
+ className: "pricing-page__faq-accordion",
457
+ children: faq.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, {
458
+ value: `faq-${index}`,
459
+ children: [/* @__PURE__ */ jsx(AccordionTrigger, { children: item.question }), /* @__PURE__ */ jsx(AccordionPanel, { children: /* @__PURE__ */ jsx("p", { children: item.answer }) })]
460
+ }, index))
461
+ })]
462
+ }),
463
+ /* @__PURE__ */ jsx(AlertDialog, {
464
+ open: confirmDialogOpen,
465
+ onOpenChange: setConfirmDialogOpen,
466
+ children: /* @__PURE__ */ jsxs(AlertDialogPortal, { children: [/* @__PURE__ */ jsx(AlertDialogBackdrop, {}), /* @__PURE__ */ jsxs(AlertDialogPopup, { children: [
467
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: isSubscribed && selectedPlan ? `${getSwitchDirection(selectedPlan) === "upgrade" ? "Upgrade" : getSwitchDirection(selectedPlan) === "downgrade" ? "Downgrade" : "Switch"} to ${selectedPlan.name}?` : `Subscribe to ${selectedPlan?.name}?` }),
468
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: isSubscribed && selectedPlan ? getSwitchDirection(selectedPlan) === "downgrade" ? `You'll be downgraded to the ${selectedPlan.name} plan. A prorated credit will be applied to your next invoice.` : `You'll be upgraded to the ${selectedPlan.name} plan. The prorated difference will be added to your next invoice.` : `You're about to subscribe to the ${selectedPlan?.name} plan at $${selectedPlan ? getPrice(selectedPlan) : 0}/month${isYearly ? " (billed yearly)" : ""}.` }),
469
+ selectedPlan && /* @__PURE__ */ jsxs("div", {
470
+ className: "pricing-page__confirm-summary",
471
+ children: [/* @__PURE__ */ jsxs("div", {
472
+ className: "pricing-page__confirm-row",
473
+ children: [/* @__PURE__ */ jsxs("span", { children: [
474
+ selectedPlan.name,
475
+ " Plan (",
476
+ isYearly ? "Yearly" : "Monthly",
477
+ ")"
478
+ ] }), /* @__PURE__ */ jsxs("span", { children: [
479
+ "$",
480
+ getPrice(selectedPlan),
481
+ "/mo"
482
+ ] })]
483
+ }), isYearly && /* @__PURE__ */ jsxs("div", {
484
+ className: "pricing-page__confirm-row pricing-page__confirm-row--savings",
485
+ children: [/* @__PURE__ */ jsx("span", { children: "Annual savings" }), /* @__PURE__ */ jsxs("span", { children: ["-$", getSavings(selectedPlan)] })]
486
+ })]
487
+ }),
488
+ /* @__PURE__ */ jsxs("div", {
489
+ className: "pricing-page__confirm-actions",
490
+ children: [/* @__PURE__ */ jsx(AlertDialogClose, {
491
+ disabled: switching,
492
+ children: "Cancel"
493
+ }), /* @__PURE__ */ jsx(Button, {
494
+ color: "primary",
495
+ onClick: handleConfirmUpgrade,
496
+ disabled: switching,
497
+ children: switching ? "Switching…" : isSubscribed && selectedPlan ? `Confirm ${getSwitchDirection(selectedPlan) === "upgrade" ? "Upgrade" : getSwitchDirection(selectedPlan) === "downgrade" ? "Downgrade" : "Switch"}` : "Confirm"
498
+ })]
499
+ })
500
+ ] })] })
501
+ })
502
+ ]
503
+ });
504
+ }
505
+ //#endregion
506
+ export { PricingPage };
@@ -0,0 +1,58 @@
1
+ import * as React from "react";
2
+ import { Progress as Progress$1 } from "@base-ui/react/progress";
3
+
4
+ //#region src/components/Progress.d.ts
5
+ type ProgressColor = "primary" | "success" | "warning" | "destructive";
6
+ interface ProgressProps extends Omit<React.ComponentPropsWithRef<typeof Progress$1.Root>, "className"> {
7
+ className?: string;
8
+ /**
9
+ * The semantic color of the progress bar.
10
+ * @default 'primary'
11
+ */
12
+ color?: ProgressColor;
13
+ }
14
+ interface ProgressTrackProps extends Omit<React.ComponentPropsWithRef<typeof Progress$1.Track>, "className"> {
15
+ className?: string;
16
+ }
17
+ interface ProgressIndicatorProps extends Omit<React.ComponentPropsWithRef<typeof Progress$1.Indicator>, "className"> {
18
+ className?: string;
19
+ }
20
+ /**
21
+ * A progress indicator component for showing completion status.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <Progress value={60}>
26
+ * <ProgressTrack>
27
+ * <ProgressIndicator />
28
+ * </ProgressTrack>
29
+ * </Progress>
30
+ * ```
31
+ *
32
+ * @see {@link https://base-ui.com/react/components/progress | Base UI Progress}
33
+ */
34
+ declare function Progress({
35
+ color,
36
+ className,
37
+ children,
38
+ ref,
39
+ ...props
40
+ }: ProgressProps & {
41
+ ref?: React.Ref<HTMLDivElement>;
42
+ }): React.JSX.Element;
43
+ declare function ProgressTrack({
44
+ className,
45
+ ref,
46
+ ...props
47
+ }: ProgressTrackProps & {
48
+ ref?: React.Ref<HTMLDivElement>;
49
+ }): React.JSX.Element;
50
+ declare function ProgressIndicator({
51
+ className,
52
+ ref,
53
+ ...props
54
+ }: ProgressIndicatorProps & {
55
+ ref?: React.Ref<HTMLDivElement>;
56
+ }): React.JSX.Element;
57
+ //#endregion
58
+ export { Progress, ProgressColor, ProgressIndicator, ProgressIndicatorProps, ProgressProps, ProgressTrack, ProgressTrackProps };
@@ -0,0 +1,51 @@
1
+ import "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { Progress as Progress$1 } from "@base-ui/react/progress";
4
+ //#region src/components/Progress.tsx
5
+ /**
6
+ * A progress indicator component for showing completion status.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <Progress value={60}>
11
+ * <ProgressTrack>
12
+ * <ProgressIndicator />
13
+ * </ProgressTrack>
14
+ * </Progress>
15
+ * ```
16
+ *
17
+ * @see {@link https://base-ui.com/react/components/progress | Base UI Progress}
18
+ */
19
+ function Progress({ color = "primary", className = "", children, ref, ...props }) {
20
+ const classes = [
21
+ "progress",
22
+ `progress--${color}`,
23
+ className
24
+ ].filter(Boolean).join(" ");
25
+ return /* @__PURE__ */ jsx(Progress$1.Root, {
26
+ ref,
27
+ "data-slot": "progress",
28
+ className: classes,
29
+ ...props,
30
+ children: children ?? /* @__PURE__ */ jsx(ProgressTrack, { children: /* @__PURE__ */ jsx(ProgressIndicator, {}) })
31
+ });
32
+ }
33
+ function ProgressTrack({ className = "", ref, ...props }) {
34
+ const classes = ["progress__track", className].filter(Boolean).join(" ");
35
+ return /* @__PURE__ */ jsx(Progress$1.Track, {
36
+ ref,
37
+ className: classes,
38
+ ...props
39
+ });
40
+ }
41
+ function ProgressIndicator({ className = "", ref, ...props }) {
42
+ const classes = ["progress__indicator", className].filter(Boolean).join(" ");
43
+ return /* @__PURE__ */ jsx(Progress$1.Indicator, {
44
+ ref,
45
+ "data-slot": "progress-indicator",
46
+ className: classes,
47
+ ...props
48
+ });
49
+ }
50
+ //#endregion
51
+ export { Progress, ProgressIndicator, ProgressTrack };