@vuu-ui/vuu-datatable 4.1.0 → 4.1.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/package.json +11 -12
- package/src/tree-table/TreeTable.js +22 -19
- package/types/tree-table/TreeTable.d.ts +10 -4
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.1.
|
|
2
|
+
"version": "4.1.1",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build:dev": "node ../../scripts/run-build.mjs",
|
|
8
7
|
"build": "node ../../scripts/run-build-rslib.ts",
|
|
9
8
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
10
9
|
},
|
|
@@ -12,16 +11,16 @@
|
|
|
12
11
|
"@salt-ds/core": "1.74.0",
|
|
13
12
|
"@salt-ds/styles": "0.4.2",
|
|
14
13
|
"@salt-ds/window": "0.1.2",
|
|
15
|
-
"@vuu-ui/vuu-data-local": "4.1.
|
|
16
|
-
"@vuu-ui/vuu-table-types": "4.1.
|
|
17
|
-
"@vuu-ui/vuu-filters": "4.1.
|
|
18
|
-
"@vuu-ui/vuu-layout": "4.1.
|
|
19
|
-
"@vuu-ui/vuu-popups": "4.1.
|
|
20
|
-
"@vuu-ui/vuu-shell": "4.1.
|
|
21
|
-
"@vuu-ui/vuu-table": "4.1.
|
|
22
|
-
"@vuu-ui/vuu-table-extras": "4.1.
|
|
23
|
-
"@vuu-ui/vuu-ui-controls": "4.1.
|
|
24
|
-
"@vuu-ui/vuu-utils": "4.1.
|
|
14
|
+
"@vuu-ui/vuu-data-local": "4.1.1",
|
|
15
|
+
"@vuu-ui/vuu-table-types": "4.1.1",
|
|
16
|
+
"@vuu-ui/vuu-filters": "4.1.1",
|
|
17
|
+
"@vuu-ui/vuu-layout": "4.1.1",
|
|
18
|
+
"@vuu-ui/vuu-popups": "4.1.1",
|
|
19
|
+
"@vuu-ui/vuu-shell": "4.1.1",
|
|
20
|
+
"@vuu-ui/vuu-table": "4.1.1",
|
|
21
|
+
"@vuu-ui/vuu-table-extras": "4.1.1",
|
|
22
|
+
"@vuu-ui/vuu-ui-controls": "4.1.1",
|
|
23
|
+
"@vuu-ui/vuu-utils": "4.1.1"
|
|
25
24
|
},
|
|
26
25
|
"peerDependencies": {
|
|
27
26
|
"clsx": "^2.0.0",
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Table } from "@vuu-ui/vuu-table";
|
|
3
3
|
import { TreeDataSource } from "@vuu-ui/vuu-data-local";
|
|
4
|
-
import { useMemo
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
useMemo(()=>{
|
|
8
|
-
if (
|
|
9
|
-
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
const TreeTable = ({ className, config, dataSource: dataSourceProp, renderNodeAdornment, source, ...tableProps })=>{
|
|
7
|
+
const dataSource = useMemo(()=>{
|
|
8
|
+
if (dataSourceProp) return dataSourceProp;
|
|
9
|
+
if (source) return new TreeDataSource({
|
|
10
10
|
data: source
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
throw Error("TreeTable either source or dataSource must be provided");
|
|
13
13
|
}, [
|
|
14
|
-
|
|
14
|
+
dataSourceProp,
|
|
15
15
|
source
|
|
16
16
|
]);
|
|
17
|
-
const tableConfig = useMemo(()=>
|
|
17
|
+
const tableConfig = useMemo(()=>{
|
|
18
|
+
const columns = renderNodeAdornment ? dataSource.columnDescriptors.map((column)=>column.hidden ? column : {
|
|
19
|
+
...column,
|
|
20
|
+
getGroupAdornment: renderNodeAdornment
|
|
21
|
+
}) : dataSource.columnDescriptors;
|
|
22
|
+
return {
|
|
18
23
|
...config,
|
|
19
|
-
columns
|
|
24
|
+
columns,
|
|
20
25
|
columnSeparators: false,
|
|
21
26
|
selectionBookendWidth: 0,
|
|
22
27
|
rowSeparators: false
|
|
23
|
-
}
|
|
24
|
-
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
config,
|
|
31
|
+
dataSource,
|
|
32
|
+
renderNodeAdornment
|
|
25
33
|
]);
|
|
26
|
-
console.log({
|
|
27
|
-
tableConfig,
|
|
28
|
-
dataSource: dataSourceRef.current
|
|
29
|
-
});
|
|
30
|
-
if (void 0 === dataSourceRef.current) return null;
|
|
31
34
|
return /*#__PURE__*/ jsx(Table, {
|
|
32
35
|
...tableProps,
|
|
33
|
-
className: "vuuTreeTable",
|
|
36
|
+
className: clsx("vuuTreeTable", className),
|
|
34
37
|
config: tableConfig,
|
|
35
|
-
dataSource:
|
|
38
|
+
dataSource: dataSource,
|
|
36
39
|
groupToggleTarget: "toggle-icon",
|
|
37
40
|
navigationStyle: "tree",
|
|
38
41
|
showColumnHeaderMenus: false,
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { TableProps } from "@vuu-ui/vuu-table";
|
|
1
|
+
import type { TableProps } from "@vuu-ui/vuu-table";
|
|
2
2
|
import { TreeDataSource } from "@vuu-ui/vuu-data-local";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
import type { DataRow, TableConfig } from "@vuu-ui/vuu-table-types";
|
|
5
|
+
import type { TreeSourceNode } from "@vuu-ui/vuu-utils";
|
|
5
6
|
interface Props extends Omit<TableProps, "config" | "dataSource"> {
|
|
6
7
|
config?: Pick<TableConfig, "columnSeparators" | "rowSeparators" | "zebraStripes">;
|
|
7
8
|
dataSource?: TreeDataSource;
|
|
9
|
+
/**
|
|
10
|
+
* Content rendered at the end of each tree node, after the label,
|
|
11
|
+
* e.g. a count, status indicator or action button.
|
|
12
|
+
*/
|
|
13
|
+
renderNodeAdornment?: (dataRow: DataRow) => ReactNode;
|
|
8
14
|
source?: TreeSourceNode[];
|
|
9
15
|
}
|
|
10
16
|
export type TreeTableProps = Props & ({
|
|
@@ -12,5 +18,5 @@ export type TreeTableProps = Props & ({
|
|
|
12
18
|
} | {
|
|
13
19
|
source: TreeSourceNode[];
|
|
14
20
|
});
|
|
15
|
-
export declare const TreeTable: ({ config, dataSource, source, ...tableProps }: TreeTableProps) => import("react").JSX.Element
|
|
21
|
+
export declare const TreeTable: ({ className, config, dataSource: dataSourceProp, renderNodeAdornment, source, ...tableProps }: TreeTableProps) => import("react").JSX.Element;
|
|
16
22
|
export {};
|