@equinor/eds-data-grid-react 0.1.0-beta.3 → 0.3.0-rc

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.
@@ -0,0 +1,204 @@
1
+ import { Column, ColumnDef, ColumnPinningState, ColumnResizeMode, OnChangeFn, Row, RowSelectionState, SortingState, TableOptions } from '@tanstack/react-table';
2
+ import { Virtualizer } from '@tanstack/react-virtual';
3
+ import { CSSProperties, MutableRefObject, ReactElement } from 'react';
4
+ type BaseProps<T> = {
5
+ /**
6
+ * The rows to display in the table
7
+ */
8
+ rows: Array<T>;
9
+ /**
10
+ * Definition of the columns to display in the table
11
+ */
12
+ columns: ColumnDef<T>[];
13
+ /**
14
+ * The mode of column resizing. If not set, column resizing is disabled.
15
+ * Can be either 'onChange' or 'onEnd'
16
+ * @default undefined
17
+ */
18
+ columnResizeMode?: ColumnResizeMode;
19
+ /**
20
+ * Set this to enable rowSelection. If a function is provided, it will be called for each row to determine if it is selectable.
21
+ * @default false
22
+ */
23
+ rowSelection?: boolean | ((row: Row<T>) => boolean);
24
+ /**
25
+ * Callback for when row-selection changes
26
+ */
27
+ onSelectRow?: OnChangeFn<RowSelectionState>;
28
+ /**
29
+ * Enable debug mode. See https://tanstack.com/table/v8/docs/api/core/table#debugall
30
+ * @default false
31
+ */
32
+ debug?: boolean;
33
+ /**
34
+ * Make the table header sticky
35
+ * @default false
36
+ */
37
+ stickyHeader?: boolean;
38
+ /**
39
+ * Element to display in Table.Caption
40
+ * @default undefined
41
+ */
42
+ caption?: ReactElement;
43
+ /**
44
+ * The message to display when there are no rows
45
+ * @default undefined
46
+ */
47
+ emptyMessage?: string;
48
+ /**
49
+ * The currently selected rows
50
+ * @default {}
51
+ */
52
+ selectedRows?: Record<string | number, boolean>;
53
+ /**
54
+ * Whether there should be horizontal scrolling.
55
+ * This must be true for column pinning to work
56
+ * @default true
57
+ */
58
+ scrollbarHorizontal?: boolean;
59
+ /**
60
+ * Width of the table. Only takes effect if {@link scrollbarHorizontal} is true.
61
+ *
62
+ * No suffix (like `px` or `rem`) equals to `px`.
63
+ * @default 800
64
+ */
65
+ width?: string | number;
66
+ /**
67
+ * Min width of the table element.
68
+ *
69
+ * @example minWidth: 800
70
+ * @default none
71
+ */
72
+ minWidth?: string | number;
73
+ /**
74
+ * Height of the table.
75
+ *
76
+ * No suffix (like `px` or `rem`) equals to `px`.
77
+ * @default none
78
+ */
79
+ height?: string | number;
80
+ /**
81
+ * This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.
82
+ * @example getRowId: row => row.userId
83
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowid)
84
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)
85
+ */
86
+ getRowId?: TableOptions<T>['getRowId'];
87
+ };
88
+ type StyleProps<T> = {
89
+ /**
90
+ * Function that can be used to set custom css on a cell
91
+ * @param row
92
+ * @param columnId
93
+ */
94
+ cellStyle?: (row: Row<T>, columnId: string) => CSSProperties;
95
+ /**
96
+ * Function that can be used to set a custom class on a cell
97
+ * @param row
98
+ * @param columnId
99
+ * @returns string with list of classes
100
+ */
101
+ cellClass?: (row: Row<T>, columnId: string) => string;
102
+ /**
103
+ * Function that can be used to set a custom class on a row
104
+ * @param row
105
+ * @returns string with list of classes
106
+ */
107
+ rowClass?: (row: Row<T>) => string;
108
+ /**
109
+ * Function that can be used to set custom css on a row
110
+ * @param row
111
+ */
112
+ rowStyle?: (row: Row<T>) => CSSProperties;
113
+ /**
114
+ * Function that can be used to set custom classes on a header cell
115
+ * @param column
116
+ */
117
+ headerClass?: (column: Column<T>) => string;
118
+ /**
119
+ * Function that can be used to set custom styles on a header cell
120
+ * @param column
121
+ */
122
+ headerStyle?: (column: Column<T>) => CSSProperties;
123
+ };
124
+ type FilterProps = {
125
+ /**
126
+ * Whether to enable column filtering, adding inputs to the header cells
127
+ * Individual columns can be configured to disable filtering
128
+ * @default false
129
+ */
130
+ enableColumnFiltering?: boolean;
131
+ };
132
+ type PagingProps = {
133
+ /**
134
+ * Whether pagination should be enabled.
135
+ * @default false
136
+ */
137
+ enablePagination?: boolean;
138
+ /**
139
+ * The number of rows per page
140
+ * Only used if enablePagination is true
141
+ * @default 25
142
+ */
143
+ pageSize?: number;
144
+ /**
145
+ * Add this if you want to implement a custom pagination component
146
+ * Useful for e.g server-side paging
147
+ */
148
+ externalPaginator?: ReactElement;
149
+ };
150
+ type VirtualProps = {
151
+ /**
152
+ * Whether to enable virtualization. This will render only the visible rows currently in view.
153
+ * @default false
154
+ */
155
+ enableVirtual?: boolean;
156
+ /**
157
+ * The height of the virtualized table in pixels.
158
+ * @default 500
159
+ */
160
+ virtualHeight?: number;
161
+ };
162
+ type SortProps = {
163
+ /**
164
+ * Enable sorting.
165
+ * @default false
166
+ */
167
+ enableSorting?: boolean;
168
+ /**
169
+ * Method to call when sorting changes
170
+ */
171
+ onSortingChange?: OnChangeFn<SortingState>;
172
+ /**
173
+ * Enable manual sorting, useful for server-side sorting.
174
+ * @default false
175
+ */
176
+ manualSorting?: boolean;
177
+ /**
178
+ * Override the default sorting state
179
+ */
180
+ sortingState?: SortingState;
181
+ };
182
+ type ColumnProps = {
183
+ columnPinState?: ColumnPinningState;
184
+ };
185
+ type RefProps = {
186
+ rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, Element> | null>;
187
+ };
188
+ export type EdsDataGridProps<T> = BaseProps<T> & StyleProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & RefProps & {
189
+ /**
190
+ * Which columns are visible. If not set, all columns are visible. undefined means that the column is visible.
191
+ * @default undefined
192
+ */
193
+ columnVisibility?: Record<string, boolean>;
194
+ /**
195
+ * Callback for when column visibility changes. Only called if columnVisibility is set.
196
+ * @param columnVisibility
197
+ */
198
+ columnVisibilityChange?: (columnVisibility: Record<string, boolean>) => void;
199
+ /**
200
+ * An array of the columnIds in the order they should be displayed.
201
+ */
202
+ columnOrder?: Array<string>;
203
+ };
204
+ 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,3 @@
1
1
  export * from './EdsDataGrid';
