@reltio/components 1.4.2071 → 1.4.2072

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.
Files changed (174) hide show
  1. package/AttributesView/AttributesView.js +1 -1
  2. package/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -3
  3. package/ColumnsSettings/helpers.d.ts +3 -1
  4. package/ColumnsSettings/types.d.ts +8 -0
  5. package/CommentsContainer/CommentsContainer.js +1 -1
  6. package/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +23 -40
  7. package/ConfigureColumnsPopup/ConfigureColumnsPopup.js +6 -26
  8. package/EditModeAttributesList/EditModeAttributesList.js +1 -1
  9. package/EditModeAttributesPager/EditModeAttributesPager.test.js +1 -1
  10. package/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.js +1 -1
  11. package/MetadataTypesSelector/MetadataTypesSelector.d.ts +2 -1
  12. package/MetadataTypesSelector/components/SelectMetadataTypesList/SelectMetadataTypesList.d.ts +5 -6
  13. package/MoreAttributesButton/useMoreAttributesItems.d.ts +1 -1
  14. package/ReadOnlyAttributesList/ReadOnlyAttributesList.js +1 -1
  15. package/ReadOnlyAttributesPager/ReadOnlyAttributesPager.js +1 -1
  16. package/ReadOnlyAttributesView/ReadOnlyAttributesView.js +1 -1
  17. package/ScrollableTabs/ScrollableTabs.test.js +69 -19
  18. package/SearchHighlighter/SearchHighlighter.test.js +18 -7
  19. package/SelectAttributesList/SelectAttributesList.d.ts +11 -6
  20. package/SelectAttributesList/SelectAttributesList.js +5 -2
  21. package/SelectorWithOnlyOptionAutoSelect/SelectorWithOnlyOptionAutoSelect.test.js +109 -60
  22. package/SidePanelContentHeader/SidePanelContentHeader.js +2 -2
  23. package/SidePanelContentHeader/SidePanelContentHeader.test.js +104 -0
  24. package/SidePanelEmptyState/SidePanelEmptyState.js +1 -1
  25. package/SidePanelEmptyState/SidePanelEmptyState.test.js +24 -0
  26. package/SimpleAttribute/SimpleAttribute.js +1 -1
  27. package/SimpleAttribute/SimpleAttribute.test.js +155 -80
  28. package/SimpleAttributeEditor/SimpleAttributeEditor.test.js +339 -330
  29. package/SimpleAttributeEditor/useAttributeValuePermissions.js +1 -1
  30. package/SimpleDropDownSelector/SimpleDropDownSelector.test.js +86 -10
  31. package/SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.js +1 -1
  32. package/SimpleDropDownSelector/components/DropDownValue/DropDownValue.js +1 -1
  33. package/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +128 -32
  34. package/SmallIconButton/SmallIconButton.test.js +98 -25
  35. package/TableWithBars/TableWithBars.test.js +98 -60
  36. package/TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.js +1 -1
  37. package/TableWithBars/components/HeadCellRenderer/HeadCellRenderer.js +1 -1
  38. package/Tags/Tags.d.ts +0 -1
  39. package/Tags/Tags.test.js +8 -7
  40. package/TransitiveMatchBlock/TransitiveMatchBlock.test.js +78 -22
  41. package/TransitiveMatchRule/TransitiveMatchRule.test.js +78 -37
  42. package/TransitiveMatchRulesTooltip/TransitiveMatchRulesTooltip.js +1 -1
  43. package/TransitiveMatchRulesTooltip/TransitiveMatchRulesTooltip.test.js +12 -18
  44. package/UploadFileButton/UploadFileButton.d.ts +2 -2
  45. package/UploadFileButton/UploadFileButton.test.js +199 -0
  46. package/UploadImageDialog/UploadImageDialog.test.js +1 -0
  47. package/UploadImageDialog/components/DividerWithText/DividerWithText.js +1 -1
  48. package/UploadImageDialog/components/ErrorSnackbar/ErrorSnackbar.test.js +80 -22
  49. package/UploadImageDialog/components/ImageByUrlField/ImageByUrlField.js +1 -1
  50. package/UploadImageDialog/components/ImageByUrlField/ImageByUrlField.test.js +162 -49
  51. package/ValueChip/ValueChip.test.js +7 -23
  52. package/VirtualGroupedList/VirtualGroupedList.d.ts +19 -31
  53. package/VirtualGroupedList/VirtualGroupedList.js +11 -36
  54. package/VirtualGroupedList/VirtualGroupedList.test.js +224 -0
  55. package/VirtualGroupedList/helpers.d.ts +7 -2
  56. package/VirtualGroupedList/helpers.js +3 -1
  57. package/VirtualGroupedList/index.d.ts +1 -1
  58. package/VirtualGroupedList/types.d.ts +10 -6
  59. package/VirtualGroupedList/useScrollToFocusItem.d.ts +8 -5
  60. package/WhiteSearchInput/{WhiteSearchInput.spec.js → WhiteSearchInput.test.js} +3 -8
  61. package/cjs/AttributesView/AttributesView.js +2 -2
  62. package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.d.ts +2 -3
  63. package/cjs/ColumnsSettings/helpers.d.ts +3 -1
  64. package/cjs/ColumnsSettings/types.d.ts +8 -0
  65. package/cjs/ColumnsSettings/types.js +2 -0
  66. package/cjs/CommentsContainer/CommentsContainer.js +1 -1
  67. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +23 -40
  68. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.js +6 -26
  69. package/cjs/EditModeAttributesList/EditModeAttributesList.js +2 -2
  70. package/cjs/EditModeAttributesPager/EditModeAttributesPager.test.js +2 -2
  71. package/cjs/EditModeAttributesPager/components/AttributeRenderer/AttributeRenderer.js +2 -2
  72. package/cjs/MetadataTypesSelector/MetadataTypesSelector.d.ts +2 -1
  73. package/cjs/MetadataTypesSelector/components/SelectMetadataTypesList/SelectMetadataTypesList.d.ts +5 -6
  74. package/cjs/MoreAttributesButton/useMoreAttributesItems.d.ts +1 -1
  75. package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.js +2 -2
  76. package/cjs/ReadOnlyAttributesPager/ReadOnlyAttributesPager.js +2 -2
  77. package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.js +2 -2
  78. package/cjs/ScrollableTabs/ScrollableTabs.test.js +69 -19
  79. package/cjs/SearchHighlighter/SearchHighlighter.test.js +18 -7
  80. package/cjs/SelectAttributesList/SelectAttributesList.d.ts +11 -6
  81. package/cjs/SelectAttributesList/SelectAttributesList.js +5 -2
  82. package/cjs/SelectorWithOnlyOptionAutoSelect/SelectorWithOnlyOptionAutoSelect.test.js +109 -60
  83. package/cjs/SidePanelContentHeader/SidePanelContentHeader.js +2 -2
  84. package/cjs/SidePanelContentHeader/SidePanelContentHeader.test.js +109 -0
  85. package/cjs/SidePanelEmptyState/SidePanelEmptyState.js +1 -1
  86. package/cjs/SidePanelEmptyState/SidePanelEmptyState.test.js +29 -0
  87. package/cjs/SimpleAttribute/SimpleAttribute.js +1 -1
  88. package/cjs/SimpleAttribute/SimpleAttribute.test.js +155 -80
  89. package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.test.js +338 -352
  90. package/cjs/SimpleAttributeEditor/useAttributeValuePermissions.js +2 -2
  91. package/cjs/SimpleDropDownSelector/SimpleDropDownSelector.test.js +86 -10
  92. package/cjs/SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.js +1 -1
  93. package/cjs/SimpleDropDownSelector/components/DropDownValue/DropDownValue.js +1 -1
  94. package/cjs/SimpleMatchRulesBlock/SimpleMatchRulesBlock.test.js +127 -31
  95. package/cjs/SmallIconButton/SmallIconButton.test.js +98 -25
  96. package/cjs/TableWithBars/TableWithBars.test.js +98 -60
  97. package/cjs/TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.js +1 -1
  98. package/cjs/TableWithBars/components/HeadCellRenderer/HeadCellRenderer.js +1 -1
  99. package/cjs/Tags/Tags.d.ts +0 -1
  100. package/cjs/Tags/Tags.test.js +8 -7
  101. package/cjs/TransitiveMatchBlock/TransitiveMatchBlock.test.js +77 -21
  102. package/cjs/TransitiveMatchRule/TransitiveMatchRule.test.js +78 -37
  103. package/cjs/TransitiveMatchRulesTooltip/TransitiveMatchRulesTooltip.js +1 -1
  104. package/cjs/TransitiveMatchRulesTooltip/TransitiveMatchRulesTooltip.test.js +12 -18
  105. package/cjs/UploadFileButton/UploadFileButton.d.ts +2 -2
  106. package/cjs/UploadFileButton/UploadFileButton.test.js +204 -0
  107. package/cjs/UploadImageDialog/UploadImageDialog.test.js +1 -0
  108. package/cjs/UploadImageDialog/components/DividerWithText/DividerWithText.js +1 -1
  109. package/cjs/UploadImageDialog/components/ErrorSnackbar/ErrorSnackbar.test.js +80 -22
  110. package/cjs/UploadImageDialog/components/ImageByUrlField/ImageByUrlField.js +1 -1
  111. package/cjs/UploadImageDialog/components/ImageByUrlField/ImageByUrlField.test.js +162 -49
  112. package/cjs/ValueChip/ValueChip.test.js +7 -23
  113. package/cjs/VirtualGroupedList/VirtualGroupedList.d.ts +19 -31
  114. package/cjs/VirtualGroupedList/VirtualGroupedList.js +11 -36
  115. package/cjs/VirtualGroupedList/VirtualGroupedList.test.js +252 -0
  116. package/cjs/VirtualGroupedList/helpers.d.ts +7 -2
  117. package/cjs/VirtualGroupedList/helpers.js +3 -1
  118. package/cjs/VirtualGroupedList/index.d.ts +1 -1
  119. package/cjs/VirtualGroupedList/types.d.ts +10 -6
  120. package/cjs/VirtualGroupedList/useScrollToFocusItem.d.ts +8 -5
  121. package/cjs/WhiteSearchInput/{WhiteSearchInput.spec.js → WhiteSearchInput.test.js} +3 -8
  122. package/cjs/features/crosswalks/hooks/useAttributeActions.test.js +24 -25
  123. package/cjs/features/crosswalks/hooks/useCrosswalkActions.test.js +10 -11
  124. package/cjs/features/workflow/hooks/useChangeRequest.test.js +5 -6
  125. package/cjs/hooks/useCommentsEntitiesMap/useCommentsEntitiesMap.test.js +8 -9
  126. package/cjs/hooks/useKeyboardNavigation/useKeyboardNavigation.d.ts +9 -13
  127. package/features/crosswalks/hooks/useAttributeActions.test.js +1 -2
  128. package/features/crosswalks/hooks/useCrosswalkActions.test.js +1 -2
  129. package/features/workflow/hooks/useChangeRequest.test.js +1 -2
  130. package/hooks/useCommentsEntitiesMap/useCommentsEntitiesMap.test.js +1 -2
  131. package/hooks/useKeyboardNavigation/useKeyboardNavigation.d.ts +9 -13
  132. package/package.json +1 -1
  133. package/SidePanelContentHeader/SidePanelContentHeader.spec.js +0 -49
  134. package/SidePanelEmptyState/SidePanelEmptyState.spec.js +0 -24
  135. package/SimpleAttributeEditor/SimpleAttributeEditorWithoutPermissions.test.js +0 -103
  136. package/SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.test.js +0 -13
  137. package/TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.test.js +0 -21
  138. package/TableWithBars/components/HeadCellRenderer/HeadCellRenderer.test.js +0 -20
  139. package/UploadFileButton/UploadFileButton.spec.js +0 -219
  140. package/UploadImageDialog/components/DividerWithText/DividerWithText.test.js +0 -9
  141. package/VirtualGroupedList/VirtualGroupedList.spec.js +0 -282
  142. package/cjs/SidePanelContentHeader/SidePanelContentHeader.spec.js +0 -54
  143. package/cjs/SidePanelEmptyState/SidePanelEmptyState.spec.d.ts +0 -1
  144. package/cjs/SidePanelEmptyState/SidePanelEmptyState.spec.js +0 -29
  145. package/cjs/SimpleAttributeEditor/SimpleAttributeEditorWithoutPermissions.test.d.ts +0 -1
  146. package/cjs/SimpleAttributeEditor/SimpleAttributeEditorWithoutPermissions.test.js +0 -108
  147. package/cjs/SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.test.d.ts +0 -1
  148. package/cjs/SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.test.js +0 -18
  149. package/cjs/TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.test.d.ts +0 -1
  150. package/cjs/TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.test.js +0 -26
  151. package/cjs/TableWithBars/components/HeadCellRenderer/HeadCellRenderer.test.d.ts +0 -1
  152. package/cjs/TableWithBars/components/HeadCellRenderer/HeadCellRenderer.test.js +0 -25
  153. package/cjs/UploadFileButton/UploadFileButton.spec.d.ts +0 -1
  154. package/cjs/UploadFileButton/UploadFileButton.spec.js +0 -224
  155. package/cjs/UploadImageDialog/components/DividerWithText/DividerWithText.test.d.ts +0 -1
  156. package/cjs/UploadImageDialog/components/DividerWithText/DividerWithText.test.js +0 -14
  157. package/cjs/VirtualGroupedList/VirtualGroupedList.spec.d.ts +0 -1
  158. package/cjs/VirtualGroupedList/VirtualGroupedList.spec.js +0 -287
  159. package/cjs/WhiteSearchInput/WhiteSearchInput.spec.d.ts +0 -1
  160. /package/{SidePanelContentHeader/SidePanelContentHeader.spec.d.ts → ColumnsSettings/types.js} +0 -0
  161. /package/{SidePanelEmptyState/SidePanelEmptyState.spec.d.ts → SidePanelContentHeader/SidePanelContentHeader.test.d.ts} +0 -0
  162. /package/{SimpleAttributeEditor/SimpleAttributeEditorWithoutPermissions.test.d.ts → SidePanelEmptyState/SidePanelEmptyState.test.d.ts} +0 -0
  163. /package/{SimpleDropDownSelector/components/DropDownPlaceholder/DropDownPlaceholder.test.d.ts → UploadFileButton/UploadFileButton.test.d.ts} +0 -0
  164. /package/{TableWithBars/components/AttributeCellRenderer/AttributeCellRenderer.test.d.ts → VirtualGroupedList/VirtualGroupedList.test.d.ts} +0 -0
  165. /package/{TableWithBars/components/HeadCellRenderer/HeadCellRenderer.test.d.ts → WhiteSearchInput/WhiteSearchInput.test.d.ts} +0 -0
  166. /package/{UploadFileButton/UploadFileButton.spec.d.ts → cjs/SidePanelContentHeader/SidePanelContentHeader.test.d.ts} +0 -0
  167. /package/{UploadImageDialog/components/DividerWithText/DividerWithText.test.d.ts → cjs/SidePanelEmptyState/SidePanelEmptyState.test.d.ts} +0 -0
  168. /package/{VirtualGroupedList/VirtualGroupedList.spec.d.ts → cjs/UploadFileButton/UploadFileButton.test.d.ts} +0 -0
  169. /package/{WhiteSearchInput/WhiteSearchInput.spec.d.ts → cjs/VirtualGroupedList/VirtualGroupedList.test.d.ts} +0 -0
  170. /package/cjs/{SidePanelContentHeader/SidePanelContentHeader.spec.d.ts → WhiteSearchInput/WhiteSearchInput.test.d.ts} +0 -0
  171. /package/cjs/contexts/{AllwaysVisibleAttributesContext → AlwaysVisibleAttributesContext}/index.d.ts +0 -0
  172. /package/cjs/contexts/{AllwaysVisibleAttributesContext → AlwaysVisibleAttributesContext}/index.js +0 -0
  173. /package/contexts/{AllwaysVisibleAttributesContext → AlwaysVisibleAttributesContext}/index.d.ts +0 -0
  174. /package/contexts/{AllwaysVisibleAttributesContext → AlwaysVisibleAttributesContext}/index.js +0 -0
