@royaloperahouse/chord 0.7.30 → 0.7.33

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,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.7.33]
4
+ - Livechat: add Talkdesk Livechat injection component
5
+
6
+ ## [0.7.32]
7
+ - Carousels: extend character limit for description
8
+
9
+ ## [0.7.31]
10
+ - Card: add image alt text as a prop
11
+
3
12
  ## [0.7.30]
4
13
  - Navigation: add possibility to pass basket link as prop
5
14
 
@@ -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);
@@ -4637,6 +4679,52 @@ var TitleWithCTA = function TitleWithCTA(_ref) {
4637
4679
  }, message)));
4638
4680
  };
4639
4681
 
4682
+ var SCRIPT_SRC = 'https://talkdeskchatsdk.talkdeskapp.com/talkdeskchatsdk.js?t=';
4683
+ var THEME_COLOR = core.colors.core;
4684
+ var DATA_BIND = '5ea4b1ad-1a17-11ec-af32-06f09e0065e0';
4685
+ var DATA_ORG = '';
4686
+ var DIV_ID = 'tdWebchat';
4687
+ var THEME_ICON = 'https://static.roh.org.uk/images/logo-crest.png';
4688
+ var SCRIPT_CONTENT = "var webchat;\n((window, document, node, props, configs) => {\n if (window.TalkdeskChatSDK) {\n console.error(\"TalkdeskChatSDK already included\");\n return;\n }\n var divContainer = document.createElement(\"div\");\n divContainer.id = node;\n document.body.appendChild(divContainer);\n var currentDate = new Date().getTime();\n var src = \"" + SCRIPT_SRC + "\" + currentDate;\n var script = document.createElement(\"script\");\n var firstScriptTag = document.getElementsByTagName(\"script\")[0];\n script.type = \"text/javascript\";\n script.charset = \"UTF-8\";\n script.id = \"tdwebchatscript\";\n script.src = src;\n script.async = true;\n firstScriptTag.parentNode.insertBefore(script, firstScriptTag);\n script.onload = () => {\n webchat = TalkdeskChatSDK(node, props);\n webchat.init(configs);\n };\n})(\n window,\n document,\n \"" + DIV_ID + "\",\n { flowId: \"cd19d348b5fb4a0ab0d3277686f28d1e\", accountId: \"\", region: \"td-us-1\" },\n { enableEmoji: true, enableUserInput: true, styles :{\n \"chatThemeColor\": \"" + THEME_COLOR + "\",\n \"chatTitleIcon\": \"" + THEME_ICON + "\"\n }}\n);";
4689
+
4690
+ var loadLiveChatScript = function loadLiveChatScript(callback) {
4691
+ var existingScript = document.getElementById(DIV_ID);
4692
+
4693
+ if (!existingScript) {
4694
+ var liveChatDiv = document.createElement('div');
4695
+ liveChatDiv.id = DIV_ID;
4696
+ liveChatDiv.setAttribute('data-bind', DATA_BIND);
4697
+ liveChatDiv.setAttribute('data-org', DATA_ORG);
4698
+ var script = document.createElement('script');
4699
+ var scriptBody = document.createTextNode(SCRIPT_CONTENT);
4700
+ script.appendChild(scriptBody);
4701
+ document.body.appendChild(liveChatDiv);
4702
+ document.body.appendChild(script);
4703
+
4704
+ script.onload = function () {
4705
+ if (callback) callback();
4706
+ };
4707
+ }
4708
+
4709
+ if (existingScript && callback) callback();
4710
+ };
4711
+
4712
+ var LiveChat = function LiveChat() {
4713
+ // eslint-disable-next-line
4714
+ var _React$useState = React.useState(false),
4715
+ loaded = _React$useState[0],
4716
+ setLoaded = _React$useState[1];
4717
+
4718
+ React.useEffect(function () {
4719
+ loadLiveChatScript(function () {
4720
+ setLoaded(true);
4721
+ });
4722
+ });
4723
+ return /*#__PURE__*/React.createElement("span", {
4724
+ "data-loaded": loaded
4725
+ });
4726
+ };
4727
+
4640
4728
  var _templateObject$B, _templateObject2$l, _templateObject3$f, _templateObject4$b, _templateObject5$7;
4641
4729
  var AccordionContainer = /*#__PURE__*/styled__default.div(_templateObject$B || (_templateObject$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n"])));
4642
4730
  var LineContainer = /*#__PURE__*/styled__default.div(_templateObject2$l || (_templateObject2$l = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 2px;\n background-color: var(--base-color-lightgrey);\n width: 100%;\n"])));
@@ -4859,6 +4947,8 @@ var Card = function Card(_ref) {
4859
4947
  _ref$tags = _ref.tags,
4860
4948
  tags = _ref$tags === void 0 ? [] : _ref$tags,
4861
4949
  image = _ref.image,
4950
+ _ref$imageAltText = _ref.imageAltText,
4951
+ imageAltText = _ref$imageAltText === void 0 ? '' : _ref$imageAltText,
4862
4952
  _ref$withContinueWatc = _ref.withContinueWatching,
4863
4953
  withContinueWatching = _ref$withContinueWatc === void 0 ? false : _ref$withContinueWatc,
4864
4954
  _ref$size = _ref.size,
@@ -4876,6 +4966,7 @@ var Card = function Card(_ref) {
4876
4966
  hovered = _useState[0],
4877
4967
  setHovered = _useState[1];
4878
4968
 
4969
+ var truncatedText = truncateHtmlString(text, 185, true);
4879
4970
  var primaryButton = links == null ? void 0 : links[0];
4880
4971
 
4881
4972
  var _ref2 = primaryButton || {},
@@ -4923,7 +5014,7 @@ var Card = function Card(_ref) {
4923
5014
  aspectRatio: exports.AspectRatio['4:3']
4924
5015
  }, /*#__PURE__*/React__default.createElement("img", {
4925
5016
  src: image,
4926
- alt: "test"
5017
+ alt: imageAltText
4927
5018
  })), withContinueWatching && /*#__PURE__*/React__default.createElement(ProgressContainer, null, /*#__PURE__*/React__default.createElement(Progress, {
4928
5019
  progress: progress
4929
5020
  }))), /*#__PURE__*/React__default.createElement(ContentContainer$2, {
@@ -4940,7 +5031,7 @@ var Card = function Card(_ref) {
4940
5031
  level: 6
4941
5032
  }, title)), subtitle ? /*#__PURE__*/React__default.createElement(SubtitleContainer, null, subtitle) : null, /*#__PURE__*/React__default.createElement(TextContainer, {
4942
5033
  dangerouslySetInnerHTML: {
4943
- __html: truncate(text, 130)
5034
+ __html: truncatedText
4944
5035
  }
4945
5036
  })), links ? /*#__PURE__*/React__default.createElement(ButtonsContainer$1, {
4946
5037
  ref: node,
@@ -6491,6 +6582,7 @@ exports.HighlightsCarouselStream = HighlightsStream;
6491
6582
  exports.Icon = Icon;
6492
6583
  exports.ImageAspectRatioWrapper = ImageAspectRatioWrapper;
6493
6584
  exports.ImageWithCaption = ImageWithCaption;
6585
+ exports.LiveChat = LiveChat;
6494
6586
  exports.Navigation = Navigation;
6495
6587
  exports.Overline = Overline;
6496
6588
  exports.PageHeadingCinema = PageHeadingCinema;