@equinor/eds-data-grid-react 0.1.0-beta.2 → 0.2.0

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.
@@ -1,133 +1,2 @@
1
- import { Column, ColumnDef, ColumnResizeMode, OnChangeFn, Row, RowSelectionState } from '@tanstack/react-table';
2
- import { CSSProperties, ReactElement } from 'react';
3
- export type EdsDataGridProps<T> = {
4
- /**
5
- * The rows to display in the table
6
- */
7
- rows: Array<T>;
8
- /**
9
- * Definition of the columns to display in the table
10
- */
11
- columns: ColumnDef<T>[];
12
- /**
13
- * The mode of column resizing. If not set, column resizing is disabled.
14
- * Can be either 'onChange' or 'onEnd'
15
- * @default undefined
16
- */
17
- columnResizeMode?: ColumnResizeMode;
18
- /**
19
- * Set this to enable rowSelection. If a function is provided, it will be called for each row to determine if it is selectable.
20
- * @default false
21
- */
22
- rowSelection?: boolean | ((row: Row<T>) => boolean);
23
- /**
24
- * Callback for when row-selection changes
25
- */
26
- onSelectRow?: OnChangeFn<RowSelectionState>;
27
- /**
28
- * Enable debug mode. See https://tanstack.com/table/v8/docs/api/core/table#debugall
29
- * @default false
30
- */
31
- debug?: boolean;
32
- /**
33
- * Enable sorting.
34
- * @default false
35
- */
36
- enableSorting?: boolean;
37
- /**
38
- * Make the table header sticky
39
- * @default false
40
- */
41
- stickyHeader?: boolean;
42
- /**
43
- * Element to display in Table.Caption
44
- * @default undefined
45
- */
46
- caption?: ReactElement;
47
- /**
48
- * Whether to enable column filtering, adding inputs to the header cells
49
- * Individual columns can be configured to disable filtering
50
- * @default false
51
- */
52
- enableColumnFiltering?: boolean;
53
- /**
54
- * Whether pagination should be enabled.
55
- * @default false
56
- */
57
- enablePagination?: boolean;
58
- /**
59
- * The number of rows per page
60
- * Only used if enablePagination is true
61
- * @default 25
62
- */
63
- pageSize?: number;
64
- /**
65
- * The message to display when there are no rows
66
- * @default undefined
67
- */
68
- emptyMessage?: string;
69
- /**
70
- * The currently selected rows
71
- * @default {}
72
- */
73
- selectedRows?: Record<string | number, boolean>;
74
- /**
75
- * Whether to enable virtualization. This will render only the visible rows currently in view.
76
- * @default false
77
- */
78
- enableVirtual?: boolean;
79
- /**
80
- * The height of the virtualized table in pixels.
81
- * @default 500
82
- */
83
- virtualHeight?: number;
84
- /**
85
- * Which columns are visible. If not set, all columns are visible. undefined means that the column is visible.
86
- * @default undefined
87
- */
88
- columnVisibility?: Record<string, boolean>;
89
- /**
90
- * Callback for when column visibility changes. Only called if columnVisibility is set.
91
- * @param columnVisibility
92
- */
93
- columnVisibilityChange?: (columnVisibility: Record<string, boolean>) => void;
94
- /**
95
- * An array of the columnIds in the order they should be displayed.
96
- */
97
- columnOrder?: Array<string>;
98
- /**
99
- * Function that can be used to set custom css on a cell
100
- * @param row
101
- * @param columnId
102
- */
103
- cellStyle?: (row: Row<T>, columnId: string) => CSSProperties;
104
- /**
105
- * Function that can be used to set a custom class on a cell
106
- * @param row
107
- * @param columnId
108
- * @returns string with list of classes
109
- */
110
- cellClass?: (row: Row<T>, columnId: string) => string;
111
- /**
112
- * Function that can be used to set a custom class on a row
113
- * @param row
114
- * @returns string with list of classes
115
- */
116
- rowClass?: (row: Row<T>) => string;
117
- /**
118
- * Function that can be used to set custom css on a row
119
- * @param row
120
- */
121
- rowStyle?: (row: Row<T>) => CSSProperties;
122
- /**
123
- * Function that can be used to set custom classes on a header cell
124
- * @param column
125
- */
126
- headerClass?: (column: Column<T>) => string;
127
- /**
128
- * Function that can be used to set custom styles on a header cell
129
- * @param column
130
- */
131
- headerStyle?: (column: Column<T>) => CSSProperties;
132
- };
133
- export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, selectedRows, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, onSelectRow, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, }: EdsDataGridProps<T>): JSX.Element;
1
+ import { EdsDataGridProps } from './EdsDataGridProps';
2
+ export declare function EdsDataGrid<T>({ rows, columns, columnResizeMode, pageSize, rowSelection, selectedRows, enableColumnFiltering, debug, enablePagination, enableSorting, stickyHeader, onSelectRow, caption, enableVirtual, virtualHeight, columnVisibility, columnVisibilityChange, emptyMessage, columnOrder, cellClass, cellStyle, rowClass, rowStyle, headerClass, headerStyle, externalPaginator, onSortingChange, manualSorting, sortingState, columnPinState, scrollbarHorizontal, width, height, }: EdsDataGridProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -15,6 +15,6 @@ type Context<T> = {
15
15
  export declare const EdsDataGridContext: import("react").Context<Context<any>>;
16
16
  export declare function TableProvider<T>({ children, ...props }: Context<T> & {
17
17
  children: ReactElement | Array<ReactElement>;
18
- }): JSX.Element;
18
+ }): import("react/jsx-runtime").JSX.Element;
19
19
  export declare const useTableContext: () => Context<any>;
