@mjhls/mjh-framework 1.0.15 → 1.0.17

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
@@ -12,6 +12,8 @@ var Card = _interopDefault(require('react-bootstrap/Card'));
12
12
  var Link = _interopDefault(require('next/link'));
13
13
  var ListGroup = _interopDefault(require('react-bootstrap/ListGroup'));
14
14
  var Head = _interopDefault(require('next/head'));
15
+ var Accordion = _interopDefault(require('react-bootstrap/Accordion'));
16
+ var AccordionToggle = require('react-bootstrap/AccordionToggle');
15
17
  var Container = _interopDefault(require('react-bootstrap/Container'));
16
18
  var Nav = _interopDefault(require('react-bootstrap/Nav'));
17
19
  var Navbar = _interopDefault(require('react-bootstrap/Navbar'));
@@ -21,6 +23,7 @@ var FormControl = _interopDefault(require('react-bootstrap/FormControl'));
21
23
  var Button = _interopDefault(require('react-bootstrap/Button'));
22
24
  var PropTypes = _interopDefault(require('prop-types'));
23
25
  var reactBootstrap = require('react-bootstrap');
26
+ var imageUrlBuilder = _interopDefault(require('@sanity/image-url'));
24
27
 
25
28
  /*! *****************************************************************************
26
29
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -488,6 +491,44 @@ var possibleConstructorReturn = function (self, call) {
488
491
  return call && (typeof call === "object" || typeof call === "function") ? call : self;
489
492
  };
490
493
 
494
+ var slicedToArray = function () {
495
+ function sliceIterator(arr, i) {
496
+ var _arr = [];
497
+ var _n = true;
498
+ var _d = false;
499
+ var _e = undefined;
500
+
501
+ try {
502
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
503
+ _arr.push(_s.value);
504
+
505
+ if (i && _arr.length === i) break;
506
+ }
507
+ } catch (err) {
508
+ _d = true;
509
+ _e = err;
510
+ } finally {
511
+ try {
512
+ if (!_n && _i["return"]) _i["return"]();
513
+ } finally {
514
+ if (_d) throw _e;
515
+ }
516
+ }
517
+
518
+ return _arr;
519
+ }
520
+
521
+ return function (arr, i) {
522
+ if (Array.isArray(arr)) {
523
+ return arr;
524
+ } else if (Symbol.iterator in Object(arr)) {
525
+ return sliceIterator(arr, i);
526
+ } else {
527
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
528
+ }
529
+ };
530
+ }();
531
+
491
532
  var toConsumableArray = function (arr) {
492
533
  if (Array.isArray(arr)) {
493
534
  for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
@@ -982,7 +1023,7 @@ var LeftNav = function LeftNav(props) {
982
1023
  { as: 'li' },
983
1024
  React__default.createElement(
984
1025
  Link,
985
- { href: subRow.url },
1026
+ { href: subRow.url || '#' },
986
1027
  React__default.createElement(
987
1028
  'a',
988
1029
  null,
@@ -1000,7 +1041,7 @@ var LeftNav = function LeftNav(props) {
1000
1041
  { as: 'li' },
1001
1042
  React__default.createElement(
1002
1043
  Link,
1003
- { href: subRow.url },
1044
+ { href: subRow.url || '#' },
1004
1045
  React__default.createElement(
1005
1046
  'a',
1006
1047
  null,
@@ -1156,6 +1197,88 @@ function IconBase(props) {
1156
1197
  }) : elem(DefaultContext);
1157
1198
  }
1158
1199
 
1200
+ // THIS FILE IS AUTO GENERATED
1201
+ var IoMdArrowDropdown = function (props) {
1202
+ return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M128 192l128 128 128-128z"}}]})(props);
1203
+ };
1204
+ IoMdArrowDropdown.displayName = "IoMdArrowDropdown";
1205
+
1206
+ var AccordionPanel = function AccordionPanel(props) {
1207
+ var accordionClassName = props.accordionClassName,
1208
+ data = props.data;
1209
+
1210
+ var _useState = React.useState('0'),
1211
+ _useState2 = slicedToArray(_useState, 2),
1212
+ activeAccordionKey = _useState2[0],
1213
+ setaAtiveAccordionKey = _useState2[1];
1214
+
1215
+ var handleAccordion = function handleAccordion(id) {
1216
+ setaAtiveAccordionKey(id);
1217
+ };
1218
+
1219
+ var CustomToggle = function CustomToggle(_ref) {
1220
+ var children = _ref.children,
1221
+ eventKey = _ref.eventKey;
1222
+
1223
+ var decoratedOnClick = AccordionToggle.useAccordionToggle(eventKey, function () {
1224
+ return handleAccordion(eventKey);
1225
+ });
1226
+ return React__default.createElement(
1227
+ 'div',
1228
+ { onMouseEnter: decoratedOnClick, className: 'accordion-head' },
1229
+ children
1230
+ );
1231
+ };
1232
+
1233
+ return React__default.createElement(
1234
+ React__default.Fragment,
1235
+ null,
1236
+ data && data.length && React__default.createElement(
1237
+ Accordion,
1238
+ { defaultActiveKey: '0', activeKey: activeAccordionKey, className: accordionClassName },
1239
+ data.map(function (item) {
1240
+ return React__default.createElement(
1241
+ React__default.Fragment,
1242
+ null,
1243
+ React__default.createElement(
1244
+ CustomToggle,
1245
+ { key: item.id, eventKey: item.id },
1246
+ React__default.createElement(
1247
+ Link,
1248
+ { href: item.url },
1249
+ React__default.createElement(
1250
+ React__default.Fragment,
1251
+ null,
1252
+ item.title,
1253
+ item.subItems && React__default.createElement(IoMdArrowDropdown, null)
1254
+ )
1255
+ )
1256
+ ),
1257
+ React__default.createElement(
1258
+ Accordion.Collapse,
1259
+ { eventKey: item.id },
1260
+ React__default.createElement(
1261
+ 'div',
1262
+ null,
1263
+ item.subItems && item.subItems.map(function (subItem) {
1264
+ return React__default.createElement(
1265
+ Link,
1266
+ { href: subItem.url },
1267
+ React__default.createElement(
1268
+ 'div',
1269
+ { key: subItem.id, className: 'accordion-sub-item' },
1270
+ subItem.title
1271
+ )
1272
+ );
1273
+ })
1274
+ )
1275
+ )
1276
+ );
1277
+ })
1278
+ )
1279
+ );
1280
+ };
1281
+
1159
1282
  // THIS FILE IS AUTO GENERATED
1160
1283
  var MdSearch = function (props) {
1161
1284
  return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 24 24"},"child":[{"tag":"path","attr":{"d":"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}}]})(props);
@@ -1223,7 +1346,7 @@ var NavMagazine = function NavMagazine(props) {
1223
1346
  null,
1224
1347
  React__default.createElement(
1225
1348
  Nav.Link,
1226
- { href: '/search' },
1349
+ { href: '/subscribe' },
1227
1350
  React__default.createElement(MdEmail, null),
1228
1351
  ' Subscribe'
1229
1352
  )
@@ -1233,7 +1356,7 @@ var NavMagazine = function NavMagazine(props) {
1233
1356
  null,
1234
1357
  React__default.createElement(
1235
1358
  Nav.Link,
1236
- { href: '/search' },
1359
+ { href: '/login' },
1237
1360
  React__default.createElement(MdMouse, null),
1238
1361
  ' Login'
1239
1362
  )
@@ -1265,10 +1388,10 @@ var NavMagazine = function NavMagazine(props) {
1265
1388
  } else {
1266
1389
  return React__default.createElement(
1267
1390
  Link,
1268
- { href: ddRow.url },
1391
+ { key: subIndex, href: ddRow.url || '#' },
1269
1392
  React__default.createElement(
1270
1393
  'a',
1271
- { key: subIndex, className: 'dropdown-item' },
1394
+ { className: 'dropdown-item' },
1272
1395
  ddRow.name
1273
1396
  )
1274
1397
  );
@@ -1280,10 +1403,10 @@ var NavMagazine = function NavMagazine(props) {
1280
1403
  // return <Nav.Link href={row.url} key={index}>{row.name}</Nav.Link>
1281
1404
  return React__default.createElement(
1282
1405
  Link,
1283
- { href: row.url },
1406
+ { key: index, href: row.url },
1284
1407
  React__default.createElement(
1285
1408
  'a',
1286
- { key: index, className: 'nav-link' },
1409
+ { className: 'nav-link' },
1287
1410
  row.name
1288
1411
  )
1289
1412
  );
@@ -1308,7 +1431,9 @@ var NavMagazine = function NavMagazine(props) {
1308
1431
 
1309
1432
  var NavNative = function NavNative(props) {
1310
1433
  var logo = props.logo,
1311
- dataObject = props.dataObject;
1434
+ dataObject = props.dataObject,
1435
+ _props$variant = props.variant,
1436
+ variant = _props$variant === undefined ? 'dark' : _props$variant;
1312
1437
 
1313
1438
 
1314
1439
  return React__default.createElement(
@@ -1316,7 +1441,7 @@ var NavNative = function NavNative(props) {
1316
1441
  null,
1317
1442
  React__default.createElement(
1318
1443
  Navbar,
1319
- { variant: 'dark', expand: 'lg', bg: 'primary' },
1444
+ { variant: variant, expand: 'lg', bg: 'primary' },
1320
1445
  React__default.createElement(
1321
1446
  Container,
1322
1447
  null,
@@ -1332,29 +1457,38 @@ var NavNative = function NavNative(props) {
1332
1457
  React__default.createElement(
1333
1458
  Nav,
1334
1459
  { className: 'mr-auto' },
1335
- dataObject && dataObject.map(function (row) {
1336
- if (row.type === 'dropdown') {
1460
+ dataObject && dataObject.map(function (row, index) {
1461
+ if (row.subQuery.length > 1) {
1337
1462
  return React__default.createElement(
1338
1463
  NavDropdown,
1339
- { title: row.name, id: 'basic-nav-dropdown' },
1340
- row.dropdown && row.dropdown.map(function (ddRow) {
1464
+ { key: index, title: row.name, id: 'basic-nav-dropdown' },
1465
+ row.subQuery && row.subQuery.map(function (ddRow, subIndex) {
1341
1466
  if (ddRow.type === 'divider') {
1342
1467
  return React__default.createElement(NavDropdown.Divider, null);
1343
1468
  } else {
1344
1469
  return React__default.createElement(
1345
- NavDropdown.Item,
1346
- { href: ddRow.url },
1347
- ddRow.name
1470
+ Link,
1471
+ { key: subIndex, href: ddRow.url || '#' },
1472
+ React__default.createElement(
1473
+ 'a',
1474
+ { className: 'dropdown-item' },
1475
+ ddRow.name
1476
+ )
1348
1477
  );
1349
1478
  }
1350
1479
  })
1351
1480
  );
1352
1481
  } else {
1353
1482
  // Link default
1483
+ // return <Nav.Link href={row.url} key={index}>{row.name}</Nav.Link>
1354
1484
  return React__default.createElement(
1355
- Nav.Link,
1356
- { href: row.url },
1357
- row.name
1485
+ Link,
1486
+ { key: index, href: row.url || '#' },
1487
+ React__default.createElement(
1488
+ 'a',
1489
+ { className: 'nav-link' },
1490
+ row.name
1491
+ )
1358
1492
  );
1359
1493
  }
1360
1494
  })
@@ -6086,543 +6220,6 @@ var YouTubePlayer$1 = function YouTubePlayer(_ref) {
6086
6220
  return React__default.createElement(YouTube, { videoId: id, opts: { width: '100%' } });
6087
6221
  };
6088
6222
 
6089
- var parseAssetId_1 = createCommonjsModule(function (module, exports) {
6090
- Object.defineProperty(exports, "__esModule", { value: true });
6091
- var example = 'image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg';
6092
- function parseAssetId(ref) {
6093
- var _a = ref.split('-'), id = _a[1], dimensionString = _a[2], format = _a[3];
6094
- if (!id || !dimensionString || !format) {
6095
- throw new Error("Malformed asset _ref '" + ref + "'. Expected an id like \"" + example + "\".");
6096
- }
6097
- var _b = dimensionString.split('x'), imgWidthStr = _b[0], imgHeightStr = _b[1];
6098
- var width = +imgWidthStr;
6099
- var height = +imgHeightStr;
6100
- var isValidAssetId = isFinite(width) && isFinite(height);
6101
- if (!isValidAssetId) {
6102
- throw new Error("Malformed asset _ref '" + ref + "'. Expected an id like \"" + example + "\".");
6103
- }
6104
- return { id: id, width: width, height: height, format: format };
6105
- }
6106
- exports.default = parseAssetId;
6107
-
6108
- });
6109
-
6110
- unwrapExports(parseAssetId_1);
6111
-
6112
- var parseSource_1 = createCommonjsModule(function (module, exports) {
6113
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6114
- __assign = Object.assign || function(t) {
6115
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6116
- s = arguments[i];
6117
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6118
- t[p] = s[p];
6119
- }
6120
- return t;
6121
- };
6122
- return __assign.apply(this, arguments);
6123
- };
6124
- Object.defineProperty(exports, "__esModule", { value: true });
6125
- var isRef = function (src) {
6126
- var source = src;
6127
- return source ? typeof source._ref === 'string' : false;
6128
- };
6129
- var isAsset = function (src) {
6130
- var source = src;
6131
- return source ? typeof source._id === 'string' : false;
6132
- };
6133
- var isAssetStub = function (src) {
6134
- var source = src;
6135
- return source && source.asset ? typeof source.asset.url === 'string' : false;
6136
- };
6137
- // Convert an asset-id, asset or image to an image record suitable for processing
6138
- // eslint-disable-next-line complexity
6139
- function parseSource(source) {
6140
- if (!source) {
6141
- return null;
6142
- }
6143
- var image;
6144
- if (typeof source === 'string' && isUrl(source)) {
6145
- // Someone passed an existing image url?
6146
- image = {
6147
- asset: { _ref: urlToId(source) }
6148
- };
6149
- }
6150
- else if (typeof source === 'string') {
6151
- // Just an asset id
6152
- image = {
6153
- asset: { _ref: source }
6154
- };
6155
- }
6156
- else if (isRef(source)) {
6157
- // We just got passed an asset directly
6158
- image = {
6159
- asset: source
6160
- };
6161
- }
6162
- else if (isAsset(source)) {
6163
- // If we were passed an image asset document
6164
- image = {
6165
- asset: {
6166
- _ref: source._id || ''
6167
- }
6168
- };
6169
- }
6170
- else if (isAssetStub(source)) {
6171
- // If we were passed a partial asset (`url`, but no `_id`)
6172
- image = {
6173
- asset: {
6174
- _ref: urlToId(source.asset.url)
6175
- }
6176
- };
6177
- }
6178
- else if (typeof source.asset === 'object') {
6179
- // Probably an actual image with materialized asset
6180
- image = source;
6181
- }
6182
- else {
6183
- // We got something that does not look like an image, or it is an image
6184
- // that currently isn't sporting an asset.
6185
- return null;
6186
- }
6187
- var img = source;
6188
- if (img.crop) {
6189
- image.crop = img.crop;
6190
- }
6191
- if (img.hotspot) {
6192
- image.hotspot = img.hotspot;
6193
- }
6194
- return applyDefaults(image);
6195
- }
6196
- exports.default = parseSource;
6197
- function isUrl(url) {
6198
- return /^https?:\/\//.test("" + url);
6199
- }
6200
- function urlToId(url) {
6201
- var parts = url.split('/').slice(-1);
6202
- return ("image-" + parts[0]).replace(/\.([a-z]+)$/, '-$1');
6203
- }
6204
- // Mock crop and hotspot if image lacks it
6205
- function applyDefaults(image) {
6206
- if (image.crop && image.hotspot) {
6207
- return image;
6208
- }
6209
- // We need to pad in default values for crop or hotspot
6210
- var result = __assign({}, image);
6211
- if (!result.crop) {
6212
- result.crop = {
6213
- left: 0,
6214
- top: 0,
6215
- bottom: 0,
6216
- right: 0
6217
- };
6218
- }
6219
- if (!result.hotspot) {
6220
- result.hotspot = {
6221
- x: 0.5,
6222
- y: 0.5,
6223
- height: 1.0,
6224
- width: 1.0
6225
- };
6226
- }
6227
- return result;
6228
- }
6229
-
6230
- });
6231
-
6232
- unwrapExports(parseSource_1);
6233
-
6234
- var urlForImage_1 = createCommonjsModule(function (module, exports) {
6235
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6236
- __assign = Object.assign || function(t) {
6237
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6238
- s = arguments[i];
6239
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6240
- t[p] = s[p];
6241
- }
6242
- return t;
6243
- };
6244
- return __assign.apply(this, arguments);
6245
- };
6246
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
6247
- return (mod && mod.__esModule) ? mod : { "default": mod };
6248
- };
6249
- Object.defineProperty(exports, "__esModule", { value: true });
6250
- var parseAssetId_1$$1 = __importDefault(parseAssetId_1);
6251
- var parseSource_1$$1 = __importDefault(parseSource_1);
6252
- exports.parseSource = parseSource_1$$1.default;
6253
- exports.SPEC_NAME_TO_URL_NAME_MAPPINGS = [
6254
- ['width', 'w'],
6255
- ['height', 'h'],
6256
- ['format', 'fm'],
6257
- ['download', 'dl'],
6258
- ['blur', 'blur'],
6259
- ['sharpen', 'sharp'],
6260
- ['invert', 'invert'],
6261
- ['orientation', 'or'],
6262
- ['minHeight', 'min-h'],
6263
- ['maxHeight', 'max-h'],
6264
- ['minWidth', 'min-w'],
6265
- ['maxWidth', 'max-w'],
6266
- ['quality', 'q'],
6267
- ['fit', 'fit'],
6268
- ['crop', 'crop'],
6269
- ['auto', 'auto'],
6270
- ['dpr', 'dpr']
6271
- ];
6272
- function urlForImage(options) {
6273
- var spec = __assign({}, (options || {}));
6274
- var source = spec.source;
6275
- delete spec.source;
6276
- var image = parseSource_1$$1.default(source);
6277
- if (!image) {
6278
- return null;
6279
- }
6280
- var id = image.asset._ref || image.asset._id || '';
6281
- var asset = parseAssetId_1$$1.default(id);
6282
- // Compute crop rect in terms of pixel coordinates in the raw source image
6283
- var cropLeft = Math.round(image.crop.left * asset.width);
6284
- var cropTop = Math.round(image.crop.top * asset.height);
6285
- var crop = {
6286
- left: cropLeft,
6287
- top: cropTop,
6288
- width: Math.round(asset.width - image.crop.right * asset.width - cropLeft),
6289
- height: Math.round(asset.height - image.crop.bottom * asset.height - cropTop)
6290
- };
6291
- // Compute hot spot rect in terms of pixel coordinates
6292
- var hotSpotVerticalRadius = (image.hotspot.height * asset.height) / 2;
6293
- var hotSpotHorizontalRadius = (image.hotspot.width * asset.width) / 2;
6294
- var hotSpotCenterX = image.hotspot.x * asset.width;
6295
- var hotSpotCenterY = image.hotspot.y * asset.height;
6296
- var hotspot = {
6297
- left: hotSpotCenterX - hotSpotHorizontalRadius,
6298
- top: hotSpotCenterY - hotSpotVerticalRadius,
6299
- right: hotSpotCenterX + hotSpotHorizontalRadius,
6300
- bottom: hotSpotCenterY + hotSpotVerticalRadius
6301
- };
6302
- // If irrelevant, or if we are requested to: don't perform crop/fit based on
6303
- // the crop/hotspot.
6304
- if (!(spec.rect || spec.focalPoint || spec.ignoreImageParams || spec.crop)) {
6305
- spec = __assign({}, spec, fit({ crop: crop, hotspot: hotspot }, spec));
6306
- }
6307
- return specToImageUrl(__assign({}, spec, { asset: asset }));
6308
- }
6309
- exports.default = urlForImage;
6310
- // eslint-disable-next-line complexity
6311
- function specToImageUrl(spec) {
6312
- var cdnUrl = spec.baseUrl || 'https://cdn.sanity.io';
6313
- var filename = spec.asset.id + "-" + spec.asset.width + "x" + spec.asset.height + "." + spec.asset.format;
6314
- var baseUrl = cdnUrl + "/images/" + spec.projectId + "/" + spec.dataset + "/" + filename;
6315
- var params = [];
6316
- if (spec.rect) {
6317
- // Only bother url with a crop if it actually crops anything
6318
- var _a = spec.rect, left = _a.left, top_1 = _a.top, width = _a.width, height = _a.height;
6319
- var isEffectiveCrop = left !== 0 || top_1 !== 0 || height !== spec.asset.height || width !== spec.asset.width;
6320
- if (isEffectiveCrop) {
6321
- params.push("rect=" + left + "," + top_1 + "," + width + "," + height);
6322
- }
6323
- }
6324
- if (spec.bg) {
6325
- params.push("bg=" + spec.bg);
6326
- }
6327
- if (spec.focalPoint) {
6328
- params.push("fp-x=" + spec.focalPoint.x);
6329
- params.push("fp-x=" + spec.focalPoint.y);
6330
- }
6331
- var flip = [spec.flipHorizontal && 'h', spec.flipVertical && 'v'].filter(Boolean).join('');
6332
- if (flip) {
6333
- params.push("flip=" + flip);
6334
- }
6335
- // Map from spec name to url param name, and allow using the actual param name as an alternative
6336
- exports.SPEC_NAME_TO_URL_NAME_MAPPINGS.forEach(function (mapping) {
6337
- var specName = mapping[0], param = mapping[1];
6338
- if (typeof spec[specName] !== 'undefined') {
6339
- params.push(param + "=" + encodeURIComponent(spec[specName]));
6340
- }
6341
- else if (typeof spec[param] !== 'undefined') {
6342
- params.push(param + "=" + encodeURIComponent(spec[param]));
6343
- }
6344
- });
6345
- if (params.length === 0) {
6346
- return baseUrl;
6347
- }
6348
- return baseUrl + "?" + params.join('&');
6349
- }
6350
- function fit(source, spec) {
6351
- var cropRect;
6352
- var imgWidth = spec.width;
6353
- var imgHeight = spec.height;
6354
- // If we are not constraining the aspect ratio, we'll just use the whole crop
6355
- if (!(imgWidth && imgHeight)) {
6356
- return { width: imgWidth, height: imgHeight, rect: source.crop };
6357
- }
6358
- var crop = source.crop;
6359
- var hotspot = source.hotspot;
6360
- // If we are here, that means aspect ratio is locked and fitting will be a bit harder
6361
- var desiredAspectRatio = imgWidth / imgHeight;
6362
- var cropAspectRatio = crop.width / crop.height;
6363
- if (cropAspectRatio > desiredAspectRatio) {
6364
- // The crop is wider than the desired aspect ratio. That means we are cutting from the sides
6365
- var height = crop.height;
6366
- var width = height * desiredAspectRatio;
6367
- var top_2 = crop.top;
6368
- // Center output horizontally over hotspot
6369
- var hotspotXCenter = (hotspot.right - hotspot.left) / 2 + hotspot.left;
6370
- var left = hotspotXCenter - width / 2;
6371
- // Keep output within crop
6372
- if (left < crop.left) {
6373
- left = crop.left;
6374
- }
6375
- else if (left + width > crop.left + crop.width) {
6376
- left = crop.left + crop.width - width;
6377
- }
6378
- cropRect = {
6379
- left: Math.round(left),
6380
- top: Math.round(top_2),
6381
- width: Math.round(width),
6382
- height: Math.round(height)
6383
- };
6384
- }
6385
- else {
6386
- // The crop is taller than the desired ratio, we are cutting from top and bottom
6387
- var width = crop.width;
6388
- var height = width / desiredAspectRatio;
6389
- var left = crop.left;
6390
- // Center output vertically over hotspot
6391
- var hotspotYCenter = (hotspot.bottom - hotspot.top) / 2 + hotspot.top;
6392
- var top_3 = hotspotYCenter - height / 2;
6393
- // Keep output rect within crop
6394
- if (top_3 < crop.top) {
6395
- top_3 = crop.top;
6396
- }
6397
- else if (top_3 + height > crop.top + crop.height) {
6398
- top_3 = crop.top + crop.height - height;
6399
- }
6400
- cropRect = {
6401
- left: Math.max(0, Math.floor(left)),
6402
- top: Math.max(0, Math.floor(top_3)),
6403
- width: Math.round(width),
6404
- height: Math.round(height)
6405
- };
6406
- }
6407
- return {
6408
- width: imgWidth,
6409
- height: imgHeight,
6410
- rect: cropRect
6411
- };
6412
- }
6413
-
6414
- });
6415
-
6416
- unwrapExports(urlForImage_1);
6417
- var urlForImage_2 = urlForImage_1.parseSource;
6418
- var urlForImage_3 = urlForImage_1.SPEC_NAME_TO_URL_NAME_MAPPINGS;
6419
-
6420
- var builder = createCommonjsModule(function (module, exports) {
6421
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
6422
- __assign = Object.assign || function(t) {
6423
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6424
- s = arguments[i];
6425
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6426
- t[p] = s[p];
6427
- }
6428
- return t;
6429
- };
6430
- return __assign.apply(this, arguments);
6431
- };
6432
- var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
6433
- if (mod && mod.__esModule) return mod;
6434
- var result = {};
6435
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6436
- result["default"] = mod;
6437
- return result;
6438
- };
6439
- Object.defineProperty(exports, "__esModule", { value: true });
6440
- var urlForImage_1$$1 = __importStar(urlForImage_1);
6441
- var validFits = ['clip', 'crop', 'fill', 'fillmax', 'max', 'scale', 'min'];
6442
- var validCrops = ['top', 'bottom', 'left', 'right', 'center', 'focalpoint', 'entropy'];
6443
- var validAutoModes = ['format'];
6444
- function isSanityClient(client) {
6445
- return client ? typeof client.clientConfig === 'object' : false;
6446
- }
6447
- function rewriteSpecName(key) {
6448
- var specs = urlForImage_1$$1.SPEC_NAME_TO_URL_NAME_MAPPINGS;
6449
- for (var _i = 0, specs_1 = specs; _i < specs_1.length; _i++) {
6450
- var entry = specs_1[_i];
6451
- var specName = entry[0], param = entry[1];
6452
- if (key === specName || key === param) {
6453
- return specName;
6454
- }
6455
- }
6456
- return key;
6457
- }
6458
- function urlBuilder(options) {
6459
- // Did we get a SanityClient?
6460
- var client = options;
6461
- if (isSanityClient(client)) {
6462
- // Inherit config from client
6463
- var _a = client.clientConfig, apiHost = _a.apiHost, projectId = _a.projectId, dataset = _a.dataset;
6464
- return new ImageUrlBuilder(null, {
6465
- baseUrl: apiHost.replace(/^https:\/\/api\./, 'https://cdn.'),
6466
- projectId: projectId,
6467
- dataset: dataset
6468
- });
6469
- }
6470
- // Or just accept the options as given
6471
- return new ImageUrlBuilder(null, options);
6472
- }
6473
- exports.default = urlBuilder;
6474
- var ImageUrlBuilder = /** @class */ (function () {
6475
- function ImageUrlBuilder(parent, options) {
6476
- this.options = parent
6477
- ? __assign({}, (parent.options || {}), (options || {})) : __assign({}, (options || {})); // Copy options
6478
- }
6479
- ImageUrlBuilder.prototype.withOptions = function (options) {
6480
- var baseUrl = options.baseUrl || '';
6481
- var newOptions = { baseUrl: baseUrl };
6482
- for (var key in options) {
6483
- if (options.hasOwnProperty(key)) {
6484
- var specKey = rewriteSpecName(key);
6485
- newOptions[specKey] = options[key];
6486
- }
6487
- }
6488
- return new ImageUrlBuilder(this, __assign({ baseUrl: baseUrl }, newOptions));
6489
- };
6490
- // The image to be represented. Accepts a Sanity 'image'-document, 'asset'-document or
6491
- // _id of asset. To get the benefit of automatic hot-spot/crop integration with the content
6492
- // studio, the 'image'-document must be provided.
6493
- ImageUrlBuilder.prototype.image = function (source) {
6494
- return this.withOptions({ source: source });
6495
- };
6496
- // Specify the dataset
6497
- ImageUrlBuilder.prototype.dataset = function (dataset) {
6498
- return this.withOptions({ dataset: dataset });
6499
- };
6500
- // Specify the projectId
6501
- ImageUrlBuilder.prototype.projectId = function (projectId) {
6502
- return this.withOptions({ projectId: projectId });
6503
- };
6504
- // Specify background color
6505
- ImageUrlBuilder.prototype.bg = function (bg) {
6506
- return this.withOptions({ bg: bg });
6507
- };
6508
- // Set DPR scaling factor
6509
- ImageUrlBuilder.prototype.dpr = function (dpr) {
6510
- return this.withOptions({ dpr: dpr });
6511
- };
6512
- // Specify the width of the image in pixels
6513
- ImageUrlBuilder.prototype.width = function (width) {
6514
- return this.withOptions({ width: width });
6515
- };
6516
- // Specify the height of the image in pixels
6517
- ImageUrlBuilder.prototype.height = function (height) {
6518
- return this.withOptions({ height: height });
6519
- };
6520
- // Specify focal point in fraction of image dimensions. Each component 0.0-1.0
6521
- ImageUrlBuilder.prototype.focalPoint = function (x, y) {
6522
- return this.withOptions({ focalPoint: { x: x, y: y } });
6523
- };
6524
- ImageUrlBuilder.prototype.maxWidth = function (maxWidth) {
6525
- return this.withOptions({ maxWidth: maxWidth });
6526
- };
6527
- ImageUrlBuilder.prototype.minWidth = function (minWidth) {
6528
- return this.withOptions({ minWidth: minWidth });
6529
- };
6530
- ImageUrlBuilder.prototype.maxHeight = function (maxHeight) {
6531
- return this.withOptions({ maxHeight: maxHeight });
6532
- };
6533
- ImageUrlBuilder.prototype.minHeight = function (minHeight) {
6534
- return this.withOptions({ minHeight: minHeight });
6535
- };
6536
- // Specify width and height in pixels
6537
- ImageUrlBuilder.prototype.size = function (width, height) {
6538
- return this.withOptions({ width: width, height: height });
6539
- };
6540
- // Specify blur between 0 and 100
6541
- ImageUrlBuilder.prototype.blur = function (blur) {
6542
- return this.withOptions({ blur: blur });
6543
- };
6544
- ImageUrlBuilder.prototype.sharpen = function (sharpen) {
6545
- return this.withOptions({ sharpen: sharpen });
6546
- };
6547
- // Specify the desired rectangle of the image
6548
- ImageUrlBuilder.prototype.rect = function (left, top, width, height) {
6549
- return this.withOptions({ rect: { left: left, top: top, width: width, height: height } });
6550
- };
6551
- // Specify the image format of the image. 'jpg', 'pjpg', 'png', 'webp'
6552
- ImageUrlBuilder.prototype.format = function (format) {
6553
- return this.withOptions({ format: format });
6554
- };
6555
- ImageUrlBuilder.prototype.invert = function (invert) {
6556
- return this.withOptions({ invert: invert });
6557
- };
6558
- // Rotation in degrees 0, 90, 180, 270
6559
- ImageUrlBuilder.prototype.orientation = function (orientation) {
6560
- return this.withOptions({ orientation: orientation });
6561
- };
6562
- // Compression quality 0-100
6563
- ImageUrlBuilder.prototype.quality = function (quality) {
6564
- return this.withOptions({ quality: quality });
6565
- };
6566
- // Make it a download link. Parameter is default filename.
6567
- ImageUrlBuilder.prototype.forceDownload = function (download) {
6568
- return this.withOptions({ download: download });
6569
- };
6570
- // Flip image horizontally
6571
- ImageUrlBuilder.prototype.flipHorizontal = function () {
6572
- return this.withOptions({ flipHorizontal: true });
6573
- };
6574
- // Flip image verically
6575
- ImageUrlBuilder.prototype.flipVertical = function () {
6576
- return this.withOptions({ flipVertical: true });
6577
- };
6578
- // Ignore crop/hotspot from image record, even when present
6579
- ImageUrlBuilder.prototype.ignoreImageParams = function () {
6580
- return this.withOptions({ ignoreImageParams: true });
6581
- };
6582
- ImageUrlBuilder.prototype.fit = function (value) {
6583
- if (validFits.indexOf(value) === -1) {
6584
- throw new Error("Invalid fit mode \"" + value + "\"");
6585
- }
6586
- return this.withOptions({ fit: value });
6587
- };
6588
- ImageUrlBuilder.prototype.crop = function (value) {
6589
- if (validCrops.indexOf(value) === -1) {
6590
- throw new Error("Invalid crop mode \"" + value + "\"");
6591
- }
6592
- return this.withOptions({ crop: value });
6593
- };
6594
- ImageUrlBuilder.prototype.auto = function (value) {
6595
- if (validAutoModes.indexOf(value) === -1) {
6596
- throw new Error("Invalid auto mode \"" + value + "\"");
6597
- }
6598
- return this.withOptions({ auto: value });
6599
- };
6600
- // Gets the url based on the submitted parameters
6601
- ImageUrlBuilder.prototype.url = function () {
6602
- return urlForImage_1$$1.default(this.options);
6603
- };
6604
- // Synonym for url()
6605
- ImageUrlBuilder.prototype.toString = function () {
6606
- return this.url();
6607
- };
6608
- return ImageUrlBuilder;
6609
- }());
6610
-
6611
- });
6612
-
6613
- unwrapExports(builder);
6614
-
6615
- var node$1 = createCommonjsModule(function (module) {
6616
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
6617
- return (mod && mod.__esModule) ? mod : { "default": mod };
6618
- };
6619
- var builder_1 = __importDefault(builder);
6620
- module.exports = builder_1.default;
6621
-
6622
- });
6623
-
6624
- var imageUrlBuilder = unwrapExports(node$1);
6625
-
6626
6223
  var urlFor = function urlFor(source, client) {
6627
6224
  return imageUrlBuilder(client).image(source);
6628
6225
  };
@@ -6663,6 +6260,7 @@ exports.Column2 = Column2;
6663
6260
  exports.Column3 = Column3;
6664
6261
  exports.Header = Header;
6665
6262
  exports.LeftNav = LeftNav;
6263
+ exports.AccordionPanel = AccordionPanel;
6666
6264
  exports.NavMagazine = NavMagazine;
6667
6265
  exports.NavNative = NavNative;
6668
6266
  exports.NavNormal = NavNormal;