@mjhls/mjh-framework 1.0.15 → 1.0.16

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
@@ -1,10 +1,12 @@
1
- import React__default, { Component, createElement, createContext } from 'react';
1
+ import React__default, { Component, useState, createElement, createContext } from 'react';
2
2
  import Row from 'react-bootstrap/Row';
3
3
  import Col from 'react-bootstrap/Col';
4
4
  import Card from 'react-bootstrap/Card';
5
5
  import Link from 'next/link';
6
6
  import ListGroup from 'react-bootstrap/ListGroup';
7
7
  import Head from 'next/head';
8
+ import Accordion from 'react-bootstrap/Accordion';
9
+ import { useAccordionToggle } from 'react-bootstrap/AccordionToggle';
8
10
  import Container from 'react-bootstrap/Container';
9
11
  import Nav from 'react-bootstrap/Nav';
10
12
  import Navbar from 'react-bootstrap/Navbar';
@@ -14,6 +16,7 @@ import FormControl from 'react-bootstrap/FormControl';
14
16
  import Button from 'react-bootstrap/Button';
15
17
  import PropTypes from 'prop-types';
16
18
  import { Figure, Carousel } from 'react-bootstrap';
19
+ import imageUrlBuilder from '@sanity/image-url';
17
20
 
18
21
  /*! *****************************************************************************
19
22
  Copyright (c) Microsoft Corporation. All rights reserved.
@@ -481,6 +484,44 @@ var possibleConstructorReturn = function (self, call) {
481
484
  return call && (typeof call === "object" || typeof call === "function") ? call : self;
482
485
  };
483
486
 
487
+ var slicedToArray = function () {
488
+ function sliceIterator(arr, i) {
489
+ var _arr = [];
490
+ var _n = true;
491
+ var _d = false;
492
+ var _e = undefined;
493
+
494
+ try {
495
+ for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
496
+ _arr.push(_s.value);
497
+
498
+ if (i && _arr.length === i) break;
499
+ }
500
+ } catch (err) {
501
+ _d = true;
502
+ _e = err;
503
+ } finally {
504
+ try {
505
+ if (!_n && _i["return"]) _i["return"]();
506
+ } finally {
507
+ if (_d) throw _e;
508
+ }
509
+ }
510
+
511
+ return _arr;
512
+ }
513
+
514
+ return function (arr, i) {
515
+ if (Array.isArray(arr)) {
516
+ return arr;
517
+ } else if (Symbol.iterator in Object(arr)) {
518
+ return sliceIterator(arr, i);
519
+ } else {
520
+ throw new TypeError("Invalid attempt to destructure non-iterable instance");
521
+ }
522
+ };
523
+ }();
524
+
484
525
  var toConsumableArray = function (arr) {
485
526
  if (Array.isArray(arr)) {
486
527
  for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
@@ -1149,6 +1190,88 @@ function IconBase(props) {
1149
1190
  }) : elem(DefaultContext);
1150
1191
  }
1151
1192
 
1193
+ // THIS FILE IS AUTO GENERATED
1194
+ var IoMdArrowDropdown = function (props) {
1195
+ return GenIcon({"tag":"svg","attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M128 192l128 128 128-128z"}}]})(props);
1196
+ };
1197
+ IoMdArrowDropdown.displayName = "IoMdArrowDropdown";
1198
+
1199
+ var AccordionPanel = function AccordionPanel(props) {
1200
+ var accordionClassName = props.accordionClassName,
1201
+ data = props.data;
1202
+
1203
+ var _useState = useState('0'),
1204
+ _useState2 = slicedToArray(_useState, 2),
1205
+ activeAccordionKey = _useState2[0],
1206
+ setaAtiveAccordionKey = _useState2[1];
1207
+
1208
+ var handleAccordion = function handleAccordion(id) {
1209
+ setaAtiveAccordionKey(id);
1210
+ };
1211
+
1212
+ var CustomToggle = function CustomToggle(_ref) {
1213
+ var children = _ref.children,
1214
+ eventKey = _ref.eventKey;
1215
+
1216
+ var decoratedOnClick = useAccordionToggle(eventKey, function () {
1217
+ return handleAccordion(eventKey);
1218
+ });
1219
+ return React__default.createElement(
1220
+ 'div',
1221
+ { onMouseEnter: decoratedOnClick, className: 'accordion-head' },
1222
+ children
1223
+ );
1224
+ };
1225
+
1226
+ return React__default.createElement(
1227
+ React__default.Fragment,
1228
+ null,
1229
+ data && data.length && React__default.createElement(
1230
+ Accordion,
1231
+ { defaultActiveKey: '0', activeKey: activeAccordionKey, className: accordionClassName },
1232
+ data.map(function (item) {
1233
+ return React__default.createElement(
1234
+ React__default.Fragment,
1235
+ null,
1236
+ React__default.createElement(
1237
+ CustomToggle,
1238
+ { key: item.id, eventKey: item.id },
1239
+ React__default.createElement(
1240
+ Link,
1241
+ { href: item.url },
1242
+ React__default.createElement(
1243
+ React__default.Fragment,
1244
+ null,
1245
+ item.title,
1246
+ item.subItems && React__default.createElement(IoMdArrowDropdown, null)
1247
+ )
1248
+ )
1249
+ ),
1250
+ React__default.createElement(
1251
+ Accordion.Collapse,
1252
+ { eventKey: item.id },
1253
+ React__default.createElement(
1254
+ 'div',
1255
+ null,
1256
+ item.subItems && item.subItems.map(function (subItem) {
1257
+ return React__default.createElement(
1258
+ Link,
1259
+ { href: subItem.url },
1260
+ React__default.createElement(
1261
+ 'div',
1262
+ { key: subItem.id, className: 'accordion-sub-item' },
1263
+ subItem.title
1264
+ )
1265
+ );
1266
+ })
1267
+ )
1268
+ )
1269
+ );
1270
+ })
1271
+ )
1272
+ );
1273
+ };
1274
+
1152
1275
  // THIS FILE IS AUTO GENERATED
1153
1276
  var MdSearch = function (props) {
1154
1277
  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);
@@ -1301,7 +1424,9 @@ var NavMagazine = function NavMagazine(props) {
1301
1424
 
1302
1425
  var NavNative = function NavNative(props) {
1303
1426
  var logo = props.logo,
1304
- dataObject = props.dataObject;
1427
+ dataObject = props.dataObject,
1428
+ _props$variant = props.variant,
1429
+ variant = _props$variant === undefined ? 'dark' : _props$variant;
1305
1430
 
1306
1431
 
1307
1432
  return React__default.createElement(
@@ -1309,7 +1434,7 @@ var NavNative = function NavNative(props) {
1309
1434
  null,
1310
1435
  React__default.createElement(
1311
1436
  Navbar,
1312
- { variant: 'dark', expand: 'lg', bg: 'primary' },
1437
+ { variant: variant, expand: 'lg', bg: 'primary' },
1313
1438
  React__default.createElement(
1314
1439
  Container,
1315
1440
  null,
@@ -1325,29 +1450,38 @@ var NavNative = function NavNative(props) {
1325
1450
  React__default.createElement(
1326
1451
  Nav,
1327
1452
  { className: 'mr-auto' },
1328
- dataObject && dataObject.map(function (row) {
1329
- if (row.type === 'dropdown') {
1453
+ dataObject && dataObject.map(function (row, index) {
1454
+ if (row.subQuery.length > 1) {
1330
1455
  return React__default.createElement(
1331
1456
  NavDropdown,
1332
1457
  { title: row.name, id: 'basic-nav-dropdown' },
1333
- row.dropdown && row.dropdown.map(function (ddRow) {
1458
+ row.subQuery && row.subQuery.map(function (ddRow, subIndex) {
1334
1459
  if (ddRow.type === 'divider') {
1335
1460
  return React__default.createElement(NavDropdown.Divider, null);
1336
1461
  } else {
1337
1462
  return React__default.createElement(
1338
- NavDropdown.Item,
1463
+ Link,
1339
1464
  { href: ddRow.url },
1340
- ddRow.name
1465
+ React__default.createElement(
1466
+ 'a',
1467
+ { key: subIndex, className: 'dropdown-item' },
1468
+ ddRow.name
1469
+ )
1341
1470
  );
1342
1471
  }
1343
1472
  })
1344
1473
  );
1345
1474
  } else {
1346
1475
  // Link default
1476
+ // return <Nav.Link href={row.url} key={index}>{row.name}</Nav.Link>
1347
1477
  return React__default.createElement(
1348
- Nav.Link,
1478
+ Link,
1349
1479
  { href: row.url },
1350
- row.name
1480
+ React__default.createElement(
1481
+ 'a',
1482
+ { key: index, className: 'nav-link' },
1483
+ row.name
1484
+ )
1351
1485
  );
1352
1486
  }
1353
1487
  })
@@ -6079,543 +6213,6 @@ var YouTubePlayer$1 = function YouTubePlayer(_ref) {
6079
6213
  return React__default.createElement(YouTube, { videoId: id, opts: { width: '100%' } });
6080
6214
  };
6081
6215
 
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
6216
  var urlFor = function urlFor(source, client) {
6620
6217
  return imageUrlBuilder(client).image(source);
6621
6218
  };
@@ -6649,5 +6246,5 @@ var getSerializers = function getSerializers(client) {
6649
6246
  };
6650
6247
  };
6651
6248
 
6652
- export { DeckContent, DeckQueue, Column1, Column2, Column3, Header, LeftNav, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
6249
+ export { DeckContent, DeckQueue, Column1, Column2, Column3, Header, LeftNav, AccordionPanel, NavMagazine, NavNative, NavNormal, NavDvm, TemplateNormal, AD300x250, AD300x250x600, AD728x90, getSerializers };
6653
6250
  //# sourceMappingURL=index.es.js.map