@@ -1,32 +1,20 @@
1
- export function VirtualGroupedList({ items, getItemSize, renderItem, renderGroupTitle, width, height, fixedTitle, itemKey, disableHorizontalScrollbar, hideSubtitles, focusIndex, onInnerContainerResize }: {
2
- items: any;
3
- getItemSize: any;
4
- renderItem: any;
5
- renderGroupTitle: any;
6
- width?: string;
7
- height: any;
8
- fixedTitle?: boolean;
9
- itemKey?: (i: any) => any;
10
- disableHorizontalScrollbar: any;
11
- hideSubtitles: any;
12
- focusIndex?: any;
13
- onInnerContainerResize: any;
14
- }): React.JSX.Element;
15
- export namespace VirtualGroupedList {
16
- namespace propTypes {
17
- let items: PropTypes.Validator<object[]>;
18
- let getItemSize: PropTypes.Validator<(...args: any[]) => any>;
19
- let renderItem: PropTypes.Validator<(...args: any[]) => any>;
20
- let width: PropTypes.Requireable<NonNullable<string | number>>;
21
- let height: PropTypes.Validator<number>;
22
- let renderGroupTitle: PropTypes.Requireable<(...args: any[]) => any>;
23
- let fixedTitle: PropTypes.Requireable<boolean>;
24
- let hideSubtitles: PropTypes.Requireable<boolean>;
25
- let itemKey: PropTypes.Requireable<(...args: any[]) => any>;
26
- let disableHorizontalScrollbar: PropTypes.Requireable<boolean>;
27
- let focusIndex: PropTypes.Requireable<number>;
28
- let onInnerContainerResize: PropTypes.Requireable<(...args: any[]) => any>;
29
- }
30
- }
31
1
  import React from 'react';
