@equinor/apollo-components 2.0.0 → 3.1.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 CHANGED
@@ -1,11 +1,14 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
2
  import * as react from 'react';
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
- import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
6
- import { SetRequired } from 'type-fest';
3
+ import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
7
4
  import * as styled_components from 'styled-components';
5
+ import * as _equinor_eds_core_react from '@equinor/eds-core-react';
8
6
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
7
+ import { Cell, CellContext, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
8
+ import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
9
+ import { SetRequired } from 'type-fest';
10
+ import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
11
+ import { FieldError } from 'react-hook-form';
9
12
 
10
13
  interface AppShellProps {
11
14
  children?: ReactNode;
@@ -26,14 +29,108 @@ declare type TableCellProps<T> = {
26
29
  highlight?: boolean;
27
30
  getStickyCellColor?: (cell: Cell<T, unknown>) => string;
28
31
  };
32
+ declare type StyledStickyCellProps = {
33
+ highlight?: boolean;
34
+ backgroundColor?: string;
35
+ };
36
+ declare const StyledStickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<_equinor_eds_core_react.CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & _equinor_eds_core_react.CellProps) & StyledStickyCellProps, never>;
29
37
  declare function DynamicCell<T>({ cell, highlight, getStickyCellColor }: TableCellProps<T>): JSX.Element;
30
38
 
39
+ declare type FormMeta = {
40
+ _isNew?: boolean;
41
+ _editMode?: boolean;
42
+ _hasRemoteChange?: boolean;
43
+ };
44
+ declare type WithoutFormMeta<T extends FormMeta> = Omit<T, keyof FormMeta>;
45
+
46
+ /**
47
+ * Subscribes to the `_editMode` field in a `react-hook-form` context.
48
+ *
49
+ * @returns edit mode value
50
+ */
51
+ declare function useEditMode(): boolean;
52
+ /**
53
+ * Subscribes to the `_hasRemoteChange` field in a `react-hook-form` context.
54
+ *
55
+ * @returns edit mode value
56
+ */
57
+ declare function useHasRemoteChange(): boolean;
58
+ /**
59
+ * @returns function getting is new meta
60
+ */
61
+ declare function useGetIsNew(): () => boolean;
62
+ declare function useSetFormMeta<T extends FormMeta>(): (newValues: Partial<T>) => void;
63
+ declare function removeFormMeta<T extends FormMeta>(withFormMeta: T): Omit<T, keyof FormMeta>;
64
+ declare function addFormMeta<T>(withoutFormMeta: T): T & FormMeta;
65
+
66
+ declare function EditableCheckboxCell<T extends FormMeta>(context: CellContext<T, boolean>): JSX.Element;
67
+
68
+ interface EditableDateCellProps<T extends FormMeta> extends CellContext<T, unknown> {
69
+ dateStringFormatter?: (date: string) => string;
70
+ }
71
+ declare function EditableDateCell<T extends FormMeta>(props: EditableDateCellProps<T>): JSX.Element;
72
+
73
+ interface Option {
74
+ label: string;
75
+ value: string;
76
+ }
77
+ interface EditableDropdownCellProps<T extends FormMeta> extends CellContext<T, unknown> {
78
+ /**
79
+ * `Option.value` is used internally to get and update selection state. `Option.label` is *only* for visual purposes.
80
+ */
81
+ options: Option[];
82
+ }
83
+ declare function EditableDropdownCell<T extends FormMeta>(props: EditableDropdownCellProps<T>): JSX.Element;
84
+ declare const AutocompleteCustom: styled_components.StyledComponent<(<T>(props: {
85
+ options: T[];
86
+ label: string;
87
+ initialSelectedOptions?: T[] | undefined;
88
+ meta?: string | undefined;
89
+ disabled?: boolean | undefined;
90
+ readOnly?: boolean | undefined;
91
+ hideClearButton?: boolean | undefined;
92
+ selectedOptions?: T[] | undefined;
93
+ onOptionsChange?: ((changes: _equinor_eds_core_react.AutocompleteChanges<T>) => void) | undefined;
94
+ multiple?: boolean | undefined;
95
+ optionLabel?: ((option: T) => string) | undefined;
96
+ disablePortal?: boolean | undefined;
97
+ optionDisabled?: ((option: T) => boolean) | undefined;
98
+ optionsFilter?: ((option: T, inputValue: string) => boolean) | undefined;
99
+ autoWidth?: boolean | undefined;
100
+ placeholder?: string | undefined;
101
+ clearSearchOnChange?: boolean | undefined;
102
+ } & react.HTMLAttributes<HTMLDivElement> & {
103
+ ref?: react.ForwardedRef<HTMLDivElement> | undefined;
104
+ displayName?: string | undefined;
105
+ }) => JSX.Element), any, {}, never>;
106
+
107
+ declare function EditableNumberCell<T extends FormMeta>(context: CellContext<T, number>): JSX.Element;
108
+
109
+ interface EdtiableTextAreaProps<T extends FormMeta> extends CellContext<T, string> {
110
+ dialogTitle: string;
111
+ }
112
+ declare function EditableTextAreaCell<T extends FormMeta>(props: EdtiableTextAreaProps<T>): JSX.Element;
113
+
114
+ declare function EditableTextFieldCell<T extends FormMeta>(context: CellContext<T, unknown>): JSX.Element;
115
+
116
+ interface HeaderCellProps<TData, TValue> {
117
+ header: Header<TData, TValue>;
118
+ }
119
+ declare const HeaderCell: <TData, TValue>({ header }: HeaderCellProps<TData, TValue>) => JSX.Element;
120
+
31
121
  declare type HierarchyCellOptions = {
32
122
  getRowDepth?: () => number;
33
123
  getDisplayName?: () => string;
34
124
  };
35
125
  declare function HierarchyCell<T>(cell: CellContext<T, any>, options?: HierarchyCellOptions): JSX.Element;
36
126
 
127
+ interface PopoverCellProps {
128
+ id: string;
129
+ value: string;
130
+ title?: string | JSX.Element | ReactNode;
131
+ }
132
+ declare const PopoverCell: (props: PopoverCellProps) => JSX.Element;
133
+
37
134
  interface ColumnSelectProps<T> {
38
135
  table: Table<T>;
39
136
  }
@@ -45,18 +142,6 @@ interface TableHeaderProps<T> {
45
142
  }
46
143
  declare function TableHeader<T>({ table, sticky }: TableHeaderProps<T>): JSX.Element;
47
144
 
48
- interface HeaderConfig {
49
- sticky?: boolean;
50
- }
51
- interface FilterConfig {
52
- enableTableCaption?: boolean;
53
- totalRowCount?: number;
54
- columnSelect?: boolean;
55
- globalFilter?: boolean;
56
- globalFilterPlaceholder?: string;
57
- filterFromLeafRows?: boolean;
58
- customActions?: <T>(table: Table<T>) => ReactNode;
59
- }
60
145
  interface TableRowWrapper<T> {
61
146
  (props: TableRowWrapperProps<T>): ReactElement;
62
147
  }
@@ -109,10 +194,10 @@ interface DataTableProps<T> {
109
194
  columns: ColumnDef<T, any>[];
110
195
  cellConfig?: CellConfig<T>;
111
196
  rowConfig?: RowConfig<T>;
112
- headerConfig?: HeaderConfig;
113
197
  isLoading?: boolean;
114
198
  height?: string;
115
199
  width?: string;
200
+ stickyHeader?: boolean;
116
201
  /**
117
202
  * Defaults to `'auto'`.
118
203
  *
@@ -139,7 +224,10 @@ interface DataTableProps<T> {
139
224
  };
140
225
  globalFilter?: ControlledState<string>;
141
226
  columnVisibility?: ControlledState<VisibilityState>;
142
- actionsRow?: {
227
+ /**
228
+ * Everything that has todo with the area (banner) over the table
229
+ */
230
+ bannerConfig?: {
143
231
  enableTableCaption?: boolean;
144
232
  totalRowCount?: number;
145
233
  enableColumnSelect?: boolean;
@@ -147,6 +235,11 @@ interface DataTableProps<T> {
147
235
  globalFilterPlaceholder?: string;
148
236
  filterFromLeafRows?: boolean;
149
237
  customActions?: <T>(table: Table<T>) => ReactNode;
238
+ /**
239
+ * Default 1rem
240
+ * Accepts any CSS padding value
241
+ */
242
+ padding?: string;
150
243
  };
151
244
  tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
152
245
  infiniteScroll?: InfiniteScrollConfig;
@@ -172,11 +265,36 @@ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTa
172
265
 
173
266
  declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
174
267
 
268
+ declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
175
269
  declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
270
+ declare const StickyHeaderCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & CellProps) & CellProps, never>;
176
271
 
177
272
  declare type TypographyProps = {
178
273
  truncate?: boolean;
179
274
  } & TypographyProps$1;
180
275
  declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
181
276
 
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 };
277
+ /**
278
+ * Generate a HSL color based on a given string.
279
+ *
280
+ * @param str - Any given string
281
+ * @returns A valid hsl color
282
+ */
283
+ declare function stringToHslColor(str: string, s?: number, l?: number): string;
284
+ /** Wrap an event handler and stop event propagation */
285
+ declare function stopPropagation<T extends HTMLElement>(handler: (e: SyntheticEvent<T>) => void): (e: SyntheticEvent<T>) => void;
286
+ interface GetHelperTextPropsProps {
287
+ error?: FieldError;
288
+ warning?: {
289
+ message: string;
290
+ };
291
+ helperText?: string;
292
+ }
293
+ interface GetHelperTextProps {
294
+ variant?: Variants;
295
+ helperText?: string;
296
+ helperIcon: JSX.Element | null;
297
+ }
298
+ declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
299
+
300
+ export { AppShell, AppSidebar, AutocompleteCustom, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownCell, EditableDropdownCellProps, 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, getHelperTextProps, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };