@lumx/react 2.1.9 → 2.2.1

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 (68) hide show
  1. package/esm/_internal/Avatar2.js +7 -2
  2. package/esm/_internal/Avatar2.js.map +1 -1
  3. package/esm/_internal/Slider2.js +21 -2
  4. package/esm/_internal/Slider2.js.map +1 -1
  5. package/esm/_internal/Thumbnail2.js +181 -782
  6. package/esm/_internal/Thumbnail2.js.map +1 -1
  7. package/esm/_internal/Tooltip2.js +0 -5
  8. package/esm/_internal/Tooltip2.js.map +1 -1
  9. package/esm/_internal/UserBlock.js +41 -17
  10. package/esm/_internal/UserBlock.js.map +1 -1
  11. package/esm/_internal/avatar.js +0 -3
  12. package/esm/_internal/avatar.js.map +1 -1
  13. package/esm/_internal/comment-block.js +0 -3
  14. package/esm/_internal/comment-block.js.map +1 -1
  15. package/esm/_internal/image-block.js +0 -3
  16. package/esm/_internal/image-block.js.map +1 -1
  17. package/esm/_internal/link-preview.js +0 -3
  18. package/esm/_internal/link-preview.js.map +1 -1
  19. package/esm/_internal/mdi.js +2 -2
  20. package/esm/_internal/mdi.js.map +1 -1
  21. package/esm/_internal/mosaic.js +0 -3
  22. package/esm/_internal/mosaic.js.map +1 -1
  23. package/esm/_internal/post-block.js +0 -3
  24. package/esm/_internal/post-block.js.map +1 -1
  25. package/esm/_internal/slider.js +1 -2
  26. package/esm/_internal/slider.js.map +1 -1
  27. package/esm/_internal/thumbnail.js +1 -4
  28. package/esm/_internal/thumbnail.js.map +1 -1
  29. package/esm/_internal/types.js +1 -0
  30. package/esm/_internal/types.js.map +1 -1
  31. package/esm/_internal/user-block.js +2 -3
  32. package/esm/_internal/user-block.js.map +1 -1
  33. package/esm/index.js +2 -4
  34. package/esm/index.js.map +1 -1
  35. package/package.json +4 -4
  36. package/src/components/avatar/Avatar.stories.tsx +30 -53
  37. package/src/components/avatar/Avatar.tsx +9 -0
  38. package/src/components/avatar/__snapshots__/Avatar.test.tsx.snap +220 -357
  39. package/src/components/image-block/__snapshots__/ImageBlock.test.tsx.snap +1 -1
  40. package/src/components/mosaic/__snapshots__/Mosaic.test.tsx.snap +30 -30
  41. package/src/components/post-block/__snapshots__/PostBlock.test.tsx.snap +1 -1
  42. package/src/components/slideshow/__snapshots__/Slideshow.test.tsx.snap +10 -10
  43. package/src/components/table/__snapshots__/Table.test.tsx.snap +3 -3
  44. package/src/components/thumbnail/Thumbnail.stories.tsx +428 -52
  45. package/src/components/thumbnail/Thumbnail.test.tsx +8 -2
  46. package/src/components/thumbnail/Thumbnail.tsx +84 -47
  47. package/src/components/thumbnail/__snapshots__/Thumbnail.test.tsx.snap +28 -81
  48. package/src/components/thumbnail/index.ts +1 -0
  49. package/src/components/thumbnail/useFocusPointStyle.tsx +89 -0
  50. package/src/components/thumbnail/useImageLoad.ts +24 -23
  51. package/src/components/tooltip/Tooltip.stories.tsx +7 -4
  52. package/src/components/tooltip/useInjectTooltipRef.tsx +1 -3
  53. package/src/components/user-block/UserBlock.stories.tsx +65 -105
  54. package/src/components/user-block/UserBlock.test.tsx +6 -0
  55. package/src/components/user-block/UserBlock.tsx +50 -25
  56. package/src/components/user-block/__snapshots__/UserBlock.test.tsx.snap +113 -144
  57. package/src/stories/generated/Badge/Demos.stories.tsx +1 -0
  58. package/src/stories/generated/Flag/Demos.stories.tsx +6 -0
  59. package/src/stories/generated/List/Demos.stories.tsx +2 -0
  60. package/src/stories/generated/Thumbnail/Demos.stories.tsx +1 -0
  61. package/src/stories/knobs/focusKnob.ts +1 -1
  62. package/src/stories/knobs/image.ts +35 -3
  63. package/src/stories/utils/CustomLink.tsx +7 -0
  64. package/types.d.ts +21 -4
  65. package/esm/_internal/clamp.js +0 -22
  66. package/esm/_internal/clamp.js.map +0 -1
  67. package/src/components/thumbnail/useClickable.ts +0 -26
  68. package/src/components/thumbnail/useFocusPoint.ts +0 -154
