@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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- # mjh-framework v. 1.0.124
2
+ # mjh-framework v. 1.0.126
3
3
 
4
4
 
5
5
  > Foundation Framework
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import React__default, { Component, useState, useEffect, useRef, createContext, createElement } from 'react';
1
+ import React__default, { Component, useState, useEffect, useRef, createElement, createContext } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import reactDom from 'react-dom';
4
4
  import Container from 'react-bootstrap/Container';
@@ -12646,6 +12646,380 @@ var VideoSeriesListing = function (_React$Component) {
12646
12646
  }(React__default.Component);
12647
12647
  var VideoSeriesListing$1 = withRouter(VideoSeriesListing);
12648
12648
 
12649
+ var MasterDeck = function (_React$Component) {
12650
+ inherits(MasterDeck, _React$Component);
12651
+
12652
+ function MasterDeck() {
12653
+ var _ref,
12654
+ _this2 = this;
12655
+
12656
+ var _temp, _this, _ret;
12657
+
12658
+ classCallCheck(this, MasterDeck);
12659
+
12660
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
12661
+ args[_key] = arguments[_key];
12662
+ }
12663
+
12664
+ 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 = {
12665
+ data: _this.data,
12666
+ dataKeptToCompareNewDatarecord: _this.data,
12667
+ per: _this.params ? _this.params.to : 2,
12668
+ page: _this.props.currentPage || 1,
12669
+ from: _this.params ? _this.params.from : 0,
12670
+ to: _this.params ? _this.params.to : 2,
12671
+ total_pages: null,
12672
+ scrolling: true,
12673
+ query: _this.query,
12674
+ currentPage: _this.props.currentPage || 1
12675
+ }, _this.loadMore = debounce_1(function () {
12676
+ _this.setState(function (state) {
12677
+ var page = state.page,
12678
+ from = state.from,
12679
+ per = state.per,
12680
+ to = state.to;
12681
+
12682
+ return {
12683
+ page: page + 1,
12684
+ from: from + per,
12685
+ to: to + per
12686
+ };
12687
+ }, _this.loadData);
12688
+ }, 0), _this.loadData = function () {
12689
+ var _this$state = _this.state,
12690
+ from = _this$state.from,
12691
+ to = _this$state.to,
12692
+ data = _this$state.data,
12693
+ query = _this$state.query,
12694
+ page = _this$state.page;
12695
+ var _this$props = _this.props,
12696
+ client = _this$props.client,
12697
+ dataHandler = _this$props.dataHandler;
12698
+
12699
+
12700
+ var params = _extends({}, _this.params, { from: from, to: to });
12701
+
12702
+ if (dataHandler) {
12703
+ var dataHandlerPromise = new Promise(function (resolve, reject) {
12704
+ try {
12705
+ var result = dataHandler(params);
12706
+ resolve(result);
12707
+ } catch (e) {
12708
+ reject(e);
12709
+ }
12710
+ });
12711
+ dataHandlerPromise.then(function (dataArr) {
12712
+ loadDataFinished(data, dataArr, page);
12713
+ });
12714
+ } else {
12715
+ client.fetch(query, params).then(function (dataArr) {
12716
+ loadDataFinished(data, dataArr, page);
12717
+ });
12718
+ }
12719
+ }, _this.loadDataFinished = function (data, dataArr, page) {
12720
+ if (_this.pointer && _this.pointerArray) {
12721
+ var pointer = _this.pointer;
12722
+ dataArr = dataArr[_this.pointerArray][pointer];
12723
+ }
12724
+ dataArr = dataArr.map(function (item) {
12725
+ return _extends({}, item, {
12726
+ pageNumber: page
12727
+ });
12728
+ });
12729
+
12730
+ _this.setState(function () {
12731
+ if (dataArr.length > 0) {
12732
+ return {
12733
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
12734
+ scrolling: true
12735
+ };
12736
+ } else {
12737
+ return {
12738
+ scrolling: false
12739
+ };
12740
+ }
12741
+ });
12742
+ }, _this.urlFor = function (source) {
12743
+ var client = _this.props.client;
12744
+
12745
+ var builder = imageUrlBuilder(client);
12746
+ return builder.image(source);
12747
+ }, _this.renderCardImage = function (row, page) {
12748
+ if (row.thumbnail && row.thumbnail.asset) {
12749
+ var url = _this.urlFor(row.thumbnail);
12750
+ if (_this.props.imageHeight) url = url.height(_this.props.imageHeight);
12751
+ if (_this.props.imageWidth) url = url.width(_this.props.imageWidth);
12752
+ return url.url();
12753
+ } else {
12754
+ return _this.defaultImage;
12755
+ }
12756
+ }, _this.changePageNumber = function (pageNumber) {
12757
+ console.log(pageNumber);
12758
+ var _this$props2 = _this.props,
12759
+ seoPaginate = _this$props2.seoPaginate,
12760
+ pageview = _this$props2.pageview,
12761
+ router = _this$props2.router;
12762
+ var currentPage = _this.state.currentPage;
12763
+
12764
+ if (seoPaginate) {
12765
+ var path = router.asPath;
12766
+ var qrIndex = path.indexOf('?');
12767
+ var pathname = router.pathname;
12768
+ var queryString = '';
12769
+
12770
+ if (qrIndex > 0) {
12771
+ path = path.substring(1, qrIndex);
12772
+
12773
+ var partialQS = router.asPath.substring(qrIndex + 1);
12774
+ var partialQSArr = partialQS.split('&');
12775
+
12776
+ // exclude page=xxx from query string
12777
+ partialQSArr.map(function (item) {
12778
+ var itemArr = item.split('=');
12779
+ var key = itemArr[0];
12780
+ var val = itemArr[1];
12781
+
12782
+ if (key !== 'page') {
12783
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
12784
+ }
12785
+ });
12786
+ }
12787
+
12788
+ if (queryString.length > 0) {
12789
+ path += '?' + queryString;
12790
+ }
12791
+
12792
+ pageNumber = parseInt(pageNumber);
12793
+
12794
+ if (currentPage !== pageNumber) {
12795
+ lib_3.refresh();
12796
+ if (pageview) {
12797
+ _this.setState({
12798
+ currentPage: pageNumber
12799
+ }, function () {
12800
+ if (path[0] !== '/') {
12801
+ path = '/' + path;
12802
+ }
12803
+
12804
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
12805
+
12806
+ // please leave this for later debug purpose : Yong Jun.
12807
+ /* console.log('page change reported', {
12808
+ currentPage: currentPage,
12809
+ pageNumber: pageNumber,
12810
+ pathname: pathname,
12811
+ path: path,
12812
+ newPath: newPath,
12813
+ firstPage: pageNumber === 1,
12814
+ queryString: queryString
12815
+ }) */
12816
+
12817
+ pageview(newPath);
12818
+
12819
+ router.push(pathname, newPath, {
12820
+ shallow: true
12821
+ });
12822
+ });
12823
+ }
12824
+ }
12825
+ }
12826
+ }, _this.renderAuthor = function (authorDetail, index$$1, length) {
12827
+ if (authorDetail) {
12828
+ var _id = authorDetail._id,
12829
+ displayName = authorDetail.displayName,
12830
+ url = authorDetail.url;
12831
+
12832
+ if (displayName && url && url.current) {
12833
+ return React__default.createElement(
12834
+ 'div',
12835
+ { key: _id },
12836
+ index$$1 === 0 && React__default.createElement(
12837
+ 'span',
12838
+ { className: 'pr-1' },
12839
+ 'By'
12840
+ ),
12841
+ React__default.createElement(
12842
+ Link,
12843
+ { href: '/authors/[url]', as: '/authors/' + url.current },
12844
+ React__default.createElement(
12845
+ 'a',
12846
+ { className: 'text-muted' },
12847
+ displayName,
12848
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12849
+ )
12850
+ )
12851
+ );
12852
+ } else if (displayName) {
12853
+ return React__default.createElement(
12854
+ 'div',
12855
+ { key: _id },
12856
+ index$$1 === 0 && React__default.createElement(
12857
+ 'span',
12858
+ { className: 'pr-1' },
12859
+ 'By'
12860
+ ),
12861
+ React__default.createElement(
12862
+ 'span',
12863
+ { className: 'text-muted' },
12864
+ displayName,
12865
+ length !== index$$1 + 1 && React__default.createElement('br', null)
12866
+ )
12867
+ );
12868
+ }
12869
+ } else return null;
12870
+ }, _this.cardLoader = function (page, columns, variant) {
12871
+
12872
+ var itemCounter = 0;
12873
+ return React__default.createElement(
12874
+ Row,
12875
+ null,
12876
+ _this.state.data && _this.state.data.map(function (row, index$$1) {
12877
+
12878
+ var pageNumber = row.pageNumber || _this.state.page;
12879
+ var contentCategoryName = row.contentCategory && row.contentCategory.name && _this.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
12880
+
12881
+ return React__default.createElement(
12882
+ React__default.Fragment,
12883
+ null,
12884
+ React__default.createElement(
12885
+ VisibilitySensor,
12886
+ {
12887
+ key: itemCounter,
12888
+ onChange: function onChange(isVisible) {
12889
+ isVisible && _this.changePageNumber(pageNumber);
12890
+ } },
12891
+ React__default.createElement(_this2.Deck, { data: row, variant: variant, index: index$$1 })
12892
+ )
12893
+ );
12894
+ })
12895
+ );
12896
+ }, _this.renderMobileAd = function (index$$1, numberOfItemsBeforeAd) {
12897
+ var rightItems = _this.props.rightItems;
12898
+
12899
+ var i = ((index$$1 + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
12900
+ return React__default.createElement(
12901
+ 'div',
12902
+ null,
12903
+ rightItems[i].component
12904
+ );
12905
+ }, _this.renderManualPagination = function () {
12906
+ var currentPage = _this.state.currentPage;
12907
+
12908
+ return React__default.createElement(
12909
+ 'div',
12910
+ { className: 'd-flex justify-content-between' },
12911
+ currentPage && currentPage > 1 && React__default.createElement(
12912
+ 'a',
12913
+ { href: '?page=' + (currentPage - 1) },
12914
+ '<< Previous'
12915
+ ),
12916
+ React__default.createElement(
12917
+ 'a',
12918
+ { href: '?page=' + (currentPage + 1) },
12919
+ 'Next >>'
12920
+ )
12921
+ );
12922
+ }, _temp), possibleConstructorReturn(_this, _ret);
12923
+ }
12924
+
12925
+ createClass(MasterDeck, [{
12926
+ key: 'componentDidUpdate',
12927
+ value: function componentDidUpdate(prevProps, prevState) {
12928
+ if (this.state.dataKeptToCompareNewDatarecord !== this.props.dataRecord) {
12929
+ // eslint-disable-next-line react/no-did-update-set-state
12930
+ this.setState({
12931
+ data: this.props.dataRecord,
12932
+ dataKeptToCompareNewDatarecord: this.props.dataRecord,
12933
+ per: this.props.params ? this.props.params.to : 2,
12934
+ page: 1,
12935
+ from: this.props.params ? this.props.params.from : 0,
12936
+ to: this.props.params ? this.props.params.to : 2,
12937
+ total_pages: null,
12938
+ scrolling: true,
12939
+ query: this.props.query
12940
+ });
12941
+ }
12942
+ }
12943
+ }, {
12944
+ key: 'componentDidMount',
12945
+ value: function componentDidMount() {
12946
+ // this.loadData();
12947
+ }
12948
+ }, {
12949
+ key: 'render',
12950
+ value: function render() {
12951
+ var _this3 = this;
12952
+
12953
+ var _props = this.props,
12954
+ columns = _props.columns,
12955
+ variant = _props.variant,
12956
+ autoScroll = _props.autoScroll,
12957
+ page = _props.page;
12958
+
12959
+
12960
+ return React__default.createElement(
12961
+ 'div',
12962
+ { className: 'contentDeck' },
12963
+ autoScroll ? React__default.createElement(
12964
+ React__default.Fragment,
12965
+ null,
12966
+ React__default.createElement(
12967
+ InfiniteScroll,
12968
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling, scrollThreshold: 0.9 },
12969
+ React__default.createElement(
12970
+ Container,
12971
+ null,
12972
+ this.cardLoader(page, columns, variant)
12973
+ )
12974
+ ),
12975
+ React__default.createElement(
12976
+ 'noscript',
12977
+ null,
12978
+ this.renderManualPagination()
12979
+ )
12980
+ ) : React__default.createElement(
12981
+ React__default.Fragment,
12982
+ null,
12983
+ React__default.createElement(
12984
+ Container,
12985
+ null,
12986
+ this.cardLoader(page, columns, variant)
12987
+ ),
12988
+ React__default.createElement(
12989
+ 'div',
12990
+ { style: { padding: '0px 10px' } },
12991
+ this.state.scrolling ? React__default.createElement(
12992
+ 'button',
12993
+ {
12994
+ style: { margin: 'auto', width: '100%' },
12995
+ onClick: function onClick(e) {
12996
+ _this3.loadMore();
12997
+ } },
12998
+ 'Load More'
12999
+ ) : React__default.createElement(
13000
+ 'p',
13001
+ { style: { textAlign: 'center' } },
13002
+ React__default.createElement(
13003
+ 'b',
13004
+ null,
13005
+ 'End of data'
13006
+ )
13007
+ )
13008
+ ),
13009
+ React__default.createElement(
13010
+ 'noscript',
13011
+ null,
13012
+ this.renderManualPagination()
13013
+ )
13014
+ )
13015
+ );
13016
+ }
13017
+ }]);
13018
+ return MasterDeck;
13019
+ }(React__default.Component);
13020
+
13021
+ var MasterDeck$1 = withRouter(MasterDeck);
13022
+
12649
13023
  var PublicationDeck = function PublicationDeck(props) {
12650
13024
  var data = props.data,
12651
13025
  imageHeight = props.imageHeight,
@@ -18014,7 +18388,8 @@ var BlockContent = SanityBlockContent;
18014
18388
 
18015
18389
  var Sidebar = function Sidebar(_ref) {
18016
18390
  var caption = _ref.caption,
18017
- content = _ref.content;
18391
+ content = _ref.content,
18392
+ serializerArguments = _ref.serializerArguments;
18018
18393
 
18019
18394
  return React__default.createElement(
18020
18395
  'article',
@@ -18027,12 +18402,12 @@ var Sidebar = function Sidebar(_ref) {
18027
18402
  null,
18028
18403
  caption
18029
18404
  ),
18030
- React__default.createElement(BlockContent, { blocks: content })
18405
+ React__default.createElement(BlockContent, { blocks: content, serializers: getSerializers$1(serializerArguments) })
18031
18406
  ),
18032
18407
  React__default.createElement(
18033
18408
  'style',
18034
18409
  { jsx: 'true' },
18035
- '\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 '
18410
+ '\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 '
18036
18411
  )
18037
18412
  );
18038
18413
  };
