0.1.5 • Published 2 years ago

@superalaa/superlist v0.1.5

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

SuperList Module

SuperList Module Helps create your front-end in seconds

  • Search , Filter , Sort and Paginate with easy integration with your backend API
  • Smooth Clean Design and Responsive, MUI based FrontEnd

Getting Started

$ npm i @superalaa/superlist
import  SuperList  from  'SuperList';
import {data} from  './data.js'
function  App() {
	return (
	<>
		<SuperList  data={data}  />
	</>
	);
}
export  default  App; 

Live Exmaple in Code SandBox Try Editing in data.js to get your head around the API docs

API documentation

NameTypeDescription
pageNameStringTitle of your page
pageSummaryStringSummary or description of your page
primaryColorStringThe primary color in the module to make the design more adaptive to your theme Ex: primaryColor:"#673ab7"
searchAttributesboolenables the filter part in the search bar
searchTitleStringthe search input title to help user what are they searching for
searchNameQueryStringfor backend purposes when you submit API request the search field data will be in object with property of the searchNameQuery
searchAttributesDataArrayThe filter part in search bar is an array of objects for example Object has properties name,label and options for select { name:"city",label:"City",options: { value: 'Alexandria', label: 'Alexandria' },{ value: 'Cairo', label: 'Cairo' },},
categorySectionboolcategory section on the left side of the page to enables you filter all the data with specific attributes
categorySubHeaderStringSubHeader for the category section
categoriesArrayArray of Objects ;Object properties are title,name,categoryIcon with bool value in case you need to add an icon , Icon prop takes Component ,nested propert is bool if you want the menu to be nested with sub categories, subCategories property takes array for objects with same params
sortboolenables you to sort the list
sortMenuArrayArray of Object for example {title:"Amount High to Low",name:"amount",sort:"DESC"},{title:"Amount Low to High",name:"amount",sort:"ASC"}
printboolin case you need to print you rows
addButtonTitleStringThe add button text
addButtonOnClickFunctionfunctionpass function whatever you wanna do when you click the button
headerItemboolin case you want have a header for you records
headerItemComponentJS Componentthe header component
listItemComponentJS Componentyour record component design with get a param props.content will have your record data
APIStringyour backend API will ge a GET Request with query params of everything that happens in the module serch,sort,filter,pagination data

Back End Example using Express

	app.get('/invoices',async  function(req,res){
		let  query = req.query;
		const  limit = parseInt(req.query.limit)
		const  offset = parseInt(req.query.offset)
		let  filters = JSON.parse(query.filter)
		if (filters.client){
			filters.client = {[Op.like]:`%${filters.client}%`}
		}
		let  dbObj = {
			where:filters,
			limit,
			offset,
		}
		if(req.query.sort){
			let  sort = JSON.parse(query.sort);
			dbObj.order = [sort]
		}
		let {count,rows} = await models.invoices.findAndCountAll(dbObj);
		res.send({count,rows}).status(200);
})

NPM GitHub