@mjhls/mjh-framework 1.0.85 → 1.0.86

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.85
2
+ # mjh-framework v. 1.0.86
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, createElement, createContext } 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';
@@ -8,6 +8,8 @@ import Card from 'react-bootstrap/Card';
8
8
  import Link from 'next/link';
9
9
  import { withRouter, useRouter } from 'next/router';
10
10
  import Media from 'react-bootstrap/Media';
11
+ import { Media as Media$1, Card as Card$1, Container as Container$1, Figure, Carousel, Table } from 'react-bootstrap';
12
+ import moment from 'moment';
11
13
  import ListGroup from 'react-bootstrap/ListGroup';
12
14
  import Head from 'next/head';
13
15
  import Accordion from 'react-bootstrap/Accordion';
@@ -19,7 +21,6 @@ import NavDropdown from 'react-bootstrap/NavDropdown';
19
21
  import Form from 'react-bootstrap/Form';
20
22
  import FormControl from 'react-bootstrap/FormControl';
21
23
  import Button from 'react-bootstrap/Button';
22
- import { Figure, Carousel, Card as Card$1, Table } from 'react-bootstrap';
23
24
 
24
25
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
25
26
 
@@ -6157,6 +6158,333 @@ var YoutubeGroup = function YoutubeGroup(props) {
6157
6158
  );
6158
6159
  };
6159
6160
 
