@widgetic/file-browser 0.5.48 → 0.5.49
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/actions/dragSelectedToFolder.js +115 -104
- package/dist/components/FolderTree.svelte.d.ts +7 -4
- package/dist/components/core/FileBrowser.svelte +1 -3
- package/dist/components/core/dropzoneClick.js +2 -3
- package/dist/components/previews/FilePreview.svelte.d.ts +2 -2
- package/dist/config.js +3 -4
- package/dist/i18n/context.js +2 -2
- package/dist/i18n/errors.js +1 -2
- package/dist/i18n/messages.js +2 -2
- package/dist/i18n/text.js +2 -2
- package/dist/mediaLibrary/capabilities.js +3 -4
- package/dist/mediaLibrary/context.js +3 -4
- package/dist/mediaLibrary/errors.js +35 -46
- package/dist/mediaLibrary/normalize.js +42 -45
- package/dist/mediaLibrary/paging.js +45 -100
- package/dist/mediaLibrary/resolve.js +95 -214
- package/dist/mediaLibrary/treeOps.js +20 -40
- package/dist/mediaLibrary/urls.js +10 -12
- package/dist/mediaLibrary/widgetic.js +54 -140
- package/dist/stores/dragStore.js +1 -1
- package/dist/stores/fileStore.d.ts +3 -3
- package/dist/stores/fileStore.js +37 -44
- package/dist/stores/folderCountStore.js +11 -12
- package/dist/stores/missingFilesStore.js +3 -3
- package/dist/stores/navigationStore.d.ts +1 -1
- package/dist/stores/navigationStore.js +178 -217
- package/dist/stores/persistentSelectStore.d.ts +1 -1
- package/dist/stores/persistentSelectStore.js +94 -117
- package/dist/stores/searchStore.js +1 -1
- package/dist/stores/uploadApiStore.js +7 -7
- package/dist/stores/viewportStore.js +4 -4
- package/dist/types/index.js +1 -0
- package/dist/utils/apiConfig.js +9 -9
- package/dist/utils/brandKitLibraryTree.js +42 -57
- package/dist/utils/dateUtils.js +9 -11
- package/dist/utils/dragToFolder/batchMoveResult.js +54 -114
- package/dist/utils/dragToFolder/folderDropTarget.js +17 -23
- package/dist/utils/dragToFolder/springStep.js +3 -4
- package/dist/utils/fileGoneProbe.js +16 -65
- package/dist/utils/fileKinds.js +13 -14
- package/dist/utils/fileNames.js +7 -7
- package/dist/utils/fileOperations.js +332 -440
- package/dist/utils/fileTypes.js +14 -19
- package/dist/utils/fileUtils.js +31 -85
- package/dist/utils/folderUtils.js +4 -5
- package/dist/utils/gridLayout.js +7 -7
- package/dist/utils/imagePreviewCache.js +15 -26
- package/dist/utils/imagePreviewFrame.js +13 -13
- package/dist/utils/imagePreviewVisualState.js +4 -5
- package/dist/utils/imageTransform.js +14 -27
- package/dist/utils/itemMenuCapabilities.js +7 -7
- package/dist/utils/libraryTree.js +39 -55
- package/dist/utils/pendingUploadDeletes.js +113 -289
- package/dist/utils/previewKeys.js +1 -1
- package/dist/utils/previewListNavigation.js +11 -13
- package/dist/utils/previewNavigation.js +7 -10
- package/dist/utils/recentFiles.js +6 -16
- package/dist/utils/recentFilesLimit.js +2 -2
- package/dist/utils/removeItems.js +29 -61
- package/dist/utils/resolveFileUrl.js +6 -6
- package/dist/utils/safeText.js +12 -14
- package/dist/utils/searchDropdownPhase.js +2 -2
- package/dist/utils/searchItems.js +14 -30
- package/dist/utils/searchNavigation.js +5 -5
- package/dist/utils/uploadAuth.js +36 -111
- package/dist/utils/uploadDisplayProgress.js +1 -1
- package/dist/utils/uploadLimits.js +66 -138
- package/dist/utils/uploadListReconcile.js +11 -24
- package/dist/utils/uploadPanelDismiss.js +1 -1
- package/dist/utils/uploadPanelProgress.js +4 -4
- package/dist/utils/uploadProgressMath.js +11 -13
- package/dist/utils/uploadRefusals.js +24 -40
- package/dist/utils/uploadResponseMapping.js +8 -9
- package/dist/utils/uploadUiHelpers.js +17 -17
- package/dist/utils/userUploadsStorage.js +133 -270
- package/dist/utils/videoFrame.js +2 -2
- package/dist/utils/widgeticDelete.js +30 -103
- package/dist/utils/widgeticTusUpload.js +105 -189
- package/dist/utils/widgeticUpload.js +62 -130
- package/dist/utils/xhrMultipartUpload.js +116 -164
- package/package.json +1 -1
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { canDropOnFolder, resolveFolderDropTarget } from '../utils/dragToFolder/folderDropTarget';
|
|
13
2
|
import { DEFAULT_GHOST_FOLLOW_FACTOR, layerFollowFactor, springLerpPoint } from '../utils/dragToFolder/springStep';
|
|
14
|
-
export
|
|
3
|
+
export const idleDragSnapshot = () => ({
|
|
15
4
|
active: false,
|
|
16
5
|
phase: 'idle',
|
|
17
6
|
pointerX: 0,
|
|
@@ -23,38 +12,38 @@ export var idleDragSnapshot = function () { return ({
|
|
|
23
12
|
hoverFolderId: null,
|
|
24
13
|
reducedMotion: false,
|
|
25
14
|
dropPulseFolderId: null
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
});
|
|
16
|
+
const MOVE_THRESHOLD_PX = 5;
|
|
17
|
+
const MAX_STACK_LAYERS = 4;
|
|
29
18
|
export function createDragSelectedToFolderController(options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
snapshot =
|
|
44
|
-
options.onSnapshot(
|
|
19
|
+
let snapshot = idleDragSnapshot();
|
|
20
|
+
let activePointerId = null;
|
|
21
|
+
let pressClientX = 0;
|
|
22
|
+
let pressClientY = 0;
|
|
23
|
+
let originClientX = 0;
|
|
24
|
+
let originClientY = 0;
|
|
25
|
+
let dragging = false;
|
|
26
|
+
let items = [];
|
|
27
|
+
let rafId = null;
|
|
28
|
+
let hoverElement = null;
|
|
29
|
+
let autoScrollFrame = null;
|
|
30
|
+
let disposed = false;
|
|
31
|
+
const setSnapshot = (next) => {
|
|
32
|
+
snapshot = { ...snapshot, ...next };
|
|
33
|
+
options.onSnapshot({ ...snapshot });
|
|
45
34
|
};
|
|
46
|
-
|
|
35
|
+
const clearHover = () => {
|
|
47
36
|
if (hoverElement) {
|
|
48
37
|
hoverElement.removeAttribute('data-folder-drop-hover');
|
|
49
38
|
hoverElement = null;
|
|
50
39
|
}
|
|
51
40
|
setSnapshot({ hoverFolderId: null });
|
|
52
41
|
};
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
const markSources = (on) => {
|
|
43
|
+
const container = options.getContainer();
|
|
55
44
|
if (!container)
|
|
56
45
|
return;
|
|
57
|
-
container.querySelectorAll('.item-container[data-selected="true"]').forEach(
|
|
46
|
+
container.querySelectorAll('.item-container[data-selected="true"]').forEach((el) => {
|
|
58
47
|
if (on)
|
|
59
48
|
el.setAttribute('data-dragging-source', 'true');
|
|
60
49
|
else
|
|
@@ -65,10 +54,10 @@ export function createDragSelectedToFolderController(options) {
|
|
|
65
54
|
else
|
|
66
55
|
document.body.classList.remove('fb-dragging-selected-files');
|
|
67
56
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return show.map(
|
|
71
|
-
item
|
|
57
|
+
const buildLayers = () => {
|
|
58
|
+
const show = items.slice(0, MAX_STACK_LAYERS);
|
|
59
|
+
return show.map((item, index) => ({
|
|
60
|
+
item,
|
|
72
61
|
x: originClientX,
|
|
73
62
|
y: originClientY,
|
|
74
63
|
offsetX: -index * 6,
|
|
@@ -76,24 +65,24 @@ export function createDragSelectedToFolderController(options) {
|
|
|
76
65
|
rotate: index % 2 === 0 ? -4 + index * 2 : 3 - index,
|
|
77
66
|
scale: 1 - index * 0.04,
|
|
78
67
|
opacity: 1 - index * 0.08
|
|
79
|
-
})
|
|
68
|
+
}));
|
|
80
69
|
};
|
|
81
|
-
|
|
70
|
+
const stopAutoScroll = () => {
|
|
82
71
|
if (autoScrollFrame != null) {
|
|
83
72
|
cancelAnimationFrame(autoScrollFrame);
|
|
84
73
|
autoScrollFrame = null;
|
|
85
74
|
}
|
|
86
75
|
};
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
const autoScrollStep = () => {
|
|
77
|
+
const scrollEl = options.getScrollContainer();
|
|
89
78
|
if (!scrollEl || !dragging) {
|
|
90
79
|
stopAutoScroll();
|
|
91
80
|
return;
|
|
92
81
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
const rect = scrollEl.getBoundingClientRect();
|
|
83
|
+
const edge = 56;
|
|
84
|
+
const maxStep = 14;
|
|
85
|
+
let delta = 0;
|
|
97
86
|
if (snapshot.pointerY < rect.top + edge) {
|
|
98
87
|
delta = -maxStep;
|
|
99
88
|
}
|
|
@@ -105,29 +94,33 @@ export function createDragSelectedToFolderController(options) {
|
|
|
105
94
|
}
|
|
106
95
|
autoScrollFrame = requestAnimationFrame(autoScrollStep);
|
|
107
96
|
};
|
|
108
|
-
|
|
97
|
+
const tick = () => {
|
|
109
98
|
if (!dragging || disposed)
|
|
110
99
|
return;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return
|
|
100
|
+
const reduced = options.prefersReducedMotion();
|
|
101
|
+
const layers = snapshot.layers.map((layer, index) => {
|
|
102
|
+
const factor = reduced ? 1 : layerFollowFactor(index, DEFAULT_GHOST_FOLLOW_FACTOR);
|
|
103
|
+
const next = springLerpPoint({ x: layer.x + layer.offsetX, y: layer.y + layer.offsetY }, { x: snapshot.pointerX + layer.offsetX, y: snapshot.pointerY + layer.offsetY }, factor);
|
|
104
|
+
return {
|
|
105
|
+
...layer,
|
|
106
|
+
x: next.x - layer.offsetX,
|
|
107
|
+
y: next.y - layer.offsetY
|
|
108
|
+
};
|
|
116
109
|
});
|
|
117
|
-
setSnapshot({ layers
|
|
110
|
+
setSnapshot({ layers });
|
|
118
111
|
rafId = requestAnimationFrame(tick);
|
|
119
112
|
};
|
|
120
|
-
|
|
113
|
+
const beginDrag = () => {
|
|
121
114
|
if (dragging)
|
|
122
115
|
return;
|
|
123
116
|
dragging = true;
|
|
124
117
|
if (options.debugLog)
|
|
125
|
-
console.log('[file-browser] drag-selected: start', items.map(
|
|
126
|
-
|
|
118
|
+
console.log('[file-browser] drag-selected: start', items.map((i) => i.id));
|
|
119
|
+
const layers = buildLayers();
|
|
127
120
|
setSnapshot({
|
|
128
121
|
active: true,
|
|
129
122
|
phase: 'dragging',
|
|
130
|
-
layers
|
|
123
|
+
layers,
|
|
131
124
|
totalCount: items.length,
|
|
132
125
|
anchorX: originClientX,
|
|
133
126
|
anchorY: originClientY,
|
|
@@ -137,21 +130,27 @@ export function createDragSelectedToFolderController(options) {
|
|
|
137
130
|
rafId = requestAnimationFrame(tick);
|
|
138
131
|
autoScrollFrame = requestAnimationFrame(autoScrollStep);
|
|
139
132
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
const animateToFolderAndFinish = (target, folderId) => {
|
|
134
|
+
const rect = target.getBoundingClientRect();
|
|
135
|
+
const endX = rect.left + rect.width / 2;
|
|
136
|
+
const endY = rect.top + rect.height / 2;
|
|
144
137
|
setSnapshot({ phase: 'dropping', active: true, dropPulseFolderId: folderId });
|
|
145
138
|
target.setAttribute('data-folder-drop-pulse', 'true');
|
|
146
|
-
window.setTimeout(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
139
|
+
window.setTimeout(() => target.removeAttribute('data-folder-drop-pulse'), 420);
|
|
140
|
+
const start = performance.now();
|
|
141
|
+
const duration = options.prefersReducedMotion() ? 140 : 320;
|
|
142
|
+
const fromLayers = snapshot.layers;
|
|
143
|
+
const dropFrame = (now) => {
|
|
144
|
+
const t = Math.min(1, (now - start) / duration);
|
|
145
|
+
const ease = 1 - Math.pow(1 - t, 3);
|
|
146
|
+
const layers = fromLayers.map((layer) => ({
|
|
147
|
+
...layer,
|
|
148
|
+
x: layer.x + (endX - layer.x - layer.offsetX) * ease,
|
|
149
|
+
y: layer.y + (endY - layer.y - layer.offsetY) * ease,
|
|
150
|
+
scale: layer.scale * (1 - 0.35 * ease),
|
|
151
|
+
opacity: layer.opacity * (1 - ease)
|
|
152
|
+
}));
|
|
153
|
+
setSnapshot({ layers, pointerX: endX, pointerY: endY });
|
|
155
154
|
if (t < 1) {
|
|
156
155
|
requestAnimationFrame(dropFrame);
|
|
157
156
|
}
|
|
@@ -161,22 +160,27 @@ export function createDragSelectedToFolderController(options) {
|
|
|
161
160
|
};
|
|
162
161
|
requestAnimationFrame(dropFrame);
|
|
163
162
|
};
|
|
164
|
-
|
|
163
|
+
const finishDrop = (folderId) => {
|
|
165
164
|
if (options.debugLog)
|
|
166
165
|
console.log('[file-browser] drag-selected: drop', folderId);
|
|
167
166
|
options.onDrop(folderId, items);
|
|
168
167
|
resetAfterGesture();
|
|
169
168
|
};
|
|
170
|
-
|
|
169
|
+
const cancelToOrigin = () => {
|
|
171
170
|
setSnapshot({ phase: 'canceling' });
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
const fromLayers = snapshot.layers;
|
|
172
|
+
const duration = options.prefersReducedMotion() ? 120 : 260;
|
|
173
|
+
const start = performance.now();
|
|
174
|
+
const cancelFrame = (now) => {
|
|
175
|
+
const t = Math.min(1, (now - start) / duration);
|
|
176
|
+
const ease = 1 - Math.pow(1 - t, 2);
|
|
177
|
+
const layers = fromLayers.map((layer) => ({
|
|
178
|
+
...layer,
|
|
179
|
+
x: layer.x + (originClientX - layer.x) * ease,
|
|
180
|
+
y: layer.y + (originClientY - layer.y) * ease,
|
|
181
|
+
opacity: layer.opacity * (1 - ease * 0.85)
|
|
182
|
+
}));
|
|
183
|
+
setSnapshot({ layers });
|
|
180
184
|
if (t < 1)
|
|
181
185
|
requestAnimationFrame(cancelFrame);
|
|
182
186
|
else
|
|
@@ -184,7 +188,7 @@ export function createDragSelectedToFolderController(options) {
|
|
|
184
188
|
};
|
|
185
189
|
requestAnimationFrame(cancelFrame);
|
|
186
190
|
};
|
|
187
|
-
|
|
191
|
+
const resetAfterGesture = () => {
|
|
188
192
|
dragging = false;
|
|
189
193
|
activePointerId = null;
|
|
190
194
|
items = [];
|
|
@@ -197,31 +201,31 @@ export function createDragSelectedToFolderController(options) {
|
|
|
197
201
|
snapshot = idleDragSnapshot();
|
|
198
202
|
options.onSnapshot(snapshot);
|
|
199
203
|
};
|
|
200
|
-
|
|
204
|
+
const isFromMenuOrThumb = (target) => {
|
|
201
205
|
return Boolean(target.closest('[data-fb-menu-root]') ||
|
|
202
206
|
target.closest('button[data-fb-action="preview"]') ||
|
|
203
207
|
target.closest('button[data-fb-action="open-folder"]'));
|
|
204
208
|
};
|
|
205
|
-
|
|
209
|
+
const onPointerDown = (event) => {
|
|
206
210
|
if (disposed || !options.isEnabled())
|
|
207
211
|
return;
|
|
208
212
|
if (event.pointerType === 'touch')
|
|
209
213
|
return;
|
|
210
214
|
if (event.button !== 0)
|
|
211
215
|
return;
|
|
212
|
-
|
|
216
|
+
const target = event.target;
|
|
213
217
|
if (isFromMenuOrThumb(target))
|
|
214
218
|
return;
|
|
215
|
-
|
|
219
|
+
const container = options.getContainer();
|
|
216
220
|
if (!container || !container.contains(target))
|
|
217
221
|
return;
|
|
218
|
-
|
|
222
|
+
const itemEl = target.closest('.item-container');
|
|
219
223
|
if (!itemEl || itemEl.getAttribute('data-selected') !== 'true')
|
|
220
224
|
return;
|
|
221
|
-
|
|
225
|
+
const openFolder = itemEl.querySelector('[data-fb-action="open-folder"]');
|
|
222
226
|
if (openFolder)
|
|
223
227
|
return;
|
|
224
|
-
|
|
228
|
+
const selected = options.getSelectedInView();
|
|
225
229
|
if (selected.length === 0)
|
|
226
230
|
return;
|
|
227
231
|
activePointerId = event.pointerId;
|
|
@@ -230,23 +234,30 @@ export function createDragSelectedToFolderController(options) {
|
|
|
230
234
|
originClientX = event.clientX;
|
|
231
235
|
originClientY = event.clientY;
|
|
232
236
|
items = selected;
|
|
233
|
-
setSnapshot(
|
|
237
|
+
setSnapshot({
|
|
238
|
+
...idleDragSnapshot(),
|
|
239
|
+
phase: 'pending',
|
|
240
|
+
pointerX: event.clientX,
|
|
241
|
+
pointerY: event.clientY,
|
|
242
|
+
totalCount: selected.length,
|
|
243
|
+
reducedMotion: options.prefersReducedMotion()
|
|
244
|
+
});
|
|
234
245
|
};
|
|
235
|
-
|
|
246
|
+
const onPointerMove = (event) => {
|
|
236
247
|
if (activePointerId == null || event.pointerId !== activePointerId)
|
|
237
248
|
return;
|
|
238
249
|
setSnapshot({ pointerX: event.clientX, pointerY: event.clientY });
|
|
239
|
-
|
|
250
|
+
const distance = Math.hypot(event.clientX - pressClientX, event.clientY - pressClientY);
|
|
240
251
|
if (!dragging && distance >= MOVE_THRESHOLD_PX) {
|
|
241
252
|
beginDrag();
|
|
242
253
|
}
|
|
243
254
|
if (!dragging)
|
|
244
255
|
return;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
256
|
+
const resolved = resolveFolderDropTarget(event.clientX, event.clientY);
|
|
257
|
+
const root = options.getRoot();
|
|
258
|
+
const parentId = options.getImmediateParentId();
|
|
259
|
+
let nextHover = null;
|
|
260
|
+
let hoverId = null;
|
|
250
261
|
if (resolved && canDropOnFolder(resolved.folderId, items, parentId, root)) {
|
|
251
262
|
nextHover = resolved.element;
|
|
252
263
|
hoverId = resolved.folderId;
|
|
@@ -259,7 +270,7 @@ export function createDragSelectedToFolderController(options) {
|
|
|
259
270
|
setSnapshot({ hoverFolderId: hoverId });
|
|
260
271
|
}
|
|
261
272
|
};
|
|
262
|
-
|
|
273
|
+
const onPointerUp = (event) => {
|
|
263
274
|
if (activePointerId == null || event.pointerId !== activePointerId)
|
|
264
275
|
return;
|
|
265
276
|
if (!dragging) {
|
|
@@ -268,9 +279,9 @@ export function createDragSelectedToFolderController(options) {
|
|
|
268
279
|
options.onSnapshot(snapshot);
|
|
269
280
|
return;
|
|
270
281
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
282
|
+
const resolved = resolveFolderDropTarget(event.clientX, event.clientY);
|
|
283
|
+
const root = options.getRoot();
|
|
284
|
+
const parentId = options.getImmediateParentId();
|
|
274
285
|
if (resolved &&
|
|
275
286
|
canDropOnFolder(resolved.folderId, items, parentId, root) &&
|
|
276
287
|
resolved.folderId) {
|
|
@@ -282,20 +293,20 @@ export function createDragSelectedToFolderController(options) {
|
|
|
282
293
|
cancelToOrigin();
|
|
283
294
|
}
|
|
284
295
|
};
|
|
285
|
-
|
|
296
|
+
const onKeyDown = (event) => {
|
|
286
297
|
if (event.key === 'Escape' && dragging) {
|
|
287
298
|
event.preventDefault();
|
|
288
299
|
cancelToOrigin();
|
|
289
300
|
}
|
|
290
301
|
};
|
|
291
|
-
|
|
302
|
+
const attach = () => {
|
|
292
303
|
window.addEventListener('pointerdown', onPointerDown, true);
|
|
293
304
|
window.addEventListener('pointermove', onPointerMove, true);
|
|
294
305
|
window.addEventListener('pointerup', onPointerUp, true);
|
|
295
306
|
window.addEventListener('pointercancel', onPointerUp, true);
|
|
296
307
|
window.addEventListener('keydown', onKeyDown, true);
|
|
297
308
|
};
|
|
298
|
-
|
|
309
|
+
const detach = () => {
|
|
299
310
|
disposed = true;
|
|
300
311
|
window.removeEventListener('pointerdown', onPointerDown, true);
|
|
301
312
|
window.removeEventListener('pointermove', onPointerMove, true);
|
|
@@ -305,5 +316,5 @@ export function createDragSelectedToFolderController(options) {
|
|
|
305
316
|
resetAfterGesture();
|
|
306
317
|
};
|
|
307
318
|
attach();
|
|
308
|
-
return { detach
|
|
319
|
+
return { detach, getSnapshot: () => snapshot };
|
|
309
320
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Mirrors Figma "Folder Row" (274:1480) with 32px level indent and a 2px start guide line.
|
|
4
4
|
*/
|
|
5
5
|
import type { FileSystemItem } from '../types';
|
|
6
|
-
import { IconArrowBounce } from '@widgetic/design-system/icons';
|
|
7
6
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
8
7
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
9
8
|
$$bindings?: Bindings;
|
|
@@ -18,17 +17,21 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
18
17
|
z_$$bindings?: Bindings;
|
|
19
18
|
}
|
|
20
19
|
declare const FolderTree: $$__sveltets_2_IsomorphicComponent<{
|
|
21
|
-
folder:
|
|
20
|
+
folder: FileSystemItem & {
|
|
21
|
+
displayChildren?: FileSystemItem[];
|
|
22
|
+
};
|
|
22
23
|
selectedFolder: FileSystemItem | undefined;
|
|
23
24
|
immediateParentId: string | null;
|
|
24
|
-
onSelect: (folder:
|
|
25
|
+
onSelect: (folder: FileSystemItem & {
|
|
26
|
+
displayChildren?: FileSystemItem[];
|
|
27
|
+
}) => void;
|
|
25
28
|
/** Kept for callers; rows use FileIcon instead of dynamic folder artwork. */ getFolderIconForItem: (folder: FileSystemItem) => string;
|
|
26
29
|
customClasses?: string;
|
|
27
30
|
iconSize?: string;
|
|
28
31
|
textClass?: string;
|
|
29
32
|
selectedIconClass?: string;
|
|
30
33
|
currentLocationClass?: string;
|
|
31
|
-
selectedIcon?:
|
|
34
|
+
selectedIcon?: any;
|
|
32
35
|
}, {
|
|
33
36
|
[evt: string]: CustomEvent<any>;
|
|
34
37
|
}, {}, {}, string>;
|
|
@@ -812,9 +812,7 @@
|
|
|
812
812
|
const token = session?.accessToken || session?.access_token;
|
|
813
813
|
if (token) {
|
|
814
814
|
// Scope Dexie only — do not invent an empty apiBasePath upload config.
|
|
815
|
-
const { ensureCacheOwnerFromSessionHint, setCacheOwner } = await import(
|
|
816
|
-
'@widgetic/cache-layer'
|
|
817
|
-
);
|
|
815
|
+
const { ensureCacheOwnerFromSessionHint, setCacheOwner } = await import('@widgetic/cache-layer');
|
|
818
816
|
ensureCacheOwnerFromSessionHint();
|
|
819
817
|
const payloadPart = token.split('.')[1];
|
|
820
818
|
if (payloadPart) {
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* button) belongs to that control and is left alone, otherwise the chooser would open twice, or open from the help icon.
|
|
7
7
|
*/
|
|
8
8
|
/** Anything inside the zone that handles its own click. */
|
|
9
|
-
|
|
9
|
+
const OWN_CLICK_SELECTOR = 'button, a, input, select, textarea, [role="button"]';
|
|
10
10
|
/** Whether the click landed on a control that sits inside the zone (not on the zone itself). */
|
|
11
11
|
export function isClickOnControlInsideZone(target, zone) {
|
|
12
|
-
|
|
13
|
-
var control = (_b = (_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, OWN_CLICK_SELECTOR)) !== null && _b !== void 0 ? _b : null;
|
|
12
|
+
const control = target?.closest?.(OWN_CLICK_SELECTOR) ?? null;
|
|
14
13
|
if (!control || control === zone)
|
|
15
14
|
return false;
|
|
16
15
|
return zone.contains(control);
|
|
@@ -22,8 +22,8 @@ declare const FilePreview: $$__sveltets_2_IsomorphicComponent<{
|
|
|
22
22
|
currentFilter?: FileFilterType;
|
|
23
23
|
target?: string;
|
|
24
24
|
}, {
|
|
25
|
-
navigate: FileSystemItem
|
|
26
|
-
select: FileSystemItem
|
|
25
|
+
navigate: CustomEvent<FileSystemItem>;
|
|
26
|
+
select: CustomEvent<FileSystemItem>;
|
|
27
27
|
close: CustomEvent<void>;
|
|
28
28
|
fileUnavailable: CustomEvent<{
|
|
29
29
|
id: string;
|
package/dist/config.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// File Browser Configuration
|
|
2
2
|
// Reads from environment variables with sensible defaults
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export var config = {
|
|
3
|
+
const env = process.env;
|
|
4
|
+
export const config = {
|
|
6
5
|
// Parse comma-separated origins or use defaults for development
|
|
7
|
-
ALLOWED_ORIGINS:
|
|
6
|
+
ALLOWED_ORIGINS: env.PUBLIC_ALLOWED_ORIGINS?.split(',') || [
|
|
8
7
|
'http://localhost:5173', // Main site dev
|
|
9
8
|
'http://localhost:3000', // API Gateway
|
|
10
9
|
'http://localhost:5174', // Alternative dev port
|
package/dist/i18n/context.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createI18n } from '@widgetic/design-system/i18n';
|
|
2
2
|
import { FILE_BROWSER_MESSAGES } from './messages';
|
|
3
3
|
/** The File Browser's words. Problems with the page's messages are said in the console as `[FileBrowser] …`. */
|
|
4
|
-
|
|
4
|
+
const fileBrowserI18n = createI18n({ catalog: FILE_BROWSER_MESSAGES, label: 'FileBrowser' });
|
|
5
5
|
/** The English `t`, for code that has no component around it (a helper called without a translator). */
|
|
6
|
-
export
|
|
6
|
+
export const translateEnglish = fileBrowserI18n.translateEnglish;
|
|
7
7
|
/**
|
|
8
8
|
* Called by the File Browser while it is created, so everything inside it speaks the page's language.
|
|
9
9
|
* The context belongs to one File Browser, so two File Browsers on a page can speak two languages.
|
package/dist/i18n/errors.js
CHANGED
|
@@ -7,8 +7,7 @@ import { MediaLibraryError } from '../mediaLibrary/errors';
|
|
|
7
7
|
* - Any other error keeps its message, as it always has.
|
|
8
8
|
* - With nothing to say, `fallbackKey`.
|
|
9
9
|
*/
|
|
10
|
-
export function messageForVisitor(error, t, fallbackKey) {
|
|
11
|
-
if (fallbackKey === void 0) { fallbackKey = 'toast.unknownError'; }
|
|
10
|
+
export function messageForVisitor(error, t, fallbackKey = 'toast.unknownError') {
|
|
12
11
|
if (error instanceof MediaLibraryError) {
|
|
13
12
|
if (error.messageKey !== undefined)
|
|
14
13
|
return t(error.messageKey, error.messageValues);
|
package/dist/i18n/messages.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Keys are grouped by where the words appear. A key that is left out of a page's `messages` keeps the English text
|
|
10
10
|
* below, so a language can be added a screen at a time.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export const FILE_BROWSER_MESSAGES = {
|
|
13
13
|
// ===== Words that appear in several places =====
|
|
14
14
|
'action.cancel': 'Cancel',
|
|
15
15
|
'action.create': 'Create',
|
|
@@ -323,7 +323,7 @@ export var FILE_BROWSER_MESSAGES = {
|
|
|
323
323
|
'date.overAYearAgo': 'Over a year ago',
|
|
324
324
|
};
|
|
325
325
|
/** Catalog keys referenced from Svelte without string literals in templates (i18n audit). */
|
|
326
|
-
export
|
|
326
|
+
export const UPLOAD_ERROR_KEYS = {
|
|
327
327
|
libraryFailed: 'libraryError.uploadFailed',
|
|
328
328
|
network: 'upload.networkError'
|
|
329
329
|
};
|
package/dist/i18n/text.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* sentence does not contain gives the sentence whole, with nothing underlined.
|
|
5
5
|
*/
|
|
6
6
|
export function splitAround(sentence, link) {
|
|
7
|
-
|
|
7
|
+
const index = link === '' ? -1 : sentence.indexOf(link);
|
|
8
8
|
if (index < 0)
|
|
9
9
|
return { before: sentence, link: '', after: '' };
|
|
10
|
-
return { before: sentence.slice(0, index), link
|
|
10
|
+
return { before: sentence.slice(0, index), link, after: sentence.slice(index + link.length) };
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* The word for a kind of file ("image", "document", "SVG") in the page's language, for a sentence like "Upload image
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* What the File Browser offers when it was not given a media library: everything it has always offered. The Widgetic
|
|
3
3
|
* site and the editor use it this way, so they behave exactly as before.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export const LEGACY_CAPABILITIES = Object.freeze({
|
|
6
6
|
upload: true,
|
|
7
7
|
rename: true,
|
|
8
8
|
delete: true,
|
|
@@ -13,7 +13,7 @@ export var LEGACY_CAPABILITIES = Object.freeze({
|
|
|
13
13
|
* What the File Browser offers when the media library it was given cannot be used: nothing, so no button leads to
|
|
14
14
|
* something that cannot work. (The screen says what is wrong.)
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export const NO_CAPABILITIES = Object.freeze({
|
|
17
17
|
upload: false,
|
|
18
18
|
rename: false,
|
|
19
19
|
delete: false,
|
|
@@ -31,8 +31,7 @@ export var NO_CAPABILITIES = Object.freeze({
|
|
|
31
31
|
* visitor's work. (Folders need a library that has folders of its own; the contract does not have them yet.)
|
|
32
32
|
*/
|
|
33
33
|
export function capabilitiesOf(provider) {
|
|
34
|
-
|
|
35
|
-
var declared = (_a = provider.capabilities) !== null && _a !== void 0 ? _a : {};
|
|
34
|
+
const declared = provider.capabilities ?? {};
|
|
36
35
|
return {
|
|
37
36
|
upload: typeof provider.upload === 'function' && declared.upload !== false,
|
|
38
37
|
rename: typeof provider.rename === 'function' && declared.rename !== false,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
2
|
import { LEGACY_CAPABILITIES } from './capabilities';
|
|
3
|
-
|
|
3
|
+
const MEDIA_LIBRARY_CONTEXT_KEY = Symbol('widgetic-file-browser-media-library');
|
|
4
4
|
/** What a part of the File Browser sees when no library was supplied: the way it has always worked. */
|
|
5
|
-
|
|
5
|
+
const LEGACY_CONTEXT = Object.freeze({
|
|
6
6
|
library: null,
|
|
7
7
|
capabilities: LEGACY_CAPABILITIES
|
|
8
8
|
});
|
|
@@ -12,6 +12,5 @@ export function provideMediaLibraryContext(context) {
|
|
|
12
12
|
}
|
|
13
13
|
/** Called by a part of the File Browser while it is created. Never throws; outside a File Browser it reads as legacy. */
|
|
14
14
|
export function useMediaLibraryContext() {
|
|
15
|
-
|
|
16
|
-
return (_a = getContext(MEDIA_LIBRARY_CONTEXT_KEY)) !== null && _a !== void 0 ? _a : LEGACY_CONTEXT;
|
|
15
|
+
return getContext(MEDIA_LIBRARY_CONTEXT_KEY) ?? LEGACY_CONTEXT;
|
|
17
16
|
}
|