@mjhls/mjh-framework 1.0.146 → 1.0.149

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
@@ -31,6 +31,7 @@ var reactSocialIcons = require('react-social-icons');
31
31
  var Nav = _interopDefault(require('react-bootstrap/Nav'));
32
32
  var Navbar = _interopDefault(require('react-bootstrap/Navbar'));
33
33
  var NavDropdown = _interopDefault(require('react-bootstrap/NavDropdown'));
34
+ var download = _interopDefault(require('downloadjs'));
34
35
  var ReactPlayerLoader = _interopDefault(require('@brightcove/react-player-loader'));
35
36
  var ReactPlayer = _interopDefault(require('react-player'));
36
37
  var Pagination = _interopDefault(require('react-bootstrap/Pagination'));
@@ -3647,8 +3648,8 @@ var ImageUrlBuilder = /** @class */ (function () {
3647
3648
  return this.withOptions({ quality: quality });
3648
3649
  };
3649
3650
  // Make it a download link. Parameter is default filename.
3650
- ImageUrlBuilder.prototype.forceDownload = function (download) {
3651
- return this.withOptions({ download: download });
3651
+ ImageUrlBuilder.prototype.forceDownload = function (download$$1) {
3652
+ return this.withOptions({ download: download$$1 });
3652
3653
  };
3653
3654
  // Flip image horizontally
3654
3655
  ImageUrlBuilder.prototype.flipHorizontal = function () {
@@ -6257,6 +6258,8 @@ var GridContent = function (_React$Component) {
6257
6258
  );
6258
6259
  }
6259
6260
  } else return null;
6261
+ }, _this.checkExternalUrl = function (url) {
6262
+ return new RegExp(['http', 'https'].join('|')).test(url);
6260
6263
  }, _this.renderMobileAd = function (index$$1, numberOfItemsBeforeAd) {
6261
6264
  var rightItems = _this.props.rightItems;
6262
6265
 
@@ -6376,10 +6379,68 @@ var GridContent = function (_React$Component) {
6376
6379
  { className: 'grid-container' },
6377
6380
  this.state.data && this.state.data.map(function (row, index$$1) {
6378
6381
  var pageNumber = row.pageNumber || _this2.state.page;
6379
- var contentCategoryName = row.contentCategory && row.contentCategory.name && _this2.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
6380
- var linkHref = _this2.mapping[contentCategoryName] + '/' + row.url.current;
6381
- if (row.url && row.url.current && row.url.externalUrl) {
6382
- linkHref = row.url.current;
6382
+ var linkHref = '' + row.url.current;
6383
+ if (row.blank || _this2.checkExternalUrl(row.url.current)) {
6384
+ return React__default.createElement(
6385
+ React__default.Fragment,
6386
+ { key: itemCounter },
6387
+ React__default.createElement(
6388
+ VisibilitySensor,
6389
+ {
6390
+ onChange: function onChange(isVisible) {
6391
+ isVisible && _this2.changePageNumber(pageNumber);
6392
+ } },
6393
+ React__default.createElement(
6394
+ 'div',
6395
+ { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
6396
+ React__default.createElement(
6397
+ Card,
6398
+ { className: 'content-card', style: { flexDirection: index$$1 === 0 || index$$1 % 4 === 0 ? 'top' : 'row' } },
6399
+ (row.thumbnail && row.thumbnail.asset || _this2.props.defaultImage) && React__default.createElement(
6400
+ 'a',
6401
+ { href: row.url.current, target: '_blank', className: index$$1 === 0 || index$$1 % 4 === 0 ? '' : 'card-image' },
6402
+ React__default.createElement(
6403
+ LazyLoad,
6404
+ { height: _this2.props.imageHeight },
6405
+ React__default.createElement(Card.Img, {
6406
+ variant: 'top',
6407
+ src: _this2.renderCardImage(row, page),
6408
+ alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
6409
+ })
6410
+ )
6411
+ ),
6412
+ React__default.createElement(
6413
+ Card.Body,
6414
+ null,
6415
+ React__default.createElement(
6416
+ 'a',
6417
+ { href: row.url.current, target: '_blank' },
6418
+ React__default.createElement(
6419
+ Card.Title,
6420
+ null,
6421
+ row.title
6422
+ )
6423
+ ),
6424
+ _this2.props.showPublished && row.published && React__default.createElement(
6425
+ Card.Subtitle,
6426
+ { style: { marginTop: 0 } },
6427
+ moment(row.published).format('MMMM DD, YYYY')
6428
+ ),
6429
+ _this2.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && row.authorMapping.map(function (authorDetail, index$$1) {
6430
+ return _this2.renderAuthor(authorDetail, index$$1, row.authorMapping.length);
6431
+ }),
6432
+ React__default.createElement(
6433
+ Card.Text,
6434
+ { className: index$$1 === 0 || index$$1 % 4 === 0 ? '' : 'card-subtext' },
6435
+ row.summary
6436
+ )
6437
+ )
6438
+ )
6439
+ )
6440
+ ),
6441
+ showVideo && (_this2.state.data.length < numberOfItemsBeforeVideo || index$$1 + 1 === numberOfItemsBeforeVideo) && React__default.createElement(VideoPlayer, null),
6442
+ main_36 && _this2.props.rightItems && (index$$1 + 1) % numberOfItemsBeforeAd === 0 && _this2.renderMobileAd(index$$1, numberOfItemsBeforeAd)
6443
+ );
6383
6444
  }
6384
6445
  return React__default.createElement(
6385
6446
  React__default.Fragment,
@@ -6401,7 +6462,7 @@ var GridContent = function (_React$Component) {
6401
6462
  { href: linkHref },
6402
6463
  React__default.createElement(
6403
6464
  'a',
6404
- { target: row.url && row.url.target ? '_blank' : '_self', className: index$$1 === 0 || index$$1 % 4 === 0 ? '' : 'card-image' },
6465
+ { className: index$$1 === 0 || index$$1 % 4 === 0 ? '' : 'card-image' },
6405
6466
  React__default.createElement(
6406
6467
  LazyLoad,
6407
6468
  { height: _this2.props.imageHeight },
@@ -6421,7 +6482,7 @@ var GridContent = function (_React$Component) {
6421
6482
  { href: linkHref },
6422
6483
  React__default.createElement(
6423
6484
  'a',
6424
- { target: row.url && row.url.target ? '_blank' : '_self' },
6485
+ null,
6425
6486
  React__default.createElement(
6426
6487
  Card.Title,
6427
6488
  null,
@@ -14071,6 +14132,19 @@ var Media$1 = function Media$$1(_ref) {
14071
14132
  )
14072
14133
  );
14073
14134
  } else if (caption && caption !== '') {
14135
+ if (uploadDoc.downloadMedia) {
14136
+ return React__default.createElement(
14137
+ 'a',
14138
+ {
14139
+ href: uploadDoc.asset.url,
14140
+ target: '_blank',
14141
+ className: 'd-block',
14142
+ onClick: function onClick() {
14143
+ download(uploadDoc.asset.url, uploadDoc.asset.originalFilename);
14144
+ } },
14145
+ caption
14146
+ );
14147
+ }
14074
14148
  return React__default.createElement(
14075
14149
  'a',
14076
14150
  { href: uploadDoc.asset.url, target: blank ? '_blank' : '_self', className: 'd-block text-center' },
@@ -14794,6 +14868,68 @@ var html_decode = function html_decode(string) {
14794
14868
  };
14795
14869
  var html_decode_1 = html_decode;
14796
14870
 
14871
+ var urlFor$3 = function urlFor(source, builder) {
14872
+ return builder.image(source);
14873
+ };
14874
+
14875
+ var onChangeSlide$1 = function onChangeSlide(selectedIndex, pageview, setCarouselIndex, asPath) {
14876
+ setCarouselIndex(selectedIndex);
14877
+ lib_3.refresh();
14878
+ if (pageview) pageview(asPath);
14879
+ };
14880
+
14881
+ var Slideshow$1 = function Slideshow(_ref) {
14882
+ var slides = _ref.node.slides,
14883
+ client = _ref.client,
14884
+ pageview = _ref.pageview,
14885
+ serializerArguments = _ref.serializerArguments;
14886
+
14887
+ console.log(slides);
14888
+ var router$$1 = router.useRouter();
14889
+
14890
+ var _useState = React.useState(0),
14891
+ _useState2 = slicedToArray(_useState, 2),
14892
+ carouselIndex = _useState2[0],
14893
+ setCarouselIndex = _useState2[1];
14894
+
14895
+ var builder = imageUrlBuilder(client);
14896
+
14897
+ return React__default.createElement(
14898
+ 'div',
14899
+ { className: 'mt-3 mb-3' },
14900
+ React__default.createElement(
14901
+ reactBootstrap.Carousel,
14902
+ { activeIndex: carouselIndex, onSelect: function onSelect(selectedIndex, e) {
14903
+ return onChangeSlide$1(selectedIndex, pageview, setCarouselIndex, router$$1.asPath);
14904
+ }, indicators: false },
14905
+ slides && slides.map(function (slide) {
14906
+ if (slide.slideshowImage && slide.slideshowImage.asset) {
14907
+ return React__default.createElement(
14908
+ reactBootstrap.Carousel.Item,
14909
+ { key: slide._key },
14910
+ React__default.createElement(
14911
+ 'a',
14912
+ { href: slide.slideshowImage.link && slide.slideshowImage.link, target: slide.slideshowImage.blank ? '_blank' : '_self' },
14913
+ React__default.createElement('img', { src: urlFor$3(slide.slideshowImage, builder).url(), alt: slide.slideshowImage.alt || 'slideshow image', style: { width: '100%' } })
14914
+ ),
14915
+ React__default.createElement(
14916
+ 'div',
14917
+ { className: 'p-2' },
14918
+ slide.slideshowImage.caption && React__default.createElement(
14919
+ 'h3',
14920
+ null,
14921
+ slide.slideshowImage.caption
14922
+ ),
14923
+ slide.description && React__default.createElement(BlockContent, { blocks: slide.description, serializers: getSerializers$1(serializerArguments) })
14924
+ )
14925
+ );
14926
+ }
14927
+ return null;
14928
+ })
14929
+ )
14930
+ );
14931
+ };
14932
+
14797
14933
  var convertEntities = function convertEntities(props) {
14798
14934
  if (typeof props === 'string' || props instanceof String) {
14799
14935
  props = html_decode_1(props);
@@ -14889,6 +15025,11 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
14889
15025
 
14890
15026
  var url = '' + drupalLeadSettings.baseUrl + leadID;
14891
15027
  return React__default.createElement(Leads, { url: url });
15028
+ },
15029
+ slideshows: function slideshows(_ref14) {
15030
+ var node = _ref14.node;
15031
+
15032
+ return React__default.createElement(Slideshow$1, { node: node, client: client, pageview: pageview, serializerArguments: (drupalLeadSettings) });
14892
15033
  }
14893
15034
  },
14894
15035
  marks: {
@@ -14918,32 +15059,32 @@ var getSerializers$1 = function getSerializers(client, pageview, videoAccountIDs
14918
15059
  children
14919
15060
  );
14920
15061
  },
14921
- alignleft: function alignleft(_ref14) {
14922
- var children = _ref14.children;
15062
+ alignleft: function alignleft(_ref15) {
15063
+ var children = _ref15.children;
14923
15064
  return React__default.createElement(
14924
15065
  'div',
14925
15066
  { style: { textAlign: 'left' } },
14926
15067
  children
14927
15068
  );
14928
15069
  },
14929
- alignright: function alignright(_ref15) {
14930
- var children = _ref15.children;
15070
+ alignright: function alignright(_ref16) {
15071
+ var children = _ref16.children;
14931
15072
  return React__default.createElement(
14932
15073
  'div',
14933
15074
  { style: { textAlign: 'right' } },
14934
15075
  children
14935
15076
  );
14936
15077
  },
14937
- aligncenter: function aligncenter(_ref16) {
14938
- var children = _ref16.children;
15078
+ aligncenter: function aligncenter(_ref17) {
15079
+ var children = _ref17.children;
14939
15080
  return React__default.createElement(
14940
15081
  'div',
14941
15082
  { style: { textAlign: 'center' } },
14942
15083
  children
14943
15084
  );
14944
15085
  },
14945
- alignjustify: function alignjustify(_ref17) {
14946
- var children = _ref17.children;
15086
+ alignjustify: function alignjustify(_ref18) {
15087
+ var children = _ref18.children;
14947
15088
  return React__default.createElement(
14948
15089
  'div',
14949
15090
  { style: { textAlign: 'justify' } },
@@ -15118,13 +15259,13 @@ var SetCookie = function SetCookie(key, value) {
15118
15259
  cookie.set(key, value, { expires: 1, sameSite: 'none', secure: true });
15119
15260
  };
15120
15261
 
15121
- var urlFor$3 = function urlFor(source, client) {
15262
+ var urlFor$4 = function urlFor(source, client) {
15122
15263
  var builder = imageUrlBuilder(client);
15123
15264
  return builder.image(source);
15124
15265
  };
15125
15266
 
15126
15267
  var renderCardImage$1 = function renderCardImage(thumbnail, client, imageHeight, imageWidth) {
15127
- var url = urlFor$3(thumbnail, client);
15268
+ var url = urlFor$4(thumbnail, client);
15128
15269
  if (imageHeight) url = url.height(imageHeight);
15129
15270
  if (imageWidth) url = url.width(imageWidth);
15130
15271
  return url.url();
@@ -15372,6 +15513,101 @@ var RelatedTopicsDropdown = function RelatedTopicsDropdown(_ref) {
15372
15513
  }
15373
15514
  };
15374
15515
 
15516
+ // THIS FILE IS AUTO GENERATED
15517
+ var FaWindowClose = function (props) {
15518
+ return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M464 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zm-83.6 290.5c4.8 4.8 4.8 12.6 0 17.4l-40.5 40.5c-4.8 4.8-12.6 4.8-17.4 0L256 313.3l-66.5 67.1c-4.8 4.8-12.6 4.8-17.4 0l-40.5-40.5c-4.8-4.8-4.8-12.6 0-17.4l67.1-66.5-67.1-66.5c-4.8-4.8-4.8-12.6 0-17.4l40.5-40.5c4.8-4.8 12.6-4.8 17.4 0l66.5 67.1 66.5-67.1c4.8-4.8 12.6-4.8 17.4 0l40.5 40.5c4.8 4.8 4.8 12.6 0 17.4L313.3 256l67.1 66.5z"}}]})(props);
15519
+ };
15520
+ FaWindowClose.displayName = "FaWindowClose";
15521
+
15522
+ /*****UStream Component*****/
15523
+ /*
15524
+
15525
+ Width and Height(percent or px) prop passed is the floating window, when closed
15526
+ it will take 100% of its parent element
15527
+
15528
+ You can pass in another SRC for Ustream if needed
15529
+
15530
+ If 'close' is passed as prop, the floating window will be removed
15531
+ from DOM once close button is hit
15532
+
15533
+ Example:
15534
+ import { Ustream } from '@mjhls/mjh-framework';
15535
+ <Ustream width={'200px'} height={'120px'} close />
15536
+
15537
+ */
15538
+ /************************* */
15539
+ var Ustream = function Ustream(_ref) {
15540
+ var _ref$width = _ref.width,
15541
+ width = _ref$width === undefined ? '300px' : _ref$width,
15542
+ _ref$height = _ref.height,
15543
+ height = _ref$height === undefined ? '168px' : _ref$height,
15544
+ _ref$close = _ref.close,
15545
+ close = _ref$close === undefined ? false : _ref$close,
15546
+ _ref$src = _ref.src,
15547
+ src = _ref$src === undefined ? 'https://video.ibm.com/embed/23627444?volume=0&autoplay=true' : _ref$src;
15548
+
15549
+ var _useState = React.useState(width),
15550
+ _useState2 = slicedToArray(_useState, 2),
15551
+ currentWidth = _useState2[0],
15552
+ setWidth = _useState2[1];
15553
+
15554
+ var _useState3 = React.useState(height),
15555
+ _useState4 = slicedToArray(_useState3, 2),
15556
+ currentHeight = _useState4[0],
15557
+ setHeight = _useState4[1];
15558
+
15559
+ var ustreamContainer = React.useRef(null);
15560
+
15561
+ React.useEffect(function () {
15562
+ try {
15563
+ document.querySelector('.ustream-close').addEventListener('click', function (e) {
15564
+ var container = document.getElementById('ustream-container');
15565
+ if (close) {
15566
+ container.remove();
15567
+ } else {
15568
+ container.style.position = 'static';
15569
+ container.style.padding = '0 1rem';
15570
+ container.classList.add('closed');
15571
+ setWidth('100%');
15572
+ //aspect ratio
15573
+ var newHeight = 9 / 16 * ustreamContainer.current.clientWidth;
15574
+ console.log(newHeight);
15575
+ console.log(ustreamContainer);
15576
+ setHeight(newHeight);
15577
+ e.target.remove();
15578
+ }
15579
+ });
15580
+ } catch (err) {}
15581
+ }, []);
15582
+
15583
+ return React__default.createElement(
15584
+ 'div',
15585
+ { id: 'ustream-container', ref: ustreamContainer, style: { width: '' + currentWidth, marginBottom: '1rem' } },
15586
+ React__default.createElement(
15587
+ 'div',
15588
+ { style: { position: 'relative' } },
15589
+ React__default.createElement(
15590
+ 'div',
15591
+ { className: 'ustream-close' },
15592
+ React__default.createElement(FaWindowClose, { style: { fontSize: '1.3rem' } })
15593
+ ),
15594
+ React__default.createElement('iframe', {
15595
+ id: 'ustream-iframe',
15596
+ src: src,
15597
+ webkitallowfullscreen: true,
15598
+ allowFullScreen: true,
15599
+ frameBorder: 'no',
15600
+
15601
+ style: { maxWidth: '100%', height: currentHeight, width: currentWidth } })
15602
+ ),
15603
+ React__default.createElement(
15604
+ 'style',
15605
+ { jsx: 'true' },
15606
+ '\n #ustream-container {\n position: fixed;\n bottom: 0;\n right: 1rem;\n z-index: 999;\n max-width: 100%;\n }\n .ustream-close {\n position: absolute;\n color: white;\n right: 0.5rem;\n top: 0.25rem;\n cursor: pointer;\n font-weight: bold;\n }\n @media screen and (max-width: 768px) {\n #ustream-container:not(.closed) {\n width: 231px !important;\n height: 130px !important;\n }\n #ustream-container:not(.closed) iframe {\n height: 130px !important;\n }\n }\n '
15607
+ )
15608
+ );
15609
+ };
15610
+
15375
15611
  exports.DeckContent = ContentCard;
15376
15612
  exports.GridContent = GridContent$1;
15377
15613
  exports.DeckQueue = Queue;
@@ -15412,4 +15648,5 @@ exports.Hero = Hero;
15412
15648
  exports.AlphabeticList = AlphabeticList;
15413
15649
  exports.PdfDownload = PdfDownload;
15414
15650
  exports.RelatedTopicsDropdown = RelatedTopicsDropdown;
15651
+ exports.Ustream = Ustream;
15415
15652
  //# sourceMappingURL=index.js.map