@reltio/components 1.4.752 → 1.4.756

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.
@@ -4,10 +4,11 @@ declare type Props<T> = {
4
4
  height: number;
5
5
  data: T[];
6
6
  defaultItemSize: number;
7
+ itemKey?: (index: number, data: T[]) => string;
7
8
  children: ({ data, index }: {
8
9
  data: T[];
9
10
  index: number;
10
11
  }) => React.ReactNode;
11
12
  };
12
- declare const _default: React.MemoExoticComponent<(<T>({ width, height, defaultItemSize, data, children }: Props<T>) => JSX.Element)>;
13
+ declare const _default: React.MemoExoticComponent<(<T extends unknown>({ width, height, defaultItemSize, data, children, itemKey }: Props<T>) => JSX.Element)>;
13
14
  export default _default;
@@ -38,29 +38,28 @@ var react_window_1 = require("react-window");
38
38
  var react_resize_detector_1 = __importDefault(require("react-resize-detector"));
39
39
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
40
40
  var AutoSizeList = function (_a) {
41
- var _b = _a.width, width = _b === void 0 ? 0 : _b, _c = _a.height, height = _c === void 0 ? 0 : _c, defaultItemSize = _a.defaultItemSize, data = _a.data, children = _a.children;
42
- var listRef = react_1.useRef();
41
+ var _b = _a.width, width = _b === void 0 ? 0 : _b, _c = _a.height, height = _c === void 0 ? 0 : _c, defaultItemSize = _a.defaultItemSize, data = _a.data, children = _a.children, itemKey = _a.itemKey;
42
+ var rowHeightsCache = react_1.useRef({});
43
+ var cacheRowHeight = function (key, height) {
44
+ var _a;
45
+ rowHeightsCache.current = __assign(__assign({}, rowHeightsCache.current), (_a = {}, _a[key] = height, _a));
46
+ };
43
47
  var _d = react_1.useState({}), rowHeights = _d[0], setRowHeights = _d[1];
44
- var getItemSize = function (index) { return rowHeights[index] || defaultItemSize; };
45
48
  var applyRowHeights = react_1.useCallback(mdm_sdk_1.debounce(function () {
46
49
  setRowHeights(__assign({}, rowHeightsCache.current));
47
- listRef.current && listRef.current.resetAfterIndex(0);
48
50
  }), []);
49
- var rowHeightsCache = react_1.useRef({});
50
- var cacheRowHeight = function (index, height) {
51
- var _a;
52
- rowHeightsCache.current = __assign(__assign({}, rowHeightsCache.current), (_a = {}, _a[index] = height, _a));
53
- };
54
- react_1.useLayoutEffect(function () {
55
- rowHeightsCache.current = {};
56
- }, [width, data, defaultItemSize, children]);
57
- return (react_1.default.createElement(react_window_1.VariableSizeList, { ref: listRef, width: width, height: height, itemCount: data.length, itemData: data, itemSize: getItemSize }, function (_a) {
51
+ var getItemKey = function (index) { return (itemKey ? itemKey(index, data) : index); };
52
+ var getItemSize = function (index) { return rowHeights[getItemKey(index)] || defaultItemSize; };
53
+ var listRef = react_1.useRef();
54
+ listRef.current && listRef.current.resetAfterIndex(0, false);
55
+ return (react_1.default.createElement(react_window_1.VariableSizeList, { ref: listRef, width: width, height: height, itemCount: data.length, itemData: data, itemSize: getItemSize, itemKey: itemKey }, function (_a) {
58
56
  var data = _a.data, index = _a.index, style = _a.style;
57
+ var key = getItemKey(index);
59
58
  return (react_1.default.createElement("div", { style: style },
60
- react_1.default.createElement("div", null,
59
+ react_1.default.createElement("div", { style: { visibility: key in rowHeights ? 'visible' : 'hidden' } },
61
60
  react_1.default.createElement(react_resize_detector_1.default, { handleHeight: true, onResize: function (_, height) {
62
- if (rowHeightsCache.current[index] !== height) {
63
- cacheRowHeight(index, height);
61
+ if (rowHeightsCache.current[key] !== height) {
62
+ cacheRowHeight(key, height);
64
63
  applyRowHeights();
65
64
  }
66
65
  } }),
@@ -105,6 +105,7 @@ declare namespace MultiSelect {
105
105
  export const getOptions: PropTypes.Requireable<(...args: any[]) => any>;
106
106
  export const menuPlacement: PropTypes.Requireable<string>;
107
107
  export const getOptionValue: PropTypes.Requireable<(...args: any[]) => any>;
108
+ export const isSearchable: PropTypes.Requireable<boolean>;
108
109
  }
109
110
  }
110
111
  import PropTypes from "prop-types";
@@ -90,10 +90,9 @@ function MultiSelect(props) {
90
90
  setInputValue(value);
91
91
  }
92
92
  }
93
- function handleChange(value, _a) {
94
- var action = _a.action;
95
- onChangeProp(value, { action: action });
96
- if (action === 'create-option') {
93
+ function handleChange(value, actionMeta) {
94
+ onChangeProp(value, actionMeta);
95
+ if (actionMeta.action === 'create-option') {
97
96
  setInputValue('');
98
97
  onInputChangeProp('', { action: 'input-change' });
99
98
  }
@@ -228,6 +227,7 @@ MultiSelect.propTypes = {
228
227
  TextFieldProps: prop_types_1.default.object /* eslint-disable-line react/forbid-prop-types */,
229
228
  getOptions: prop_types_1.default.func,
230
229
  menuPlacement: prop_types_1.default.string,
231
- getOptionValue: prop_types_1.default.func
230
+ getOptionValue: prop_types_1.default.func,
231
+ isSearchable: prop_types_1.default.bool
232
232
  };
233
233
  exports.default = MultiSelect;
@@ -61,7 +61,7 @@ var ActivityLog = function (_a) {
61
61
  }, []); // eslint-disable-line
62
62
  return (react_1.default.createElement(react_1.default.Fragment, null,
63
63
  react_1.default.createElement(CollapsibleItemsContext_1.CollapsibleItemsProvider, null,
64
- react_1.default.createElement(AutoSizeList_1.default, { width: width, height: height - PAGINATION_HEIGHT, data: flatItems, defaultItemSize: 40 }, renderRow)),
64
+ react_1.default.createElement(AutoSizeList_1.default, { width: width, height: height - PAGINATION_HEIGHT, data: flatItems, defaultItemSize: 40, itemKey: helpers_1.getItemKey }, renderRow)),
65
65
  react_1.default.createElement(BasicTablePagination_1.default, { count: count, onChangePage: onChangePage, page: page, rowsPerPage: rowsPerPage, onChangeRowsPerPage: onChangeRowsPerPage, rowsPerPageOptions: rowsPerPageOptions, labelRowsPerPage: ui_i18n_1.default.text('Events per page:') })));
66
66
  };
67
67
  exports.default = ActivityLog;
@@ -1,8 +1,15 @@
1
+ import { ActivityData } from '../types';
1
2
  export declare type GroupedItemData = {
2
3
  collapsed: boolean;
3
4
  timestamp: number;
4
5
  children: unknown[];
5
6
  };
6
7
  export declare const buildGroupedItems: any;
8
+ export declare type GroupItemData = {
9
+ collapsed: boolean;
10
+ timestamp: number;
11
+ index: number;
12
+ };
7
13
  export declare const flattenGroupedItems: any;
8
14
  export declare const isGroupItem: any;
15
+ export declare const getItemKey: (index: number, data: (ActivityData | GroupItemData)[]) => string;
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.isGroupItem = exports.flattenGroupedItems = exports.buildGroupedItems = void 0;
11
+ exports.getItemKey = exports.isGroupItem = exports.flattenGroupedItems = exports.buildGroupedItems = void 0;
12
12
  var ramda_1 = require("ramda");
13
13
  var moment_1 = __importDefault(require("moment"));
14
14
  var buildGroupedItem = function (_a) {
@@ -31,3 +31,8 @@ exports.flattenGroupedItems = chainIndexed(function (_a, index) {
31
31
  return collapsed ? [groupItem] : __spreadArray([groupItem], children);
32
32
  });
33
33
  exports.isGroupItem = ramda_1.has('collapsed');
34
+ var getItemKey = function (index, data) {
35
+ var item = data[index];
36
+ return 'uri' in item ? item.uri : "" + item.index;
37
+ };
38
+ exports.getItemKey = getItemKey;
@@ -1,10 +1,7 @@
1
1
  /// <reference types="react" />
2
+ import { GroupItemData } from '../../helpers';
2
3
  declare type Props = {
3
- item: {
4
- index: number;
5
- timestamp: number;
6
- collapsed: boolean;
7
- };
4
+ item: GroupItemData;
8
5
  onToggle: (index: number) => void;
9
6
  };
10
7
  declare const GroupItem: ({ item: { index, timestamp, collapsed }, onToggle }: Props) => JSX.Element;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.752",
3
+ "version": "1.4.756",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
7
  "@date-io/moment": "^1.3.5",
8
- "@reltio/mdm-module": "^1.4.752",
9
- "@reltio/mdm-sdk": "^1.4.752",
8
+ "@reltio/mdm-module": "^1.4.756",
9
+ "@reltio/mdm-sdk": "^1.4.756",
10
10
  "classnames": "^2.2.5",
11
11
  "frontend-collective-react-dnd-scrollzone": "^1.0.2",
12
12
  "nanoid": "^2.0.0",