@@ -25508,7 +25883,6 @@ var html_decode = function html_decode(string) {
25508
25883
  var html_decode_1 = html_decode;
25509
25884
 
25510
25885
  var convertEntities = function convertEntities(props) {
25511
-
25512
25886
  if (typeof props === 'string' || props instanceof String) {
25513
25887
  props = html_decode_1(props);
25514
25888
  }
@@ -25558,7 +25932,7 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
25558
25932
  var caption = node.caption,
25559
25933
  content = node.content;
25560
25934
 
25561
- return React__default.createElement(Sidebar, { caption: caption, content: content });
25935
+ return React__default.createElement(Sidebar, { caption: caption, content: content, serializerArguments: (drupalLeadSettings) });
25562
25936
  },
25563
25937
  datatable: function datatable(_ref6) {
25564
25938
  var node = _ref6.node;
@@ -26186,5 +26560,5 @@ var PdfDownload = function PdfDownload(props) {
26186
26560
  );
26187
26561
  };
26188
26562
 
26189
- export { ContentCard as DeckContent, GridContent$1 as GridContent, Queue as DeckQueue, ThumbnailCard, TaxonomyCard, GroupDeck, YoutubeGroup, QueueDeckExpanded, VideoSeriesListing$1 as VideoSeriesListing, PublicationDeck, IssueDeck, IssueContentDeck, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, SocialShare, PageFilter, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD, AD300x250, AD300x250x600, AD728x90, ADFooter, getSerializers$1 as getSerializers, Search, Feature, Breadcrumbs, SetCookie, Hero, AlphabeticList, PdfDownload };
26563
+ export { ContentCard as DeckContent, GridContent$1 as GridContent, Queue as DeckQueue, ThumbnailCard, TaxonomyCard, GroupDeck, YoutubeGroup, QueueDeckExpanded, VideoSeriesListing$1 as VideoSeriesListing, MasterDeck$1 as MasterDeck, PublicationDeck, IssueDeck, IssueContentDeck, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, SocialShare, PageFilter, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD, AD300x250, AD300x250x600, AD728x90, ADFooter, getSerializers$1 as getSerializers, Search, Feature, Breadcrumbs, SetCookie, Hero, AlphabeticList, PdfDownload };
26190
26564
  //# sourceMappingURL=index.es.js.map