@mjhls/mjh-framework 1.0.124 → 1.0.126

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/dist/index.js CHANGED
@@ -12653,6 +12653,380 @@ var VideoSeriesListing = function (_React$Component) {
12653
12653
  }(React__default.Component);
12654
12654
  var VideoSeriesListing$1 = router.withRouter(VideoSeriesListing);
12655
12655
 
12656
+ var MasterDeck = function (_React$Component) {
12657
+ inherits(MasterDeck, _React$Component);
12658
+
12659
+ function MasterDeck() {
12660
+ var _ref,
12661
+ _this2 = this;
12662
+
12663
+ var _temp, _this, _ret;
12664
+
12665
+ classCallCheck(this, MasterDeck);
12666
+
12667
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
12668
+ args[_key] = arguments[_key];
12669
+ }
12670
+
12671
+ 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.variant = _this.props.variant, _this.mapping = _this.props.mapping, _this.data = _this.props.dataRecord || [], _this.query = _this.props.query, _this.params = _this.props.params, _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.state = {
12672
+ data: _this.data,
12673
+ dataKeptToCompareNewDatarecord: _this.data,
12674
+ per: _this.params ? _this.params.to : 2,
12675
+ page: _this.props.currentPage || 1,
12676
+ from: _this.params ? _this.params.from : 0,
12677
+ to: _this.params ? _this.params.to : 2,
12678
+ total_pages: null,
12679
+ scrolling: true,
12680
+ query: _this.query,
12681
+ currentPage: _this.props.currentPage || 1
12682
+ }, _this.loadMore = debounce_1(function () {
12683
+ _this.setState(function (state) {
12684
+ var page = state.page,
12685
+ from = state.from,
12686
+ per = state.per,
12687
+ to = state.to;
12688
+
12689
+ return {
12690
+ page: page + 1,
12691
+ from: from + per,
12692
+ to: to + per
12693
+ };
12694
+ }, _this.loadData);
12695
+ }, 0), _this.loadData = function () {
12696
+ var _this$state = _this.state,
12697
+ from = _this$state.from,
12698
+ to = _this$state.to,
12699
+ data = _this$state.data,
12700
+ query = _this$state.query,
12701
+ page = _this$state.page;
12702
+ var _this$props = _this.props,
12703
+ client = _this$props.client,
12704
+ dataHandler = _this$props.dataHandler;
12705
+
12706
+
12707
+ var params = _extends({}, _this.params, { from: from, to: to });
12708
+
12709
+ if (dataHandler) {
12710
+ var dataHandlerPromise = new Promise(function (resolve, reject) {
12711
+ try {
12712
+ var result = dataHandler(params);
12713
+ resolve(result);
12714
+ } catch (e) {
12715
+ reject(e);
12716
+ }
12717
+ });
12718
+ dataHandlerPromise.then(function (dataArr) {
12719
+ loadDataFinished(data, dataArr, page);
12720
+ });
12721
+ } else {
12722
+ client.fetch(query, params).then(function (dataArr) {
12723
+ loadDataFinished(data, dataArr, page);
12724
+ });
12725
+ }
12726
+ }, _this.loadDataFinished = function (data, dataArr, page) {
12727
+ if (_this.pointer && _this.pointerArray) {
12728
+ var pointer = _this.pointer;
12729
+ dataArr = dataArr[_this.pointerArray][pointer];
12730
+ }
12731
+ dataArr = dataArr.map(function (item) {
12732
+ return _extends({}, item, {
12733
+ pageNumber: page
12734
+ });
12735
+ });
12736
+
12737
+ _this.setState(function () {
12738
+ if (dataArr.length > 0) {
12739
+ return {
12740
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12741
+ scrolling: true
12742
+ };
12743
+ } else {
12744
+ return {
12745
+ scrolling: false
12746
+ };
12747
+ }
12748
+ });
12749
+ }, _this.urlFor = function (source) {
12750
+ var client = _this.props.client;
12751
+
12752
+ var builder = imageUrlBuilder(client);
12753
+ return builder.image(source);
12754
+ }, _this.renderCardImage = function (row, page) {
12755
+ if (row.thumbnail && row.thumbnail.asset) {
12756
+ var url = _this.urlFor(row.thumbnail);
12757
+ if (_this.props.imageHeight) url = url.height(_this.props.imageHeight);
12758
+ if (_this.props.imageWidth) url = url.width(_this.props.imageWidth);
12759
+ return url.url();
12760
+ } else {
12761
+ return _this.defaultImage;
12762
+ }
12763
+ }, _this.changePageNumber = function (pageNumber) {
12764
+ console.log(pageNumber);
12765
+ var _this$props2 = _this.props,
12766
+ seoPaginate = _this$props2.seoPaginate,
12767
+ pageview = _this$props2.pageview,
12768
+ router$$1 = _this$props2.router;
12769
+ var currentPage = _this.state.currentPage;
12770
+
12771
+ if (seoPaginate) {
12772
+ var path = router$$1.asPath;
12773
+ var qrIndex = path.indexOf('?');
12774
+ var pathname = router$$1.pathname;
12775
+ var queryString = '';
12776
+
12777
+ if (qrIndex > 0) {
12778
+ path = path.substring(1, qrIndex);
12779
+
12780
+ var partialQS = router$$1.asPath.substring(qrIndex + 1);
12781
+ var partialQSArr = partialQS.split('&');
12782
+
12783
+ // exclude page=xxx from query string
12784
+ partialQSArr.map(function (item) {
12785
+ var itemArr = item.split('=');
12786
+ var key = itemArr[0];
12787
+ var val = itemArr[1];
12788
+
12789
+ if (key !== 'page') {
12790
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
12791
+ }
12792
+ });
12793
+ }
12794
+
12795
+ if (queryString.length > 0) {
12796
+ path += '?' + queryString;
12797
+ }
12798
+
12799
+ pageNumber = parseInt(pageNumber);
12800
+
12801
+ if (currentPage !== pageNumber) {
12802
+ lib_3.refresh();
12803
+ if (pageview) {
12804
+ _this.setState({
12805
+ currentPage: pageNumber
12806
+ }, function () {
12807
+ if (path[0] !== '/') {
12808
+ path = '/' + path;
12809
+ }
12810
+
12811
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
12812
+
12813
+ // please leave this for later debug purpose : Yong Jun.
12814
+ /* console.log('page change reported', {
12815
+ currentPage: currentPage,
12816
+ pageNumber: pageNumber,
12817
+ pathname: pathname,
12818
+ path: path,
12819
+ newPath: newPath,
12820
+ firstPage: pageNumber === 1,
12821
+ queryString: queryString
12822
+ }) */
12823
+
12824
+ pageview(newPath);
12825
+
12826
+ router$$1.push(pathname, newPath, {
12827
+ shallow: true
12828
+ });
12829
+ });
12830
+ }
12831
+ }
12832
+ }
12833
+ }, _this.renderAuthor = function (authorDetail, index$$1, length) {
12834
+ if (authorDetail) {
12835
+ var _id = authorDetail._id,
12836
+ displayName = authorDetail.displayName,
12837
+ url = authorDetail.url;
12838
+
12839
+ if (displayName && url && url.current) {
12840
+ return React__default.createElement(
12841
+ 'div',
12842
+ { key: _id },
12843
+ index$$1 === 0 && React__default.createElement(
12844
+ 'span',
12845
+ { className: 'pr-1' },
12846
+ 'By'
12847
+ ),
12848
+ React__default.createElement(
12849
+ Link,
12850
+ { href: '/authors/[url]', as: '/authors/' + url.current },
12851
+ React__default.createElement(
12852
+ 'a',
12853
+ { className: 'text-muted' },
12854
+ displayName,
12855
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12856
+ )
12857
+ )
12858
+ );
12859
+ } else if (displayName) {
12860
+ return React__default.createElement(
12861
+ 'div',
12862
+ { key: _id },
12863
+ index$$1 === 0 && React__default.createElement(
12864
+ 'span',
12865
+ { className: 'pr-1' },
12866
+ 'By'
12867
+ ),
12868
+ React__default.createElement(
12869
+ 'span',
12870
+ { className: 'text-muted' },
12871
+ displayName,
12872
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12873
+ )
12874
+ );
12875
+ }
12876
+ } else return null;
12877
+ }, _this.cardLoader = function (page, columns, variant) {
12878
+
12879
+ var itemCounter = 0;
12880
+ return React__default.createElement(
12881
+ Row,
12882
+ null,
12883
+ _this.state.data && _this.state.data.map(function (row, index$$1) {
12884
+
12885
+ var pageNumber = row.pageNumber || _this.state.page;
12886
+ var contentCategoryName = row.contentCategory && row.contentCategory.name && _this.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
12887
+
12888
+ return React__default.createElement(
12889
+ React__default.Fragment,
12890
+ null,
12891
+ React__default.createElement(
12892
+ VisibilitySensor,
12893
+ {
12894
+ key: itemCounter,
12895
+ onChange: function onChange(isVisible) {
12896
+ isVisible && _this.changePageNumber(pageNumber);
12897
+ } },
12898
+ React__default.createElement(_this2.Deck, { data: row, variant: variant, index: index$$1 })
12899
+ )
12900
+ );
12901
+ })
12902
+ );
12903
+ }, _this.renderMobileAd = function (index$$1, numberOfItemsBeforeAd) {
12904
+ var rightItems = _this.props.rightItems;
12905
+
12906
+ var i = ((index$$1 + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
12907
+ return React__default.createElement(
12908
+ 'div',
12909
+ null,
12910
+ rightItems[i].component
12911
+ );
12912
+ }, _this.renderManualPagination = function () {
12913
+ var currentPage = _this.state.currentPage;
12914
+
12915
+ return React__default.createElement(
12916
+ 'div',
12917
+ { className: 'd-flex justify-content-between' },
12918
+ currentPage && currentPage > 1 && React__default.createElement(
12919
+ 'a',
12920
+ { href: '?page=' + (currentPage - 1) },
12921
+ '<< Previous'
12922
+ ),
12923
+ React__default.createElement(
12924
+ 'a',
12925
+ { href: '?page=' + (currentPage + 1) },
12926
+ 'Next >>'
12927
+ )
12928
+ );
12929
+ }, _temp), possibleConstructorReturn(_this, _ret);
12930
+ }
12931
+
12932
+ createClass(MasterDeck, [{
12933
+ key: 'componentDidUpdate',
12934
+ value: function componentDidUpdate(prevProps, prevState) {
12935
+ if (this.state.dataKeptToCompareNewDatarecord !== this.props.dataRecord) {
12936
+ // eslint-disable-next-line react/no-did-update-set-state
12937
+ this.setState({
12938
+ data: this.props.dataRecord,
12939
+ dataKeptToCompareNewDatarecord: this.props.dataRecord,
12940
+ per: this.props.params ? this.props.params.to : 2,
12941
+ page: 1,
12942
+ from: this.props.params ? this.props.params.from : 0,
12943
+ to: this.props.params ? this.props.params.to : 2,
12944
+ total_pages: null,
12945
+ scrolling: true,
12946
+ query: this.props.query
12947
+ });
12948
+ }
12949
+ }
12950
+ }, {
12951
+ key: 'componentDidMount',
12952
+ value: function componentDidMount() {
12953
+ // this.loadData();
12954
+ }
12955
+ }, {
12956
+ key: 'render',
12957
+ value: function render() {
12958
+ var _this3 = this;
12959
+
12960
+ var _props = this.props,
12961
+ columns = _props.columns,
12962
+ variant = _props.variant,
12963
+ autoScroll = _props.autoScroll,
12964
+ page = _props.page;
12965
+
12966
+
12967
+ return React__default.createElement(
12968
+ 'div',
12969
+ { className: 'contentDeck' },
12970
+ autoScroll ? React__default.createElement(
12971
+ React__default.Fragment,
12972
+ null,
12973
+ React__default.createElement(
12974
+ InfiniteScroll,
12975
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling, scrollThreshold: 0.9 },
12976
+ React__default.createElement(
12977
+ Container,
12978
+ null,
12979
+ this.cardLoader(page, columns, variant)
12980
+ )
12981
+ ),
12982
+ React__default.createElement(
12983
+ 'noscript',
12984
+ null,
12985
+ this.renderManualPagination()
12986
+ )
12987
+ ) : React__default.createElement(
12988
+ React__default.Fragment,
12989
+ null,
12990
+ React__default.createElement(
12991
+ Container,
12992
+ null,
12993
+ this.cardLoader(page, columns, variant)
12994
+ ),
12995
+ React__default.createElement(
12996
+ 'div',
12997
+ { style: { padding: '0px 10px' } },
12998
+ this.state.scrolling ? React__default.createElement(
12999
+ 'button',
13000
+ {
13001
+ style: { margin: 'auto', width: '100%' },
13002
+ onClick: function onClick(e) {
13003
+ _this3.loadMore();
13004
+ } },
13005
+ 'Load More'
13006
+ ) : React__default.createElement(
13007
+ 'p',
13008
+ { style: { textAlign: 'center' } },
13009
+ React__default.createElement(
13010
+ 'b',
13011
+ null,
13012
+ 'End of data'
13013
+ )
13014
+ )
13015
+ ),
13016
+ React__default.createElement(
13017
+ 'noscript',
13018
+ null,
13019
+ this.renderManualPagination()
13020
+ )
13021
+ )
13022
+ );
13023
+ }
13024
+ }]);
13025
+ return MasterDeck;
13026
+ }(React__default.Component);
13027
+
13028
+ var MasterDeck$1 = router.withRouter(MasterDeck);
13029
+
12656
13030
  var PublicationDeck = function PublicationDeck(props) {
12657
13031
  var data = props.data,
12658
13032
  imageHeight = props.imageHeight,
@@ -18021,7 +18395,8 @@ var BlockContent = SanityBlockContent;
18021
18395
 
18022
18396
  var Sidebar = function Sidebar(_ref) {
18023
18397
  var caption = _ref.caption,
18024
- content = _ref.content;
18398
+ content = _ref.content,
18399
+ serializerArguments = _ref.serializerArguments;
18025
18400
 
18026
18401
  return React__default.createElement(
18027
18402
  'article',
@@ -18034,12 +18409,12 @@ var Sidebar = function Sidebar(_ref) {
18034
18409
  null,
18035
18410
  caption
18036
18411
  ),
18037
- React__default.createElement(BlockContent, { blocks: content })
18412
+ React__default.createElement(BlockContent, { blocks: content, serializers: getSerializers$1(serializerArguments) })
18038
18413
  ),
18039
18414
  React__default.createElement(
18040
18415
  'style',
18041
18416
  { jsx: 'true' },
18042
- '\n .sidebar {\n width: 40%;\n padding: 1rem 0 0;\n margin-left: 1rem;\n margin-right: 10%;\n }\n @media screen and (max-width: 991px) {\n .sidebar {\n width: unset;\n padding: 1.25rem;\n margin-left: 1rem;\n margin-right: 1rem;\n }\n }\n '
18417
+ '\n .sidebar {\n width: 40%;\n padding: 1rem 0 0;\n margin-left: 1rem;\n margin-right: 10%;\n }\n @media screen and (max-width: 991px) {\n .sidebar {\n width: unset;\n padding: 1.25rem;\n margin-left: 1rem;\n margin-right: 1rem;\n }\n }\n '
18043
18418
  )
18044
18419
  );
18045
18420
  };
