@equinor/apollo-components 3.5.1-beta.2 → 3.5.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,13 +1,13 @@
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, ColumnResizeMode, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } from '@tanstack/react-table';
5
- export { Cell, CellContext, ColumnDef, ColumnPinningState, ColumnResizeMode, ExpandedState, HeaderContext, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState, createColumnHelper } from '@tanstack/react-table';
4
+ import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } from '@tanstack/react-table';
6
5
  import * as styled_components from 'styled-components';
7
6
  import * as _equinor_eds_core_react from '@equinor/eds-core-react';
8
7
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
9
8
  import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
10
9
  import { SetRequired } from 'type-fest';
10
+ import { TableOptions } from '@tanstack/table-core/build/lib/types';
11
11
  import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
12
12
  import { FieldError } from 'react-hook-form';
13
13
 
@@ -27,12 +27,12 @@ declare const ChipsCell: (props: {
27
27
  values?: string[];
28
28
  }) => JSX.Element;
29
29
 
30
- type TableCellProps<T> = {
30
+ declare type TableCellProps<T> = {
31
31
  cell: Cell<T, unknown>;
32
32
  highlight?: boolean;
33
33
  getStickyCellColor?: (cell: Cell<T, unknown>) => string;
34
34
  };
35
- type StyledStickyCellProps = {
35
+ declare type StyledStickyCellProps = {
36
36
  highlight?: boolean;
37
37
  backgroundColor?: string;
38
38
  };
@@ -46,7 +46,7 @@ interface HeaderCellProps<TData, TValue> {
46
46
  }
47
47
  declare const HeaderCell: <TData, TValue>({ header, table }: HeaderCellProps<TData, TValue>) => JSX.Element;
48
48
 
49
- type HierarchyCellOptions = {
49
+ declare type HierarchyCellOptions = {
50
50
  getRowDepth?: () => number;
51
51
  getDisplayName?: () => string;
52
52
  };
@@ -87,8 +87,8 @@ interface RowConfig<T> {
87
87
  onMouseEnter?: (row: Row<T>) => void;
88
88
  onMouseLeave?: (row: Row<T>) => void;
89
89
  }
90
- type TruncateMode = 'wrap' | 'hover';
91
- type SortConfig = {
90
+ declare type TruncateMode = 'wrap' | 'hover';
91
+ declare type SortConfig = {
92
92
  enableSorting?: boolean;
93
93
  manualSorting?: boolean;
94
94
  sorting?: SortingState;
@@ -105,8 +105,8 @@ interface CellConfig<T> {
105
105
  */
106
106
  truncateMode?: TruncateMode | ((cell: Cell<T, unknown>) => TruncateMode);
107
107
  }
108
- type RowSelectionMode = 'single' | 'multiple';
109
- type TableLayout = 'auto' | 'fixed';
108
+ declare type RowSelectionMode = 'single' | 'multiple';
109
+ declare type TableLayout = 'auto' | 'fixed';
110
110
  interface HTMLPropsRef<T extends HTMLElement> extends HTMLProps<T> {
111
111
  ref?: MutableRefObject<T | null> | null;
112
112
  }
@@ -138,7 +138,7 @@ interface DataTableProps<T> {
138
138
  virtual?: boolean;
139
139
  getRowId?: (originalRow: T, index: number, parent: Row<T> | undefined) => string;
140
140
  getSubRows?: (originalRow: T) => T[] | undefined;
141
- columnResizing?: boolean | ColumnResizeMode;
141
+ columnResizing?: boolean | TableOptions<T>['columnResizeMode'];
142
142
  rowSelection?: Partial<ControlledState<RowSelectionState>> & {
143
143
  mode?: RowSelectionMode;
144
144
  selectColumn?: 'default' | ((options?: Record<string, any>) => ColumnDef<T, any>);
@@ -181,7 +181,7 @@ interface DataTableProps<T> {
181
181
  tableContainerProps?: HTMLPropsRef<HTMLDivElement>;
182
182
  infiniteScroll?: InfiniteScrollConfig;
183
183
  }
184
- type ControlledState<T> = {
184
+ declare type ControlledState<T> = {
185
185
  state?: T;
186
186
  /** Callback when state chagnes. Using this requires the state to be fully controlled. */
187
187
  onChange?: Dispatch<SetStateAction<T>>;
@@ -197,26 +197,8 @@ declare function DataTable<T>(props: DataTableProps<T>): JSX.Element;
197
197
  * @returns A capitalized header
198
198
  */
199
199
  declare function capitalizeHeader<T>(context: HeaderContext<T, any>): string;
200
- /**
201
- * Used to conditionally return any given value.
202
- *
203
- * @param enabled - A bool whether the value should be enabled or not
204
- * @param value - Any given value.
205
- * @returns Value or undefined
206
- */
207
- declare function enableOrUndefined<T>(enabled: boolean | undefined, value: T): T | undefined;
208
- /**
209
- * Get column header if set
210
- * @param column
211
- * @returns Column label
212
- */
213
- declare function getColumnHeader<T>(column: Column<T, any>): string;
214
- /** Prepend a column definition array with a select column if enabled in the config. */
215
- declare function prependSelectColumnIfEnabled<T>(columns: ColumnDef<T, any>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T, any>[];
216
200
  /** Prepend a column definition array with a select column. */
217
- declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T>[];
218
- /** Useful in cases where you either have a value, function or undefined. */
219
- declare function getFunctionValueOrDefault<T extends boolean | string | number, P>(valueOrFn: ((props: P) => T) | T | undefined, fnProps: P, defaultValue: T): T;
201
+ declare function prependSelectColumn<T>(columns: ColumnDef<T>[], config?: DataTableProps<T>['rowSelection']): ColumnDef<T, unknown>[];
220
202
 
221
203
  declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
222
204
 
@@ -224,7 +206,7 @@ declare const leftCellShadow: styled_components.FlattenSimpleInterpolation;
224
206
  declare const StickyCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, {} & CellProps, never>;
225
207
  declare const StickyHeaderCell: styled_components.StyledComponent<react.ForwardRefExoticComponent<CellProps & react.RefAttributes<HTMLTableCellElement>>, any, ({} & CellProps) & CellProps, never>;
226
208
 
227
- type TypographyProps = {
209
+ declare type TypographyProps = {
228
210
  truncate?: boolean;
229
211
  enableShowAllOnHover?: boolean;
230
212
  } & TypographyProps$1;
@@ -244,12 +226,12 @@ declare function getTotalRight<TData>(table: Table<TData>, column: Column<TData>
244
226
  declare function getIsFirstRightPinnedColumn<TData>(column: Column<TData>): boolean;
245
227
  declare function getIsLastLeftPinnedColumn<TData>(table: Table<TData>, column: Column<TData>): boolean;
246
228
 
247
- type FormMeta = {
229
+ declare type FormMeta = {
248
230
  _isNew?: boolean;
249
231
  _editMode?: boolean;
250
232
  _hasRemoteChange?: boolean;
251
233
  };
252
- type WithoutFormMeta<T extends FormMeta> = Omit<T, keyof FormMeta>;
234
+ declare type WithoutFormMeta<T extends FormMeta> = Omit<T, keyof FormMeta>;
253
235
 
254
236
  /**
255
237
  * Subscribes to the `_editMode` field in a `react-hook-form` context.
@@ -328,4 +310,4 @@ declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromPro
328
310
  declare const WARNING_PREFIX = "WARNING";
329
311
  declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
330
312
 
331
- export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCellBaseProps, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, GetHelperTextProps, GetHelperTextPropsProps, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WARNING_PREFIX, WithoutFormMeta, addFormMeta, capitalizeHeader, enableOrUndefined, getColumnHeader, getFunctionValueOrDefault, getHelperTextProps, getIsFirstRightPinnedColumn, getIsLastLeftPinnedColumn, getTotalRight, leftCellShadow, prependSelectColumn, prependSelectColumnIfEnabled, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
313
+ export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCellBaseProps, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, EditableNumberCell, EditableTextAreaCell, EditableTextFieldCell, FormMeta, GetHelperTextProps, GetHelperTextPropsProps, HTMLPropsRef, HeaderCell, HierarchyCell, InfiniteScrollConfig, Option, PopoverCell, RowConfig, RowSelectionMode, SelectColumnDef, SortConfig, StickyCell, StickyHeaderCell, StyledStickyCell, TableHeader, TableLayout, TableRowWrapper, TableRowWrapperProps, TruncateMode, TypographyCustom, TypographyProps, WARNING_PREFIX, WithoutFormMeta, addFormMeta, capitalizeHeader, getHelperTextProps, getIsFirstRightPinnedColumn, getIsLastLeftPinnedColumn, getTotalRight, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
package/dist/index.js CHANGED
@@ -2397,17 +2397,12 @@ __export(src_exports, {
2397
2397
  WARNING_PREFIX: () => WARNING_PREFIX,
2398
2398
  addFormMeta: () => addFormMeta,
2399
2399
  capitalizeHeader: () => capitalizeHeader,
2400
- createColumnHelper: () => import_react_table3.createColumnHelper,
2401
- enableOrUndefined: () => enableOrUndefined,
2402
- getColumnHeader: () => getColumnHeader,
2403
- getFunctionValueOrDefault: () => getFunctionValueOrDefault,
2404
2400
  getHelperTextProps: () => getHelperTextProps,
2405
2401
  getIsFirstRightPinnedColumn: () => getIsFirstRightPinnedColumn,
2406
2402
  getIsLastLeftPinnedColumn: () => getIsLastLeftPinnedColumn,
2407
2403
  getTotalRight: () => getTotalRight,
2408
2404
  leftCellShadow: () => leftCellShadow,
2409
2405
  prependSelectColumn: () => prependSelectColumn,
2410
- prependSelectColumnIfEnabled: () => prependSelectColumnIfEnabled,
2411
2406
  removeFormMeta: () => removeFormMeta,
2412
2407
  stopPropagation: () => stopPropagation,
2413
2408
  stringToHslColor: () => stringToHslColor,
@@ -2959,7 +2954,6 @@ var import_react3 = require("react");
2959
2954
  var import_styled_components10 = __toESM(require("styled-components"));
2960
2955
 
2961
2956
  // src/DataTable/utils.tsx
2962
- var import_react_table3 = require("@tanstack/react-table");
2963
2957
  function capitalizeHeader(context) {
2964
2958
  const header = context.header.id;
2965
2959
  return header.charAt(0).toUpperCase() + header.slice(1);
@@ -2973,13 +2967,6 @@ function getColumnHeader(column) {
2973
2967
  return column.id;
2974
2968
  return typeof columnHeader === "string" ? columnHeader : column.id;
2975
2969
  }
2976
- function prependSelectColumnIfEnabled(columns, config) {
2977
- if (!config)
2978
- return columns;
2979
- if (!Boolean(config == null ? void 0 : config.mode))
2980
- return columns;
2981
- return prependSelectColumn(columns, config);
2982
- }
2983
2970
  function prependSelectColumn(columns, config) {
2984
2971
  if (!(config == null ? void 0 : config.selectColumn))
2985
2972
  return columns;
@@ -3085,7 +3072,7 @@ function TableHeader({ table, sticky }) {
3085
3072
  }
3086
3073
 
3087
3074
  // src/DataTable/DataTable.tsx
3088
- var import_react_table4 = require("@tanstack/react-table");
3075
+ var import_react_table3 = require("@tanstack/react-table");
3089
3076
  var import_react7 = require("react");
3090
3077
  var import_styled_components16 = __toESM(require("styled-components"));
3091
3078
 
@@ -3475,7 +3462,7 @@ function DataTable(props) {
3475
3462
  typeof props.columnPinning === "object" && props.columnPinning.state ? props.columnPinning.state : internalColumnPinning,
3476
3463
  typeof props.columnPinning === "object" && props.columnPinning.onChange ? props.columnPinning.onChange : setInternalColumnPinning
3477
3464
  ];
3478
- const table = (0, import_react_table4.useReactTable)({
3465
+ const table = (0, import_react_table3.useReactTable)({
3479
3466
  columns: prependSelectColumn(columns, props.rowSelection),
3480
3467
  data,
3481
3468
  globalFilterFn: enableGlobalFilter(fuzzyFilter),
@@ -3502,10 +3489,10 @@ function DataTable(props) {
3502
3489
  enableSubRowSelection: ((_z = props.rowSelection) == null ? void 0 : _z.mode) !== "single",
3503
3490
  filterFromLeafRows: bannerConfig == null ? void 0 : bannerConfig.filterFromLeafRows,
3504
3491
  enablePinning: props.columnPinning !== void 0 && (typeof props.columnPinning === "boolean" ? props.columnPinning : props.columnPinning.enable),
3505
- getFilteredRowModel: enableGlobalFilter((0, import_react_table4.getFilteredRowModel)()),
3506
- getCoreRowModel: (0, import_react_table4.getCoreRowModel)(),
3507
- getExpandedRowModel: (0, import_react_table4.getExpandedRowModel)(),
3508
- getSortedRowModel: (0, import_react_table4.getSortedRowModel)(),
3492
+ getFilteredRowModel: enableGlobalFilter((0, import_react_table3.getFilteredRowModel)()),
3493
+ getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
3494
+ getExpandedRowModel: (0, import_react_table3.getExpandedRowModel)(),
3495
+ getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
3509
3496
  onExpandedChange: setExpandedState,
3510
3497
  onRowSelectionChange: setRowSelectionState,
3511
3498
  onColumnPinningChange: setColumnPinning,
@@ -4156,17 +4143,12 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
4156
4143
  WARNING_PREFIX,
4157
4144
  addFormMeta,
4158
4145
  capitalizeHeader,
4159
- createColumnHelper,
4160
- enableOrUndefined,
4161
- getColumnHeader,
4162
- getFunctionValueOrDefault,
4163
4146
  getHelperTextProps,
4164
4147
  getIsFirstRightPinnedColumn,
4165
4148
  getIsLastLeftPinnedColumn,
4166
4149
  getTotalRight,
4167
4150
  leftCellShadow,
4168
4151
  prependSelectColumn,
4169
- prependSelectColumnIfEnabled,
4170
4152
  removeFormMeta,
4171
4153
  stopPropagation,
4172
4154
  stringToHslColor,
package/dist/index.mjs CHANGED
@@ -2906,7 +2906,6 @@ import { useRef as useRef2, useState as useState3 } from "react";
2906
2906
  import styled10 from "styled-components";
2907
2907
 
2908
2908
  // src/DataTable/utils.tsx
2909
- import { createColumnHelper } from "@tanstack/react-table";
2910
2909
  function capitalizeHeader(context) {
2911
2910
  const header = context.header.id;
2912
2911
  return header.charAt(0).toUpperCase() + header.slice(1);
@@ -2920,13 +2919,6 @@ function getColumnHeader(column) {
2920
2919
  return column.id;
2921
2920
  return typeof columnHeader === "string" ? columnHeader : column.id;
2922
2921
  }
2923
- function prependSelectColumnIfEnabled(columns, config) {
2924
- if (!config)
2925
- return columns;
2926
- if (!Boolean(config == null ? void 0 : config.mode))
2927
- return columns;
2928
- return prependSelectColumn(columns, config);
2929
- }
2930
2922
  function prependSelectColumn(columns, config) {
2931
2923
  if (!(config == null ? void 0 : config.selectColumn))
2932
2924
  return columns;
@@ -4108,17 +4100,12 @@ export {
4108
4100
  WARNING_PREFIX,
4109
4101
  addFormMeta,
4110
4102
  capitalizeHeader,
4111
- createColumnHelper,
4112
- enableOrUndefined,
4113
- getColumnHeader,
4114
- getFunctionValueOrDefault,
4115
4103
  getHelperTextProps,
4116
4104
  getIsFirstRightPinnedColumn,
4117
4105
  getIsLastLeftPinnedColumn,
4118
4106
  getTotalRight,
4119
4107
  leftCellShadow,
4120
4108
  prependSelectColumn,
4121
- prependSelectColumnIfEnabled,
4122
4109
  removeFormMeta,
4123
4110
  stopPropagation,
4124
4111
  stringToHslColor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "3.5.1-beta.2",
3
+ "version": "3.5.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -46,7 +46,7 @@
46
46
  "eslint-config-custom": "*",
47
47
  "storybook": "^7.0.0-alpha.38",
48
48
  "tsconfig": "*",
49
- "typescript": "^5.2.2"
49
+ "typescript": "^4.5.2"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"