32
- import PropTypes from 'prop-types';
2
+ import { VariableSizeList as List } from 'react-window';
3
+ import { OnResizeCallback } from 'react-resize-detector/build/types/types';
4
+ import { VirtualGroupedListItem, VirtualGroupedListMainItem, VirtualGroupedListRenderGroupTitle, VirtualGroupedListRenderItem } from './types';
5
+ type Props<T> = {
6
+ items: VirtualGroupedListMainItem<T>[];
7
+ getItemSize: (index: number, item: VirtualGroupedListItem<T>) => number;
8
+ renderItem: VirtualGroupedListRenderItem<T>;
9
+ renderGroupTitle?: VirtualGroupedListRenderGroupTitle<T>;
10
+ width?: string | number;
11
+ height: number;
12
+ fixedTitle?: boolean;
13
+ itemKey?: React.ComponentProps<typeof List>['itemKey'];
14
+ disableHorizontalScrollbar?: boolean;
15
+ hideSubtitles?: boolean;
16
+ focusIndex?: number;
17
+ onInnerContainerResize?: OnResizeCallback;
18
+ };
19
+ export declare const VirtualGroupedList: <Data>({ items, getItemSize, renderItem, renderGroupTitle, width, height, fixedTitle, itemKey, disableHorizontalScrollbar, hideSubtitles, focusIndex, onInnerContainerResize }: Props<Data>) => React.JSX.Element;
20
+ export {};
@@ -37,27 +37,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.VirtualGroupedList = void 0;
39
39
  var react_1 = __importStar(require("react"));
