@times-components/article-comments 0.43.28-alpha.37 → 0.43.28

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
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.43.28](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.43.27...@times-components/article-comments@0.43.28) (2024-08-08)
7
+
8
+ **Note:** Version bump only for package @times-components/article-comments
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.43.27](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.43.26...@times-components/article-comments@0.43.27) (2024-07-15)
7
15
 
8
16
  **Note:** Version bump only for package @times-components/article-comments
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _react = _interopRequireWildcard(require("react"));
8
+ var _react = _interopRequireDefault(require("react"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
@@ -17,32 +17,9 @@ var _disabledComments = _interopRequireDefault(require("./disabled-comments"));
17
17
 
18
18
  var _joinTheConversationDialog = _interopRequireDefault(require("./join-the-conversation-dialog"));
19
19
 
20
- var _userEntitlementProvider = _interopRequireDefault(require("./user-entitlement-provider"));
21
-
22
- var _userEntitlements = require("./user-entitlements");
23
-
24
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
21
 
26
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
-
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
-
30
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
31
-
32
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
33
-
34
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
-
36
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
37
-
38
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
39
-
40
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
41
-
42
- function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
43
-
44
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
-
22
+ /* eslint-env browser */
46
23
  const ArticleComments = _ref => {
47
24
  let articleId = _ref.articleId,
48
25
  isEnabled = _ref.isEnabled,
@@ -50,57 +27,19 @@ const ArticleComments = _ref => {
50
27
  commentingConfig = _ref.commentingConfig,
51
28
  isCommentEnabled = _ref.isCommentEnabled,
52
29
  storefrontConfig = _ref.storefrontConfig,
53
- domainSpecificUrl = _ref.domainSpecificUrl,
54
- isEntitlementFeatureEnabled = _ref.isEntitlementFeatureEnabled;
55
-
56
- const _useState = (0, _react.useState)(undefined),
57
- _useState2 = _slicedToArray(_useState, 2),
58
- userEntitlements = _useState2[0],
59
- setUserEntitlements = _useState2[1];
60
-
61
- console.log('ArticleComments -> isEntitlementFeatureEnabled', isEntitlementFeatureEnabled);
62
- (0, _react.useEffect)(() => {
63
- const fetchUserEntitlements = /*#__PURE__*/function () {
64
- var _ref2 = _asyncToGenerator(function* () {
65
- const response = yield fetch("/api/get-user-entitlements");
66
- const data = yield response.json();
67
- setUserEntitlements(data);
68
- });
69
-
70
- return function fetchUserEntitlements() {
71
- return _ref2.apply(this, arguments);
72
- };
73
- }();
74
-
75
- if (typeof window !== undefined) {
76
- fetchUserEntitlements();
77
- }
78
- }, []);
79
- return (
80
- /*#__PURE__*/
81
- // isEnabled && isCommentEnabled ? (
82
- _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_userState.default, {
83
- state: _userState.default.showJoinTheConversationDialog
84
- }, /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default, {
85
- storefrontConfig: storefrontConfig
86
- })), !isEntitlementFeatureEnabled ? /*#__PURE__*/_react.default.createElement(_userState.default, {
87
- state: _userState.default.showCommentingModule
88
- }, /*#__PURE__*/_react.default.createElement("p", null, "inside UserState provider"), /*#__PURE__*/_react.default.createElement(_comments.default, {
89
- articleId: articleId,
90
- isReadOnly: isReadOnly,
91
- commentingConfig: commentingConfig,
92
- domainSpecificUrl: domainSpecificUrl
93
- })) : /*#__PURE__*/_react.default.createElement(_userEntitlements.UserEntitlements, {
94
- userEntitlementsList: userEntitlements
95
- }, /*#__PURE__*/_react.default.createElement("p", null, "inside UserEntitlements"), /*#__PURE__*/_react.default.createElement(_comments.default, {
96
- articleId: articleId,
97
- isReadOnly: isReadOnly,
98
- commentingConfig: commentingConfig,
99
- domainSpecificUrl: domainSpecificUrl
100
- })))
101
- ); // : (
102
- // <DisabledComments />
103
- // );
30
+ domainSpecificUrl = _ref.domainSpecificUrl;
31
+ return isEnabled && isCommentEnabled ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_userState.default, {
32
+ state: _userState.default.showJoinTheConversationDialog
33
+ }, /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default, {
34
+ storefrontConfig: storefrontConfig
35
+ })), /*#__PURE__*/_react.default.createElement(_userState.default, {
36
+ state: _userState.default.showCommentingModule
37
+ }, /*#__PURE__*/_react.default.createElement(_comments.default, {
38
+ articleId: articleId,
39
+ isReadOnly: isReadOnly,
40
+ commentingConfig: commentingConfig,
41
+ domainSpecificUrl: domainSpecificUrl
42
+ }))) : /*#__PURE__*/_react.default.createElement(_disabledComments.default, null);
104
43
  };
