11import type { Elevation } from "@eqtylab/equality" ;
22import {
33 Badge ,
4- Button ,
54 EmptyTableState ,
5+ IconButton ,
66 SortButton ,
77 Table ,
88} from "@eqtylab/equality" ;
99
1010interface TableDemoProps {
1111 variant ?:
12- | "unclickable "
12+ | "default "
1313 | "clickable"
14- | "with-actions"
1514 | "with-border"
1615 | "with-sorter"
1716 | "empty-state"
1817 | "empty-state-custom" ;
19- elevation : Elevation ;
18+ elevation ? : Elevation ;
2019}
2120
2221export const TableDemo = ( {
23- variant = "unclickable " ,
22+ variant = "default " ,
2423 elevation,
2524} : TableDemoProps ) => {
2625 const columns = [
2726 { key : "name" , content : "Name" } ,
2827 { key : "email" , content : "Email" } ,
2928 { key : "role" , content : "Role" } ,
3029 { key : "status" , content : "Status" } ,
30+ { key : "actions" , content : "" } ,
3131 ] ;
3232
33- const demo_rows_unclickable = [
33+ const rows = [
3434 {
3535 key : "1" ,
3636 cells : [
3737 { key : "name" , content : "Alice Cooper" } ,
3838 { key : "email" , content : "alice@example.com" } ,
3939 { key : "role" , content : "Admin" } ,
4040 { key : "status" , content : < Badge variant = "success" > Active</ Badge > } ,
41+ {
42+ key : "actions" ,
43+ content : < IconButton name = "EllipsisVertical" label = "Row actions" /> ,
44+ } ,
4145 ] ,
46+ ...( variant === "clickable" && {
47+ onClick : ( ) => console . log ( "Clicked row 1" ) ,
48+ } ) ,
4249 } ,
4350 {
4451 key : "2" ,
@@ -47,188 +54,38 @@ export const TableDemo = ({
4754 { key : "email" , content : "bob@example.com" } ,
4855 { key : "role" , content : "User" } ,
4956 { key : "status" , content : < Badge variant = "success" > Active</ Badge > } ,
57+ {
58+ key : "actions" ,
59+ content : < IconButton name = "EllipsisVertical" label = "Row actions" /> ,
60+ } ,
5061 ] ,
62+ ...( variant === "clickable" && {
63+ onClick : ( ) => console . log ( "Clicked row 2" ) ,
64+ } ) ,
5165 } ,
5266 {
5367 key : "3" ,
5468 cells : [
5569 { key : "name" , content : "Charlie Brown" } ,
5670 { key : "email" , content : "charlie@example.com" } ,
5771 { key : "role" , content : "Viewer" } ,
58- { key : "status" , content : < Badge variant = "neutral" > Inactive</ Badge > } ,
72+ {
73+ key : "status" ,
74+ content : < Badge variant = "neutral" > Inactive</ Badge > ,
75+ } ,
76+ {
77+ key : "actions" ,
78+ content : < IconButton name = "EllipsisVertical" label = "Row actions" /> ,
79+ } ,
5980 ] ,
81+ ...( variant === "clickable" && {
82+ onClick : ( ) => console . log ( "Clicked row 3" ) ,
83+ } ) ,
6084 } ,
6185 ] ;
6286
63- const demo_rows_clickable = [
64- {
65- key : "1" ,
66- cells : [
67- { key : "name" , content : "Alice Cooper" } ,
68- { key : "email" , content : "alice@example.com" } ,
69- { key : "role" , content : "Admin" } ,
70- { key : "status" , content : "Active" } ,
71- ] ,
72- onClick : ( ) => console . log ( "Clicked row 1" ) ,
73- } ,
74- {
75- key : "2" ,
76- cells : [
77- { key : "name" , content : "Bob Smith" } ,
78- { key : "email" , content : "bob@example.com" } ,
79- { key : "role" , content : "User" } ,
80- { key : "status" , content : "Active" } ,
81- ] ,
82- onClick : ( ) => console . log ( "Clicked row 2" ) ,
83- } ,
84- {
85- key : "3" ,
86- cells : [
87- { key : "name" , content : "Charlie Brown" } ,
88- { key : "email" , content : "charlie@example.com" } ,
89- { key : "role" , content : "Viewer" } ,
90- { key : "status" , content : "Inactive" } ,
91- ] ,
92- onClick : ( ) => console . log ( "Clicked row 3" ) ,
93- } ,
94- ] ;
95-
96- if ( variant === "unclickable" ) {
97- return (
98- < Table
99- columns = { columns }
100- rows = { demo_rows_unclickable }
101- elevation = { elevation }
102- />
103- ) ;
104- }
105-
106- if ( variant === "clickable" ) {
107- return (
108- < Table
109- columns = { columns }
110- rows = { demo_rows_clickable }
111- elevation = { elevation }
112- />
113- ) ;
114- }
115-
116- if ( variant === "with-actions" ) {
117- const columns_with_actions = [
118- { key : "name" , content : "Name" } ,
119- { key : "email" , content : "Email" } ,
120- { key : "role" , content : "Role" } ,
121- { key : "status" , content : "Status" } ,
122- { key : "actions" , content : "Actions" } ,
123- ] ;
124-
125- const demo_rows_with_actions = [
126- {
127- key : "1" ,
128- cells : [
129- { key : "name" , content : "Alice Cooper" } ,
130- { key : "email" , content : "alice@example.com" } ,
131- { key : "role" , content : "Admin" } ,
132- { key : "status" , content : "Active" } ,
133- {
134- key : "actions" ,
135- content : (
136- < Button variant = "tertiary" size = "sm" >
137- View
138- </ Button >
139- ) ,
140- } ,
141- ] ,
142- } ,
143- {
144- key : "2" ,
145- cells : [
146- { key : "name" , content : "Bob Smith" } ,
147- { key : "email" , content : "bob@example.com" } ,
148- { key : "role" , content : "User" } ,
149- { key : "status" , content : "Active" } ,
150- {
151- key : "actions" ,
152- content : (
153- < Button variant = "tertiary" size = "sm" >
154- View
155- </ Button >
156- ) ,
157- } ,
158- ] ,
159- } ,
160- {
161- key : "3" ,
162- cells : [
163- { key : "name" , content : "Charlie Brown" } ,
164- { key : "email" , content : "charlie@example.com" } ,
165- { key : "role" , content : "Viewer" } ,
166- { key : "status" , content : "Inactive" } ,
167- {
168- key : "actions" ,
169- content : (
170- < Button variant = "tertiary" size = "sm" >
171- View
172- </ Button >
173- ) ,
174- } ,
175- ] ,
176- } ,
177- ] ;
178- return (
179- < Table
180- columns = { columns_with_actions }
181- rows = { demo_rows_with_actions }
182- elevation = { elevation }
183- />
184- ) ;
185- }
186-
187- if ( variant === "with-border" ) {
188- return (
189- < Table
190- columns = { columns }
191- rows = { demo_rows_unclickable }
192- border
193- elevation = { elevation }
194- />
195- ) ;
196- }
197-
198- if ( variant === "empty-state" ) {
199- return (
200- < Table
201- columns = { columns }
202- rows = { [ ] }
203- border
204- elevation = { elevation }
205- emptyState = "No data available"
206- />
207- ) ;
208- }
209-
210- if ( variant === "empty-state-custom" ) {
211- return (
212- < Table
213- columns = { columns }
214- rows = { [ ] }
215- border
216- elevation = { elevation }
217- emptyState = {
218- < EmptyTableState
219- icon = "SearchX"
220- title = "No Members Found"
221- description = "Try refining your search terms or clearing filters."
222- showClearButton
223- onClear = { ( ) => { } }
224- />
225- }
226- />
227- ) ;
228- }
229-
23087 if ( variant === "with-sorter" ) {
231- const columns_with_sorter = [
88+ const sortColumns = [
23289 {
23390 key : "name" ,
23491 content : (
@@ -281,16 +138,50 @@ export const TableDemo = ({
281138 </ SortButton >
282139 ) ,
283140 } ,
141+ { key : "actions" , content : "" } ,
284142 ] ;
285143
144+ return < Table columns = { sortColumns } rows = { rows } elevation = { elevation } /> ;
145+ }
146+
147+ if ( variant === "empty-state" ) {
286148 return (
287149 < Table
288- columns = { columns_with_sorter }
289- rows = { demo_rows_unclickable }
150+ columns = { columns }
151+ rows = { [ ] }
152+ border
290153 elevation = { elevation }
154+ emptyState = "No data available"
155+ />
156+ ) ;
157+ }
158+
159+ if ( variant === "empty-state-custom" ) {
160+ return (
161+ < Table
162+ columns = { columns }
163+ rows = { [ ] }
164+ border
165+ elevation = { elevation }
166+ emptyState = {
167+ < EmptyTableState
168+ icon = "SearchX"
169+ title = "No Members Found"
170+ description = "Try refining your search terms or clearing filters."
171+ showClearButton
172+ onClear = { ( ) => { } }
173+ />
174+ }
291175 />
292176 ) ;
293177 }
294178
295- return null ;
179+ return (
180+ < Table
181+ columns = { columns }
182+ rows = { rows }
183+ border = { variant === "with-border" }
184+ elevation = { elevation }
185+ />
186+ ) ;
296187} ;
0 commit comments