@panneau/medias 4.0.38 → 4.0.40-alpha.1

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +319 -57
  2. package/dist/index.js +1184 -979
  3. package/package.json +17 -17
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, Dispatch, SetStateAction } from 'react';
3
- import { Media } from '@panneau/core';
3
+ import * as _panneau_core from '@panneau/core';
4
+ import { Media, Resource } from '@panneau/core';
4
5
  import * as _tanstack_query_core from '@tanstack/query-core';
5
6
 
6
7
  type MediaFormField = Record<string, unknown>;
@@ -34,7 +35,6 @@ type ColumnItem = Record<string, unknown> & {
34
35
  id?: string | null;
35
36
  actions?: ColumnAction[];
36
37
  };
37
- type SelectionValue = Media | Media[] | null;
38
38
  interface LayoutItem {
39
39
  id: string;
40
40
  label: ReactNode;
@@ -63,8 +63,8 @@ interface MediasBrowserProps {
63
63
  onMediaFormOpen?: (() => void) | null;
64
64
  onMediaFormClose?: (() => void) | null;
65
65
  selectable?: boolean;
66
- selectedItems?: SelectionValue;
67
- onSelectionChange?: ((selection: SelectionValue) => void) | null;
66
+ selectedItems?: Media[] | null;
67
+ onSelectionChange?: ((items: Media[] | null) => void) | null;
68
68
  multipleSelection?: boolean;
69
69
  uppyConfig?: Record<string, unknown>;
70
70
  withDelete?: boolean;
@@ -77,11 +77,10 @@ interface MediasBrowserProps {
77
77
  }
78
78
  declare function MediasBrowser({ items: initialItems, extraItems, types, permissions, baseUrl, filters, columns, fields, query: initialQuery, layout: initialLayout, layouts, theme, onMediaUploaded, onItemsChange, onLayoutChange, onMediaFormOpen, onMediaFormClose, selectable, selectedItems, onSelectionChange, multipleSelection, uppyConfig, withDelete, withTrash, withReplace, withStickySelection, withoutUpload, className, formChildren, }: MediasBrowserProps): react_jsx_runtime.JSX.Element;
79
79
 
80
- type PickerSelection = Media | Media[] | null;
81
80
  interface MediasPickerProps {
82
81
  items?: Media[] | null;
83
- value?: PickerSelection;
84
- onChange?: ((selection: PickerSelection) => void) | null;
82
+ value?: Media[] | null;
83
+ onChange?: ((selection: Media[] | null) => void) | null;
85
84
  multiple?: boolean;
86
85
  className?: string | null;
87
86
  [key: string]: unknown;
@@ -89,14 +88,14 @@ interface MediasPickerProps {
89
88
  declare function MediasPicker({ items: initialItems, value: initialSelectedItems, onChange, multiple, className, ...props }: MediasPickerProps): react_jsx_runtime.JSX.Element;
90
89
 
91
90
  interface MediasApi {
92
- get: (...args: unknown[]) => Promise<unknown> | unknown;
93
- getTrashed: (...args: unknown[]) => Promise<unknown> | unknown;
94
- create: (...args: unknown[]) => Promise<unknown> | unknown;
95
- find: (...args: unknown[]) => Promise<unknown> | unknown;
96
- update: (...args: unknown[]) => Promise<unknown> | unknown;
97
- trash: (...args: unknown[]) => Promise<unknown> | unknown;
98
- restore?: (...args: unknown[]) => Promise<unknown> | unknown;
99
- delete: (...args: unknown[]) => Promise<unknown> | unknown;
91
+ get: (query?: Record<string, unknown>, page?: number | null, count?: number | null) => Promise<unknown>;
92
+ getTrashed: (query?: Record<string, unknown>, page?: number | null, count?: number | null) => Promise<unknown>;
93
+ create: (data: Partial<Media>) => Promise<Media>;
94
+ find: (id: string) => Promise<Media>;
95
+ update: (id: string, data: Partial<Media>) => Promise<Media>;
96
+ trash: (id: string) => Promise<unknown>;
97
+ restore?: (id: string) => Promise<unknown>;
98
+ delete: (id: string) => Promise<unknown>;
100
99
  }
101
100
  interface MediasApiProviderProps {
102
101
  api?: MediasApi | null;
@@ -131,27 +130,30 @@ interface MediaProviderProps {
131
130
  declare function useCurrentMedia(): MediaContextValue;
132
131
  declare function MediaProvider({ media: providedMedia, children }: MediaProviderProps): react_jsx_runtime.JSX.Element;
133
132
 
134
- declare function useMedias(query?: any, page?: any, count?: any, opts?: {}): {
135
- isLoading: false;
136
- isFetching: boolean;
137
- isRefetching: boolean;
138
- isFetched: boolean;
139
- pages: any;
140
- allItems: any;
133
+ interface UseMediasOpts {
134
+ trashed?: boolean;
135
+ [key: string]: unknown;
136
+ }
137
+ declare function useMedias(query?: any, page?: any, count?: any, opts?: UseMediasOpts): {
138
+ allItems: _panneau_core.Item[];
139
+ pagination: {
140
+ page: number;
141
+ lastPage: number;
142
+ total: number;
143
+ } | null;
141
144
  loading: boolean;
142
145
  loaded: boolean;
143
- reload: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<unknown, Error>>;
144
- loadPage: (newPage: any) => void;
145
- loadNextPage: () => void;
146
- updateItem: (item: any) => void;
147
- pagination: {
148
- page: any;
149
- lastPage: any;
150
- total: any;
151
- };
146
+ reload: () => void;
147
+ updateItem: (item: _panneau_core.Item) => void;
148
+ data: {
149
+ data: _panneau_core.Item[];
150
+ pagination: _panneau_core.Pagination;
151
+ meta?: _panneau_core.Pagination;
152
+ } | _panneau_core.Item[];
152
153
  error: Error;
153
154
  isError: true;
154
155
  isPending: false;
156
+ isLoading: false;
155
157
  isLoadingError: false;
156
158
  isRefetchError: true;
157
159
  isSuccess: false;
@@ -162,84 +164,344 @@ declare function useMedias(query?: any, page?: any, count?: any, opts?: {}): {
162
164
  failureCount: number;
163
165
  failureReason: Error;
164
166
  errorUpdateCount: number;
167
+ isFetched: boolean;
165
168
  isFetchedAfterMount: boolean;
169
+ isFetching: boolean;
166
170
  isInitialLoading: boolean;
167
171
  isPaused: boolean;
172
+ isRefetching: boolean;
168
173
  isStale: boolean;
169
174
  isEnabled: boolean;
175
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
176
+ data: _panneau_core.Item[];
177
+ pagination: _panneau_core.Pagination;
178
+ meta?: _panneau_core.Pagination;
179
+ } | _panneau_core.Item[], Error>>;
170
180
  fetchStatus: _tanstack_query_core.FetchStatus;
171
- promise: Promise<unknown>;
172
- items: any;
181
+ promise: Promise<{
182
+ data: _panneau_core.Item[];
183
+ pagination: _panneau_core.Pagination;
184
+ meta?: _panneau_core.Pagination;
185
+ } | _panneau_core.Item[]>;
186
+ items: _panneau_core.Item[];
173
187
  } | {
188
+ allItems: _panneau_core.Item[];
189
+ pagination: {
190
+ page: number;
191
+ lastPage: number;
192
+ total: number;
193
+ } | null;
194
+ loading: boolean;
195
+ loaded: boolean;
196
+ reload: () => void;
197
+ updateItem: (item: _panneau_core.Item) => void;
198
+ data: {
199
+ data: _panneau_core.Item[];
200
+ pagination: _panneau_core.Pagination;
201
+ meta?: _panneau_core.Pagination;
202
+ } | _panneau_core.Item[];
203
+ error: null;
204
+ isError: false;
205
+ isPending: false;
174
206
  isLoading: false;
207
+ isLoadingError: false;
208
+ isRefetchError: false;
209
+ isSuccess: true;
210
+ isPlaceholderData: false;
211
+ status: "success";
212
+ dataUpdatedAt: number;
213
+ errorUpdatedAt: number;
214
+ failureCount: number;
215
+ failureReason: Error;
216
+ errorUpdateCount: number;
217
+ isFetched: boolean;
218
+ isFetchedAfterMount: boolean;
175
219
  isFetching: boolean;
220
+ isInitialLoading: boolean;
221
+ isPaused: boolean;
176
222
  isRefetching: boolean;
223
+ isStale: boolean;
224
+ isEnabled: boolean;
225
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
226
+ data: _panneau_core.Item[];
227
+ pagination: _panneau_core.Pagination;
228
+ meta?: _panneau_core.Pagination;
229
+ } | _panneau_core.Item[], Error>>;
230
+ fetchStatus: _tanstack_query_core.FetchStatus;
231
+ promise: Promise<{
232
+ data: _panneau_core.Item[];
233
+ pagination: _panneau_core.Pagination;
234
+ meta?: _panneau_core.Pagination;
235
+ } | _panneau_core.Item[]>;
236
+ items: _panneau_core.Item[];
237
+ } | {
238
+ allItems: _panneau_core.Item[];
239
+ pagination: {
240
+ page: number;
241
+ lastPage: number;
242
+ total: number;
243
+ } | null;
244
+ loading: boolean;
245
+ loaded: boolean;
246
+ reload: () => void;
247
+ updateItem: (item: _panneau_core.Item) => void;
248
+ data: undefined;
249
+ error: Error;
250
+ isError: true;
251
+ isPending: false;
252
+ isLoading: false;
253
+ isLoadingError: true;
254
+ isRefetchError: false;
255
+ isSuccess: false;
256
+ isPlaceholderData: false;
257
+ status: "error";
258
+ dataUpdatedAt: number;
259
+ errorUpdatedAt: number;
260
+ failureCount: number;
261
+ failureReason: Error;
262
+ errorUpdateCount: number;
177
263
  isFetched: boolean;
178
- pages: any;
179
- allItems: any;
264
+ isFetchedAfterMount: boolean;
265
+ isFetching: boolean;
266
+ isInitialLoading: boolean;
267
+ isPaused: boolean;
268
+ isRefetching: boolean;
269
+ isStale: boolean;
270
+ isEnabled: boolean;
271
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
272
+ data: _panneau_core.Item[];
273
+ pagination: _panneau_core.Pagination;
274
+ meta?: _panneau_core.Pagination;
275
+ } | _panneau_core.Item[], Error>>;
276
+ fetchStatus: _tanstack_query_core.FetchStatus;
277
+ promise: Promise<{
278
+ data: _panneau_core.Item[];
279
+ pagination: _panneau_core.Pagination;
280
+ meta?: _panneau_core.Pagination;
281
+ } | _panneau_core.Item[]>;
282
+ items: _panneau_core.Item[];
283
+ } | {
284
+ allItems: _panneau_core.Item[];
285
+ pagination: {
286
+ page: number;
287
+ lastPage: number;
288
+ total: number;
289
+ } | null;
180
290
  loading: boolean;
181
291
  loaded: boolean;
182
- reload: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<unknown, Error>>;
183
- loadPage: (newPage: any) => void;
184
- loadNextPage: () => void;
185
- updateItem: (item: any) => void;
292
+ reload: () => void;
293
+ updateItem: (item: _panneau_core.Item) => void;
294
+ data: undefined;
295
+ error: null;
296
+ isError: false;
297
+ isPending: true;
298
+ isLoading: true;
299
+ isLoadingError: false;
300
+ isRefetchError: false;
301
+ isSuccess: false;
302
+ isPlaceholderData: false;
303
+ status: "pending";
304
+ dataUpdatedAt: number;
305
+ errorUpdatedAt: number;
306
+ failureCount: number;
307
+ failureReason: Error;
308
+ errorUpdateCount: number;
309
+ isFetched: boolean;
310
+ isFetchedAfterMount: boolean;
311
+ isFetching: boolean;
312
+ isInitialLoading: boolean;
313
+ isPaused: boolean;
314
+ isRefetching: boolean;
315
+ isStale: boolean;
316
+ isEnabled: boolean;
317
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
318
+ data: _panneau_core.Item[];
319
+ pagination: _panneau_core.Pagination;
320
+ meta?: _panneau_core.Pagination;
321
+ } | _panneau_core.Item[], Error>>;
322
+ fetchStatus: _tanstack_query_core.FetchStatus;
323
+ promise: Promise<{
324
+ data: _panneau_core.Item[];
325
+ pagination: _panneau_core.Pagination;
326
+ meta?: _panneau_core.Pagination;
327
+ } | _panneau_core.Item[]>;
328
+ items: _panneau_core.Item[];
329
+ } | {
330
+ allItems: _panneau_core.Item[];
186
331
  pagination: {
187
- page: any;
188
- lastPage: any;
189
- total: any;
190
- };
332
+ page: number;
333
+ lastPage: number;
334
+ total: number;
335
+ } | null;
336
+ loading: boolean;
337
+ loaded: boolean;
338
+ reload: () => void;
339
+ updateItem: (item: _panneau_core.Item) => void;
340
+ data: undefined;
191
341
  error: null;
192
342
  isError: false;
343
+ isPending: true;
344
+ isLoadingError: false;
345
+ isRefetchError: false;
346
+ isSuccess: false;
347
+ isPlaceholderData: false;
348
+ status: "pending";
349
+ dataUpdatedAt: number;
350
+ errorUpdatedAt: number;
351
+ failureCount: number;
352
+ failureReason: Error;
353
+ errorUpdateCount: number;
354
+ isFetched: boolean;
355
+ isFetchedAfterMount: boolean;
356
+ isFetching: boolean;
357
+ isLoading: boolean;
358
+ isInitialLoading: boolean;
359
+ isPaused: boolean;
360
+ isRefetching: boolean;
361
+ isStale: boolean;
362
+ isEnabled: boolean;
363
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
364
+ data: _panneau_core.Item[];
365
+ pagination: _panneau_core.Pagination;
366
+ meta?: _panneau_core.Pagination;
367
+ } | _panneau_core.Item[], Error>>;
368
+ fetchStatus: _tanstack_query_core.FetchStatus;
369
+ promise: Promise<{
370
+ data: _panneau_core.Item[];
371
+ pagination: _panneau_core.Pagination;
372
+ meta?: _panneau_core.Pagination;
373
+ } | _panneau_core.Item[]>;
374
+ items: _panneau_core.Item[];
375
+ } | {
376
+ allItems: _panneau_core.Item[];
377
+ pagination: {
378
+ page: number;
379
+ lastPage: number;
380
+ total: number;
381
+ } | null;
382
+ loading: boolean;
383
+ loaded: boolean;
384
+ reload: () => void;
385
+ updateItem: (item: _panneau_core.Item) => void;
386
+ data: {
387
+ data: _panneau_core.Item[];
388
+ pagination: _panneau_core.Pagination;
389
+ meta?: _panneau_core.Pagination;
390
+ } | _panneau_core.Item[];
391
+ isError: false;
392
+ error: null;
193
393
  isPending: false;
394
+ isLoading: false;
194
395
  isLoadingError: false;
195
396
  isRefetchError: false;
196
397
  isSuccess: true;
197
- isPlaceholderData: false;
398
+ isPlaceholderData: true;
198
399
  status: "success";
199
400
  dataUpdatedAt: number;
200
401
  errorUpdatedAt: number;
201
402
  failureCount: number;
202
403
  failureReason: Error;
203
404
  errorUpdateCount: number;
405
+ isFetched: boolean;
204
406
  isFetchedAfterMount: boolean;
407
+ isFetching: boolean;
205
408
  isInitialLoading: boolean;
206
409
  isPaused: boolean;
410
+ isRefetching: boolean;
207
411
  isStale: boolean;
208
412
  isEnabled: boolean;
413
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<{
414
+ data: _panneau_core.Item[];
415
+ pagination: _panneau_core.Pagination;
416
+ meta?: _panneau_core.Pagination;
417
+ } | _panneau_core.Item[], Error>>;
209
418
  fetchStatus: _tanstack_query_core.FetchStatus;
210
- promise: Promise<unknown>;
211
- items: any;
419
+ promise: Promise<{
420
+ data: _panneau_core.Item[];
421
+ pagination: _panneau_core.Pagination;
422
+ meta?: _panneau_core.Pagination;
423
+ } | _panneau_core.Item[]>;
424
+ items: _panneau_core.Item[];
212
425
  };
213
426
 
214
- declare function useMedia(id: any, opts: any): {
215
- load: (...args: any[]) => any;
216
- loading: boolean;
217
- error: boolean;
218
- story: any;
427
+ declare function useMedia(id: string, opts: any): {
428
+ error: Error;
429
+ isError: true;
430
+ isPending: false;
431
+ isLoading: false;
432
+ isLoadingError: false;
433
+ isRefetchError: true;
434
+ isSuccess: false;
435
+ isPlaceholderData: false;
436
+ status: "error";
437
+ dataUpdatedAt: number;
438
+ errorUpdatedAt: number;
439
+ failureCount: number;
440
+ failureReason: Error;
441
+ errorUpdateCount: number;
442
+ isFetched: boolean;
443
+ isFetchedAfterMount: boolean;
444
+ isFetching: boolean;
445
+ isInitialLoading: boolean;
446
+ isPaused: boolean;
447
+ isRefetching: boolean;
448
+ isStale: boolean;
449
+ isEnabled: boolean;
450
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<Media, Error>>;
451
+ fetchStatus: _tanstack_query_core.FetchStatus;
452
+ promise: Promise<Media>;
453
+ media: Media;
454
+ } | {
455
+ error: null;
456
+ isError: false;
457
+ isPending: false;
458
+ isLoading: false;
459
+ isLoadingError: false;
460
+ isRefetchError: false;
461
+ isSuccess: true;
462
+ isPlaceholderData: false;
463
+ status: "success";
464
+ dataUpdatedAt: number;
465
+ errorUpdatedAt: number;
466
+ failureCount: number;
467
+ failureReason: Error;
468
+ errorUpdateCount: number;
469
+ isFetched: boolean;
470
+ isFetchedAfterMount: boolean;
471
+ isFetching: boolean;
472
+ isInitialLoading: boolean;
473
+ isPaused: boolean;
474
+ isRefetching: boolean;
475
+ isStale: boolean;
476
+ isEnabled: boolean;
477
+ refetch: (options?: _tanstack_query_core.RefetchOptions) => Promise<_tanstack_query_core.QueryObserverResult<Media, Error>>;
478
+ fetchStatus: _tanstack_query_core.FetchStatus;
479
+ promise: Promise<Media>;
480
+ media: Media;
219
481
  };
220
482
 
221
483
  declare function useMediaCreate(): {
222
- create: (data: any) => any;
484
+ create: (data: any) => Promise<_panneau_core.Media>;
223
485
  creating: boolean;
224
486
  };
225
487
 
226
488
  declare function useMediaUpdate(): {
227
- update: (id: any, data: any) => any;
489
+ update: (id: any, data: any) => Promise<_panneau_core.Media>;
228
490
  updating: boolean;
229
491
  };
230
492
 
231
493
  declare function useMediaDelete(): {
232
- mediaDelete: (id: any, data: any) => any;
494
+ mediaDelete: (id: any, data: any) => Promise<unknown>;
233
495
  deleting: boolean;
234
496
  };
235
497
 
236
498
  declare function useMediaTrash(): {
237
- mediaTrash: (id: any, data: any) => any;
499
+ mediaTrash: (id: any, data: any) => Promise<unknown>;
238
500
  trashing: boolean;
239
501
  };
240
502
 
241
503
  declare function useMediaRestore(): {
242
- mediaRestore: (id: any, data: any) => any;
504
+ mediaRestore: (id: any, data: any) => Promise<unknown>;
243
505
  restoring: boolean;
244
506
  };
245
507
 
@@ -369,7 +631,7 @@ interface MediasResourceBrowserProps {
369
631
  declare function MediasResourceBrowser({ resource: resourceId, ...props }: MediasResourceBrowserProps): react_jsx_runtime.JSX.Element;
370
632
 
371
633
  interface MediasResourcePickerProps {
372
- resource?: string | null;
634
+ resource?: Resource | string | null;
373
635
  [key: string]: unknown;
374
636
  }
375
637
  declare function MediasResourcePicker({ resource: resourceId, ...props }: MediasResourcePickerProps): react_jsx_runtime.JSX.Element;