6161
+ var _this = undefined;
6162
+
6163
+ var urlFor = function urlFor(builder, source) {
6164
+ return builder.image(source);
6165
+ };
6166
+
6167
+ var loadMore = function loadMore(values, setValues, per) {
6168
+ setValues({
6169
+ page: values.page + 1,
6170
+ from: values.from + per,
6171
+ to: values.to + per
6172
+ });
6173
+ };
6174
+
6175
+ var loadData = function loadData(values, query, client, params, setData, setScrolling, pointer, pointerArray) {
6176
+ params = _extends({}, params, {
6177
+ from: values.from,
6178
+ to: values.to
6179
+ });
6180
+
6181
+ client.fetch(query, params).then(function (dataArr) {
6182
+ if (pointer && pointerArray) {
6183
+ var _pointer = _this.pointer;
6184
+ dataArr = dataArr[pointerArray][_pointer];
6185
+ }
6186
+ dataArr = dataArr.map(function (item) {
6187
+ return _extends({}, item, {
6188
+ pageNumber: values.page
6189
+ });
6190
+ });
6191
+
6192
+ if (dataArr.length > 0) {
6193
+ setData(function (prevData) {
6194
+ return [].concat(toConsumableArray(prevData), toConsumableArray(dataArr));
6195
+ });
6196
+ setScrolling(true);
6197
+ } else {
6198
+ setScrolling(false);
6199
+ }
6200
+ });
6201
+ };
6202
+
6203
+ var changePageNumber = function changePageNumber(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage) {
6204
+ if (seoPaginate) {
6205
+ var path = router.asPath;
6206
+ var qrIndex = path.indexOf('?');
6207
+ var pathname = router.pathname;
6208
+ var queryString = '';
6209
+
6210
+ if (qrIndex > 0) {
6211
+ path = path.substring(1, qrIndex);
6212
+
6213
+ var partialQS = router.asPath.substring(qrIndex + 1);
6214
+ var partialQSArr = partialQS.split('&');
6215
+
6216
+ // exclude page=xxx from query string
6217
+ partialQSArr.map(function (item) {
6218
+ var itemArr = item.split('=');
6219
+ var key = itemArr[0];
6220
+ var val = itemArr[1];
6221
+
6222
+ if (key !== 'page') {
6223
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
6224
+ }
6225
+ });
6226
+ }
6227
+
6228
+ if (queryString.length > 0) {
6229
+ path += '?' + queryString;
6230
+ }
6231
+
6232
+ pageNumber = parseInt(pageNumber);
6233
+
6234
+ if (currentPage !== pageNumber) {
6235
+ lib_3.refresh();
6236
+ if (pageview) {
6237
+ setCurrentPage(pageNumber);
6238
+ if (path[0] !== '/') {
6239
+ path = '/' + path;
6240
+ }
6241
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
6242
+ pageview(newPath);
6243
+
6244
+ router.push(pathname, newPath, {
6245
+ shallow: true
6246
+ });
6247
+ }
6248
+ }
6249
+ }
6250
+ };
6251
+
6252
+ var renderAuthor = function renderAuthor(authorName, authorURL, index$$1, length) {
6253
+ if (authorName && authorURL) {
6254
+ return React__default.createElement(
6255
+ Link,
6256
+ { href: '/authors/' + authorURL.current, key: index$$1 },
6257
+ React__default.createElement(
6258
+ 'a',
6259
+ null,
6260
+ authorName,
6261
+ length !== index$$1 + 1 && ' | '
6262
+ )
6263
+ );
6264
+ } else if (authorName) {
6265
+ return React__default.createElement(
6266
+ 'span',
6267
+ { key: index$$1 },
6268
+ authorName,
6269
+ length !== index$$1 + 1 && ' | '
6270
+ );
6271
+ }
6272
+ };
6273
+
6274
+ var cardLoader = function cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage) {
6275
+ return React__default.createElement(
6276
+ 'div',
6277
+ null,
6278
+ data && data.map(function (article, index$$1) {
6279
+ var pageNumber = article.pageNumber || values.page;
6280
+ var contentCategoryName = article.contentCategory ? article.contentCategory.name : 'Articles';
6281
+ return React__default.createElement(
6282
+ VisibilitySensor,
6283
+ {
6284
+ key: article._id ? article._id : index$$1,
6285
+ onChange: function onChange(isVisible) {
6286
+ isVisible && changePageNumber(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage);
6287
+ } },
6288
+ React__default.createElement(
6289
+ Card$1,
6290
+ { key: article._id ? article._id : index$$1 },
6291
+ React__default.createElement(
6292
+ Card$1.Body,
6293
+ null,
6294
+ React__default.createElement(
6295
+ Media$1,
6296
+ null,
6297
+ React__default.createElement(
6298
+ Link,
6299
+ { href: mapping[contentCategoryName] + '/[url]', as: mapping[contentCategoryName] + '/' + article.url.current },
6300
+ React__default.createElement(
6301
+ 'a',
6302
+ null,
6303
+ React__default.createElement('img', { width: 200, height: 130, className: 'mr-3', src: urlFor(builder, article.thumbnail.asset).url(), style: { objectFit: 'cover' } })
6304
+ )
6305
+ ),
6306
+ React__default.createElement(
6307
+ Media$1.Body,
6308
+ null,
6309
+ React__default.createElement(
6310
+ Link,
6311
+ { href: mapping[contentCategoryName] + '/[url]', as: mapping[contentCategoryName] + '/' + article.url.current },
6312
+ React__default.createElement(
6313
+ 'a',
6314
+ null,
6315
+ article.title && React__default.createElement(
6316
+ 'h5',
6317
+ { className: 'card-title' },
6318
+ article.title
6319
+ )
6320
+ )
6321
+ ),
6322
+ article.published && React__default.createElement(
6323
+ 'h6',
6324
+ { className: 'card-text' },
6325
+ moment(article.published).format('MMMM DD, YYYY')
6326
+ ),
6327
+ article.authorDetails && article.authorDetails.length > 0 && article.authorDetails.map(function (authorDetail, index$$1) {
6328
+ return React__default.createElement(
6329
+ 'div',
6330
+ { className: 'card-text d-inline', key: index$$1 },
6331
+ renderAuthor(authorDetail.displayName, authorDetail.url, index$$1, article.authorDetails.length)
6332
+ );
6333
+ })
6334
+ )
6335
+ ),
6336
+ article.summary && React__default.createElement(
6337
+ 'p',
6338
+ { className: 'pt-2 card-text' },
6339
+ article.summary
6340
+ )
6341
+ )
6342
+ )
6343
+ );
6344
+ })
6345
+ );
6346
+ };
6347
+
6348
+ var renderManualPagination = function renderManualPagination(currentPage) {
6349
+ return React__default.createElement(
6350
+ 'div',
6351
+ { className: 'd-flex justify-content-between' },
6352
+ currentPage && currentPage > 1 && React__default.createElement(
6353
+ 'a',
6354
+ { href: '?page=' + (currentPage - 1) },
6355
+ '<< Previous'
6356
+ ),
6357
+ React__default.createElement(
6358
+ 'a',
6359
+ { href: '?page=' + (currentPage + 1) },
6360
+ 'Next >>'
6361
+ )
6362
+ );
6363
+ };
6364
+
6365
+ var usePrevious = function usePrevious(value) {
6366
+ var ref = useRef();
6367
+ useEffect(function () {
6368
+ ref.current = value;
6369
+ });
6370
+ return ref.current;
6371
+ };
6372
+
6373
+ var QueueDeckExpanded = function QueueDeckExpanded(props) {
6374
+ var router = useRouter();
6375
+ var initialData = props.dataRecord,
6376
+ client = props.client,
6377
+ params = props.params,
6378
+ query = props.query,
6379
+ autoScroll = props.autoScroll,
6380
+ pointer = props.pointer,
6381
+ pointerArray = props.pointerArray,
6382
+ mapping = props.mapping,
6383
+ seoPaginate = props.seoPaginate,
6384
+ pageview = props.pageview;
6385
+ var initialCurrentPage = props.currentPage;
6386
+
6387
+ var builder = imageUrlBuilder(client);
6388
+
6389
+ var _useState = useState(initialData),
6390
+ _useState2 = slicedToArray(_useState, 2),
6391
+ data = _useState2[0],
6392
+ setData = _useState2[1];
6393
+
6394
+ var _useState3 = useState(true),
6395
+ _useState4 = slicedToArray(_useState3, 2),
6396
+ scrolling = _useState4[0],
6397
+ setScrolling = _useState4[1];
6398
+
6399
+ var _useState5 = useState(params ? params.to : 0),
6400
+ _useState6 = slicedToArray(_useState5, 2),
6401
+ per = _useState6[0],
6402
+ setPer = _useState6[1];
6403
+
6404
+ var _useState7 = useState(initialCurrentPage || 1),
6405
+ _useState8 = slicedToArray(_useState7, 2),
6406
+ currentPage = _useState8[0],
6407
+ setCurrentPage = _useState8[1];
6408
+
6409
+ var _useState9 = useState({
6410
+ from: params ? params.from : 0,
6411
+ to: params ? params.to : 0,
6412
+ page: 1
6413
+ }),
6414
+ _useState10 = slicedToArray(_useState9, 2),
6415
+ values = _useState10[0],
6416
+ setValues = _useState10[1];
6417
+
6418
+ var prevValues = usePrevious(values);
6419
+
6420
+ useEffect(function () {
6421
+ if (prevValues) {
6422
+ if (values.page !== prevValues.page && values.from !== prevValues.from && values.to !== prevValues.from) {
6423
+ loadData(values, query, client, params, setData, setScrolling, pointer, pointerArray);
6424
+ }
6425
+ }
6426
+ }, [values, prevValues, query, client, params, setData, setScrolling, pointer, pointerArray]);
6427
+
6428
+ return React__default.createElement(
6429
+ 'div',
6430
+ null,
6431
+ autoScroll ? React__default.createElement(
6432
+ React__default.Fragment,
6433
+ null,
6434
+ React__default.createElement(
6435
+ InfiniteScroll,
6436
+ { dataLength: data && data.length, next: function next() {
6437
+ return loadMore(values, setValues, per);
6438
+ }, hasMore: scrolling, scrollThreshold: 0.9 },
6439
+ React__default.createElement(
6440
+ Container$1,
6441
+ null,
6442
+ cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage)
6443
+ )
6444
+ ),
6445
+ React__default.createElement(
6446
+ 'noscript',
6447
+ null,
6448
+ renderManualPagination(currentPage)
6449
+ )
6450
+ ) : React__default.createElement(
6451
+ React__default.Fragment,
6452
+ null,
6453
+ React__default.createElement(
6454
+ Container$1,
6455
+ null,
6456
+ cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage)
6457
+ ),
6458
+ React__default.createElement(
6459
+ 'div',
6460
+ { style: { padding: '0px 10px' } },
6461
+ scrolling ? React__default.createElement(
6462
+ 'button',
6463
+ {
6464
+ style: { margin: 'auto', width: '100%' },
6465
+ onClick: function onClick(e) {
6466
+ loadMore(values, setValues, per);
6467
+ } },
6468
+ 'Load More'
6469
+ ) : React__default.createElement(
6470
+ 'p',
6471
+ { style: { textAlign: 'center' } },
6472
+ React__default.createElement(
6473
+ 'b',
6474
+ null,
6475
+ 'End of data'
6476
+ )
6477
+ )
6478
+ ),
6479
+ React__default.createElement(
6480
+ 'noscript',
6481
+ null,
6482
+ renderManualPagination(currentPage)
6483
+ )
6484
+ )
6485
+ );
6486
+ };
6487
+
6160
6488
  var Column1 = function Column1(props) {
6161
6489
  var title = props.title;
6162
6490
 
@@ -8157,7 +8485,7 @@ var FigureComponent = function FigureComponent(_ref) {
8157
8485
  );
8158
8486
  };
