@strapi/upload 5.52.3 → 5.54.0
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/admin/future/components/Drawer.js +6 -3
- package/dist/admin/future/components/Drawer.js.map +1 -1
- package/dist/admin/future/components/Drawer.mjs +6 -3
- package/dist/admin/future/components/Drawer.mjs.map +1 -1
- package/dist/admin/future/components/UploadProgressDialog.js +9 -8
- package/dist/admin/future/components/UploadProgressDialog.js.map +1 -1
- package/dist/admin/future/components/UploadProgressDialog.mjs +9 -8
- package/dist/admin/future/components/UploadProgressDialog.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/AssetsPage.js +16 -4
- package/dist/admin/future/pages/Assets/AssetsPage.js.map +1 -1
- package/dist/admin/future/pages/Assets/AssetsPage.mjs +16 -4
- package/dist/admin/future/pages/Assets/AssetsPage.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetActionsMenu.js +5 -0
- package/dist/admin/future/pages/Assets/components/AssetActionsMenu.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetActionsMenu.mjs +5 -0
- package/dist/admin/future/pages/Assets/components/AssetActionsMenu.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetCropEditor.js +19 -4
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetCropEditor.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetCropEditor.mjs +19 -4
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetCropEditor.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetDetailsDrawer.js +35 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetDetailsDrawer.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetDetailsDrawer.mjs +35 -1
- package/dist/admin/future/pages/Assets/components/AssetDetails/AssetDetailsDrawer.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetsGrid.js +10 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs +10 -0
- package/dist/admin/future/pages/Assets/components/AssetsGrid.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetsTable.js +9 -0
- package/dist/admin/future/pages/Assets/components/AssetsTable.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/AssetsTable.mjs +10 -1
- package/dist/admin/future/pages/Assets/components/AssetsTable.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/BulkActionsBar.js +132 -88
- package/dist/admin/future/pages/Assets/components/BulkActionsBar.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/BulkActionsBar.mjs +135 -91
- package/dist/admin/future/pages/Assets/components/BulkActionsBar.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.js +7 -0
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.mjs +7 -0
- package/dist/admin/future/pages/Assets/components/Dnd/AssetsDndProvider.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.js +4 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.js.map +1 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.mjs +4 -1
- package/dist/admin/future/pages/Assets/components/Dnd/DragOverlayChip.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/components/MainAreaContextMenu.js +181 -0
- package/dist/admin/future/pages/Assets/components/MainAreaContextMenu.js.map +1 -0
- package/dist/admin/future/pages/Assets/components/MainAreaContextMenu.mjs +179 -0
- package/dist/admin/future/pages/Assets/components/MainAreaContextMenu.mjs.map +1 -0
- package/dist/admin/future/pages/Assets/constants.js +22 -0
- package/dist/admin/future/pages/Assets/constants.js.map +1 -1
- package/dist/admin/future/pages/Assets/constants.mjs +19 -1
- package/dist/admin/future/pages/Assets/constants.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.js +65 -10
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.js.map +1 -1
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.mjs +66 -11
- package/dist/admin/future/pages/Assets/hooks/useInfiniteAssets.mjs.map +1 -1
- package/dist/admin/future/pages/Assets/hooks/useListScrollRestoration.js +111 -0
- package/dist/admin/future/pages/Assets/hooks/useListScrollRestoration.js.map +1 -0
- package/dist/admin/future/pages/Assets/hooks/useListScrollRestoration.mjs +109 -0
- package/dist/admin/future/pages/Assets/hooks/useListScrollRestoration.mjs.map +1 -0
- package/dist/admin/future/services/api.js +17 -0
- package/dist/admin/future/services/api.js.map +1 -1
- package/dist/admin/future/services/api.mjs +18 -1
- package/dist/admin/future/services/api.mjs.map +1 -1
- package/dist/admin/future/store/uploadProgress.js +31 -22
- package/dist/admin/future/store/uploadProgress.js.map +1 -1
- package/dist/admin/future/store/uploadProgress.mjs +31 -22
- package/dist/admin/future/store/uploadProgress.mjs.map +1 -1
- package/dist/admin/index.js +11 -10
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +11 -10
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/src/future/components/Drawer.d.ts +10 -0
- package/dist/admin/src/future/pages/Assets/components/MainAreaContextMenu.d.ts +28 -0
- package/dist/admin/src/future/pages/Assets/constants.d.ts +20 -0
- package/dist/admin/src/future/pages/Assets/hooks/useInfiniteAssets.d.ts +4 -0
- package/dist/admin/src/future/pages/Assets/hooks/useListScrollRestoration.d.ts +15 -0
- package/dist/admin/src/future/store/uploadProgress.d.ts +14 -20
- package/dist/admin/translations/en.json.js +1 -3
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +1 -3
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/bootstrap.js +11 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +11 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/admin-upload.js +31 -1
- package/dist/server/controllers/admin-upload.js.map +1 -1
- package/dist/server/controllers/admin-upload.mjs +31 -1
- package/dist/server/controllers/admin-upload.mjs.map +1 -1
- package/dist/server/controllers/utils/find-entity-and-check-permissions.js +15 -4
- package/dist/server/controllers/utils/find-entity-and-check-permissions.js.map +1 -1
- package/dist/server/controllers/utils/find-entity-and-check-permissions.mjs +15 -4
- package/dist/server/controllers/utils/find-entity-and-check-permissions.mjs.map +1 -1
- package/dist/server/controllers/utils/folders.js +1 -1
- package/dist/server/controllers/utils/folders.js.map +1 -1
- package/dist/server/controllers/utils/folders.mjs +1 -1
- package/dist/server/controllers/utils/folders.mjs.map +1 -1
- package/dist/server/mcp/ambient-instance.js +46 -0
- package/dist/server/mcp/ambient-instance.js.map +1 -0
- package/dist/server/mcp/ambient-instance.mjs +43 -0
- package/dist/server/mcp/ambient-instance.mjs.map +1 -0
- package/dist/server/mcp/handlers/constants.js +60 -0
- package/dist/server/mcp/handlers/constants.js.map +1 -0
- package/dist/server/mcp/handlers/constants.mjs +45 -0
- package/dist/server/mcp/handlers/constants.mjs.map +1 -0
- package/dist/server/mcp/handlers/folder-handlers.js +308 -0
- package/dist/server/mcp/handlers/folder-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/folder-handlers.mjs +303 -0
- package/dist/server/mcp/handlers/folder-handlers.mjs.map +1 -0
- package/dist/server/mcp/handlers/read-handlers.js +134 -0
- package/dist/server/mcp/handlers/read-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/read-handlers.mjs +130 -0
- package/dist/server/mcp/handlers/read-handlers.mjs.map +1 -0
- package/dist/server/mcp/handlers/write-handlers.js +315 -0
- package/dist/server/mcp/handlers/write-handlers.js.map +1 -0
- package/dist/server/mcp/handlers/write-handlers.mjs +311 -0
- package/dist/server/mcp/handlers/write-handlers.mjs.map +1 -0
- package/dist/server/mcp/permissions.js +36 -0
- package/dist/server/mcp/permissions.js.map +1 -0
- package/dist/server/mcp/permissions.mjs +33 -0
- package/dist/server/mcp/permissions.mjs.map +1 -0
- package/dist/server/mcp/register-upload-mcp-tools.js +235 -0
- package/dist/server/mcp/register-upload-mcp-tools.js.map +1 -0
- package/dist/server/mcp/register-upload-mcp-tools.mjs +232 -0
- package/dist/server/mcp/register-upload-mcp-tools.mjs.map +1 -0
- package/dist/server/mcp/sanitizers/sanitize-media.js +97 -0
- package/dist/server/mcp/sanitizers/sanitize-media.js.map +1 -0
- package/dist/server/mcp/sanitizers/sanitize-media.mjs +93 -0
- package/dist/server/mcp/sanitizers/sanitize-media.mjs.map +1 -0
- package/dist/server/mcp/schemas/input-schemas.js +206 -0
- package/dist/server/mcp/schemas/input-schemas.js.map +1 -0
- package/dist/server/mcp/schemas/input-schemas.mjs +190 -0
- package/dist/server/mcp/schemas/input-schemas.mjs.map +1 -0
- package/dist/server/mcp/schemas/output-schemas.js +158 -0
- package/dist/server/mcp/schemas/output-schemas.js.map +1 -0
- package/dist/server/mcp/schemas/output-schemas.mjs +142 -0
- package/dist/server/mcp/schemas/output-schemas.mjs.map +1 -0
- package/dist/server/mcp/utils.js +14 -0
- package/dist/server/mcp/utils.js.map +1 -0
- package/dist/server/mcp/utils.mjs +12 -0
- package/dist/server/mcp/utils.mjs.map +1 -0
- package/dist/server/media-library-default-notice.js +42 -0
- package/dist/server/media-library-default-notice.js.map +1 -0
- package/dist/server/media-library-default-notice.mjs +40 -0
- package/dist/server/media-library-default-notice.mjs.map +1 -0
- package/dist/server/register.js +5 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +5 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/services/folder.js.map +1 -1
- package/dist/server/services/folder.mjs.map +1 -1
- package/dist/server/services/upload.js +34 -10
- package/dist/server/services/upload.js.map +1 -1
- package/dist/server/services/upload.mjs +34 -10
- package/dist/server/services/upload.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/admin-upload.d.ts +1 -0
- package/dist/server/src/controllers/admin-upload.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/find-entity-and-check-permissions.d.ts +14 -1
- package/dist/server/src/controllers/utils/find-entity-and-check-permissions.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/folders.d.ts +2 -1
- package/dist/server/src/controllers/utils/folders.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +10 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/ambient-instance.d.ts +65 -0
- package/dist/server/src/mcp/ambient-instance.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/constants.d.ts +48 -0
- package/dist/server/src/mcp/handlers/constants.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/folder-handlers.d.ts +49 -0
- package/dist/server/src/mcp/handlers/folder-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/index.d.ts +5 -0
- package/dist/server/src/mcp/handlers/index.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/read-handlers.d.ts +35 -0
- package/dist/server/src/mcp/handlers/read-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/handlers/write-handlers.d.ts +66 -0
- package/dist/server/src/mcp/handlers/write-handlers.d.ts.map +1 -0
- package/dist/server/src/mcp/index.d.ts +3 -0
- package/dist/server/src/mcp/index.d.ts.map +1 -0
- package/dist/server/src/mcp/permissions.d.ts +22 -0
- package/dist/server/src/mcp/permissions.d.ts.map +1 -0
- package/dist/server/src/mcp/register-upload-mcp-tools.d.ts +29 -0
- package/dist/server/src/mcp/register-upload-mcp-tools.d.ts.map +1 -0
- package/dist/server/src/mcp/sanitizers/sanitize-media.d.ts +63 -0
- package/dist/server/src/mcp/sanitizers/sanitize-media.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/index.d.ts +3 -0
- package/dist/server/src/mcp/schemas/index.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/input-schemas.d.ts +148 -0
- package/dist/server/src/mcp/schemas/input-schemas.d.ts.map +1 -0
- package/dist/server/src/mcp/schemas/output-schemas.d.ts +276 -0
- package/dist/server/src/mcp/schemas/output-schemas.d.ts.map +1 -0
- package/dist/server/src/mcp/types.d.ts +19 -0
- package/dist/server/src/mcp/types.d.ts.map +1 -0
- package/dist/server/src/mcp/utils.d.ts +4 -0
- package/dist/server/src/mcp/utils.d.ts.map +1 -0
- package/dist/server/src/media-library-default-notice.d.ts +19 -0
- package/dist/server/src/media-library-default-notice.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/services/folder.d.ts +6 -2
- package/dist/server/src/services/folder.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +10 -2
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/upload.d.ts +10 -1
- package/dist/server/src/services/upload.d.ts.map +1 -1
- package/dist/server/src/types.d.ts +2 -2
- package/dist/server/src/types.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -1
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/utils/index.js +2 -2
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs +2 -2
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/shared/contracts/files.d.ts +22 -0
- package/dist/shared/contracts/files.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/admin/future/components/BetaNotice.js +0 -72
- package/dist/admin/future/components/BetaNotice.js.map +0 -1
- package/dist/admin/future/components/BetaNotice.mjs +0 -70
- package/dist/admin/future/components/BetaNotice.mjs.map +0 -1
- package/dist/admin/src/future/components/BetaNotice.d.ts +0 -11
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { Menu } from '@strapi/design-system';
|
|
4
|
+
import { Folder, Files, Link } from '@strapi/icons';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { getTranslationKey } from '../../../utils/translations.mjs';
|
|
7
|
+
import { ActionsMenuContent } from './ActionsMenuContent.mjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The admin layout marks the element that scrolls the main column. Listening on
|
|
11
|
+
* it rather than a wrapper of our own is what makes the whole column part of the
|
|
12
|
+
* hit area: it carries a responsive `padding-bottom` (16 / 24 / 40px) that no
|
|
13
|
+
* descendant can cover, and that strip is exactly where a right-click "below the
|
|
14
|
+
* list" lands.
|
|
15
|
+
*/ const SCROLL_ROOT_SELECTOR = '[data-strapi-main-content]';
|
|
16
|
+
/**
|
|
17
|
+
* Subtrees that keep the browser's own context menu instead of opening the
|
|
18
|
+
* create menu.
|
|
19
|
+
*
|
|
20
|
+
* `data-native-context-menu` is the explicit opt-out carried by the list items
|
|
21
|
+
* themselves (asset cards, folder cards, table rows) and by the bulk actions
|
|
22
|
+
* bar — right-clicking one of those must behave exactly as it does today. The
|
|
23
|
+
* rest are the generic cases where the native menu is the useful one: links,
|
|
24
|
+
* buttons and anything the user can type into or select text in.
|
|
25
|
+
*
|
|
26
|
+
* `thead` covers the table's header row, which is chrome rather than empty
|
|
27
|
+
* background even though it carries no `data-native-context-menu` item.
|
|
28
|
+
*/ const NATIVE_CONTEXT_MENU_SELECTOR = [
|
|
29
|
+
'[data-native-context-menu]',
|
|
30
|
+
'thead',
|
|
31
|
+
'a',
|
|
32
|
+
'button',
|
|
33
|
+
'input',
|
|
34
|
+
'textarea',
|
|
35
|
+
'select',
|
|
36
|
+
'[contenteditable="true"]'
|
|
37
|
+
].join(', ');
|
|
38
|
+
/**
|
|
39
|
+
* The menu is anchored to a zero-sized element parked at the cursor, because
|
|
40
|
+
* the design system's `Menu` is a dropdown: it positions its content against a
|
|
41
|
+
* trigger, and there is no real trigger for a right-click on empty space.
|
|
42
|
+
*
|
|
43
|
+
* Inline styles rather than a `styled` wrapper — the trigger renders a design
|
|
44
|
+
* system `Button`, and losing the specificity race with its own class would put
|
|
45
|
+
* a stray button on the page.
|
|
46
|
+
*/ const CURSOR_ANCHOR_STYLE = {
|
|
47
|
+
position: 'fixed',
|
|
48
|
+
width: 0,
|
|
49
|
+
height: 0,
|
|
50
|
+
minWidth: 0,
|
|
51
|
+
minHeight: 0,
|
|
52
|
+
padding: 0,
|
|
53
|
+
border: 0,
|
|
54
|
+
opacity: 0,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
pointerEvents: 'none'
|
|
57
|
+
};
|
|
58
|
+
const LOCATOR_STYLE = {
|
|
59
|
+
height: 0
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Drive/Dropbox-style right-click on the empty parts of the assets area: the
|
|
63
|
+
* same creation actions the header "New" menu offers, acting on the folder
|
|
64
|
+
* currently open.
|
|
65
|
+
*
|
|
66
|
+
* Renders no wrapper — it finds the scrolling column and listens there, so the
|
|
67
|
+
* hit area is the whole column including the padding below the list.
|
|
68
|
+
*
|
|
69
|
+
* Deliberately background-only. Right-clicking an asset, a folder or a table
|
|
70
|
+
* row is left alone — those carry `data-native-context-menu` and keep the
|
|
71
|
+
* browser's menu (which is what you want over a thumbnail or a filename).
|
|
72
|
+
*/ const MainAreaContextMenu = ({ onCreateFolder, onImportFiles, onImportFromUrl, disabled })=>{
|
|
73
|
+
const { formatMessage } = useIntl();
|
|
74
|
+
const [position, setPosition] = useState(null);
|
|
75
|
+
const [locator, setLocator] = useState(null);
|
|
76
|
+
const anchorRef = useCallback((node)=>setLocator(node), []);
|
|
77
|
+
useEffect(()=>{
|
|
78
|
+
const container = locator?.closest(SCROLL_ROOT_SELECTOR);
|
|
79
|
+
if (!container || disabled) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const handleContextMenu = (event)=>{
|
|
83
|
+
if (!(event.target instanceof Element)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (event.target.closest(NATIVE_CONTEXT_MENU_SELECTOR)) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
event.preventDefault();
|
|
90
|
+
// A right-click while the menu is open reaches Radix's dismiss listener
|
|
91
|
+
// first, which closes it; re-anchoring here reopens it under the new
|
|
92
|
+
// cursor rather than leaving the user with a menu that just vanished.
|
|
93
|
+
setPosition({
|
|
94
|
+
x: event.clientX,
|
|
95
|
+
y: event.clientY
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
container.addEventListener('contextmenu', handleContextMenu);
|
|
99
|
+
return ()=>container.removeEventListener('contextmenu', handleContextMenu);
|
|
100
|
+
}, [
|
|
101
|
+
locator,
|
|
102
|
+
disabled
|
|
103
|
+
]);
|
|
104
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ jsx("div", {
|
|
107
|
+
ref: anchorRef,
|
|
108
|
+
style: LOCATOR_STYLE,
|
|
109
|
+
"aria-hidden": true
|
|
110
|
+
}),
|
|
111
|
+
!disabled && /*#__PURE__*/ jsxs(Menu.Root, {
|
|
112
|
+
modal: false,
|
|
113
|
+
open: position !== null,
|
|
114
|
+
onOpenChange: (open)=>{
|
|
115
|
+
if (!open) {
|
|
116
|
+
setPosition(null);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ jsx(Menu.Trigger, {
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
// No visible content, so the name has to come from `aria-label` —
|
|
123
|
+
// the trigger's `label` prop renders as button text, which would
|
|
124
|
+
// defeat the point of an invisible anchor. Radix points the menu's
|
|
125
|
+
// `aria-labelledby` at this element, so it names the menu too.
|
|
126
|
+
endIcon: null,
|
|
127
|
+
"aria-label": formatMessage({
|
|
128
|
+
id: getTranslationKey('list.context-menu.label'),
|
|
129
|
+
defaultMessage: 'Media library actions'
|
|
130
|
+
}),
|
|
131
|
+
style: {
|
|
132
|
+
...CURSOR_ANCHOR_STYLE,
|
|
133
|
+
top: position?.y ?? 0,
|
|
134
|
+
left: position?.x ?? 0
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ jsxs(ActionsMenuContent, {
|
|
138
|
+
popoverPlacement: "bottom-start",
|
|
139
|
+
zIndex: 2,
|
|
140
|
+
minWidth: "22rem",
|
|
141
|
+
// The anchor is invisible and sits wherever the cursor was, so
|
|
142
|
+
// handing focus back to it on close would be a focus ring nobody can
|
|
143
|
+
// see. Let it fall to the body instead.
|
|
144
|
+
onCloseAutoFocus: (event)=>event.preventDefault(),
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ jsx(Menu.Item, {
|
|
147
|
+
onSelect: onCreateFolder,
|
|
148
|
+
startIcon: /*#__PURE__*/ jsx(Folder, {}),
|
|
149
|
+
children: formatMessage({
|
|
150
|
+
id: getTranslationKey('folder.create.title'),
|
|
151
|
+
defaultMessage: 'New folder'
|
|
152
|
+
})
|
|
153
|
+
}),
|
|
154
|
+
/*#__PURE__*/ jsx(Menu.Item, {
|
|
155
|
+
onSelect: onImportFiles,
|
|
156
|
+
startIcon: /*#__PURE__*/ jsx(Files, {}),
|
|
157
|
+
children: formatMessage({
|
|
158
|
+
id: getTranslationKey('import-files'),
|
|
159
|
+
defaultMessage: 'File upload'
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ jsx(Menu.Item, {
|
|
163
|
+
onSelect: onImportFromUrl,
|
|
164
|
+
startIcon: /*#__PURE__*/ jsx(Link, {}),
|
|
165
|
+
children: formatMessage({
|
|
166
|
+
id: getTranslationKey('import-from-url'),
|
|
167
|
+
defaultMessage: 'File upload from URL'
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export { MainAreaContextMenu };
|
|
179
|
+
//# sourceMappingURL=MainAreaContextMenu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MainAreaContextMenu.mjs","sources":["../../../../../../admin/src/future/pages/Assets/components/MainAreaContextMenu.tsx"],"sourcesContent":["import { useCallback, useEffect, useState, type CSSProperties } from 'react';\n\nimport { Menu } from '@strapi/design-system';\nimport { Files, Folder as FolderIcon, Link } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { getTranslationKey } from '../../../utils/translations';\n\nimport { ActionsMenuContent } from './ActionsMenuContent';\n\n/**\n * The admin layout marks the element that scrolls the main column. Listening on\n * it rather than a wrapper of our own is what makes the whole column part of the\n * hit area: it carries a responsive `padding-bottom` (16 / 24 / 40px) that no\n * descendant can cover, and that strip is exactly where a right-click \"below the\n * list\" lands.\n */\nconst SCROLL_ROOT_SELECTOR = '[data-strapi-main-content]';\n\n/**\n * Subtrees that keep the browser's own context menu instead of opening the\n * create menu.\n *\n * `data-native-context-menu` is the explicit opt-out carried by the list items\n * themselves (asset cards, folder cards, table rows) and by the bulk actions\n * bar — right-clicking one of those must behave exactly as it does today. The\n * rest are the generic cases where the native menu is the useful one: links,\n * buttons and anything the user can type into or select text in.\n *\n * `thead` covers the table's header row, which is chrome rather than empty\n * background even though it carries no `data-native-context-menu` item.\n */\nconst NATIVE_CONTEXT_MENU_SELECTOR = [\n '[data-native-context-menu]',\n 'thead',\n 'a',\n 'button',\n 'input',\n 'textarea',\n 'select',\n '[contenteditable=\"true\"]',\n].join(', ');\n\n/**\n * The menu is anchored to a zero-sized element parked at the cursor, because\n * the design system's `Menu` is a dropdown: it positions its content against a\n * trigger, and there is no real trigger for a right-click on empty space.\n *\n * Inline styles rather than a `styled` wrapper — the trigger renders a design\n * system `Button`, and losing the specificity race with its own class would put\n * a stray button on the page.\n */\nconst CURSOR_ANCHOR_STYLE: CSSProperties = {\n position: 'fixed',\n width: 0,\n height: 0,\n minWidth: 0,\n minHeight: 0,\n padding: 0,\n border: 0,\n opacity: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n};\n\nconst LOCATOR_STYLE: CSSProperties = { height: 0 };\n\ninterface CursorPosition {\n x: number;\n y: number;\n}\n\ninterface MainAreaContextMenuProps {\n /** Opens the \"new folder\" dialog in the folder currently on screen. */\n onCreateFolder: () => void;\n /** Opens the native file picker — same entry point as the header \"New\" menu. */\n onImportFiles: () => void;\n /** Opens the \"import from URL\" dialog. */\n onImportFromUrl: () => void;\n /**\n * RBAC gate — without `assets.create` there is nothing to offer, so the\n * right-click falls through to the browser. Required (not defaulted) so a\n * permission gate can't silently regress to permissive.\n */\n disabled: boolean;\n}\n\n/**\n * Drive/Dropbox-style right-click on the empty parts of the assets area: the\n * same creation actions the header \"New\" menu offers, acting on the folder\n * currently open.\n *\n * Renders no wrapper — it finds the scrolling column and listens there, so the\n * hit area is the whole column including the padding below the list.\n *\n * Deliberately background-only. Right-clicking an asset, a folder or a table\n * row is left alone — those carry `data-native-context-menu` and keep the\n * browser's menu (which is what you want over a thumbnail or a filename).\n */\nexport const MainAreaContextMenu = ({\n onCreateFolder,\n onImportFiles,\n onImportFromUrl,\n disabled,\n}: MainAreaContextMenuProps) => {\n const { formatMessage } = useIntl();\n const [position, setPosition] = useState<CursorPosition | null>(null);\n const [locator, setLocator] = useState<HTMLElement | null>(null);\n\n const anchorRef = useCallback((node: HTMLElement | null) => setLocator(node), []);\n\n useEffect(() => {\n const container = locator?.closest<HTMLElement>(SCROLL_ROOT_SELECTOR);\n\n if (!container || disabled) {\n return;\n }\n\n const handleContextMenu = (event: MouseEvent) => {\n if (!(event.target instanceof Element)) {\n return;\n }\n\n if (event.target.closest(NATIVE_CONTEXT_MENU_SELECTOR)) {\n return;\n }\n\n event.preventDefault();\n // A right-click while the menu is open reaches Radix's dismiss listener\n // first, which closes it; re-anchoring here reopens it under the new\n // cursor rather than leaving the user with a menu that just vanished.\n setPosition({ x: event.clientX, y: event.clientY });\n };\n\n container.addEventListener('contextmenu', handleContextMenu);\n\n return () => container.removeEventListener('contextmenu', handleContextMenu);\n }, [locator, disabled]);\n\n return (\n <>\n <div ref={anchorRef} style={LOCATOR_STYLE} aria-hidden />\n {/* Non-modal, like the row-level menus: a right-click elsewhere is both\n \"close this\" and \"open that\", which a modal layer would swallow.\n Skipped entirely without the permission — the anchor is a real\n (if invisible) button, and one that can never open is noise in the\n accessibility tree. */}\n {!disabled && (\n <Menu.Root\n modal={false}\n open={position !== null}\n onOpenChange={(open) => {\n if (!open) {\n setPosition(null);\n }\n }}\n >\n <Menu.Trigger\n tabIndex={-1}\n // No visible content, so the name has to come from `aria-label` —\n // the trigger's `label` prop renders as button text, which would\n // defeat the point of an invisible anchor. Radix points the menu's\n // `aria-labelledby` at this element, so it names the menu too.\n endIcon={null}\n aria-label={formatMessage({\n id: getTranslationKey('list.context-menu.label'),\n defaultMessage: 'Media library actions',\n })}\n style={{ ...CURSOR_ANCHOR_STYLE, top: position?.y ?? 0, left: position?.x ?? 0 }}\n />\n <ActionsMenuContent\n popoverPlacement=\"bottom-start\"\n zIndex={2}\n minWidth=\"22rem\"\n // The anchor is invisible and sits wherever the cursor was, so\n // handing focus back to it on close would be a focus ring nobody can\n // see. Let it fall to the body instead.\n onCloseAutoFocus={(event) => event.preventDefault()}\n >\n <Menu.Item onSelect={onCreateFolder} startIcon={<FolderIcon />}>\n {formatMessage({\n id: getTranslationKey('folder.create.title'),\n defaultMessage: 'New folder',\n })}\n </Menu.Item>\n <Menu.Item onSelect={onImportFiles} startIcon={<Files />}>\n {formatMessage({\n id: getTranslationKey('import-files'),\n defaultMessage: 'File upload',\n })}\n </Menu.Item>\n <Menu.Item onSelect={onImportFromUrl} startIcon={<Link />}>\n {formatMessage({\n id: getTranslationKey('import-from-url'),\n defaultMessage: 'File upload from URL',\n })}\n </Menu.Item>\n </ActionsMenuContent>\n </Menu.Root>\n )}\n </>\n );\n};\n"],"names":["SCROLL_ROOT_SELECTOR","NATIVE_CONTEXT_MENU_SELECTOR","join","CURSOR_ANCHOR_STYLE","position","width","height","minWidth","minHeight","padding","border","opacity","overflow","pointerEvents","LOCATOR_STYLE","MainAreaContextMenu","onCreateFolder","onImportFiles","onImportFromUrl","disabled","formatMessage","useIntl","setPosition","useState","locator","setLocator","anchorRef","useCallback","node","useEffect","container","closest","handleContextMenu","event","target","Element","preventDefault","x","clientX","y","clientY","addEventListener","removeEventListener","_jsxs","_Fragment","_jsx","div","ref","style","aria-hidden","Menu","Root","modal","open","onOpenChange","Trigger","tabIndex","endIcon","aria-label","id","getTranslationKey","defaultMessage","top","left","ActionsMenuContent","popoverPlacement","zIndex","onCloseAutoFocus","Item","onSelect","startIcon","FolderIcon","Files","Link"],"mappings":";;;;;;;;AAUA;;;;;;AAMC,IACD,MAAMA,oBAAAA,GAAuB,4BAAA;AAE7B;;;;;;;;;;;;AAYC,IACD,MAAMC,4BAAAA,GAA+B;AACnC,IAAA,4BAAA;AACA,IAAA,OAAA;AACA,IAAA,GAAA;AACA,IAAA,QAAA;AACA,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,QAAA;AACA,IAAA;AACD,CAAA,CAACC,IAAI,CAAC,IAAA,CAAA;AAEP;;;;;;;;AAQC,IACD,MAAMC,mBAAAA,GAAqC;IACzCC,QAAAA,EAAU,OAAA;IACVC,KAAAA,EAAO,CAAA;IACPC,MAAAA,EAAQ,CAAA;IACRC,QAAAA,EAAU,CAAA;IACVC,SAAAA,EAAW,CAAA;IACXC,OAAAA,EAAS,CAAA;IACTC,MAAAA,EAAQ,CAAA;IACRC,OAAAA,EAAS,CAAA;IACTC,QAAAA,EAAU,QAAA;IACVC,aAAAA,EAAe;AACjB,CAAA;AAEA,MAAMC,aAAAA,GAA+B;IAAER,MAAAA,EAAQ;AAAE,CAAA;AAsBjD;;;;;;;;;;;AAWC,IACM,MAAMS,mBAAAA,GAAsB,CAAC,EAClCC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,QAAQ,EACiB,GAAA;IACzB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,CAACjB,QAAAA,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AA;gCAACC,QAAAA,EAAUpD,aAAAA;AAAeqD,gCAAAA,SAAAA,gBAAWzB,GAAA,CAAC2B,KAAAA,EAAAA,EAAAA,CAAAA;0CAC7CpD,aAAAA,CAAc;AACbuC,oCAAAA,EAAAA,EAAIC,iBAAAA,CAAkB,cAAA,CAAA;oCACtBC,cAAAA,EAAgB;AAClB,iCAAA;;AAEF,0CAAAhB,GAAA,CAACK,KAAKkB,IAAI,EAAA;gCAACC,QAAAA,EAAUnD,eAAAA;AAAiBoD,gCAAAA,SAAAA,gBAAWzB,GAAA,CAAC4B,IAAAA,EAAAA,EAAAA,CAAAA;0CAC/CrD,aAAAA,CAAc;AACbuC,oCAAAA,EAAAA,EAAIC,iBAAAA,CAAkB,iBAAA,CAAA;oCACtBC,cAAAA,EAAgB;AAClB,iCAAA;;;;;;;;AAOd;;;;"}
|
|
@@ -9,6 +9,24 @@ const viewOptions = {
|
|
|
9
9
|
GRID: 0,
|
|
10
10
|
TABLE: 1
|
|
11
11
|
};
|
|
12
|
+
const ASSET_DETAILS_TRIGGER_ATTRIBUTE = 'data-asset-details-trigger';
|
|
13
|
+
/**
|
|
14
|
+
* Spread onto grid cards and table rows, whose click opens or switches the
|
|
15
|
+
* asset details drawer. The drawer's outside-click dismissal skips presses
|
|
16
|
+
* landing on one of these, so switching assets doesn't close-then-reopen it.
|
|
17
|
+
*/ const ASSET_DETAILS_TRIGGER_PROPS = {
|
|
18
|
+
[ASSET_DETAILS_TRIGGER_ATTRIBUTE]: ''
|
|
19
|
+
};
|
|
20
|
+
const ASSET_ITEM_CONTROL_ATTRIBUTE = 'data-asset-item-control';
|
|
21
|
+
/**
|
|
22
|
+
* Spread onto the controls inside an asset card or row that act on the item
|
|
23
|
+
* rather than opening it — its selection checkbox and its actions menu. They
|
|
24
|
+
* stop the card's own click, so no details switch follows them.
|
|
25
|
+
*/ const ASSET_ITEM_CONTROL_PROPS = {
|
|
26
|
+
[ASSET_ITEM_CONTROL_ATTRIBUTE]: ''
|
|
27
|
+
};
|
|
28
|
+
/** Matches an element carrying {@link ASSET_ITEM_CONTROL_PROPS}. */ const ASSET_ITEM_CONTROL_SELECTOR = `[${ASSET_ITEM_CONTROL_ATTRIBUTE}]`;
|
|
29
|
+
/** Matches an element carrying {@link ASSET_DETAILS_TRIGGER_PROPS}. */ const ASSET_DETAILS_TRIGGER_SELECTOR = `[${ASSET_DETAILS_TRIGGER_ATTRIBUTE}]`;
|
|
12
30
|
const TABLE_HEADERS = [
|
|
13
31
|
{
|
|
14
32
|
name: 'name',
|
|
@@ -48,6 +66,10 @@ const TABLE_HEADERS = [
|
|
|
48
66
|
}
|
|
49
67
|
];
|
|
50
68
|
|
|
69
|
+
exports.ASSET_DETAILS_TRIGGER_PROPS = ASSET_DETAILS_TRIGGER_PROPS;
|
|
70
|
+
exports.ASSET_DETAILS_TRIGGER_SELECTOR = ASSET_DETAILS_TRIGGER_SELECTOR;
|
|
71
|
+
exports.ASSET_ITEM_CONTROL_PROPS = ASSET_ITEM_CONTROL_PROPS;
|
|
72
|
+
exports.ASSET_ITEM_CONTROL_SELECTOR = ASSET_ITEM_CONTROL_SELECTOR;
|
|
51
73
|
exports.TABLE_HEADERS = TABLE_HEADERS;
|
|
52
74
|
exports.localStorageKeys = localStorageKeys;
|
|
53
75
|
exports.viewOptions = viewOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVisuallyHidden"],"mappings":";;;;MAEaA,gBAAAA,GAAmB;IAC9BC,IAAAA,EAAM,CAAC,0BAA0B;AACnC;MAEaC,WAAAA,GAAc;IACzBC,IAAAA,EAAM,CAAA;IACNC,KAAAA,EAAO;AACT;
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\nconst ASSET_DETAILS_TRIGGER_ATTRIBUTE = 'data-asset-details-trigger';\n\n/**\n * Spread onto grid cards and table rows, whose click opens or switches the\n * asset details drawer. The drawer's outside-click dismissal skips presses\n * landing on one of these, so switching assets doesn't close-then-reopen it.\n */\nexport const ASSET_DETAILS_TRIGGER_PROPS = { [ASSET_DETAILS_TRIGGER_ATTRIBUTE]: '' };\n\nconst ASSET_ITEM_CONTROL_ATTRIBUTE = 'data-asset-item-control';\n\n/**\n * Spread onto the controls inside an asset card or row that act on the item\n * rather than opening it — its selection checkbox and its actions menu. They\n * stop the card's own click, so no details switch follows them.\n */\nexport const ASSET_ITEM_CONTROL_PROPS = { [ASSET_ITEM_CONTROL_ATTRIBUTE]: '' };\n\n/** Matches an element carrying {@link ASSET_ITEM_CONTROL_PROPS}. */\nexport const ASSET_ITEM_CONTROL_SELECTOR = `[${ASSET_ITEM_CONTROL_ATTRIBUTE}]`;\n\n/** Matches an element carrying {@link ASSET_DETAILS_TRIGGER_PROPS}. */\nexport const ASSET_DETAILS_TRIGGER_SELECTOR = `[${ASSET_DETAILS_TRIGGER_ATTRIBUTE}]`;\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","ASSET_DETAILS_TRIGGER_ATTRIBUTE","ASSET_DETAILS_TRIGGER_PROPS","ASSET_ITEM_CONTROL_ATTRIBUTE","ASSET_ITEM_CONTROL_PROPS","ASSET_ITEM_CONTROL_SELECTOR","ASSET_DETAILS_TRIGGER_SELECTOR","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVisuallyHidden"],"mappings":";;;;MAEaA,gBAAAA,GAAmB;IAC9BC,IAAAA,EAAM,CAAC,0BAA0B;AACnC;MAEaC,WAAAA,GAAc;IACzBC,IAAAA,EAAM,CAAA;IACNC,KAAAA,EAAO;AACT;AAEA,MAAMC,+BAAAA,GAAkC,4BAAA;AAExC;;;;UAKaC,2BAAAA,GAA8B;AAAE,IAAA,CAACD,kCAAkC;AAAG;AAEnF,MAAME,4BAAAA,GAA+B,yBAAA;AAErC;;;;UAKaC,wBAAAA,GAA2B;AAAE,IAAA,CAACD,+BAA+B;AAAG;AAE7E,qEACO,MAAME,2BAAAA,GAA8B,CAAC,CAAC,EAAEF,4BAAAA,CAA6B,CAAC;AAE7E,wEACO,MAAMG,8BAAAA,GAAiC,CAAC,CAAC,EAAEL,+BAAAA,CAAgC,CAAC;MAQtEM,aAAAA,GAA+B;AAC1C,IAAA;QACEC,IAAAA,EAAM,MAAA;QACNC,KAAAA,EAAO;AAAEC,YAAAA,EAAAA,EAAIC,8BAAAA,CAAkB,wBAAA,CAAA;YAA2BC,cAAAA,EAAgB;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,WAAA;QACNC,KAAAA,EAAO;AACLC,YAAAA,EAAAA,EAAIC,8BAAAA,CAAkB,gCAAA,CAAA;YACtBC,cAAAA,EAAgB;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,WAAA;QACNC,KAAAA,EAAO;AACLC,YAAAA,EAAAA,EAAIC,8BAAAA,CAAkB,gCAAA,CAAA;YACtBC,cAAAA,EAAgB;AAClB;AACF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,MAAA;QACNC,KAAAA,EAAO;AAAEC,YAAAA,EAAAA,EAAIC,8BAAAA,CAAkB,wBAAA,CAAA;YAA2BC,cAAAA,EAAgB;AAAO;AACnF,KAAA;AACA,IAAA;QACEJ,IAAAA,EAAM,SAAA;QACNC,KAAAA,EAAO;AAAEC,YAAAA,EAAAA,EAAIC,8BAAAA,CAAkB,2BAAA,CAAA;YAA8BC,cAAAA,EAAgB;AAAU,SAAA;QACvFC,gBAAAA,EAAkB;AACpB;;;;;;;;;;;"}
|
|
@@ -7,6 +7,24 @@ const viewOptions = {
|
|
|
7
7
|
GRID: 0,
|
|
8
8
|
TABLE: 1
|
|
9
9
|
};
|
|
10
|
+
const ASSET_DETAILS_TRIGGER_ATTRIBUTE = 'data-asset-details-trigger';
|
|
11
|
+
/**
|
|
12
|
+
* Spread onto grid cards and table rows, whose click opens or switches the
|
|
13
|
+
* asset details drawer. The drawer's outside-click dismissal skips presses
|
|
14
|
+
* landing on one of these, so switching assets doesn't close-then-reopen it.
|
|
15
|
+
*/ const ASSET_DETAILS_TRIGGER_PROPS = {
|
|
16
|
+
[ASSET_DETAILS_TRIGGER_ATTRIBUTE]: ''
|
|
17
|
+
};
|
|
18
|
+
const ASSET_ITEM_CONTROL_ATTRIBUTE = 'data-asset-item-control';
|
|
19
|
+
/**
|
|
20
|
+
* Spread onto the controls inside an asset card or row that act on the item
|
|
21
|
+
* rather than opening it — its selection checkbox and its actions menu. They
|
|
22
|
+
* stop the card's own click, so no details switch follows them.
|
|
23
|
+
*/ const ASSET_ITEM_CONTROL_PROPS = {
|
|
24
|
+
[ASSET_ITEM_CONTROL_ATTRIBUTE]: ''
|
|
25
|
+
};
|
|
26
|
+
/** Matches an element carrying {@link ASSET_ITEM_CONTROL_PROPS}. */ const ASSET_ITEM_CONTROL_SELECTOR = `[${ASSET_ITEM_CONTROL_ATTRIBUTE}]`;
|
|
27
|
+
/** Matches an element carrying {@link ASSET_DETAILS_TRIGGER_PROPS}. */ const ASSET_DETAILS_TRIGGER_SELECTOR = `[${ASSET_DETAILS_TRIGGER_ATTRIBUTE}]`;
|
|
10
28
|
const TABLE_HEADERS = [
|
|
11
29
|
{
|
|
12
30
|
name: 'name',
|
|
@@ -46,5 +64,5 @@ const TABLE_HEADERS = [
|
|
|
46
64
|
}
|
|
47
65
|
];
|
|
48
66
|
|
|
49
|
-
export { TABLE_HEADERS, localStorageKeys, viewOptions };
|
|
67
|
+
export { ASSET_DETAILS_TRIGGER_PROPS, ASSET_DETAILS_TRIGGER_SELECTOR, ASSET_ITEM_CONTROL_PROPS, ASSET_ITEM_CONTROL_SELECTOR, TABLE_HEADERS, localStorageKeys, viewOptions };
|
|
50
68
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVisuallyHidden"],"mappings":";;MAEaA,gBAAAA,GAAmB;IAC9BC,IAAAA,EAAM,CAAC,0BAA0B;AACnC;MAEaC,WAAAA,GAAc;IACzBC,IAAAA,EAAM,CAAA;IACNC,KAAAA,EAAO;AACT;
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../../../../admin/src/future/pages/Assets/constants.ts"],"sourcesContent":["import { getTranslationKey } from '../../utils/translations';\n\nexport const localStorageKeys = {\n view: `STRAPI_UPLOAD_LIBRARY_VIEW`,\n};\n\nexport const viewOptions = {\n GRID: 0,\n TABLE: 1,\n};\n\nconst ASSET_DETAILS_TRIGGER_ATTRIBUTE = 'data-asset-details-trigger';\n\n/**\n * Spread onto grid cards and table rows, whose click opens or switches the\n * asset details drawer. The drawer's outside-click dismissal skips presses\n * landing on one of these, so switching assets doesn't close-then-reopen it.\n */\nexport const ASSET_DETAILS_TRIGGER_PROPS = { [ASSET_DETAILS_TRIGGER_ATTRIBUTE]: '' };\n\nconst ASSET_ITEM_CONTROL_ATTRIBUTE = 'data-asset-item-control';\n\n/**\n * Spread onto the controls inside an asset card or row that act on the item\n * rather than opening it — its selection checkbox and its actions menu. They\n * stop the card's own click, so no details switch follows them.\n */\nexport const ASSET_ITEM_CONTROL_PROPS = { [ASSET_ITEM_CONTROL_ATTRIBUTE]: '' };\n\n/** Matches an element carrying {@link ASSET_ITEM_CONTROL_PROPS}. */\nexport const ASSET_ITEM_CONTROL_SELECTOR = `[${ASSET_ITEM_CONTROL_ATTRIBUTE}]`;\n\n/** Matches an element carrying {@link ASSET_DETAILS_TRIGGER_PROPS}. */\nexport const ASSET_DETAILS_TRIGGER_SELECTOR = `[${ASSET_DETAILS_TRIGGER_ATTRIBUTE}]`;\n\ninterface TableHeader {\n name: string;\n label: { id: string; defaultMessage: string };\n isVisuallyHidden?: boolean;\n}\n\nexport const TABLE_HEADERS: TableHeader[] = [\n {\n name: 'name',\n label: { id: getTranslationKey('list.table.header.name'), defaultMessage: 'name' },\n },\n {\n name: 'createdAt',\n label: {\n id: getTranslationKey('list.table.header.creationDate'),\n defaultMessage: 'creation date',\n },\n },\n {\n name: 'updatedAt',\n label: {\n id: getTranslationKey('list.table.header.lastModified'),\n defaultMessage: 'last modified',\n },\n },\n {\n name: 'size',\n label: { id: getTranslationKey('list.table.header.size'), defaultMessage: 'size' },\n },\n {\n name: 'actions',\n label: { id: getTranslationKey('list.table.header.actions'), defaultMessage: 'actions' },\n isVisuallyHidden: true,\n },\n];\n"],"names":["localStorageKeys","view","viewOptions","GRID","TABLE","ASSET_DETAILS_TRIGGER_ATTRIBUTE","ASSET_DETAILS_TRIGGER_PROPS","ASSET_ITEM_CONTROL_ATTRIBUTE","ASSET_ITEM_CONTROL_PROPS","ASSET_ITEM_CONTROL_SELECTOR","ASSET_DETAILS_TRIGGER_SELECTOR","TABLE_HEADERS","name","label","id","getTranslationKey","defaultMessage","isVis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iBAAAA,CAAkB,2BAAA,CAAA;YAA8BC,cAAAA,EAAgB;AAAU,SAAA;QACvFC,gBAAAA,EAAkB;AACpB;;;;;"}
|
|
@@ -10,6 +10,9 @@ var getRelationId = require('../../../utils/getRelationId.js');
|
|
|
10
10
|
var mergeUploadedAssets = require('../utils/mergeUploadedAssets.js');
|
|
11
11
|
|
|
12
12
|
const PAGE_SIZE = 20;
|
|
13
|
+
/**
|
|
14
|
+
* How many list views keep their loaded pages in memory.
|
|
15
|
+
*/ const MAX_REMEMBERED_LISTS = 10;
|
|
13
16
|
/**
|
|
14
17
|
* Concatenates the pages in ascending order, one entry per asset id.
|
|
15
18
|
*
|
|
@@ -27,6 +30,10 @@ const PAGE_SIZE = 20;
|
|
|
27
30
|
...byId.values()
|
|
28
31
|
];
|
|
29
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* The highest page an accumulator holds — where the list was last read to, and
|
|
35
|
+
* so where to resume from on the way back.
|
|
36
|
+
*/ const deepestPage = (pages)=>Object.keys(pages).reduce((deepest, key)=>Math.max(deepest, Number(key)), 1);
|
|
30
37
|
/**
|
|
31
38
|
* Keeps one earlier page's `getAssets` query subscribed and reports its results
|
|
32
39
|
* back up whenever they change.
|
|
@@ -64,6 +71,10 @@ const PAGE_SIZE = 20;
|
|
|
64
71
|
* The caller MUST render the returned `subscribers` node — that is what keeps
|
|
65
72
|
* every loaded page subscribed, so `{Asset, LIST}` invalidations keep the whole
|
|
66
73
|
* list consistent rather than only the current page.
|
|
74
|
+
*
|
|
75
|
+
* Loaded pages survive navigating away and back: each list's accumulator is
|
|
76
|
+
* remembered (LRU, `MAX_REMEMBERED_LISTS`) and restored when its key returns, so
|
|
77
|
+
* stepping into a subfolder and back out keeps the rows the user scrolled for.
|
|
67
78
|
*/ const useInfiniteAssets = ({ folder = null, sort, search, filters, enabled = true } = {})=>{
|
|
68
79
|
// Derived from the request args themselves, so a new filter can't reach the
|
|
69
80
|
// API without also invalidating what was accumulated under the old one.
|
|
@@ -94,15 +105,30 @@ const PAGE_SIZE = 20;
|
|
|
94
105
|
listKey,
|
|
95
106
|
pages: {}
|
|
96
107
|
});
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
108
|
+
// Each list's loaded pages, kept across navigation away from it.
|
|
109
|
+
const memoryRef = React.useRef(new Map());
|
|
110
|
+
const isNewList = pageState.queryKey !== queryKey;
|
|
111
|
+
const remembered = isNewList ? memoryRef.current.get(queryKey) : undefined;
|
|
112
|
+
// Derived rather than read from state: the render that discovers the key
|
|
113
|
+
// change still reaches the query below, and a list with no page 1 must never
|
|
114
|
+
// be requested at page 2. A remembered list always holds page 1, so resuming
|
|
115
|
+
// at its deepest page can't skip one.
|
|
116
|
+
let page;
|
|
117
|
+
if (!isNewList) {
|
|
118
|
+
page = pageState.page;
|
|
119
|
+
} else if (remembered) {
|
|
120
|
+
page = deepestPage(remembered.pages);
|
|
121
|
+
} else {
|
|
122
|
+
page = 1;
|
|
123
|
+
}
|
|
124
|
+
if (isNewList) {
|
|
102
125
|
setPageState({
|
|
103
126
|
queryKey,
|
|
104
|
-
page
|
|
127
|
+
page
|
|
105
128
|
});
|
|
129
|
+
if (remembered) {
|
|
130
|
+
setAccumulated(remembered);
|
|
131
|
+
}
|
|
106
132
|
}
|
|
107
133
|
const { currentData, isLoading, isFetching, error, startedTimeStamp, fulfilledTimeStamp } = assets.useGetAssetsQuery({
|
|
108
134
|
...queryArgs,
|
|
@@ -115,7 +141,8 @@ const PAGE_SIZE = 20;
|
|
|
115
141
|
// `currentData` is only ever the payload for the args just passed, so it
|
|
116
142
|
// belongs to this key at this page — nothing to infer. Its reference is
|
|
117
143
|
// stable per cache entry, so this settles after one extra render.
|
|
118
|
-
if (
|
|
144
|
+
if (// A restore already set the accumulator from memory; don't overwrite it.
|
|
145
|
+
!remembered && currentData && (!isSameQuery || accumulated.pages[page] !== currentData.results)) {
|
|
119
146
|
setAccumulated(isSameQuery ? {
|
|
120
147
|
...accumulated,
|
|
121
148
|
pages: {
|
|
@@ -163,6 +190,29 @@ const PAGE_SIZE = 20;
|
|
|
163
190
|
page: earlierPage,
|
|
164
191
|
onRefreshed: handlePageRefreshed
|
|
165
192
|
})));
|
|
193
|
+
// Remember what this list has read, so leaving it isn't forgetting it. Filed
|
|
194
|
+
// under `accumulated.queryKey`, not the live `queryKey`: the accumulator names
|
|
195
|
+
// the list it belongs to, so an entry still describing the list being left
|
|
196
|
+
// can't be misfiled under the one being entered.
|
|
197
|
+
React.useEffect(()=>{
|
|
198
|
+
if (Object.keys(accumulated.pages).length === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const memory = memoryRef.current;
|
|
202
|
+
// Delete before set so the entry moves to the end. Map iterates in
|
|
203
|
+
// insertion order, so the first key is the least recently used.
|
|
204
|
+
memory.delete(accumulated.queryKey);
|
|
205
|
+
memory.set(accumulated.queryKey, accumulated);
|
|
206
|
+
while(memory.size > MAX_REMEMBERED_LISTS){
|
|
207
|
+
const oldest = memory.keys().next();
|
|
208
|
+
if (oldest.done) {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
memory.delete(oldest.value);
|
|
212
|
+
}
|
|
213
|
+
}, [
|
|
214
|
+
accumulated
|
|
215
|
+
]);
|
|
166
216
|
// Drop the left folder's cached `getAssets` pages when the folder changes.
|
|
167
217
|
//
|
|
168
218
|
// RTK Query 1.9.7 leaves a query's store subscription in place when its last
|
|
@@ -172,8 +222,9 @@ const PAGE_SIZE = 20;
|
|
|
172
222
|
// next `{Asset, LIST}` invalidation (an upload in the new folder) refetch the
|
|
173
223
|
// *previous* folder's pages: one bogus `/upload/files` request per loaded
|
|
174
224
|
// page. There is no public per-entry unsubscribe, so evict the left folder's
|
|
175
|
-
// entries outright
|
|
176
|
-
//
|
|
225
|
+
// entries outright. Returning then re-reads every page it had loaded, but the
|
|
226
|
+
// rows come straight back from the accumulator memory above — so those
|
|
227
|
+
// requests refresh a list already on screen rather than being waited on.
|
|
177
228
|
const dispatch = reactRedux.useDispatch();
|
|
178
229
|
const store = reactRedux.useStore();
|
|
179
230
|
const prevFolderRef = React.useRef(folder);
|
|
@@ -252,6 +303,10 @@ const PAGE_SIZE = 20;
|
|
|
252
303
|
listAnsweredAfter
|
|
253
304
|
]);
|
|
254
305
|
const isFetchingMore = isFetching && page > 1;
|
|
306
|
+
// A restored list already has rows on screen, so re-reading its current page
|
|
307
|
+
// is a background refresh — reporting it as loading would swap those rows for
|
|
308
|
+
// a spinner. Only an empty list has nothing better to show.
|
|
309
|
+
const isLoadingList = isChangingList || isLoading && assets$1.length === 0;
|
|
255
310
|
const fetchNextPage = React.useCallback(()=>{
|
|
256
311
|
setPageState((prev)=>({
|
|
257
312
|
queryKey,
|
|
@@ -279,7 +334,7 @@ const PAGE_SIZE = 20;
|
|
|
279
334
|
// Falls back to the accumulated total so a consumer showing the count
|
|
280
335
|
// doesn't flash zero mid-transition, matching the possibly stale `assets`.
|
|
281
336
|
pagination: currentData?.pagination ?? accumulated.pagination,
|
|
282
|
-
isLoading:
|
|
337
|
+
isLoading: isLoadingList,
|
|
283
338
|
isFetchingMore,
|
|
284
339
|
hasNextPage,
|
|
285
340
|
fetchNextPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteAssets.js","sources":["../../../../../../admin/src/future/pages/Assets/hooks/useInfiniteAssets.ts"],"sourcesContent":["import { createElement, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useDispatch, useStore } from 'react-redux';\n\nimport { uploadApi } from '../../../services/api';\nimport { useGetAssetsQuery } from '../../../services/assets';\nimport { useTypedSelector } from '../../../store/hooks';\nimport { selectCompletedUploads } from '../../../store/uploadProgress';\nimport { getRelationId } from '../../../utils/getRelationId';\nimport { mergeUploadedAssets } from '../utils/mergeUploadedAssets';\n\nimport type { File, Pagination } from '../../../../../../shared/contracts/files';\n\nconst PAGE_SIZE = 20;\n\ninterface UseInfiniteAssetsOptions {\n folder?: number | null;\n sort?: string;\n search?: string;\n /** Extra `filters[$and]` entries for the files query. */\n filters?: Record<string, unknown>[];\n /** Structural switch: an `is [folder]`-only type badge means no file can match. */\n enabled?: boolean;\n}\n\ninterface QueryArgs {\n folder: number | null;\n sort?: string;\n search?: string;\n filters?: Record<string, unknown>[];\n}\n\n/**\n * Everything loaded for one query identity.\n *\n * `queryKey` lags the live key while a new query is in flight — that lag is\n * what keeps the previous results on screen across a search change.\n */\ninterface Accumulated {\n queryKey: string;\n listKey: string;\n pages: Record<number, File[]>;\n pagination?: Pagination;\n}\n\ninterface PageState {\n queryKey: string;\n page: number;\n}\n\ntype PageRefreshedHandler = (page: number, results: File[]) => void;\n\n/**\n * Concatenates the pages in ascending order, one entry per asset id.\n *\n * `Map.set` keeps the first insertion position but takes the latest value, so\n * an asset that moved between pages after a mutation holds its place and shows\n * fresh data instead of rendering twice under a duplicate key.\n */\nconst flattenPages = (pages: Record<number, File[]>): File[] => {\n const byId = new Map<number, File>();\n\n for (const page of Object.keys(pages)\n .map(Number)\n .sort((a, b) => a - b)) {\n for (const asset of pages[page]) {\n byId.set(asset.id, asset);\n }\n }\n\n return [...byId.values()];\n};\n\n/**\n * Keeps one earlier page's `getAssets` query subscribed and reports its results\n * back up whenever they change.\n *\n * The hook itself only subscribes the current (latest) page. Without these, a\n * mutation invalidating `{Asset, LIST}` refetches that page alone and earlier\n * pages stay frozen — a rename or delete on an earlier page never reaches the\n * list until a folder/sort/search change. One subscriber per earlier\n * page keeps them all subscribed so the invalidation refetches the whole list.\n * Renders nothing; it exists only for the subscription + `onRefreshed` report.\n */\nconst PageSubscriber = ({\n queryArgs,\n page,\n onRefreshed,\n}: {\n queryArgs: QueryArgs;\n page: number;\n onRefreshed: PageRefreshedHandler;\n}) => {\n const { currentData } = useGetAssetsQuery({ ...queryArgs, page, pageSize: PAGE_SIZE });\n const results = currentData?.results;\n\n useEffect(() => {\n if (results) {\n onRefreshed(page, results);\n }\n // `results` is a stable reference per cache entry, so this only re-reports\n // when a refetch actually replaces the page's data. Reporting the same\n // reference the accumulator already holds is a no-op (see `onRefreshed`).\n }, [results, page, onRefreshed]);\n\n return null;\n};\n\n/**\n * Infinite scroll over `/upload/files`, keeping one accumulated slot per page.\n *\n * The caller MUST render the returned `subscribers` node — that is what keeps\n * every loaded page subscribed, so `{Asset, LIST}` invalidations keep the whole\n * list consistent rather than only the current page.\n */\nconst useInfiniteAssets = ({\n folder = null,\n sort,\n search,\n filters,\n enabled = true,\n}: UseInfiniteAssetsOptions = {}) => {\n // Derived from the request args themselves, so a new filter can't reach the\n // API without also invalidating what was accumulated under the old one.\n const queryArgs: QueryArgs = { folder, sort, search, filters };\n const queryKey = JSON.stringify(queryArgs);\n // Identifies the list being viewed, ignoring the search term. Folder, sort\n // and filter changes are single committed actions, so one clean reset per\n // change is honest. Search is committed per keystroke on a 300ms debounce,\n // and blanking the list on each one would strobe as the user types.\n // The cost: through the search window the previous rows stay rendered and\n // `hasNextPage` is false, so the list reads as complete until page 1 lands.\n const listKey = JSON.stringify({ folder, sort, filters });\n\n const [pageState, setPageState] = useState<PageState>({ queryKey, page: 1 });\n const [accumulated, setAccumulated] = useState<Accumulated>({ queryKey, listKey, pages: {} });\n\n // Derived rather than read straight from state: the render that discovers\n // the key change still reaches the query below, and a list with no page 1\n // must never be requested at page 2.\n const page = pageState.queryKey === queryKey ? pageState.page : 1;\n\n if (pageState.queryKey !== queryKey) {\n setPageState({ queryKey, page: 1 });\n }\n\n const { currentData, isLoading, isFetching, error, startedTimeStamp, fulfilledTimeStamp } =\n useGetAssetsQuery(\n {\n ...queryArgs,\n page,\n pageSize: PAGE_SIZE,\n },\n { skip: !enabled }\n );\n\n const isSameQuery = accumulated.queryKey === queryKey;\n\n // `currentData` is only ever the payload for the args just passed, so it\n // belongs to this key at this page — nothing to infer. Its reference is\n // stable per cache entry, so this settles after one extra render.\n if (currentData && (!isSameQuery || accumulated.pages[page] !== currentData.results)) {\n setAccumulated(\n isSameQuery\n ? {\n ...accumulated,\n pages: { ...accumulated.pages, [page]: currentData.results },\n pagination: currentData.pagination,\n }\n : {\n queryKey,\n listKey,\n pages: { [page]: currentData.results },\n pagination: currentData.pagination,\n }\n );\n }\n\n // Merges a refetched earlier page back into the accumulator. Ignores reports\n // for a superseded query, and no-ops when the reference is unchanged so a\n // subscriber re-reporting its already-stored page can't loop.\n const handlePageRefreshed = useCallback<PageRefreshedHandler>(\n (refreshedPage, results) => {\n setAccumulated((prev) => {\n if (prev.queryKey !== queryKey || prev.pages[refreshedPage] === results) {\n return prev;\n }\n\n return { ...prev, pages: { ...prev.pages, [refreshedPage]: results } };\n });\n },\n [queryKey]\n );\n\n // One subscriber per earlier page (the current page is already subscribed by\n // the query above). Keyed by queryKey so a folder/sort/search change remounts\n // them against the new args instead of reusing a stale cache entry.\n // `createElement` rather than JSX so this stays a plain `.ts` hook file.\n const subscribers = createElement(\n Fragment,\n null,\n Array.from({ length: Math.max(0, page - 1) }, (_, index) => index + 1).map((earlierPage) =>\n createElement(PageSubscriber, {\n key: `${queryKey}:${earlierPage}`,\n queryArgs,\n page: earlierPage,\n onRefreshed: handlePageRefreshed,\n })\n )\n );\n\n // Drop the left folder's cached `getAssets` pages when the folder changes.\n //\n // RTK Query 1.9.7 leaves a query's store subscription in place when its last\n // subscriber unmounts while a refetch is still in flight — e.g. a delete\n // invalidates `{Asset, LIST}`, every loaded page starts refetching, and the\n // user navigates away before those settle. Those stale subscriptions make the\n // next `{Asset, LIST}` invalidation (an upload in the new folder) refetch the\n // *previous* folder's pages: one bogus `/upload/files` request per loaded\n // page. There is no public per-entry unsubscribe, so evict the left folder's\n // entries outright — returning reloads from page 1, which the accumulator\n // already does on a list change.\n const dispatch = useDispatch();\n const store = useStore();\n const prevFolderRef = useRef(folder);\n useEffect(() => {\n const prevFolder = prevFolderRef.current;\n prevFolderRef.current = folder;\n if (prevFolder === folder) {\n return;\n }\n\n const apiState = (store.getState() as Record<string, { queries?: Record<string, unknown> }>)[\n uploadApi.reducerPath\n ];\n const removeQueryResult = (\n uploadApi as unknown as {\n internalActions: {\n removeQueryResult: (payload: { queryCacheKey: string }) => { type: string };\n };\n }\n ).internalActions.removeQueryResult;\n\n Object.keys(apiState?.queries ?? {}).forEach((cacheKey) => {\n if (!cacheKey.startsWith('getAssets(')) {\n return;\n }\n let args: { folder?: number | null };\n try {\n args = JSON.parse(cacheKey.slice('getAssets('.length, -1));\n } catch {\n return;\n }\n if (args.folder === prevFolder) {\n dispatch(removeQueryResult({ queryCacheKey: cacheKey }));\n }\n });\n }, [folder, dispatch, store]);\n\n // Until the new list's first page lands the accumulator still holds the\n // previous folder. Reported as loading so the page shows a spinner instead\n // of the outgoing folder's assets under the incoming folder's header.\n const isChangingList = accumulated.listKey !== listKey;\n\n const loadedAssets = useMemo(\n () => (isChangingList ? [] : flattenPages(accumulated.pages)),\n [isChangingList, accumulated.pages]\n );\n\n // Deliberately the live value, not the stale-tolerant one below: paging must\n // never be driven by a total that belongs to the previous query.\n const hasNextPage = currentData ? page < currentData.pagination.pageCount : false;\n\n const completedUploads = useTypedSelector(selectCompletedUploads);\n\n // Only an unfiltered, unsearched list can place an upload locally: deciding\n // whether an asset satisfies a filter means reimplementing the server's\n // filter semantics client-side. Filtered views still refresh on the\n // end-of-batch invalidation, as they did before.\n const canPlaceUploads = !search && (filters?.length ?? 0) === 0;\n\n // When the loaded data came back from a request that started after a given\n // upload — i.e. the server had already stored it when asked. Past that point\n // the list is the authority on whether the asset is there at all, so bridging\n // must stop: otherwise a later delete or move, which refetches without it,\n // would have it re-inserted.\n const listAnsweredAfter =\n fulfilledTimeStamp !== undefined &&\n startedTimeStamp !== undefined &&\n // A refetch in flight leaves `fulfilledTimeStamp` on the previous response,\n // which predates this request — so only settled data counts.\n fulfilledTimeStamp > startedTimeStamp\n ? startedTimeStamp\n : undefined;\n\n const assets = useMemo(() => {\n if (!canPlaceUploads || completedUploads.length === 0) {\n return loadedAssets;\n }\n\n const bridging = completedUploads.filter(\n ({ asset, completedAt }) =>\n getRelationId(asset.folder) === folder &&\n (listAnsweredAfter === undefined || completedAt > listAnsweredAfter)\n );\n\n return mergeUploadedAssets({\n assets: loadedAssets,\n uploaded: bridging.map(({ asset }) => asset),\n sort,\n hasNextPage,\n });\n }, [\n canPlaceUploads,\n completedUploads,\n loadedAssets,\n folder,\n sort,\n hasNextPage,\n listAnsweredAfter,\n ]);\n const isFetchingMore = isFetching && page > 1;\n\n const fetchNextPage = useCallback(() => {\n setPageState((prev) => ({\n queryKey,\n page: (prev.queryKey === queryKey ? prev.page : 1) + 1,\n }));\n }, [queryKey]);\n\n if (!enabled) {\n return {\n assets: [] as File[],\n // No list to keep fresh while disabled, so nothing to subscribe.\n subscribers: null,\n pagination: undefined,\n isLoading: false,\n isFetchingMore: false,\n hasNextPage: false,\n fetchNextPage,\n error: undefined,\n };\n }\n\n return {\n assets,\n subscribers,\n // Falls back to the accumulated total so a consumer showing the count\n // doesn't flash zero mid-transition, matching the possibly stale `assets`.\n pagination: currentData?.pagination ?? accumulated.pagination,\n isLoading: isLoading || isChangingList,\n isFetchingMore,\n hasNextPage,\n fetchNextPage,\n error,\n };\n};\n\nexport { useInfiniteAssets };\nexport { PAGE_SIZE };\n"],"names":["PAGE_SIZE","flattenPages","pages","byId","Map","page","Object","keys","map","Number","sort","a","b","asset","set","id","values","PageSubscriber","queryArgs","onRefreshed","currentData","useGetAssetsQuery","pageSize","results","useEffect","useInfiniteAssets","folder","search","filters","enabled","queryKey","JSON","stringify","listKey","pageState","setPageState","useState","accumulated","setAccumulated","isLoading","isFetching","error","startedTimeStamp","fulfilledTimeStamp","skip","isSameQuery","pagination","handlePageRefreshed","useCallback","refreshedPage","prev","subscribers","createElement","Fragment","Array","from","length","Math","max","_","index","earlierPage","key","dispatch","useDispatch","store","useStore","prevFolderRef","useRef","prevFolder","current","apiState","getState","uploadApi","reducerPath","removeQueryResult","internalActions","queries","forEach","cacheKey","startsWith","args","parse","slice","queryCacheKey","isChangingList","loadedAssets","useMemo","hasNextPage","pageCount","completedUploads","useTypedSelector","selectCompletedUploads","canPlaceUploads","listAnsweredAfter","undefined","assets","bridging","filter","completedAt","getRelationId","mergeUploadedAssets","uploaded","isFetchingMore","fetchNextPage"],"mappings":";;;;;;;;;;;AAaA,MAAMA,SAAAA,GAAY;AAuClB;;;;;;IAOA,MAAMC,eAAe,CAACC,KAAAA,GAAAA;AACpB,IAAA,MAAMC,OAAO,IAAIC,GAAAA,EAAAA;AAEjB,IAAA,KAAK,MAAMC,IAAAA,IAAQC,MAAAA,CAAOC,IAAI,CAACL,KAAAA,CAAAA,CAC5BM,GAAG,CAACC,MAAAA,CAAAA,CACJC,IAAI,CAAC,CAACC,CAAAA,EAAGC,CAAAA,GAAMD,IAAIC,CAAAA,CAAAA,CAAI;AACxB,QAAA,KAAK,MAAMC,KAAAA,IAASX,KAAK,CAACG,KAAK,CAAE;AAC/BF,YAAAA,IAAAA,CAAKW,GAAG,CAACD,KAAAA,CAAME,EAAE,EAAEF,KAAAA,CAAAA;AACrB,QAAA;AACF,IAAA;IAEA,OAAO;AAAIV,QAAAA,GAAAA,IAAAA,CAAKa,MAAM;AAAG,KAAA;AAC3B,CAAA;AAEA;;;;;;;;;;IAWA,MAAMC,iBAAiB,CAAC,EACtBC,SAAS,EACTb,IAAI,EACJc,WAAW,EAKZ,GAAA;AACC,IAAA,MAAM,EAAEC,WAAW,EAAE,GAAGC,wBAAAA,CAAkB;AAAE,QAAA,GAAGH,SAAS;AAAEb,QAAAA,IAAAA;QAAMiB,QAAAA,EAAUtB;AAAU,KAAA,CAAA;AACpF,IAAA,MAAMuB,UAAUH,WAAAA,EAAaG,OAAAA;IAE7BC,eAAAA,CAAU,IAAA;AACR,QAAA,IAAID,OAAAA,EAAS;AACXJ,YAAAA,WAAAA,CAAYd,IAAAA,EAAMkB,OAAAA,CAAAA;AACpB,QAAA;;;;IAIF,CAAA,EAAG;AAACA,QAAAA,OAAAA;AAASlB,QAAAA,IAAAA;AAAMc,QAAAA;AAAY,KAAA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AAa,IAAA;YACbL,UAAAA,EAAYiD,SAAAA;YACZxD,SAAAA,EAAW,KAAA;YACXgE,cAAAA,EAAgB,KAAA;YAChBf,WAAAA,EAAa,KAAA;AACbgB,YAAAA,aAAAA;YACA/D,KAAAA,EAAOsD;AACT,SAAA;AACF,IAAA;IAEA,OAAO;AACLC,gBAAAA,QAAAA;AACA7C,QAAAA,WAAAA;;;QAGAL,UAAAA,EAAY1B,WAAAA,EAAa0B,UAAAA,IAAcT,WAAAA,CAAYS,UAAU;AAC7DP,QAAAA,SAAAA,EAAWA,SAAAA,IAAa8C,cAAAA;AACxBkB,QAAAA,cAAAA;AACAf,QAAAA,WAAAA;AACAgB,QAAAA,aAAAA;AACA/D,QAAAA;AACF,KAAA;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"useInfiniteAssets.js","sources":["../../../../../../admin/src/future/pages/Assets/hooks/useInfiniteAssets.ts"],"sourcesContent":["import { createElement, Fragment, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useDispatch, useStore } from 'react-redux';\n\nimport { uploadApi } from '../../../services/api';\nimport { useGetAssetsQuery } from '../../../services/assets';\nimport { useTypedSelector } from '../../../store/hooks';\nimport { selectCompletedUploads } from '../../../store/uploadProgress';\nimport { getRelationId } from '../../../utils/getRelationId';\nimport { mergeUploadedAssets } from '../utils/mergeUploadedAssets';\n\nimport type { File, Pagination } from '../../../../../../shared/contracts/files';\n\nconst PAGE_SIZE = 20;\n\n/**\n * How many list views keep their loaded pages in memory.\n */\nconst MAX_REMEMBERED_LISTS = 10;\n\ninterface UseInfiniteAssetsOptions {\n folder?: number | null;\n sort?: string;\n search?: string;\n /** Extra `filters[$and]` entries for the files query. */\n filters?: Record<string, unknown>[];\n /** Structural switch: an `is [folder]`-only type badge means no file can match. */\n enabled?: boolean;\n}\n\ninterface QueryArgs {\n folder: number | null;\n sort?: string;\n search?: string;\n filters?: Record<string, unknown>[];\n}\n\n/**\n * Everything loaded for one query identity.\n *\n * `queryKey` lags the live key while a new query is in flight — that lag is\n * what keeps the previous results on screen across a search change.\n */\ninterface Accumulated {\n queryKey: string;\n listKey: string;\n pages: Record<number, File[]>;\n pagination?: Pagination;\n}\n\ninterface PageState {\n queryKey: string;\n page: number;\n}\n\ntype PageRefreshedHandler = (page: number, results: File[]) => void;\n\n/**\n * Concatenates the pages in ascending order, one entry per asset id.\n *\n * `Map.set` keeps the first insertion position but takes the latest value, so\n * an asset that moved between pages after a mutation holds its place and shows\n * fresh data instead of rendering twice under a duplicate key.\n */\nconst flattenPages = (pages: Record<number, File[]>): File[] => {\n const byId = new Map<number, File>();\n\n for (const page of Object.keys(pages)\n .map(Number)\n .sort((a, b) => a - b)) {\n for (const asset of pages[page]) {\n byId.set(asset.id, asset);\n }\n }\n\n return [...byId.values()];\n};\n\n/**\n * The highest page an accumulator holds — where the list was last read to, and\n * so where to resume from on the way back.\n */\nconst deepestPage = (pages: Record<number, File[]>): number =>\n Object.keys(pages).reduce((deepest, key) => Math.max(deepest, Number(key)), 1);\n\n/**\n * Keeps one earlier page's `getAssets` query subscribed and reports its results\n * back up whenever they change.\n *\n * The hook itself only subscribes the current (latest) page. Without these, a\n * mutation invalidating `{Asset, LIST}` refetches that page alone and earlier\n * pages stay frozen — a rename or delete on an earlier page never reaches the\n * list until a folder/sort/search change. One subscriber per earlier\n * page keeps them all subscribed so the invalidation refetches the whole list.\n * Renders nothing; it exists only for the subscription + `onRefreshed` report.\n */\nconst PageSubscriber = ({\n queryArgs,\n page,\n onRefreshed,\n}: {\n queryArgs: QueryArgs;\n page: number;\n onRefreshed: PageRefreshedHandler;\n}) => {\n const { currentData } = useGetAssetsQuery({ ...queryArgs, page, pageSize: PAGE_SIZE });\n const results = currentData?.results;\n\n useEffect(() => {\n if (results) {\n onRefreshed(page, results);\n }\n // `results` is a stable reference per cache entry, so this only re-reports\n // when a refetch actually replaces the page's data. Reporting the same\n // reference the accumulator already holds is a no-op (see `onRefreshed`).\n }, [results, page, onRefreshed]);\n\n return null;\n};\n\n/**\n * Infinite scroll over `/upload/files`, keeping one accumulated slot per page.\n *\n * The caller MUST render the returned `subscribers` node — that is what keeps\n * every loaded page subscribed, so `{Asset, LIST}` invalidations keep the whole\n * list consistent rather than only the current page.\n *\n * Loaded pages survive navigating away and back: each list's accumulator is\n * remembered (LRU, `MAX_REMEMBERED_LISTS`) and restored when its key returns, so\n * stepping into a subfolder and back out keeps the rows the user scrolled for.\n */\nconst useInfiniteAssets = ({\n folder = null,\n sort,\n search,\n filters,\n enabled = true,\n}: UseInfiniteAssetsOptions = {}) => {\n // Derived from the request args themselves, so a new filter can't reach the\n // API without also invalidating what was accumulated under the old one.\n const queryArgs: QueryArgs = { folder, sort, search, filters };\n const queryKey = JSON.stringify(queryArgs);\n // Identifies the list being viewed, ignoring the search term. Folder, sort\n // and filter changes are single committed actions, so one clean reset per\n // change is honest. Search is committed per keystroke on a 300ms debounce,\n // and blanking the list on each one would strobe as the user types.\n // The cost: through the search window the previous rows stay rendered and\n // `hasNextPage` is false, so the list reads as complete until page 1 lands.\n const listKey = JSON.stringify({ folder, sort, filters });\n\n const [pageState, setPageState] = useState<PageState>({ queryKey, page: 1 });\n const [accumulated, setAccumulated] = useState<Accumulated>({ queryKey, listKey, pages: {} });\n\n // Each list's loaded pages, kept across navigation away from it.\n const memoryRef = useRef(new Map<string, Accumulated>());\n\n const isNewList = pageState.queryKey !== queryKey;\n\n const remembered = isNewList ? memoryRef.current.get(queryKey) : undefined;\n\n // Derived rather than read from state: the render that discovers the key\n // change still reaches the query below, and a list with no page 1 must never\n // be requested at page 2. A remembered list always holds page 1, so resuming\n // at its deepest page can't skip one.\n let page: number;\n if (!isNewList) {\n page = pageState.page;\n } else if (remembered) {\n page = deepestPage(remembered.pages);\n } else {\n page = 1;\n }\n\n if (isNewList) {\n setPageState({ queryKey, page });\n\n if (remembered) {\n setAccumulated(remembered);\n }\n }\n\n const { currentData, isLoading, isFetching, error, startedTimeStamp, fulfilledTimeStamp } =\n useGetAssetsQuery(\n {\n ...queryArgs,\n page,\n pageSize: PAGE_SIZE,\n },\n { skip: !enabled }\n );\n\n const isSameQuery = accumulated.queryKey === queryKey;\n\n // `currentData` is only ever the payload for the args just passed, so it\n // belongs to this key at this page — nothing to infer. Its reference is\n // stable per cache entry, so this settles after one extra render.\n if (\n // A restore already set the accumulator from memory; don't overwrite it.\n !remembered &&\n currentData &&\n (!isSameQuery || accumulated.pages[page] !== currentData.results)\n ) {\n setAccumulated(\n isSameQuery\n ? {\n ...accumulated,\n pages: { ...accumulated.pages, [page]: currentData.results },\n pagination: currentData.pagination,\n }\n : {\n queryKey,\n listKey,\n pages: { [page]: currentData.results },\n pagination: currentData.pagination,\n }\n );\n }\n\n // Merges a refetched earlier page back into the accumulator. Ignores reports\n // for a superseded query, and no-ops when the reference is unchanged so a\n // subscriber re-reporting its already-stored page can't loop.\n const handlePageRefreshed = useCallback<PageRefreshedHandler>(\n (refreshedPage, results) => {\n setAccumulated((prev) => {\n if (prev.queryKey !== queryKey || prev.pages[refreshedPage] === results) {\n return prev;\n }\n\n return { ...prev, pages: { ...prev.pages, [refreshedPage]: results } };\n });\n },\n [queryKey]\n );\n\n // One subscriber per earlier page (the current page is already subscribed by\n // the query above). Keyed by queryKey so a folder/sort/search change remounts\n // them against the new args instead of reusing a stale cache entry.\n // `createElement` rather than JSX so this stays a plain `.ts` hook file.\n const subscribers = createElement(\n Fragment,\n null,\n Array.from({ length: Math.max(0, page - 1) }, (_, index) => index + 1).map((earlierPage) =>\n createElement(PageSubscriber, {\n key: `${queryKey}:${earlierPage}`,\n queryArgs,\n page: earlierPage,\n onRefreshed: handlePageRefreshed,\n })\n )\n );\n\n // Remember what this list has read, so leaving it isn't forgetting it. Filed\n // under `accumulated.queryKey`, not the live `queryKey`: the accumulator names\n // the list it belongs to, so an entry still describing the list being left\n // can't be misfiled under the one being entered.\n useEffect(() => {\n if (Object.keys(accumulated.pages).length === 0) {\n return;\n }\n\n const memory = memoryRef.current;\n // Delete before set so the entry moves to the end. Map iterates in\n // insertion order, so the first key is the least recently used.\n memory.delete(accumulated.queryKey);\n memory.set(accumulated.queryKey, accumulated);\n\n while (memory.size > MAX_REMEMBERED_LISTS) {\n const oldest = memory.keys().next();\n\n if (oldest.done) {\n break;\n }\n\n memory.delete(oldest.value);\n }\n }, [accumulated]);\n\n // Drop the left folder's cached `getAssets` pages when the folder changes.\n //\n // RTK Query 1.9.7 leaves a query's store subscription in place when its last\n // subscriber unmounts while a refetch is still in flight — e.g. a delete\n // invalidates `{Asset, LIST}`, every loaded page starts refetching, and the\n // user navigates away before those settle. Those stale subscriptions make the\n // next `{Asset, LIST}` invalidation (an upload in the new folder) refetch the\n // *previous* folder's pages: one bogus `/upload/files` request per loaded\n // page. There is no public per-entry unsubscribe, so evict the left folder's\n // entries outright. Returning then re-reads every page it had loaded, but the\n // rows come straight back from the accumulator memory above — so those\n // requests refresh a list already on screen rather than being waited on.\n const dispatch = useDispatch();\n const store = useStore();\n const prevFolderRef = useRef(folder);\n useEffect(() => {\n const prevFolder = prevFolderRef.current;\n prevFolderRef.current = folder;\n if (prevFolder === folder) {\n return;\n }\n\n const apiState = (store.getState() as Record<string, { queries?: Record<string, unknown> }>)[\n uploadApi.reducerPath\n ];\n const removeQueryResult = (\n uploadApi as unknown as {\n internalActions: {\n removeQueryResult: (payload: { queryCacheKey: string }) => { type: string };\n };\n }\n ).internalActions.removeQueryResult;\n\n Object.keys(apiState?.queries ?? {}).forEach((cacheKey) => {\n if (!cacheKey.startsWith('getAssets(')) {\n return;\n }\n let args: { folder?: number | null };\n try {\n args = JSON.parse(cacheKey.slice('getAssets('.length, -1));\n } catch {\n return;\n }\n if (args.folder === prevFolder) {\n dispatch(removeQueryResult({ queryCacheKey: cacheKey }));\n }\n });\n }, [folder, dispatch, store]);\n\n // Until the new list's first page lands the accumulator still holds the\n // previous folder. Reported as loading so the page shows a spinner instead\n // of the outgoing folder's assets under the incoming folder's header.\n const isChangingList = accumulated.listKey !== listKey;\n\n const loadedAssets = useMemo(\n () => (isChangingList ? [] : flattenPages(accumulated.pages)),\n [isChangingList, accumulated.pages]\n );\n\n // Deliberately the live value, not the stale-tolerant one below: paging must\n // never be driven by a total that belongs to the previous query.\n const hasNextPage = currentData ? page < currentData.pagination.pageCount : false;\n\n const completedUploads = useTypedSelector(selectCompletedUploads);\n\n // Only an unfiltered, unsearched list can place an upload locally: deciding\n // whether an asset satisfies a filter means reimplementing the server's\n // filter semantics client-side. Filtered views still refresh on the\n // end-of-batch invalidation, as they did before.\n const canPlaceUploads = !search && (filters?.length ?? 0) === 0;\n\n // When the loaded data came back from a request that started after a given\n // upload — i.e. the server had already stored it when asked. Past that point\n // the list is the authority on whether the asset is there at all, so bridging\n // must stop: otherwise a later delete or move, which refetches without it,\n // would have it re-inserted.\n const listAnsweredAfter =\n fulfilledTimeStamp !== undefined &&\n startedTimeStamp !== undefined &&\n // A refetch in flight leaves `fulfilledTimeStamp` on the previous response,\n // which predates this request — so only settled data counts.\n fulfilledTimeStamp > startedTimeStamp\n ? startedTimeStamp\n : undefined;\n\n const assets = useMemo(() => {\n if (!canPlaceUploads || completedUploads.length === 0) {\n return loadedAssets;\n }\n\n const bridging = completedUploads.filter(\n ({ asset, completedAt }) =>\n getRelationId(asset.folder) === folder &&\n (listAnsweredAfter === undefined || completedAt > listAnsweredAfter)\n );\n\n return mergeUploadedAssets({\n assets: loadedAssets,\n uploaded: bridging.map(({ asset }) => asset),\n sort,\n hasNextPage,\n });\n }, [\n canPlaceUploads,\n completedUploads,\n loadedAssets,\n folder,\n sort,\n hasNextPage,\n listAnsweredAfter,\n ]);\n const isFetchingMore = isFetching && page > 1;\n\n // A restored list already has rows on screen, so re-reading its current page\n // is a background refresh — reporting it as loading would swap those rows for\n // a spinner. Only an empty list has nothing better to show.\n const isLoadingList = isChangingList || (isLoading && assets.length === 0);\n\n const fetchNextPage = useCallback(() => {\n setPageState((prev) => ({\n queryKey,\n page: (prev.queryKey === queryKey ? prev.page : 1) + 1,\n }));\n }, [queryKey]);\n\n if (!enabled) {\n return {\n assets: [] as File[],\n // No list to keep fresh while disabled, so nothing to subscribe.\n subscribers: null,\n pagination: undefined,\n isLoading: false,\n isFetchingMore: false,\n hasNextPage: false,\n fetchNextPage,\n error: undefined,\n };\n }\n\n return {\n assets,\n subscribers,\n // Falls back to the accumulated total so a consumer showing the count\n // doesn't flash zero mid-transition, matching the possibly stale `assets`.\n pagination: currentData?.pagination ?? accumulated.pagination,\n isLoading: isLoadingList,\n isFetchingMore,\n hasNextPage,\n fetchNextPage,\n error,\n };\n};\n\nexport { useInfiniteAssets };\nexport { PAGE_SIZE };\n"],"names":["PAGE_SIZE","MAX_REMEMBERED_LISTS","flattenPages","pages","byId","Map","page","Object","keys","map","Number","sort","a","b","asset","set","id","values","deepestPage","reduce","deepest","key","Math","max","PageSubscriber","queryArgs","onRefreshed","currentData","useGetAssetsQuery","pageSize","results","useEffect","useInfiniteAssets","folder","search","filters","enabled","queryKey","JSON","stringify","listKey","pageState","setPageState","useState","accumulated","setAccumulated","memoryRef","useRef","isNewList","remembered","current","get","undefined","isLoading","isFetching","error","startedTimeStamp","fulfilledTimeStamp","skip","isSameQuery","pagination","handlePageRefreshed","useCallback","refreshedPage","prev","subscribers","createElement","Fragment","Array","from","length","_","index","earlierPage","memory","delete","size","oldest","next","done","value","dispatch","useDispatch","store","useStore","prevFolderRef","prevFolder","apiState","getState","uploadApi","reducerPath","removeQueryResult","internalActions","queries","forEach","cacheKey","startsWith","args","parse","slice","queryCacheKey","isChangingList","loadedAssets","useMemo","hasNextPage","pageCount","completedUploads","useTypedSelector","selectCompletedUploads","canPlaceUploads","listAnsweredAfter","assets","bridging","filter","completedAt","getRelationId","mergeUploadedAssets","uploaded","isFetchingMore","isLoadingList","fetchNextPage"],"mappings":";;;;;;;;;;;AAaA,MAAMA,SAAAA,GAAY;AAElB;;AAEC,IACD,MAAMC,oBAAAA,GAAuB,EAAA;AAuC7B;;;;;;IAOA,MAAMC,eAAe,CAACC,KAAAA,GAAAA;A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