@mjhls/mjh-framework 1.0.83 → 1.0.84

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.82
2
+ # mjh-framework v. 1.0.84
3
3
 
4
4
 
5
5
  > Foundation Framework
package/dist/index.es.js CHANGED
@@ -5126,6 +5126,330 @@ function get$1(object, path, defaultValue) {
5126
5126
 
5127
5127
  var get_1 = get$1;
5128
5128
 
5129
+ var GridContent = function (_React$Component) {
5130
+ inherits(GridContent, _React$Component);
5131
+
5132
+ function GridContent() {
5133
+ var _ref;
5134
+
5135
+ var _temp, _this, _ret;
5136
+
5137
+ classCallCheck(this, GridContent);
5138
+
5139
+ for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
5140
+ args[_key] = arguments[_key];
5141
+ }
5142
+
5143
+ return _ret = (_temp = (_this = possibleConstructorReturn(this, (_ref = GridContent.__proto__ || Object.getPrototypeOf(GridContent)).call.apply(_ref, [this].concat(args))), _this), _this.page = _this.props.page, _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.state = {
5144
+ data: _this.data,
5145
+ per: _this.params ? _this.params.to : 2,
5146
+ page: 1,
5147
+ from: _this.params ? _this.params.from : 0,
5148
+ to: _this.params ? _this.params.to : 2,
5149
+ total_pages: null,
5150
+ scrolling: true,
5151
+ query: _this.query
5152
+ }, _this.loadMore = function () {
5153
+ setTimeout(function () {
5154
+ _this.setState(function (state, props) {
5155
+ return {
5156
+ page: state.page + 1,
5157
+ from: state.from + state.per,
5158
+ to: state.to + state.per
5159
+ };
5160
+ }, _this.loadData);
5161
+ }, 10);
5162
+ }, _this.loadData = function () {
5163
+ var _this$state = _this.state,
5164
+ from = _this$state.from,
5165
+ to = _this$state.to,
5166
+ data = _this$state.data,
5167
+ query = _this$state.query;
5168
+ var client = _this.props.client;
5169
+
5170
+
5171
+ var params = _extends({}, _this.params, { from: from, to: to
5172
+ // const queryUpdated = query.replace('$from', params.from).replace('$to', params.to)
5173
+
5174
+ });if (_this.pointer && _this.pointerArray) {
5175
+ var pointer = _this.pointer;
5176
+ client.fetch(query, params).then(function (dataArr) {
5177
+ _this.setState(function (state, props) {
5178
+ if (dataArr[_this.pointerArray][pointer].length > 0) {
5179
+ return {
5180
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr[_this.pointerArray][pointer])),
5181
+ scrolling: true
5182
+ };
5183
+ } else {
5184
+ return {
5185
+ scrolling: false
5186
+ };
5187
+ }
5188
+ });
5189
+ });
5190
+ } else {
5191
+ client.fetch(query, params).then(function (dataArr) {
5192
+ _this.setState(function (state, props) {
5193
+ if (dataArr.length > 0) {
5194
+ return {
5195
+ data: [].concat(toConsumableArray(data), toConsumableArray(dataArr)),
5196
+ scrolling: true
5197
+ };
5198
+ } else {
5199
+ return {
5200
+ scrolling: false
5201
+ };
5202
+ }
5203
+ });
5204
+ });
5205
+ }
5206
+ }, _this.urlFor = function (source) {
5207
+ var client = _this.props.client;
5208
+
5209
+ var builder = imageUrlBuilder(client);
5210
+ return builder.image(source);
5211
+ }, _this.renderCardImage = function (row, page) {
5212
+ if (row.thumbnail) {
5213
+ return _this.urlFor(row.thumbnail).url();
5214
+ } else {
5215
+ return _this.defaultImage;
5216
+ }
5217
+ }, _this.changePageNumber = function (pageNumber) {
5218
+ var _this$props = _this.props,
5219
+ seoPaginate = _this$props.seoPaginate,
5220
+ pageview = _this$props.pageview,
5221
+ router = _this$props.router;
5222
+ var currentPage = _this.state.currentPage;
5223
+
5224
+ if (seoPaginate) {
5225
+ var path = router.asPath;
5226
+ var qrIndex = path.indexOf('?');
5227
+ var pathname = router.pathname;
5228
+ var queryString = '';
5229
+
5230
+ if (qrIndex > 0) {
5231
+ path = path.substring(1, qrIndex);
5232
+
5233
+ var partialQS = router.asPath.substring(qrIndex + 1);
5234
+ var partialQSArr = partialQS.split('&');
5235
+
5236
+ // exclude page=xxx from query string
5237
+ partialQSArr.map(function (item) {
5238
+ var itemArr = item.split('=');
5239
+ var key = itemArr[0];
5240
+ var val = itemArr[1];
5241
+
5242
+ if (key !== 'page') {
5243
+ queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
5244
+ }
5245
+ });
5246
+ }
5247
+
5248
+ if (queryString.length > 0) {
5249
+ path += '?' + queryString;
5250
+ }
5251
+
5252
+ pageNumber = parseInt(pageNumber);
5253
+
5254
+ if (currentPage !== pageNumber) {
5255
+ DFPManager.refresh();
5256
+ if (pageview) {
5257
+ _this.setState({
5258
+ currentPage: pageNumber
5259
+ }, function () {
5260
+ if (path[0] !== '/') {
5261
+ path = '/' + path;
5262
+ }
5263
+
5264
+ var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
5265
+
5266
+ pageview(newPath);
5267
+
5268
+ router.push(pathname, newPath, {
5269
+ shallow: true
5270
+ });
5271
+ });
5272
+ }
5273
+ }
5274
+ }
5275
+ }, _temp), possibleConstructorReturn(_this, _ret);
5276
+ }
5277
+
5278
+ createClass(GridContent, [{
5279
+ key: 'cardLoader',
5280
+ value: function cardLoader(page, columns, variant) {
5281
+ var _this2 = this;
5282
+
5283
+ var lgVar = Math.floor(12 / columns);
5284
+ var itemCounter = 0;
5285
+ if (variant === 'stack') {
5286
+ return React__default.createElement(
5287
+ Row,
5288
+ null,
5289
+ this.state.data && this.state.data.map(function (row, index) {
5290
+ // const thumbnailURL = get(row, 'thumbnail.asset.url', this.props.defaultImage)
5291
+ var thumbnailURL = row.thumbnail ? _this2.urlFor(row.thumbnail).url() : _this2.props.defaultImage;
5292
+ return React__default.createElement(
5293
+ Col,
5294
+ { key: index, md: 12, lg: lgVar, style: { display: 'flex', flex: '1 0 auto' } },
5295
+ React__default.createElement(
5296
+ Link,
5297
+ { href: _this2.page + '/[url]', as: _this2.page + '/' + get_1(row, 'url.current') },
5298
+ React__default.createElement(
5299
+ 'a',
5300
+ null,
5301
+ React__default.createElement(
5302
+ Card,
5303
+ { className: 'queue-card', style: { borderTop: '1px solid #EEE' } },
5304
+ React__default.createElement(
5305
+ Row,
5306
+ { style: { flexDirection: 'row' } },
5307
+ React__default.createElement(
5308
+ Col,
5309
+ { md: 12, lg: 4 },
5310
+ React__default.createElement(Card.Img, { variant: 'top', src: thumbnailURL })
5311
+ ),
5312
+ React__default.createElement(
5313
+ Col,
5314
+ null,
5315
+ React__default.createElement(
5316
+ Card.Body,
5317
+ { style: { padding: '20px' } },
5318
+ React__default.createElement(
5319
+ Card.Title,
5320
+ null,
5321
+ row.title
5322
+ ),
5323
+ React__default.createElement(
5324
+ Card.Text,
5325
+ null,
5326
+ row.summary
5327
+ )
5328
+ )
5329
+ )
5330
+ )
5331
+ )
5332
+ )
5333
+ )
5334
+ );
5335
+ })
5336
+ );
5337
+ }
5338
+ return React__default.createElement(
5339
+ 'div',
5340
+ { className: 'grid-container' },
5341
+ this.state.data && this.state.data.map(function (row, index) {
5342
+ var pageNumber = row.pageNumber || _this2.state.page;
5343
+ var contentCategoryName = row.contentCategory ? row.contentCategory.name : 'Articles';
5344
+ return React__default.createElement(
5345
+ VisibilitySensor,
5346
+ {
5347
+ key: itemCounter,
5348
+ onChange: function onChange(isVisible) {
5349
+ isVisible && _this2.changePageNumber(pageNumber);
5350
+ } },
5351
+ React__default.createElement(
5352
+ 'div',
5353
+ { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
5354
+ React__default.createElement(
5355
+ Card,
5356
+ { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
5357
+ React__default.createElement(
5358
+ Link,
5359
+ { href: _this2.mapping[contentCategoryName] + '/[url]', as: _this2.mapping[contentCategoryName] + '/' + row.url.current },
5360
+ React__default.createElement(
5361
+ 'a',
5362
+ { className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
5363
+ React__default.createElement(Card.Img, { variant: 'top', src: _this2.renderCardImage(row, page), alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : '' })
5364
+ )
5365
+ ),
5366
+ React__default.createElement(
5367
+ Card.Body,
5368
+ null,
5369
+ React__default.createElement(
5370
+ Link,
5371
+ { href: _this2.mapping[contentCategoryName] + '/[url]', as: _this2.mapping[contentCategoryName] + '/' + row.url.current },
5372
+ React__default.createElement(
5373
+ 'a',
5374
+ null,
5375
+ React__default.createElement(
5376
+ Card.Title,
5377
+ null,
5378
+ row.title
5379
+ ),
5380
+ React__default.createElement(
5381
+ Card.Text,
5382
+ { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
5383
+ row.summary
5384
+ )
5385
+ )
5386
+ )
5387
+ )
5388
+ )
5389
+ )
5390
+ );
5391
+ })
5392
+ );
5393
+ }
5394
+ }, {
5395
+ key: 'render',
5396
+ value: function render() {
5397
+ var _this3 = this;
5398
+
5399
+ var _props = this.props,
5400
+ columns = _props.columns,
5401
+ variant = _props.variant,
5402
+ autoScroll = _props.autoScroll,
5403
+ page = _props.page;
5404
+
5405
+
5406
+ return React__default.createElement(
5407
+ 'div',
5408
+ { className: 'contentDeck' },
5409
+ autoScroll ? React__default.createElement(
5410
+ InfiniteScroll,
5411
+ { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
5412
+ React__default.createElement(
5413
+ Container,
5414
+ null,
5415
+ this.cardLoader(page, columns, variant)
5416
+ )
5417
+ ) : React__default.createElement(
5418
+ React__default.Fragment,
5419
+ null,
5420
+ React__default.createElement(
5421
+ Container,
5422
+ null,
5423
+ this.cardLoader(page, columns, variant)
5424
+ ),
5425
+ React__default.createElement(
5426
+ 'div',
5427
+ { style: { padding: '0px 10px' } },
5428
+ this.state.scrolling ? React__default.createElement(
5429
+ 'button',
5430
+ {
5431
+ style: { margin: 'auto', width: '100%' },
5432
+ onClick: function onClick(e) {
5433
+ _this3.loadMore();
5434
+ } },
5435
+ 'Load More'
5436
+ ) : React__default.createElement(
5437
+ 'p',
5438
+ { style: { textAlign: 'center' } },
5439
+ React__default.createElement(
5440
+ 'b',
5441
+ null,
5442
+ 'End of data'
5443
+ )
5444
+ )
5445
+ )
5446
+ )
5447
+ );
5448
+ }
5449
+ }]);
5450
+ return GridContent;
5451
+ }(React__default.Component);
5452
+
5129
5453
  var DeckQueue = function (_React$Component) {
5130
5454
  inherits(DeckQueue, _React$Component);
5131
5455
 
@@ -11703,5 +12027,5 @@ var getSerializers$1 = function getSerializers(client, pageview) {
11703
12027
  };
11704
12028
  };
11705
12029
 
11706
- export { ContentCard as DeckContent, 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 };
12030
+ 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 };
11707
12031
  //# sourceMappingURL=index.es.js.map