@royaloperahouse/chord 0.7.31 → 0.7.32
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/CHANGELOG.md +3 -0
- package/dist/chord.cjs.development.js +45 -2
- package/dist/chord.cjs.development.js.map +1 -1
- package/dist/chord.cjs.production.min.js +1 -1
- package/dist/chord.cjs.production.min.js.map +1 -1
- package/dist/chord.esm.js +45 -2
- package/dist/chord.esm.js.map +1 -1
- package/dist/helpers/htmlStrings.d.ts +1 -0
- package/package.json +1 -1
package/dist/chord.esm.js
CHANGED
|
@@ -4413,6 +4413,48 @@ var RotatorButtonsWrapper = /*#__PURE__*/styled.div(_templateObject9$1 || (_temp
|
|
|
4413
4413
|
var RotatorButtonsWrapperMobile = /*#__PURE__*/styled.div(_templateObject10$1 || (_templateObject10$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: none;\n\n @media ", " {\n & {\n display: flex;\n grid-area: 1 / 12 / 2 / 14;\n align-self: center;\n justify-content: flex-end;\n }\n }\n\n @media ", " {\n & {\n display: flex;\n grid-area: 1 / 11 / 2 / 14;\n align-self: center;\n justify-content: flex-end;\n }\n }\n"])), devices.tablet, devices.mobile);
|
|
4414
4414
|
var HtmlBodyText = /*#__PURE__*/styled.p(_templateObject11$1 || (_templateObject11$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n"])));
|
|
4415
4415
|
|
|
4416
|
+
var TEXT_STYLE_HTML_TAGS_REGEXP = '<em>|</em>|<b>|</b>';
|
|
4417
|
+
|
|
4418
|
+
var stripAllHtmlTags = function stripAllHtmlTags(htmlString) {
|
|
4419
|
+
return htmlString.replace(/<[^>]*>/g, '');
|
|
4420
|
+
};
|
|
4421
|
+
|
|
4422
|
+
var insertString = function insertString(mainString, str, position) {
|
|
4423
|
+
return "" + mainString.substring(0, position) + str + mainString.substring(position);
|
|
4424
|
+
};
|
|
4425
|
+
|
|
4426
|
+
var insertHtmlTags = function insertHtmlTags(strWithTags, strWithoutTags, resultLength) {
|
|
4427
|
+
var htmlTagPositions = Array.from(strWithTags.matchAll(new RegExp(TEXT_STYLE_HTML_TAGS_REGEXP, 'g')));
|
|
4428
|
+
var tagsLength = 0;
|
|
4429
|
+
var resultString = strWithoutTags;
|
|
4430
|
+
htmlTagPositions.forEach(function (tag) {
|
|
4431
|
+
resultString = insertString(resultString, tag[0], tag.index);
|
|
4432
|
+
if (tag.index - tagsLength <= resultLength) tagsLength += tag[0].length;
|
|
4433
|
+
});
|
|
4434
|
+
return {
|
|
4435
|
+
stringWithInsertedTags: resultString,
|
|
4436
|
+
tagsLength: tagsLength
|
|
4437
|
+
};
|
|
4438
|
+
};
|
|
4439
|
+
|
|
4440
|
+
var truncateHtmlString = function truncateHtmlString(str, resultLength, addDots) {
|
|
4441
|
+
if (addDots === void 0) {
|
|
4442
|
+
addDots = false;
|
|
4443
|
+
}
|
|
4444
|
+
|
|
4445
|
+
var strWithoutTags = stripAllHtmlTags(str);
|
|
4446
|
+
if (strWithoutTags.length <= resultLength) return str;
|
|
4447
|
+
|
|
4448
|
+
var _insertHtmlTags = insertHtmlTags(str, strWithoutTags, resultLength),
|
|
4449
|
+
stringWithInsertedTags = _insertHtmlTags.stringWithInsertedTags,
|
|
4450
|
+
tagsLength = _insertHtmlTags.tagsLength;
|
|
4451
|
+
|
|
4452
|
+
var truncatedString = stringWithInsertedTags.substring(0, resultLength + tagsLength);
|
|
4453
|
+
var isSpaceNext = strWithoutTags[resultLength] === ' ';
|
|
4454
|
+
if (!isSpaceNext) truncatedString = truncatedString.substring(0, truncatedString.lastIndexOf(' '));
|
|
4455
|
+
return addDots ? truncatedString + "..." : truncatedString;
|
|
4456
|
+
};
|
|
4457
|
+
|
|
4416
4458
|
var _excluded$8 = ["text"];
|
|
4417
4459
|
|
|
4418
4460
|
var HighlightsCarousel = function HighlightsCarousel(_ref) {
|
|
@@ -4444,7 +4486,7 @@ var HighlightsCarousel = function HighlightsCarousel(_ref) {
|
|
|
4444
4486
|
var linkText = link.text,
|
|
4445
4487
|
restLink = _objectWithoutPropertiesLoose(link, _excluded$8);
|
|
4446
4488
|
|
|
4447
|
-
var description = infoText
|
|
4489
|
+
var description = infoText ? truncateHtmlString(infoText, 185, true) : '';
|
|
4448
4490
|
useEffect(function () {
|
|
4449
4491
|
var slideChangeHandler = function slideChangeHandler(s) {
|
|
4450
4492
|
return setCurrentSlide(s.realIndex);
|
|
@@ -4880,6 +4922,7 @@ var Card = function Card(_ref) {
|
|
|
4880
4922
|
hovered = _useState[0],
|
|
4881
4923
|
setHovered = _useState[1];
|
|
4882
4924
|
|
|
4925
|
+
var truncatedText = truncateHtmlString(text, 185, true);
|
|
4883
4926
|
var primaryButton = links == null ? void 0 : links[0];
|
|
4884
4927
|
|
|
4885
4928
|
var _ref2 = primaryButton || {},
|
|
@@ -4944,7 +4987,7 @@ var Card = function Card(_ref) {
|
|
|
4944
4987
|
level: 6
|
|
4945
4988
|
}, title)), subtitle ? /*#__PURE__*/React__default.createElement(SubtitleContainer, null, subtitle) : null, /*#__PURE__*/React__default.createElement(TextContainer, {
|
|
4946
4989
|
dangerouslySetInnerHTML: {
|
|
4947
|
-
__html:
|
|
4990
|
+
__html: truncatedText
|
|
4948
4991
|
}
|
|
4949
4992
|
})), links ? /*#__PURE__*/React__default.createElement(ButtonsContainer$1, {
|
|
4950
4993
|
ref: node,
|