// import dependencies import dotProp from 'dot-prop'; import SimpleBar from 'simplebar-react'; import React, { useState } from 'react'; import { Box, Card, useTheme, Avatar, Icon, IconButton, CardHeader, Button, Drawer, Typography, Divider, TextField } from '../'; // create dashup grid body const DashupUIBlockMenu = (props = {}) => { // theme const theme = useTheme(); // selected const [search, setSearch] = useState(''); const [selected, setSelected] = useState(null); // colors const colors = ['primary', 'info', 'success', 'warning', 'danger']; // available props.available.sort((a, b) => { // return sort return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }).forEach((item, i) => { // i let t = i; // while while (t > (colors.length - 1)) { t = t - colors.length; } // color item.color = item.color || colors[t]; }); return ( { props.title || 'Grid Blocks' } Select one of these blocks and click "Add Block" to add it to your grid. setSearch(e.target.value) } fullWidth placeholder="Filter Fields" /> { (props.available || []).sort((a, b) => { // return sort return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }).map((block, i) => { // search if (search && search.length) { // search string const str = `${block.type} ${block.title} ${block.description}`.toLowerCase(); // check search if (search.toLowerCase().split(' ').filter((t) => t.length).find((tag) => { // find in value return !str.includes(tag); })) return null; } // return jsx return ( setSelected(block.type) }> ) } title={ block.title } subheader={ block.description } /> ); }).filter((i) => i) } { !!selected && ( <> ) } ); }; // export default page menu export default DashupUIBlockMenu;