@equinor/apollo-components 1.12.3 → 3.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 -86
- package/dist/index.js +342 -337
- package/dist/index.mjs +344 -335
- 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,18 +34,17 @@ declare type HierarchyCellOptions = {
|
|
|
35
34
|
};
|
|
36
35
|
declare function HierarchyCell<T>(cell: CellContext<T, any>, options?: HierarchyCellOptions): JSX.Element;
|
|
37
36
|
|
|
38
|
-
interface
|
|
39
|
-
|
|
40
|
-
stickyHeader?: boolean;
|
|
41
|
-
tableCaption?: string;
|
|
37
|
+
interface ColumnSelectProps<T> {
|
|
38
|
+
table: Table<T>;
|
|
42
39
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
filterActions?: <T>(table: Table<T>) => ReactNode;
|
|
40
|
+
declare function ColumnSelect<T>({ table }: ColumnSelectProps<T>): JSX.Element;
|
|
41
|
+
|
|
42
|
+
interface TableHeaderProps<T> {
|
|
43
|
+
table: Table<T>;
|
|
44
|
+
sticky?: boolean;
|
|
49
45
|
}
|
|
46
|
+
declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
|
|
47
|
+
|
|
50
48
|
interface TableRowWrapper<T> {
|
|
51
49
|
(props: TableRowWrapperProps<T>): ReactElement;
|
|
52
50
|
}
|
|
@@ -84,8 +82,25 @@ interface CellConfig<T> {
|
|
|
84
82
|
}
|
|
85
83
|
declare type RowSelectionMode = 'single' | 'multiple';
|
|
86
84
|
declare type TableLayout = 'auto' | 'fixed';
|
|
87
|
-
|
|
85
|
+
interface HTMLPropsRef<T extends HTMLElement> extends HTMLProps<T> {
|
|
86
|
+
ref?: MutableRefObject<T | null> | null;
|
|
87
|
+
}
|
|
88
|
+
interface InfiniteScrollConfig {
|
|
89
|
+
/** Called on scroll below offset. */
|
|
90
|
+
onBottomScroll: () => void;
|
|
91
|
+
/** Pixels above bottom. Defines when the onBottomScroll should be called. Defaults to `300`. */
|
|
92
|
+
offset?: number;
|
|
93
|
+
}
|
|
94
|
+
interface DataTableProps<T> {
|
|
95
|
+
tableCaption: string;
|
|
96
|
+
data: T[];
|
|
97
|
+
columns: ColumnDef<T, any>[];
|
|
98
|
+
cellConfig?: CellConfig<T>;
|
|
99
|
+
rowConfig?: RowConfig<T>;
|
|
100
|
+
isLoading?: boolean;
|
|
88
101
|
height?: string;
|
|
102
|
+
width?: string;
|
|
103
|
+
stickyHeader?: boolean;
|
|
89
104
|
/**
|
|
90
105
|
* Defaults to `'auto'`.
|
|
91
106
|
*
|
|
@@ -95,76 +110,50 @@ declare type DataTableConfig<T> = {
|
|
|
95
110
|
* Default size is 150px.
|
|
96
111
|
*/
|
|
97
112
|
tableLayout?: TableLayout;
|
|
98
|
-
/** @deprecated use `cellConfig.enableSorting` instead. This is to align with \@tanstack/react-table types. */
|
|
99
|
-
sortable?: boolean;
|
|
100
113
|
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
114
|
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
|
-
|
|
115
|
+
getSubRows?: (originalRow: T) => T[] | undefined;
|
|
116
|
+
rowSelection?: Partial<ControlledState<RowSelectionState>> & {
|
|
117
|
+
mode?: RowSelectionMode;
|
|
118
|
+
selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
|
|
119
|
+
includeExpansionButton?: boolean;
|
|
120
|
+
};
|
|
121
|
+
expansion?: Partial<ControlledState<ExpandedState>> & {
|
|
122
|
+
expandAllByDefault?: boolean;
|
|
123
|
+
};
|
|
124
|
+
sorting?: Partial<ControlledState<SortingState>> & {
|
|
125
|
+
enableSorting?: boolean;
|
|
126
|
+
manualSorting?: boolean;
|
|
127
|
+
};
|
|
128
|
+
globalFilter?: ControlledState<string>;
|
|
129
|
+
columnVisibility?: ControlledState<VisibilityState>;
|
|
130
|
+
/**
|
|
131
|
+
* Everything that has todo with the area (banner) over the table
|
|
132
|
+
*/
|
|
133
|
+
bannerConfig?: {
|
|
134
|
+
enableTableCaption?: boolean;
|
|
135
|
+
totalRowCount?: number;
|
|
136
|
+
enableColumnSelect?: boolean;
|
|
137
|
+
enableGlobalFilterInput?: boolean;
|
|
138
|
+
globalFilterPlaceholder?: string;
|
|
139
|
+
filterFromLeafRows?: boolean;
|
|
140
|
+
customActions?: <T>(table: Table<T>) => ReactNode;
|
|
141
|
+
/**
|
|
142
|
+
* Default 1rem
|
|
143
|
+
* Accepts any CSS padding value
|
|
144
|
+
*/
|
|
145
|
+
padding?: string;
|
|
146
|
+
};
|
|
129
147
|
tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
|
|
130
148
|
infiniteScroll?: InfiniteScrollConfig;
|
|
131
149
|
}
|
|
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;
|
|
150
|
+
declare type ControlledState<T> = {
|
|
151
|
+
state: T;
|
|
152
|
+
/** Callback when state chagnes. Using this requires the state to be fully controlled. */
|
|
153
|
+
onChange?: Dispatch<SetStateAction<T>>;
|
|
156
154
|
};
|
|
157
155
|
|
|
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;
|
|
156
|
+
declare function DataTable<T>(props: DataTableProps<T>): JSX.Element;
|
|
168
157
|
|
|
169
158
|
/**
|
|
170
159
|
* Capitalize the table header.
|
|
@@ -175,14 +164,9 @@ declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Ele
|
|
|
175
164
|
*/
|
|
176
165
|
declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
|
|
177
166
|
/** 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;
|
|
167
|
+
declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T, unknown>[];
|
|
184
168
|
|
|
185
|
-
declare function SelectColumnDef<T>(props
|
|
169
|
+
declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
|
|
186
170
|
|
|
187
171
|
declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
|
|
188
172
|
|
|
@@ -191,4 +175,4 @@ declare type TypographyProps = {
|
|
|
191
175
|
} & TypographyProps$1;
|
|
192
176
|
declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
|
|
193
177
|
|
|
194
|
-
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable,
|
|
178
|
+
export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, HTMLPropsRef, HierarchyCell, InfiniteScrollConfig, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, capitalizeHeader, prependSelectColumn };
|