@mjhls/mjh-framework 1.0.204 → 1.0.206

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.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/AD-e2479b7c.js +31 -0
  3. package/dist/cjs/DeckContent.js +430 -0
  4. package/dist/cjs/DeckQueue.js +366 -0
  5. package/dist/cjs/Dfp-d94f7f73.js +97 -0
  6. package/dist/cjs/GridContent.js +613 -0
  7. package/dist/cjs/GroupDeck.js +156 -0
  8. package/dist/cjs/IssueContentDeck.js +81 -0
  9. package/dist/cjs/IssueDeck.js +144 -0
  10. package/dist/cjs/MasterDeck.js +340 -0
  11. package/dist/cjs/Normal-7dd8c339.js +2374 -0
  12. package/dist/cjs/PublicationDeck.js +81 -0
  13. package/dist/cjs/QueueDeckExpanded.js +559 -0
  14. package/dist/cjs/TaxonomyCard-7b5b4298.js +1045 -0
  15. package/dist/cjs/TaxonomyCard.js +18 -0
  16. package/dist/cjs/TemplateNormal.js +29 -0
  17. package/dist/cjs/ThumbnailCard.js +58 -0
  18. package/dist/cjs/Ustream-0d3dd953.js +122 -0
  19. package/dist/cjs/Ustream.js +10 -0
  20. package/dist/cjs/VideoSeriesListing.js +248 -0
  21. package/dist/cjs/YoutubeGroup-4cf7a4aa.js +228 -0
  22. package/dist/cjs/YoutubeGroup.js +13 -0
  23. package/dist/cjs/_babelHelpers-f321c258.js +119 -0
  24. package/dist/cjs/_commonjsHelpers-3fc1f64e.js +20 -0
  25. package/dist/cjs/debounce-286eb3fb.js +279 -0
  26. package/dist/cjs/entities-3e0b4a16.js +506 -0
  27. package/dist/cjs/get-06aac51b.js +992 -0
  28. package/dist/cjs/index-0d0efcfa.js +610 -0
  29. package/dist/cjs/index-a4c53ff4.js +551 -0
  30. package/dist/cjs/index.es-2289df51.js +5028 -0
  31. package/dist/cjs/index.esm-340d3792.js +113 -0
  32. package/dist/cjs/index.js +12044 -0
  33. package/dist/cjs/isSymbol-311eb805.js +209 -0
  34. package/dist/cjs/main-58839f4e.js +858 -0
  35. package/dist/cjs/visibility-sensor-5c5a7302.js +2251 -0
  36. package/dist/esm/AD-1b2a3dd3.js +26 -0
  37. package/dist/esm/DeckContent.js +424 -0
  38. package/dist/esm/DeckQueue.js +360 -0
  39. package/dist/esm/Dfp-ab7941d3.js +92 -0
  40. package/dist/esm/GridContent.js +607 -0
  41. package/dist/esm/GroupDeck.js +151 -0
  42. package/dist/esm/IssueContentDeck.js +76 -0
  43. package/dist/esm/IssueDeck.js +139 -0
  44. package/dist/esm/MasterDeck.js +334 -0
  45. package/dist/esm/Normal-403c5666.js +2354 -0
  46. package/dist/esm/PublicationDeck.js +76 -0
  47. package/dist/esm/QueueDeckExpanded.js +553 -0
  48. package/dist/esm/TaxonomyCard-f9c93953.js +1039 -0
  49. package/dist/esm/TaxonomyCard.js +12 -0
  50. package/dist/esm/TemplateNormal.js +23 -0
  51. package/dist/esm/ThumbnailCard.js +53 -0
  52. package/dist/esm/Ustream-6bb45fe7.js +116 -0
  53. package/dist/esm/Ustream.js +4 -0
  54. package/dist/esm/VideoSeriesListing.js +242 -0
  55. package/dist/esm/YoutubeGroup-dc617e8b.js +222 -0
  56. package/dist/esm/YoutubeGroup.js +7 -0
  57. package/dist/esm/_babelHelpers-67c05996.js +111 -0
  58. package/dist/esm/_commonjsHelpers-ae1b5db5.js +15 -0
  59. package/dist/esm/debounce-a0242b4a.js +277 -0
  60. package/dist/esm/entities-e85d3a4a.js +503 -0
  61. package/dist/esm/get-b684ff61.js +990 -0
  62. package/dist/esm/index-3c1ee9ab.js +605 -0
  63. package/dist/esm/index-ca4ff5cb.js +548 -0
  64. package/dist/esm/index.es-f369b3e8.js +5022 -0
  65. package/dist/esm/index.esm-536609db.js +103 -0
  66. package/dist/esm/index.js +11991 -0
  67. package/dist/esm/isSymbol-c2b7d05a.js +203 -0
  68. package/dist/esm/main-dea495b7.js +851 -0
  69. package/dist/esm/visibility-sensor-3cfe6713.js +2243 -0
  70. package/package.json +8 -7
  71. package/dist/index.es.js +0 -30261
  72. package/dist/index.es.js.map +0 -1
  73. package/dist/index.js +0 -30320
  74. package/dist/index.js.map +0 -1
