@panneau/data 4.0.11 → 4.0.15
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/index.d.ts +460 -0
- package/{es → dist}/index.js +34 -48
- package/package.json +12 -10
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
declare function useData(loadData: any, { initialData, autoload }?: {
|
|
8
|
+
initialData?: any;
|
|
9
|
+
autoload?: boolean;
|
|
10
|
+
}): {
|
|
11
|
+
data: any;
|
|
12
|
+
load: (...args: any[]) => any;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
error: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
declare function useItems$1({ store, url, paginated: initialPaginated, query: initialQuery, onQueryChange, queryConfig, keepData, ...oldProps }: {
|
|
18
|
+
[x: string]: any;
|
|
19
|
+
store: any;
|
|
20
|
+
url: any;
|
|
21
|
+
paginated?: boolean;
|
|
22
|
+
query?: any;
|
|
23
|
+
onQueryChange: any;
|
|
24
|
+
queryConfig?: any;
|
|
25
|
+
keepData?: boolean;
|
|
26
|
+
}): {
|
|
27
|
+
items: any;
|
|
28
|
+
allItems: any;
|
|
29
|
+
pages: any;
|
|
30
|
+
pageItems: any;
|
|
31
|
+
pagination: {
|
|
32
|
+
page: any;
|
|
33
|
+
lastPage: any;
|
|
34
|
+
total: any;
|
|
35
|
+
};
|
|
36
|
+
total: any;
|
|
37
|
+
lastPage: any;
|
|
38
|
+
loaded: boolean;
|
|
39
|
+
allLoaded: boolean;
|
|
40
|
+
loading: boolean;
|
|
41
|
+
loadNextPage: () => void;
|
|
42
|
+
loadPage: (newPage: any) => void;
|
|
43
|
+
reloadPage: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
44
|
+
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
45
|
+
reset: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
46
|
+
updateItem: (item: any) => void;
|
|
47
|
+
status: "error" | "success";
|
|
48
|
+
error: Error;
|
|
49
|
+
isError: true;
|
|
50
|
+
isPending: false;
|
|
51
|
+
isLoadingError: false;
|
|
52
|
+
isRefetchError: true;
|
|
53
|
+
isSuccess: false;
|
|
54
|
+
isPlaceholderData: false;
|
|
55
|
+
dataUpdatedAt: number;
|
|
56
|
+
errorUpdatedAt: number;
|
|
57
|
+
failureCount: number;
|
|
58
|
+
failureReason: Error;
|
|
59
|
+
errorUpdateCount: number;
|
|
60
|
+
isFetchedAfterMount: boolean;
|
|
61
|
+
isInitialLoading: boolean;
|
|
62
|
+
isPaused: boolean;
|
|
63
|
+
isStale: boolean;
|
|
64
|
+
isEnabled: boolean;
|
|
65
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
66
|
+
promise: Promise<unknown>;
|
|
67
|
+
} | {
|
|
68
|
+
items: any;
|
|
69
|
+
allItems: any;
|
|
70
|
+
pages: any;
|
|
71
|
+
pageItems: any;
|
|
72
|
+
pagination: {
|
|
73
|
+
page: any;
|
|
74
|
+
lastPage: any;
|
|
75
|
+
total: any;
|
|
76
|
+
};
|
|
77
|
+
total: any;
|
|
78
|
+
lastPage: any;
|
|
79
|
+
loaded: boolean;
|
|
80
|
+
allLoaded: boolean;
|
|
81
|
+
loading: boolean;
|
|
82
|
+
loadNextPage: () => void;
|
|
83
|
+
loadPage: (newPage: any) => void;
|
|
84
|
+
reloadPage: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
85
|
+
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
86
|
+
reset: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
87
|
+
updateItem: (item: any) => void;
|
|
88
|
+
status: "error" | "success";
|
|
89
|
+
error: Error;
|
|
90
|
+
isError: false;
|
|
91
|
+
isPending: false;
|
|
92
|
+
isLoadingError: false;
|
|
93
|
+
isRefetchError: false;
|
|
94
|
+
isSuccess: true;
|
|
95
|
+
isPlaceholderData: false;
|
|
96
|
+
dataUpdatedAt: number;
|
|
97
|
+
errorUpdatedAt: number;
|
|
98
|
+
failureCount: number;
|
|
99
|
+
failureReason: Error;
|
|
100
|
+
errorUpdateCount: number;
|
|
101
|
+
isFetchedAfterMount: boolean;
|
|
102
|
+
isInitialLoading: boolean;
|
|
103
|
+
isPaused: boolean;
|
|
104
|
+
isStale: boolean;
|
|
105
|
+
isEnabled: boolean;
|
|
106
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
107
|
+
promise: Promise<unknown>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
declare function useItems({ getPage, getItems, page, count, items: providedItems, pages: initialPages, getPageFromResponse, getItemsFromResponse, onItemsLoaded, onPageLoaded, onLoaded, onError, }: {
|
|
111
|
+
getPage?: any;
|
|
112
|
+
getItems?: any;
|
|
113
|
+
page?: any;
|
|
114
|
+
count?: number;
|
|
115
|
+
items?: any;
|
|
116
|
+
pages?: any;
|
|
117
|
+
getPageFromResponse?: ({ pagination: { page: currentPage, last_page: lastPage, total, per_page: perPage }, data: items, }: {
|
|
118
|
+
pagination: {
|
|
119
|
+
page: any;
|
|
120
|
+
last_page: any;
|
|
121
|
+
total: any;
|
|
122
|
+
per_page: any;
|
|
123
|
+
};
|
|
124
|
+
data: any;
|
|
125
|
+
}) => {
|
|
126
|
+
page: number;
|
|
127
|
+
lastPage: number;
|
|
128
|
+
total: number;
|
|
129
|
+
count: number;
|
|
130
|
+
items: any;
|
|
131
|
+
};
|
|
132
|
+
getItemsFromResponse?: (data: any) => any;
|
|
133
|
+
onItemsLoaded?: any;
|
|
134
|
+
onPageLoaded?: any;
|
|
135
|
+
onLoaded?: any;
|
|
136
|
+
onError?: any;
|
|
137
|
+
}): {
|
|
138
|
+
items: any;
|
|
139
|
+
pages: any;
|
|
140
|
+
pageItems: any;
|
|
141
|
+
total: any;
|
|
142
|
+
lastPage: any;
|
|
143
|
+
loaded: boolean;
|
|
144
|
+
allLoaded: boolean;
|
|
145
|
+
loading: boolean;
|
|
146
|
+
loadNextPage: () => any;
|
|
147
|
+
loadPage: (pageToLoad: any) => any;
|
|
148
|
+
reloadPage: () => any;
|
|
149
|
+
reload: () => any;
|
|
150
|
+
reset: () => void;
|
|
151
|
+
updateItem: (newItem: any) => void;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
declare function useItemsStore(store: any, { url, getPage, getItems, getPageFromResponse, getItemsFromResponse, page: initialPage, count: initialCount, query, onQueryChange, queryConfig, keepData, }: {
|
|
155
|
+
url?: any;
|
|
156
|
+
getPage?: any;
|
|
157
|
+
getItems?: any;
|
|
158
|
+
getPageFromResponse?: any;
|
|
159
|
+
getItemsFromResponse?: any;
|
|
160
|
+
page?: any;
|
|
161
|
+
count?: any;
|
|
162
|
+
query?: any;
|
|
163
|
+
onQueryChange?: any;
|
|
164
|
+
queryConfig?: any;
|
|
165
|
+
keepData?: boolean;
|
|
166
|
+
}): {
|
|
167
|
+
isLoading: false;
|
|
168
|
+
isFetching: boolean;
|
|
169
|
+
isRefetching: boolean;
|
|
170
|
+
isFetched: boolean;
|
|
171
|
+
items: any;
|
|
172
|
+
pages: any;
|
|
173
|
+
allItems: any;
|
|
174
|
+
loading: boolean;
|
|
175
|
+
loaded: boolean;
|
|
176
|
+
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
177
|
+
loadPage: (newPage: any) => void;
|
|
178
|
+
loadNextPage: () => void;
|
|
179
|
+
updateItem: (item: any) => void;
|
|
180
|
+
pagination: {
|
|
181
|
+
page: any;
|
|
182
|
+
lastPage: any;
|
|
183
|
+
total: any;
|
|
184
|
+
};
|
|
185
|
+
error: Error;
|
|
186
|
+
isError: true;
|
|
187
|
+
isPending: false;
|
|
188
|
+
isLoadingError: false;
|
|
189
|
+
isRefetchError: true;
|
|
190
|
+
isSuccess: false;
|
|
191
|
+
isPlaceholderData: false;
|
|
192
|
+
status: "error";
|
|
193
|
+
dataUpdatedAt: number;
|
|
194
|
+
errorUpdatedAt: number;
|
|
195
|
+
failureCount: number;
|
|
196
|
+
failureReason: Error;
|
|
197
|
+
errorUpdateCount: number;
|
|
198
|
+
isFetchedAfterMount: boolean;
|
|
199
|
+
isInitialLoading: boolean;
|
|
200
|
+
isPaused: boolean;
|
|
201
|
+
isStale: boolean;
|
|
202
|
+
isEnabled: boolean;
|
|
203
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
204
|
+
promise: Promise<unknown>;
|
|
205
|
+
} | {
|
|
206
|
+
isLoading: false;
|
|
207
|
+
isFetching: boolean;
|
|
208
|
+
isRefetching: boolean;
|
|
209
|
+
isFetched: boolean;
|
|
210
|
+
items: any;
|
|
211
|
+
pages: any;
|
|
212
|
+
allItems: any;
|
|
213
|
+
loading: boolean;
|
|
214
|
+
loaded: boolean;
|
|
215
|
+
reload: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<unknown, Error>>;
|
|
216
|
+
loadPage: (newPage: any) => void;
|
|
217
|
+
loadNextPage: () => void;
|
|
218
|
+
updateItem: (item: any) => void;
|
|
219
|
+
pagination: {
|
|
220
|
+
page: any;
|
|
221
|
+
lastPage: any;
|
|
222
|
+
total: any;
|
|
223
|
+
};
|
|
224
|
+
error: null;
|
|
225
|
+
isError: false;
|
|
226
|
+
isPending: false;
|
|
227
|
+
isLoadingError: false;
|
|
228
|
+
isRefetchError: false;
|
|
229
|
+
isSuccess: true;
|
|
230
|
+
isPlaceholderData: false;
|
|
231
|
+
status: "success";
|
|
232
|
+
dataUpdatedAt: number;
|
|
233
|
+
errorUpdatedAt: number;
|
|
234
|
+
failureCount: number;
|
|
235
|
+
failureReason: Error;
|
|
236
|
+
errorUpdateCount: number;
|
|
237
|
+
isFetchedAfterMount: boolean;
|
|
238
|
+
isInitialLoading: boolean;
|
|
239
|
+
isPaused: boolean;
|
|
240
|
+
isStale: boolean;
|
|
241
|
+
isEnabled: boolean;
|
|
242
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
243
|
+
promise: Promise<unknown>;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
declare function useResourceDestroy(resource: any, id?: any): {
|
|
247
|
+
destroy: (providedId: any) => any;
|
|
248
|
+
loading: boolean;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
declare function useResourceItem(resource: any, id: any, opts: any): {
|
|
252
|
+
load: (...args: any[]) => any;
|
|
253
|
+
loading: boolean;
|
|
254
|
+
error: boolean;
|
|
255
|
+
item: any;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
declare function useResourceItems(resource: any, query?: any, page?: any, count?: any, opts?: any): {
|
|
259
|
+
isLoading: false;
|
|
260
|
+
isFetching: boolean;
|
|
261
|
+
isRefetching: boolean;
|
|
262
|
+
isFetched: boolean;
|
|
263
|
+
pages: any;
|
|
264
|
+
allItems: any;
|
|
265
|
+
loading: boolean;
|
|
266
|
+
loaded: boolean;
|
|
267
|
+
reload: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<unknown, Error>>;
|
|
268
|
+
loadPage: (newPage: any) => void;
|
|
269
|
+
loadNextPage: () => void;
|
|
270
|
+
updateItem: (item: any) => void;
|
|
271
|
+
pagination: {
|
|
272
|
+
page: any;
|
|
273
|
+
lastPage: any;
|
|
274
|
+
total: any;
|
|
275
|
+
};
|
|
276
|
+
error: Error;
|
|
277
|
+
isError: true;
|
|
278
|
+
isPending: false;
|
|
279
|
+
isLoadingError: false;
|
|
280
|
+
isRefetchError: true;
|
|
281
|
+
isSuccess: false;
|
|
282
|
+
isPlaceholderData: false;
|
|
283
|
+
status: "error";
|
|
284
|
+
dataUpdatedAt: number;
|
|
285
|
+
errorUpdatedAt: number;
|
|
286
|
+
failureCount: number;
|
|
287
|
+
failureReason: Error;
|
|
288
|
+
errorUpdateCount: number;
|
|
289
|
+
isFetchedAfterMount: boolean;
|
|
290
|
+
isInitialLoading: boolean;
|
|
291
|
+
isPaused: boolean;
|
|
292
|
+
isStale: boolean;
|
|
293
|
+
isEnabled: boolean;
|
|
294
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
295
|
+
promise: Promise<unknown>;
|
|
296
|
+
items: any;
|
|
297
|
+
} | {
|
|
298
|
+
isLoading: false;
|
|
299
|
+
isFetching: boolean;
|
|
300
|
+
isRefetching: boolean;
|
|
301
|
+
isFetched: boolean;
|
|
302
|
+
pages: any;
|
|
303
|
+
allItems: any;
|
|
304
|
+
loading: boolean;
|
|
305
|
+
loaded: boolean;
|
|
306
|
+
reload: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<unknown, Error>>;
|
|
307
|
+
loadPage: (newPage: any) => void;
|
|
308
|
+
loadNextPage: () => void;
|
|
309
|
+
updateItem: (item: any) => void;
|
|
310
|
+
pagination: {
|
|
311
|
+
page: any;
|
|
312
|
+
lastPage: any;
|
|
313
|
+
total: any;
|
|
314
|
+
};
|
|
315
|
+
error: null;
|
|
316
|
+
isError: false;
|
|
317
|
+
isPending: false;
|
|
318
|
+
isLoadingError: false;
|
|
319
|
+
isRefetchError: false;
|
|
320
|
+
isSuccess: true;
|
|
321
|
+
isPlaceholderData: false;
|
|
322
|
+
status: "success";
|
|
323
|
+
dataUpdatedAt: number;
|
|
324
|
+
errorUpdatedAt: number;
|
|
325
|
+
failureCount: number;
|
|
326
|
+
failureReason: Error;
|
|
327
|
+
errorUpdateCount: number;
|
|
328
|
+
isFetchedAfterMount: boolean;
|
|
329
|
+
isInitialLoading: boolean;
|
|
330
|
+
isPaused: boolean;
|
|
331
|
+
isStale: boolean;
|
|
332
|
+
isEnabled: boolean;
|
|
333
|
+
fetchStatus: _tanstack_query_core.FetchStatus;
|
|
334
|
+
promise: Promise<unknown>;
|
|
335
|
+
items: any;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
declare function useResourceCreate(resource: any): {
|
|
339
|
+
store: (data: any) => any;
|
|
340
|
+
loading: boolean;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
declare function useResourceUpdate(resource: any, id: any): {
|
|
344
|
+
update: (data: any) => any;
|
|
345
|
+
loading: boolean;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
declare function useResourceClone(resource: any, id?: any): {
|
|
349
|
+
clone: (providedId: any) => any;
|
|
350
|
+
loading: boolean;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
declare function useResourceRestore(resource: any, id?: any): {
|
|
354
|
+
restore: (providedId: any) => any;
|
|
355
|
+
loading: boolean;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
declare class Base {
|
|
359
|
+
constructor(opts?: {});
|
|
360
|
+
options: {
|
|
361
|
+
baseUrl: any;
|
|
362
|
+
onUnauthorized: any;
|
|
363
|
+
routes: {};
|
|
364
|
+
generateUrl: any;
|
|
365
|
+
};
|
|
366
|
+
requestGet(path: any, query?: any, opts?: any): any;
|
|
367
|
+
requestPost(path: any, data: any, opts?: any): any;
|
|
368
|
+
requestPut(path: any, data: any, opts?: any): any;
|
|
369
|
+
requestPatch(path: any, data: any, opts?: any): any;
|
|
370
|
+
requestDelete(path: any): any;
|
|
371
|
+
route(route: any, params: any): any;
|
|
372
|
+
getFullUrl(path: any): any;
|
|
373
|
+
onError(err: any): any;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
declare class AuthApi {
|
|
377
|
+
constructor(api: any, opts: any);
|
|
378
|
+
api: any;
|
|
379
|
+
options: any;
|
|
380
|
+
check(): any;
|
|
381
|
+
login(email: any, password: any): any;
|
|
382
|
+
register(data: any): any;
|
|
383
|
+
logout(): Promise<Response>;
|
|
384
|
+
requestPassword(email: any): any;
|
|
385
|
+
resetPassword(data: any): any;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare class AccountApi {
|
|
389
|
+
constructor(api: any, opts: any);
|
|
390
|
+
api: any;
|
|
391
|
+
options: any;
|
|
392
|
+
update(data: any): any;
|
|
393
|
+
updatePassword(data: any): any;
|
|
394
|
+
updateTaxes(data: any): any;
|
|
395
|
+
delete(data: any): any;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
declare class MediasApi extends Base {
|
|
399
|
+
find(id: any): any;
|
|
400
|
+
get(query?: {}, page?: number, count?: number): any;
|
|
401
|
+
getTrashed(query?: {}, page?: number, count?: number): any;
|
|
402
|
+
getTags(query?: {}, count?: number): any;
|
|
403
|
+
create(data: any): any;
|
|
404
|
+
update(id: any, data: any): any;
|
|
405
|
+
trash(id: any): any;
|
|
406
|
+
restore(id: any): any;
|
|
407
|
+
delete(id: any): any;
|
|
408
|
+
replace(id: any, data: any): any;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare class ResourcesApi {
|
|
412
|
+
constructor(api: any);
|
|
413
|
+
api: any;
|
|
414
|
+
resourceRoute({ id, has_routes: hasRoutes }: {
|
|
415
|
+
id: any;
|
|
416
|
+
has_routes?: boolean;
|
|
417
|
+
}, route: any, params: any): any;
|
|
418
|
+
find(resource: any, id: any): any;
|
|
419
|
+
get(resource: any, query?: {}, page?: number, count?: number): any;
|
|
420
|
+
store(resource: any, data: any): any;
|
|
421
|
+
update(resource: any, id: any, data: any): any;
|
|
422
|
+
destroy(resource: any, id: any): any;
|
|
423
|
+
clone(resource: any, id: any, data?: any): any;
|
|
424
|
+
restore(resource: any, id: any, data?: any): any;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare class Api extends Base {
|
|
428
|
+
auth: AuthApi;
|
|
429
|
+
account: AccountApi;
|
|
430
|
+
medias: MediasApi;
|
|
431
|
+
resources: ResourcesApi;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
interface ApiProviderProps {
|
|
435
|
+
api?: Api | null;
|
|
436
|
+
baseUrl?: string;
|
|
437
|
+
onUnauthorized?: (() => void) | null;
|
|
438
|
+
children: ReactNode;
|
|
439
|
+
}
|
|
440
|
+
declare function useApi(): Api;
|
|
441
|
+
declare function ApiProvider({ api: initialApi, baseUrl, onUnauthorized, children, }: ApiProviderProps): react_jsx_runtime.JSX.Element;
|
|
442
|
+
|
|
443
|
+
type QueryInitialData = Record<string, unknown> | Array<Record<string, unknown>>;
|
|
444
|
+
interface QueryProviderProps {
|
|
445
|
+
config?: Record<string, unknown> | null;
|
|
446
|
+
initialKey?: string[] | null;
|
|
447
|
+
initialData?: QueryInitialData | null;
|
|
448
|
+
children: ReactNode;
|
|
449
|
+
}
|
|
450
|
+
declare function useQueryContext(): QueryClient;
|
|
451
|
+
declare function QueryProvider({ config: initialConfig, initialKey, initialData, children, }: QueryProviderProps): react_jsx_runtime.JSX.Element;
|
|
452
|
+
|
|
453
|
+
interface DataProviderProps {
|
|
454
|
+
api?: Api | null;
|
|
455
|
+
apiBaseUrl?: string;
|
|
456
|
+
children?: ReactNode;
|
|
457
|
+
}
|
|
458
|
+
declare function DataProvider({ api, apiBaseUrl, children }: DataProviderProps): react_jsx_runtime.JSX.Element;
|
|
459
|
+
|
|
460
|
+
export { Api, ApiProvider, Base as BaseApi, DataProvider, QueryProvider, useApi, useData, useItems$1 as useItems, useItems as useItemsLegacy, useItemsStore, useQueryContext, useResourceClone, useResourceDestroy, useResourceItem, useResourceItems, useResourceRestore, useResourceCreate as useResourceStore, useResourceUpdate };
|
package/{es → dist}/index.js
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState, useCallback, useEffect, useMemo, useRef, useContext, createContext } from 'react';
|
|
1
|
+
import { useState, useCallback, useEffect, useMemo, useRef, use, createContext } from 'react';
|
|
3
2
|
import { useUrlGenerator } from '@panneau/core/contexts';
|
|
4
3
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
5
4
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
@@ -15,9 +14,9 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
15
14
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
16
15
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
17
16
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
18
|
-
import isEmpty from 'lodash
|
|
17
|
+
import isEmpty from 'lodash/isEmpty';
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
function useData(loadData) {
|
|
21
20
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
22
21
|
_ref$initialData = _ref.initialData,
|
|
23
22
|
initialData = _ref$initialData === void 0 ? null : _ref$initialData,
|
|
@@ -71,7 +70,7 @@ var useData = function useData(loadData) {
|
|
|
71
70
|
loading: loading,
|
|
72
71
|
error: error
|
|
73
72
|
};
|
|
74
|
-
}
|
|
73
|
+
}
|
|
75
74
|
|
|
76
75
|
var _excluded$3 = ["store", "url", "paginated", "query", "onQueryChange", "queryConfig", "keepData"],
|
|
77
76
|
_excluded2$1 = ["page", "count"],
|
|
@@ -79,7 +78,7 @@ var _excluded$3 = ["store", "url", "paginated", "query", "onQueryChange", "query
|
|
|
79
78
|
|
|
80
79
|
// For backwards compatibility
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
function useItems$1(_ref) {
|
|
83
82
|
var store = _ref.store,
|
|
84
83
|
url = _ref.url,
|
|
85
84
|
_ref$paginated = _ref.paginated,
|
|
@@ -342,9 +341,9 @@ var useItems$1 = function useItems(_ref) {
|
|
|
342
341
|
status: status,
|
|
343
342
|
error: error
|
|
344
343
|
});
|
|
345
|
-
}
|
|
344
|
+
}
|
|
346
345
|
|
|
347
|
-
|
|
346
|
+
function useItems(_ref) {
|
|
348
347
|
var _ref$getPage = _ref.getPage,
|
|
349
348
|
getPage = _ref$getPage === void 0 ? null : _ref$getPage,
|
|
350
349
|
_ref$getItems = _ref.getItems,
|
|
@@ -613,7 +612,7 @@ var useItems = function useItems(_ref) {
|
|
|
613
612
|
reset: reset,
|
|
614
613
|
updateItem: updateItem
|
|
615
614
|
};
|
|
616
|
-
}
|
|
615
|
+
}
|
|
617
616
|
|
|
618
617
|
var _excluded$2 = ["page", "count"],
|
|
619
618
|
_excluded2 = ["data", "refetch", "isLoading", "isFetching", "isRefetching", "isFetched"];
|
|
@@ -1269,17 +1268,12 @@ var Api = /*#__PURE__*/function (_Base) {
|
|
|
1269
1268
|
}(Base);
|
|
1270
1269
|
|
|
1271
1270
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
1271
|
+
|
|
1272
1272
|
var ApiContext = /*#__PURE__*/createContext(null);
|
|
1273
|
-
|
|
1274
|
-
return
|
|
1275
|
-
}
|
|
1276
|
-
|
|
1277
|
-
api: PropTypes.instanceOf(Api),
|
|
1278
|
-
baseUrl: PropTypes.string,
|
|
1279
|
-
onUnauthorized: PropTypes.func,
|
|
1280
|
-
children: PropTypes.node.isRequired
|
|
1281
|
-
};
|
|
1282
|
-
var ApiProvider = function ApiProvider(_ref) {
|
|
1273
|
+
function useApi() {
|
|
1274
|
+
return use(ApiContext);
|
|
1275
|
+
}
|
|
1276
|
+
function ApiProvider(_ref) {
|
|
1283
1277
|
var _ref$api = _ref.api,
|
|
1284
1278
|
initialApi = _ref$api === void 0 ? null : _ref$api,
|
|
1285
1279
|
_ref$baseUrl = _ref.baseUrl,
|
|
@@ -1296,14 +1290,13 @@ var ApiProvider = function ApiProvider(_ref) {
|
|
|
1296
1290
|
onUnauthorized: onUnauthorized
|
|
1297
1291
|
});
|
|
1298
1292
|
}, [previousApi, initialApi, baseUrl]);
|
|
1299
|
-
return /*#__PURE__*/jsx(ApiContext
|
|
1293
|
+
return /*#__PURE__*/jsx(ApiContext, {
|
|
1300
1294
|
value: api,
|
|
1301
1295
|
children: children
|
|
1302
1296
|
});
|
|
1303
|
-
}
|
|
1304
|
-
ApiProvider.propTypes = propTypes$1;
|
|
1297
|
+
}
|
|
1305
1298
|
|
|
1306
|
-
|
|
1299
|
+
function useResourceDestroy(resource) {
|
|
1307
1300
|
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1308
1301
|
var _useState = useState(false),
|
|
1309
1302
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -1324,10 +1317,10 @@ var useResourceDestroy = function useResourceDestroy(resource) {
|
|
|
1324
1317
|
destroy: destroy,
|
|
1325
1318
|
loading: loading
|
|
1326
1319
|
};
|
|
1327
|
-
}
|
|
1320
|
+
}
|
|
1328
1321
|
|
|
1329
1322
|
var _excluded$1 = ["data"];
|
|
1330
|
-
|
|
1323
|
+
function useResourceItem(resource, id, opts) {
|
|
1331
1324
|
var api = useApi();
|
|
1332
1325
|
var loader = useCallback(function () {
|
|
1333
1326
|
return api.resources.find(resource, id);
|
|
@@ -1338,10 +1331,10 @@ var useResourceItem = function useResourceItem(resource, id, opts) {
|
|
|
1338
1331
|
return _objectSpread({
|
|
1339
1332
|
item: data
|
|
1340
1333
|
}, request);
|
|
1341
|
-
}
|
|
1334
|
+
}
|
|
1342
1335
|
|
|
1343
1336
|
var _excluded = ["items"];
|
|
1344
|
-
|
|
1337
|
+
function useResourceItems(resource) {
|
|
1345
1338
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1346
1339
|
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
1347
1340
|
var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -1391,9 +1384,9 @@ var useResourceItems = function useResourceItems(resource) {
|
|
|
1391
1384
|
return _objectSpread({
|
|
1392
1385
|
items: resourceChanging ? null : items
|
|
1393
1386
|
}, request);
|
|
1394
|
-
}
|
|
1387
|
+
}
|
|
1395
1388
|
|
|
1396
|
-
|
|
1389
|
+
function useResourceCreate(resource) {
|
|
1397
1390
|
var _useState = useState(false),
|
|
1398
1391
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1399
1392
|
loading = _useState2[0],
|
|
@@ -1413,9 +1406,9 @@ var useResourceCreate = function useResourceCreate(resource) {
|
|
|
1413
1406
|
store: store,
|
|
1414
1407
|
loading: loading
|
|
1415
1408
|
};
|
|
1416
|
-
}
|
|
1409
|
+
}
|
|
1417
1410
|
|
|
1418
|
-
|
|
1411
|
+
function useResourceUpdate(resource, id) {
|
|
1419
1412
|
var _useState = useState(false),
|
|
1420
1413
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1421
1414
|
loading = _useState2[0],
|
|
@@ -1435,9 +1428,9 @@ var useResourceUpdate = function useResourceUpdate(resource, id) {
|
|
|
1435
1428
|
update: update,
|
|
1436
1429
|
loading: loading
|
|
1437
1430
|
};
|
|
1438
|
-
}
|
|
1431
|
+
}
|
|
1439
1432
|
|
|
1440
|
-
|
|
1433
|
+
function useResourceClone(resource) {
|
|
1441
1434
|
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1442
1435
|
var _useState = useState(false),
|
|
1443
1436
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -1458,9 +1451,9 @@ var useResourceClone = function useResourceClone(resource) {
|
|
|
1458
1451
|
clone: clone,
|
|
1459
1452
|
loading: loading
|
|
1460
1453
|
};
|
|
1461
|
-
}
|
|
1454
|
+
}
|
|
1462
1455
|
|
|
1463
|
-
|
|
1456
|
+
function useResourceRestore(resource) {
|
|
1464
1457
|
var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1465
1458
|
var _useState = useState(false),
|
|
1466
1459
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -1481,19 +1474,13 @@ var useResourceRestore = function useResourceRestore(resource) {
|
|
|
1481
1474
|
restore: restore,
|
|
1482
1475
|
loading: loading
|
|
1483
1476
|
};
|
|
1484
|
-
}
|
|
1477
|
+
}
|
|
1485
1478
|
|
|
1486
1479
|
var QueryContext = /*#__PURE__*/createContext(null);
|
|
1487
|
-
|
|
1488
|
-
return
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
config: PropTypes.shape({}),
|
|
1492
|
-
initialKey: PropTypes.arrayOf(PropTypes.string),
|
|
1493
|
-
initialData: PropTypes.oneOfType([PropTypes.shape({}), PropTypes.arrayOf(PropTypes.shape({}))]),
|
|
1494
|
-
children: PropTypes.node.isRequired
|
|
1495
|
-
};
|
|
1496
|
-
var QueryProvider = function QueryProvider(_ref) {
|
|
1480
|
+
function useQueryContext() {
|
|
1481
|
+
return use(QueryContext);
|
|
1482
|
+
}
|
|
1483
|
+
function QueryProvider(_ref) {
|
|
1497
1484
|
var _ref$config = _ref.config,
|
|
1498
1485
|
initialConfig = _ref$config === void 0 ? null : _ref$config,
|
|
1499
1486
|
_ref$initialKey = _ref.initialKey,
|
|
@@ -1518,8 +1505,7 @@ var QueryProvider = function QueryProvider(_ref) {
|
|
|
1518
1505
|
client: queryClient,
|
|
1519
1506
|
children: children
|
|
1520
1507
|
});
|
|
1521
|
-
}
|
|
1522
|
-
QueryProvider.propTypes = propTypes;
|
|
1508
|
+
}
|
|
1523
1509
|
|
|
1524
1510
|
function DataProvider(_ref) {
|
|
1525
1511
|
var _ref$api = _ref.api,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/data",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -34,18 +34,21 @@
|
|
|
34
34
|
],
|
|
35
35
|
"license": "ISC",
|
|
36
36
|
"type": "module",
|
|
37
|
-
"module": "
|
|
37
|
+
"module": "dist/index.js",
|
|
38
|
+
"types": "dist/index.d.ts",
|
|
38
39
|
"exports": {
|
|
39
|
-
".":
|
|
40
|
+
".": {
|
|
41
|
+
"default": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts"
|
|
43
|
+
}
|
|
40
44
|
},
|
|
41
45
|
"files": [
|
|
42
|
-
"
|
|
43
|
-
"es",
|
|
46
|
+
"dist",
|
|
44
47
|
"assets"
|
|
45
48
|
],
|
|
46
49
|
"scripts": {
|
|
47
50
|
"prepublishOnly": "npm run build",
|
|
48
|
-
"build": "../../scripts/prepare-package.sh"
|
|
51
|
+
"build": "../../scripts/prepare-package.sh --types"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"react": "^19.0.0",
|
|
@@ -59,14 +62,13 @@
|
|
|
59
62
|
"@babel/runtime": "^7.12.5",
|
|
60
63
|
"@folklore/fetch": "^0.1.21",
|
|
61
64
|
"@folklore/routes": "^0.2.44",
|
|
62
|
-
"@panneau/core": "^4.0.
|
|
65
|
+
"@panneau/core": "^4.0.15",
|
|
63
66
|
"@tanstack/react-query": "^5.29.2",
|
|
64
|
-
"lodash
|
|
65
|
-
"prop-types": "^15.7.2",
|
|
67
|
+
"lodash": "^4.17.21",
|
|
66
68
|
"query-string": "^9.0.0"
|
|
67
69
|
},
|
|
68
70
|
"publishConfig": {
|
|
69
71
|
"access": "public"
|
|
70
72
|
},
|
|
71
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "83c02ca2f26e02383ef452ffcafda984d0b211cd"
|
|
72
74
|
}
|