@liberfi.io/ui-predict 1.0.0 → 1.0.2

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.d.mts CHANGED
@@ -13,7 +13,7 @@ declare global {
13
13
  };
14
14
  }
15
15
  }
16
- declare const _default: "1.0.0";
16
+ declare const _default: "1.0.2";
17
17
 
18
18
  /**
19
19
  * A single category entry in the static navigation model.
@@ -132,8 +132,14 @@ interface EventsPageProps {
132
132
  onHover?: (event: PredictEvent) => void;
133
133
  /** Optional background image for the Hero area. */
134
134
  bgImageSrc?: string;
135
+ /**
136
+ * Forwarded to the underlying trade modal: invoked when the user attempts
137
+ * to buy with an amount exceeding the available USDC balance for the
138
+ * market's source. Use this to open a Fund Wallet / deposit flow.
139
+ */
140
+ onInsufficientBalance?: (source: ProviderSource) => void;
135
141
  }
136
- declare function EventsPage({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, bgImageSrc: _bgImageSrc, }: EventsPageProps): react_jsx_runtime.JSX.Element;
142
+ declare function EventsPage({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, bgImageSrc: _bgImageSrc, onInsufficientBalance, }: EventsPageProps): react_jsx_runtime.JSX.Element;
137
143
 
138
144
  interface EventsWidgetProps {
139
145
  /** Category / tag selection from the categories widget. */
@@ -258,8 +264,15 @@ interface EventDetailPageProps {
258
264
  event: PredictEvent;
259
265
  walletAddress?: string;
260
266
  }) => React.ReactNode;
267
+ /**
268
+ * Forwarded to the inline TradeFormWidget and the mobile trade modal:
269
+ * invoked when the user attempts to buy with an amount exceeding the
270
+ * available USDC balance for the market's source. Use this to open a Fund
271
+ * Wallet / deposit flow.
272
+ */
273
+ onInsufficientBalance?: (source: ProviderSource) => void;
261
274
  }
262
- declare function EventDetailPage({ eventSlug, source, chain, walletAddress, onSimilarEventClick, onSimilarEventHover, onBack, renderActivitySection, }: EventDetailPageProps): react_jsx_runtime.JSX.Element;
275
+ declare function EventDetailPage({ eventSlug, source, chain, walletAddress, onSimilarEventClick, onSimilarEventHover, onBack, renderActivitySection, onInsufficientBalance, }: EventDetailPageProps): react_jsx_runtime.JSX.Element;
263
276
 
264
277
  type TradeOutcome = "yes" | "no";
265
278
  type TradeSide = "buy" | "sell";
@@ -301,6 +314,14 @@ interface UseTradeFormParams {
301
314
  market: PredictMarket;
302
315
  chain?: string;
303
316
  initialOutcome?: TradeOutcome;
317
+ /**
318
+ * Callback fired when the user attempts to submit a buy with an amount
319
+ * larger than the available USDC balance for the market's source. The
320
+ * consumer typically uses this to open a "Fund wallet" / Deposit flow.
321
+ * The callback is invoked BEFORE the inline validation errors are shown,
322
+ * giving the consumer a chance to redirect the user to a top-up flow.
323
+ */
324
+ onInsufficientBalance?: (source: ProviderSource) => void;
304
325
  }
