@equinor/eds-data-grid-react 0.2.0 → 0.3.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,5 +1,6 @@
1
- import { Column, ColumnDef, ColumnPinningState, ColumnResizeMode, OnChangeFn, Row, RowSelectionState, SortingState } from '@tanstack/react-table';
2
- import { CSSProperties, ReactElement } from 'react';
1
+ import { Column, ColumnDef, ColumnPinningState, ColumnResizeMode, ColumnSizingState, OnChangeFn, Row, RowSelectionState, SortingState, TableOptions } from '@tanstack/react-table';
2
+ import { Virtualizer } from '@tanstack/react-virtual';
3
+ import { CSSProperties, MutableRefObject, ReactElement } from 'react';
3
4
  type BaseProps<T> = {
4
5
  /**
5
6
  * The rows to display in the table
@@ -57,14 +58,32 @@ type BaseProps<T> = {
57
58
  scrollbarHorizontal?: boolean;
58
59
  /**
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`.
60
63
  * @default 800
61
64
  */
62
- width?: number;
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;
63
73
  /**
64
74
  * Height of the table.
75
+ *
76
+ * No suffix (like `px` or `rem`) equals to `px`.
65
77
  * @default none
66
78
  */
67
- height?: number;
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'];
68
87
  };
69
88
  type StyleProps<T> = {
70
89
  /**
@@ -162,8 +181,13 @@ type SortProps = {
162
181
  };
163
182
  type ColumnProps = {
164
183
  columnPinState?: ColumnPinningState;
184
+ columnSizing?: ColumnSizingState;
185
+ onColumnResize?: (e: ColumnSizingState) => void;
186
+ };
187
+ type RefProps = {
188
+ rowVirtualizerInstanceRef?: MutableRefObject<Virtualizer<HTMLDivElement, Element> | null>;
165
189
  };
166
- export type EdsDataGridProps<T> = BaseProps<T> & StyleProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & {
190
+ export type EdsDataGridProps<T> = BaseProps<T> & StyleProps<T> & SortProps & FilterProps & PagingProps & ColumnProps & VirtualProps & RefProps & {
167
191
  /**
168
192
  * Which columns are visible. If not set, all columns are visible. undefined means that the column is visible.
169
193
  * @default undefined
@@ -1,2 +1,3 @@
1
1
  export * from './EdsDataGrid';
2
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, };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Function returning wether a string only contains number. Allows leading or trailing spaces.
3
+ *
4
+ * Examples:
5
+ *
6
+ * ```
7
+ * isNumberOnlyString("10") // true
8
+ * isNumberOnlyString("10.10") // true
9
+ * isNumberOnlyString("10px") // false
10
+ * isNumberOnlyString("10%") // false
11
+ * isNumberOnlyString("10 ") // true
12
+ * ```
13
+ *
14
+ * @param number
15
+ * @returns
16
+ */
17
+ export declare function isNumberOnlyString(number: string): boolean;
18
+ export declare function addPxSuffixIfInputHasNoPrefix(size: number | string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/eds-data-grid-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
@@ -14,16 +14,16 @@
14
14
  "email": "fg_eds@equinor.com"
15
15
  },
16
16
  "peerDependencies": {
17
+ "@equinor/eds-core-react": ">=0.36.0",
17
18
  "react": ">=16.8",
18
19
  "react-dom": ">=16.8",
19
20
  "styled-components": ">=4.2"
20
21
  },
21
22
  "dependencies": {
22
23
  "@tanstack/react-table": "^8.10.7",
23
- "@tanstack/react-virtual": "^3.0.0-beta.54",
24
- "@equinor/eds-core-react": "^0.35.0",
25
- "@equinor/eds-icons": "^0.20.0",
26
- "@equinor/eds-utils": "^0.8.3",
24
+ "@tanstack/react-virtual": "^3.0.4",
25
+ "@equinor/eds-icons": "^0.21.0",
26
+ "@equinor/eds-utils": "^0.8.4",
27
27
  "@equinor/eds-tokens": "0.9.2"
28
28
  },
29
29
  "devDependencies": {
@@ -92,7 +92,6 @@
92
92
  "pnpm": ">=4",
93
93
  "node": ">=10.0.0"
94
94
  },
95
- "browserslist": "defaults, not IE 11",
96
95
  "scripts": {
97
96
  "build": "rollup -c --bundleConfigAsCjs && tsc -p tsconfig.build.json",
98
97
  "test": "tsc -p tsconfig.spec.json && jest",