@equinor/apollo-components 3.5.1-beta.0 → 3.5.1-beta.2

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
@@ -2,7 +2,7 @@ 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
4
  import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, ColumnResizeMode, RowSelectionState, ExpandedState, ColumnPinningState, VisibilityState, HeaderContext, Column } from '@tanstack/react-table';
5
- export { Cell, ColumnDef, ColumnPinningState, ColumnResizeMode, ExpandedState, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
5
+ export { Cell, CellContext, ColumnDef, ColumnPinningState, ColumnResizeMode, ExpandedState, HeaderContext, OnChangeFn, Row, RowSelectionState, SortingState, Table, VisibilityState, createColumnHelper } from '@tanstack/react-table';
6
6
  import * as styled_components from 'styled-components';
7
7
  import * as _equinor_eds_core_react from '@equinor/eds-core-react';
8
8
  import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-core-react';
@@ -197,8 +197,26 @@ 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>[];
200
216
  /** Prepend a column definition array with a select column. */
201
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;
202
220
 
203
221
  declare function SelectColumnDef<T>(props: SetRequired<DataTableProps<T>, 'rowSelection'>['rowSelection']): ColumnDef$1<T, any>;
204
222
 
@@ -310,4 +328,4 @@ declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromPro
310
328
  declare const WARNING_PREFIX = "WARNING";
311
329
  declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
312
330
 
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 };
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 };
package/dist/index.js CHANGED
@@ -2397,12 +2397,17 @@ __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,
2400
2404
  getHelperTextProps: () => getHelperTextProps,
2401
2405
  getIsFirstRightPinnedColumn: () => getIsFirstRightPinnedColumn,
2402
2406
  getIsLastLeftPinnedColumn: () => getIsLastLeftPinnedColumn,
2403
2407
  getTotalRight: () => getTotalRight,
2404
2408
  leftCellShadow: () => leftCellShadow,
2405
2409
  prependSelectColumn: () => prependSelectColumn,
2410
+ prependSelectColumnIfEnabled: () => prependSelectColumnIfEnabled,
2406
2411
  removeFormMeta: () => removeFormMeta,
2407
2412
  stopPropagation: () => stopPropagation,
2408
2413
  stringToHslColor: () => stringToHslColor,
@@ -2968,6 +2973,13 @@ function getColumnHeader(column) {
2968
2973
  return column.id;
2969
2974
  return typeof columnHeader === "string" ? columnHeader : column.id;
2970
2975
  }
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
+ }
2971
2983
  function prependSelectColumn(columns, config) {
2972
2984
  if (!(config == null ? void 0 : config.selectColumn))
2973
2985
  return columns;
@@ -4144,12 +4156,17 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
4144
4156
  WARNING_PREFIX,
4145
4157
  addFormMeta,
4146
4158
  capitalizeHeader,
4159
+ createColumnHelper,
4160
+ enableOrUndefined,
4161
+ getColumnHeader,
4162
+ getFunctionValueOrDefault,
4147
4163
  getHelperTextProps,
4148
4164
  getIsFirstRightPinnedColumn,
4149
4165
  getIsLastLeftPinnedColumn,
4150
4166
  getTotalRight,
4151
4167
  leftCellShadow,
4152
4168
  prependSelectColumn,
4169
+ prependSelectColumnIfEnabled,
4153
4170
  removeFormMeta,
4154
4171
  stopPropagation,
4155
4172
  stringToHslColor,
package/dist/index.mjs CHANGED
@@ -2920,6 +2920,13 @@ function getColumnHeader(column) {
2920
2920
  return column.id;
2921
2921
  return typeof columnHeader === "string" ? columnHeader : column.id;
2922
2922
  }
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
+ }
2923
2930
  function prependSelectColumn(columns, config) {
2924
2931
  if (!(config == null ? void 0 : config.selectColumn))
2925
2932
  return columns;
@@ -4101,12 +4108,17 @@ export {
4101
4108
  WARNING_PREFIX,
4102
4109
  addFormMeta,
4103
4110
  capitalizeHeader,
4111
+ createColumnHelper,
4112
+ enableOrUndefined,
4113
+ getColumnHeader,
4114
+ getFunctionValueOrDefault,
4104
4115
  getHelperTextProps,
4105
4116
  getIsFirstRightPinnedColumn,
4106
4117
  getIsLastLeftPinnedColumn,
4107
4118
  getTotalRight,
4108
4119
  leftCellShadow,
4109
4120
  prependSelectColumn,
4121
+ prependSelectColumnIfEnabled,
4110
4122
  removeFormMeta,
4111
4123
  stopPropagation,
4112
4124
  stringToHslColor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "3.5.1-beta.0",
3
+ "version": "3.5.1-beta.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",