@douglasneuroinformatics/libui 2.3.0 → 2.3.1
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/dist/components/ClientTable/ClientTable.js +4 -4
- package/dist/components/Table/TableCell.d.ts.map +1 -1
- package/dist/components/Table/TableCell.js +1 -1
- package/dist/components/Table/TableHead.js +1 -1
- package/package.json +1 -1
- package/src/components/ClientTable/ClientTable.tsx +4 -4
- package/src/components/Table/TableCell.tsx +3 -1
- package/src/components/Table/TableHead.tsx +1 -1
|
@@ -24,7 +24,7 @@ function defaultFormatter(value) {
|
|
|
24
24
|
}
|
|
25
25
|
export const ClientTable = ({ className, columnDropdownOptions, columns, data, entriesPerPage = 10, minRows, onEntryClick }) => {
|
|
26
26
|
const [currentPage, setCurrentPage] = useState(1);
|
|
27
|
-
const pageCount = Math.ceil(data.length / entriesPerPage);
|
|
27
|
+
const pageCount = Math.max(Math.ceil(data.length / entriesPerPage), 1);
|
|
28
28
|
const firstEntry = data.length === 0 ? 0 : (currentPage - 1) * entriesPerPage + 1;
|
|
29
29
|
const lastEntry = Math.min(firstEntry + entriesPerPage - 1, data.length);
|
|
30
30
|
const currentEntries = data.slice(firstEntry - 1, lastEntry);
|
|
@@ -33,7 +33,7 @@ export const ClientTable = ({ className, columnDropdownOptions, columns, data, e
|
|
|
33
33
|
React.createElement("div", { className: "rounded-md border bg-card tracking-tight text-muted-foreground shadow" },
|
|
34
34
|
React.createElement(Table, null,
|
|
35
35
|
React.createElement(Table.Header, null,
|
|
36
|
-
React.createElement(Table.Row, null, columns.map((column, i) => (React.createElement(Table.Head, { className: "whitespace-nowrap text-foreground
|
|
36
|
+
React.createElement(Table.Row, null, columns.map((column, i) => (React.createElement(Table.Head, { className: "whitespace-nowrap text-foreground", key: i }, columnDropdownOptions ? (React.createElement(DropdownMenu, null,
|
|
37
37
|
React.createElement(DropdownMenu.Trigger, { className: "flex items-center justify-between gap-3" },
|
|
38
38
|
React.createElement("span", null, column.label),
|
|
39
39
|
React.createElement(ChevronDownIcon, null)),
|
|
@@ -53,7 +53,7 @@ export const ClientTable = ({ className, columnDropdownOptions, columns, data, e
|
|
|
53
53
|
} }, columns.map(({ field, formatter }, j) => {
|
|
54
54
|
let value;
|
|
55
55
|
if (!entry) {
|
|
56
|
-
value = '';
|
|
56
|
+
value = 'NA';
|
|
57
57
|
}
|
|
58
58
|
else if (typeof field === 'function') {
|
|
59
59
|
value = field(entry);
|
|
@@ -62,7 +62,7 @@ export const ClientTable = ({ className, columnDropdownOptions, columns, data, e
|
|
|
62
62
|
value = entry[field];
|
|
63
63
|
}
|
|
64
64
|
const formattedValue = entry && formatter ? formatter(value) : defaultFormatter(value);
|
|
65
|
-
return (React.createElement(Table.Cell, { className:
|
|
65
|
+
return (React.createElement(Table.Cell, { className: cn('text-ellipsis leading-none', !entry && 'invisible'), key: j }, formattedValue));
|
|
66
66
|
})));
|
|
67
67
|
})))),
|
|
68
68
|
React.createElement(ClientTablePagination, { currentPage: currentPage, firstEntry: firstEntry, lastEntry: lastEntry, pageCount: pageCount, setCurrentPage: setCurrentPage, totalEntries: data.length })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../src/components/Table/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"TableCell.d.ts","sourceRoot":"","sources":["../../../src/components/Table/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,SAAS,2HAMrB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { cn } from '../../utils.js';
|
|
3
3
|
export const TableCell = React.forwardRef(function TableCell({ className, ...props }, ref) {
|
|
4
|
-
return React.createElement("td", { className: cn('
|
|
4
|
+
return (React.createElement("td", { className: cn('px-6 py-3 align-middle [&:has([role=checkbox])]:pr-0', className), ref: ref, ...props }));
|
|
5
5
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { cn } from '../../utils.js';
|
|
3
3
|
export const TableHead = React.forwardRef(function TableHead({ className, ...props }, ref) {
|
|
4
|
-
return (React.createElement("th", { className: cn('
|
|
4
|
+
return (React.createElement("th", { className: cn('px-6 py-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0', className), ref: ref, ...props }));
|
|
5
5
|
});
|
package/package.json
CHANGED
|
@@ -72,7 +72,7 @@ export const ClientTable = <T extends ClientTableEntry>({
|
|
|
72
72
|
}: ClientTableProps<T>) => {
|
|
73
73
|
const [currentPage, setCurrentPage] = useState(1);
|
|
74
74
|
|
|
75
|
-
const pageCount = Math.ceil(data.length / entriesPerPage);
|
|
75
|
+
const pageCount = Math.max(Math.ceil(data.length / entriesPerPage), 1);
|
|
76
76
|
|
|
77
77
|
const firstEntry = data.length === 0 ? 0 : (currentPage - 1) * entriesPerPage + 1;
|
|
78
78
|
const lastEntry = Math.min(firstEntry + entriesPerPage - 1, data.length);
|
|
@@ -86,7 +86,7 @@ export const ClientTable = <T extends ClientTableEntry>({
|
|
|
86
86
|
<Table.Header>
|
|
87
87
|
<Table.Row>
|
|
88
88
|
{columns.map((column, i) => (
|
|
89
|
-
<Table.Head className="whitespace-nowrap text-foreground
|
|
89
|
+
<Table.Head className="whitespace-nowrap text-foreground" key={i}>
|
|
90
90
|
{columnDropdownOptions ? (
|
|
91
91
|
<DropdownMenu>
|
|
92
92
|
<DropdownMenu.Trigger className="flex items-center justify-between gap-3">
|
|
@@ -133,7 +133,7 @@ export const ClientTable = <T extends ClientTableEntry>({
|
|
|
133
133
|
{columns.map(({ field, formatter }, j) => {
|
|
134
134
|
let value: unknown;
|
|
135
135
|
if (!entry) {
|
|
136
|
-
value = '';
|
|
136
|
+
value = 'NA';
|
|
137
137
|
} else if (typeof field === 'function') {
|
|
138
138
|
value = field(entry);
|
|
139
139
|
} else {
|
|
@@ -141,7 +141,7 @@ export const ClientTable = <T extends ClientTableEntry>({
|
|
|
141
141
|
}
|
|
142
142
|
const formattedValue = entry && formatter ? formatter(value) : defaultFormatter(value);
|
|
143
143
|
return (
|
|
144
|
-
<Table.Cell className=
|
|
144
|
+
<Table.Cell className={cn('text-ellipsis leading-none', !entry && 'invisible')} key={j}>
|
|
145
145
|
{formattedValue}
|
|
146
146
|
</Table.Cell>
|
|
147
147
|
);
|
|
@@ -4,6 +4,8 @@ import { cn } from '../../utils.js';
|
|
|
4
4
|
|
|
5
5
|
export const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(
|
|
6
6
|
function TableCell({ className, ...props }, ref) {
|
|
7
|
-
return
|
|
7
|
+
return (
|
|
8
|
+
<td className={cn('px-6 py-3 align-middle [&:has([role=checkbox])]:pr-0', className)} ref={ref} {...props} />
|
|
9
|
+
);
|
|
8
10
|
}
|
|
9
11
|
);
|
|
@@ -7,7 +7,7 @@ export const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttr
|
|
|
7
7
|
return (
|
|
8
8
|
<th
|
|
9
9
|
className={cn(
|
|
10
|
-
'
|
|
10
|
+
'px-6 py-3 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0',
|
|
11
11
|
className
|
|
12
12
|
)}
|
|
13
13
|
ref={ref}
|