@@ -1,773 +1,154 @@
1
- import { d as _slicedToArray, e as _toConsumableArray, _ as _objectSpread2, b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
1
+ import { d as _slicedToArray, b as _objectWithoutProperties, _ as _objectSpread2, c as _extends } from './_rollupPluginBabelHelpers.js';
2
2
  import { AspectRatio, Size, Theme } from './components.js';
3
- import React, { useRef, useEffect, useState, useMemo, useLayoutEffect, useCallback, forwardRef } from 'react';
3
+ import React, { useState, useEffect, useMemo, forwardRef } from 'react';
4
4
  import { g as getRootClassName, c as classnames, h as handleBasicClasses } from './getRootClassName.js';
5
- import { r as mdiImageBrokenVariant } from './mdi.js';
6
- import { W as WINDOW } from './constants.js';
5
+ import { r as mdiImageBroken } from './mdi.js';
7
6
  import { m as mergeRefs } from './mergeRefs.js';
8
7
  import { I as Icon } from './Icon2.js';
9
- import { c as clamp } from './clamp.js';
10
- import { isEqual } from 'lodash';
11
8
 
12
- /**
13
- * Check if browser is IE
14
- * @return Browser is IE or not
15
- */
16
-
17
- var isInternetExplorer = function isInternetExplorer() {
18
- var _WINDOW$navigator;
19
-
20
- var userAgent = WINDOW === null || WINDOW === void 0 ? void 0 : (_WINDOW$navigator = WINDOW.navigator) === null || _WINDOW$navigator === void 0 ? void 0 : _WINDOW$navigator.userAgent;
21
-
22
- if (!userAgent) {
23
- return false;
24
- }
9
+ function getState(img, event) {
10
+ // Error event occurred or image loaded empty.
11
+ if ((event === null || event === void 0 ? void 0 : event.type) === 'error' || (img === null || img === void 0 ? void 0 : img.complete) && ((img === null || img === void 0 ? void 0 : img.naturalWidth) === 0 || (img === null || img === void 0 ? void 0 : img.naturalHeight) === 0)) {
12
+ return 'hasError';
13
+ } // Image is undefined or incomplete.
25
14
 
26
- var msie = userAgent.indexOf('MSIE ');
27
- var isIEVersion = !!userAgent.match(/Trident.*rv:11\./);
28
- return msie > 0 || isIEVersion;
29
- };
30
-
31
- var resizeObservers = [];
32
-
33
- var hasActiveObservations = function () {
34
- return resizeObservers.some(function (ro) { return ro.activeTargets.length > 0; });
35
- };
36
-
37
- var hasSkippedObservations = function () {
38
- return resizeObservers.some(function (ro) { return ro.skippedTargets.length > 0; });
39
- };
40
-
41
- var msg = 'ResizeObserver loop completed with undelivered notifications.';
42
- var deliverResizeLoopError = function () {
43
- var event;
44
- if (typeof ErrorEvent === 'function') {
45
- event = new ErrorEvent('error', {
46
- message: msg
47
- });
48
- }
49
- else {
50
- event = document.createEvent('Event');
51
- event.initEvent('error', false, false);
52
- event.message = msg;
53
- }
54
- window.dispatchEvent(event);
55
- };
56
-
57
- var ResizeObserverBoxOptions;
58
- (function (ResizeObserverBoxOptions) {
59
- ResizeObserverBoxOptions["BORDER_BOX"] = "border-box";
60
- ResizeObserverBoxOptions["CONTENT_BOX"] = "content-box";
61
- ResizeObserverBoxOptions["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
62
- })(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
63
-
64
- var DOMRectReadOnly = (function () {
65
- function DOMRectReadOnly(x, y, width, height) {
66
- this.x = x;
67
- this.y = y;
68
- this.width = width;
69
- this.height = height;
70
- this.top = this.y;
71
- this.left = this.x;
72
- this.bottom = this.top + this.height;
73
- this.right = this.left + this.width;
74
- return Object.freeze(this);
75
- }
76
- DOMRectReadOnly.prototype.toJSON = function () {
77
- var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
78
- return { x: x, y: y, top: top, right: right, bottom: bottom, left: left, width: width, height: height };
79
- };
80
- DOMRectReadOnly.fromRect = function (rectangle) {
81
- return new DOMRectReadOnly(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
82
- };
83
- return DOMRectReadOnly;
84
- }());
85
-
86
- var isSVG = function (target) { return target instanceof SVGElement && 'getBBox' in target; };
87
- var isHidden = function (target) {
88
- if (isSVG(target)) {
89
- var _a = target.getBBox(), width = _a.width, height = _a.height;
90
- return !width && !height;
91
- }
92
- var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
93
- return !(offsetWidth || offsetHeight || target.getClientRects().length);
94
- };
95
- var isElement = function (obj) {
96
- var _a, _b;
97
- var scope = (_b = (_a = obj) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView;
98
- return !!(scope && obj instanceof scope.Element);
99
- };
100
- var isReplacedElement = function (target) {
101
- switch (target.tagName) {
102
- case 'INPUT':
103
- if (target.type !== 'image') {
104
- break;
105
- }
106
- case 'VIDEO':
107
- case 'AUDIO':
108
- case 'EMBED':
109
- case 'OBJECT':
110
- case 'CANVAS':
111
- case 'IFRAME':
112
- case 'IMG':
113
- return true;
114
- }
115
- return false;
116
- };
117
-
118
- var global = typeof window !== 'undefined' ? window : {};
119
-
120
- var cache = new WeakMap();
121
- var scrollRegexp = /auto|scroll/;
122
- var verticalRegexp = /^tb|vertical/;
123
- var IE = (/msie|trident/i).test(global.navigator && global.navigator.userAgent);
124
- var parseDimension = function (pixel) { return parseFloat(pixel || '0'); };
125
- var size = function (inlineSize, blockSize, switchSizes) {
126
- if (inlineSize === void 0) { inlineSize = 0; }
127
- if (blockSize === void 0) { blockSize = 0; }
128
- if (switchSizes === void 0) { switchSizes = false; }
129
- return Object.freeze({
130
- inlineSize: (switchSizes ? blockSize : inlineSize) || 0,
131
- blockSize: (switchSizes ? inlineSize : blockSize) || 0
132
- });
133
- };
134
- var zeroBoxes = Object.freeze({
135
- devicePixelContentBoxSize: size(),
136
- borderBoxSize: size(),
137
- contentBoxSize: size(),
138
- contentRect: new DOMRectReadOnly(0, 0, 0, 0)
139
- });
140
- var calculateBoxSizes = function (target, forceRecalculation) {
141
- if (forceRecalculation === void 0) { forceRecalculation = false; }
142
- if (cache.has(target) && !forceRecalculation) {
143
- return cache.get(target);
144
- }
145
- if (isHidden(target)) {
146
- cache.set(target, zeroBoxes);
147
- return zeroBoxes;
148
- }
149
- var cs = getComputedStyle(target);
150
- var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
151
- var removePadding = !IE && cs.boxSizing === 'border-box';
152
- var switchSizes = verticalRegexp.test(cs.writingMode || '');
153
- var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || '');
154
- var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || '');
155
- var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
156
- var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
157
- var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
158
- var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
159
- var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
160
- var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
161
- var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
162
- var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
163
- var horizontalPadding = paddingLeft + paddingRight;
164
- var verticalPadding = paddingTop + paddingBottom;
165
- var horizontalBorderArea = borderLeft + borderRight;
166
- var verticalBorderArea = borderTop + borderBottom;
167
- var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
168
- var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
169
- var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
170
- var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
171
- var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
172
- var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
173
- var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
174
- var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
175
- var boxes = Object.freeze({
176
- devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
177
- borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
178
- contentBoxSize: size(contentWidth, contentHeight, switchSizes),
179
- contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
180
- });
181
- cache.set(target, boxes);
182
- return boxes;
183
- };
184
- var calculateBoxSize = function (target, observedBox, forceRecalculation) {
185
- var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
186
- switch (observedBox) {
187
- case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
188
- return devicePixelContentBoxSize;
189
- case ResizeObserverBoxOptions.BORDER_BOX:
190
- return borderBoxSize;
191
- default:
192
- return contentBoxSize;
193
- }
194
- };
195
-
196
- var ResizeObserverEntry = (function () {
197
- function ResizeObserverEntry(target) {
198
- var boxes = calculateBoxSizes(target);
199
- this.target = target;
200
- this.contentRect = boxes.contentRect;
201
- this.borderBoxSize = [boxes.borderBoxSize];
202
- this.contentBoxSize = [boxes.contentBoxSize];
203
- this.devicePixelContentBoxSize = [boxes.devicePixelContentBoxSize];
204
- }
205
- return ResizeObserverEntry;
206
- }());
207
-
208
- var calculateDepthForNode = function (node) {
209
- if (isHidden(node)) {
210
- return Infinity;
211
- }
212
- var depth = 0;
213
- var parent = node.parentNode;
214
- while (parent) {
215
- depth += 1;
216
- parent = parent.parentNode;
217
- }
218
- return depth;
219
- };
220
-
221
- var broadcastActiveObservations = function () {
222
- var shallowestDepth = Infinity;
223
- var callbacks = [];
224
- resizeObservers.forEach(function processObserver(ro) {
225
- if (ro.activeTargets.length === 0) {
226
- return;
227
- }
228
- var entries = [];
229
- ro.activeTargets.forEach(function processTarget(ot) {
230
- var entry = new ResizeObserverEntry(ot.target);
231
- var targetDepth = calculateDepthForNode(ot.target);
232
- entries.push(entry);
233
- ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
234
- if (targetDepth < shallowestDepth) {
235
- shallowestDepth = targetDepth;
236
- }
237
- });
238
- callbacks.push(function resizeObserverCallback() {
239
- ro.callback.call(ro.observer, entries, ro.observer);
240
- });
241
- ro.activeTargets.splice(0, ro.activeTargets.length);
242
- });
243
- for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
244
- var callback = callbacks_1[_i];
245
- callback();
246
- }
247
- return shallowestDepth;
248
- };
249
15
 
250
- var gatherActiveObservationsAtDepth = function (depth) {
251
- resizeObservers.forEach(function processObserver(ro) {
252
- ro.activeTargets.splice(0, ro.activeTargets.length);
253
- ro.skippedTargets.splice(0, ro.skippedTargets.length);
254
- ro.observationTargets.forEach(function processTarget(ot) {
255
- if (ot.isActive()) {
256
- if (calculateDepthForNode(ot.target) > depth) {
257
- ro.activeTargets.push(ot);
258
- }
259
- else {
260
- ro.skippedTargets.push(ot);
261
- }
262
- }
263
- });
264
- });
265
- };
16
+ if (!img || !img.complete) {
17
+ return 'isLoading';
18
+ } // Else loaded.
266
19
 
267
- var process = function () {
268
- var depth = 0;
269
- gatherActiveObservationsAtDepth(depth);
270
- while (hasActiveObservations()) {
271
- depth = broadcastActiveObservations();
272
- gatherActiveObservationsAtDepth(depth);
273
- }
274
- if (hasSkippedObservations()) {
275
- deliverResizeLoopError();
276
- }
277
- return depth > 0;
278
- };
279
20
 
280
- var trigger;
281
- var callbacks = [];
282
- var notify = function () { return callbacks.splice(0).forEach(function (cb) { return cb(); }); };
283
- var queueMicroTask = function (callback) {
284
- if (!trigger) {
285
- var toggle_1 = 0;
286
- var el_1 = document.createTextNode('');
287
- var config = { characterData: true };
288
- new MutationObserver(function () { return notify(); }).observe(el_1, config);
289
- trigger = function () { el_1.textContent = "" + (toggle_1 ? toggle_1-- : toggle_1++); };
290
- }
291
- callbacks.push(callback);
292
- trigger();
293
- };
21
+ return 'isLoaded';
22
+ }
294
23
 
295
- var queueResizeObserver = function (cb) {
296
- queueMicroTask(function ResizeObserver() {
297
- requestAnimationFrame(cb);
298
- });
299
- };
24
+ function useImageLoad(imageURL, imgRef) {
25
+ var _useState = useState(getState(imgRef)),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ state = _useState2[0],
28
+ setState = _useState2[1]; // Update state when changing image URL or DOM reference.
300
29
 
301
- var watching = 0;
302
- var isWatching = function () { return !!watching; };
303
- var CATCH_PERIOD = 250;
304
- var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
305
- var events = [
306
- 'resize',
307
- 'load',
308
- 'transitionend',
309
- 'animationend',
310
- 'animationstart',
311
- 'animationiteration',
312
- 'keyup',
313
- 'keydown',
314
- 'mouseup',
315
- 'mousedown',
316
- 'mouseover',
317
- 'mouseout',
318
- 'blur',
319
- 'focus'
320
- ];
321
- var time = function (timeout) {
322
- if (timeout === void 0) { timeout = 0; }
323
- return Date.now() + timeout;
324
- };
325
- var scheduled = false;
326
- var Scheduler = (function () {
327
- function Scheduler() {
328
- var _this = this;
329
- this.stopped = true;
330
- this.listener = function () { return _this.schedule(); };
331
- }
332
- Scheduler.prototype.run = function (timeout) {
333
- var _this = this;
334
- if (timeout === void 0) { timeout = CATCH_PERIOD; }
335
- if (scheduled) {
336
- return;
337
- }
338
- scheduled = true;
339
- var until = time(timeout);
340
- queueResizeObserver(function () {
341
- var elementsHaveResized = false;
342
- try {
343
- elementsHaveResized = process();
344
- }
345
- finally {
346
- scheduled = false;
347
- timeout = until - time();
348
- if (!isWatching()) {
349
- return;
350
- }
351
- if (elementsHaveResized) {
352
- _this.run(1000);
353
- }
354
- else if (timeout > 0) {
355
- _this.run(timeout);
356
- }
357
- else {
358
- _this.start();
359
- }
360
- }
361
- });
362
- };
363
- Scheduler.prototype.schedule = function () {
364
- this.stop();
365
- this.run();
366
- };
367
- Scheduler.prototype.observe = function () {
368
- var _this = this;
369
- var cb = function () { return _this.observer && _this.observer.observe(document.body, observerConfig); };
370
- document.body ? cb() : global.addEventListener('DOMContentLoaded', cb);
371
- };
372
- Scheduler.prototype.start = function () {
373
- var _this = this;
374
- if (this.stopped) {
375
- this.stopped = false;
376
- this.observer = new MutationObserver(this.listener);
377
- this.observe();
378
- events.forEach(function (name) { return global.addEventListener(name, _this.listener, true); });
379
- }
380
- };
381
- Scheduler.prototype.stop = function () {
382
- var _this = this;
383
- if (!this.stopped) {
384
- this.observer && this.observer.disconnect();
385
- events.forEach(function (name) { return global.removeEventListener(name, _this.listener, true); });
386
- this.stopped = true;
387
- }
388
- };
389
- return Scheduler;
390
- }());
391
- var scheduler = new Scheduler();
392
- var updateCount = function (n) {
393
- !watching && n > 0 && scheduler.start();
394
- watching += n;
395
- !watching && scheduler.stop();
396
- };
397
30
 
398
- var skipNotifyOnElement = function (target) {
399
- return !isSVG(target)
400
- && !isReplacedElement(target)
401
- && getComputedStyle(target).display === 'inline';
402
- };
403
- var ResizeObservation = (function () {
404
- function ResizeObservation(target, observedBox) {
405
- this.target = target;
406
- this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
407
- this.lastReportedSize = {
408
- inlineSize: 0,
409
- blockSize: 0
410
- };
411
- }
412
- ResizeObservation.prototype.isActive = function () {
413
- var size = calculateBoxSize(this.target, this.observedBox, true);
414
- if (skipNotifyOnElement(this.target)) {
415
- this.lastReportedSize = size;
416
- }
417
- if (this.lastReportedSize.inlineSize !== size.inlineSize
418
- || this.lastReportedSize.blockSize !== size.blockSize) {
419
- return true;
420
- }
421
- return false;
422
- };
423
- return ResizeObservation;
424
- }());
425
-
426
- var ResizeObserverDetail = (function () {
427
- function ResizeObserverDetail(resizeObserver, callback) {
428
- this.activeTargets = [];
429
- this.skippedTargets = [];
430
- this.observationTargets = [];
431
- this.observer = resizeObserver;
432
- this.callback = callback;
433
- }
434
- return ResizeObserverDetail;
435
- }());
436
-
437
- var observerMap = new WeakMap();
438
- var getObservationIndex = function (observationTargets, target) {
439
- for (var i = 0; i < observationTargets.length; i += 1) {
440
- if (observationTargets[i].target === target) {
441
- return i;
442
- }
443
- }
444
- return -1;
445
- };
446
- var ResizeObserverController = (function () {
447
- function ResizeObserverController() {
448
- }
449
- ResizeObserverController.connect = function (resizeObserver, callback) {
450
- var detail = new ResizeObserverDetail(resizeObserver, callback);
451
- observerMap.set(resizeObserver, detail);
452
- };
453
- ResizeObserverController.observe = function (resizeObserver, target, options) {
454
- var detail = observerMap.get(resizeObserver);
455
- var firstObservation = detail.observationTargets.length === 0;
456
- if (getObservationIndex(detail.observationTargets, target) < 0) {
457
- firstObservation && resizeObservers.push(detail);
458
- detail.observationTargets.push(new ResizeObservation(target, options && options.box));
459
- updateCount(1);
460
- scheduler.schedule();
461
- }
462
- };
463
- ResizeObserverController.unobserve = function (resizeObserver, target) {
464
- var detail = observerMap.get(resizeObserver);
465
- var index = getObservationIndex(detail.observationTargets, target);
466
- var lastObservation = detail.observationTargets.length === 1;
467
- if (index >= 0) {
468
- lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
469
- detail.observationTargets.splice(index, 1);
470
- updateCount(-1);
471
- }
472
- };
473
- ResizeObserverController.disconnect = function (resizeObserver) {
474
- var _this = this;
475
- var detail = observerMap.get(resizeObserver);
476
- detail.observationTargets.slice().forEach(function (ot) { return _this.unobserve(resizeObserver, ot.target); });
477
- detail.activeTargets.splice(0, detail.activeTargets.length);
478
- };
479
- return ResizeObserverController;
480
- }());
481
-
482
- var ResizeObserver = (function () {
483
- function ResizeObserver(callback) {
484
- if (arguments.length === 0) {
485
- throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
486
- }
487
- if (typeof callback !== 'function') {
488
- throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
489
- }
490
- ResizeObserverController.connect(this, callback);
491
- }
492
- ResizeObserver.prototype.observe = function (target, options) {
493
- if (arguments.length === 0) {
494
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
495
- }
496
- if (!isElement(target)) {
497
- throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
498
- }
499
- ResizeObserverController.observe(this, target, options);
500
- };
501
- ResizeObserver.prototype.unobserve = function (target) {
502
- if (arguments.length === 0) {
503
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
504
- }
505
- if (!isElement(target)) {
506
- throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
507
- }
508
- ResizeObserverController.unobserve(this, target);
509
- };
510
- ResizeObserver.prototype.disconnect = function () {
511
- ResizeObserverController.disconnect(this);
512
- };
513
- ResizeObserver.toString = function () {
514
- return 'function ResizeObserver () { [polyfill code] }';
515
- };
516
- return ResizeObserver;
517
- }());
518
-
519
- var _ref;
520
- var ResizeObserver$1 = ((_ref = WINDOW) === null || _ref === void 0 ? void 0 : _ref.ResizeObserver) || ResizeObserver;
521
- function useOnResize(element, update) {
522
- var observerRef = useRef(null);
523
- var previousSize = useRef();
524
31
  useEffect(function () {
525
- if (!element || !update) {
526
- return undefined;
527
- }
528
-
529
- previousSize.current = undefined;
530
- var observer = observerRef.current || new ResizeObserver$1(function (_ref2) {
531
- var _previousSize$current, _previousSize$current2;
532
-
533
- var _ref3 = _slicedToArray(_ref2, 1),
534
- entry = _ref3[0];
32
+ setState(getState(imgRef));
33
+ }, [imageURL, imgRef]); // Listen to `load` and `error` event on image
535
34
 
536
- var updateFunction = update.current;
537
-
538
- if (!updateFunction) {
539
- return;
540
- }
541
-
542
- var _entry$contentRect = entry.contentRect,
543
- width = _entry$contentRect.width,
544
- height = _entry$contentRect.height;
35
+ useEffect(function () {
36
+ var img = imgRef;
37
+ if (!img) return undefined;
545
38
 
546
- if (((_previousSize$current = previousSize.current) === null || _previousSize$current === void 0 ? void 0 : _previousSize$current.width) === width && ((_previousSize$current2 = previousSize.current) === null || _previousSize$current2 === void 0 ? void 0 : _previousSize$current2.height) === height) {
547
- return;
548
- }
39
+ var update = function update(event) {
40
+ return setState(getState(img, event));
41
+ };
549
42
 
550
- window.requestAnimationFrame(function () {
551
- return updateFunction();
552
- });
553
- previousSize.current = entry.contentRect;
554
- });
555
- if (!observerRef.current) observerRef.current = observer;
556
- observer.observe(element);
43
+ img.addEventListener('load', update);
44
+ img.addEventListener('error', update);
557
45
  return function () {
558
- observer.unobserve(element);
46
+ img.removeEventListener('load', update);
47
+ img.removeEventListener('error', update);
559
48
  };
560
- }, [element, update]);
49
+ }, [imgRef, imgRef === null || imgRef === void 0 ? void 0 : imgRef.src]);
50
+ return state;
561
51
  }
562
52
 
563
- var IMG_STYLES = {
564
- bottom: 0,
565
- left: 0,
566
- position: 'absolute',
567
- right: 0,
568
- top: 0,
569
- minHeight: '100%',
570
- minWidth: '100%'
571
- };
572
- var WRAPPER_STYLES = {
573
- overflow: 'hidden',
574
- position: 'relative'
575
- };
576
-
577
- function calculateSizes(imageElement, parentElement, aspectRatio) {
578
- if (!imageElement || !parentElement || !aspectRatio || aspectRatio === AspectRatio.original) return undefined;
579
-
580
- var _ref = imageElement || {
581
- naturalWidth: 0,
582
- naturalHeight: 0
583
- },
584
- imgWidth = _ref.naturalWidth,
585
- imgHeight = _ref.naturalHeight;
586
-
587
- var _ref2 = (parentElement === null || parentElement === void 0 ? void 0 : parentElement.getBoundingClientRect()) || {
588
- width: 0,
589
- height: 0
590
- },
591
- containerWidth = _ref2.width,
592
- containerHeight = _ref2.height;
593
-
594
- return {
595
- imgWidth: imgWidth,
596
- imgHeight: imgHeight,
597
- containerWidth: containerWidth,
598
- containerHeight: containerHeight,
599
- aspectRatio: aspectRatio
600
- };
53
+ // Calculate shift to center the focus point in the container.
54
+ function shiftPosition(scale, focusPoint, imageSize, containerSize) {
55
+ var scaledSize = imageSize / scale;
56
+ var scaledFocusHeight = focusPoint * scaledSize;
57
+ var startFocus = scaledFocusHeight - containerSize / 2;
58
+ var shift = startFocus / (scaledSize - containerSize);
59
+ return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);
601
60
  }
602
61
 
603
- var parseFocusPoint = function parseFocusPoint() {
604
- var point = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
605
- return {
606
- x: point.x ? clamp(point.x, -1, 1) : 0,
607
- y: point.y ? clamp(point.y, -1, 1) : 0
608
- };
609
- };
610
-
611
- function calculateImageShift(containerToImageSizeRatio, containerSize, imageSize, focusSize, toMinus) {
612
- var containerCenter = Math.floor(containerSize / 2); // Container center in px
613
-
614
- var focusFactor = (focusSize + 1) / 2; // Focus point of resize image in px
615
-
616
- var scaledImage = Math.floor(imageSize / containerToImageSizeRatio); // Can't use width() as images may be display:none
617
-
618
- var focus = Math.floor(focusFactor * scaledImage);
619
-
620
- if (toMinus) {
621
- focus = scaledImage - focus;
622
- }
623
-
624
- var focusOffset = focus - containerCenter; // Calculate difference between focus point and center
625
-
626
- var remainder = scaledImage - focus; // Reduce offset if necessary so image remains filled
627
-
628
- var containerRemainder = containerSize - containerCenter;
629
-
630
- if (remainder < containerRemainder) {
631
- focusOffset -= containerRemainder - remainder;
632
- }
633
-
634
- if (focusOffset < 0) {
635
- focusOffset = 0;
636
- }
637
-
638
- return focusOffset * -100 / containerSize;
639
- }
640
-
641
- function calculateImageStyle(sizes, point) {
642
- if (!sizes.imgWidth || !sizes.imgHeight || !sizes.containerWidth || !sizes.containerHeight) {
62
+ // Compute CSS properties to apply the focus point.
63
+ var useFocusPointStyle = function useFocusPointStyle(_ref, element, isLoaded) {
64
+ var image = _ref.image,
65
+ aspectRatio = _ref.aspectRatio,
66
+ focusPoint = _ref.focusPoint,
67
+ _ref$imgProps = _ref.imgProps;
68
+ _ref$imgProps = _ref$imgProps === void 0 ? {} : _ref$imgProps;
69
+ var width = _ref$imgProps.width,
70
+ height = _ref$imgProps.height;
71
+ // Get natural image size from imgProps or img element.
72
+ var imageSize = useMemo(function () {
73
+ // Focus point is not applicable => exit early
74
+ if (!image || aspectRatio === AspectRatio.original || !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) && !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y)) return undefined;
75
+ if (typeof width === 'number' && typeof height === 'number') return {
76
+ width: width,
77
+ height: height
78
+ };
79
+ if (element && isLoaded) return {
80
+ width: element.naturalWidth,
81
+ height: element.naturalHeight
82
+ };
643
83
  return undefined;
644
- } // Which is over by more?
645
-
646
-
647
- var widthRatio = sizes.imgWidth / sizes.containerWidth;
648
- var heightRatio = sizes.imgHeight / sizes.containerHeight;
649
-
650
- var image = _objectSpread2({}, IMG_STYLES); // Minimize image while still filling space
651
-
652
-
653
- if (sizes.imgWidth > sizes.containerWidth && sizes.imgHeight > sizes.containerHeight) {
654
- image[widthRatio > heightRatio ? 'maxHeight' : 'maxWidth'] = '100%';
655
- }
656
-
657
- if (widthRatio > heightRatio) {
658
- image.left = "".concat(calculateImageShift(heightRatio, sizes.containerWidth, sizes.imgWidth, point.x), "%");
659
- } else if (widthRatio < heightRatio) {
660
- image.top = "".concat(calculateImageShift(widthRatio, sizes.containerHeight, sizes.imgHeight, point.y, true), "%");
661
- }
84
+ }, [aspectRatio, element, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y, height, image, isLoaded, width]); // Get container size (dependant on imageSize).
662
85
 
663
- return {
664
- image: image,
665
- wrapper: WRAPPER_STYLES
666
- };
667
- }
668
- /**
669
- * Hook that calculate CSS style to shift the image in it's container according to the focus point.
670
- */
671
-
672
-
673
- var useFocusPoint = function useFocusPoint(options) {
674
- var image = options.image,
675
- aspectRatio = options.aspectRatio,
676
- focusPoint = options.focusPoint,
677
- imgRef = options.imgRef,
678
- loadingState = options.loadingState,
679
- wrapper = options.wrapper;
680
- var point = parseFocusPoint(focusPoint);
681
- var previousPoint = useRef();
682
- var previousSizes = useRef({});
683
-
684
- var _useState = useState(),
86
+ var _useState = useState(undefined),
685
87
  _useState2 = _slicedToArray(_useState, 2),
686
- style = _useState2[0],
687
- setStyle = _useState2[1]; // Update style.
688
-
689
-
690
- var updateRef = useRef(null);
691
- var update = useMemo(function () {
692
- var updateFunction = function updateFunction() {
693
- var sizes = calculateSizes(imgRef === null || imgRef === void 0 ? void 0 : imgRef.current, wrapper, aspectRatio);
694
-
695
- if (!sizes || isEqual(sizes, previousSizes.current) && isEqual(point, previousPoint.current)) {
696
- // Nothing changed.
697
- return;
698
- }
699
-
700
- setStyle(calculateImageStyle(sizes, point));
701
- previousPoint.current = point;
702
- previousSizes.current = sizes;
703
- };
704
-
705
- updateRef.current = updateFunction;
706
- return updateFunction;
707
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
708
- [].concat(_toConsumableArray(Object.values(point)), [imgRef, wrapper, aspectRatio])); // Update on image loaded.
709
-
710
- useLayoutEffect(update, [image, update, loadingState]); // Update on parent resize.
711
-
712
- useOnResize(wrapper, updateRef);
713
- return style;
714
- };
715
-
716
- function useImageLoad(imgRef) {
717
- var _imgRef$current;
88
+ containerSize = _useState2[0],
89
+ setContainerSize = _useState2[1];
90
+
91
+ useEffect(function updateContainerSize() {
92
+ var cWidth = element === null || element === void 0 ? void 0 : element.offsetWidth;
93
+ var cHeight = element === null || element === void 0 ? void 0 : element.offsetHeight;
94
+
95
+ if (cWidth && cHeight) {
96
+ // Update only if needed.
97
+ setContainerSize(function (oldContainerSize) {
98
+ return (oldContainerSize === null || oldContainerSize === void 0 ? void 0 : oldContainerSize.width) === cWidth && oldContainerSize.height === cHeight ? oldContainerSize : {
99
+ width: cWidth,
100
+ height: cHeight
101
+ };
102
+ });
103
+ } else if (imageSize) {
104
+ // Wait for a render (in case the container size is dependent on the image size).
105
+ requestAnimationFrame(updateContainerSize);
106
+ }
107
+ }, [element === null || element === void 0 ? void 0 : element.offsetHeight, element === null || element === void 0 ? void 0 : element.offsetWidth, imageSize]); // Compute style.
718
108
 
719
- var _useState = useState('isLoading'),
720
- _useState2 = _slicedToArray(_useState, 2),
721
- state = _useState2[0],
722
- setState = _useState2[1];
109
+ var _useState3 = useState({}),
110
+ _useState4 = _slicedToArray(_useState3, 2),
111
+ style = _useState4[0],
112
+ setStyle = _useState4[1];
723
113
 
724
- var update = useCallback(function (event) {
725
- var img = imgRef === null || imgRef === void 0 ? void 0 : imgRef.current;
114
+ useEffect(function () {
115
+ // Focus point is not applicable => exit early
116
+ if (!image || aspectRatio === AspectRatio.original || !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) && !(focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y)) {
117
+ return;
118
+ }
726
119
 
727
- if (!img || !img.complete) {
728
- setState('isLoading');
120
+ if (!element || !imageSize) {
121
+ // Focus point can be computed but now right now (image size unknown).
122
+ setStyle({
123
+ visibility: 'hidden'
124
+ });
729
125
  return;
730
126
  }
731
127
 
732
- if ((event === null || event === void 0 ? void 0 : event.type) === 'error' || img.complete && (img === null || img === void 0 ? void 0 : img.naturalWidth) === 0) {
733
- setState('hasError');
128
+ if (!containerSize) {
129
+ // Missing container size abort focus point compute.
130
+ setStyle({});
734
131
  return;
735
132
  }
736
133
 
737
- setState('isLoaded');
738
- }, [imgRef]);
739
- useEffect(function () {
740
- var img = imgRef === null || imgRef === void 0 ? void 0 : imgRef.current;
741
- if (!img) return undefined;
742
- update();
743
- img.addEventListener('load', update);
744
- img.addEventListener('error', update);
745
- return function () {
746
- img.removeEventListener('load', update);
747
- img.removeEventListener('error', update);
748
- };
749
- }, [update, imgRef, imgRef === null || imgRef === void 0 ? void 0 : (_imgRef$current = imgRef.current) === null || _imgRef$current === void 0 ? void 0 : _imgRef$current.src]);
750
- return state;
751
- }
134
+ var heightScale = imageSize.height / containerSize.height;
135
+ var widthScale = imageSize.width / containerSize.width;
136
+ var scale = Math.min(widthScale, heightScale); // Focus Y relative to the top (instead of the center)
752
137
 
753
- var useClickable = function useClickable(_ref) {
754
- var onClick = _ref.onClick,
755
- _onKeyPress = _ref.onKeyPress;
756
- return useMemo(function () {
757
- if (!onClick) return undefined;
758
- return {
759
- role: 'button',
760
- tabIndex: 0,
761
- onClick: onClick,
762
- onKeyPress: function onKeyPress(event) {
763
- _onKeyPress === null || _onKeyPress === void 0 ? void 0 : _onKeyPress(event);
764
-
765
- if (event.key === 'Enter' || event.key === ' ') {
766
- onClick === null || onClick === void 0 ? void 0 : onClick();
767
- }
768
- }
769
- };
770
- }, [onClick, _onKeyPress]);
138
+ var focusPointFromTop = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y) || 0) - 1) / 2;
139
+ var y = shiftPosition(scale, focusPointFromTop, imageSize.height, containerSize.height); // Focus X relative to the left (instead of the center)
140
+
141
+ var focusPointFromLeft = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) || 0) + 1) / 2;
142
+ var x = shiftPosition(scale, focusPointFromLeft, imageSize.width, containerSize.width);
143
+ var objectPosition = "".concat(x, "% ").concat(y, "%"); // Update only if needed.
144
+
145
+ setStyle(function (oldStyle) {
146
+ return oldStyle.objectPosition === objectPosition ? oldStyle : {
147
+ objectPosition: objectPosition
148
+ };
149
+ });
150
+ }, [aspectRatio, containerSize, element, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x, focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y, image, imageSize]);
151
+ return style;
771
152
  };
