@equinor/apollo-components 3.0.0 → 3.1.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,11 +1,40 @@
1
+ export * from 'apollo-common';
1
2
  import { IconData } from '@equinor/eds-icons';
2
3
  import * as react from 'react';
3
4
  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 * as styled_components from 'styled-components';
6
+ import * as _equinor_eds_core_react from '@equinor/eds-core-react';
7
+ import { CellProps } from '@equinor/eds-core-react';
8
+ import { Cell, Header, CellContext, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
5
9
  import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
6
10
  import { SetRequired } from 'type-fest';
7
- import * as styled_components from 'styled-components';
8
- import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
11
+
12
+ declare type FormMeta = {
13
+ _isNew?: boolean;
14
+ _editMode?: boolean;
15
+ _hasRemoteChange?: boolean;
16
+ };
17
+ declare type WithoutFormMeta<T extends FormMeta> = Omit<T, keyof FormMeta>;
18
+
19
+ /**
20
+ * Subscribes to the `_editMode` field in a `react-hook-form` context.
21
+ *
22
+ * @returns edit mode value
23
+ */
24
+ declare function useEditMode(): boolean;
25
+ /**
26
+ * Subscribes to the `_hasRemoteChange` field in a `react-hook-form` context.
27
+ *
28
+ * @returns edit mode value
29
+ */
30
+ declare function useHasRemoteChange(): boolean;
31
+ /**
32
+ * @returns function getting is new meta
33
+ */
34
+ declare function useGetIsNew(): () => boolean;
35
+ declare function useSetFormMeta<T extends FormMeta>(): (newValues: Partial<T>) => void;
36
+ declare function removeFormMeta<T extends FormMeta>(withFormMeta: T): Omit<T, keyof FormMeta>;
37
+ declare function addFormMeta<T>(withoutFormMeta: T): T & FormMeta;
9
38
 
10
39
  interface AppShellProps {
11
40
  children?: ReactNode;
@@ -26,8 +55,18 @@ declare type TableCellProps<T> = {
26
55
  highlight?: boolean;
27
56
  getStickyCellColor?: (cell: Cell<T, unknown>) => string;
28
57
  };
58
+ declare type StyledStickyCellProps = {
59
+ highlight?: boolean;
60
+ backgroundColor?: string;
61
+ };
62
+ 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
63
  declare function DynamicCell<T>({ cell, highlight, getStickyCellColor }: TableCellProps<T>): JSX.Element;
30
64
 
65
+ interface HeaderCellProps<TData, TValue> {
66
+ header: Header<TData, TValue>;
67
+ }
68
+ declare const HeaderCell: <TData, TValue>({ header }: HeaderCellProps<TData, TValue>) => JSX.Element;
69
+
31
70
  declare type HierarchyCellOptions = {
32
71
  getRowDepth?: () => number;
33
72
  getDisplayName?: () => string;
@@ -168,11 +207,16 @@ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTa
168
207
 
169
208
  declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
170
209
 
210
+ declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
171
211
  declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
212
+ declare const StickyHeaderCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & CellProps) & CellProps, never>;
172
213
 
173
- declare type TypographyProps = {
174
- truncate?: boolean;
175
- } & TypographyProps$1;
176
- declare const TypographyCustom: (props: TypographyProps) => JSX.Element;
214
+ /**
215
+ * Generate a HSL color based on a given string.
216
+ *
217
+ * @param str - Any given string
218
+ * @returns A valid hsl color
219
+ */
220
+ declare function stringToHslColor(str: string, s?: number, l?: number): string;
177
221
 
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 };
222
+ export { AppShell, AppSidebar, CellConfig, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, FormMeta, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, WithoutFormMeta, addFormMeta, capitalizeHeader, leftCellShadow, prependSelectColumn, removeFormMeta, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };