@equinor/apollo-components 3.3.0 → 3.4.0-beta.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,6 +1,6 @@
1
1
  import { IconData } from '@equinor/eds-icons';
2
2
  import * as react from 'react';
3
- import { ReactNode, ReactElement, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
3
+ import { ReactNode, ReactElement, MouseEvent, HTMLProps, MutableRefObject, Dispatch, SetStateAction, SyntheticEvent } from 'react';
4
4
  import { CellContext, Cell, Header, Table, Row, SortingState, OnChangeFn, ColumnDef, RowSelectionState, ExpandedState, VisibilityState, HeaderContext } from '@tanstack/react-table';
5
5
  import * as styled_components from 'styled-components';
6
6
  import * as _equinor_eds_core_react from '@equinor/eds-core-react';
@@ -8,6 +8,7 @@ import { CellProps, TypographyProps as TypographyProps$1 } from '@equinor/eds-co
8
8
  import { ColumnDef as ColumnDef$1 } from '@tanstack/table-core';
9
9
  import { SetRequired } from 'type-fest';
10
10
  import { TableOptions } from '@tanstack/table-core/build/lib/types';
11
+ import { Variants } from '@equinor/eds-core-react/dist/types/components/types';
11
12
  import { FieldError } from 'react-hook-form';
12
13
 
13
14
  interface AppShellProps {
@@ -82,7 +83,7 @@ interface RowConfig<T> {
82
83
  */
83
84
  rowWrapper?: TableRowWrapper<T>;
84
85
  getRowBackground?: (row: Row<T>) => string | undefined;
85
- onClick?: (row: Row<T>) => void;
86
+ onClick?: (row: Row<T>, e: MouseEvent) => void;
86
87
  onMouseEnter?: (row: Row<T>) => void;
87
88
  onMouseLeave?: (row: Row<T>) => void;
88
89
  }
@@ -245,10 +246,23 @@ declare function useSetFormMeta<T extends FormMeta>(): (newValues: Partial<T>) =
245
246
  declare function removeFormMeta<T extends FormMeta>(withFormMeta: T): Omit<T, keyof FormMeta>;
246
247
  declare function addFormMeta<T>(withoutFormMeta: T): T & FormMeta;
247
248
 
249
+ interface GetHelperTextPropsProps {
250
+ error?: {
251
+ message?: string;
252
+ };
253
+ warning?: {
254
+ message: string;
255
+ };
256
+ helperText?: string;
257
+ }
258
+ interface GetHelperTextProps {
259
+ variant?: Variants;
260
+ helperText?: string;
261
+ helperIcon: JSX.Element | null;
262
+ }
248
263
  interface EditableCellBaseProps<T extends FormMeta, Value> extends CellContext<T, Value> {
249
264
  /**
250
- * FieldError object used to overwrite react-hook-form validation result. It is prioritized over
251
- * react-hook-form's validation.
265
+ * FieldError object used to overwrite react-hook-form validation result. It is prioritized over react-hook-form's validation. If prefixed with the exported `WARNING_PREFIX` it will be displayed as an warning.
252
266
  */
253
267
  error?: FieldError;
254
268
  /**
@@ -286,4 +300,7 @@ declare function EditableTextAreaCell<T extends FormMeta>({ title, error: errorF
286
300
 
287
301
  declare function EditableTextFieldCell<T extends FormMeta>({ error: errorFromProps, ...context }: EditableCellBaseProps<T, string>): JSX.Element;
288
302
 
289
- export { AppShell, AppSidebar, CellConfig, CheckboxCell, ChipsCell, ColumnSelect, DataTable, DataTableProps, DynamicCell, EditableCheckboxCell, EditableDateCell, EditableDateCellProps, EditableDropdownSingleCell, EditableDropdownSingleCellProps, 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, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
303
+ declare const WARNING_PREFIX = "WARNING";
304
+ declare function getHelperTextProps({ error, warning, helperText, }: GetHelperTextPropsProps): GetHelperTextProps;
305
+
306
+ 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, leftCellShadow, prependSelectColumn, removeFormMeta, stopPropagation, stringToHslColor, useEditMode, useGetIsNew, useHasRemoteChange, useSetFormMeta };
package/dist/index.js CHANGED
@@ -2394,8 +2394,10 @@ __export(src_exports, {
2394
2394
  StyledStickyCell: () => StyledStickyCell,
2395
2395
  TableHeader: () => TableHeader,
2396
2396
  TypographyCustom: () => TypographyCustom,
2397
+ WARNING_PREFIX: () => WARNING_PREFIX,
2397
2398
  addFormMeta: () => addFormMeta,
2398
2399
  capitalizeHeader: () => capitalizeHeader,
2400
+ getHelperTextProps: () => getHelperTextProps,
2399
2401
  leftCellShadow: () => leftCellShadow,
2400
2402
  prependSelectColumn: () => prependSelectColumn,
2401
2403
  removeFormMeta: () => removeFormMeta,
@@ -3062,9 +3064,9 @@ function TableRow({
3062
3064
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
3063
3065
  backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
3064
3066
  },
3065
- onClick: () => {
3067
+ onClick: (e) => {
3066
3068
  var _a2;
3067
- return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
3069
+ return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row, e);
3068
3070
  },
3069
3071
  onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
3070
3072
  onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
@@ -3598,17 +3600,27 @@ var import_styled_components17 = __toESM(require("styled-components"));
3598
3600
  var import_eds_core_react21 = require("@equinor/eds-core-react");
3599
3601
  var import_eds_icons8 = require("@equinor/eds-icons");
3600
3602
  var import_jsx_runtime22 = require("react/jsx-runtime");
3603
+ var WARNING_PREFIX = "WARNING";
3601
3604
  function getHelperTextProps({
3602
3605
  error,
3603
3606
  warning,
3604
3607
  helperText
3605
3608
  }) {
3606
- if (error)
3609
+ var _a;
3610
+ if (error) {
3611
+ if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
3612
+ return {
3613
+ variant: "warning",
3614
+ helperText: error.message.substring(WARNING_PREFIX.length),
3615
+ helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.warning_filled, size: 16 })
3616
+ };
3617
+ }
3607
3618
  return {
3608
3619
  variant: "error",
3609
3620
  helperText: error.message,
3610
3621
  helperIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_eds_core_react21.Icon, { data: import_eds_icons8.error_filled, size: 16 })
3611
3622
  };
3623
+ }
3612
3624
  if (warning)
3613
3625
  return {
3614
3626
  variant: "warning",
@@ -3620,12 +3632,6 @@ function getHelperTextProps({
3620
3632
  helperIcon: null
3621
3633
  };
3622
3634
  }
3623
- function stopPropagation2(handler) {
3624
- return (e) => {
3625
- e.stopPropagation();
3626
- handler(e);
3627
- };
3628
- }
3629
3635
 
3630
3636
  // src/form-cells/EditableDateCell.tsx
3631
3637
  var import_jsx_runtime23 = require("react/jsx-runtime");
@@ -3907,7 +3913,7 @@ function EditableTextAreaCell(_a) {
3907
3913
  ref
3908
3914
  }, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
3909
3915
  ),
3910
- /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { variant: "ghost_icon", onClick: stopPropagation2(openDialog), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Icon, { data: import_eds_icons9.arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
3916
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_eds_core_react26.Icon, { data: import_eds_icons9.arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
3911
3917
  ]
3912
3918
  }
3913
3919
  ),
@@ -4067,8 +4073,10 @@ var InlineTextField3 = (0, import_styled_components20.default)(import_eds_core_r
4067
4073
  StyledStickyCell,
4068
4074
  TableHeader,
4069
4075
  TypographyCustom,
4076
+ WARNING_PREFIX,
4070
4077
  addFormMeta,
4071
4078
  capitalizeHeader,
4079
+ getHelperTextProps,
4072
4080
  leftCellShadow,
4073
4081
  prependSelectColumn,
4074
4082
  removeFormMeta,
package/dist/index.mjs CHANGED
@@ -3025,9 +3025,9 @@ function TableRow({
3025
3025
  cursor: (rowConfig == null ? void 0 : rowConfig.onClick) ? "pointer" : "initial",
3026
3026
  backgroundColor: (_a = rowConfig == null ? void 0 : rowConfig.getRowBackground) == null ? void 0 : _a.call(rowConfig, row)
3027
3027
  },
3028
- onClick: () => {
3028
+ onClick: (e) => {
3029
3029
  var _a2;
3030
- return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row);
3030
+ return (_a2 = rowConfig == null ? void 0 : rowConfig.onClick) == null ? void 0 : _a2.call(rowConfig, row, e);
3031
3031
  },
3032
3032
  onMouseEnter: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseEnter),
3033
3033
  onMouseLeave: handleRowEvent(row, rowConfig == null ? void 0 : rowConfig.onMouseLeave),
@@ -3561,17 +3561,27 @@ import styled17 from "styled-components";
3561
3561
  import { Icon as Icon7 } from "@equinor/eds-core-react";
3562
3562
  import { error_filled, warning_filled } from "@equinor/eds-icons";
3563
3563
  import { jsx as jsx22 } from "react/jsx-runtime";
3564
+ var WARNING_PREFIX = "WARNING";
3564
3565
  function getHelperTextProps({
3565
3566
  error,
3566
3567
  warning,
3567
3568
  helperText
3568
3569
  }) {
3569
- if (error)
3570
+ var _a;
3571
+ if (error) {
3572
+ if ((_a = error.message) == null ? void 0 : _a.startsWith(WARNING_PREFIX)) {
3573
+ return {
3574
+ variant: "warning",
3575
+ helperText: error.message.substring(WARNING_PREFIX.length),
3576
+ helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: warning_filled, size: 16 })
3577
+ };
3578
+ }
3570
3579
  return {
3571
3580
  variant: "error",
3572
3581
  helperText: error.message,
3573
3582
  helperIcon: /* @__PURE__ */ jsx22(Icon7, { data: error_filled, size: 16 })
3574
3583
  };
3584
+ }
3575
3585
  if (warning)
3576
3586
  return {
3577
3587
  variant: "warning",
@@ -3583,12 +3593,6 @@ function getHelperTextProps({
3583
3593
  helperIcon: null
3584
3594
  };
3585
3595
  }
3586
- function stopPropagation2(handler) {
3587
- return (e) => {
3588
- e.stopPropagation();
3589
- handler(e);
3590
- };
3591
- }
3592
3596
 
3593
3597
  // src/form-cells/EditableDateCell.tsx
3594
3598
  import { jsx as jsx23 } from "react/jsx-runtime";
@@ -3870,7 +3874,7 @@ function EditableTextAreaCell(_a) {
3870
3874
  ref
3871
3875
  }, field), getHelperTextProps({ error: errorFromProps != null ? errorFromProps : error }))
3872
3876
  ),
3873
- /* @__PURE__ */ jsx27(IconButton, { variant: "ghost_icon", onClick: stopPropagation2(openDialog), children: /* @__PURE__ */ jsx27(Icon8, { data: arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
3877
+ /* @__PURE__ */ jsx27(IconButton, { variant: "ghost_icon", onClick: stopPropagation(openDialog), children: /* @__PURE__ */ jsx27(Icon8, { data: arrow_up, size: 24, style: { transform: "rotateZ(45deg)" } }) })
3874
3878
  ]
3875
3879
  }
3876
3880
  ),
@@ -4029,8 +4033,10 @@ export {
4029
4033
  StyledStickyCell,
4030
4034
  TableHeader,
4031
4035
  TypographyCustom,
4036
+ WARNING_PREFIX,
4032
4037
  addFormMeta,
4033
4038
  capitalizeHeader,
4039
+ getHelperTextProps,
4034
4040
  leftCellShadow,
4035
4041
  prependSelectColumn,
4036
4042
  removeFormMeta,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/apollo-components",
3
- "version": "3.3.0",
3
+ "version": "3.4.0-beta.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",