105
44
 
106
45
  ArticleComments.propTypes = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@times-components/article-comments",
3
- "version": "0.43.28-alpha.37+b94c0c45ae",
3
+ "version": "0.43.28",
4
4
  "description": "Article Comments",
5
5
  "main": "dist/article-comments",
6
6
  "dev": "src/article-comments",
@@ -33,11 +33,11 @@
33
33
  },
34
34
  "homepage": "https://github.com/newsuk/times-components#readme",
35
35
  "dependencies": {
36
- "@times-components/link": "^3.17.34",
37
- "@times-components/tracking": "^2.22.34",
38
- "@times-components/ts-components": "^1.98.2",
39
- "@times-components/ts-styleguide": "^1.50.34",
40
- "@times-components/user-state": "^0.5.51",
36
+ "@times-components/link": "3.17.34",
37
+ "@times-components/tracking": "2.22.34",
38
+ "@times-components/ts-components": "1.99.0",
39
+ "@times-components/ts-styleguide": "1.50.34",
40
+ "@times-components/user-state": "0.5.51",
41
41
  "prop-types": "15.7.2",
42
42
  "styled-components": "4.3.2"
43
43
  },
@@ -45,10 +45,10 @@
45
45
  "@babel/core": "7.4.4",
46
46
  "@testing-library/jest-dom": "^5.12.0",
47
47
  "@testing-library/react": "^12.1.2",
48
- "@times-components/eslint-config-thetimes": "^0.8.18",
49
- "@times-components/jest-configurator-web": "^0.8.2",
50
- "@times-components/storybook": "^4.12.34",
51
- "@times-components/webpack-configurator": "^2.1.1",
48
+ "@times-components/eslint-config-thetimes": "0.8.18",
49
+ "@times-components/jest-configurator-web": "0.8.2",
50
+ "@times-components/storybook": "4.12.34",
51
+ "@times-components/webpack-configurator": "2.1.1",
52
52
  "babel-jest": "24.8.0",
53
53
  "eslint": "5.9.0",
54
54
  "jest": "24.8.0",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "b94c0c45aed23c5e6ed7847329bfc449ff30a9d4"
73
+ "gitHead": "bcc7c21aebd47d19401ccb6aaa9cfd754ba2e06f"
74
74
  }
