@equinor/apollo-components 1.12.2 → 2.0.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.
- package/dist/index.d.ts +70 -71
- package/dist/index.js +374 -328
- package/dist/index.mjs +377 -327
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IconData } from '@equinor/eds-icons';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, ReactElement,
|
|
4
|
-
import { Cell, CellContext, Table, Row, SortingState, OnChangeFn, ColumnDef,
|
|
3
|
+
import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction } from 'react';
|
|
4
|
+
import { Cell, CellContext, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
|
|
5
5
|
import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
|
|
6
|
+
import { SetRequired } from 'type-fest';
|
|
6
7
|
import * as styled_components from 'styled-components';
|
|
7
8
|
import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
|
|
8
|
-
import * as jotai from 'jotai';
|
|
9
|
-
import { Provider } from 'jotai';
|
|
10
9
|
|
|
11
10
|
interface AppShellProps {
|
|
12
11
|
children?: ReactNode;
|
|
@@ -35,17 +34,28 @@ declare type HierarchyCellOptions = {
|
|
|
35
34
|
};
|
|
36
35
|
declare function HierarchyCell<T>(cell: CellContext<T, any>, options?: HierarchyCellOptions): JSX.Element;
|
|
37
36
|
|
|
37
|
+
interface ColumnSelectProps<T> {
|
|
38
|
+
table: Table<T>;
|
|
39
|
+
}
|
|
40
|
+
declare function ColumnSelect<T>({ table }: ColumnSelectProps<T>): JSX.Element;
|
|
41
|
+
|
|
42
|
+
interface TableHeaderProps<T> {
|
|
43
|
+
table: Table<T>;
|
|
44
|
+
sticky?: boolean;
|
|
45
|
+
}
|
|
46
|
+
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
47
|
+
|
|
38
48
|
interface HeaderConfig {
|
|
39
|
-
|
|
40
|
-
stickyHeader?: boolean;
|
|
41
|
-
tableCaption?: string;
|
|
49
|
+
sticky?: boolean;
|
|
42
50
|
}
|
|
43
51
|
interface FilterConfig {
|
|
52
|
+
enableTableCaption?: boolean;
|
|
53
|
+
totalRowCount?: number;
|
|
44
54
|
columnSelect?: boolean;
|
|
45
55
|
globalFilter?: boolean;
|
|
46
56
|
globalFilterPlaceholder?: string;
|
|
47
57
|
filterFromLeafRows?: boolean;
|
|
48
|
-
|
|
58
|
+
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
49
59
|
}
|
|
50
60
|
interface TableRowWrapper<T> {
|
|
51
61
|
(props: TableRowWrapperProps<T>): ReactElement;
|
|
@@ -84,8 +94,25 @@ interface CellConfig<T> {
|
|
|
84
94
|
}
|
|
85
95
|
declare type RowSelectionMode = 'single' | 'multiple';
|
|
86
96
|
declare type TableLayout = 'auto' | 'fixed';
|
|
87
|
-
|
|
97
|
+
interface HTMLPropsRef<T extends HTMLElement> extends HTMLProps<T> {
|
|
98
|
+
ref?: MutableRefObject<T | null> | null;
|
|
99
|
+
}
|
|
100
|
+
interface InfiniteScrollConfig {
|
|
101
|
+
/** Called on scroll below offset. */
|
|
102
|
+
onBottomScroll: () => void;
|
|
103
|
+
/** Pixels above bottom. Defines when the onBottomScroll should be called. Defaults to `300`. */
|
|
104
|
+
offset?: number;
|
|
105
|
+
}
|
|
106
|
+
interface DataTableProps<T> {
|
|
107
|
+
tableCaption: string;
|
|
108
|
+
data: T[];
|
|
109
|
+
columns: ColumnDef<T, any>[];
|
|
110
|
+
cellConfig?: CellConfig<T>;
|
|
111
|
+
rowConfig?: RowConfig<T>;
|
|
112
|
+
headerConfig?: HeaderConfig;
|
|
113
|
+
isLoading?: boolean;
|
|
88
114
|
height?: string;
|
|
115
|
+
width?: string;
|
|
89
116
|
/**
|
|
90
117
|
* Defaults to `'auto'`.
|
|
91
118
|
*
|
|
@@ -95,65 +122,42 @@ declare type DataTableConfig<T> = {
|
|
|
95
122
|
* Default size is 150px.
|
|
96
123
|
*/
|
|
97
124
|
tableLayout?: TableLayout;
|
|
98
|
-
/** @deprecated use `cellConfig.enableSorting` instead. This is to align with \@tanstack/react-table types. */
|
|
99
|
-
sortable?: boolean;
|
|
100
125
|
virtual?: boolean;
|
|
101
|
-
rowSelectionMode?: RowSelectionMode;
|
|
102
|
-
width?: string;
|
|
103
|
-
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
|
104
|
-
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
105
126
|
getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
128
|
+
rowSelection?: Partial<ControlledState<RowSelectionState>> & {
|
|
129
|
+
mode?: RowSelectionMode;
|
|
130
|
+
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
|
131
|
+
includeExpansionButton?: boolean;
|
|
132
|
+
};
|
|
133
|
+
expansion?: Partial<ControlledState<ExpandedState>> & {
|
|
134
|
+
expandAllByDefault?: boolean;
|
|
135
|
+
};
|
|
136
|
+
sorting?: Partial<ControlledState<SortingState>> & {
|
|
137
|
+
enableSorting?: boolean;
|
|
138
|
+
manualSorting?: boolean;
|
|
139
|
+
};
|
|
140
|
+
globalFilter?: ControlledState<string>;
|
|
141
|
+
columnVisibility?: ControlledState<VisibilityState>;
|
|
142
|
+
actionsRow?: {
|
|
143
|
+
enableTableCaption?: boolean;
|
|
144
|
+
totalRowCount?: number;
|
|
145
|
+
enableColumnSelect?: boolean;
|
|
146
|
+
enableGlobalFilterInput?: boolean;
|
|
147
|
+
globalFilterPlaceholder?: string;
|
|
148
|
+
filterFromLeafRows?: boolean;
|
|
149
|
+
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
150
|
+
};
|
|
151
|
+
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
152
|
+
infiniteScroll?: InfiniteScrollConfig;
|
|
127
153
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
|
|
133
|
-
|
|
134
|
-
declare const columnVisibilityAtom: jotai.PrimitiveAtom<VisibilityState> & {
|
|
135
|
-
init: VisibilityState;
|
|
136
|
-
};
|
|
137
|
-
declare const globalFilterAtom: jotai.PrimitiveAtom<string> & {
|
|
138
|
-
init: string;
|
|
139
|
-
};
|
|
140
|
-
declare const rowSelectionAtom: jotai.PrimitiveAtom<RowSelectionState> & {
|
|
141
|
-
init: RowSelectionState;
|
|
142
|
-
};
|
|
143
|
-
declare const tableSortingAtom: jotai.PrimitiveAtom<SortingState> & {
|
|
144
|
-
init: SortingState;
|
|
154
|
+
declare type ControlledState<T> = {
|
|
155
|
+
state: T;
|
|
156
|
+
/** Callback when state chagnes. Using this requires the state to be fully controlled. */
|
|
157
|
+
onChange?: Dispatch<SetStateAction<T>>;
|
|
145
158
|
};
|
|
146
159
|
|
|
147
|
-
|
|
148
|
-
table: Table<T>;
|
|
149
|
-
}
|
|
150
|
-
declare function ColumnSelect<T>({ table }: ColumnSelectProps<T>): JSX.Element;
|
|
151
|
-
|
|
152
|
-
interface TableHeaderProps<T> {
|
|
153
|
-
table: Table<T>;
|
|
154
|
-
sticky?: boolean;
|
|
155
|
-
}
|
|
156
|
-
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
160
|
+
declare function DataTable<T>(props: DataTableProps<T>): JSX.Element;
|
|
157
161
|
|
|
158
162
|
/**
|
|
159
163
|
* Capitalize the table header.
|
|
@@ -164,14 +168,9 @@ declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Ele
|
|
|
164
168
|
*/
|
|
165
169
|
declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
|
|
166
170
|
/** Prepend a column definition array with a select column. */
|
|
167
|
-
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?:
|
|
168
|
-
|
|
169
|
-
declare type DataTableCompoundProps = typeof DataTable$1 & {
|
|
170
|
-
Provider: typeof DataTableProvider;
|
|
171
|
-
};
|
|
172
|
-
declare const DataTable: DataTableCompoundProps;
|
|
171
|
+
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T, unknown>[];
|
|
173
172
|
|
|
174
|
-
declare function SelectColumnDef<T>(props
|
|
173
|
+
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
175
174
|
|
|
176
175
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
177
176
|
|
|
@@ -180,4 +179,4 @@ declare type TypographyProps = {
|
|
|
180
179
|
} & TypographyProps$1;
|
|
181
180
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
182
181
|
|
|
183
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable,
|
|
182
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, FilterConfig, HTMLPropsRef, HeaderConfig, HierarchyCell, InfiniteScrollConfig, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, prependSelectColumn };
|