@panneau/media 5.0.0-alpha.33 → 5.0.0-alpha.34

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.
@@ -1,75 +1,16 @@
1
1
  import MediaPicker_module_default from "./MediaPicker.module.js";
2
- import { describeAccept, isProcessingMedia } from "./format.js";
3
- import { MediaGrid } from "./MediaGrid.js";
4
- import { MediaDetails } from "./MediaDetails.js";
5
- import { PickerToolbar } from "./PickerToolbar.js";
6
- import { UploadPanel } from "./UploadPanel.js";
7
- import { useMediaBrowser } from "./useMediaBrowser.js";
2
+ import { toReference, useMediaLibrary } from "./useMediaLibrary.js";
8
3
  import { c } from "react/compiler-runtime";
9
- import { Images, Lock, SearchX } from "lucide-react";
10
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
11
- import { formatSize, useFieldsContext, useRejectionMessage, useUploads } from "@panneau/fields";
12
4
  import { mediaMessages } from "@panneau/intl";
13
- import { Alert, Button, Dialog, Heading, LoadingRegion, SegmentedControl, Select, Skeleton, Spinner, Tab, TabList, TabPanel, Tabs, Text, usePanneauIntl } from "@panneau/ui";
5
+ import { Button, Dialog, Text, usePanneauIntl } from "@panneau/ui";
14
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
7
  //#region src/picker/MediaPicker.tsx
16
- var NO_FILTER = {};
17
- var keyOf = (source, id) => `${source}\n${id}`;
18
- /** The smallest of two limits, either of which may be missing. */
19
- function smallest(a, b) {
20
- const limits = [a, b].filter((limit) => typeof limit === "number");
21
- return limits.length > 0 ? Math.min(...limits) : null;
22
- }
23
- function isDefaultQuery(query) {
24
- return query.q === "" && query.type === null && Object.keys(query.filter).length === 0;
25
- }
26
- /** The reference a picker returns for a media of a source. */
27
- function toReference({ source, item }) {
28
- return {
29
- id: item.id,
30
- resource: source,
31
- label: item.label,
32
- media: item.media
33
- };
34
- }
35
- /** The cards of a library that loads: a thumbnail, a name and a line of details. */
36
- function Skeletons() {
37
- const $ = c(1);
38
- let t0;
39
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
40
- t0 = /* @__PURE__ */ jsx("div", {
41
- className: MediaPicker_module_default.grid,
42
- children: Array.from({ length: 12 }, _temp)
43
- });
44
- $[0] = t0;
45
- } else t0 = $[0];
46
- return t0;
47
- }
48
8
  /**
49
9
  * The media picker (decision 0027): browse the libraries given as sources, upload to them, and
50
10
  * pick one media, or several with `multiple`. It returns references with their library
51
11
  * (`resource`). The `media` field opens it, and so can a product's own screens, with their
52
- * sources, title and button.
12
+ * sources, title and button. Its library is `MediaLibrary`'s, in a dialog.
53
13
  */