305
326
  interface UseTradeFormResult {
306
327
  outcome: TradeOutcome;
@@ -316,6 +337,10 @@ interface UseTradeFormResult {
316
337
  isMarketDataLoading: boolean;
317
338
  isSubmitting: boolean;
318
339
  validation: TradeFormValidation;
340
+ /** True when the user has entered an amount that exceeds the available USDC balance. */
341
+ isInsufficientBalance: boolean;
342
+ /** The provider source for this market, useful to map to the right wallet. */
343
+ source: ProviderSource;
319
344
  supportsLimitOrder: boolean;
320
345
  kycRequired: boolean;
321
346
  kycUrl: string | null;
@@ -332,8 +357,14 @@ interface UseTradeFormResult {
332
357
  setCustomDuration: (v: number) => void;
333
358
  setCustomDurationUnit: (u: DurationUnit) => void;
334
359
  submit: () => void;
360
+ /**
361
+ * Notify the consumer about an insufficient-balance attempt. The hook
362
+ * forwards the configured `onInsufficientBalance` callback (if any) so the
363
+ * UI layer can call it without re-threading the option from the consumer.
364
+ */
365
+ notifyInsufficientBalance: () => void;
335
366
  }
336
- declare function useTradeForm({ market, initialOutcome, }: UseTradeFormParams): UseTradeFormResult;
367
+ declare function useTradeForm({ market, initialOutcome, onInsufficientBalance, }: UseTradeFormParams): UseTradeFormResult;
337
368
 
338
369
  interface EventDetailUIProps {
339
370
  event: PredictEvent;
@@ -455,6 +486,11 @@ type PredictTradeModalParams = {
455
486
  market: PredictMarket;
456
487
  initialOutcome?: TradeOutcome;
457
488
  chain?: string;
489
+ /**
490
+ * Called when the user presses Buy with insufficient USDC balance for the
491
+ * market's source. Allows the consumer to open a Fund Wallet flow.
492
+ */
493
+ onInsufficientBalance?: (source: ProviderSource) => void;
458
494
  };
459
495
  type PredictTradeModalResult = void;
460
496
  declare const PREDICT_TRADE_MODAL_ID = "predict-trade";
@@ -498,6 +534,10 @@ interface TradeFormUIProps {
498
534
  isBalanceLoading: boolean;
499
535
  isValid: boolean;
500
536
  validationErrors: string[];
537
+ /** When true, pressing submit triggers the insufficient-balance handler (e.g. open Fund Wallet) instead of showing inline errors. */
538
+ isInsufficientBalance: boolean;
539
+ /** Invoked when the user presses submit while balance is insufficient. */
540
+ onInsufficientBalance?: () => void;
501
541
  supportsLimitOrder: boolean;
502
542
  kycRequired: boolean;
503
543
  kycUrl: string | null;
@@ -515,7 +555,7 @@ interface TradeFormUIProps {
515
555
  onCustomDurationUnitChange: (u: DurationUnit) => void;
516
556
  onSubmit: () => void;
517
557
  }
518
- declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, isValid, validationErrors, supportsLimitOrder, kycRequired, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
558
+ declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, kycRequired, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
519
559
 
520
560
  interface TradeFormWidgetProps {
521
561
  event?: PredictEvent;
@@ -523,8 +563,14 @@ interface TradeFormWidgetProps {
523
563
  variant?: "bordered" | "flat";
524
564
  initialOutcome?: TradeOutcome;
525
565
  chain?: string;
566
+ /**
567
+ * Called when the user presses Buy with an amount larger than the available
568
+ * USDC balance for the market's source. Use this to show a top-up flow
569
+ * (e.g. open a Fund Wallet modal pre-selected for the right chain).
570
+ */
571
+ onInsufficientBalance?: (source: ProviderSource) => void;
526
572
  }
527
- declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
573
+ declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, onInsufficientBalance, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
528
574
 
529
575
  type PredictSellModalParams = {
530
576
  event: PredictEvent;
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ declare global {
13
13
  };
14
14
  }
15
15
  }
16
- declare const _default: "1.0.0";
16
+ declare const _default: "1.0.2";
17
17
 
18
18
  /**
19
19
  * A single category entry in the static navigation model.
@@ -132,8 +132,14 @@ interface EventsPageProps {
132
132
  onHover?: (event: PredictEvent) => void;
133
133
  /** Optional background image for the Hero area. */
134
134
  bgImageSrc?: string;
135
+ /**
136
+ * Forwarded to the underlying trade modal: invoked when the user attempts
137
+ * to buy with an amount exceeding the available USDC balance for the
138
+ * market's source. Use this to open a Fund Wallet / deposit flow.
139
+ */
140
+ onInsufficientBalance?: (source: ProviderSource) => void;
135
141
  }
136
- declare function EventsPage({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, bgImageSrc: _bgImageSrc, }: EventsPageProps): react_jsx_runtime.JSX.Element;
142
+ declare function EventsPage({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, bgImageSrc: _bgImageSrc, onInsufficientBalance, }: EventsPageProps): react_jsx_runtime.JSX.Element;
137
143
 
138
144
  interface EventsWidgetProps {
139
145
  /** Category / tag selection from the categories widget. */
@@ -258,8 +264,15 @@ interface EventDetailPageProps {
258
264
  event: PredictEvent;
259
265
  walletAddress?: string;
260
266
  }) => React.ReactNode;
267
+ /**
268
+ * Forwarded to the inline TradeFormWidget and the mobile trade modal:
269
+ * invoked when the user attempts to buy with an amount exceeding the
270
+ * available USDC balance for the market's source. Use this to open a Fund
271
+ * Wallet / deposit flow.
272
+ */
273
+ onInsufficientBalance?: (source: ProviderSource) => void;
261
274
  }
262
- declare function EventDetailPage({ eventSlug, source, chain, walletAddress, onSimilarEventClick, onSimilarEventHover, onBack, renderActivitySection, }: EventDetailPageProps): react_jsx_runtime.JSX.Element;
275
+ declare function EventDetailPage({ eventSlug, source, chain, walletAddress, onSimilarEventClick, onSimilarEventHover, onBack, renderActivitySection, onInsufficientBalance, }: EventDetailPageProps): react_jsx_runtime.JSX.Element;
263
276
 
264
277
  type TradeOutcome = "yes" | "no";
265
278
  type TradeSide = "buy" | "sell";
@@ -301,6 +314,14 @@ interface UseTradeFormParams {
301
314
  market: PredictMarket;
302
315
  chain?: string;
303
316
  initialOutcome?: TradeOutcome;
317
+ /**
318
+ * Callback fired when the user attempts to submit a buy with an amount
319
+ * larger than the available USDC balance for the market's source. The
320
+ * consumer typically uses this to open a "Fund wallet" / Deposit flow.
321
+ * The callback is invoked BEFORE the inline validation errors are shown,
322
+ * giving the consumer a chance to redirect the user to a top-up flow.
323
+ */
324
+ onInsufficientBalance?: (source: ProviderSource) => void;
304
325
  }
305
326
  interface UseTradeFormResult {
306
327
  outcome: TradeOutcome;
@@ -316,6 +337,10 @@ interface UseTradeFormResult {
316
337
  isMarketDataLoading: boolean;
317
338
  isSubmitting: boolean;
318
339
  validation: TradeFormValidation;
340
+ /** True when the user has entered an amount that exceeds the available USDC balance. */
341
+ isInsufficientBalance: boolean;
342
+ /** The provider source for this market, useful to map to the right wallet. */
343
+ source: ProviderSource;
319
344
  supportsLimitOrder: boolean;
320
345
  kycRequired: boolean;
321
346
  kycUrl: string | null;
@@ -332,8 +357,14 @@ interface UseTradeFormResult {
332
357
  setCustomDuration: (v: number) => void;
333
358
  setCustomDurationUnit: (u: DurationUnit) => void;
334
359
  submit: () => void;
360
+ /**
361
+ * Notify the consumer about an insufficient-balance attempt. The hook
362
+ * forwards the configured `onInsufficientBalance` callback (if any) so the
363
+ * UI layer can call it without re-threading the option from the consumer.
364
+ */
365
+ notifyInsufficientBalance: () => void;
335
366
  }
336
- declare function useTradeForm({ market, initialOutcome, }: UseTradeFormParams): UseTradeFormResult;
367
+ declare function useTradeForm({ market, initialOutcome, onInsufficientBalance, }: UseTradeFormParams): UseTradeFormResult;
337
368
 
338
369
  interface EventDetailUIProps {
339
370
  event: PredictEvent;
@@ -455,6 +486,11 @@ type PredictTradeModalParams = {
455
486
  market: PredictMarket;
456
487
  initialOutcome?: TradeOutcome;
457
488
  chain?: string;
489
+ /**
490
+ * Called when the user presses Buy with insufficient USDC balance for the
491
+ * market's source. Allows the consumer to open a Fund Wallet flow.
492
+ */
493
+ onInsufficientBalance?: (source: ProviderSource) => void;
458
494
  };
459
495
  type PredictTradeModalResult = void;
460
496
  declare const PREDICT_TRADE_MODAL_ID = "predict-trade";
@@ -498,6 +534,10 @@ interface TradeFormUIProps {
498
534
  isBalanceLoading: boolean;
499
535
  isValid: boolean;
500
536
  validationErrors: string[];
537
+ /** When true, pressing submit triggers the insufficient-balance handler (e.g. open Fund Wallet) instead of showing inline errors. */
538
+ isInsufficientBalance: boolean;
539
+ /** Invoked when the user presses submit while balance is insufficient. */
540
+ onInsufficientBalance?: () => void;
501
541
  supportsLimitOrder: boolean;
502
542
  kycRequired: boolean;
503
543
  kycUrl: string | null;
@@ -515,7 +555,7 @@ interface TradeFormUIProps {
515
555
  onCustomDurationUnitChange: (u: DurationUnit) => void;
516
556
  onSubmit: () => void;
517
557
  }
518
- declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, isValid, validationErrors, supportsLimitOrder, kycRequired, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
558
+ declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, kycRequired, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
519
559
 
520
560
  interface TradeFormWidgetProps {
521
561
  event?: PredictEvent;
@@ -523,8 +563,14 @@ interface TradeFormWidgetProps {
523
563
  variant?: "bordered" | "flat";
524
564
  initialOutcome?: TradeOutcome;
525
565
  chain?: string;
566
+ /**
567
+ * Called when the user presses Buy with an amount larger than the available
568
+ * USDC balance for the market's source. Use this to show a top-up flow
569
+ * (e.g. open a Fund Wallet modal pre-selected for the right chain).
570
+ */
571
+ onInsufficientBalance?: (source: ProviderSource) => void;
526
572
  }
527
- declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
573
+ declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, onInsufficientBalance, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
528
574
 
529
575
  type PredictSellModalParams = {
530
576
  event: PredictEvent;