@royaloperahouse/harmonic 0.12.0-e → 0.12.0-f
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.
- package/dist/harmonic.cjs.development.js +65 -15
- package/dist/harmonic.cjs.development.js.map +1 -1
- package/dist/harmonic.cjs.production.min.js +1 -1
- package/dist/harmonic.cjs.production.min.js.map +1 -1
- package/dist/harmonic.esm.js +65 -15
- package/dist/harmonic.esm.js.map +1 -1
- package/dist/types/image.d.ts +5 -9
- package/package.json +1 -1
package/dist/harmonic.esm.js
CHANGED
|
@@ -3500,6 +3500,11 @@ var RotatorButtons = function RotatorButtons(_ref) {
|
|
|
3500
3500
|
onClickFullscreen();
|
|
3501
3501
|
}
|
|
3502
3502
|
};
|
|
3503
|
+
var onFullscreenKeyDownHandler = function onFullscreenKeyDownHandler(e) {
|
|
3504
|
+
if (e.key === 'Enter') {
|
|
3505
|
+
onClickFullscreenHandler();
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3503
3508
|
var renderPrevIcon = function renderPrevIcon() {
|
|
3504
3509
|
return /*#__PURE__*/React__default.createElement(Icon, {
|
|
3505
3510
|
iconName: "CarouselArrow",
|
|
@@ -3542,6 +3547,7 @@ var RotatorButtons = function RotatorButtons(_ref) {
|
|
|
3542
3547
|
"data-testid": "iconnextnoavailable"
|
|
3543
3548
|
}, renderNextIcon())), showFullscreen && (/*#__PURE__*/React__default.createElement(FullscreenIconWrapper, {
|
|
3544
3549
|
onClick: onClickFullscreenHandler,
|
|
3550
|
+
onKeyDown: onFullscreenKeyDownHandler,
|
|
3545
3551
|
tabIndex: 0,
|
|
3546
3552
|
"data-testid": "iconfullscreen",
|
|
3547
3553
|
className: "carousel-icon-wrapper-fullscreen",
|
|
@@ -11403,7 +11409,7 @@ var SelectComponent$1 = function SelectComponent(_ref) {
|
|
|
11403
11409
|
};
|
|
11404
11410
|
|
|
11405
11411
|
var _templateObject$1h, _templateObject2$_;
|
|
11406
|
-
var Wrapper$8 = /*#__PURE__*/styled.figure(_templateObject$1h || (_templateObject$1h = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n
|
|
11412
|
+
var Wrapper$8 = /*#__PURE__*/styled.figure(_templateObject$1h || (_templateObject$1h = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: column;\n align-items: center;\n margin: 0;\n\n ", " {\n height: calc(100% - 34px);\n @supports not (aspect-ratio: ", ") {\n width: ", ";\n }\n\n @media ", " {\n height: calc(100% - 30px);\n @supports not (aspect-ratio: ", ") {\n width: ", ";\n }\n }\n }\n"])), StyledImageAspectRatioWrapper, function (_ref) {
|
|
11407
11413
|
var _ref$aspectRatio = _ref.aspectRatio,
|
|
11408
11414
|
aspectRatio = _ref$aspectRatio === void 0 ? AspectRatio['1:1'] : _ref$aspectRatio;
|
|
11409
11415
|
return aspectRatio;
|
|
@@ -11422,38 +11428,82 @@ var Wrapper$8 = /*#__PURE__*/styled.figure(_templateObject$1h || (_templateObjec
|
|
|
11422
11428
|
height = _ref4.height;
|
|
11423
11429
|
return "calc(calc(" + height + "px - 30px) * " + AspectRatioWidth[aspectRatio] + ")";
|
|
11424
11430
|
});
|
|
11425
|
-
var CaptionWrapper = /*#__PURE__*/styled(Caption)(_templateObject2$_ || (_templateObject2$_ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 12px;\n height: 22px;\n font-feature-settings: var(--font-feature-settings-body);\n text-transform: var(--text-transform-body);\n word-break: var(--word-break-body);\n
|
|
11431
|
+
var CaptionWrapper = /*#__PURE__*/styled(Caption)(_templateObject2$_ || (_templateObject2$_ = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n && {\n margin-top: 12px;\n max-width: var(--caption-max-width, 100%);\n width: 100%;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n overflow-wrap: normal;\n }\n height: 22px;\n font-feature-settings: var(--font-feature-settings-body);\n text-transform: var(--text-transform-body);\n word-break: var(--word-break-body);\n\n @media ", " {\n height: 18px;\n }\n"])), devices.mobile);
|
|
11426
11432
|
|
|
11427
11433
|
var ImageWithCaption = function ImageWithCaption(_ref) {
|
|
11428
11434
|
var caption = _ref.caption,
|
|
11435
|
+
altText = _ref.altText,
|
|
11429
11436
|
children = _ref.children,
|
|
11430
11437
|
aspectRatio = _ref.aspectRatio;
|
|
11431
11438
|
var wrapperRef = useRef(null);
|
|
11439
|
+
var imgRef = useRef(null);
|
|
11432
11440
|
var _useState = useState(0),
|
|
11433
11441
|
height = _useState[0],
|
|
11434
11442
|
setHeight = _useState[1];
|
|
11443
|
+
var updateWrapperHeight = React__default.useCallback(function () {
|
|
11444
|
+
var _wrapperRef$current;
|
|
11445
|
+
setHeight((wrapperRef == null || (_wrapperRef$current = wrapperRef.current) == null ? void 0 : _wrapperRef$current.offsetHeight) || 0);
|
|
11446
|
+
}, []);
|
|
11447
|
+
var updateCaptionWidth = React__default.useCallback(function () {
|
|
11448
|
+
var img = imgRef.current;
|
|
11449
|
+
var wrapper = wrapperRef.current;
|
|
11450
|
+
if (img && wrapper) {
|
|
11451
|
+
var w = img.getBoundingClientRect().width;
|
|
11452
|
+
wrapper.style.setProperty('--caption-max-width', Math.round(w) + "px");
|
|
11453
|
+
}
|
|
11454
|
+
}, []);
|
|
11435
11455
|
useEffect(function () {
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11456
|
+
updateWrapperHeight();
|
|
11457
|
+
updateCaptionWidth();
|
|
11458
|
+
window.addEventListener('resize', updateWrapperHeight);
|
|
11459
|
+
window.addEventListener('resize', updateCaptionWidth);
|
|
11460
|
+
var imageResizeObserver = null;
|
|
11461
|
+
if (typeof ResizeObserver !== 'undefined' && imgRef.current) {
|
|
11462
|
+
imageResizeObserver = new ResizeObserver(updateCaptionWidth);
|
|
11463
|
+
imageResizeObserver.observe(imgRef.current);
|
|
11464
|
+
}
|
|
11442
11465
|
return function () {
|
|
11443
|
-
|
|
11466
|
+
window.removeEventListener('resize', updateWrapperHeight);
|
|
11467
|
+
window.removeEventListener('resize', updateCaptionWidth);
|
|
11468
|
+
if (imageResizeObserver && imgRef.current) imageResizeObserver.unobserve(imgRef.current);
|
|
11444
11469
|
};
|
|
11445
|
-
}, []);
|
|
11470
|
+
}, [updateWrapperHeight, updateCaptionWidth]);
|
|
11471
|
+
var clonedChildren = React__default.Children.map(children, function (child) {
|
|
11472
|
+
if (! /*#__PURE__*/React__default.isValidElement(child)) return child;
|
|
11473
|
+
var childElement = child;
|
|
11474
|
+
var originalRef = child.ref;
|
|
11475
|
+
var newProps = {
|
|
11476
|
+
alt: altText,
|
|
11477
|
+
tabIndex: 0,
|
|
11478
|
+
onKeyDown: function onKeyDown(e) {
|
|
11479
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
11480
|
+
var _imgRef$current;
|
|
11481
|
+
e.preventDefault();
|
|
11482
|
+
(_imgRef$current = imgRef.current) == null || _imgRef$current.click();
|
|
11483
|
+
}
|
|
11484
|
+
var originalOnKeyDownHandler = childElement.props.onKeyDown;
|
|
11485
|
+
if (originalOnKeyDownHandler) originalOnKeyDownHandler(e);
|
|
11486
|
+
},
|
|
11487
|
+
ref: function ref(node) {
|
|
11488
|
+
imgRef.current = node;
|
|
11489
|
+
if (node) updateCaptionWidth();
|
|
11490
|
+
if (!originalRef) return;
|
|
11491
|
+
if (typeof originalRef === 'function') {
|
|
11492
|
+
originalRef(node);
|
|
11493
|
+
} else {
|
|
11494
|
+
originalRef.current = node;
|
|
11495
|
+
}
|
|
11496
|
+
}
|
|
11497
|
+
};
|
|
11498
|
+
return /*#__PURE__*/React__default.cloneElement(childElement, newProps);
|
|
11499
|
+
});
|
|
11446
11500
|
return /*#__PURE__*/React__default.createElement(Wrapper$8, {
|
|
11447
11501
|
aspectRatio: aspectRatio,
|
|
11448
11502
|
ref: wrapperRef,
|
|
11449
11503
|
height: height
|
|
11450
11504
|
}, /*#__PURE__*/React__default.createElement(ImageAspectRatioWrapper, {
|
|
11451
11505
|
aspectRatio: aspectRatio
|
|
11452
|
-
}, React__default.
|
|
11453
|
-
return /*#__PURE__*/React__default.isValidElement(child) ? /*#__PURE__*/React__default.cloneElement(child, {
|
|
11454
|
-
alt: child.props.alt || 'Visual representation'
|
|
11455
|
-
}) : child;
|
|
11456
|
-
})), caption && /*#__PURE__*/React__default.createElement(CaptionWrapper, {
|
|
11506
|
+
}, clonedChildren), caption && /*#__PURE__*/React__default.createElement(CaptionWrapper, {
|
|
11457
11507
|
tag: "figcaption"
|
|
11458
11508
|
}, caption));
|
|
11459
11509
|
};
|