11import { useStore , useTask$ , component$ } from "@builder.io/qwik"
22import SortArrows from "./SortArrows"
33import FilterInput from "./FilterInput"
4- import { param2string , sortTable , filterTable } from "../utils"
4+ import { param2string , sortTable } from "../utils"
55import type {
66 TableProps ,
77 TableRecord ,
@@ -31,8 +31,8 @@ export default component$(
3131 tData : tData ,
3232 tHeadings : {
3333 headingList : Object . keys ( tData [ 0 ] ) ,
34- customHeadings : { ...tHeadings . customHeadings } ,
35- ...tHeadings ,
34+ customHeadings : { ...tHeadings ? .customHeadings } ,
35+ ...tHeadings ! ,
3636 } ,
3737 tColumns : {
3838 ...tColumns ,
@@ -56,11 +56,19 @@ export default component$(
5656 useTask$ ( async ( { track } ) => {
5757 track ( ( ) => [ sortConfigs . param , sortConfigs . order , filterConfigs . params ] )
5858
59- const filteredData = await filterTable (
60- tData ,
61- tableData . tHeadings . headingList ,
62- filterConfigs
63- )
59+ const filteredData = tData . filter ( ( record : TableRecord ) => {
60+ let i = 0
61+ tableData . tHeadings . headingList . map ( ( param : string ) => {
62+ if (
63+ record [ param ]
64+ ?. toString ( )
65+ . toLowerCase ( )
66+ . includes ( filterConfigs . params [ param ] ?. toString ( ) . toLowerCase ( ) )
67+ )
68+ ++ i
69+ } )
70+ if ( i === Object . keys ( filterConfigs ?. params ) . length ) return record
71+ } )
6472
6573 if ( sortConfigs . order === 0 ) {
6674 tableData . tData = filteredData
@@ -82,10 +90,10 @@ export default component$(
8290 < th
8391 key = { index }
8492 class = { `
85- ${ tableData . tHeadings . classList }
86- ${ tableData . tColumns ?. classList }
87- ${ tableData . tColumns ?. columnClassList ?. [ heading ] }
88- ` }
93+ ${ tableData . tHeadings . classList }
94+ ${ tableData . tColumns ?. classList }
95+ ${ tableData . tColumns ?. columnClassList ?. [ heading ] }
96+ ` }
8997 >
9098 < div class = "flex flex-col" >
9199 < div class = "flex flex-row items-center justify-between gap-[10px]" >
@@ -95,16 +103,22 @@ export default component$(
95103 ? tableData . tHeadings . element$ [ heading ] (
96104 tableData . tHeadings . customHeadings ?. [ heading ] !
97105 ) || tableData . tHeadings . customHeadings ?. [ heading ]
98- : tableData . tHeadings . element$ [ heading ] (
106+ : tableData . tHeadings . element$ ?. [ heading ] ?. (
99107 param2string ( heading )
100108 ) || param2string ( heading ) }
101109 { tableData . sortOptions ?. params ?. includes ( heading ) && (
102110 < SortArrows
103111 heading = { heading }
104112 classList = { {
105- container : "" ,
106- arrowUp : "" ,
107- arrowDown : "" ,
113+ container :
114+ tableData . tableOptions ?. sortArrowsClassList
115+ ?. container ,
116+ arrowUp :
117+ tableData . tableOptions ?. sortArrowsClassList
118+ ?. arrowUp ,
119+ arrowDown :
120+ tableData . tableOptions ?. sortArrowsClassList
121+ ?. arrowDown ,
108122 } }
109123 sortConfigs = { sortConfigs }
110124 highlightColor = { tableData . sortOptions . highlightColor }
@@ -118,7 +132,9 @@ export default component$(
118132 { tableData . filterOptions ?. params ?. [ heading ] ===
119133 "search" ? (
120134 < FilterInput
121- classList = { "" }
135+ classList = {
136+ tableData . tableOptions ?. filterInputClassList
137+ }
122138 heading = { heading }
123139 filterConfigs = { filterConfigs }
124140 />
0 commit comments