40
- var prop_types_1 = __importDefault(require("prop-types"));
41
40
  var react_window_1 = require("react-window");
42
41
  var react_resize_detector_1 = __importDefault(require("react-resize-detector"));
43
42
  var useScrollToFocusItem_1 = require("./useScrollToFocusItem");
44
43
  var helpers_1 = require("./helpers");
45
44
  var styles_1 = require("./styles");
46
- /*
47
- items = [
48
- {
49
- item: {
50
- item: {},
51
- level: number
52
- },
53
- titleItemIndex: number,
54
- index: number,
55
- moveTo: true|false,
56
- items: [...]
57
- ...
58
- }
59
- ]
60
- */
61
45
  var OVERSCAN_COUNT = 5;
62
46
  var VirtualGroupedList = function (_a) {
63
47
  var items = _a.items, getItemSize = _a.getItemSize, renderItem = _a.renderItem, renderGroupTitle = _a.renderGroupTitle, _b = _a.width, width = _b === void 0 ? '100%' : _b, height = _a.height, _c = _a.fixedTitle, fixedTitle = _c === void 0 ? true : _c, _d = _a.itemKey, itemKey = _d === void 0 ? function (i) { return i; } : _d, disableHorizontalScrollbar = _a.disableHorizontalScrollbar, hideSubtitles = _a.hideSubtitles, _e = _a.focusIndex, focusIndex = _e === void 0 ? null : _e, onInnerContainerResize = _a.onInnerContainerResize;
@@ -69,9 +53,12 @@ var VirtualGroupedList = function (_a) {
69
53
  var stepCalcOffset = 10;
70
54
  var stickyItemClass = 'stickyTitleItem';
71
55
  var currentTitleParams = {
72
- topMargin: 0
56
+ topMargin: 0,
57
+ index: undefined
58
+ };
59
+ var isGroupHasSubTitles = function (groupedItems) {
60
+ return (groupedItems || []).some(function (item) { return item.titleItemIndex !== null; });
73
61
  };
74
- var isGroupHasSubTitles = function (groupedItems) { return (groupedItems || []).some(function (item) { return item.titleItemIndex !== null; }); };
75
62
  var hasSubTitles = (0, react_1.useMemo)(function () { return !hideSubtitles || isGroupHasSubTitles(items); }, [items, hideSubtitles]);
76
63
  var calcOffsetsToIndex = (0, react_1.useCallback)(function (index) {
77
64
  var curItemsLength = itemOffsets.current.length;
@@ -205,9 +192,11 @@ var VirtualGroupedList = function (_a) {
205
192
  var render = (0, react_1.useCallback)(function (_a) {
206
193
  var index = _a.index, style = _a.style, data = _a.data;
207
194
  var listItem = getItemByIndex(index);
208
- return (listItem.item &&
209
- (((0, helpers_1.isTitleListItem)(listItem) && renderGroupTitle(style, listItem.item)) ||
210
- renderItem(style, listItem.item, index, data)));
195
+ if (!listItem.item)
196
+ return null;
197
+ return (0, helpers_1.isTitleListItem)(listItem)
198
+ ? renderGroupTitle(style, listItem.item)
199
+ : renderItem(style, listItem.item, index, data);
211
200
  }, [getItemByIndex, renderGroupTitle, renderItem]);
212
201
  var handleOnItemsRendered = (0, useScrollToFocusItem_1.useScrollToFocusItem)({ items: items, focusIndex: focusIndex, listRef: listRef }).handleOnItemsRendered;
213
202
  var renderTitles = (0, react_1.useCallback)(function () {
@@ -215,22 +204,8 @@ var VirtualGroupedList = function (_a) {
215
204
  return items.filter(function (listItem) { return (0, helpers_1.isTitleListItem)(listItem); }).map(function (listItem) { return renderTitle(listItem); });
216
205
  }, [getItemSize, items, renderGroupTitle]);
217
206
  return (react_1.default.createElement(react_1.default.Fragment, null,
218
- react_1.default.createElement("div", { ref: titlesRef, className: styles.stickyTitlesWrapper }, fixedTitle && renderTitles()),
207
+ react_1.default.createElement("div", { ref: titlesRef, "data-reltio-id": "grouped-list-sticky-titles", className: styles.stickyTitlesWrapper }, fixedTitle && renderTitles()),
219
208
  onInnerContainerResize && itemsRef.current && (react_1.default.createElement(react_resize_detector_1.default, { handleHeight: true, onResize: onInnerContainerResize, targetRef: itemsRef })),
220
209
  react_1.default.createElement(react_window_1.VariableSizeList, { ref: listRef, itemCount: items.length, itemSize: _getItemSize, width: width, height: height, itemKey: itemKey, innerRef: itemsRef, onScroll: onScroll, style: disableHorizontalScrollbar ? { overflowX: 'hidden' } : undefined, overscanCount: OVERSCAN_COUNT, onItemsRendered: handleOnItemsRendered }, render)));
221
210
  };
222
211
  exports.VirtualGroupedList = VirtualGroupedList;
223
- exports.VirtualGroupedList.propTypes = {
224
- items: prop_types_1.default.arrayOf(prop_types_1.default.object).isRequired,
225
- getItemSize: prop_types_1.default.func.isRequired,
226
- renderItem: prop_types_1.default.func.isRequired,
227
- width: prop_types_1.default.oneOfType([prop_types_1.default.number, prop_types_1.default.string]),
228
- height: prop_types_1.default.number.isRequired,
229
- renderGroupTitle: prop_types_1.default.func,
230
- fixedTitle: prop_types_1.default.bool,
231
- hideSubtitles: prop_types_1.default.bool,
232
- itemKey: prop_types_1.default.func,
233
- disableHorizontalScrollbar: prop_types_1.default.bool,
234
- focusIndex: prop_types_1.default.number,
235
- onInnerContainerResize: prop_types_1.default.func
236
- };
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ var react_1 = __importDefault(require("react"));
41
+ var react_2 = require("@testing-library/react");
42
+ var react_window_1 = require("react-window");
43
+ var useScrollToFocusItemImport = __importStar(require("./useScrollToFocusItem"));
44
+ var helpers_1 = require("./helpers");
45
+ var VirtualGroupedList_1 = require("./VirtualGroupedList");
46
+ describe('VirtualGroupedList tests', function () {
47
+ var getItems = function (type) {
48
+ var simpleItems = [
49
+ { item: { label: 'Label 1', id: 'some_id1' } },
50
+ { item: { label: 'Label 2', id: 'some_id2' } },
51
+ { item: { label: 'Label 3', id: 'some_id3' } }
52
+ ];
53
+ var newSimpleItems = [{ item: { label: 'Label 1', id: 'some_id1' } }, { item: { label: 'Label 2', id: 'some_id2' } }];
54
+ var groupedItems = [
55
+ {
56
+ item: { label: 'Label 1', id: 'some_id1' },
57
+ items: [
58
+ { item: { label: 'Label 1.1', id: 'some_id1.1' } },
59
+ { item: { label: 'Label 1.2', id: 'some_id1.2' } },
60
+ { item: { label: 'Label 1.3', id: 'some_id1.3' } }
61
+ ]
62
+ },
63
+ {
64
+ item: { label: 'Label 2', id: 'some_id2' },
65
+ items: [
66
+ { item: { label: 'Label 2.1', id: 'some_id2.1' } },
67
+ { item: { label: 'Label 2.2', id: 'some_id2.2' }, moveTo: false }
68
+ ]
69
+ }
70
+ ];
71
+ switch (type) {
72
+ case 'grouped':
73
+ return (0, helpers_1.flattenGroupedItemsData)(groupedItems);
74
+ case 'groupedWithMove': {
75
+ groupedItems[1].items[1].moveTo = true;
76
+ return (0, helpers_1.flattenGroupedItemsData)(groupedItems);
77
+ }
78
+ case 'newSimpleItems': {
79
+ return (0, helpers_1.flattenGroupedItemsData)(newSimpleItems);
80
+ }
81
+ case 'simple':
82
+ default:
83
+ return (0, helpers_1.flattenGroupedItemsData)(simpleItems);
84
+ }
85
+ };
86
+ var renderItem = function (style, _a) {
87
+ var item = _a.item;
88
+ return (react_1.default.createElement("div", { style: style, "data-reltio-id": "grouped-list-item" }, item.label));
89
+ };
90
+ var defaultProps = {
91
+ getItemSize: function () { return 50; },
92
+ renderItem: renderItem,
93
+ renderGroupTitle: renderItem,
94
+ items: getItems('simple'),
95
+ height: 500
96
+ };
97
+ var setUp = function (props) {
98
+ if (props === void 0) { props = {}; }
99
+ return (0, react_2.render)(react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, __assign({}, defaultProps, props)));
100
+ };
101
+ afterEach(function () {
102
+ jest.restoreAllMocks();
103
+ });
104
+ it('should correct render simple items', function () {
105
+ setUp({ items: getItems('simple') });
106
+ expect(react_2.screen.getByText('Label 1')).toBeInTheDocument();
107
+ expect(react_2.screen.getByText('Label 2')).toBeInTheDocument();
108
+ expect(react_2.screen.getByText('Label 3')).toBeInTheDocument();
109
+ });
110
+ it('should correct render grouped items', function () {
111
+ setUp({ items: getItems('grouped') });
112
+ var stickyTitles = react_2.screen.getByTestId('grouped-list-sticky-titles');
113
+ expect(stickyTitles.childNodes).toHaveLength(2);
114
+ expect((0, react_2.within)(stickyTitles).getByText('Label 1')).toHaveStyle('visibility: visible');
115
+ expect((0, react_2.within)(stickyTitles).getByText('Label 2')).toHaveStyle('visibility: hidden');
116
+ var items = react_2.screen.getAllByTestId('grouped-list-item');
117
+ expect(items).toHaveLength(9);
118
+ expect(items.map(function (item) { return item.textContent; })).toEqual([
119
+ 'Label 1',
120
+ 'Label 2',
121
+ 'Label 1',
122
+ 'Label 1.1',
123
+ 'Label 1.2',
124
+ 'Label 1.3',
125
+ 'Label 2',
126
+ 'Label 2.1',
127
+ 'Label 2.2'
128
+ ]);
129
+ });
130
+ it('should set sticky titles width if items width changed', function () {
131
+ var _a = setUp({ items: getItems('grouped') }), container = _a.container, rerender = _a.rerender;
132
+ var stickyTitles = react_2.screen.getByTestId('grouped-list-sticky-titles');
133
+ Object.defineProperties(container.childNodes[1].firstChild, {
134
+ offsetWidth: {
135
+ get: function () {
136
+ return 200;
137
+ }
138
+ }
139
+ });
140
+ rerender(react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, __assign({}, defaultProps, { items: getItems('grouped'), height: 100 })));
141
+ expect(stickyTitles).toHaveStyle('width: 200px');
142
+ });
143
+ it('should not render fixed group title when fixedTitle is false', function () {
144
+ setUp({ items: getItems('grouped'), fixedTitle: false });
145
+ var stickyTitles = react_2.screen.getByTestId('grouped-list-sticky-titles');
146
+ expect(stickyTitles.childNodes).toHaveLength(0);
147
+ });
148
+ it('should clear index when items is updated', function () {
149
+ var useScrollToFocusItemSpy = jest.spyOn(useScrollToFocusItemImport, 'useScrollToFocusItem');
150
+ var rerender = setUp({ items: getItems('simple') }).rerender;
151
+ var listRef = useScrollToFocusItemSpy.mock.calls[0][0].listRef;
152
+ var resetAfterIndexSpy = jest.spyOn(listRef.current, 'resetAfterIndex');
153
+ rerender(react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, __assign({}, defaultProps, { items: getItems('simple') })));
154
+ expect(resetAfterIndexSpy).toHaveBeenCalledWith(0);
155
+ });
156
+ describe('Scroll behavior', function () {
157
+ var setHeightForNode = function (node, height, scrollHeight) {
158
+ Object.defineProperties(node, {
159
+ clientHeight: {
160
+ get: function () { return height; },
161
+ configurable: true
162
+ },
163
+ scrollHeight: {
164
+ get: function () { return scrollHeight; },
165
+ configurable: true
166
+ }
167
+ });
168
+ };
169
+ /*
170
+ Some scroll offsets for grouped items(getItems('grouped')):
171
+ First title offset: 0
172
+ First title will be showing in offset range: 0-199
173
+ Second title offset: 200
174
+ Second title will be showing in offset range: 200+
175
+ Offset range when titles is touching each other: 150-200
176
+ */
177
+ it('should scroll to moveTo item', function () {
178
+ var requestAnimationFrameMock = jest
179
+ .spyOn(window, 'requestAnimationFrame')
180
+ .mockImplementation(function (callback) {
181
+ callback(0);
182
+ return 0;
183
+ });
184
+ var scrollToSpy = jest.spyOn(react_window_1.VariableSizeList.prototype, 'scrollTo').mockImplementation(function () { return null; });
185
+ var rerender = setUp({ items: getItems('grouped'), height: 150 }).rerender;
186
+ rerender(react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, __assign({}, defaultProps, { items: getItems('groupedWithMove'), height: 150 })));
187
+ expect(scrollToSpy).toHaveBeenCalledTimes(2);
188
+ expect(scrollToSpy).toHaveBeenCalledWith(200);
189
+ requestAnimationFrameMock.mockRestore();
190
+ });
191
+ it('should scroll to top of item', function () {
192
+ var scrollToSpy = jest.spyOn(react_window_1.VariableSizeList.prototype, 'scrollTo').mockImplementation(function () { return null; });
193
+ var rerender = setUp({ items: getItems('grouped'), height: 150 }).rerender;
194
+ var requestAnimationFrameMock = jest
195
+ .spyOn(window, 'requestAnimationFrame')
196
+ .mockImplementation(function (callback) {
197
+ callback(0);
198
+ return 0;
199
+ });
200
+ rerender(react_1.default.createElement(VirtualGroupedList_1.VirtualGroupedList, __assign({}, defaultProps, { items: getItems('newSimpleItems'), height: 150 })));
201
+ expect(scrollToSpy).toHaveBeenCalledTimes(1);
202
+ expect(scrollToSpy).toHaveBeenCalledWith(0);
203
+ requestAnimationFrameMock.mockRestore();
204
+ });
205
+ it('should change fixed title on forward scroll', function () {
206
+ var container = setUp({ items: getItems('grouped'), height: 150 }).container;
207
+ var titlesContainer = react_2.screen.getByTestId('grouped-list-sticky-titles');
208
+ var titles = (0, react_2.within)(titlesContainer).getAllByTestId('grouped-list-item');
209
+ setHeightForNode(container.childNodes[1], 150, 400);
210
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 210 } });
211
+ expect(titles).toHaveLength(2);
212
+ expect(titlesContainer).toHaveStyle('top: 0px');
213
+ expect(titles[0]).toHaveStyle('visibility: hidden');
214
+ expect(titles[1]).toHaveStyle('visibility: visible');
215
+ });
216
+ it('should move current fixed title on forward scroll when next title start touching the current title', function () {
217
+ var container = setUp({ items: getItems('grouped'), height: 150 }).container;
218
+ var titlesContainer = react_2.screen.getByTestId('grouped-list-sticky-titles');
219
+ var titles = (0, react_2.within)(titlesContainer).getAllByTestId('grouped-list-item');
220
+ setHeightForNode(container.childNodes[1], 150, 400);
221
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 151 } });
222
+ expect(titles).toHaveLength(2);
223
+ expect(titlesContainer).toHaveStyle('top: -1px');
224
+ expect(titles[0]).toHaveStyle('visibility: visible');
225
+ expect(titles[1]).toHaveStyle('visibility: hidden');
226
+ });
227
+ it('should change fixed title on backward scroll', function () {
228
+ var container = setUp({ items: getItems('grouped'), height: 150 }).container;
229
+ var titlesContainer = react_2.screen.getByTestId('grouped-list-sticky-titles');
230
+ var titles = (0, react_2.within)(titlesContainer).getAllByTestId('grouped-list-item');
231
+ setHeightForNode(container.childNodes[1], 150, 400);
232
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 210 } });
233
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 140 } });
234
+ expect(titles).toHaveLength(2);
235
+ expect(titlesContainer).toHaveStyle('top: 0px');
236
+ expect(titles[0]).toHaveStyle('visibility: visible');
237
+ expect(titles[1]).toHaveStyle('visibility: hidden');
238
+ });
239
+ it('should move current fixed title on backward scroll when previous title start touching the current title', function () {
240
+ var container = setUp({ items: getItems('grouped'), height: 150 }).container;
241
+ var titlesContainer = react_2.screen.getByTestId('grouped-list-sticky-titles');
242
+ var titles = (0, react_2.within)(titlesContainer).getAllByTestId('grouped-list-item');
243
+ setHeightForNode(container.childNodes[1], 150, 400);
244
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 210 } });
245
+ react_2.fireEvent.scroll(container.childNodes[1], { target: { scrollTop: 199 } });
246
+ expect(titles).toHaveLength(2);
247
+ expect(titlesContainer).toHaveStyle('top: -49px');
248
+ expect(titles[0]).toHaveStyle('visibility: visible');
249
+ expect(titles[1]).toHaveStyle('visibility: hidden');
250
+ });
251
+ });
252
+ });
@@ -1,2 +1,7 @@
1
- export function flattenGroupedItemsData(groupedItems: any): any;
2
- export function isTitleListItem(listItem: any): boolean;
1
+ import { VirtualGroupedListItem, VirtualGroupedListMainItem } from './types';
2
+ export type GroupedItem<T> = {
3
+ item: T;
4
+ items?: GroupedItem<T>[];
5
+ };
6
+ export declare const flattenGroupedItemsData: <T>(groupedItems: VirtualGroupedListItem<T>[]) => VirtualGroupedListMainItem<T>[];
7
+ export declare const isTitleListItem: <T>(listItem: VirtualGroupedListMainItem<T>) => boolean;
@@ -16,5 +16,7 @@ var flattenGroupedItemsData = function (groupedItems) {
16
16
  return items;
17
17
  };
