@ram_28/kf-ai-sdk 1.0.22 → 1.0.23
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/auth.cjs +1 -1
- package/dist/auth.mjs +15 -15
- package/dist/components/hooks/useForm/types.d.ts +3 -5
- package/dist/components/hooks/useForm/types.d.ts.map +1 -1
- package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +193 -194
- package/docs/api.md +648 -0
- package/docs/useFilter.md +58 -18
- package/docs/useForm.md +445 -586
- package/docs/useTable.md +154 -20
- package/package.json +1 -1
- package/sdk/auth/authClient.ts +2 -2
- package/sdk/components/hooks/useForm/types.ts +4 -7
- package/sdk/components/hooks/useForm/useForm.ts +5 -4
package/docs/useTable.md
CHANGED
|
@@ -16,71 +16,204 @@ import type {
|
|
|
16
16
|
|
|
17
17
|
## Type Definitions
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
// Column configuration
|
|
21
|
-
interface ColumnDefinitionType<T> {
|
|
22
|
-
fieldId: keyof T;
|
|
23
|
-
label?: string;
|
|
24
|
-
enableSorting?: boolean;
|
|
25
|
-
enableFiltering?: boolean;
|
|
26
|
-
transform?: (value: any, row: T) => React.ReactNode;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Pagination state
|
|
30
|
-
interface PaginationStateType {
|
|
31
|
-
pageNo: number;
|
|
32
|
-
pageSize: number;
|
|
33
|
-
}
|
|
19
|
+
### UseTableOptionsType
|
|
34
20
|
|
|
35
|
-
|
|
21
|
+
```typescript
|
|
22
|
+
// Hook options for initializing the table
|
|
36
23
|
interface UseTableOptionsType<T> {
|
|
24
|
+
// Business Object ID (required)
|
|
25
|
+
// Example: "BDO_Product", "BDO_Order"
|
|
37
26
|
source: string;
|
|
27
|
+
|
|
28
|
+
// Column configurations (required)
|
|
29
|
+
// Defines which fields to display and their behavior
|
|
38
30
|
columns: ColumnDefinitionType<T>[];
|
|
31
|
+
|
|
32
|
+
// Initial state for the table (optional)
|
|
39
33
|
initialState?: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
// Initial sort configuration
|
|
35
|
+
// Format: [{ "fieldName": "ASC" }] or [{ "fieldName": "DESC" }]
|
|
36
|
+
sort?: SortType;
|
|
37
|
+
|
|
38
|
+
// Initial pagination
|
|
39
|
+
// Defaults: { pageNo: 1, pageSize: 10 }
|
|
40
|
+
pagination?: PaginationStateType;
|
|
41
|
+
|
|
42
|
+
// Initial filter conditions
|
|
43
|
+
// See useFilter docs for full options
|
|
44
|
+
filter?: UseFilterOptionsType<T>;
|
|
43
45
|
};
|
|
46
|
+
|
|
47
|
+
// Called when data fetch fails
|
|
44
48
|
onError?: (error: Error) => void;
|
|
49
|
+
|
|
50
|
+
// Called with fetched data after successful load
|
|
45
51
|
onSuccess?: (data: T[]) => void;
|
|
46
52
|
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### ColumnDefinitionType
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Column configuration for table display
|
|
59
|
+
interface ColumnDefinitionType<T> {
|
|
60
|
+
// Field name from the data type (required)
|
|
61
|
+
fieldId: keyof T;
|
|
62
|
+
|
|
63
|
+
// Display label for column header
|
|
64
|
+
// Defaults to fieldId if not provided
|
|
65
|
+
label?: string;
|
|
66
|
+
|
|
67
|
+
// Enable sorting for this column
|
|
68
|
+
// When true, column header is clickable to toggle sort
|
|
69
|
+
enableSorting?: boolean;
|
|
47
70
|
|
|
48
|
-
//
|
|
71
|
+
// Enable filtering for this column
|
|
72
|
+
// When true, column can be used in filter conditions
|
|
73
|
+
enableFiltering?: boolean;
|
|
74
|
+
|
|
75
|
+
// Custom value transformer for display
|
|
76
|
+
// Receives raw value and full row, returns rendered content
|
|
77
|
+
transform?: (value: any, row: T) => React.ReactNode;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### UseTableReturnType
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
// Hook return type with all table state and methods
|
|
49
85
|
interface UseTableReturnType<T> {
|
|
86
|
+
// ============================================================
|
|
87
|
+
// DATA
|
|
88
|
+
// ============================================================
|
|
89
|
+
|
|
90
|
+
// Current page data (array of records)
|
|
50
91
|
rows: T[];
|
|
92
|
+
|
|
93
|
+
// Total matching records across all pages
|
|
51
94
|
totalItems: number;
|
|
95
|
+
|
|
96
|
+
// ============================================================
|
|
97
|
+
// LOADING STATES
|
|
98
|
+
// ============================================================
|
|
99
|
+
|
|
100
|
+
// True during initial load
|
|
52
101
|
isLoading: boolean;
|
|
102
|
+
|
|
103
|
+
// True during background refetch
|
|
53
104
|
isFetching: boolean;
|
|
105
|
+
|
|
106
|
+
// ============================================================
|
|
107
|
+
// ERROR HANDLING
|
|
108
|
+
// ============================================================
|
|
109
|
+
|
|
110
|
+
// Current error state, null when no error
|
|
54
111
|
error: Error | null;
|
|
112
|
+
|
|
113
|
+
// ============================================================
|
|
114
|
+
// SEARCH (full-text search across all fields)
|
|
115
|
+
// ============================================================
|
|
116
|
+
|
|
55
117
|
search: {
|
|
118
|
+
// Current search query string
|
|
56
119
|
query: string;
|
|
120
|
+
|
|
121
|
+
// Update search query (300ms debounced internally)
|
|
57
122
|
setQuery: (value: string) => void;
|
|
123
|
+
|
|
124
|
+
// Clear search and reset to empty string
|
|
58
125
|
clear: () => void;
|
|
59
126
|
};
|
|
127
|
+
|
|
128
|
+
// ============================================================
|
|
129
|
+
// SORT (single column sorting)
|
|
130
|
+
// ============================================================
|
|
131
|
+
|
|
60
132
|
sort: {
|
|
133
|
+
// Currently sorted field, null if no sort active
|
|
61
134
|
field: keyof T | null;
|
|
135
|
+
|
|
136
|
+
// Current sort direction, null if no sort active
|
|
62
137
|
direction: "asc" | "desc" | null;
|
|
138
|
+
|
|
139
|
+
// Toggle sort on a field
|
|
140
|
+
// Cycles: none → asc → desc → none
|
|
63
141
|
toggle: (field: keyof T) => void;
|
|
142
|
+
|
|
143
|
+
// Clear sorting (return to default order)
|
|
64
144
|
clear: () => void;
|
|
145
|
+
|
|
146
|
+
// Set explicit sort field and direction
|
|
65
147
|
set: (field: keyof T, direction: "asc" | "desc") => void;
|
|
66
148
|
};
|
|
149
|
+
|
|
150
|
+
// ============================================================
|
|
151
|
+
// FILTER (see useFilter docs for full API)
|
|
152
|
+
// ============================================================
|
|
153
|
+
|
|
154
|
+
// Full useFilter return type
|
|
155
|
+
// Includes addCondition, removeCondition, clearAllConditions, etc.
|
|
67
156
|
filter: UseFilterReturnType<T>;
|
|
157
|
+
|
|
158
|
+
// ============================================================
|
|
159
|
+
// PAGINATION (1-indexed pages)
|
|
160
|
+
// ============================================================
|
|
161
|
+
|
|
68
162
|
pagination: {
|
|
163
|
+
// Current page number (1-indexed, starts at 1)
|
|
69
164
|
pageNo: number;
|
|
165
|
+
|
|
166
|
+
// Number of items per page
|
|
70
167
|
pageSize: number;
|
|
168
|
+
|
|
169
|
+
// Total number of pages
|
|
71
170
|
totalPages: number;
|
|
171
|
+
|
|
172
|
+
// Total matching records (same as top-level totalItems)
|
|
72
173
|
totalItems: number;
|
|
174
|
+
|
|
175
|
+
// True if there's a next page available
|
|
73
176
|
canGoNext: boolean;
|
|
177
|
+
|
|
178
|
+
// True if there's a previous page available
|
|
74
179
|
canGoPrevious: boolean;
|
|
180
|
+
|
|
181
|
+
// Navigate to next page
|
|
75
182
|
goToNext: () => void;
|
|
183
|
+
|
|
184
|
+
// Navigate to previous page
|
|
76
185
|
goToPrevious: () => void;
|
|
186
|
+
|
|
187
|
+
// Navigate to specific page number (1-indexed)
|
|
77
188
|
goToPage: (page: number) => void;
|
|
189
|
+
|
|
190
|
+
// Change items per page (resets to page 1)
|
|
78
191
|
setPageSize: (size: number) => void;
|
|
79
192
|
};
|
|
193
|
+
|
|
194
|
+
// ============================================================
|
|
195
|
+
// OPERATIONS
|
|
196
|
+
// ============================================================
|
|
197
|
+
|
|
198
|
+
// Manually trigger data refetch
|
|
199
|
+
// Returns promise with the list response
|
|
80
200
|
refetch: () => Promise<ListResponseType<T>>;
|
|
81
201
|
}
|
|
82
202
|
```
|
|
83
203
|
|
|
204
|
+
### PaginationStateType
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
// Pagination state for initial configuration
|
|
208
|
+
interface PaginationStateType {
|
|
209
|
+
// Page number (1-indexed)
|
|
210
|
+
pageNo: number;
|
|
211
|
+
|
|
212
|
+
// Number of items per page
|
|
213
|
+
pageSize: number;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
84
217
|
## Basic Example
|
|
85
218
|
|
|
86
219
|
A minimal table displaying data with loading and error states.
|
|
@@ -881,3 +1014,4 @@ function ProductListPage() {
|
|
|
881
1014
|
);
|
|
882
1015
|
}
|
|
883
1016
|
```
|
|
1017
|
+
|
package/package.json
CHANGED
package/sdk/auth/authClient.ts
CHANGED
|
@@ -138,8 +138,8 @@ export function initiateLogin(
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
window.
|
|
142
|
-
// Promise never resolves -
|
|
141
|
+
window.open(loginUrl.toString(), '_blank');
|
|
142
|
+
// Promise never resolves - login opens in new tab
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -536,15 +536,12 @@ export interface UseFormReturnType<
|
|
|
536
536
|
// LOADING STATES
|
|
537
537
|
// ============================================================
|
|
538
538
|
|
|
539
|
-
/**
|
|
540
|
-
isLoadingInitialData: boolean;
|
|
541
|
-
|
|
542
|
-
/** Loading record data for update */
|
|
543
|
-
isLoadingRecord: boolean;
|
|
544
|
-
|
|
545
|
-
/** Any loading state active */
|
|
539
|
+
/** True during initial load */
|
|
546
540
|
isLoading: boolean;
|
|
547
541
|
|
|
542
|
+
/** True during background operations */
|
|
543
|
+
isFetching: boolean;
|
|
544
|
+
|
|
548
545
|
// ============================================================
|
|
549
546
|
// INTERACTIVE MODE STATE
|
|
550
547
|
// ============================================================
|
|
@@ -815,11 +815,13 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
815
815
|
// ============================================================
|
|
816
816
|
|
|
817
817
|
// Loading state includes interactive mode draft creation
|
|
818
|
-
const
|
|
818
|
+
const isLoading =
|
|
819
819
|
isLoadingSchema ||
|
|
820
820
|
(operation === "update" && isLoadingRecord) ||
|
|
821
821
|
(isInteractiveMode && operation === "create" && isCreatingDraft);
|
|
822
|
-
|
|
822
|
+
|
|
823
|
+
// Background operations (submission)
|
|
824
|
+
const isFetching = isSubmitting;
|
|
823
825
|
const loadError = schemaError || recordError || draftError;
|
|
824
826
|
const hasError = !!loadError;
|
|
825
827
|
|
|
@@ -974,9 +976,8 @@ export function useForm<T extends Record<string, any> = Record<string, any>>(
|
|
|
974
976
|
isSubmitSuccessful: rhfForm.formState.isSubmitSuccessful,
|
|
975
977
|
|
|
976
978
|
// Loading states
|
|
977
|
-
isLoadingInitialData,
|
|
978
|
-
isLoadingRecord,
|
|
979
979
|
isLoading,
|
|
980
|
+
isFetching,
|
|
980
981
|
|
|
981
982
|
// Interactive mode state
|
|
982
983
|
draftId,
|