@spothero/ui 14.3.1 → 14.3.2

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 (46) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/CHANGELOG.tmp +2 -2
  3. package/package.json +2 -2
  4. package/styles/v2/components/index.js +1 -1
  5. package/v1/{index-bundled-cjs/index.js → index-bundled.cjs.js} +1 -1
  6. package/v1/index-bundled.cjs.js.map +1 -0
  7. package/v1/{index-bundled-esm/index.js → index-bundled.esm.js} +1 -1
  8. package/v1/index-bundled.esm.js.map +1 -0
  9. package/v1/{index-unbundled-cjs/index.js → index-unbundled.cjs.js} +1 -1
  10. package/v1/index-unbundled.cjs.js.map +1 -0
  11. package/v1/{index-unbundled-esm/index.js → index-unbundled.esm.js} +1 -1
  12. package/v1/index-unbundled.esm.js.map +1 -0
  13. package/v1/index.js +2 -2
  14. package/v2/{index-bundled-cjs/index-b41e1da9.js → index-bundled.cjs.js} +4 -4
  15. package/v2/index-bundled.cjs.js.map +1 -0
  16. package/v2/{index-bundled-esm/index-22452751.js → index-bundled.esm.js} +4 -4
  17. package/v2/index-bundled.esm.js.map +1 -0
  18. package/v2/{index-unbundled-cjs/index-c8c6025d.js → index-unbundled.cjs.js} +3594 -952
  19. package/v2/index-unbundled.cjs.js.map +1 -0
  20. package/v2/{index-unbundled-esm/index-403d8033.js → index-unbundled.esm.js} +3579 -887
  21. package/v2/index-unbundled.esm.js.map +1 -0
  22. package/v2/index.js +2 -2
  23. package/v1/index-bundled-cjs/index.js.map +0 -1
  24. package/v1/index-bundled-esm/index.js.map +0 -1
  25. package/v1/index-unbundled-cjs/index.js.map +0 -1
  26. package/v1/index-unbundled-esm/index.js.map +0 -1
  27. package/v2/index-bundled-cjs/ImageCarousel-217e7062.js +0 -2
  28. package/v2/index-bundled-cjs/ImageCarousel-217e7062.js.map +0 -1
  29. package/v2/index-bundled-cjs/index-b41e1da9.js.map +0 -1
  30. package/v2/index-bundled-cjs/index.js +0 -2
  31. package/v2/index-bundled-cjs/index.js.map +0 -1
  32. package/v2/index-bundled-esm/ImageCarousel-4127414d.js +0 -2
  33. package/v2/index-bundled-esm/ImageCarousel-4127414d.js.map +0 -1
  34. package/v2/index-bundled-esm/index-22452751.js.map +0 -1
  35. package/v2/index-bundled-esm/index.js +0 -2
  36. package/v2/index-bundled-esm/index.js.map +0 -1
  37. package/v2/index-unbundled-cjs/ImageCarousel-0575526b.js +0 -2729
  38. package/v2/index-unbundled-cjs/ImageCarousel-0575526b.js.map +0 -1
  39. package/v2/index-unbundled-cjs/index-c8c6025d.js.map +0 -1
  40. package/v2/index-unbundled-cjs/index.js +0 -72
  41. package/v2/index-unbundled-cjs/index.js.map +0 -1
  42. package/v2/index-unbundled-esm/ImageCarousel-c8a3e563.js +0 -2722
  43. package/v2/index-unbundled-esm/ImageCarousel-c8a3e563.js.map +0 -1
  44. package/v2/index-unbundled-esm/index-403d8033.js.map +0 -1
  45. package/v2/index-unbundled-esm/index.js +0 -7
  46. package/v2/index-unbundled-esm/index.js.map +0 -1
