nitro-web 0.0.109 → 0.0.110
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.
|
@@ -81,4 +81,18 @@
|
|
|
81
81
|
|
|
82
82
|
.__PrivateStripeElementLoader {
|
|
83
83
|
display: none !important;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* ---- Animation ------------------------- */
|
|
87
|
+
|
|
88
|
+
@keyframes dots {
|
|
89
|
+
0%, 20% { content: ""; }
|
|
90
|
+
40% { content: "."; }
|
|
91
|
+
60% { content: ".."; }
|
|
92
|
+
80%, 100% { content: "..."; }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.loading-dots::after {
|
|
96
|
+
content: "";
|
|
97
|
+
animation: dots 2s steps(1, end) infinite;
|
|
84
98
|
}
|
|
@@ -42,6 +42,7 @@ export type TableProps<T> = {
|
|
|
42
42
|
columnHeaderClassName?: string
|
|
43
43
|
checkboxClassName?: string
|
|
44
44
|
checkboxSize?: number
|
|
45
|
+
isLoading?:boolean
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export function Table<T extends TableRow>({
|
|
@@ -67,6 +68,7 @@ export function Table<T extends TableRow>({
|
|
|
67
68
|
columnHeaderClassName,
|
|
68
69
|
checkboxClassName,
|
|
69
70
|
checkboxSize=16,
|
|
71
|
+
isLoading=false,
|
|
70
72
|
}: TableProps<T>) {
|
|
71
73
|
const location = useLocation()
|
|
72
74
|
const [selectedRowIds, setSelectedRowIds] = useState<string[]>([])
|
|
@@ -87,7 +89,7 @@ export function Table<T extends TableRow>({
|
|
|
87
89
|
|
|
88
90
|
const onSelect = useCallback((idOrAll: string, checked: boolean) => {
|
|
89
91
|
setSelectedRowIds((o) => {
|
|
90
|
-
if (idOrAll == 'all' && checked) return rows.map(row => row?._id||'')
|
|
92
|
+
if (idOrAll == 'all' && checked) return (rows ?? []).map(row => row?._id||'')
|
|
91
93
|
else if (idOrAll == 'all' && !checked) return []
|
|
92
94
|
else if (o.includes(idOrAll) && !checked) return o.filter(id => id != idOrAll)
|
|
93
95
|
else if (!o.includes(idOrAll) && checked) return [...o, idOrAll]
|
|
@@ -101,7 +103,7 @@ export function Table<T extends TableRow>({
|
|
|
101
103
|
}, [])
|
|
102
104
|
|
|
103
105
|
// Reset selected rows when the location changes, or the number of rows changed (e.g. when a row is removed)
|
|
104
|
-
useEffect(() => setSelectedRowIds([]), [location.key, rows.map(row => row?._id||'').join(',')])
|
|
106
|
+
useEffect(() => setSelectedRowIds([]), [location.key, (rows ?? []).map(row => row?._id||'').join(',')])
|
|
105
107
|
|
|
106
108
|
// --- Sorting ---
|
|
107
109
|
|
|
@@ -287,11 +289,12 @@ export function Table<T extends TableRow>({
|
|
|
287
289
|
>
|
|
288
290
|
<div
|
|
289
291
|
className={twMerge(
|
|
290
|
-
'absolute top-0 h-full flex items-center justify-center text-sm
|
|
292
|
+
'absolute top-0 h-full flex items-center justify-center text-sm',
|
|
293
|
+
isLoading ? '' : 'text-gray-500',
|
|
291
294
|
col.innerClassName
|
|
292
295
|
)}
|
|
293
296
|
>
|
|
294
|
-
{ j == 0 && 'No records found.' }
|
|
297
|
+
{ j == 0 && (isLoading ? <>Loading<span className="relative ml-[2px] loading-dots" /></> : 'No records found.') }
|
|
295
298
|
</div>
|
|
296
299
|
</div>
|
|
297
300
|
)
|
|
@@ -505,6 +505,15 @@ export function Styleguide({ className, elements, children, currencies }: Styleg
|
|
|
505
505
|
generateTd={generateTd}
|
|
506
506
|
className="mb-6"
|
|
507
507
|
/>
|
|
508
|
+
<Table
|
|
509
|
+
rows={[]}
|
|
510
|
+
columns={thead}
|
|
511
|
+
rowSideColor={(row) => ({ className: row?.status == 'pending' ? 'bg-yellow-400' : '', width: 5 })}
|
|
512
|
+
generateCheckboxActions={generateCheckboxActions}
|
|
513
|
+
generateTd={generateTd}
|
|
514
|
+
className="mb-6"
|
|
515
|
+
isLoading={true}
|
|
516
|
+
/>
|
|
508
517
|
<Table
|
|
509
518
|
rows={rows.slice(0, 2).map(row => ({ ...row, _id: row._id + '1' }))}
|
|
510
519
|
columns={thead}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitro-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.110",
|
|
4
4
|
"repository": "github:boycce/nitro-web",
|
|
5
5
|
"homepage": "https://boycce.github.io/nitro-web/",
|
|
6
6
|
"description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
|