@reltio/components 1.4.2083 → 1.4.2084

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.
@@ -37,7 +37,7 @@ export var ImageAttributesLine = function (_a) {
37
37
  }
38
38
  }, [paging, requestNextPageOfAttributeValues, attributeType, parentUri, attributeValues.length, showNonOv]);
39
39
  var lastWidth = useRef();
40
- var _f = useState(0), maxItems = _f[0], setMaxItems = _f[1];
40
+ var _f = useState(attributeValues.length), maxItems = _f[0], setMaxItems = _f[1];
41
41
  var _g = useState(0), hiddenItemsLength = _g[0], setHiddenItemsLength = _g[1];
42
42
  var isBlockImageGalleryDialog = useContext(BlockImageGalleryDialogContext);
43
43
  var _h = useState(false), isOpenDialog = _h[0], setIsOpenDialog = _h[1];
@@ -101,7 +101,7 @@ export var ImageAttributesLine = function (_a) {
101
101
  onSetAsDefault: handleSetAsDefault
102
102
  }));
103
103
  return (React.createElement(React.Fragment, null,
104
- React.createElement(ReactResizeDetector, { handleWidth: true, onResize: handleResize }),
104
+ React.createElement(ReactResizeDetector, { handleWidth: true, handleHeight: false, onResize: handleResize, refreshMode: "debounce", refreshRate: 50 }),
105
105
  React.createElement(ImageAttributesGallery, { attributeValues: attributeValues, open: isOpenDialog, onClose: handleCloseImageGalleryDialog, setCurrentAttributeValueUri: setCurrentAttributeValueUri, currentAttributeValueUri: currentAttributeValueUri, attributeType: attributeType, onDownload: handleDownload, onShareLink: handleShareLink, onSetAsDefault: handleSetAsDefault, onUpload: onUpload, onDeleteAttribute: onDeleteAttribute }),
106
106
  React.createElement("div", { className: styles.imageBox },
107
107
  children,
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  import React from 'react';
49
49
  import { mockResizeObserver } from 'jsdom-testing-mocks';
50
- import { act, render, screen, waitForElementToBeRemoved } from '@testing-library/react';
50
+ import { act, render, screen, waitForElementToBeRemoved, waitFor } from '@testing-library/react';
51
51
  import userEvent from '@testing-library/user-event';
52
52
  import { insertDefaultImageByAttrUri, Mode } from '@reltio/mdm-sdk';
53
53
  import { imageAttributeValues, attributeType } from './imageAttributeValues.test-data';
@@ -99,49 +99,71 @@ describe('ImageAttributesLine tests', function () {
99
99
  downloadImagesByURLs.mockReturnValue(undefined);
100
100
  insertDefaultImageByAttrUri.mockResolvedValue({ status: 'success' });
101
101
  });
102
- it('should resize component', function () {
103
- var container = setUp({ props: { attributeValues: imageAttributeValues } }).container;
104
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
105
- act(function () {
106
- resizeObserver.resize();
107
- });
108
- expect(screen.getAllByTestId('image')).toHaveLength(3);
109
- expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
110
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
111
- act(function () {
112
- resizeObserver.resize(container);
113
- });
114
- expect(screen.getAllByTestId('image')).toHaveLength(2);
115
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
116
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
117
- act(function () {
118
- resizeObserver.resize(container);
119
- });
120
- expect(screen.getAllByTestId('image')).toHaveLength(2);
121
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
122
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
123
- act(function () {
124
- resizeObserver.resize(container);
102
+ it('should resize component', function () { return __awaiter(void 0, void 0, void 0, function () {
103
+ var container;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ container = setUp({ props: { attributeValues: imageAttributeValues } }).container;
108
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
109
+ act(function () {
110
+ resizeObserver.resize();
111
+ });
112
+ expect(screen.getAllByTestId('image')).toHaveLength(3);
113
+ expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
114
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
115
+ act(function () {
116
+ resizeObserver.resize(container);
117
+ });
118
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
119
+ case 1:
120
+ _a.sent();
121
+ expect(screen.getAllByTestId('image')).toHaveLength(2);
122
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
123
+ act(function () {
124
+ resizeObserver.resize(container);
125
+ });
126
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
127
+ case 2:
128
+ _a.sent();
129
+ expect(screen.getAllByTestId('image')).toHaveLength(2);
130
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
131
+ act(function () {
132
+ resizeObserver.resize(container);
133
+ });
134
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
135
+ case 3:
136
+ _a.sent();
137
+ expect(screen.getAllByTestId('image')).toHaveLength(2);
138
+ return [2 /*return*/];
139
+ }
125
140
  });
126
- expect(screen.getAllByTestId('image')).toHaveLength(2);
127
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
128
- });
129
- it('should recalculate max items to screen width after attributeValues.length changing', function () {
130
- var _a = setUp({ props: { attributeValues: imageAttributeValues } }), container = _a.container, rerender = _a.rerender;
131
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
132
- act(function () {
133
- resizeObserver.resize();
141
+ }); });
142
+ it('should recalculate max items to screen width after attributeValues.length changing', function () { return __awaiter(void 0, void 0, void 0, function () {
143
+ var _a, container, rerender, newAttributeValues;
144
+ return __generator(this, function (_b) {
145
+ switch (_b.label) {
146
+ case 0:
147
+ _a = setUp({ props: { attributeValues: imageAttributeValues } }), container = _a.container, rerender = _a.rerender;
148
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
149
+ act(function () {
150
+ resizeObserver.resize();
151
+ });
152
+ expect(screen.getAllByTestId('image')).toHaveLength(3);
153
+ expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
154
+ rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: [imageAttributeValues[0]] })));
155
+ expect(screen.getAllByTestId('image')).toHaveLength(1);
156
+ expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
157
+ newAttributeValues = Array.from({ length: 6 }, function (_, i) { return (__assign(__assign({}, imageAttributeValues[0]), { uri: imageAttributeValues[0].uri + i })); });
158
+ rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: newAttributeValues })));
159
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
160
+ case 1:
161
+ _b.sent();
162
+ expect(screen.getAllByTestId('image')).toHaveLength(5);
163
+ return [2 /*return*/];
164
+ }
134
165
  });
135
- expect(screen.getAllByTestId('image')).toHaveLength(3);
136
- expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
137
- rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: [imageAttributeValues[0]] })));
138
- expect(screen.getAllByTestId('image')).toHaveLength(1);
139
- expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
140
- var newAttributeValues = Array.from({ length: 6 }, function (_, i) { return (__assign(__assign({}, imageAttributeValues[0]), { uri: imageAttributeValues[0].uri + i })); });
141
- rerender(React.createElement(ImageAttributesLine, __assign({}, defaultProps, { attributeValues: newAttributeValues })));
142
- expect(screen.getAllByTestId('image')).toHaveLength(5);
143
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+1');
144
- });
166
+ }); });
145
167
  it('should open ImageAttributesGallery when click to image or button if BlockImageGalleryDialogContext context has falsy value', function () { return __awaiter(void 0, void 0, void 0, function () {
146
168
  var _a, container, user;
147
169
  return __generator(this, function (_b) {
@@ -286,34 +308,47 @@ describe('ImageAttributesLine tests', function () {
286
308
  });
287
309
  });
288
310
  });
289
- it('should calculate max items if countFixedItems more than 0', function () {
290
- var container = setUp({
291
- props: { attributeValues: imageAttributeValues, countFixedItems: 1 },
292
- mdmValues: { mode: Mode.Editing }
293
- }).container;
294
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
295
- act(function () {
296
- resizeObserver.resize();
297
- });
298
- expect(screen.getAllByTestId('image')).toHaveLength(3);
299
- expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
300
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
301
- act(function () {
302
- resizeObserver.resize(container);
303
- });
304
- expect(screen.getAllByTestId('image')).toHaveLength(1);
305
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
306
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
307
- act(function () {
308
- resizeObserver.resize(container);
309
- });
310
- expect(screen.getAllByTestId('image')).toHaveLength(1);
311
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+3');
312
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
313
- act(function () {
314
- resizeObserver.resize(container);
311
+ it('should calculate max items if countFixedItems more than 0', function () { return __awaiter(void 0, void 0, void 0, function () {
312
+ var container;
313
+ return __generator(this, function (_a) {
314
+ switch (_a.label) {
315
+ case 0:
316
+ container = setUp({
317
+ props: { attributeValues: imageAttributeValues, countFixedItems: 1 },
318
+ mdmValues: { mode: Mode.Editing }
319
+ }).container;
320
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
321
+ act(function () {
322
+ resizeObserver.resize();
323
+ });
324
+ expect(screen.getAllByTestId('image')).toHaveLength(3);
325
+ expect(screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
326
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
327
+ act(function () {
328
+ resizeObserver.resize(container);
329
+ });
330
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
331
+ case 1:
332
+ _a.sent();
333
+ expect(screen.getAllByTestId('image')).toHaveLength(1);
334
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
335
+ act(function () {
336
+ resizeObserver.resize(container);
337
+ });
338
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+3'); })];
339
+ case 2:
340
+ _a.sent();
341
+ expect(screen.getAllByTestId('image')).toHaveLength(1);
342
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
343
+ act(function () {
344
+ resizeObserver.resize(container);
345
+ });
346
+ return [4 /*yield*/, waitFor(function () { return expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
347
+ case 3:
348
+ _a.sent();
349
+ expect(screen.getAllByTestId('image')).toHaveLength(1);
350
+ return [2 /*return*/];
351
+ }
315
352
  });
316
- expect(screen.getAllByTestId('image')).toHaveLength(1);
317
- expect(screen.getByTestId('more-image-button')).toHaveTextContent('+2');
318
- });
353
+ }); });
319
354
  });
@@ -38,7 +38,7 @@ var ReltioGridLayout = function (_a) {
38
38
  };
39
39
  var onToggleFullscreen = useCallback(function (id) { return setFullscreenItemId(function (prevId) { return (prevId ? null : id); }); }, []);
40
40
  var isFullscreenEnabled = fullscreenItemId !== null;
41
- var getAutosizeComponent = function (layoutItemId) { return (React.createElement(ReactResizeDetector, { handleHeight: true, onResize: function (_, height) {
41
+ var getAutosizeComponent = function (layoutItemId) { return (React.createElement(ReactResizeDetector, { handleHeight: true, handleWidth: false, refreshMode: "debounce", refreshRate: 50, onResize: function (_, height) {
42
42
  if (height) {
43
43
  var newHeight = calcHeight(height, layoutOptions);
44
44
  if (newHeight !== heightsMap.current[layoutItemId]) {
@@ -64,7 +64,7 @@ var ReltioGridLayout = function (_a) {
64
64
  }
65
65
  }, [processedLayout, isStatic]);
66
66
  return (React.createElement(React.Fragment, null,
67
- React.createElement(ReactResizeDetector, { refreshMode: "debounce", refreshRate: 50, handleWidth: true, onResize: function (width) { return width > 0 && setWidth(width); } }),
67
+ React.createElement(ReactResizeDetector, { refreshMode: "debounce", refreshRate: 50, handleWidth: true, handleHeight: false, onResize: function (width) { return width > 0 && setWidth(width); } }),
68
68
  !!width && (React.createElement(GridLayout, { innerRef: ref, layout: processedLayout, cols: cols, draggableHandle: draggableHandle, autoSize: true, rowHeight: rowHeight, width: width, margin: margin, onLayoutChange: isStatic ? undefined : onReltioLayoutChanged, isResizable: !isStatic && !isFullscreenEnabled, isDraggable: !isStatic && !isFullscreenEnabled, className: classnames(classes === null || classes === void 0 ? void 0 : classes.root, styles.gridLayout, (_b = {},
69
69
  _b[styles.gridFullscreen] = isFullscreenEnabled,
70
70
  _b)), onDrop: handleDrop, onDropDragOver: onDropDragOver, droppingItem: droppingItem, isDroppable: !isStatic && isDroppable, onResizeStart: function (_, layoutItem) { return setResizingItemId(layoutItem.i); }, onResizeStop: function () { return setResizingItemId(null); }, onResize: onResize, "data-reltio-id": "reltio-grid-layout" }, processedLayout.map(function (layoutItem) {
@@ -66,7 +66,7 @@ var ImageAttributesLine = function (_a) {
66
66
  }
67
67
  }, [paging, requestNextPageOfAttributeValues, attributeType, parentUri, attributeValues.length, showNonOv]);
68
68
  var lastWidth = (0, react_1.useRef)();
69
- var _f = (0, react_1.useState)(0), maxItems = _f[0], setMaxItems = _f[1];
69
+ var _f = (0, react_1.useState)(attributeValues.length), maxItems = _f[0], setMaxItems = _f[1];
70
70
  var _g = (0, react_1.useState)(0), hiddenItemsLength = _g[0], setHiddenItemsLength = _g[1];
71
71
  var isBlockImageGalleryDialog = (0, react_1.useContext)(BlockImageGalleryDialogContext_1.BlockImageGalleryDialogContext);
72
72
  var _h = (0, react_1.useState)(false), isOpenDialog = _h[0], setIsOpenDialog = _h[1];
@@ -130,7 +130,7 @@ var ImageAttributesLine = function (_a) {
130
130
  onSetAsDefault: handleSetAsDefault
131
131
  }));
132
132
  return (react_1.default.createElement(react_1.default.Fragment, null,
133
- react_1.default.createElement(react_resize_detector_1.default, { handleWidth: true, onResize: handleResize }),
133
+ react_1.default.createElement(react_resize_detector_1.default, { handleWidth: true, handleHeight: false, onResize: handleResize, refreshMode: "debounce", refreshRate: 50 }),
134
134
  react_1.default.createElement(ImageAttributesGallery_1.ImageAttributesGallery, { attributeValues: attributeValues, open: isOpenDialog, onClose: handleCloseImageGalleryDialog, setCurrentAttributeValueUri: setCurrentAttributeValueUri, currentAttributeValueUri: currentAttributeValueUri, attributeType: attributeType, onDownload: handleDownload, onShareLink: handleShareLink, onSetAsDefault: handleSetAsDefault, onUpload: onUpload, onDeleteAttribute: onDeleteAttribute }),
135
135
  react_1.default.createElement("div", { className: styles.imageBox },
136
136
  children,
@@ -104,49 +104,71 @@ describe('ImageAttributesLine tests', function () {
104
104
  helpers_1.downloadImagesByURLs.mockReturnValue(undefined);
105
105
  mdm_sdk_1.insertDefaultImageByAttrUri.mockResolvedValue({ status: 'success' });
106
106
  });
107
- it('should resize component', function () {
108
- var container = setUp({ props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues } }).container;
109
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
110
- (0, react_2.act)(function () {
111
- resizeObserver.resize();
112
- });
113
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
114
- expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
115
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
116
- (0, react_2.act)(function () {
117
- resizeObserver.resize(container);
118
- });
119
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
120
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1');
121
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
122
- (0, react_2.act)(function () {
123
- resizeObserver.resize(container);
124
- });
125
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
126
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2');
127
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
128
- (0, react_2.act)(function () {
129
- resizeObserver.resize(container);
107
+ it('should resize component', function () { return __awaiter(void 0, void 0, void 0, function () {
108
+ var container;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ container = setUp({ props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues } }).container;
113
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
114
+ (0, react_2.act)(function () {
115
+ resizeObserver.resize();
116
+ });
117
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
118
+ expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
119
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
120
+ (0, react_2.act)(function () {
121
+ resizeObserver.resize(container);
122
+ });
123
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
124
+ case 1:
125
+ _a.sent();
126
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
127
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
128
+ (0, react_2.act)(function () {
129
+ resizeObserver.resize(container);
130
+ });
131
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
132
+ case 2:
133
+ _a.sent();
134
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
135
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
136
+ (0, react_2.act)(function () {
137
+ resizeObserver.resize(container);
138
+ });
139
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
140
+ case 3:
141
+ _a.sent();
142
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
143
+ return [2 /*return*/];
144
+ }
130
145
  });
131
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(2);
132
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1');
133
- });
134
- it('should recalculate max items to screen width after attributeValues.length changing', function () {
135
- var _a = setUp({ props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues } }), container = _a.container, rerender = _a.rerender;
136
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
137
- (0, react_2.act)(function () {
138
- resizeObserver.resize();
146
+ }); });
147
+ it('should recalculate max items to screen width after attributeValues.length changing', function () { return __awaiter(void 0, void 0, void 0, function () {
148
+ var _a, container, rerender, newAttributeValues;
149
+ return __generator(this, function (_b) {
150
+ switch (_b.label) {
151
+ case 0:
152
+ _a = setUp({ props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues } }), container = _a.container, rerender = _a.rerender;
153
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
154
+ (0, react_2.act)(function () {
155
+ resizeObserver.resize();
156
+ });
157
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
158
+ expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
159
+ rerender(react_1.default.createElement(ImageAttributesLine_1.ImageAttributesLine, __assign({}, defaultProps, { attributeValues: [imageAttributeValues_test_data_1.imageAttributeValues[0]] })));
160
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
161
+ expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
162
+ newAttributeValues = Array.from({ length: 6 }, function (_, i) { return (__assign(__assign({}, imageAttributeValues_test_data_1.imageAttributeValues[0]), { uri: imageAttributeValues_test_data_1.imageAttributeValues[0].uri + i })); });
163
+ rerender(react_1.default.createElement(ImageAttributesLine_1.ImageAttributesLine, __assign({}, defaultProps, { attributeValues: newAttributeValues })));
164
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1'); })];
165
+ case 1:
166
+ _b.sent();
167
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(5);
168
+ return [2 /*return*/];
169
+ }
139
170
  });
140
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
141
- expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
142
- rerender(react_1.default.createElement(ImageAttributesLine_1.ImageAttributesLine, __assign({}, defaultProps, { attributeValues: [imageAttributeValues_test_data_1.imageAttributeValues[0]] })));
143
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
144
- expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
145
- var newAttributeValues = Array.from({ length: 6 }, function (_, i) { return (__assign(__assign({}, imageAttributeValues_test_data_1.imageAttributeValues[0]), { uri: imageAttributeValues_test_data_1.imageAttributeValues[0].uri + i })); });
146
- rerender(react_1.default.createElement(ImageAttributesLine_1.ImageAttributesLine, __assign({}, defaultProps, { attributeValues: newAttributeValues })));
147
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(5);
148
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+1');
149
- });
171
+ }); });
150
172
  it('should open ImageAttributesGallery when click to image or button if BlockImageGalleryDialogContext context has falsy value', function () { return __awaiter(void 0, void 0, void 0, function () {
151
173
  var _a, container, user;
152
174
  return __generator(this, function (_b) {
@@ -291,34 +313,47 @@ describe('ImageAttributesLine tests', function () {
291
313
  });
292
314
  });
293
315
  });
294
- it('should calculate max items if countFixedItems more than 0', function () {
295
- var container = setUp({
296
- props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues, countFixedItems: 1 },
297
- mdmValues: { mode: mdm_sdk_1.Mode.Editing }
298
- }).container;
299
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
300
- (0, react_2.act)(function () {
301
- resizeObserver.resize();
302
- });
303
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
304
- expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
305
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
306
- (0, react_2.act)(function () {
307
- resizeObserver.resize(container);
308
- });
309
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
310
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2');
311
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
312
- (0, react_2.act)(function () {
313
- resizeObserver.resize(container);
314
- });
315
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
316
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+3');
317
- resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
318
- (0, react_2.act)(function () {
319
- resizeObserver.resize(container);
316
+ it('should calculate max items if countFixedItems more than 0', function () { return __awaiter(void 0, void 0, void 0, function () {
317
+ var container;
318
+ return __generator(this, function (_a) {
319
+ switch (_a.label) {
320
+ case 0:
321
+ container = setUp({
322
+ props: { attributeValues: imageAttributeValues_test_data_1.imageAttributeValues, countFixedItems: 1 },
323
+ mdmValues: { mode: mdm_sdk_1.Mode.Editing }
324
+ }).container;
325
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 600 } });
326
+ (0, react_2.act)(function () {
327
+ resizeObserver.resize();
328
+ });
329
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(3);
330
+ expect(react_2.screen.queryByTestId('more-image-button')).not.toBeInTheDocument();
331
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 300 } });
332
+ (0, react_2.act)(function () {
333
+ resizeObserver.resize(container);
334
+ });
335
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
336
+ case 1:
337
+ _a.sent();
338
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
339
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 239 } });
340
+ (0, react_2.act)(function () {
341
+ resizeObserver.resize(container);
342
+ });
343
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+3'); })];
344
+ case 2:
345
+ _a.sent();
346
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
347
+ resizeObserver.mockElementSize(container, { contentBoxSize: { inlineSize: 240 } });
348
+ (0, react_2.act)(function () {
349
+ resizeObserver.resize(container);
350
+ });
351
+ return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2'); })];
352
+ case 3:
353
+ _a.sent();
354
+ expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
355
+ return [2 /*return*/];
356
+ }
320
357
  });
321
- expect(react_2.screen.getAllByTestId('image')).toHaveLength(1);
322
- expect(react_2.screen.getByTestId('more-image-button')).toHaveTextContent('+2');
323
- });
358
+ }); });
324
359
  });
@@ -66,7 +66,7 @@ var ReltioGridLayout = function (_a) {
66
66
  };
67
67
  var onToggleFullscreen = (0, react_1.useCallback)(function (id) { return setFullscreenItemId(function (prevId) { return (prevId ? null : id); }); }, []);
68
68
  var isFullscreenEnabled = fullscreenItemId !== null;
69
- var getAutosizeComponent = function (layoutItemId) { return (react_1.default.createElement(react_resize_detector_1.default, { handleHeight: true, onResize: function (_, height) {
69
+ var getAutosizeComponent = function (layoutItemId) { return (react_1.default.createElement(react_resize_detector_1.default, { handleHeight: true, handleWidth: false, refreshMode: "debounce", refreshRate: 50, onResize: function (_, height) {
70
70
  if (height) {
71
71
  var newHeight = (0, helpers_1.calcHeight)(height, layoutOptions);
72
72
  if (newHeight !== heightsMap.current[layoutItemId]) {
@@ -92,7 +92,7 @@ var ReltioGridLayout = function (_a) {
92
92
  }
93
93
  }, [processedLayout, isStatic]);
94
94
  return (react_1.default.createElement(react_1.default.Fragment, null,
95
- react_1.default.createElement(react_resize_detector_1.default, { refreshMode: "debounce", refreshRate: 50, handleWidth: true, onResize: function (width) { return width > 0 && setWidth(width); } }),
95
+ react_1.default.createElement(react_resize_detector_1.default, { refreshMode: "debounce", refreshRate: 50, handleWidth: true, handleHeight: false, onResize: function (width) { return width > 0 && setWidth(width); } }),
96
96
  !!width && (react_1.default.createElement(react_grid_layout_1.default, { innerRef: ref, layout: processedLayout, cols: cols, draggableHandle: draggableHandle, autoSize: true, rowHeight: rowHeight, width: width, margin: margin, onLayoutChange: isStatic ? undefined : onReltioLayoutChanged, isResizable: !isStatic && !isFullscreenEnabled, isDraggable: !isStatic && !isFullscreenEnabled, className: (0, classnames_1.default)(classes === null || classes === void 0 ? void 0 : classes.root, styles.gridLayout, (_b = {},
97
97
  _b[styles.gridFullscreen] = isFullscreenEnabled,
98
98
  _b)), onDrop: handleDrop, onDropDragOver: onDropDragOver, droppingItem: droppingItem, isDroppable: !isStatic && isDroppable, onResizeStart: function (_, layoutItem) { return setResizingItemId(layoutItem.i); }, onResizeStop: function () { return setResizingItemId(null); }, onResize: onResize, "data-reltio-id": "reltio-grid-layout" }, processedLayout.map(function (layoutItem) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.2083",
3
+ "version": "1.4.2084",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",