@@ -1,2722 +0,0 @@
1
- import { _ as _export, i as isArray$5, p as path, d as defineWellKnownSymbol, s as setToStringTag, g as global_1, f as functionUncurryThis, t as toString_1, r as requireObjectCoercible, a as toIntegerOrInfinity, b as internalState, c as defineIterator, w as wellKnownSymbol, e as getMethod, h as iterators, j as classof, k as arrayMethodHasSpeciesSupport, l as toIndexedObject, m as lengthOfArrayLike, n as isConstructor, o as isObject, q as arraySlice, u as createProperty, v as toAbsoluteIndex, x as entryVirtual, y as objectIsPrototypeOf, z as anObject, A as functionCall, B as aCallable, C as tryToString, D as toObject, E as functionBindContext, F as wellKnownSymbolWrapped, G as redefine, H as descriptors, I as isCallable, J as fails, K as internalMetadata, L as createNonEnumerableProperty, M as objectDefineProperty, N as arrayIteration, O as hasOwnProperty_1, P as nativeWeakMap, Q as objectIsExtensible, R as createCommonjsModule, S as defineProperty$1, T as _extends$1, U as getOwnPropertyDescriptor, V as unwrapExports, W as _objectWithoutProperties, X as Box, Y as map$1, Z as concat, $ as _default$1 } from './index-403d8033.js';
2
- import React, { useState, useRef, useMemo, useEffect, useCallback } from 'react';
3
- import PropTypes from 'prop-types';
4
- import 'lodash/merge';
5
- import 'lodash/template';
6
- import 'react-dom';
7
-
8
- // `Array.isArray` method
9
- // https://tc39.es/ecma262/#sec-array.isarray
10
- _export({ target: 'Array', stat: true }, {
11
- isArray: isArray$5
12
- });
13
-
14
- var isArray$4 = path.Array.isArray;
15
-
16
- var isArray$3 = isArray$4;
17
-
18
- var isArray$2 = isArray$3;
19
-
20
- var isArray$1 = isArray$2;
21
-
22
- var isArray = isArray$1;
23
-
24
- function _arrayWithHoles(arr) {
25
- if (isArray(arr)) return arr;
26
- }
27
-
28
- // `Symbol.asyncIterator` well-known symbol
29
- // https://tc39.es/ecma262/#sec-symbol.asynciterator
30
- defineWellKnownSymbol('asyncIterator');
31
-
32
- // `Symbol.hasInstance` well-known symbol
33
- // https://tc39.es/ecma262/#sec-symbol.hasinstance
34
- defineWellKnownSymbol('hasInstance');
35
-
36
- // `Symbol.isConcatSpreadable` well-known symbol
37
- // https://tc39.es/ecma262/#sec-symbol.isconcatspreadable
38
- defineWellKnownSymbol('isConcatSpreadable');
39
-
40
- // `Symbol.iterator` well-known symbol
41
- // https://tc39.es/ecma262/#sec-symbol.iterator
42
- defineWellKnownSymbol('iterator');
43
-
44
- // `Symbol.match` well-known symbol
45
- // https://tc39.es/ecma262/#sec-symbol.match
46
- defineWellKnownSymbol('match');
47
-
48
- // `Symbol.matchAll` well-known symbol
49
- // https://tc39.es/ecma262/#sec-symbol.matchall
50
- defineWellKnownSymbol('matchAll');
51
-
52
- // `Symbol.replace` well-known symbol
53
- // https://tc39.es/ecma262/#sec-symbol.replace
54
- defineWellKnownSymbol('replace');
55
-
56
- // `Symbol.search` well-known symbol
57
- // https://tc39.es/ecma262/#sec-symbol.search
58
- defineWellKnownSymbol('search');
59
-
60
- // `Symbol.species` well-known symbol
61
- // https://tc39.es/ecma262/#sec-symbol.species
62
- defineWellKnownSymbol('species');
63
-
64
- // `Symbol.split` well-known symbol
65
- // https://tc39.es/ecma262/#sec-symbol.split
66
- defineWellKnownSymbol('split');
67
-
68
- // `Symbol.toPrimitive` well-known symbol
69
- // https://tc39.es/ecma262/#sec-symbol.toprimitive
70
- defineWellKnownSymbol('toPrimitive');
71
-
72
- // `Symbol.toStringTag` well-known symbol
73
- // https://tc39.es/ecma262/#sec-symbol.tostringtag
74
- defineWellKnownSymbol('toStringTag');
75
-
76
- // `Symbol.unscopables` well-known symbol
77
- // https://tc39.es/ecma262/#sec-symbol.unscopables
78
- defineWellKnownSymbol('unscopables');
79
-
80
- // JSON[@@toStringTag] property
81
- // https://tc39.es/ecma262/#sec-json-@@tostringtag
82
- setToStringTag(global_1.JSON, 'JSON', true);
83
-
84
- var symbol$4 = path.Symbol;
85
-
86
- var symbol$3 = symbol$4;
87
-
88
- var symbol$2 = symbol$3;
89
-
90
- // `Symbol.asyncDispose` well-known symbol
91
- // https://github.com/tc39/proposal-using-statement
92
- defineWellKnownSymbol('asyncDispose');
93
-
94
- // `Symbol.dispose` well-known symbol
95
- // https://github.com/tc39/proposal-using-statement
96
- defineWellKnownSymbol('dispose');
97
-
98
- // `Symbol.matcher` well-known symbol
99
- // https://github.com/tc39/proposal-pattern-matching
100
- defineWellKnownSymbol('matcher');
101
-
102
- // `Symbol.metadata` well-known symbol
103
- // https://github.com/tc39/proposal-decorators
104
- defineWellKnownSymbol('metadata');
105
-
106
- // `Symbol.observable` well-known symbol
107
- // https://github.com/tc39/proposal-observable
108
- defineWellKnownSymbol('observable');
109
-
110
- // TODO: remove from `core-js@4`
111
-
112
-
113
- // `Symbol.patternMatch` well-known symbol
114
- // https://github.com/tc39/proposal-pattern-matching
115
- defineWellKnownSymbol('patternMatch');
116
-
117
- // TODO: remove from `core-js@4`
118
-
119
-
120
- defineWellKnownSymbol('replaceAll');
121
-
122
- // TODO: Remove from `core-js@4`
123
-
124
- // TODO: Remove from `core-js@4`
125
-
126
-
127
- var symbol$1 = symbol$2;
128
-
129
- var symbol = symbol$1;
130
-
131
- var charAt$1 = functionUncurryThis(''.charAt);
132
- var charCodeAt = functionUncurryThis(''.charCodeAt);
133
- var stringSlice = functionUncurryThis(''.slice);
134
-
135
- var createMethod = function (CONVERT_TO_STRING) {
136
- return function ($this, pos) {
137
- var S = toString_1(requireObjectCoercible($this));
138
- var position = toIntegerOrInfinity(pos);
139
- var size = S.length;
140
- var first, second;
141
- if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
142
- first = charCodeAt(S, position);
143
- return first < 0xD800 || first > 0xDBFF || position + 1 === size
144
- || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
145
- ? CONVERT_TO_STRING
146
- ? charAt$1(S, position)
147
- : first
148
- : CONVERT_TO_STRING
149
- ? stringSlice(S, position, position + 2)
150
- : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
151
- };
152
- };
153
-
154
- var stringMultibyte = {
155
- // `String.prototype.codePointAt` method
156
- // https://tc39.es/ecma262/#sec-string.prototype.codepointat
157
- codeAt: createMethod(false),
158
- // `String.prototype.at` method
159
- // https://github.com/mathiasbynens/String.prototype.at
160
- charAt: createMethod(true)
161
- };
162
-
163
- var charAt = stringMultibyte.charAt;
164
-
165
-
166
-
167
-
168
- var STRING_ITERATOR = 'String Iterator';
169
- var setInternalState$2 = internalState.set;
170
- var getInternalState = internalState.getterFor(STRING_ITERATOR);
171
-
172
- // `String.prototype[@@iterator]` method
173
- // https://tc39.es/ecma262/#sec-string.prototype-@@iterator
174
- defineIterator(String, 'String', function (iterated) {
175
- setInternalState$2(this, {
176
- type: STRING_ITERATOR,
177
- string: toString_1(iterated),
178
- index: 0
179
- });
180
- // `%StringIteratorPrototype%.next` method
181
- // https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
182
- }, function next() {
183
- var state = getInternalState(this);
184
- var string = state.string;
185
- var index = state.index;
186
- var point;
187
- if (index >= string.length) return { value: undefined, done: true };
188
- point = charAt(string, index);
189
- state.index += point.length;
190
- return { value: point, done: false };
191
- });
192
-
193
- var ITERATOR$2 = wellKnownSymbol('iterator');
194
-
195
- var getIteratorMethod$4 = function (it) {
196
- if (it != undefined) return getMethod(it, ITERATOR$2)
197
- || getMethod(it, '@@iterator')
198
- || iterators[classof(it)];
199
- };
200
-
201
- var getIteratorMethod_1 = getIteratorMethod$4;
202
-
203
- var getIteratorMethod$3 = getIteratorMethod_1;
204
-
205
- var getIteratorMethod$2 = getIteratorMethod$3;
206
-
207
- var getIteratorMethod$1 = getIteratorMethod$2;
208
-
209
- var getIteratorMethod = getIteratorMethod$1;
210
-
211
- function _iterableToArrayLimit(arr, i) {
212
- var _i = arr == null ? null : typeof symbol !== "undefined" && getIteratorMethod(arr) || arr["@@iterator"];
213
-
214
- if (_i == null) return;
215
- var _arr = [];
216
- var _n = true;
217
- var _d = false;
218
-
219
- var _s, _e;
220
-
221
- try {
222
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
223
- _arr.push(_s.value);
224
-
225
- if (i && _arr.length === i) break;
226
- }
227
- } catch (err) {
228
- _d = true;
229
- _e = err;
230
- } finally {
231
- try {
232
- if (!_n && _i["return"] != null) _i["return"]();
233
- } finally {
234
- if (_d) throw _e;
235
- }
236
- }
237
-
238
- return _arr;
239
- }
240
-
241
- var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');
242
-
243
- var SPECIES = wellKnownSymbol('species');
244
- var Array$2 = global_1.Array;
245
- var max = Math.max;
246
-
247
- // `Array.prototype.slice` method
248
- // https://tc39.es/ecma262/#sec-array.prototype.slice
249
- // fallback for not array-like ES3 strings and DOM objects
250
- _export({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
251
- slice: function slice(start, end) {
252
- var O = toIndexedObject(this);
253
- var length = lengthOfArrayLike(O);
254
- var k = toAbsoluteIndex(start, length);
255
- var fin = toAbsoluteIndex(end === undefined ? length : end, length);
256
- // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
257
- var Constructor, result, n;
258
- if (isArray$5(O)) {
259
- Constructor = O.constructor;
260
- // cross-realm fallback
261
- if (isConstructor(Constructor) && (Constructor === Array$2 || isArray$5(Constructor.prototype))) {
262
- Constructor = undefined;
263
- } else if (isObject(Constructor)) {
264
- Constructor = Constructor[SPECIES];
265
- if (Constructor === null) Constructor = undefined;
266
- }
267
- if (Constructor === Array$2 || Constructor === undefined) {
268
- return arraySlice(O, k, fin);
269
- }
270
- }
271
- result = new (Constructor === undefined ? Array$2 : Constructor)(max(fin - k, 0));
272
- for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
273
- result.length = n;
274
- return result;
275
- }
276
- });
277
-
278
- var slice$5 = entryVirtual('Array').slice;
279
-
280
- var ArrayPrototype$1 = Array.prototype;
281
-
282
- var slice$4 = function (it) {
283
- var own = it.slice;
284
- return it === ArrayPrototype$1 || (objectIsPrototypeOf(ArrayPrototype$1, it) && own === ArrayPrototype$1.slice) ? slice$5 : own;
285
- };
286
-
287
- var slice$3 = slice$4;
288
-
289
- var slice$2 = slice$3;
290
-
291
- var slice$1 = slice$2;
292
-
293
- var slice = slice$1;
294
-
295
- var iteratorClose = function (iterator, kind, value) {
296
- var innerResult, innerError;
297
- anObject(iterator);
298
- try {
299
- innerResult = getMethod(iterator, 'return');
300
- if (!innerResult) {
301
- if (kind === 'throw') throw value;
302
- return value;
303
- }
304
- innerResult = functionCall(innerResult, iterator);
305
- } catch (error) {
306
- innerError = true;
307
- innerResult = error;
308
- }
309
- if (kind === 'throw') throw value;
310
- if (innerError) throw innerResult;
311
- anObject(innerResult);
312
- return value;
313
- };
314
-
315
- // call something on iterator step with safe closing on error
316
- var callWithSafeIterationClosing = function (iterator, fn, value, ENTRIES) {
317
- try {
318
- return ENTRIES ? fn(anObject(value)[0], value[1]) : fn(value);
319
- } catch (error) {
320
- iteratorClose(iterator, 'throw', error);
321
- }
322
- };
323
-
324
- var ITERATOR$1 = wellKnownSymbol('iterator');
325
- var ArrayPrototype = Array.prototype;
326
-
327
- // check on default Array iterator
328
- var isArrayIteratorMethod = function (it) {
329
- return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$1] === it);
330
- };
331
-
332
- var TypeError$3 = global_1.TypeError;
333
-
334
- var getIterator = function (argument, usingIterator) {
335
- var iteratorMethod = arguments.length < 2 ? getIteratorMethod$4(argument) : usingIterator;
336
- if (aCallable(iteratorMethod)) return anObject(functionCall(iteratorMethod, argument));
337
- throw TypeError$3(tryToString(argument) + ' is not iterable');
338
- };
339
-
340
- var Array$1 = global_1.Array;
341
-
342
- // `Array.from` method implementation
343
- // https://tc39.es/ecma262/#sec-array.from
344
- var arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
345
- var O = toObject(arrayLike);
346
- var IS_CONSTRUCTOR = isConstructor(this);
347
- var argumentsLength = arguments.length;
348
- var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
349
- var mapping = mapfn !== undefined;
350
- if (mapping) mapfn = functionBindContext(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
351
- var iteratorMethod = getIteratorMethod$4(O);
352
- var index = 0;
353
- var length, result, step, iterator, next, value;
354
- // if the target is not iterable or it's an array with the default iterator - use a simple case
355
- if (iteratorMethod && !(this == Array$1 && isArrayIteratorMethod(iteratorMethod))) {
356
- iterator = getIterator(O, iteratorMethod);
357
- next = iterator.next;
358
- result = IS_CONSTRUCTOR ? new this() : [];
359
- for (;!(step = functionCall(next, iterator)).done; index++) {
360
- value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
361
- createProperty(result, index, value);
362
- }
363
- } else {
364
- length = lengthOfArrayLike(O);
365
- result = IS_CONSTRUCTOR ? new this(length) : Array$1(length);
366
- for (;length > index; index++) {
367
- value = mapping ? mapfn(O[index], index) : O[index];
368
- createProperty(result, index, value);
369
- }
370
- }
371
- result.length = index;
372
- return result;
373
- };
374
-
375
- var ITERATOR = wellKnownSymbol('iterator');
376
- var SAFE_CLOSING = false;
377
-
378
- try {
379
- var called = 0;
380
- var iteratorWithReturn = {
381
- next: function () {
382
- return { done: !!called++ };
383
- },
384
- 'return': function () {
385
- SAFE_CLOSING = true;
386
- }
387
- };
388
- iteratorWithReturn[ITERATOR] = function () {
389
- return this;
390
- };
391
- // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
392
- Array.from(iteratorWithReturn, function () { throw 2; });
393
- } catch (error) { /* empty */ }
394
-
395
- var checkCorrectnessOfIteration = function (exec, SKIP_CLOSING) {
396
- if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
397
- var ITERATION_SUPPORT = false;
398
- try {
399
- var object = {};
400
- object[ITERATOR] = function () {
401
- return {
402
- next: function () {
403
- return { done: ITERATION_SUPPORT = true };
404
- }
405
- };
406
- };
407
- exec(object);
408
- } catch (error) { /* empty */ }
409
- return ITERATION_SUPPORT;
410
- };
411
-
412
- var INCORRECT_ITERATION = !checkCorrectnessOfIteration(function (iterable) {
413
- // eslint-disable-next-line es/no-array-from -- required for testing
414
- Array.from(iterable);
415
- });
416
-
417
- // `Array.from` method
418
- // https://tc39.es/ecma262/#sec-array.from
419
- _export({ target: 'Array', stat: true, forced: INCORRECT_ITERATION }, {
420
- from: arrayFrom
421
- });
422
-
423
- var from_1$4 = path.Array.from;
424
-
425
- var from_1$3 = from_1$4;
426
-
427
- var from_1$2 = from_1$3;
428
-
429
- var from_1$1 = from_1$2;
430
-
431
- var from_1 = from_1$1;
432
-
433
- function _arrayLikeToArray(arr, len) {
434
- if (len == null || len > arr.length) len = arr.length;
435
-
436
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
437
- arr2[i] = arr[i];
438
- }
439
-
440
- return arr2;
441
- }
442
-
443
- function _unsupportedIterableToArray(o, minLen) {
444
- var _context;
445
-
446
- if (!o) return;
447
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
448
-
449
- var n = slice(_context = Object.prototype.toString.call(o)).call(_context, 8, -1);
450
-
451
- if (n === "Object" && o.constructor) n = o.constructor.name;
452
- if (n === "Map" || n === "Set") return from_1(o);
453
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
454
- }
455
-
456
- function _nonIterableRest() {
457
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
458
- }
459
-
460
- function _slicedToArray(arr, i) {
461
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
462
- }
463
-
464
- function canUseDOM() {
465
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
466
- }
467
- function areEqualShallow(objectA, objectB) {
468
- return Object.keys(objectA).length === Object.keys(objectB).length && Object.keys(objectA).every(function (objectKey) {
469
- if (!Object.prototype.hasOwnProperty.call(objectB, objectKey)) {
470
- return false;
471
- }
472
-
473
- return objectA[objectKey] === objectB[objectKey];
474
- });
475
- }
476
-
477
- function _extends() {
478
- _extends = Object.assign || function (target) {
479
- for (var i = 1; i < arguments.length; i++) {
480
- var source = arguments[i];
481
-
482
- for (var key in source) {
483
- if (Object.prototype.hasOwnProperty.call(source, key)) {
484
- target[key] = source[key];
485
- }
486
- }
487
- }
488
-
489
- return target;
490
- };
491
-
492
- return _extends.apply(this, arguments);
493
- }
494
-
495
- function Alignment(align, viewSize) {
496
- var predefined = {
497
- start: start,
498
- center: center,
499
- end: end
500
- };
501
-
502
- function start() {
503
- return 0;
504
- }
505
-
506
- function center(n) {
507
- return end(n) / 2;
508
- }
509
-
510
- function end(n) {
511
- return viewSize - n;
512
- }
513
-
514
- function percent() {
515
- return viewSize * Number(align);
516
- }
517
-
518
- function measure(n) {
519
- if (typeof align === 'number') return percent();
520
- return predefined[align](n);
521
- }
522
-
523
- var self = {
524
- measure: measure
525
- };
526
- return self;
527
- }
528
-
529
- function Animation(callback) {
530
- var animationFrame = 0;
531
-
532
- function ifAnimating(active, cb) {
533
- return function () {
534
- if (active === !!animationFrame) cb();
535
- };
536
- }
537
-
538
- function start() {
539
- animationFrame = window.requestAnimationFrame(callback);
540
- }
541
-
542
- function stop() {
543
- window.cancelAnimationFrame(animationFrame);
544
- animationFrame = 0;
545
- }
546
-
547
- var self = {
548
- proceed: ifAnimating(true, start),
549
- start: ifAnimating(false, start),
550
- stop: ifAnimating(true, stop)
551
- };
552
- return self;
553
- }
554
-
555
- function Axis(axis, contentDirection) {
556
- var scroll = axis === 'y' ? 'y' : 'x';
557
- var cross = axis === 'y' ? 'x' : 'y';
558
- var startEdge = getStartEdge();
559
- var endEdge = getEndEdge();
560
-
561
- function measureSize(rect) {
562
- var width = rect.width,
563
- height = rect.height;
564
- return scroll === 'x' ? width : height;
565
- }
566
-
567
- function getStartEdge() {
568
- if (scroll === 'y') return 'top';
569
- return contentDirection === 'rtl' ? 'right' : 'left';
570
- }
571
-
572
- function getEndEdge() {
573
- if (scroll === 'y') return 'bottom';
574
- return contentDirection === 'rtl' ? 'left' : 'right';
575
- }
576
-
577
- var self = {
578
- scroll: scroll,
579
- cross: cross,
580
- startEdge: startEdge,
581
- endEdge: endEdge,
582
- measureSize: measureSize
583
- };
584
- return self;
585
- }
586
-
587
- function Limit(min, max) {
588
- var length = Math.abs(min - max);
589
-
590
- function reachedMin(n) {
591
- return n < min;
592
- }
593
-
594
- function reachedMax(n) {
595
- return n > max;
596
- }
597
-
598
- function reachedAny(n) {
599
- return reachedMin(n) || reachedMax(n);
600
- }
601
-
602
- function constrain(n) {
603
- if (!reachedAny(n)) return n;
604
- return reachedMin(n) ? min : max;
605
- }
606
-
607
- function removeOffset(n) {
608
- if (!length) return n;
609
- return n - length * Math.ceil((n - max) / length);
610
- }
611
-
612
- var self = {
613
- constrain: constrain,
614
- length: length,
615
- max: max,
616
- min: min,
617
- reachedAny: reachedAny,
618
- reachedMax: reachedMax,
619
- reachedMin: reachedMin,
620
- removeOffset: removeOffset
621
- };
622
- return self;
623
- }
624
-
625
- function Counter(max, start, loop) {
626
- var _a = Limit(0, max),
627
- min = _a.min,
628
- constrain = _a.constrain;
629
-
630
- var loopEnd = max + 1;
631
- var counter = withinLimit(start);
632
-
633
- function withinLimit(n) {
634
- return !loop ? constrain(n) : Math.abs((loopEnd + n) % loopEnd);
635
- }
636
-
637
- function get() {
638
- return counter;
639
- }
640
-
641
- function set(n) {
642
- counter = withinLimit(n);
643
- return self;
644
- }
645
-
646
- function add(n) {
647
- return set(get() + n);
648
- }
649
-
650
- function clone() {
651
- return Counter(max, get(), loop);
652
- }
653
-
654
- var self = {
655
- add: add,
656
- clone: clone,
657
- get: get,
658
- set: set,
659
- min: min,
660
- max: max
661
- };
662
- return self;
663
- }
664
-
665
- function Direction(direction) {
666
- var sign = direction === 'rtl' ? -1 : 1;
667
-
668
- function applyTo(n) {
669
- return n * sign;
670
- }
671
-
672
- var self = {
673
- applyTo: applyTo
674
- };
675
- return self;
676
- }
677
-
678
- function EventStore() {
679
- var listeners = [];
680
-
681
- function add(node, type, handler, options) {
682
- if (options === void 0) {
683
- options = false;
684
- }
685
-
686
- node.addEventListener(type, handler, options);
687
- listeners.push(function () {
688
- return node.removeEventListener(type, handler, options);
689
- });
690
- return self;
691
- }
692
-
693
- function removeAll() {
694
- listeners = listeners.filter(function (remove) {
695
- return remove();
696
- });
697
- return self;
698
- }
699
-
700
- var self = {
701
- add: add,
702
- removeAll: removeAll
703
- };
704
- return self;
705
- }
706
-
707
- function Vector1D(value) {
708
- var vector = value;
709
-
710
- function get() {
711
- return vector;
712
- }
713
-
714
- function set(n) {
715
- vector = readNumber(n);
716
- return self;
717
- }
718
-
719
- function add(n) {
720
- vector += readNumber(n);
721
- return self;
722
- }
723
-
724
- function subtract(n) {
725
- vector -= readNumber(n);
726
- return self;
727
- }
728
-
729
- function multiply(n) {
730
- vector *= n;
731
- return self;
732
- }
733
-
734
- function divide(n) {
735
- vector /= n;
736
- return self;
737
- }
738
-
739
- function normalize() {
740
- if (vector !== 0) divide(vector);
741
- return self;
742
- }
743
-
744
- function readNumber(n) {
745
- return typeof n === 'number' ? n : n.get();
746
- }
747
-
748
- var self = {
749
- add: add,
750
- divide: divide,
751
- get: get,
752
- multiply: multiply,
753
- normalize: normalize,
754
- set: set,
755
- subtract: subtract
756
- };
757
- return self;
758
- }
759
-
760
- function map(value, iStart, iStop, oStart, oStop) {
761
- return oStart + (oStop - oStart) * ((value - iStart) / (iStop - iStart));
762
- }
763
-
764
- function mathSign(n) {
765
- return !n ? 0 : n / Math.abs(n);
766
- }
767
-
768
- function deltaAbs(valueB, valueA) {
769
- return Math.abs(valueB - valueA);
770
- }
771
-
772
- function factorAbs(valueB, valueA) {
773
- if (valueB === 0 || valueA === 0) return 0;
774
- if (Math.abs(valueB) <= Math.abs(valueA)) return 0;
775
- var diff = deltaAbs(Math.abs(valueB), Math.abs(valueA));
776
- return Math.abs(diff / valueB);
777
- }
778
-
779
- function roundToDecimals(decimalPoints) {
780
- var pow = Math.pow(10, decimalPoints);
781
- return function (n) {
782
- return Math.round(n * pow) / pow;
783
- };
784
- }
785
-
786
- function debounce(callback, time) {
787
- var timeout = 0;
788
- return function () {
789
- window.clearTimeout(timeout);
790
- timeout = window.setTimeout(callback, time) || 0;
791
- };
792
- }
793
-
794
- function groupArray(array, size) {
795
- var groups = [];
796
-
797
- for (var i = 0; i < array.length; i += size) {
798
- groups.push(array.slice(i, i + size));
799
- }
800
-
801
- return groups;
802
- }
803
-
804
- function arrayKeys(array) {
805
- return Object.keys(array).map(Number);
806
- }
807
-
808
- function arrayLast(array) {
809
- return array[lastIndex(array)];
810
- }
811
-
812
- function lastIndex(array) {
813
- return Math.max(0, array.length - 1);
814
- }
815
-
816
- function removeClass(node, className) {
817
- var cl = node.classList;
818
- if (className && cl.contains(className)) cl.remove(className);
819
- }
820
-
821
- function addClass(node, className) {
822
- var cl = node.classList;
823
- if (className && !cl.contains(className)) cl.add(className);
824
- }
825
-
826
- function DragHandler(axis, direction, rootNode, target, dragFree, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, events, loop, skipSnaps) {
827
- var scrollAxis = axis.scroll,
828
- crossAxis = axis.cross;
829
- var focusNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
830
- var startScroll = Vector1D(0);
831
- var startCross = Vector1D(0);
832
- var dragStartPoint = Vector1D(0);
833
- var activationEvents = EventStore();
834
- var interactionEvents = EventStore();
835
- var snapForceBoost = {
836
- mouse: 2.5,
837
- touch: 3.5
838
- };
839
- var freeForceBoost = {
840
- mouse: 5,
841
- touch: 7
842
- };
843
- var baseSpeed = dragFree ? 5 : 16;
844
- var baseMass = 1;
845
- var dragThreshold = 20;
846
- var pointerIsDown = false;
847
- var preventScroll = false;
848
- var preventClick = false;
849
- var isMouse = false;
850
-
851
- function addActivationEvents() {
852
- var node = rootNode;
853
- activationEvents.add(node, 'touchmove', function () {
854
- return undefined;
855
- }).add(node, 'touchend', function () {
856
- return undefined;
857
- }).add(node, 'touchstart', down).add(node, 'mousedown', down).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click);
858
- }
859
-
860
- function addInteractionEvents() {
861
- var node = !isMouse ? rootNode : document;
862
- interactionEvents.add(node, 'touchmove', move).add(node, 'touchend', up).add(node, 'mousemove', move).add(node, 'mouseup', up);
863
- }
864
-
865
- function removeAllEvents() {
866
- activationEvents.removeAll();
867
- interactionEvents.removeAll();
868
- }
869
-
870
- function isFocusNode(node) {
871
- var name = node.nodeName || '';
872
- return focusNodes.indexOf(name) > -1;
873
- }
874
-
875
- function forceBoost() {
876
- var boost = dragFree ? freeForceBoost : snapForceBoost;
877
- var type = isMouse ? 'mouse' : 'touch';
878
- return boost[type];
879
- }
880
-
881
- function allowedForce(force, targetChanged) {
882
- var next = index.clone().add(mathSign(force) * -1);
883
- var isEdge = next.get() === index.min || next.get() === index.max;
884
- var baseForce = scrollTarget.byDistance(force, !dragFree).distance;
885
- if (dragFree || Math.abs(force) < dragThreshold) return baseForce;
886
- if (!loop && isEdge) return baseForce * 0.6;
887
- if (skipSnaps && targetChanged) return baseForce * 0.5;
888
- return scrollTarget.byIndex(next.get(), 0).distance;
889
- }
890
-
891
- function down(evt) {
892
- isMouse = evt.type === 'mousedown';
893
- if (isMouse && evt.button !== 0) return;
894
- var isMoving = deltaAbs(target.get(), location.get()) >= 2;
895
- var clearPreventClick = isMouse || !isMoving;
896
- var isNotFocusNode = !isFocusNode(evt.target);
897
- var preventDefault = isMoving || isMouse && isNotFocusNode;
898
- pointerIsDown = true;
899
- dragTracker.pointerDown(evt);
900
- dragStartPoint.set(target);
901
- target.set(location);
902
- scrollBody.useBaseMass().useSpeed(80);
903
- addInteractionEvents();
904
- startScroll.set(dragTracker.readPoint(evt, scrollAxis));
905
- startCross.set(dragTracker.readPoint(evt, crossAxis));
906
- events.emit('pointerDown');
907
- if (clearPreventClick) preventClick = false;
908
- if (preventDefault) evt.preventDefault();
909
- }
910
-
911
- function move(evt) {
912
- if (!preventScroll && !isMouse) {
913
- if (!evt.cancelable) return up();
914
- var moveScroll = dragTracker.readPoint(evt, scrollAxis).get();
915
- var moveCross = dragTracker.readPoint(evt, crossAxis).get();
916
- var diffScroll = deltaAbs(moveScroll, startScroll.get());
917
- var diffCross = deltaAbs(moveCross, startCross.get());
918
- preventScroll = diffScroll > diffCross;
919
- if (!preventScroll && !preventClick) return up();
920
- }
921
-
922
- var diff = dragTracker.pointerMove(evt);
923
- if (!preventClick && diff) preventClick = true;
924
- animation.start();
925
- target.add(direction.applyTo(diff));
926
- evt.preventDefault();
927
- }
928
-
929
- function up() {
930
- var currentLocation = scrollTarget.byDistance(0, false);
931
- var targetChanged = currentLocation.index !== index.get();
932
- var rawForce = dragTracker.pointerUp() * forceBoost();
933
- var force = allowedForce(direction.applyTo(rawForce), targetChanged);
934
- var forceFactor = factorAbs(rawForce, force);
935
- var isMoving = deltaAbs(target.get(), dragStartPoint.get()) >= 0.5;
936
- var isVigorous = targetChanged && forceFactor > 0.75;
937
- var isBelowThreshold = Math.abs(rawForce) < dragThreshold;
938
- var speed = isVigorous ? 10 : baseSpeed;
939
- var mass = isVigorous ? baseMass + 2.5 * forceFactor : baseMass;
940
- if (isMoving && !isMouse) preventClick = true;
941
- preventScroll = false;
942
- pointerIsDown = false;
943
- interactionEvents.removeAll();
944
- scrollBody.useSpeed(isBelowThreshold ? 9 : speed).useMass(mass);
945
- scrollTo.distance(force, !dragFree);
946
- isMouse = false;
947
- events.emit('pointerUp');
948
- }
949
-
950
- function click(evt) {
951
- if (preventClick) evt.preventDefault();
952
- }
953
-
954
- function clickAllowed() {
955
- return !preventClick;
956
- }
957
-
958
- function pointerDown() {
959
- return pointerIsDown;
960
- }
961
-
962
- var self = {
963
- addActivationEvents: addActivationEvents,
964
- clickAllowed: clickAllowed,
965
- pointerDown: pointerDown,
966
- removeAllEvents: removeAllEvents
967
- };
968
- return self;
969
- }
970
-
971
- function DragTracker(axis, pxToPercent) {
972
- var scrollAxis = axis.scroll;
973
- var coords = {
974
- x: 'clientX',
975
- y: 'clientY'
976
- };
977
- var startDrag = Vector1D(0);
978
- var diffDrag = Vector1D(0);
979
- var lastDrag = Vector1D(0);
980
- var pointValue = Vector1D(0);
981
- var trackInterval = 10;
982
- var trackLength = 5;
983
- var trackTime = 100;
984
- var trackPoints = [];
985
- var lastMoveTime = new Date().getTime();
986
- var isMouse = false;
987
-
988
- function readPoint(evt, type) {
989
- isMouse = !evt.touches;
990
- var c = coords[type];
991
- var value = isMouse ? evt[c] : evt.touches[0][c];
992
- return pointValue.set(value);
993
- }
994
-
995
- function pointerDown(evt) {
996
- var point = readPoint(evt, scrollAxis);
997
- startDrag.set(point);
998
- lastDrag.set(point);
999
- return pxToPercent.measure(startDrag.get());
1000
- }
1001
-
1002
- function pointerMove(evt) {
1003
- var point = readPoint(evt, scrollAxis);
1004
- var nowTime = new Date().getTime();
1005
- var diffTime = nowTime - lastMoveTime;
1006
-
1007
- if (diffTime >= trackInterval) {
1008
- if (diffTime >= trackTime) trackPoints = [];
1009
- trackPoints.push(point.get());
1010
- lastMoveTime = nowTime;
1011
- }
1012
-
1013
- diffDrag.set(point).subtract(lastDrag);
1014
- lastDrag.set(point);
1015
- return pxToPercent.measure(diffDrag.get());
1016
- }
1017
-
1018
- function pointerUp() {
1019
- var nowTime = new Date().getTime();
1020
- var diffTime = nowTime - lastMoveTime;
1021
- var currentPoint = lastDrag.get();
1022
- var force = trackPoints.slice(-trackLength).map(function (trackPoint) {
1023
- return currentPoint - trackPoint;
1024
- }).sort(function (p1, p2) {
1025
- return Math.abs(p1) < Math.abs(p2) ? 1 : -1;
1026
- })[0];
1027
- lastDrag.set(diffTime > trackTime || !force ? 0 : force);
1028
- trackPoints = [];
1029
- return pxToPercent.measure(lastDrag.get());
1030
- }
1031
-
1032
- var self = {
1033
- pointerDown: pointerDown,
1034
- pointerMove: pointerMove,
1035
- pointerUp: pointerUp,
1036
- readPoint: readPoint
1037
- };
1038
- return self;
1039
- }
1040
-
1041
- function PxToPercent(viewInPx) {
1042
- var totalPercent = 100;
1043
-
1044
- function measure(n) {
1045
- if (viewInPx === 0) return 0;
1046
- return n / viewInPx * totalPercent;
1047
- }
1048
-
1049
- var self = {
1050
- measure: measure,
1051
- totalPercent: totalPercent
1052
- };
1053
- return self;
1054
- }
1055
-
1056
- function ScrollBody(location, baseSpeed, baseMass) {
1057
- var roundToTwoDecimals = roundToDecimals(2);
1058
- var velocity = Vector1D(0);
1059
- var acceleration = Vector1D(0);
1060
- var attraction = Vector1D(0);
1061
- var attractionDirection = 0;
1062
- var speed = baseSpeed;
1063
- var mass = baseMass;
1064
-
1065
- function update() {
1066
- velocity.add(acceleration);
1067
- location.add(velocity);
1068
- acceleration.multiply(0);
1069
- }
1070
-
1071
- function applyForce(v) {
1072
- v.divide(mass);
1073
- acceleration.add(v);
1074
- }
1075
-
1076
- function seek(v) {
1077
- attraction.set(v).subtract(location);
1078
- var magnitude = map(attraction.get(), 0, 100, 0, speed);
1079
- attractionDirection = mathSign(attraction.get());
1080
- attraction.normalize().multiply(magnitude).subtract(velocity);
1081
- applyForce(attraction);
1082
- return self;
1083
- }
1084
-
1085
- function settle(v) {
1086
- var diff = v.get() - location.get();
1087
- var hasSettled = !roundToTwoDecimals(diff);
1088
- if (hasSettled) location.set(v);
1089
- return hasSettled;
1090
- }
1091
-
1092
- function direction() {
1093
- return attractionDirection;
1094
- }
1095
-
1096
- function useBaseSpeed() {
1097
- return useSpeed(baseSpeed);
1098
- }
1099
-
1100
- function useBaseMass() {
1101
- return useMass(baseMass);
1102
- }
1103
-
1104
- function useSpeed(n) {
1105
- speed = n;
1106
- return self;
1107
- }
1108
-
1109
- function useMass(n) {
1110
- mass = n;
1111
- return self;
1112
- }
1113
-
1114
- var self = {
1115
- direction: direction,
1116
- seek: seek,
1117
- settle: settle,
1118
- update: update,
1119
- useBaseMass: useBaseMass,
1120
- useBaseSpeed: useBaseSpeed,
1121
- useMass: useMass,
1122
- useSpeed: useSpeed
1123
- };
1124
- return self;
1125
- }
1126
-
1127
- function ScrollBounds(limit, location, target, scrollBody) {
1128
- var pullBackThreshold = 10;
1129
- var disabled = false;
1130
-
1131
- function shouldConstrain() {
1132
- if (disabled) return false;
1133
- if (!limit.reachedAny(target.get())) return false;
1134
- if (!limit.reachedAny(location.get())) return false;
1135
- return true;
1136
- }
1137
-
1138
- function constrain(pointerDown) {
1139
- if (!shouldConstrain()) return;
1140
- var friction = pointerDown ? 0.7 : 0.45;
1141
- var diffToTarget = target.get() - location.get();
1142
- target.subtract(diffToTarget * friction);
1143
-
1144
- if (!pointerDown && Math.abs(diffToTarget) < pullBackThreshold) {
1145
- target.set(limit.constrain(target.get()));
1146
- scrollBody.useSpeed(10).useMass(3);
1147
- }
1148
- }
1149
-
1150
- function toggleActive(active) {
1151
- disabled = !active;
1152
- }
1153
-
1154
- var self = {
1155
- constrain: constrain,
1156
- toggleActive: toggleActive
1157
- };
1158
- return self;
1159
- }
1160
-
1161
- function ScrollContain(viewSize, contentSize, snaps, snapsAligned, containScroll) {
1162
- var scrollBounds = Limit(-contentSize + viewSize, snaps[0]);
1163
- var snapsBounded = snapsAligned.map(scrollBounds.constrain);
1164
- var snapsContained = measureContained();
1165
-
1166
- function findDuplicates() {
1167
- var startSnap = snapsBounded[0];
1168
- var endSnap = arrayLast(snapsBounded);
1169
- var min = snapsBounded.lastIndexOf(startSnap);
1170
- var max = snapsBounded.indexOf(endSnap) + 1;
1171
- return Limit(min, max);
1172
- }
1173
-
1174
- function measureContained() {
1175
- if (contentSize <= viewSize) return [scrollBounds.max];
1176
- if (containScroll === 'keepSnaps') return snapsBounded;
1177
-
1178
- var _a = findDuplicates(),
1179
- min = _a.min,
1180
- max = _a.max;
1181
-
1182
- return snapsBounded.slice(min, max);
1183
- }
1184
-
1185
- var self = {
1186
- snapsContained: snapsContained
1187
- };
1188
- return self;
1189
- }
1190
-
1191
- function ScrollLimit(contentSize, scrollSnaps, loop) {
1192
- var limit = measureLimit();
1193
-
1194
- function measureLimit() {
1195
- var startSnap = scrollSnaps[0];
1196
- var endSnap = arrayLast(scrollSnaps);
1197
- var min = loop ? startSnap - contentSize : endSnap;
1198
- var max = startSnap;
1199
- return Limit(min, max);
1200
- }
1201
-
1202
- var self = {
1203
- limit: limit
1204
- };
1205
- return self;
1206
- }
1207
-
1208
- function ScrollLooper(contentSize, pxToPercent, limit, location, vectors) {
1209
- var min = limit.min + pxToPercent.measure(0.1);
1210
- var max = limit.max + pxToPercent.measure(0.1);
1211
-
1212
- var _a = Limit(min, max),
1213
- reachedMin = _a.reachedMin,
1214
- reachedMax = _a.reachedMax;
1215
-
1216
- function shouldLoop(direction) {
1217
- if (direction === 1) return reachedMax(location.get());
1218
- if (direction === -1) return reachedMin(location.get());
1219
- return false;
1220
- }
1221
-
1222
- function loop(direction) {
1223
- if (!shouldLoop(direction)) return;
1224
- var loopDistance = contentSize * (direction * -1);
1225
- vectors.forEach(function (v) {
1226
- return v.add(loopDistance);
1227
- });
1228
- }
1229
-
1230
- var self = {
1231
- loop: loop
1232
- };
1233
- return self;
1234
- }
1235
-
1236
- function ScrollProgress(limit) {
1237
- var max = limit.max,
1238
- scrollLength = limit.length;
1239
-
1240
- function get(n) {
1241
- var currentLocation = n - max;
1242
- return currentLocation / -scrollLength;
1243
- }
1244
-
1245
- var self = {
1246
- get: get
1247
- };
1248
- return self;
1249
- }
1250
-
1251
- function ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll) {
1252
- var startEdge = axis.startEdge,
1253
- endEdge = axis.endEdge;
1254
- var snaps = measureUnaligned();
1255
- var snapsAligned = measureAligned();
1256
-
1257
- function measureSizes() {
1258
- return groupArray(slideRects, slidesToScroll).map(function (rects) {
1259
- return arrayLast(rects)[endEdge] - rects[0][startEdge];
1260
- }).map(pxToPercent.measure).map(Math.abs);
1261
- }
1262
-
1263
- function measureUnaligned() {
1264
- return slideRects.map(function (rect) {
1265
- return containerRect[startEdge] - rect[startEdge];
1266
- }).map(pxToPercent.measure).map(function (snap) {
1267
- return -Math.abs(snap);
1268
- });
1269
- }
1270
-
1271
- function measureAligned() {
1272
- var groupedSnaps = groupArray(snaps, slidesToScroll).map(function (g) {
1273
- return g[0];
1274
- });
1275
- var alignments = measureSizes().map(alignment.measure);
1276
- return groupedSnaps.map(function (snap, index) {
1277
- return snap + alignments[index];
1278
- });
1279
- }
1280
-
1281
- var self = {
1282
- snaps: snaps,
1283
- snapsAligned: snapsAligned
1284
- };
1285
- return self;
1286
- }
1287
-
1288
- function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
1289
- var reachedAny = limit.reachedAny,
1290
- removeOffset = limit.removeOffset,
1291
- constrain = limit.constrain;
1292
-
1293
- function minDistance(d1, d2) {
1294
- return Math.abs(d1) < Math.abs(d2) ? d1 : d2;
1295
- }
1296
-
1297
- function findTargetSnap(target) {
1298
- var distance = loop ? removeOffset(target) : constrain(target);
1299
- var ascDiffsToSnaps = scrollSnaps.map(function (scrollSnap) {
1300
- return scrollSnap - distance;
1301
- }).map(function (diffToSnap) {
1302
- return shortcut(diffToSnap, 0);
1303
- }).map(function (diff, i) {
1304
- return {
1305
- diff: diff,
1306
- index: i
1307
- };
1308
- }).sort(function (d1, d2) {
1309
- return Math.abs(d1.diff) - Math.abs(d2.diff);
1310
- });
1311
- var index = ascDiffsToSnaps[0].index;
1312
- return {
1313
- index: index,
1314
- distance: distance
1315
- };
1316
- }
1317
-
1318
- function shortcut(target, direction) {
1319
- var t1 = target;
1320
- var t2 = target + contentSize;
1321
- var t3 = target - contentSize;
1322
- if (!loop) return t1;
1323
- if (!direction) return minDistance(minDistance(t1, t2), t3);
1324
- var shortest = minDistance(t1, direction === 1 ? t2 : t3);
1325
- return Math.abs(shortest) * direction;
1326
- }
1327
-
1328
- function byIndex(index, direction) {
1329
- var diffToSnap = scrollSnaps[index] - targetVector.get();
1330
- var distance = shortcut(diffToSnap, direction);
1331
- return {
1332
- index: index,
1333
- distance: distance
1334
- };
1335
- }
1336
-
1337
- function byDistance(distance, snap) {
1338
- var target = targetVector.get() + distance;
1339
-
1340
- var _a = findTargetSnap(target),
1341
- index = _a.index,
1342
- targetSnapDistance = _a.distance;
1343
-
1344
- var reachedBound = !loop && reachedAny(target);
1345
- if (!snap || reachedBound) return {
1346
- index: index,
1347
- distance: distance
1348
- };
1349
- var diffToSnap = scrollSnaps[index] - targetSnapDistance;
1350
- var snapDistance = distance + shortcut(diffToSnap, 0);
1351
- return {
1352
- index: index,
1353
- distance: snapDistance
1354
- };
1355
- }
1356
-
1357
- var self = {
1358
- byDistance: byDistance,
1359
- byIndex: byIndex,
1360
- shortcut: shortcut
1361
- };
1362
- return self;
1363
- }
1364
-
1365
- function ScrollTo(animation, indexCurrent, indexPrevious, scrollTarget, targetVector, events) {
1366
- function scrollTo(target) {
1367
- var distanceDiff = target.distance;
1368
- var indexDiff = target.index !== indexCurrent.get();
1369
-
1370
- if (distanceDiff) {
1371
- animation.start();
1372
- targetVector.add(distanceDiff);
1373
- }
1374
-
1375
- if (indexDiff) {
1376
- indexPrevious.set(indexCurrent.get());
1377
- indexCurrent.set(target.index);
1378
- events.emit('select');
1379
- }
1380
- }
1381
-
1382
- function distance(n, snap) {
1383
- var target = scrollTarget.byDistance(n, snap);
1384
- scrollTo(target);
1385
- }
1386
-
1387
- function index(n, direction) {
1388
- var targetIndex = indexCurrent.clone().set(n);
1389
- var target = scrollTarget.byIndex(targetIndex.get(), direction);
1390
- scrollTo(target);
1391
- }
1392
-
1393
- var self = {
1394
- distance: distance,
1395
- index: index
1396
- };
1397
- return self;
1398
- }
1399
-
1400
- function SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, scrollLocation, slides) {
1401
- var ascItems = arrayKeys(slideSizesWithGaps);
1402
- var descItems = arrayKeys(slideSizesWithGaps).reverse();
1403
- var loopPoints = startPoints().concat(endPoints());
1404
-
1405
- function removeSlideSizes(indexes, from) {
1406
- return indexes.reduce(function (a, i) {
1407
- return a - slideSizesWithGaps[i];
1408
- }, from);
1409
- }
1410
-
1411
- function slidesInGap(indexes, gap) {
1412
- return indexes.reduce(function (a, i) {
1413
- var remainingGap = removeSlideSizes(a, gap);
1414
- return remainingGap > 0 ? a.concat([i]) : a;
1415
- }, []);
1416
- }
1417
-
1418
- function findLoopPoints(indexes, edge) {
1419
- var isStartEdge = edge === 'start';
1420
- var offset = isStartEdge ? -contentSize : contentSize;
1421
- var slideBounds = slidesInView.findSlideBounds(offset);
1422
- return indexes.map(function (index) {
1423
- var initial = isStartEdge ? 0 : -contentSize;
1424
- var altered = isStartEdge ? contentSize : 0;
1425
- var bounds = slideBounds.filter(function (b) {
1426
- return b.index === index;
1427
- })[0];
1428
- var point = bounds[isStartEdge ? 'end' : 'start'];
1429
-
1430
- var getTarget = function getTarget() {
1431
- return scrollLocation.get() > point ? initial : altered;
1432
- };
1433
-
1434
- return {
1435
- point: point,
1436
- getTarget: getTarget,
1437
- index: index,
1438
- location: -1
1439
- };
1440
- });
1441
- }
1442
-
1443
- function startPoints() {
1444
- var gap = scrollSnaps[0] - 1;
1445
- var indexes = slidesInGap(descItems, gap);
1446
- return findLoopPoints(indexes, 'end');
1447
- }
1448
-
1449
- function endPoints() {
1450
- var gap = viewSize - scrollSnaps[0] - 1;
1451
- var indexes = slidesInGap(ascItems, gap);
1452
- return findLoopPoints(indexes, 'start');
1453
- }
1454
-
1455
- function canLoop() {
1456
- return loopPoints.every(function (_a) {
1457
- var index = _a.index;
1458
- var otherIndexes = ascItems.filter(function (i) {
1459
- return i !== index;
1460
- });
1461
- return removeSlideSizes(otherIndexes, viewSize) <= 0;
1462
- });
1463
- }
1464
-
1465
- function loop() {
1466
- loopPoints.forEach(function (loopPoint) {
1467
- var getTarget = loopPoint.getTarget,
1468
- location = loopPoint.location,
1469
- index = loopPoint.index;
1470
- var target = getTarget();
1471
-
1472
- if (target !== location) {
1473
- slides[index].style[axis.startEdge] = target + "%";
1474
- loopPoint.location = target;
1475
- }
1476
- });
1477
- }
1478
-
1479
- function clear() {
1480
- loopPoints.forEach(function (_a) {
1481
- var index = _a.index;
1482
- slides[index].style[axis.startEdge] = '';
1483
- });
1484
- }
1485
-
1486
- var self = {
1487
- canLoop: canLoop,
1488
- clear: clear,
1489
- loop: loop,
1490
- loopPoints: loopPoints
1491
- };
1492
- return self;
1493
- }
1494
-
1495
- function SlideFocus(rootNode, scrollTo, slidesToScroll) {
1496
- var eventStore = EventStore();
1497
- var removeAllEvents = eventStore.removeAll;
1498
- var lastTabPressTime = 0;
1499
-
1500
- function registerTabPress(event) {
1501
- if (event.keyCode !== 9) return;
1502
- lastTabPressTime = new Date().getTime();
1503
- }
1504
-
1505
- function addFocusEvent(slide, index) {
1506
- var focus = function focus() {
1507
- var nowTime = new Date().getTime();
1508
- var diffTime = nowTime - lastTabPressTime;
1509
- if (diffTime > 10) return;
1510
- rootNode.scrollLeft = 0;
1511
- var selectedIndex = Math.floor(index / slidesToScroll);
1512
- scrollTo.index(selectedIndex, 0);
1513
- };
1514
-
1515
- eventStore.add(slide, 'focus', focus, true);
1516
- }
1517
-
1518
- function addActivationEvents(slides) {
1519
- eventStore.add(document, 'keydown', registerTabPress, false);
1520
- slides.forEach(addFocusEvent);
1521
- }
1522
-
1523
- var self = {
1524
- addActivationEvents: addActivationEvents,
1525
- removeAllEvents: removeAllEvents
1526
- };
1527
- return self;
1528
- }
1529
-
1530
- function SlidesInView(viewSize, contentSize, slideSizes, snaps, loop, inViewThreshold) {
1531
- var threshold = Math.min(Math.max(inViewThreshold, 0.01), 0.99);
1532
- var offsets = loop ? [0, contentSize, -contentSize] : [0];
1533
- var slideBounds = offsets.reduce(function (a, offset) {
1534
- return a.concat(findSlideBounds(offset, threshold));
1535
- }, []);
1536
-
1537
- function findSlideBounds(offset, threshold) {
1538
- var thresholds = slideSizes.map(function (s) {
1539
- return s * (threshold || 0);
1540
- });
1541
- return snaps.map(function (snap, index) {
1542
- return {
1543
- start: snap - slideSizes[index] + thresholds[index] + offset,
1544
- end: snap + viewSize - thresholds[index] + offset,
1545
- index: index
1546
- };
1547
- });
1548
- }
1549
-
1550
- function check(location) {
1551
- return slideBounds.reduce(function (list, slideBound) {
1552
- var index = slideBound.index,
1553
- start = slideBound.start,
1554
- end = slideBound.end;
1555
- var inList = list.indexOf(index) !== -1;
1556
- var inView = start < location && end > location;
1557
- return !inList && inView ? list.concat([index]) : list;
1558
- }, []);
1559
- }
1560
-
1561
- var self = {
1562
- check: check,
1563
- findSlideBounds: findSlideBounds
1564
- };
1565
- return self;
1566
- }
1567
-
1568
- function SlideSizes(axis, pxToPercent, slides, slideRects, loop) {
1569
- var measureSize = axis.measureSize,
1570
- startEdge = axis.startEdge,
1571
- endEdge = axis.endEdge;
1572
- var sizesInPx = slideRects.map(measureSize);
1573
- var slideSizes = sizesInPx.map(pxToPercent.measure);
1574
- var slideSizesWithGaps = measureWithGaps();
1575
-
1576
- function measureWithGaps() {
1577
- return slideRects.map(function (rect, index, rects) {
1578
- var isLast = index === lastIndex(rects);
1579
- var style = window.getComputedStyle(arrayLast(slides));
1580
- var endGap = parseFloat(style.getPropertyValue("margin-" + endEdge));
1581
- if (isLast) return sizesInPx[index] + (loop ? endGap : 0);
1582
- return rects[index + 1][startEdge] - rect[startEdge];
1583
- }).map(pxToPercent.measure).map(Math.abs);
1584
- }
1585
-
1586
- var self = {
1587
- slideSizes: slideSizes,
1588
- slideSizesWithGaps: slideSizesWithGaps
1589
- };
1590
- return self;
1591
- }
1592
-
1593
- function Translate(axis, direction, container) {
1594
- var containerStyle = container.style;
1595
- var translate = axis.scroll === 'x' ? x : y;
1596
- var disabled = false;
1597
-
1598
- function x(n) {
1599
- return "translate3d(" + n + "%,0px,0px)";
1600
- }
1601
-
1602
- function y(n) {
1603
- return "translate3d(0px," + n + "%,0px)";
1604
- }
1605
-
1606
- function to(target) {
1607
- if (disabled) return;
1608
- containerStyle.transform = translate(direction.applyTo(target.get()));
1609
- }
1610
-
1611
- function toggleActive(active) {
1612
- disabled = !active;
1613
- }
1614
-
1615
- function clear() {
1616
- containerStyle.transform = '';
1617
- }
1618
-
1619
- var self = {
1620
- clear: clear,
1621
- to: to,
1622
- toggleActive: toggleActive
1623
- };
1624
- return self;
1625
- }
1626
-
1627
- function Engine(root, container, slides, options, events) {
1628
- // Options
1629
- var align = options.align,
1630
- scrollAxis = options.axis,
1631
- contentDirection = options.direction,
1632
- startIndex = options.startIndex,
1633
- inViewThreshold = options.inViewThreshold,
1634
- loop = options.loop,
1635
- speed = options.speed,
1636
- dragFree = options.dragFree,
1637
- slidesToScroll = options.slidesToScroll,
1638
- skipSnaps = options.skipSnaps,
1639
- containScroll = options.containScroll; // Measurements
1640
-
1641
- var containerRect = container.getBoundingClientRect();
1642
- var slideRects = slides.map(function (slide) {
1643
- return slide.getBoundingClientRect();
1644
- });
1645
- var direction = Direction(contentDirection);
1646
- var axis = Axis(scrollAxis, contentDirection);
1647
- var pxToPercent = PxToPercent(axis.measureSize(containerRect));
1648
- var viewSize = pxToPercent.totalPercent;
1649
- var alignment = Alignment(align, viewSize);
1650
-
1651
- var _a = SlideSizes(axis, pxToPercent, slides, slideRects, loop),
1652
- slideSizes = _a.slideSizes,
1653
- slideSizesWithGaps = _a.slideSizesWithGaps;
1654
-
1655
- var _b = ScrollSnap(axis, alignment, pxToPercent, containerRect, slideRects, slidesToScroll),
1656
- snaps = _b.snaps,
1657
- snapsAligned = _b.snapsAligned;
1658
-
1659
- var contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
1660
- var snapsContained = ScrollContain(viewSize, contentSize, snaps, snapsAligned, containScroll).snapsContained;
1661
- var contain = !loop && containScroll !== '';
1662
- var scrollSnaps = contain ? snapsContained : snapsAligned;
1663
- var limit = ScrollLimit(contentSize, scrollSnaps, loop).limit; // Indexes
1664
-
1665
- var index = Counter(lastIndex(scrollSnaps), startIndex, loop);
1666
- var indexPrevious = index.clone();
1667
- var slideIndexes = arrayKeys(slides); // Draw
1668
-
1669
- var update = function update() {
1670
- if (!loop) engine.scrollBounds.constrain(engine.dragHandler.pointerDown());
1671
- engine.scrollBody.seek(target).update();
1672
- var settled = engine.scrollBody.settle(target);
1673
-
1674
- if (settled && !engine.dragHandler.pointerDown()) {
1675
- engine.animation.stop();
1676
- events.emit('settle');
1677
- }
1678
-
1679
- if (!settled) {
1680
- events.emit('scroll');
1681
- }
1682
-
1683
- if (loop) {
1684
- engine.scrollLooper.loop(engine.scrollBody.direction());
1685
- engine.slideLooper.loop();
1686
- }
1687
-
1688
- engine.translate.to(location);
1689
- engine.animation.proceed();
1690
- }; // Shared
1691
-
1692
-
1693
- var animation = Animation(update);
1694
- var startLocation = scrollSnaps[index.get()];
1695
- var location = Vector1D(startLocation);
1696
- var target = Vector1D(startLocation);
1697
- var scrollBody = ScrollBody(location, speed, 1);
1698
- var scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
1699
- var scrollTo = ScrollTo(animation, index, indexPrevious, scrollTarget, target, events);
1700
- var slidesInView = SlidesInView(viewSize, contentSize, slideSizes, snaps, loop, inViewThreshold); // DragHandler
1701
-
1702
- var dragHandler = DragHandler(axis, direction, root, target, dragFree, DragTracker(axis, pxToPercent), location, animation, scrollTo, scrollBody, scrollTarget, index, events, loop, skipSnaps); // Slider
1703
-
1704
- var engine = {
1705
- animation: animation,
1706
- axis: axis,
1707
- direction: direction,
1708
- dragHandler: dragHandler,
1709
- pxToPercent: pxToPercent,
1710
- index: index,
1711
- indexPrevious: indexPrevious,
1712
- limit: limit,
1713
- location: location,
1714
- options: options,
1715
- scrollBody: scrollBody,
1716
- scrollBounds: ScrollBounds(limit, location, target, scrollBody),
1717
- scrollLooper: ScrollLooper(contentSize, pxToPercent, limit, location, [location, target]),
1718
- scrollProgress: ScrollProgress(limit),
1719
- scrollSnaps: scrollSnaps,
1720
- scrollTarget: scrollTarget,
1721
- scrollTo: scrollTo,
1722
- slideFocus: SlideFocus(root, scrollTo, slidesToScroll),
1723
- slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizesWithGaps, scrollSnaps, slidesInView, location, slides),
1724
- slidesInView: slidesInView,
1725
- slideIndexes: slideIndexes,
1726
- target: target,
1727
- translate: Translate(axis, direction, container)
1728
- };
1729
- return engine;
1730
- }
1731
-
1732
- function EventEmitter() {
1733
- var listeners = {};
1734
-
1735
- function getListeners(evt) {
1736
- var eventListeners = listeners[evt];
1737
- return eventListeners || [];
1738
- }
1739
-
1740
- function emit(evt) {
1741
- getListeners(evt).forEach(function (e) {
1742
- return e(evt);
1743
- });
1744
- return self;
1745
- }
1746
-
1747
- function on(evt, cb) {
1748
- listeners[evt] = getListeners(evt).concat([cb]);
1749
- return self;
1750
- }
1751
-
1752
- function off(evt, cb) {
1753
- listeners[evt] = getListeners(evt).filter(function (e) {
1754
- return e !== cb;
1755
- });
1756
- return self;
1757
- }
1758
-
1759
- var self = {
1760
- emit: emit,
1761
- off: off,
1762
- on: on
1763
- };
1764
- return self;
1765
- }
1766
-
1767
- var defaultOptions = {
1768
- align: 'center',
1769
- axis: 'x',
1770
- containScroll: '',
1771
- direction: 'ltr',
1772
- dragFree: false,
1773
- draggable: true,
1774
- draggableClass: 'is-draggable',
1775
- draggingClass: 'is-dragging',
1776
- inViewThreshold: 0,
1777
- loop: false,
1778
- skipSnaps: true,
1779
- selectedClass: 'is-selected',
1780
- slidesToScroll: 1,
1781
- speed: 10,
1782
- startIndex: 0
1783
- };
1784
-
1785
- function OptionsPseudo(node) {
1786
- var pseudoString = getComputedStyle(node, ':before').content;
1787
-
1788
- function get() {
1789
- try {
1790
- return JSON.parse(pseudoString.slice(1, -1).replace(/\\/g, ''));
1791
- } catch (error) {} // eslint-disable-line no-empty
1792
-
1793
-
1794
- return {};
1795
- }
1796
-
1797
- var self = {
1798
- get: get
1799
- };
1800
- return self;
1801
- }
1802
-
1803
- function EmblaCarousel(sliderRoot, userOptions) {
1804
- var events = EventEmitter();
1805
- var eventStore = EventStore();
1806
- var debouncedResize = debounce(resize, 500);
1807
- var reInit = reActivate;
1808
- var on = events.on,
1809
- off = events.off;
1810
- var engine;
1811
- var activated = false;
1812
-
1813
- var optionsBase = _extends({}, defaultOptions);
1814
-
1815
- var options = _extends({}, optionsBase);
1816
-
1817
- var optionsPseudo;
1818
- var rootNodeSize = 0;
1819
- var container;
1820
- var slides;
1821
- activate(userOptions);
1822
-
1823
- function setupElements() {
1824
- if (!sliderRoot) throw new Error('Missing root node 😢');
1825
- var sliderContainer = sliderRoot.querySelector('*');
1826
- if (!sliderContainer) throw new Error('Missing container node 😢');
1827
- container = sliderContainer;
1828
- slides = Array.prototype.slice.call(container.children);
1829
- optionsPseudo = OptionsPseudo(sliderRoot);
1830
- }
1831
-
1832
- function activate(partialOptions) {
1833
- setupElements();
1834
- optionsBase = _extends({}, optionsBase, partialOptions);
1835
- options = _extends({}, optionsBase, optionsPseudo.get());
1836
- engine = Engine(sliderRoot, container, slides, options, events);
1837
- eventStore.add(window, 'resize', debouncedResize);
1838
- engine.translate.to(engine.location);
1839
- rootNodeSize = engine.axis.measureSize(sliderRoot.getBoundingClientRect());
1840
-
1841
- if (options.loop) {
1842
- if (!engine.slideLooper.canLoop()) {
1843
- deActivate();
1844
- return activate({
1845
- loop: false
1846
- });
1847
- }
1848
-
1849
- engine.slideLooper.loop();
1850
- }
1851
-
1852
- if (options.draggable && container.offsetParent && slides.length) {
1853
- engine.dragHandler.addActivationEvents();
1854
-
1855
- if (options.draggableClass) {
1856
- addClass(sliderRoot, options.draggableClass);
1857
- }
1858
-
1859
- if (options.draggingClass) {
1860
- events.on('pointerDown', toggleDraggingClass).on('pointerUp', toggleDraggingClass);
1861
- }
1862
- }
1863
-
1864
- if (slides.length) {
1865
- engine.slideFocus.addActivationEvents(slides);
1866
- }
1867
-
1868
- if (options.selectedClass) {
1869
- toggleSelectedClass();
1870
- events.on('select', toggleSelectedClass).on('pointerUp', toggleSelectedClass);
1871
- }
1872
-
1873
- if (!activated) {
1874
- setTimeout(function () {
1875
- return events.emit('init');
1876
- }, 0);
1877
- activated = true;
1878
- }
1879
- }
1880
-
1881
- function toggleDraggingClass(evt) {
1882
- var draggingClass = options.draggingClass;
1883
- if (evt === 'pointerDown') addClass(sliderRoot, draggingClass);else removeClass(sliderRoot, draggingClass);
1884
- }
1885
-
1886
- function toggleSelectedClass() {
1887
- var selectedClass = options.selectedClass;
1888
- var inView = slidesInView(true);
1889
- var notInView = slidesNotInView(true);
1890
- notInView.forEach(function (index) {
1891
- return removeClass(slides[index], selectedClass);
1892
- });
1893
- inView.forEach(function (index) {
1894
- return addClass(slides[index], selectedClass);
1895
- });
1896
- }
1897
-
1898
- function deActivate() {
1899
- engine.dragHandler.removeAllEvents();
1900
- engine.slideFocus.removeAllEvents();
1901
- engine.animation.stop();
1902
- eventStore.removeAll();
1903
- engine.translate.clear();
1904
- engine.slideLooper.clear();
1905
- removeClass(sliderRoot, options.draggableClass);
1906
- slides.forEach(function (slide) {
1907
- return removeClass(slide, options.selectedClass);
1908
- });
1909
- events.off('select', toggleSelectedClass).off('pointerUp', toggleSelectedClass).off('pointerDown', toggleDraggingClass).off('pointerUp', toggleDraggingClass);
1910
- }
1911
-
1912
- function reActivate(partialOptions) {
1913
- if (!activated) return;
1914
- var startIndex = selectedScrollSnap();
1915
-
1916
- var newOptions = _extends({
1917
- startIndex: startIndex
1918
- }, partialOptions);
1919
-
1920
- deActivate();
1921
- activate(newOptions);
1922
- events.emit('reInit');
1923
- }
1924
-
1925
- function destroy() {
1926
- if (!activated) return;
1927
- deActivate();
1928
- activated = false;
1929
- events.emit('destroy');
1930
- }
1931
-
1932
- function resize() {
1933
- if (!activated) return;
1934
- var size = engine.axis.measureSize(sliderRoot.getBoundingClientRect());
1935
- if (rootNodeSize !== size) reActivate();
1936
- events.emit('resize');
1937
- }
1938
-
1939
- function slidesInView(target) {
1940
- var location = engine[target ? 'target' : 'location'].get();
1941
- var type = options.loop ? 'removeOffset' : 'constrain';
1942
- return engine.slidesInView.check(engine.limit[type](location));
1943
- }
1944
-
1945
- function slidesNotInView(target) {
1946
- var inView = slidesInView(target);
1947
- return engine.slideIndexes.filter(function (index) {
1948
- return inView.indexOf(index) === -1;
1949
- });
1950
- }
1951
-
1952
- function scrollTo(index, jump, direction) {
1953
- engine.scrollBody.useBaseMass().useSpeed(jump ? 100 : options.speed);
1954
- if (activated) engine.scrollTo.index(index, direction || 0);
1955
- }
1956
-
1957
- function scrollNext(jump) {
1958
- var next = engine.index.clone().add(1);
1959
- scrollTo(next.get(), jump === true, -1);
1960
- }
1961
-
1962
- function scrollPrev(jump) {
1963
- var prev = engine.index.clone().add(-1);
1964
- scrollTo(prev.get(), jump === true, 1);
1965
- }
1966
-
1967
- function canScrollNext() {
1968
- var next = engine.index.clone().add(1);
1969
- return next.get() !== selectedScrollSnap();
1970
- }
1971
-
1972
- function canScrollPrev() {
1973
- var prev = engine.index.clone().add(-1);
1974
- return prev.get() !== selectedScrollSnap();
1975
- }
1976
-
1977
- function scrollSnapList() {
1978
- return engine.scrollSnaps.map(engine.scrollProgress.get);
1979
- }
1980
-
1981
- function scrollProgress() {
1982
- return engine.scrollProgress.get(engine.location.get());
1983
- }
1984
-
1985
- function selectedScrollSnap() {
1986
- return engine.index.get();
1987
- }
1988
-
1989
- function previousScrollSnap() {
1990
- return engine.indexPrevious.get();
1991
- }
1992
-
1993
- function clickAllowed() {
1994
- return engine.dragHandler.clickAllowed();
1995
- }
1996
-
1997
- function dangerouslyGetEngine() {
1998
- return engine;
1999
- }
2000
-
2001
- function rootNode() {
2002
- return sliderRoot;
2003
- }
2004
-
2005
- function containerNode() {
2006
- return container;
2007
- }
2008
-
2009
- function slideNodes() {
2010
- return slides;
2011
- }
2012
-
2013
- var self = {
2014
- canScrollNext: canScrollNext,
2015
- canScrollPrev: canScrollPrev,
2016
- clickAllowed: clickAllowed,
2017
- containerNode: containerNode,
2018
- dangerouslyGetEngine: dangerouslyGetEngine,
2019
- destroy: destroy,
2020
- off: off,
2021
- on: on,
2022
- previousScrollSnap: previousScrollSnap,
2023
- reInit: reInit,
2024
- rootNode: rootNode,
2025
- scrollNext: scrollNext,
2026
- scrollPrev: scrollPrev,
2027
- scrollProgress: scrollProgress,
2028
- scrollSnapList: scrollSnapList,
2029
- scrollTo: scrollTo,
2030
- selectedScrollSnap: selectedScrollSnap,
2031
- slideNodes: slideNodes,
2032
- slidesInView: slidesInView,
2033
- slidesNotInView: slidesNotInView
2034
- };
2035
- return self;
2036
- }
2037
-
2038
- function useEmblaCarousel(options) {
2039
- if (options === void 0) {
2040
- options = {};
2041
- }
2042
-
2043
- var _a = useState(),
2044
- embla = _a[0],
2045
- setEmbla = _a[1];
2046
-
2047
- var _b = useState(),
2048
- viewport = _b[0],
2049
- setViewport = _b[1];
2050
-
2051
- var storedOptions = useRef(options);
2052
- var activeOptions = useMemo(function () {
2053
- if (!areEqualShallow(storedOptions.current, options)) {
2054
- storedOptions.current = options;
2055
- }
2056
-
2057
- return storedOptions.current;
2058
- }, [storedOptions, options]);
2059
- useEffect(function () {
2060
- if (canUseDOM() && viewport) {
2061
- var newEmbla_1 = EmblaCarousel(viewport, activeOptions);
2062
- setEmbla(newEmbla_1);
2063
- return function () {
2064
- return newEmbla_1.destroy();
2065
- };
2066
- } else {
2067
- setEmbla(undefined);
2068
- }
2069
- }, [viewport, activeOptions, setEmbla]);
2070
- return [setViewport, embla];
2071
- }
2072
-
2073
- var iterator$4 = wellKnownSymbolWrapped.f('iterator');
2074
-
2075
- var iterator$3 = iterator$4;
2076
-
2077
- var iterator$2 = iterator$3;
2078
-
2079
- var iterator$1 = iterator$2;
2080
-
2081
- var iterator = iterator$1;
2082
-
2083
- function _typeof(obj) {
2084
- "@babel/helpers - typeof";
2085
-
2086
- if (typeof symbol === "function" && typeof iterator === "symbol") {
2087
- _typeof = function _typeof(obj) {
2088
- return typeof obj;
2089
- };
2090
- } else {
2091
- _typeof = function _typeof(obj) {
2092
- return obj && typeof symbol === "function" && obj.constructor === symbol && obj !== symbol.prototype ? "symbol" : typeof obj;
2093
- };
2094
- }
2095
-
2096
- return _typeof(obj);
2097
- }
2098
-
2099
- var redefineAll = function (target, src, options) {
2100
- for (var key in src) {
2101
- if (options && options.unsafe && target[key]) target[key] = src[key];
2102
- else redefine(target, key, src[key], options);
2103
- } return target;
2104
- };
2105
-
2106
- var TypeError$2 = global_1.TypeError;
2107
-
2108
- var Result = function (stopped, result) {
2109
- this.stopped = stopped;
2110
- this.result = result;
2111
- };
2112
-
2113
- var ResultPrototype = Result.prototype;
2114
-
2115
- var iterate = function (iterable, unboundFunction, options) {
2116
- var that = options && options.that;
2117
- var AS_ENTRIES = !!(options && options.AS_ENTRIES);
2118
- var IS_ITERATOR = !!(options && options.IS_ITERATOR);
2119
- var INTERRUPTED = !!(options && options.INTERRUPTED);
2120
- var fn = functionBindContext(unboundFunction, that);
2121
- var iterator, iterFn, index, length, result, next, step;
2122
-
2123
- var stop = function (condition) {
2124
- if (iterator) iteratorClose(iterator, 'normal', condition);
2125
- return new Result(true, condition);
2126
- };
2127
-
2128
- var callFn = function (value) {
2129
- if (AS_ENTRIES) {
2130
- anObject(value);
2131
- return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
2132
- } return INTERRUPTED ? fn(value, stop) : fn(value);
2133
- };
2134
-
2135
- if (IS_ITERATOR) {
2136
- iterator = iterable;
2137
- } else {
2138
- iterFn = getIteratorMethod$4(iterable);
2139
- if (!iterFn) throw TypeError$2(tryToString(iterable) + ' is not iterable');
2140
- // optimisation for array iterators
2141
- if (isArrayIteratorMethod(iterFn)) {
2142
- for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
2143
- result = callFn(iterable[index]);
2144
- if (result && objectIsPrototypeOf(ResultPrototype, result)) return result;
2145
- } return new Result(false);
2146
- }
2147
- iterator = getIterator(iterable, iterFn);
2148
- }
2149
-
2150
- next = iterator.next;
2151
- while (!(step = functionCall(next, iterator)).done) {
2152
- try {
2153
- result = callFn(step.value);
2154
- } catch (error) {
2155
- iteratorClose(iterator, 'throw', error);
2156
- }
2157
- if (typeof result == 'object' && result && objectIsPrototypeOf(ResultPrototype, result)) return result;
2158
- } return new Result(false);
2159
- };
2160
-
2161
- var TypeError$1 = global_1.TypeError;
2162
-
2163
- var anInstance = function (it, Prototype) {
2164
- if (objectIsPrototypeOf(Prototype, it)) return it;
2165
- throw TypeError$1('Incorrect invocation');
2166
- };
2167
-
2168
- var defineProperty = objectDefineProperty.f;
2169
- var forEach = arrayIteration.forEach;
2170
-
2171
-
2172
-
2173
- var setInternalState$1 = internalState.set;
2174
- var internalStateGetterFor$1 = internalState.getterFor;
2175
-
2176
- var collection = function (CONSTRUCTOR_NAME, wrapper, common) {
2177
- var IS_MAP = CONSTRUCTOR_NAME.indexOf('Map') !== -1;
2178
- var IS_WEAK = CONSTRUCTOR_NAME.indexOf('Weak') !== -1;
2179
- var ADDER = IS_MAP ? 'set' : 'add';
2180
- var NativeConstructor = global_1[CONSTRUCTOR_NAME];
2181
- var NativePrototype = NativeConstructor && NativeConstructor.prototype;
2182
- var exported = {};
2183
- var Constructor;
2184
-
2185
- if (!descriptors || !isCallable(NativeConstructor)
2186
- || !(IS_WEAK || NativePrototype.forEach && !fails(function () { new NativeConstructor().entries().next(); }))
2187
- ) {
2188
- // create collection constructor
2189
- Constructor = common.getConstructor(wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER);
2190
- internalMetadata.enable();
2191
- } else {
2192
- Constructor = wrapper(function (target, iterable) {
2193
- setInternalState$1(anInstance(target, Prototype), {
2194
- type: CONSTRUCTOR_NAME,
2195
- collection: new NativeConstructor()
2196
- });
2197
- if (iterable != undefined) iterate(iterable, target[ADDER], { that: target, AS_ENTRIES: IS_MAP });
2198
- });
2199
-
2200
- var Prototype = Constructor.prototype;
2201
-
2202
- var getInternalState = internalStateGetterFor$1(CONSTRUCTOR_NAME);
2203
-
2204
- forEach(['add', 'clear', 'delete', 'forEach', 'get', 'has', 'set', 'keys', 'values', 'entries'], function (KEY) {
2205
- var IS_ADDER = KEY == 'add' || KEY == 'set';
2206
- if (KEY in NativePrototype && !(IS_WEAK && KEY == 'clear')) {
2207
- createNonEnumerableProperty(Prototype, KEY, function (a, b) {
2208
- var collection = getInternalState(this).collection;
2209
- if (!IS_ADDER && IS_WEAK && !isObject(a)) return KEY == 'get' ? undefined : false;
2210
- var result = collection[KEY](a === 0 ? 0 : a, b);
2211
- return IS_ADDER ? this : result;
2212
- });
2213
- }
2214
- });
2215
-
2216
- IS_WEAK || defineProperty(Prototype, 'size', {
2217
- configurable: true,
2218
- get: function () {
2219
- return getInternalState(this).collection.size;
2220
- }
2221
- });
2222
- }
2223
-
2224
- setToStringTag(Constructor, CONSTRUCTOR_NAME, false, true);
2225
-
2226
- exported[CONSTRUCTOR_NAME] = Constructor;
2227
- _export({ global: true, forced: true }, exported);
2228
-
2229
- if (!IS_WEAK) common.setStrong(Constructor, CONSTRUCTOR_NAME, IS_MAP);
2230
-
2231
- return Constructor;
2232
- };
2233
-
2234
- var getWeakData = internalMetadata.getWeakData;
2235
-
2236
-
2237
-
2238
-
2239
-
2240
-
2241
-
2242
-
2243
- var setInternalState = internalState.set;
2244
- var internalStateGetterFor = internalState.getterFor;
2245
- var find = arrayIteration.find;
2246
- var findIndex = arrayIteration.findIndex;
2247
- var splice = functionUncurryThis([].splice);
2248
- var id = 0;
2249
-
2250
- // fallback for uncaught frozen keys
2251
- var uncaughtFrozenStore = function (store) {
2252
- return store.frozen || (store.frozen = new UncaughtFrozenStore());
2253
- };
2254
-
2255
- var UncaughtFrozenStore = function () {
2256
- this.entries = [];
2257
- };
2258
-
2259
- var findUncaughtFrozen = function (store, key) {
2260
- return find(store.entries, function (it) {
2261
- return it[0] === key;
2262
- });
2263
- };
2264
-
2265
- UncaughtFrozenStore.prototype = {
2266
- get: function (key) {
2267
- var entry = findUncaughtFrozen(this, key);
2268
- if (entry) return entry[1];
2269
- },
2270
- has: function (key) {
2271
- return !!findUncaughtFrozen(this, key);
2272
- },
2273
- set: function (key, value) {
2274
- var entry = findUncaughtFrozen(this, key);
2275
- if (entry) entry[1] = value;
2276
- else this.entries.push([key, value]);
2277
- },
2278
- 'delete': function (key) {
2279
- var index = findIndex(this.entries, function (it) {
2280
- return it[0] === key;
2281
- });
2282
- if (~index) splice(this.entries, index, 1);
2283
- return !!~index;
2284
- }
2285
- };
2286
-
2287
- var collectionWeak = {
2288
- getConstructor: function (wrapper, CONSTRUCTOR_NAME, IS_MAP, ADDER) {
2289
- var Constructor = wrapper(function (that, iterable) {
2290
- anInstance(that, Prototype);
2291
- setInternalState(that, {
2292
- type: CONSTRUCTOR_NAME,
2293
- id: id++,
2294
- frozen: undefined
2295
- });
2296
- if (iterable != undefined) iterate(iterable, that[ADDER], { that: that, AS_ENTRIES: IS_MAP });
2297
- });
2298
-
2299
- var Prototype = Constructor.prototype;
2300
-
2301
- var getInternalState = internalStateGetterFor(CONSTRUCTOR_NAME);
2302
-
2303
- var define = function (that, key, value) {
2304
- var state = getInternalState(that);
2305
- var data = getWeakData(anObject(key), true);
2306
- if (data === true) uncaughtFrozenStore(state).set(key, value);
2307
- else data[state.id] = value;
2308
- return that;
2309
- };
2310
-
2311
- redefineAll(Prototype, {
2312
- // `{ WeakMap, WeakSet }.prototype.delete(key)` methods
2313
- // https://tc39.es/ecma262/#sec-weakmap.prototype.delete
2314
- // https://tc39.es/ecma262/#sec-weakset.prototype.delete
2315
- 'delete': function (key) {
2316
- var state = getInternalState(this);
2317
- if (!isObject(key)) return false;
2318
- var data = getWeakData(key);
2319
- if (data === true) return uncaughtFrozenStore(state)['delete'](key);
2320
- return data && hasOwnProperty_1(data, state.id) && delete data[state.id];
2321
- },
2322
- // `{ WeakMap, WeakSet }.prototype.has(key)` methods
2323
- // https://tc39.es/ecma262/#sec-weakmap.prototype.has
2324
- // https://tc39.es/ecma262/#sec-weakset.prototype.has
2325
- has: function has(key) {
2326
- var state = getInternalState(this);
2327
- if (!isObject(key)) return false;
2328
- var data = getWeakData(key);
2329
- if (data === true) return uncaughtFrozenStore(state).has(key);
2330
- return data && hasOwnProperty_1(data, state.id);
2331
- }
2332
- });
2333
-
2334
- redefineAll(Prototype, IS_MAP ? {
2335
- // `WeakMap.prototype.get(key)` method
2336
- // https://tc39.es/ecma262/#sec-weakmap.prototype.get
2337
- get: function get(key) {
2338
- var state = getInternalState(this);
2339
- if (isObject(key)) {
2340
- var data = getWeakData(key);
2341
- if (data === true) return uncaughtFrozenStore(state).get(key);
2342
- return data ? data[state.id] : undefined;
2343
- }
2344
- },
2345
- // `WeakMap.prototype.set(key, value)` method
2346
- // https://tc39.es/ecma262/#sec-weakmap.prototype.set
2347
- set: function set(key, value) {
2348
- return define(this, key, value);
2349
- }
2350
- } : {
2351
- // `WeakSet.prototype.add(value)` method
2352
- // https://tc39.es/ecma262/#sec-weakset.prototype.add
2353
- add: function add(value) {
2354
- return define(this, value, true);
2355
- }
2356
- });
2357
-
2358
- return Constructor;
2359
- }
2360
- };
2361
-
2362
- var enforceInternalState = internalState.enforce;
2363
-
2364
-
2365
- var IS_IE11 = !global_1.ActiveXObject && 'ActiveXObject' in global_1;
2366
- var InternalWeakMap;
2367
-
2368
- var wrapper = function (init) {
2369
- return function WeakMap() {
2370
- return init(this, arguments.length ? arguments[0] : undefined);
2371
- };
2372
- };
2373
-
2374
- // `WeakMap` constructor
2375
- // https://tc39.es/ecma262/#sec-weakmap-constructor
2376
- var $WeakMap = collection('WeakMap', wrapper, collectionWeak);
2377
-
2378
- // IE11 WeakMap frozen keys fix
2379
- // We can't use feature detection because it crash some old IE builds
2380
- // https://github.com/zloirock/core-js/issues/485
2381
- if (nativeWeakMap && IS_IE11) {
2382
- InternalWeakMap = collectionWeak.getConstructor(wrapper, 'WeakMap', true);
2383
- internalMetadata.enable();
2384
- var WeakMapPrototype = $WeakMap.prototype;
2385
- var nativeDelete = functionUncurryThis(WeakMapPrototype['delete']);
2386
- var nativeHas = functionUncurryThis(WeakMapPrototype.has);
2387
- var nativeGet = functionUncurryThis(WeakMapPrototype.get);
2388
- var nativeSet = functionUncurryThis(WeakMapPrototype.set);
2389
- redefineAll(WeakMapPrototype, {
2390
- 'delete': function (key) {
2391
- if (isObject(key) && !objectIsExtensible(key)) {
2392
- var state = enforceInternalState(this);
2393
- if (!state.frozen) state.frozen = new InternalWeakMap();
2394
- return nativeDelete(this, key) || state.frozen['delete'](key);
2395
- } return nativeDelete(this, key);
2396
- },
2397
- has: function has(key) {
2398
- if (isObject(key) && !objectIsExtensible(key)) {
2399
- var state = enforceInternalState(this);
2400
- if (!state.frozen) state.frozen = new InternalWeakMap();
2401
- return nativeHas(this, key) || state.frozen.has(key);
2402
- } return nativeHas(this, key);
2403
- },
2404
- get: function get(key) {
2405
- if (isObject(key) && !objectIsExtensible(key)) {
2406
- var state = enforceInternalState(this);
2407
- if (!state.frozen) state.frozen = new InternalWeakMap();
2408
- return nativeHas(this, key) ? nativeGet(this, key) : state.frozen.get(key);
2409
- } return nativeGet(this, key);
2410
- },
2411
- set: function set(key, value) {
2412
- if (isObject(key) && !objectIsExtensible(key)) {
2413
- var state = enforceInternalState(this);
2414
- if (!state.frozen) state.frozen = new InternalWeakMap();
2415
- nativeHas(this, key) ? nativeSet(this, key, value) : state.frozen.set(key, value);
2416
- } else nativeSet(this, key, value);
2417
- return this;
2418
- }
2419
- });
2420
- }
2421
-
2422
- var weakMap$2 = path.WeakMap;
2423
-
2424
- var weakMap$1 = weakMap$2;
2425
-
2426
- var weakMap = weakMap$1;
2427
-
2428
- function _interopRequireDefault(obj) {
2429
- return obj && obj.__esModule ? obj : {
2430
- "default": obj
2431
- };
2432
- }
2433
-
2434
- var ChevronLeft = createCommonjsModule(function (module, exports) {
2435
-
2436
-
2437
-
2438
-
2439
-
2440
-
2441
-
2442
-
2443
-
2444
-
2445
-
2446
- defineProperty$1(exports, "__esModule", {
2447
- value: true
2448
- });
2449
-
2450
- exports["default"] = void 0;
2451
-
2452
- var _extends2 = _interopRequireDefault(_extends$1);
2453
-
2454
- var React$1 = _interopRequireWildcard(React);
2455
-
2456
- function _getRequireWildcardCache(nodeInterop) { if (typeof weakMap !== "function") return null; var cacheBabelInterop = new weakMap(); var cacheNodeInterop = new weakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
2457
-
2458
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = defineProperty$1 && getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { defineProperty$1(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
2459
-
2460
- function SvgChevronLeft(props, svgRef) {
2461
- return /*#__PURE__*/React$1.createElement("svg", (0, _extends2["default"])({}, props, {
2462
- xmlns: "http://www.w3.org/2000/svg",
2463
- viewBox: "0 0 1024 1024",
2464
- fill: "currentColor",
2465
- className: "Icon ".concat(props.className ? props.className : ''),
2466
- ref: svgRef
2467
- }), /*#__PURE__*/React$1.createElement("path", {
2468
- d: "M199.5 480L762.8 10.5c21.3-17.1 51.2-12.8 64 8.5 17.1 25.6 12.8 55.5-8.5 68.3L306.1 514.1l516.4 426.8c21.3 17.1 25.6 42.7 8.5 64-17.1 21.3-42.7 25.6-64 8.5L199.5 556.8c-12.8-8.5-17.1-21.3-17.1-38.4 0-17.1 4.2-29.9 17.1-38.4z"
2469
- }));
2470
- }
2471
-
2472
- var ForwardRef = /*#__PURE__*/React$1.forwardRef(SvgChevronLeft);
2473
- var _default = ForwardRef;
2474
- exports["default"] = _default;
2475
- });
2476
-
2477
- unwrapExports(ChevronLeft);
2478
-
2479
- var chevronLeft = ChevronLeft;
2480
-
2481
- var ChevronRight = createCommonjsModule(function (module, exports) {
2482
-
2483
-
2484
-
2485
-
2486
-
2487
-
2488
-
2489
-
2490
-
2491
-
2492
-
2493
- defineProperty$1(exports, "__esModule", {
2494
- value: true
2495
- });
2496
-
2497
- exports["default"] = void 0;
2498
-
2499
- var _extends2 = _interopRequireDefault(_extends$1);
2500
-
2501
- var React$1 = _interopRequireWildcard(React);
2502
-
2503
- function _getRequireWildcardCache(nodeInterop) { if (typeof weakMap !== "function") return null; var cacheBabelInterop = new weakMap(); var cacheNodeInterop = new weakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
2504
-
2505
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = defineProperty$1 && getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { defineProperty$1(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
2506
-
2507
- function SvgChevronRight(props, svgRef) {
2508
- return /*#__PURE__*/React$1.createElement("svg", (0, _extends2["default"])({}, props, {
2509
- xmlns: "http://www.w3.org/2000/svg",
2510
- viewBox: "0 0 1024 1024",
2511
- fill: "currentColor",
2512
- className: "Icon ".concat(props.className ? props.className : ''),
2513
- ref: svgRef
2514
- }), /*#__PURE__*/React$1.createElement("path", {
2515
- d: "M841.6 518.4c0 17.1-4.3 29.9-17.1 38.4L257 1013.4c-21.3 17.1-46.9 12.8-64-8.5s-12.8-46.9 8.5-64l516.4-426.8L205.7 87.4c-21.3-12.8-25.6-42.7-8.5-68.3 12.8-21.3 42.7-25.6 64-8.5l563.3 469.5c12.9 8.5 17.1 21.3 17.1 38.3z"
2516
- }));
2517
- }
2518
-
2519
- var ForwardRef = /*#__PURE__*/React$1.forwardRef(SvgChevronRight);
2520
- var _default = ForwardRef;
2521
- exports["default"] = _default;
2522
- });
2523
-
2524
- unwrapExports(ChevronRight);
2525
-
2526
- var chevronRight = ChevronRight;
2527
-
2528
- var _excluded = ["images", "width", "height"];
2529
-
2530
- (function () {
2531
- var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
2532
- enterModule && enterModule(module);
2533
- })();
2534
-
2535
- var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
2536
- return a;
2537
- };
2538
-
2539
- var ImageCarousel = function ImageCarousel(_ref) {
2540
- var images = _ref.images,
2541
- width = _ref.width,
2542
- height = _ref.height,
2543
- props = _objectWithoutProperties(_ref, _excluded);
2544
-
2545
- var imgWidth = width ? "".concat(width, "rem") : '100%';
2546
- var imgHeight = "".concat(height, "rem");
2547
-
2548
- var _useEmblaCarousel = useEmblaCarousel({
2549
- skipSnaps: false,
2550
- loop: true
2551
- }),
2552
- _useEmblaCarousel2 = _slicedToArray(_useEmblaCarousel, 2),
2553
- viewportRef = _useEmblaCarousel2[0],
2554
- embla = _useEmblaCarousel2[1];
2555
-
2556
- var _useState = useState(0),
2557
- _useState2 = _slicedToArray(_useState, 2),
2558
- selectedIndex = _useState2[0],
2559
- setSelectedIndex = _useState2[1];
2560
-
2561
- var scrollPrev = useCallback(function () {
2562
- return embla && embla.scrollPrev();
2563
- }, [embla]);
2564
- var scrollNext = useCallback(function () {
2565
- return embla && embla.scrollNext();
2566
- }, [embla]);
2567
- var onSelect = useCallback(function () {
2568
- if (!embla) return;
2569
- setSelectedIndex(embla.selectedScrollSnap());
2570
- }, [embla, setSelectedIndex]);
2571
- useEffect(function () {
2572
- if (!embla) return;
2573
- onSelect();
2574
- embla.on('select', onSelect);
2575
- }, [embla, onSelect]);
2576
-
2577
- if (images.length === 1) {
2578
- var image = images[0];
2579
- return /*#__PURE__*/React.createElement(Box, _extends$1({
2580
- width: imgWidth,
2581
- height: imgHeight
2582
- }, props), /*#__PURE__*/React.createElement("img", {
2583
- style: {
2584
- width: '100%',
2585
- height: '100%',
2586
- objectFit: 'cover'
2587
- },
2588
- src: image.src,
2589
- alt: image.alt
2590
- }));
2591
- }
2592
-
2593
- return /*#__PURE__*/React.createElement(Box, _extends$1({
2594
- as: "section",
2595
- position: "relative",
2596
- overflow: "hidden",
2597
- width: imgWidth
2598
- }, props), /*#__PURE__*/React.createElement(Box, {
2599
- ref: viewportRef
2600
- }, /*#__PURE__*/React.createElement(Box, {
2601
- display: "flex",
2602
- role: "group"
2603
- }, map$1(images).call(images, function (image, index) {
2604
- var _context;
2605
-
2606
- return /*#__PURE__*/React.createElement(Box, {
2607
- position: "relative",
2608
- flex: "0 0 100%",
2609
- key: index,
2610
- "aria-label": concat(_context = "Slide ".concat(index + 1, " of ")).call(_context, images.length)
2611
- }, /*#__PURE__*/React.createElement(Box, {
2612
- position: "relative",
2613
- height: imgHeight
2614
- }, /*#__PURE__*/React.createElement("img", {
2615
- style: {
2616
- width: '100%',
2617
- height: '100%',
2618
- objectFit: 'cover'
2619
- },
2620
- src: image.src,
2621
- alt: image.alt
2622
- })));
2623
- }))), /*#__PURE__*/React.createElement(_default$1, {
2624
- onClick: scrollPrev,
2625
- width: "16",
2626
- height: "100%",
2627
- position: "absolute",
2628
- left: "0",
2629
- top: "0",
2630
- bg: "none",
2631
- borderRadius: "0",
2632
- border: "0",
2633
- _hover: {
2634
- bg: 'none',
2635
- border: 0
2636
- },
2637
- _focus: {
2638
- boxShadow: 'none'
2639
- },
2640
- padding: "3"
2641
- }, /*#__PURE__*/React.createElement(Box, {
2642
- width: "100%",
2643
- padding: "3",
2644
- borderRadius: "50%",
2645
- bgColor: "black",
2646
- opacity: "0.6"
2647
- }, /*#__PURE__*/React.createElement(chevronLeft, null))), /*#__PURE__*/React.createElement(_default$1, {
2648
- onClick: scrollNext,
2649
- width: "16",
2650
- height: "100%",
2651
- position: "absolute",
2652
- right: "0",
2653
- top: "0",
2654
- bg: "none",
2655
- borderRadius: "0",
2656
- border: "0",
2657
- _hover: {
2658
- bg: 'none',
2659
- border: 0
2660
- },
2661
- _focus: {
2662
- boxShadow: 'none'
2663
- },
2664
- padding: "3"
2665
- }, /*#__PURE__*/React.createElement(Box, {
2666
- width: "100%",
2667
- padding: "3",
2668
- borderRadius: "50%",
2669
- bgColor: "black",
2670
- opacity: "0.6"
2671
- }, /*#__PURE__*/React.createElement(chevronRight, null))), /*#__PURE__*/React.createElement(Box, {
2672
- color: "white",
2673
- borderRadius: "1rem",
2674
- bgColor: "black",
2675
- opacity: "0.6",
2676
- paddingX: 3,
2677
- paddingY: 1,
2678
- fontSize: "xs",
2679
- position: "absolute",
2680
- bottom: 3,
2681
- left: "50%",
2682
- transform: "translateX(-50%)"
2683
- }, selectedIndex + 1, "/", images.length));
2684
- };
2685
-
2686
- __signature__(ImageCarousel, "useEmblaCarousel{[viewportRef, embla]}\nuseState{[selectedIndex, setSelectedIndex](0)}\nuseCallback{scrollPrev}\nuseCallback{scrollNext}\nuseCallback{onSelect}\nuseEffect{}", function () {
2687
- return [useEmblaCarousel];
2688
- });
2689
-
2690
- ImageCarousel.propTypes = {
2691
- /** Array of images with src and alt */
2692
- images: PropTypes.arrayOf(PropTypes.shape({
2693
- src: PropTypes.string.isRequired,
2694
- alt: PropTypes.string.isRequired
2695
- })).isRequired,
2696
-
2697
- /** Height of the carousel in rem */
2698
- height: PropTypes.number.isRequired,
2699
-
2700
- /** Width of the carousel in rem */
2701
- width: PropTypes.number
2702
- };
2703
- var _default = ImageCarousel;
2704
-
2705
- (function () {
2706
- var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
2707
-
2708
- if (!reactHotLoader) {
2709
- return;
2710
- }
2711
-
2712
- reactHotLoader.register(ImageCarousel, "ImageCarousel", "/tmp/build/44cb8d9a/src/src/v2/components/ImageCarousel/ImageCarousel.jsx");
2713
- reactHotLoader.register(_default, "default", "/tmp/build/44cb8d9a/src/src/v2/components/ImageCarousel/ImageCarousel.jsx");
2714
- })();
2715
-
2716
- (function () {
2717
- var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
2718
- leaveModule && leaveModule(module);
2719
- })();
2720
-
2721
- export default _default;
2722
- //# sourceMappingURL=ImageCarousel-c8a3e563.js.map