@olwiba/ui 0.2.8 → 0.2.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olwiba/ui",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -131,6 +131,15 @@ export interface PricingSectionProps {
131
131
  cadences?: PricingCadence[];
132
132
  /** Which cadence opens selected. Defaults to the first in `cadences`. */
133
133
  defaultCadence?: string;
134
+ /**
135
+ * Called when a plan's CTA is pressed, with the cadence currently selected —
136
+ * which is the half the caller can't otherwise know, since the toggle's state
137
+ * lives in here. Without it the CTA is inert: `PricingCard` takes an
138
+ * `onSelect` and this section had never passed one.
139
+ */
140
+ onSelectPlan?: (plan: PricingPlan, cadence?: string) => void;
141
+ /** Marks one plan as busy (e.g. its checkout is being created). */
142
+ pendingPlanName?: string;
134
143
  }
135
144
 
136
145
  const defaultRenderLink: AppShellRenderLink = ({ href, children, className }) => (
@@ -153,6 +162,8 @@ export function PricingSection({
153
162
  renderPlanFooter,
154
163
  cadences,
155
164
  defaultCadence,
165
+ onSelectPlan,
166
+ pendingPlanName,
156
167
  }: PricingSectionProps) {
157
168
  const [annual, setAnnual] = React.useState(false);
158
169
  const isOneTime = mode === 'one-time';
@@ -290,12 +301,19 @@ export function PricingSection({
290
301
  period={period}
291
302
  description={plan.description}
292
303
  features={plan.features}
293
- cta={plan.cta}
304
+ cta={pendingPlanName === plan.name ? 'Redirecting…' : plan.cta}
294
305
  highlighted={plan.highlighted}
295
306
  disabled={plan.disabled}
296
- ctaDisabled={plan.ctaDisabled}
307
+ // A plan mid-checkout is disabled too, so a second click
308
+ // can't open a second session.
309
+ ctaDisabled={plan.ctaDisabled || pendingPlanName === plan.name}
297
310
  badge={badge}
298
311
  footer={renderPlanFooter?.(plan)}
312
+ onSelect={
313
+ onSelectPlan
314
+ ? () => onSelectPlan(plan, useCadences ? activeCadence : undefined)
315
+ : undefined
316
+ }
299
317
  />
300
318
  );
301
319
  })}