@royaloperahouse/chord 0.7.31 → 0.7.34

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.34]
4
+ - Tabs: Left-align last dropdown menu in the navigation bar
5
+
6
+ ## [0.7.33]
7
+ - Livechat: add Talkdesk Livechat injection component
8
+
9
+ ## [0.7.32]
10
+ - Carousels: extend character limit for description
11
+
3
12
  ## [0.7.31]
4
13
  - Card: add image alt text as a prop
5
14
 
@@ -3554,7 +3554,7 @@ var NavTop = function NavTop(_ref) {
3554
3554
 
3555
3555
  var _templateObject$s, _templateObject2$c, _templateObject3$6, _templateObject4$3;
3556
3556
  var TabsContainer = /*#__PURE__*/styled__default.div(_templateObject$s || (_templateObject$s = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: row;\n column-gap: 32px;\n"])));
3557
- var ItemsContainer = /*#__PURE__*/styled__default.div(_templateObject2$c || (_templateObject2$c = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: row;\n column-gap: 32px;\n\n @media ", " {\n column-gap: 15px;\n }\n\n @media ", " {\n ", "\n }\n"])), devices.desktop, devices.mobileAndTablet, function (props) {
3557
+ var ItemsContainer = /*#__PURE__*/styled__default.div(_templateObject2$c || (_templateObject2$c = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: inline-flex;\n flex-direction: row;\n column-gap: 32px;\n\n @media ", ", ", " {\n column-gap: 15px;\n\n div:last-child > div {\n right: 1px;\n }\n }\n\n @media ", " {\n ", "\n }\n"])), devices.desktop, devices.largeDesktop, devices.mobileAndTablet, function (props) {
3558
3558
  if (props.showMenu) {
3559
3559
  return "\n display: flex;\n flex-direction: column;\n row-gap: 32px;\n ";
3560
3560
  }
@@ -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"])));
@@ -4878,6 +4966,7 @@ var Card = function Card(_ref) {
4878
4966
  hovered = _useState[0],
4879
4967
  setHovered = _useState[1];
4880
4968
 
4969
+ var truncatedText = truncateHtmlString(text, 185, true);
4881
4970
  var primaryButton = links == null ? void 0 : links[0];
4882
4971
 
4883
4972
  var _ref2 = primaryButton || {},
@@ -4942,7 +5031,7 @@ var Card = function Card(_ref) {
4942
5031
  level: 6
4943
5032
  }, title)), subtitle ? /*#__PURE__*/React__default.createElement(SubtitleContainer, null, subtitle) : null, /*#__PURE__*/React__default.createElement(TextContainer, {
4944
5033
  dangerouslySetInnerHTML: {
4945
- __html: truncate(text, 130)
5034
+ __html: truncatedText
4946
5035
  }
4947
5036
  })), links ? /*#__PURE__*/React__default.createElement(ButtonsContainer$1, {
4948
5037
  ref: node,
@@ -6493,6 +6582,7 @@ exports.HighlightsCarouselStream = HighlightsStream;
6493
6582
  exports.Icon = Icon;
6494
6583
  exports.ImageAspectRatioWrapper = ImageAspectRatioWrapper;
6495
6584
  exports.ImageWithCaption = ImageWithCaption;
6585
+ exports.LiveChat = LiveChat;
6496
6586
  exports.Navigation = Navigation;
6497
6587
  exports.Overline = Overline;
6498
6588
  exports.PageHeadingCinema = PageHeadingCinema;