@mjhls/mjh-framework 1.0.123 → 1.0.125

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,363 @@ 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 client = _this.props.client;
12703
+
12704
+
12705
+ var params = _extends({}, _this.params, { from: from, to: to
12706
+ // const queryUpdated = query.replace('$from', params.from).replace('$to', params.to)
12707
+ // const query = '*[_type == "article" && defined(title) && defined(thumbnail)][$from...$to] { title, summary, thumbnail { asset-> }, url }'
12708
+ });client.fetch(query, params).then(function (dataArr) {
12709
+ if (_this.pointer && _this.pointerArray) {
12710
+ var pointer = _this.pointer;
12711
+ dataArr = dataArr[_this.pointerArray][pointer];
12712
+ }
12713
+ dataArr = dataArr.map(function (item) {
12714
+ return _extends({}, item, {
12715
+ pageNumber: page
12716
+ });
12717
+ });
12718
+
12719
+ _this.setState(function () {
12720
+ if (dataArr.length > 0) {
12721
+ return {
12722
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12723
+ scrolling: true
12724
+ };
12725
+ } else {
12726
+ return {
12727
+ scrolling: false
12728
+ };
12729
+ }
12730
+ });
12731
+ });
12732
+ }, _this.urlFor = function (source) {
12733
+ var client = _this.props.client;
12734
+
12735
+ var builder = imageUrlBuilder(client);
12736
+ return builder.image(source);
12737
+ }, _this.renderCardImage = function (row, page) {
12738
+ if (row.thumbnail && row.thumbnail.asset) {
12739
+ var url = _this.urlFor(row.thumbnail);
12740
+ if (_this.props.imageHeight) url = url.height(_this.props.imageHeight);
12741
+ if (_this.props.imageWidth) url = url.width(_this.props.imageWidth);
12742
+ return url.url();
12743
+ } else {
12744
+ return _this.defaultImage;
12745
+ }
12746
+ }, _this.changePageNumber = function (pageNumber) {
12747
+ console.log(pageNumber);
12748
+ var _this$props = _this.props,
12749
+ seoPaginate = _this$props.seoPaginate,
12750
+ pageview = _this$props.pageview,
12751
+ router$$1 = _this$props.router;
12752
+ var currentPage = _this.state.currentPage;
12753
+
12754
+ if (seoPaginate) {
12755
+ var path = router$$1.asPath;
12756
+ var qrIndex = path.indexOf('?');
12757
+ var pathname = router$$1.pathname;
12758
+ var queryString = '';
12759
+
12760
+ if (qrIndex > 0) {
12761
+ path = path.substring(1, qrIndex);
12762
+
12763
+ var partialQS = router$$1.asPath.substring(qrIndex + 1);
12764
+ var partialQSArr = partialQS.split('&');
12765
+
12766
+ // exclude page=xxx from query string
12767
+ partialQSArr.map(function (item) {
12768
+ var itemArr = item.split('=');
12769
+ var key = itemArr[0];
12770
+ var val = itemArr[1];
12771
+
12772
+ if (key !== 'page') {
12773
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
12774
+ }
12775
+ });
12776
+ }
12777
+
12778
+ if (queryString.length > 0) {
12779
+ path += '?' + queryString;
12780
+ }
12781
+
12782
+ pageNumber = parseInt(pageNumber);
12783
+
12784
+ if (currentPage !== pageNumber) {
12785
+ lib_3.refresh();
12786
+ if (pageview) {
12787
+ _this.setState({
12788
+ currentPage: pageNumber
12789
+ }, function () {
12790
+ if (path[0] !== '/') {
12791
+ path = '/' + path;
12792
+ }
12793
+
12794
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
12795
+
12796
+ // please leave this for later debug purpose : Yong Jun.
12797
+ /* console.log('page change reported', {
12798
+ currentPage: currentPage,
12799
+ pageNumber: pageNumber,
12800
+ pathname: pathname,
12801
+ path: path,
12802
+ newPath: newPath,
12803
+ firstPage: pageNumber === 1,
12804
+ queryString: queryString
12805
+ }) */
12806
+
12807
+ pageview(newPath);
12808
+
12809
+ router$$1.push(pathname, newPath, {
12810
+ shallow: true
12811
+ });
12812
+ });
12813
+ }
12814
+ }
12815
+ }
12816
+ }, _this.renderAuthor = function (authorDetail, index$$1, length) {
12817
+ if (authorDetail) {
12818
+ var _id = authorDetail._id,
12819
+ displayName = authorDetail.displayName,
12820
+ url = authorDetail.url;
12821
+
12822
+ if (displayName && url && url.current) {
12823
+ return React__default.createElement(
12824
+ 'div',
12825
+ { key: _id },
12826
+ index$$1 === 0 && React__default.createElement(
12827
+ 'span',
12828
+ { className: 'pr-1' },
12829
+ 'By'
12830
+ ),
12831
+ React__default.createElement(
12832
+ Link,
12833
+ { href: '/authors/[url]', as: '/authors/' + url.current },
12834
+ React__default.createElement(
12835
+ 'a',
12836
+ { className: 'text-muted' },
12837
+ displayName,
12838
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12839
+ )
12840
+ )
12841
+ );
12842
+ } else if (displayName) {
12843
+ return React__default.createElement(
12844
+ 'div',
12845
+ { key: _id },
12846
+ index$$1 === 0 && React__default.createElement(
12847
+ 'span',
12848
+ { className: 'pr-1' },
12849
+ 'By'
12850
+ ),
12851
+ React__default.createElement(
12852
+ 'span',
12853
+ { className: 'text-muted' },
12854
+ displayName,
12855
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12856
+ )
12857
+ );
12858
+ }
12859
+ } else return null;
12860
+ }, _this.cardLoader = function (page, columns, variant) {
12861
+
12862
+ var itemCounter = 0;
12863
+ return React__default.createElement(
12864
+ Row,
12865
+ null,
12866
+ _this.state.data && _this.state.data.map(function (row, index$$1) {
12867
+
12868
+ var pageNumber = row.pageNumber || _this.state.page;
12869
+ var contentCategoryName = row.contentCategory && row.contentCategory.name && _this.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
12870
+
12871
+ return React__default.createElement(
12872
+ React__default.Fragment,
12873
+ null,
12874
+ React__default.createElement(
12875
+ VisibilitySensor,
12876
+ {
12877
+ key: itemCounter,
12878
+ onChange: function onChange(isVisible) {
12879
+ isVisible && _this.changePageNumber(pageNumber);
12880
+ } },
12881
+ React__default.createElement(_this2.Deck, { data: row, variant: variant, index: index$$1 })
12882
+ )
12883
+ );
12884
+ })
12885
+ );
12886
+ }, _this.renderMobileAd = function (index$$1, numberOfItemsBeforeAd) {
12887
+ var rightItems = _this.props.rightItems;
12888
+
12889
+ var i = ((index$$1 + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
12890
+ return React__default.createElement(
12891
+ 'div',
12892
+ null,
12893
+ rightItems[i].component
12894
+ );
12895
+ }, _this.renderManualPagination = function () {
12896
+ var currentPage = _this.state.currentPage;
12897
+
12898
+ return React__default.createElement(
12899
+ 'div',
12900
+ { className: 'd-flex justify-content-between' },
12901
+ currentPage && currentPage > 1 && React__default.createElement(
12902
+ 'a',
12903
+ { href: '?page=' + (currentPage - 1) },
12904
+ '<< Previous'
12905
+ ),
12906
+ React__default.createElement(
12907
+ 'a',
12908
+ { href: '?page=' + (currentPage + 1) },
12909
+ 'Next >>'
12910
+ )
12911
+ );
12912
+ }, _temp), possibleConstructorReturn(_this, _ret);
12913
+ }
12914
+
12915
+ createClass(MasterDeck, [{
12916
+ key: 'componentDidUpdate',
12917
+ value: function componentDidUpdate(prevProps, prevState) {
12918
+ if (this.state.dataKeptToCompareNewDatarecord !== this.props.dataRecord) {
12919
+ // eslint-disable-next-line react/no-did-update-set-state
12920
+ this.setState({
12921
+ data: this.props.dataRecord,
12922
+ dataKeptToCompareNewDatarecord: this.props.dataRecord,
12923
+ per: this.props.params ? this.props.params.to : 2,
12924
+ page: 1,
12925
+ from: this.props.params ? this.props.params.from : 0,
12926
+ to: this.props.params ? this.props.params.to : 2,
12927
+ total_pages: null,
12928
+ scrolling: true,
12929
+ query: this.props.query
12930
+ });
12931
+ }
12932
+ }
12933
+ }, {
12934
+ key: 'componentDidMount',
12935
+ value: function componentDidMount() {
12936
+ // this.loadData();
12937
+ }
12938
+ }, {
12939
+ key: 'render',
12940
+ value: function render() {
12941
+ var _this3 = this;
12942
+
12943
+ var _props = this.props,
12944
+ columns = _props.columns,
12945
+ variant = _props.variant,
12946
+ autoScroll = _props.autoScroll,
12947
+ page = _props.page;
12948
+
12949
+
12950
+ return React__default.createElement(
12951
+ 'div',
12952
+ { className: 'contentDeck' },
12953
+ autoScroll ? React__default.createElement(
12954
+ React__default.Fragment,
12955
+ null,
12956
+ React__default.createElement(
12957
+ InfiniteScroll,
12958
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling, scrollThreshold: 0.9 },
12959
+ React__default.createElement(
12960
+ Container,
12961
+ null,
12962
+ this.cardLoader(page, columns, variant)
12963
+ )
12964
+ ),
12965
+ React__default.createElement(
12966
+ 'noscript',
12967
+ null,
12968
+ this.renderManualPagination()
12969
+ )
12970
+ ) : React__default.createElement(
12971
+ React__default.Fragment,
12972
+ null,
12973
+ React__default.createElement(
12974
+ Container,
12975
+ null,
12976
+ this.cardLoader(page, columns, variant)
12977
+ ),
12978
+ React__default.createElement(
12979
+ 'div',
12980
+ { style: { padding: '0px 10px' } },
12981
+ this.state.scrolling ? React__default.createElement(
12982
+ 'button',
12983
+ {
12984
+ style: { margin: 'auto', width: '100%' },
12985
+ onClick: function onClick(e) {
12986
+ _this3.loadMore();
12987
+ } },
12988
+ 'Load More'
12989
+ ) : React__default.createElement(
12990
+ 'p',
12991
+ { style: { textAlign: 'center' } },
12992
+ React__default.createElement(
12993
+ 'b',
12994
+ null,
12995
+ 'End of data'
12996
+ )
12997
+ )
12998
+ ),
12999
+ React__default.createElement(
13000
+ 'noscript',
13001
+ null,
13002
+ this.renderManualPagination()
13003
+ )
13004
+ )
13005
+ );
13006
+ }
13007
+ }]);
13008
+ return MasterDeck;
13009
+ }(React__default.Component);
13010
+
13011
+ var MasterDeck$1 = router.withRouter(MasterDeck);
13012
+
12656
13013
  var PublicationDeck = function PublicationDeck(props) {
12657
13014
  var data = props.data,
12658
13015
  imageHeight = props.imageHeight,
@@ -18021,7 +18378,8 @@ var BlockContent = SanityBlockContent;
18021
18378
 
18022
18379
  var Sidebar = function Sidebar(_ref) {
18023
18380
  var caption = _ref.caption,
18024
- content = _ref.content;
18381
+ content = _ref.content,
18382
+ serializerArguments = _ref.serializerArguments;
18025
18383
 
18026
18384
  return React__default.createElement(
18027
18385
  'article',
@@ -18034,12 +18392,12 @@ var Sidebar = function Sidebar(_ref) {
18034
18392
  null,
18035
18393
  caption
18036
18394
  ),
18037
- React__default.createElement(BlockContent, { blocks: content })
18395
+ React__default.createElement(BlockContent, { blocks: content, serializers: getSerializers$1(serializerArguments) })
18038
18396
  ),
18039
18397
  React__default.createElement(
18040
18398
  'style',
18041
18399
  { 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 '
18400
+ '\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
18401
  )
18044
18402
  );
18045
18403
  };
@@ -25515,7 +25873,6 @@ var html_decode = function html_decode(string) {
25515
25873
  var html_decode_1 = html_decode;
25516
25874
 
25517
25875
  var convertEntities = function convertEntities(props) {
25518
-
25519
25876
  if (typeof props === 'string' || props instanceof String) {
25520
25877
  props = html_decode_1(props);
25521
25878
  }
@@ -25565,7 +25922,7 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
25565
25922
  var caption = node.caption,
25566
25923
  content = node.content;
25567
25924
 
25568
- return React__default.createElement(Sidebar, { caption: caption, content: content });
25925
+ return React__default.createElement(Sidebar, { caption: caption, content: content, serializerArguments: (drupalLeadSettings) });
25569
25926
  },
25570
25927
  datatable: function datatable(_ref6) {
25571
25928
  var node = _ref6.node;
@@ -25685,9 +26042,14 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
25685
26042
  // feature_img { asset-> {url} }
25686
26043
  // }`
25687
26044
 
26045
+ //Update* Added control toggle for features. Will default to off -
26046
+ //<Feature controls dataset={props.features} /></div>
25688
26047
 
25689
26048
  var Feature = function Feature(props) {
25690
26049
  var dataset = props.dataset;
26050
+ var _props$controls = props.controls,
26051
+ controls = _props$controls === undefined ? false : _props$controls;
26052
+
25691
26053
 
25692
26054
  var checkUrlIsExternal = function checkUrlIsExternal(url) {
25693
26055
  if (/(http|https?)([^\s]+)/g.test(url)) {
@@ -25743,7 +26105,7 @@ var Feature = function Feature(props) {
25743
26105
  null,
25744
26106
  React__default.createElement(
25745
26107
  Carousel,
25746
- { touch: true },
26108
+ { touch: true, controls: controls },
25747
26109
  dataset.map(function (feature, index) {
25748
26110
  var feature_title = feature.feature_title,
25749
26111
  feature_body = feature.feature_body,
@@ -26197,6 +26559,7 @@ exports.GroupDeck = GroupDeck;
26197
26559
  exports.YoutubeGroup = YoutubeGroup;
26198
26560
  exports.QueueDeckExpanded = QueueDeckExpanded;
26199
26561
  exports.VideoSeriesListing = VideoSeriesListing$1;
26562
+ exports.MasterDeck = MasterDeck$1;
26200
26563
  exports.PublicationDeck = PublicationDeck;
26201
26564
  exports.IssueDeck = IssueDeck;
26202
26565
  exports.IssueContentDeck = IssueContentDeck;