@panneau/medias 4.0.39 → 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.
- package/dist/index.d.ts +319 -57
- package/dist/index.js +1184 -979
- package/package.json +17 -17
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
1
|
import classNames from 'classnames';
|
|
4
|
-
import { use,
|
|
2
|
+
import { use, createContext, useState, useCallback, useMemo, useEffect } from 'react';
|
|
5
3
|
import { FormattedMessage } from 'react-intl';
|
|
6
4
|
import { useFieldComponent, usePanneauResource } from '@panneau/core/contexts';
|
|
7
5
|
import { useForm, useQuery } from '@panneau/core/hooks';
|
|
@@ -9,12 +7,10 @@ import Button from '@panneau/element-button';
|
|
|
9
7
|
import Form from '@panneau/element-form';
|
|
10
8
|
import FormStatus from '@panneau/element-form-status';
|
|
11
9
|
import UploadField from '@panneau/field-upload';
|
|
10
|
+
import { c } from 'react/compiler-runtime';
|
|
12
11
|
import ImageDisplay from '@panneau/display-image';
|
|
13
12
|
import MediaPlayer from '@panneau/element-media-player';
|
|
14
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
16
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
17
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
18
14
|
import uniqBy from 'lodash/uniqBy';
|
|
19
15
|
import Buttons from '@panneau/element-buttons';
|
|
20
16
|
import Grid from '@panneau/element-grid';
|
|
@@ -23,246 +19,490 @@ import MediaCard from '@panneau/element-media-card';
|
|
|
23
19
|
import Pagination from '@panneau/element-pagination';
|
|
24
20
|
import Table from '@panneau/element-table';
|
|
25
21
|
import Filters from '@panneau/filter-filters';
|
|
26
|
-
import {
|
|
22
|
+
import { useItems, useItem, useApi } from '@panneau/data';
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var MediasApiContext = /*#__PURE__*/createContext(null);
|
|
24
|
+
const MediasApiContext = /*#__PURE__*/createContext(null);
|
|
31
25
|
function useMediasApi() {
|
|
32
26
|
return use(MediasApiContext);
|
|
33
27
|
}
|
|
34
|
-
function MediasApiProvider(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
function MediasApiProvider(t0) {
|
|
29
|
+
const $ = c(3);
|
|
30
|
+
const {
|
|
31
|
+
api: t1,
|
|
32
|
+
children
|
|
33
|
+
} = t0;
|
|
34
|
+
const providedApi = t1 === undefined ? null : t1;
|
|
35
|
+
const previousApi = useMediasApi();
|
|
36
|
+
const api = providedApi || previousApi;
|
|
37
|
+
let t2;
|
|
38
|
+
if ($[0] !== api || $[1] !== children) {
|
|
39
|
+
t2 = /*#__PURE__*/jsx(MediasApiContext, {
|
|
40
|
+
value: api,
|
|
41
|
+
children: children
|
|
42
|
+
});
|
|
43
|
+
$[0] = api;
|
|
44
|
+
$[1] = children;
|
|
45
|
+
$[2] = t2;
|
|
46
|
+
} else {
|
|
47
|
+
t2 = $[2];
|
|
48
|
+
}
|
|
49
|
+
return t2;
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
52
|
+
function useMedias(t0, t1, t2, t3) {
|
|
53
|
+
const $ = c(25);
|
|
54
|
+
const query = t0 === undefined ? null : t0;
|
|
55
|
+
const page = t1 === undefined ? null : t1;
|
|
56
|
+
const count = t2 === undefined ? null : t2;
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[0] !== t3) {
|
|
59
|
+
t4 = t3 === undefined ? {} : t3;
|
|
60
|
+
$[0] = t3;
|
|
61
|
+
$[1] = t4;
|
|
62
|
+
} else {
|
|
63
|
+
t4 = $[1];
|
|
64
|
+
}
|
|
65
|
+
const opts = t4;
|
|
66
|
+
const api = useMediasApi();
|
|
67
|
+
let t5;
|
|
68
|
+
if ($[2] !== opts) {
|
|
69
|
+
t5 = opts || {};
|
|
70
|
+
$[2] = opts;
|
|
71
|
+
$[3] = t5;
|
|
72
|
+
} else {
|
|
73
|
+
t5 = $[3];
|
|
74
|
+
}
|
|
75
|
+
let queryOpts;
|
|
76
|
+
let t6;
|
|
77
|
+
if ($[4] !== t5) {
|
|
78
|
+
({
|
|
79
|
+
trashed: t6,
|
|
80
|
+
...queryOpts
|
|
81
|
+
} = t5);
|
|
82
|
+
$[4] = t5;
|
|
83
|
+
$[5] = queryOpts;
|
|
84
|
+
$[6] = t6;
|
|
85
|
+
} else {
|
|
86
|
+
queryOpts = $[5];
|
|
87
|
+
t6 = $[6];
|
|
88
|
+
}
|
|
89
|
+
const trashed = t6 === undefined ? false : t6;
|
|
90
|
+
let t7;
|
|
91
|
+
if ($[7] !== query || $[8] !== trashed) {
|
|
92
|
+
t7 = {
|
|
93
|
+
...query,
|
|
94
|
+
trashed
|
|
95
|
+
};
|
|
96
|
+
$[7] = query;
|
|
97
|
+
$[8] = trashed;
|
|
98
|
+
$[9] = t7;
|
|
99
|
+
} else {
|
|
100
|
+
t7 = $[9];
|
|
101
|
+
}
|
|
102
|
+
const finalQuery = t7;
|
|
103
|
+
let t8;
|
|
104
|
+
if ($[10] !== api || $[11] !== trashed) {
|
|
105
|
+
t8 = (requestedQuery, t9, requestedCount) => {
|
|
106
|
+
const requestedPage = t9 === undefined ? null : t9;
|
|
107
|
+
return trashed ? api.getTrashed(requestedQuery, requestedPage, requestedCount) : api.get(requestedQuery, requestedPage, requestedCount);
|
|
108
|
+
};
|
|
109
|
+
$[10] = api;
|
|
110
|
+
$[11] = trashed;
|
|
111
|
+
$[12] = t8;
|
|
112
|
+
} else {
|
|
113
|
+
t8 = $[12];
|
|
114
|
+
}
|
|
115
|
+
const getItems = t8;
|
|
116
|
+
const t9 = page === null ? getItems : null;
|
|
117
|
+
let t10;
|
|
118
|
+
if ($[13] !== count || $[14] !== finalQuery || $[15] !== page || $[16] !== queryOpts || $[17] !== t9) {
|
|
119
|
+
t10 = {
|
|
120
|
+
getItems: t9,
|
|
121
|
+
page,
|
|
122
|
+
count,
|
|
123
|
+
query: finalQuery,
|
|
124
|
+
...queryOpts
|
|
125
|
+
};
|
|
126
|
+
$[13] = count;
|
|
127
|
+
$[14] = finalQuery;
|
|
128
|
+
$[15] = page;
|
|
129
|
+
$[16] = queryOpts;
|
|
130
|
+
$[17] = t9;
|
|
131
|
+
$[18] = t10;
|
|
132
|
+
} else {
|
|
133
|
+
t10 = $[18];
|
|
134
|
+
}
|
|
135
|
+
const t11 = useItems("medias", t10);
|
|
136
|
+
let items;
|
|
137
|
+
let props;
|
|
138
|
+
if ($[19] !== t11) {
|
|
139
|
+
({
|
|
140
|
+
items,
|
|
141
|
+
...props
|
|
142
|
+
} = t11);
|
|
143
|
+
$[19] = t11;
|
|
144
|
+
$[20] = items;
|
|
145
|
+
$[21] = props;
|
|
146
|
+
} else {
|
|
147
|
+
items = $[20];
|
|
148
|
+
props = $[21];
|
|
149
|
+
}
|
|
150
|
+
let t12;
|
|
151
|
+
if ($[22] !== items || $[23] !== props) {
|
|
152
|
+
t12 = {
|
|
153
|
+
items,
|
|
154
|
+
...props
|
|
155
|
+
};
|
|
156
|
+
$[22] = items;
|
|
157
|
+
$[23] = props;
|
|
158
|
+
$[24] = t12;
|
|
159
|
+
} else {
|
|
160
|
+
t12 = $[24];
|
|
161
|
+
}
|
|
162
|
+
return t12;
|
|
82
163
|
}
|
|
83
164
|
|
|
84
|
-
var _excluded$6 = ["data"];
|
|
85
165
|
function useMedia(id, opts) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
166
|
+
const $ = c(8);
|
|
167
|
+
const api = useMediasApi();
|
|
168
|
+
let t0;
|
|
169
|
+
if ($[0] !== api) {
|
|
170
|
+
t0 = id_0 => api.find(id_0);
|
|
171
|
+
$[0] = api;
|
|
172
|
+
$[1] = t0;
|
|
173
|
+
} else {
|
|
174
|
+
t0 = $[1];
|
|
175
|
+
}
|
|
176
|
+
const loader = t0;
|
|
177
|
+
const t1 = useItem("medias", id, loader, opts);
|
|
178
|
+
let item;
|
|
179
|
+
let request;
|
|
180
|
+
if ($[2] !== t1) {
|
|
181
|
+
({
|
|
182
|
+
item,
|
|
183
|
+
...request
|
|
184
|
+
} = t1);
|
|
185
|
+
$[2] = t1;
|
|
186
|
+
$[3] = item;
|
|
187
|
+
$[4] = request;
|
|
188
|
+
} else {
|
|
189
|
+
item = $[3];
|
|
190
|
+
request = $[4];
|
|
191
|
+
}
|
|
192
|
+
let t2;
|
|
193
|
+
if ($[5] !== item || $[6] !== request) {
|
|
194
|
+
t2 = {
|
|
195
|
+
media: item,
|
|
196
|
+
...request
|
|
197
|
+
};
|
|
198
|
+
$[5] = item;
|
|
199
|
+
$[6] = request;
|
|
200
|
+
$[7] = t2;
|
|
201
|
+
} else {
|
|
202
|
+
t2 = $[7];
|
|
203
|
+
}
|
|
204
|
+
return t2;
|
|
96
205
|
}
|
|
97
206
|
|
|
98
207
|
function useMediaCreate() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
208
|
+
const $ = c(5);
|
|
209
|
+
const [creating, setCreating] = useState(false);
|
|
210
|
+
const api = useMediasApi();
|
|
211
|
+
let t0;
|
|
212
|
+
if ($[0] !== api) {
|
|
213
|
+
t0 = data => {
|
|
214
|
+
setCreating(true);
|
|
215
|
+
return api.create(data).then(response => {
|
|
216
|
+
setCreating(false);
|
|
217
|
+
return response;
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
$[0] = api;
|
|
221
|
+
$[1] = t0;
|
|
222
|
+
} else {
|
|
223
|
+
t0 = $[1];
|
|
224
|
+
}
|
|
225
|
+
const create = t0;
|
|
226
|
+
let t1;
|
|
227
|
+
if ($[2] !== create || $[3] !== creating) {
|
|
228
|
+
t1 = {
|
|
229
|
+
create,
|
|
230
|
+
creating
|
|
231
|
+
};
|
|
232
|
+
$[2] = create;
|
|
233
|
+
$[3] = creating;
|
|
234
|
+
$[4] = t1;
|
|
235
|
+
} else {
|
|
236
|
+
t1 = $[4];
|
|
237
|
+
}
|
|
238
|
+
return t1;
|
|
115
239
|
}
|
|
116
240
|
|
|
117
241
|
function useMediaUpdate() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
242
|
+
const $ = c(5);
|
|
243
|
+
const [updating, setUpdating] = useState(false);
|
|
244
|
+
const api = useMediasApi();
|
|
245
|
+
let t0;
|
|
246
|
+
if ($[0] !== api) {
|
|
247
|
+
t0 = (id, data) => {
|
|
248
|
+
setUpdating(true);
|
|
249
|
+
return api.update(id, data).then(response => {
|
|
250
|
+
setUpdating(false);
|
|
251
|
+
return response;
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
$[0] = api;
|
|
255
|
+
$[1] = t0;
|
|
256
|
+
} else {
|
|
257
|
+
t0 = $[1];
|
|
258
|
+
}
|
|
259
|
+
const update = t0;
|
|
260
|
+
let t1;
|
|
261
|
+
if ($[2] !== update || $[3] !== updating) {
|
|
262
|
+
t1 = {
|
|
263
|
+
update,
|
|
264
|
+
updating
|
|
265
|
+
};
|
|
266
|
+
$[2] = update;
|
|
267
|
+
$[3] = updating;
|
|
268
|
+
$[4] = t1;
|
|
269
|
+
} else {
|
|
270
|
+
t1 = $[4];
|
|
271
|
+
}
|
|
272
|
+
return t1;
|
|
134
273
|
}
|
|
135
274
|
|
|
136
275
|
function useMediaDelete() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
276
|
+
const $ = c(5);
|
|
277
|
+
const [deleting, setDeleting] = useState(false);
|
|
278
|
+
const api = useMediasApi();
|
|
279
|
+
let t0;
|
|
280
|
+
if ($[0] !== api) {
|
|
281
|
+
t0 = (id, data) => {
|
|
282
|
+
setDeleting(true);
|
|
283
|
+
return api.delete(id, data).then(response => {
|
|
284
|
+
setDeleting(false);
|
|
285
|
+
return response;
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
$[0] = api;
|
|
289
|
+
$[1] = t0;
|
|
290
|
+
} else {
|
|
291
|
+
t0 = $[1];
|
|
292
|
+
}
|
|
293
|
+
const mediaDelete = t0;
|
|
294
|
+
let t1;
|
|
295
|
+
if ($[2] !== deleting || $[3] !== mediaDelete) {
|
|
296
|
+
t1 = {
|
|
297
|
+
mediaDelete,
|
|
298
|
+
deleting
|
|
299
|
+
};
|
|
300
|
+
$[2] = deleting;
|
|
301
|
+
$[3] = mediaDelete;
|
|
302
|
+
$[4] = t1;
|
|
303
|
+
} else {
|
|
304
|
+
t1 = $[4];
|
|
305
|
+
}
|
|
306
|
+
return t1;
|
|
153
307
|
}
|
|
154
308
|
|
|
155
309
|
function useMediaTrash() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
310
|
+
const $ = c(5);
|
|
311
|
+
const [trashing, setTrashing] = useState(false);
|
|
312
|
+
const api = useMediasApi();
|
|
313
|
+
let t0;
|
|
314
|
+
if ($[0] !== api) {
|
|
315
|
+
t0 = (id, data) => {
|
|
316
|
+
setTrashing(true);
|
|
317
|
+
return api.trash(id, data).then(response => {
|
|
318
|
+
setTrashing(false);
|
|
319
|
+
return response;
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
$[0] = api;
|
|
323
|
+
$[1] = t0;
|
|
324
|
+
} else {
|
|
325
|
+
t0 = $[1];
|
|
326
|
+
}
|
|
327
|
+
const mediaTrash = t0;
|
|
328
|
+
let t1;
|
|
329
|
+
if ($[2] !== mediaTrash || $[3] !== trashing) {
|
|
330
|
+
t1 = {
|
|
331
|
+
mediaTrash,
|
|
332
|
+
trashing
|
|
333
|
+
};
|
|
334
|
+
$[2] = mediaTrash;
|
|
335
|
+
$[3] = trashing;
|
|
336
|
+
$[4] = t1;
|
|
337
|
+
} else {
|
|
338
|
+
t1 = $[4];
|
|
339
|
+
}
|
|
340
|
+
return t1;
|
|
172
341
|
}
|
|
173
342
|
|
|
174
343
|
function useMediaRestore() {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
344
|
+
const $ = c(5);
|
|
345
|
+
const [restoring, setRestoring] = useState(false);
|
|
346
|
+
const api = useMediasApi();
|
|
347
|
+
let t0;
|
|
348
|
+
if ($[0] !== api) {
|
|
349
|
+
t0 = (id, data) => {
|
|
350
|
+
setRestoring(true);
|
|
351
|
+
return api.restore(id, data).then(response => {
|
|
352
|
+
setRestoring(false);
|
|
353
|
+
return response;
|
|
354
|
+
});
|
|
355
|
+
};
|
|
356
|
+
$[0] = api;
|
|
357
|
+
$[1] = t0;
|
|
358
|
+
} else {
|
|
359
|
+
t0 = $[1];
|
|
360
|
+
}
|
|
361
|
+
const mediaRestore = t0;
|
|
362
|
+
let t1;
|
|
363
|
+
if ($[2] !== mediaRestore || $[3] !== restoring) {
|
|
364
|
+
t1 = {
|
|
365
|
+
mediaRestore,
|
|
366
|
+
restoring
|
|
367
|
+
};
|
|
368
|
+
$[2] = mediaRestore;
|
|
369
|
+
$[3] = restoring;
|
|
370
|
+
$[4] = t1;
|
|
371
|
+
} else {
|
|
372
|
+
t1 = $[4];
|
|
373
|
+
}
|
|
374
|
+
return t1;
|
|
191
375
|
}
|
|
192
376
|
|
|
193
377
|
function useMediaReplace() {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
378
|
+
const $ = c(5);
|
|
379
|
+
const [replacing, setReplacing] = useState(false);
|
|
380
|
+
const api = useMediasApi();
|
|
381
|
+
let t0;
|
|
382
|
+
if ($[0] !== api) {
|
|
383
|
+
t0 = (id, data) => {
|
|
384
|
+
setReplacing(true);
|
|
385
|
+
return api.replace(id, data).then(response => {
|
|
386
|
+
setReplacing(false);
|
|
387
|
+
return response;
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
$[0] = api;
|
|
391
|
+
$[1] = t0;
|
|
392
|
+
} else {
|
|
393
|
+
t0 = $[1];
|
|
394
|
+
}
|
|
395
|
+
const mediaReplace = t0;
|
|
396
|
+
let t1;
|
|
397
|
+
if ($[2] !== mediaReplace || $[3] !== replacing) {
|
|
398
|
+
t1 = {
|
|
399
|
+
mediaReplace,
|
|
400
|
+
replacing
|
|
401
|
+
};
|
|
402
|
+
$[2] = mediaReplace;
|
|
403
|
+
$[3] = replacing;
|
|
404
|
+
$[4] = t1;
|
|
405
|
+
} else {
|
|
406
|
+
t1 = $[4];
|
|
407
|
+
}
|
|
408
|
+
return t1;
|
|
210
409
|
}
|
|
211
410
|
|
|
212
411
|
var styles = {"mediaFrame":"panneau-medias-mediaFrame"};
|
|
213
412
|
|
|
214
|
-
function MediaFrame(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
413
|
+
function MediaFrame(t0) {
|
|
414
|
+
const $ = c(15);
|
|
415
|
+
const {
|
|
416
|
+
value: t1,
|
|
417
|
+
showPlayer: t2,
|
|
418
|
+
className: t3
|
|
419
|
+
} = t0;
|
|
420
|
+
const value = t1 === undefined ? null : t1;
|
|
421
|
+
const initialShowPlayer = t2 === undefined ? true : t2;
|
|
422
|
+
const className = t3 === undefined ? null : t3;
|
|
423
|
+
const [showPlayer, setShowPlayer] = useState(initialShowPlayer);
|
|
424
|
+
let t4;
|
|
425
|
+
if ($[0] !== value) {
|
|
426
|
+
t4 = value || {};
|
|
427
|
+
$[0] = value;
|
|
428
|
+
$[1] = t4;
|
|
429
|
+
} else {
|
|
430
|
+
t4 = $[1];
|
|
431
|
+
}
|
|
432
|
+
const {
|
|
433
|
+
type: t5
|
|
434
|
+
} = t4;
|
|
435
|
+
const type = t5 === undefined ? null : t5;
|
|
436
|
+
let t6;
|
|
437
|
+
if ($[2] !== showPlayer) {
|
|
438
|
+
t6 = () => {
|
|
439
|
+
setShowPlayer(!showPlayer);
|
|
440
|
+
};
|
|
441
|
+
$[2] = showPlayer;
|
|
442
|
+
$[3] = t6;
|
|
443
|
+
} else {
|
|
444
|
+
t6 = $[3];
|
|
445
|
+
}
|
|
446
|
+
const onClick = t6;
|
|
447
|
+
const t7 = className != null;
|
|
448
|
+
let t8;
|
|
449
|
+
if ($[4] !== className || $[5] !== t7) {
|
|
450
|
+
t8 = classNames([styles.mediaFrame, "position-relative", "d-flex", "flex-grow-1", "w-100", "mw-100", {
|
|
451
|
+
[className]: t7
|
|
452
|
+
}]);
|
|
453
|
+
$[4] = className;
|
|
454
|
+
$[5] = t7;
|
|
455
|
+
$[6] = t8;
|
|
456
|
+
} else {
|
|
457
|
+
t8 = $[6];
|
|
458
|
+
}
|
|
459
|
+
let t9;
|
|
460
|
+
if ($[7] !== onClick || $[8] !== showPlayer || $[9] !== type || $[10] !== value) {
|
|
461
|
+
t9 = showPlayer && type !== "image" ? /*#__PURE__*/jsx(MediaPlayer, {
|
|
234
462
|
value: value,
|
|
235
463
|
autoPlay: false,
|
|
236
464
|
width: "100%"
|
|
237
465
|
}) : /*#__PURE__*/jsx(ImageDisplay, {
|
|
238
466
|
className: "w-100",
|
|
239
467
|
value: value,
|
|
240
|
-
onClick: type ===
|
|
468
|
+
onClick: type === "video" || type === "audio" ? onClick : null,
|
|
241
469
|
maxWidth: null,
|
|
242
470
|
maxHeight: null
|
|
243
|
-
})
|
|
244
|
-
|
|
471
|
+
});
|
|
472
|
+
$[7] = onClick;
|
|
473
|
+
$[8] = showPlayer;
|
|
474
|
+
$[9] = type;
|
|
475
|
+
$[10] = value;
|
|
476
|
+
$[11] = t9;
|
|
477
|
+
} else {
|
|
478
|
+
t9 = $[11];
|
|
479
|
+
}
|
|
480
|
+
let t10;
|
|
481
|
+
if ($[12] !== t8 || $[13] !== t9) {
|
|
482
|
+
t10 = /*#__PURE__*/jsx("div", {
|
|
483
|
+
className: t8,
|
|
484
|
+
children: t9
|
|
485
|
+
});
|
|
486
|
+
$[12] = t8;
|
|
487
|
+
$[13] = t9;
|
|
488
|
+
$[14] = t10;
|
|
489
|
+
} else {
|
|
490
|
+
t10 = $[14];
|
|
491
|
+
}
|
|
492
|
+
return t10;
|
|
245
493
|
}
|
|
246
494
|
|
|
247
495
|
var defaultFields = [{
|
|
248
496
|
name: 'name',
|
|
249
497
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
250
|
-
id: "WX83V9"
|
|
251
|
-
defaultMessage: [{
|
|
252
|
-
"type": 0,
|
|
253
|
-
"value": "File name"
|
|
254
|
-
}]
|
|
498
|
+
id: "WX83V9"
|
|
255
499
|
}),
|
|
256
500
|
type: 'text',
|
|
257
501
|
component: 'text'
|
|
258
502
|
}, {
|
|
259
503
|
name: 'description',
|
|
260
504
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
261
|
-
id: "ygNvmz"
|
|
262
|
-
defaultMessage: [{
|
|
263
|
-
"type": 0,
|
|
264
|
-
"value": "Description"
|
|
265
|
-
}]
|
|
505
|
+
id: "ygNvmz"
|
|
266
506
|
}),
|
|
267
507
|
type: 'text',
|
|
268
508
|
component: 'text'
|
|
@@ -285,22 +525,14 @@ var defaultFields = [{
|
|
|
285
525
|
id: 'info',
|
|
286
526
|
component: 'fields',
|
|
287
527
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
288
|
-
id: "3RT69u"
|
|
289
|
-
defaultMessage: [{
|
|
290
|
-
"type": 0,
|
|
291
|
-
"value": "Informations"
|
|
292
|
-
}]
|
|
528
|
+
id: "3RT69u"
|
|
293
529
|
}),
|
|
294
530
|
isList: true,
|
|
295
531
|
hideWithoutValue: true,
|
|
296
532
|
fields: [{
|
|
297
533
|
id: 'user',
|
|
298
534
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
299
|
-
id: "yByaBh"
|
|
300
|
-
defaultMessage: [{
|
|
301
|
-
"type": 0,
|
|
302
|
-
"value": "Added by"
|
|
303
|
-
}]
|
|
535
|
+
id: "yByaBh"
|
|
304
536
|
}),
|
|
305
537
|
type: 'display',
|
|
306
538
|
display: 'avatar',
|
|
@@ -309,11 +541,7 @@ var defaultFields = [{
|
|
|
309
541
|
}, {
|
|
310
542
|
id: 'created_at',
|
|
311
543
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
312
|
-
id: "PN+75e"
|
|
313
|
-
defaultMessage: [{
|
|
314
|
-
"type": 0,
|
|
315
|
-
"value": "Created at"
|
|
316
|
-
}]
|
|
544
|
+
id: "PN+75e"
|
|
317
545
|
}),
|
|
318
546
|
type: 'display',
|
|
319
547
|
display: 'date',
|
|
@@ -325,22 +553,14 @@ var defaultFields = [{
|
|
|
325
553
|
id: 'technical',
|
|
326
554
|
component: 'fields',
|
|
327
555
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
328
|
-
id: "xKUOLG"
|
|
329
|
-
defaultMessage: [{
|
|
330
|
-
"type": 0,
|
|
331
|
-
"value": "Technical details"
|
|
332
|
-
}]
|
|
556
|
+
id: "xKUOLG"
|
|
333
557
|
}),
|
|
334
558
|
isList: true,
|
|
335
559
|
hideWithoutValue: true,
|
|
336
560
|
fields: [{
|
|
337
561
|
id: 'format',
|
|
338
562
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
339
|
-
id: "JuxiUN"
|
|
340
|
-
defaultMessage: [{
|
|
341
|
-
"type": 0,
|
|
342
|
-
"value": "Format"
|
|
343
|
-
}]
|
|
563
|
+
id: "JuxiUN"
|
|
344
564
|
}),
|
|
345
565
|
type: 'display',
|
|
346
566
|
display: 'unit',
|
|
@@ -350,11 +570,7 @@ var defaultFields = [{
|
|
|
350
570
|
}, {
|
|
351
571
|
id: 'dimensions',
|
|
352
572
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
353
|
-
id: "rmJBin"
|
|
354
|
-
defaultMessage: [{
|
|
355
|
-
"type": 0,
|
|
356
|
-
"value": "Dimensions"
|
|
357
|
-
}]
|
|
573
|
+
id: "rmJBin"
|
|
358
574
|
}),
|
|
359
575
|
type: 'display',
|
|
360
576
|
display: 'unit',
|
|
@@ -364,11 +580,7 @@ var defaultFields = [{
|
|
|
364
580
|
}, {
|
|
365
581
|
id: 'size',
|
|
366
582
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
367
|
-
id: "g2CRt5"
|
|
368
|
-
defaultMessage: [{
|
|
369
|
-
"type": 0,
|
|
370
|
-
"value": "Size"
|
|
371
|
-
}]
|
|
583
|
+
id: "g2CRt5"
|
|
372
584
|
}),
|
|
373
585
|
type: 'display',
|
|
374
586
|
display: 'unit',
|
|
@@ -378,11 +590,7 @@ var defaultFields = [{
|
|
|
378
590
|
}, {
|
|
379
591
|
id: 'duration',
|
|
380
592
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
381
|
-
id: "wU++NJ"
|
|
382
|
-
defaultMessage: [{
|
|
383
|
-
"type": 0,
|
|
384
|
-
"value": "Duration"
|
|
385
|
-
}]
|
|
593
|
+
id: "wU++NJ"
|
|
386
594
|
}),
|
|
387
595
|
type: 'display',
|
|
388
596
|
display: 'unit',
|
|
@@ -392,74 +600,63 @@ var defaultFields = [{
|
|
|
392
600
|
}]
|
|
393
601
|
}];
|
|
394
602
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
changed = _useState2[0],
|
|
436
|
-
setChanged = _useState2[1];
|
|
437
|
-
var disabled = updating || deleting || trashing || initialValue === null;
|
|
438
|
-
var _ref2 = initialValue || {},
|
|
439
|
-
_ref2$name = _ref2.name,
|
|
440
|
-
name = _ref2$name === void 0 ? null : _ref2$name,
|
|
441
|
-
_ref2$type = _ref2.type,
|
|
442
|
-
type = _ref2$type === void 0 ? null : _ref2$type,
|
|
443
|
-
_ref2$deletedAt = _ref2.deletedAt,
|
|
444
|
-
deletedAt = _ref2$deletedAt === void 0 ? null : _ref2$deletedAt;
|
|
445
|
-
var onChangeMedia = useCallback(function (newValue) {
|
|
603
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
604
|
+
function MediaForm({
|
|
605
|
+
value: initialValue = null,
|
|
606
|
+
fields: initialFields = defaultFields,
|
|
607
|
+
onChange = null,
|
|
608
|
+
onSave = null,
|
|
609
|
+
onReplace = null,
|
|
610
|
+
onDelete = null,
|
|
611
|
+
onClose = null,
|
|
612
|
+
withDelete = false,
|
|
613
|
+
withTrash = false,
|
|
614
|
+
withReplace = false,
|
|
615
|
+
className = null,
|
|
616
|
+
children = null
|
|
617
|
+
}) {
|
|
618
|
+
const FieldsComponent = useFieldComponent('fields');
|
|
619
|
+
const {
|
|
620
|
+
update,
|
|
621
|
+
updating
|
|
622
|
+
} = useMediaUpdate();
|
|
623
|
+
const {
|
|
624
|
+
mediaTrash,
|
|
625
|
+
trashing
|
|
626
|
+
} = useMediaTrash();
|
|
627
|
+
const {
|
|
628
|
+
mediaDelete,
|
|
629
|
+
deleting
|
|
630
|
+
} = useMediaDelete();
|
|
631
|
+
const {
|
|
632
|
+
mediaReplace,
|
|
633
|
+
replacing
|
|
634
|
+
} = useMediaReplace();
|
|
635
|
+
const [changed, setChanged] = useState(false);
|
|
636
|
+
const disabled = updating || deleting || trashing || initialValue === null;
|
|
637
|
+
const {
|
|
638
|
+
name = null,
|
|
639
|
+
type = null,
|
|
640
|
+
deletedAt = null
|
|
641
|
+
} = initialValue || {};
|
|
642
|
+
const onChangeMedia = useCallback(newValue => {
|
|
446
643
|
if (onChange !== null) {
|
|
447
644
|
onChange(newValue);
|
|
448
645
|
}
|
|
449
646
|
setChanged(true);
|
|
450
647
|
}, [onChange, setChanged]);
|
|
451
|
-
|
|
648
|
+
const onMediaSaved = useCallback(newValue_0 => {
|
|
452
649
|
if (onSave !== null) {
|
|
453
|
-
onSave(
|
|
650
|
+
onSave(newValue_0);
|
|
454
651
|
}
|
|
455
652
|
setChanged(false);
|
|
456
653
|
}, [onChange, setChanged]);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
654
|
+
const onDeleteMedia = useCallback(() => {
|
|
655
|
+
const {
|
|
656
|
+
id = null
|
|
657
|
+
} = initialValue || {};
|
|
461
658
|
if (withTrash && deletedAt !== null) {
|
|
462
|
-
mediaTrash(id, initialValue).then(
|
|
659
|
+
mediaTrash(id, initialValue).then(() => {
|
|
463
660
|
if (onDelete !== null) {
|
|
464
661
|
onDelete();
|
|
465
662
|
}
|
|
@@ -470,7 +667,7 @@ function MediaForm(_ref) {
|
|
|
470
667
|
});
|
|
471
668
|
} else {
|
|
472
669
|
// Destroy
|
|
473
|
-
mediaDelete(id, initialValue).then(
|
|
670
|
+
mediaDelete(id, initialValue).then(() => {
|
|
474
671
|
if (onDelete !== null) {
|
|
475
672
|
onDelete();
|
|
476
673
|
}
|
|
@@ -481,31 +678,32 @@ function MediaForm(_ref) {
|
|
|
481
678
|
});
|
|
482
679
|
}
|
|
483
680
|
}, [initialValue, mediaDelete, mediaTrash, deletedAt, setChanged, onDelete, withTrash]);
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
mediaReplace(
|
|
681
|
+
const onUploadComplete = useCallback(data => {
|
|
682
|
+
const {
|
|
683
|
+
id: id_0 = null
|
|
684
|
+
} = initialValue || {};
|
|
685
|
+
mediaReplace(id_0, data).then(onReplace);
|
|
489
686
|
}, [initialValue, onReplace]);
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
generalError = _useForm.generalError;
|
|
687
|
+
const postForm = useCallback((action, data_0) => initialValue !== null ? update(initialValue.id, data_0) : Promise.resolve(null), [initialValue, update]);
|
|
688
|
+
const {
|
|
689
|
+
value,
|
|
690
|
+
setValue,
|
|
691
|
+
fields,
|
|
692
|
+
onSubmit,
|
|
693
|
+
status,
|
|
694
|
+
generalError
|
|
695
|
+
} = useForm({
|
|
696
|
+
fields: initialFields,
|
|
697
|
+
postForm,
|
|
698
|
+
onComplete: onMediaSaved,
|
|
699
|
+
value: initialValue,
|
|
700
|
+
setValue: onChangeMedia,
|
|
701
|
+
disabled: updating
|
|
702
|
+
});
|
|
507
703
|
return /*#__PURE__*/jsxs("div", {
|
|
508
|
-
className: classNames(['text-body',
|
|
704
|
+
className: classNames(['text-body', {
|
|
705
|
+
[className]: className !== null
|
|
706
|
+
}]),
|
|
509
707
|
children: [/*#__PURE__*/jsxs("nav", {
|
|
510
708
|
className: "navbar d-flex w-100 align-items-end justify-content-between border-bottom mb-3",
|
|
511
709
|
children: [/*#__PURE__*/jsxs("div", {
|
|
@@ -521,11 +719,7 @@ function MediaForm(_ref) {
|
|
|
521
719
|
onClick: onClose,
|
|
522
720
|
icon: "arrow-left",
|
|
523
721
|
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
524
|
-
id: "8NyYTH"
|
|
525
|
-
defaultMessage: [{
|
|
526
|
-
"type": 0,
|
|
527
|
-
"value": "Back"
|
|
528
|
-
}]
|
|
722
|
+
id: "8NyYTH"
|
|
529
723
|
})
|
|
530
724
|
})
|
|
531
725
|
}), /*#__PURE__*/jsx("h4", {
|
|
@@ -546,11 +740,7 @@ function MediaForm(_ref) {
|
|
|
546
740
|
closeAfterFinish: true,
|
|
547
741
|
disabled: deleting || trashing || updating || replacing,
|
|
548
742
|
addButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
|
|
549
|
-
id: "GxOBVL"
|
|
550
|
-
defaultMessage: [{
|
|
551
|
-
"type": 0,
|
|
552
|
-
"value": "Replace"
|
|
553
|
-
}]
|
|
743
|
+
id: "GxOBVL"
|
|
554
744
|
}),
|
|
555
745
|
onChange: onUploadComplete
|
|
556
746
|
}) : null, withDelete ? /*#__PURE__*/jsx(Button, {
|
|
@@ -561,17 +751,9 @@ function MediaForm(_ref) {
|
|
|
561
751
|
onClick: onDeleteMedia,
|
|
562
752
|
disabled: deleting || trashing || updating || replacing,
|
|
563
753
|
children: withTrash && deletedAt === null ? /*#__PURE__*/jsx(FormattedMessage, {
|
|
564
|
-
id: "PSlT7H"
|
|
565
|
-
defaultMessage: [{
|
|
566
|
-
"type": 0,
|
|
567
|
-
"value": "Trash"
|
|
568
|
-
}]
|
|
754
|
+
id: "PSlT7H"
|
|
569
755
|
}) : /*#__PURE__*/jsx(FormattedMessage, {
|
|
570
|
-
id: "Bhu3B2"
|
|
571
|
-
defaultMessage: [{
|
|
572
|
-
"type": 0,
|
|
573
|
-
"value": "Delete"
|
|
574
|
-
}]
|
|
756
|
+
id: "Bhu3B2"
|
|
575
757
|
})
|
|
576
758
|
}) : null, onSave !== null ? /*#__PURE__*/jsx(Button, {
|
|
577
759
|
className: "mb-1 mt-1",
|
|
@@ -581,11 +763,7 @@ function MediaForm(_ref) {
|
|
|
581
763
|
onClick: onSubmit,
|
|
582
764
|
disabled: !changed || updating || deleting || trashing,
|
|
583
765
|
children: /*#__PURE__*/jsx(FormattedMessage, {
|
|
584
|
-
id: "R1HYj0"
|
|
585
|
-
defaultMessage: [{
|
|
586
|
-
"type": 0,
|
|
587
|
-
"value": "Save"
|
|
588
|
-
}]
|
|
766
|
+
id: "R1HYj0"
|
|
589
767
|
})
|
|
590
768
|
}) : null]
|
|
591
769
|
})]
|
|
@@ -624,38 +802,49 @@ function MediaForm(_ref) {
|
|
|
624
802
|
});
|
|
625
803
|
}
|
|
626
804
|
|
|
627
|
-
|
|
805
|
+
const MediaContext = /*#__PURE__*/createContext(null);
|
|
628
806
|
function useCurrentMedia() {
|
|
629
807
|
return use(MediaContext);
|
|
630
808
|
}
|
|
631
|
-
function MediaProvider(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
809
|
+
function MediaProvider(t0) {
|
|
810
|
+
const $ = c(5);
|
|
811
|
+
const {
|
|
812
|
+
media: t1,
|
|
813
|
+
children
|
|
814
|
+
} = t0;
|
|
815
|
+
const providedMedia = t1 === undefined ? null : t1;
|
|
816
|
+
const [currentMedia, setCurrentMedia] = useState(providedMedia);
|
|
817
|
+
let t2;
|
|
818
|
+
if ($[0] !== currentMedia) {
|
|
819
|
+
t2 = {
|
|
820
|
+
currentMedia,
|
|
821
|
+
setCurrentMedia
|
|
643
822
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
823
|
+
$[0] = currentMedia;
|
|
824
|
+
$[1] = t2;
|
|
825
|
+
} else {
|
|
826
|
+
t2 = $[1];
|
|
827
|
+
}
|
|
828
|
+
const values = t2;
|
|
829
|
+
let t3;
|
|
830
|
+
if ($[2] !== children || $[3] !== values) {
|
|
831
|
+
t3 = /*#__PURE__*/jsx(MediaContext, {
|
|
832
|
+
value: values,
|
|
833
|
+
children: children
|
|
834
|
+
});
|
|
835
|
+
$[2] = children;
|
|
836
|
+
$[3] = values;
|
|
837
|
+
$[4] = t3;
|
|
838
|
+
} else {
|
|
839
|
+
t3 = $[4];
|
|
840
|
+
}
|
|
841
|
+
return t3;
|
|
649
842
|
}
|
|
650
843
|
|
|
651
844
|
var defaultColumns = [{
|
|
652
845
|
id: 'image',
|
|
653
846
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
654
|
-
id: "UbxbKP"
|
|
655
|
-
defaultMessage: [{
|
|
656
|
-
"type": 0,
|
|
657
|
-
"value": "Preview"
|
|
658
|
-
}]
|
|
847
|
+
id: "UbxbKP"
|
|
659
848
|
}),
|
|
660
849
|
component: 'image',
|
|
661
850
|
path: 'thumbnail_url',
|
|
@@ -663,54 +852,30 @@ var defaultColumns = [{
|
|
|
663
852
|
}, {
|
|
664
853
|
id: 'name',
|
|
665
854
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
666
|
-
id: "WX83V9"
|
|
667
|
-
defaultMessage: [{
|
|
668
|
-
"type": 0,
|
|
669
|
-
"value": "File name"
|
|
670
|
-
}]
|
|
855
|
+
id: "WX83V9"
|
|
671
856
|
}),
|
|
672
857
|
component: 'text-description',
|
|
673
858
|
path: 'name',
|
|
674
859
|
descriptionPath: 'type',
|
|
675
860
|
descriptionValues: {
|
|
676
861
|
image: /*#__PURE__*/jsx(FormattedMessage, {
|
|
677
|
-
id: "AwDQvD"
|
|
678
|
-
defaultMessage: [{
|
|
679
|
-
"type": 0,
|
|
680
|
-
"value": "Image"
|
|
681
|
-
}]
|
|
862
|
+
id: "AwDQvD"
|
|
682
863
|
}),
|
|
683
864
|
video: /*#__PURE__*/jsx(FormattedMessage, {
|
|
684
|
-
id: "mQiyAm"
|
|
685
|
-
defaultMessage: [{
|
|
686
|
-
"type": 0,
|
|
687
|
-
"value": "Video"
|
|
688
|
-
}]
|
|
865
|
+
id: "mQiyAm"
|
|
689
866
|
}),
|
|
690
867
|
audio: /*#__PURE__*/jsx(FormattedMessage, {
|
|
691
|
-
id: "XnyI69"
|
|
692
|
-
defaultMessage: [{
|
|
693
|
-
"type": 0,
|
|
694
|
-
"value": "Audio"
|
|
695
|
-
}]
|
|
868
|
+
id: "XnyI69"
|
|
696
869
|
}),
|
|
697
870
|
document: /*#__PURE__*/jsx(FormattedMessage, {
|
|
698
|
-
id: "1dqmFw"
|
|
699
|
-
defaultMessage: [{
|
|
700
|
-
"type": 0,
|
|
701
|
-
"value": "Document"
|
|
702
|
-
}]
|
|
871
|
+
id: "1dqmFw"
|
|
703
872
|
})
|
|
704
873
|
},
|
|
705
874
|
sortable: true
|
|
706
875
|
}, {
|
|
707
876
|
id: 'dimensions',
|
|
708
877
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
709
|
-
id: "eCe9ZY"
|
|
710
|
-
defaultMessage: [{
|
|
711
|
-
"type": 0,
|
|
712
|
-
"value": "Dimensions"
|
|
713
|
-
}]
|
|
878
|
+
id: "eCe9ZY"
|
|
714
879
|
}),
|
|
715
880
|
component: 'unit',
|
|
716
881
|
format: 'dimensions',
|
|
@@ -718,11 +883,7 @@ var defaultColumns = [{
|
|
|
718
883
|
}, {
|
|
719
884
|
id: 'size',
|
|
720
885
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
721
|
-
id: "c3hu9o"
|
|
722
|
-
defaultMessage: [{
|
|
723
|
-
"type": 0,
|
|
724
|
-
"value": "Size"
|
|
725
|
-
}]
|
|
886
|
+
id: "c3hu9o"
|
|
726
887
|
}),
|
|
727
888
|
component: 'unit',
|
|
728
889
|
format: 'bytes',
|
|
@@ -730,11 +891,7 @@ var defaultColumns = [{
|
|
|
730
891
|
}, {
|
|
731
892
|
id: 'duration',
|
|
732
893
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
733
|
-
id: "002oWQ"
|
|
734
|
-
defaultMessage: [{
|
|
735
|
-
"type": 0,
|
|
736
|
-
"value": "Duration"
|
|
737
|
-
}]
|
|
894
|
+
id: "002oWQ"
|
|
738
895
|
}),
|
|
739
896
|
component: 'unit',
|
|
740
897
|
format: 'duration',
|
|
@@ -751,11 +908,7 @@ var defaultColumns = [{
|
|
|
751
908
|
{
|
|
752
909
|
id: 'created_at',
|
|
753
910
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
754
|
-
id: "OzYWZz"
|
|
755
|
-
defaultMessage: [{
|
|
756
|
-
"type": 0,
|
|
757
|
-
"value": "Created at"
|
|
758
|
-
}]
|
|
911
|
+
id: "OzYWZz"
|
|
759
912
|
}),
|
|
760
913
|
component: 'date',
|
|
761
914
|
path: 'created_at',
|
|
@@ -764,11 +917,7 @@ var defaultColumns = [{
|
|
|
764
917
|
}, {
|
|
765
918
|
id: 'actions',
|
|
766
919
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
767
|
-
id: "rtwfuZ"
|
|
768
|
-
defaultMessage: [{
|
|
769
|
-
"type": 0,
|
|
770
|
-
"value": "Actions"
|
|
771
|
-
}]
|
|
920
|
+
id: "rtwfuZ"
|
|
772
921
|
}),
|
|
773
922
|
actions: ['edit', 'delete']
|
|
774
923
|
// component: ItemActions,
|
|
@@ -793,46 +942,26 @@ var defaultFilters = [{
|
|
|
793
942
|
component: 'select',
|
|
794
943
|
name: 'types',
|
|
795
944
|
placeholder: /*#__PURE__*/jsx(FormattedMessage, {
|
|
796
|
-
id: "9/t5wK"
|
|
797
|
-
defaultMessage: [{
|
|
798
|
-
"type": 0,
|
|
799
|
-
"value": "Type"
|
|
800
|
-
}]
|
|
945
|
+
id: "9/t5wK"
|
|
801
946
|
}),
|
|
802
947
|
options: [{
|
|
803
948
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
804
|
-
id: "yHAmDD"
|
|
805
|
-
defaultMessage: [{
|
|
806
|
-
"type": 0,
|
|
807
|
-
"value": "Image"
|
|
808
|
-
}]
|
|
949
|
+
id: "yHAmDD"
|
|
809
950
|
}),
|
|
810
951
|
value: 'image'
|
|
811
952
|
}, {
|
|
812
953
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
813
|
-
id: "xSERPA"
|
|
814
|
-
defaultMessage: [{
|
|
815
|
-
"type": 0,
|
|
816
|
-
"value": "Video"
|
|
817
|
-
}]
|
|
954
|
+
id: "xSERPA"
|
|
818
955
|
}),
|
|
819
956
|
value: 'video'
|
|
820
957
|
}, {
|
|
821
958
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
822
|
-
id: "yQRtgx"
|
|
823
|
-
defaultMessage: [{
|
|
824
|
-
"type": 0,
|
|
825
|
-
"value": "Audio"
|
|
826
|
-
}]
|
|
959
|
+
id: "yQRtgx"
|
|
827
960
|
}),
|
|
828
961
|
value: 'audio'
|
|
829
962
|
}, {
|
|
830
963
|
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
831
|
-
id: "8INLfU"
|
|
832
|
-
defaultMessage: [{
|
|
833
|
-
"type": 0,
|
|
834
|
-
"value": "Document"
|
|
835
|
-
}]
|
|
964
|
+
id: "8INLfU"
|
|
836
965
|
}),
|
|
837
966
|
value: 'document'
|
|
838
967
|
}],
|
|
@@ -858,9 +987,8 @@ var defaultFilters = [{
|
|
|
858
987
|
// },
|
|
859
988
|
];
|
|
860
989
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
var DEFAULT_LAYOUTS = [{
|
|
990
|
+
/* eslint-disable react/jsx-props-no-spreading, react/no-array-index-key */
|
|
991
|
+
const DEFAULT_LAYOUTS = [{
|
|
864
992
|
id: 'table',
|
|
865
993
|
label: /*#__PURE__*/jsx(Icon, {
|
|
866
994
|
name: "table"
|
|
@@ -871,175 +999,128 @@ var DEFAULT_LAYOUTS = [{
|
|
|
871
999
|
name: "grid"
|
|
872
1000
|
})
|
|
873
1001
|
}];
|
|
874
|
-
|
|
875
|
-
function MediasBrowser(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
_ref$withTrash = _ref.withTrash,
|
|
923
|
-
withTrash = _ref$withTrash === void 0 ? false : _ref$withTrash,
|
|
924
|
-
_ref$withReplace = _ref.withReplace,
|
|
925
|
-
withReplace = _ref$withReplace === void 0 ? false : _ref$withReplace,
|
|
926
|
-
_ref$withStickySelect = _ref.withStickySelection,
|
|
927
|
-
withStickySelection = _ref$withStickySelect === void 0 ? false : _ref$withStickySelect,
|
|
928
|
-
_ref$withoutUpload = _ref.withoutUpload,
|
|
929
|
-
withoutUpload = _ref$withoutUpload === void 0 ? false : _ref$withoutUpload,
|
|
930
|
-
_ref$className = _ref.className,
|
|
931
|
-
className = _ref$className === void 0 ? null : _ref$className,
|
|
932
|
-
_ref$formChildren = _ref.formChildren,
|
|
933
|
-
formChildren = _ref$formChildren === void 0 ? null : _ref$formChildren;
|
|
934
|
-
var _useState = useState(initialItems || null),
|
|
935
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
936
|
-
baseItems = _useState2[0];
|
|
937
|
-
var baseQuery = useMemo(function () {
|
|
938
|
-
return _objectSpread(_objectSpread({
|
|
939
|
-
count: 12
|
|
940
|
-
}, initialQuery), types !== null ? {
|
|
941
|
-
types: types
|
|
942
|
-
} : null);
|
|
943
|
-
}, [initialQuery, types]);
|
|
944
|
-
var _useQuery = useQuery(baseQuery),
|
|
945
|
-
fullQuery = _useQuery.query,
|
|
946
|
-
onPageChange = _useQuery.onPageChange,
|
|
947
|
-
onQueryChange = _useQuery.onQueryChange,
|
|
948
|
-
onQueryReset = _useQuery.onQueryReset;
|
|
949
|
-
var page = useMemo(function () {
|
|
950
|
-
var _page;
|
|
951
|
-
return (_page = (fullQuery || {}).page) !== null && _page !== void 0 ? _page : null;
|
|
952
|
-
}, [fullQuery]);
|
|
953
|
-
var count = useMemo(function () {
|
|
954
|
-
var _count;
|
|
955
|
-
return (_count = (fullQuery || {}).count) !== null && _count !== void 0 ? _count : null;
|
|
956
|
-
}, [fullQuery]);
|
|
1002
|
+
const DEFAULT_UPPY_CONFIG = {};
|
|
1003
|
+
function MediasBrowser({
|
|
1004
|
+
items: initialItems = null,
|
|
1005
|
+
extraItems = null,
|
|
1006
|
+
types = null,
|
|
1007
|
+
permissions = null,
|
|
1008
|
+
baseUrl = null,
|
|
1009
|
+
filters = defaultFilters,
|
|
1010
|
+
columns = defaultColumns,
|
|
1011
|
+
fields = defaultFields,
|
|
1012
|
+
query: initialQuery = null,
|
|
1013
|
+
layout: initialLayout = 'table',
|
|
1014
|
+
layouts = DEFAULT_LAYOUTS,
|
|
1015
|
+
theme = null,
|
|
1016
|
+
onMediaUploaded = null,
|
|
1017
|
+
onItemsChange = null,
|
|
1018
|
+
onLayoutChange = null,
|
|
1019
|
+
onMediaFormOpen = null,
|
|
1020
|
+
onMediaFormClose = null,
|
|
1021
|
+
selectable = false,
|
|
1022
|
+
selectedItems = null,
|
|
1023
|
+
onSelectionChange = null,
|
|
1024
|
+
multipleSelection = false,
|
|
1025
|
+
uppyConfig = DEFAULT_UPPY_CONFIG,
|
|
1026
|
+
withDelete = false,
|
|
1027
|
+
withTrash = false,
|
|
1028
|
+
withReplace = false,
|
|
1029
|
+
withStickySelection = false,
|
|
1030
|
+
withoutUpload = false,
|
|
1031
|
+
className = null,
|
|
1032
|
+
formChildren = null
|
|
1033
|
+
}) {
|
|
1034
|
+
const [baseItems] = useState(initialItems || null);
|
|
1035
|
+
const baseQuery = useMemo(() => ({
|
|
1036
|
+
count: 12,
|
|
1037
|
+
...initialQuery,
|
|
1038
|
+
...(types !== null ? {
|
|
1039
|
+
types
|
|
1040
|
+
} : null)
|
|
1041
|
+
}), [initialQuery, types]);
|
|
1042
|
+
const {
|
|
1043
|
+
query: fullQuery,
|
|
1044
|
+
onPageChange,
|
|
1045
|
+
onQueryChange,
|
|
1046
|
+
onQueryReset
|
|
1047
|
+
} = useQuery(baseQuery);
|
|
1048
|
+
const page = useMemo(() => (fullQuery || {}).page ?? null, [fullQuery]);
|
|
1049
|
+
const count = useMemo(() => (fullQuery || {}).count ?? null, [fullQuery]);
|
|
957
1050
|
|
|
958
1051
|
// Stabilize the filter query reference: only create a new object when filter values actually change.
|
|
959
1052
|
// We use JSON.stringify as a stable primitive key so that useMemo only recomputes when values differ.
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1053
|
+
const queryJSON = useMemo(() => {
|
|
1054
|
+
const {
|
|
1055
|
+
page: _p,
|
|
1056
|
+
count: _c,
|
|
1057
|
+
...params
|
|
1058
|
+
} = fullQuery || {};
|
|
965
1059
|
return Object.keys(params).length > 0 ? JSON.stringify(params) : null;
|
|
966
1060
|
}, [fullQuery]);
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
_useMedias$pagination2 = _useMedias$pagination === void 0 ? {} : _useMedias$pagination,
|
|
1011
|
-
_useMedias$pagination3 = _useMedias$pagination2.lastPage,
|
|
1012
|
-
lastPage = _useMedias$pagination3 === void 0 ? null : _useMedias$pagination3,
|
|
1013
|
-
_useMedias$pagination4 = _useMedias$pagination2.total,
|
|
1014
|
-
total = _useMedias$pagination4 === void 0 ? null : _useMedias$pagination4,
|
|
1015
|
-
_useMedias$pages = _useMedias.pages,
|
|
1016
|
-
pages = _useMedias$pages === void 0 ? null : _useMedias$pages,
|
|
1017
|
-
reload = _useMedias.reload;
|
|
1018
|
-
var onClickTrash = useCallback(function () {
|
|
1061
|
+
const query = useMemo(() => queryJSON !== null ? JSON.parse(queryJSON) : null, [queryJSON]);
|
|
1062
|
+
const {
|
|
1063
|
+
create: canCreate = true,
|
|
1064
|
+
edit: canEdit = true,
|
|
1065
|
+
delete: canDelete = true
|
|
1066
|
+
} = permissions || {};
|
|
1067
|
+
const canUpload = canCreate && !withoutUpload;
|
|
1068
|
+
const {
|
|
1069
|
+
trashed = null,
|
|
1070
|
+
...queryWithoutTypes
|
|
1071
|
+
} = query || {};
|
|
1072
|
+
const {
|
|
1073
|
+
mediaTrash,
|
|
1074
|
+
trashing
|
|
1075
|
+
} = useMediaTrash();
|
|
1076
|
+
const {
|
|
1077
|
+
mediaDelete,
|
|
1078
|
+
deleting
|
|
1079
|
+
} = useMediaDelete();
|
|
1080
|
+
const {
|
|
1081
|
+
mediaRestore
|
|
1082
|
+
} = useMediaRestore();
|
|
1083
|
+
const [showTrashed, setShowTrashed] = useState(false);
|
|
1084
|
+
const {
|
|
1085
|
+
items,
|
|
1086
|
+
allItems,
|
|
1087
|
+
loading = false,
|
|
1088
|
+
loaded = false,
|
|
1089
|
+
updateItem = null,
|
|
1090
|
+
pagination: {
|
|
1091
|
+
lastPage = null,
|
|
1092
|
+
total = null
|
|
1093
|
+
} = {},
|
|
1094
|
+
pages = null,
|
|
1095
|
+
reload
|
|
1096
|
+
} = useMedias(query, page, count, {
|
|
1097
|
+
items: baseItems,
|
|
1098
|
+
trashed: showTrashed,
|
|
1099
|
+
queryConfig: {
|
|
1100
|
+
staleTime: 0
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
const onClickTrash = useCallback(() => {
|
|
1019
1104
|
setShowTrashed(!showTrashed);
|
|
1020
1105
|
}, [showTrashed, setShowTrashed]);
|
|
1021
|
-
useEffect(
|
|
1106
|
+
useEffect(() => {
|
|
1022
1107
|
if (onItemsChange !== null) {
|
|
1023
1108
|
onItemsChange(items);
|
|
1024
1109
|
}
|
|
1025
1110
|
}, [items, onItemsChange]);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
setLayout = _useState6[1];
|
|
1030
|
-
var hasLayouts = useMemo(function () {
|
|
1031
|
-
return layouts !== null && layouts.length > 1;
|
|
1032
|
-
}, [layouts]);
|
|
1033
|
-
var onClickLayout = useCallback(function (newLayout) {
|
|
1111
|
+
const [layout, setLayout] = useState(initialLayout || 'table');
|
|
1112
|
+
const hasLayouts = useMemo(() => layouts !== null && layouts.length > 1, [layouts]);
|
|
1113
|
+
const onClickLayout = useCallback(newLayout => {
|
|
1034
1114
|
setLayout(newLayout);
|
|
1035
1115
|
if (onLayoutChange !== null) {
|
|
1036
1116
|
onLayoutChange(newLayout);
|
|
1037
1117
|
}
|
|
1038
1118
|
}, [setLayout]);
|
|
1039
|
-
|
|
1040
|
-
currentMedia
|
|
1041
|
-
setCurrentMedia
|
|
1042
|
-
|
|
1119
|
+
const {
|
|
1120
|
+
currentMedia,
|
|
1121
|
+
setCurrentMedia
|
|
1122
|
+
} = useCurrentMedia();
|
|
1123
|
+
useEffect(() => {
|
|
1043
1124
|
if (currentMedia !== null && onMediaFormOpen !== null) {
|
|
1044
1125
|
onMediaFormOpen();
|
|
1045
1126
|
}
|
|
@@ -1047,102 +1128,86 @@ function MediasBrowser(_ref) {
|
|
|
1047
1128
|
onMediaFormClose();
|
|
1048
1129
|
}
|
|
1049
1130
|
}, [currentMedia]);
|
|
1050
|
-
|
|
1131
|
+
const onOpenMedia = useCallback(media => {
|
|
1051
1132
|
setCurrentMedia(media);
|
|
1052
1133
|
}, [setCurrentMedia]);
|
|
1053
|
-
|
|
1134
|
+
const onCloseMedia = useCallback(() => {
|
|
1054
1135
|
setCurrentMedia(null);
|
|
1055
1136
|
}, [setCurrentMedia]);
|
|
1056
|
-
|
|
1137
|
+
const onSaveMedia = useCallback(item => {
|
|
1057
1138
|
setCurrentMedia(null);
|
|
1058
1139
|
updateItem(item);
|
|
1059
1140
|
}, [setCurrentMedia, updateItem]);
|
|
1060
|
-
|
|
1061
|
-
setCurrentMedia(
|
|
1141
|
+
const onReplaceMedia = useCallback(item_0 => {
|
|
1142
|
+
setCurrentMedia(item_0);
|
|
1062
1143
|
reload();
|
|
1063
1144
|
}, [setCurrentMedia]);
|
|
1064
|
-
|
|
1145
|
+
const onDeleteMedia = useCallback(() => {
|
|
1065
1146
|
if (reload !== null) {
|
|
1066
1147
|
reload();
|
|
1067
1148
|
}
|
|
1068
1149
|
}, [reload]);
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
onSelectionChange(null);
|
|
1075
|
-
}
|
|
1150
|
+
const onTrashMedia = useCallback(id => !showTrashed && withTrash ? mediaTrash(id).then(() => {
|
|
1151
|
+
if (!multipleSelection) {
|
|
1152
|
+
const selectedId = selectedItems?.[0]?.id || null;
|
|
1153
|
+
if (selectedId !== null && selectedId === id && onSelectionChange !== null) {
|
|
1154
|
+
onSelectionChange(null);
|
|
1076
1155
|
}
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1156
|
+
}
|
|
1157
|
+
// Todo remove from mult selection
|
|
1158
|
+
}).then(() => reload()) : mediaDelete(id).then(() => {
|
|
1159
|
+
if (!multipleSelection) {
|
|
1160
|
+
const selectedId_0 = selectedItems?.[0]?.id || null;
|
|
1161
|
+
if (selectedId_0 !== null && selectedId_0 === id && onSelectionChange !== null) {
|
|
1162
|
+
onSelectionChange(null);
|
|
1084
1163
|
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
}, [showTrashed, withTrash, mediaTrash, mediaDelete, reload, selectedItems, multipleSelection, onSelectionChange]);
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
var _useState9 = useState(false),
|
|
1093
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
1094
|
-
uploadProcessing = _useState0[0],
|
|
1095
|
-
setUploadProcessing = _useState0[1];
|
|
1096
|
-
var onUploadedMediaChanged = useCallback(function (newMedias) {
|
|
1097
|
-
var uploadedNewMedias = (Array.isArray(newMedias) ? [].concat(_toConsumableArray(newMedias), _toConsumableArray(uploadedMedias || [])) : [newMedias].concat(_toConsumableArray(uploadedMedias || []))).filter(function (it) {
|
|
1098
|
-
return it !== null;
|
|
1099
|
-
});
|
|
1164
|
+
}
|
|
1165
|
+
// Todo remove from selection
|
|
1166
|
+
}).then(() => reload()), [showTrashed, withTrash, mediaTrash, mediaDelete, reload, selectedItems, multipleSelection, onSelectionChange]);
|
|
1167
|
+
const [uploadedMedias, setUploadedMedias] = useState(null);
|
|
1168
|
+
const [uploadProcessing, setUploadProcessing] = useState(false);
|
|
1169
|
+
const onUploadedMediaChanged = useCallback(newMedias => {
|
|
1170
|
+
const uploadedNewMedias = (Array.isArray(newMedias) ? [...newMedias, ...(uploadedMedias || [])] : [newMedias, ...(uploadedMedias || [])]).filter(it => it !== null);
|
|
1100
1171
|
setUploadedMedias(uploadedNewMedias);
|
|
1101
1172
|
if (onSelectionChange !== null) {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
onSelectionChange(multipleSelection && Array.isArray(newMedias) ? newMedias : firstMedia);
|
|
1173
|
+
const firstMedia = Array.isArray(newMedias) ? newMedias[0] ?? null : newMedias ?? null;
|
|
1174
|
+
onSelectionChange(multipleSelection && Array.isArray(newMedias) ? newMedias : [firstMedia]);
|
|
1105
1175
|
onQueryReset();
|
|
1106
|
-
reload().then(
|
|
1176
|
+
reload().then(() => {
|
|
1107
1177
|
setUploadedMedias(null);
|
|
1108
1178
|
});
|
|
1109
1179
|
}
|
|
1110
1180
|
}, [onSelectionChange, setUploadedMedias, uploadedMedias, onQueryReset, reload, multipleSelection]);
|
|
1111
|
-
|
|
1112
|
-
var medias = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1181
|
+
const onUploadComplete = useCallback((medias = null) => {
|
|
1113
1182
|
if (showTrashed) {
|
|
1114
1183
|
setShowTrashed(false);
|
|
1115
1184
|
}
|
|
1116
1185
|
if (medias === null) return;
|
|
1117
|
-
|
|
1118
|
-
return it !== null;
|
|
1119
|
-
});
|
|
1186
|
+
const rawMedias = (Array.isArray(medias) ? medias : [medias]).filter(it_0 => it_0 !== null);
|
|
1120
1187
|
if (onMediaUploaded !== null) {
|
|
1121
1188
|
setUploadProcessing(true);
|
|
1122
|
-
Promise.resolve(onMediaUploaded(rawMedias)).then(
|
|
1123
|
-
onUploadedMediaChanged(
|
|
1189
|
+
Promise.resolve(onMediaUploaded(rawMedias)).then(newMedias_0 => {
|
|
1190
|
+
onUploadedMediaChanged(newMedias_0 || null);
|
|
1124
1191
|
setUploadProcessing(false);
|
|
1125
|
-
})
|
|
1192
|
+
}).catch(() => {
|
|
1126
1193
|
setUploadProcessing(false);
|
|
1127
1194
|
});
|
|
1128
1195
|
} else {
|
|
1129
1196
|
onUploadedMediaChanged(rawMedias);
|
|
1130
1197
|
}
|
|
1131
1198
|
}, [onMediaUploaded, setUploadedMedias, setUploadProcessing, onUploadedMediaChanged]);
|
|
1132
|
-
|
|
1133
|
-
var pageNumber = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1199
|
+
const onClickPage = useCallback((e, pageNumber = null) => {
|
|
1134
1200
|
e.preventDefault();
|
|
1135
1201
|
e.stopPropagation();
|
|
1136
1202
|
onPageChange(pageNumber);
|
|
1137
1203
|
}, [onPageChange]);
|
|
1138
|
-
|
|
1204
|
+
const pagination = /*#__PURE__*/jsx(Pagination, {
|
|
1139
1205
|
page: page,
|
|
1140
1206
|
lastPage: lastPage,
|
|
1141
1207
|
total: total,
|
|
1142
1208
|
url: baseUrl,
|
|
1143
1209
|
query: query,
|
|
1144
1210
|
onClickPage: onClickPage,
|
|
1145
|
-
theme: theme,
|
|
1146
1211
|
loading: loading && pages !== null,
|
|
1147
1212
|
selectable: selectable,
|
|
1148
1213
|
selectedItems: selectedItems,
|
|
@@ -1151,9 +1216,9 @@ function MediasBrowser(_ref) {
|
|
|
1151
1216
|
withPreviousNext: true,
|
|
1152
1217
|
alwaysShowButtons: true
|
|
1153
1218
|
});
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1219
|
+
const hidePagination = loaded && !loading && total === 0;
|
|
1220
|
+
const finalFilters = useMemo(() => {
|
|
1221
|
+
const partialFilters = withTrash ? (filters || []).concat([{
|
|
1157
1222
|
name: 'trashed',
|
|
1158
1223
|
component: 'button',
|
|
1159
1224
|
theme: showTrashed ? 'danger' : 'secondary',
|
|
@@ -1164,111 +1229,91 @@ function MediasBrowser(_ref) {
|
|
|
1164
1229
|
onClick: onClickTrash
|
|
1165
1230
|
}]) : filters;
|
|
1166
1231
|
if (types !== null && partialFilters !== null) {
|
|
1167
|
-
return (partialFilters || []).map(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
return
|
|
1232
|
+
return (partialFilters || []).map(filter => {
|
|
1233
|
+
const {
|
|
1234
|
+
id: id_0 = null
|
|
1235
|
+
} = filter || {};
|
|
1236
|
+
return id_0 === 'types' ? {
|
|
1237
|
+
...filter,
|
|
1172
1238
|
disabled: true
|
|
1173
|
-
}
|
|
1239
|
+
} : filter;
|
|
1174
1240
|
});
|
|
1175
1241
|
}
|
|
1176
1242
|
return partialFilters;
|
|
1177
1243
|
}, [filters, types, withTrash, showTrashed, uploadProcessing, onClickTrash]);
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
_ref8$id = _ref8.id,
|
|
1225
|
-
columnId = _ref8$id === void 0 ? null : _ref8$id;
|
|
1226
|
-
if (columnId === 'actions') {
|
|
1227
|
-
var _ref9 = column || {},
|
|
1228
|
-
_ref9$actions = _ref9.actions,
|
|
1229
|
-
actions = _ref9$actions === void 0 ? [] : _ref9$actions;
|
|
1230
|
-
var availableActions = actions.filter(function (act) {
|
|
1231
|
-
return act !== 'delete' || canDelete;
|
|
1232
|
-
}).filter(function (act) {
|
|
1233
|
-
return act !== 'edit' || canEdit;
|
|
1234
|
-
});
|
|
1235
|
-
if (availableActions.length === 0) {
|
|
1236
|
-
return null;
|
|
1237
|
-
}
|
|
1238
|
-
return _objectSpread(_objectSpread({}, column), {}, {
|
|
1239
|
-
actions: availableActions
|
|
1240
|
-
});
|
|
1244
|
+
const partialColumns = useMemo(() => withTrash && showTrashed ? (columns || []).map(column => {
|
|
1245
|
+
const {
|
|
1246
|
+
id: columnId = null
|
|
1247
|
+
} = column || {};
|
|
1248
|
+
if (columnId === 'created_at') {
|
|
1249
|
+
return {
|
|
1250
|
+
...column,
|
|
1251
|
+
path: 'deleted_at',
|
|
1252
|
+
label: /*#__PURE__*/jsx(FormattedMessage, {
|
|
1253
|
+
id: "uds4wJ"
|
|
1254
|
+
})
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
if (columnId === 'actions') {
|
|
1258
|
+
const {
|
|
1259
|
+
actions = []
|
|
1260
|
+
} = column || {};
|
|
1261
|
+
return {
|
|
1262
|
+
...column,
|
|
1263
|
+
actions: (actions || []).reduce((acc, action) => {
|
|
1264
|
+
if (action === 'delete') {
|
|
1265
|
+
acc.push({
|
|
1266
|
+
id: 'restore',
|
|
1267
|
+
component: 'restore',
|
|
1268
|
+
withConfirmation: true,
|
|
1269
|
+
action: ids => mediaRestore(ids[0]).then(reload)
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
acc.push(action);
|
|
1273
|
+
return acc;
|
|
1274
|
+
}, []).filter(it_1 => it_1 !== 'edit')
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
return column;
|
|
1278
|
+
}) : columns, [columns, withTrash, showTrashed]);
|
|
1279
|
+
const finalColumns = useMemo(() => (partialColumns || []).map(column_0 => {
|
|
1280
|
+
const {
|
|
1281
|
+
id: columnId_0 = null
|
|
1282
|
+
} = column_0 || {};
|
|
1283
|
+
if (columnId_0 === 'actions') {
|
|
1284
|
+
const {
|
|
1285
|
+
actions: actions_0 = []
|
|
1286
|
+
} = column_0 || {};
|
|
1287
|
+
const availableActions = actions_0.filter(act => act !== 'delete' || canDelete).filter(act_0 => act_0 !== 'edit' || canEdit);
|
|
1288
|
+
if (availableActions.length === 0) {
|
|
1289
|
+
return null;
|
|
1241
1290
|
}
|
|
1242
|
-
return
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1291
|
+
return {
|
|
1292
|
+
...column_0,
|
|
1293
|
+
actions: availableActions
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
return column_0;
|
|
1297
|
+
}).filter(act_1 => act_1 !== null), [partialColumns, canEdit, canDelete]);
|
|
1298
|
+
const hasQueryItem = useMemo(() => {
|
|
1299
|
+
const showOnTopQuery = types === null ? query : queryWithoutTypes;
|
|
1249
1300
|
return showOnTopQuery !== null && !trashed ? Object.keys(showOnTopQuery).length > 0 : false;
|
|
1250
1301
|
}, [types, query, queryWithoutTypes, trashed]);
|
|
1251
|
-
|
|
1302
|
+
const finalItems = useMemo(() => {
|
|
1252
1303
|
if (withStickySelection && (extraItems !== null || uploadedMedias !== null || uploadProcessing === true)) {
|
|
1253
|
-
return uniqBy([
|
|
1304
|
+
return uniqBy([...(uploadProcessing ? [{
|
|
1254
1305
|
id: '-',
|
|
1255
1306
|
loading: true,
|
|
1256
1307
|
actionsDisabled: true,
|
|
1257
1308
|
selectionDisabled: true
|
|
1258
|
-
}] : []),
|
|
1259
|
-
|
|
1260
|
-
itemId =
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
}) || item || null;
|
|
1267
|
-
}).filter(function (it) {
|
|
1268
|
-
return it !== null;
|
|
1269
|
-
}) || [] : []), _toConsumableArray(items || [])), function (it) {
|
|
1270
|
-
return it === null || it === void 0 ? void 0 : it.id;
|
|
1271
|
-
});
|
|
1309
|
+
}] : []), ...(page === 1 && !hasQueryItem ? uploadedMedias || [] : []), ...(page === 1 && !hasQueryItem && !showTrashed ? (extraItems || []).map(item_1 => {
|
|
1310
|
+
const {
|
|
1311
|
+
id: itemId = null
|
|
1312
|
+
} = item_1;
|
|
1313
|
+
return (allItems || []).find(({
|
|
1314
|
+
id: otherId = null
|
|
1315
|
+
} = {}) => otherId === itemId) || item_1 || null;
|
|
1316
|
+
}).filter(it_2 => it_2 !== null) || [] : []), ...(items || [])], it_3 => it_3?.id);
|
|
1272
1317
|
}
|
|
1273
1318
|
return items;
|
|
1274
1319
|
}, [items, page, allItems, withStickySelection, extraItems, uploadProcessing, hasQueryItem, showTrashed]);
|
|
@@ -1304,8 +1349,7 @@ function MediasBrowser(_ref) {
|
|
|
1304
1349
|
clearValue: types !== null ? queryWithoutTypes : null,
|
|
1305
1350
|
filters: finalFilters,
|
|
1306
1351
|
onChange: onQueryChange,
|
|
1307
|
-
onClear: onQueryReset
|
|
1308
|
-
theme: theme
|
|
1352
|
+
onClear: onQueryReset
|
|
1309
1353
|
}) : null
|
|
1310
1354
|
}), /*#__PURE__*/jsx("div", {
|
|
1311
1355
|
className: "col-12 col-lg-auto",
|
|
@@ -1315,15 +1359,12 @@ function MediasBrowser(_ref) {
|
|
|
1315
1359
|
size: "sm",
|
|
1316
1360
|
theme: "secondary",
|
|
1317
1361
|
outline: true,
|
|
1318
|
-
items: (layouts || []).map(
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
className: 'px-3 py-2'
|
|
1325
|
-
});
|
|
1326
|
-
})
|
|
1362
|
+
items: (layouts || []).map(lay => ({
|
|
1363
|
+
...lay,
|
|
1364
|
+
active: layout === lay.id,
|
|
1365
|
+
onClick: () => onClickLayout(lay.id),
|
|
1366
|
+
className: 'px-3 py-2'
|
|
1367
|
+
}))
|
|
1327
1368
|
}) : null, canUpload ? /*#__PURE__*/jsx(UploadField, {
|
|
1328
1369
|
className: "w-auto text-nowrap",
|
|
1329
1370
|
withButton: true,
|
|
@@ -1345,14 +1386,13 @@ function MediasBrowser(_ref) {
|
|
|
1345
1386
|
}) : null]
|
|
1346
1387
|
}), layout === 'grid' ? /*#__PURE__*/jsx(Grid, {
|
|
1347
1388
|
size: "small",
|
|
1348
|
-
theme: theme,
|
|
1349
1389
|
component: MediaCard,
|
|
1350
1390
|
componentProps: {
|
|
1351
1391
|
className: 'd-flex w-100',
|
|
1352
1392
|
cardClassName: 'flex-grow-1',
|
|
1353
1393
|
vertical: true,
|
|
1354
|
-
onClickDescription:
|
|
1355
|
-
onOpenMedia(
|
|
1394
|
+
onClickDescription: it_4 => {
|
|
1395
|
+
onOpenMedia(it_4);
|
|
1356
1396
|
}
|
|
1357
1397
|
},
|
|
1358
1398
|
selectable: selectable && !showTrashed,
|
|
@@ -1386,25 +1426,19 @@ function MediasBrowser(_ref) {
|
|
|
1386
1426
|
// empty={emptyWithSticky}
|
|
1387
1427
|
,
|
|
1388
1428
|
actionsProps: {
|
|
1389
|
-
getDeletePropsFromValue:
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
href: null,
|
|
1403
|
-
onClick: function onClick() {
|
|
1404
|
-
onOpenMedia(it);
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
}
|
|
1429
|
+
getDeletePropsFromValue: () => ({
|
|
1430
|
+
href: null,
|
|
1431
|
+
withConfirmation: true,
|
|
1432
|
+
disabled: trashing || deleting,
|
|
1433
|
+
icon: showTrashed ? 'trash-fill' : 'trash',
|
|
1434
|
+
action: ids_0 => onTrashMedia(ids_0[0])
|
|
1435
|
+
}),
|
|
1436
|
+
getEditPropsFromValue: it_5 => ({
|
|
1437
|
+
href: null,
|
|
1438
|
+
onClick: () => {
|
|
1439
|
+
onOpenMedia(it_5);
|
|
1440
|
+
}
|
|
1441
|
+
})
|
|
1408
1442
|
}
|
|
1409
1443
|
}) : null, !hidePagination ? /*#__PURE__*/jsx("div", {
|
|
1410
1444
|
className: classNames(['d-flex', 'd-md-none', 'mt-3', 'mb-1', 'justify-content-end']),
|
|
@@ -1414,239 +1448,410 @@ function MediasBrowser(_ref) {
|
|
|
1414
1448
|
});
|
|
1415
1449
|
}
|
|
1416
1450
|
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
className: className,
|
|
1458
|
-
children: /*#__PURE__*/jsx(MediasBrowser, _objectSpread({
|
|
1459
|
-
items: initialItems // TODO: fix useItems if actually using this
|
|
1460
|
-
,
|
|
1451
|
+
function MediasPicker(t0) {
|
|
1452
|
+
const $ = c(16);
|
|
1453
|
+
let onChange;
|
|
1454
|
+
let props;
|
|
1455
|
+
let t1;
|
|
1456
|
+
let t2;
|
|
1457
|
+
let t3;
|
|
1458
|
+
let t4;
|
|
1459
|
+
if ($[0] !== t0) {
|
|
1460
|
+
({
|
|
1461
|
+
items: t1,
|
|
1462
|
+
value: t2,
|
|
1463
|
+
onChange,
|
|
1464
|
+
multiple: t3,
|
|
1465
|
+
className: t4,
|
|
1466
|
+
...props
|
|
1467
|
+
} = t0);
|
|
1468
|
+
$[0] = t0;
|
|
1469
|
+
$[1] = onChange;
|
|
1470
|
+
$[2] = props;
|
|
1471
|
+
$[3] = t1;
|
|
1472
|
+
$[4] = t2;
|
|
1473
|
+
$[5] = t3;
|
|
1474
|
+
$[6] = t4;
|
|
1475
|
+
} else {
|
|
1476
|
+
onChange = $[1];
|
|
1477
|
+
props = $[2];
|
|
1478
|
+
t1 = $[3];
|
|
1479
|
+
t2 = $[4];
|
|
1480
|
+
t3 = $[5];
|
|
1481
|
+
t4 = $[6];
|
|
1482
|
+
}
|
|
1483
|
+
const initialItems = t1 === undefined ? null : t1;
|
|
1484
|
+
const initialSelectedItems = t2 === undefined ? null : t2;
|
|
1485
|
+
const multiple = t3 === undefined ? false : t3;
|
|
1486
|
+
const className = t4 === undefined ? null : t4;
|
|
1487
|
+
let t5;
|
|
1488
|
+
if ($[7] !== initialItems || $[8] !== initialSelectedItems || $[9] !== multiple || $[10] !== onChange || $[11] !== props) {
|
|
1489
|
+
t5 = /*#__PURE__*/jsx(MediasBrowser, {
|
|
1490
|
+
items: initialItems,
|
|
1461
1491
|
selectable: true,
|
|
1462
1492
|
selectedItems: initialSelectedItems,
|
|
1463
1493
|
onSelectionChange: onChange,
|
|
1464
1494
|
multipleSelection: multiple,
|
|
1465
|
-
extraItems:
|
|
1466
|
-
|
|
1467
|
-
|
|
1495
|
+
extraItems: initialSelectedItems,
|
|
1496
|
+
...props
|
|
1497
|
+
});
|
|
1498
|
+
$[7] = initialItems;
|
|
1499
|
+
$[8] = initialSelectedItems;
|
|
1500
|
+
$[9] = multiple;
|
|
1501
|
+
$[10] = onChange;
|
|
1502
|
+
$[11] = props;
|
|
1503
|
+
$[12] = t5;
|
|
1504
|
+
} else {
|
|
1505
|
+
t5 = $[12];
|
|
1506
|
+
}
|
|
1507
|
+
let t6;
|
|
1508
|
+
if ($[13] !== className || $[14] !== t5) {
|
|
1509
|
+
t6 = /*#__PURE__*/jsx("div", {
|
|
1510
|
+
className: className,
|
|
1511
|
+
children: t5
|
|
1512
|
+
});
|
|
1513
|
+
$[13] = className;
|
|
1514
|
+
$[14] = t5;
|
|
1515
|
+
$[15] = t6;
|
|
1516
|
+
} else {
|
|
1517
|
+
t6 = $[15];
|
|
1518
|
+
}
|
|
1519
|
+
return t6;
|
|
1468
1520
|
}
|
|
1469
1521
|
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1522
|
+
function MediasBrowserContainer(t0) {
|
|
1523
|
+
const $ = c(12);
|
|
1524
|
+
let props;
|
|
1525
|
+
let t1;
|
|
1526
|
+
let t2;
|
|
1527
|
+
if ($[0] !== t0) {
|
|
1528
|
+
({
|
|
1529
|
+
api: t1,
|
|
1530
|
+
media: t2,
|
|
1531
|
+
...props
|
|
1532
|
+
} = t0);
|
|
1533
|
+
$[0] = t0;
|
|
1534
|
+
$[1] = props;
|
|
1535
|
+
$[2] = t1;
|
|
1536
|
+
$[3] = t2;
|
|
1537
|
+
} else {
|
|
1538
|
+
props = $[1];
|
|
1539
|
+
t1 = $[2];
|
|
1540
|
+
t2 = $[3];
|
|
1541
|
+
}
|
|
1542
|
+
const api = t1 === undefined ? null : t1;
|
|
1543
|
+
const media = t2 === undefined ? null : t2;
|
|
1544
|
+
let t3;
|
|
1545
|
+
if ($[4] !== props) {
|
|
1546
|
+
t3 = /*#__PURE__*/jsx(MediasBrowser, {
|
|
1547
|
+
...props
|
|
1548
|
+
});
|
|
1549
|
+
$[4] = props;
|
|
1550
|
+
$[5] = t3;
|
|
1551
|
+
} else {
|
|
1552
|
+
t3 = $[5];
|
|
1553
|
+
}
|
|
1554
|
+
let t4;
|
|
1555
|
+
if ($[6] !== media || $[7] !== t3) {
|
|
1556
|
+
t4 = /*#__PURE__*/jsx(MediaProvider, {
|
|
1480
1557
|
media: media,
|
|
1481
|
-
children:
|
|
1482
|
-
})
|
|
1483
|
-
|
|
1558
|
+
children: t3
|
|
1559
|
+
});
|
|
1560
|
+
$[6] = media;
|
|
1561
|
+
$[7] = t3;
|
|
1562
|
+
$[8] = t4;
|
|
1563
|
+
} else {
|
|
1564
|
+
t4 = $[8];
|
|
1565
|
+
}
|
|
1566
|
+
let t5;
|
|
1567
|
+
if ($[9] !== api || $[10] !== t4) {
|
|
1568
|
+
t5 = /*#__PURE__*/jsx(MediasApiProvider, {
|
|
1569
|
+
api: api,
|
|
1570
|
+
children: t4
|
|
1571
|
+
});
|
|
1572
|
+
$[9] = api;
|
|
1573
|
+
$[10] = t4;
|
|
1574
|
+
$[11] = t5;
|
|
1575
|
+
} else {
|
|
1576
|
+
t5 = $[11];
|
|
1577
|
+
}
|
|
1578
|
+
return t5;
|
|
1484
1579
|
}
|
|
1485
1580
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1581
|
+
function MediasPickerContainer(t0) {
|
|
1582
|
+
const $ = c(14);
|
|
1583
|
+
let props;
|
|
1584
|
+
let t1;
|
|
1585
|
+
let t2;
|
|
1586
|
+
let t3;
|
|
1587
|
+
if ($[0] !== t0) {
|
|
1588
|
+
({
|
|
1589
|
+
api: t1,
|
|
1590
|
+
media: t2,
|
|
1591
|
+
onChange: t3,
|
|
1592
|
+
...props
|
|
1593
|
+
} = t0);
|
|
1594
|
+
$[0] = t0;
|
|
1595
|
+
$[1] = props;
|
|
1596
|
+
$[2] = t1;
|
|
1597
|
+
$[3] = t2;
|
|
1598
|
+
$[4] = t3;
|
|
1599
|
+
} else {
|
|
1600
|
+
props = $[1];
|
|
1601
|
+
t1 = $[2];
|
|
1602
|
+
t2 = $[3];
|
|
1603
|
+
t3 = $[4];
|
|
1604
|
+
}
|
|
1605
|
+
const api = t1 === undefined ? null : t1;
|
|
1606
|
+
const media = t2 === undefined ? null : t2;
|
|
1607
|
+
const onChange = t3 === undefined ? null : t3;
|
|
1608
|
+
let t4;
|
|
1609
|
+
if ($[5] !== onChange || $[6] !== props) {
|
|
1610
|
+
t4 = /*#__PURE__*/jsx(MediasPicker, {
|
|
1611
|
+
...props,
|
|
1612
|
+
onChange: onChange
|
|
1613
|
+
});
|
|
1614
|
+
$[5] = onChange;
|
|
1615
|
+
$[6] = props;
|
|
1616
|
+
$[7] = t4;
|
|
1617
|
+
} else {
|
|
1618
|
+
t4 = $[7];
|
|
1619
|
+
}
|
|
1620
|
+
let t5;
|
|
1621
|
+
if ($[8] !== media || $[9] !== t4) {
|
|
1622
|
+
t5 = /*#__PURE__*/jsx(MediaProvider, {
|
|
1498
1623
|
media: media,
|
|
1499
|
-
children:
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1624
|
+
children: t4
|
|
1625
|
+
});
|
|
1626
|
+
$[8] = media;
|
|
1627
|
+
$[9] = t4;
|
|
1628
|
+
$[10] = t5;
|
|
1629
|
+
} else {
|
|
1630
|
+
t5 = $[10];
|
|
1631
|
+
}
|
|
1632
|
+
let t6;
|
|
1633
|
+
if ($[11] !== api || $[12] !== t5) {
|
|
1634
|
+
t6 = /*#__PURE__*/jsx(MediasApiProvider, {
|
|
1635
|
+
api: api,
|
|
1636
|
+
children: t5
|
|
1637
|
+
});
|
|
1638
|
+
$[11] = api;
|
|
1639
|
+
$[12] = t5;
|
|
1640
|
+
$[13] = t6;
|
|
1641
|
+
} else {
|
|
1642
|
+
t6 = $[13];
|
|
1643
|
+
}
|
|
1644
|
+
return t6;
|
|
1504
1645
|
}
|
|
1505
1646
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1647
|
+
function MediasResourceBrowser(t0) {
|
|
1648
|
+
const $ = c(9);
|
|
1649
|
+
let props;
|
|
1650
|
+
let t1;
|
|
1651
|
+
if ($[0] !== t0) {
|
|
1652
|
+
({
|
|
1653
|
+
resource: t1,
|
|
1654
|
+
...props
|
|
1655
|
+
} = t0);
|
|
1656
|
+
$[0] = t0;
|
|
1657
|
+
$[1] = props;
|
|
1658
|
+
$[2] = t1;
|
|
1659
|
+
} else {
|
|
1660
|
+
props = $[1];
|
|
1661
|
+
t1 = $[2];
|
|
1662
|
+
}
|
|
1663
|
+
const resourceId = t1 === undefined ? "medias" : t1;
|
|
1664
|
+
const resource = usePanneauResource(resourceId);
|
|
1665
|
+
const api = useApi();
|
|
1666
|
+
let t2;
|
|
1667
|
+
if ($[3] !== api || $[4] !== resource) {
|
|
1668
|
+
t2 = {
|
|
1669
|
+
get: (...t3) => {
|
|
1670
|
+
const args = t3;
|
|
1671
|
+
return api.resources.get(resource, ...args);
|
|
1521
1672
|
},
|
|
1522
|
-
getTrashed:
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
args[_key2] = arguments[_key2];
|
|
1526
|
-
}
|
|
1527
|
-
return (_api$resources2 = api.resources).getTrashed.apply(_api$resources2, [resource].concat(args));
|
|
1673
|
+
getTrashed: (...t4) => {
|
|
1674
|
+
const args_0 = t4;
|
|
1675
|
+
return api.resources.getTrashed(resource, ...args_0);
|
|
1528
1676
|
},
|
|
1529
|
-
find:
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
args[_key3] = arguments[_key3];
|
|
1533
|
-
}
|
|
1534
|
-
return (_api$resources3 = api.resources).find.apply(_api$resources3, [resource].concat(args));
|
|
1677
|
+
find: (...t5) => {
|
|
1678
|
+
const args_1 = t5;
|
|
1679
|
+
return api.resources.find(resource, ...args_1);
|
|
1535
1680
|
},
|
|
1536
|
-
create:
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
args[_key4] = arguments[_key4];
|
|
1540
|
-
}
|
|
1541
|
-
return (_api$resources4 = api.resources).create.apply(_api$resources4, [resource].concat(args));
|
|
1681
|
+
create: (...t6) => {
|
|
1682
|
+
const args_2 = t6;
|
|
1683
|
+
return api.resources.store(resource, ...args_2);
|
|
1542
1684
|
},
|
|
1543
|
-
update:
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
args[_key5] = arguments[_key5];
|
|
1547
|
-
}
|
|
1548
|
-
return (_api$resources5 = api.resources).update.apply(_api$resources5, [resource].concat(args));
|
|
1685
|
+
update: (...t7) => {
|
|
1686
|
+
const args_3 = t7;
|
|
1687
|
+
return api.resources.update(resource, ...args_3);
|
|
1549
1688
|
},
|
|
1550
|
-
trash:
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
args[_key6] = arguments[_key6];
|
|
1554
|
-
}
|
|
1555
|
-
return (_api$resources6 = api.resources).trash.apply(_api$resources6, [resource].concat(args));
|
|
1689
|
+
trash: (...t8) => {
|
|
1690
|
+
const args_4 = t8;
|
|
1691
|
+
return api.resources.trash(resource, ...args_4);
|
|
1556
1692
|
},
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
args[_key7] = arguments[_key7];
|
|
1561
|
-
}
|
|
1562
|
-
return (_api$resources7 = api.resources)["delete"].apply(_api$resources7, [resource].concat(args));
|
|
1693
|
+
delete: (...t9) => {
|
|
1694
|
+
const args_5 = t9;
|
|
1695
|
+
return api.resources.destroy(resource, ...args_5);
|
|
1563
1696
|
}
|
|
1564
1697
|
};
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
}
|
|
1698
|
+
$[3] = api;
|
|
1699
|
+
$[4] = resource;
|
|
1700
|
+
$[5] = t2;
|
|
1701
|
+
} else {
|
|
1702
|
+
t2 = $[5];
|
|
1703
|
+
}
|
|
1704
|
+
const mediasApi = t2;
|
|
1705
|
+
let t3;
|
|
1706
|
+
if ($[6] !== mediasApi || $[7] !== props) {
|
|
1707
|
+
t3 = /*#__PURE__*/jsx(MediasBrowserContainer, {
|
|
1708
|
+
api: mediasApi,
|
|
1709
|
+
...props
|
|
1710
|
+
});
|
|
1711
|
+
$[6] = mediasApi;
|
|
1712
|
+
$[7] = props;
|
|
1713
|
+
$[8] = t3;
|
|
1714
|
+
} else {
|
|
1715
|
+
t3 = $[8];
|
|
1716
|
+
}
|
|
1717
|
+
return t3;
|
|
1569
1718
|
}
|
|
1570
1719
|
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1720
|
+
function MediasResourcePicker(t0) {
|
|
1721
|
+
const $ = c(22);
|
|
1722
|
+
let props;
|
|
1723
|
+
let t1;
|
|
1724
|
+
if ($[0] !== t0) {
|
|
1725
|
+
({
|
|
1726
|
+
resource: t1,
|
|
1727
|
+
...props
|
|
1728
|
+
} = t0);
|
|
1729
|
+
$[0] = t0;
|
|
1730
|
+
$[1] = props;
|
|
1731
|
+
$[2] = t1;
|
|
1732
|
+
} else {
|
|
1733
|
+
props = $[1];
|
|
1734
|
+
t1 = $[2];
|
|
1735
|
+
}
|
|
1736
|
+
const resourceId = t1 === undefined ? "medias" : t1;
|
|
1737
|
+
const resource = usePanneauResource(resourceId);
|
|
1738
|
+
let t2;
|
|
1739
|
+
if ($[3] !== resource) {
|
|
1740
|
+
t2 = resource || {};
|
|
1741
|
+
$[3] = resource;
|
|
1742
|
+
$[4] = t2;
|
|
1743
|
+
} else {
|
|
1744
|
+
t2 = $[4];
|
|
1745
|
+
}
|
|
1746
|
+
const {
|
|
1747
|
+
index: t3,
|
|
1748
|
+
fields: t4
|
|
1749
|
+
} = t2;
|
|
1750
|
+
const index = t3 === undefined ? null : t3;
|
|
1751
|
+
const fields = t4 === undefined ? null : t4;
|
|
1752
|
+
let t5;
|
|
1753
|
+
if ($[5] !== index) {
|
|
1754
|
+
t5 = index || {};
|
|
1755
|
+
$[5] = index;
|
|
1756
|
+
$[6] = t5;
|
|
1757
|
+
} else {
|
|
1758
|
+
t5 = $[6];
|
|
1759
|
+
}
|
|
1760
|
+
const {
|
|
1761
|
+
filters: t6,
|
|
1762
|
+
columns: t7
|
|
1763
|
+
} = t5;
|
|
1764
|
+
const filters = t6 === undefined ? null : t6;
|
|
1765
|
+
const columns = t7 === undefined ? null : t7;
|
|
1766
|
+
const api = useApi();
|
|
1767
|
+
let t8;
|
|
1768
|
+
if ($[7] !== api || $[8] !== resource) {
|
|
1769
|
+
t8 = {
|
|
1770
|
+
get: (...t9) => {
|
|
1771
|
+
const args = t9;
|
|
1772
|
+
return api.resources.get(resource, ...args);
|
|
1596
1773
|
},
|
|
1597
|
-
getTrashed:
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
args[_key2] = arguments[_key2];
|
|
1601
|
-
}
|
|
1602
|
-
return (_api$resources2 = api.resources).getTrashed.apply(_api$resources2, [resource].concat(args));
|
|
1774
|
+
getTrashed: (...t10) => {
|
|
1775
|
+
const args_0 = t10;
|
|
1776
|
+
return api.resources.getTrashed(resource, ...args_0);
|
|
1603
1777
|
},
|
|
1604
|
-
find:
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
args[_key3] = arguments[_key3];
|
|
1608
|
-
}
|
|
1609
|
-
return (_api$resources3 = api.resources).find.apply(_api$resources3, [resource].concat(args));
|
|
1778
|
+
find: (...t11) => {
|
|
1779
|
+
const args_1 = t11;
|
|
1780
|
+
return api.resources.find(resource, ...args_1);
|
|
1610
1781
|
},
|
|
1611
|
-
create:
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
args[_key4] = arguments[_key4];
|
|
1615
|
-
}
|
|
1616
|
-
return (_api$resources4 = api.resources).create.apply(_api$resources4, [resource].concat(args));
|
|
1782
|
+
create: (...t12) => {
|
|
1783
|
+
const args_2 = t12;
|
|
1784
|
+
return api.resources.store(resource, ...args_2);
|
|
1617
1785
|
},
|
|
1618
|
-
update:
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
args[_key5] = arguments[_key5];
|
|
1622
|
-
}
|
|
1623
|
-
return (_api$resources5 = api.resources).update.apply(_api$resources5, [resource].concat(args));
|
|
1786
|
+
update: (...t13) => {
|
|
1787
|
+
const args_3 = t13;
|
|
1788
|
+
return api.resources.update(resource, ...args_3);
|
|
1624
1789
|
},
|
|
1625
|
-
trash:
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
args[_key6] = arguments[_key6];
|
|
1629
|
-
}
|
|
1630
|
-
return (_api$resources6 = api.resources).trash.apply(_api$resources6, [resource].concat(args));
|
|
1790
|
+
trash: (...t14) => {
|
|
1791
|
+
const args_4 = t14;
|
|
1792
|
+
return api.resources.trash(resource, ...args_4);
|
|
1631
1793
|
},
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
args[_key7] = arguments[_key7];
|
|
1636
|
-
}
|
|
1637
|
-
return (_api$resources7 = api.resources)["delete"].apply(_api$resources7, [resource].concat(args));
|
|
1794
|
+
delete: (...t15) => {
|
|
1795
|
+
const args_5 = t15;
|
|
1796
|
+
return api.resources.destroy(resource, ...args_5);
|
|
1638
1797
|
}
|
|
1639
1798
|
};
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1799
|
+
$[7] = api;
|
|
1800
|
+
$[8] = resource;
|
|
1801
|
+
$[9] = t8;
|
|
1802
|
+
} else {
|
|
1803
|
+
t8 = $[9];
|
|
1804
|
+
}
|
|
1805
|
+
const mediasApi = t8;
|
|
1806
|
+
let t9;
|
|
1807
|
+
if ($[10] !== filters) {
|
|
1808
|
+
t9 = filters !== null ? {
|
|
1809
|
+
filters
|
|
1810
|
+
} : null;
|
|
1811
|
+
$[10] = filters;
|
|
1812
|
+
$[11] = t9;
|
|
1813
|
+
} else {
|
|
1814
|
+
t9 = $[11];
|
|
1815
|
+
}
|
|
1816
|
+
let t10;
|
|
1817
|
+
if ($[12] !== fields) {
|
|
1818
|
+
t10 = fields !== null ? {
|
|
1819
|
+
fields
|
|
1820
|
+
} : null;
|
|
1821
|
+
$[12] = fields;
|
|
1822
|
+
$[13] = t10;
|
|
1823
|
+
} else {
|
|
1824
|
+
t10 = $[13];
|
|
1825
|
+
}
|
|
1826
|
+
let t11;
|
|
1827
|
+
if ($[14] !== columns) {
|
|
1828
|
+
t11 = columns !== null ? {
|
|
1829
|
+
columns
|
|
1830
|
+
} : null;
|
|
1831
|
+
$[14] = columns;
|
|
1832
|
+
$[15] = t11;
|
|
1833
|
+
} else {
|
|
1834
|
+
t11 = $[15];
|
|
1835
|
+
}
|
|
1836
|
+
let t12;
|
|
1837
|
+
if ($[16] !== mediasApi || $[17] !== props || $[18] !== t10 || $[19] !== t11 || $[20] !== t9) {
|
|
1838
|
+
t12 = /*#__PURE__*/jsx(MediasPickerContainer, {
|
|
1839
|
+
api: mediasApi,
|
|
1840
|
+
...t9,
|
|
1841
|
+
...t10,
|
|
1842
|
+
...t11,
|
|
1843
|
+
...props
|
|
1844
|
+
});
|
|
1845
|
+
$[16] = mediasApi;
|
|
1846
|
+
$[17] = props;
|
|
1847
|
+
$[18] = t10;
|
|
1848
|
+
$[19] = t11;
|
|
1849
|
+
$[20] = t9;
|
|
1850
|
+
$[21] = t12;
|
|
1851
|
+
} else {
|
|
1852
|
+
t12 = $[21];
|
|
1853
|
+
}
|
|
1854
|
+
return t12;
|
|
1650
1855
|
}
|
|
1651
1856
|
|
|
1652
1857
|
export { MediaForm, MediaProvider, MediasApiProvider, MediasBrowser, MediasBrowserContainer, MediasPicker, MediasPickerContainer, MediasResourceBrowser, MediasResourcePicker, defaultColumns as columns, defaultFields as fields, defaultFilters as filters, useCurrentMedia, useMedia, useMediaCreate, useMediaDelete, useMediaReplace, useMediaRestore, useMediaTrash, useMediaUpdate, useMedias, useMediasApi };
|