@times-components/article-comments 0.46.2 → 0.47.0
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 +11 -0
- package/dist/article-comments.js +2 -8
- package/dist/join-the-conversation-dialog.js +5 -14
- package/package.json +7 -7
- package/rnw.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.47.0](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.46.2...@times-components/article-comments@0.47.0) (2025-03-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **TMG-3050:** Fix CTA URL for Commenting banner ([#4103](https://github.com/newsuk/times-components/issues/4103)) ([2a6b973](https://github.com/newsuk/times-components/commit/2a6b973bfaa40105beff42b0223ccb1fc82153c3))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.46.2](https://github.com/newsuk/times-components/compare/@times-components/article-comments@0.46.1...@times-components/article-comments@0.46.2) (2025-03-26)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @times-components/article-comments
|
package/dist/article-comments.js
CHANGED
|
@@ -46,7 +46,6 @@ const ArticleComments = _ref => {
|
|
|
46
46
|
isEnabled = _ref.isEnabled,
|
|
47
47
|
isReadOnly = _ref.isReadOnly,
|
|
48
48
|
commentingConfig = _ref.commentingConfig,
|
|
49
|
-
storefrontConfig = _ref.storefrontConfig,
|
|
50
49
|
domainSpecificUrl = _ref.domainSpecificUrl;
|
|
51
50
|
|
|
52
51
|
const _useState = (0, _react.useState)(undefined),
|
|
@@ -93,9 +92,7 @@ const ArticleComments = _ref => {
|
|
|
93
92
|
domainSpecificUrl: domainSpecificUrl
|
|
94
93
|
})), /*#__PURE__*/_react.default.createElement(_userState.default, {
|
|
95
94
|
state: _userState.default.showJoinTheConversationDialog
|
|
96
|
-
}, /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default,
|
|
97
|
-
storefrontConfig: storefrontConfig
|
|
98
|
-
})));
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default, null)));
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
return isEntitled ? /*#__PURE__*/_react.default.createElement(_comments.default, {
|
|
@@ -103,9 +100,7 @@ const ArticleComments = _ref => {
|
|
|
103
100
|
isReadOnly: isReadOnly,
|
|
104
101
|
commentingConfig: commentingConfig,
|
|
105
102
|
domainSpecificUrl: domainSpecificUrl
|
|
106
|
-
}) : /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default,
|
|
107
|
-
storefrontConfig: storefrontConfig
|
|
108
|
-
});
|
|
103
|
+
}) : /*#__PURE__*/_react.default.createElement(_joinTheConversationDialog.default, null);
|
|
109
104
|
};
|
|
110
105
|
|
|
111
106
|
ArticleComments.propTypes = {
|
|
@@ -115,7 +110,6 @@ ArticleComments.propTypes = {
|
|
|
115
110
|
commentingConfig: _propTypes.default.shape({
|
|
116
111
|
account: _propTypes.default.string.isRequired
|
|
117
112
|
}).isRequired,
|
|
118
|
-
storefrontConfig: _propTypes.default.string.isRequired,
|
|
119
113
|
domainSpecificUrl: _propTypes.default.string.isRequired
|
|
120
114
|
};
|
|
121
115
|
ArticleComments.defaultProps = {
|
|
@@ -7,31 +7,22 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _tsComponents = require("@times-components/ts-components");
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
14
|
/* eslint-env browser */
|
|
17
|
-
const JoinTheConversationDialog = _ref => {
|
|
18
|
-
let storefrontConfig = _ref.storefrontConfig;
|
|
19
|
-
const isLightPackUser = window.nuk && window.nuk.user && window.nuk.user.isLightPackUser;
|
|
20
|
-
const href = isLightPackUser ? null : storefrontConfig; // temp solution until the modal is moved out to a proper UI repo
|
|
21
|
-
// this event triggers cps-content-render/packages/components-global/src/FreeArticlePromotion/FreeArticleBottomBanner/FreeArticleBottomBanner.tsx
|
|
22
|
-
// todo: remove this event dispatching and implement the modal from the shared UI component repo
|
|
23
15
|
|
|
24
|
-
|
|
16
|
+
/* eslint no-underscore-dangle: 0 */
|
|
17
|
+
const JoinTheConversationDialog = () => {
|
|
18
|
+
const href = typeof window !== "undefined" && window.__TIMES_CONFIG__ && window.__TIMES_CONFIG__.account && window.__TIMES_CONFIG__.account.url;
|
|
25
19
|
return /*#__PURE__*/_react.default.createElement(_tsComponents.InlineDialog, {
|
|
26
20
|
title: "Join the conversation",
|
|
27
|
-
buttonText: "
|
|
21
|
+
buttonText: "Go to My account",
|
|
28
22
|
href: href,
|
|
29
|
-
onClick:
|
|
23
|
+
onClick: () => {}
|
|
30
24
|
}, "Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.");
|
|
31
25
|
};
|
|
32
26
|
|
|
33
|
-
JoinTheConversationDialog.propTypes = {
|
|
34
|
-
storefrontConfig: _propTypes.default.string.isRequired
|
|
35
|
-
};
|
|
36
27
|
var _default = JoinTheConversationDialog;
|
|
37
28
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@times-components/article-comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Article Comments",
|
|
5
5
|
"main": "dist/article-comments",
|
|
6
6
|
"dev": "src/article-comments",
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/newsuk/times-components#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@times-components/link": "3.17.
|
|
36
|
+
"@times-components/link": "3.17.45",
|
|
37
37
|
"@times-components/tracking": "2.22.44",
|
|
38
|
-
"@times-components/ts-components": "1.
|
|
39
|
-
"@times-components/ts-styleguide": "1.
|
|
40
|
-
"@times-components/user-state": "0.6.
|
|
41
|
-
"@times-components/utils": "6.31.
|
|
38
|
+
"@times-components/ts-components": "1.125.0",
|
|
39
|
+
"@times-components/ts-styleguide": "1.52.0",
|
|
40
|
+
"@times-components/user-state": "0.6.6",
|
|
41
|
+
"@times-components/utils": "6.31.2",
|
|
42
42
|
"prop-types": "15.7.2",
|
|
43
43
|
"styled-components": "4.3.2"
|
|
44
44
|
},
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "d3a2621613dab86d8b764fea857c17cb4acb4b8b"
|
|
75
75
|
}
|
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=9)}([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/utils/rnw")},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(5),c=n(3),s=n.n(c),l=n(0);const u=s.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%;}"],l.breakpoints.medium,l.breakpoints.wide),d=(s.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:",";"],l.colours.functional.secondary,l.fontsWithFallback.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.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;"],l.colours.functional.secondary,l.fontsWithFallback.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.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;"],l.colours.functional.primary,l.fontsWithFallback.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6));function f(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 g(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 g(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 g(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 C=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=f(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const b=(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 y=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(C(e),"_v2");window.SPOTIM.startSSO({callback:b,userId:t})}},v=n(6);class h 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,g=e.onCommentRecommend,C=e.onCommentNotificationClicked,b=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",b),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?y():document.addEventListener("spot-im-api-ready",()=>{y()})),document.addEventListener("spot-im-renew-sso",()=>{y()});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,l=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(u,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}h.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var w,k=(w=h,Object(v.withTrackEvents)(w,{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"}]})),O=n(7);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}var E={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:N(N({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:N(N({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function P(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 x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){F(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var T=x(x({},E),{},{link:x(x({},E.link),{},{fontFamily:l.fontsWithFallback.supporting,fontSize:l.fontSizes.commentsGuidelines})});var I=()=>i.a.createElement(u,null,i.a.createElement(p,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(O.TextLink,{style:T.link,url:"/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),".")),L=n(8);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.")};function A(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 M(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 M(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 M(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 U=e=>{let t=e.articleId,n=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig,s=e.storefrontConfig,l=e.domainSpecificUrl;const u=A(Object(o.useState)(void 0),2),d=u[0],p=u[1],f=A(Object(o.useState)(void 0),2),g=f[0],C=f[1];return Object(o.useEffect)(()=>{if(new URLSearchParams(window.location.search).get("entitlements")){const e=Object(m.getBase64CookieValue)("access-decisions");C(!!e&&Object(m.hasEntitlement)(e,"functionalCommentingFull"))}else p(!1)},[]),void 0===d&&void 0===g?null:n?!1===d?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement(k,{articleId:t,isReadOnly:r,commentingConfig:c,domainSpecificUrl:l})),i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(R,{storefrontConfig:s}))):g?i.a.createElement(k,{articleId:t,isReadOnly:r,commentingConfig:c,domainSpecificUrl:l}):i.a.createElement(R,{storefrontConfig:s}):i.a.createElement(I,null)};U.defaultProps={isReadOnly:!1};t.default=U}]);
|
|
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=9)}([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("@times-components/utils/rnw")},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(5),n(2)),a=n.n(r),m=n(4),c=n(3),s=n.n(c),l=n(0);const u=s.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%;}"],l.breakpoints.medium,l.breakpoints.wide),d=(s.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:",";"],l.colours.functional.secondary,l.fontsWithFallback.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(-2),Object(l.spacing)(6)),s.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;"],l.colours.functional.secondary,l.fontsWithFallback.supporting,l.fontSizes.commentsGuidelines,Object(l.spacing)(6),Object(l.spacing)(1))),p=s.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;"],l.colours.functional.primary,l.fontsWithFallback.headline,l.fontSizes.commentsHeadline,Object(l.spacing)(1),Object(l.spacing)(6));function f(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 g(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 g(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 g(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 C=e=>e?(e=>e.split("&").reduce((e,t)=>{const n=f(t.split("="),2),o=n[0],i=n[1];return e[o]=i,e},{}))(e).eid:void 0;const b=(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 y=()=>{if(window.SPOTIM&&window.SPOTIM.startSSO){const e=window&&window.nuk&&window.nuk.getCookieValue&&window.nuk.getCookieValue("acs_tnl"),t="".concat(C(e),"_v2");window.SPOTIM.startSSO({callback:b,userId:t})}},v=n(6);class h 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,g=e.onCommentRecommend,C=e.onCommentNotificationClicked,b=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",b),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?y():document.addEventListener("spot-im-api-ready",()=>{y()})),document.addEventListener("spot-im-renew-sso",()=>{y()});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,l=e.onCommentShareTwitter,d=e.onCommentShareEmail,p=e.onCommentShareFacebook,f=e.onCommentRecommend,g=e.onCommentNotificationClicked,C=e.onCommentUsernameClicked,b=e.onCommentSettingsClicked;return i.a.createElement(u,{id:"comments-container",onCommentStart:t,onCommentPost:n,onCommentNotification:o,onCommentReplyClick:c,onCommentFilterNewest:r,onCommentFilterMostRecommended:a,onCommentFilterOldest:m,onCommentShareLink:s,onCommentShareTwitter:l,onCommentShareEmail:d,onCommentShareFacebook:p,onCommentRecommend:f,onCommentNotificationClicked:g,onCommentUsernameClicked:C,onCommentSettingsClicked:b},i.a.createElement("div",{ref:e=>{this.container=e}}))}}h.defaultProps={onCommentStart:()=>{},onCommentPost:()=>{},onCommentNotification:()=>{},onCommentReplyClick:()=>{},onCommentFilterNewest:()=>{},onCommentFilterMostRecommended:()=>{},onCommentFilterOldest:()=>{},onCommentShareLink:()=>{},onCommentShareTwitter:()=>{},onCommentShareEmail:()=>{},onCommentShareFacebook:()=>{},onCommentRecommend:()=>{},onCommentNotificationClicked:()=>{},onCommentUsernameClicked:()=>{},onCommentSettingsClicked:()=>{}};var w,O=(w=h,Object(v.withTrackEvents)(w,{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"}]})),k=n(7);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}var E={button:{marginBottom:Object(l.spacing)(0),marginTop:Object(l.spacing)(5),maxWidth:215},container:{alignItems:"center",borderStyle:"solid",borderTopColor:l.colours.functional.keyline,borderTopWidth:1,marginBottom:Object(l.spacing)(10),width:"100%"},headline:N(N({color:l.colours.functional.primary},Object(l.fontFactory)({font:"headline",fontSize:"commentsHeadline"})),{},{maxWidth:315,paddingBottom:Object(l.spacing)(2),paddingTop:Object(l.spacing)(6),textAlign:"center"}),link:{color:l.colours.functional.action},supporting:N(N({},Object(l.fontFactory)({font:"supporting",fontSize:"tertiary"})),{},{color:l.colours.functional.secondary,maxWidth:280,textAlign:"center"})};function P(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 x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){F(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function F(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _=x(x({},E),{},{link:x(x({},E.link),{},{fontFamily:l.fontsWithFallback.supporting,fontSize:l.fontSizes.commentsGuidelines})});var I=()=>i.a.createElement(u,null,i.a.createElement(p,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(k.TextLink,{style:_.link,url:"/article/f4024fbe-d989-11e6-9063-500e6740fc32"},"here"),".")),T=n(8);var M=()=>{const e="undefined"!=typeof window&&window.__TIMES_CONFIG__&&window.__TIMES_CONFIG__.account&&window.__TIMES_CONFIG__.account.url;return i.a.createElement(T.InlineDialog,{title:"Join the conversation",buttonText:"Go to My account",href:e,onClick:()=>{}},"Commenting is only available to unlimited access subscribers. Upgrade your subscription to have your say.")};function R(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 L=e=>{let t=e.articleId,n=e.isEnabled,r=e.isReadOnly,c=e.commentingConfig,s=e.domainSpecificUrl;const l=R(Object(o.useState)(void 0),2),u=l[0],d=l[1],p=R(Object(o.useState)(void 0),2),f=p[0],g=p[1];return Object(o.useEffect)(()=>{if(new URLSearchParams(window.location.search).get("entitlements")){const e=Object(m.getBase64CookieValue)("access-decisions");g(!!e&&Object(m.hasEntitlement)(e,"functionalCommentingFull"))}else d(!1)},[]),void 0===u&&void 0===f?null:n?!1===u?i.a.createElement(i.a.Fragment,null,i.a.createElement(a.a,{state:a.a.showCommentingModule},i.a.createElement(O,{articleId:t,isReadOnly:r,commentingConfig:c,domainSpecificUrl:s})),i.a.createElement(a.a,{state:a.a.showJoinTheConversationDialog},i.a.createElement(M,null))):f?i.a.createElement(O,{articleId:t,isReadOnly:r,commentingConfig:c,domainSpecificUrl:s}):i.a.createElement(M,null):i.a.createElement(I,null)};L.defaultProps={isReadOnly:!1};t.default=L}]);
|