@equinor/apollo-components 1.12.3 → 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 +68 -80
- package/dist/index.js +338 -335
- package/dist/index.mjs +340 -333
- 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, HTMLProps, MutableRefObject,
|
|
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,76 +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
|
-
|
|
128
|
-
|
|
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
|
+
};
|
|
129
151
|
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
130
152
|
infiniteScroll?: InfiniteScrollConfig;
|
|
131
153
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
interface DataTableRawProps<T> extends DataTableCommonProps<T> {
|
|
137
|
-
table: Table<T>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
declare function DataTable$1<T>(props: DataTableProps<T>): JSX.Element;
|
|
141
|
-
|
|
142
|
-
declare type DataTableProviderProps = ComponentProps<typeof Provider>;
|
|
143
|
-
declare function DataTableProvider({ children, ...props }: DataTableProviderProps): JSX.Element;
|
|
144
|
-
|
|
145
|
-
declare const columnVisibilityAtom: jotai.PrimitiveAtom<VisibilityState> & {
|
|
146
|
-
init: VisibilityState;
|
|
147
|
-
};
|
|
148
|
-
declare const globalFilterAtom: jotai.PrimitiveAtom<string> & {
|
|
149
|
-
init: string;
|
|
150
|
-
};
|
|
151
|
-
declare const rowSelectionAtom: jotai.PrimitiveAtom<RowSelectionState> & {
|
|
152
|
-
init: RowSelectionState;
|
|
153
|
-
};
|
|
154
|
-
declare const tableSortingAtom: jotai.PrimitiveAtom<SortingState> & {
|
|
155
|
-
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>>;
|
|
156
158
|
};
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
table: Table<T>;
|
|
160
|
-
}
|
|
161
|
-
declare function ColumnSelect<T>({ table }: ColumnSelectProps<T>): JSX.Element;
|
|
162
|
-
|
|
163
|
-
interface TableHeaderProps<T> {
|
|
164
|
-
table: Table<T>;
|
|
165
|
-
sticky?: boolean;
|
|
166
|
-
}
|
|
167
|
-
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
160
|
+
declare function DataTable<T>(props: DataTableProps<T>): JSX.Element;
|
|
168
161
|
|
|
169
162
|
/**
|
|
170
163
|
* Capitalize the table header.
|
|
@@ -175,14 +168,9 @@ declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Ele
|
|
|
175
168
|
*/
|
|
176
169
|
declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
|
|
177
170
|
/** Prepend a column definition array with a select column. */
|
|
178
|
-
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?:
|
|
179
|
-
|
|
180
|
-
declare type DataTableCompoundProps = typeof DataTable$1 & {
|
|
181
|
-
Provider: typeof DataTableProvider;
|
|
182
|
-
};
|
|
183
|
-
declare const DataTable: DataTableCompoundProps;
|
|
171
|
+
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T, unknown>[];
|
|
184
172
|
|
|
185
|
-
declare function SelectColumnDef<T>(props
|
|
173
|
+
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
186
174
|
|
|
187
175
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
188
176
|
|
|
@@ -191,4 +179,4 @@ declare type TypographyProps = {
|
|
|
191
179
|
} & TypographyProps$1;
|
|
192
180
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
193
181
|
|
|
194
|
-
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 };
|