@@ -25515,7 +25890,6 @@ var html_decode = function html_decode(string) {
25515
25890
  var html_decode_1 = html_decode;
25516
25891
 
25517
25892
  var convertEntities = function convertEntities(props) {
25518
-
25519
25893
  if (typeof props === 'string' || props instanceof String) {
25520
25894
  props = html_decode_1(props);
25521
25895
  }
@@ -25565,7 +25939,7 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
25565
25939
  var caption = node.caption,
25566
25940
  content = node.content;
25567
25941
 
25568
- return React__default.createElement(Sidebar, { caption: caption, content: content });
25942
+ return React__default.createElement(Sidebar, { caption: caption, content: content, serializerArguments: (drupalLeadSettings) });
25569
25943
  },
25570
25944
  datatable: function datatable(_ref6) {
25571
25945
  var node = _ref6.node;
@@ -26202,6 +26576,7 @@ exports.GroupDeck = GroupDeck;
26202
26576
  exports.YoutubeGroup = YoutubeGroup;
26203
26577
  exports.QueueDeckExpanded = QueueDeckExpanded;
26204
26578
  exports.VideoSeriesListing = VideoSeriesListing$1;
26579
+ exports.MasterDeck = MasterDeck$1;
26205
26580
  exports.PublicationDeck = PublicationDeck;
26206
26581
  exports.IssueDeck = IssueDeck;
26207
26582
  exports.IssueContentDeck = IssueContentDeck;