node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,321 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
var styledComponents = require('styled-components');
var useAssets = require('../../hooks/useAssets.js');
var useFolders = require('../../hooks/useFolders.js');
var useMediaLibraryPermissions = require('../../hooks/useMediaLibraryPermissions.js');
var useModalQueryParams = require('../../hooks/useModalQueryParams.js');
var useSelectionState = require('../../hooks/useSelectionState.js');
var containsAssetFilter = require('../../utils/containsAssetFilter.js');
require('byte-size');
require('date-fns');
var getAllowedFiles = require('../../utils/getAllowedFiles.js');
var getTrad = require('../../utils/getTrad.js');
require('qs');
var moveElement = require('../../utils/moveElement.js');
require('../../constants.js');
require('../../utils/urlYupSchema.js');
var EditAssetContent = require('../EditAssetDialog/EditAssetContent.js');
var EditFolderDialog = require('../EditFolderDialog/EditFolderDialog.js');
var BrowseStep = require('./BrowseStep/BrowseStep.js');
var DialogFooter = require('./DialogFooter.js');
var SelectedStep = require('./SelectedStep/SelectedStep.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
// TODO: find a better naming convention for the file that was an index file before
const LoadingBody = styledComponents.styled(designSystem.Flex)`
/* 80px are coming from the Tabs component that is not included in the ModalBody */
min-height: ${()=>`calc(60vh + 8rem)`};
`;
const AssetContent = ({ allowedTypes = [], folderId = null, onClose, onAddAsset, onAddFolder, onChangeFolder, onValidate, multiple = false, initiallySelectedAssets = [], trackedLocation })=>{
const [assetToEdit, setAssetToEdit] = React__namespace.useState(undefined);
const [folderToEdit, setFolderToEdit] = React__namespace.useState(undefined);
const { formatMessage } = reactIntl.useIntl();
const { canRead, canCreate, isLoading: isLoadingPermissions, canUpdate, canCopyLink, canDownload } = useMediaLibraryPermissions.useMediaLibraryPermissions();
const [{ queryObject }, { onChangeFilters, onChangePage, onChangePageSize, onChangeSort, onChangeSearch, onChangeFolder: onChangeFolderParam }] = useModalQueryParams.useModalQueryParams({
folder: folderId
});
const { data: { pagination, results: assets } = {}, isLoading: isLoadingAssets, error: errorAssets } = useAssets.useAssets({
skipWhen: !canRead,
query: queryObject
});
const { data: folders, isLoading: isLoadingFolders, error: errorFolders } = useFolders.useFolders({
enabled: canRead && !containsAssetFilter.containsAssetFilter(queryObject) && pagination?.page === 1,
query: queryObject
});
const [selectedAssets, { selectOne, selectOnly, setSelections, selectMultiple, deselectMultiple }] = useSelectionState.useSelectionState([
'id'
], initiallySelectedAssets);
const handleSelectAllAssets = ()=>{
const allowedAssets = getAllowedFiles.getAllowedFiles(allowedTypes, assets);
if (!multiple) {
return undefined;
}
// selected files in current folder
const alreadySelected = allowedAssets.filter((asset)=>selectedAssets.findIndex((selectedAsset)=>selectedAsset.id === asset.id) !== -1);
if (alreadySelected.length > 0) {
deselectMultiple(alreadySelected);
} else {
selectMultiple(allowedAssets);
}
};
const handleSelectAsset = (asset)=>{
return multiple ? selectOne(asset) : selectOnly(asset);
};
const isLoading = isLoadingPermissions || isLoadingAssets || isLoadingFolders;
const hasError = errorAssets || errorFolders;
if (isLoading) {
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: formatMessage({
id: getTrad.getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(LoadingBody, {
justifyContent: "center",
paddingTop: 4,
paddingBottom: 4,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Loader, {
children: formatMessage({
id: getTrad.getTrad('content.isLoading'),
defaultMessage: 'Content is loading.'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(DialogFooter.DialogFooter, {
onClose: onClose
})
]
});
}
if (hasError) {
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: formatMessage({
id: getTrad.getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.Error, {}),
/*#__PURE__*/ jsxRuntime.jsx(DialogFooter.DialogFooter, {
onClose: onClose
})
]
});
}
if (!canRead) {
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: formatMessage({
id: getTrad.getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.Page.NoPermissions, {}),
/*#__PURE__*/ jsxRuntime.jsx(DialogFooter.DialogFooter, {
onClose: onClose
})
]
});
}
if (assetToEdit) {
return /*#__PURE__*/ jsxRuntime.jsx(EditAssetContent.EditAssetContent, {
onClose: ()=>setAssetToEdit(undefined),
asset: assetToEdit,
canUpdate: canUpdate,
canCopyLink: canCopyLink,
canDownload: canDownload,
trackedLocation: trackedLocation
});
}
if (folderToEdit) {
return /*#__PURE__*/ jsxRuntime.jsx(EditFolderDialog.EditFolderContent, {
folder: folderToEdit,
onClose: ()=>setFolderToEdit(undefined),
location: "content-manager",
parentFolderId: queryObject?.folder
});
}
const handleMoveItem = (hoverIndex, destIndex)=>{
const offset = destIndex - hoverIndex;
const orderedAssetsClone = selectedAssets.slice();
const nextAssets = moveElement.moveElement(orderedAssetsClone, hoverIndex, offset);
setSelections(nextAssets);
};
const handleFolderChange = (folderId, folderPath)=>{
onChangeFolder(folderId);
if (onChangeFolderParam) {
onChangeFolderParam(folderId, folderPath);
}
};
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: formatMessage({
id: getTrad.getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(TabsRoot, {
variant: "simple",
defaultValue: selectedAssets.length > 0 ? 'selected' : 'browse',
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
paddingLeft: 8,
paddingRight: 8,
paddingTop: 6,
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tabs.List, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Trigger, {
value: "browse",
children: formatMessage({
id: getTrad.getTrad('modal.nav.browse'),
defaultMessage: 'Browse'
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tabs.Trigger, {
value: "selected",
children: [
formatMessage({
id: getTrad.getTrad('modal.header.select-files'),
defaultMessage: 'Selected files'
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Badge, {
marginLeft: 2,
children: selectedAssets.length
})
]
})
]
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "secondary",
onClick: ()=>onAddFolder({
folderId: queryObject?.folder
}),
children: formatMessage({
id: getTrad.getTrad('modal.upload-list.sub-header.add-folder'),
defaultMessage: 'Add folder'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
onClick: ()=>onAddAsset({
folderId: queryObject?.folder
}),
children: formatMessage({
id: getTrad.getTrad('modal.upload-list.sub-header.button'),
defaultMessage: 'Add more assets'
})
})
]
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Divider, {}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Body, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
value: "browse",
children: /*#__PURE__*/ jsxRuntime.jsx(BrowseStep.BrowseStep, {
allowedTypes: allowedTypes,
assets: assets,
canCreate: canCreate,
canRead: canRead,
folders: folders,
onSelectAsset: handleSelectAsset,
selectedAssets: selectedAssets,
multiple: multiple,
onSelectAllAsset: handleSelectAllAssets,
onEditAsset: setAssetToEdit,
onEditFolder: setFolderToEdit,
pagination: pagination,
queryObject: queryObject,
onAddAsset: onAddAsset,
onChangeFilters: (filters)=>onChangeFilters(filters),
onChangeFolder: handleFolderChange,
onChangePage: onChangePage,
onChangePageSize: onChangePageSize,
onChangeSort: (sort)=>onChangeSort(sort),
onChangeSearch: onChangeSearch
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Tabs.Content, {
value: "selected",
children: /*#__PURE__*/ jsxRuntime.jsx(SelectedStep.SelectedStep, {
selectedAssets: selectedAssets,
onSelectAsset: handleSelectAsset,
onReorderAsset: handleMoveItem
})
})
]
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(DialogFooter.DialogFooter, {
onClose: onClose,
onValidate: ()=>onValidate(selectedAssets)
})
]
});
};
const AssetDialog = ({ open = false, onClose, ...restProps })=>{
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Root, {
open: open,
onOpenChange: onClose,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Content, {
children: /*#__PURE__*/ jsxRuntime.jsx(AssetContent, {
onClose: onClose,
...restProps
})
})
});
};
const TabsRoot = styledComponents.styled(designSystem.Tabs.Root)`
display: flex;
flex-direction: column;
overflow: hidden;
`;
exports.AssetContent = AssetContent;
exports.AssetDialog = AssetDialog;
//# sourceMappingURL=AssetDialog.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,299 @@
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import * as React from 'react';
import { Page } from '@strapi/admin/strapi-admin';
import { Flex, Tabs, Modal, Loader, Badge, Button, Divider } from '@strapi/design-system';
import { useIntl } from 'react-intl';
import { styled } from 'styled-components';
import { useAssets } from '../../hooks/useAssets.mjs';
import { useFolders } from '../../hooks/useFolders.mjs';
import { useMediaLibraryPermissions } from '../../hooks/useMediaLibraryPermissions.mjs';
import { useModalQueryParams } from '../../hooks/useModalQueryParams.mjs';
import { useSelectionState } from '../../hooks/useSelectionState.mjs';
import { containsAssetFilter } from '../../utils/containsAssetFilter.mjs';
import 'byte-size';
import 'date-fns';
import { getAllowedFiles } from '../../utils/getAllowedFiles.mjs';
import { getTrad } from '../../utils/getTrad.mjs';
import 'qs';
import { moveElement } from '../../utils/moveElement.mjs';
import '../../constants.mjs';
import '../../utils/urlYupSchema.mjs';
import { EditAssetContent } from '../EditAssetDialog/EditAssetContent.mjs';
import { EditFolderContent } from '../EditFolderDialog/EditFolderDialog.mjs';
import { BrowseStep } from './BrowseStep/BrowseStep.mjs';
import { DialogFooter } from './DialogFooter.mjs';
import { SelectedStep } from './SelectedStep/SelectedStep.mjs';
// TODO: find a better naming convention for the file that was an index file before
const LoadingBody = styled(Flex)`
/* 80px are coming from the Tabs component that is not included in the ModalBody */
min-height: ${()=>`calc(60vh + 8rem)`};
`;
const AssetContent = ({ allowedTypes = [], folderId = null, onClose, onAddAsset, onAddFolder, onChangeFolder, onValidate, multiple = false, initiallySelectedAssets = [], trackedLocation })=>{
const [assetToEdit, setAssetToEdit] = React.useState(undefined);
const [folderToEdit, setFolderToEdit] = React.useState(undefined);
const { formatMessage } = useIntl();
const { canRead, canCreate, isLoading: isLoadingPermissions, canUpdate, canCopyLink, canDownload } = useMediaLibraryPermissions();
const [{ queryObject }, { onChangeFilters, onChangePage, onChangePageSize, onChangeSort, onChangeSearch, onChangeFolder: onChangeFolderParam }] = useModalQueryParams({
folder: folderId
});
const { data: { pagination, results: assets } = {}, isLoading: isLoadingAssets, error: errorAssets } = useAssets({
skipWhen: !canRead,
query: queryObject
});
const { data: folders, isLoading: isLoadingFolders, error: errorFolders } = useFolders({
enabled: canRead && !containsAssetFilter(queryObject) && pagination?.page === 1,
query: queryObject
});
const [selectedAssets, { selectOne, selectOnly, setSelections, selectMultiple, deselectMultiple }] = useSelectionState([
'id'
], initiallySelectedAssets);
const handleSelectAllAssets = ()=>{
const allowedAssets = getAllowedFiles(allowedTypes, assets);
if (!multiple) {
return undefined;
}
// selected files in current folder
const alreadySelected = allowedAssets.filter((asset)=>selectedAssets.findIndex((selectedAsset)=>selectedAsset.id === asset.id) !== -1);
if (alreadySelected.length > 0) {
deselectMultiple(alreadySelected);
} else {
selectMultiple(allowedAssets);
}
};
const handleSelectAsset = (asset)=>{
return multiple ? selectOne(asset) : selectOnly(asset);
};
const isLoading = isLoadingPermissions || isLoadingAssets || isLoadingFolders;
const hasError = errorAssets || errorFolders;
if (isLoading) {
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsx(Modal.Title, {
children: formatMessage({
id: getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsx(LoadingBody, {
justifyContent: "center",
paddingTop: 4,
paddingBottom: 4,
children: /*#__PURE__*/ jsx(Loader, {
children: formatMessage({
id: getTrad('content.isLoading'),
defaultMessage: 'Content is loading.'
})
})
}),
/*#__PURE__*/ jsx(DialogFooter, {
onClose: onClose
})
]
});
}
if (hasError) {
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsx(Modal.Title, {
children: formatMessage({
id: getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsx(Page.Error, {}),
/*#__PURE__*/ jsx(DialogFooter, {
onClose: onClose
})
]
});
}
if (!canRead) {
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsx(Modal.Title, {
children: formatMessage({
id: getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsx(Page.NoPermissions, {}),
/*#__PURE__*/ jsx(DialogFooter, {
onClose: onClose
})
]
});
}
if (assetToEdit) {
return /*#__PURE__*/ jsx(EditAssetContent, {
onClose: ()=>setAssetToEdit(undefined),
asset: assetToEdit,
canUpdate: canUpdate,
canCopyLink: canCopyLink,
canDownload: canDownload,
trackedLocation: trackedLocation
});
}
if (folderToEdit) {
return /*#__PURE__*/ jsx(EditFolderContent, {
folder: folderToEdit,
onClose: ()=>setFolderToEdit(undefined),
location: "content-manager",
parentFolderId: queryObject?.folder
});
}
const handleMoveItem = (hoverIndex, destIndex)=>{
const offset = destIndex - hoverIndex;
const orderedAssetsClone = selectedAssets.slice();
const nextAssets = moveElement(orderedAssetsClone, hoverIndex, offset);
setSelections(nextAssets);
};
const handleFolderChange = (folderId, folderPath)=>{
onChangeFolder(folderId);
if (onChangeFolderParam) {
onChangeFolderParam(folderId, folderPath);
}
};
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsx(Modal.Title, {
children: formatMessage({
id: getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
})
}),
/*#__PURE__*/ jsxs(TabsRoot, {
variant: "simple",
defaultValue: selectedAssets.length > 0 ? 'selected' : 'browse',
children: [
/*#__PURE__*/ jsxs(Flex, {
paddingLeft: 8,
paddingRight: 8,
paddingTop: 6,
justifyContent: "space-between",
children: [
/*#__PURE__*/ jsxs(Tabs.List, {
children: [
/*#__PURE__*/ jsx(Tabs.Trigger, {
value: "browse",
children: formatMessage({
id: getTrad('modal.nav.browse'),
defaultMessage: 'Browse'
})
}),
/*#__PURE__*/ jsxs(Tabs.Trigger, {
value: "selected",
children: [
formatMessage({
id: getTrad('modal.header.select-files'),
defaultMessage: 'Selected files'
}),
/*#__PURE__*/ jsx(Badge, {
marginLeft: 2,
children: selectedAssets.length
})
]
})
]
}),
/*#__PURE__*/ jsxs(Flex, {
gap: 2,
children: [
/*#__PURE__*/ jsx(Button, {
variant: "secondary",
onClick: ()=>onAddFolder({
folderId: queryObject?.folder
}),
children: formatMessage({
id: getTrad('modal.upload-list.sub-header.add-folder'),
defaultMessage: 'Add folder'
})
}),
/*#__PURE__*/ jsx(Button, {
onClick: ()=>onAddAsset({
folderId: queryObject?.folder
}),
children: formatMessage({
id: getTrad('modal.upload-list.sub-header.button'),
defaultMessage: 'Add more assets'
})
})
]
})
]
}),
/*#__PURE__*/ jsx(Divider, {}),
/*#__PURE__*/ jsxs(Modal.Body, {
children: [
/*#__PURE__*/ jsx(Tabs.Content, {
value: "browse",
children: /*#__PURE__*/ jsx(BrowseStep, {
allowedTypes: allowedTypes,
assets: assets,
canCreate: canCreate,
canRead: canRead,
folders: folders,
onSelectAsset: handleSelectAsset,
selectedAssets: selectedAssets,
multiple: multiple,
onSelectAllAsset: handleSelectAllAssets,
onEditAsset: setAssetToEdit,
onEditFolder: setFolderToEdit,
pagination: pagination,
queryObject: queryObject,
onAddAsset: onAddAsset,
onChangeFilters: (filters)=>onChangeFilters(filters),
onChangeFolder: handleFolderChange,
onChangePage: onChangePage,
onChangePageSize: onChangePageSize,
onChangeSort: (sort)=>onChangeSort(sort),
onChangeSearch: onChangeSearch
})
}),
/*#__PURE__*/ jsx(Tabs.Content, {
value: "selected",
children: /*#__PURE__*/ jsx(SelectedStep, {
selectedAssets: selectedAssets,
onSelectAsset: handleSelectAsset,
onReorderAsset: handleMoveItem
})
})
]
})
]
}),
/*#__PURE__*/ jsx(DialogFooter, {
onClose: onClose,
onValidate: ()=>onValidate(selectedAssets)
})
]
});
};
const AssetDialog = ({ open = false, onClose, ...restProps })=>{
return /*#__PURE__*/ jsx(Modal.Root, {
open: open,
onOpenChange: onClose,
children: /*#__PURE__*/ jsx(Modal.Content, {
children: /*#__PURE__*/ jsx(AssetContent, {
onClose: onClose,
...restProps
})
})
});
};
const TabsRoot = styled(Tabs.Root)`
display: flex;
flex-direction: column;
overflow: hidden;
`;
export { AssetContent, AssetDialog };
//# sourceMappingURL=AssetDialog.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,313 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var reactIntl = require('react-intl');
var styledComponents = require('styled-components');
var constants = require('../../../constants.js');
var useFolder = require('../../../hooks/useFolder.js');
var usePersistentState = require('../../../hooks/usePersistentState.js');
require('byte-size');
require('date-fns');
var getAllowedFiles = require('../../../utils/getAllowedFiles.js');
var getBreadcrumbDataCM = require('../../../utils/getBreadcrumbDataCM.js');
require('qs');
var getTrad = require('../../../utils/getTrad.js');
var toSingularTypes = require('../../../utils/toSingularTypes.js');
require('../../../utils/urlYupSchema.js');
var AssetGridList = require('../../AssetGridList/AssetGridList.js');
var Breadcrumbs = require('../../Breadcrumbs/Breadcrumbs.js');
var EmptyAssets = require('../../EmptyAssets/EmptyAssets.js');
var FolderCard = require('../../FolderCard/FolderCard/FolderCard.js');
var FolderCardBody = require('../../FolderCard/FolderCardBody/FolderCardBody.js');
var FolderCardBodyAction = require('../../FolderCard/FolderCardBodyAction/FolderCardBodyAction.js');
var FolderGridList = require('../../FolderGridList/FolderGridList.js');
var SortPicker = require('../../SortPicker/SortPicker.js');
var TableList = require('../../TableList/TableList.js');
var Filters = require('./Filters.js');
var PageSize = require('./PageSize.js');
var PaginationFooter = require('./PaginationFooter/PaginationFooter.js');
var SearchAsset = require('./SearchAsset/SearchAsset.js');
var isSelectable = require('./utils/isSelectable.js');
// TODO: find a better naming convention for the file that was an index file before
const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
max-width: 100%;
`;
const ActionContainer = styledComponents.styled(designSystem.Box)`
svg {
path {
fill: ${({ theme })=>theme.colors.neutral500};
}
}
`;
const BrowseStep = ({ allowedTypes = [], assets: rawAssets, canCreate, canRead, folders = [], multiple = false, onAddAsset, onChangeFilters, onChangePage, onChangePageSize, onChangeSearch, onChangeSort, onChangeFolder, onEditAsset, onEditFolder, onSelectAllAsset, onSelectAsset, pagination, queryObject, selectedAssets })=>{
const { formatMessage } = reactIntl.useIntl();
const [view, setView] = usePersistentState.usePersistentState(constants.localStorageKeys.modalView, constants.viewOptions.GRID);
const isGridView = view === constants.viewOptions.GRID;
const { data: currentFolder, isLoading: isCurrentFolderLoading } = useFolder.useFolder(queryObject?.folder, {
enabled: canRead && !!queryObject?.folder
});
const singularTypes = toSingularTypes.toSingularTypes(allowedTypes);
const assets = rawAssets.map((asset)=>({
...asset,
isSelectable: isSelectable.isSelectable(singularTypes, asset?.mime),
type: 'asset'
}));
const breadcrumbs = !isCurrentFolderLoading ? getBreadcrumbDataCM.getBreadcrumbDataCM(currentFolder) : undefined;
const allAllowedAsset = getAllowedFiles.getAllowedFiles(allowedTypes, assets);
const areAllAssetSelected = allAllowedAsset.length > 0 && selectedAssets.length > 0 && allAllowedAsset.every((asset)=>selectedAssets.findIndex((currAsset)=>currAsset.id === asset.id) !== -1);
const hasSomeAssetSelected = allAllowedAsset.some((asset)=>selectedAssets.findIndex((currAsset)=>currAsset.id === asset.id) !== -1);
const isSearching = !!queryObject?._q;
const isFiltering = !!queryObject?.filters?.$and?.length && queryObject.filters.$and.length > 0;
const isSearchingOrFiltering = isSearching || isFiltering;
const assetCount = assets.length;
const folderCount = folders.length;
const handleClickFolderCard = (...args)=>{
// Search query will always fetch the same results
// we remove it here to allow navigating in a folder and see the result of this navigation
onChangeSearch('');
onChangeFolder(...args);
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
children: [
onSelectAllAsset && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingBottom: 4,
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
justifyContent: "space-between",
alignItems: "flex-start",
children: [
(assetCount > 0 || folderCount > 0 || isFiltering) && /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 2,
wrap: "wrap",
children: [
multiple && isGridView && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
paddingLeft: 2,
paddingRight: 2,
background: "neutral0",
hasRadius: true,
borderColor: "neutral200",
height: "3.2rem",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Checkbox, {
"aria-label": formatMessage({
id: getTrad.getTrad('bulk.select.label'),
defaultMessage: 'Select all assets'
}),
checked: !areAllAssetSelected && hasSomeAssetSelected ? 'indeterminate' : areAllAssetSelected,
onCheckedChange: onSelectAllAsset
})
}),
isGridView && /*#__PURE__*/ jsxRuntime.jsx(SortPicker.SortPicker, {
onChangeSort: onChangeSort,
value: queryObject?.sort
}),
/*#__PURE__*/ jsxRuntime.jsx(Filters.Filters, {
appliedFilters: queryObject?.filters?.$and,
onChangeFilters: onChangeFilters
})
]
}),
(assetCount > 0 || folderCount > 0 || isSearching) && /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
marginLeft: "auto",
shrink: 0,
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(ActionContainer, {
paddingTop: 1,
paddingBottom: 1,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
label: isGridView ? formatMessage({
id: 'view-switch.list',
defaultMessage: 'List View'
}) : formatMessage({
id: 'view-switch.grid',
defaultMessage: 'Grid View'
}),
onClick: ()=>setView(isGridView ? constants.viewOptions.LIST : constants.viewOptions.GRID),
children: isGridView ? /*#__PURE__*/ jsxRuntime.jsx(icons.List, {}) : /*#__PURE__*/ jsxRuntime.jsx(icons.GridFour, {})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(SearchAsset.SearchAsset, {
onChangeSearch: onChangeSearch,
queryValue: queryObject._q || ''
})
]
})
]
})
}),
canRead && breadcrumbs?.length && breadcrumbs.length > 0 && currentFolder && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingTop: 3,
children: /*#__PURE__*/ jsxRuntime.jsx(Breadcrumbs.Breadcrumbs, {
onChangeFolder: onChangeFolder,
label: formatMessage({
id: getTrad.getTrad('header.breadcrumbs.nav.label'),
defaultMessage: 'Folders navigation'
}),
breadcrumbs: breadcrumbs,
currentFolderId: queryObject?.folder
})
}),
assetCount === 0 && folderCount === 0 && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingBottom: 6,
children: /*#__PURE__*/ jsxRuntime.jsx(EmptyAssets.EmptyAssets, {
size: "S",
count: 6,
action: canCreate && !isFiltering && !isSearching && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "secondary",
startIcon: /*#__PURE__*/ jsxRuntime.jsx(icons.Plus, {}),
onClick: onAddAsset,
children: formatMessage({
id: getTrad.getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
}),
content: // eslint-disable-next-line no-nested-ternary
isSearchingOrFiltering ? formatMessage({
id: getTrad.getTrad('list.assets-empty.title-withSearch'),
defaultMessage: 'There are no assets with the applied filters'
}) : canCreate && !isSearching ? formatMessage({
id: getTrad.getTrad('list.assets.empty'),
defaultMessage: 'Upload your first assets...'
}) : formatMessage({
id: getTrad.getTrad('list.assets.empty.no-permissions'),
defaultMessage: 'The asset list is empty'
})
})
}),
!isGridView && (folderCount > 0 || assetCount > 0) && /*#__PURE__*/ jsxRuntime.jsx(TableList.TableList, {
allowedTypes: allowedTypes,
assetCount: assetCount,
folderCount: folderCount,
indeterminate: !areAllAssetSelected && hasSomeAssetSelected,
isFolderSelectionAllowed: false,
onChangeSort: onChangeSort,
onChangeFolder: handleClickFolderCard,
onEditAsset: onEditAsset,
onEditFolder: onEditFolder,
onSelectOne: onSelectAsset,
onSelectAll: onSelectAllAsset,
rows: [
...folders.map((folder)=>({
...folder,
type: 'folder'
})),
...assets
],
selected: selectedAssets,
shouldDisableBulkSelect: !multiple,
sortQuery: queryObject?.sort ?? ''
}),
isGridView && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
folderCount > 0 && /*#__PURE__*/ jsxRuntime.jsx(FolderGridList.FolderGridList, {
title: (isSearchingOrFiltering && assetCount > 0 || !isSearchingOrFiltering) && formatMessage({
id: getTrad.getTrad('list.folders.title'),
defaultMessage: 'Folders ({count})'
}, {
count: folderCount
}) || '',
children: folders.map((folder)=>{
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 3,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(FolderCard.FolderCard, {
ariaLabel: folder.name,
id: `folder-${folder.id}`,
onClick: ()=>handleClickFolderCard(folder.id, folder.path),
cardActions: onEditFolder && /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
withTooltip: false,
label: formatMessage({
id: getTrad.getTrad('list.folder.edit'),
defaultMessage: 'Edit folder'
}),
onClick: ()=>onEditFolder(folder),
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Pencil, {})
}),
children: /*#__PURE__*/ jsxRuntime.jsx(FolderCardBody.FolderCardBody, {
children: /*#__PURE__*/ jsxRuntime.jsx(FolderCardBodyAction.FolderCardBodyAction, {
onClick: ()=>handleClickFolderCard(folder.id, folder.path),
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
tag: "h2",
direction: "column",
alignItems: "start",
maxWidth: "100%",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(TypographyMaxWidth, {
fontWeight: "semiBold",
ellipsis: true,
textColor: "neutral800",
children: [
folder.name,
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: "-"
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(TypographyMaxWidth, {
tag: "span",
textColor: "neutral600",
variant: "pi",
ellipsis: true,
children: formatMessage({
id: getTrad.getTrad('list.folder.subtitle'),
defaultMessage: '{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}'
}, {
folderCount: folder.children?.count,
filesCount: folder.files?.count
})
})
]
})
})
})
})
}, `folder-${folder.id}`);
})
}),
assetCount > 0 && folderCount > 0 && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingTop: 6,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Divider, {})
}),
assetCount > 0 && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingTop: 6,
children: /*#__PURE__*/ jsxRuntime.jsx(AssetGridList.AssetGridList, {
allowedTypes: allowedTypes,
size: "S",
assets: assets,
onSelectAsset: onSelectAsset,
selectedAssets: selectedAssets,
onEditAsset: onEditAsset,
title: (!isSearchingOrFiltering || isSearchingOrFiltering && folderCount > 0) && queryObject.page === 1 && formatMessage({
id: getTrad.getTrad('list.assets.title'),
defaultMessage: 'Assets ({count})'
}, {
count: assetCount
}) || ''
})
})
]
}),
pagination.pageCount > 0 && /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
justifyContent: "space-between",
paddingTop: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsx(PageSize.PageSize, {
pageSize: queryObject.pageSize,
onChangePageSize: onChangePageSize
}),
/*#__PURE__*/ jsxRuntime.jsx(PaginationFooter.PaginationFooter, {
activePage: queryObject.page,
onChangePage: onChangePage,
pagination: pagination
})
]
})
]
});
};
exports.BrowseStep = BrowseStep;
//# sourceMappingURL=BrowseStep.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,311 @@
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import { Typography, Box, Flex, Checkbox, IconButton, Button, Grid, VisuallyHidden, Divider } from '@strapi/design-system';
import { List, GridFour, Plus, Pencil } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { styled } from 'styled-components';
import { viewOptions, localStorageKeys } from '../../../constants.mjs';
import { useFolder } from '../../../hooks/useFolder.mjs';
import { usePersistentState } from '../../../hooks/usePersistentState.mjs';
import 'byte-size';
import 'date-fns';
import { getAllowedFiles } from '../../../utils/getAllowedFiles.mjs';
import { getBreadcrumbDataCM } from '../../../utils/getBreadcrumbDataCM.mjs';
import 'qs';
import { getTrad } from '../../../utils/getTrad.mjs';
import { toSingularTypes } from '../../../utils/toSingularTypes.mjs';
import '../../../utils/urlYupSchema.mjs';
import { AssetGridList } from '../../AssetGridList/AssetGridList.mjs';
import { Breadcrumbs } from '../../Breadcrumbs/Breadcrumbs.mjs';
import { EmptyAssets } from '../../EmptyAssets/EmptyAssets.mjs';
import { FolderCard } from '../../FolderCard/FolderCard/FolderCard.mjs';
import { FolderCardBody } from '../../FolderCard/FolderCardBody/FolderCardBody.mjs';
import { FolderCardBodyAction } from '../../FolderCard/FolderCardBodyAction/FolderCardBodyAction.mjs';
import { FolderGridList } from '../../FolderGridList/FolderGridList.mjs';
import { SortPicker } from '../../SortPicker/SortPicker.mjs';
import { TableList } from '../../TableList/TableList.mjs';
import { Filters } from './Filters.mjs';
import { PageSize } from './PageSize.mjs';
import { PaginationFooter } from './PaginationFooter/PaginationFooter.mjs';
import { SearchAsset } from './SearchAsset/SearchAsset.mjs';
import { isSelectable } from './utils/isSelectable.mjs';
// TODO: find a better naming convention for the file that was an index file before
const TypographyMaxWidth = styled(Typography)`
max-width: 100%;
`;
const ActionContainer = styled(Box)`
svg {
path {
fill: ${({ theme })=>theme.colors.neutral500};
}
}
`;
const BrowseStep = ({ allowedTypes = [], assets: rawAssets, canCreate, canRead, folders = [], multiple = false, onAddAsset, onChangeFilters, onChangePage, onChangePageSize, onChangeSearch, onChangeSort, onChangeFolder, onEditAsset, onEditFolder, onSelectAllAsset, onSelectAsset, pagination, queryObject, selectedAssets })=>{
const { formatMessage } = useIntl();
const [view, setView] = usePersistentState(localStorageKeys.modalView, viewOptions.GRID);
const isGridView = view === viewOptions.GRID;
const { data: currentFolder, isLoading: isCurrentFolderLoading } = useFolder(queryObject?.folder, {
enabled: canRead && !!queryObject?.folder
});
const singularTypes = toSingularTypes(allowedTypes);
const assets = rawAssets.map((asset)=>({
...asset,
isSelectable: isSelectable(singularTypes, asset?.mime),
type: 'asset'
}));
const breadcrumbs = !isCurrentFolderLoading ? getBreadcrumbDataCM(currentFolder) : undefined;
const allAllowedAsset = getAllowedFiles(allowedTypes, assets);
const areAllAssetSelected = allAllowedAsset.length > 0 && selectedAssets.length > 0 && allAllowedAsset.every((asset)=>selectedAssets.findIndex((currAsset)=>currAsset.id === asset.id) !== -1);
const hasSomeAssetSelected = allAllowedAsset.some((asset)=>selectedAssets.findIndex((currAsset)=>currAsset.id === asset.id) !== -1);
const isSearching = !!queryObject?._q;
const isFiltering = !!queryObject?.filters?.$and?.length && queryObject.filters.$and.length > 0;
const isSearchingOrFiltering = isSearching || isFiltering;
const assetCount = assets.length;
const folderCount = folders.length;
const handleClickFolderCard = (...args)=>{
// Search query will always fetch the same results
// we remove it here to allow navigating in a folder and see the result of this navigation
onChangeSearch('');
onChangeFolder(...args);
};
return /*#__PURE__*/ jsxs(Box, {
children: [
onSelectAllAsset && /*#__PURE__*/ jsx(Box, {
paddingBottom: 4,
children: /*#__PURE__*/ jsxs(Flex, {
justifyContent: "space-between",
alignItems: "flex-start",
children: [
(assetCount > 0 || folderCount > 0 || isFiltering) && /*#__PURE__*/ jsxs(Flex, {
gap: 2,
wrap: "wrap",
children: [
multiple && isGridView && /*#__PURE__*/ jsx(Flex, {
paddingLeft: 2,
paddingRight: 2,
background: "neutral0",
hasRadius: true,
borderColor: "neutral200",
height: "3.2rem",
children: /*#__PURE__*/ jsx(Checkbox, {
"aria-label": formatMessage({
id: getTrad('bulk.select.label'),
defaultMessage: 'Select all assets'
}),
checked: !areAllAssetSelected && hasSomeAssetSelected ? 'indeterminate' : areAllAssetSelected,
onCheckedChange: onSelectAllAsset
})
}),
isGridView && /*#__PURE__*/ jsx(SortPicker, {
onChangeSort: onChangeSort,
value: queryObject?.sort
}),
/*#__PURE__*/ jsx(Filters, {
appliedFilters: queryObject?.filters?.$and,
onChangeFilters: onChangeFilters
})
]
}),
(assetCount > 0 || folderCount > 0 || isSearching) && /*#__PURE__*/ jsxs(Flex, {
marginLeft: "auto",
shrink: 0,
gap: 2,
children: [
/*#__PURE__*/ jsx(ActionContainer, {
paddingTop: 1,
paddingBottom: 1,
children: /*#__PURE__*/ jsx(IconButton, {
label: isGridView ? formatMessage({
id: 'view-switch.list',
defaultMessage: 'List View'
}) : formatMessage({
id: 'view-switch.grid',
defaultMessage: 'Grid View'
}),
onClick: ()=>setView(isGridView ? viewOptions.LIST : viewOptions.GRID),
children: isGridView ? /*#__PURE__*/ jsx(List, {}) : /*#__PURE__*/ jsx(GridFour, {})
})
}),
/*#__PURE__*/ jsx(SearchAsset, {
onChangeSearch: onChangeSearch,
queryValue: queryObject._q || ''
})
]
})
]
})
}),
canRead && breadcrumbs?.length && breadcrumbs.length > 0 && currentFolder && /*#__PURE__*/ jsx(Box, {
paddingTop: 3,
children: /*#__PURE__*/ jsx(Breadcrumbs, {
onChangeFolder: onChangeFolder,
label: formatMessage({
id: getTrad('header.breadcrumbs.nav.label'),
defaultMessage: 'Folders navigation'
}),
breadcrumbs: breadcrumbs,
currentFolderId: queryObject?.folder
})
}),
assetCount === 0 && folderCount === 0 && /*#__PURE__*/ jsx(Box, {
paddingBottom: 6,
children: /*#__PURE__*/ jsx(EmptyAssets, {
size: "S",
count: 6,
action: canCreate && !isFiltering && !isSearching && /*#__PURE__*/ jsx(Button, {
variant: "secondary",
startIcon: /*#__PURE__*/ jsx(Plus, {}),
onClick: onAddAsset,
children: formatMessage({
id: getTrad('header.actions.add-assets'),
defaultMessage: 'Add new assets'
})
}),
content: // eslint-disable-next-line no-nested-ternary
isSearchingOrFiltering ? formatMessage({
id: getTrad('list.assets-empty.title-withSearch'),
defaultMessage: 'There are no assets with the applied filters'
}) : canCreate && !isSearching ? formatMessage({
id: getTrad('list.assets.empty'),
defaultMessage: 'Upload your first assets...'
}) : formatMessage({
id: getTrad('list.assets.empty.no-permissions'),
defaultMessage: 'The asset list is empty'
})
})
}),
!isGridView && (folderCount > 0 || assetCount > 0) && /*#__PURE__*/ jsx(TableList, {
allowedTypes: allowedTypes,
assetCount: assetCount,
folderCount: folderCount,
indeterminate: !areAllAssetSelected && hasSomeAssetSelected,
isFolderSelectionAllowed: false,
onChangeSort: onChangeSort,
onChangeFolder: handleClickFolderCard,
onEditAsset: onEditAsset,
onEditFolder: onEditFolder,
onSelectOne: onSelectAsset,
onSelectAll: onSelectAllAsset,
rows: [
...folders.map((folder)=>({
...folder,
type: 'folder'
})),
...assets
],
selected: selectedAssets,
shouldDisableBulkSelect: !multiple,
sortQuery: queryObject?.sort ?? ''
}),
isGridView && /*#__PURE__*/ jsxs(Fragment, {
children: [
folderCount > 0 && /*#__PURE__*/ jsx(FolderGridList, {
title: (isSearchingOrFiltering && assetCount > 0 || !isSearchingOrFiltering) && formatMessage({
id: getTrad('list.folders.title'),
defaultMessage: 'Folders ({count})'
}, {
count: folderCount
}) || '',
children: folders.map((folder)=>{
return /*#__PURE__*/ jsx(Grid.Item, {
col: 3,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(FolderCard, {
ariaLabel: folder.name,
id: `folder-${folder.id}`,
onClick: ()=>handleClickFolderCard(folder.id, folder.path),
cardActions: onEditFolder && /*#__PURE__*/ jsx(IconButton, {
withTooltip: false,
label: formatMessage({
id: getTrad('list.folder.edit'),
defaultMessage: 'Edit folder'
}),
onClick: ()=>onEditFolder(folder),
children: /*#__PURE__*/ jsx(Pencil, {})
}),
children: /*#__PURE__*/ jsx(FolderCardBody, {
children: /*#__PURE__*/ jsx(FolderCardBodyAction, {
onClick: ()=>handleClickFolderCard(folder.id, folder.path),
children: /*#__PURE__*/ jsxs(Flex, {
tag: "h2",
direction: "column",
alignItems: "start",
maxWidth: "100%",
children: [
/*#__PURE__*/ jsxs(TypographyMaxWidth, {
fontWeight: "semiBold",
ellipsis: true,
textColor: "neutral800",
children: [
folder.name,
/*#__PURE__*/ jsx(VisuallyHidden, {
children: "-"
})
]
}),
/*#__PURE__*/ jsx(TypographyMaxWidth, {
tag: "span",
textColor: "neutral600",
variant: "pi",
ellipsis: true,
children: formatMessage({
id: getTrad('list.folder.subtitle'),
defaultMessage: '{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}'
}, {
folderCount: folder.children?.count,
filesCount: folder.files?.count
})
})
]
})
})
})
})
}, `folder-${folder.id}`);
})
}),
assetCount > 0 && folderCount > 0 && /*#__PURE__*/ jsx(Box, {
paddingTop: 6,
children: /*#__PURE__*/ jsx(Divider, {})
}),
assetCount > 0 && /*#__PURE__*/ jsx(Box, {
paddingTop: 6,
children: /*#__PURE__*/ jsx(AssetGridList, {
allowedTypes: allowedTypes,
size: "S",
assets: assets,
onSelectAsset: onSelectAsset,
selectedAssets: selectedAssets,
onEditAsset: onEditAsset,
title: (!isSearchingOrFiltering || isSearchingOrFiltering && folderCount > 0) && queryObject.page === 1 && formatMessage({
id: getTrad('list.assets.title'),
defaultMessage: 'Assets ({count})'
}, {
count: assetCount
}) || ''
})
})
]
}),
pagination.pageCount > 0 && /*#__PURE__*/ jsxs(Flex, {
justifyContent: "space-between",
paddingTop: 4,
children: [
/*#__PURE__*/ jsx(PageSize, {
pageSize: queryObject.pageSize,
onChangePageSize: onChangePageSize
}),
/*#__PURE__*/ jsx(PaginationFooter, {
activePage: queryObject.page,
onChangePage: onChangePage,
pagination: pagination
})
]
})
]
});
};
export { BrowseStep };
//# sourceMappingURL=BrowseStep.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,70 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var reactIntl = require('react-intl');
var displayedFilters = require('../../../utils/displayedFilters.js');
require('byte-size');
require('date-fns');
require('qs');
require('../../../constants.js');
require('../../../utils/urlYupSchema.js');
var FilterList = require('../../FilterList/FilterList.js');
var FilterPopover = require('../../FilterPopover/FilterPopover.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const Filters = ({ appliedFilters, onChangeFilters })=>{
const [open, setOpen] = React__namespace.useState(false);
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Popover.Root, {
open: open,
onOpenChange: setOpen,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Popover.Trigger, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "tertiary",
startIcon: /*#__PURE__*/ jsxRuntime.jsx(icons.Filter, {}),
size: "S",
children: formatMessage({
id: 'app.utils.filters',
defaultMessage: 'Filters'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(FilterPopover.FilterPopover, {
onToggle: ()=>setOpen((prev)=>!prev),
displayedFilters: displayedFilters.displayedFilters,
filters: appliedFilters,
onSubmit: onChangeFilters
}),
appliedFilters && /*#__PURE__*/ jsxRuntime.jsx(FilterList.FilterList, {
appliedFilters: appliedFilters,
filtersSchema: displayedFilters.displayedFilters,
onRemoveFilter: onChangeFilters
})
]
});
};
exports.Filters = Filters;
//# sourceMappingURL=Filters.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Filters.js","sources":["../../../../../admin/src/components/AssetDialog/BrowseStep/Filters.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button, Popover } from '@strapi/design-system';\nimport { Filter } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { displayedFilters } from '../../../utils';\nimport { FilterList } from '../../FilterList/FilterList';\nimport { FilterPopover } from '../../FilterPopover/FilterPopover';\n\ntype NumberKeyedObject = Record<number, string>;\n\ntype StringFilter = {\n [key: string]: string;\n};\n\ntype MimeFilter = {\n [key: string]:\n | string\n | NumberKeyedObject\n | Record<string, string | NumberKeyedObject>\n | undefined;\n};\n\nexport type FilterStructure = {\n [key: string]: MimeFilter | StringFilter | undefined;\n};\n\nexport type Filter = {\n [key in 'mime' | 'createdAt' | 'updatedAt']?:\n | {\n [key in '$contains' | '$notContains' | '$eq' | '$not']?:\n | string[]\n | string\n | { $contains: string[] };\n }\n | undefined;\n};\n\ninterface FiltersProps {\n appliedFilters: FilterStructure[];\n onChangeFilters: (filters: Filter[]) => void;\n}\n\nexport const Filters = ({ appliedFilters, onChangeFilters }: FiltersProps) => {\n const [open, setOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n\n return (\n <Popover.Root open={open} onOpenChange={setOpen}>\n <Popover.Trigger>\n <Button variant=\"tertiary\" startIcon={<Filter />} size=\"S\">\n {formatMessage({ id: 'app.utils.filters', defaultMessage: 'Filters' })}\n </Button>\n </Popover.Trigger>\n <FilterPopover\n onToggle={() => setOpen((prev) => !prev)}\n displayedFilters={displayedFilters}\n filters={appliedFilters}\n onSubmit={onChangeFilters}\n />\n\n {appliedFilters && (\n <FilterList\n appliedFilters={appliedFilters}\n filtersSchema={displayedFilters}\n onRemoveFilter={onChangeFilters}\n />\n )}\n </Popover.Root>\n );\n};\n"],"names":["Filters","appliedFilters","onChangeFilters","open","setOpen","React","useState","formatMessage","useIntl","_jsxs","Popover","Root","onOpenChange","_jsx","Trigger","Button","variant","startIcon","Filter","size","id","defaultMessage","FilterPopover","onToggle","prev","displayedFilters","filters","onSubmit","FilterList","filtersSchema","onRemoveFilter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4CaA,OAAU,GAAA,CAAC,EAAEC,cAAc,EAAEC,eAAe,EAAgB,GAAA;AACvE,IAAA,MAAM,CAACC,IAAMC,EAAAA,OAAAA,CAAQ,GAAGC,gBAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IACvC,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAE1B,qBACEC,eAAA,CAACC,qBAAQC,IAAI,EAAA;QAACR,IAAMA,EAAAA,IAAAA;QAAMS,YAAcR,EAAAA,OAAAA;;AACtC,0BAAAS,cAAA,CAACH,qBAAQI,OAAO,EAAA;AACd,gBAAA,QAAA,gBAAAD,cAACE,CAAAA,mBAAAA,EAAAA;oBAAOC,OAAQ,EAAA,UAAA;AAAWC,oBAAAA,SAAAA,gBAAWJ,cAACK,CAAAA,YAAAA,EAAAA,EAAAA,CAAAA;oBAAWC,IAAK,EAAA,GAAA;8BACpDZ,aAAc,CAAA;wBAAEa,EAAI,EAAA,mBAAA;wBAAqBC,cAAgB,EAAA;AAAU,qBAAA;;;0BAGxER,cAACS,CAAAA,2BAAAA,EAAAA;AACCC,gBAAAA,QAAAA,EAAU,IAAMnB,OAAAA,CAAQ,CAACoB,IAAAA,GAAS,CAACA,IAAAA,CAAAA;gBACnCC,gBAAkBA,EAAAA,iCAAAA;gBAClBC,OAASzB,EAAAA,cAAAA;gBACT0B,QAAUzB,EAAAA;;AAGXD,YAAAA,cAAAA,kBACCY,cAACe,CAAAA,qBAAAA,EAAAA;gBACC3B,cAAgBA,EAAAA,cAAAA;gBAChB4B,aAAeJ,EAAAA,iCAAAA;gBACfK,cAAgB5B,EAAAA;;;;AAK1B;;;;"}

View File

@@ -0,0 +1,49 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { Popover, Button } from '@strapi/design-system';
import { Filter } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { displayedFilters } from '../../../utils/displayedFilters.mjs';
import 'byte-size';
import 'date-fns';
import 'qs';
import '../../../constants.mjs';
import '../../../utils/urlYupSchema.mjs';
import { FilterList } from '../../FilterList/FilterList.mjs';
import { FilterPopover } from '../../FilterPopover/FilterPopover.mjs';
const Filters = ({ appliedFilters, onChangeFilters })=>{
const [open, setOpen] = React.useState(false);
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsxs(Popover.Root, {
open: open,
onOpenChange: setOpen,
children: [
/*#__PURE__*/ jsx(Popover.Trigger, {
children: /*#__PURE__*/ jsx(Button, {
variant: "tertiary",
startIcon: /*#__PURE__*/ jsx(Filter, {}),
size: "S",
children: formatMessage({
id: 'app.utils.filters',
defaultMessage: 'Filters'
})
})
}),
/*#__PURE__*/ jsx(FilterPopover, {
onToggle: ()=>setOpen((prev)=>!prev),
displayedFilters: displayedFilters,
filters: appliedFilters,
onSubmit: onChangeFilters
}),
appliedFilters && /*#__PURE__*/ jsx(FilterList, {
appliedFilters: appliedFilters,
filtersSchema: displayedFilters,
onRemoveFilter: onChangeFilters
})
]
});
};
export { Filters };
//# sourceMappingURL=Filters.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Filters.mjs","sources":["../../../../../admin/src/components/AssetDialog/BrowseStep/Filters.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Button, Popover } from '@strapi/design-system';\nimport { Filter } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\n\nimport { displayedFilters } from '../../../utils';\nimport { FilterList } from '../../FilterList/FilterList';\nimport { FilterPopover } from '../../FilterPopover/FilterPopover';\n\ntype NumberKeyedObject = Record<number, string>;\n\ntype StringFilter = {\n [key: string]: string;\n};\n\ntype MimeFilter = {\n [key: string]:\n | string\n | NumberKeyedObject\n | Record<string, string | NumberKeyedObject>\n | undefined;\n};\n\nexport type FilterStructure = {\n [key: string]: MimeFilter | StringFilter | undefined;\n};\n\nexport type Filter = {\n [key in 'mime' | 'createdAt' | 'updatedAt']?:\n | {\n [key in '$contains' | '$notContains' | '$eq' | '$not']?:\n | string[]\n | string\n | { $contains: string[] };\n }\n | undefined;\n};\n\ninterface FiltersProps {\n appliedFilters: FilterStructure[];\n onChangeFilters: (filters: Filter[]) => void;\n}\n\nexport const Filters = ({ appliedFilters, onChangeFilters }: FiltersProps) => {\n const [open, setOpen] = React.useState(false);\n const { formatMessage } = useIntl();\n\n return (\n <Popover.Root open={open} onOpenChange={setOpen}>\n <Popover.Trigger>\n <Button variant=\"tertiary\" startIcon={<Filter />} size=\"S\">\n {formatMessage({ id: 'app.utils.filters', defaultMessage: 'Filters' })}\n </Button>\n </Popover.Trigger>\n <FilterPopover\n onToggle={() => setOpen((prev) => !prev)}\n displayedFilters={displayedFilters}\n filters={appliedFilters}\n onSubmit={onChangeFilters}\n />\n\n {appliedFilters && (\n <FilterList\n appliedFilters={appliedFilters}\n filtersSchema={displayedFilters}\n onRemoveFilter={onChangeFilters}\n />\n )}\n </Popover.Root>\n );\n};\n"],"names":["Filters","appliedFilters","onChangeFilters","open","setOpen","React","useState","formatMessage","useIntl","_jsxs","Popover","Root","onOpenChange","_jsx","Trigger","Button","variant","startIcon","Filter","size","id","defaultMessage","FilterPopover","onToggle","prev","displayedFilters","filters","onSubmit","FilterList","filtersSchema","onRemoveFilter"],"mappings":";;;;;;;;;;;;;;MA4CaA,OAAU,GAAA,CAAC,EAAEC,cAAc,EAAEC,eAAe,EAAgB,GAAA;AACvE,IAAA,MAAM,CAACC,IAAMC,EAAAA,OAAAA,CAAQ,GAAGC,KAAAA,CAAMC,QAAQ,CAAC,KAAA,CAAA;IACvC,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,qBACEC,IAAA,CAACC,QAAQC,IAAI,EAAA;QAACR,IAAMA,EAAAA,IAAAA;QAAMS,YAAcR,EAAAA,OAAAA;;AACtC,0BAAAS,GAAA,CAACH,QAAQI,OAAO,EAAA;AACd,gBAAA,QAAA,gBAAAD,GAACE,CAAAA,MAAAA,EAAAA;oBAAOC,OAAQ,EAAA,UAAA;AAAWC,oBAAAA,SAAAA,gBAAWJ,GAACK,CAAAA,MAAAA,EAAAA,EAAAA,CAAAA;oBAAWC,IAAK,EAAA,GAAA;8BACpDZ,aAAc,CAAA;wBAAEa,EAAI,EAAA,mBAAA;wBAAqBC,cAAgB,EAAA;AAAU,qBAAA;;;0BAGxER,GAACS,CAAAA,aAAAA,EAAAA;AACCC,gBAAAA,QAAAA,EAAU,IAAMnB,OAAAA,CAAQ,CAACoB,IAAAA,GAAS,CAACA,IAAAA,CAAAA;gBACnCC,gBAAkBA,EAAAA,gBAAAA;gBAClBC,OAASzB,EAAAA,cAAAA;gBACT0B,QAAUzB,EAAAA;;AAGXD,YAAAA,cAAAA,kBACCY,GAACe,CAAAA,UAAAA,EAAAA;gBACC3B,cAAgBA,EAAAA,cAAAA;gBAChB4B,aAAeJ,EAAAA,gBAAAA;gBACfK,cAAgB5B,EAAAA;;;;AAK1B;;;;"}

View File

@@ -0,0 +1,58 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
const PageSize = ({ onChangePageSize, pageSize })=>{
const { formatMessage } = reactIntl.useIntl();
const handleChange = (value)=>{
onChangePageSize(Number(value));
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.SingleSelect, {
size: "S",
"aria-label": formatMessage({
id: 'components.PageFooter.select',
defaultMessage: 'Entries per page'
}),
onChange: handleChange,
value: pageSize.toString(),
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
value: "10",
children: "10"
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
value: "20",
children: "20"
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
value: "50",
children: "50"
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.SingleSelectOption, {
value: "100",
children: "100"
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingLeft: 2,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
textColor: "neutral600",
tag: "label",
htmlFor: "page-size",
children: formatMessage({
id: 'components.PageFooter.select',
defaultMessage: 'Entries per page'
})
})
})
]
});
};
exports.PageSize = PageSize;
//# sourceMappingURL=PageSize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PageSize.js","sources":["../../../../../admin/src/components/AssetDialog/BrowseStep/PageSize.tsx"],"sourcesContent":["import { Box, Flex, SingleSelectOption, SingleSelect, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\ninterface PageSizeProps {\n onChangePageSize: (value: number) => void;\n pageSize: number;\n}\n\nexport const PageSize = ({ onChangePageSize, pageSize }: PageSizeProps) => {\n const { formatMessage } = useIntl();\n\n const handleChange = (value: string | number) => {\n onChangePageSize(Number(value));\n };\n\n return (\n <Flex>\n <SingleSelect\n size=\"S\"\n aria-label={formatMessage({\n id: 'components.PageFooter.select',\n defaultMessage: 'Entries per page',\n })}\n onChange={handleChange}\n value={pageSize.toString()}\n >\n <SingleSelectOption value=\"10\">10</SingleSelectOption>\n <SingleSelectOption value=\"20\">20</SingleSelectOption>\n <SingleSelectOption value=\"50\">50</SingleSelectOption>\n <SingleSelectOption value=\"100\">100</SingleSelectOption>\n </SingleSelect>\n <Box paddingLeft={2}>\n <Typography textColor=\"neutral600\" tag=\"label\" htmlFor=\"page-size\">\n {formatMessage({\n id: 'components.PageFooter.select',\n defaultMessage: 'Entries per page',\n })}\n </Typography>\n </Box>\n </Flex>\n );\n};\n"],"names":["PageSize","onChangePageSize","pageSize","formatMessage","useIntl","handleChange","value","Number","_jsxs","Flex","SingleSelect","size","aria-label","id","defaultMessage","onChange","toString","_jsx","SingleSelectOption","Box","paddingLeft","Typography","textColor","tag","htmlFor"],"mappings":";;;;;;MAQaA,QAAW,GAAA,CAAC,EAAEC,gBAAgB,EAAEC,QAAQ,EAAiB,GAAA;IACpE,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAE1B,IAAA,MAAMC,eAAe,CAACC,KAAAA,GAAAA;AACpBL,QAAAA,gBAAAA,CAAiBM,MAAOD,CAAAA,KAAAA,CAAAA,CAAAA;AAC1B,KAAA;AAEA,IAAA,qBACEE,eAACC,CAAAA,iBAAAA,EAAAA;;0BACCD,eAACE,CAAAA,yBAAAA,EAAAA;gBACCC,IAAK,EAAA,GAAA;AACLC,gBAAAA,YAAAA,EAAYT,aAAc,CAAA;oBACxBU,EAAI,EAAA,8BAAA;oBACJC,cAAgB,EAAA;AAClB,iBAAA,CAAA;gBACAC,QAAUV,EAAAA,YAAAA;AACVC,gBAAAA,KAAAA,EAAOJ,SAASc,QAAQ,EAAA;;kCAExBC,cAACC,CAAAA,+BAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,cAACC,CAAAA,+BAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,cAACC,CAAAA,+BAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,cAACC,CAAAA,+BAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,KAAA;AAAM,wBAAA,QAAA,EAAA;;;;0BAElCW,cAACE,CAAAA,gBAAAA,EAAAA;gBAAIC,WAAa,EAAA,CAAA;AAChB,gBAAA,QAAA,gBAAAH,cAACI,CAAAA,uBAAAA,EAAAA;oBAAWC,SAAU,EAAA,YAAA;oBAAaC,GAAI,EAAA,OAAA;oBAAQC,OAAQ,EAAA,WAAA;8BACpDrB,aAAc,CAAA;wBACbU,EAAI,EAAA,8BAAA;wBACJC,cAAgB,EAAA;AAClB,qBAAA;;;;;AAKV;;;;"}

View File

@@ -0,0 +1,56 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { Flex, SingleSelect, SingleSelectOption, Box, Typography } from '@strapi/design-system';
import { useIntl } from 'react-intl';
const PageSize = ({ onChangePageSize, pageSize })=>{
const { formatMessage } = useIntl();
const handleChange = (value)=>{
onChangePageSize(Number(value));
};
return /*#__PURE__*/ jsxs(Flex, {
children: [
/*#__PURE__*/ jsxs(SingleSelect, {
size: "S",
"aria-label": formatMessage({
id: 'components.PageFooter.select',
defaultMessage: 'Entries per page'
}),
onChange: handleChange,
value: pageSize.toString(),
children: [
/*#__PURE__*/ jsx(SingleSelectOption, {
value: "10",
children: "10"
}),
/*#__PURE__*/ jsx(SingleSelectOption, {
value: "20",
children: "20"
}),
/*#__PURE__*/ jsx(SingleSelectOption, {
value: "50",
children: "50"
}),
/*#__PURE__*/ jsx(SingleSelectOption, {
value: "100",
children: "100"
})
]
}),
/*#__PURE__*/ jsx(Box, {
paddingLeft: 2,
children: /*#__PURE__*/ jsx(Typography, {
textColor: "neutral600",
tag: "label",
htmlFor: "page-size",
children: formatMessage({
id: 'components.PageFooter.select',
defaultMessage: 'Entries per page'
})
})
})
]
});
};
export { PageSize };
//# sourceMappingURL=PageSize.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"PageSize.mjs","sources":["../../../../../admin/src/components/AssetDialog/BrowseStep/PageSize.tsx"],"sourcesContent":["import { Box, Flex, SingleSelectOption, SingleSelect, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\ninterface PageSizeProps {\n onChangePageSize: (value: number) => void;\n pageSize: number;\n}\n\nexport const PageSize = ({ onChangePageSize, pageSize }: PageSizeProps) => {\n const { formatMessage } = useIntl();\n\n const handleChange = (value: string | number) => {\n onChangePageSize(Number(value));\n };\n\n return (\n <Flex>\n <SingleSelect\n size=\"S\"\n aria-label={formatMessage({\n id: 'components.PageFooter.select',\n defaultMessage: 'Entries per page',\n })}\n onChange={handleChange}\n value={pageSize.toString()}\n >\n <SingleSelectOption value=\"10\">10</SingleSelectOption>\n <SingleSelectOption value=\"20\">20</SingleSelectOption>\n <SingleSelectOption value=\"50\">50</SingleSelectOption>\n <SingleSelectOption value=\"100\">100</SingleSelectOption>\n </SingleSelect>\n <Box paddingLeft={2}>\n <Typography textColor=\"neutral600\" tag=\"label\" htmlFor=\"page-size\">\n {formatMessage({\n id: 'components.PageFooter.select',\n defaultMessage: 'Entries per page',\n })}\n </Typography>\n </Box>\n </Flex>\n );\n};\n"],"names":["PageSize","onChangePageSize","pageSize","formatMessage","useIntl","handleChange","value","Number","_jsxs","Flex","SingleSelect","size","aria-label","id","defaultMessage","onChange","toString","_jsx","SingleSelectOption","Box","paddingLeft","Typography","textColor","tag","htmlFor"],"mappings":";;;;MAQaA,QAAW,GAAA,CAAC,EAAEC,gBAAgB,EAAEC,QAAQ,EAAiB,GAAA;IACpE,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAE1B,IAAA,MAAMC,eAAe,CAACC,KAAAA,GAAAA;AACpBL,QAAAA,gBAAAA,CAAiBM,MAAOD,CAAAA,KAAAA,CAAAA,CAAAA;AAC1B,KAAA;AAEA,IAAA,qBACEE,IAACC,CAAAA,IAAAA,EAAAA;;0BACCD,IAACE,CAAAA,YAAAA,EAAAA;gBACCC,IAAK,EAAA,GAAA;AACLC,gBAAAA,YAAAA,EAAYT,aAAc,CAAA;oBACxBU,EAAI,EAAA,8BAAA;oBACJC,cAAgB,EAAA;AAClB,iBAAA,CAAA;gBACAC,QAAUV,EAAAA,YAAAA;AACVC,gBAAAA,KAAAA,EAAOJ,SAASc,QAAQ,EAAA;;kCAExBC,GAACC,CAAAA,kBAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,GAACC,CAAAA,kBAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,GAACC,CAAAA,kBAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,IAAA;AAAK,wBAAA,QAAA,EAAA;;kCAC/BW,GAACC,CAAAA,kBAAAA,EAAAA;wBAAmBZ,KAAM,EAAA,KAAA;AAAM,wBAAA,QAAA,EAAA;;;;0BAElCW,GAACE,CAAAA,GAAAA,EAAAA;gBAAIC,WAAa,EAAA,CAAA;AAChB,gBAAA,QAAA,gBAAAH,GAACI,CAAAA,UAAAA,EAAAA;oBAAWC,SAAU,EAAA,YAAA;oBAAaC,GAAI,EAAA,OAAA;oBAAQC,OAAQ,EAAA,WAAA;8BACpDrB,aAAc,CAAA;wBACbU,EAAI,EAAA,8BAAA;wBACJC,cAAgB,EAAA;AAClB,qBAAA;;;;;AAKV;;;;"}

View File

@@ -0,0 +1,55 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const PaginationContext = /*#__PURE__*/ React__namespace.createContext({
activePage: 1,
pageCount: 1
});
const usePagination = ()=>React__namespace.useContext(PaginationContext);
const Pagination = ({ children, activePage, pageCount, label = 'pagination' })=>{
const paginationValue = React__namespace.useMemo(()=>({
activePage,
pageCount
}), [
activePage,
pageCount
]);
return /*#__PURE__*/ jsxRuntime.jsx(PaginationContext.Provider, {
value: paginationValue,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
tag: "nav",
"aria-label": label,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
tag: "ul",
gap: 1,
children: children
})
})
});
};
exports.Pagination = Pagination;
exports.usePagination = usePagination;
//# sourceMappingURL=Pagination.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Pagination.js","sources":["../../../../../../admin/src/components/AssetDialog/BrowseStep/PaginationFooter/Pagination.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex } from '@strapi/design-system';\n\nconst PaginationContext = React.createContext({ activePage: 1, pageCount: 1 });\nexport const usePagination = () => React.useContext(PaginationContext);\n\ninterface PaginationProps {\n activePage: number;\n children: React.ReactNode;\n label?: string;\n pageCount: number;\n}\n\nexport const Pagination = ({\n children,\n activePage,\n pageCount,\n label = 'pagination',\n}: PaginationProps) => {\n const paginationValue = React.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);\n\n return (\n <PaginationContext.Provider value={paginationValue}>\n <Box tag=\"nav\" aria-label={label}>\n <Flex tag=\"ul\" gap={1}>\n {children}\n </Flex>\n </Box>\n </PaginationContext.Provider>\n );\n};\n"],"names":["PaginationContext","React","createContext","activePage","pageCount","usePagination","useContext","Pagination","children","label","paginationValue","useMemo","_jsx","Provider","value","Box","tag","aria-label","Flex","gap"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAMA,iBAAAA,iBAAoBC,gBAAMC,CAAAA,aAAa,CAAC;IAAEC,UAAY,EAAA,CAAA;IAAGC,SAAW,EAAA;AAAE,CAAA,CAAA;MAC/DC,aAAgB,GAAA,IAAMJ,gBAAMK,CAAAA,UAAU,CAACN,iBAAmB;AAS1DO,MAAAA,UAAAA,GAAa,CAAC,EACzBC,QAAQ,EACRL,UAAU,EACVC,SAAS,EACTK,KAAQ,GAAA,YAAY,EACJ,GAAA;AAChB,IAAA,MAAMC,eAAkBT,GAAAA,gBAAAA,CAAMU,OAAO,CAAC,KAAO;AAAER,YAAAA,UAAAA;AAAYC,YAAAA;AAAU,SAAA,CAAI,EAAA;AAACD,QAAAA,UAAAA;AAAYC,QAAAA;AAAU,KAAA,CAAA;IAEhG,qBACEQ,cAAA,CAACZ,kBAAkBa,QAAQ,EAAA;QAACC,KAAOJ,EAAAA,eAAAA;AACjC,QAAA,QAAA,gBAAAE,cAACG,CAAAA,gBAAAA,EAAAA;YAAIC,GAAI,EAAA,KAAA;YAAMC,YAAYR,EAAAA,KAAAA;AACzB,YAAA,QAAA,gBAAAG,cAACM,CAAAA,iBAAAA,EAAAA;gBAAKF,GAAI,EAAA,IAAA;gBAAKG,GAAK,EAAA,CAAA;AACjBX,gBAAAA,QAAAA,EAAAA;;;;AAKX;;;;;"}

View File

@@ -0,0 +1,33 @@
import { jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { Box, Flex } from '@strapi/design-system';
const PaginationContext = /*#__PURE__*/ React.createContext({
activePage: 1,
pageCount: 1
});
const usePagination = ()=>React.useContext(PaginationContext);
const Pagination = ({ children, activePage, pageCount, label = 'pagination' })=>{
const paginationValue = React.useMemo(()=>({
activePage,
pageCount
}), [
activePage,
pageCount
]);
return /*#__PURE__*/ jsx(PaginationContext.Provider, {
value: paginationValue,
children: /*#__PURE__*/ jsx(Box, {
tag: "nav",
"aria-label": label,
children: /*#__PURE__*/ jsx(Flex, {
tag: "ul",
gap: 1,
children: children
})
})
});
};
export { Pagination, usePagination };
//# sourceMappingURL=Pagination.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"Pagination.mjs","sources":["../../../../../../admin/src/components/AssetDialog/BrowseStep/PaginationFooter/Pagination.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex } from '@strapi/design-system';\n\nconst PaginationContext = React.createContext({ activePage: 1, pageCount: 1 });\nexport const usePagination = () => React.useContext(PaginationContext);\n\ninterface PaginationProps {\n activePage: number;\n children: React.ReactNode;\n label?: string;\n pageCount: number;\n}\n\nexport const Pagination = ({\n children,\n activePage,\n pageCount,\n label = 'pagination',\n}: PaginationProps) => {\n const paginationValue = React.useMemo(() => ({ activePage, pageCount }), [activePage, pageCount]);\n\n return (\n <PaginationContext.Provider value={paginationValue}>\n <Box tag=\"nav\" aria-label={label}>\n <Flex tag=\"ul\" gap={1}>\n {children}\n </Flex>\n </Box>\n </PaginationContext.Provider>\n );\n};\n"],"names":["PaginationContext","React","createContext","activePage","pageCount","usePagination","useContext","Pagination","children","label","paginationValue","useMemo","_jsx","Provider","value","Box","tag","aria-label","Flex","gap"],"mappings":";;;;AAIA,MAAMA,iBAAAA,iBAAoBC,KAAMC,CAAAA,aAAa,CAAC;IAAEC,UAAY,EAAA,CAAA;IAAGC,SAAW,EAAA;AAAE,CAAA,CAAA;MAC/DC,aAAgB,GAAA,IAAMJ,KAAMK,CAAAA,UAAU,CAACN,iBAAmB;AAS1DO,MAAAA,UAAAA,GAAa,CAAC,EACzBC,QAAQ,EACRL,UAAU,EACVC,SAAS,EACTK,KAAQ,GAAA,YAAY,EACJ,GAAA;AAChB,IAAA,MAAMC,eAAkBT,GAAAA,KAAAA,CAAMU,OAAO,CAAC,KAAO;AAAER,YAAAA,UAAAA;AAAYC,YAAAA;AAAU,SAAA,CAAI,EAAA;AAACD,QAAAA,UAAAA;AAAYC,QAAAA;AAAU,KAAA,CAAA;IAEhG,qBACEQ,GAAA,CAACZ,kBAAkBa,QAAQ,EAAA;QAACC,KAAOJ,EAAAA,eAAAA;AACjC,QAAA,QAAA,gBAAAE,GAACG,CAAAA,GAAAA,EAAAA;YAAIC,GAAI,EAAA,KAAA;YAAMC,YAAYR,EAAAA,KAAAA;AACzB,YAAA,QAAA,gBAAAG,GAACM,CAAAA,IAAAA,EAAAA;gBAAKF,GAAI,EAAA,IAAA;gBAAKG,GAAK,EAAA,CAAA;AACjBX,gBAAAA,QAAAA,EAAAA;;;;AAKX;;;;"}

View File

@@ -0,0 +1,378 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var reactIntl = require('react-intl');
var styledComponents = require('styled-components');
var Pagination = require('./Pagination.js');
// TODO: find a better naming convention for the file that was an index file before
const PaginationText = styledComponents.styled(designSystem.Typography)`
line-height: revert;
`;
const linkWrapperStyles = styledComponents.css`
padding: ${({ theme })=>theme.spaces[3]};
border-radius: ${({ theme })=>theme.borderRadius};
box-shadow: ${({ $active, theme })=>$active ? theme.shadows.filterShadow : undefined};
text-decoration: none;
display: flex;
position: relative;
outline: none;
&:after {
transition-property: all;
transition-duration: 0.2s;
border-radius: 8px;
content: '';
position: absolute;
top: -4px;
bottom: -4px;
left: -4px;
right: -4px;
border: 2px solid transparent;
}
&:focus-visible {
outline: none;
&:after {
border-radius: 8px;
content: '';
position: absolute;
top: -5px;
bottom: -5px;
left: -5px;
right: -5px;
border: 2px solid ${(props)=>props.theme.colors.primary600};
}
}
`;
const LinkWrapperButton = styledComponents.styled.button`
${linkWrapperStyles}
`;
const LinkWrapperDiv = styledComponents.styled.div`
${linkWrapperStyles}
`;
LinkWrapperButton.defaultProps = {
type: 'button'
};
const PageLinkWrapper = styledComponents.styled(LinkWrapperButton)`
color: ${({ theme, $active })=>$active ? theme.colors.primary700 : theme.colors.neutral800};
background: ${({ theme, $active })=>$active ? theme.colors.neutral0 : undefined};
&:hover {
box-shadow: ${({ theme })=>theme.shadows.filterShadow};
}
`;
const ActionLinkWrapper = styledComponents.styled(LinkWrapperButton)`
font-size: 1.1rem;
svg path {
fill: ${(p)=>p['aria-disabled'] ? p.theme.colors.neutral300 : p.theme.colors.neutral600};
}
&:focus,
&:hover {
svg path {
fill: ${(p)=>p['aria-disabled'] ? p.theme.colors.neutral300 : p.theme.colors.neutral700};
}
}
${(p)=>p['aria-disabled'] ? `
pointer-events: none;
` : undefined}
`;
const DotsWrapper = styledComponents.styled(LinkWrapperDiv)`
color: ${({ theme })=>theme.colors.neutral800};
`;
const PreviousLink = ({ children, ...props })=>{
const { activePage } = Pagination.usePagination();
const disabled = activePage === 1;
return /*#__PURE__*/ jsxRuntime.jsx("li", {
children: /*#__PURE__*/ jsxRuntime.jsxs(ActionLinkWrapper, {
"aria-disabled": disabled,
tabIndex: disabled ? -1 : undefined,
...props,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsxRuntime.jsx(icons.ChevronLeft, {
"aria-hidden": true
})
]
})
});
};
const NextLink = ({ children, ...props })=>{
const { activePage, pageCount } = Pagination.usePagination();
const disabled = activePage === pageCount;
return /*#__PURE__*/ jsxRuntime.jsx("li", {
children: /*#__PURE__*/ jsxRuntime.jsxs(ActionLinkWrapper, {
"aria-disabled": disabled,
tabIndex: disabled ? -1 : undefined,
...props,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsxRuntime.jsx(icons.ChevronRight, {
"aria-hidden": true
})
]
})
});
};
const PageLink = ({ number, children, ...props })=>{
const { activePage } = Pagination.usePagination();
const isActive = activePage === number;
return /*#__PURE__*/ jsxRuntime.jsx("li", {
children: /*#__PURE__*/ jsxRuntime.jsxs(PageLinkWrapper, {
...props,
$active: isActive,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsxRuntime.jsx(PaginationText, {
"aria-hidden": true,
variant: "pi",
fontWeight: isActive ? 'bold' : '',
children: number
})
]
})
});
};
const Dots = ({ children, ...props })=>/*#__PURE__*/ jsxRuntime.jsx("li", {
children: /*#__PURE__*/ jsxRuntime.jsxs(DotsWrapper, {
...props,
as: "div",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsxRuntime.jsx(PaginationText, {
"aria-hidden": true,
small: true,
children: "…"
})
]
})
});
const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount } })=>{
const { formatMessage } = reactIntl.useIntl();
const previousActivePage = activePage - 1;
const nextActivePage = activePage + 1;
const firstLinks = [
/*#__PURE__*/ jsxRuntime.jsx(PageLink, {
number: 1,
onClick: ()=>{
onChangePage(1);
},
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: 1
})
}, 1)
];
if (pageCount <= 4) {
const links = Array.from({
length: pageCount
}).map((_, i)=>i + 1).map((number)=>{
return /*#__PURE__*/ jsxRuntime.jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number);
});
return /*#__PURE__*/ jsxRuntime.jsxs(Pagination.Pagination, {
activePage: activePage,
pageCount: pageCount,
children: [
/*#__PURE__*/ jsxRuntime.jsx(PreviousLink, {
onClick: ()=>onChangePage(previousActivePage),
children: formatMessage({
id: 'components.pagination.go-to-previous',
defaultMessage: 'Go to previous page'
})
}),
links,
/*#__PURE__*/ jsxRuntime.jsx(NextLink, {
onClick: ()=>onChangePage(nextActivePage),
children: formatMessage({
id: 'components.pagination.go-to-next',
defaultMessage: 'Go to next page'
})
})
]
});
}
let firstLinksToCreate = [];
const lastLinks = [];
let lastLinksToCreate = [];
const middleLinks = [];
if (pageCount > 1) {
lastLinks.push(/*#__PURE__*/ jsxRuntime.jsx(PageLink, {
number: pageCount,
onClick: ()=>onChangePage(pageCount),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: pageCount
})
}, pageCount));
}
if (activePage === 1 && pageCount >= 3) {
firstLinksToCreate = [
2
];
}
if (activePage === 2 && pageCount >= 3) {
if (pageCount === 5) {
firstLinksToCreate = [
2,
3,
4
];
} else if (pageCount === 3) {
firstLinksToCreate = [
2
];
} else {
firstLinksToCreate = [
2,
3
];
}
}
if (activePage === 4 && pageCount >= 3) {
firstLinksToCreate = [
2
];
}
if (activePage === pageCount && pageCount >= 3) {
lastLinksToCreate = [
pageCount - 1
];
}
if (activePage === pageCount - 2 && pageCount > 3) {
lastLinksToCreate = [
activePage + 1,
activePage,
activePage - 1
];
}
if (activePage === pageCount - 3 && pageCount > 3 && activePage > 5) {
lastLinksToCreate = [
activePage + 2,
activePage + 1,
activePage,
activePage - 1
];
}
if (activePage === pageCount - 1 && pageCount > 3) {
lastLinksToCreate = [
activePage,
activePage - 1
];
}
lastLinksToCreate.forEach((number)=>{
lastLinks.unshift(/*#__PURE__*/ jsxRuntime.jsxs(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: [
"Go to page ",
number
]
}, number));
});
firstLinksToCreate.forEach((number)=>{
firstLinks.push(/*#__PURE__*/ jsxRuntime.jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number));
});
if (![
1,
2
].includes(activePage) && activePage <= pageCount - 3 && firstLinks.length + lastLinks.length < 6) {
const middleLinksToCreate = [
activePage - 1,
activePage,
activePage + 1
];
middleLinksToCreate.forEach((number)=>{
middleLinks.push(/*#__PURE__*/ jsxRuntime.jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number));
});
}
const shouldShowDotsAfterFirstLink = pageCount > 5 || pageCount === 5 && (activePage === 1 || activePage === 5);
const shouldShowMiddleDots = middleLinks.length > 2 && activePage > 4 && pageCount > 5;
const beforeDotsLinksLength = shouldShowMiddleDots ? pageCount - activePage - 1 : pageCount - firstLinks.length - lastLinks.length;
const afterDotsLength = shouldShowMiddleDots ? pageCount - firstLinks.length - lastLinks.length : pageCount - activePage - 1;
return /*#__PURE__*/ jsxRuntime.jsxs(Pagination.Pagination, {
activePage: activePage,
pageCount: pageCount,
children: [
/*#__PURE__*/ jsxRuntime.jsx(PreviousLink, {
onClick: ()=>onChangePage(previousActivePage),
children: formatMessage({
id: 'components.pagination.go-to-previous',
defaultMessage: 'Go to previous page'
})
}),
firstLinks,
shouldShowMiddleDots && /*#__PURE__*/ jsxRuntime.jsx(Dots, {
children: formatMessage({
id: 'components.pagination.remaining-links',
defaultMessage: 'And {number} other links'
}, {
number: beforeDotsLinksLength
})
}),
middleLinks,
shouldShowDotsAfterFirstLink && /*#__PURE__*/ jsxRuntime.jsx(Dots, {
children: formatMessage({
id: 'components.pagination.remaining-links',
defaultMessage: 'And {number} other links'
}, {
number: afterDotsLength
})
}),
lastLinks,
/*#__PURE__*/ jsxRuntime.jsx(NextLink, {
onClick: ()=>onChangePage(nextActivePage),
children: formatMessage({
id: 'components.pagination.go-to-next',
defaultMessage: 'Go to next page'
})
})
]
});
};
exports.PaginationFooter = PaginationFooter;
//# sourceMappingURL=PaginationFooter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,376 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { Typography, VisuallyHidden } from '@strapi/design-system';
import { ChevronLeft, ChevronRight } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { styled, css } from 'styled-components';
import { Pagination, usePagination } from './Pagination.mjs';
// TODO: find a better naming convention for the file that was an index file before
const PaginationText = styled(Typography)`
line-height: revert;
`;
const linkWrapperStyles = css`
padding: ${({ theme })=>theme.spaces[3]};
border-radius: ${({ theme })=>theme.borderRadius};
box-shadow: ${({ $active, theme })=>$active ? theme.shadows.filterShadow : undefined};
text-decoration: none;
display: flex;
position: relative;
outline: none;
&:after {
transition-property: all;
transition-duration: 0.2s;
border-radius: 8px;
content: '';
position: absolute;
top: -4px;
bottom: -4px;
left: -4px;
right: -4px;
border: 2px solid transparent;
}
&:focus-visible {
outline: none;
&:after {
border-radius: 8px;
content: '';
position: absolute;
top: -5px;
bottom: -5px;
left: -5px;
right: -5px;
border: 2px solid ${(props)=>props.theme.colors.primary600};
}
}
`;
const LinkWrapperButton = styled.button`
${linkWrapperStyles}
`;
const LinkWrapperDiv = styled.div`
${linkWrapperStyles}
`;
LinkWrapperButton.defaultProps = {
type: 'button'
};
const PageLinkWrapper = styled(LinkWrapperButton)`
color: ${({ theme, $active })=>$active ? theme.colors.primary700 : theme.colors.neutral800};
background: ${({ theme, $active })=>$active ? theme.colors.neutral0 : undefined};
&:hover {
box-shadow: ${({ theme })=>theme.shadows.filterShadow};
}
`;
const ActionLinkWrapper = styled(LinkWrapperButton)`
font-size: 1.1rem;
svg path {
fill: ${(p)=>p['aria-disabled'] ? p.theme.colors.neutral300 : p.theme.colors.neutral600};
}
&:focus,
&:hover {
svg path {
fill: ${(p)=>p['aria-disabled'] ? p.theme.colors.neutral300 : p.theme.colors.neutral700};
}
}
${(p)=>p['aria-disabled'] ? `
pointer-events: none;
` : undefined}
`;
const DotsWrapper = styled(LinkWrapperDiv)`
color: ${({ theme })=>theme.colors.neutral800};
`;
const PreviousLink = ({ children, ...props })=>{
const { activePage } = usePagination();
const disabled = activePage === 1;
return /*#__PURE__*/ jsx("li", {
children: /*#__PURE__*/ jsxs(ActionLinkWrapper, {
"aria-disabled": disabled,
tabIndex: disabled ? -1 : undefined,
...props,
children: [
/*#__PURE__*/ jsx(VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsx(ChevronLeft, {
"aria-hidden": true
})
]
})
});
};
const NextLink = ({ children, ...props })=>{
const { activePage, pageCount } = usePagination();
const disabled = activePage === pageCount;
return /*#__PURE__*/ jsx("li", {
children: /*#__PURE__*/ jsxs(ActionLinkWrapper, {
"aria-disabled": disabled,
tabIndex: disabled ? -1 : undefined,
...props,
children: [
/*#__PURE__*/ jsx(VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsx(ChevronRight, {
"aria-hidden": true
})
]
})
});
};
const PageLink = ({ number, children, ...props })=>{
const { activePage } = usePagination();
const isActive = activePage === number;
return /*#__PURE__*/ jsx("li", {
children: /*#__PURE__*/ jsxs(PageLinkWrapper, {
...props,
$active: isActive,
children: [
/*#__PURE__*/ jsx(VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsx(PaginationText, {
"aria-hidden": true,
variant: "pi",
fontWeight: isActive ? 'bold' : '',
children: number
})
]
})
});
};
const Dots = ({ children, ...props })=>/*#__PURE__*/ jsx("li", {
children: /*#__PURE__*/ jsxs(DotsWrapper, {
...props,
as: "div",
children: [
/*#__PURE__*/ jsx(VisuallyHidden, {
children: children
}),
/*#__PURE__*/ jsx(PaginationText, {
"aria-hidden": true,
small: true,
children: "…"
})
]
})
});
const PaginationFooter = ({ activePage, onChangePage, pagination: { pageCount } })=>{
const { formatMessage } = useIntl();
const previousActivePage = activePage - 1;
const nextActivePage = activePage + 1;
const firstLinks = [
/*#__PURE__*/ jsx(PageLink, {
number: 1,
onClick: ()=>{
onChangePage(1);
},
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: 1
})
}, 1)
];
if (pageCount <= 4) {
const links = Array.from({
length: pageCount
}).map((_, i)=>i + 1).map((number)=>{
return /*#__PURE__*/ jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number);
});
return /*#__PURE__*/ jsxs(Pagination, {
activePage: activePage,
pageCount: pageCount,
children: [
/*#__PURE__*/ jsx(PreviousLink, {
onClick: ()=>onChangePage(previousActivePage),
children: formatMessage({
id: 'components.pagination.go-to-previous',
defaultMessage: 'Go to previous page'
})
}),
links,
/*#__PURE__*/ jsx(NextLink, {
onClick: ()=>onChangePage(nextActivePage),
children: formatMessage({
id: 'components.pagination.go-to-next',
defaultMessage: 'Go to next page'
})
})
]
});
}
let firstLinksToCreate = [];
const lastLinks = [];
let lastLinksToCreate = [];
const middleLinks = [];
if (pageCount > 1) {
lastLinks.push(/*#__PURE__*/ jsx(PageLink, {
number: pageCount,
onClick: ()=>onChangePage(pageCount),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: pageCount
})
}, pageCount));
}
if (activePage === 1 && pageCount >= 3) {
firstLinksToCreate = [
2
];
}
if (activePage === 2 && pageCount >= 3) {
if (pageCount === 5) {
firstLinksToCreate = [
2,
3,
4
];
} else if (pageCount === 3) {
firstLinksToCreate = [
2
];
} else {
firstLinksToCreate = [
2,
3
];
}
}
if (activePage === 4 && pageCount >= 3) {
firstLinksToCreate = [
2
];
}
if (activePage === pageCount && pageCount >= 3) {
lastLinksToCreate = [
pageCount - 1
];
}
if (activePage === pageCount - 2 && pageCount > 3) {
lastLinksToCreate = [
activePage + 1,
activePage,
activePage - 1
];
}
if (activePage === pageCount - 3 && pageCount > 3 && activePage > 5) {
lastLinksToCreate = [
activePage + 2,
activePage + 1,
activePage,
activePage - 1
];
}
if (activePage === pageCount - 1 && pageCount > 3) {
lastLinksToCreate = [
activePage,
activePage - 1
];
}
lastLinksToCreate.forEach((number)=>{
lastLinks.unshift(/*#__PURE__*/ jsxs(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: [
"Go to page ",
number
]
}, number));
});
firstLinksToCreate.forEach((number)=>{
firstLinks.push(/*#__PURE__*/ jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number));
});
if (![
1,
2
].includes(activePage) && activePage <= pageCount - 3 && firstLinks.length + lastLinks.length < 6) {
const middleLinksToCreate = [
activePage - 1,
activePage,
activePage + 1
];
middleLinksToCreate.forEach((number)=>{
middleLinks.push(/*#__PURE__*/ jsx(PageLink, {
number: number,
onClick: ()=>onChangePage(number),
children: formatMessage({
id: 'components.pagination.go-to',
defaultMessage: 'Go to page {page}'
}, {
page: number
})
}, number));
});
}
const shouldShowDotsAfterFirstLink = pageCount > 5 || pageCount === 5 && (activePage === 1 || activePage === 5);
const shouldShowMiddleDots = middleLinks.length > 2 && activePage > 4 && pageCount > 5;
const beforeDotsLinksLength = shouldShowMiddleDots ? pageCount - activePage - 1 : pageCount - firstLinks.length - lastLinks.length;
const afterDotsLength = shouldShowMiddleDots ? pageCount - firstLinks.length - lastLinks.length : pageCount - activePage - 1;
return /*#__PURE__*/ jsxs(Pagination, {
activePage: activePage,
pageCount: pageCount,
children: [
/*#__PURE__*/ jsx(PreviousLink, {
onClick: ()=>onChangePage(previousActivePage),
children: formatMessage({
id: 'components.pagination.go-to-previous',
defaultMessage: 'Go to previous page'
})
}),
firstLinks,
shouldShowMiddleDots && /*#__PURE__*/ jsx(Dots, {
children: formatMessage({
id: 'components.pagination.remaining-links',
defaultMessage: 'And {number} other links'
}, {
number: beforeDotsLinksLength
})
}),
middleLinks,
shouldShowDotsAfterFirstLink && /*#__PURE__*/ jsx(Dots, {
children: formatMessage({
id: 'components.pagination.remaining-links',
defaultMessage: 'And {number} other links'
}, {
number: afterDotsLength
})
}),
lastLinks,
/*#__PURE__*/ jsx(NextLink, {
onClick: ()=>onChangePage(nextActivePage),
children: formatMessage({
id: 'components.pagination.go-to-next',
defaultMessage: 'Go to next page'
})
})
]
});
};
export { PaginationFooter };
//# sourceMappingURL=PaginationFooter.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,102 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var reactIntl = require('react-intl');
require('byte-size');
require('date-fns');
var getTrad = require('../../../../utils/getTrad.js');
require('qs');
require('../../../../constants.js');
require('../../../../utils/urlYupSchema.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
// TODO: find a better naming convention for the file that was an index file before
const SearchAsset = ({ onChangeSearch, queryValue = null })=>{
const { formatMessage } = reactIntl.useIntl();
const { trackUsage } = strapiAdmin.useTracking();
const [isOpen, setIsOpen] = React__namespace.useState(!!queryValue);
const [value, setValue] = React__namespace.useState(queryValue || '');
const wrapperRef = React__namespace.useRef(null);
React__namespace.useLayoutEffect(()=>{
if (isOpen) {
setTimeout(()=>{
wrapperRef.current?.querySelector('input')?.focus();
}, 0);
}
}, [
isOpen
]);
const handleToggle = ()=>{
setIsOpen((prev)=>!prev);
};
const handleClear = ()=>{
handleToggle();
onChangeSearch(null);
};
const handleSubmit = (e)=>{
e.preventDefault();
e.stopPropagation();
trackUsage('didSearchMediaLibraryElements', {
location: 'content-manager'
});
onChangeSearch(value);
};
if (isOpen) {
return /*#__PURE__*/ jsxRuntime.jsx("div", {
ref: wrapperRef,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.SearchForm, {
onSubmit: handleSubmit,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Searchbar, {
name: "search",
onClear: handleClear,
onChange: (e)=>setValue(e.target.value),
clearLabel: formatMessage({
id: getTrad.getTrad('search.clear.label'),
defaultMessage: 'Clear the search'
}),
"aria-label": "search",
size: "S",
value: value,
placeholder: formatMessage({
id: getTrad.getTrad('search.placeholder'),
defaultMessage: 'e.g: the first dog on the moon'
}),
children: formatMessage({
id: getTrad.getTrad('search.label'),
defaultMessage: 'Search for an asset'
})
})
})
});
}
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
label: "Search",
onClick: handleToggle,
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Search, {})
});
};
exports.SearchAsset = SearchAsset;
//# sourceMappingURL=SearchAsset.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,81 @@
import { jsx } from 'react/jsx-runtime';
import * as React from 'react';
import { useTracking } from '@strapi/admin/strapi-admin';
import { SearchForm, Searchbar, IconButton } from '@strapi/design-system';
import { Search } from '@strapi/icons';
import { useIntl } from 'react-intl';
import 'byte-size';
import 'date-fns';
import { getTrad } from '../../../../utils/getTrad.mjs';
import 'qs';
import '../../../../constants.mjs';
import '../../../../utils/urlYupSchema.mjs';
// TODO: find a better naming convention for the file that was an index file before
const SearchAsset = ({ onChangeSearch, queryValue = null })=>{
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const [isOpen, setIsOpen] = React.useState(!!queryValue);
const [value, setValue] = React.useState(queryValue || '');
const wrapperRef = React.useRef(null);
React.useLayoutEffect(()=>{
if (isOpen) {
setTimeout(()=>{
wrapperRef.current?.querySelector('input')?.focus();
}, 0);
}
}, [
isOpen
]);
const handleToggle = ()=>{
setIsOpen((prev)=>!prev);
};
const handleClear = ()=>{
handleToggle();
onChangeSearch(null);
};
const handleSubmit = (e)=>{
e.preventDefault();
e.stopPropagation();
trackUsage('didSearchMediaLibraryElements', {
location: 'content-manager'
});
onChangeSearch(value);
};
if (isOpen) {
return /*#__PURE__*/ jsx("div", {
ref: wrapperRef,
children: /*#__PURE__*/ jsx(SearchForm, {
onSubmit: handleSubmit,
children: /*#__PURE__*/ jsx(Searchbar, {
name: "search",
onClear: handleClear,
onChange: (e)=>setValue(e.target.value),
clearLabel: formatMessage({
id: getTrad('search.clear.label'),
defaultMessage: 'Clear the search'
}),
"aria-label": "search",
size: "S",
value: value,
placeholder: formatMessage({
id: getTrad('search.placeholder'),
defaultMessage: 'e.g: the first dog on the moon'
}),
children: formatMessage({
id: getTrad('search.label'),
defaultMessage: 'Search for an asset'
})
})
})
});
}
return /*#__PURE__*/ jsx(IconButton, {
label: "Search",
onClick: handleToggle,
children: /*#__PURE__*/ jsx(Search, {})
});
};
export { SearchAsset };
//# sourceMappingURL=SearchAsset.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
'use strict';
const isSelectable = (allowedTypes, mime = '')=>{
if (!mime) return false;
const fileType = mime.split('/')[0];
return allowedTypes.includes(fileType) || allowedTypes.includes('file') && ![
'video',
'image',
'audio'
].includes(fileType);
};
exports.isSelectable = isSelectable;
//# sourceMappingURL=isSelectable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isSelectable.js","sources":["../../../../../../admin/src/components/AssetDialog/BrowseStep/utils/isSelectable.ts"],"sourcesContent":["export const isSelectable = (allowedTypes: string[], mime = '') => {\n if (!mime) return false;\n\n const fileType = mime.split('/')[0];\n\n return (\n allowedTypes.includes(fileType) ||\n (allowedTypes.includes('file') && !['video', 'image', 'audio'].includes(fileType))\n );\n};\n"],"names":["isSelectable","allowedTypes","mime","fileType","split","includes"],"mappings":";;AAAaA,MAAAA,YAAAA,GAAe,CAACC,YAAAA,EAAwBC,OAAO,EAAE,GAAA;IAC5D,IAAI,CAACA,MAAM,OAAO,KAAA;AAElB,IAAA,MAAMC,WAAWD,IAAKE,CAAAA,KAAK,CAAC,GAAA,CAAI,CAAC,CAAE,CAAA;IAEnC,OACEH,YAAAA,CAAaI,QAAQ,CAACF,QAAAA,CAAAA,IACrBF,aAAaI,QAAQ,CAAC,WAAW,CAAC;AAAC,QAAA,OAAA;AAAS,QAAA,OAAA;AAAS,QAAA;AAAQ,KAAA,CAACA,QAAQ,CAACF,QAAAA,CAAAA;AAE5E;;;;"}

View File

@@ -0,0 +1,12 @@
const isSelectable = (allowedTypes, mime = '')=>{
if (!mime) return false;
const fileType = mime.split('/')[0];
return allowedTypes.includes(fileType) || allowedTypes.includes('file') && ![
'video',
'image',
'audio'
].includes(fileType);
};
export { isSelectable };
//# sourceMappingURL=isSelectable.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"isSelectable.mjs","sources":["../../../../../../admin/src/components/AssetDialog/BrowseStep/utils/isSelectable.ts"],"sourcesContent":["export const isSelectable = (allowedTypes: string[], mime = '') => {\n if (!mime) return false;\n\n const fileType = mime.split('/')[0];\n\n return (\n allowedTypes.includes(fileType) ||\n (allowedTypes.includes('file') && !['video', 'image', 'audio'].includes(fileType))\n );\n};\n"],"names":["isSelectable","allowedTypes","mime","fileType","split","includes"],"mappings":"AAAaA,MAAAA,YAAAA,GAAe,CAACC,YAAAA,EAAwBC,OAAO,EAAE,GAAA;IAC5D,IAAI,CAACA,MAAM,OAAO,KAAA;AAElB,IAAA,MAAMC,WAAWD,IAAKE,CAAAA,KAAK,CAAC,GAAA,CAAI,CAAC,CAAE,CAAA;IAEnC,OACEH,YAAAA,CAAaI,QAAQ,CAACF,QAAAA,CAAAA,IACrBF,aAAaI,QAAQ,CAAC,WAAW,CAAC;AAAC,QAAA,OAAA;AAAS,QAAA,OAAA;AAAS,QAAA;AAAQ,KAAA,CAACA,QAAQ,CAACF,QAAAA,CAAAA;AAE5E;;;;"}

View File

@@ -0,0 +1,31 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
const DialogFooter = ({ onClose, onValidate })=>{
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Footer, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
onClick: onClose,
variant: "tertiary",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
}),
onValidate && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
onClick: onValidate,
children: formatMessage({
id: 'global.finish',
defaultMessage: 'Finish'
})
})
]
});
};
exports.DialogFooter = DialogFooter;
//# sourceMappingURL=DialogFooter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DialogFooter.js","sources":["../../../../admin/src/components/AssetDialog/DialogFooter.tsx"],"sourcesContent":["import { Button, Modal } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\ninterface DialogFooterProps {\n onClose: () => void;\n onValidate?: () => void;\n}\n\nexport const DialogFooter = ({ onClose, onValidate }: DialogFooterProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Modal.Footer>\n <Button onClick={onClose} variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n {onValidate && (\n <Button onClick={onValidate}>\n {formatMessage({ id: 'global.finish', defaultMessage: 'Finish' })}\n </Button>\n )}\n </Modal.Footer>\n );\n};\n"],"names":["DialogFooter","onClose","onValidate","formatMessage","useIntl","_jsxs","Modal","Footer","_jsx","Button","onClick","variant","id","defaultMessage"],"mappings":";;;;;;MAQaA,YAAe,GAAA,CAAC,EAAEC,OAAO,EAAEC,UAAU,EAAqB,GAAA;IACrE,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;IAE1B,qBACEC,eAAA,CAACC,mBAAMC,MAAM,EAAA;;0BACXC,cAACC,CAAAA,mBAAAA,EAAAA;gBAAOC,OAAST,EAAAA,OAAAA;gBAASU,OAAQ,EAAA,UAAA;0BAC/BR,aAAc,CAAA;oBAAES,EAAI,EAAA,8BAAA;oBAAgCC,cAAgB,EAAA;AAAS,iBAAA;;AAE/EX,YAAAA,UAAAA,kBACCM,cAACC,CAAAA,mBAAAA,EAAAA;gBAAOC,OAASR,EAAAA,UAAAA;0BACdC,aAAc,CAAA;oBAAES,EAAI,EAAA,eAAA;oBAAiBC,cAAgB,EAAA;AAAS,iBAAA;;;;AAKzE;;;;"}

View File

@@ -0,0 +1,29 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { Modal, Button } from '@strapi/design-system';
import { useIntl } from 'react-intl';
const DialogFooter = ({ onClose, onValidate })=>{
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsxs(Modal.Footer, {
children: [
/*#__PURE__*/ jsx(Button, {
onClick: onClose,
variant: "tertiary",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
}),
onValidate && /*#__PURE__*/ jsx(Button, {
onClick: onValidate,
children: formatMessage({
id: 'global.finish',
defaultMessage: 'Finish'
})
})
]
});
};
export { DialogFooter };
//# sourceMappingURL=DialogFooter.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DialogFooter.mjs","sources":["../../../../admin/src/components/AssetDialog/DialogFooter.tsx"],"sourcesContent":["import { Button, Modal } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\ninterface DialogFooterProps {\n onClose: () => void;\n onValidate?: () => void;\n}\n\nexport const DialogFooter = ({ onClose, onValidate }: DialogFooterProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Modal.Footer>\n <Button onClick={onClose} variant=\"tertiary\">\n {formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}\n </Button>\n {onValidate && (\n <Button onClick={onValidate}>\n {formatMessage({ id: 'global.finish', defaultMessage: 'Finish' })}\n </Button>\n )}\n </Modal.Footer>\n );\n};\n"],"names":["DialogFooter","onClose","onValidate","formatMessage","useIntl","_jsxs","Modal","Footer","_jsx","Button","onClick","variant","id","defaultMessage"],"mappings":";;;;MAQaA,YAAe,GAAA,CAAC,EAAEC,OAAO,EAAEC,UAAU,EAAqB,GAAA;IACrE,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,qBACEC,IAAA,CAACC,MAAMC,MAAM,EAAA;;0BACXC,GAACC,CAAAA,MAAAA,EAAAA;gBAAOC,OAAST,EAAAA,OAAAA;gBAASU,OAAQ,EAAA,UAAA;0BAC/BR,aAAc,CAAA;oBAAES,EAAI,EAAA,8BAAA;oBAAgCC,cAAgB,EAAA;AAAS,iBAAA;;AAE/EX,YAAAA,UAAAA,kBACCM,GAACC,CAAAA,MAAAA,EAAAA;gBAAOC,OAASR,EAAAA,UAAAA;0BACdC,aAAc,CAAA;oBAAES,EAAI,EAAA,eAAA;oBAAiBC,cAAgB,EAAA;AAAS,iBAAA;;;;AAKzE;;;;"}

View File

@@ -0,0 +1,60 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
require('byte-size');
require('date-fns');
var getTrad = require('../../../utils/getTrad.js');
require('qs');
require('../../../constants.js');
require('../../../utils/urlYupSchema.js');
var AssetGridList = require('../../AssetGridList/AssetGridList.js');
// TODO: find a better naming convention for the file that was an index file before
const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset })=>{
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
gap: 0,
direction: "column",
alignItems: "start",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "pi",
fontWeight: "bold",
textColor: "neutral800",
children: formatMessage({
id: getTrad.getTrad('list.assets.to-upload'),
defaultMessage: '{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload'
}, {
number: selectedAssets.length
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "pi",
textColor: "neutral600",
children: formatMessage({
id: getTrad.getTrad('modal.upload-list.sub-header-subtitle'),
defaultMessage: 'Manage the assets before adding them to the Media Library'
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(AssetGridList.AssetGridList, {
size: "S",
assets: selectedAssets,
onSelectAsset: onSelectAsset,
selectedAssets: selectedAssets,
onReorderAsset: onReorderAsset
})
]
});
};
exports.SelectedStep = SelectedStep;
//# sourceMappingURL=SelectedStep.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SelectedStep.js","sources":["../../../../../admin/src/components/AssetDialog/SelectedStep/SelectedStep.tsx"],"sourcesContent":["// TODO: find a better naming convention for the file that was an index file before\nimport { Flex, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { getTrad } from '../../../utils';\nimport { AssetGridList } from '../../AssetGridList/AssetGridList';\n\nimport type { File } from '../../../../../shared/contracts/files';\n\ninterface SelectedStepProps {\n onSelectAsset: (asset: File) => void;\n selectedAssets: File[];\n onReorderAsset?: (fromIndex: number, toIndex: number) => void;\n}\n\nexport const SelectedStep = ({\n selectedAssets,\n onSelectAsset,\n onReorderAsset,\n}: SelectedStepProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex gap={0} direction=\"column\" alignItems=\"start\">\n <Typography variant=\"pi\" fontWeight=\"bold\" textColor=\"neutral800\">\n {formatMessage(\n {\n id: getTrad('list.assets.to-upload'),\n defaultMessage:\n '{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',\n },\n { number: selectedAssets.length }\n )}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('modal.upload-list.sub-header-subtitle'),\n defaultMessage: 'Manage the assets before adding them to the Media Library',\n })}\n </Typography>\n </Flex>\n\n <AssetGridList\n size=\"S\"\n assets={selectedAssets}\n onSelectAsset={onSelectAsset}\n selectedAssets={selectedAssets}\n onReorderAsset={onReorderAsset}\n />\n </Flex>\n );\n};\n"],"names":["SelectedStep","selectedAssets","onSelectAsset","onReorderAsset","formatMessage","useIntl","_jsxs","Flex","direction","alignItems","gap","_jsx","Typography","variant","fontWeight","textColor","id","getTrad","defaultMessage","number","length","AssetGridList","size","assets"],"mappings":";;;;;;;;;;;;;AAAA;AAeO,MAAMA,eAAe,CAAC,EAC3BC,cAAc,EACdC,aAAa,EACbC,cAAc,EACI,GAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAE1B,IAAA,qBACEC,eAACC,CAAAA,iBAAAA,EAAAA;QAAKC,SAAU,EAAA,QAAA;QAASC,UAAW,EAAA,SAAA;QAAUC,GAAK,EAAA,CAAA;;0BACjDJ,eAACC,CAAAA,iBAAAA,EAAAA;gBAAKG,GAAK,EAAA,CAAA;gBAAGF,SAAU,EAAA,QAAA;gBAASC,UAAW,EAAA,OAAA;;kCAC1CE,cAACC,CAAAA,uBAAAA,EAAAA;wBAAWC,OAAQ,EAAA,IAAA;wBAAKC,UAAW,EAAA,MAAA;wBAAOC,SAAU,EAAA,YAAA;kCAClDX,aACC,CAAA;AACEY,4BAAAA,EAAAA,EAAIC,eAAQ,CAAA,uBAAA,CAAA;4BACZC,cACE,EAAA;yBAEJ,EAAA;AAAEC,4BAAAA,MAAAA,EAAQlB,eAAemB;AAAO,yBAAA;;kCAGpCT,cAACC,CAAAA,uBAAAA,EAAAA;wBAAWC,OAAQ,EAAA,IAAA;wBAAKE,SAAU,EAAA,YAAA;kCAChCX,aAAc,CAAA;AACbY,4BAAAA,EAAAA,EAAIC,eAAQ,CAAA,uCAAA,CAAA;4BACZC,cAAgB,EAAA;AAClB,yBAAA;;;;0BAIJP,cAACU,CAAAA,2BAAAA,EAAAA;gBACCC,IAAK,EAAA,GAAA;gBACLC,MAAQtB,EAAAA,cAAAA;gBACRC,aAAeA,EAAAA,aAAAA;gBACfD,cAAgBA,EAAAA,cAAAA;gBAChBE,cAAgBA,EAAAA;;;;AAIxB;;;;"}

View File

@@ -0,0 +1,58 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { Flex, Typography } from '@strapi/design-system';
import { useIntl } from 'react-intl';
import 'byte-size';
import 'date-fns';
import { getTrad } from '../../../utils/getTrad.mjs';
import 'qs';
import '../../../constants.mjs';
import '../../../utils/urlYupSchema.mjs';
import { AssetGridList } from '../../AssetGridList/AssetGridList.mjs';
// TODO: find a better naming convention for the file that was an index file before
const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset })=>{
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsxs(Flex, {
gap: 0,
direction: "column",
alignItems: "start",
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "pi",
fontWeight: "bold",
textColor: "neutral800",
children: formatMessage({
id: getTrad('list.assets.to-upload'),
defaultMessage: '{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload'
}, {
number: selectedAssets.length
})
}),
/*#__PURE__*/ jsx(Typography, {
variant: "pi",
textColor: "neutral600",
children: formatMessage({
id: getTrad('modal.upload-list.sub-header-subtitle'),
defaultMessage: 'Manage the assets before adding them to the Media Library'
})
})
]
}),
/*#__PURE__*/ jsx(AssetGridList, {
size: "S",
assets: selectedAssets,
onSelectAsset: onSelectAsset,
selectedAssets: selectedAssets,
onReorderAsset: onReorderAsset
})
]
});
};
export { SelectedStep };
//# sourceMappingURL=SelectedStep.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SelectedStep.mjs","sources":["../../../../../admin/src/components/AssetDialog/SelectedStep/SelectedStep.tsx"],"sourcesContent":["// TODO: find a better naming convention for the file that was an index file before\nimport { Flex, Typography } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { getTrad } from '../../../utils';\nimport { AssetGridList } from '../../AssetGridList/AssetGridList';\n\nimport type { File } from '../../../../../shared/contracts/files';\n\ninterface SelectedStepProps {\n onSelectAsset: (asset: File) => void;\n selectedAssets: File[];\n onReorderAsset?: (fromIndex: number, toIndex: number) => void;\n}\n\nexport const SelectedStep = ({\n selectedAssets,\n onSelectAsset,\n onReorderAsset,\n}: SelectedStepProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Flex gap={0} direction=\"column\" alignItems=\"start\">\n <Typography variant=\"pi\" fontWeight=\"bold\" textColor=\"neutral800\">\n {formatMessage(\n {\n id: getTrad('list.assets.to-upload'),\n defaultMessage:\n '{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',\n },\n { number: selectedAssets.length }\n )}\n </Typography>\n <Typography variant=\"pi\" textColor=\"neutral600\">\n {formatMessage({\n id: getTrad('modal.upload-list.sub-header-subtitle'),\n defaultMessage: 'Manage the assets before adding them to the Media Library',\n })}\n </Typography>\n </Flex>\n\n <AssetGridList\n size=\"S\"\n assets={selectedAssets}\n onSelectAsset={onSelectAsset}\n selectedAssets={selectedAssets}\n onReorderAsset={onReorderAsset}\n />\n </Flex>\n );\n};\n"],"names":["SelectedStep","selectedAssets","onSelectAsset","onReorderAsset","formatMessage","useIntl","_jsxs","Flex","direction","alignItems","gap","_jsx","Typography","variant","fontWeight","textColor","id","getTrad","defaultMessage","number","length","AssetGridList","size","assets"],"mappings":";;;;;;;;;;;AAAA;AAeO,MAAMA,eAAe,CAAC,EAC3BC,cAAc,EACdC,aAAa,EACbC,cAAc,EACI,GAAA;IAClB,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAE1B,IAAA,qBACEC,IAACC,CAAAA,IAAAA,EAAAA;QAAKC,SAAU,EAAA,QAAA;QAASC,UAAW,EAAA,SAAA;QAAUC,GAAK,EAAA,CAAA;;0BACjDJ,IAACC,CAAAA,IAAAA,EAAAA;gBAAKG,GAAK,EAAA,CAAA;gBAAGF,SAAU,EAAA,QAAA;gBAASC,UAAW,EAAA,OAAA;;kCAC1CE,GAACC,CAAAA,UAAAA,EAAAA;wBAAWC,OAAQ,EAAA,IAAA;wBAAKC,UAAW,EAAA,MAAA;wBAAOC,SAAU,EAAA,YAAA;kCAClDX,aACC,CAAA;AACEY,4BAAAA,EAAAA,EAAIC,OAAQ,CAAA,uBAAA,CAAA;4BACZC,cACE,EAAA;yBAEJ,EAAA;AAAEC,4BAAAA,MAAAA,EAAQlB,eAAemB;AAAO,yBAAA;;kCAGpCT,GAACC,CAAAA,UAAAA,EAAAA;wBAAWC,OAAQ,EAAA,IAAA;wBAAKE,SAAU,EAAA,YAAA;kCAChCX,aAAc,CAAA;AACbY,4BAAAA,EAAAA,EAAIC,OAAQ,CAAA,uCAAA,CAAA;4BACZC,cAAgB,EAAA;AAClB,yBAAA;;;;0BAIJP,GAACU,CAAAA,aAAAA,EAAAA;gBACCC,IAAK,EAAA,GAAA;gBACLC,MAAQtB,EAAAA,cAAAA;gBACRC,aAAeA,EAAAA,aAAAA;gBACfD,cAAgBA,EAAAA,cAAAA;gBAChBE,cAAgBA,EAAAA;;;;AAIxB;;;;"}