18
18
  exports.flattenGroupedItemsData = flattenGroupedItemsData;
19
- var isTitleListItem = function (listItem) { return listItem.titleItemIndex === listItem.index; };
19
+ var isTitleListItem = function (listItem) {
20
+ return listItem.titleItemIndex === listItem.index;
21
+ };
20
22
  exports.isTitleListItem = isTitleListItem;
@@ -1,3 +1,3 @@
1
1
  export { VirtualGroupedList } from './VirtualGroupedList';
2
- export type { VirtualListGroupedItem, VirtualListItem } from './types';
2
+ export type { VirtualGroupedListItem, VirtualGroupedListMainItem, VirtualGroupedListRenderGroupTitle, VirtualGroupedListRenderItem } from './types';
3
3
  export { isTitleListItem, flattenGroupedItemsData } from './helpers';
@@ -1,10 +1,14 @@
1
- export type VirtualListItem = {
2
- item: Record<string, unknown>;
3
- moveTo?: number;
1
+ export type VirtualGroupedListItem<T, E = Record<string, unknown>> = E & {
2
+ item: T;
3
+ level?: number;
4
+ moveTo?: boolean;
5
+ items?: VirtualGroupedListItem<T, E>[];
4
6
  };
5
- export type VirtualListGroupedItem = {
6
- item: VirtualListItem;
7
+ export type VirtualGroupedListMainItem<T, E = Record<string, unknown>> = E & {
8
+ item: VirtualGroupedListItem<T, E>;
7
9
  titleItemIndex?: number;
8
10
  index: number;
9
- items?: VirtualListGroupedItem[];
11
+ moveTo?: boolean;
10
12
  };
13
+ export type VirtualGroupedListRenderItem<T, E = Record<string, unknown>> = (style: React.CSSProperties, item: VirtualGroupedListItem<T, E>, index: number, data: VirtualGroupedListMainItem<T, E>) => React.ReactElement;
14
+ export type VirtualGroupedListRenderGroupTitle<T, E = Record<string, unknown>> = (style: React.CSSProperties, item: VirtualGroupedListItem<T, E>) => React.ReactElement;
@@ -1,7 +1,10 @@
1
- export declare const useScrollToFocusItem: ({ focusIndex, listRef, items }: {
2
- focusIndex: any;
3
- listRef: any;
4
- items: any;
5
- }) => {
1
+ import { VariableSizeList } from 'react-window';
2
+ type Props<T> = {
3
+ focusIndex: number;
4
+ listRef: React.MutableRefObject<VariableSizeList>;
5
+ items: T[];
6
+ };
7
+ export declare const useScrollToFocusItem: <T>({ focusIndex, listRef, items }: Props<T>) => {
6
8
  handleOnItemsRendered: ({ visibleStartIndex, visibleStopIndex }: any) => void;
7
9
  };
10
+ export {};
@@ -15,8 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  var react_1 = __importDefault(require("react"));
18
- var enzyme_1 = require("enzyme");
19
- var SearchInput_1 = require("../SearchInput");
18
+ var react_2 = require("@testing-library/react");
20
19
  var WhiteSearchInput_1 = require("./WhiteSearchInput");
21
20
  describe('WhiteSearchInput tests', function () {
22
21
  var defaultProps = {
@@ -26,11 +25,7 @@ describe('WhiteSearchInput tests', function () {
26
25
  height: 40
27
26
  };
28
27
  it('should render SearchInput with specified focused class', function () {
29
- var component = (0, enzyme_1.shallow)(react_1.default.createElement(WhiteSearchInput_1.WhiteSearchInput, __assign({}, defaultProps)));
30
- var searchInput = component.find(SearchInput_1.SearchInput);
31
- expect(searchInput).toHaveLength(1);
32
- expect(searchInput.prop('classes')).toMatchObject({
33
- focused: 'white'
34
- });
28
+ (0, react_2.render)(react_1.default.createElement(WhiteSearchInput_1.WhiteSearchInput, __assign({}, defaultProps)));
29
+ expect(react_2.screen.getByRole('textbox').parentElement).toHaveClass('white');
35
30
  });
36
31
  });