@helpdice/ui 1.7.8 → 1.7.9

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 (65) hide show
  1. package/dist/breadcrumbs/index.js +10 -7
  2. package/dist/card/index.js +10 -7
  3. package/dist/carousal/CSSTranslate.d.ts +2 -0
  4. package/dist/carousal/component/Arrow.d.ts +9 -0
  5. package/dist/carousal/component/Indicator.d.ts +9 -0
  6. package/dist/carousal/component/Thumbs.d.ts +65 -0
  7. package/dist/carousal/component/animations.d.ts +27 -0
  8. package/dist/carousal/component/index.d.ts +87 -0
  9. package/dist/carousal/component/types.d.ts +79 -0
  10. package/dist/carousal/component/utils.d.ts +15 -0
  11. package/dist/carousal/cssClasses.d.ts +11 -0
  12. package/dist/carousal/dimensions.d.ts +1 -0
  13. package/dist/carousal/index.d.ts +3 -0
  14. package/dist/carousal/index.js +13166 -0
  15. package/dist/carousal/shims/document.d.ts +2 -0
  16. package/dist/carousal/shims/window.d.ts +2 -0
  17. package/dist/image/index.js +10 -7
  18. package/dist/index.d.ts +4 -0
  19. package/dist/index.js +2794 -197
  20. package/dist/link/index.js +10 -7
  21. package/dist/link/link.d.ts +2 -1
  22. package/dist/swipe/index.d.ts +4 -0
  23. package/dist/swipe/index.js +1314 -0
  24. package/dist/swipe/react-swipe.d.ts +58 -0
  25. package/dist/user/index.js +10 -7
  26. package/esm/carousal/CSSTranslate.d.ts +2 -0
  27. package/esm/carousal/CSSTranslate.js +7 -0
  28. package/esm/carousal/component/Arrow.d.ts +9 -0
  29. package/esm/carousal/component/Arrow.js +21 -0
  30. package/esm/carousal/component/Indicator.d.ts +9 -0
  31. package/esm/carousal/component/Indicator.js +23 -0
  32. package/esm/carousal/component/Thumbs.d.ts +65 -0
  33. package/esm/carousal/{Thumbs.js → component/Thumbs.js} +41 -12
  34. package/esm/carousal/component/animations.d.ts +27 -0
  35. package/esm/carousal/{animations.js → component/animations.js} +1 -1
  36. package/esm/carousal/component/index.d.ts +87 -0
  37. package/esm/carousal/component/index.js +698 -0
  38. package/esm/carousal/component/types.d.ts +79 -0
  39. package/esm/carousal/component/utils.d.ts +15 -0
  40. package/esm/carousal/{utils.js → component/utils.js} +1 -1
  41. package/esm/carousal/cssClasses.d.ts +11 -0
  42. package/esm/carousal/cssClasses.js +56 -0
  43. package/esm/carousal/dimensions.d.ts +1 -0
  44. package/esm/carousal/dimensions.js +6 -0
  45. package/esm/carousal/index.d.ts +3 -0
  46. package/esm/carousal/index.js +2 -683
  47. package/esm/carousal/main.js +59 -0
  48. package/esm/carousal/shims/document.d.ts +2 -0
  49. package/esm/carousal/shims/document.js +3 -0
  50. package/esm/carousal/shims/window.d.ts +2 -0
  51. package/esm/carousal/shims/window.js +3 -0
  52. package/esm/index.d.ts +4 -0
  53. package/esm/index.js +6 -1
  54. package/esm/link/link.d.ts +2 -1
  55. package/esm/link/link.js +10 -7
  56. package/esm/login-with/index.js +0 -2
  57. package/esm/swipe/demo.js +57 -0
  58. package/esm/swipe/index.d.ts +4 -0
  59. package/esm/swipe/index.js +2 -0
  60. package/esm/swipe/react-swipe.d.ts +58 -0
  61. package/esm/swipe/react-swipe.js +246 -0
  62. package/package.json +4 -3
  63. package/esm/carousal/Arrow.js +0 -18
  64. package/esm/carousal/Indicator.js +0 -20
  65. /package/esm/carousal/{types.js → component/types.js} +0 -0
