@ram_28/kf-ai-sdk 2.0.20-beta.2 → 2.0.21
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 +16 -8
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +1 -1
- package/dist/auth/authConfig.d.ts +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/bdo/core/Item.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +1 -1
- package/dist/components/hooks/useActivityForm/types.d.ts +4 -5
- package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/types.d.ts +5 -4
- package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +2 -2
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/types.d.ts +20 -12
- package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
- package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
- package/dist/{constants-ConHc1oS.js → constants-Cyi942Yr.js} +5 -5
- package/dist/constants-DEmYwKfC.cjs +1 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +15 -16
- package/dist/table.types.d.ts +1 -1
- package/dist/table.types.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/workflow/Activity.d.ts +8 -5
- package/dist/workflow/Activity.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +461 -476
- package/docs/README.md +57 -0
- package/docs/bdo/README.md +161 -0
- package/docs/bdo/api_reference.md +281 -0
- package/docs/examples/bdo/create-product.md +69 -0
- package/docs/examples/bdo/edit-product-dialog.md +95 -0
- package/docs/examples/bdo/filtered-product-table.md +100 -0
- package/docs/examples/bdo/product-listing.md +73 -0
- package/docs/examples/bdo/supplier-dropdown.md +60 -0
- package/docs/examples/fields/complex-fields.md +248 -0
- package/docs/examples/fields/primitive-fields.md +217 -0
- package/docs/examples/workflow/approve-leave-request.md +76 -0
- package/docs/examples/workflow/filtered-activity-table.md +101 -0
- package/docs/examples/workflow/my-pending-requests.md +90 -0
- package/docs/examples/workflow/start-new-workflow.md +47 -0
- package/docs/examples/workflow/submit-leave-request.md +72 -0
- package/docs/examples/workflow/workflow-progress.md +49 -0
- package/docs/fields/README.md +141 -0
- package/docs/fields/api_reference.md +134 -0
- package/docs/useActivityForm/README.md +244 -0
- package/docs/useActivityForm/api_reference.md +279 -0
- package/docs/useActivityTable/README.md +263 -0
- package/docs/useActivityTable/api_reference.md +294 -0
- package/docs/useBDOForm/README.md +175 -0
- package/docs/useBDOForm/api_reference.md +244 -0
- package/docs/useBDOTable/README.md +242 -0
- package/docs/useBDOTable/api_reference.md +253 -0
- package/docs/useFilter/README.md +323 -0
- package/docs/useFilter/api_reference.md +228 -0
- package/docs/workflow/README.md +158 -0
- package/docs/workflow/api_reference.md +161 -0
- package/package.json +15 -14
- package/sdk/auth/authConfig.ts +1 -1
- package/sdk/auth/types.ts +1 -1
- package/sdk/bdo/core/Item.ts +2 -1
- package/sdk/bdo/expressions/evaluator.ts +8 -4
- package/sdk/components/hooks/useActivityForm/types.ts +4 -6
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +10 -73
- package/sdk/components/hooks/useActivityTable/types.ts +4 -5
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +10 -8
- package/sdk/components/hooks/useBDOForm/createItemProxy.ts +9 -5
- package/sdk/components/hooks/useBDOTable/types.ts +20 -10
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +12 -8
- package/sdk/table.types.ts +2 -0
- package/sdk/types/constants.ts +1 -1
- package/sdk/workflow/Activity.ts +39 -7
- package/dist/constants-QX2RX-wu.cjs +0 -1
- package/docs/api.md +0 -95
- package/docs/bdo.md +0 -224
- package/docs/gaps.md +0 -360
- package/docs/useActivityForm.md +0 -393
- package/docs/useActivityTable.md +0 -418
- package/docs/useBDOForm.md +0 -498
- package/docs/useBDOTable.md +0 -284
- package/docs/useFilter.md +0 -188
- package/docs/workflow.md +0 -560
- /package/docs/{useAuth.md → useAuth/README.md} +0 -0
package/docs/useActivityTable.md
DELETED
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
# useActivityTable
|
|
2
|
-
|
|
3
|
-
Hook for listing workflow activity (business process) instances with search, sort, filter, and pagination.
|
|
4
|
-
|
|
5
|
-
## Imports
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { useActivityTable, ActivityTableStatus } from "@ram_28/kf-ai-sdk/workflow";
|
|
9
|
-
import type {
|
|
10
|
-
UseActivityTableOptionsType,
|
|
11
|
-
UseActivityTableReturnType,
|
|
12
|
-
ActivityRowType,
|
|
13
|
-
ActivityInstanceFieldsType,
|
|
14
|
-
} from "@ram_28/kf-ai-sdk/workflow";
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Common Mistakes (READ FIRST)
|
|
20
|
-
|
|
21
|
-
### 1. Passing a Workflow instead of an Activity
|
|
22
|
-
|
|
23
|
-
The `activity` property must be an `Activity` instance, not a `Workflow` instance.
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
// ❌ WRONG — passing the workflow class
|
|
27
|
-
const wf = new SimpleLeaveProcess();
|
|
28
|
-
useActivityTable({ activity: wf, status: ActivityTableStatus.InProgress });
|
|
29
|
-
|
|
30
|
-
// ✅ CORRECT — pass the activity instance
|
|
31
|
-
const activity = new SimpleLeaveProcess().employeeInputActivity();
|
|
32
|
-
useActivityTable({ activity, status: ActivityTableStatus.InProgress });
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 2. Using string literals instead of ActivityTableStatus
|
|
36
|
-
|
|
37
|
-
While string literals work at runtime, always use the `ActivityTableStatus` constant for type safety and readability.
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
// ❌ WRONG — raw string (no type safety, easy to typo)
|
|
41
|
-
useActivityTable({ activity, status: "inProgress" });
|
|
42
|
-
useActivityTable({ activity, status: "in_progress" });
|
|
43
|
-
|
|
44
|
-
// ✅ CORRECT — use the constant
|
|
45
|
-
useActivityTable({ activity, status: ActivityTableStatus.InProgress });
|
|
46
|
-
useActivityTable({ activity, status: ActivityTableStatus.Completed });
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### 3. Forgetting to memoize the activity instance
|
|
50
|
-
|
|
51
|
-
Like BDO instances passed to `useBDOTable`, the activity instance should be memoized to prevent unnecessary re-renders and refetches.
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
// ❌ WRONG — creates a new activity on every render
|
|
55
|
-
const activity = new SimpleLeaveProcess().employeeInputActivity();
|
|
56
|
-
useActivityTable({ activity, status: ActivityTableStatus.InProgress });
|
|
57
|
-
|
|
58
|
-
// ✅ CORRECT — memoize with useMemo
|
|
59
|
-
const activity = useMemo(
|
|
60
|
-
() => new SimpleLeaveProcess().employeeInputActivity(),
|
|
61
|
-
[],
|
|
62
|
-
);
|
|
63
|
-
useActivityTable({ activity, status: ActivityTableStatus.InProgress });
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 4. Calling `.get()` on activity table rows
|
|
67
|
-
|
|
68
|
-
Table rows are plain objects, not `ActivityInstance` proxies. There is no `.get()` method.
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
// ❌ WRONG — rows are plain objects
|
|
72
|
-
row.StartDate.get();
|
|
73
|
-
row.Status.get();
|
|
74
|
-
|
|
75
|
-
// ✅ CORRECT — access values directly
|
|
76
|
-
row.StartDate;
|
|
77
|
-
row.Status;
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Example: Employee Leave Request Table
|
|
83
|
-
|
|
84
|
-
Display in-progress leave requests with search, pagination, and a detail view.
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
import { useMemo, useState } from "react";
|
|
88
|
-
import { useActivityTable, ActivityTableStatus } from "@ram_28/kf-ai-sdk/workflow";
|
|
89
|
-
import type { ActivityRowType } from "@ram_28/kf-ai-sdk/workflow";
|
|
90
|
-
import {
|
|
91
|
-
SimpleLeaveProcess,
|
|
92
|
-
EmployeeInputActivity,
|
|
93
|
-
} from "@/bdo/workflows/SimpleLeaveProcess";
|
|
94
|
-
|
|
95
|
-
function EmployeeLeaveTable() {
|
|
96
|
-
const activity = useMemo(() => new SimpleLeaveProcess().employeeInputActivity(), []);
|
|
97
|
-
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
98
|
-
|
|
99
|
-
const {
|
|
100
|
-
rows,
|
|
101
|
-
totalItems,
|
|
102
|
-
isLoading,
|
|
103
|
-
isFetching,
|
|
104
|
-
error,
|
|
105
|
-
search,
|
|
106
|
-
sort,
|
|
107
|
-
pagination,
|
|
108
|
-
refetch,
|
|
109
|
-
} = useActivityTable({
|
|
110
|
-
activity,
|
|
111
|
-
status: ActivityTableStatus.InProgress,
|
|
112
|
-
initialState: {
|
|
113
|
-
pagination: { pageNo: 1, pageSize: 10 },
|
|
114
|
-
},
|
|
115
|
-
onError: (err) => console.error("Failed to load leave requests:", err.message),
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
if (isLoading) return <div>Loading...</div>;
|
|
119
|
-
if (error) return <div>Error: {error.message}</div>;
|
|
120
|
-
|
|
121
|
-
return (
|
|
122
|
-
<div>
|
|
123
|
-
<h2>My Leave Requests ({totalItems})</h2>
|
|
124
|
-
|
|
125
|
-
{/* Search */}
|
|
126
|
-
<div>
|
|
127
|
-
<input
|
|
128
|
-
type="text"
|
|
129
|
-
placeholder="Search by leave type..."
|
|
130
|
-
value={search.query}
|
|
131
|
-
onChange={(e) => search.set(activity.LeaveType.id, e.target.value)}
|
|
132
|
-
/>
|
|
133
|
-
{search.query && <button onClick={search.clear}>Clear</button>}
|
|
134
|
-
{isFetching && <span>Loading...</span>}
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
{/* Table */}
|
|
138
|
-
<table>
|
|
139
|
-
<thead>
|
|
140
|
-
<tr>
|
|
141
|
-
<th>ID</th>
|
|
142
|
-
<th>Status</th>
|
|
143
|
-
<th>Assigned To</th>
|
|
144
|
-
<th
|
|
145
|
-
style={{ cursor: "pointer" }}
|
|
146
|
-
onClick={() => sort.toggle(activity.LeaveType.id)}
|
|
147
|
-
>
|
|
148
|
-
Leave Type
|
|
149
|
-
</th>
|
|
150
|
-
<th>Start Date</th>
|
|
151
|
-
<th>End Date</th>
|
|
152
|
-
<th>Days</th>
|
|
153
|
-
<th>Action</th>
|
|
154
|
-
</tr>
|
|
155
|
-
</thead>
|
|
156
|
-
<tbody>
|
|
157
|
-
{rows.map((row) => (
|
|
158
|
-
<tr key={row._id}>
|
|
159
|
-
<td>{row._id}</td>
|
|
160
|
-
<td>{row.Status}</td>
|
|
161
|
-
<td>{row.AssignedTo.map((u) => u._name).join(", ")}</td>
|
|
162
|
-
<td>{row.LeaveType}</td>
|
|
163
|
-
<td>{row.StartDate}</td>
|
|
164
|
-
<td>{row.EndDate}</td>
|
|
165
|
-
<td>{row.LeaveDays}</td>
|
|
166
|
-
<td>
|
|
167
|
-
<button onClick={() => setSelectedId(row._id)}>View</button>
|
|
168
|
-
</td>
|
|
169
|
-
</tr>
|
|
170
|
-
))}
|
|
171
|
-
</tbody>
|
|
172
|
-
</table>
|
|
173
|
-
|
|
174
|
-
{/* Pagination */}
|
|
175
|
-
<div>
|
|
176
|
-
<button
|
|
177
|
-
onClick={pagination.goToPrevious}
|
|
178
|
-
disabled={!pagination.canGoPrevious}
|
|
179
|
-
>
|
|
180
|
-
Previous
|
|
181
|
-
</button>
|
|
182
|
-
<span>
|
|
183
|
-
Page {pagination.pageNo} of {pagination.totalPages}
|
|
184
|
-
</span>
|
|
185
|
-
<button
|
|
186
|
-
onClick={pagination.goToNext}
|
|
187
|
-
disabled={!pagination.canGoNext}
|
|
188
|
-
>
|
|
189
|
-
Next
|
|
190
|
-
</button>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
## Example: Manager Approval Table
|
|
200
|
-
|
|
201
|
-
Display pending approvals with status tabs for in-progress and completed items.
|
|
202
|
-
|
|
203
|
-
```tsx
|
|
204
|
-
import { useMemo, useState } from "react";
|
|
205
|
-
import {
|
|
206
|
-
useActivityTable,
|
|
207
|
-
ActivityTableStatus,
|
|
208
|
-
} from "@ram_28/kf-ai-sdk/workflow";
|
|
209
|
-
import type { ActivityRowType } from "@ram_28/kf-ai-sdk/workflow";
|
|
210
|
-
import { SimpleLeaveProcess } from "@/bdo/workflows/SimpleLeaveProcess";
|
|
211
|
-
|
|
212
|
-
type StatusTab = "inprogress" | "completed";
|
|
213
|
-
|
|
214
|
-
function ManagerApprovalTable() {
|
|
215
|
-
const activity = useMemo(
|
|
216
|
-
() => new SimpleLeaveProcess().managerApprovalActivity(),
|
|
217
|
-
[],
|
|
218
|
-
);
|
|
219
|
-
const [activeTab, setActiveTab] = useState<StatusTab>("inprogress");
|
|
220
|
-
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
221
|
-
|
|
222
|
-
const {
|
|
223
|
-
rows,
|
|
224
|
-
totalItems,
|
|
225
|
-
isLoading,
|
|
226
|
-
isFetching,
|
|
227
|
-
error,
|
|
228
|
-
search,
|
|
229
|
-
sort,
|
|
230
|
-
filter,
|
|
231
|
-
pagination,
|
|
232
|
-
refetch,
|
|
233
|
-
} = useActivityTable({
|
|
234
|
-
activity,
|
|
235
|
-
status: activeTab,
|
|
236
|
-
initialState: {
|
|
237
|
-
pagination: { pageNo: 1, pageSize: 10 },
|
|
238
|
-
},
|
|
239
|
-
onError: (err) => console.error("Fetch failed:", err.message),
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
if (selectedId) {
|
|
243
|
-
return (
|
|
244
|
-
<ApprovalForm
|
|
245
|
-
activityInstanceId={selectedId}
|
|
246
|
-
onComplete={() => {
|
|
247
|
-
setSelectedId(null);
|
|
248
|
-
refetch();
|
|
249
|
-
}}
|
|
250
|
-
/>
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return (
|
|
255
|
-
<div>
|
|
256
|
-
{/* Status tabs */}
|
|
257
|
-
<div>
|
|
258
|
-
<button
|
|
259
|
-
onClick={() => setActiveTab("inprogress")}
|
|
260
|
-
disabled={activeTab === "inprogress"}
|
|
261
|
-
>
|
|
262
|
-
Pending
|
|
263
|
-
</button>
|
|
264
|
-
<button
|
|
265
|
-
onClick={() => setActiveTab("completed")}
|
|
266
|
-
disabled={activeTab === "completed"}
|
|
267
|
-
>
|
|
268
|
-
Completed
|
|
269
|
-
</button>
|
|
270
|
-
</div>
|
|
271
|
-
|
|
272
|
-
<h2>
|
|
273
|
-
{activeTab === "inprogress" ? "Pending" : "Completed"} Approvals ({totalItems})
|
|
274
|
-
</h2>
|
|
275
|
-
|
|
276
|
-
{isLoading && <div>Loading...</div>}
|
|
277
|
-
{error && <div>Error: {error.message}</div>}
|
|
278
|
-
|
|
279
|
-
{/* Table */}
|
|
280
|
-
<table>
|
|
281
|
-
<thead>
|
|
282
|
-
<tr>
|
|
283
|
-
<th>ID</th>
|
|
284
|
-
<th
|
|
285
|
-
style={{ cursor: "pointer" }}
|
|
286
|
-
onClick={() => sort.toggle("Status")}
|
|
287
|
-
>
|
|
288
|
-
Status
|
|
289
|
-
{sort.field === "Status" && (
|
|
290
|
-
<span>{sort.direction === "ASC" ? " ↑" : " ↓"}</span>
|
|
291
|
-
)}
|
|
292
|
-
</th>
|
|
293
|
-
<th>Assigned To</th>
|
|
294
|
-
<th>Approved</th>
|
|
295
|
-
<th>Reason</th>
|
|
296
|
-
{activeTab === "inprogress" && <th>Action</th>}
|
|
297
|
-
</tr>
|
|
298
|
-
</thead>
|
|
299
|
-
<tbody>
|
|
300
|
-
{rows.map((row) => (
|
|
301
|
-
<tr key={row._id}>
|
|
302
|
-
<td>{row._id}</td>
|
|
303
|
-
<td>{row.Status}</td>
|
|
304
|
-
<td>{row.AssignedTo.map((u) => u._name).join(", ")}</td>
|
|
305
|
-
<td>{row.ManagerApproved ? "Yes" : "No"}</td>
|
|
306
|
-
<td>{row.ManagerReason}</td>
|
|
307
|
-
{activeTab === "inprogress" && (
|
|
308
|
-
<td>
|
|
309
|
-
<button onClick={() => setSelectedId(row._id)}>Review</button>
|
|
310
|
-
</td>
|
|
311
|
-
)}
|
|
312
|
-
</tr>
|
|
313
|
-
))}
|
|
314
|
-
</tbody>
|
|
315
|
-
</table>
|
|
316
|
-
|
|
317
|
-
{/* Pagination */}
|
|
318
|
-
<div>
|
|
319
|
-
<button
|
|
320
|
-
onClick={pagination.goToPrevious}
|
|
321
|
-
disabled={!pagination.canGoPrevious}
|
|
322
|
-
>
|
|
323
|
-
Previous
|
|
324
|
-
</button>
|
|
325
|
-
<span>
|
|
326
|
-
Page {pagination.pageNo} of {pagination.totalPages}
|
|
327
|
-
</span>
|
|
328
|
-
<button
|
|
329
|
-
onClick={pagination.goToNext}
|
|
330
|
-
disabled={!pagination.canGoNext}
|
|
331
|
-
>
|
|
332
|
-
Next
|
|
333
|
-
</button>
|
|
334
|
-
<select
|
|
335
|
-
value={pagination.pageSize}
|
|
336
|
-
onChange={(e) => pagination.setPageSize(Number(e.target.value))}
|
|
337
|
-
>
|
|
338
|
-
<option value={10}>10 per page</option>
|
|
339
|
-
<option value={25}>25 per page</option>
|
|
340
|
-
<option value={50}>50 per page</option>
|
|
341
|
-
</select>
|
|
342
|
-
</div>
|
|
343
|
-
</div>
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
---
|
|
349
|
-
|
|
350
|
-
## Type Definitions
|
|
351
|
-
|
|
352
|
-
### ActivityTableStatus
|
|
353
|
-
|
|
354
|
-
```typescript
|
|
355
|
-
export const ActivityTableStatus = {
|
|
356
|
-
InProgress: "inprogress",
|
|
357
|
-
Completed: "completed",
|
|
358
|
-
} as const;
|
|
359
|
-
|
|
360
|
-
export type ActivityTableStatusType =
|
|
361
|
-
(typeof ActivityTableStatus)[keyof typeof ActivityTableStatus];
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### ActivityRowType\<A\>
|
|
365
|
-
|
|
366
|
-
Row type for activity table data. System fields and entity fields are flat at the top level.
|
|
367
|
-
|
|
368
|
-
```typescript
|
|
369
|
-
export type ActivityRowType<A extends Activity<any, any, any>> =
|
|
370
|
-
A extends Activity<infer E, any, any>
|
|
371
|
-
? ActivityInstanceFieldsType & E
|
|
372
|
-
: never;
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
### UseActivityTableOptionsType\<A\>
|
|
376
|
-
|
|
377
|
-
```typescript
|
|
378
|
-
export interface UseActivityTableOptionsType<A extends Activity<any, any, any>> {
|
|
379
|
-
/** The activity instance to fetch data for */
|
|
380
|
-
activity: A;
|
|
381
|
-
|
|
382
|
-
/** Which activity instances to fetch — determines endpoint */
|
|
383
|
-
status: ActivityTableStatusType;
|
|
384
|
-
|
|
385
|
-
/** Initial state for sort, pagination, and filter */
|
|
386
|
-
initialState?: {
|
|
387
|
-
sort?: SortType;
|
|
388
|
-
pagination?: PaginationStateType;
|
|
389
|
-
filter?: UseFilterOptionsType<ActivityRowType<A>>;
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
/** Called when data fetch fails */
|
|
393
|
-
onError?: (error: Error) => void;
|
|
394
|
-
|
|
395
|
-
/** Called with fetched rows after successful load */
|
|
396
|
-
onSuccess?: (data: ActivityRowType<A>[]) => void;
|
|
397
|
-
}
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
### UseActivityTableReturnType\<A\>
|
|
401
|
-
|
|
402
|
-
```typescript
|
|
403
|
-
export type UseActivityTableReturnType<A extends Activity<any, any, any>> =
|
|
404
|
-
UseTableReturnType<ActivityRowType<A>>;
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
The return type is identical to `UseTableReturnType`. All properties — `rows`, `totalItems`, `isLoading`, `isFetching`, `error`, `search`, `sort`, `filter`, `pagination`, and `refetch` — behave the same.
|
|
408
|
-
|
|
409
|
-
---
|
|
410
|
-
|
|
411
|
-
## Search, Sort, Filter, and Pagination
|
|
412
|
-
|
|
413
|
-
`useActivityTable` supports `initialState`, `onError`, and `onSuccess` options.
|
|
414
|
-
|
|
415
|
-
- **Search** — `search.set(field, query)`, `search.clear()`, 300ms debounce
|
|
416
|
-
- **Sort** — `sort.toggle(field)`, `sort.set(field, direction)`, `sort.clear()`
|
|
417
|
-
- **Filter** — `filter.addCondition(...)`, `filter.removeCondition(...)`, `filter.clearAllConditions()`
|
|
418
|
-
- **Pagination** — `pagination.goToNext()`, `pagination.goToPrevious()`, `pagination.goToPage(n)`, `pagination.setPageSize(n)`
|