@liberfi.io/ui-predict 0.1.74 → 0.1.76
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 +46 -43
- package/dist/index.d.mts +270 -1416
- package/dist/index.d.ts +270 -1416
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -21
- package/dist/client/index.d.mts +0 -2
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.js +0 -2
- package/dist/client/index.js.map +0 -1
- package/dist/client/index.mjs +0 -2
- package/dist/client/index.mjs.map +0 -1
- package/dist/client-Doli88ls.d.mts +0 -420
- package/dist/client-Doli88ls.d.ts +0 -420
- package/dist/index-BphwuECY.d.mts +0 -1420
- package/dist/index-NXmKF-C9.d.ts +0 -1420
- package/dist/server-CeHdJzO-.d.ts +0 -120
- package/dist/server-f1B7ItWZ.d.mts +0 -120
- package/dist/server.d.mts +0 -2
- package/dist/server.d.ts +0 -2
- package/dist/server.js +0 -2
- package/dist/server.js.map +0 -1
- package/dist/server.mjs +0 -2
- package/dist/server.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,11 +19,12 @@ pnpm add @liberfi.io/ui-predict
|
|
|
19
19
|
|
|
20
20
|
The consumer must provide:
|
|
21
21
|
|
|
22
|
-
| Package
|
|
23
|
-
|
|
|
24
|
-
| `react`
|
|
25
|
-
| `react-dom`
|
|
26
|
-
| `@tanstack/react-query`
|
|
22
|
+
| Package | Version |
|
|
23
|
+
| --------------------------- | -------------------------------- |
|
|
24
|
+
| `react` | >= 18 |
|
|
25
|
+
| `react-dom` | >= 18 |
|
|
26
|
+
| `@tanstack/react-query` | ^5.90.2 |
|
|
27
|
+
| `@liberfi.io/react-predict` | workspace / matching SDK version |
|
|
27
28
|
|
|
28
29
|
## API Reference
|
|
29
30
|
|
|
@@ -35,23 +36,25 @@ The consumer must provide:
|
|
|
35
36
|
| `PredictV2Provider` | `client: PredictClientV2` | Supplies the v2 prediction-server client. |
|
|
36
37
|
| `UserPredictProvider` | `walletAddress: string, enabled: boolean` | Provides user-specific prediction context (positions, orders). |
|
|
37
38
|
|
|
38
|
-
### Components — Events
|
|
39
|
+
### Components — Events
|
|
39
40
|
|
|
40
|
-
| Component
|
|
41
|
-
|
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
41
|
+
| Component | Key Props | Description |
|
|
42
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `EventsPage` | `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Full events page with categories, toolbar, filters, and grid. |
|
|
44
|
+
| `EventsWidget` | `tagSlugSelection`, `limit`, `status`, `sort_by`, `source`, `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Container that wires `useEventsInfinite` data to `EventsUI`. |
|
|
45
|
+
| `EventsUI` | `events`, `hasMore`, `onFetchMore`, `onSelect`, `onSelectOutcome`, `getEventHref`, `LinkComponent`, `onHover` | Virtualized grid (react-window) rendering `EventItem` cards. |
|
|
46
|
+
| `EventItem` | `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. |
|
|
47
|
+
| `EventsToolbarUI` | Sort + filter button props | Toolbar for sort preset and filter modal trigger. |
|
|
48
|
+
| `EventsFilterUI` | Modal filter state props | Filter modal (platform, time, volume, liquidity). |
|
|
49
|
+
| `CategoriesWidget` | `onSelect`, `trailing` | Category/tag navigation (slug-based). |
|
|
47
50
|
|
|
48
51
|
#### Link integration props
|
|
49
52
|
|
|
50
53
|
These props enable framework-agnostic route link rendering and prefetching:
|
|
51
54
|
|
|
52
|
-
- **`getEventHref?: (event:
|
|
55
|
+
- **`getEventHref?: (event: PredictEvent) => string`** — Generates the URL for each event card. When provided, cards render as link elements instead of plain divs.
|
|
53
56
|
- **`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:
|
|
57
|
+
- **`onHover?: (event: PredictEvent) => void`** — Called when a card is hovered (`onMouseEnter`). Use this to trigger data prefetching (e.g. `queryClient.prefetchQuery`).
|
|
55
58
|
|
|
56
59
|
### Components — Event Detail
|
|
57
60
|
|
|
@@ -74,12 +77,12 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
74
77
|
|
|
75
78
|
### Hooks — Events
|
|
76
79
|
|
|
77
|
-
| Hook | Params | Return
|
|
78
|
-
| ------------------------ | ---------------------------- |
|
|
79
|
-
| `
|
|
80
|
-
| `useEventByIdQuery` | `{ id, withNestedMarkets? }` | TanStack Query result
|
|
81
|
-
| `useEventsQuery` | `EventQueryParams` | TanStack Query result
|
|
82
|
-
| `useEventsInfiniteQuery` | `EventQueryParams` | TanStack infinite query
|
|
80
|
+
| Hook | Params | Return | Description |
|
|
81
|
+
| ------------------------ | ---------------------------- | ------------------------- | -------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `useEventsInfinite` | `UseEventsInfiniteParams` | `UseEventsInfiniteResult` | Infinite-scroll events list (flattened pages, cursor-based via `@liberfi.io/react-predict`). |
|
|
83
|
+
| `useEventByIdQuery` | `{ id, withNestedMarkets? }` | TanStack Query result | Single event by ID/slug. |
|
|
84
|
+
| `useEventsQuery` | `EventQueryParams` | TanStack Query result | Legacy paginated events. |
|
|
85
|
+
| `useEventsInfiniteQuery` | `EventQueryParams` | TanStack infinite query | Legacy infinite-scroll events. |
|
|
83
86
|
|
|
84
87
|
### Hooks — Markets & Data
|
|
85
88
|
|
|
@@ -125,11 +128,11 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
125
128
|
|
|
126
129
|
### Hooks — V2
|
|
127
130
|
|
|
128
|
-
| Hook | Description
|
|
129
|
-
| -------------------- |
|
|
130
|
-
| `usePredictV2Client` | Access the v2 prediction-server client.
|
|
131
|
-
| `
|
|
132
|
-
| `useEventV2Query` | V2 single event query.
|
|
131
|
+
| Hook | Description |
|
|
132
|
+
| -------------------- | ------------------------------------------------------------- |
|
|
133
|
+
| `usePredictV2Client` | Access the v2 prediction-server client. |
|
|
134
|
+
| `useEvents` | Events query (single page) — see `@liberfi.io/react-predict`. |
|
|
135
|
+
| `useEventV2Query` | V2 single event query. |
|
|
133
136
|
|
|
134
137
|
### Functions / Utilities
|
|
135
138
|
|
|
@@ -144,16 +147,16 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
144
147
|
|
|
145
148
|
### Key Types
|
|
146
149
|
|
|
147
|
-
| Type | Description
|
|
148
|
-
| ------------------ |
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
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"
|
|
150
|
+
| Type | Description |
|
|
151
|
+
| ------------------ | ----------------------------------------------------------------------- |
|
|
152
|
+
| `PredictEvent` | Event with markets, metadata, and volume (`@liberfi.io/react-predict`). |
|
|
153
|
+
| `PredictMarket` | Market with outcomes, status, and pricing. |
|
|
154
|
+
| `StandardEvent` | Legacy event model. |
|
|
155
|
+
| `StandardMarket` | Legacy market model. |
|
|
156
|
+
| `IPredictClient` | Interface for the prediction API client. |
|
|
157
|
+
| `IPredictWsClient` | Interface for the WebSocket client. |
|
|
158
|
+
| `TagSlugSelection` | Category/tag selection state `{ categorySlug, tagSlug }`. |
|
|
159
|
+
| `ChartRangeType` | `"1d" \| "1w" \| "1m" \| "all"` |
|
|
157
160
|
|
|
158
161
|
### Constants
|
|
159
162
|
|
|
@@ -174,12 +177,12 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
174
177
|
import Link from "next/link";
|
|
175
178
|
import { useRouter } from "next/navigation";
|
|
176
179
|
import {
|
|
177
|
-
|
|
180
|
+
EventsPage,
|
|
178
181
|
eventByIdQueryKey,
|
|
179
182
|
fetchEventById,
|
|
180
183
|
usePredictClient,
|
|
181
184
|
} from "@liberfi.io/ui-predict";
|
|
182
|
-
import type {
|
|
185
|
+
import type { PredictEvent } from "@liberfi.io/ui-predict";
|
|
183
186
|
|
|
184
187
|
function PredictListPage() {
|
|
185
188
|
const router = useRouter();
|
|
@@ -188,7 +191,7 @@ function PredictListPage() {
|
|
|
188
191
|
|
|
189
192
|
// TanStack Query data prefetch on hover
|
|
190
193
|
const handleHover = useCallback(
|
|
191
|
-
(event:
|
|
194
|
+
(event: PredictEvent) => {
|
|
192
195
|
queryClient.prefetchQuery({
|
|
193
196
|
queryKey: eventByIdQueryKey({
|
|
194
197
|
id: event.slug,
|
|
@@ -206,7 +209,7 @@ function PredictListPage() {
|
|
|
206
209
|
);
|
|
207
210
|
|
|
208
211
|
return (
|
|
209
|
-
<
|
|
212
|
+
<EventsPage
|
|
210
213
|
getEventHref={(event) => `/predict/${event.slug}`}
|
|
211
214
|
LinkComponent={Link}
|
|
212
215
|
onHover={handleHover}
|
|
@@ -219,11 +222,11 @@ function PredictListPage() {
|
|
|
219
222
|
### Event list without Link (callback-only, backward compatible)
|
|
220
223
|
|
|
221
224
|
```tsx
|
|
222
|
-
import {
|
|
225
|
+
import { EventsPage } from "@liberfi.io/ui-predict";
|
|
223
226
|
|
|
224
227
|
function PredictListPage() {
|
|
225
228
|
return (
|
|
226
|
-
<
|
|
229
|
+
<EventsPage
|
|
227
230
|
onSelect={(event) => console.log("selected", event.slug)}
|
|
228
231
|
onSelectOutcome={(event, market, side) =>
|
|
229
232
|
console.log("outcome", event.slug, market.slug, side)
|
|
@@ -260,4 +263,4 @@ function App({ children }) {
|
|
|
260
263
|
- Migrate remaining v1 components (events list, categories) to v2 client, then deprecate v1 hooks and types.
|
|
261
264
|
- Add `onHover` callback support to `EventDetailWidget` for prefetching related series/candlestick data.
|
|
262
265
|
- Consider a `usePrefetchEventDetail` convenience hook that combines route prefetch + query prefetch in one call.
|
|
263
|
-
- Extract common virtualized grid logic (`
|
|
266
|
+
- Extract common virtualized grid logic (`EventsUI` pattern) into a shared `@liberfi.io/ui` component for reuse in token lists and channel lists.
|