@equinor/apollo-components 3.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
  }
@@ -168,11 +265,36 @@ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTa
168
265
 
169
266
  declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
170
267
 
268
+ declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
171
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>;
172
271
 
173
272
  declare type TypographyProps = {
174
273
  truncate?: boolean;
175
274
  } & TypographyProps$1;
176
275
  declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
177
276
 
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 };
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 };