20
20
  export {};
@@ -0,0 +1,182 @@
1
+ import { Column, ColumnDef, ColumnPinningState, ColumnResizeMode, OnChangeFn, Row, RowSelectionState, SortingState } from '@tanstack/react-table';
2
+ import { CSSProperties, ReactElement } from 'react';
3
+ type BaseProps<T> = {
4
+ /**
5
+ * The rows to display in the table
6
+ */
7
+ rows: Array<T>;
8
+ /**
9
+ * Definition of the columns to display in the table
10
+ */
11
+ columns: ColumnDef<T>[];
12
+ /**
13
+ * The mode of column resizing. If not set, column resizing is disabled.
14
+ * Can be either 'onChange' or 'onEnd'
15
+ * @default undefined
16
+ */
17
+ columnResizeMode?: ColumnResizeMode;
18
+ /**
19
+ * Set this to enable rowSelection. If a function is provided, it will be called for each row to determine if it is selectable.
20
+ * @default false
21
+ */
22
+ rowSelection?: boolean | ((row: Row<T>) => boolean);
23
+ /**
24
+ * Callback for when row-selection changes
25
+ */
26
+ onSelectRow?: OnChangeFn<RowSelectionState>;
27
+ /**
28
+ * Enable debug mode. See https://tanstack.com/table/v8/docs/api/core/table#debugall
29
+ * @default false
30
+ */
31
+ debug?: boolean;
32
+ /**
33
+ * Make the table header sticky
34
+ * @default false
35
+ */
36
+ stickyHeader?: boolean;
37
+ /**
38
+ * Element to display in Table.Caption
39
+ * @default undefined
40
+ */
41
+ caption?: ReactElement;
42
+ /**
43
+ * The message to display when there are no rows
44
+ * @default undefined
45
+ */
46
+ emptyMessage?: string;
47
+ /**
48
+ * The currently selected rows
49
+ * @default {}
50
+ */
51
+ selectedRows?: Record<string | number, boolean>;
52
+ /**
53
+ * Whether there should be horizontal scrolling.
54
+ * This must be true for column pinning to work
55
+ * @default true
56
+ */
57
+ scrollbarHorizontal?: boolean;
58
+ /**
59
+ * Width of the table. Only takes effect if {@link scrollbarHorizontal} is true.
60
+ * @default 800
61
+ */
62
+ width?: number;
63
+ /**
64
+ * Height of the table.
65
+ * @default none
66
+ */
67
+ height?: number;
68
+ };
69
+ type StyleProps<T> = {
70
+ /**
71
+ * Function that can be used to set custom css on a cell
72
+ * @param row
73
+ * @param columnId
74
+ */
75
+ cellStyle?: (row: Row<T>, columnId: string) => CSSProperties;
76
+ /**
77
+ * Function that can be used to set a custom class on a cell
78
+ * @param row
79
+ * @param columnId
80
+ * @returns string with list of classes
81
+ */
82
+ cellClass?: (row: Row<T>, columnId: string) => string;
83
+ /**
84
+ * Function that can be used to set a custom class on a row
85
+ * @param row
86
+ * @returns string with list of classes
87
+ */
88
+ rowClass?: (row: Row<T>) => string;
89
+ /**
90
+ * Function that can be used to set custom css on a row
91
+ * @param row
92
+ */
93
+ rowStyle?: (row: Row<T>) => CSSProperties;
94
+ /**
95
+ * Function that can be used to set custom classes on a header cell
96
+ * @param column
97
+ */
98
+ headerClass?: (column: Column<T>) => string;
99
+ /**
100
+ * Function that can be used to set custom styles on a header cell
101
+ * @param column
102
+ */
103
+ headerStyle?: (column: Column<T>) => CSSProperties;
104
+ };
105
+ type FilterProps = {
106
+ /**
107
+ * Whether to enable column filtering, adding inputs to the header cells
108
+ * Individual columns can be configured to disable filtering
109
+ * @default false
110
+ */
111
+ enableColumnFiltering?: boolean;
112
+ };
113
+ type PagingProps = {
114
+ /**
115
+ * Whether pagination should be enabled.
116
+ * @default false
117
+ */
118
+ enablePagination?: boolean;
119
+ /**
120
+ * The number of rows per page
121
+ * Only used if enablePagination is true
122
+ * @default 25
123
+ */
124
+ pageSize?: number;
125
+ /**
126
+ * Add this if you want to implement a custom pagination component
127
+ * Useful for e.g server-side paging
128
+ */
129
+ externalPaginator?: ReactElement;
130
+ };
131
+ type VirtualProps = {
132
+ /**
133
+ * Whether to enable virtualization. This will render only the visible rows currently in view.
134
+ * @default false
135
+ */
136
+ enableVirtual?: boolean;
137
+ /**
138
+ * The height of the virtualized table in pixels.
139
+ * @default 500
140
+ */
141
+ virtualHeight?: number;
142
+ };
143
+ type SortProps = {
144
+ /**
145
+ * Enable sorting.
146
+ * @default false
147
+ */
148
+ enableSorting?: boolean;
149
+ /**
150
+ * Method to call when sorting changes
151
+ */
152
+ onSortingChange?: OnChangeFn<SortingState>;
153
+ /**
154
+ * Enable manual sorting, useful for server-side sorting.
155
+ * @default false
156
+ */
157
+ manualSorting?: boolean;
158
+ /**
159
+ * Override the default sorting state
160
+ */
161
+ sortingState?: SortingState;
162
+ };
163
+ type ColumnProps = {
164
+ columnPinState?: ColumnPinningState;
165
+ };
166
+ export type EdsDataGridProps<T> = BaseProps<T> & StyleProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & {
167
+ /**
168
+ * Which columns are visible. If not set, all columns are visible. undefined means that the column is visible.
169
+ * @default undefined
170
+ */
171
+ columnVisibility?: Record<string, boolean>;
172
+ /**
173
+ * Callback for when column visibility changes. Only called if columnVisibility is set.
174
+ * @param columnVisibility
175
+ */
176
+ columnVisibilityChange?: (columnVisibility: Record<string, boolean>) => void;
177
+ /**
178
+ * An array of the columnIds in the order they should be displayed.
179
+ */
180
+ columnOrder?: Array<string>;
181
+ };
182
+ export {};
@@ -1,9 +1,10 @@
1
1
  import { InputHTMLAttributes } from 'react';