package/rnw.js CHANGED
@@ -1 +1 @@
1
- module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(4),n(2)),a=n.n(r),m=n(3),c=n.n(m),s=n(0);const l=c.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],s.breakpoints.medium,s.breakpoints.wide);c.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",";font-family:",";font-size:","px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(-2),Object(s.spacing)(6)),c.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(6),Object(s.spacing)(1)),c.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.primary,s.fontsWithFallback.headline,s.fontSizes.commentsHeadline,Object(s.spacing)(1),Object(s.spacing)(6));function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var p=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=u(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const f=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var g=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(p(e),"_v2");window.SPOTIM.startSSO({callback:f,userId:t})}},b=n(6);class C extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.commentingConfig,i=e.onCommentStart,r=e.onCommentPost,a=e.onCommentNotification,m=e.onCommentFilterNewest,c=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,u=e.onCommentShareLink,d=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,b=e.onCommentRecommend,C=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,v=e.onCommentSettingsClicked,h=e.domainSpecificUrl;if(!this.container||!t||!o)return;document.addEventListener("spot-im-current-user-typing-start",i),document.addEventListener("spot-im-current-user-sent-message",r),document.addEventListener("spot-im-notification-drop-down-link",a),document.addEventListener("spot-im-user-up-vote-click",b),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return c(e);case"oldest":return s(e);case"newest":return m(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",l),document.addEventListener("spot-im-clicked-settings",v),document.addEventListener("spot-im-user-notifications-click",C),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return u(e);case"email":return p(e);case"twitter":return d(e);case"facebook":return f(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?g():document.addEventListener("spot-im-api-ready",()=>{g()})),document.addEventListener("spot-im-renew-sso",()=>{g()});const w=document.createElement("script");w.setAttribute("async","async"),w.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),w.setAttribute("data-spotim-module","spotim-launcher"),w.setAttribute("data-post-id",t),w.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),w.setAttribute("data-seo-enabled",!0),w.setAttribute("data-livefyre-url",t),this.container.appendChild(w)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,u=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,b=e.onCommentUsernameClicked,C=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:u,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:b,onCommentSettingsClicked:C},i.a.createElement("div",{ref:e=>{this.container=e}}))}}C.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var y,v=(y=C,Object(b.withTrackEvents)(y,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]}));n(7);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O={button:{marginBottom:Object(s.spacing)(0),marginTop:Object(s.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:s.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(s.spacing)(10),width:"100%"},headline:w(w({color:s.colours.functional.primary},Object(s.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(s.spacing)(2),paddingTop:Object(s.spacing)(6),textAlign:"center"}),link:{color:s.colours.functional.action},supporting:w(w({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function S(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?S(Object(n),!0).forEach((function(t){j(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):S(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function j(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}N(N({},O),{},{link:N(N({},O.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var E=n(5);var P=e=>{let t=e.storefrontConfig;const n=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,o=n?null:t,r=n?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(E.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:o,onClick:r},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")};const x=e=>{let t=e.userEntitlementsList,n=e.children;const o=t&&t.user&&t.user.subscriptions&&t.user.subscriptions[0]&&t.user.subscriptions[0].featureDecisions||[],i=o&&o.some(e=>"fp-752"===e.code&&e.outcome.toLowerCase().includes("disable"));return void 0===t?null:i&&n};function F(e,t,n,o,i,r,a){try{var m=e[r](a),c=m.value}catch(e){return void n(e)}m.done?t(c):Promise.resolve(c).then(o,i)}function L(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return A(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return A(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}const I=e=>{let t=e.articleId,n=(e.isEnabled,e.isReadOnly),r=e.commentingConfig,m=(e.isCommentEnabled,e.storefrontConfig),c=e.domainSpecificUrl,s=e.isEntitlementFeatureEnabled;const l=L(Object(o.useState)(void 0),2),u=l[0],d=l[1];return console.log("ArticleComments -> isEntitlementFeatureEnabled",s),Object(o.useEffect)(()=>{void 0!==typeof window&&function(){var e,t=(e=function*(){const e=yield fetch("/api/get-user-entitlements"),t=yield e.json();d(t)},function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function a(e){F(r,o,i,a,m,"next",e)}function m(e){F(r,o,i,a,m,"throw",e)}a(void 0)}))});return function(){return t.apply(this,arguments)}}()()},[]),i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(P,{storefrontConfig:m})),s?i.a.createElement(x,{userEntitlementsList:u},i.a.createElement("p",null,"inside UserEntitlements"),i.a.createElement(v,{articleId:t,isReadOnly:n,commentingConfig:r,domainSpecificUrl:c})):i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement("p",null,"inside UserState provider"),i.a.createElement(v,{articleId:t,isReadOnly:n,commentingConfig:r,domainSpecificUrl:c})))};I.defaultProps={isReadOnly:!1,isCommentEnabled:!0};t.default=I}]);
1
+ module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@times-components/user-state/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/tracking/rnw")},function(e,t){e.exports=require("@times-components/link/rnw")},function(e,t){e.exports=require("@times-components/ts-components/rnw")},function(e,t,n){"use strict";n.r(t);var o=n(1),i=n.n(o),r=(n(4),n(2)),a=n.n(r),m=n(3),c=n.n(m),s=n(0);const l=c.a.div.withConfig({displayName:"responsive__CommentContainer",componentId:"sc-2j1dkf-0"})(["margin-left:auto;margin-right:auto;@media (min-width:","px){width:80.8%;}@media (min-width:","px){width:56.2%;}"],s.breakpoints.medium,s.breakpoints.wide),d=(c.a.p.withConfig({displayName:"responsive__CommentEnabledGuidelines",componentId:"sc-2j1dkf-1"})(["color:",";font-family:",";font-size:","px;margin:0 0 "," 0;padding-left:7px;padding-top:",";"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(-2),Object(s.spacing)(6)),c.a.p.withConfig({displayName:"responsive__CommentDisabledGuidelines",componentId:"sc-2j1dkf-2"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.secondary,s.fontsWithFallback.supporting,s.fontSizes.commentsGuidelines,Object(s.spacing)(6),Object(s.spacing)(1))),u=c.a.p.withConfig({displayName:"responsive__CommentDisabledHeadline",componentId:"sc-2j1dkf-3"})(["color:",";font-family:",";font-size:","px;margin:0;padding-bottom:",";padding-top:",";text-align:center;"],s.colours.functional.primary,s.fontsWithFallback.headline,s.fontSizes.commentsHeadline,Object(s.spacing)(1),Object(s.spacing)(6));function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,i,r=[],a=!0,m=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){m=!0,i=e}finally{try{a||null==n.return||n.return()}finally{if(m)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var g=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=p(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const C=(e,t)=>((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const e=(200===n.status?JSON.parse(n.response):{}).spotimCodeB;e&&t(e)}),n.open("GET",e),n.send()})("/api/comments/loginv2?codeA=".concat(encodeURIComponent(e)),t);var b=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(g(e),"_v2");window.SPOTIM.startSSO({callback:C,userId:t})}},y=n(5);class v extends o.Component{constructor(){super(),this.container=null}componentDidMount(){this.initialiseComments()}componentWillUnmount(){this.disposeComments()}initialiseComments(){const e=this.props,t=e.articleId,n=e.isReadOnly,o=e.commentingConfig,i=e.onCommentStart,r=e.onCommentPost,a=e.onCommentNotification,m=e.onCommentFilterNewest,c=e.onCommentFilterMostRecommended,s=e.onCommentFilterOldest,l=e.onCommentReplyClick,d=e.onCommentShareLink,u=e.onCommentShareTwitter,p=e.onCommentShareEmail,f=e.onCommentShareFacebook,g=e.onCommentRecommend,C=e.onCommentNotificationClicked,y=e.onCommentUsernameClicked,v=e.onCommentSettingsClicked,h=e.domainSpecificUrl;if(!this.container||!t||!o)return;document.addEventListener("spot-im-current-user-typing-start",i),document.addEventListener("spot-im-current-user-sent-message",r),document.addEventListener("spot-im-notification-drop-down-link",a),document.addEventListener("spot-im-user-up-vote-click",g),document.addEventListener("spot-im-sort-by-select",e=>(e=>{switch(e.detail.sortedBy){case"best":return c(e);case"oldest":return s(e);case"newest":return m(e);default:return null}})(e)),document.addEventListener("spot-im-user-clicked-reply",l),document.addEventListener("spot-im-clicked-settings",v),document.addEventListener("spot-im-user-notifications-click",C),document.addEventListener("spot-im-open-user-profile",y),document.addEventListener("spot-im-share-type",e=>(e=>{switch(e.detail.type){case"link":return d(e);case"email":return p(e);case"twitter":return u(e);case"facebook":return f(e);default:return null}})(e)),n||(window.SPOTIM&&window.SPOTIM.startSSO?b():document.addEventListener("spot-im-api-ready",()=>{b()})),document.addEventListener("spot-im-renew-sso",()=>{b()});const k=document.createElement("script");k.setAttribute("async","async"),k.setAttribute("src","https://launcher.spot.im/spot/".concat(o.account)),k.setAttribute("data-spotim-module","spotim-launcher"),k.setAttribute("data-post-id",t),k.setAttribute("data-post-url","".concat(h,"/article/").concat(t)),k.setAttribute("data-seo-enabled",!0),k.setAttribute("data-livefyre-url",t),this.container.appendChild(k)}disposeComments(){this.container&&(this.container.innerHTML="")}render(){const e=this.props,t=e.onCommentStart,n=e.onCommentPost,o=e.onCommentNotification,r=e.onCommentFilterNewest,a=e.onCommentFilterMostRecommended,m=e.onCommentFilterOldest,c=e.onCommentReplyClick,s=e.onCommentShareLink,d=e.onCommentShareTwitter,u=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(l,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:d,onCommentShareEmail:u,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}v.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var h,k=(h=v,Object(y.withTrackEvents)(h,{analyticsEvents:[{actionName:"navigation",eventName:"onCommentStart",trackingName:"spot im : comment : start"},{actionName:"navigation",eventName:"onCommentPost",trackingName:"spot im : comment : complete"},{actionName:"navigation",eventName:"onCommentNotification",trackingName:"spot im : notification"},{actionName:"navigation",eventName:"onCommentFilterNewest",trackingName:"spot im : sort : newest"},{actionName:"navigation",eventName:"onCommentFilterMostRecommended",trackingName:"spot im : sort : best"},{actionName:"navigation",eventName:"onCommentFilterOldest",trackingName:"spot im : sort : oldest"},{actionName:"navigation",eventName:"onCommentReplyClick",trackingName:"spot im : reply"},{actionName:"navigation",eventName:"onCommentSettingsClicked",trackingName:"spot im : settings button clicked"},{actionName:"navigation",eventName:"onCommentShareLink",trackingName:"spot im : comment : share : copy link"},{actionName:"navigation",eventName:"onCommentShareEmail",trackingName:"spot im : comment : share : email"},{actionName:"navigation",eventName:"onCommentShareTwitter",trackingName:"spot im : comment : share : twitter"},{actionName:"navigation",eventName:"onCommentShareFacebook",trackingName:"spot im : comment : share : facebook"},{actionName:"navigation",eventName:"onCommentRecommend",trackingName:"spot im : vote up"},{actionName:"navigation",eventName:"onCommentUsernameClicked",trackingName:"spot im : username clicked"},{actionName:"navigation",eventName:"onCommentNotificationClicked",trackingName:"spot im : notification clicked"}]})),w=n(6);function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){N(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j={button:{marginBottom:Object(s.spacing)(0),marginTop:Object(s.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:s.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(s.spacing)(10),width:"100%"},headline:S(S({color:s.colours.functional.primary},Object(s.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(s.spacing)(2),paddingTop:Object(s.spacing)(6),textAlign:"center"}),link:{color:s.colours.functional.action},supporting:S(S({},Object(s.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:s.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function P(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach((function(t){x(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=P(P({},j),{},{link:P(P({},j.link),{},{fontFamily:s.fontsWithFallback.supporting,fontSize:s.fontSizes.commentsGuidelines})});var T=()=>i.a.createElement(l,null,i.a.createElement(u,null,"Comments for this article have been turned off"),i.a.createElement(d,null,"Comments are subject to our community guidelines, which can be viewed"," ",i.a.createElement(w.TextLink,{style:F.link,url:"/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),".")),L=n(7);var R=e=>{let t=e.storefrontConfig;const n=window.nuk&&window.nuk.user&&window.nuk.user.isLightPackUser,o=n?null:t,r=n?()=>document&&document.dispatchEvent(new Event("show::upgrade::modal")):null;return i.a.createElement(L.InlineDialog,{title:"Join the conversation",buttonText:"View offers",href:o,onClick:r},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")};const I=e=>{let t=e.articleId,n=e.isEnabled,o=e.isReadOnly,r=e.commentingConfig,m=e.isCommentEnabled,c=e.storefrontConfig,s=e.domainSpecificUrl;return n&&m?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(R,{storefrontConfig:c})),i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement(k,{articleId:t,isReadOnly:o,commentingConfig:r,domainSpecificUrl:s}))):i.a.createElement(T,null)};I.defaultProps={isReadOnly:!1,isCommentEnabled:!0};t.default=I}]);
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _tsComponents = require("@times-components/ts-components");
11
-
12
- var _userEntitlements = require("./user-entitlements");
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
- const UserEntitlementProvider = _ref => {
19
- let children = _ref.children;
20
- console.log("children inside UserEntitlementProvider", children);
21
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null) // <FetchProvider url="/api/get-user-entitlements">
22
- // <UserEntitlements>{children}</UserEntitlements>
23
- // </FetchProvider>
24
- ;
25
- };
26
-
27
- var _default = UserEntitlementProvider;
28
- exports.default = _default;
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UserEntitlements = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- // import { useFetch } from '@times-components/ts-components';
13
- // interface FeatureDecision {
14
- // code: string;
15
- // name: string;
16
- // outcome: string;
17
- // }
18
- // interface Subscription {
19
- // id: string;
20
- // featureDecisions: FeatureDecision[];
21
- // }
22
- // interface User {
23
- // cpn: string;
24
- // subscriptions: Subscription[];
25
- // }
26
- // interface Data {
27
- // user: User;
28
- // }
29
- // interface FetchResponse {
30
- // data: Data;
31
- // }
32
- // export interface UserEntitlementProps {
33
- // loading?: boolean;
34
- // error?: string;
35
- // data: FetchResponse;
36
- // }
37
- const UserEntitlements = _ref => {
38
- let userEntitlementsList = _ref.userEntitlementsList,
39
- children = _ref.children;
40
- // const { data, loading } = useFetch();
41
- // console.log("fetchResponse", userEntitlementsList);
42
- // const subscriptions = data?.data?.user?.subscriptions || []
43
- const featureDecisions = userEntitlementsList && userEntitlementsList.user && userEntitlementsList.user.subscriptions && userEntitlementsList.user.subscriptions[0] && userEntitlementsList.user.subscriptions[0].featureDecisions || []; // const {
44
- // data: { user }
45
- // } = fetchResponse || {};
46
- // const { subscriptions } = user || [];
47
- // console.log('featureDecisions', featureDecisions);
48
-
49
- const isCommentingEntitlementEnabled = featureDecisions && featureDecisions.some(decision => {
50
- return decision.code === "fp-752" && decision.outcome.toLowerCase().includes("disable");
51
- });
52
-
53
- if (userEntitlementsList === undefined) {
54
- return null;
55
- }
56
-
57
- return isCommentingEntitlementEnabled && children;
58
- };
59
-
60
- exports.UserEntitlements = UserEntitlements;