@vuu-ui/vuu-datatable 4.0.1 → 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 CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
- "version": "4.0.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.0.1",
16
- "@vuu-ui/vuu-table-types": "4.0.1",
17
- "@vuu-ui/vuu-filters": "4.0.1",
18
- "@vuu-ui/vuu-layout": "4.0.1",
19
- "@vuu-ui/vuu-popups": "4.0.1",
20
- "@vuu-ui/vuu-shell": "4.0.1",
21
- "@vuu-ui/vuu-table": "4.0.1",
22
- "@vuu-ui/vuu-table-extras": "4.0.1",
23
- "@vuu-ui/vuu-ui-controls": "4.0.1",
24
- "@vuu-ui/vuu-utils": "4.0.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, useRef } from "react";
5
- const TreeTable = ({ config, dataSource, source, ...tableProps })=>{
6
- const dataSourceRef = useRef(void 0);
7
- useMemo(()=>{
8
- if (dataSource) dataSourceRef.current = dataSource;
9
- else if (source) dataSourceRef.current = new TreeDataSource({
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
- else throw Error("TreeTable either source or dataSource must be provided");
12
+ throw Error("TreeTable either source or dataSource must be provided");
13
13
  }, [
14
- dataSource,
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: dataSourceRef.current?.columnDescriptors ?? [],
24
+ columns,
20
25
  columnSeparators: false,
21
26
  selectionBookendWidth: 0,
22
27
  rowSeparators: false
23
- }), [
24
- config
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: dataSourceRef.current,
38
+ dataSource: dataSource,
36
39
  groupToggleTarget: "toggle-icon",
37
40
  navigationStyle: "tree",
38
41
  showColumnHeaderMenus: false,
@@ -5,4 +5,4 @@ export interface FilterTableProps extends HTMLAttributes<HTMLDivElement> {
5
5
  FilterBarProps?: Partial<FilterBarProps>;
6
6
  TableProps: Omit<TableProps, "height" | "width">;
7
7
  }
8
- export declare const FilterTable: ({ FilterBarProps, TableProps, style: styleProps, ...htmlAttributes }: FilterTableProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const FilterTable: ({ FilterBarProps, TableProps, style: styleProps, ...htmlAttributes }: FilterTableProps) => import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { TableCellProps } from "@vuu-ui/vuu-table-types";
2
- export declare const JsonCell: ({ column, dataRow }: TableCellProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const JsonCell: ({ column, dataRow }: TableCellProps) => import("react").JSX.Element;
@@ -5,4 +5,4 @@ export interface JsonTableProps extends Omit<TableProps, "config" | "dataSource"
5
5
  config?: Pick<TableConfig, "columnSeparators" | "rowSeparators" | "zebraStripes">;
6
6
  source: JsonData;
7
7
  }
8
- export declare const JsonTable: ({ config, source: sourceProp, ...tableProps }: JsonTableProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ export declare const JsonTable: ({ config, source: sourceProp, ...tableProps }: JsonTableProps) => import("react").JSX.Element | null;
@@ -51,4 +51,4 @@ export interface LinkedTableViewProps extends HTMLAttributes<HTMLDivElement> {
51
51
  filter?: Filter;
52
52
  linkedDataSources: LinkedDataSources;
53
53
  }
54
- export declare const LinkedTableView: ({ className, linkedDataSources, ...htmlAttributes }: LinkedTableViewProps) => import("react/jsx-runtime").JSX.Element;
54
+ export declare const LinkedTableView: ({ className, linkedDataSources, ...htmlAttributes }: LinkedTableViewProps) => import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { ToggleButtonGroupProps } from "@salt-ds/core";
2
- export declare const TableLayoutToggleButton: (props: ToggleButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TableLayoutToggleButton: (props: ToggleButtonGroupProps) => import("react").JSX.Element;
@@ -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 { TableConfig } from "@vuu-ui/vuu-table-types";
4
- import { type TreeSourceNode } from "@vuu-ui/vuu-utils";
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-runtime").JSX.Element | null;
21
+ export declare const TreeTable: ({ className, config, dataSource: dataSourceProp, renderNodeAdornment, source, ...tableProps }: TreeTableProps) => import("react").JSX.Element;
16
22
  export {};