2
2
  type Value = string | number | Array<string | number>;
3
- export declare function DebouncedInput({ value: initialValue, values, onChange, debounce, ...props }: {
3
+ export declare function DebouncedInput({ value: initialValue, values, onChange, debounce, label, ...props }: {
4
4
  value: Value;
5
5
  values: Array<string | number>;
6
6
  onChange: (value: Value) => void;
7
7
  debounce?: number;
8
- } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>): JSX.Element;
8
+ label?: string;
9
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -3,5 +3,5 @@ type FilterProps<T = unknown> = {
3
3
  column: Column<T>;
4
4
  table: TanStackTable<T>;
5
5
  };
6
- export declare function Filter<T = unknown>({ column, table }: FilterProps<T>): JSX.Element;
6
+ export declare function Filter<T = unknown>({ column, table }: FilterProps<T>): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -2,5 +2,5 @@ import { Cell } from '@tanstack/react-table';
2
2
  type Props<T> = {
3
3
  cell: Cell<T, unknown>;
4
4
  };
5
- export declare function TableBodyCell<T>({ cell }: Props<T>): JSX.Element;
5
+ export declare function TableBodyCell<T>({ cell }: Props<T>): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
@@ -5,5 +5,5 @@ type Props<T> = {
5
5
  deltaOffset: number | null;
6
6
  table: TanStackTable<T>;
7
7
  };
8
- export declare function TableHeaderCell<T>({ header, columnResizeMode }: Props<T>): JSX.Element;
8
+ export declare function TableHeaderCell<T>({ header, columnResizeMode }: Props<T>): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -5,5 +5,5 @@ type Props<T> = {
5
5
  deltaOffset: number | null;
6
6
  table: TanStackTable<T>;
7
7
  };
8
- export declare function TableHeaderRow<T>({ headerGroup, columnResizeMode, deltaOffset, table, }: Props<T>): JSX.Element;
8
+ export declare function TableHeaderRow<T>({ headerGroup, columnResizeMode, deltaOffset, table, }: Props<T>): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -3,5 +3,5 @@ import { HTMLAttributes } from 'react';
3
3
  type Props<T> = {
4
4
  row: Row<T>;
5
5
  } & HTMLAttributes<HTMLTableRowElement>;
6
- export declare function TableRow<T>({ row }: Props<T>): JSX.Element;
6
+ export declare function TableRow<T>({ row }: Props<T>): import("react/jsx-runtime").JSX.Element;
7
7
  export {};
@@ -1 +1,2 @@
1
1
  export * from './EdsDataGrid';
2
+ export * from './EdsDataGridProps';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-data-grid-react",
3
- "version": "0.1.0-beta.2",
3
+ "version": "0.2.0",
4
4
  "description": "A feature-rich data-grid written in React, implementing the Equinor Design System",
5
5
  "license": "MIT",
6
6
  "types": "dist/types/index.d.ts",
@@ -16,63 +16,61 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=16.8",
18
18
  "react-dom": ">=16.8",
19
- "styled-components": ">=4.2 < 6"
19
+ "styled-components": ">=4.2"
20
20
  },
21
21
  "dependencies": {
22
- "@tanstack/react-table": "^8.8.5",
22
+ "@tanstack/react-table": "^8.10.7",
23
23
  "@tanstack/react-virtual": "^3.0.0-beta.54",
24
- "@equinor/eds-core-react": "^0.32.2",
25
- "@equinor/eds-tokens": "0.9.2",
26
- "@equinor/eds-icons": "^0.19.2",
27
- "@equinor/eds-utils": "^0.8.0"
24
+ "@equinor/eds-core-react": "^0.35.0",
25
+ "@equinor/eds-icons": "^0.20.0",
26
+ "@equinor/eds-utils": "^0.8.3",
27
+ "@equinor/eds-tokens": "0.9.2"
28
28
  },
29
29
  "devDependencies": {
30
- "typescript": "~4.9.5",
31
- "ts-jest": "29.0.5",
32
- "ts-node": "10.9.1",
33
- "@types/node": "18.14.2",
34
- "jest": "29.4.3",
35
- "jest-environment-jsdom": "29.4.3",
36
- "@testing-library/jest-dom": "^5.16.5",
30
+ "@mdx-js/react": "2.3.0",
31
+ "@rollup/plugin-babel": "^6.0.4",
32
+ "@rollup/plugin-commonjs": "^25.0.7",
33
+ "@rollup/plugin-node-resolve": "^15.2.3",
34
+ "@storybook/addon-a11y": "^7.5.1",
35
+ "@storybook/addon-actions": "^7.5.1",
36
+ "@storybook/addon-docs": "^7.5.1",
37
+ "@storybook/addon-essentials": "^7.5.1",
38
+ "@storybook/addon-links": "^7.5.1",
39
+ "@storybook/blocks": "^7.5.1",
40
+ "@storybook/builder-vite": "^7.5.1",
41
+ "@storybook/client-api": "^7.5.1",
42
+ "@storybook/react": "^7.5.1",
43
+ "@storybook/react-vite": "^7.5.1",
44
+ "@testing-library/dom": "^9.3.3",
45
+ "@testing-library/jest-dom": "^6.1.4",
37
46
  "@testing-library/react": "14.0.0",
38
- "@testing-library/user-event": "^14.4.3",
47
+ "@testing-library/user-event": "^14.5.1",
48
+ "@types/jest": "^29.5.6",
49
+ "@types/node": "20.8.9",
50
+ "@types/ramda": "^0.29.7",
51
+ "@types/react": "^18.2.33",
52
+ "@types/react-dom": "^18.2.14",
53
+ "babel-loader": "^9.1.3",
54
+ "babel-plugin-styled-components": "^2.1.4",
55
+ "jest": "29.7.0",
56
+ "jest-environment-jsdom": "29.7.0",
57
+ "jest-styled-components": "^7.2.0",
58
+ "js-file-download": "^0.4.12",
59
+ "postcss": "^8.4.31",
60
+ "ramda": "^0.29.1",
39
61
  "react": "^18.2.0",
40
62
  "react-dom": "^18.2.0",
41
- "@types/jest": "^29.5.0",
42
- "@types/react": "^18.0.21",
43
- "@types/react-dom": "^18.0.10",
44
- "@types/styled-components": "^5.1.26",
45
- "rollup": "^3.25.1",
63
+ "react-hook-form": "^7.47.0",
64
+ "remark-gfm": "^4.0.0",
65
+ "rollup": "^4.2.0",
46
66
  "rollup-plugin-delete": "^2.0.0",
47
67
  "rollup-plugin-postcss": "^4.0.2",
48
- "storybook": "^7.0.11",
49
- "styled-components": "5.3.9",
50
- "@mdx-js/react": "1.6.22",
51
- "@rollup/plugin-babel": "^6.0.3",
52
- "@rollup/plugin-commonjs": "^25.0.1",
53
- "@rollup/plugin-node-resolve": "^15.1.0",
54
- "@storybook/addon-a11y": "^7.0.11",
55
- "@storybook/addon-actions": "^7.0.11",
56
- "@storybook/addon-docs": "^7.0.11",
57
- "@storybook/addon-essentials": "^7.0.11",
58
- "@storybook/addon-links": "^7.0.11",
59
- "@storybook/blocks": "^7.0.11",
60
- "@storybook/builder-vite": "^7.0.11",
61
- "@storybook/client-api": "^7.0.11",
62
- "@storybook/react": "^7.0.11",
63
- "@storybook/react-vite": "^7.0.11",
64
- "@testing-library/dom": "^9.2.0",
65
- "@types/ramda": "^0.28.24",
66
- "@types/testing-library__jest-dom": "^5.14.5",
67
- "babel-loader": "^9.1.2",
68
- "babel-plugin-styled-components": "^2.1.1",
69
- "jest-styled-components": "^7.1.1",
70
- "js-file-download": "^0.4.12",
71
- "postcss": "^8.4.21",
72
- "ramda": "^0.29.0",
73
- "react-hook-form": "^7.43.9",
74
- "remark-gfm": "^3.0.1",
75
- "tsc-watch": "^6.0.0"
68
+ "storybook": "^7.5.1",
69
+ "styled-components": "6.1.0",
70
+ "ts-jest": "29.1.1",
71
+ "ts-node": "10.9.1",
72
+ "tsc-watch": "^6.0.4",
73
+ "typescript": "~5.2.2"
76
74
  },
77
75
  "homepage": "https://eds.equinor.com",
78
76
  "repository": {