@mjhls/mjh-framework 1.0.885 → 1.0.886

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.
Files changed (32) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/ContentCardPaginated.js +414 -0
  3. package/dist/cjs/DeckQueuePaginated.js +345 -0
  4. package/dist/cjs/GridContent.js +44 -157
  5. package/dist/cjs/GridContentPaginated.js +704 -0
  6. package/dist/cjs/ImageSlider-b96720eb.js +2813 -0
  7. package/dist/cjs/MasterDeckPaginated.js +446 -0
  8. package/dist/cjs/MediaSeriesCard-8b4efd28.js +9505 -0
  9. package/dist/cjs/MediaSeriesLanding.js +20 -9502
  10. package/dist/cjs/MediaSeriesLandingPaginated.js +524 -0
  11. package/dist/cjs/Pagination-8f2038bf.js +53 -0
  12. package/dist/cjs/PartnerDetailListing.js +12 -2807
  13. package/dist/cjs/PartnerDetailListingPaginated.js +314 -0
  14. package/dist/cjs/PublicationFeature-5ccf9b13.js +130 -0
  15. package/dist/cjs/QueueDeckExpandedPaginated.js +1378 -0
  16. package/dist/cjs/index.js +2 -0
  17. package/dist/esm/ContentCardPaginated.js +403 -0
  18. package/dist/esm/DeckQueuePaginated.js +334 -0
  19. package/dist/esm/GridContent.js +2 -114
  20. package/dist/esm/GridContentPaginated.js +693 -0
  21. package/dist/esm/ImageSlider-de7846ea.js +2804 -0
  22. package/dist/esm/MasterDeckPaginated.js +438 -0
  23. package/dist/esm/MediaSeriesCard-51ebf1c0.js +9495 -0
  24. package/dist/esm/MediaSeriesLanding.js +16 -9496
  25. package/dist/esm/MediaSeriesLandingPaginated.js +517 -0
  26. package/dist/esm/Pagination-c0db7ca1.js +46 -0
  27. package/dist/esm/PartnerDetailListing.js +13 -2807
  28. package/dist/esm/PartnerDetailListingPaginated.js +308 -0
  29. package/dist/esm/PublicationFeature-d88e76b9.js +121 -0
  30. package/dist/esm/QueueDeckExpandedPaginated.js +1372 -0
  31. package/dist/esm/index.js +2 -0
  32. package/package.json +2 -1
