@liberfi.io/ui-predict 0.1.53 → 0.1.54
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 +263 -0
- package/dist/index.d.mts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# @liberfi.io/ui-predict
|
|
2
|
+
|
|
3
|
+
Prediction market UI components, data hooks, and client for the Liberfi React SDK. Provides a full-stack prediction market experience — from event browsing and detail views to trading, order management, and real-time price feeds. Consumed by template apps (e.g. `dex-nextjs-template`) and composed with `@liberfi.io/ui` base components.
|
|
4
|
+
|
|
5
|
+
## Design Philosophy
|
|
6
|
+
|
|
7
|
+
- **Script / UI / Widget separation** — Each feature area (events, trade-form, order-book, etc.) is split into a `.script` (data hook), `.ui` (pure presentation), and `.widget` (wiring) layer. Presentational components are reusable without the full data stack.
|
|
8
|
+
- **Inversion of Control** — Navigation, side effects, and framework-specific behaviour (e.g. Next.js `<Link>`) are injected via callbacks and component props. The package never imports a router or framework directly.
|
|
9
|
+
- **V1 / V2 coexistence** — Legacy DFlow-backed components coexist with the prediction-server v2 client. Consumers migrate at their own pace; both APIs are stable and exported.
|
|
10
|
+
- **Provider-based client injection** — `PredictProvider` / `PredictV2Provider` supply the API client via React Context. Hooks pull the client from context, keeping components testable and decoupled from concrete HTTP implementations.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @liberfi.io/ui-predict
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Peer dependencies
|
|
19
|
+
|
|
20
|
+
The consumer must provide:
|
|
21
|
+
|
|
22
|
+
| Package | Version |
|
|
23
|
+
| ----------------------- | ------- |
|
|
24
|
+
| `react` | >= 18 |
|
|
25
|
+
| `react-dom` | >= 18 |
|
|
26
|
+
| `@tanstack/react-query` | ^5.90.2 |
|
|
27
|
+
|
|
28
|
+
## API Reference
|
|
29
|
+
|
|
30
|
+
### Providers
|
|
31
|
+
|
|
32
|
+
| Provider | Props | Description |
|
|
33
|
+
| --------------------- | ----------------------------------------- | ---------------------------------------------------------------------------- |
|
|
34
|
+
| `PredictProvider` | `client: IPredictClient` | Supplies the legacy DFlow predict client to all descendant hooks/components. |
|
|
35
|
+
| `PredictV2Provider` | `client: PredictClientV2` | Supplies the v2 prediction-server client. |
|
|
36
|
+
| `UserPredictProvider` | `walletAddress: string, enabled: boolean` | Provides user-specific prediction context (positions, orders). |
|
|
37
|
+
|
|
38
|
+
### Components — Events (V2)
|
|
39
|
+
|
|
40
|
+
| Component | Key Props | Description |
|
|
41
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `EventsPageV2` | `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Full events page with categories, toolbar, filters, and grid. |
|
|
43
|
+
| `EventsWidgetV2` | `tagSlugSelection`, `limit`, `status`, `sort_by`, `source`, `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Container that wires `useEventsV2` data to `EventsV2UI`. |
|
|
44
|
+
| `EventsV2UI` | `events`, `hasMore`, `onFetchMore`, `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Virtualized grid (react-window) rendering `EventItemV2UI` cards. |
|
|
45
|
+
| `EventItemV2UI` | `event`, `href`, `LinkComponent`, `onSelect`, `onSelectOutcome`, `onHover` | Single event card. Uses `Linkable` from `@liberfi.io/ui` — renders as a `<Link>` when `href` is set, `<div>` otherwise. |
|
|
46
|
+
| `CategoriesWidgetV2` | `onSelect`, `trailing` | Category/tag navigation (slug-based). |
|
|
47
|
+
|
|
48
|
+
#### Link integration props
|
|
49
|
+
|
|
50
|
+
These props enable framework-agnostic route link rendering and prefetching:
|
|
51
|
+
|
|
52
|
+
- **`getEventHref?: (event: V2Event) => string`** — Generates the URL for each event card. When provided, cards render as link elements instead of plain divs.
|
|
53
|
+
- **`LinkComponent?: LinkComponentType`** — A custom link component (e.g. `next/link`). Falls back to `<a>` when `href` is set without this prop. Import `LinkComponentType` from `@liberfi.io/ui`.
|
|
54
|
+
- **`onHover?: (event: V2Event) => void`** — Called when a card is hovered (`onMouseEnter`). Use this to trigger data prefetching (e.g. `queryClient.prefetchQuery`).
|
|
55
|
+
|
|
56
|
+
### Components — Event Detail
|
|
57
|
+
|
|
58
|
+
| Component | Key Props | Description |
|
|
59
|
+
| --------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------- |
|
|
60
|
+
| `EventDetailPage` | `eventId`, `onTradeAction` | Full detail page composing detail + trade form. |
|
|
61
|
+
| `EventDetailWidget` | `eventId`, `initialMarketTickers`, `initialChartRange`, `onTradeAction` | Event detail with candlestick chart and market list. |
|
|
62
|
+
| `EventDetailUI` | `event`, `series`, `candlesticks`, `chartRange`, ... | Pure presentation for event detail. |
|
|
63
|
+
| `EventDetailSkeleton` | `marketCount?` | Loading skeleton for the detail page. |
|
|
64
|
+
|
|
65
|
+
### Components — Trading
|
|
66
|
+
|
|
67
|
+
| Component | Description |
|
|
68
|
+
| -------------------- | ---------------------------------------------------- |
|
|
69
|
+
| `TradeFormWidget` | Trade form wiring (market, side, amount, execution). |
|
|
70
|
+
| `OrderBookWidget` | Live order book with depth visualization. |
|
|
71
|
+
| `OpenOrdersWidget` | User's open orders with cancel support. |
|
|
72
|
+
| `TradeHistoryWidget` | Recent trade history. |
|
|
73
|
+
| `PositionsWidget` | User's prediction market positions. |
|
|
74
|
+
|
|
75
|
+
### Hooks — Events
|
|
76
|
+
|
|
77
|
+
| Hook | Params | Return | Description |
|
|
78
|
+
| ------------------------ | ---------------------------- | ----------------------- | ---------------------------------------------- |
|
|
79
|
+
| `useEventsV2` | `UseEventsV2Params` | `UseEventsV2Result` | V2 infinite-scroll events list (cursor-based). |
|
|
80
|
+
| `useEventByIdQuery` | `{ id, withNestedMarkets? }` | TanStack Query result | Single event by ID/slug. |
|
|
81
|
+
| `useEventsQuery` | `EventQueryParams` | TanStack Query result | Legacy paginated events. |
|
|
82
|
+
| `useEventsInfiniteQuery` | `EventQueryParams` | TanStack infinite query | Legacy infinite-scroll events. |
|
|
83
|
+
|
|
84
|
+
### Hooks — Markets & Data
|
|
85
|
+
|
|
86
|
+
| Hook | Description |
|
|
87
|
+
| --------------------------------------------------------- | ------------------------------- |
|
|
88
|
+
| `useMarketsQuery` | Markets by event. |
|
|
89
|
+
| `useMarketByIdQuery` | Single market by ticker. |
|
|
90
|
+
| `useMarketByMintQuery` | Market lookup by mint address. |
|
|
91
|
+
| `useMarketsBatchQuery` | Batch market lookup. |
|
|
92
|
+
| `useOrderBookQuery` | Order book for a market. |
|
|
93
|
+
| `useTradesQuery` | Recent trades. |
|
|
94
|
+
| `useOnchainTradesQuery` / `useOnchainTradesInfiniteQuery` | On-chain trade history. |
|
|
95
|
+
| `usePriceHistoryQuery` | Candlestick data. |
|
|
96
|
+
| `useForecastHistoryQuery` | AI forecast percentile history. |
|
|
97
|
+
| `useLiveDataQuery` | Real-time market data. |
|
|
98
|
+
| `useSeriesQuery` | Series metadata. |
|
|
99
|
+
| `useCategoriesQuery` | Tag/category list. |
|
|
100
|
+
| `useSearchQuery` | Search events. |
|
|
101
|
+
|
|
102
|
+
### Hooks — User & Trading
|
|
103
|
+
|
|
104
|
+
| Hook | Description |
|
|
105
|
+
| --------------------------- | -------------------------------- |
|
|
106
|
+
| `usePositionsByWalletQuery` | User positions by wallet. |
|
|
107
|
+
| `useMarketPositions` | Positions for a specific market. |
|
|
108
|
+
| `useQuoteQuery` | Trade quote. |
|
|
109
|
+
| `useSwapMutation` | Execute a swap/trade. |
|
|
110
|
+
| `useOrderQuery` | Place a limit order. |
|
|
111
|
+
| `useIntentQuery` | Intent-based trading. |
|
|
112
|
+
| `useOutcomeMintsQuery` | Outcome token mints. |
|
|
113
|
+
| `useTokensQuery` | Token list. |
|
|
114
|
+
| `useVenuesQuery` | Venue list. |
|
|
115
|
+
|
|
116
|
+
### Hooks — WebSocket
|
|
117
|
+
|
|
118
|
+
| Hook | Description |
|
|
119
|
+
| -------------------------- | ----------------------------------------- |
|
|
120
|
+
| `useWsConnection` | WebSocket connection lifecycle. |
|
|
121
|
+
| `useWsClient` | Access the WS client instance. |
|
|
122
|
+
| `usePricesSubscription` | Subscribe to real-time price updates. |
|
|
123
|
+
| `useTradesSubscription` | Subscribe to real-time trade updates. |
|
|
124
|
+
| `useOrderbookSubscription` | Subscribe to real-time orderbook updates. |
|
|
125
|
+
|
|
126
|
+
### Hooks — V2
|
|
127
|
+
|
|
128
|
+
| Hook | Description |
|
|
129
|
+
| -------------------- | --------------------------------------- |
|
|
130
|
+
| `usePredictV2Client` | Access the v2 prediction-server client. |
|
|
131
|
+
| `useEventsV2Query` | V2 events query (single page). |
|
|
132
|
+
| `useEventV2Query` | V2 single event query. |
|
|
133
|
+
|
|
134
|
+
### Functions / Utilities
|
|
135
|
+
|
|
136
|
+
| Function | Signature | Description |
|
|
137
|
+
| ---------------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
138
|
+
| `eventByIdQueryKey` | `(params: UseEventByIdQueryParams) => unknown[]` | Stable query key for `useEventByIdQuery`. Useful for prefetching. |
|
|
139
|
+
| `fetchEventById` | `(client: IPredictClient, params: UseEventByIdQueryParams) => Promise<StandardEvent>` | Standalone fetch function for event detail. Useful for `queryClient.prefetchQuery`. |
|
|
140
|
+
| `marketCandlesticksQueryKey` | `(params) => unknown[]` | Query key for candlestick data. |
|
|
141
|
+
| `fetchMarketCandlesticks` | `(client, params) => Promise<CandlesticksResponse>` | Standalone candlestick fetch. |
|
|
142
|
+
| `createPredictClientV2` | `(baseURL: string) => PredictClientV2` | Factory for the v2 client. |
|
|
143
|
+
| `createPredictWsClient` | `(config: WsClientConfig) => PredictWsClient` | Factory for the WebSocket client. |
|
|
144
|
+
|
|
145
|
+
### Key Types
|
|
146
|
+
|
|
147
|
+
| Type | Description |
|
|
148
|
+
| ------------------ | --------------------------------------------------------- | ---- | ---- | ------ |
|
|
149
|
+
| `V2Event` | V2 event with markets, metadata, and volume. |
|
|
150
|
+
| `V2Market` | V2 market with outcomes, status, and pricing. |
|
|
151
|
+
| `StandardEvent` | Legacy event model. |
|
|
152
|
+
| `StandardMarket` | Legacy market model. |
|
|
153
|
+
| `IPredictClient` | Interface for the prediction API client. |
|
|
154
|
+
| `IPredictWsClient` | Interface for the WebSocket client. |
|
|
155
|
+
| `TagSlugSelection` | Category/tag selection state `{ categorySlug, tagSlug }`. |
|
|
156
|
+
| `ChartRangeType` | `"1d" | "1w" | "1m" | "all"` |
|
|
157
|
+
|
|
158
|
+
### Constants
|
|
159
|
+
|
|
160
|
+
| Constant | Value | Description |
|
|
161
|
+
| --------------------------- | --------------------------------------- | ------------------------------------ |
|
|
162
|
+
| `DEFAULT_PAGE_SIZE` | 48 | Default events per page. |
|
|
163
|
+
| `MAX_PRICE_HISTORY_MARKETS` | 4 | Max markets for candlestick queries. |
|
|
164
|
+
| `ChartRange` | `{ ONE_DAY, ONE_WEEK, ONE_MONTH, ALL }` | Chart time range enum. |
|
|
165
|
+
| `CandlestickPeriod` | `{ ONE_MINUTE, ONE_HOUR, ONE_DAY }` | Candlestick granularity. |
|
|
166
|
+
|
|
167
|
+
## Usage Examples
|
|
168
|
+
|
|
169
|
+
### Basic event list with Next.js Link prefetching
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { useCallback } from "react";
|
|
173
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
174
|
+
import Link from "next/link";
|
|
175
|
+
import { useRouter } from "next/navigation";
|
|
176
|
+
import {
|
|
177
|
+
EventsPageV2,
|
|
178
|
+
eventByIdQueryKey,
|
|
179
|
+
fetchEventById,
|
|
180
|
+
usePredictClient,
|
|
181
|
+
} from "@liberfi.io/ui-predict";
|
|
182
|
+
import type { V2Event } from "@liberfi.io/ui-predict";
|
|
183
|
+
|
|
184
|
+
function PredictListPage() {
|
|
185
|
+
const router = useRouter();
|
|
186
|
+
const queryClient = useQueryClient();
|
|
187
|
+
const predictClient = usePredictClient();
|
|
188
|
+
|
|
189
|
+
// TanStack Query data prefetch on hover
|
|
190
|
+
const handleHover = useCallback(
|
|
191
|
+
(event: V2Event) => {
|
|
192
|
+
queryClient.prefetchQuery({
|
|
193
|
+
queryKey: eventByIdQueryKey({
|
|
194
|
+
id: event.slug,
|
|
195
|
+
withNestedMarkets: true,
|
|
196
|
+
}),
|
|
197
|
+
queryFn: () =>
|
|
198
|
+
fetchEventById(predictClient, {
|
|
199
|
+
id: event.slug,
|
|
200
|
+
withNestedMarkets: true,
|
|
201
|
+
}),
|
|
202
|
+
staleTime: 30_000,
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
[queryClient, predictClient],
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<EventsPageV2
|
|
210
|
+
getEventHref={(event) => `/predict/${event.slug}`}
|
|
211
|
+
LinkComponent={Link}
|
|
212
|
+
onHover={handleHover}
|
|
213
|
+
onSelect={(event) => router.push(`/predict/${event.slug}`)}
|
|
214
|
+
/>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Event list without Link (callback-only, backward compatible)
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
import { EventsPageV2 } from "@liberfi.io/ui-predict";
|
|
223
|
+
|
|
224
|
+
function PredictListPage() {
|
|
225
|
+
return (
|
|
226
|
+
<EventsPageV2
|
|
227
|
+
onSelect={(event) => console.log("selected", event.slug)}
|
|
228
|
+
onSelectOutcome={(event, market, side) =>
|
|
229
|
+
console.log("outcome", event.slug, market.slug, side)
|
|
230
|
+
}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Provider setup
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import {
|
|
240
|
+
PredictProvider,
|
|
241
|
+
PredictV2Provider,
|
|
242
|
+
PredictClient,
|
|
243
|
+
createPredictClientV2,
|
|
244
|
+
} from "@liberfi.io/ui-predict";
|
|
245
|
+
|
|
246
|
+
const legacyClient = new PredictClient("https://api.example.com");
|
|
247
|
+
const v2Client = createPredictClientV2("https://predict-v2.example.com");
|
|
248
|
+
|
|
249
|
+
function App({ children }) {
|
|
250
|
+
return (
|
|
251
|
+
<PredictProvider client={legacyClient}>
|
|
252
|
+
<PredictV2Provider client={v2Client}>{children}</PredictV2Provider>
|
|
253
|
+
</PredictProvider>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Future Improvements
|
|
259
|
+
|
|
260
|
+
- Migrate remaining v1 components (events list, categories) to v2 client, then deprecate v1 hooks and types.
|
|
261
|
+
- Add `onHover` callback support to `EventDetailWidget` for prefetching related series/candlestick data.
|
|
262
|
+
- Consider a `usePrefetchEventDetail` convenience hook that combines route prefetch + query prefetch in one call.
|
|
263
|
+
- Extract common virtualized grid logic (`EventsV2UI` pattern) into a shared `@liberfi.io/ui` component for reuse in token lists and channel lists.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { S as StandardEvent, a as StandardMarket, E as EventQueryParams, V as V2EventSortField, b as V2ProviderSource, c as V2Event, d as V2Market, e as V2EventStatus, O as OrderResponse, f as OrderStatusResponse, g as SeriesResponse, C as CandlesticksResponse, h as OrderbookLevel, i as SingleTradeResponse, I as IPredictClient, j as IPredictWsClient, W as WalletPositionItem, P as PredictClientV2, k as V2ListEventsParams, l as V2Page, m as StandardEventsResponse, M as MarketQueryParams, n as StandardMarketsResponse, o as MarketsBatchRequest, p as OrderbookResponse, T as TradesQueryParams, q as MultiTradeResponse, r as TradesByMintQueryParams, s as OnchainTradesByWalletQueryParams, t as MultiOnchainTradeResponse, u as OnchainTradesByEventQueryParams, v as OnchainTradesByMarketQueryParams, w as CandlesticksQueryParams, F as ForecastPercentileHistoryQueryParams, x as ForecastPercentileHistoryResponse, y as ForecastPercentileHistoryByMintQueryParams, L as LiveDataQueryParams, z as LiveDataResponse, A as LiveDataByEventQueryParams, B as LiveDataByMintQueryParams, D as SeriesQueryParams, G as SeriesListResponse, H as TagsByCategoriesResponse, J as FiltersBySportsResponse, K as SearchQueryParams, N as SearchResponse, Q as PositionsByWalletQueryParams, R as WalletPositionsResponse, U as OutcomeMintsQueryParams, X as OutcomeMintsResponse, Y as FilterOutcomeMintsRequest, Z as FilterOutcomeMintsResponse, _ as QuoteQueryParams, $ as QuoteResponse, a0 as SwapRequestBody, a1 as SwapResponse, a2 as SwapInstructionsResponse, a3 as OrderQueryParams, a4 as OrderStatusQueryParams, a5 as IntentQuoteQueryParams, a6 as IntentQuoteResponse, a7 as IntentSwapRequestBody, a8 as IntentSwapResponse, a9 as PredictionMarketInitQueryParams, aa as PredictionMarketInitResponse, ab as TokenListResponse, ac as TokenListWithDecimalsResponse, ad as VenueListResponse, ae as WsConnectionStatus, af as WsPriceUpdate, ag as WsTradeUpdate, ah as WsOrderbookUpdate } from './index-DIcC-37S.mjs';
|
|
3
3
|
export { aE as AccountMetaResponse, aR as BasePredictClient, aG as BlockhashWithMetadata, ax as CandlestickDataPoint, aw as CandlestickOHLC, aC as ComputeBudgetInfo, aO as CreateFeeAccountParams, aN as DestinationTokenAccountParam, aU as DflowPredictClient, aV as DflowPredictWsClient, aq as ExecutionMode, ay as ForecastPercentileDataPoint, aF as InstructionResponse, aJ as IntentExpiry, as as MarketAccountInfo, aj as MarketStatus, at as OnchainTrade, au as OnchainTradeSortBy, av as OnchainTradesBaseQueryParams, aH as OrderFill, aI as OrderRevert, am as OrderStatus, aL as OrderbookQueryParams, aB as PlatformFee, an as PlatformFeeMode, aP as PositiveSlippageParams, aU as PredictClient, aV as PredictWsClient, aM as PrioritizationFeeLamports, aD as PrioritizationType, ap as PriorityLevel, ai as ProviderType, aA as RoutePlanLeg, az as SeriesSettlementSource, ar as SettlementSource, ao as SlippageTolerance, ak as SortField, al as SortOrder, aK as TokenWithDecimals, aZ as V2MarketResult, a_ as V2MarketStatus, a$ as V2Outcome, b0 as V2ProviderMeta, b1 as V2SettlementSource, b2 as V2Tag, aX as WsClientConfig, aQ as WsSubscribeOptions, aS as buildQuery, aW as createDflowPredictWsClient, aY as createPredictClientV2, aW as createPredictWsClient, aT as toRecord } from './index-DIcC-37S.mjs';
|
|
4
|
+
import { LinkComponentType } from '@liberfi.io/ui';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import { PropsWithChildren } from 'react';
|
|
6
7
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
@@ -13,7 +14,7 @@ declare global {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
declare const _default: "0.1.
|
|
17
|
+
declare const _default: "0.1.54";
|
|
17
18
|
|
|
18
19
|
interface EventsPageProps {
|
|
19
20
|
/** Callback when an event is selected */
|
|
@@ -213,8 +214,14 @@ interface EventsPageV2Props {
|
|
|
213
214
|
onSelect?: (event: V2Event) => void;
|
|
214
215
|
/** Callback when an outcome button (yes / no) is pressed */
|
|
215
216
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
217
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
218
|
+
getEventHref?: (event: V2Event) => string;
|
|
219
|
+
/** Custom link component (e.g. next/link). */
|
|
220
|
+
LinkComponent?: LinkComponentType;
|
|
221
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
222
|
+
onHover?: (event: V2Event) => void;
|
|
216
223
|
}
|
|
217
|
-
declare function EventsPageV2({ onSelect, onSelectOutcome }: EventsPageV2Props): react_jsx_runtime.JSX.Element;
|
|
224
|
+
declare function EventsPageV2({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsPageV2Props): react_jsx_runtime.JSX.Element;
|
|
218
225
|
|
|
219
226
|
interface EventsWidgetV2Props {
|
|
220
227
|
/**
|
|
@@ -238,8 +245,14 @@ interface EventsWidgetV2Props {
|
|
|
238
245
|
onSelect?: (event: V2Event) => void;
|
|
239
246
|
/** Callback when an outcome button (yes/no) is pressed */
|
|
240
247
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
248
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
249
|
+
getEventHref?: (event: V2Event) => string;
|
|
250
|
+
/** Custom link component (e.g. next/link). */
|
|
251
|
+
LinkComponent?: LinkComponentType;
|
|
252
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
253
|
+
onHover?: (event: V2Event) => void;
|
|
241
254
|
}
|
|
242
|
-
declare function EventsWidgetV2({ tagSlugSelection, limit, status, sort_by, sort_asc, source, with_markets, onSelect, onSelectOutcome, }: EventsWidgetV2Props): react_jsx_runtime.JSX.Element;
|
|
255
|
+
declare function EventsWidgetV2({ tagSlugSelection, limit, status, sort_by, sort_asc, source, with_markets, onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsWidgetV2Props): react_jsx_runtime.JSX.Element;
|
|
243
256
|
|
|
244
257
|
/** Parameters for useEventsV2 */
|
|
245
258
|
interface UseEventsV2Params {
|
|
@@ -313,15 +326,27 @@ type EventsV2UIProps = {
|
|
|
313
326
|
onSelect?: (event: V2Event) => void;
|
|
314
327
|
/** Callback when an outcome button (yes/no) is pressed */
|
|
315
328
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
329
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
330
|
+
getEventHref?: (event: V2Event) => string;
|
|
331
|
+
/** Custom link component (e.g. next/link). */
|
|
332
|
+
LinkComponent?: LinkComponentType;
|
|
333
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
334
|
+
onHover?: (event: V2Event) => void;
|
|
316
335
|
};
|
|
317
|
-
declare function EventsV2UI({ events, hasMore, onFetchMore, onSelect, onSelectOutcome, }: EventsV2UIProps): react_jsx_runtime.JSX.Element;
|
|
336
|
+
declare function EventsV2UI({ events, hasMore, onFetchMore, onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsV2UIProps): react_jsx_runtime.JSX.Element;
|
|
318
337
|
|
|
319
338
|
type EventItemV2UIProps = {
|
|
320
339
|
event: V2Event;
|
|
340
|
+
/** URL for the detail page. When set, card renders as a link via Linkable. */
|
|
341
|
+
href?: string;
|
|
342
|
+
/** Custom link component (e.g. next/link). Passed to Linkable. */
|
|
343
|
+
LinkComponent?: LinkComponentType;
|
|
321
344
|
onSelect?: (event: V2Event) => void;
|
|
322
345
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
346
|
+
/** Called when the card is hovered (for data prefetching). */
|
|
347
|
+
onHover?: (event: V2Event) => void;
|
|
323
348
|
};
|
|
324
|
-
declare function EventItemV2UI({ event, onSelect, onSelectOutcome, }: EventItemV2UIProps): react_jsx_runtime.JSX.Element;
|
|
349
|
+
declare function EventItemV2UI({ event, href, LinkComponent, onSelect, onSelectOutcome, onHover, }: EventItemV2UIProps): react_jsx_runtime.JSX.Element;
|
|
325
350
|
|
|
326
351
|
/** Default page size for list queries */
|
|
327
352
|
declare const DEFAULT_PAGE_SIZE = 48;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { S as StandardEvent, a as StandardMarket, E as EventQueryParams, V as V2EventSortField, b as V2ProviderSource, c as V2Event, d as V2Market, e as V2EventStatus, O as OrderResponse, f as OrderStatusResponse, g as SeriesResponse, C as CandlesticksResponse, h as OrderbookLevel, i as SingleTradeResponse, I as IPredictClient, j as IPredictWsClient, W as WalletPositionItem, P as PredictClientV2, k as V2ListEventsParams, l as V2Page, m as StandardEventsResponse, M as MarketQueryParams, n as StandardMarketsResponse, o as MarketsBatchRequest, p as OrderbookResponse, T as TradesQueryParams, q as MultiTradeResponse, r as TradesByMintQueryParams, s as OnchainTradesByWalletQueryParams, t as MultiOnchainTradeResponse, u as OnchainTradesByEventQueryParams, v as OnchainTradesByMarketQueryParams, w as CandlesticksQueryParams, F as ForecastPercentileHistoryQueryParams, x as ForecastPercentileHistoryResponse, y as ForecastPercentileHistoryByMintQueryParams, L as LiveDataQueryParams, z as LiveDataResponse, A as LiveDataByEventQueryParams, B as LiveDataByMintQueryParams, D as SeriesQueryParams, G as SeriesListResponse, H as TagsByCategoriesResponse, J as FiltersBySportsResponse, K as SearchQueryParams, N as SearchResponse, Q as PositionsByWalletQueryParams, R as WalletPositionsResponse, U as OutcomeMintsQueryParams, X as OutcomeMintsResponse, Y as FilterOutcomeMintsRequest, Z as FilterOutcomeMintsResponse, _ as QuoteQueryParams, $ as QuoteResponse, a0 as SwapRequestBody, a1 as SwapResponse, a2 as SwapInstructionsResponse, a3 as OrderQueryParams, a4 as OrderStatusQueryParams, a5 as IntentQuoteQueryParams, a6 as IntentQuoteResponse, a7 as IntentSwapRequestBody, a8 as IntentSwapResponse, a9 as PredictionMarketInitQueryParams, aa as PredictionMarketInitResponse, ab as TokenListResponse, ac as TokenListWithDecimalsResponse, ad as VenueListResponse, ae as WsConnectionStatus, af as WsPriceUpdate, ag as WsTradeUpdate, ah as WsOrderbookUpdate } from './index-DIcC-37S.js';
|
|
3
3
|
export { aE as AccountMetaResponse, aR as BasePredictClient, aG as BlockhashWithMetadata, ax as CandlestickDataPoint, aw as CandlestickOHLC, aC as ComputeBudgetInfo, aO as CreateFeeAccountParams, aN as DestinationTokenAccountParam, aU as DflowPredictClient, aV as DflowPredictWsClient, aq as ExecutionMode, ay as ForecastPercentileDataPoint, aF as InstructionResponse, aJ as IntentExpiry, as as MarketAccountInfo, aj as MarketStatus, at as OnchainTrade, au as OnchainTradeSortBy, av as OnchainTradesBaseQueryParams, aH as OrderFill, aI as OrderRevert, am as OrderStatus, aL as OrderbookQueryParams, aB as PlatformFee, an as PlatformFeeMode, aP as PositiveSlippageParams, aU as PredictClient, aV as PredictWsClient, aM as PrioritizationFeeLamports, aD as PrioritizationType, ap as PriorityLevel, ai as ProviderType, aA as RoutePlanLeg, az as SeriesSettlementSource, ar as SettlementSource, ao as SlippageTolerance, ak as SortField, al as SortOrder, aK as TokenWithDecimals, aZ as V2MarketResult, a_ as V2MarketStatus, a$ as V2Outcome, b0 as V2ProviderMeta, b1 as V2SettlementSource, b2 as V2Tag, aX as WsClientConfig, aQ as WsSubscribeOptions, aS as buildQuery, aW as createDflowPredictWsClient, aY as createPredictClientV2, aW as createPredictWsClient, aT as toRecord } from './index-DIcC-37S.js';
|
|
4
|
+
import { LinkComponentType } from '@liberfi.io/ui';
|
|
4
5
|
import * as react from 'react';
|
|
5
6
|
import { PropsWithChildren } from 'react';
|
|
6
7
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
@@ -13,7 +14,7 @@ declare global {
|
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
declare const _default: "0.1.
|
|
17
|
+
declare const _default: "0.1.54";
|
|
17
18
|
|
|
18
19
|
interface EventsPageProps {
|
|
19
20
|
/** Callback when an event is selected */
|
|
@@ -213,8 +214,14 @@ interface EventsPageV2Props {
|
|
|
213
214
|
onSelect?: (event: V2Event) => void;
|
|
214
215
|
/** Callback when an outcome button (yes / no) is pressed */
|
|
215
216
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
217
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
218
|
+
getEventHref?: (event: V2Event) => string;
|
|
219
|
+
/** Custom link component (e.g. next/link). */
|
|
220
|
+
LinkComponent?: LinkComponentType;
|
|
221
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
222
|
+
onHover?: (event: V2Event) => void;
|
|
216
223
|
}
|
|
217
|
-
declare function EventsPageV2({ onSelect, onSelectOutcome }: EventsPageV2Props): react_jsx_runtime.JSX.Element;
|
|
224
|
+
declare function EventsPageV2({ onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsPageV2Props): react_jsx_runtime.JSX.Element;
|
|
218
225
|
|
|
219
226
|
interface EventsWidgetV2Props {
|
|
220
227
|
/**
|
|
@@ -238,8 +245,14 @@ interface EventsWidgetV2Props {
|
|
|
238
245
|
onSelect?: (event: V2Event) => void;
|
|
239
246
|
/** Callback when an outcome button (yes/no) is pressed */
|
|
240
247
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
248
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
249
|
+
getEventHref?: (event: V2Event) => string;
|
|
250
|
+
/** Custom link component (e.g. next/link). */
|
|
251
|
+
LinkComponent?: LinkComponentType;
|
|
252
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
253
|
+
onHover?: (event: V2Event) => void;
|
|
241
254
|
}
|
|
242
|
-
declare function EventsWidgetV2({ tagSlugSelection, limit, status, sort_by, sort_asc, source, with_markets, onSelect, onSelectOutcome, }: EventsWidgetV2Props): react_jsx_runtime.JSX.Element;
|
|
255
|
+
declare function EventsWidgetV2({ tagSlugSelection, limit, status, sort_by, sort_asc, source, with_markets, onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsWidgetV2Props): react_jsx_runtime.JSX.Element;
|
|
243
256
|
|
|
244
257
|
/** Parameters for useEventsV2 */
|
|
245
258
|
interface UseEventsV2Params {
|
|
@@ -313,15 +326,27 @@ type EventsV2UIProps = {
|
|
|
313
326
|
onSelect?: (event: V2Event) => void;
|
|
314
327
|
/** Callback when an outcome button (yes/no) is pressed */
|
|
315
328
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
329
|
+
/** Generate href for each event card. When set, cards render as links. */
|
|
330
|
+
getEventHref?: (event: V2Event) => string;
|
|
331
|
+
/** Custom link component (e.g. next/link). */
|
|
332
|
+
LinkComponent?: LinkComponentType;
|
|
333
|
+
/** Called when a card is hovered (for data prefetching). */
|
|
334
|
+
onHover?: (event: V2Event) => void;
|
|
316
335
|
};
|
|
317
|
-
declare function EventsV2UI({ events, hasMore, onFetchMore, onSelect, onSelectOutcome, }: EventsV2UIProps): react_jsx_runtime.JSX.Element;
|
|
336
|
+
declare function EventsV2UI({ events, hasMore, onFetchMore, onSelect, onSelectOutcome, getEventHref, LinkComponent, onHover, }: EventsV2UIProps): react_jsx_runtime.JSX.Element;
|
|
318
337
|
|
|
319
338
|
type EventItemV2UIProps = {
|
|
320
339
|
event: V2Event;
|
|
340
|
+
/** URL for the detail page. When set, card renders as a link via Linkable. */
|
|
341
|
+
href?: string;
|
|
342
|
+
/** Custom link component (e.g. next/link). Passed to Linkable. */
|
|
343
|
+
LinkComponent?: LinkComponentType;
|
|
321
344
|
onSelect?: (event: V2Event) => void;
|
|
322
345
|
onSelectOutcome?: (event: V2Event, market: V2Market, side: "yes" | "no") => void;
|
|
346
|
+
/** Called when the card is hovered (for data prefetching). */
|
|
347
|
+
onHover?: (event: V2Event) => void;
|
|
323
348
|
};
|
|
324
|
-
declare function EventItemV2UI({ event, onSelect, onSelectOutcome, }: EventItemV2UIProps): react_jsx_runtime.JSX.Element;
|
|
349
|
+
declare function EventItemV2UI({ event, href, LinkComponent, onSelect, onSelectOutcome, onHover, }: EventItemV2UIProps): react_jsx_runtime.JSX.Element;
|
|
325
350
|
|
|
326
351
|
/** Default page size for list queries */
|
|
327
352
|
declare const DEFAULT_PAGE_SIZE = 48;
|