8159
8487
 
8160
- var urlFor = function urlFor(source, builder) {
8488
+ var urlFor$1 = function urlFor(source, builder) {
8161
8489
  return builder.image(source);
8162
8490
  };
8163
8491
 
@@ -8193,7 +8521,7 @@ var Slideshow = function Slideshow(_ref) {
8193
8521
  return React__default.createElement(
8194
8522
  Carousel.Item,
8195
8523
  { key: slide._key },
8196
- React__default.createElement('img', { src: urlFor(slide.asset, builder).url(), style: { width: '100%' } })
8524
+ React__default.createElement('img', { src: urlFor$1(slide.asset, builder).url(), style: { width: '100%' } })
8197
8525
  );
8198
8526
  })
8199
8527
  )
@@ -11781,7 +12109,7 @@ var TableShow = function TableShow(_ref) {
11781
12109
  );
11782
12110
  };
11783
12111
 
11784
- var Media$1 = function Media$$1(_ref) {
12112
+ var Media$2 = function Media$$1(_ref) {
11785
12113
  var uploadDoc = _ref.uploadDoc,
11786
12114
  poster = _ref.poster,
11787
12115
  client = _ref.client,
@@ -12063,7 +12391,7 @@ var getSerializers$1 = function getSerializers(client, pageview) {
12063
12391
  caption = node.caption,
12064
12392
  blank = node.blank;
12065
12393
 
12066
- return React__default.createElement(Media$1, { uploadDoc: upload_doc, poster: poster, blank: blank, client: client, caption: caption });
12394
+ return React__default.createElement(Media$2, { uploadDoc: upload_doc, poster: poster, blank: blank, client: client, caption: caption });
12067
12395
  },
12068
12396
  iframe: function iframe(_ref8) {
12069
12397
  var node = _ref8.node;
@@ -12102,5 +12430,5 @@ var getSerializers$1 = function getSerializers(client, pageview) {
12102
12430
  };
12103
12431
  };
12104
12432
 
12105
- export { ContentCard as DeckContent, GridContent, DeckQueue, ThumbnailCard, TaxonomyCard, GroupDeck, YoutubeGroup, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, SocialShare, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers$1 as getSerializers, Search };
12433
+ export { ContentCard as DeckContent, 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 };
12106
12434
  //# sourceMappingURL=index.es.js.map