UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

87 lines (85 loc) 3.36 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import { FormattedMessage, useIntl } from 'react-intl'; import translations from './translations'; import React from 'react'; import List from '@mui/material/List'; import { DraggablePanelListItem } from '../DraggablePanelListItem/DraggablePanelListItem'; import EmptyState from '../EmptyState/EmptyState'; import { useComponentsPanelUI } from './styles'; import FormHelperText from '@mui/material/FormHelperText'; import Pagination from '../Pagination'; export function PreviewBrowseComponentsPanelUI(props) { const { items, onPageChanged, onDragStart, onDragEnd, onRowsPerPageChange, count, pageNumber, limit } = props; const { formatMessage } = useIntl(); const { classes } = useComponentsPanelUI(); return React.createElement( React.Fragment, null, React.createElement(Pagination, { count: count, rowsPerPage: limit, page: pageNumber, onPageChange: (e, page) => onPageChanged(page * limit), onRowsPerPageChange: onRowsPerPageChange }), React.createElement( 'div', { className: classes.browsePanelWrapper }, React.createElement( List, null, items.map((item) => React.createElement(DraggablePanelListItem, { key: item.craftercms.id, primaryText: item.craftercms.label, onDragStart: () => onDragStart(item), onDragEnd: onDragEnd }) ) ), count === 0 && React.createElement(EmptyState, { title: formatMessage(translations.noResults), classes: { image: classes.noResultsImage, title: classes.noResultsTitle } }), React.createElement( FormHelperText, { className: classes.helperTextWrapper }, React.createElement(FormattedMessage, { id: 'previewBrowseComponentsPanel.sharedComponentsHelperText', defaultMessage: 'Only shared components are shown here' }) ) ) ); } export default PreviewBrowseComponentsPanelUI;