|
|
@ -5,7 +5,6 @@ import Tabbar from "./Tabbar"; |
|
|
|
|
|
|
|
|
|
|
|
import MOCK_DATA2 from "./MOCK_DATA2.json"; |
|
|
|
import MOCK_DATA2 from "./MOCK_DATA2.json"; |
|
|
|
|
|
|
|
|
|
|
|
import { ColumnSearch } from "./ColumnSearch"; |
|
|
|
|
|
|
|
import { GlobalFilter } from "./GlobalFilter"; |
|
|
|
import { GlobalFilter } from "./GlobalFilter"; |
|
|
|
|
|
|
|
|
|
|
|
import { COLUMNS } from "./COLUMNS"; |
|
|
|
import { COLUMNS } from "./COLUMNS"; |
|
|
@ -14,6 +13,7 @@ import { GoToPage } from "./GoToPage"; |
|
|
|
import ShowMoreRows from "./ShowMoreRows"; |
|
|
|
import ShowMoreRows from "./ShowMoreRows"; |
|
|
|
import { Settings } from "./Settings"; |
|
|
|
import { Settings } from "./Settings"; |
|
|
|
import { Checkbox } from "./Checkbox"; |
|
|
|
import { Checkbox } from "./Checkbox"; |
|
|
|
|
|
|
|
import { FilterFileType } from "./FilterFileType"; |
|
|
|
|
|
|
|
|
|
|
|
import grid from "./grid.svg"; |
|
|
|
import grid from "./grid.svg"; |
|
|
|
import list from "./list.svg"; |
|
|
|
import list from "./list.svg"; |
|
|
@ -32,16 +32,75 @@ import { |
|
|
|
useColumnOrder, |
|
|
|
useColumnOrder, |
|
|
|
useExpanded, |
|
|
|
useExpanded, |
|
|
|
} from "react-table"; |
|
|
|
} from "react-table"; |
|
|
|
|
|
|
|
import ButtonNewDesign from "../ButtonNewDesign"; |
|
|
|
|
|
|
|
|
|
|
|
export function CheckBox({}) { |
|
|
|
export function CheckBox({}) { |
|
|
|
return <input type="checkbox" className="cursor-pointer" />; |
|
|
|
return <input type="checkbox" className="cursor-pointer" />; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const SelectColumnFilter = ({ |
|
|
|
|
|
|
|
column: { filterValue, setFilter, preFilteredRows, id, render }, |
|
|
|
|
|
|
|
}) => { |
|
|
|
|
|
|
|
const options = React.useMemo(() => { |
|
|
|
|
|
|
|
const options = new Set(); |
|
|
|
|
|
|
|
preFilteredRows.forEach((row) => { |
|
|
|
|
|
|
|
options.add(row.values[id]); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return [...options.values()]; |
|
|
|
|
|
|
|
}, [id, preFilteredRows]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<select |
|
|
|
|
|
|
|
className="w-32 appearance-none text-xs flex flex-row items-start p-2 rounded focus:outline-none border focus:border-gray-200 focus:ring focus:ring-gray-200 focus:ring-opacity-20" |
|
|
|
|
|
|
|
style={{ borderColor: "#EEEEEE", color: "#00253A" }} |
|
|
|
|
|
|
|
name={id} |
|
|
|
|
|
|
|
id={id} |
|
|
|
|
|
|
|
value={filterValue} |
|
|
|
|
|
|
|
onChange={(e) => { |
|
|
|
|
|
|
|
setFilter(e.target.value || undefined); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<option |
|
|
|
|
|
|
|
className="text-white" |
|
|
|
|
|
|
|
value="" |
|
|
|
|
|
|
|
style={{ backgroundColor: "#65A9FF" }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
بر اساس نوع فایل |
|
|
|
|
|
|
|
</option> |
|
|
|
|
|
|
|
{options.map((option, i) => ( |
|
|
|
|
|
|
|
<option |
|
|
|
|
|
|
|
key={i} |
|
|
|
|
|
|
|
value={option} |
|
|
|
|
|
|
|
className="text-right text-white px-2" |
|
|
|
|
|
|
|
style={{ backgroundColor: "#65A9FF" }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{(() => { |
|
|
|
|
|
|
|
if (option === 1) { |
|
|
|
|
|
|
|
return "JPG"; |
|
|
|
|
|
|
|
} else if (option === 2) { |
|
|
|
|
|
|
|
return "PNG"; |
|
|
|
|
|
|
|
} else if (option === 3) { |
|
|
|
|
|
|
|
return "PDF"; |
|
|
|
|
|
|
|
} else if (option === 4) { |
|
|
|
|
|
|
|
return "CSV"; |
|
|
|
|
|
|
|
} else if (option === 5) { |
|
|
|
|
|
|
|
return "PPT"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return "MP4"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
})()}{" "} |
|
|
|
|
|
|
|
</option> |
|
|
|
|
|
|
|
))} |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const BasicTable = ({ |
|
|
|
const BasicTable = ({ |
|
|
|
settingsIcon, |
|
|
|
settingsIcon, |
|
|
|
thead, |
|
|
|
thead, |
|
|
|
goToPage, |
|
|
|
goToPage, |
|
|
|
showMore, |
|
|
|
showMore, |
|
|
|
|
|
|
|
filterBarDefault, |
|
|
|
addTab, |
|
|
|
addTab, |
|
|
|
tabs, |
|
|
|
tabs, |
|
|
|
delTab, |
|
|
|
delTab, |
|
|
@ -85,14 +144,8 @@ const BasicTable = ({ |
|
|
|
[] |
|
|
|
[] |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// const defaultColumn = {
|
|
|
|
|
|
|
|
// Cell: EditableCell,
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// یعنی فیلتر دیفالت هدر های ما سرچ خواهد بود مگه اینکه خودمون تغییرش بدیم
|
|
|
|
|
|
|
|
const defaultColumn = useMemo(() => { |
|
|
|
const defaultColumn = useMemo(() => { |
|
|
|
return { |
|
|
|
return {}; |
|
|
|
Filter: ColumnSearch, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
// اگر بخواهیم ردیف های جدولمون یکی در میان زنگ پس زمینه اشون با هم فرق کند
|
|
|
|
// اگر بخواهیم ردیف های جدولمون یکی در میان زنگ پس زمینه اشون با هم فرق کند
|
|
|
@ -169,7 +222,7 @@ const BasicTable = ({ |
|
|
|
/> |
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</div>{" "} */} |
|
|
|
</div>{" "} */} |
|
|
|
<div> |
|
|
|
<div className="mb-3 flex flex-row items-center gap-x-5"> |
|
|
|
{/* select View list */} |
|
|
|
{/* select View list */} |
|
|
|
<div className="flex flex-row items-center gap-x-2"> |
|
|
|
<div className="flex flex-row items-center gap-x-2"> |
|
|
|
<img |
|
|
|
<img |
|
|
@ -183,18 +236,42 @@ const BasicTable = ({ |
|
|
|
onClick={() => setActiveList(true)} |
|
|
|
onClick={() => setActiveList(true)} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{headerGroups.map((headerGroup) => |
|
|
|
|
|
|
|
headerGroup.headers.map((column) => |
|
|
|
|
|
|
|
column.Filter ? ( |
|
|
|
|
|
|
|
<div className="mt-2 sm:mt-0" key={column.id}> |
|
|
|
|
|
|
|
{column.render("Filter")} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) : null |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
<ButtonNewDesign |
|
|
|
|
|
|
|
bgColor={"bg-blue-500"} |
|
|
|
|
|
|
|
icon={null} |
|
|
|
|
|
|
|
border={"border-0"} |
|
|
|
|
|
|
|
borderRadius={"rounded"} |
|
|
|
|
|
|
|
fontSize={"text-xs"} |
|
|
|
|
|
|
|
padding={"p-2"} |
|
|
|
|
|
|
|
text={"انتخاب چند فایل"} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<div className="flex-1 "> |
|
|
|
|
|
|
|
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* <FilterFileType /> */} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="flex flex-row items-center justify-between"> |
|
|
|
{filterBarDefault && ( |
|
|
|
{/* right box */} |
|
|
|
<div className="flex flex-row items-center justify-between"> |
|
|
|
<di className="bg-red-400"> |
|
|
|
{/* right box */} |
|
|
|
<Tabbar |
|
|
|
<di className=""> |
|
|
|
tabs={tabs} |
|
|
|
<Tabbar |
|
|
|
delTab={delTab} |
|
|
|
tabs={tabs} |
|
|
|
setActivateTab={setActivateTab} |
|
|
|
delTab={delTab} |
|
|
|
activeTab={activeTab} |
|
|
|
setActivateTab={setActivateTab} |
|
|
|
/> |
|
|
|
activeTab={activeTab} |
|
|
|
</di> |
|
|
|
/> |
|
|
|
{/* <div className=""> |
|
|
|
</di> |
|
|
|
|
|
|
|
{/* <div className=""> |
|
|
|
<Tabbar |
|
|
|
<Tabbar |
|
|
|
tabs={tabs} |
|
|
|
tabs={tabs} |
|
|
|
delTab={delTab} |
|
|
|
delTab={delTab} |
|
|
@ -202,57 +279,57 @@ const BasicTable = ({ |
|
|
|
activeTab={activeTab} |
|
|
|
activeTab={activeTab} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> */} |
|
|
|
</div> */} |
|
|
|
{/* left box */} |
|
|
|
{/* left box */} |
|
|
|
{activeTab == 0 ? ( |
|
|
|
{activeTab == 0 ? ( |
|
|
|
<div |
|
|
|
|
|
|
|
className="flex flex-row items-center p-2 rounded-tl rounded-tr" |
|
|
|
|
|
|
|
style={{ backgroundColor: "#F1F6FF" }} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{/* search box */} |
|
|
|
|
|
|
|
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} /> |
|
|
|
|
|
|
|
{/* pagination */} |
|
|
|
|
|
|
|
<div |
|
|
|
<div |
|
|
|
className="flex flex-row items-center p-1 rounded" |
|
|
|
className="flex flex-row items-center p-2 rounded-tl rounded-tr" |
|
|
|
style={{ backgroundColor: "#F9FBFF" }} |
|
|
|
style={{ backgroundColor: "#F1F6FF" }} |
|
|
|
> |
|
|
|
> |
|
|
|
{/* go to page */} |
|
|
|
{/* search box */} |
|
|
|
<GoToPage |
|
|
|
<GlobalFilter filter={globalFilter} setFilter={setGlobalFilter} /> |
|
|
|
pageIndex={pageIndex} |
|
|
|
{/* pagination */} |
|
|
|
gotoPage={gotoPage} |
|
|
|
|
|
|
|
pageOptions={pageOptions} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
{/* vertical line */} |
|
|
|
|
|
|
|
<div |
|
|
|
<div |
|
|
|
className={`w-0.5 h-4 mr-2`} |
|
|
|
className="flex flex-row items-center p-1 rounded" |
|
|
|
style={{ backgroundColor: "#65A9FF" }} |
|
|
|
style={{ backgroundColor: "#F9FBFF" }} |
|
|
|
></div> |
|
|
|
> |
|
|
|
{/* arrows */} |
|
|
|
{/* go to page */} |
|
|
|
<Pagination |
|
|
|
<GoToPage |
|
|
|
gotoPage={gotoPage} |
|
|
|
pageIndex={pageIndex} |
|
|
|
canPreviousPage={canPreviousPage} |
|
|
|
gotoPage={gotoPage} |
|
|
|
previousPage={previousPage} |
|
|
|
pageOptions={pageOptions} |
|
|
|
canNextPage={canNextPage} |
|
|
|
/> |
|
|
|
pageCount={pageCount} |
|
|
|
{/* vertical line */} |
|
|
|
nextPage={nextPage} |
|
|
|
<div |
|
|
|
/> |
|
|
|
className={`w-0.5 h-4 mr-2`} |
|
|
|
|
|
|
|
style={{ backgroundColor: "#65A9FF" }} |
|
|
|
|
|
|
|
></div> |
|
|
|
|
|
|
|
{/* arrows */} |
|
|
|
|
|
|
|
<Pagination |
|
|
|
|
|
|
|
gotoPage={gotoPage} |
|
|
|
|
|
|
|
canPreviousPage={canPreviousPage} |
|
|
|
|
|
|
|
previousPage={previousPage} |
|
|
|
|
|
|
|
canNextPage={canNextPage} |
|
|
|
|
|
|
|
pageCount={pageCount} |
|
|
|
|
|
|
|
nextPage={nextPage} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
{/* settings icon */} |
|
|
|
|
|
|
|
{settingsIcon && ( |
|
|
|
|
|
|
|
<Settings |
|
|
|
|
|
|
|
allColumns={allColumns} |
|
|
|
|
|
|
|
getToggleHideAllColumnsProps={getToggleHideAllColumnsProps} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{/* settings icon */} |
|
|
|
) : null} |
|
|
|
{settingsIcon && ( |
|
|
|
</div> |
|
|
|
<Settings |
|
|
|
)} |
|
|
|
allColumns={allColumns} |
|
|
|
{/* {activeList === true ? <div>listView</div> : <div>gridView</div>} */} |
|
|
|
getToggleHideAllColumnsProps={getToggleHideAllColumnsProps} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) : null} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{activeList === true ? <div>listView</div> : <div>gridView</div>} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* table LIST */} |
|
|
|
{/* table LIST */} |
|
|
|
{activeTab == 0 ? ( |
|
|
|
{activeTab == 0 ? ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
{activeList === false && ( |
|
|
|
{activeList === true && ( |
|
|
|
// table
|
|
|
|
// table
|
|
|
|
<table |
|
|
|
<table |
|
|
|
{...getTableProps()} |
|
|
|
{...getTableProps()} |
|
|
@ -368,21 +445,32 @@ const BasicTable = ({ |
|
|
|
</table> |
|
|
|
</table> |
|
|
|
)} |
|
|
|
)} |
|
|
|
{/* GRID LIST */} |
|
|
|
{/* GRID LIST */} |
|
|
|
{activeList === true && ( |
|
|
|
{activeList === false && ( |
|
|
|
<div className="flex flex-row gap-4"> |
|
|
|
<div |
|
|
|
{data.map((item, index) => ( |
|
|
|
{...getTableBodyProps()} |
|
|
|
<div |
|
|
|
className="flex flex-row flex-wrap gap-4 items-center justify-center" |
|
|
|
className="flex flex-col px-4 py-5 rounded-md" |
|
|
|
> |
|
|
|
key={index} |
|
|
|
{rows.map((row, index) => { |
|
|
|
style={{ backgroundColor: "#F3F3F3" }} |
|
|
|
prepareRow(row); |
|
|
|
> |
|
|
|
return ( |
|
|
|
<img src={image1} className="w-52" /> |
|
|
|
<div |
|
|
|
<p className="text-sm my-3">{item.fileName}</p> |
|
|
|
{...row.getRowProps()} |
|
|
|
<span className="text-xs text-left text-gray-500"> |
|
|
|
className="flex flex-col px-4 py-5 rounded-md" |
|
|
|
{item.fileSize} |
|
|
|
key={index} |
|
|
|
</span> |
|
|
|
style={{ backgroundColor: "#F3F3F3" }} |
|
|
|
</div> |
|
|
|
> |
|
|
|
))} |
|
|
|
<img |
|
|
|
|
|
|
|
src={row.original.filePic} |
|
|
|
|
|
|
|
alt={row.original.filePic} |
|
|
|
|
|
|
|
className="w-52" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<p className="text-sm my-3">{row.original.fileName}</p> |
|
|
|
|
|
|
|
<span className="text-xs text-left text-gray-500"> |
|
|
|
|
|
|
|
{row.original.fileSize} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
})} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
)} |
|
|
|
)} |
|
|
|
{/* bottom table */} |
|
|
|
{/* bottom table */} |
|
|
@ -418,6 +506,7 @@ BasicTable.defaultProps = { |
|
|
|
thead: false, |
|
|
|
thead: false, |
|
|
|
goToPage: false, |
|
|
|
goToPage: false, |
|
|
|
showMore: false, |
|
|
|
showMore: false, |
|
|
|
|
|
|
|
filterBarDefault: false, |
|
|
|
|
|
|
|
|
|
|
|
// listView: [
|
|
|
|
// listView: [
|
|
|
|
// { icon: grid, click: () => setActiveList(false) },
|
|
|
|
// { icon: grid, click: () => setActiveList(false) },
|
|
|
|