@royaloperahouse/chord 0.7.32 → 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,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.7.33]
4
+ - Livechat: add Talkdesk Livechat injection component
5
+
3
6
  ## [0.7.32]
4
7
  - Carousels: extend character limit for description
5
8
 
@@ -4679,6 +4679,52 @@ var TitleWithCTA = function TitleWithCTA(_ref) {
4679
4679
  }, message)));
4680
4680
  };
4681
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
+
4682
4728
  var _templateObject$B, _templateObject2$l, _templateObject3$f, _templateObject4$b, _templateObject5$7;
4683
4729
  var AccordionContainer = /*#__PURE__*/styled__default.div(_templateObject$B || (_templateObject$B = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n"])));
4684
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"])));
@@ -6536,6 +6582,7 @@ exports.HighlightsCarouselStream = HighlightsStream;
6536
6582
  exports.Icon = Icon;
6537
6583
  exports.ImageAspectRatioWrapper = ImageAspectRatioWrapper;
6538
6584
  exports.ImageWithCaption = ImageWithCaption;
6585
+ exports.LiveChat = LiveChat;
6539
6586
  exports.Navigation = Navigation;
6540
6587
  exports.Overline = Overline;
6541
6588
  exports.PageHeadingCinema = PageHeadingCinema;