@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 CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.7.32]
4
+ - Carousels: extend character limit for description
5
+
3
6
  ## [0.7.31]
4
7
  - Card: add image alt text as a prop
5
8
 
@@ -4411,6 +4411,48 @@ var RotatorButtonsWrapper = /*#__PURE__*/styled__default.div(_templateObject9$1
4411
4411
  var RotatorButtonsWrapperMobile = /*#__PURE__*/styled__default.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);
4412
4412
  var HtmlBodyText = /*#__PURE__*/styled__default.p(_templateObject11$1 || (_templateObject11$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0;\n"])));
4413
4413
 
4414
+ var TEXT_STYLE_HTML_TAGS_REGEXP = '<em>|</em>|<b>|</b>';
4415
+
4416
+ var stripAllHtmlTags = function stripAllHtmlTags(htmlString) {
4417
+ return htmlString.replace(/<[^>]*>/g, '');
4418
+ };
4419
+
4420
+ var insertString = function insertString(mainString, str, position) {
4421
+ return "" + mainString.substring(0, position) + str + mainString.substring(position);
4422
+ };
4423
+
4424
+ var insertHtmlTags = function insertHtmlTags(strWithTags, strWithoutTags, resultLength) {
4425
+ var htmlTagPositions = Array.from(strWithTags.matchAll(new RegExp(TEXT_STYLE_HTML_TAGS_REGEXP, 'g')));
4426
+ var tagsLength = 0;
4427
+ var resultString = strWithoutTags;
4428
+ htmlTagPositions.forEach(function (tag) {
4429
+ resultString = insertString(resultString, tag[0], tag.index);
4430
+ if (tag.index - tagsLength <= resultLength) tagsLength += tag[0].length;
4431
+ });
4432
+ return {
4433
+ stringWithInsertedTags: resultString,
4434
+ tagsLength: tagsLength
4435
+ };
4436
+ };
4437
+
4438
+ var truncateHtmlString = function truncateHtmlString(str, resultLength, addDots) {
4439
+ if (addDots === void 0) {
4440
+ addDots = false;
4441
+ }
4442
+
4443
+ var strWithoutTags = stripAllHtmlTags(str);
4444
+ if (strWithoutTags.length <= resultLength) return str;
4445
+
4446
+ var _insertHtmlTags = insertHtmlTags(str, strWithoutTags, resultLength),
4447
+ stringWithInsertedTags = _insertHtmlTags.stringWithInsertedTags,
4448
+ tagsLength = _insertHtmlTags.tagsLength;
4449
+
4450
+ var truncatedString = stringWithInsertedTags.substring(0, resultLength + tagsLength);
4451
+ var isSpaceNext = strWithoutTags[resultLength] === ' ';
4452
+ if (!isSpaceNext) truncatedString = truncatedString.substring(0, truncatedString.lastIndexOf(' '));
4453
+ return addDots ? truncatedString + "..." : truncatedString;
4454
+ };
4455
+
4414
4456
  var _excluded$8 = ["text"];
4415
4457
 
4416
4458
  var HighlightsCarousel = function HighlightsCarousel(_ref) {
@@ -4442,7 +4484,7 @@ var HighlightsCarousel = function HighlightsCarousel(_ref) {
4442
4484
  var linkText = link.text,
4443
4485
  restLink = _objectWithoutPropertiesLoose(link, _excluded$8);
4444
4486
 
4445
- var description = infoText == null ? void 0 : infoText.substring(0, 130);
4487
+ var description = infoText ? truncateHtmlString(infoText, 185, true) : '';
4446
4488
  React.useEffect(function () {
4447
4489
  var slideChangeHandler = function slideChangeHandler(s) {
4448
4490
  return setCurrentSlide(s.realIndex);
@@ -4878,6 +4920,7 @@ var Card = function Card(_ref) {
4878
4920
  hovered = _useState[0],
4879
4921
  setHovered = _useState[1];
4880
4922
 
4923
+ var truncatedText = truncateHtmlString(text, 185, true);
4881
4924
  var primaryButton = links == null ? void 0 : links[0];
4882
4925
 
4883
4926
  var _ref2 = primaryButton || {},
@@ -4942,7 +4985,7 @@ var Card = function Card(_ref) {
4942
4985
  level: 6
4943
4986
  }, title)), subtitle ? /*#__PURE__*/React__default.createElement(SubtitleContainer, null, subtitle) : null, /*#__PURE__*/React__default.createElement(TextContainer, {
4944
4987
  dangerouslySetInnerHTML: {
4945
- __html: truncate(text, 130)
4988
+ __html: truncatedText
4946
4989
  }
4947
4990
  })), links ? /*#__PURE__*/React__default.createElement(ButtonsContainer$1, {
4948
4991
  ref: node,