@equinor/apollo-components 3.1.8 → 3.2.0-beta.1

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 CHANGED
@@ -1,12 +1,14 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
2
  import * as react from 'react';
3
3
  import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
4
+ import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
4
5
  import * as styled_components from 'styled-components';
5
6
  import * as _equinor_eds_core_react from '@equinor/eds-core-react';
6
7
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
7
- import { Cell, Header, CellContext, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
8
8
  import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
9
9
  import { SetRequired } from 'type-fest';
10
+ import { TableOptions } from '@tanstack/table-core/build/lib/types';
11
+ import { FieldError } from 'react-hook-form';
10
12
 
11
13
  interface AppShellProps {
12
14
  children?: ReactNode;
@@ -18,6 +20,8 @@ declare const AppShell: ({ children, icon, title, sidebar }: AppShellProps) => J
18
20
 
19
21
  declare function AppSidebar(): JSX.Element;
20
22
 
23
+ declare function CheckboxCell<T>(context: CellContext<T, boolean>): JSX.Element;
24
+
21
25
  declare const ChipsCell: (props: {
22
26
  values?: string[];
23
27
  }) => JSX.Element;
@@ -36,8 +40,10 @@ declare function DynamicCell<T>({ cell, highlight, getStickyCellColor }: TableCe
36
40
 
37
41
  interface HeaderCellProps<TData, TValue> {
38
42
  header: Header<TData, TValue>;
43
+ /** Needed for column resizing */
44
+ table: Table<TData>;
39
45
  }
40
- declare const HeaderCell: <TData, TValue>({ header }: HeaderCellProps<TData, TValue>) => JSX.Element;
46
+ declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
41
47
 
42
48
  declare type HierarchyCellOptions = {
43
49
  getRowDepth?: () => number;
@@ -131,6 +137,7 @@ interface DataTableProps<T> {
131
137
  virtual?: boolean;
132
138
  getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
133
139
  getSubRows?: (originalRow: T) => T[] | undefined;
140
+ columnResizing?: boolean | TableOptions<T>['columnResizeMode'];
134
141
  rowSelection?: Partial<ControlledState<RowSelectionState>> & {
135
142
  mode?: RowSelectionMode;
136
143
  selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
@@ -155,7 +162,12 @@ interface DataTableProps<T> {
155
162
  enableGlobalFilterInput?: boolean;
156
163
  globalFilterPlaceholder?: string;
157
164
  filterFromLeafRows?: boolean;
165
+ /**
166
+ * @deprecated Use `customActionsLeft` instead
167
+ */
158
168
  customActions?: <T>(table: Table<T>) => ReactNode;
169
+ customActionsLeft?: <T>(table: Table<T>) => ReactNode;
170
+ customActionsRight?: <T>(table: Table<T>) => ReactNode;
159
171
  /**
160
172
  * Default 1rem
161
173
  * Accepts any CSS padding value
@@ -237,8 +249,13 @@ declare function EditableCheckboxCell<T extends FormMeta>(context: CellContext<T
237
249
 
238
250
  interface EditableDateCellProps<T extends FormMeta> extends CellContext<T, unknown> {
239
251
  dateStringFormatter?: (date: string) => string;
252
+ /**
253
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
254
+ * react-hook-form's validation.
255
+ */
256
+ error?: FieldError;
240
257
  }
241
- declare function EditableDateCell<T extends FormMeta>(props: EditableDateCellProps<T>): JSX.Element;
258
+ declare function EditableDateCell<T extends FormMeta>({ dateStringFormatter, error: errorFromProps, ...context }: EditableDateCellProps<T>): JSX.Element;
242
259
 
243
260
  interface Option {
244
261
  label: string;
@@ -249,16 +266,40 @@ interface EditableDropdownSingleCellProps<T extends FormMeta> extends CellContex
249
266
  * `Option.value` is used internally to get and update selection state. `Option.label` is *only* for visual purposes.
250
267
  */
251
268
  options: Option[];
269
+ /**
270
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
271
+ * react-hook-form's validation.
272
+ */
273
+ error?: FieldError;
252
274
  }
253
- declare function EditableDropdownSingleCell<T extends FormMeta>(props: EditableDropdownSingleCellProps<T>): JSX.Element;
275
+ declare function EditableDropdownSingleCell<T extends FormMeta>({ options, error: errorFromProps, ...context }: EditableDropdownSingleCellProps<T>): JSX.Element;
254
276
 
255
- declare function EditableNumberCell<T extends FormMeta>(context: CellContext<T, number>): JSX.Element;
277
+ interface EditableNumberCellProps<T extends FormMeta> extends CellContext<T, number> {
278
+ /**
279
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
280
+ * react-hook-form's validation.
281
+ */
282
+ error?: FieldError;
283
+ }
284
+ declare function EditableNumberCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableNumberCellProps<T>): JSX.Element;
256
285
 
257
286
  interface EdtiableTextAreaProps<T extends FormMeta> extends CellContext<T, string> {
258
287
  title: string;
288
+ /**
289
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
290
+ * react-hook-form's validation.
291
+ */
292
+ error?: FieldError;
259
293
  }
260
- declare function EditableTextAreaCell<T extends FormMeta>(props: EdtiableTextAreaProps<T>): JSX.Element;
294
+ declare function EditableTextAreaCell<T extends FormMeta>({ title, error: errorFromProps, ...context }: EdtiableTextAreaProps<T>): JSX.Element;
261
295
 
262
- declare function EditableTextFieldCell<T extends FormMeta>(context: CellContext<T, unknown>): JSX.Element;
296
+ interface EditableTextFieldCellProps<T extends FormMeta> extends CellContext<T, unknown> {
297
+ /**
298
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
299
+ * react-hook-form's validation.
300
+ */
301
+ error?: FieldError;
302
+ }
303
+ declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableTextFieldCellProps<T>): JSX.Element;
263
304
 
264
- export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WithoutFormMeta, addFormMeta, capitalizeHeader, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
305
+ export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WithoutFormMeta, addFormMeta, capitalizeHeader, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };