@mjhls/mjh-framework 1.0.94 → 1.0.95

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.94
2
+ # mjh-framework v. 1.0.95
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, createElement, createContext } from 'react';
1
+ import React__default, { Component, useState, useEffect, useRef, createContext, createElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import reactDom from 'react-dom';
4
4
  import Container from 'react-bootstrap/Container';
@@ -7,9 +7,9 @@ import Col from 'react-bootstrap/Col';
7
7
  import Card from 'react-bootstrap/Card';
8
8
  import moment from 'moment';
9
9
  import Link from 'next/link';
10
- import { withRouter, useRouter } from 'next/router';
10
+ import Router, { withRouter, useRouter } from 'next/router';
11
11
  import Media from 'react-bootstrap/Media';
12
- import { Media as Media$1, Container as Container$1, Figure, Carousel, Table } from 'react-bootstrap';
12
+ import { Media as Media$1, Container as Container$1, Spinner, Figure, Carousel, Table } from 'react-bootstrap';
13
13
  import ListGroup from 'react-bootstrap/ListGroup';
14
14
  import Head from 'next/head';
15
15
  import Accordion from 'react-bootstrap/Accordion';
@@ -3973,8 +3973,7 @@ var DeckContent = function (_React$Component) {
3973
3973
  }
3974
3974
 
3975
3975
  var pageNumber = row.pageNumber || _this.state.page;
3976
- var contentCategoryName = row.contentCategory ? row.contentCategory.name : 'Articles';
3977
-
3976
+ var contentCategoryName = row.contentCategory && row.contentCategory.name && _this.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
3978
3977
  return React__default.createElement(
3979
3978
  VisibilitySensor,
3980
3979
  {
@@ -5366,7 +5365,7 @@ var GridContent = function (_React$Component) {
5366
5365
  { className: 'grid-container' },
5367
5366
  this.state.data && this.state.data.map(function (row, index$$1) {
5368
5367
  var pageNumber = row.pageNumber || _this2.state.page;
5369
- var contentCategoryName = row.contentCategory ? row.contentCategory.name : 'Articles';
5368
+ var contentCategoryName = row.contentCategory && row.contentCategory.name && _this2.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
5370
5369
  return React__default.createElement(
5371
5370
  VisibilitySensor,
5372
5371
  {
@@ -5502,74 +5501,151 @@ var DeckQueue = function (_React$Component) {
5502
5501
  args[_key] = arguments[_key];
5503
5502
  }
5504
5503
 
5505
- return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = DeckQueue.__proto__ || Object.getPrototypeOf(DeckQueue)).call.apply(_ref, [this].concat(args))), _this), _this.page = _this.props.page, _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.state = {
5504
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = DeckQueue.__proto__ || Object.getPrototypeOf(DeckQueue)).call.apply(_ref, [this].concat(args))), _this), _this.page = _this.props.page, _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 = {
5506
5505
  data: _this.data,
5507
5506
  per: _this.params ? _this.params.to : 2,
5508
- page: 1,
5507
+ page: _this.props.currentPage || 1,
5509
5508
  from: _this.params ? _this.params.from : 0,
5510
5509
  to: _this.params ? _this.params.to : 2,
5511
5510
  total_pages: null,
5512
5511
  scrolling: true,
5513
- query: _this.query
5514
- }, _this.loadMore = function () {
5515
- setTimeout(function () {
5516
- _this.setState(function (state, props) {
5517
- return {
5518
- page: state.page + 1,
5519
- from: state.from + state.per,
5520
- to: state.to + state.per
5521
- };
5522
- }, _this.loadData);
5523
- }, 10);
5524
- }, _this.loadData = function () {
5512
+ query: _this.query,
5513
+ currentPage: _this.props.currentPage || 1
5514
+ }, _this.loadMore = debounce_1(function () {
5515
+ _this.setState(function (state) {
5516
+ var page = state.page,
5517
+ from = state.from,
5518
+ per = state.per,
5519
+ to = state.to;
5520
+
5521
+ return {
5522
+ page: page + 1,
5523
+ from: from + per,
5524
+ to: to + per
5525
+ };
5526
+ }, _this.loadData);
5527
+ }, 0), _this.loadData = function () {
5525
5528
  var _this$state = _this.state,
5526
5529
  from = _this$state.from,
5527
5530
  to = _this$state.to,
5528
5531
  data = _this$state.data,
5529
- query = _this$state.query;
5532
+ query = _this$state.query,
5533
+ page = _this$state.page;
5530
5534
  var client = _this.props.client;
5531
5535
 
5532
5536
 
5533
5537
  var params = _extends({}, _this.params, { from: from, to: to
5534
5538
  // const queryUpdated = query.replace('$from', params.from).replace('$to', params.to)
5535
-
5536
- });if (_this.pointer && _this.pointerArray) {
5537
- var pointer = _this.pointer;
5538
- client.fetch(query, params).then(function (dataArr) {
5539
- _this.setState(function (state, props) {
5540
- if (dataArr[_this.pointerArray][pointer].length > 0) {
5541
- return {
5542
- data: [].concat(toConsumableArray(data), toConsumableArray(dataArr[_this.pointerArray][pointer])),
5543
- scrolling: true
5544
- };
5545
- } else {
5546
- return {
5547
- scrolling: false
5548
- };
5549
- }
5539
+ });client.fetch(query, params).then(function (dataArr) {
5540
+ if (_this.pointer && _this.pointerArray) {
5541
+ var pointer = _this.pointer;
5542
+ dataArr = dataArr[_this.pointerArray][pointer];
5543
+ }
5544
+ dataArr = dataArr.map(function (item) {
5545
+ return _extends({}, item, {
5546
+ pageNumber: page
5550
5547
  });
5551
5548
  });
5552
- } else {
5553
- client.fetch(query, params).then(function (dataArr) {
5554
- _this.setState(function (state, props) {
5555
- if (dataArr.length > 0) {
5556
- return {
5557
- data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
5558
- scrolling: true
5559
- };
5560
- } else {
5561
- return {
5562
- scrolling: false
5563
- };
5564
- }
5565
- });
5549
+
5550
+ _this.setState(function () {
5551
+ if (dataArr.length > 0) {
5552
+ return {
5553
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
5554
+ scrolling: true
5555
+ };
5556
+ } else {
5557
+ return {
5558
+ scrolling: false
5559
+ };
5560
+ }
5566
5561
  });
5567
- }
5562
+ });
5568
5563
  }, _this.urlFor = function (source) {
5569
5564
  var client = _this.props.client;
5570
5565
 
5571
5566
  var builder = imageUrlBuilder(client);
5572
5567
  return builder.image(source);
5568
+ }, _this.renderCardImage = function (row, page) {
5569
+ if (row.thumbnail) {
5570
+ return _this.urlFor(row.thumbnail).url();
5571
+ } else {
5572
+ return _this.defaultImage;
5573
+ }
5574
+ }, _this.changePageNumber = function (pageNumber) {
5575
+ var _this$props = _this.props,
5576
+ seoPaginate = _this$props.seoPaginate,
5577
+ pageview = _this$props.pageview,
5578
+ router = _this$props.router;
5579
+ var currentPage = _this.state.currentPage;
5580
+
5581
+ if (seoPaginate) {
5582
+ var path = router.asPath;
5583
+ var qrIndex = path.indexOf('?');
5584
+ var pathname = router.pathname;
5585
+ var queryString = '';
5586
+
5587
+ if (qrIndex > 0) {
5588
+ path = path.substring(1, qrIndex);
5589
+
5590
+ var partialQS = router.asPath.substring(qrIndex + 1);
5591
+ var partialQSArr = partialQS.split('&');
5592
+
5593
+ // exclude page=xxx from query string
5594
+ partialQSArr.map(function (item) {
5595
+ var itemArr = item.split('=');
5596
+ var key = itemArr[0];
5597
+ var val = itemArr[1];
5598
+
5599
+ if (key !== 'page') {
5600
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
5601
+ }
5602
+ });
5603
+ }
5604
+
5605
+ if (queryString.length > 0) {
5606
+ path += '?' + queryString;
5607
+ }
5608
+
5609
+ pageNumber = parseInt(pageNumber);
5610
+
5611
+ if (currentPage !== pageNumber) {
5612
+ lib_3.refresh();
5613
+ if (pageview) {
5614
+ _this.setState({
5615
+ currentPage: pageNumber
5616
+ }, function () {
5617
+ if (path[0] !== '/') {
5618
+ path = '/' + path;
5619
+ }
5620
+
5621
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
5622
+
5623
+ pageview(newPath);
5624
+
5625
+ router.push(pathname, newPath, {
5626
+ shallow: true
5627
+ });
5628
+ });
5629
+ }
5630
+ }
5631
+ }
5632
+ }, _this.renderManualPagination = function () {
5633
+ var currentPage = _this.state.currentPage;
5634
+
5635
+ return React__default.createElement(
5636
+ 'div',
5637
+ { className: 'd-flex justify-content-between' },
5638
+ currentPage && currentPage > 1 && React__default.createElement(
5639
+ 'a',
5640
+ { href: '?page=' + (currentPage - 1) },
5641
+ '<< Previous'
5642
+ ),
5643
+ React__default.createElement(
5644
+ 'a',
5645
+ { href: '?page=' + (currentPage + 1) },
5646
+ 'Next >>'
5647
+ )
5648
+ );
5573
5649
  }, _temp), possibleConstructorReturn(_this, _ret);
5574
5650
  }
5575
5651
 
@@ -5584,64 +5660,73 @@ var DeckQueue = function (_React$Component) {
5584
5660
  return React__default.createElement(
5585
5661
  Row,
5586
5662
  null,
5587
- this.state.data && this.state.data.map(function (row, index) {
5663
+ this.state.data && this.state.data.map(function (row, index$$1) {
5664
+ var pageNumber = row.pageNumber || _this2.state.page;
5588
5665
  // const thumbnailURL = get(row, 'thumbnail.asset.url', this.props.defaultImage)
5589
5666
  var thumbnailURL = row.thumbnail ? _this2.urlFor(row.thumbnail).url() : _this2.props.defaultImage;
5590
5667
  return React__default.createElement(
5591
- Col,
5592
- { key: index, md: 12, lg: lgVar, style: { display: 'flex', flex: '1 0 auto' } },
5668
+ VisibilitySensor,
5669
+ {
5670
+ key: index$$1,
5671
+ onChange: function onChange(isVisible) {
5672
+ isVisible && _this2.changePageNumber(pageNumber);
5673
+ } },
5593
5674
  React__default.createElement(
5594
- Card,
5595
- { className: 'queue-card', style: { borderTop: '1px solid #EEE' } },
5675
+ Col,
5676
+ { md: 12, lg: lgVar, style: { display: 'flex', flex: '1 0 auto' } },
5596
5677
  React__default.createElement(
5597
- Row,
5598
- { style: { flexDirection: mode } },
5599
- React__default.createElement(
5600
- Col,
5601
- { md: 12, lg: 4 },
5602
- React__default.createElement(
5603
- Link,
5604
- { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5605
- React__default.createElement(Card.Img, { variant: 'top', src: thumbnailURL })
5606
- )
5607
- ),
5678
+ Card,
5679
+ { className: 'queue-card', style: { borderTop: '1px solid #EEE' } },
5608
5680
  React__default.createElement(
5609
- Col,
5610
- null,
5681
+ Row,
5682
+ { style: { flexDirection: mode } },
5611
5683
  React__default.createElement(
5612
- Card.Body,
5613
- { style: { padding: '20px' } },
5614
- row.title && React__default.createElement(
5684
+ Col,
5685
+ { md: 12, lg: 4 },
5686
+ React__default.createElement(
5615
5687
  Link,
5616
5688
  { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5617
- React__default.createElement(
5618
- Card.Title,
5619
- null,
5620
- row.title
5621
- )
5622
- ),
5623
- _this2.props.showPublished && row.published && React__default.createElement(
5624
- Card.Subtitle,
5625
- null,
5626
- moment(row.published).format('MMMM DD, YYYY')
5627
- ),
5628
- _this2.props.showRecent && row.recent && row.recent.title && React__default.createElement(
5629
- Card.Subtitle,
5630
- null,
5631
- 'Recent : ',
5632
- React__default.createElement(
5689
+ React__default.createElement(Card.Img, { variant: 'top', src: thumbnailURL })
5690
+ )
5691
+ ),
5692
+ React__default.createElement(
5693
+ Col,
5694
+ null,
5695
+ React__default.createElement(
5696
+ Card.Body,
5697
+ { style: { padding: '20px' } },
5698
+ row.title && React__default.createElement(
5633
5699
  Link,
5634
- { href: 'view/' + row.recent.url.current },
5635
- row.recent.title
5636
- )
5637
- ),
5638
- row.summary && React__default.createElement(
5639
- Link,
5640
- { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5641
- React__default.createElement(
5642
- Card.Text,
5700
+ { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5701
+ React__default.createElement(
5702
+ Card.Title,
5703
+ null,
5704
+ row.title
5705
+ )
5706
+ ),
5707
+ _this2.props.showPublished && row.published && React__default.createElement(
5708
+ Card.Subtitle,
5643
5709
  null,
5644
- row.summary
5710
+ moment(row.published).format('MMMM DD, YYYY')
5711
+ ),
5712
+ _this2.props.showRecent && row.recent && row.recent.title && React__default.createElement(
5713
+ Card.Subtitle,
5714
+ null,
5715
+ 'Recent : ',
5716
+ React__default.createElement(
5717
+ Link,
5718
+ { href: 'view/' + row.recent.url.current },
5719
+ row.recent.title
5720
+ )
5721
+ ),
5722
+ row.summary && React__default.createElement(
5723
+ Link,
5724
+ { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5725
+ React__default.createElement(
5726
+ Card.Text,
5727
+ null,
5728
+ row.summary
5729
+ )
5645
5730
  )
5646
5731
  )
5647
5732
  )
@@ -5703,6 +5788,11 @@ var DeckQueue = function (_React$Component) {
5703
5788
  'End of data'
5704
5789
  )
5705
5790
  )
5791
+ ),
5792
+ React__default.createElement(
5793
+ 'noscript',
5794
+ null,
5795
+ this.renderManualPagination()
5706
5796
  )
5707
5797
  )
5708
5798
  );
@@ -5711,6 +5801,8 @@ var DeckQueue = function (_React$Component) {
5711
5801
  return DeckQueue;
5712
5802
  }(React__default.Component);
5713
5803
 
5804
+ var Queue = withRouter(DeckQueue);
5805
+
5714
5806
  var ThumbnailCard = function ThumbnailCard(_ref) {
5715
5807
  var size = _ref.size,
5716
5808
  mediaData = _ref.mediaData,
@@ -7045,12 +7137,25 @@ var Search = function Search(_ref) {
7045
7137
  searchKey = _useState2[0],
7046
7138
  setSearchKey = _useState2[1];
7047
7139
 
7048
- var handleSearch = function handleSearch(value) {
7049
- router.push({
7050
- pathname: '/search',
7051
- query: { searchTerm: value }
7140
+ var _useState3 = useState(false),
7141
+ _useState4 = slicedToArray(_useState3, 2),
7142
+ activesearch = _useState4[0],
7143
+ setActivesearch = _useState4[1];
7144
+
7145
+ useEffect(function () {
7146
+ if (activesearch) {
7147
+ router.push({
7148
+ pathname: '/search',
7149
+ query: { searchTerm: searchKey }
7150
+ });
7151
+ }
7152
+ }, [activesearch]);
7153
+
7154
+ useEffect(function () {
7155
+ Router.events.on('routeChangeComplete', function () {
7156
+ return setActivesearch(false);
7052
7157
  });
7053
- };
7158
+ });
7054
7159
 
7055
7160
  return React__default.createElement(
7056
7161
  Form,
@@ -7058,16 +7163,17 @@ var Search = function Search(_ref) {
7058
7163
  inline: true,
7059
7164
  onSubmit: function onSubmit(e) {
7060
7165
  e.preventDefault();
7061
- handleSearch(searchKey);
7166
+ setActivesearch(true);
7062
7167
  } },
7168
+ activesearch && React__default.createElement(Spinner, { className: 'active-loader mr-3', animation: 'border', variant: 'light' }),
7063
7169
  React__default.createElement(FormControl, { type: 'text', placeholder: placeholder, className: 'mr-sm-2', value: searchKey, onChange: function onChange(e) {
7064
7170
  return setSearchKey(e.target.value);
7065
7171
  } }),
7066
7172
  React__default.createElement(
7067
7173
  Button,
7068
7174
  { variant: 'secondary', onClick: function onClick() {
7069
- return handleSearch(searchKey);
7070
- } },
7175
+ return setActivesearch(true);
7176
+ }, disabled: activesearch },
7071
7177
  btnText
7072
7178
  )
7073
7179
  );
@@ -8563,8 +8669,8 @@ var Slideshow = function Slideshow(_ref) {
8563
8669
  return React__default.createElement(
8564
8670
  Carousel.Item,
8565
8671
  { key: slide._key },
8566
- React__default.createElement('img', { src: slide.image && urlFor$1(slide.image, builder).url(), style: { width: '100%' } }),
8567
- React__default.createElement(
8672
+ React__default.createElement('img', { src: slide.asset && urlFor$1(slide.asset, builder).url(), alt: slide.alt && slide.alt, style: { width: '100%' } }),
8673
+ slide.caption && React__default.createElement(
8568
8674
  'p',
8569
8675
  { className: 'p-2' },
8570
8676
  slide.caption
@@ -12605,5 +12711,5 @@ var Breadcrumbs = function Breadcrumbs() {
12605
12711
  );
12606
12712
  };
12607
12713
 
12608
- export { ContentCard as DeckContent, GridContent$1 as GridContent, DeckQueue, ThumbnailCard, TaxonomyCard, GroupDeck, YoutubeGroup, QueueDeckExpanded, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, SocialShare, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers$1 as getSerializers, Search, Feature, Breadcrumbs };
12714
+ export { ContentCard as DeckContent, GridContent$1 as GridContent, Queue as DeckQueue, ThumbnailCard, TaxonomyCard, GroupDeck, YoutubeGroup, QueueDeckExpanded, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, SocialShare, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers$1 as getSerializers, Search, Feature, Breadcrumbs };
12609
12715
  //# sourceMappingURL=index.es.js.map