772
153
 
773
154
  /**
@@ -784,7 +165,7 @@ var CLASSNAME = getRootClassName(COMPONENT_NAME);
784
165
  */
785
166
 
786
167
  var DEFAULT_PROPS = {
787
- fallback: mdiImageBrokenVariant,
168
+ fallback: mdiImageBroken,
788
169
  loading: 'lazy',
789
170
  theme: Theme.light
790
171
  };
@@ -797,11 +178,10 @@ var DEFAULT_PROPS = {
797
178
  */
798
179
 
799
180
  var Thumbnail = forwardRef(function (props, ref) {
800
- var _wrapper$getBoundingC;
801
-
802
181
  var align = props.align,
803
182
  alt = props.alt,
804
- aspectRatio = props.aspectRatio,
183
+ _props$aspectRatio = props.aspectRatio,
184
+ aspectRatio = _props$aspectRatio === void 0 ? AspectRatio.original : _props$aspectRatio,
805
185
  badge = props.badge,
806
186
  className = props.className,
807
187
  crossOrigin = props.crossOrigin,
@@ -811,69 +191,88 @@ var Thumbnail = forwardRef(function (props, ref) {
811
191
  image = props.image,
812
192
  imgProps = props.imgProps,
813
193
  propImgRef = props.imgRef,
194
+ isLoadingProp = props.isLoading,
814
195
  loading = props.loading,
815
196
  size = props.size,
816
197
  theme = props.theme,
817
198
  variant = props.variant,
818
- forwardedProps = _objectWithoutProperties(props, ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "loading", "size", "theme", "variant"]);
819
-
820
- var imgRef = useRef(null); // Image loading state.
821
-
822
- var loadingState = useImageLoad(imgRef);
823
- var hasError = loadingState === 'hasError';
824
- var isLoading = loadingState === 'isLoading';
199
+ linkProps = props.linkProps,
200
+ linkAs = props.linkAs,
201
+ forwardedProps = _objectWithoutProperties(props, ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "loading", "size", "theme", "variant", "linkProps", "linkAs"]);
825
202
 
826
203
  var _useState = useState(),
827
204
  _useState2 = _slicedToArray(_useState, 2),
828
- wrapper = _useState2[0],
829
- setWrapper = _useState2[1];
205
+ imgElement = _useState2[0],
206
+ setImgElement = _useState2[1]; // Image loading state.
207
+
208
+
209
+ var loadingState = useImageLoad(image, imgElement);
210
+ var isLoaded = loadingState === 'isLoaded';
211
+ var isLoading = isLoadingProp || loadingState === 'isLoading';
212
+ var hasError = loadingState === 'hasError'; // Focus point.
213
+
214
+ var focusPointStyle = useFocusPointStyle(props, imgElement, isLoaded);
215
+ var hasIconErrorFallback = hasError && typeof fallback === 'string';
216
+ var hasCustomErrorFallback = hasError && !hasIconErrorFallback;
217
+ var imageErrorStyle = {};
218
+
219
+ if (hasIconErrorFallback) {
220
+ // Keep the image layout on icon fallback.
221
+ imageErrorStyle.visibility = 'hidden';
222
+ } else if (hasCustomErrorFallback) {
223
+ // Remove the image on custom fallback.
224
+ imageErrorStyle.display = 'none';
225
+ }
226
+
227
+ var isLink = Boolean((linkProps === null || linkProps === void 0 ? void 0 : linkProps.href) || linkAs);
228
+ var isButton = !!forwardedProps.onClick;
229
+ var isClickable = isButton || isLink;
230
+ var Wrapper = 'div';
830
231
 
831
- var wrapperProps = _objectSpread2({}, forwardedProps, {
832
- ref: mergeRefs(setWrapper, ref),
833
- className: classnames(className, handleBasicClasses({
232
+ var wrapperProps = _objectSpread2({}, forwardedProps);
233
+
234
+ if (isLink) {
235
+ Wrapper = linkAs || 'a';
236
+ Object.assign(wrapperProps, linkProps);
237
+ } else if (isButton) {
238
+ Wrapper = 'button';
239
+ wrapperProps.type = forwardedProps.type || 'button';
240
+ wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
241
+ }
242
+
243
+ return React.createElement(Wrapper, _extends({}, wrapperProps, {
244
+ ref: ref,
245
+ className: classnames(linkProps === null || linkProps === void 0 ? void 0 : linkProps.className, className, handleBasicClasses({
834
246
  align: align,
835
247
  aspectRatio: aspectRatio,
836
248
  prefix: CLASSNAME,
837
249
  size: size,
838
250
  theme: theme,
839
251
  variant: variant,
252
+ isClickable: isClickable,
253
+ hasError: hasError,
254
+ hasIconErrorFallback: hasIconErrorFallback,
255
+ hasCustomErrorFallback: hasCustomErrorFallback,
256
+ isLoading: isLoading,
840
257
  hasBadge: !!badge
841
- }), isLoading && (wrapper === null || wrapper === void 0 ? void 0 : (_wrapper$getBoundingC = wrapper.getBoundingClientRect()) === null || _wrapper$getBoundingC === void 0 ? void 0 : _wrapper$getBoundingC.height) && 'lumx-color-background-dark-L6', fillHeight && "".concat(CLASSNAME, "--fill-height"))
842
- }, useClickable(props)); // Update img style according to focus point and aspect ratio.
843
-
844
-
845
- var style = useFocusPoint({
846
- image: image,
847
- focusPoint: focusPoint,
848
- aspectRatio: aspectRatio,
849
- imgRef: imgRef,
850
- loadingState: loadingState,
851
- wrapper: wrapper
852
- });
853
- return React.createElement("div", wrapperProps, React.createElement("div", {
854
- className: "".concat(CLASSNAME, "__background"),
855
- style: _objectSpread2({}, style === null || style === void 0 ? void 0 : style.wrapper, {
856
- // Remove from layout if image not loaded correctly (use fallback)
857
- display: hasError ? 'none' : undefined,
858
- // Hide while loading.
859
- visibility: isLoading ? 'hidden' : undefined
860
- })
258
+ }), fillHeight && "".concat(CLASSNAME, "--fill-height"))
259
+ }), React.createElement("div", {
260
+ className: "".concat(CLASSNAME, "__background")
861
261
  }, React.createElement("img", _extends({}, imgProps, {
862
- style: _objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style, {}, style === null || style === void 0 ? void 0 : style.image),
863
- ref: mergeRefs(imgRef, propImgRef),
864
- className: (style === null || style === void 0 ? void 0 : style.image) ? "".concat(CLASSNAME, "__focused-image") : "".concat(CLASSNAME, "__image"),
865
- crossOrigin: crossOrigin && !isInternetExplorer() ? crossOrigin : undefined,
262
+ style: _objectSpread2({}, imgProps === null || imgProps === void 0 ? void 0 : imgProps.style, {}, imageErrorStyle, {}, focusPointStyle),
263
+ ref: mergeRefs(setImgElement, propImgRef),
264
+ className: classnames("".concat(CLASSNAME, "__image"), isLoading && "".concat(CLASSNAME, "__image--is-loading")),
265
+ crossOrigin: crossOrigin,
866
266
  src: image,
867
267
  alt: alt,
868
268
  loading: loading
869
- }))), hasError && (typeof fallback === 'string' ? React.createElement(Icon, {
870
- className: "".concat(CLASSNAME, "__fallback"),
269
+ })), !isLoading && hasError && React.createElement("div", {
270
+ className: "".concat(CLASSNAME, "__fallback")
271
+ }, hasIconErrorFallback ? React.createElement(Icon, {
871
272
  icon: fallback,
872
- size: size || Size.m,
273
+ size: Size.xxs,
873
274
  theme: theme
874
- }) : React.createElement("div", {
875
- className: "".concat(CLASSNAME, "__fallback")
876
- }, fallback)), badge && React.cloneElement(badge, {
275
+ }) : fallback)), badge && React.cloneElement(badge, {
877
276
  className: classnames("".concat(CLASSNAME, "__badge"), badge.props.className)
878
277
  }));
879
278
  });
@@ -881,5 +280,5 @@ Thumbnail.displayName = COMPONENT_NAME;
881
280
  Thumbnail.className = CLASSNAME;
882
281
  Thumbnail.defaultProps = DEFAULT_PROPS;
883
282
 
884
- export { Thumbnail as T };
283
+ export { Thumbnail as T, useFocusPointStyle as u };
885
284
  //# sourceMappingURL=Thumbnail2.js.map