@reltio/components 1.4.1625 → 1.4.1627

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.
@@ -5,8 +5,8 @@ type GetRowCellKeyProps = {
5
5
  columnData: ColumnData;
6
6
  rowValue: RowValue;
7
7
  };
8
- declare const useDynamicRowCellHeight: (getRowCellKey?: ({ rowIndex, columnData: { id }, cellIndex }: GetRowCellKeyProps) => string) => {
9
- getDynamicRowCellHeight: any;
8
+ declare const useDynamicRowCellHeight: (getRowCellKey?: ({ rowIndex, columnData, cellIndex }: GetRowCellKeyProps) => string) => {
9
+ getDynamicRowCellHeight: (cell: GetRowCellKeyProps) => number;
10
10
  changeRowCellHeight: any;
11
11
  clearHeightsCache: () => void;
12
12
  };
@@ -15,27 +15,29 @@ var react_1 = require("react");
15
15
  var ramda_1 = require("ramda");
16
16
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
17
17
  var defaultGetRowCellKey = function (_a) {
18
- var rowIndex = _a.rowIndex, id = _a.columnData.id, cellIndex = _a.cellIndex;
19
- return "".concat(id, "[").concat(rowIndex, "][").concat(cellIndex, "]");
18
+ var rowIndex = _a.rowIndex, columnData = _a.columnData, cellIndex = _a.cellIndex;
19
+ return "".concat(columnData.id, "[").concat(rowIndex, "][").concat(cellIndex, "]");
20
20
  };
21
21
  var useDynamicRowCellHeight = function (getRowCellKey) {
22
22
  if (getRowCellKey === void 0) { getRowCellKey = defaultGetRowCellKey; }
23
23
  var _a = (0, react_1.useState)({}), rowCellHeightsMap = _a[0], setRowCellHeightsMap = _a[1];
24
24
  var rowCellHeightsMapCache = (0, react_1.useRef)({});
25
- var batchHeightUpdate = function (key, value) {
26
- rowCellHeightsMapCache.current[key] = value;
27
- };
28
- var flushHeightUpdates = (0, react_1.useCallback)((0, mdm_sdk_1.debounce)(function () {
29
- setRowCellHeightsMap(function (prev) {
30
- var next = __assign({}, rowCellHeightsMapCache.current);
31
- return (0, ramda_1.equals)(prev, next) ? prev : next;
32
- });
33
- }), []);
25
+ var flushHeightUpdates = (0, react_1.useCallback)((0, mdm_sdk_1.debounce)(function () { return setRowCellHeightsMap(__assign({}, rowCellHeightsMapCache.current)); }), []);
34
26
  var clearHeightsCache = (0, react_1.useCallback)(function () {
35
27
  rowCellHeightsMapCache.current = {};
36
28
  }, []);
37
- var getDynamicRowCellHeight = (0, react_1.useCallback)((0, ramda_1.pipe)(getRowCellKey, (0, ramda_1.prop)(ramda_1.__, rowCellHeightsMap)), [rowCellHeightsMap]);
38
- var changeRowCellHeight = (0, react_1.useCallback)((0, ramda_1.curry)((0, ramda_1.useWith)((0, ramda_1.pipe)(batchHeightUpdate, flushHeightUpdates), [getRowCellKey, ramda_1.identity])), []);
29
+ var getDynamicRowCellHeight = (0, react_1.useCallback)(function (cell) {
30
+ var key = getRowCellKey(cell);
31
+ return rowCellHeightsMap[key];
32
+ }, [getRowCellKey, rowCellHeightsMap]);
33
+ var changeRowCellHeight = (0, react_1.useCallback)((0, ramda_1.curry)(function (cell, height) {
34
+ var key = getRowCellKey(cell);
35
+ var currentHeight = rowCellHeightsMapCache.current[key];
36
+ if (currentHeight !== height) {
37
+ rowCellHeightsMapCache.current[key] = height;
38
+ flushHeightUpdates();
39
+ }
40
+ }), [flushHeightUpdates, getRowCellKey]);
39
41
  return { getDynamicRowCellHeight: getDynamicRowCellHeight, changeRowCellHeight: changeRowCellHeight, clearHeightsCache: clearHeightsCache };
40
42
  };
41
43
  exports.default = useDynamicRowCellHeight;
@@ -47,7 +47,6 @@ var RowCellAutoSizer = function (_a) {
47
47
  var changeCellHeight = onChangeHeight({ rowIndex: rowIndex, cellIndex: cellIndex, columnData: columnData, rowValue: rowValue });
48
48
  var adjustCellHeight = function () { return cellRef.current && changeCellHeight(cellRef.current.clientHeight); };
49
49
  (0, hooks_1.useDidUpdateEffect)(adjustCellHeight, [rowValue.rawValue]);
50
- (0, react_1.useEffect)(function () { return function () { return changeCellHeight(undefined); }; }, []);
51
50
  return (react_1.default.createElement("div", { ref: cellRef },
52
51
  react_1.default.createElement(react_resize_detector_1.default, { handleHeight: true, onResize: adjustCellHeight }),
53
52
  cell));
@@ -1,5 +1,6 @@
1
- /// <reference types="react" />
2
- export declare const useScrollToAttribute: (context: any) => {
1
+ import { ContextType } from 'react';
2
+ import { ScrollToElementContext } from '../../../../../contexts';
3
+ export declare const useScrollToAttribute: (context?: ContextType<typeof ScrollToElementContext>) => {
3
4
  ref: import("react").MutableRefObject<HTMLDivElement>;
4
5
  highlightedClassName: string;
5
6
  } | {
@@ -6,12 +6,11 @@ var styles_1 = require("./styles");
6
6
  var useScrollToAttribute = function (context) {
7
7
  var styles = (0, styles_1.useStyles)();
8
8
  var ref = (0, react_1.useRef)(null);
9
- var scrollIntoRef = (context || {}).scrollIntoRef;
10
9
  (0, react_1.useEffect)(function () {
11
10
  if (context) {
12
- scrollIntoRef(ref);
11
+ context.scrollIntoRef(ref);
13
12
  }
14
- }, [context, scrollIntoRef]);
13
+ }, [context]);
15
14
  return context ? { ref: ref, highlightedClassName: styles.highlighted } : { ref: ref };
16
15
  };
17
16
  exports.useScrollToAttribute = useScrollToAttribute;
@@ -47,13 +47,11 @@ var ScrollToElementProvider = function (_a) {
47
47
  var _b = (0, react_1.useState)(null), element = _b[0], setElement = _b[1];
48
48
  var highlightTimer = (0, react_1.useRef)(null);
49
49
  var scrollIntoRef = (0, react_1.useCallback)(function (ref) {
50
+ if (!ref.current)
51
+ return;
50
52
  ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
51
- if (highlightTimer) {
52
- clearTimeout(highlightTimer.current);
53
- }
54
- highlightTimer.current = setTimeout(function () {
55
- setElement(null);
56
- }, 2000);
53
+ clearTimeout(highlightTimer.current);
54
+ highlightTimer.current = setTimeout(function () { return setElement(null); }, 2000);
57
55
  }, []);
58
56
  var handleHighlightError = (0, react_1.useCallback)(function (highlightedError) {
59
57
  setElement({ value: highlightedError, type: ScrollType.Error });
@@ -14,8 +14,7 @@ var useScrollToAttributeError = function (_a) {
14
14
  var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
15
15
  var styles = (0, styles_1.useStyles)();
16
16
  var ref = (0, react_1.useRef)(null);
17
- var _d = context || {}, element = _d.element, scrollIntoRef = _d.scrollIntoRef;
18
- var severity = (0, react_1.useMemo)(function () { return (0, ramda_1.propOr)(mdm_sdk_1.ErrorSeverity.ERROR, 'severity')(element); }, [element]);
17
+ var severity = (0, ramda_1.pathOr)(mdm_sdk_1.ErrorSeverity.ERROR, ['element', 'severity'])(context);
19
18
  var errorClassName = (0, classnames_1.default)((_b = {},
20
19
  _b[styles.highlightError] = severity === mdm_sdk_1.ErrorSeverity.ERROR,
21
20
  _b[styles.highlightWarning] = severity === mdm_sdk_1.ErrorSeverity.WARNING,
@@ -23,9 +22,9 @@ var useScrollToAttributeError = function (_a) {
23
22
  _b));
24
23
  (0, react_1.useEffect)(function () {
25
24
  if (context) {
26
- scrollIntoRef(ref);
25
+ context.scrollIntoRef(ref);
27
26
  }
28
- }, [context, scrollIntoRef]);
27
+ }, [context]);
29
28
  return context ? { ref: ref, errorClassName: errorClassName } : { ref: ref };
30
29
  };
31
30
  exports.useScrollToAttributeError = useScrollToAttributeError;
@@ -5,8 +5,8 @@ type GetRowCellKeyProps = {
5
5
  columnData: ColumnData;
6
6
  rowValue: RowValue;
7
7
  };
8
- declare const useDynamicRowCellHeight: (getRowCellKey?: ({ rowIndex, columnData: { id }, cellIndex }: GetRowCellKeyProps) => string) => {
9
- getDynamicRowCellHeight: any;
8
+ declare const useDynamicRowCellHeight: (getRowCellKey?: ({ rowIndex, columnData, cellIndex }: GetRowCellKeyProps) => string) => {
9
+ getDynamicRowCellHeight: (cell: GetRowCellKeyProps) => number;
10
10
  changeRowCellHeight: any;
11
11
  clearHeightsCache: () => void;
12
12
  };
@@ -10,30 +10,32 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { useCallback, useRef, useState } from 'react';
13
- import { __, curry, identity, pipe, prop, useWith, equals } from 'ramda';
13
+ import { curry } from 'ramda';
14
14
  import { debounce } from '@reltio/mdm-sdk';
15
15
  var defaultGetRowCellKey = function (_a) {
16
- var rowIndex = _a.rowIndex, id = _a.columnData.id, cellIndex = _a.cellIndex;
17
- return "".concat(id, "[").concat(rowIndex, "][").concat(cellIndex, "]");
16
+ var rowIndex = _a.rowIndex, columnData = _a.columnData, cellIndex = _a.cellIndex;
17
+ return "".concat(columnData.id, "[").concat(rowIndex, "][").concat(cellIndex, "]");
18
18
  };
19
19
  var useDynamicRowCellHeight = function (getRowCellKey) {
20
20
  if (getRowCellKey === void 0) { getRowCellKey = defaultGetRowCellKey; }
21
21
  var _a = useState({}), rowCellHeightsMap = _a[0], setRowCellHeightsMap = _a[1];
22
22
  var rowCellHeightsMapCache = useRef({});
23
- var batchHeightUpdate = function (key, value) {
24
- rowCellHeightsMapCache.current[key] = value;
25
- };
26
- var flushHeightUpdates = useCallback(debounce(function () {
27
- setRowCellHeightsMap(function (prev) {
28
- var next = __assign({}, rowCellHeightsMapCache.current);
29
- return equals(prev, next) ? prev : next;
30
- });
31
- }), []);
23
+ var flushHeightUpdates = useCallback(debounce(function () { return setRowCellHeightsMap(__assign({}, rowCellHeightsMapCache.current)); }), []);
32
24
  var clearHeightsCache = useCallback(function () {
33
25
  rowCellHeightsMapCache.current = {};
34
26
  }, []);
35
- var getDynamicRowCellHeight = useCallback(pipe(getRowCellKey, prop(__, rowCellHeightsMap)), [rowCellHeightsMap]);
36
- var changeRowCellHeight = useCallback(curry(useWith(pipe(batchHeightUpdate, flushHeightUpdates), [getRowCellKey, identity])), []);
27
+ var getDynamicRowCellHeight = useCallback(function (cell) {
28
+ var key = getRowCellKey(cell);
29
+ return rowCellHeightsMap[key];
30
+ }, [getRowCellKey, rowCellHeightsMap]);
31
+ var changeRowCellHeight = useCallback(curry(function (cell, height) {
32
+ var key = getRowCellKey(cell);
33
+ var currentHeight = rowCellHeightsMapCache.current[key];
34
+ if (currentHeight !== height) {
35
+ rowCellHeightsMapCache.current[key] = height;
36
+ flushHeightUpdates();
37
+ }
38
+ }), [flushHeightUpdates, getRowCellKey]);
37
39
  return { getDynamicRowCellHeight: getDynamicRowCellHeight, changeRowCellHeight: changeRowCellHeight, clearHeightsCache: clearHeightsCache };
38
40
  };
39
41
  export default useDynamicRowCellHeight;
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { useEffect, useRef } from 'react';
12
+ import React, { useRef } from 'react';
13
13
  import ReactResizeDetector from 'react-resize-detector';
14
14
  import { useDidUpdateEffect } from '../../../hooks';
15
15
  var RowCellAutoSizer = function (_a) {
@@ -19,7 +19,6 @@ var RowCellAutoSizer = function (_a) {
19
19
  var changeCellHeight = onChangeHeight({ rowIndex: rowIndex, cellIndex: cellIndex, columnData: columnData, rowValue: rowValue });
20
20
  var adjustCellHeight = function () { return cellRef.current && changeCellHeight(cellRef.current.clientHeight); };
21
21
  useDidUpdateEffect(adjustCellHeight, [rowValue.rawValue]);
22
- useEffect(function () { return function () { return changeCellHeight(undefined); }; }, []);
23
22
  return (React.createElement("div", { ref: cellRef },
24
23
  React.createElement(ReactResizeDetector, { handleHeight: true, onResize: adjustCellHeight }),
25
24
  cell));
@@ -1,5 +1,6 @@
1
- /// <reference types="react" />
2
- export declare const useScrollToAttribute: (context: any) => {
1
+ import { ContextType } from 'react';
2
+ import { ScrollToElementContext } from '../../../../../contexts';
3
+ export declare const useScrollToAttribute: (context?: ContextType<typeof ScrollToElementContext>) => {
3
4
  ref: import("react").MutableRefObject<HTMLDivElement>;
4
5
  highlightedClassName: string;
5
6
  } | {
@@ -3,11 +3,10 @@ import { useStyles } from './styles';
3
3
  export var useScrollToAttribute = function (context) {
4
4
  var styles = useStyles();
5
5
  var ref = useRef(null);
6
- var scrollIntoRef = (context || {}).scrollIntoRef;
7
6
  useEffect(function () {
8
7
  if (context) {
9
- scrollIntoRef(ref);
8
+ context.scrollIntoRef(ref);
10
9
  }
11
- }, [context, scrollIntoRef]);
10
+ }, [context]);
12
11
  return context ? { ref: ref, highlightedClassName: styles.highlighted } : { ref: ref };
13
12
  };
@@ -19,13 +19,11 @@ export var ScrollToElementProvider = function (_a) {
19
19
  var _b = useState(null), element = _b[0], setElement = _b[1];
20
20
  var highlightTimer = useRef(null);
21
21
  var scrollIntoRef = useCallback(function (ref) {
22
+ if (!ref.current)
23
+ return;
22
24
  ref.current.scrollIntoView({ behavior: 'smooth', block: 'center' });
23
- if (highlightTimer) {
24
- clearTimeout(highlightTimer.current);
25
- }
26
- highlightTimer.current = setTimeout(function () {
27
- setElement(null);
28
- }, 2000);
25
+ clearTimeout(highlightTimer.current);
26
+ highlightTimer.current = setTimeout(function () { return setElement(null); }, 2000);
29
27
  }, []);
30
28
  var handleHighlightError = useCallback(function (highlightedError) {
31
29
  setElement({ value: highlightedError, type: ScrollType.Error });
@@ -1,5 +1,5 @@
1
- import { useEffect, useMemo, useRef } from 'react';
2
- import { propOr } from 'ramda';
1
+ import { useEffect, useRef } from 'react';
2
+ import { pathOr } from 'ramda';
3
3
  import classnames from 'classnames';
4
4
  import { ErrorSeverity } from '@reltio/mdm-sdk';
5
5
  import { useStyles } from './styles';
@@ -8,8 +8,7 @@ export var useScrollToAttributeError = function (_a) {
8
8
  var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
9
9
  var styles = useStyles();
10
10
  var ref = useRef(null);
11
- var _d = context || {}, element = _d.element, scrollIntoRef = _d.scrollIntoRef;
12
- var severity = useMemo(function () { return propOr(ErrorSeverity.ERROR, 'severity')(element); }, [element]);
11
+ var severity = pathOr(ErrorSeverity.ERROR, ['element', 'severity'])(context);
13
12
  var errorClassName = classnames((_b = {},
14
13
  _b[styles.highlightError] = severity === ErrorSeverity.ERROR,
15
14
  _b[styles.highlightWarning] = severity === ErrorSeverity.WARNING,
@@ -17,8 +16,8 @@ export var useScrollToAttributeError = function (_a) {
17
16
  _b));
18
17
  useEffect(function () {
19
18
  if (context) {
20
- scrollIntoRef(ref);
19
+ context.scrollIntoRef(ref);
21
20
  }
22
- }, [context, scrollIntoRef]);
21
+ }, [context]);
23
22
  return context ? { ref: ref, errorClassName: errorClassName } : { ref: ref };
24
23
  };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1625",
3
+ "version": "1.4.1627",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1625",
11
- "@reltio/mdm-sdk": "^1.4.1625",
10
+ "@reltio/mdm-module": "^1.4.1627",
11
+ "@reltio/mdm-sdk": "^1.4.1627",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",