@sikka/hawa 0.1.55 → 0.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE.yml +33 -61
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +520 -528
- package/dist/index.mjs +778 -782
- package/package.json +1 -1
- package/src/elements/DropdownMenu.tsx +14 -4
- package/src/elements/HawaTable.tsx +298 -147
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
|
|
|
25
25
|
)}
|
|
26
26
|
{...props}
|
|
27
27
|
>
|
|
28
|
-
{children}
|
|
28
|
+
<div className="flex flex-row items-center gap-1">{children}</div>{" "}
|
|
29
29
|
{/* <ChevronRight className="ml-auto h-4 w-4" /> */}
|
|
30
30
|
<svg
|
|
31
31
|
aria-label="Chevron Right Icon"
|
|
@@ -230,11 +230,13 @@ type ExtendedDropdownMenuTriggerProps = Partial<
|
|
|
230
230
|
type SubItem = {
|
|
231
231
|
label: string
|
|
232
232
|
value: string
|
|
233
|
+
icon?: any
|
|
233
234
|
action?: () => void
|
|
234
235
|
highlighted?: boolean
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
type Item = {
|
|
239
|
+
icon?: any
|
|
238
240
|
label: string
|
|
239
241
|
value: string
|
|
240
242
|
action?: () => void
|
|
@@ -276,23 +278,26 @@ export const DropdownMenu = ({
|
|
|
276
278
|
<DropdownMenuContent
|
|
277
279
|
side={side}
|
|
278
280
|
sideOffset={sideOffset}
|
|
279
|
-
className={cn(className)}
|
|
281
|
+
className={cn(className, "flex flex-col gap-1")}
|
|
280
282
|
align={align}
|
|
281
283
|
alignOffset={alignOffset}
|
|
282
284
|
>
|
|
283
285
|
{items.map((item, index) => {
|
|
284
286
|
return item.subitems ? (
|
|
285
|
-
<DropdownMenuSub>
|
|
287
|
+
<DropdownMenuSub key={index}>
|
|
286
288
|
<DropdownMenuSubTrigger dir={direction}>
|
|
289
|
+
{item.icon && item.icon}
|
|
287
290
|
{item.label}
|
|
288
291
|
</DropdownMenuSubTrigger>
|
|
289
292
|
<DropdownMenuPortal>
|
|
290
293
|
<DropdownMenuSubContent>
|
|
291
294
|
{item.subitems.map((subitem, subIndex) => (
|
|
292
295
|
<DropdownMenuItem
|
|
296
|
+
className="flex flex-row gap-1"
|
|
293
297
|
onSelect={() => subitem.action()}
|
|
294
298
|
key={subIndex}
|
|
295
299
|
>
|
|
300
|
+
{subitem.icon && subitem.icon}
|
|
296
301
|
{subitem.label}
|
|
297
302
|
</DropdownMenuItem>
|
|
298
303
|
))}
|
|
@@ -300,7 +305,12 @@ export const DropdownMenu = ({
|
|
|
300
305
|
</DropdownMenuPortal>
|
|
301
306
|
</DropdownMenuSub>
|
|
302
307
|
) : (
|
|
303
|
-
<DropdownMenuItem
|
|
308
|
+
<DropdownMenuItem
|
|
309
|
+
className="flex flex-row gap-1"
|
|
310
|
+
key={index}
|
|
311
|
+
onSelect={() => item.action()}
|
|
312
|
+
>
|
|
313
|
+
{item.icon && item.icon}
|
|
304
314
|
{item.label}
|
|
305
315
|
</DropdownMenuItem>
|
|
306
316
|
)
|
|
@@ -4,6 +4,9 @@ import { HawaMenu } from "./HawaMenu"
|
|
|
4
4
|
import useTable from "../hooks/useTable"
|
|
5
5
|
import { HawaTextField } from "./HawaTextField"
|
|
6
6
|
import { HawaButton } from "./HawaButton"
|
|
7
|
+
import { cn } from "../util"
|
|
8
|
+
import { Button } from "./Button"
|
|
9
|
+
import { DropdownMenu } from "./DropdownMenu"
|
|
7
10
|
|
|
8
11
|
// TODO: translate header tools and make it more customizable
|
|
9
12
|
// TODO: pass the onSearch handler to the parent
|
|
@@ -21,7 +24,7 @@ type ColTypes = {
|
|
|
21
24
|
type TableTypes = {
|
|
22
25
|
pagination?: boolean
|
|
23
26
|
columns: ColTypes[]
|
|
24
|
-
actions?:
|
|
27
|
+
actions?: Item[]
|
|
25
28
|
direction?: "rtl" | "ltr"
|
|
26
29
|
rows?: RowTypes[][]
|
|
27
30
|
handleActionClick?: any
|
|
@@ -51,6 +54,29 @@ type ActionItems = {
|
|
|
51
54
|
element?: any
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
type Item = {
|
|
58
|
+
label: string
|
|
59
|
+
value: string
|
|
60
|
+
action?: () => void
|
|
61
|
+
highlighted?: boolean
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const ChevronIcon = () => (
|
|
65
|
+
<svg
|
|
66
|
+
aria-label="Chevron Right Icon"
|
|
67
|
+
stroke="currentColor"
|
|
68
|
+
fill="currentColor"
|
|
69
|
+
stroke-width="0"
|
|
70
|
+
viewBox="0 0 16 16"
|
|
71
|
+
height="1em"
|
|
72
|
+
width="1em"
|
|
73
|
+
>
|
|
74
|
+
<path
|
|
75
|
+
fill-rule="evenodd"
|
|
76
|
+
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
77
|
+
></path>
|
|
78
|
+
</svg>
|
|
79
|
+
)
|
|
54
80
|
export const HawaTable: FC<TableTypes> = ({
|
|
55
81
|
size = "normal",
|
|
56
82
|
bodyColor = "white",
|
|
@@ -66,40 +92,9 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
66
92
|
const [enteredPage, setEnteredPage] = useState(null)
|
|
67
93
|
const [page, setPage] = useState(1)
|
|
68
94
|
const [sortingCol, setSortingCol] = useState(null)
|
|
69
|
-
|
|
70
95
|
const [sortedRows, setSortedRows] = useState(props.rows)
|
|
71
96
|
const [sortColumn, setSortColumn] = useState(null)
|
|
72
97
|
const [sortDirection, setSortDirection] = useState(null)
|
|
73
|
-
|
|
74
|
-
const handleSort = (colIndex, sortable) => {
|
|
75
|
-
if (sortable) {
|
|
76
|
-
setSortColumn(colIndex)
|
|
77
|
-
setSortDirection((prevDirection) =>
|
|
78
|
-
prevDirection === "asc" ? "desc" : "asc"
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
// const newDirection =
|
|
82
|
-
// sortColumn === colIndex && sortDirection === "asc" ? "desc" : "asc"
|
|
83
|
-
|
|
84
|
-
// const sortedData = [...sortedRows].sort((a, b) => {
|
|
85
|
-
// const aValue = a[colIndex].value
|
|
86
|
-
// const bValue = b[colIndex].value
|
|
87
|
-
|
|
88
|
-
// // You can enhance the sorting logic based on the data type
|
|
89
|
-
// if (newDirection === "asc") {
|
|
90
|
-
// return aValue.localeCompare(bValue)
|
|
91
|
-
// } else {
|
|
92
|
-
// return bValue.localeCompare(aValue)
|
|
93
|
-
// }
|
|
94
|
-
// })
|
|
95
|
-
|
|
96
|
-
// setSortedRows(sortedData)
|
|
97
|
-
// setSortColumn(colIndex)
|
|
98
|
-
// setSortDirection(newDirection)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// const { slice, range } = useTable(props.rows, page, perPage)
|
|
102
|
-
// Use the custom hook to get paginated and sorted data
|
|
103
98
|
const { slice, range } = useTable(
|
|
104
99
|
props.rows,
|
|
105
100
|
page,
|
|
@@ -108,13 +103,18 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
108
103
|
sortDirection
|
|
109
104
|
)
|
|
110
105
|
let isRTL = direction === "rtl"
|
|
111
|
-
|
|
112
106
|
let sizeStyles = {
|
|
113
107
|
normal: "py-3 px-6",
|
|
114
108
|
small: "px-3 py-1",
|
|
115
109
|
}
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
const handleSort = (colIndex, sortable) => {
|
|
111
|
+
if (sortable) {
|
|
112
|
+
setSortColumn(colIndex)
|
|
113
|
+
setSortDirection((prevDirection) =>
|
|
114
|
+
prevDirection === "asc" ? "desc" : "asc"
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
118
|
const changePage = () => {
|
|
119
119
|
if (slice?.length < 1 && page !== 1) {
|
|
120
120
|
setPage(page - 1)
|
|
@@ -150,39 +150,34 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
150
150
|
margin="none"
|
|
151
151
|
/>
|
|
152
152
|
<div className="flex flex-row items-center justify-between gap-2">
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
>
|
|
164
|
-
|
|
165
|
-
</svg>
|
|
166
|
-
}
|
|
167
|
-
endIcon={
|
|
168
|
-
<svg
|
|
169
|
-
aria-label="Chevron Right Icon"
|
|
170
|
-
stroke="currentColor"
|
|
171
|
-
fill="currentColor"
|
|
172
|
-
stroke-width="0"
|
|
173
|
-
viewBox="0 0 16 16"
|
|
174
|
-
height="1em"
|
|
175
|
-
width="1em"
|
|
176
|
-
>
|
|
177
|
-
<path
|
|
178
|
-
fill-rule="evenodd"
|
|
179
|
-
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
180
|
-
></path>
|
|
181
|
-
</svg>
|
|
182
|
-
}
|
|
183
|
-
>
|
|
153
|
+
<Button className="flex flex-row gap-2">
|
|
154
|
+
<svg
|
|
155
|
+
aria-label="Filter Icon"
|
|
156
|
+
stroke="currentColor"
|
|
157
|
+
fill="currentColor"
|
|
158
|
+
stroke-width="0"
|
|
159
|
+
viewBox="0 0 16 16"
|
|
160
|
+
height="1em"
|
|
161
|
+
width="1em"
|
|
162
|
+
>
|
|
163
|
+
<path d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"></path>
|
|
164
|
+
</svg>
|
|
184
165
|
{props.texts?.filter ?? "Filter"}
|
|
185
|
-
|
|
166
|
+
<svg
|
|
167
|
+
aria-label="Chevron Right Icon"
|
|
168
|
+
stroke="currentColor"
|
|
169
|
+
fill="currentColor"
|
|
170
|
+
stroke-width="0"
|
|
171
|
+
viewBox="0 0 16 16"
|
|
172
|
+
height="1em"
|
|
173
|
+
width="1em"
|
|
174
|
+
>
|
|
175
|
+
<path
|
|
176
|
+
fill-rule="evenodd"
|
|
177
|
+
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
178
|
+
></path>
|
|
179
|
+
</svg>
|
|
180
|
+
</Button>
|
|
186
181
|
</div>
|
|
187
182
|
</div>
|
|
188
183
|
)}
|
|
@@ -323,33 +318,21 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
323
318
|
)
|
|
324
319
|
}
|
|
325
320
|
})}
|
|
326
|
-
{props.actions
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
<div className="flex items-center justify-center">
|
|
342
|
-
<HawaMenu
|
|
343
|
-
size="small"
|
|
344
|
-
actionedItem={[rowIndex, singleRow]}
|
|
345
|
-
menuItems={props.actions}
|
|
346
|
-
position={
|
|
347
|
-
direction === "rtl"
|
|
348
|
-
? "right-bottom"
|
|
349
|
-
: "left-bottom"
|
|
350
|
-
}
|
|
351
|
-
direction={direction}
|
|
352
|
-
>
|
|
321
|
+
{props.actions && (
|
|
322
|
+
<td
|
|
323
|
+
align={isRTL ? "right" : "left"}
|
|
324
|
+
className={cn(
|
|
325
|
+
isRTL && lastRow && "rounded-bl rounded-br-none",
|
|
326
|
+
!isRTL && lastRow && "rounded-bl-none rounded-br"
|
|
327
|
+
)}
|
|
328
|
+
colSpan={1}
|
|
329
|
+
>
|
|
330
|
+
<div className="flex items-center justify-center">
|
|
331
|
+
<DropdownMenu
|
|
332
|
+
direction={direction}
|
|
333
|
+
side="right"
|
|
334
|
+
items={props.actions}
|
|
335
|
+
trigger={
|
|
353
336
|
<div className="flex w-fit cursor-pointer items-center justify-center rounded p-2 hover:bg-gray-200 dark:hover:bg-gray-600">
|
|
354
337
|
<svg
|
|
355
338
|
aria-label="Vertical Three Dots Menu Icon"
|
|
@@ -363,19 +346,11 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
363
346
|
<path d="M3 9.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm5 0a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z"></path>
|
|
364
347
|
</svg>
|
|
365
348
|
</div>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
</td>
|
|
369
|
-
) : (
|
|
370
|
-
<div className="flex flex-row items-center justify-center gap-2 p-1">
|
|
371
|
-
{props.actions[0].map((act) => (
|
|
372
|
-
<div className=" p-1 transition-all hover:bg-gray-100">
|
|
373
|
-
{act.icon}
|
|
374
|
-
</div>
|
|
375
|
-
))}
|
|
349
|
+
}
|
|
350
|
+
/>
|
|
376
351
|
</div>
|
|
377
|
-
|
|
378
|
-
)
|
|
352
|
+
</td>
|
|
353
|
+
)}
|
|
379
354
|
</tr>
|
|
380
355
|
)
|
|
381
356
|
})
|
|
@@ -405,27 +380,15 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
405
380
|
<div className="flex w-fit flex-row items-stretch justify-center gap-2 overflow-clip rounded ">
|
|
406
381
|
{/* Previous Page Button */}
|
|
407
382
|
<div
|
|
408
|
-
className={
|
|
409
|
-
"flex h-6 w-6 rotate-180 cursor-pointer items-center justify-center rounded border bg-
|
|
383
|
+
className={cn(
|
|
384
|
+
"flex h-6 w-6 rotate-180 cursor-pointer items-center justify-center rounded border bg-background p-1 text-xs hover:bg-primary/10 dark:hover:bg-primary/10",
|
|
385
|
+
direction === "rtl" && "rotate-0"
|
|
410
386
|
)}
|
|
411
387
|
onClick={() =>
|
|
412
388
|
page <= 1 ? setPage(range.length) : setPage(page - 1)
|
|
413
389
|
}
|
|
414
390
|
>
|
|
415
|
-
<
|
|
416
|
-
aria-label="Chevron Right Icon"
|
|
417
|
-
stroke="currentColor"
|
|
418
|
-
fill="currentColor"
|
|
419
|
-
stroke-width="0"
|
|
420
|
-
viewBox="0 0 16 16"
|
|
421
|
-
height="1em"
|
|
422
|
-
width="1em"
|
|
423
|
-
>
|
|
424
|
-
<path
|
|
425
|
-
fill-rule="evenodd"
|
|
426
|
-
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
427
|
-
></path>
|
|
428
|
-
</svg>
|
|
391
|
+
<ChevronIcon />
|
|
429
392
|
</div>
|
|
430
393
|
{/* Numbered Pagination */}
|
|
431
394
|
<div className="flex flex-row items-center overflow-clip rounded transition-all">
|
|
@@ -439,7 +402,7 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
439
402
|
className={clsx(
|
|
440
403
|
"w-10 p-1 text-xs hover:bg-gray-200",
|
|
441
404
|
page === el
|
|
442
|
-
? "bg-
|
|
405
|
+
? "bg-primary text-primary-foreground hover:bg-primary"
|
|
443
406
|
: "bg-gray-100"
|
|
444
407
|
)}
|
|
445
408
|
onClick={() => setPage(el)}
|
|
@@ -483,7 +446,7 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
483
446
|
className={clsx(
|
|
484
447
|
"w-10 p-1 text-xs hover:bg-gray-200",
|
|
485
448
|
page === el
|
|
486
|
-
? "bg-
|
|
449
|
+
? "bg-primary text-primary-foreground hover:bg-primary"
|
|
487
450
|
: "bg-gray-100"
|
|
488
451
|
)}
|
|
489
452
|
onClick={() => setPage(el)}
|
|
@@ -501,15 +464,27 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
501
464
|
<button
|
|
502
465
|
key={index}
|
|
503
466
|
className={clsx(
|
|
504
|
-
"w-10 p-1 text-xs
|
|
467
|
+
"w-10 p-1 text-xs",
|
|
505
468
|
page === el
|
|
506
|
-
? "bg-
|
|
507
|
-
: "border bg-background",
|
|
469
|
+
? "bg-primary text-primary-foreground "
|
|
470
|
+
: "border bg-background hover:bg-primary/10 dark:hover:bg-primary/10",
|
|
508
471
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
?
|
|
512
|
-
|
|
472
|
+
// Check if the direction is 'rtl'
|
|
473
|
+
direction === "rtl"
|
|
474
|
+
? // If direction is 'rtl', then check for the index conditions
|
|
475
|
+
// and apply respective classes along with the 'something' class
|
|
476
|
+
index === 0
|
|
477
|
+
? "rounded-r border-l-0" // Apply if index is 0 and direction is 'rtl'
|
|
478
|
+
: index === range.length - 1
|
|
479
|
+
? "rounded-l border-r-0" // Apply if index is the last element and direction is 'rtl'
|
|
480
|
+
: "" // Apply if index is other than 0 or last element and direction is 'rtl'
|
|
481
|
+
: // If direction is not 'rtl', then again check for the index conditions
|
|
482
|
+
// and apply respective classes along with the 'something else' class
|
|
483
|
+
index === 0
|
|
484
|
+
? "rounded-l border-r-0" // Apply if index is 0 and direction is not 'rtl'
|
|
485
|
+
: index === range.length - 1
|
|
486
|
+
? "rounded-r border-l-0" // Apply if index is the last element and direction is not 'rtl'
|
|
487
|
+
: "" // Apply if index is other than 0 or last element and direction is not 'rtl'
|
|
513
488
|
)}
|
|
514
489
|
onClick={() => setPage(el)}
|
|
515
490
|
>
|
|
@@ -523,24 +498,12 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
523
498
|
onClick={() =>
|
|
524
499
|
page >= range.length ? setPage(1) : setPage(page + 1)
|
|
525
500
|
}
|
|
526
|
-
className={
|
|
527
|
-
"flex h-6 w-6 cursor-pointer items-center justify-center rounded border bg-
|
|
501
|
+
className={cn(
|
|
502
|
+
"flex h-6 w-6 cursor-pointer items-center justify-center rounded border bg-background p-1 text-xs hover:bg-primary/10 dark:hover:bg-primary/10",
|
|
503
|
+
direction === "rtl" && "rotate-180"
|
|
528
504
|
)}
|
|
529
505
|
>
|
|
530
|
-
<
|
|
531
|
-
aria-label="Chevron Right Icon"
|
|
532
|
-
stroke="currentColor"
|
|
533
|
-
fill="currentColor"
|
|
534
|
-
stroke-width="0"
|
|
535
|
-
viewBox="0 0 16 16"
|
|
536
|
-
height="1em"
|
|
537
|
-
width="1em"
|
|
538
|
-
>
|
|
539
|
-
<path
|
|
540
|
-
fill-rule="evenodd"
|
|
541
|
-
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
542
|
-
></path>
|
|
543
|
-
</svg>
|
|
506
|
+
<ChevronIcon />
|
|
544
507
|
</div>
|
|
545
508
|
</div>
|
|
546
509
|
) : (
|
|
@@ -582,6 +545,194 @@ export const HawaTable: FC<TableTypes> = ({
|
|
|
582
545
|
)}
|
|
583
546
|
</div>
|
|
584
547
|
)}
|
|
548
|
+
|
|
549
|
+
{/* <Pagination
|
|
550
|
+
handleNextPage={() =>
|
|
551
|
+
page >= range.length ? setPage(1) : setPage(page + 1)
|
|
552
|
+
}
|
|
553
|
+
handlePrevPage={() =>
|
|
554
|
+
page <= 1 ? setPage(range.length) : setPage(page - 1)
|
|
555
|
+
}
|
|
556
|
+
/> */}
|
|
585
557
|
</div>
|
|
586
558
|
)
|
|
587
559
|
}
|
|
560
|
+
|
|
561
|
+
// const Pagination = (props) => (
|
|
562
|
+
// <div className="flex flex-row items-center justify-between ">
|
|
563
|
+
// {/* Pagination Pages */}
|
|
564
|
+
// {range.length > 1 ? (
|
|
565
|
+
// <div className="flex w-fit flex-row items-stretch justify-center gap-2 overflow-clip rounded ">
|
|
566
|
+
// {/* Previous Page Button */}
|
|
567
|
+
// <div
|
|
568
|
+
// className={clsx(
|
|
569
|
+
// "flex h-6 w-6 rotate-180 cursor-pointer items-center justify-center rounded border bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 dark:bg-background dark:hover:bg-gray-700 "
|
|
570
|
+
// )}
|
|
571
|
+
// onClick={props.handlePrevPage}
|
|
572
|
+
// >
|
|
573
|
+
// <svg
|
|
574
|
+
// aria-label="Chevron Right Icon"
|
|
575
|
+
// stroke="currentColor"
|
|
576
|
+
// fill="currentColor"
|
|
577
|
+
// stroke-width="0"
|
|
578
|
+
// viewBox="0 0 16 16"
|
|
579
|
+
// height="1em"
|
|
580
|
+
// width="1em"
|
|
581
|
+
// >
|
|
582
|
+
// <path
|
|
583
|
+
// fill-rule="evenodd"
|
|
584
|
+
// d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
585
|
+
// ></path>
|
|
586
|
+
// </svg>
|
|
587
|
+
// </div>
|
|
588
|
+
// {/* Numbered Pagination */}
|
|
589
|
+
// <div className="flex flex-row items-center overflow-clip rounded transition-all">
|
|
590
|
+
// {/* The first page */}
|
|
591
|
+
// {range.length > 6 &&
|
|
592
|
+
// range.map((el, index) => {
|
|
593
|
+
// if (index <= 0) {
|
|
594
|
+
// return (
|
|
595
|
+
// <button
|
|
596
|
+
// key={index}
|
|
597
|
+
// className={clsx(
|
|
598
|
+
// "w-10 p-1 text-xs hover:bg-gray-200",
|
|
599
|
+
// page === el
|
|
600
|
+
// ? "bg-primary text-white hover:bg-primary"
|
|
601
|
+
// : "bg-gray-100"
|
|
602
|
+
// )}
|
|
603
|
+
// onClick={() => setPage(el)}
|
|
604
|
+
// >
|
|
605
|
+
// {el}
|
|
606
|
+
// </button>
|
|
607
|
+
// )
|
|
608
|
+
// }
|
|
609
|
+
// })}
|
|
610
|
+
// {/* The Current Page / Input */}
|
|
611
|
+
// {range?.length > 6 && (
|
|
612
|
+
// <input
|
|
613
|
+
// type={"text"}
|
|
614
|
+
// className=" w-10 bg-gray-100 p-1 text-center text-xs"
|
|
615
|
+
// defaultValue={
|
|
616
|
+
// page !== 0 || page !== range.length - 1 ? page : "..."
|
|
617
|
+
// }
|
|
618
|
+
// value={
|
|
619
|
+
// page == 1 || page == range.length
|
|
620
|
+
// ? "..."
|
|
621
|
+
// : enteredPage
|
|
622
|
+
// ? enteredPage
|
|
623
|
+
// : page
|
|
624
|
+
// }
|
|
625
|
+
// onChange={(e) => setEnteredPage(parseInt(e.target.value))}
|
|
626
|
+
// onKeyDown={(e) => {
|
|
627
|
+
// if (e.key === "Enter") {
|
|
628
|
+
// setPage(enteredPage)
|
|
629
|
+
// setEnteredPage(null)
|
|
630
|
+
// }
|
|
631
|
+
// }}
|
|
632
|
+
// />
|
|
633
|
+
// )}
|
|
634
|
+
// {/* The last page */}
|
|
635
|
+
// {range?.length > 6 &&
|
|
636
|
+
// range.map((el, index) => {
|
|
637
|
+
// if (index >= range.length - 1) {
|
|
638
|
+
// return (
|
|
639
|
+
// <button
|
|
640
|
+
// key={index}
|
|
641
|
+
// className={clsx(
|
|
642
|
+
// "w-10 p-1 text-xs hover:bg-gray-200",
|
|
643
|
+
// page === el
|
|
644
|
+
// ? "bg-primary text-white hover:bg-primary"
|
|
645
|
+
// : "bg-gray-100"
|
|
646
|
+
// )}
|
|
647
|
+
// onClick={() => setPage(el)}
|
|
648
|
+
// >
|
|
649
|
+
// {el}
|
|
650
|
+
// </button>
|
|
651
|
+
// )
|
|
652
|
+
// }
|
|
653
|
+
// })}
|
|
654
|
+
|
|
655
|
+
// {/* All Pages if less than 6 pages */}
|
|
656
|
+
// {range?.length <= 6 &&
|
|
657
|
+
// range.map((el, index) => {
|
|
658
|
+
// return (
|
|
659
|
+
// <button
|
|
660
|
+
// key={index}
|
|
661
|
+
// className={clsx(
|
|
662
|
+
// "w-10 p-1 text-xs hover:bg-gray-200 dark:hover:bg-gray-700",
|
|
663
|
+
// page === el
|
|
664
|
+
// ? "bg-primary text-white hover:bg-primary"
|
|
665
|
+
// : "border bg-background",
|
|
666
|
+
|
|
667
|
+
// index === 0 ? "rounded-l border-r-0" : "",
|
|
668
|
+
// index === range.length - 1 ? "rounded-r border-l-0" : ""
|
|
669
|
+
// )}
|
|
670
|
+
// onClick={() => setPage(el)}
|
|
671
|
+
// >
|
|
672
|
+
// {el}
|
|
673
|
+
// </button>
|
|
674
|
+
// )
|
|
675
|
+
// })}
|
|
676
|
+
// </div>
|
|
677
|
+
// {/* Next Page Button */}
|
|
678
|
+
// <div
|
|
679
|
+
// onClick={props.handleNextPage}
|
|
680
|
+
// className={clsx(
|
|
681
|
+
// "flex h-6 w-6 cursor-pointer items-center justify-center rounded border bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 dark:bg-background dark:hover:bg-gray-700 "
|
|
682
|
+
// )}
|
|
683
|
+
// >
|
|
684
|
+
// <svg
|
|
685
|
+
// aria-label="Chevron Right Icon"
|
|
686
|
+
// stroke="currentColor"
|
|
687
|
+
// fill="currentColor"
|
|
688
|
+
// stroke-width="0"
|
|
689
|
+
// viewBox="0 0 16 16"
|
|
690
|
+
// height="1em"
|
|
691
|
+
// width="1em"
|
|
692
|
+
// >
|
|
693
|
+
// <path
|
|
694
|
+
// fill-rule="evenodd"
|
|
695
|
+
// d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"
|
|
696
|
+
// ></path>
|
|
697
|
+
// </svg>
|
|
698
|
+
// </div>
|
|
699
|
+
// </div>
|
|
700
|
+
// ) : (
|
|
701
|
+
// <div></div>
|
|
702
|
+
// )}
|
|
703
|
+
// {/* Pagination Settings */}
|
|
704
|
+
// {props.rows ? (
|
|
705
|
+
// <div className="flex w-fit flex-row items-center gap-2 ">
|
|
706
|
+
// <div className="text-xs ">
|
|
707
|
+
// {props.rows.length} {props.texts?.items ?? "Items"}
|
|
708
|
+
// </div>
|
|
709
|
+
|
|
710
|
+
// <select
|
|
711
|
+
// value={perPage}
|
|
712
|
+
// className="h-6 cursor-pointer rounded border bg-background px-2 text-xs"
|
|
713
|
+
// onChange={(e) => {
|
|
714
|
+
// setPerPage(parseInt(e.target.value))
|
|
715
|
+
// }}
|
|
716
|
+
// >
|
|
717
|
+
// <option value={10} style={{ fontSize: 10 }}>
|
|
718
|
+
// 10 / {props.texts?.page ?? "Page"}
|
|
719
|
+
// </option>
|
|
720
|
+
// <option value={20} style={{ fontSize: 10 }}>
|
|
721
|
+
// 20 / {props.texts?.page ?? "Page"}
|
|
722
|
+
// </option>
|
|
723
|
+
// <option value={30} style={{ fontSize: 10 }}>
|
|
724
|
+
// 30 / {props.texts?.page ?? "Page"}
|
|
725
|
+
// </option>
|
|
726
|
+
// <option value={50} style={{ fontSize: 10 }}>
|
|
727
|
+
// 50 / {props.texts?.page ?? "Page"}
|
|
728
|
+
// </option>
|
|
729
|
+
// <option value={100} style={{ fontSize: 10 }}>
|
|
730
|
+
// 100 / {props.texts?.page ?? "Page"}
|
|
731
|
+
// </option>
|
|
732
|
+
// </select>
|
|
733
|
+
// </div>
|
|
734
|
+
// ) : (
|
|
735
|
+
// <div></div>
|
|
736
|
+
// )}
|
|
737
|
+
// </div>
|
|
738
|
+
// )
|