54
- function _temp(_, index) {
55
- return /* @__PURE__ */ jsxs("div", {
56
- className: MediaPicker_module_default.skeletonCard,
57
- children: [
58
- /* @__PURE__ */ jsx(Skeleton, {
59
- shape: "rect",
60
- aspectRatio: 1
61
- }),
62
- /* @__PURE__ */ jsx(Skeleton, {
63
- className: MediaPicker_module_default.cardName,
64
- width: "80%"
65
- }),
66
- /* @__PURE__ */ jsx(Skeleton, {
67
- className: MediaPicker_module_default.cardMeta,
68
- width: "50%"
69
- })
70
- ]
71
- }, index);
72
- }
73
14
  function MediaPicker(props) {
74
15
  const $ = c(2);
75
16
  if (!props.isOpen) return null;
@@ -82,1035 +23,222 @@ function MediaPicker(props) {
82
23
  return t0;
83
24
  }
84
25
  function OpenMediaPicker(t0) {
85
- const $ = c(180);
86
- const { onOpenChange, sources, source: initialSource, multiple: t1, accept: t2, maxSize: t3, filter: t4, filters: t5, sorts: t6, sort: openerSort, value: t7, title, confirmLabel, confirmOnUpload: t8, stateKey, uploadSource, refreshInterval: t9, onSelect } = t0;
87
- const multiple = t1 === void 0 ? false : t1;
88
- const accept = t2 === void 0 ? null : t2;
89
- const maxSize = t3 === void 0 ? null : t3;
90
- const locked = t4 === void 0 ? NO_FILTER : t4;
91
- const openerFilters = t5 === void 0 ? [] : t5;
92
- let t10;
93
- if ($[0] !== t6) {
94
- t10 = t6 === void 0 ? [] : t6;
95
- $[0] = t6;
96
- $[1] = t10;
97
- } else t10 = $[1];
98
- const openerSorts = t10;
99
- const value = t7 === void 0 ? [] : t7;
100
- const confirmOnUpload = t8 === void 0 ? false : t8;
101
- const refreshInterval = t9 === void 0 ? 3e3 : t9;
26
+ const $ = c(59);
27
+ let confirmLabel;
28
+ let onOpenChange;
29
+ let onSelect;
30
+ let options;
31
+ let t1;
32
+ let title;
33
+ if ($[0] !== t0) {
34
+ const { onOpenChange: t2, title: t3, confirmLabel: t4, confirmOnUpload: t5, onSelect: t6, isOpen: _isOpen, ...t7 } = t0;
35
+ onOpenChange = t2;
36
+ title = t3;
37
+ confirmLabel = t4;
38
+ t1 = t5;
39
+ onSelect = t6;
40
+ options = t7;
41
+ $[0] = t0;
42
+ $[1] = confirmLabel;
43
+ $[2] = onOpenChange;
44
+ $[3] = onSelect;
45
+ $[4] = options;
46
+ $[5] = t1;
47
+ $[6] = title;
48
+ } else {
49
+ confirmLabel = $[1];
50
+ onOpenChange = $[2];
51
+ onSelect = $[3];
52
+ options = $[4];
53
+ t1 = $[5];
54
+ title = $[6];
55
+ }
56
+ const confirmOnUpload = t1 === void 0 ? false : t1;
102
57
  const intl = usePanneauIntl();
103
- const context = useFieldsContext();
104
- const [sourceId, setSourceId] = useState(initialSource ?? sources[0]?.id ?? "");
105
- const source = sources.find((candidate) => candidate.id === sourceId) ?? sources[0] ?? null;
106
- const [tab, setTab] = useState("library");
107
- let t11;
108
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
109
- t11 = /* @__PURE__ */ new Map();
110
- $[2] = t11;
111
- } else t11 = $[2];
112
- const [selection, setSelection] = useState(t11);
113
- const [focused, setFocused] = useState(null);
114
- const [pendingFocus, setPendingFocus] = useState(null);
115
- const [detailsOpen, setDetailsOpen] = useState(false);
116
- const [draft, setDraft] = useState(null);
117
- const [saving, setSaving] = useState(false);
118
- const [saveError, setSaveError] = useState(null);
119
- let t12;
120
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
121
- t12 = /* @__PURE__ */ new Map();
122
- $[3] = t12;
123
- } else t12 = $[3];
124
- const [uploaded, setUploaded] = useState(t12);
125
- let t13;
126
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
127
- t13 = [];
128
- $[4] = t13;
129
- } else t13 = $[4];
130
- const [problems, setProblems] = useState(t13);
131
- let t14;
132
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
133
- t14 = [];
134
- $[5] = t14;
135
- } else t14 = $[5];
136
- const [creating, setCreating] = useState(t14);
137
- let t15;
138
- if ($[6] !== openerSorts) {
139
- t15 = (candidate_0) => [...candidate_0.sorts ?? [], ...openerSorts.filter((sort) => !(candidate_0.sorts ?? []).some((own) => own.id === sort.id))];
140
- $[6] = openerSorts;
141
- $[7] = t15;
142
- } else t15 = $[7];
143
- const sortsOf = t15;
144
- let t16;
145
- if ($[8] !== openerSort || $[9] !== sortsOf) {
146
- t16 = (candidate_1) => openerSort ?? sortsOf(candidate_1)[0]?.id ?? null;
147
- $[8] = openerSort;
148
- $[9] = sortsOf;
149
- $[10] = t16;
150
- } else t16 = $[10];
151
- const browser = useMediaBrowser({
152
- sources,
153
- source,
154
- locked,
155
- defaultSort: t16,
156
- stateKey
157
- });
158
- const { state } = browser;
159
- let t17;
160
- if ($[11] !== sources[0]?.id) {
161
- t17 = (reference) => keyOf(reference.resource ?? sources[0]?.id ?? "", reference.id);
162
- $[11] = sources[0]?.id;
163
- $[12] = t17;
164
- } else t17 = $[12];
165
- const current = new Set(value.map(t17));
166
- const picked = [...selection.values()];
167
- const unchanged = !multiple && picked.length === 1 && value.length === 1 && current.has(keyOf(picked[0]?.source ?? "", picked[0]?.item.id ?? ""));
168
- const pickedSources = new Set(picked.map(_temp2));
169
- const known = /* @__PURE__ */ new Map();
170
- for (const [id, items] of uploaded) items.forEach((item) => known.set(keyOf(id, item.id), {
171
- source: id,
172
- item
173
- }));
174
- if (source !== null) state.items.forEach((item_0) => known.set(keyOf(source.id, item_0.id), {
175
- source: source.id,
176
- item: item_0
177
- }));
178
- for (const [key, entry_0] of selection) known.set(key, entry_0);
179
- const focusedEntry = focused !== null ? known.get(focused) ?? null : null;
180
- const focusedSource = sources.find((candidate_2) => candidate_2.id === focusedEntry?.source);
181
- const fields = focusedSource?.update !== void 0 ? focusedSource.fields ?? [] : [];
182
- const draftValues = draft !== null && draft.key === focused ? draft.values : focusedEntry?.item.values ?? {};
183
- const dirty = draft !== null && draft.key === focused;
184
- let t18;
185
- if ($[13] !== browser) {
186
- t18 = (sourceKey, item_1) => {
187
- const key_0 = keyOf(sourceKey, item_1.id);
188
- browser.upsert(sourceKey, [item_1]);
189
- setSelection((currentSelection) => currentSelection.has(key_0) ? new Map(currentSelection).set(key_0, {
190
- source: sourceKey,
191
- item: item_1
192
- }) : currentSelection);
193
- setUploaded((currentUploaded) => {
194
- const items_0 = currentUploaded.get(sourceKey);
195
- return items_0?.some((entry_2) => entry_2.id === item_1.id) === true ? new Map(currentUploaded).set(sourceKey, items_0.map((entry_1) => entry_1.id === item_1.id ? item_1 : entry_1)) : currentUploaded;
196
- });
197
- };
198
- $[13] = browser;
199
- $[14] = t18;
200
- } else t18 = $[14];
201
- const replace = t18;
202
- let t19;
203
- if ($[15] !== dirty || $[16] !== focused || $[17] !== setFocused || $[18] !== setPendingFocus) {
204
- t19 = (key_1) => {
205
- if (dirty && key_1 !== focused) {
206
- setPendingFocus(key_1);
207
- return;
208
- }
209
- setFocused(key_1);
210
- setSaveError(null);
211
- };
212
- $[15] = dirty;
213
- $[16] = focused;
214
- $[17] = setFocused;
215
- $[18] = setPendingFocus;
216
- $[19] = t19;
217
- } else t19 = $[19];
218
- const focus = t19;
219
- const save = async () => {
220
- if (focusedEntry === null || focusedSource?.update === void 0 || draft === null) return true;
221
- setSaving(true);
222
- setSaveError(null);
223
- let saved = true;
224
- try {
225
- const item_2 = await focusedSource.update(focusedEntry.item.id, draft.values);
226
- replace(focusedEntry.source, item_2);
227
- setDraft(null);
228
- } catch (t20) {
229
- const error = t20;
230
- setSaveError(intl.formatMessage(mediaMessages.pickerSaveFailed, { error: error instanceof Error ? error.message : String(error) }));
231
- saved = false;
232
- }
233
- setSaving(false);
234
- return saved;
235
- };
236
- let t21;
237
- if ($[20] !== onOpenChange || $[21] !== onSelect) {
238
- t21 = (entries) => {
58
+ const multiple = options.multiple ?? false;
59
+ let t2;
60
+ if ($[7] !== onOpenChange || $[8] !== onSelect) {
61
+ t2 = (entries) => {
239
62
  onSelect(entries.map(toReference));
240
63
  onOpenChange(false);
241
64
  };
242
- $[20] = onOpenChange;
243
- $[21] = onSelect;
244
- $[22] = t21;
245
- } else t21 = $[22];
246
- const confirm = t21;
247
- let t22;
248
- if ($[23] !== focus || $[24] !== multiple) {
249
- t22 = (sourceKey_0, items_1, ids, added) => {
250
- const shown = new Set(items_1.map(_temp3));
251
- const isShown = (entry_3) => entry_3.source === sourceKey_0 && shown.has(entry_3.item.id);
252
- setSelection((currentSelection_0) => {
253
- if (!multiple) {
254
- const item_4 = items_1.find((entry_4) => ids.has(entry_4.id));
255
- if (item_4 !== void 0) return /* @__PURE__ */ new Map([[keyOf(sourceKey_0, item_4.id), {
256
- source: sourceKey_0,
257
- item: item_4
258
- }]]);
259
- return [...currentSelection_0.values()].some(isShown) ? /* @__PURE__ */ new Map() : currentSelection_0;
260
- }
261
- const next = new Map([...currentSelection_0].filter((t23) => {
262
- const [, entry_5] = t23;
263
- return !isShown(entry_5) || ids.has(entry_5.item.id);
264
- }));
265
- for (const item_5 of items_1) if (ids.has(item_5.id)) next.set(keyOf(sourceKey_0, item_5.id), {
266
- source: sourceKey_0,
267
- item: item_5
268
- });
269
- return next;
270
- });
271
- if (added !== null) focus(keyOf(sourceKey_0, added));
272
- };
273
- $[23] = focus;
274
- $[24] = multiple;
275
- $[25] = t22;
276
- } else t22 = $[25];
277
- const select = t22;
278
- const following = [...known.values()].filter(_temp4);
279
- const followKey = following.map(_temp5).join(",");
280
- const latestFollowing = useRef(following);
281
- const latestReplace = useRef(replace);
282
- useEffect(() => {
283
- latestFollowing.current = following;
284
- latestReplace.current = replace;
285
- });
286
- let t23;
287
- if ($[26] !== followKey || $[27] !== refreshInterval || $[28] !== sources) {
288
- t23 = [
289
- followKey,
290
- refreshInterval,
291
- sources
292
- ];
293
- $[26] = followKey;
294
- $[27] = refreshInterval;
295
- $[28] = sources;
296
- $[29] = t23;
297
- } else t23 = $[29];
298
- useEffect(() => {
299
- if (followKey === "") return;
300
- const controller = new AbortController();
301
- const timer = setTimeout(() => {
302
- for (const entry_6 of latestFollowing.current) sources.find((candidate_3) => candidate_3.id === entry_6.source)?.get(entry_6.item.id, { signal: controller.signal }).then((item_8) => latestReplace.current(entry_6.source, item_8)).catch(_temp6);
303
- }, refreshInterval);
304
- return () => {
305
- clearTimeout(timer);
306
- controller.abort();
307
- };
308
- }, t23);
309
- const uploadAccept = accept ?? source?.accept ?? null;
310
- const uploadMaxSize = smallest(maxSize, source?.maxSize);
311
- const rejectionMessage = useRejectionMessage(uploadMaxSize);
312
- let t24;
313
- if ($[30] !== rejectionMessage) {
314
- t24 = (file_0, reason) => setProblems((currentProblems_0) => [...currentProblems_0, rejectionMessage(file_0, reason)]);
315
- $[30] = rejectionMessage;
316
- $[31] = t24;
317
- } else t24 = $[31];
318
- const upload = useUploads({
319
- source: uploadSource === void 0 ? context.uploadSource : uploadSource,
320
- accept: uploadAccept,
321
- maxSize: uploadMaxSize,
322
- onUploaded: (file) => {
323
- if (source === null) return;
324
- const target = source;
325
- const name = file.name;
326
- setCreating((currentCreating) => [...currentCreating, name]);
327
- target.create(file).then((item_9) => {
328
- const entry_7 = {
329
- source: target.id,
330
- item: item_9
331
- };
332
- setUploaded((currentUploaded_0) => new Map(currentUploaded_0).set(target.id, [item_9, ...currentUploaded_0.get(target.id) ?? []]));
333
- browser.upsert(target.id, [item_9]);
334
- if (!multiple && confirmOnUpload) {
335
- confirm([entry_7]);
336
- return;
337
- }
338
- setSelection((currentSelection_1) => multiple ? new Map(currentSelection_1).set(keyOf(target.id, item_9.id), entry_7) : /* @__PURE__ */ new Map([[keyOf(target.id, item_9.id), entry_7]]));
339
- focus(keyOf(target.id, item_9.id));
340
- }).catch((error_0) => setProblems((currentProblems) => [...currentProblems, intl.formatMessage(mediaMessages.pickerCreateFailed, {
341
- name,
342
- error: error_0 instanceof Error ? error_0.message : String(error_0)
343
- })])).finally(() => setCreating((currentCreating_0) => {
344
- const at = currentCreating_0.indexOf(name);
345
- return at === -1 ? currentCreating_0 : currentCreating_0.filter((_, index) => index !== at);
346
- }));
347
- },
348
- onRejected: t24
349
- });
350
- const scroller = useRef(null);
351
- const sentinel = useRef(null);
352
- const latestLoadMore = useRef(browser.loadMore);
353
- let t25;
354
- if ($[32] !== browser.loadMore) {
355
- t25 = () => {
356
- latestLoadMore.current = browser.loadMore;
357
- };
358
- $[32] = browser.loadMore;
359
- $[33] = t25;
360
- } else t25 = $[33];
361
- useEffect(t25);
362
- const hasMore = state.nextCursor !== null;
363
- const browsing = state.items.length > 0;
364
- let t26;
365
- if ($[34] !== hasMore) {
366
- t26 = () => {
367
- const target_0 = sentinel.current;
368
- if (target_0 === null || !hasMore || typeof IntersectionObserver === "undefined") return;
369
- const observer = new IntersectionObserver((entries_0) => {
370
- if (entries_0.some(_temp7)) latestLoadMore.current();
371
- }, {
372
- root: scroller.current,
373
- rootMargin: "200px"
374
- });
375
- observer.observe(target_0);
376
- return () => observer.disconnect();
377
- };
378
- $[34] = hasMore;
379
- $[35] = t26;
380
- } else t26 = $[35];
381
- let t27;
382
- if ($[36] !== browsing || $[37] !== hasMore || $[38] !== sourceId || $[39] !== tab) {
383
- t27 = [
384
- hasMore,
385
- browsing,
386
- sourceId,
387
- tab
388
- ];
389
- $[36] = browsing;
390
- $[37] = hasMore;
391
- $[38] = sourceId;
392
- $[39] = tab;
393
- $[40] = t27;
394
- } else t27 = $[40];
395
- useEffect(t26, t27);
396
- const restoreScroll = useRef(browser.scrollTop);
397
- let t28;
398
- if ($[41] !== browser.scrollTop) {
399
- t28 = () => {
400
- restoreScroll.current = browser.scrollTop;
65
+ $[7] = onOpenChange;
66
+ $[8] = onSelect;
67
+ $[9] = t2;
68
+ } else t2 = $[9];
69
+ const confirm = t2;
70
+ let t3;
71
+ if ($[10] !== confirm || $[11] !== confirmOnUpload || $[12] !== multiple) {
72
+ t3 = (entry) => {
73
+ if (!multiple && confirmOnUpload) {
74
+ confirm([entry]);
75
+ return true;
76
+ }
77
+ return false;
401
78
  };
402
- $[41] = browser.scrollTop;
403
- $[42] = t28;
404
- } else t28 = $[42];
405
- useEffect(t28);
406
- let t29;
407
- if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
408
- t29 = () => {
409
- if (scroller.current !== null) scroller.current.scrollTop = restoreScroll.current();
79
+ $[10] = confirm;
80
+ $[11] = confirmOnUpload;
81
+ $[12] = multiple;
82
+ $[13] = t3;
83
+ } else t3 = $[13];
84
+ let t4;
85
+ if ($[14] !== confirmOnUpload || $[15] !== options || $[16] !== t3) {
86
+ t4 = {
87
+ ...options,
88
+ selectable: true,
89
+ scroll: "self",
90
+ confirmOnUpload,
91
+ onCreated: t3
410
92
  };
411
- $[43] = t29;
412
- } else t29 = $[43];
413
- let t30;
414
- if ($[44] !== browsing || $[45] !== sourceId || $[46] !== tab) {
415
- t30 = [
416
- sourceId,
417
- tab,
418
- browsing
419
- ];
420
- $[44] = browsing;
421
- $[45] = sourceId;
422
- $[46] = tab;
423
- $[47] = t30;
424
- } else t30 = $[47];
425
- useLayoutEffect(t29, t30);
426
- if (source === null) return null;
427
- const library = source.label;
428
- const filters = [...source.filters ?? [], ...openerFilters];
429
- const label = typeof confirmLabel === "function" ? confirmLabel(picked.length) : confirmLabel ?? intl.formatMessage(mediaMessages.pickerSelect);
430
- const selectedIn = (sourceKey_1) => new Set(picked.filter((entry_9) => entry_9.source === sourceKey_1).map(_temp8));
431
- let t31;
432
- if ($[48] !== sources[0]?.id || $[49] !== value) {
433
- t31 = (sourceKey_2) => new Set(value.filter((reference_0) => (reference_0.resource ?? sources[0]?.id) === sourceKey_2).map(_temp9));
434
- $[48] = sources[0]?.id;
435
- $[49] = value;
436
- $[50] = t31;
437
- } else t31 = $[50];
438
- const currentIn = t31;
439
- const grid = (items_2, gridLabel) => /* @__PURE__ */ jsx(MediaGrid, {
440
- items: items_2,
441
- label: gridLabel,
442
- multiple,
443
- selected: selectedIn(source.id),
444
- current: currentIn(source.id),
445
- onSelectionChange: (ids_0, added_0) => select(source.id, items_2, ids_0, added_0),
446
- onDetails: (id_1) => {
447
- focus(keyOf(source.id, id_1));
448
- setDetailsOpen(true);
449
- },
450
- accept,
451
- maxSize
452
- });
453
- let libraryContent;
454
- if (state.items.length === 0 && (state.status === "idle" || state.status === "loading")) {
455
- let t32;
456
- if ($[51] !== intl) {
457
- t32 = intl.formatMessage(mediaMessages.pickerLoading);
458
- $[51] = intl;
459
- $[52] = t32;
460
- } else t32 = $[52];
461
- let t33;
462
- if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
463
- t33 = /* @__PURE__ */ jsx(Skeletons, {});
464
- $[53] = t33;
465
- } else t33 = $[53];
466
- let t34;
467
- if ($[54] !== t32) {
468
- t34 = /* @__PURE__ */ jsx(LoadingRegion, {
469
- className: MediaPicker_module_default.scroll,
470
- label: t32,
471
- children: t33
472
- });
473
- $[54] = t32;
474
- $[55] = t34;
475
- } else t34 = $[55];
476
- libraryContent = t34;
477
- } else if (state.items.length === 0 && state.status === "error") {
478
- let t32;
479
- if ($[56] !== intl) {
480
- t32 = intl.formatMessage(mediaMessages.pickerLoadError);
481
- $[56] = intl;
482
- $[57] = t32;
483
- } else t32 = $[57];
484
- const t33 = browser.retry;
485
- let t34;
486
- if ($[58] !== intl) {
487
- t34 = intl.formatMessage(mediaMessages.pickerRetry);
488
- $[58] = intl;
489
- $[59] = t34;
490
- } else t34 = $[59];
491
- let t35;
492
- if ($[60] !== browser.retry || $[61] !== t34) {
493
- t35 = /* @__PURE__ */ jsx(Button, {
494
- size: "sm",
495
- onPress: t33,
496
- children: t34
497
- });
498
- $[60] = browser.retry;
499
- $[61] = t34;
500
- $[62] = t35;
501
- } else t35 = $[62];
502
- let t36;
503
- if ($[63] !== t32 || $[64] !== t35) {
504
- t36 = /* @__PURE__ */ jsx("div", {
505
- className: MediaPicker_module_default.center,
506
- children: /* @__PURE__ */ jsx(Alert, {
507
- tone: "danger",
508
- role: "alert",
509
- title: t32,
510
- actions: t35
511
- })
512
- });
513
- $[63] = t32;
514
- $[64] = t35;
515
- $[65] = t36;
516
- } else t36 = $[65];
517
- libraryContent = t36;
518
- } else if (state.items.length === 0 && isDefaultQuery(state.query)) {
519
- let t32;
520
- if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
521
- t32 = /* @__PURE__ */ jsx(Images, {
522
- "aria-hidden": true,
523
- size: 48,
524
- strokeWidth: 1.25,
525
- className: MediaPicker_module_default.emptyIcon
526
- });
527
- $[66] = t32;
528
- } else t32 = $[66];
529
- libraryContent = /* @__PURE__ */ jsxs("div", {
530
- className: MediaPicker_module_default.empty,
531
- children: [
532
- t32,
533
- /* @__PURE__ */ jsx(Heading, {
534
- level: 3,
535
- size: 4,
536
- children: intl.formatMessage(mediaMessages.pickerEmpty, { library })
537
- }),
538
- source.canCreate ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
539
- muted: true,
540
- size: "sm",
541
- children: intl.formatMessage(mediaMessages.pickerEmptyUpload, { library })
542
- }), /* @__PURE__ */ jsx(Button, {
543
- variant: "primary",
544
- onPress: () => setTab("upload"),
545
- children: intl.formatMessage(mediaMessages.pickerUploadFiles)
546
- })] }) : /* @__PURE__ */ jsx(Text, {
547
- muted: true,
548
- size: "sm",
549
- children: intl.formatMessage(mediaMessages.pickerEmptyReadOnly)
550
- })
551
- ]
552
- });
553
- } else if (state.items.length === 0) {
554
- let t32;
555
- if ($[67] === Symbol.for("react.memo_cache_sentinel")) {
556
- t32 = /* @__PURE__ */ jsx(SearchX, {
557
- "aria-hidden": true,
558
- size: 48,
559
- strokeWidth: 1.25,
560
- className: MediaPicker_module_default.emptyIcon
561
- });
562
- $[67] = t32;
563
- } else t32 = $[67];
564
- let t33;
565
- if ($[68] !== intl) {
566
- t33 = intl.formatMessage(mediaMessages.pickerNoResults);
567
- $[68] = intl;
568
- $[69] = t33;
569
- } else t33 = $[69];
570
- let t34;
571
- if ($[70] !== t33) {
572
- t34 = /* @__PURE__ */ jsx(Heading, {
573
- level: 3,
574
- size: 4,
575
- children: t33
576
- });
577
- $[70] = t33;
578
- $[71] = t34;
579
- } else t34 = $[71];
580
- let t35;
581
- if ($[72] !== browser || $[73] !== state.query) {
582
- t35 = () => browser.setQuery({
583
- ...state.query,
584
- q: "",
585
- type: null,
586
- filter: {}
587
- });
588
- $[72] = browser;
589
- $[73] = state.query;
590
- $[74] = t35;
591
- } else t35 = $[74];
592
- let t36;
593
- if ($[75] !== intl) {
594
- t36 = intl.formatMessage(mediaMessages.pickerClearSearch);
595
- $[75] = intl;
596
- $[76] = t36;
597
- } else t36 = $[76];
598
- let t37;
599
- if ($[77] !== t35 || $[78] !== t36) {
600
- t37 = /* @__PURE__ */ jsx(Button, {
601
- onPress: t35,
602
- children: t36
603
- });
604
- $[77] = t35;
605
- $[78] = t36;
606
- $[79] = t37;
607
- } else t37 = $[79];
608
- let t38;
609
- if ($[80] !== t34 || $[81] !== t37) {
610
- t38 = /* @__PURE__ */ jsxs("div", {
611
- className: MediaPicker_module_default.empty,
612
- children: [
613
- t32,
614
- t34,
615
- t37
616
- ]
617
- });
618
- $[80] = t34;
619
- $[81] = t37;
620
- $[82] = t38;
621
- } else t38 = $[82];
622
- libraryContent = t38;
623
- } else {
624
- let t32;
625
- if ($[83] !== browser) {
626
- t32 = (event) => browser.rememberScroll(event.currentTarget.scrollTop);
627
- $[83] = browser;
628
- $[84] = t32;
629
- } else t32 = $[84];
630
- let t33;
631
- if ($[85] !== intl || $[86] !== state.items.length || $[87] !== state.total) {
632
- t33 = state.total !== null ? /* @__PURE__ */ jsx(Text, {
93
+ $[14] = confirmOnUpload;
94
+ $[15] = options;
95
+ $[16] = t3;
96
+ $[17] = t4;
97
+ } else t4 = $[17];
98
+ const library = useMediaLibrary(t4);
99
+ if (library.source === null) return null;
100
+ let t5;
101
+ if ($[18] !== confirmLabel || $[19] !== intl || $[20] !== library.picked.length) {
102
+ t5 = typeof confirmLabel === "function" ? confirmLabel(library.picked.length) : confirmLabel ?? intl.formatMessage(mediaMessages.pickerSelect);
103
+ $[18] = confirmLabel;
104
+ $[19] = intl;
105
+ $[20] = library.picked.length;
106
+ $[21] = t5;
107
+ } else t5 = $[21];
108
+ const label = t5;
109
+ let t6;
110
+ if ($[22] !== intl || $[23] !== title) {
111
+ t6 = title ?? intl.formatMessage(mediaMessages.pickerTitle);
112
+ $[22] = intl;
113
+ $[23] = title;
114
+ $[24] = t6;
115
+ } else t6 = $[24];
116
+ const t7 = library.switcher;
117
+ let t8;
118
+ if ($[25] !== intl || $[26] !== library.clear || $[27] !== library.picked[0]?.item || $[28] !== library.picked.length || $[29] !== library.pickedSources || $[30] !== multiple) {
119
+ t8 = /* @__PURE__ */ jsx("div", {
120
+ className: MediaPicker_module_default.summary,
121
+ "aria-live": "polite",
122
+ children: library.picked.length === 0 ? /* @__PURE__ */ jsx(Text, {
633
123
  muted: true,
634
124
  size: "sm",
635
125
  as: "span",
636
- children: intl.formatMessage(mediaMessages.pickerCount, {
637
- shown: state.items.length,
638
- total: state.total
639
- })
640
- }) : null;
641
- $[85] = intl;
642
- $[86] = state.items.length;
643
- $[87] = state.total;
644
- $[88] = t33;
645
- } else t33 = $[88];
646
- let t34;
647
- if ($[89] !== intl || $[90] !== state.status) {
648
- t34 = state.status === "more" ? /* @__PURE__ */ jsx(Spinner, {
649
- size: "sm",
650
- label: intl.formatMessage(mediaMessages.pickerLoadingMore)
651
- }) : null;
652
- $[89] = intl;
653
- $[90] = state.status;
654
- $[91] = t34;
655
- } else t34 = $[91];
656
- let t35;
657
- if ($[92] !== browser.loadMore || $[93] !== browser.retry || $[94] !== hasMore || $[95] !== intl || $[96] !== state.status) {
658
- t35 = state.status === "error" ? /* @__PURE__ */ jsx(Button, {
126
+ children: intl.formatMessage(mediaMessages.pickerNothingSelected)
127
+ }) : multiple ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
659
128
  size: "sm",
660
- onPress: browser.retry,
661
- children: intl.formatMessage(mediaMessages.pickerRetry)
662
- }) : hasMore && state.status === "ready" ? /* @__PURE__ */ jsx(Button, {
129
+ weight: "medium",
130
+ as: "span",
131
+ children: library.pickedSources > 1 ? intl.formatMessage(mediaMessages.pickerSelectedIn, {
132
+ count: library.picked.length,
133
+ libraries: library.pickedSources
134
+ }) : intl.formatMessage(mediaMessages.pickerSelectedCount, { count: library.picked.length })
135
+ }), /* @__PURE__ */ jsx(Button, {
663
136
  size: "sm",
664
137
  variant: "ghost",
665
- onPress: browser.loadMore,
666
- children: intl.formatMessage(mediaMessages.pickerLoadMore)
667
- }) : null;
668
- $[92] = browser.loadMore;
669
- $[93] = browser.retry;
670
- $[94] = hasMore;
671
- $[95] = intl;
672
- $[96] = state.status;
673
- $[97] = t35;
674
- } else t35 = $[97];
675
- let t36;
676
- if ($[98] === Symbol.for("react.memo_cache_sentinel")) {
677
- t36 = /* @__PURE__ */ jsx("div", {
678
- ref: sentinel,
679
- className: MediaPicker_module_default.sentinel
680
- });
681
- $[98] = t36;
682
- } else t36 = $[98];
683
- let t37;
684
- if ($[99] !== t33 || $[100] !== t34 || $[101] !== t35) {
685
- t37 = /* @__PURE__ */ jsxs("div", {
686
- className: MediaPicker_module_default.more,
687
- children: [
688
- t33,
689
- t34,
690
- t35,
691
- t36
692
- ]
693
- });
694
- $[99] = t33;
695
- $[100] = t34;
696
- $[101] = t35;
697
- $[102] = t37;
698
- } else t37 = $[102];
699
- let t38;
700
- if ($[103] !== focused || $[104] !== setDraft) {
701
- t38 = (values) => focused !== null ? setDraft({
702
- key: focused,
703
- values
704
- }) : void 0;
705
- $[103] = focused;
706
- $[104] = setDraft;
707
- $[105] = t38;
708
- } else t38 = $[105];
709
- let t39;
710
- if ($[106] === Symbol.for("react.memo_cache_sentinel")) {
711
- t39 = () => setDetailsOpen(false);
712
- $[106] = t39;
713
- } else t39 = $[106];
714
- libraryContent = /* @__PURE__ */ jsxs("div", {
715
- className: MediaPicker_module_default.browse,
716
- "data-details-open": detailsOpen || void 0,
717
- children: [/* @__PURE__ */ jsxs("div", {
718
- ref: scroller,
719
- className: MediaPicker_module_default.scroll,
720
- onScroll: t32,
721
- children: [grid(state.items, intl.formatMessage(mediaMessages.pickerMedia, { library })), t37]
722
- }), /* @__PURE__ */ jsx(MediaDetails, {
723
- item: focusedEntry?.item ?? null,
724
- fields,
725
- draft: draftValues,
726
- onDraftChange: t38,
727
- dirty,
728
- saving,
729
- error: saveError,
730
- onSave: () => void save(),
731
- onBack: t39
732
- })]
733
- });
734
- }
735
- const uploadedHere = uploaded.get(source.id) ?? [];
736
- let t32;
737
- if ($[107] !== intl || $[108] !== title) {
738
- t32 = title ?? intl.formatMessage(mediaMessages.pickerTitle);
739
- $[107] = intl;
740
- $[108] = title;
741
- $[109] = t32;
742
- } else t32 = $[109];
743
- const t33 = picked.length === 0 ? /* @__PURE__ */ jsx(Text, {
744
- muted: true,
745
- size: "sm",
746
- as: "span",
747
- children: intl.formatMessage(mediaMessages.pickerNothingSelected)
748
- }) : multiple ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Text, {
749
- size: "sm",
750
- weight: "medium",
751
- as: "span",
752
- children: pickedSources.size > 1 ? intl.formatMessage(mediaMessages.pickerSelectedIn, {
753
- count: picked.length,
754
- libraries: pickedSources.size
755
- }) : intl.formatMessage(mediaMessages.pickerSelectedCount, { count: picked.length })
756
- }), /* @__PURE__ */ jsx(Button, {
757
- size: "sm",
758
- variant: "ghost",
759
- onPress: () => setSelection(/* @__PURE__ */ new Map()),
760
- children: intl.formatMessage(mediaMessages.pickerClear)
761
- })] }) : /* @__PURE__ */ jsx(Text, {
762
- size: "sm",
763
- as: "span",
764
- truncate: true,
765
- children: intl.formatMessage(mediaMessages.pickerSelected, { name: picked[0]?.item.label ?? "" })
766
- });
767
- let t34;
768
- if ($[110] !== t33) {
769
- t34 = /* @__PURE__ */ jsx("div", {
770
- className: MediaPicker_module_default.summary,
771
- "aria-live": "polite",
772
- children: t33
138
+ onPress: library.clear,
139
+ children: intl.formatMessage(mediaMessages.pickerClear)
140
+ })] }) : /* @__PURE__ */ jsx(Text, {
141
+ size: "sm",
142
+ as: "span",
143
+ truncate: true,
144
+ children: intl.formatMessage(mediaMessages.pickerSelected, { name: library.picked[0]?.item.label ?? "" })
145
+ })
773
146
  });
