@liberfi.io/ui-predict 0.1.75 → 0.1.77
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 -41
- package/dist/index.d.mts +277 -1417
- package/dist/index.d.ts +277 -1417
- 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,27 @@ 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
41
|
| Component | Key Props | Description |
|
|
41
42
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
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
|
+
| `EventsSkeleton` | `count?` | Grid skeleton used while events cards are loading. |
|
|
50
|
+
| `EventsPageSkeleton` | `count?` | Page-level skeleton including category/toolbar placeholders + events grid skeleton. |
|
|
51
|
+
| `CategoriesWidget` | `onSelect`, `trailing` | Category/tag navigation (slug-based). |
|
|
47
52
|
|
|
48
53
|
#### Link integration props
|
|
49
54
|
|
|
50
55
|
These props enable framework-agnostic route link rendering and prefetching:
|
|
51
56
|
|
|
52
|
-
- **`getEventHref?: (event:
|
|
57
|
+
- **`getEventHref?: (event: PredictEvent) => string`** — Generates the URL for each event card. When provided, cards render as link elements instead of plain divs.
|
|
53
58
|
- **`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:
|
|
59
|
+
- **`onHover?: (event: PredictEvent) => void`** — Called when a card is hovered (`onMouseEnter`). Use this to trigger data prefetching (e.g. `queryClient.prefetchQuery`).
|
|
55
60
|
|
|
56
61
|
### Components — Event Detail
|
|
57
62
|
|
|
@@ -74,12 +79,12 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
74
79
|
|
|
75
80
|
### Hooks — Events
|
|
76
81
|
|
|
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
|
|
82
|
+
| Hook | Params | Return | Description |
|
|
83
|
+
| ------------------------ | ---------------------------- | ------------------------- | -------------------------------------------------------------------------------------------- |
|
|
84
|
+
| `useEventsInfinite` | `UseEventsInfiniteParams` | `UseEventsInfiniteResult` | Infinite-scroll events list (flattened pages, cursor-based via `@liberfi.io/react-predict`). |
|
|
85
|
+
| `useEventByIdQuery` | `{ id, withNestedMarkets? }` | TanStack Query result | Single event by ID/slug. |
|
|
86
|
+
| `useEventsQuery` | `EventQueryParams` | TanStack Query result | Legacy paginated events. |
|
|
87
|
+
| `useEventsInfiniteQuery` | `EventQueryParams` | TanStack infinite query | Legacy infinite-scroll events. |
|
|
83
88
|
|
|
84
89
|
### Hooks — Markets & Data
|
|
85
90
|
|
|
@@ -125,11 +130,11 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
125
130
|
|
|
126
131
|
### Hooks — V2
|
|
127
132
|
|
|
128
|
-
| Hook | Description
|
|
129
|
-
| -------------------- |
|
|
130
|
-
| `usePredictV2Client` | Access the v2 prediction-server client.
|
|
131
|
-
| `
|
|
132
|
-
| `useEventV2Query` | V2 single event query.
|
|
133
|
+
| Hook | Description |
|
|
134
|
+
| -------------------- | ------------------------------------------------------------- |
|
|
135
|
+
| `usePredictV2Client` | Access the v2 prediction-server client. |
|
|
136
|
+
| `useEvents` | Events query (single page) — see `@liberfi.io/react-predict`. |
|
|
137
|
+
| `useEventV2Query` | V2 single event query. |
|
|
133
138
|
|
|
134
139
|
### Functions / Utilities
|
|
135
140
|
|
|
@@ -144,16 +149,16 @@ These props enable framework-agnostic route link rendering and prefetching:
|
|
|
144
149
|
|
|
145
150
|
### Key Types
|
|
146
151
|
|
|
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"
|
|
152
|
+
| Type | Description |
|
|
153
|
+
| ------------------ | ----------------------------------------------------------------------- |
|
|
154
|
+
| `PredictEvent` | Event with markets, metadata, and volume (`@liberfi.io/react-predict`). |
|
|
155
|
+
| `PredictMarket` | Market with outcomes, status, and pricing. |
|
|
156
|
+
| `StandardEvent` | Legacy event model. |
|
|
157
|
+
| `StandardMarket` | Legacy market model. |
|
|
158
|
+
| `IPredictClient` | Interface for the prediction API client. |
|
|
159
|
+
| `IPredictWsClient` | Interface for the WebSocket client. |
|
|
160
|
+
| `TagSlugSelection` | Category/tag selection state `{ categorySlug, tagSlug }`. |
|
|
161
|
+
| `ChartRangeType` | `"1d" \| "1w" \| "1m" \| "all"` |
|
|
157
162
|
|
|
158
163
|
### Constants
|
|
159
164
|
|
|
@@ -174,12 +179,12 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
174
179
|
import Link from "next/link";
|
|
175
180
|
import { useRouter } from "next/navigation";
|
|
176
181
|
import {
|
|
177
|
-
|
|
182
|
+
EventsPage,
|
|
178
183
|
eventByIdQueryKey,
|
|
179
184
|
fetchEventById,
|
|
180
185
|
usePredictClient,
|
|
181
186
|
} from "@liberfi.io/ui-predict";
|
|
182
|
-
import type {
|
|
187
|
+
import type { PredictEvent } from "@liberfi.io/ui-predict";
|
|
183
188
|
|
|
184
189
|
function PredictListPage() {
|
|
185
190
|
const router = useRouter();
|
|
@@ -188,7 +193,7 @@ function PredictListPage() {
|
|
|
188
193
|
|
|
189
194
|
// TanStack Query data prefetch on hover
|
|
190
195
|
const handleHover = useCallback(
|
|
191
|
-
(event:
|
|
196
|
+
(event: PredictEvent) => {
|
|
192
197
|
queryClient.prefetchQuery({
|
|
193
198
|
queryKey: eventByIdQueryKey({
|
|
194
199
|
id: event.slug,
|
|
@@ -206,7 +211,7 @@ function PredictListPage() {
|
|
|
206
211
|
);
|
|
207
212
|
|
|
208
213
|
return (
|
|
209
|
-
<
|
|
214
|
+
<EventsPage
|
|
210
215
|
getEventHref={(event) => `/predict/${event.slug}`}
|
|
211
216
|
LinkComponent={Link}
|
|
212
217
|
onHover={handleHover}
|
|
@@ -219,11 +224,11 @@ function PredictListPage() {
|
|
|
219
224
|
### Event list without Link (callback-only, backward compatible)
|
|
220
225
|
|
|
221
226
|
```tsx
|
|
222
|
-
import {
|
|
227
|
+
import { EventsPage } from "@liberfi.io/ui-predict";
|
|
223
228
|
|
|
224
229
|
function PredictListPage() {
|
|
225
230
|
return (
|
|
226
|
-
<
|
|
231
|
+
<EventsPage
|
|
227
232
|
onSelect={(event) => console.log("selected", event.slug)}
|
|
228
233
|
onSelectOutcome={(event, market, side) =>
|
|
229
234
|
console.log("outcome", event.slug, market.slug, side)
|
|
@@ -260,4 +265,4 @@ function App({ children }) {
|
|
|
260
265
|
- Migrate remaining v1 components (events list, categories) to v2 client, then deprecate v1 hooks and types.
|
|
261
266
|
- Add `onHover` callback support to `EventDetailWidget` for prefetching related series/candlestick data.
|
|
262
267
|
- Consider a `usePrefetchEventDetail` convenience hook that combines route prefetch + query prefetch in one call.
|
|
263
|
-
- Extract common virtualized grid logic (`
|
|
268
|
+
- Extract common virtualized grid logic (`EventsUI` pattern) into a shared `@liberfi.io/ui` component for reuse in token lists and channel lists.
|