@@ -0,0 +1,1045 @@
1
+ 'use strict';
2
+
3
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
+
5
+ var React = require('react');
6
+ var React__default = _interopDefault(React);
7
+ var PropTypes = _interopDefault(require('prop-types'));
8
+ var Container = _interopDefault(require('react-bootstrap/Container'));
9
+ var Row = _interopDefault(require('react-bootstrap/Row'));
10
+ var Col = _interopDefault(require('react-bootstrap/Col'));
11
+ var Card = _interopDefault(require('react-bootstrap/Card'));
12
+ var index = require('./index-a4c53ff4.js');
13
+ var index$1 = require('./index-0d0efcfa.js');
14
+ var _babelHelpers = require('./_babelHelpers-f321c258.js');
15
+
16
+ /*
17
+ object-assign
18
+ (c) Sindre Sorhus
19
+ @license MIT
20
+ */
21
+ /* eslint-disable no-unused-vars */
22
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
23
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
24
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
25
+
26
+ function toObject(val) {
27
+ if (val === null || val === undefined) {
28
+ throw new TypeError('Object.assign cannot be called with null or undefined');
29
+ }
30
+
31
+ return Object(val);
32
+ }
33
+
34
+ function shouldUseNative() {
35
+ try {
36
+ if (!Object.assign) {
37
+ return false;
38
+ }
39
+
40
+ // Detect buggy property enumeration order in older V8 versions.
41
+
42
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
43
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
44
+ test1[5] = 'de';
45
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
46
+ return false;
47
+ }
48
+
49
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
50
+ var test2 = {};
51
+ for (var i = 0; i < 10; i++) {
52
+ test2['_' + String.fromCharCode(i)] = i;
53
+ }
54
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
55
+ return test2[n];
56
+ });
57
+ if (order2.join('') !== '0123456789') {
58
+ return false;
59
+ }
60
+
61
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
62
+ var test3 = {};
63
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
64
+ test3[letter] = letter;
65
+ });
66
+ if (Object.keys(Object.assign({}, test3)).join('') !==
67
+ 'abcdefghijklmnopqrst') {
68
+ return false;
69
+ }
70
+
71
+ return true;
72
+ } catch (err) {
73
+ // We don't expect any of the above to throw, but better to be safe.
74
+ return false;
75
+ }
76
+ }
77
+
78
+ var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
79
+ var from;
80
+ var to = toObject(target);
81
+ var symbols;
82
+
83
+ for (var s = 1; s < arguments.length; s++) {
84
+ from = Object(arguments[s]);
85
+
86
+ for (var key in from) {
87
+ if (hasOwnProperty.call(from, key)) {
88
+ to[key] = from[key];
89
+ }
90
+ }
91
+
92
+ if (getOwnPropertySymbols) {
93
+ symbols = getOwnPropertySymbols(from);
94
+ for (var i = 0; i < symbols.length; i++) {
95
+ if (propIsEnumerable.call(from, symbols[i])) {
96
+ to[symbols[i]] = from[symbols[i]];
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ return to;
103
+ };
104
+
105
+ var baseUrl = 'https://docs.sanity.io/help/';
106
+
107
+ var generateHelpUrl = function generateHelpUrl(slug) {
108
+ return baseUrl + slug
109
+ };
110
+
111
+ var enc = encodeURIComponent;
112
+ var materializeError = "You must either:\n - Pass `projectId` and `dataset` to the block renderer\n - Materialize images to include the `url` field.\n\nFor more information, see ".concat(generateHelpUrl('block-content-image-materializing'));
113
+
114
+ var getQueryString = function getQueryString(options) {
115
+ var query = options.imageOptions;
116
+ var keys = Object.keys(query);
117
+
118
+ if (!keys.length) {
119
+ return '';
120
+ }
121
+
122
+ var params = keys.map(function (key) {
123
+ return "".concat(enc(key), "=").concat(enc(query[key]));
124
+ });
125
+ return "?".concat(params.join('&'));
126
+ };
127
+
128
+ var buildUrl = function buildUrl(props) {
129
+ var node = props.node,
130
+ options = props.options;
131
+ var projectId = options.projectId,
132
+ dataset = options.dataset;
133
+ var asset = node.asset;
134
+
135
+ if (!asset) {
136
+ throw new Error('Image does not have required `asset` property');
137
+ }
138
+
139
+ if (asset.url) {
140
+ return asset.url + getQueryString(options);
141
+ }
142
+
143
+ if (!projectId || !dataset) {
144
+ throw new Error(materializeError);
145
+ }
146
+
147
+ var ref = asset._ref;
148
+
149
+ if (!ref) {
150
+ throw new Error('Invalid image reference in block, no `_ref` found on `asset`');
151
+ }
152
+
153
+ return index.node(objectAssign({
154
+ projectId: projectId,
155
+ dataset: dataset
156
+ }, options.imageOptions || {})).image(node).toString();
157
+ };
158
+
159
+ var getImageUrl = buildUrl;
160
+
161
+ var serializers = function (h, serializerOpts) {
162
+ var serializeOptions = serializerOpts || {
163
+ useDashedStyles: false // Low-level block serializer
164
+
165
+ };
166
+
167
+ function BlockSerializer(props) {
168
+ var node = props.node,
169
+ serializers = props.serializers,
170
+ options = props.options,
171
+ isInline = props.isInline,
172
+ children = props.children;
173
+ var blockType = node._type;
174
+ var serializer = serializers.types[blockType];
175
+
176
+ if (!serializer) {
177
+ throw new Error("Unknown block type \"".concat(blockType, "\", please specify a serializer for it in the `serializers.types` prop"));
178
+ }
179
+
180
+ return h(serializer, {
181
+ node: node,
182
+ options: options,
183
+ isInline: isInline
184
+ }, children);
185
+ } // Low-level span serializer
186
+
187
+
188
+ function SpanSerializer(props) {
189
+ var _props$node = props.node,
190
+ mark = _props$node.mark,
191
+ children = _props$node.children;
192
+ var isPlain = typeof mark === 'string';
193
+ var markType = isPlain ? mark : mark._type;
194
+ var serializer = props.serializers.marks[markType];
195
+
196
+ if (!serializer) {
197
+ // @todo Revert back to throwing errors?
198
+ // eslint-disable-next-line no-console
199
+ console.warn("Unknown mark type \"".concat(markType, "\", please specify a serializer for it in the `serializers.marks` prop"));
200
+ return h(props.serializers.markFallback, null, children);
201
+ }
202
+
203
+ return h(serializer, props.node, children);
204
+ } // Low-level list serializer
205
+
206
+
207
+ function ListSerializer(props) {
208
+ var tag = props.type === 'bullet' ? 'ul' : 'ol';
209
+ return h(tag, null, props.children);
210
+ } // Low-level list item serializer
211
+
212
+
213
+ function ListItemSerializer(props) {
214
+ var children = !props.node.style || props.node.style === 'normal' ? // Don't wrap plain text in paragraphs inside of a list item
215
+ props.children : // But wrap any other style in whatever the block serializer says to use
216
+ h(props.serializers.types.block, props, props.children);
217
+ return h('li', null, children);
218
+ } // Renderer of an actual block of type `block`. Confusing, we know.
219
+
220
+
221
+ function BlockTypeSerializer(props) {
222
+ var style = props.node.style || 'normal';
223
+
224
+ if (/^h\d/.test(style)) {
225
+ return h(style, null, props.children);
226
+ }
227
+
228
+ return style === 'blockquote' ? h('blockquote', null, props.children) : h('p', null, props.children);
229
+ } // Serializers for things that can be directly attributed to a tag without any props
230
+ // We use partial application to do this, passing the tag name as the first argument
231
+
232
+
233
+ function RawMarkSerializer(tag, props) {
234
+ return h(tag, null, props.children);
235
+ }
236
+
237
+ function UnderlineSerializer(props) {
238
+ var style = serializeOptions.useDashedStyles ? {
239
+ 'text-decoration': 'underline'
240
+ } : {
241
+ textDecoration: 'underline'
242
+ };
243
+ return h('span', {
244
+ style: style
245
+ }, props.children);
246
+ }
247
+
248
+ function StrikeThroughSerializer(props) {
249
+ return h('del', null, props.children);
250
+ }
251
+
252
+ function LinkSerializer(props) {
253
+ return h('a', {
254
+ href: props.mark.href
255
+ }, props.children);
256
+ }
257
+
258
+ function ImageSerializer(props) {
259
+ if (!props.node.asset) {
260
+ return null;
261
+ }
262
+
263
+ var img = h('img', {
264
+ src: getImageUrl(props)
265
+ });
266
+ return props.isInline ? img : h('figure', null, img);
267
+ } // Serializer that recursively calls itself, producing a hyperscript tree of spans
268
+
269
+
270
+ function serializeSpan(span, serializers, index, options) {
271
+ if (span === '\n' && serializers.hardBreak) {
272
+ return h(serializers.hardBreak, {
273
+ key: "hb-".concat(index)
274
+ });
275
+ }
276
+
277
+ if (typeof span === 'string') {
278
+ return serializers.text ? h(serializers.text, {
279
+ key: "text-".concat(index)
280
+ }, span) : span;
281
+ }
282
+
283
+ var children;
284
+
285
+ if (span.children) {
286
+ children = {
287
+ children: span.children.map(function (child, i) {
288
+ return options.serializeNode(child, i, span.children, true);
289
+ })
290
+ };
291
+ }
292
+
293
+ var serializedNode = objectAssign({}, span, children);
294
+ return h(serializers.span, {
295
+ key: span._key || "span-".concat(index),
296
+ node: serializedNode,
297
+ serializers: serializers
298
+ });
299
+ }
300
+
301
+ var HardBreakSerializer = function HardBreakSerializer() {
302
+ return h('br');
303
+ };
304
+
305
+ var defaultMarkSerializers = {
306
+ strong: RawMarkSerializer.bind(null, 'strong'),
307
+ em: RawMarkSerializer.bind(null, 'em'),
308
+ code: RawMarkSerializer.bind(null, 'code'),
309
+ underline: UnderlineSerializer,
310
+ 'strike-through': StrikeThroughSerializer,
311
+ link: LinkSerializer
312
+ };
313
+ var defaultSerializers = {
314
+ // Common overrides
315
+ types: {
316
+ block: BlockTypeSerializer,
317
+ image: ImageSerializer
318
+ },
319
+ marks: defaultMarkSerializers,
320
+ // Less common overrides
321
+ list: ListSerializer,
322
+ listItem: ListItemSerializer,
323
+ block: BlockSerializer,
324
+ span: SpanSerializer,
325
+ hardBreak: HardBreakSerializer,
326
+ // Container element
327
+ container: 'div',
328
+ // When we can't resolve the mark properly, use this renderer as the container
329
+ markFallback: 'span',
330
+ // Allow overriding text renderer, but leave undefined to just use plain strings by default
331
+ text: undefined,
332
+ // Empty nodes (React uses null, hyperscript with empty strings)
333
+ empty: ''
334
+ };
335
+ return {
336
+ defaultSerializers: defaultSerializers,
337
+ serializeSpan: serializeSpan
338
+ };
339
+ };
340
+
341
+ var defaultMarks = ['strong', 'em', 'code', 'underline', 'strike-through'];
342
+
343
+ var buildMarksTree = function buildMarksTree(block) {
344
+ var children = block.children,
345
+ markDefs = block.markDefs;
346
+
347
+ if (!children || !children.length) {
348
+ return [];
349
+ }
350
+
351
+ var sortedMarks = children.map(sortMarksByOccurences);
352
+ var rootNode = {
353
+ _type: 'span',
354
+ children: []
355
+ };
356
+ var nodeStack = [rootNode];
357
+ children.forEach(function (span, i) {
358
+ var marksNeeded = sortedMarks[i];
359
+
360
+ if (!marksNeeded) {
361
+ var lastNode = nodeStack[nodeStack.length - 1];
362
+ lastNode.children.push(span);
363
+ return;
364
+ }
365
+
366
+ var pos = 1; // Start at position one. Root is always plain and should never be removed. (?)
367
+
368
+ if (nodeStack.length > 1) {
369
+ for (pos; pos < nodeStack.length; pos++) {
370
+ var mark = nodeStack[pos].markKey;
371
+ var index = marksNeeded.indexOf(mark); // eslint-disable-next-line max-depth
372
+
373
+ if (index === -1) {
374
+ break;
375
+ }
376
+
377
+ marksNeeded.splice(index, 1);
378
+ }
379
+ } // Keep from beginning to first miss
380
+
381
+
382
+ nodeStack = nodeStack.slice(0, pos); // Add needed nodes
383
+
384
+ var currentNode = findLastParentNode(nodeStack);
385
+ marksNeeded.forEach(function (mark) {
386
+ var node = {
387
+ _type: 'span',
388
+ _key: span._key,
389
+ children: [],
390
+ mark: markDefs.find(function (def) {
391
+ return def._key === mark;
392
+ }) || mark,
393
+ markKey: mark
394
+ };
395
+ currentNode.children.push(node);
396
+ nodeStack.push(node);
397
+ currentNode = node;
398
+ }); // Split at newlines to make individual line chunks, but keep newline
399
+ // characters as individual elements in the array. We use these characters
400
+ // in the span serializer to trigger hard-break rendering
401
+
402
+ if (isTextSpan(span)) {
403
+ var lines = span.text.split('\n');
404
+
405
+ for (var line = lines.length; line-- > 1;) {
406
+ lines.splice(line, 0, '\n');
407
+ }
408
+
409
+ currentNode.children = currentNode.children.concat(lines);
410
+ } else {
411
+ currentNode.children = currentNode.children.concat(span);
412
+ }
413
+ });
414
+ return rootNode.children;
415
+ }; // We want to sort all the marks of all the spans in the following order:
416
+ // 1. Marks that are shared amongst the most adjacent siblings
417
+ // 2. Non-default marks (links, custom metadata)
418
+ // 3. Built-in, plain marks (bold, emphasis, code etc)
419
+
420
+
421
+ function sortMarksByOccurences(span, i, spans) {
422
+ if (!span.marks || span.marks.length === 0) {
423
+ return span.marks || [];
424
+ }
425
+
426
+ var markOccurences = span.marks.reduce(function (occurences, mark) {
427
+ occurences[mark] = occurences[mark] ? occurences[mark] + 1 : 1;
428
+
429
+ for (var siblingIndex = i + 1; siblingIndex < spans.length; siblingIndex++) {
430
+ var sibling = spans[siblingIndex];
431
+
432
+ if (sibling.marks && Array.isArray(sibling.marks) && sibling.marks.indexOf(mark) !== -1) {
433
+ occurences[mark]++;
434
+ } else {
435
+ break;
436
+ }
437
+ }
438
+
439
+ return occurences;
440
+ }, {});
441
+ var sortByOccurence = sortMarks.bind(null, markOccurences); // Slicing because sort() mutates the input
442
+
443
+ return span.marks.slice().sort(sortByOccurence);
444
+ }
445
+
446
+ function sortMarks(occurences, markA, markB) {
447
+ var aOccurences = occurences[markA] || 0;
448
+ var bOccurences = occurences[markB] || 0;
449
+
450
+ if (aOccurences !== bOccurences) {
451
+ return bOccurences - aOccurences;
452
+ }
453
+
454
+ var aDefaultPos = defaultMarks.indexOf(markA);
455
+ var bDefaultPos = defaultMarks.indexOf(markB); // Sort default marks last
456
+
457
+ if (aDefaultPos !== bDefaultPos) {
458
+ return aDefaultPos - bDefaultPos;
459
+ } // Sort other marks simply by key
460
+
461
+
462
+ if (markA < markB) {
463
+ return -1;
464
+ } else if (markA > markB) {
465
+ return 1;
466
+ }
467
+
468
+ return 0;
469
+ }
470
+
471
+ function isTextSpan(node) {
472
+ return node._type === 'span' && typeof node.text === 'string' && (Array.isArray(node.marks) || typeof node.marks === 'undefined');
473
+ }
474
+
475
+ function findLastParentNode(nodes) {
476
+ for (var i = nodes.length - 1; i >= 0; i--) {
477
+ var node = nodes[i];
478
+
479
+ if (node._type === 'span' && node.children) {
480
+ return node;
481
+ }
482
+ }
483
+
484
+ return undefined;
485
+ }
486
+
487
+ var buildMarksTree_1 = buildMarksTree;
488
+
489
+ /* eslint-disable max-depth, complexity */
490
+
491
+
492
+ function nestLists(blocks) {
493
+ var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'html';
494
+ var tree = [];
495
+ var currentList;
496
+
497
+ for (var i = 0; i < blocks.length; i++) {
498
+ var block = blocks[i];
499
+
500
+ if (!isListBlock(block)) {
501
+ tree.push(block);
502
+ currentList = null;
503
+ continue;
504
+ } // Start of a new list?
505
+
506
+
507
+ if (!currentList) {
508
+ currentList = listFromBlock(block);
509
+ tree.push(currentList);
510
+ continue;
511
+ } // New list item within same list?
512
+
513
+
514
+ if (blockMatchesList(block, currentList)) {
515
+ currentList.children.push(block);
516
+ continue;
517
+ } // Different list props, are we going deeper?
518
+
519
+
520
+ if (block.level > currentList.level) {
521
+ var newList = listFromBlock(block);
522
+
523
+ if (mode === 'html') {
524
+ // Because HTML is kinda weird, nested lists needs to be nested within list items
525
+ // So while you would think that we could populate the parent list with a new sub-list,
526
+ // We actually have to target the last list element (child) of the parent.
527
+ // However, at this point we need to be very careful - simply pushing to the list of children
528
+ // will mutate the input, and we don't want to blindly clone the entire tree.
529
+ // Clone the last child while adding our new list as the last child of it
530
+ var lastListItem = lastChild(currentList);
531
+ var newLastChild = objectAssign({}, lastListItem, {
532
+ children: lastListItem.children.concat(newList)
533
+ }); // Swap the last child
534
+
535
+ currentList.children[currentList.children.length - 1] = newLastChild;
536
+ } else {
537
+ currentList.children.push(newList);
538
+ } // Set the newly created, deeper list as the current
539
+
540
+
541
+ currentList = newList;
542
+ continue;
543
+ } // Different list props, are we going back up the tree?
544
+
545
+
546
+ if (block.level < currentList.level) {
547
+ // Current list has ended, and we need to hook up with a parent of the same level and type
548
+ var match = findListMatching(tree[tree.length - 1], block);
549
+
550
+ if (match) {
551
+ currentList = match;
552
+ currentList.children.push(block);
553
+ continue;
554
+ } // Similar parent can't be found, assume new list
555
+
556
+
557
+ currentList = listFromBlock(block);
558
+ tree.push(currentList);
559
+ continue;
560
+ } // Different list props, different list style?
561
+
562
+
563
+ if (block.listItem !== currentList.listItem) {
564
+ var _match = findListMatching(tree[tree.length - 1], {
565
+ level: block.level
566
+ });
567
+
568
+ if (_match && _match.listItem === block.listItem) {
569
+ currentList = _match;
570
+ currentList.children.push(block);
571
+ continue;
572
+ } else {
573
+ currentList = listFromBlock(block);
574
+ tree.push(currentList);
575
+ continue;
576
+ }
577
+ } // eslint-disable-next-line no-console
578
+
579
+
580
+ console.warn('Unknown state encountered for block', block);
581
+ tree.push(block);
582
+ }
583
+
584
+ return tree;
585
+ }
586
+
587
+ function isListBlock(block) {
588
+ return Boolean(block.listItem);
589
+ }
590
+
591
+ function blockMatchesList(block, list) {
592
+ return block.level === list.level && block.listItem === list.listItem;
593
+ }
594
+
595
+ function listFromBlock(block) {
596
+ return {
597
+ _type: 'list',
598
+ _key: "".concat(block._key, "-parent"),
599
+ level: block.level,
600
+ listItem: block.listItem,
601
+ children: [block]
602
+ };
603
+ }
604
+
605
+ function lastChild(block) {
606
+ return block.children && block.children[block.children.length - 1];
607
+ }
608
+
609
+ function findListMatching(rootNode, matching) {
610
+ var filterOnType = typeof matching.listItem === 'string';
611
+
612
+ if (rootNode._type === 'list' && rootNode.level === matching.level && filterOnType && rootNode.listItem === matching.listItem) {
613
+ return rootNode;
614
+ }
615
+
616
+ var node = lastChild(rootNode);
617
+
618
+ if (!node) {
619
+ return false;
620
+ }
621
+
622
+ return findListMatching(node, matching);
623
+ }
624
+
625
+ var nestLists_1 = nestLists;
626
+
627
+ var generateKeys = function (blocks) {
628
+ return blocks.map(function (block) {
629
+ if (block._key) {
630
+ return block;
631
+ }
632
+
633
+ return objectAssign({
634
+ _key: getStaticKey(block)
635
+ }, block);
636
+ });
637
+ };
638
+
639
+ function getStaticKey(item) {
640
+ return checksum(JSON.stringify(item)).toString(36).replace(/[^A-Za-z0-9]/g, '');
641
+ }
642
+ /* eslint-disable no-bitwise */
643
+
644
+
645
+ function checksum(str) {
646
+ var hash = 0;
647
+ var strlen = str.length;
648
+
649
+ if (strlen === 0) {
650
+ return hash;
651
+ }
652
+
653
+ for (var i = 0; i < strlen; i++) {
654
+ hash = (hash << 5) - hash + str.charCodeAt(i);
655
+ hash &= hash; // Convert to 32bit integer
656
+ }
657
+
658
+ return hash;
659
+ }
660
+
661
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
662
+
663
+
664
+
665
+ var isDefined = function isDefined(val) {
666
+ return typeof val !== 'undefined';
667
+ }; // Recursively merge/replace default serializers with user-specified serializers
668
+
669
+
670
+ var mergeSerializers = function mergeSerializers(defaultSerializers, userSerializers) {
671
+ return Object.keys(defaultSerializers).reduce(function (acc, key) {
672
+ var type = _typeof(defaultSerializers[key]);
673
+
674
+ if (type === 'function') {
675
+ acc[key] = isDefined(userSerializers[key]) ? userSerializers[key] : defaultSerializers[key];
676
+ } else if (type === 'object') {
677
+ acc[key] = objectAssign({}, defaultSerializers[key], userSerializers[key]);
678
+ } else {
679
+ acc[key] = typeof userSerializers[key] === 'undefined' ? defaultSerializers[key] : userSerializers[key];
680
+ }
681
+
682
+ return acc;
683
+ }, {});
684
+ };
685
+
686
+ // Properties to extract from props and pass to serializers as options
687
+
688
+
689
+ var optionProps = ['projectId', 'dataset', 'imageOptions'];
690
+
691
+ var isDefined$1 = function isDefined(val) {
692
+ return typeof val !== 'undefined';
693
+ };
694
+
695
+ var defaults = {
696
+ imageOptions: {}
697
+ };
698
+
699
+ function blocksToNodes(h, properties, defaultSerializers, serializeSpan) {
700
+ var props = objectAssign({}, defaults, properties);
701
+ var rawBlocks = Array.isArray(props.blocks) ? props.blocks : [props.blocks];
702
+ var keyedBlocks = generateKeys(rawBlocks);
703
+ var blocks = nestLists_1(keyedBlocks, props.listNestMode);
704
+ var serializers = mergeSerializers(defaultSerializers, props.serializers || {});
705
+ var options = optionProps.reduce(function (opts, key) {
706
+ var value = props[key];
707
+
708
+ if (isDefined$1(value)) {
709
+ opts[key] = value;
710
+ }
711
+
712
+ return opts;
713
+ }, {});
714
+
715
+ function serializeNode(node, index, siblings, isInline) {
716
+ if (isList(node)) {
717
+ return serializeList(node);
718
+ }
719
+
720
+ if (isListItem(node)) {
721
+ return serializeListItem(node, findListItemIndex(node, siblings));
722
+ }
723
+
724
+ if (isSpan(node)) {
725
+ return serializeSpan(node, serializers, index, {
726
+ serializeNode: serializeNode
727
+ });
728
+ }
729
+
730
+ return serializeBlock(node, index, isInline);
731
+ }
732
+
733
+ function findListItemIndex(node, siblings) {
734
+ var index = 0;
735
+
736
+ for (var i = 0; i < siblings.length; i++) {
737
+ if (siblings[i] === node) {
738
+ return index;
739
+ }
740
+
741
+ if (!isListItem(siblings[i])) {
742
+ continue;
743
+ }
744
+
745
+ index++;
746
+ }
747
+
748
+ return index;
749
+ }
750
+
751
+ function serializeBlock(block, index, isInline) {
752
+ var tree = buildMarksTree_1(block);
753
+ var children = tree.map(function (node, i, siblings) {
754
+ return serializeNode(node, i, siblings, true);
755
+ });
756
+ var blockProps = {
757
+ key: block._key || "block-".concat(index),
758
+ node: block,
759
+ isInline: isInline,
760
+ serializers: serializers,
761
+ options: options
762
+ };
763
+ return h(serializers.block, blockProps, children);
764
+ }
765
+
766
+ function serializeListItem(block, index) {
767
+ var key = block._key;
768
+ var tree = buildMarksTree_1(block);
769
+ var children = tree.map(serializeNode);
770
+ return h(serializers.listItem, {
771
+ node: block,
772
+ serializers: serializers,
773
+ index: index,
774
+ key: key,
775
+ options: options
776
+ }, children);
777
+ }
778
+
779
+ function serializeList(list) {
780
+ var type = list.listItem;
781
+ var level = list.level;
782
+ var key = list._key;
783
+ var children = list.children.map(serializeNode);
784
+ return h(serializers.list, {
785
+ key: key,
786
+ level: level,
787
+ type: type,
788
+ options: options
789
+ }, children);
790
+ } // Default to false, so `undefined` will evaluate to the default here
791
+
792
+
793
+ var renderContainerOnSingleChild = Boolean(props.renderContainerOnSingleChild);
794
+ var nodes = blocks.map(serializeNode);
795
+
796
+ if (renderContainerOnSingleChild || nodes.length > 1) {
797
+ var containerProps = props.className ? {
798
+ className: props.className
799
+ } : {};
800
+ return h(serializers.container, containerProps, nodes);
801
+ }
802
+
803
+ if (nodes[0]) {
804
+ return nodes[0];
805
+ }
806
+
807
+ return typeof serializers.empty === 'function' ? h(serializers.empty) : serializers.empty;
808
+ }
809
+
810
+ function isList(block) {
811
+ return block._type === 'list' && block.listItem;
812
+ }
813
+
814
+ function isListItem(block) {
815
+ return block._type === 'block' && block.listItem;
816
+ }
817
+
818
+ function isSpan(block) {
819
+ return typeof block === 'string' || block.marks || block._type === 'span';
820
+ }
821
+
822
+ var blocksToNodes_1 = blocksToNodes;
823
+
824
+ var internals = {
825
+ blocksToNodes: function blocksToNodes(renderNode, props, defaultSerializers, serializeSpan) {
826
+ if (defaultSerializers) {
827
+ return blocksToNodes_1(renderNode, props, defaultSerializers, serializeSpan);
828
+ } // Backwards-compatibility
829
+
830
+
831
+ var serializers$1 = serializers(renderNode);
832
+ return blocksToNodes_1(renderNode, props, serializers$1.defaultSerializers, serializers$1.serializeSpan);
833
+ },
834
+ getSerializers: serializers,
835
+ getImageUrl: getImageUrl,
836
+ mergeSerializers: mergeSerializers
837
+ };
838
+
839
+ var internals$1 = internals;
840
+
841
+ var getSerializers = internals$1.getSerializers;
842
+
843
+ var renderNode = React__default.createElement;
844
+
845
+ var _getSerializers = getSerializers(renderNode),
846
+ defaultSerializers = _getSerializers.defaultSerializers,
847
+ serializeSpan = _getSerializers.serializeSpan;
848
+
849
+ var dom = {
850
+ serializeSpan: serializeSpan,
851
+ serializers: defaultSerializers,
852
+ renderProps: { nestMarks: true }
853
+ };
854
+
855
+ var serializers$1 = dom.serializers,
856
+ serializeSpan$1 = dom.serializeSpan,
857
+ renderProps = dom.renderProps;
858
+
859
+ var getImageUrl$1 = internals$1.getImageUrl,
860
+ blocksToNodes$1 = internals$1.blocksToNodes,
861
+ mergeSerializers$1 = internals$1.mergeSerializers;
862
+
863
+ var renderNode$1 = React__default.createElement;
864
+
865
+ var SanityBlockContent = function SanityBlockContent(props) {
866
+ var customSerializers = mergeSerializers$1(SanityBlockContent.defaultSerializers, props.serializers);
867
+
868
+ var blockProps = Object.assign({}, renderProps, props, {
869
+ serializers: customSerializers,
870
+ blocks: props.blocks || []
871
+ });
872
+
873
+ return blocksToNodes$1(renderNode$1, blockProps, serializers$1, serializeSpan$1);
874
+ };
875
+
876
+ // Expose default serializers to the user
877
+ SanityBlockContent.defaultSerializers = serializers$1;
878
+
879
+ // Expose logic for building image URLs from an image reference/node
880
+ SanityBlockContent.getImageUrl = getImageUrl$1;
881
+
882
+ SanityBlockContent.propTypes = {
883
+ className: PropTypes.string,
884
+ renderContainerOnSingleChild: PropTypes.bool,
885
+
886
+ // When rendering images, we need project id and dataset, unless images are materialized
887
+ projectId: PropTypes.string,
888
+ dataset: PropTypes.string,
889
+ imageOptions: PropTypes.object,
890
+
891
+ serializers: PropTypes.shape({
892
+ // Common overrides
893
+ types: PropTypes.object,
894
+ marks: PropTypes.object,
895
+
896
+ // Less common overrides
897
+ list: PropTypes.func,
898
+ listItem: PropTypes.func,
899
+
900
+ // Low-level serializers
901
+ block: PropTypes.func,
902
+ span: PropTypes.func
903
+ }),
904
+
905
+ blocks: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
906
+ _type: PropTypes.string.isRequired
907
+ })), PropTypes.shape({
908
+ _type: PropTypes.string.isRequired
909
+ })]).isRequired
910
+ };
911
+
912
+ SanityBlockContent.defaultProps = {
913
+ renderContainerOnSingleChild: false,
914
+ serializers: {},
915
+ imageOptions: {}
916
+ };
917
+
918
+ var BlockContent = SanityBlockContent;
919
+
920
+ // import Link from 'next/link'
921
+ // import { clean_html } from '../utilities/entities'
922
+
923
+ var TaxonomyCard = function TaxonomyCard(props) {
924
+ var columns = props.columns,
925
+ variant = props.variant,
926
+ _props$icon = props.icon,
927
+ icon = _props$icon === undefined ? false : _props$icon,
928
+ data = props.dataRecord,
929
+ defaultImage = props.defaultImage,
930
+ client = props.client,
931
+ imageHeight = props.imageHeight,
932
+ imageWidth = props.imageWidth,
933
+ getSerializers = props.getSerializers;
934
+
935
+
936
+ var builder = index.imageUrlBuilder(client);
937
+
938
+ var urlFor = function urlFor(source) {
939
+ return builder.image(source).auto('format');
940
+ };
941
+
942
+ var renderCardImage = function renderCardImage(row) {
943
+ var url = urlFor(row.thumbnail);
944
+ if (imageHeight) url = url.height(imageHeight);
945
+ if (imageWidth) url = url.width(imageWidth);
946
+ return url.url();
947
+ };
948
+
949
+ var mode = variant && variant === 'bottom' ? 'column-reverse' : 'column';
950
+
951
+ var itemCounter = 0;
952
+ var lgVar = 12;
953
+
954
+ return React__default.createElement(
955
+ 'div',
956
+ { className: 'contentDeck' },
957
+ React__default.createElement(
958
+ Container,
959
+ null,
960
+ React__default.createElement(
961
+ Row,
962
+ null,
963
+ data && data.map(function (row, index) {
964
+ if (columns === 'rotate' && itemCounter % 3 === 0) {
965
+ lgVar = 12;
966
+ } else if (columns && columns !== 'rotate') {
967
+ lgVar = Math.floor(12 / columns);
968
+ } else {
969
+ lgVar = 6;
970
+ }
971
+ var thumbnailURL = row.thumbnail && row.thumbnail.asset ? renderCardImage(row) : defaultImage;
972
+ return React__default.createElement(
973
+ Col,
974
+ { key: itemCounter, md: 12, lg: lgVar, counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
975
+ React__default.createElement(
976
+ Card,
977
+ { className: 'taxonomy-card', style: { flexDirection: mode, position: 'relative', overflow: 'hidden' } },
978
+ React__default.createElement(
979
+ Card.Body,
980
+ null,
981
+ React__default.createElement(
982
+ Row,
983
+ null,
984
+ thumbnailURL && React__default.createElement(
985
+ Col,
986
+ null,
987
+ React__default.createElement(
988
+ index$1.LazyLoad,
989
+ { height: imageHeight },
990
+ React__default.createElement(Card.Img, { variant: 'top', src: thumbnailURL })
991
+ )
992
+ ),
993
+ React__default.createElement(
994
+ Col,
995
+ null,
996
+ row.url ? React__default.createElement(
997
+ 'a',
998
+ { href: row.url },
999
+ React__default.createElement(
1000
+ Card.Title,
1001
+ null,
1002
+ row.name
1003
+ )
1004
+ ) : React__default.createElement(
1005
+ Card.Title,
1006
+ null,
1007
+ row.name
1008
+ ),
1009
+ React__default.createElement(
1010
+ Card.Text,
1011
+ null,
1012
+ React__default.createElement(BlockContent, _babelHelpers._extends({ blocks: row.summary, serializers: getSerializers }, client.config()))
1013
+ )
1014
+ )
1015
+ ),
1016
+ icon && React__default.createElement(
1017
+ 'span',
1018
+ {
1019
+ className: 'taxonomy-icon',
1020
+ style: {
1021
+ position: 'absolute',
1022
+ right: '20px',
1023
+ top: '50%',
1024
+ transform: 'translateY(-50%) translateX(50px)',
1025
+ transition: 'all .25s',
1026
+ pointerEvents: 'none'
1027
+ } },
1028
+ '\u2192'
1029
+ )
1030
+ )
1031
+ )
1032
+ );
1033
+ })
1034
+ )
1035
+ ),
1036
+ icon && React__default.createElement(
1037
+ 'style',
1038
+ { jsx: 'true' },
1039
+ '\n .taxonomy-card:hover .taxonomy-icon {\n transform: translateY(-50%) scale(1.5) translateX(0) !important;\n }\n '
1040
+ )
1041
+ );
1042
+ };
1043
+
1044
+ exports.BlockContent = BlockContent;
1045
+ exports.TaxonomyCard = TaxonomyCard;