2
+ export * from './EdsDataGridProps';
3
+ export * from './types';
@@ -0,0 +1,3 @@
1
+ import type { Cell, CellContext, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSort, ExpandedState, HeaderContext, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
2
+ import type { Virtualizer } from '@tanstack/react-virtual';
3
+ export type { Cell, CellContext, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSort, ExpandedState, HeaderContext, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState, Virtualizer, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-data-grid-react",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.3.0-rc",
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,62 +16,61 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=16.8",
18
18
  "react-dom": ">=16.8",
19
- "styled-components": ">=4.2"
19
+ "styled-components": ">=4.2",
20
+ "@equinor/eds-core-react": "^0.35.1"
20
21
  },
21
22
  "dependencies": {
22
- "@tanstack/react-table": "^8.8.5",
23
- "@tanstack/react-virtual": "^3.0.0-beta.54",
24
- "@equinor/eds-core-react": "^0.33.0",
25
- "@equinor/eds-icons": "^0.19.3",
23
+ "@tanstack/react-table": "^8.10.7",
24
+ "@tanstack/react-virtual": "^3.0.1",
25
+ "@equinor/eds-icons": "^0.21.0",
26
26
  "@equinor/eds-tokens": "0.9.2",
27
- "@equinor/eds-utils": "^0.8.2"
27
+ "@equinor/eds-utils": "^0.8.3"
28
28
  },
29
29
  "devDependencies": {
30
- "@mdx-js/react": "1.6.22",
31
- "@rollup/plugin-babel": "^6.0.3",
32
- "@rollup/plugin-commonjs": "^25.0.1",
33
- "@rollup/plugin-node-resolve": "^15.1.0",
34
- "@storybook/addon-a11y": "^7.3.0",
35
- "@storybook/addon-actions": "^7.3.0",
36
- "@storybook/addon-docs": "^7.3.0",
37
- "@storybook/addon-essentials": "^7.3.0",
38
- "@storybook/addon-links": "^7.3.0",
39
- "@storybook/blocks": "^7.3.0",
40
- "@storybook/builder-vite": "^7.3.0",
41
- "@storybook/client-api": "^7.3.0",
42
- "@storybook/react": "^7.3.0",
43
- "@storybook/react-vite": "^7.3.0",
44
- "@testing-library/dom": "^9.2.0",
45
- "@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",
46
46
  "@testing-library/react": "14.0.0",
47
- "@testing-library/user-event": "^14.4.3",
48
- "@types/jest": "^29.5.0",
49
- "@types/node": "18.14.2",
50
- "@types/ramda": "^0.28.24",
51
- "@types/react": "^18.0.21",
52
- "@types/react-dom": "^18.0.10",
53
- "@types/testing-library__jest-dom": "^5.14.5",
54
- "babel-loader": "^9.1.2",
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",
55
54
  "babel-plugin-styled-components": "^2.1.4",
56
- "jest": "29.4.3",
57
- "jest-environment-jsdom": "29.4.3",
58
- "jest-styled-components": "^7.1.1",
55
+ "jest": "29.7.0",
56
+ "jest-environment-jsdom": "29.7.0",
57
+ "jest-styled-components": "^7.2.0",
59
58
  "js-file-download": "^0.4.12",
60
- "postcss": "^8.4.21",
61
- "ramda": "^0.29.0",
59
+ "postcss": "^8.4.31",
60
+ "ramda": "^0.29.1",
62
61
  "react": "^18.2.0",
63
62
  "react-dom": "^18.2.0",
64
- "react-hook-form": "^7.43.9",
65
- "remark-gfm": "^3.0.1",
66
- "rollup": "^3.25.1",
63
+ "react-hook-form": "^7.47.0",
64
+ "remark-gfm": "^4.0.0",
65
+ "rollup": "^4.2.0",
67
66
  "rollup-plugin-delete": "^2.0.0",
68
67
  "rollup-plugin-postcss": "^4.0.2",
69
- "storybook": "^7.3.0",
70
- "styled-components": "6.0.8",
71
- "ts-jest": "29.0.5",
68
+ "storybook": "^7.5.1",
69
+ "styled-components": "6.1.0",
70
+ "ts-jest": "29.1.1",
72
71
  "ts-node": "10.9.1",
73
- "tsc-watch": "^6.0.0",
74
- "typescript": "~5.1.6"
72
+ "tsc-watch": "^6.0.4",
73
+ "typescript": "~5.2.2"
75
74
  },
76
75
  "homepage": "https://eds.equinor.com",
77
76
  "repository": {
@@ -93,7 +92,6 @@
93
92
  "pnpm": ">=4",
94
93
  "node": ">=10.0.0"
95
94
  },
96
- "browserslist": "defaults, not IE 11",
97
95
  "scripts": {
98
96
  "build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",
99
97
  "test": "tsc -p tsconfig.spec.json && jest",