@mjhls/mjh-framework 1.0.13 → 1.0.15

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.es.js CHANGED
@@ -13,6 +13,7 @@ import Form from 'react-bootstrap/Form';
13
13
  import FormControl from 'react-bootstrap/FormControl';
14
14
  import Button from 'react-bootstrap/Button';
15
15
  import PropTypes from 'prop-types';
16
+ import { Figure, Carousel } from 'react-bootstrap';
16
17
 
17
18
  /*! *****************************************************************************
18
19
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -892,6 +893,27 @@ var DeckQueue = function (_React$Component) {
892
893
  return DeckQueue;
893
894
  }(React__default.Component);
894
895
 
896
+ var Column1 = function Column1(props) {
897
+ return React__default.createElement(
898
+ 'section',
899
+ null,
900
+ React__default.createElement(
901
+ Row,
902
+ { className: 'justify-content-md-center' },
903
+ React__default.createElement(
904
+ Col,
905
+ { className: 'middleCol' },
906
+ React__default.createElement(
907
+ 'h1',
908
+ null,
909
+ props.title
910
+ ),
911
+ props.children
912
+ )
913
+ )
914
+ );
915
+ };
916
+
895
917
  var Column2 = function Column2(props) {
896
918
  var rightItems = props.rightItems;
897
919
 
@@ -1428,6 +1450,126 @@ var NavNormal = function NavNormal(props) {
1428
1450
  );
1429
1451
  };
1430
1452
 
1453
+ var NavDvm = function NavDvm(props) {
1454
+ var logo = props.logo,
1455
+ dataObject = props.dataObject,
1456
+ subNavHeads = props.subNavHeads;
1457
+
1458
+
1459
+ return React__default.createElement(
1460
+ 'section',
1461
+ null,
1462
+ React__default.createElement(
1463
+ Navbar,
1464
+ { expand: 'md', className: 'header-container', style: { background: '#151F5D' } },
1465
+ React__default.createElement(
1466
+ Container,
1467
+ { className: 'd-flex px-0' },
1468
+ React__default.createElement(
1469
+ 'div',
1470
+ { className: 'd-flex' },
1471
+ React__default.createElement('img', { src: logo, className: 'h-100' }),
1472
+ React__default.createElement('div', { className: ' ml-4' })
1473
+ ),
1474
+ React__default.createElement(
1475
+ 'div',
1476
+ { className: 'login-right-wrapper w-50 my-3', style: { background: 'linear-gradient(to right,#104676,#01ABB5)' } },
1477
+ React__default.createElement(
1478
+ 'div',
1479
+ { className: 'row' },
1480
+ subNavHeads && subNavHeads.map(function (item, index) {
1481
+ return React__default.createElement(
1482
+ 'div',
1483
+ { key: index, className: 'col-3 py-1', style: { fontSize: '12px' } },
1484
+ React__default.createElement(
1485
+ 'span',
1486
+ { style: { color: '#fff' } },
1487
+ item.name,
1488
+ ' '
1489
+ )
1490
+ );
1491
+ })
1492
+ )
1493
+ )
1494
+ )
1495
+ ),
1496
+ React__default.createElement(
1497
+ Navbar,
1498
+ { variant: 'dark', className: 'dvm-nav p-0', style: { background: 'linear-gradient(to right,#FFB71C,#ED4303,#EB3300)' } },
1499
+ React__default.createElement(
1500
+ Container,
1501
+ null,
1502
+ React__default.createElement(Navbar.Toggle, { 'aria-controls': 'basic-navbar-nav' }),
1503
+ React__default.createElement(
1504
+ Navbar.Collapse,
1505
+ { id: 'basic-navbar-nav' },
1506
+ React__default.createElement(
1507
+ Nav,
1508
+ { className: 'mr-auto' },
1509
+ dataObject && dataObject.map(function (row, index) {
1510
+ if (row.subQuery.length > 1) {
1511
+ return React__default.createElement(
1512
+ NavDropdown,
1513
+ { key: index, title: row.name, id: 'basic-nav-dropdown' },
1514
+ row.subQuery && row.subQuery.map(function (ddRow, ddItems, subIndex) {
1515
+ if (ddRow.type === 'divider') {
1516
+ return React__default.createElement(NavDropdown.Divider, { key: subIndex });
1517
+ } else {
1518
+ return React__default.createElement(
1519
+ Link,
1520
+ { href: ddRow.url },
1521
+ React__default.createElement(
1522
+ 'a',
1523
+ { key: subIndex, className: 'dropdown-item' },
1524
+ ddRow.name
1525
+ )
1526
+ );
1527
+ }
1528
+ })
1529
+ );
1530
+ } else {
1531
+ return React__default.createElement(
1532
+ Link,
1533
+ { href: row.url },
1534
+ React__default.createElement(
1535
+ 'a',
1536
+ { key: index, className: 'nav-link' },
1537
+ row.name
1538
+ )
1539
+ );
1540
+ }
1541
+ })
1542
+ ),
1543
+ React__default.createElement(
1544
+ 'div',
1545
+ { className: 'login-subscibe', style: { fontSize: '12px' } },
1546
+ React__default.createElement(
1547
+ 'span',
1548
+ { style: { color: '#FFDC3F' } },
1549
+ '>> ',
1550
+ React__default.createElement(
1551
+ 'span',
1552
+ { style: { color: '#fff' } },
1553
+ ' Login'
1554
+ )
1555
+ ),
1556
+ React__default.createElement(
1557
+ 'span',
1558
+ { style: { color: '#FFDC3F' } },
1559
+ '>> ',
1560
+ React__default.createElement(
1561
+ 'span',
1562
+ { style: { color: '#fff' } },
1563
+ ' Register'
1564
+ )
1565
+ )
1566
+ )
1567
+ )
1568
+ )
1569
+ )
1570
+ );
1571
+ };
1572
+
1431
1573
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
1432
1574
 
1433
1575
  function unwrapExports (x) {
@@ -3081,52 +3223,63 @@ var lib_1 = lib.DFPSlotsProvider;
3081
3223
  var lib_2 = lib.AdSlot;
3082
3224
  var lib_3 = lib.DFPManager;
3083
3225
 
3084
- var AD728x90 = function (_Component) {
3085
- inherits(AD728x90, _Component);
3086
-
3087
- function AD728x90(props) {
3088
- classCallCheck(this, AD728x90);
3226
+ var AD = function AD(_ref) {
3227
+ var networkID = _ref.networkID,
3228
+ adUnit = _ref.adUnit,
3229
+ sizeMapping = _ref.sizeMapping,
3230
+ className = _ref.className,
3231
+ _ref$slotId = _ref.slotId,
3232
+ slotId = _ref$slotId === undefined ? 'test' : _ref$slotId,
3233
+ sizes = _ref.sizes,
3234
+ minInViewPercent = _ref.minInViewPercent;
3089
3235
 
3090
- var _this = possibleConstructorReturn(this, (AD728x90.__proto__ || Object.getPrototypeOf(AD728x90)).call(this, props));
3236
+ return React__default.createElement(
3237
+ lib_1,
3238
+ { dfpNetworkId: networkID, sizeMapping: sizeMapping },
3239
+ React__default.createElement(
3240
+ 'div',
3241
+ { className: className },
3242
+ React__default.createElement(lib_2, {
3243
+ slotId: slotId,
3244
+ sizes: sizes,
3245
+ adUnit: adUnit,
3246
+ sizeMapping: sizeMapping,
3247
+ onSlotVisibilityChanged: function onSlotVisibilityChanged(dfpEventData) {
3248
+ if (minInViewPercent && dfpEventData.event.inViewPercentage < minInViewPercent) {
3249
+ lib_3.refresh(slotId);
3250
+ }
3251
+ },
3252
+ onSlotIsViewable: function onSlotIsViewable(dfpEventData) {
3253
+ return console.log(slotId + ' viewable!.', dfpEventData);
3254
+ }
3255
+ })
3256
+ )
3257
+ );
3258
+ };
3091
3259
 
3092
- _this.option = {
3093
- networkID: props.networkID,
3094
- adUnit: props.adUnit
3095
- };
3096
- return _this;
3097
- }
3260
+ AD.propTypes = {
3261
+ networkID: PropTypes.number.isRequired,
3262
+ adUnit: PropTypes.string.isRequired,
3263
+ slotId: PropTypes.string.isRequired,
3264
+ className: PropTypes.string,
3265
+ sizeMapping: PropTypes.array,
3266
+ sizes: PropTypes.array,
3267
+ minInViewPercent: PropTypes.number
3268
+ };
3098
3269
 
3099
- createClass(AD728x90, [{
3100
- key: 'render',
3101
- value: function render() {
3102
- return React__default.createElement(
3103
- lib_1,
3104
- {
3105
- dfpNetworkId: this.option.networkID,
3106
- sizeMapping: [{ viewport: [768, 1], sizes: [[728, 90]] }, { viewport: [1, 1], sizes: [[320, 50]] }] },
3107
- React__default.createElement(
3108
- 'div',
3109
- { className: 'AD728x90' },
3110
- React__default.createElement(lib_2, {
3111
- slotId: 'test',
3112
- sizes: [[728, 90], [320, 50]],
3113
- adUnit: this.option.adUnit,
3114
- sizeMapping: [{ viewport: [768, 1], sizes: [[728, 90]] }, { viewport: [1, 1], sizes: [[320, 50]] }],
3115
- onSlotVisibilityChanged: function onSlotVisibilityChanged(dfpEventData) {
3116
- if (dfpEventData.event.inViewPercentage < '70') {
3117
- lib_3.refresh('test');
3118
- }
3119
- },
3120
- onSlotIsViewable: function onSlotIsViewable(dfpEventData) {
3121
- return console.log('slot 1 viewable!.', dfpEventData);
3122
- }
3123
- })
3124
- )
3125
- );
3126
- }
3127
- }]);
3128
- return AD728x90;
3129
- }(Component);
3270
+ var AD728x90 = function AD728x90(_ref) {
3271
+ var networkID = _ref.networkID,
3272
+ adUnit = _ref.adUnit;
3273
+
3274
+ return React__default.createElement(AD, {
3275
+ networkID: networkID,
3276
+ adUnit: adUnit,
3277
+ className: 'AD728x90',
3278
+ sizes: [[300, 250], [300, 600]],
3279
+ sizeMapping: [{ viewport: [768, 1], sizes: [[728, 90]] }, { viewport: [1, 1], sizes: [[320, 50]] }],
3280
+ minInViewPercent: 70
3281
+ });
3282
+ };
3130
3283
 
3131
3284
  // Main
3132
3285
  var TemplateNormal = function TemplateNormal(props) {
@@ -3145,6 +3298,8 @@ var TemplateNormal = function TemplateNormal(props) {
3145
3298
  return React__default.createElement(NavMagazine, { logo: website.logo, dataObject: config.navItems });
3146
3299
  case 'native':
3147
3300
  return React__default.createElement(NavNative, { logo: website.logo, dataObject: config.navItems });
3301
+ case 'dvm':
3302
+ return React__default.createElement(NavDvm, { logo: website.logo, dataObject: config.navItems });
3148
3303
  default:
3149
3304
  return React__default.createElement('noNav', null);
3150
3305
  }
@@ -3152,6 +3307,12 @@ var TemplateNormal = function TemplateNormal(props) {
3152
3307
 
3153
3308
  function layout() {
3154
3309
  switch (config.columns) {
3310
+ case '1':
3311
+ return React__default.createElement(
3312
+ Column1,
3313
+ null,
3314
+ props.children
3315
+ );
3155
3316
  case '2':
3156
3317
  return React__default.createElement(
3157
3318
  Column2,
@@ -3187,72 +3348,64 @@ var TemplateNormal = function TemplateNormal(props) {
3187
3348
  );
3188
3349
  };
3189
3350
 
3190
- var AD300x250 = function (_Component) {
3191
- inherits(AD300x250, _Component);
3351
+ var AD300x250 = function AD300x250(_ref) {
3352
+ var networkID = _ref.networkID,
3353
+ adUnit = _ref.adUnit;
3192
3354
 
3193
- function AD300x250(props) {
3194
- classCallCheck(this, AD300x250);
3195
-
3196
- var _this = possibleConstructorReturn(this, (AD300x250.__proto__ || Object.getPrototypeOf(AD300x250)).call(this, props));
3197
-
3198
- _this.option = {
3199
- networkID: props.networkID,
3200
- adUnit: props.adUnit
3201
- };
3202
- return _this;
3203
- }
3355
+ return React__default.createElement(AD, { networkID: networkID, adUnit: adUnit, className: 'AD300x250', sizes: [[300, 250]] });
3356
+ };
3204
3357
 
3205
- createClass(AD300x250, [{
3206
- key: 'render',
3207
- value: function render() {
3208
- return React__default.createElement(
3209
- lib_1,
3210
- { dfpNetworkId: this.option.networkID },
3211
- React__default.createElement(
3212
- 'div',
3213
- { className: 'AD300x250' },
3214
- React__default.createElement(lib_2, { sizes: [[300, 250]], adUnit: this.option.adUnit })
3215
- )
3216
- );
3217
- }
3218
- }]);
3219
- return AD300x250;
3220
- }(Component);
3358
+ var AD300x250x600 = function AD300x250x600(_ref) {
3359
+ var networkID = _ref.networkID,
3360
+ adUnit = _ref.adUnit;
3221
3361
 
3222
- var AD300x250x600 = function (_Component) {
3223
- inherits(AD300x250x600, _Component);
3362
+ return React__default.createElement(AD, {
3363
+ networkID: networkID,
3364
+ adUnit: adUnit,
3365
+ className: 'AD300x250',
3366
+ sizes: [[300, 250], [300, 600]]
3367
+ });
3368
+ };
3224
3369
 
3225
- function AD300x250x600(props) {
3226
- classCallCheck(this, AD300x250x600);
3370
+ var FigureComponent = function FigureComponent(_ref) {
3371
+ var caption = _ref.caption,
3372
+ url = _ref.url;
3227
3373
 
3228
- var _this = possibleConstructorReturn(this, (AD300x250x600.__proto__ || Object.getPrototypeOf(AD300x250x600)).call(this, props));
3374
+ return React__default.createElement(
3375
+ 'div',
3376
+ { style: { textAlign: 'center', marginTop: '1em', marginBottom: '1em' } },
3377
+ React__default.createElement(
3378
+ Figure,
3379
+ null,
3380
+ React__default.createElement(Figure.Image, { alt: caption, src: url }),
3381
+ React__default.createElement(
3382
+ Figure.Caption,
3383
+ null,
3384
+ caption
3385
+ )
3386
+ )
3387
+ );
3388
+ };
3229
3389
 
3230
- _this.option = {
3231
- networkID: props.networkID,
3232
- adUnit: props.adUnit
3233
- };
3234
- return _this;
3235
- }
3390
+ var Slideshow = function Slideshow(_ref) {
3391
+ var slides = _ref.slides;
3236
3392
 
3237
- createClass(AD300x250x600, [{
3238
- key: 'render',
3239
- value: function render() {
3240
- return React__default.createElement(
3241
- lib_1,
3242
- { dfpNetworkId: this.option.networkID },
3243
- React__default.createElement(
3244
- 'div',
3245
- { className: 'AD300x250' },
3246
- React__default.createElement(lib_2, {
3247
- sizes: [[300, 250], [300, 600]],
3248
- adUnit: this.option.adUnit
3249
- })
3250
- )
3251
- );
3252
- }
3253
- }]);
3254
- return AD300x250x600;
3255
- }(Component);
3393
+ return React__default.createElement(
3394
+ 'div',
3395
+ { style: { marginTop: '1em', marginBottom: '1em' } },
3396
+ React__default.createElement(
3397
+ Carousel,
3398
+ null,
3399
+ slides && slides.map(function (slide) {
3400
+ return React__default.createElement(
3401
+ Carousel.Item,
3402
+ { key: slide._key },
3403
+ React__default.createElement('img', { style: { width: '100%' }, src: slide.url, alt: slide.asset.originalFilename })
3404
+ );
3405
+ })
3406
+ )
3407
+ );
3408
+ };
3256
3409
 
3257
3410
  var getYoutubeId = createCommonjsModule(function (module, exports) {
3258
3411
  (function (root, factory) {
@@ -5919,19 +6072,582 @@ YouTube.PlayerState = {
5919
6072
  CUED: 5
5920
6073
  };
5921
6074
 
5922
- var getSerializers = function getSerializers() {
6075
+ var YouTubePlayer$1 = function YouTubePlayer(_ref) {
6076
+ var url = _ref.url;
6077
+
6078
+ var id = getYoutubeId(url);
6079
+ return React__default.createElement(YouTube, { videoId: id, opts: { width: '100%' } });
6080
+ };
6081
+
6082
+ var parseAssetId_1 = createCommonjsModule(function (module, exports) {
6083
+ Object.defineProperty(exports, "__esModule", { value: true });
6084
+ var example = 'image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg';
6085
+ function parseAssetId(ref) {
6086
+ var _a = ref.split('-'), id = _a[1], dimensionString = _a[2], format = _a[3];
6087
+ if (!id || !dimensionString || !format) {
6088
+ throw new Error("Malformed asset _ref '" + ref + "'. Expected an id like \"" + example + "\".");
6089
+ }
6090
+ var _b = dimensionString.split('x'), imgWidthStr = _b[0], imgHeightStr = _b[1];
6091
+ var width = +imgWidthStr;
6092
+ var height = +imgHeightStr;
6093
+ var isValidAssetId = isFinite(width) && isFinite(height);
6094
+ if (!isValidAssetId) {
6095
+ throw new Error("Malformed asset _ref '" + ref + "'. Expected an id like \"" + example + "\".");
6096
+ }
6097
+ return { id: id, width: width, height: height, format: format };
6098
+ }
6099
+ exports.default = parseAssetId;
6100
+
6101
+ });
6102
+
6103
+ unwrapExports(parseAssetId_1);
6104
+
6105
+ var parseSource_1 = createCommonjsModule(function (module, exports) {
6106
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6107
+ __assign = Object.assign || function(t) {
6108
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6109
+ s = arguments[i];
6110
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6111
+ t[p] = s[p];
6112
+ }
6113
+ return t;
6114
+ };
6115
+ return __assign.apply(this, arguments);
6116
+ };
6117
+ Object.defineProperty(exports, "__esModule", { value: true });
6118
+ var isRef = function (src) {
6119
+ var source = src;
6120
+ return source ? typeof source._ref === 'string' : false;
6121
+ };
6122
+ var isAsset = function (src) {
6123
+ var source = src;
6124
+ return source ? typeof source._id === 'string' : false;
6125
+ };
6126
+ var isAssetStub = function (src) {
6127
+ var source = src;
6128
+ return source && source.asset ? typeof source.asset.url === 'string' : false;
6129
+ };
6130
+ // Convert an asset-id, asset or image to an image record suitable for processing
6131
+ // eslint-disable-next-line complexity
6132
+ function parseSource(source) {
6133
+ if (!source) {
6134
+ return null;
6135
+ }
6136
+ var image;
6137
+ if (typeof source === 'string' && isUrl(source)) {
6138
+ // Someone passed an existing image url?
6139
+ image = {
6140
+ asset: { _ref: urlToId(source) }
6141
+ };
6142
+ }
6143
+ else if (typeof source === 'string') {
6144
+ // Just an asset id
6145
+ image = {
6146
+ asset: { _ref: source }
6147
+ };
6148
+ }
6149
+ else if (isRef(source)) {
6150
+ // We just got passed an asset directly
6151
+ image = {
6152
+ asset: source
6153
+ };
6154
+ }
6155
+ else if (isAsset(source)) {
6156
+ // If we were passed an image asset document
6157
+ image = {
6158
+ asset: {
6159
+ _ref: source._id || ''
6160
+ }
6161
+ };
6162
+ }
6163
+ else if (isAssetStub(source)) {
6164
+ // If we were passed a partial asset (`url`, but no `_id`)
6165
+ image = {
6166
+ asset: {
6167
+ _ref: urlToId(source.asset.url)
6168
+ }
6169
+ };
6170
+ }
6171
+ else if (typeof source.asset === 'object') {
6172
+ // Probably an actual image with materialized asset
6173
+ image = source;
6174
+ }
6175
+ else {
6176
+ // We got something that does not look like an image, or it is an image
6177
+ // that currently isn't sporting an asset.
6178
+ return null;
6179
+ }
6180
+ var img = source;
6181
+ if (img.crop) {
6182
+ image.crop = img.crop;
6183
+ }
6184
+ if (img.hotspot) {
6185
+ image.hotspot = img.hotspot;
6186
+ }
6187
+ return applyDefaults(image);
6188
+ }
6189
+ exports.default = parseSource;
6190
+ function isUrl(url) {
6191
+ return /^https?:\/\//.test("" + url);
6192
+ }
6193
+ function urlToId(url) {
6194
+ var parts = url.split('/').slice(-1);
6195
+ return ("image-" + parts[0]).replace(/\.([a-z]+)$/, '-$1');
6196
+ }
6197
+ // Mock crop and hotspot if image lacks it
6198
+ function applyDefaults(image) {
6199
+ if (image.crop && image.hotspot) {
6200
+ return image;
6201
+ }
6202
+ // We need to pad in default values for crop or hotspot
6203
+ var result = __assign({}, image);
6204
+ if (!result.crop) {
6205
+ result.crop = {
6206
+ left: 0,
6207
+ top: 0,
6208
+ bottom: 0,
6209
+ right: 0
6210
+ };
6211
+ }
6212
+ if (!result.hotspot) {
6213
+ result.hotspot = {
6214
+ x: 0.5,
6215
+ y: 0.5,
6216
+ height: 1.0,
6217
+ width: 1.0
6218
+ };
6219
+ }
6220
+ return result;
6221
+ }
6222
+
6223
+ });
6224
+
6225
+ unwrapExports(parseSource_1);
6226
+
6227
+ var urlForImage_1 = createCommonjsModule(function (module, exports) {
6228
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6229
+ __assign = Object.assign || function(t) {
6230
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6231
+ s = arguments[i];
6232
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6233
+ t[p] = s[p];
6234
+ }
6235
+ return t;
6236
+ };
6237
+ return __assign.apply(this, arguments);
6238
+ };
6239
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
6240
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6241
+ };
6242
+ Object.defineProperty(exports, "__esModule", { value: true });
6243
+ var parseAssetId_1$$1 = __importDefault(parseAssetId_1);
6244
+ var parseSource_1$$1 = __importDefault(parseSource_1);
6245
+ exports.parseSource = parseSource_1$$1.default;
6246
+ exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = [
6247
+ ['width', 'w'],
6248
+ ['height', 'h'],
6249
+ ['format', 'fm'],
6250
+ ['download', 'dl'],
6251
+ ['blur', 'blur'],
6252
+ ['sharpen', 'sharp'],
6253
+ ['invert', 'invert'],
6254
+ ['orientation', 'or'],
6255
+ ['minHeight', 'min-h'],
6256
+ ['maxHeight', 'max-h'],
6257
+ ['minWidth', 'min-w'],
6258
+ ['maxWidth', 'max-w'],
6259
+ ['quality', 'q'],
6260
+ ['fit', 'fit'],
6261
+ ['crop', 'crop'],
6262
+ ['auto', 'auto'],
6263
+ ['dpr', 'dpr']
6264
+ ];
6265
+ function urlForImage(options) {
6266
+ var spec = __assign({}, (options || {}));
6267
+ var source = spec.source;
6268
+ delete spec.source;
6269
+ var image = parseSource_1$$1.default(source);
6270
+ if (!image) {
6271
+ return null;
6272
+ }
6273
+ var id = image.asset._ref || image.asset._id || '';
6274
+ var asset = parseAssetId_1$$1.default(id);
6275
+ // Compute crop rect in terms of pixel coordinates in the raw source image
6276
+ var cropLeft = Math.round(image.crop.left * asset.width);
6277
+ var cropTop = Math.round(image.crop.top * asset.height);
6278
+ var crop = {
6279
+ left: cropLeft,
6280
+ top: cropTop,
6281
+ width: Math.round(asset.width - image.crop.right * asset.width - cropLeft),
6282
+ height: Math.round(asset.height - image.crop.bottom * asset.height - cropTop)
6283
+ };
6284
+ // Compute hot spot rect in terms of pixel coordinates
6285
+ var hotSpotVerticalRadius = (image.hotspot.height * asset.height) / 2;
6286
+ var hotSpotHorizontalRadius = (image.hotspot.width * asset.width) / 2;
6287
+ var hotSpotCenterX = image.hotspot.x * asset.width;
6288
+ var hotSpotCenterY = image.hotspot.y * asset.height;
6289
+ var hotspot = {
6290
+ left: hotSpotCenterX - hotSpotHorizontalRadius,
6291
+ top: hotSpotCenterY - hotSpotVerticalRadius,
6292
+ right: hotSpotCenterX + hotSpotHorizontalRadius,
6293
+ bottom: hotSpotCenterY + hotSpotVerticalRadius
6294
+ };
6295
+ // If irrelevant, or if we are requested to: don't perform crop/fit based on
6296
+ // the crop/hotspot.
6297
+ if (!(spec.rect || spec.focalPoint || spec.ignoreImageParams || spec.crop)) {
6298
+ spec = __assign({}, spec, fit({ crop: crop, hotspot: hotspot }, spec));
6299
+ }
6300
+ return specToImageUrl(__assign({}, spec, { asset: asset }));
6301
+ }
6302
+ exports.default = urlForImage;
6303
+ // eslint-disable-next-line complexity
6304
+ function specToImageUrl(spec) {
6305
+ var cdnUrl = spec.baseUrl || 'https://cdn.sanity.io';
6306
+ var filename = spec.asset.id + "-" + spec.asset.width + "x" + spec.asset.height + "." + spec.asset.format;
6307
+ var baseUrl = cdnUrl + "/images/" + spec.projectId + "/" + spec.dataset + "/" + filename;
6308
+ var params = [];
6309
+ if (spec.rect) {
6310
+ // Only bother url with a crop if it actually crops anything
6311
+ var _a = spec.rect, left = _a.left, top_1 = _a.top, width = _a.width, height = _a.height;
6312
+ var isEffectiveCrop = left !== 0 || top_1 !== 0 || height !== spec.asset.height || width !== spec.asset.width;
6313
+ if (isEffectiveCrop) {
6314
+ params.push("rect=" + left + "," + top_1 + "," + width + "," + height);
6315
+ }
6316
+ }
6317
+ if (spec.bg) {
6318
+ params.push("bg=" + spec.bg);
6319
+ }
6320
+ if (spec.focalPoint) {
6321
+ params.push("fp-x=" + spec.focalPoint.x);
6322
+ params.push("fp-x=" + spec.focalPoint.y);
6323
+ }
6324
+ var flip = [spec.flipHorizontal && 'h', spec.flipVertical && 'v'].filter(Boolean).join('');
6325
+ if (flip) {
6326
+ params.push("flip=" + flip);
6327
+ }
6328
+ // Map from spec name to url param name, and allow using the actual param name as an alternative
6329
+ exports.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach(function (mapping) {
6330
+ var specName = mapping[0], param = mapping[1];
6331
+ if (typeof spec[specName] !== 'undefined') {
6332
+ params.push(param + "=" + encodeURIComponent(spec[specName]));
6333
+ }
6334
+ else if (typeof spec[param] !== 'undefined') {
6335
+ params.push(param + "=" + encodeURIComponent(spec[param]));
6336
+ }
6337
+ });
6338
+ if (params.length === 0) {
6339
+ return baseUrl;
6340
+ }
6341
+ return baseUrl + "?" + params.join('&');
6342
+ }
6343
+ function fit(source, spec) {
6344
+ var cropRect;
6345
+ var imgWidth = spec.width;
6346
+ var imgHeight = spec.height;
6347
+ // If we are not constraining the aspect ratio, we'll just use the whole crop
6348
+ if (!(imgWidth && imgHeight)) {
6349
+ return { width: imgWidth, height: imgHeight, rect: source.crop };
6350
+ }
6351
+ var crop = source.crop;
6352
+ var hotspot = source.hotspot;
6353
+ // If we are here, that means aspect ratio is locked and fitting will be a bit harder
6354
+ var desiredAspectRatio = imgWidth / imgHeight;
6355
+ var cropAspectRatio = crop.width / crop.height;
6356
+ if (cropAspectRatio > desiredAspectRatio) {
6357
+ // The crop is wider than the desired aspect ratio. That means we are cutting from the sides
6358
+ var height = crop.height;
6359
+ var width = height * desiredAspectRatio;
6360
+ var top_2 = crop.top;
6361
+ // Center output horizontally over hotspot
6362
+ var hotspotXCenter = (hotspot.right - hotspot.left) / 2 + hotspot.left;
6363
+ var left = hotspotXCenter - width / 2;
6364
+ // Keep output within crop
6365
+ if (left < crop.left) {
6366
+ left = crop.left;
6367
+ }
6368
+ else if (left + width > crop.left + crop.width) {
6369
+ left = crop.left + crop.width - width;
6370
+ }
6371
+ cropRect = {
6372
+ left: Math.round(left),
6373
+ top: Math.round(top_2),
6374
+ width: Math.round(width),
6375
+ height: Math.round(height)
6376
+ };
6377
+ }
6378
+ else {
6379
+ // The crop is taller than the desired ratio, we are cutting from top and bottom
6380
+ var width = crop.width;
6381
+ var height = width / desiredAspectRatio;
6382
+ var left = crop.left;
6383
+ // Center output vertically over hotspot
6384
+ var hotspotYCenter = (hotspot.bottom - hotspot.top) / 2 + hotspot.top;
6385
+ var top_3 = hotspotYCenter - height / 2;
6386
+ // Keep output rect within crop
6387
+ if (top_3 < crop.top) {
6388
+ top_3 = crop.top;
6389
+ }
6390
+ else if (top_3 + height > crop.top + crop.height) {
6391
+ top_3 = crop.top + crop.height - height;
6392
+ }
6393
+ cropRect = {
6394
+ left: Math.max(0, Math.floor(left)),
6395
+ top: Math.max(0, Math.floor(top_3)),
6396
+ width: Math.round(width),
6397
+ height: Math.round(height)
6398
+ };
6399
+ }
6400
+ return {
6401
+ width: imgWidth,
6402
+ height: imgHeight,
6403
+ rect: cropRect
6404
+ };
6405
+ }
6406
+
6407
+ });
6408
+
6409
+ unwrapExports(urlForImage_1);
6410
+ var urlForImage_2 = urlForImage_1.parseSource;
6411
+ var urlForImage_3 = urlForImage_1.SPEC_NAME_TO_URL_NAME_MAPPINGS;
6412
+
6413
+ var builder = createCommonjsModule(function (module, exports) {
6414
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6415
+ __assign = Object.assign || function(t) {
6416
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6417
+ s = arguments[i];
6418
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6419
+ t[p] = s[p];
6420
+ }
6421
+ return t;
6422
+ };
6423
+ return __assign.apply(this, arguments);
6424
+ };
6425
+ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
6426
+ if (mod && mod.__esModule) return mod;
6427
+ var result = {};
6428
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6429
+ result["default"] = mod;
6430
+ return result;
6431
+ };
6432
+ Object.defineProperty(exports, "__esModule", { value: true });
6433
+ var urlForImage_1$$1 = __importStar(urlForImage_1);
6434
+ var validFits = ['clip', 'crop', 'fill', 'fillmax', 'max', 'scale', 'min'];
6435
+ var validCrops = ['top', 'bottom', 'left', 'right', 'center', 'focalpoint', 'entropy'];
6436
+ var validAutoModes = ['format'];
6437
+ function isSanityClient(client) {
6438
+ return client ? typeof client.clientConfig === 'object' : false;
6439
+ }
6440
+ function rewriteSpecName(key) {
6441
+ var specs = urlForImage_1$$1.SPEC_NAME_TO_URL_NAME_MAPPINGS;
6442
+ for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
6443
+ var entry = specs_1[_i];
6444
+ var specName = entry[0], param = entry[1];
6445
+ if (key === specName || key === param) {
6446
+ return specName;
6447
+ }
6448
+ }
6449
+ return key;
6450
+ }
6451
+ function urlBuilder(options) {
6452
+ // Did we get a SanityClient?
6453
+ var client = options;
6454
+ if (isSanityClient(client)) {
6455
+ // Inherit config from client
6456
+ var _a = client.clientConfig, apiHost = _a.apiHost, projectId = _a.projectId, dataset = _a.dataset;
6457
+ return new ImageUrlBuilder(null, {
6458
+ baseUrl: apiHost.replace(/^https:\/\/api\./, 'https://cdn.'),
6459
+ projectId: projectId,
6460
+ dataset: dataset
6461
+ });
6462
+ }
6463
+ // Or just accept the options as given
6464
+ return new ImageUrlBuilder(null, options);
6465
+ }
6466
+ exports.default = urlBuilder;
6467
+ var ImageUrlBuilder = /** @class */ (function () {
6468
+ function ImageUrlBuilder(parent, options) {
6469
+ this.options = parent
6470
+ ? __assign({}, (parent.options || {}), (options || {})) : __assign({}, (options || {})); // Copy options
6471
+ }
6472
+ ImageUrlBuilder.prototype.withOptions = function (options) {
6473
+ var baseUrl = options.baseUrl || '';
6474
+ var newOptions = { baseUrl: baseUrl };
6475
+ for (var key in options) {
6476
+ if (options.hasOwnProperty(key)) {
6477
+ var specKey = rewriteSpecName(key);
6478
+ newOptions[specKey] = options[key];
6479
+ }
6480
+ }
6481
+ return new ImageUrlBuilder(this, __assign({ baseUrl: baseUrl }, newOptions));
6482
+ };
6483
+ // The image to be represented. Accepts a Sanity 'image'-document, 'asset'-document or
6484
+ // _id of asset. To get the benefit of automatic hot-spot/crop integration with the content
6485
+ // studio, the 'image'-document must be provided.
6486
+ ImageUrlBuilder.prototype.image = function (source) {
6487
+ return this.withOptions({ source: source });
6488
+ };
6489
+ // Specify the dataset
6490
+ ImageUrlBuilder.prototype.dataset = function (dataset) {
6491
+ return this.withOptions({ dataset: dataset });
6492
+ };
6493
+ // Specify the projectId
6494
+ ImageUrlBuilder.prototype.projectId = function (projectId) {
6495
+ return this.withOptions({ projectId: projectId });
6496
+ };
6497
+ // Specify background color
6498
+ ImageUrlBuilder.prototype.bg = function (bg) {
6499
+ return this.withOptions({ bg: bg });
6500
+ };
6501
+ // Set DPR scaling factor
6502
+ ImageUrlBuilder.prototype.dpr = function (dpr) {
6503
+ return this.withOptions({ dpr: dpr });
6504
+ };
6505
+ // Specify the width of the image in pixels
6506
+ ImageUrlBuilder.prototype.width = function (width) {
6507
+ return this.withOptions({ width: width });
6508
+ };
6509
+ // Specify the height of the image in pixels
6510
+ ImageUrlBuilder.prototype.height = function (height) {
6511
+ return this.withOptions({ height: height });
6512
+ };
6513
+ // Specify focal point in fraction of image dimensions. Each component 0.0-1.0
6514
+ ImageUrlBuilder.prototype.focalPoint = function (x, y) {
6515
+ return this.withOptions({ focalPoint: { x: x, y: y } });
6516
+ };
6517
+ ImageUrlBuilder.prototype.maxWidth = function (maxWidth) {
6518
+ return this.withOptions({ maxWidth: maxWidth });
6519
+ };
6520
+ ImageUrlBuilder.prototype.minWidth = function (minWidth) {
6521
+ return this.withOptions({ minWidth: minWidth });
6522
+ };
6523
+ ImageUrlBuilder.prototype.maxHeight = function (maxHeight) {
6524
+ return this.withOptions({ maxHeight: maxHeight });
6525
+ };
6526
+ ImageUrlBuilder.prototype.minHeight = function (minHeight) {
6527
+ return this.withOptions({ minHeight: minHeight });
6528
+ };
6529
+ // Specify width and height in pixels
6530
+ ImageUrlBuilder.prototype.size = function (width, height) {
6531
+ return this.withOptions({ width: width, height: height });
6532
+ };
6533
+ // Specify blur between 0 and 100
6534
+ ImageUrlBuilder.prototype.blur = function (blur) {
6535
+ return this.withOptions({ blur: blur });
6536
+ };
6537
+ ImageUrlBuilder.prototype.sharpen = function (sharpen) {
6538
+ return this.withOptions({ sharpen: sharpen });
6539
+ };
6540
+ // Specify the desired rectangle of the image
6541
+ ImageUrlBuilder.prototype.rect = function (left, top, width, height) {
6542
+ return this.withOptions({ rect: { left: left, top: top, width: width, height: height } });
6543
+ };
6544
+ // Specify the image format of the image. 'jpg', 'pjpg', 'png', 'webp'
6545
+ ImageUrlBuilder.prototype.format = function (format) {
6546
+ return this.withOptions({ format: format });
6547
+ };
6548
+ ImageUrlBuilder.prototype.invert = function (invert) {
6549
+ return this.withOptions({ invert: invert });
6550
+ };
6551
+ // Rotation in degrees 0, 90, 180, 270
6552
+ ImageUrlBuilder.prototype.orientation = function (orientation) {
6553
+ return this.withOptions({ orientation: orientation });
6554
+ };
6555
+ // Compression quality 0-100
6556
+ ImageUrlBuilder.prototype.quality = function (quality) {
6557
+ return this.withOptions({ quality: quality });
6558
+ };
6559
+ // Make it a download link. Parameter is default filename.
6560
+ ImageUrlBuilder.prototype.forceDownload = function (download) {
6561
+ return this.withOptions({ download: download });
6562
+ };
6563
+ // Flip image horizontally
6564
+ ImageUrlBuilder.prototype.flipHorizontal = function () {
6565
+ return this.withOptions({ flipHorizontal: true });
6566
+ };
6567
+ // Flip image verically
6568
+ ImageUrlBuilder.prototype.flipVertical = function () {
6569
+ return this.withOptions({ flipVertical: true });
6570
+ };
6571
+ // Ignore crop/hotspot from image record, even when present
6572
+ ImageUrlBuilder.prototype.ignoreImageParams = function () {
6573
+ return this.withOptions({ ignoreImageParams: true });
6574
+ };
6575
+ ImageUrlBuilder.prototype.fit = function (value) {
6576
+ if (validFits.indexOf(value) === -1) {
6577
+ throw new Error("Invalid fit mode \"" + value + "\"");
6578
+ }
6579
+ return this.withOptions({ fit: value });
6580
+ };
6581
+ ImageUrlBuilder.prototype.crop = function (value) {
6582
+ if (validCrops.indexOf(value) === -1) {
6583
+ throw new Error("Invalid crop mode \"" + value + "\"");
6584
+ }
6585
+ return this.withOptions({ crop: value });
6586
+ };
6587
+ ImageUrlBuilder.prototype.auto = function (value) {
6588
+ if (validAutoModes.indexOf(value) === -1) {
6589
+ throw new Error("Invalid auto mode \"" + value + "\"");
6590
+ }
6591
+ return this.withOptions({ auto: value });
6592
+ };
6593
+ // Gets the url based on the submitted parameters
6594
+ ImageUrlBuilder.prototype.url = function () {
6595
+ return urlForImage_1$$1.default(this.options);
6596
+ };
6597
+ // Synonym for url()
6598
+ ImageUrlBuilder.prototype.toString = function () {
6599
+ return this.url();
6600
+ };
6601
+ return ImageUrlBuilder;
6602
+ }());
6603
+
6604
+ });
6605
+
6606
+ unwrapExports(builder);
6607
+
6608
+ var node$1 = createCommonjsModule(function (module) {
6609
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
6610
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6611
+ };
6612
+ var builder_1 = __importDefault(builder);
6613
+ module.exports = builder_1.default;
6614
+
6615
+ });
6616
+
6617
+ var imageUrlBuilder = unwrapExports(node$1);
6618
+
6619
+ var urlFor = function urlFor(source, client) {
6620
+ return imageUrlBuilder(client).image(source);
6621
+ };
6622
+
6623
+ var getSerializers = function getSerializers(client) {
5923
6624
  return {
5924
6625
  types: {
5925
6626
  youtube: function youtube(_ref) {
5926
6627
  var node = _ref.node;
5927
6628
  var url = node.url;
5928
6629
 
5929
- var id = getYoutubeId(url);
5930
- return React__default.createElement(YouTube, { videoId: id, className: 'youtube' });
6630
+ return React__default.createElement(YouTubePlayer$1, { url: url });
6631
+ },
6632
+ figure: function figure(_ref2) {
6633
+ var node = _ref2.node;
6634
+ var asset = node.asset,
6635
+ caption = node.caption;
6636
+
6637
+ var url = urlFor(asset, client).url();
6638
+ return React__default.createElement(FigureComponent, { caption: caption, url: url });
6639
+ },
6640
+ slideshow: function slideshow(_ref3) {
6641
+ var node = _ref3.node;
6642
+
6643
+ var slides = node.slides && node.slides.map(function (slide) {
6644
+ return Object.assign(slide, { url: urlFor(slide.asset, client).url() });
6645
+ });
6646
+ return React__default.createElement(Slideshow, { slides: slides });
5931
6647
  }
5932
6648
  }
5933
6649
  };
5934
6650
  };
5935
6651
 
5936
- export { DeckContent, DeckQueue, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
6652
+ export { DeckContent, DeckQueue, Column1, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
5937
6653
  //# sourceMappingURL=index.es.js.map