@@ -0,0 +1,438 @@
1
+ import { _ as _JSON$stringify } from './stringify-2b084bee.js';
2
+ import { a as _asyncToGenerator, r as regenerator, _ as _Promise } from './asyncToGenerator-5ef104a7.js';
3
+ import { _ as _extends } from './extends-6d8e3924.js';
4
+ import { _ as _toConsumableArray } from './toConsumableArray-f7074d7c.js';
5
+ import { _ as _inherits, a as _classCallCheck, b as _possibleConstructorReturn, c as _Object$getPrototypeOf, d as _createClass } from './inherits-a6ba2ec4.js';
6
+ import React__default from 'react';
7
+ import { l as lib_3 } from './index-f0fc23eb.js';
8
+ import Container from 'react-bootstrap/Container';
9
+ import Spinner from 'react-bootstrap/Spinner';
10
+ import { withRouter } from 'next/router';
11
+ import { l as lodash } from './lodash-f97fd99a.js';
12
+ import { m as main_43 } from './main-1894c974.js';
13
+ import { A as ADlgInfeed } from './ADlgInfeed-013e1f4a.js';
14
+ import { A as ADInfeed } from './ADInfeed-0a55cd2d.js';
15
+ import { P as Pagination } from './Pagination-c0db7ca1.js';
16
+ import './_commonjsHelpers-0c4b6f40.js';
17
+ import './core.get-iterator-method-ea258bb1.js';
18
+ import './web.dom.iterable-ab4dea5c.js';
19
+ import './_library-528f1934.js';
20
+ import './_iter-detect-98db3b07.js';
21
+ import './_object-pie-133f504a.js';
22
+ import './_object-sap-7cee6f84.js';
23
+ import './define-property-5f1bda73.js';
24
+ import './typeof-e9fc0c5d.js';
25
+ import './_is-array-8d21b9e3.js';
26
+ import './events-6c3a7a63.js';
27
+ import 'prop-types';
28
+ import './slicedToArray-6ebcbfea.js';
29
+ import 'react-bootstrap/Card';
30
+ import './AdSlot.js';
31
+ import './debounce-533d9748.js';
32
+ import './isSymbol-a7e9aafe.js';
33
+ import './toNumber-5aeba6e7.js';
34
+ import './Beam.js';
35
+ import './Segment.js';
36
+ import 'react-paginate';
37
+
38
+ var MasterDeck = function (_React$Component) {
39
+ _inherits(MasterDeck, _React$Component);
40
+
41
+ function MasterDeck() {
42
+ var _ref,
43
+ _this2 = this;
44
+
45
+ var _temp, _this, _ret;
46
+
47
+ _classCallCheck(this, MasterDeck);
48
+
49
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
50
+ args[_key] = arguments[_key];
51
+ }
52
+
53
+ return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = MasterDeck.__proto__ || _Object$getPrototypeOf(MasterDeck)).call.apply(_ref, [this].concat(args))), _this), _this.Deck = _this.props.deck, _this.data = _this.props.dataRecord || [], _this.pointer = _this.props.pointer ? _this.props.pointer : false, _this.pointerArray = _this.props.pointerArray ? _this.props.pointerArray : false, _this.defaultImage = _this.props.defaultImage ? _this.props.defaultImage : '/placeholder.jpg', _this.rightItems = _this.props.rightItems ? _this.props.rightItems : false, _this.isSeriesLanding = _this.props.isSeriesLanding ? _this.props.isSeriesLanding : false, _this.state = {
54
+ isDataLoading: false,
55
+ data: _this.data,
56
+ prevData: _this.data,
57
+ currentPage: _this.props.currentPage || 1,
58
+ dataRemapped: !_this.props.showBI || !_this.props.brandInsightAd,
59
+ itemsPerPage: _this.props.params ? _this.props.params.to - _this.props.params.from : 2,
60
+ mobileView: false
61
+ }, _this.seoPagination = function (pageNumber) {
62
+ var _this$props = _this.props,
63
+ pageview = _this$props.pageview,
64
+ router = _this$props.router;
65
+
66
+ var path = router.asPath;
67
+ var qrIndex = path.indexOf('?');
68
+ var pathname = router.pathname;
69
+ var queryString = '';
70
+
71
+ if (qrIndex > 0) {
72
+ path = path.substring(1, qrIndex);
73
+
74
+ var partialQS = router.asPath.substring(qrIndex + 1);
75
+ var partialQSArr = partialQS.split('&');
76
+
77
+ // exclude page=xxx from query string
78
+ partialQSArr.map(function (item) {
79
+ var itemArr = item.split('=');
80
+ var key = itemArr[0];
81
+ var val = itemArr[1];
82
+
83
+ if (key !== 'page') {
84
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
85
+ }
86
+ });
87
+ }
88
+
89
+ if (queryString.length > 0) {
90
+ path += '?' + queryString;
91
+ }
92
+
93
+ pageNumber = parseInt(pageNumber);
94
+
95
+ if (path[0] !== '/') {
96
+ path = '/' + path;
97
+ }
98
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
99
+ if (window.location.href.includes('?')) {
100
+ if (window.location.href.includes('?page')) {
101
+ newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
102
+ } else {
103
+ newPath = pageNumber === 1 ? '' + path : path + '&page=' + pageNumber;
104
+ }
105
+ }
106
+
107
+ // please leave this for later debug purpose : Yong Jun.
108
+ /* console.log('page change reported', {
109
+ currentPage: currentPage,
110
+ pageNumber: pageNumber,
111
+ pathname: pathname,
112
+ path: path,
113
+ newPath: newPath,
114
+ firstPage: pageNumber === 1,
115
+ queryString: queryString
116
+ }) */
117
+
118
+ if (pageview) {
119
+ pageview(newPath);
120
+ }
121
+
122
+ router.push(pathname, newPath, {
123
+ shallow: true
124
+ });
125
+ }, _this.cardLoader = function (_ref2) {
126
+ var variant = _ref2.variant,
127
+ brandInsightAd = _ref2.brandInsightAd,
128
+ showBI = _ref2.showBI,
129
+ lgInfeedAd = _ref2.lgInfeedAd;
130
+
131
+ var numberOfItemsBeforeAd = 6;
132
+ var data = _this.state.data;
133
+ var insertBrandInsightAd = function insertBrandInsightAd(arr, index, newElement) {
134
+ return [].concat(_toConsumableArray(arr.slice(0, index)), [newElement], _toConsumableArray(arr.slice(index)));
135
+ };
136
+ // Need to pass flag "lgInfeedAd={true}" along with brandInsightAd from site level for large infeed-ad to render
137
+ // Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
138
+ // Integrating large infeed AD
139
+ if (lgInfeedAd && brandInsightAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
140
+ var lgInfeed = {
141
+ _type: 'lg-infeed',
142
+ adUnit: brandInsightAd.adUnit,
143
+ className: 'lg-infeed',
144
+ networkID: brandInsightAd.networkID,
145
+ sizes: [728, 90],
146
+ sizeMapping: [{
147
+ viewport: [1400, 0],
148
+ sizes: [[728, 90]]
149
+ }, { viewport: [0, 0], sizes: [] }],
150
+ targeting: {
151
+ content_placement: brandInsightAd.targeting.content_placement,
152
+ document_url: brandInsightAd.targeting.document_url,
153
+ rootDocumentGroup: brandInsightAd.targeting.rootDocumentGroup
154
+ },
155
+ /* Passing refresh flag */
156
+ refreshFlag: brandInsightAd.refreshFlag ? brandInsightAd.refreshFlag : false
157
+ };
158
+
159
+ var chunks = lodash.chunk(data, 6).map(function (chunk) {
160
+ var set = lodash.chunk(chunk, 2);
161
+ for (var i = 0; i < set.length; i++) {
162
+ if (i !== set.length - 1) {
163
+ set[i].push(lgInfeed);
164
+ }
165
+ }
166
+ return lodash.flattenDeep(set);
167
+ });
168
+ data = lodash.flatten(chunks);
169
+ !_this.state.dataRemapped && _this.setState({ dataRemapped: true }); // To detect if appending of insights ads are completed
170
+ }
171
+
172
+ // Integrating infeed AD
173
+ if (showBI && brandInsightAd) {
174
+ // Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
175
+ if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) brandInsightAd.interval = 8;
176
+ var pos = 0;
177
+ for (var i = 1; pos < data.length; i++) {
178
+ var inFeedAd = {
179
+ adUnit: brandInsightAd.adUnit,
180
+ className: brandInsightAd.className,
181
+ networkID: brandInsightAd.networkID,
182
+ sizes: brandInsightAd.sizes,
183
+ slotId: brandInsightAd.slotId + '_' + i,
184
+ targeting: {
185
+ pos: 'infeed',
186
+ content_placement: brandInsightAd.targeting.content_placement,
187
+ document_url: brandInsightAd.targeting.document_url,
188
+ rootDocumentGroup: brandInsightAd.targeting.rootDocumentGroup
189
+ },
190
+ _type: 'brandInsightAd',
191
+ /* Passing refresh flag */
192
+ refreshFlag: brandInsightAd.refreshFlag ? brandInsightAd.refreshFlag : false
193
+ };
194
+
195
+ data = insertBrandInsightAd(data, pos, inFeedAd);
196
+ pos += brandInsightAd.interval + 1;
197
+ }
198
+ }
199
+
200
+ // 'index' was including the indexes for infeed ads along with article count making the page number change before it reaches last article.
201
+ data = data.map(function (ele, i) {
202
+ if (ele._type === 'lg-infeed') {
203
+ // Setting pos as top2 for the first occurence of large infeed ad
204
+ // const pos = data.indexOf(data.find((d) => d._type === 'lg-infeed')) === i ? 'top2' : `lg-infeed_${i}`
205
+ return _extends({}, ele, { slotId: 'lg-infeed_' + i, targeting: _extends({}, ele.targeting, { pos: 'lg-infeed' }) });
206
+ } else {
207
+ return ele;
208
+ }
209
+ });
210
+
211
+ return React__default.createElement(
212
+ 'div',
213
+ null,
214
+ data && _this.state.dataRemapped && data.length > 0 ? // If JS enabled and Data remapped with ads
215
+ data.map(function (row, index) {
216
+ if (row._type === 'lg-infeed' && row.adUnit) {
217
+ return React__default.createElement(ADlgInfeed, _extends({ index: index }, row));
218
+ // Returning view for infeed Ad
219
+ } else if (row._type === 'brandInsightAd' && row.adUnit) {
220
+ return React__default.createElement(ADInfeed, { index: index, infeedAd: row });
221
+ } else if (!row._type || !['lg-infeed', 'brandInsightAd'].includes(row._type)) {
222
+ // Returning view for articles
223
+ return React__default.createElement(
224
+ React__default.Fragment,
225
+ { key: index },
226
+ React__default.createElement(_this2.Deck, { data: row, variant: variant, index: index, client: _this.props.client, defaultImage: _this.defaultImage, isSeriesLanding: _this.isSeriesLanding }),
227
+ _this.state.mobileView && _this.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && React__default.createElement(
228
+ 'div',
229
+ { className: 'ad-container', style: { margin: '0 auto' } },
230
+ _this.renderMobileAd(index, numberOfItemsBeforeAd, _this.rightItems)
231
+ )
232
+ );
233
+ } else {
234
+ return null;
235
+ }
236
+ }) : data && data.length > 0 ? // For Javascript Disabled Cases. data is not remapped if JS is disabled.
237
+ data.map(function (row, index) {
238
+ if (!row._type || !['lg-infeed', 'brandInsightAd'].includes(row._type)) {
239
+ return React__default.createElement(
240
+ React__default.Fragment,
241
+ { key: index },
242
+ React__default.createElement(_this2.Deck, { data: row, variant: variant, index: index, client: _this.props.client, defaultImage: _this.defaultImage, isSeriesLanding: _this.isSeriesLanding })
243
+ );
244
+ }
245
+ }) : React__default.createElement(
246
+ 'div',
247
+ null,
248
+ React__default.createElement(
249
+ 'em',
250
+ null,
251
+ 'New content coming soon, please check back later.'
252
+ )
253
+ )
254
+ );
255
+ }, _this.renderMobileAd = function (index, numberOfItemsBeforeAd, rightItems) {
256
+ var i = ((index + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
257
+ return React__default.createElement(
258
+ 'div',
259
+ { className: 'ad-container', style: { display: 'flex', flex: '1 0 auto', width: '100%', textAlign: 'center', marginBottom: '2rem' } },
260
+ rightItems[i].component
261
+ );
262
+ }, _this.handlePageChange = function () {
263
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(selectedPage) {
264
+ var itemsPerPage, _this$props2, query, params, client, dataHandler, seoPaginate, start, newParams, dataHandlerPromise, newData;
265
+
266
+ return regenerator.wrap(function _callee$(_context) {
267
+ while (1) {
268
+ switch (_context.prev = _context.next) {
269
+ case 0:
270
+ itemsPerPage = _this.state.itemsPerPage;
271
+ _this$props2 = _this.props, query = _this$props2.query, params = _this$props2.params, client = _this$props2.client, dataHandler = _this$props2.dataHandler, seoPaginate = _this$props2.seoPaginate;
272
+
273
+ _this.setState({ isDataLoading: true, currentPage: selectedPage });
274
+ seoPaginate && _this.seoPagination(selectedPage);
275
+ lib_3.refresh();
276
+ document.body.scrollTop = 0;
277
+ document.documentElement.scrollTop = 0;
278
+ start = (selectedPage - 1) * itemsPerPage;
279
+ newParams = _extends({}, params, {
280
+ from: start,
281
+ to: start + itemsPerPage
282
+ });
283
+ dataHandlerPromise = null;
284
+
285
+ if (dataHandler) {
286
+ dataHandlerPromise = new _Promise(function (resolve, reject) {
287
+ try {
288
+ var result = dataHandler(newParams);
289
+ resolve(result);
290
+ } catch (e) {
291
+ reject(e);
292
+ }
293
+ });
294
+ }
295
+
296
+ _context.prev = 11;
297
+
298
+ if (!dataHandlerPromise) {
299
+ _context.next = 18;
300
+ break;
301
+ }
302
+
303
+ _context.next = 15;
304
+ return dataHandlerPromise;
305
+
306
+ case 15:
307
+ _context.t0 = _context.sent;
308
+ _context.next = 21;
309
+ break;
310
+
311
+ case 18:
312
+ _context.next = 20;
313
+ return client.fetch(query, newParams);
314
+
315
+ case 20:
316
+ _context.t0 = _context.sent;
317
+
318
+ case 21:
319
+ newData = _context.t0;
320
+
321
+ if (_this.pointer && _this.pointerArray) newData = newData[_this.pointerArray][_this.pointer];
322
+ if (newData && newData.length > 0) {
323
+ _this.setState({ isDataLoading: false, data: newData });
324
+ }
325
+ _context.next = 29;
326
+ break;
327
+
328
+ case 26:
329
+ _context.prev = 26;
330
+ _context.t1 = _context['catch'](11);
331
+
332
+ console.error(_context.t1);
333
+
334
+ case 29:
335
+ case 'end':
336
+ return _context.stop();
337
+ }
338
+ }
339
+ }, _callee, _this2, [[11, 26]]);
340
+ }));
341
+
342
+ return function (_x) {
343
+ return _ref3.apply(this, arguments);
344
+ };
345
+ }(), _temp), _possibleConstructorReturn(_this, _ret);
346
+ }
347
+
348
+ _createClass(MasterDeck, [{
349
+ key: 'componentDidUpdate',
350
+ value: function componentDidUpdate(prevProps, prevState) {
351
+ if (_JSON$stringify(this.state.prevData) !== _JSON$stringify(prevState.prevData) && this.props.seoPaginate) {
352
+ this.seoPagination(this.state.currentPage);
353
+ }
354
+ // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
355
+ if (typeof window !== 'undefined' && (!this.props.lgInfeedAd || !this.props.brandInsightAd || window.innerWidth < 1400) && !this.state.dataRemapped) {
356
+ !this.state.dataRemapped && this.setState({ dataRemapped: true });
357
+ }
358
+ if (typeof window !== 'undefined' && window.innerWidth <= 1191) {
359
+ !this.state.mobileView && this.setState({ mobileView: true });
360
+ }
361
+ }
362
+ }, {
363
+ key: 'render',
364
+ value: function render() {
365
+ // Setting default value for 'showBI' and 'lgInfeedAd'
366
+ var _props = this.props,
367
+ variant = _props.variant,
368
+ brandInsightAd = _props.brandInsightAd,
369
+ _props$showBI = _props.showBI,
370
+ showBI = _props$showBI === undefined ? false : _props$showBI,
371
+ _props$lgInfeedAd = _props.lgInfeedAd,
372
+ lgInfeedAd = _props$lgInfeedAd === undefined ? false : _props$lgInfeedAd,
373
+ totalDataCount = _props.totalDataCount;
374
+ var _state = this.state,
375
+ data = _state.data,
376
+ itemsPerPage = _state.itemsPerPage,
377
+ currentPage = _state.currentPage,
378
+ isDataLoading = _state.isDataLoading;
379
+
380
+ return React__default.createElement(
381
+ 'div',
382
+ { className: 'contentDeck' },
383
+ isDataLoading ? React__default.createElement(
384
+ 'div',
385
+ { className: 'd-flex justify-content-center', style: { marginTop: '100px' } },
386
+ React__default.createElement(
387
+ Spinner,
388
+ { animation: 'border', role: 'status' },
389
+ React__default.createElement(
390
+ 'span',
391
+ { className: 'sr-only' },
392
+ 'Loading...'
393
+ )
394
+ )
395
+ ) : data && data.length > 0 ? React__default.createElement(
396
+ Container,
397
+ null,
398
+ this.cardLoader({ variant: variant, brandInsightAd: brandInsightAd, showBI: showBI, lgInfeedAd: lgInfeedAd }),
399
+ React__default.createElement(
400
+ 'div',
401
+ { className: 'pagination-wrapper' },
402
+ React__default.createElement(Pagination, {
403
+ pageCount: Math.ceil(totalDataCount / itemsPerPage),
404
+ pageRangeDisplayed: main_43 ? 3 : 9,
405
+ currentPage: currentPage,
406
+ onPageChange: this.handlePageChange
407
+ }),
408
+ React__default.createElement(
409
+ 'style',
410
+ { jsx: 'true' },
411
+ '\n .pagination-wrapper {\n margin: 3rem 0;\n }\n @media only screen and (max-width: 768px) {\n .pagination-wrapper {\n margin-bottom: 6rem;\n }\n }\n '
412
+ )
413
+ )
414
+ ) : null
415
+ );
416
+ }
417
+ }], [{
418
+ key: 'getDerivedStateFromProps',
419
+ value: function getDerivedStateFromProps(props, state) {
420
+ if (_JSON$stringify(props.dataRecord) !== _JSON$stringify(state.prevData)) {
421
+ return {
422
+ data: props.dataRecord,
423
+ prevData: props.dataRecord,
424
+ currentPage: props.currentPage
425
+ };
426
+ }
427
+ return null;
428
+ }
429
+ // Passing 'brandInsightAd','showBI' and 'lgInfeedAd'
430
+
431
+ }]);
432
+
433
+ return MasterDeck;
434
+ }(React__default.Component);
435
+
436
+ var MasterDeck$1 = withRouter(MasterDeck);
437
+
438
+ export default MasterDeck$1;