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