774
- $[110] = t33;
775
- $[111] = t34;
776
- } else t34 = $[111];
777
- let t35;
778
- if ($[112] !== onOpenChange) {
779
- t35 = () => onOpenChange(false);
780
- $[112] = onOpenChange;
781
- $[113] = t35;
782
- } else t35 = $[113];
783
- let t36;
784
- if ($[114] !== intl) {
785
- t36 = intl.formatMessage(mediaMessages.pickerCancel);
786
- $[114] = intl;
787
- $[115] = t36;
788
- } else t36 = $[115];
789
- let t37;
790
- if ($[116] !== t35 || $[117] !== t36) {
791
- t37 = /* @__PURE__ */ jsx(Button, {
147
+ $[25] = intl;
148
+ $[26] = library.clear;
149
+ $[27] = library.picked[0]?.item;
150
+ $[28] = library.picked.length;
151
+ $[29] = library.pickedSources;
152
+ $[30] = multiple;
153
+ $[31] = t8;
154
+ } else t8 = $[31];
155
+ let t9;
156
+ if ($[32] !== onOpenChange) {
157
+ t9 = () => onOpenChange(false);
158
+ $[32] = onOpenChange;
159
+ $[33] = t9;
160
+ } else t9 = $[33];
161
+ let t10;
162
+ if ($[34] !== intl) {
163
+ t10 = intl.formatMessage(mediaMessages.pickerCancel);
164
+ $[34] = intl;
165
+ $[35] = t10;
166
+ } else t10 = $[35];
167
+ let t11;
168
+ if ($[36] !== t10 || $[37] !== t9) {
169
+ t11 = /* @__PURE__ */ jsx(Button, {
792
170
  className: MediaPicker_module_default.cancel,
793
- onPress: t35,
794
- children: t36
795
- });
796
- $[116] = t35;
797
- $[117] = t36;
798
- $[118] = t37;
799
- } else t37 = $[118];
800
- let t38;
801
- if ($[119] === Symbol.for("react.memo_cache_sentinel")) {
802
- t38 = (key_2) => setTab(String(key_2));
803
- $[119] = t38;
804
- } else t38 = $[119];
805
- let t39;
806
- if ($[120] !== intl) {
807
- t39 = intl.formatMessage(mediaMessages.pickerTabs);
808
- $[120] = intl;
809
- $[121] = t39;
810
- } else t39 = $[121];
811
- let t40;
812
- if ($[122] !== intl) {
813
- t40 = intl.formatMessage(mediaMessages.pickerTabLibrary);
814
- $[122] = intl;
815
- $[123] = t40;
816
- } else t40 = $[123];
817
- let t41;
818
- if ($[124] !== t40) {
819
- t41 = /* @__PURE__ */ jsx(Tab, {
820
- id: "library",
821
- children: t40
822
- });
823
- $[124] = t40;
824
- $[125] = t41;
825
- } else t41 = $[125];
826
- let t42;
827
- if ($[126] !== intl) {
828
- t42 = intl.formatMessage(mediaMessages.pickerTabUpload);
829
- $[126] = intl;
830
- $[127] = t42;
831
- } else t42 = $[127];
832
- let t43;
833
- if ($[128] !== t42) {
834
- t43 = /* @__PURE__ */ jsx(Tab, {
835
- id: "upload",
836
- children: t42
837
- });
838
- $[128] = t42;
839
- $[129] = t43;
840
- } else t43 = $[129];
841
- let t44;
842
- if ($[130] !== t39 || $[131] !== t41 || $[132] !== t43) {
843
- t44 = /* @__PURE__ */ jsxs(TabList, {
844
- "aria-label": t39,
845
- className: MediaPicker_module_default.tabList,
846
- children: [t41, t43]
847
- });
848
- $[130] = t39;
849
- $[131] = t41;
850
- $[132] = t43;
851
- $[133] = t44;
852
- } else t44 = $[133];
853
- const t45 = !source.canCreate ? /* @__PURE__ */ jsxs("span", {
854
- className: MediaPicker_module_default.cannotUpload,
855
- children: [/* @__PURE__ */ jsx(Lock, {
856
- "aria-hidden": true,
857
- size: 14
858
- }), intl.formatMessage(mediaMessages.pickerCannotUpload, { library })]
859
- }) : null;
860
- let t46;
861
- if ($[134] !== t44 || $[135] !== t45) {
862
- t46 = /* @__PURE__ */ jsxs("div", {
863
- className: MediaPicker_module_default.bar,
864
- children: [t44, t45]
865
- });
866
- $[134] = t44;
867
- $[135] = t45;
868
- $[136] = t46;
869
- } else t46 = $[136];
870
- const t47 = state.items.length > 0 || !isDefaultQuery(state.query) ? /* @__PURE__ */ jsx(PickerToolbar, {
871
- query: state.query,
872
- onQueryChange: browser.setQuery,
873
- sorts: sortsOf(source),
874
- filters,
875
- locked,
876
- lockedFilters: filters
877
- }) : null;
878
- let t48;
879
- if ($[137] !== accept || $[138] !== intl || $[139] !== maxSize) {
880
- t48 = accept !== null || maxSize !== null ? /* @__PURE__ */ jsx(Text, {
881
- size: "sm",
882
- muted: true,
883
- className: MediaPicker_module_default.constraints,
884
- children: maxSize !== null ? intl.formatMessage(mediaMessages.pickerAcceptedSize, {
885
- types: accept !== null && accept.length > 0 ? describeAccept(accept, intl) : intl.formatMessage(mediaMessages.pickerAnyFile),
886
- size: formatSize(maxSize, intl.locale)
887
- }) : intl.formatMessage(mediaMessages.pickerAccepted, { types: describeAccept(accept ?? [], intl) })
888
- }) : null;
889
- $[137] = accept;
890
- $[138] = intl;
891
- $[139] = maxSize;
892
- $[140] = t48;
893
- } else t48 = $[140];
894
- let t49;
895
- if ($[141] !== libraryContent || $[142] !== t47 || $[143] !== t48) {
896
- t49 = /* @__PURE__ */ jsxs(TabPanel, {
897
- id: "library",
898
- className: MediaPicker_module_default.panel,
899
- children: [
900
- t47,
901
- t48,
902
- libraryContent
903
- ]
904
- });
905
- $[141] = libraryContent;
906
- $[142] = t47;
907
- $[143] = t48;
908
- $[144] = t49;
909
- } else t49 = $[144];
910
- const T0 = Dialog;
911
- const t50 = pendingFocus !== null;
912
- let t51;
913
- if ($[145] !== setPendingFocus) {
914
- t51 = (open) => open ? void 0 : setPendingFocus(null);
915
- $[145] = setPendingFocus;
916
- $[146] = t51;
917
- } else t51 = $[146];
918
- const t52 = "alertdialog";
919
- const t53 = false;
920
- const t54 = "sm";
921
- const t55 = intl.formatMessage(mediaMessages.pickerUnsaved, { name: focusedEntry?.item.label ?? "" });
922
- let t56;
923
- if ($[147] !== pendingFocus || $[148] !== setDraft || $[149] !== setFocused || $[150] !== setPendingFocus) {
924
- t56 = () => {
925
- setDraft(null);
926
- setFocused(pendingFocus);
927
- setPendingFocus(null);
928
- };
929
- $[147] = pendingFocus;
930
- $[148] = setDraft;
931
- $[149] = setFocused;
932
- $[150] = setPendingFocus;
933
- $[151] = t56;
934
- } else t56 = $[151];
935
- let t57;
936
- if ($[152] !== intl) {
937
- t57 = intl.formatMessage(mediaMessages.pickerDiscard);
938
- $[152] = intl;
939
- $[153] = t57;
940
- } else t57 = $[153];
941
- let t58;
942
- if ($[154] !== t56 || $[155] !== t57) {
943
- t58 = /* @__PURE__ */ jsx(Button, {
944
- onPress: t56,
945
- children: t57
171
+ onPress: t9,
172
+ children: t10
946
173
  });
947
- $[154] = t56;
948
- $[155] = t57;
949
- $[156] = t58;
950
- } else t58 = $[156];
951
- let t59;
952
- if ($[157] !== pendingFocus || $[158] !== save || $[159] !== setFocused || $[160] !== setPendingFocus) {
953
- t59 = () => void save().then((saved_0) => {
954
- if (saved_0) setFocused(pendingFocus);
955
- setPendingFocus(null);
956
- });
957
- $[157] = pendingFocus;
958
- $[158] = save;
959
- $[159] = setFocused;
960
- $[160] = setPendingFocus;
961
- $[161] = t59;
962
- } else t59 = $[161];
963
- let t60;
964
- if ($[162] !== intl) {
965
- t60 = intl.formatMessage(mediaMessages.pickerSave);
966
- $[162] = intl;
967
- $[163] = t60;
968
- } else t60 = $[163];
969
- let t61;
970
- if ($[164] !== saving || $[165] !== t59 || $[166] !== t60) {
971
- t61 = /* @__PURE__ */ jsx(Button, {
174
+ $[36] = t10;
175
+ $[37] = t9;
176
+ $[38] = t11;
177
+ } else t11 = $[38];
178
+ const t12 = library.picked.length === 0 || library.unchanged;
179
+ let t13;
180
+ if ($[39] !== confirm || $[40] !== library.picked) {
181
+ t13 = () => confirm(library.picked);
182
+ $[39] = confirm;
183
+ $[40] = library.picked;
184
+ $[41] = t13;
185
+ } else t13 = $[41];
186
+ let t14;
187
+ if ($[42] !== label || $[43] !== t12 || $[44] !== t13) {
188
+ t14 = /* @__PURE__ */ jsx(Button, {
972
189
  variant: "primary",
973
- isDisabled: saving,
974
- onPress: t59,
975
- children: t60
190
+ isDisabled: t12,
191
+ onPress: t13,
192
+ children: label
976
193
  });
977
- $[164] = saving;
978
- $[165] = t59;
979
- $[166] = t60;
980
- $[167] = t61;
981
- } else t61 = $[167];
982
- let t62;
983
- if ($[168] !== t58 || $[169] !== t61) {
984
- t62 = /* @__PURE__ */ jsxs(Fragment, { children: [t58, t61] });
985
- $[168] = t58;
986
- $[169] = t61;
987
- $[170] = t62;
988
- } else t62 = $[170];
989
- let t63;
990
- if ($[171] !== intl) {
991
- t63 = intl.formatMessage(mediaMessages.pickerUnsavedText);
992
- $[171] = intl;
993
- $[172] = t63;
994
- } else t63 = $[172];
995
- let t64;
996
- if ($[173] !== T0 || $[174] !== t50 || $[175] !== t51 || $[176] !== t55 || $[177] !== t62 || $[178] !== t63) {
997
- t64 = /* @__PURE__ */ jsx(T0, {
998
- isOpen: t50,
999
- onOpenChange: t51,
1000
- role: t52,
1001
- isDismissable: t53,
1002
- size: t54,
1003
- title: t55,
1004
- footer: t62,
1005
- children: t63
194
+ $[42] = label;
195
+ $[43] = t12;
196
+ $[44] = t13;
197
+ $[45] = t14;
198
+ } else t14 = $[45];
199
+ let t15;
200
+ if ($[46] !== t11 || $[47] !== t14) {
201
+ t15 = /* @__PURE__ */ jsxs("div", {
202
+ className: MediaPicker_module_default.actions,
203
+ children: [t11, t14]
1006
204
  });
1007
- $[173] = T0;
1008
- $[174] = t50;
1009
- $[175] = t51;
1010
- $[176] = t55;
1011
- $[177] = t62;
1012
- $[178] = t63;
1013
- $[179] = t64;
1014
- } else t64 = $[179];
1015
- return /* @__PURE__ */ jsxs(Dialog, {
1016
- isOpen: true,
1017
- onOpenChange,
1018
- title: t32,
1019
- size: "xl",
1020
- fullScreenOnPhone: true,
1021
- className: MediaPicker_module_default.dialog,
1022
- bodyClassName: MediaPicker_module_default.body,
1023
- headerContent: sources.length > 3 ? /* @__PURE__ */ jsx(Select, {
1024
- "aria-label": intl.formatMessage(mediaMessages.pickerLibraries),
1025
- isRequired: true,
1026
- options: sources.map(_temp0),
1027
- value: source.id,
1028
- onChange: (next_0) => setSourceId(String(next_0)),
1029
- className: MediaPicker_module_default.librarySelect
1030
- }) : sources.length > 1 ? /* @__PURE__ */ jsx(SegmentedControl, {
1031
- "aria-label": intl.formatMessage(mediaMessages.pickerLibraries),
1032
- size: "sm",
1033
- options: sources.map(_temp1),
1034
- value: source.id,
1035
- onChange: setSourceId
1036
- }) : null,
1037
- footer: /* @__PURE__ */ jsxs("div", {
205
+ $[46] = t11;
206
+ $[47] = t14;
207
+ $[48] = t15;
208
+ } else t15 = $[48];
209
+ let t16;
210
+ if ($[49] !== t15 || $[50] !== t8) {
211
+ t16 = /* @__PURE__ */ jsxs("div", {
1038
212
  className: MediaPicker_module_default.footer,
1039
- children: [t34, /* @__PURE__ */ jsxs("div", {
1040
- className: MediaPicker_module_default.actions,
1041
- children: [t37, /* @__PURE__ */ jsx(Button, {
1042
- variant: "primary",
1043
- isDisabled: picked.length === 0 || unchanged,
1044
- onPress: () => confirm(picked),
1045
- children: label
1046
- })]
1047
- })]
1048
- }),
1049
- children: [/* @__PURE__ */ jsxs(Tabs, {
1050
- className: MediaPicker_module_default.tabs,
1051
- selectedKey: tab,
1052
- onSelectionChange: t38,
1053
- disabledKeys: source.canCreate ? [] : ["upload"],
1054
- children: [
1055
- t46,
1056
- t49,
1057
- /* @__PURE__ */ jsx(TabPanel, {
1058
- id: "upload",
1059
- className: MediaPicker_module_default.panel,
1060
- children: /* @__PURE__ */ jsx("div", {
1061
- className: MediaPicker_module_default.scroll,
1062
- children: /* @__PURE__ */ jsx(UploadPanel, {
1063
- library,
1064
- multiple,
1065
- confirmOnUpload,
1066
- accept: uploadAccept,
1067
- maxSize: uploadMaxSize,
1068
- upload,
1069
- problems,
1070
- creating,
1071
- uploaded: uploadedHere.length > 0 ? grid(uploadedHere, intl.formatMessage(mediaMessages.pickerAddedTo, { library })) : null
1072
- })
1073
- })
1074
- })
1075
- ]
1076
- }), t64]
1077
- });
1078
- }
1079
- function _temp1(candidate_5) {
1080
- return {
1081
- value: candidate_5.id,
1082
- label: candidate_5.label
1083
- };
1084
- }
1085
- function _temp0(candidate_4) {
1086
- return {
1087
- value: candidate_4.id,
1088
- label: candidate_4.label
1089
- };
1090
- }
1091
- function _temp9(reference_1) {
1092
- return reference_1.id;
1093
- }
1094
- function _temp8(entry_10) {
1095
- return entry_10.item.id;
1096
- }
1097
- function _temp7(entry_8) {
1098
- return entry_8.isIntersecting;
1099
- }
1100
- function _temp6() {}
1101
- function _temp5(t0) {
1102
- const { source: id_0, item: item_7 } = t0;
1103
- return `${keyOf(id_0, item_7.id)}:${item_7.media.status ?? ""}`;
1104
- }
1105
- function _temp4(t0) {
1106
- const { item: item_6 } = t0;
1107
- return isProcessingMedia(item_6);
1108
- }
1109
- function _temp3(item_3) {
1110
- return item_3.id;
1111
- }
1112
- function _temp2(entry) {
1113
- return entry.source;
213
+ children: [t8, t15]
214
+ });
215
+ $[49] = t15;
216
+ $[50] = t8;
217
+ $[51] = t16;
218
+ } else t16 = $[51];
219
+ let t17;
220
+ if ($[52] !== library.switcher || $[53] !== library.tabs || $[54] !== library.unsaved || $[55] !== onOpenChange || $[56] !== t16 || $[57] !== t6) {
221
+ t17 = /* @__PURE__ */ jsxs(Dialog, {
222
+ isOpen: true,
223
+ onOpenChange,
224
+ title: t6,
225
+ size: "xl",
226
+ fullScreenOnPhone: true,
227
+ className: MediaPicker_module_default.dialog,
228
+ bodyClassName: MediaPicker_module_default.body,
229
+ headerContent: t7,
230
+ footer: t16,
231
+ children: [library.tabs, library.unsaved]
232
+ });
233
+ $[52] = library.switcher;
234
+ $[53] = library.tabs;
235
+ $[54] = library.unsaved;
236
+ $[55] = onOpenChange;
237
+ $[56] = t16;
238
+ $[57] = t6;
239
+ $[58] = t17;
240
+ } else t17 = $[58];
241
+ return t17;
1114
242
  }
1115
243
  //#endregion
1116
244
  export { MediaPicker };