// import dependencies import dotProp from 'dot-prop'; import SimpleBar from 'simplebar-react'; import { ReactSortable } from 'react-sortablejs'; import React, { useRef, useState, useEffect } from 'react'; import { Box, Card, useTheme, Avatar, Icon, IconButton, CardHeader, Drawer, Typography, Divider, TextField } from '../'; // import on end import onEnd from './drag'; // let context let DashupUIContext = null; // create dashup grid body const DashupUIFormMenu = (props = {}) => { // theme const theme = useTheme(); // state const [search, setSearch] = useState(''); // colors const colors = ['primary', 'info', 'success', 'warning', 'danger']; // use ref const searchRef = useRef(null); // use effect useEffect(() => { // focus on search ref searchRef.current?.focus(); }, []); return ( { (data) => { // available data.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 || 'Form Fields' } Drag one of these fields into the form where you need it. setSearch(e.target.value) } fullWidth placeholder="Filter Fields" /> { // return sort return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }) } group={ data.id } onEnd={ (e) => onEnd(e, data.fields, data.setFields, data.onSaving, data.onConfig, props.onHide) } setList={ () => {} } > { (data.available || []).sort((a, b) => { // return sort return a.title.toLowerCase().localeCompare(b.title.toLowerCase()); }).map((field, i) => { // search if (search && search.length) { // search string const str = `${field.type} ${field.title} ${field.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 ( ) } title={ field.title } subheader={ field.description } /> ); }).filter((i) => i) } ); } } ); }; // export default page menu export default (ctx) => { // use context DashupUIContext = ctx; // return actual component return DashupUIFormMenu; };