@@ -0,0 +1,1314 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var require$$0 = require('react-is');
7
+
8
+ function _assertThisInitialized(e) {
9
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
10
+ return e;
11
+ }
12
+ function _callSuper(t, o, e) {
13
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
14
+ }
15
+ function _classCallCheck(a, n) {
16
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
17
+ }
18
+ function _defineProperties(e, r) {
19
+ for (var t = 0; t < r.length; t++) {
20
+ var o = r[t];
21
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
22
+ }
23
+ }
24
+ function _createClass(e, r, t) {
25
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
26
+ writable: false
27
+ }), e;
28
+ }
29
+ function _defineProperty(e, r, t) {
30
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
31
+ value: t,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ }) : e[r] = t, e;
36
+ }
37
+ function _extends() {
38
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
39
+ for (var e = 1; e < arguments.length; e++) {
40
+ var t = arguments[e];
41
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
42
+ }
43
+ return n;
44
+ }, _extends.apply(null, arguments);
45
+ }
46
+ function _getPrototypeOf(t) {
47
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
48
+ return t.__proto__ || Object.getPrototypeOf(t);
49
+ }, _getPrototypeOf(t);
50
+ }
51
+ function _inherits(t, e) {
52
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
53
+ t.prototype = Object.create(e && e.prototype, {
54
+ constructor: {
55
+ value: t,
56
+ writable: true,
57
+ configurable: true
58
+ }
59
+ }), Object.defineProperty(t, "prototype", {
60
+ writable: false
61
+ }), e && _setPrototypeOf(t, e);
62
+ }
63
+ function _isNativeReflectConstruct() {
64
+ try {
65
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
66
+ } catch (t) {}
67
+ return (_isNativeReflectConstruct = function () {
68
+ return !!t;
69
+ })();
70
+ }
71
+ function _objectWithoutProperties(e, t) {
72
+ if (null == e) return {};
73
+ var o,
74
+ r,
75
+ i = _objectWithoutPropertiesLoose(e, t);
76
+ if (Object.getOwnPropertySymbols) {
77
+ var n = Object.getOwnPropertySymbols(e);
78
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
79
+ }
80
+ return i;
81
+ }
82
+ function _objectWithoutPropertiesLoose(r, e) {
83
+ if (null == r) return {};
84
+ var t = {};
85
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
86
+ if (-1 !== e.indexOf(n)) continue;
87
+ t[n] = r[n];
88
+ }
89
+ return t;
90
+ }
91
+ function _possibleConstructorReturn(t, e) {
92
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
93
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
94
+ return _assertThisInitialized(t);
95
+ }
96
+ function _setPrototypeOf(t, e) {
97
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
98
+ return t.__proto__ = e, t;
99
+ }, _setPrototypeOf(t, e);
100
+ }
101
+ function _toPrimitive(t, r) {
102
+ if ("object" != typeof t || !t) return t;
103
+ var e = t[Symbol.toPrimitive];
104
+ if (void 0 !== e) {
105
+ var i = e.call(t, r);
106
+ if ("object" != typeof i) return i;
107
+ throw new TypeError("@@toPrimitive must return a primitive value.");
108
+ }
109
+ return (String )(t);
110
+ }
111
+ function _toPropertyKey(t) {
112
+ var i = _toPrimitive(t, "string");
113
+ return "symbol" == typeof i ? i : i + "";
114
+ }
115
+
116
+ function getDefaultExportFromCjs (x) {
117
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
118
+ }
119
+
120
+ var propTypes = {exports: {}};
121
+
122
+ /*
123
+ object-assign
124
+ (c) Sindre Sorhus
125
+ @license MIT
126
+ */
127
+
128
+ var objectAssign;
129
+ var hasRequiredObjectAssign;
130
+
131
+ function requireObjectAssign () {
132
+ if (hasRequiredObjectAssign) return objectAssign;
133
+ hasRequiredObjectAssign = 1;
134
+ /* eslint-disable no-unused-vars */
135
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
136
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
137
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
138
+
139
+ function toObject(val) {
140
+ if (val === null || val === undefined) {
141
+ throw new TypeError('Object.assign cannot be called with null or undefined');
142
+ }
143
+
144
+ return Object(val);
145
+ }
146
+
147
+ function shouldUseNative() {
148
+ try {
149
+ if (!Object.assign) {
150
+ return false;
151
+ }
152
+
153
+ // Detect buggy property enumeration order in older V8 versions.
154
+
155
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
156
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
157
+ test1[5] = 'de';
158
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
159
+ return false;
160
+ }
161
+
162
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
163
+ var test2 = {};
164
+ for (var i = 0; i < 10; i++) {
165
+ test2['_' + String.fromCharCode(i)] = i;
166
+ }
167
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
168
+ return test2[n];
169
+ });
170
+ if (order2.join('') !== '0123456789') {
171
+ return false;
172
+ }
173
+
174
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
175
+ var test3 = {};
176
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
177
+ test3[letter] = letter;
178
+ });
179
+ if (Object.keys(Object.assign({}, test3)).join('') !==
180
+ 'abcdefghijklmnopqrst') {
181
+ return false;
182
+ }
183
+
184
+ return true;
185
+ } catch (err) {
186
+ // We don't expect any of the above to throw, but better to be safe.
187
+ return false;
188
+ }
189
+ }
190
+
191
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
192
+ var from;
193
+ var to = toObject(target);
194
+ var symbols;
195
+
196
+ for (var s = 1; s < arguments.length; s++) {
197
+ from = Object(arguments[s]);
198
+
199
+ for (var key in from) {
200
+ if (hasOwnProperty.call(from, key)) {
201
+ to[key] = from[key];
202
+ }
203
+ }
204
+
205
+ if (getOwnPropertySymbols) {
206
+ symbols = getOwnPropertySymbols(from);
207
+ for (var i = 0; i < symbols.length; i++) {
208
+ if (propIsEnumerable.call(from, symbols[i])) {
209
+ to[symbols[i]] = from[symbols[i]];
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ return to;
216
+ };
217
+ return objectAssign;
218
+ }
219
+
220
+ /**
221
+ * Copyright (c) 2013-present, Facebook, Inc.
222
+ *
223
+ * This source code is licensed under the MIT license found in the
224
+ * LICENSE file in the root directory of this source tree.
225
+ */
226
+
227
+ var ReactPropTypesSecret_1;
228
+ var hasRequiredReactPropTypesSecret;
229
+
230
+ function requireReactPropTypesSecret () {
231
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
232
+ hasRequiredReactPropTypesSecret = 1;
233
+
234
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
235
+
236
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
237
+ return ReactPropTypesSecret_1;
238
+ }
239
+
240
+ var has;
241
+ var hasRequiredHas;
242
+
243
+ function requireHas () {
244
+ if (hasRequiredHas) return has;
245
+ hasRequiredHas = 1;
246
+ has = Function.call.bind(Object.prototype.hasOwnProperty);
247
+ return has;
248
+ }
249
+
250
+ /**
251
+ * Copyright (c) 2013-present, Facebook, Inc.
252
+ *
253
+ * This source code is licensed under the MIT license found in the
254
+ * LICENSE file in the root directory of this source tree.
255
+ */
256
+
257
+ var checkPropTypes_1;
258
+ var hasRequiredCheckPropTypes;
259
+
260
+ function requireCheckPropTypes () {
261
+ if (hasRequiredCheckPropTypes) return checkPropTypes_1;
262
+ hasRequiredCheckPropTypes = 1;
263
+
264
+ var printWarning = function() {};
265
+
266
+ if (process.env.NODE_ENV !== 'production') {
267
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
268
+ var loggedTypeFailures = {};
269
+ var has = /*@__PURE__*/ requireHas();
270
+
271
+ printWarning = function(text) {
272
+ var message = 'Warning: ' + text;
273
+ if (typeof console !== 'undefined') {
274
+ console.error(message);
275
+ }
276
+ try {
277
+ // --- Welcome to debugging React ---
278
+ // This error was thrown as a convenience so that you can use this stack
279
+ // to find the callsite that caused this warning to fire.
280
+ throw new Error(message);
281
+ } catch (x) { /**/ }
282
+ };
283
+ }
284
+
285
+ /**
286
+ * Assert that the values match with the type specs.
287
+ * Error messages are memorized and will only be shown once.
288
+ *
289
+ * @param {object} typeSpecs Map of name to a ReactPropType
290
+ * @param {object} values Runtime values that need to be type-checked
291
+ * @param {string} location e.g. "prop", "context", "child context"
292
+ * @param {string} componentName Name of the component for error messages.
293
+ * @param {?Function} getStack Returns the component stack.
294
+ * @private
295
+ */
296
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
297
+ if (process.env.NODE_ENV !== 'production') {
298
+ for (var typeSpecName in typeSpecs) {
299
+ if (has(typeSpecs, typeSpecName)) {
300
+ var error;
301
+ // Prop type validation may throw. In case they do, we don't want to
302
+ // fail the render phase where it didn't fail before. So we log it.
303
+ // After these have been cleaned up, we'll let them throw.
304
+ try {
305
+ // This is intentionally an invariant that gets caught. It's the same
306
+ // behavior as without this statement except with a better message.
307
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
308
+ var err = Error(
309
+ (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
310
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
311
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
312
+ );
313
+ err.name = 'Invariant Violation';
314
+ throw err;
315
+ }
316
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
317
+ } catch (ex) {
318
+ error = ex;
319
+ }
320
+ if (error && !(error instanceof Error)) {
321
+ printWarning(
322
+ (componentName || 'React class') + ': type specification of ' +
323
+ location + ' `' + typeSpecName + '` is invalid; the type checker ' +
324
+ 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
325
+ 'You may have forgotten to pass an argument to the type checker ' +
326
+ 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
327
+ 'shape all require an argument).'
328
+ );
329
+ }
330
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
331
+ // Only monitor this failure once because there tends to be a lot of the
332
+ // same error.
333
+ loggedTypeFailures[error.message] = true;
334
+
335
+ var stack = getStack ? getStack() : '';
336
+
337
+ printWarning(
338
+ 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
339
+ );
340
+ }
341
+ }
342
+ }
343
+ }
344
+ }
345
+
346
+ /**
347
+ * Resets warning cache when testing.
348
+ *
349
+ * @private
350
+ */
351
+ checkPropTypes.resetWarningCache = function() {
352
+ if (process.env.NODE_ENV !== 'production') {
353
+ loggedTypeFailures = {};
354
+ }
355
+ };
356
+
357
+ checkPropTypes_1 = checkPropTypes;
358
+ return checkPropTypes_1;
359
+ }
360
+
361
+ /**
362
+ * Copyright (c) 2013-present, Facebook, Inc.
363
+ *
364
+ * This source code is licensed under the MIT license found in the
365
+ * LICENSE file in the root directory of this source tree.
366
+ */
367
+
368
+ var factoryWithTypeCheckers;
369
+ var hasRequiredFactoryWithTypeCheckers;
370
+
371
+ function requireFactoryWithTypeCheckers () {
372
+ if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
373
+ hasRequiredFactoryWithTypeCheckers = 1;
374
+
375
+ var ReactIs = require$$0;
376
+ var assign = requireObjectAssign();
377
+
378
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
379
+ var has = /*@__PURE__*/ requireHas();
380
+ var checkPropTypes = /*@__PURE__*/ requireCheckPropTypes();
381
+
382
+ var printWarning = function() {};
383
+
384
+ if (process.env.NODE_ENV !== 'production') {
385
+ printWarning = function(text) {
386
+ var message = 'Warning: ' + text;
387
+ if (typeof console !== 'undefined') {
388
+ console.error(message);
389
+ }
390
+ try {
391
+ // --- Welcome to debugging React ---
392
+ // This error was thrown as a convenience so that you can use this stack
393
+ // to find the callsite that caused this warning to fire.
394
+ throw new Error(message);
395
+ } catch (x) {}
396
+ };
397
+ }
398
+
399
+ function emptyFunctionThatReturnsNull() {
400
+ return null;
401
+ }
402
+
403
+ factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
404
+ /* global Symbol */
405
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
406
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
407
+
408
+ /**
409
+ * Returns the iterator method function contained on the iterable object.
410
+ *
411
+ * Be sure to invoke the function with the iterable as context:
412
+ *
413
+ * var iteratorFn = getIteratorFn(myIterable);
414
+ * if (iteratorFn) {
415
+ * var iterator = iteratorFn.call(myIterable);
416
+ * ...
417
+ * }
418
+ *
419
+ * @param {?object} maybeIterable
420
+ * @return {?function}
421
+ */
422
+ function getIteratorFn(maybeIterable) {
423
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
424
+ if (typeof iteratorFn === 'function') {
425
+ return iteratorFn;
426
+ }
427
+ }
428
+
429
+ /**
430
+ * Collection of methods that allow declaration and validation of props that are
431
+ * supplied to React components. Example usage:
432
+ *
433
+ * var Props = require('ReactPropTypes');
434
+ * var MyArticle = React.createClass({
435
+ * propTypes: {
436
+ * // An optional string prop named "description".
437
+ * description: Props.string,
438
+ *
439
+ * // A required enum prop named "category".
440
+ * category: Props.oneOf(['News','Photos']).isRequired,
441
+ *
442
+ * // A prop named "dialog" that requires an instance of Dialog.
443
+ * dialog: Props.instanceOf(Dialog).isRequired
444
+ * },
445
+ * render: function() { ... }
446
+ * });
447
+ *
448
+ * A more formal specification of how these methods are used:
449
+ *
450
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
451
+ * decl := ReactPropTypes.{type}(.isRequired)?
452
+ *
453
+ * Each and every declaration produces a function with the same signature. This
454
+ * allows the creation of custom validation functions. For example:
455
+ *
456
+ * var MyLink = React.createClass({
457
+ * propTypes: {
458
+ * // An optional string or URI prop named "href".
459
+ * href: function(props, propName, componentName) {
460
+ * var propValue = props[propName];
461
+ * if (propValue != null && typeof propValue !== 'string' &&
462
+ * !(propValue instanceof URI)) {
463
+ * return new Error(
464
+ * 'Expected a string or an URI for ' + propName + ' in ' +
465
+ * componentName
466
+ * );
467
+ * }
468
+ * }
469
+ * },
470
+ * render: function() {...}
471
+ * });
472
+ *
473
+ * @internal
474
+ */
475
+
476
+ var ANONYMOUS = '<<anonymous>>';
477
+
478
+ // Important!
479
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
480
+ var ReactPropTypes = {
481
+ array: createPrimitiveTypeChecker('array'),
482
+ bigint: createPrimitiveTypeChecker('bigint'),
483
+ bool: createPrimitiveTypeChecker('boolean'),
484
+ func: createPrimitiveTypeChecker('function'),
485
+ number: createPrimitiveTypeChecker('number'),
486
+ object: createPrimitiveTypeChecker('object'),
487
+ string: createPrimitiveTypeChecker('string'),
488
+ symbol: createPrimitiveTypeChecker('symbol'),
489
+
490
+ any: createAnyTypeChecker(),
491
+ arrayOf: createArrayOfTypeChecker,
492
+ element: createElementTypeChecker(),
493
+ elementType: createElementTypeTypeChecker(),
494
+ instanceOf: createInstanceTypeChecker,
495
+ node: createNodeChecker(),
496
+ objectOf: createObjectOfTypeChecker,
497
+ oneOf: createEnumTypeChecker,
498
+ oneOfType: createUnionTypeChecker,
499
+ shape: createShapeTypeChecker,
500
+ exact: createStrictShapeTypeChecker,
501
+ };
502
+
503
+ /**
504
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
505
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
506
+ */
507
+ /*eslint-disable no-self-compare*/
508
+ function is(x, y) {
509
+ // SameValue algorithm
510
+ if (x === y) {
511
+ // Steps 1-5, 7-10
512
+ // Steps 6.b-6.e: +0 != -0
513
+ return x !== 0 || 1 / x === 1 / y;
514
+ } else {
515
+ // Step 6.a: NaN == NaN
516
+ return x !== x && y !== y;
517
+ }
518
+ }
519
+ /*eslint-enable no-self-compare*/
520
+
521
+ /**
522
+ * We use an Error-like object for backward compatibility as people may call
523
+ * PropTypes directly and inspect their output. However, we don't use real
524
+ * Errors anymore. We don't inspect their stack anyway, and creating them
525
+ * is prohibitively expensive if they are created too often, such as what
526
+ * happens in oneOfType() for any type before the one that matched.
527
+ */
528
+ function PropTypeError(message, data) {
529
+ this.message = message;
530
+ this.data = data && typeof data === 'object' ? data: {};
531
+ this.stack = '';
532
+ }
533
+ // Make `instanceof Error` still work for returned errors.
534
+ PropTypeError.prototype = Error.prototype;
535
+
536
+ function createChainableTypeChecker(validate) {
537
+ if (process.env.NODE_ENV !== 'production') {
538
+ var manualPropTypeCallCache = {};
539
+ var manualPropTypeWarningCount = 0;
540
+ }
541
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
542
+ componentName = componentName || ANONYMOUS;
543
+ propFullName = propFullName || propName;
544
+
545
+ if (secret !== ReactPropTypesSecret) {
546
+ if (throwOnDirectAccess) {
547
+ // New behavior only for users of `prop-types` package
548
+ var err = new Error(
549
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
550
+ 'Use `PropTypes.checkPropTypes()` to call them. ' +
551
+ 'Read more at http://fb.me/use-check-prop-types'
552
+ );
553
+ err.name = 'Invariant Violation';
554
+ throw err;
555
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
556
+ // Old behavior for people using React.PropTypes
557
+ var cacheKey = componentName + ':' + propName;
558
+ if (
559
+ !manualPropTypeCallCache[cacheKey] &&
560
+ // Avoid spamming the console because they are often not actionable except for lib authors
561
+ manualPropTypeWarningCount < 3
562
+ ) {
563
+ printWarning(
564
+ 'You are manually calling a React.PropTypes validation ' +
565
+ 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
566
+ 'and will throw in the standalone `prop-types` package. ' +
567
+ 'You may be seeing this warning due to a third-party PropTypes ' +
568
+ 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
569
+ );
570
+ manualPropTypeCallCache[cacheKey] = true;
571
+ manualPropTypeWarningCount++;
572
+ }
573
+ }
574
+ }
575
+ if (props[propName] == null) {
576
+ if (isRequired) {
577
+ if (props[propName] === null) {
578
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
579
+ }
580
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
581
+ }
582
+ return null;
583
+ } else {
584
+ return validate(props, propName, componentName, location, propFullName);
585
+ }
586
+ }
587
+
588
+ var chainedCheckType = checkType.bind(null, false);
589
+ chainedCheckType.isRequired = checkType.bind(null, true);
590
+
591
+ return chainedCheckType;
592
+ }
593
+
594
+ function createPrimitiveTypeChecker(expectedType) {
595
+ function validate(props, propName, componentName, location, propFullName, secret) {
596
+ var propValue = props[propName];
597
+ var propType = getPropType(propValue);
598
+ if (propType !== expectedType) {
599
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
600
+ // check, but we can offer a more precise error message here rather than
601
+ // 'of type `object`'.
602
+ var preciseType = getPreciseType(propValue);
603
+
604
+ return new PropTypeError(
605
+ 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
606
+ {expectedType: expectedType}
607
+ );
608
+ }
609
+ return null;
610
+ }
611
+ return createChainableTypeChecker(validate);
612
+ }
613
+
614
+ function createAnyTypeChecker() {
615
+ return createChainableTypeChecker(emptyFunctionThatReturnsNull);
616
+ }
617
+
618
+ function createArrayOfTypeChecker(typeChecker) {
619
+ function validate(props, propName, componentName, location, propFullName) {
620
+ if (typeof typeChecker !== 'function') {
621
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
622
+ }
623
+ var propValue = props[propName];
624
+ if (!Array.isArray(propValue)) {
625
+ var propType = getPropType(propValue);
626
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
627
+ }
628
+ for (var i = 0; i < propValue.length; i++) {
629
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
630
+ if (error instanceof Error) {
631
+ return error;
632
+ }
633
+ }
634
+ return null;
635
+ }
636
+ return createChainableTypeChecker(validate);
637
+ }
638
+
639
+ function createElementTypeChecker() {
640
+ function validate(props, propName, componentName, location, propFullName) {
641
+ var propValue = props[propName];
642
+ if (!isValidElement(propValue)) {
643
+ var propType = getPropType(propValue);
644
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
645
+ }
646
+ return null;
647
+ }
648
+ return createChainableTypeChecker(validate);
649
+ }
650
+
651
+ function createElementTypeTypeChecker() {
652
+ function validate(props, propName, componentName, location, propFullName) {
653
+ var propValue = props[propName];
654
+ if (!ReactIs.isValidElementType(propValue)) {
655
+ var propType = getPropType(propValue);
656
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
657
+ }
658
+ return null;
659
+ }
660
+ return createChainableTypeChecker(validate);
661
+ }
662
+
663
+ function createInstanceTypeChecker(expectedClass) {
664
+ function validate(props, propName, componentName, location, propFullName) {
665
+ if (!(props[propName] instanceof expectedClass)) {
666
+ var expectedClassName = expectedClass.name || ANONYMOUS;
667
+ var actualClassName = getClassName(props[propName]);
668
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
669
+ }
670
+ return null;
671
+ }
672
+ return createChainableTypeChecker(validate);
673
+ }
674
+
675
+ function createEnumTypeChecker(expectedValues) {
676
+ if (!Array.isArray(expectedValues)) {
677
+ if (process.env.NODE_ENV !== 'production') {
678
+ if (arguments.length > 1) {
679
+ printWarning(
680
+ 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
681
+ 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
682
+ );
683
+ } else {
684
+ printWarning('Invalid argument supplied to oneOf, expected an array.');
685
+ }
686
+ }
687
+ return emptyFunctionThatReturnsNull;
688
+ }
689
+
690
+ function validate(props, propName, componentName, location, propFullName) {
691
+ var propValue = props[propName];
692
+ for (var i = 0; i < expectedValues.length; i++) {
693
+ if (is(propValue, expectedValues[i])) {
694
+ return null;
695
+ }
696
+ }
697
+
698
+ var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
699
+ var type = getPreciseType(value);
700
+ if (type === 'symbol') {
701
+ return String(value);
702
+ }
703
+ return value;
704
+ });
705
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
706
+ }
707
+ return createChainableTypeChecker(validate);
708
+ }
709
+
710
+ function createObjectOfTypeChecker(typeChecker) {
711
+ function validate(props, propName, componentName, location, propFullName) {
712
+ if (typeof typeChecker !== 'function') {
713
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
714
+ }
715
+ var propValue = props[propName];
716
+ var propType = getPropType(propValue);
717
+ if (propType !== 'object') {
718
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
719
+ }
720
+ for (var key in propValue) {
721
+ if (has(propValue, key)) {
722
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
723
+ if (error instanceof Error) {
724
+ return error;
725
+ }
726
+ }
727
+ }
728
+ return null;
729
+ }
730
+ return createChainableTypeChecker(validate);
731
+ }
732
+
733
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
734
+ if (!Array.isArray(arrayOfTypeCheckers)) {
735
+ process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
736
+ return emptyFunctionThatReturnsNull;
737
+ }
738
+
739
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
740
+ var checker = arrayOfTypeCheckers[i];
741
+ if (typeof checker !== 'function') {
742
+ printWarning(
743
+ 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
744
+ 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
745
+ );
746
+ return emptyFunctionThatReturnsNull;
747
+ }
748
+ }
749
+
750
+ function validate(props, propName, componentName, location, propFullName) {
751
+ var expectedTypes = [];
752
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
753
+ var checker = arrayOfTypeCheckers[i];
754
+ var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
755
+ if (checkerResult == null) {
756
+ return null;
757
+ }
758
+ if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
759
+ expectedTypes.push(checkerResult.data.expectedType);
760
+ }
761
+ }
762
+ var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
763
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
764
+ }
765
+ return createChainableTypeChecker(validate);
766
+ }
767
+
768
+ function createNodeChecker() {
769
+ function validate(props, propName, componentName, location, propFullName) {
770
+ if (!isNode(props[propName])) {
771
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
772
+ }
773
+ return null;
774
+ }
775
+ return createChainableTypeChecker(validate);
776
+ }
777
+
778
+ function invalidValidatorError(componentName, location, propFullName, key, type) {
779
+ return new PropTypeError(
780
+ (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
781
+ 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
782
+ );
783
+ }
784
+
785
+ function createShapeTypeChecker(shapeTypes) {
786
+ function validate(props, propName, componentName, location, propFullName) {
787
+ var propValue = props[propName];
788
+ var propType = getPropType(propValue);
789
+ if (propType !== 'object') {
790
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
791
+ }
792
+ for (var key in shapeTypes) {
793
+ var checker = shapeTypes[key];
794
+ if (typeof checker !== 'function') {
795
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
796
+ }
797
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
798
+ if (error) {
799
+ return error;
800
+ }
801
+ }
802
+ return null;
803
+ }
804
+ return createChainableTypeChecker(validate);
805
+ }
806
+
807
+ function createStrictShapeTypeChecker(shapeTypes) {
808
+ function validate(props, propName, componentName, location, propFullName) {
809
+ var propValue = props[propName];
810
+ var propType = getPropType(propValue);
811
+ if (propType !== 'object') {
812
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
813
+ }
814
+ // We need to check all keys in case some are required but missing from props.
815
+ var allKeys = assign({}, props[propName], shapeTypes);
816
+ for (var key in allKeys) {
817
+ var checker = shapeTypes[key];
818
+ if (has(shapeTypes, key) && typeof checker !== 'function') {
819
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
820
+ }
821
+ if (!checker) {
822
+ return new PropTypeError(
823
+ 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
824
+ '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
825
+ '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
826
+ );
827
+ }
828
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
829
+ if (error) {
830
+ return error;
831
+ }
832
+ }
833
+ return null;
834
+ }
835
+
836
+ return createChainableTypeChecker(validate);
837
+ }
838
+
839
+ function isNode(propValue) {
840
+ switch (typeof propValue) {
841
+ case 'number':
842
+ case 'string':
843
+ case 'undefined':
844
+ return true;
845
+ case 'boolean':
846
+ return !propValue;
847
+ case 'object':
848
+ if (Array.isArray(propValue)) {
849
+ return propValue.every(isNode);
850
+ }
851
+ if (propValue === null || isValidElement(propValue)) {
852
+ return true;
853
+ }
854
+
855
+ var iteratorFn = getIteratorFn(propValue);
856
+ if (iteratorFn) {
857
+ var iterator = iteratorFn.call(propValue);
858
+ var step;
859
+ if (iteratorFn !== propValue.entries) {
860
+ while (!(step = iterator.next()).done) {
861
+ if (!isNode(step.value)) {
862
+ return false;
863
+ }
864
+ }
865
+ } else {
866
+ // Iterator will provide entry [k,v] tuples rather than values.
867
+ while (!(step = iterator.next()).done) {
868
+ var entry = step.value;
869
+ if (entry) {
870
+ if (!isNode(entry[1])) {
871
+ return false;
872
+ }
873
+ }
874
+ }
875
+ }
876
+ } else {
877
+ return false;
878
+ }
879
+
880
+ return true;
881
+ default:
882
+ return false;
883
+ }
884
+ }
885
+
886
+ function isSymbol(propType, propValue) {
887
+ // Native Symbol.
888
+ if (propType === 'symbol') {
889
+ return true;
890
+ }
891
+
892
+ // falsy value can't be a Symbol
893
+ if (!propValue) {
894
+ return false;
895
+ }
896
+
897
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
898
+ if (propValue['@@toStringTag'] === 'Symbol') {
899
+ return true;
900
+ }
901
+
902
+ // Fallback for non-spec compliant Symbols which are polyfilled.
903
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
904
+ return true;
905
+ }
906
+
907
+ return false;
908
+ }
909
+
910
+ // Equivalent of `typeof` but with special handling for array and regexp.
911
+ function getPropType(propValue) {
912
+ var propType = typeof propValue;
913
+ if (Array.isArray(propValue)) {
914
+ return 'array';
915
+ }
916
+ if (propValue instanceof RegExp) {
917
+ // Old webkits (at least until Android 4.0) return 'function' rather than
918
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
919
+ // passes PropTypes.object.
920
+ return 'object';
921
+ }
922
+ if (isSymbol(propType, propValue)) {
923
+ return 'symbol';
924
+ }
925
+ return propType;
926
+ }
927
+
928
+ // This handles more types than `getPropType`. Only used for error messages.
929
+ // See `createPrimitiveTypeChecker`.
930
+ function getPreciseType(propValue) {
931
+ if (typeof propValue === 'undefined' || propValue === null) {
932
+ return '' + propValue;
933
+ }
934
+ var propType = getPropType(propValue);
935
+ if (propType === 'object') {
936
+ if (propValue instanceof Date) {
937
+ return 'date';
938
+ } else if (propValue instanceof RegExp) {
939
+ return 'regexp';
940
+ }
941
+ }
942
+ return propType;
943
+ }
944
+
945
+ // Returns a string that is postfixed to a warning about an invalid type.
946
+ // For example, "undefined" or "of type array"
947
+ function getPostfixForTypeWarning(value) {
948
+ var type = getPreciseType(value);
949
+ switch (type) {
950
+ case 'array':
951
+ case 'object':
952
+ return 'an ' + type;
953
+ case 'boolean':
954
+ case 'date':
955
+ case 'regexp':
956
+ return 'a ' + type;
957
+ default:
958
+ return type;
959
+ }
960
+ }
961
+
962
+ // Returns class name of the object, if any.
963
+ function getClassName(propValue) {
964
+ if (!propValue.constructor || !propValue.constructor.name) {
965
+ return ANONYMOUS;
966
+ }
967
+ return propValue.constructor.name;
968
+ }
969
+
970
+ ReactPropTypes.checkPropTypes = checkPropTypes;
971
+ ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
972
+ ReactPropTypes.PropTypes = ReactPropTypes;
973
+
974
+ return ReactPropTypes;
975
+ };
976
+ return factoryWithTypeCheckers;
977
+ }
978
+
979
+ /**
980
+ * Copyright (c) 2013-present, Facebook, Inc.
981
+ *
982
+ * This source code is licensed under the MIT license found in the
983
+ * LICENSE file in the root directory of this source tree.
984
+ */
985
+
986
+ var factoryWithThrowingShims;
987
+ var hasRequiredFactoryWithThrowingShims;
988
+
989
+ function requireFactoryWithThrowingShims () {
990
+ if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
991
+ hasRequiredFactoryWithThrowingShims = 1;
992
+
993
+ var ReactPropTypesSecret = /*@__PURE__*/ requireReactPropTypesSecret();
994
+
995
+ function emptyFunction() {}
996
+ function emptyFunctionWithReset() {}
997
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
998
+
999
+ factoryWithThrowingShims = function() {
1000
+ function shim(props, propName, componentName, location, propFullName, secret) {
1001
+ if (secret === ReactPropTypesSecret) {
1002
+ // It is still safe when called from React.
1003
+ return;
1004
+ }
1005
+ var err = new Error(
1006
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1007
+ 'Use PropTypes.checkPropTypes() to call them. ' +
1008
+ 'Read more at http://fb.me/use-check-prop-types'
1009
+ );
1010
+ err.name = 'Invariant Violation';
1011
+ throw err;
1012
+ } shim.isRequired = shim;
1013
+ function getShim() {
1014
+ return shim;
1015
+ } // Important!
1016
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1017
+ var ReactPropTypes = {
1018
+ array: shim,
1019
+ bigint: shim,
1020
+ bool: shim,
1021
+ func: shim,
1022
+ number: shim,
1023
+ object: shim,
1024
+ string: shim,
1025
+ symbol: shim,
1026
+
1027
+ any: shim,
1028
+ arrayOf: getShim,
1029
+ element: shim,
1030
+ elementType: shim,
1031
+ instanceOf: getShim,
1032
+ node: shim,
1033
+ objectOf: getShim,
1034
+ oneOf: getShim,
1035
+ oneOfType: getShim,
1036
+ shape: getShim,
1037
+ exact: getShim,
1038
+
1039
+ checkPropTypes: emptyFunctionWithReset,
1040
+ resetWarningCache: emptyFunction
1041
+ };
1042
+
1043
+ ReactPropTypes.PropTypes = ReactPropTypes;
1044
+
1045
+ return ReactPropTypes;
1046
+ };
1047
+ return factoryWithThrowingShims;
1048
+ }
1049
+
1050
+ /**
1051
+ * Copyright (c) 2013-present, Facebook, Inc.
1052
+ *
1053
+ * This source code is licensed under the MIT license found in the
1054
+ * LICENSE file in the root directory of this source tree.
1055
+ */
1056
+
1057
+ var hasRequiredPropTypes;
1058
+
1059
+ function requirePropTypes () {
1060
+ if (hasRequiredPropTypes) return propTypes.exports;
1061
+ hasRequiredPropTypes = 1;
1062
+ if (process.env.NODE_ENV !== 'production') {
1063
+ var ReactIs = require$$0;
1064
+
1065
+ // By explicitly using `prop-types` you are opting into new development behavior.
1066
+ // http://fb.me/prop-types-in-prod
1067
+ var throwOnDirectAccess = true;
1068
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
1069
+ } else {
1070
+ // By explicitly using `prop-types` you are opting into new production behavior.
1071
+ // http://fb.me/prop-types-in-prod
1072
+ propTypes.exports = /*@__PURE__*/ requireFactoryWithThrowingShims()();
1073
+ }
1074
+ return propTypes.exports;
1075
+ }
1076
+
1077
+ var propTypesExports = /*@__PURE__*/ requirePropTypes();
1078
+ var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
1079
+
1080
+ var _excluded = ["tagName", "className", "style", "children", "allowMouseEvents", "onSwipeUp", "onSwipeDown", "onSwipeLeft", "onSwipeRight", "onSwipeStart", "onSwipeMove", "onSwipeEnd", "innerRef", "tolerance"];
1081
+ var supportsCaptureOption = false;
1082
+ function setHasSupportToCaptureOption(hasSupport) {
1083
+ supportsCaptureOption = hasSupport;
1084
+ }
1085
+ try {
1086
+ addEventListener('test', null, Object.defineProperty({}, 'capture', {
1087
+ get: function get() {
1088
+ setHasSupportToCaptureOption(true);
1089
+ }
1090
+ }));
1091
+ } catch (e) {} // eslint-disable-line no-empty
1092
+
1093
+ function getSafeEventHandlerOpts() {
1094
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
1095
+ capture: true
1096
+ };
1097
+ return supportsCaptureOption ? options : false;
1098
+ }
1099
+
1100
+ /**
1101
+ * [getPosition returns a position element that works for mouse or touch events]
1102
+ * @param {[Event]} event [the received event]
1103
+ * @return {[Object]} [x and y coords]
1104
+ */
1105
+ function getPosition(event) {
1106
+ if ('touches' in event) {
1107
+ var _event$touches$ = event.touches[0],
1108
+ pageX = _event$touches$.pageX,
1109
+ pageY = _event$touches$.pageY;
1110
+ return {
1111
+ x: pageX,
1112
+ y: pageY
1113
+ };
1114
+ }
1115
+ var screenX = event.screenX,
1116
+ screenY = event.screenY;
1117
+ return {
1118
+ x: screenX,
1119
+ y: screenY
1120
+ };
1121
+ }
1122
+ var ReactSwipe = /*#__PURE__*/function (_Component) {
1123
+ function ReactSwipe() {
1124
+ var _this;
1125
+ _classCallCheck(this, ReactSwipe);
1126
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1127
+ args[_key] = arguments[_key];
1128
+ }
1129
+ _this = _callSuper(this, ReactSwipe, [].concat(args));
1130
+ _this._handleSwipeStart = _this._handleSwipeStart.bind(_this);
1131
+ _this._handleSwipeMove = _this._handleSwipeMove.bind(_this);
1132
+ _this._handleSwipeEnd = _this._handleSwipeEnd.bind(_this);
1133
+ _this._onMouseDown = _this._onMouseDown.bind(_this);
1134
+ _this._onMouseMove = _this._onMouseMove.bind(_this);
1135
+ _this._onMouseUp = _this._onMouseUp.bind(_this);
1136
+ _this._setSwiperRef = _this._setSwiperRef.bind(_this);
1137
+ return _this;
1138
+ }
1139
+ _inherits(ReactSwipe, _Component);
1140
+ return _createClass(ReactSwipe, [{
1141
+ key: "componentDidMount",
1142
+ value: function componentDidMount() {
1143
+ if (this.swiper) {
1144
+ this.swiper.addEventListener('touchmove', this._handleSwipeMove, getSafeEventHandlerOpts({
1145
+ capture: true,
1146
+ passive: false
1147
+ }));
1148
+ }
1149
+ }
1150
+ }, {
1151
+ key: "componentWillUnmount",
1152
+ value: function componentWillUnmount() {
1153
+ if (this.swiper) {
1154
+ this.swiper.removeEventListener('touchmove', this._handleSwipeMove, getSafeEventHandlerOpts({
1155
+ capture: true,
1156
+ passive: false
1157
+ }));
1158
+ }
1159
+ }
1160
+ }, {
1161
+ key: "_onMouseDown",
1162
+ value: function _onMouseDown(event) {
1163
+ if (!this.props.allowMouseEvents) {
1164
+ return;
1165
+ }
1166
+ this.mouseDown = true;
1167
+ document.addEventListener('mouseup', this._onMouseUp);
1168
+ document.addEventListener('mousemove', this._onMouseMove);
1169
+ this._handleSwipeStart(event);
1170
+ }
1171
+ }, {
1172
+ key: "_onMouseMove",
1173
+ value: function _onMouseMove(event) {
1174
+ if (!this.mouseDown) {
1175
+ return;
1176
+ }
1177
+ this._handleSwipeMove(event);
1178
+ }
1179
+ }, {
1180
+ key: "_onMouseUp",
1181
+ value: function _onMouseUp(event) {
1182
+ this.mouseDown = false;
1183
+ document.removeEventListener('mouseup', this._onMouseUp);
1184
+ document.removeEventListener('mousemove', this._onMouseMove);
1185
+ this._handleSwipeEnd(event);
1186
+ }
1187
+ }, {
1188
+ key: "_handleSwipeStart",
1189
+ value: function _handleSwipeStart(event) {
1190
+ var _getPosition = getPosition(event),
1191
+ x = _getPosition.x,
1192
+ y = _getPosition.y;
1193
+ this.moveStart = {
1194
+ x: x,
1195
+ y: y
1196
+ };
1197
+ this.props.onSwipeStart(event);
1198
+ }
1199
+ }, {
1200
+ key: "_handleSwipeMove",
1201
+ value: function _handleSwipeMove(event) {
1202
+ if (!this.moveStart) {
1203
+ return;
1204
+ }
1205
+ var _getPosition2 = getPosition(event),
1206
+ x = _getPosition2.x,
1207
+ y = _getPosition2.y;
1208
+ var deltaX = x - this.moveStart.x;
1209
+ var deltaY = y - this.moveStart.y;
1210
+ this.moving = true;
1211
+
1212
+ // handling the responsability of cancelling the scroll to
1213
+ // the component handling the event
1214
+ var shouldPreventDefault = this.props.onSwipeMove({
1215
+ x: deltaX,
1216
+ y: deltaY
1217
+ }, event);
1218
+ if (shouldPreventDefault && event.cancelable) {
1219
+ event.preventDefault();
1220
+ }
1221
+ this.movePosition = {
1222
+ deltaX: deltaX,
1223
+ deltaY: deltaY
1224
+ };
1225
+ }
1226
+ }, {
1227
+ key: "_handleSwipeEnd",
1228
+ value: function _handleSwipeEnd(event) {
1229
+ this.props.onSwipeEnd(event);
1230
+ var tolerance = this.props.tolerance;
1231
+ if (this.moving && this.movePosition) {
1232
+ if (this.movePosition.deltaX < -tolerance) {
1233
+ this.props.onSwipeLeft(1, event);
1234
+ } else if (this.movePosition.deltaX > tolerance) {
1235
+ this.props.onSwipeRight(1, event);
1236
+ }
1237
+ if (this.movePosition.deltaY < -tolerance) {
1238
+ this.props.onSwipeUp(1, event);
1239
+ } else if (this.movePosition.deltaY > tolerance) {
1240
+ this.props.onSwipeDown(1, event);
1241
+ }
1242
+ }
1243
+ this.moveStart = null;
1244
+ this.moving = false;
1245
+ this.movePosition = null;
1246
+ }
1247
+ }, {
1248
+ key: "_setSwiperRef",
1249
+ value: function _setSwiperRef(node) {
1250
+ this.swiper = node;
1251
+ this.props.innerRef(node);
1252
+ }
1253
+ }, {
1254
+ key: "render",
1255
+ value: function render() {
1256
+ var _this$props = this.props;
1257
+ _this$props.tagName;
1258
+ var className = _this$props.className,
1259
+ style = _this$props.style,
1260
+ children = _this$props.children;
1261
+ _this$props.allowMouseEvents;
1262
+ _this$props.onSwipeUp;
1263
+ _this$props.onSwipeDown;
1264
+ _this$props.onSwipeLeft;
1265
+ _this$props.onSwipeRight;
1266
+ _this$props.onSwipeStart;
1267
+ _this$props.onSwipeMove;
1268
+ _this$props.onSwipeEnd;
1269
+ _this$props.innerRef;
1270
+ _this$props.tolerance;
1271
+ var props = _objectWithoutProperties(_this$props, _excluded);
1272
+ return /*#__PURE__*/React.createElement(this.props.tagName, _extends({
1273
+ ref: this._setSwiperRef,
1274
+ onMouseDown: this._onMouseDown,
1275
+ onTouchStart: this._handleSwipeStart,
1276
+ onTouchEnd: this._handleSwipeEnd,
1277
+ className: className,
1278
+ style: style
1279
+ }, props), children);
1280
+ }
1281
+ }]);
1282
+ }(React.Component);
1283
+ _defineProperty(ReactSwipe, "displayName", 'ReactSwipe');
1284
+ _defineProperty(ReactSwipe, "propTypes", {
1285
+ tagName: PropTypes.string,
1286
+ className: PropTypes.string,
1287
+ style: PropTypes.object,
1288
+ children: PropTypes.node,
1289
+ allowMouseEvents: PropTypes.bool,
1290
+ onSwipeUp: PropTypes.func,
1291
+ onSwipeDown: PropTypes.func,
1292
+ onSwipeLeft: PropTypes.func,
1293
+ onSwipeRight: PropTypes.func,
1294
+ onSwipeStart: PropTypes.func,
1295
+ onSwipeMove: PropTypes.func,
1296
+ onSwipeEnd: PropTypes.func,
1297
+ innerRef: PropTypes.func,
1298
+ tolerance: PropTypes.number.isRequired
1299
+ });
1300
+ _defineProperty(ReactSwipe, "defaultProps", {
1301
+ tagName: 'div',
1302
+ allowMouseEvents: false,
1303
+ onSwipeUp: function onSwipeUp() {},
1304
+ onSwipeDown: function onSwipeDown() {},
1305
+ onSwipeLeft: function onSwipeLeft() {},
1306
+ onSwipeRight: function onSwipeRight() {},
1307
+ onSwipeStart: function onSwipeStart() {},
1308
+ onSwipeMove: function onSwipeMove() {},
1309
+ onSwipeEnd: function onSwipeEnd() {},
1310
+ innerRef: function innerRef() {},
1311
+ tolerance: 0
1312
+ });
1313
+
1314
+ exports.default = ReactSwipe;