@itcase/ui 1.0.10 → 1.0.13

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 (41) hide show
  1. package/dist/components/Avatar.js +4 -2
  2. package/dist/components/Chips.js +2 -0
  3. package/dist/components/Choice.js +118 -0
  4. package/dist/components/DatePicker.js +10201 -0
  5. package/dist/components/Empty.js +95 -0
  6. package/dist/components/FormField.js +1 -1
  7. package/dist/components/Grid.js +8 -14
  8. package/dist/components/Input.js +2 -0
  9. package/dist/components/Label.js +0 -5
  10. package/dist/components/Logo.js +4 -4
  11. package/dist/components/Modal.js +3 -3
  12. package/dist/components/RangeSlider.js +7 -1978
  13. package/dist/components/Scrollbar.js +5 -3826
  14. package/dist/components/Search.js +4 -5
  15. package/dist/components/Segmented.js +5 -1
  16. package/dist/components/Select.js +348 -270
  17. package/dist/components/Swiper.js +4208 -188
  18. package/dist/components/Switch.js +3 -2
  19. package/dist/components/Tab.js +0 -1
  20. package/dist/components/Textarea.js +5 -1
  21. package/dist/components/Tile.js +0 -3
  22. package/dist/css/components/Choice/Choice.css +73 -0
  23. package/dist/css/components/DatePicker/DatePicker.css +924 -0
  24. package/dist/css/components/Empty/Empty.css +13 -0
  25. package/dist/css/components/Input/Input.css +12 -4
  26. package/dist/css/components/Segmented/Segmented.css +16 -0
  27. package/dist/css/components/Select/Select.css +11 -4
  28. package/dist/css/components/Select/css/__menu/select__menu.css +7 -3
  29. package/dist/css/components/Swiper/Swiper.css +128 -83
  30. package/dist/css/styles/fill/fill.css +4 -4
  31. package/dist/css/styles/fill/fill_active.css +5 -5
  32. package/dist/defineProperty-f9e5e1f3.js +166 -0
  33. package/dist/hooks/styleAttributes.js +5 -1
  34. package/package.json +30 -27
  35. package/dist/components/Emoji.js +0 -124
  36. package/dist/components/Profile.js +0 -105
  37. package/dist/css/components/Emoji/Emoji.css +0 -104
  38. package/dist/css/components/Emoji/css/__icon/emoji__icon-shape.css +0 -12
  39. package/dist/css/components/Emoji/css/__icon/emoji__icon.css +0 -5
  40. package/dist/css/components/Profile/Profile.css +0 -19
  41. package/dist/objectWithoutProperties-ea190611.js +0 -188
@@ -1,3842 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var React$1 = require('react');
4
- var PropTypes = require('prop-types');
3
+ var React = require('react');
4
+ require('prop-types');
5
5
  var clsx = require('clsx');
6
- var require$$2 = require('react-dom');
6
+ var reactScrollbarsCustom = require('react-scrollbars-custom');
7
7
 
8
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
 
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var React__namespace = /*#__PURE__*/_interopNamespace(React$1);
29
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
10
+ var React__default = /*#__PURE__*/_interopDefault(React);
30
11
  var clsx__default = /*#__PURE__*/_interopDefault(clsx);
31
- var require$$2__default = /*#__PURE__*/_interopDefault(require$$2);
32
-
33
- var isArray = Array.isArray;
34
- var toClassName = function (val) {
35
- var str = '';
36
- if (typeof val === 'string')
37
- str += val;
38
- else if (typeof val === 'object') {
39
- var tmp = void 0;
40
- if (isArray(val)) {
41
- var i = 0;
42
- var l = val.length;
43
- while (i < l) {
44
- tmp = toClassName(val[i++]);
45
- if (tmp) {
46
- if (str) {
47
- str += ' ';
48
- }
49
- str += tmp;
50
- }
51
- }
52
- }
53
- else {
54
- // eslint-disable-next-line guard-for-in
55
- for (tmp in val) {
56
- if (tmp && val[tmp]) {
57
- if (str) {
58
- str += ' ';
59
- }
60
- str += tmp;
61
- }
62
- }
63
- }
64
- }
65
- return str;
66
- };
67
- function cnb() {
68
- var l = arguments.length;
69
- var i = 0;
70
- var n;
71
- var tmp;
72
- var str = '';
73
- while (i < l) {
74
- n = arguments[i++];
75
- if (n) {
76
- tmp = toClassName(n);
77
- if (tmp) {
78
- if (str) {
79
- str += ' ';
80
- }
81
- str += tmp;
82
- }
83
- }
84
- }
85
- return str;
86
- }
87
-
88
- function e(e,i,t,o){for(;i>=t&&!e("(min-resolution: "+i/o+"dppx)").matches;)i--;return i}function i(i){if(void 0===i&&(i=window),!i)return 1;if(void 0!==i.devicePixelRatio)return i.devicePixelRatio;var t=i.document.frames;return void 0!==t?void 0!==t.devicePixelRatio?t.devicePixelRatio:t.screen.deviceXDPI/t.screen.systemXDPI:void 0!==i.matchMedia?function(i){for(var t=i.matchMedia,o=10,n=.1,r=1,a=o,c=0;c<4;c++)o=(a=10*e(t,o,n,r))+9,n=a,r*=10;return a/r}(i):1}
89
-
90
- var cjs = {exports: {}};
91
-
92
- var Draggable$1 = {};
93
-
94
- var domFns = {};
95
-
96
- var shims = {};
97
-
98
- Object.defineProperty(shims, "__esModule", {
99
- value: true
100
- });
101
- shims.dontSetMe = dontSetMe;
102
- shims.findInArray = findInArray;
103
- shims.int = int;
104
- shims.isFunction = isFunction;
105
- shims.isNum = isNum$1;
106
-
107
- // @credits https://gist.github.com/rogozhnikoff/a43cfed27c41e4e68cdc
108
- function findInArray(array
109
- /*: Array<any> | TouchList*/
110
- , callback
111
- /*: Function*/
112
- )
113
- /*: any*/
114
- {
115
- for (var i = 0, length = array.length; i < length; i++) {
116
- if (callback.apply(callback, [array[i], i, array])) return array[i];
117
- }
118
- }
119
-
120
- function isFunction(func
121
- /*: any*/
122
- )
123
- /*: boolean %checks*/
124
- {
125
- // $FlowIgnore[method-unbinding]
126
- return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
127
- }
128
-
129
- function isNum$1(num
130
- /*: any*/
131
- )
132
- /*: boolean %checks*/
133
- {
134
- return typeof num === 'number' && !isNaN(num);
135
- }
136
-
137
- function int(a
138
- /*: string*/
139
- )
140
- /*: number*/
141
- {
142
- return parseInt(a, 10);
143
- }
144
-
145
- function dontSetMe(props
146
- /*: Object*/
147
- , propName
148
- /*: string*/
149
- , componentName
150
- /*: string*/
151
- )
152
- /*: ?Error*/
153
- {
154
- if (props[propName]) {
155
- return new Error("Invalid prop ".concat(propName, " passed to ").concat(componentName, " - do not set this, set it on the child."));
156
- }
157
- }
158
-
159
- var getPrefix$1 = {};
160
-
161
- Object.defineProperty(getPrefix$1, "__esModule", {
162
- value: true
163
- });
164
- getPrefix$1.browserPrefixToKey = browserPrefixToKey;
165
- getPrefix$1.browserPrefixToStyle = browserPrefixToStyle;
166
- getPrefix$1.default = void 0;
167
- getPrefix$1.getPrefix = getPrefix;
168
- var prefixes = ['Moz', 'Webkit', 'O', 'ms'];
169
-
170
- function getPrefix()
171
- /*: string*/
172
- {
173
- var _window$document, _window$document$docu;
174
-
175
- var prop
176
- /*: string*/
177
- = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform';
178
- // Ensure we're running in an environment where there is actually a global
179
- // `window` obj
180
- if (typeof window === 'undefined') return ''; // If we're in a pseudo-browser server-side environment, this access
181
- // path may not exist, so bail out if it doesn't.
182
-
183
- var style = (_window$document = window.document) === null || _window$document === void 0 ? void 0 : (_window$document$docu = _window$document.documentElement) === null || _window$document$docu === void 0 ? void 0 : _window$document$docu.style;
184
- if (!style) return '';
185
- if (prop in style) return '';
186
-
187
- for (var i = 0; i < prefixes.length; i++) {
188
- if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
189
- }
190
-
191
- return '';
192
- }
193
-
194
- function browserPrefixToKey(prop
195
- /*: string*/
196
- , prefix
197
- /*: string*/
198
- )
199
- /*: string*/
200
- {
201
- return prefix ? "".concat(prefix).concat(kebabToTitleCase(prop)) : prop;
202
- }
203
-
204
- function browserPrefixToStyle(prop
205
- /*: string*/
206
- , prefix
207
- /*: string*/
208
- )
209
- /*: string*/
210
- {
211
- return prefix ? "-".concat(prefix.toLowerCase(), "-").concat(prop) : prop;
212
- }
213
-
214
- function kebabToTitleCase(str
215
- /*: string*/
216
- )
217
- /*: string*/
218
- {
219
- var out = '';
220
- var shouldCapitalize = true;
221
-
222
- for (var i = 0; i < str.length; i++) {
223
- if (shouldCapitalize) {
224
- out += str[i].toUpperCase();
225
- shouldCapitalize = false;
226
- } else if (str[i] === '-') {
227
- shouldCapitalize = true;
228
- } else {
229
- out += str[i];
230
- }
231
- }
232
-
233
- return out;
234
- } // Default export is the prefix itself, like 'Moz', 'Webkit', etc
235
- // Note that you may have to re-test for certain things; for instance, Chrome 50
236
- // can handle unprefixed `transform`, but not unprefixed `user-select`
237
-
238
-
239
- var _default = (getPrefix()
240
- /*: string*/
241
- );
242
-
243
- getPrefix$1.default = _default;
244
-
245
- function _typeof$2(obj) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$2(obj); }
246
-
247
- Object.defineProperty(domFns, "__esModule", {
248
- value: true
249
- });
250
- domFns.addClassName = addClassName;
251
- domFns.addEvent = addEvent;
252
- domFns.addUserSelectStyles = addUserSelectStyles;
253
- domFns.createCSSTransform = createCSSTransform;
254
- domFns.createSVGTransform = createSVGTransform;
255
- domFns.getTouch = getTouch;
256
- domFns.getTouchIdentifier = getTouchIdentifier;
257
- domFns.getTranslation = getTranslation;
258
- domFns.innerHeight = innerHeight;
259
- domFns.innerWidth = innerWidth;
260
- domFns.matchesSelector = matchesSelector;
261
- domFns.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
262
- domFns.offsetXYFromParent = offsetXYFromParent;
263
- domFns.outerHeight = outerHeight;
264
- domFns.outerWidth = outerWidth;
265
- domFns.removeClassName = removeClassName;
266
- domFns.removeEvent = removeEvent;
267
- domFns.removeUserSelectStyles = removeUserSelectStyles;
268
-
269
- var _shims$2 = shims;
270
-
271
- var _getPrefix = _interopRequireWildcard$1(getPrefix$1);
272
-
273
- function _getRequireWildcardCache$1(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache$1 = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
274
-
275
- function _interopRequireWildcard$1(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof$2(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache$1(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
276
-
277
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
278
-
279
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
280
-
281
- function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
282
-
283
- var matchesSelectorFunc = '';
284
-
285
- function matchesSelector(el
286
- /*: Node*/
287
- , selector
288
- /*: string*/
289
- )
290
- /*: boolean*/
291
- {
292
- if (!matchesSelectorFunc) {
293
- matchesSelectorFunc = (0, _shims$2.findInArray)(['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'], function (method) {
294
- // $FlowIgnore: Doesn't think elements are indexable
295
- return (0, _shims$2.isFunction)(el[method]);
296
- });
297
- } // Might not be found entirely (not an Element?) - in that case, bail
298
- // $FlowIgnore: Doesn't think elements are indexable
299
-
300
-
301
- if (!(0, _shims$2.isFunction)(el[matchesSelectorFunc])) return false; // $FlowIgnore: Doesn't think elements are indexable
302
-
303
- return el[matchesSelectorFunc](selector);
304
- } // Works up the tree to the draggable itself attempting to match selector.
305
-
306
-
307
- function matchesSelectorAndParentsTo(el
308
- /*: Node*/
309
- , selector
310
- /*: string*/
311
- , baseNode
312
- /*: Node*/
313
- )
314
- /*: boolean*/
315
- {
316
- var node = el;
317
-
318
- do {
319
- if (matchesSelector(node, selector)) return true;
320
- if (node === baseNode) return false;
321
- node = node.parentNode;
322
- } while (node);
323
-
324
- return false;
325
- }
326
-
327
- function addEvent(el
328
- /*: ?Node*/
329
- , event
330
- /*: string*/
331
- , handler
332
- /*: Function*/
333
- , inputOptions
334
- /*: Object*/
335
- )
336
- /*: void*/
337
- {
338
- if (!el) return;
339
-
340
- var options = _objectSpread({
341
- capture: true
342
- }, inputOptions); // $FlowIgnore[method-unbinding]
343
-
344
-
345
- if (el.addEventListener) {
346
- el.addEventListener(event, handler, options);
347
- } else if (el.attachEvent) {
348
- el.attachEvent('on' + event, handler);
349
- } else {
350
- // $FlowIgnore: Doesn't think elements are indexable
351
- el['on' + event] = handler;
352
- }
353
- }
354
-
355
- function removeEvent(el
356
- /*: ?Node*/
357
- , event
358
- /*: string*/
359
- , handler
360
- /*: Function*/
361
- , inputOptions
362
- /*: Object*/
363
- )
364
- /*: void*/
365
- {
366
- if (!el) return;
367
-
368
- var options = _objectSpread({
369
- capture: true
370
- }, inputOptions); // $FlowIgnore[method-unbinding]
371
-
372
-
373
- if (el.removeEventListener) {
374
- el.removeEventListener(event, handler, options);
375
- } else if (el.detachEvent) {
376
- el.detachEvent('on' + event, handler);
377
- } else {
378
- // $FlowIgnore: Doesn't think elements are indexable
379
- el['on' + event] = null;
380
- }
381
- }
382
-
383
- function outerHeight(node
384
- /*: HTMLElement*/
385
- )
386
- /*: number*/
387
- {
388
- // This is deliberately excluding margin for our calculations, since we are using
389
- // offsetTop which is including margin. See getBoundPosition
390
- var height = node.clientHeight;
391
- var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
392
- height += (0, _shims$2.int)(computedStyle.borderTopWidth);
393
- height += (0, _shims$2.int)(computedStyle.borderBottomWidth);
394
- return height;
395
- }
396
-
397
- function outerWidth(node
398
- /*: HTMLElement*/
399
- )
400
- /*: number*/
401
- {
402
- // This is deliberately excluding margin for our calculations, since we are using
403
- // offsetLeft which is including margin. See getBoundPosition
404
- var width = node.clientWidth;
405
- var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
406
- width += (0, _shims$2.int)(computedStyle.borderLeftWidth);
407
- width += (0, _shims$2.int)(computedStyle.borderRightWidth);
408
- return width;
409
- }
410
-
411
- function innerHeight(node
412
- /*: HTMLElement*/
413
- )
414
- /*: number*/
415
- {
416
- var height = node.clientHeight;
417
- var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
418
- height -= (0, _shims$2.int)(computedStyle.paddingTop);
419
- height -= (0, _shims$2.int)(computedStyle.paddingBottom);
420
- return height;
421
- }
422
-
423
- function innerWidth(node
424
- /*: HTMLElement*/
425
- )
426
- /*: number*/
427
- {
428
- var width = node.clientWidth;
429
- var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
430
- width -= (0, _shims$2.int)(computedStyle.paddingLeft);
431
- width -= (0, _shims$2.int)(computedStyle.paddingRight);
432
- return width;
433
- }
434
- /*:: interface EventWithOffset {
435
- clientX: number, clientY: number
436
- }*/
437
-
438
-
439
- // Get from offsetParent
440
- function offsetXYFromParent(evt
441
- /*: EventWithOffset*/
442
- , offsetParent
443
- /*: HTMLElement*/
444
- , scale
445
- /*: number*/
446
- )
447
- /*: ControlPosition*/
448
- {
449
- var isBody = offsetParent === offsetParent.ownerDocument.body;
450
- var offsetParentRect = isBody ? {
451
- left: 0,
452
- top: 0
453
- } : offsetParent.getBoundingClientRect();
454
- var x = (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale;
455
- var y = (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale;
456
- return {
457
- x: x,
458
- y: y
459
- };
460
- }
461
-
462
- function createCSSTransform(controlPos
463
- /*: ControlPosition*/
464
- , positionOffset
465
- /*: PositionOffsetControlPosition*/
466
- )
467
- /*: Object*/
468
- {
469
- var translation = getTranslation(controlPos, positionOffset, 'px');
470
- return _defineProperty$1({}, (0, _getPrefix.browserPrefixToKey)('transform', _getPrefix.default), translation);
471
- }
472
-
473
- function createSVGTransform(controlPos
474
- /*: ControlPosition*/
475
- , positionOffset
476
- /*: PositionOffsetControlPosition*/
477
- )
478
- /*: string*/
479
- {
480
- var translation = getTranslation(controlPos, positionOffset, '');
481
- return translation;
482
- }
483
-
484
- function getTranslation(_ref2, positionOffset
485
- /*: PositionOffsetControlPosition*/
486
- , unitSuffix
487
- /*: string*/
488
- )
489
- /*: string*/
490
- {
491
- var x = _ref2.x,
492
- y = _ref2.y;
493
- var translation = "translate(".concat(x).concat(unitSuffix, ",").concat(y).concat(unitSuffix, ")");
494
-
495
- if (positionOffset) {
496
- var defaultX = "".concat(typeof positionOffset.x === 'string' ? positionOffset.x : positionOffset.x + unitSuffix);
497
- var defaultY = "".concat(typeof positionOffset.y === 'string' ? positionOffset.y : positionOffset.y + unitSuffix);
498
- translation = "translate(".concat(defaultX, ", ").concat(defaultY, ")") + translation;
499
- }
500
-
501
- return translation;
502
- }
503
-
504
- function getTouch(e
505
- /*: MouseTouchEvent*/
506
- , identifier
507
- /*: number*/
508
- )
509
- /*: ?{clientX: number, clientY: number}*/
510
- {
511
- return e.targetTouches && (0, _shims$2.findInArray)(e.targetTouches, function (t) {
512
- return identifier === t.identifier;
513
- }) || e.changedTouches && (0, _shims$2.findInArray)(e.changedTouches, function (t) {
514
- return identifier === t.identifier;
515
- });
516
- }
517
-
518
- function getTouchIdentifier(e
519
- /*: MouseTouchEvent*/
520
- )
521
- /*: ?number*/
522
- {
523
- if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
524
- if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
525
- } // User-select Hacks:
526
- //
527
- // Useful for preventing blue highlights all over everything when dragging.
528
- // Note we're passing `document` b/c we could be iframed
529
-
530
-
531
- function addUserSelectStyles(doc
532
- /*: ?Document*/
533
- ) {
534
- if (!doc) return;
535
- var styleEl = doc.getElementById('react-draggable-style-el');
536
-
537
- if (!styleEl) {
538
- styleEl = doc.createElement('style');
539
- styleEl.type = 'text/css';
540
- styleEl.id = 'react-draggable-style-el';
541
- styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n';
542
- styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {all: inherit;}\n';
543
- doc.getElementsByTagName('head')[0].appendChild(styleEl);
544
- }
545
-
546
- if (doc.body) addClassName(doc.body, 'react-draggable-transparent-selection');
547
- }
548
-
549
- function removeUserSelectStyles(doc
550
- /*: ?Document*/
551
- ) {
552
- if (!doc) return;
553
-
554
- try {
555
- if (doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection'); // $FlowIgnore: IE
556
-
557
- if (doc.selection) {
558
- // $FlowIgnore: IE
559
- doc.selection.empty();
560
- } else {
561
- // Remove selection caused by scroll, unless it's a focused input
562
- // (we use doc.defaultView in case we're in an iframe)
563
- var selection = (doc.defaultView || window).getSelection();
564
-
565
- if (selection && selection.type !== 'Caret') {
566
- selection.removeAllRanges();
567
- }
568
- }
569
- } catch (e) {// probably IE
570
- }
571
- }
572
-
573
- function addClassName(el
574
- /*: HTMLElement*/
575
- , className
576
- /*: string*/
577
- ) {
578
- if (el.classList) {
579
- el.classList.add(className);
580
- } else {
581
- if (!el.className.match(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)")))) {
582
- el.className += " ".concat(className);
583
- }
584
- }
585
- }
586
-
587
- function removeClassName(el
588
- /*: HTMLElement*/
589
- , className
590
- /*: string*/
591
- ) {
592
- if (el.classList) {
593
- el.classList.remove(className);
594
- } else {
595
- el.className = el.className.replace(new RegExp("(?:^|\\s)".concat(className, "(?!\\S)"), 'g'), '');
596
- }
597
- }
598
-
599
- var positionFns = {};
600
-
601
- Object.defineProperty(positionFns, "__esModule", {
602
- value: true
603
- });
604
- positionFns.canDragX = canDragX;
605
- positionFns.canDragY = canDragY;
606
- positionFns.createCoreData = createCoreData;
607
- positionFns.createDraggableData = createDraggableData;
608
- positionFns.getBoundPosition = getBoundPosition;
609
- positionFns.getControlPosition = getControlPosition;
610
- positionFns.snapToGrid = snapToGrid;
611
-
612
- var _shims$1 = shims;
613
-
614
- var _domFns$1 = domFns;
615
-
616
- function getBoundPosition(draggable
617
- /*: Draggable*/
618
- , x
619
- /*: number*/
620
- , y
621
- /*: number*/
622
- )
623
- /*: [number, number]*/
624
- {
625
- // If no bounds, short-circuit and move on
626
- if (!draggable.props.bounds) return [x, y]; // Clone new bounds
627
-
628
- var bounds = draggable.props.bounds;
629
- bounds = typeof bounds === 'string' ? bounds : cloneBounds(bounds);
630
- var node = findDOMNode(draggable);
631
-
632
- if (typeof bounds === 'string') {
633
- var ownerDocument = node.ownerDocument;
634
- var ownerWindow = ownerDocument.defaultView;
635
- var boundNode;
636
-
637
- if (bounds === 'parent') {
638
- boundNode = node.parentNode;
639
- } else {
640
- boundNode = ownerDocument.querySelector(bounds);
641
- }
642
-
643
- if (!(boundNode instanceof ownerWindow.HTMLElement)) {
644
- throw new Error('Bounds selector "' + bounds + '" could not find an element.');
645
- }
646
-
647
- var boundNodeEl
648
- /*: HTMLElement*/
649
- = boundNode; // for Flow, can't seem to refine correctly
650
-
651
- var nodeStyle = ownerWindow.getComputedStyle(node);
652
- var boundNodeStyle = ownerWindow.getComputedStyle(boundNodeEl); // Compute bounds. This is a pain with padding and offsets but this gets it exactly right.
653
-
654
- bounds = {
655
- left: -node.offsetLeft + (0, _shims$1.int)(boundNodeStyle.paddingLeft) + (0, _shims$1.int)(nodeStyle.marginLeft),
656
- top: -node.offsetTop + (0, _shims$1.int)(boundNodeStyle.paddingTop) + (0, _shims$1.int)(nodeStyle.marginTop),
657
- right: (0, _domFns$1.innerWidth)(boundNodeEl) - (0, _domFns$1.outerWidth)(node) - node.offsetLeft + (0, _shims$1.int)(boundNodeStyle.paddingRight) - (0, _shims$1.int)(nodeStyle.marginRight),
658
- bottom: (0, _domFns$1.innerHeight)(boundNodeEl) - (0, _domFns$1.outerHeight)(node) - node.offsetTop + (0, _shims$1.int)(boundNodeStyle.paddingBottom) - (0, _shims$1.int)(nodeStyle.marginBottom)
659
- };
660
- } // Keep x and y below right and bottom limits...
661
-
662
-
663
- if ((0, _shims$1.isNum)(bounds.right)) x = Math.min(x, bounds.right);
664
- if ((0, _shims$1.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom); // But above left and top limits.
665
-
666
- if ((0, _shims$1.isNum)(bounds.left)) x = Math.max(x, bounds.left);
667
- if ((0, _shims$1.isNum)(bounds.top)) y = Math.max(y, bounds.top);
668
- return [x, y];
669
- }
670
-
671
- function snapToGrid(grid
672
- /*: [number, number]*/
673
- , pendingX
674
- /*: number*/
675
- , pendingY
676
- /*: number*/
677
- )
678
- /*: [number, number]*/
679
- {
680
- var x = Math.round(pendingX / grid[0]) * grid[0];
681
- var y = Math.round(pendingY / grid[1]) * grid[1];
682
- return [x, y];
683
- }
684
-
685
- function canDragX(draggable
686
- /*: Draggable*/
687
- )
688
- /*: boolean*/
689
- {
690
- return draggable.props.axis === 'both' || draggable.props.axis === 'x';
691
- }
692
-
693
- function canDragY(draggable
694
- /*: Draggable*/
695
- )
696
- /*: boolean*/
697
- {
698
- return draggable.props.axis === 'both' || draggable.props.axis === 'y';
699
- } // Get {x, y} positions from event.
700
-
701
-
702
- function getControlPosition(e
703
- /*: MouseTouchEvent*/
704
- , touchIdentifier
705
- /*: ?number*/
706
- , draggableCore
707
- /*: DraggableCore*/
708
- )
709
- /*: ?ControlPosition*/
710
- {
711
- var touchObj = typeof touchIdentifier === 'number' ? (0, _domFns$1.getTouch)(e, touchIdentifier) : null;
712
- if (typeof touchIdentifier === 'number' && !touchObj) return null; // not the right touch
713
-
714
- var node = findDOMNode(draggableCore); // User can provide an offsetParent if desired.
715
-
716
- var offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
717
- return (0, _domFns$1.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
718
- } // Create an data object exposed by <DraggableCore>'s events
719
-
720
-
721
- function createCoreData(draggable
722
- /*: DraggableCore*/
723
- , x
724
- /*: number*/
725
- , y
726
- /*: number*/
727
- )
728
- /*: DraggableData*/
729
- {
730
- var state = draggable.state;
731
- var isStart = !(0, _shims$1.isNum)(state.lastX);
732
- var node = findDOMNode(draggable);
733
-
734
- if (isStart) {
735
- // If this is our first move, use the x and y as last coords.
736
- return {
737
- node: node,
738
- deltaX: 0,
739
- deltaY: 0,
740
- lastX: x,
741
- lastY: y,
742
- x: x,
743
- y: y
744
- };
745
- } else {
746
- // Otherwise calculate proper values.
747
- return {
748
- node: node,
749
- deltaX: x - state.lastX,
750
- deltaY: y - state.lastY,
751
- lastX: state.lastX,
752
- lastY: state.lastY,
753
- x: x,
754
- y: y
755
- };
756
- }
757
- } // Create an data exposed by <Draggable>'s events
758
-
759
-
760
- function createDraggableData(draggable
761
- /*: Draggable*/
762
- , coreData
763
- /*: DraggableData*/
764
- )
765
- /*: DraggableData*/
766
- {
767
- var scale = draggable.props.scale;
768
- return {
769
- node: coreData.node,
770
- x: draggable.state.x + coreData.deltaX / scale,
771
- y: draggable.state.y + coreData.deltaY / scale,
772
- deltaX: coreData.deltaX / scale,
773
- deltaY: coreData.deltaY / scale,
774
- lastX: draggable.state.x,
775
- lastY: draggable.state.y
776
- };
777
- } // A lot faster than stringify/parse
778
-
779
-
780
- function cloneBounds(bounds
781
- /*: Bounds*/
782
- )
783
- /*: Bounds*/
784
- {
785
- return {
786
- left: bounds.left,
787
- top: bounds.top,
788
- right: bounds.right,
789
- bottom: bounds.bottom
790
- };
791
- }
792
-
793
- function findDOMNode(draggable
794
- /*: Draggable | DraggableCore*/
795
- )
796
- /*: HTMLElement*/
797
- {
798
- var node = draggable.findDOMNode();
799
-
800
- if (!node) {
801
- throw new Error('<DraggableCore>: Unmounted during event!');
802
- } // $FlowIgnore we can't assert on HTMLElement due to tests... FIXME
803
-
804
-
805
- return node;
806
- }
807
-
808
- var DraggableCore$2 = {};
809
-
810
- var log$1 = {};
811
-
812
- Object.defineProperty(log$1, "__esModule", {
813
- value: true
814
- });
815
- log$1.default = log;
816
-
817
- /*eslint no-console:0*/
818
- function log() {
819
- }
820
-
821
- function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof$1(obj); }
822
-
823
- Object.defineProperty(DraggableCore$2, "__esModule", {
824
- value: true
825
- });
826
- DraggableCore$2.default = void 0;
827
-
828
- var React = _interopRequireWildcard(React__namespace.default);
829
-
830
- var _propTypes = _interopRequireDefault(PropTypes__default.default);
831
-
832
- var _reactDom = _interopRequireDefault(require$$2__default.default);
833
-
834
- var _domFns = domFns;
835
-
836
- var _positionFns = positionFns;
837
-
838
- var _shims = shims;
839
-
840
- var _log = _interopRequireDefault(log$1);
841
-
842
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
843
-
844
- 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); }
845
-
846
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof$1(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 = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
847
-
848
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
849
-
850
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
851
-
852
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
853
-
854
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
855
-
856
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
857
-
858
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
859
-
860
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
861
-
862
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
863
-
864
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
865
-
866
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
867
-
868
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
869
-
870
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
871
-
872
- function _possibleConstructorReturn(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
873
-
874
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
875
-
876
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
877
-
878
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
879
-
880
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
881
-
882
- // Simple abstraction for dragging events names.
883
- var eventsFor = {
884
- touch: {
885
- start: 'touchstart',
886
- move: 'touchmove',
887
- stop: 'touchend'
888
- },
889
- mouse: {
890
- start: 'mousedown',
891
- move: 'mousemove',
892
- stop: 'mouseup'
893
- }
894
- }; // Default to mouse events.
895
-
896
- var dragEventFor = eventsFor.mouse;
897
- /*:: type DraggableCoreState = {
898
- dragging: boolean,
899
- lastX: number,
900
- lastY: number,
901
- touchIdentifier: ?number
902
- };*/
903
-
904
- /*:: export type DraggableData = {
905
- node: HTMLElement,
906
- x: number, y: number,
907
- deltaX: number, deltaY: number,
908
- lastX: number, lastY: number,
909
- };*/
910
-
911
- /*:: export type DraggableEventHandler = (e: MouseEvent, data: DraggableData) => void | false;*/
912
-
913
- /*:: export type ControlPosition = {x: number, y: number};*/
914
-
915
- /*:: export type PositionOffsetControlPosition = {x: number|string, y: number|string};*/
916
-
917
- /*:: export type DraggableCoreDefaultProps = {
918
- allowAnyClick: boolean,
919
- disabled: boolean,
920
- enableUserSelectHack: boolean,
921
- onStart: DraggableEventHandler,
922
- onDrag: DraggableEventHandler,
923
- onStop: DraggableEventHandler,
924
- onMouseDown: (e: MouseEvent) => void,
925
- scale: number,
926
- };*/
927
-
928
- /*:: export type DraggableCoreProps = {
929
- ...DraggableCoreDefaultProps,
930
- cancel: string,
931
- children: ReactElement<any>,
932
- offsetParent: HTMLElement,
933
- grid: [number, number],
934
- handle: string,
935
- nodeRef?: ?React.ElementRef<any>,
936
- };*/
937
-
938
- //
939
- // Define <DraggableCore>.
940
- //
941
- // <DraggableCore> is for advanced usage of <Draggable>. It maintains minimal internal state so it can
942
- // work well with libraries that require more control over the element.
943
- //
944
- var DraggableCore$1 = /*#__PURE__*/function (_React$Component) {
945
- _inherits(DraggableCore, _React$Component);
946
-
947
- var _super = _createSuper(DraggableCore);
948
-
949
- function DraggableCore() {
950
- var _this;
951
-
952
- _classCallCheck(this, DraggableCore);
953
-
954
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
955
- args[_key] = arguments[_key];
956
- }
957
-
958
- _this = _super.call.apply(_super, [this].concat(args));
959
-
960
- _defineProperty(_assertThisInitialized(_this), "state", {
961
- dragging: false,
962
- // Used while dragging to determine deltas.
963
- lastX: NaN,
964
- lastY: NaN,
965
- touchIdentifier: null
966
- });
967
-
968
- _defineProperty(_assertThisInitialized(_this), "mounted", false);
969
-
970
- _defineProperty(_assertThisInitialized(_this), "handleDragStart", function (e) {
971
- // Make it possible to attach event handlers on top of this one.
972
- _this.props.onMouseDown(e); // Only accept left-clicks.
973
-
974
-
975
- if (!_this.props.allowAnyClick && typeof e.button === 'number' && e.button !== 0) return false; // Get nodes. Be sure to grab relative document (could be iframed)
976
-
977
- var thisNode = _this.findDOMNode();
978
-
979
- if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) {
980
- throw new Error('<DraggableCore> not mounted on DragStart!');
981
- }
982
-
983
- var ownerDocument = thisNode.ownerDocument; // Short circuit if handle or cancel prop was provided and selector doesn't match.
984
-
985
- if (_this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || _this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.handle, thisNode) || _this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.cancel, thisNode)) {
986
- return;
987
- } // Prevent scrolling on mobile devices, like ipad/iphone.
988
- // Important that this is after handle/cancel.
989
-
990
-
991
- if (e.type === 'touchstart') e.preventDefault(); // Set touch identifier in component state if this is a touch event. This allows us to
992
- // distinguish between individual touches on multitouch screens by identifying which
993
- // touchpoint was set to this element.
994
-
995
- var touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
996
-
997
- _this.setState({
998
- touchIdentifier: touchIdentifier
999
- }); // Get the current drag point from the event. This is used as the offset.
1000
-
1001
-
1002
- var position = (0, _positionFns.getControlPosition)(e, touchIdentifier, _assertThisInitialized(_this));
1003
- if (position == null) return; // not possible but satisfies flow
1004
-
1005
- var x = position.x,
1006
- y = position.y; // Create an event object with all the data parents need to make a decision here.
1007
-
1008
- var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y);
1009
- (0, _log.default)('DraggableCore: handleDragStart: %j', coreEvent); // Call event handler. If it returns explicit false, cancel.
1010
-
1011
- (0, _log.default)('calling', _this.props.onStart);
1012
-
1013
- var shouldUpdate = _this.props.onStart(e, coreEvent);
1014
-
1015
- if (shouldUpdate === false || _this.mounted === false) return; // Add a style to the body to disable user-select. This prevents text from
1016
- // being selected all over the page.
1017
-
1018
- if (_this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument); // Initiate dragging. Set the current x and y as offsets
1019
- // so we know how much we've moved during the drag. This allows us
1020
- // to drag elements around even if they have been moved, without issue.
1021
-
1022
- _this.setState({
1023
- dragging: true,
1024
- lastX: x,
1025
- lastY: y
1026
- }); // Add events to the document directly so we catch when the user's mouse/touch moves outside of
1027
- // this element. We use different events depending on whether or not we have detected that this
1028
- // is a touch-capable device.
1029
-
1030
-
1031
- (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, _this.handleDrag);
1032
- (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, _this.handleDragStop);
1033
- });
1034
-
1035
- _defineProperty(_assertThisInitialized(_this), "handleDrag", function (e) {
1036
- // Get the current drag point from the event. This is used as the offset.
1037
- var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _assertThisInitialized(_this));
1038
- if (position == null) return;
1039
- var x = position.x,
1040
- y = position.y; // Snap to grid if prop has been provided
1041
-
1042
- if (Array.isArray(_this.props.grid)) {
1043
- var deltaX = x - _this.state.lastX,
1044
- deltaY = y - _this.state.lastY;
1045
-
1046
- var _snapToGrid = (0, _positionFns.snapToGrid)(_this.props.grid, deltaX, deltaY);
1047
-
1048
- var _snapToGrid2 = _slicedToArray(_snapToGrid, 2);
1049
-
1050
- deltaX = _snapToGrid2[0];
1051
- deltaY = _snapToGrid2[1];
1052
- if (!deltaX && !deltaY) return; // skip useless drag
1053
-
1054
- x = _this.state.lastX + deltaX, y = _this.state.lastY + deltaY;
1055
- }
1056
-
1057
- var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y);
1058
- (0, _log.default)('DraggableCore: handleDrag: %j', coreEvent); // Call event handler. If it returns explicit false, trigger end.
1059
-
1060
- var shouldUpdate = _this.props.onDrag(e, coreEvent);
1061
-
1062
- if (shouldUpdate === false || _this.mounted === false) {
1063
- try {
1064
- // $FlowIgnore
1065
- _this.handleDragStop(new MouseEvent('mouseup'));
1066
- } catch (err) {
1067
- // Old browsers
1068
- var event = ((document.createEvent('MouseEvents')
1069
- /*: any*/
1070
- )
1071
- /*: MouseTouchEvent*/
1072
- ); // I see why this insanity was deprecated
1073
- // $FlowIgnore
1074
-
1075
- event.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
1076
-
1077
- _this.handleDragStop(event);
1078
- }
1079
-
1080
- return;
1081
- }
1082
-
1083
- _this.setState({
1084
- lastX: x,
1085
- lastY: y
1086
- });
1087
- });
1088
-
1089
- _defineProperty(_assertThisInitialized(_this), "handleDragStop", function (e) {
1090
- if (!_this.state.dragging) return;
1091
- var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _assertThisInitialized(_this));
1092
- if (position == null) return;
1093
- var x = position.x,
1094
- y = position.y; // Snap to grid if prop has been provided
1095
-
1096
- if (Array.isArray(_this.props.grid)) {
1097
- var deltaX = x - _this.state.lastX || 0;
1098
- var deltaY = y - _this.state.lastY || 0;
1099
-
1100
- var _snapToGrid3 = (0, _positionFns.snapToGrid)(_this.props.grid, deltaX, deltaY);
1101
-
1102
- var _snapToGrid4 = _slicedToArray(_snapToGrid3, 2);
1103
-
1104
- deltaX = _snapToGrid4[0];
1105
- deltaY = _snapToGrid4[1];
1106
- x = _this.state.lastX + deltaX, y = _this.state.lastY + deltaY;
1107
- }
1108
-
1109
- var coreEvent = (0, _positionFns.createCoreData)(_assertThisInitialized(_this), x, y); // Call event handler
1110
-
1111
- var shouldContinue = _this.props.onStop(e, coreEvent);
1112
-
1113
- if (shouldContinue === false || _this.mounted === false) return false;
1114
-
1115
- var thisNode = _this.findDOMNode();
1116
-
1117
- if (thisNode) {
1118
- // Remove user-select hack
1119
- if (_this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(thisNode.ownerDocument);
1120
- }
1121
-
1122
- (0, _log.default)('DraggableCore: handleDragStop: %j', coreEvent); // Reset the el.
1123
-
1124
- _this.setState({
1125
- dragging: false,
1126
- lastX: NaN,
1127
- lastY: NaN
1128
- });
1129
-
1130
- if (thisNode) {
1131
- // Remove event handlers
1132
- (0, _log.default)('DraggableCore: Removing handlers');
1133
- (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, _this.handleDrag);
1134
- (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, _this.handleDragStop);
1135
- }
1136
- });
1137
-
1138
- _defineProperty(_assertThisInitialized(_this), "onMouseDown", function (e) {
1139
- dragEventFor = eventsFor.mouse; // on touchscreen laptops we could switch back to mouse
1140
-
1141
- return _this.handleDragStart(e);
1142
- });
1143
-
1144
- _defineProperty(_assertThisInitialized(_this), "onMouseUp", function (e) {
1145
- dragEventFor = eventsFor.mouse;
1146
- return _this.handleDragStop(e);
1147
- });
1148
-
1149
- _defineProperty(_assertThisInitialized(_this), "onTouchStart", function (e) {
1150
- // We're on a touch device now, so change the event handlers
1151
- dragEventFor = eventsFor.touch;
1152
- return _this.handleDragStart(e);
1153
- });
1154
-
1155
- _defineProperty(_assertThisInitialized(_this), "onTouchEnd", function (e) {
1156
- // We're on a touch device now, so change the event handlers
1157
- dragEventFor = eventsFor.touch;
1158
- return _this.handleDragStop(e);
1159
- });
1160
-
1161
- return _this;
1162
- }
1163
-
1164
- _createClass(DraggableCore, [{
1165
- key: "componentDidMount",
1166
- value: function componentDidMount() {
1167
- this.mounted = true; // Touch handlers must be added with {passive: false} to be cancelable.
1168
- // https://developers.google.com/web/updates/2017/01/scrolling-intervention
1169
-
1170
- var thisNode = this.findDOMNode();
1171
-
1172
- if (thisNode) {
1173
- (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
1174
- passive: false
1175
- });
1176
- }
1177
- }
1178
- }, {
1179
- key: "componentWillUnmount",
1180
- value: function componentWillUnmount() {
1181
- this.mounted = false; // Remove any leftover event handlers. Remove both touch and mouse handlers in case
1182
- // some browser quirk caused a touch event to fire during a mouse move, or vice versa.
1183
-
1184
- var thisNode = this.findDOMNode();
1185
-
1186
- if (thisNode) {
1187
- var ownerDocument = thisNode.ownerDocument;
1188
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
1189
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
1190
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
1191
- (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
1192
- (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, {
1193
- passive: false
1194
- });
1195
- if (this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(ownerDocument);
1196
- }
1197
- } // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
1198
- // the underlying DOM node ourselves. See the README for more information.
1199
-
1200
- }, {
1201
- key: "findDOMNode",
1202
- value: function findDOMNode()
1203
- /*: ?HTMLElement*/
1204
- {
1205
- var _this$props, _this$props2, _this$props2$nodeRef;
1206
-
1207
- return (_this$props = this.props) !== null && _this$props !== void 0 && _this$props.nodeRef ? (_this$props2 = this.props) === null || _this$props2 === void 0 ? void 0 : (_this$props2$nodeRef = _this$props2.nodeRef) === null || _this$props2$nodeRef === void 0 ? void 0 : _this$props2$nodeRef.current : _reactDom.default.findDOMNode(this);
1208
- }
1209
- }, {
1210
- key: "render",
1211
- value: function render()
1212
- /*: React.Element<any>*/
1213
- {
1214
- // Reuse the child provided
1215
- // This makes it flexible to use whatever element is wanted (div, ul, etc)
1216
- return /*#__PURE__*/React.cloneElement(React.Children.only(this.props.children), {
1217
- // Note: mouseMove handler is attached to document so it will still function
1218
- // when the user drags quickly and leaves the bounds of the element.
1219
- onMouseDown: this.onMouseDown,
1220
- onMouseUp: this.onMouseUp,
1221
- // onTouchStart is added on `componentDidMount` so they can be added with
1222
- // {passive: false}, which allows it to cancel. See
1223
- // https://developers.google.com/web/updates/2017/01/scrolling-intervention
1224
- onTouchEnd: this.onTouchEnd
1225
- });
1226
- }
1227
- }]);
1228
-
1229
- return DraggableCore;
1230
- }(React.Component);
1231
-
1232
- DraggableCore$2.default = DraggableCore$1;
1233
-
1234
- _defineProperty(DraggableCore$1, "displayName", 'DraggableCore');
1235
-
1236
- _defineProperty(DraggableCore$1, "propTypes", {
1237
- /**
1238
- * `allowAnyClick` allows dragging using any mouse button.
1239
- * By default, we only accept the left button.
1240
- *
1241
- * Defaults to `false`.
1242
- */
1243
- allowAnyClick: _propTypes.default.bool,
1244
-
1245
- /**
1246
- * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
1247
- * with the exception of `onMouseDown`, will not fire.
1248
- */
1249
- disabled: _propTypes.default.bool,
1250
-
1251
- /**
1252
- * By default, we add 'user-select:none' attributes to the document body
1253
- * to prevent ugly text selection during drag. If this is causing problems
1254
- * for your app, set this to `false`.
1255
- */
1256
- enableUserSelectHack: _propTypes.default.bool,
1257
-
1258
- /**
1259
- * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
1260
- * instead of using the parent node.
1261
- */
1262
- offsetParent: function offsetParent(props
1263
- /*: DraggableCoreProps*/
1264
- , propName
1265
- /*: $Keys<DraggableCoreProps>*/
1266
- ) {
1267
- if (props[propName] && props[propName].nodeType !== 1) {
1268
- throw new Error('Draggable\'s offsetParent must be a DOM Node.');
1269
- }
1270
- },
1271
-
1272
- /**
1273
- * `grid` specifies the x and y that dragging should snap to.
1274
- */
1275
- grid: _propTypes.default.arrayOf(_propTypes.default.number),
1276
-
1277
- /**
1278
- * `handle` specifies a selector to be used as the handle that initiates drag.
1279
- *
1280
- * Example:
1281
- *
1282
- * ```jsx
1283
- * let App = React.createClass({
1284
- * render: function () {
1285
- * return (
1286
- * <Draggable handle=".handle">
1287
- * <div>
1288
- * <div className="handle">Click me to drag</div>
1289
- * <div>This is some other content</div>
1290
- * </div>
1291
- * </Draggable>
1292
- * );
1293
- * }
1294
- * });
1295
- * ```
1296
- */
1297
- handle: _propTypes.default.string,
1298
-
1299
- /**
1300
- * `cancel` specifies a selector to be used to prevent drag initialization.
1301
- *
1302
- * Example:
1303
- *
1304
- * ```jsx
1305
- * let App = React.createClass({
1306
- * render: function () {
1307
- * return(
1308
- * <Draggable cancel=".cancel">
1309
- * <div>
1310
- * <div className="cancel">You can't drag from here</div>
1311
- * <div>Dragging here works fine</div>
1312
- * </div>
1313
- * </Draggable>
1314
- * );
1315
- * }
1316
- * });
1317
- * ```
1318
- */
1319
- cancel: _propTypes.default.string,
1320
-
1321
- /* If running in React Strict mode, ReactDOM.findDOMNode() is deprecated.
1322
- * Unfortunately, in order for <Draggable> to work properly, we need raw access
1323
- * to the underlying DOM node. If you want to avoid the warning, pass a `nodeRef`
1324
- * as in this example:
1325
- *
1326
- * function MyComponent() {
1327
- * const nodeRef = React.useRef(null);
1328
- * return (
1329
- * <Draggable nodeRef={nodeRef}>
1330
- * <div ref={nodeRef}>Example Target</div>
1331
- * </Draggable>
1332
- * );
1333
- * }
1334
- *
1335
- * This can be used for arbitrarily nested components, so long as the ref ends up
1336
- * pointing to the actual child DOM node and not a custom component.
1337
- */
1338
- nodeRef: _propTypes.default.object,
1339
-
1340
- /**
1341
- * Called when dragging starts.
1342
- * If this function returns the boolean false, dragging will be canceled.
1343
- */
1344
- onStart: _propTypes.default.func,
1345
-
1346
- /**
1347
- * Called while dragging.
1348
- * If this function returns the boolean false, dragging will be canceled.
1349
- */
1350
- onDrag: _propTypes.default.func,
1351
-
1352
- /**
1353
- * Called when dragging stops.
1354
- * If this function returns the boolean false, the drag will remain active.
1355
- */
1356
- onStop: _propTypes.default.func,
1357
-
1358
- /**
1359
- * A workaround option which can be passed if onMouseDown needs to be accessed,
1360
- * since it'll always be blocked (as there is internal use of onMouseDown)
1361
- */
1362
- onMouseDown: _propTypes.default.func,
1363
-
1364
- /**
1365
- * `scale`, if set, applies scaling while dragging an element
1366
- */
1367
- scale: _propTypes.default.number,
1368
-
1369
- /**
1370
- * These properties should be defined on the child, not here.
1371
- */
1372
- className: _shims.dontSetMe,
1373
- style: _shims.dontSetMe,
1374
- transform: _shims.dontSetMe
1375
- });
1376
-
1377
- _defineProperty(DraggableCore$1, "defaultProps", {
1378
- allowAnyClick: false,
1379
- // by default only accept left click
1380
- disabled: false,
1381
- enableUserSelectHack: true,
1382
- onStart: function onStart() {},
1383
- onDrag: function onDrag() {},
1384
- onStop: function onStop() {},
1385
- onMouseDown: function onMouseDown() {},
1386
- scale: 1
1387
- });
1388
-
1389
- (function (exports) {
1390
-
1391
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1392
-
1393
- Object.defineProperty(exports, "__esModule", {
1394
- value: true
1395
- });
1396
- Object.defineProperty(exports, "DraggableCore", {
1397
- enumerable: true,
1398
- get: function get() {
1399
- return _DraggableCore.default;
1400
- }
1401
- });
1402
- exports.default = void 0;
1403
-
1404
- var React = _interopRequireWildcard(React__namespace.default);
1405
-
1406
- var _propTypes = _interopRequireDefault(PropTypes__default.default);
1407
-
1408
- var _reactDom = _interopRequireDefault(require$$2__default.default);
1409
-
1410
- var _clsx2 = _interopRequireDefault(clsx__default.default);
1411
-
1412
- var _domFns = domFns;
1413
-
1414
- var _positionFns = positionFns;
1415
-
1416
- var _shims = shims;
1417
-
1418
- var _DraggableCore = _interopRequireDefault(DraggableCore$2);
1419
-
1420
- var _log = _interopRequireDefault(log$1);
1421
-
1422
- var _excluded = ["axis", "bounds", "children", "defaultPosition", "defaultClassName", "defaultClassNameDragging", "defaultClassNameDragged", "position", "positionOffset", "scale"];
1423
-
1424
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1425
-
1426
- 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); }
1427
-
1428
- 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 = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1429
-
1430
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1431
-
1432
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1433
-
1434
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1435
-
1436
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1437
-
1438
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1439
-
1440
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1441
-
1442
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1443
-
1444
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1445
-
1446
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1447
-
1448
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1449
-
1450
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1451
-
1452
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1453
-
1454
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1455
-
1456
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1457
-
1458
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
1459
-
1460
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1461
-
1462
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1463
-
1464
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1465
-
1466
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1467
-
1468
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1469
-
1470
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1471
-
1472
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1473
-
1474
- //
1475
- // Define <Draggable>
1476
- //
1477
- var Draggable = /*#__PURE__*/function (_React$Component) {
1478
- _inherits(Draggable, _React$Component);
1479
-
1480
- var _super = _createSuper(Draggable);
1481
-
1482
- function Draggable(props
1483
- /*: DraggableProps*/
1484
- ) {
1485
- var _this;
1486
-
1487
- _classCallCheck(this, Draggable);
1488
-
1489
- _this = _super.call(this, props);
1490
-
1491
- _defineProperty(_assertThisInitialized(_this), "onDragStart", function (e, coreData) {
1492
- (0, _log.default)('Draggable: onDragStart: %j', coreData); // Short-circuit if user's callback killed it.
1493
-
1494
- var shouldStart = _this.props.onStart(e, (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData)); // Kills start event on core as well, so move handlers are never bound.
1495
-
1496
-
1497
- if (shouldStart === false) return false;
1498
-
1499
- _this.setState({
1500
- dragging: true,
1501
- dragged: true
1502
- });
1503
- });
1504
-
1505
- _defineProperty(_assertThisInitialized(_this), "onDrag", function (e, coreData) {
1506
- if (!_this.state.dragging) return false;
1507
- (0, _log.default)('Draggable: onDrag: %j', coreData);
1508
- var uiData = (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData);
1509
- var newState
1510
- /*: $Shape<DraggableState>*/
1511
- = {
1512
- x: uiData.x,
1513
- y: uiData.y
1514
- }; // Keep within bounds.
1515
-
1516
- if (_this.props.bounds) {
1517
- // Save original x and y.
1518
- var x = newState.x,
1519
- y = newState.y; // Add slack to the values used to calculate bound position. This will ensure that if
1520
- // we start removing slack, the element won't react to it right away until it's been
1521
- // completely removed.
1522
-
1523
- newState.x += _this.state.slackX;
1524
- newState.y += _this.state.slackY; // Get bound position. This will ceil/floor the x and y within the boundaries.
1525
-
1526
- var _getBoundPosition = (0, _positionFns.getBoundPosition)(_assertThisInitialized(_this), newState.x, newState.y),
1527
- _getBoundPosition2 = _slicedToArray(_getBoundPosition, 2),
1528
- newStateX = _getBoundPosition2[0],
1529
- newStateY = _getBoundPosition2[1];
1530
-
1531
- newState.x = newStateX;
1532
- newState.y = newStateY; // Recalculate slack by noting how much was shaved by the boundPosition handler.
1533
-
1534
- newState.slackX = _this.state.slackX + (x - newState.x);
1535
- newState.slackY = _this.state.slackY + (y - newState.y); // Update the event we fire to reflect what really happened after bounds took effect.
1536
-
1537
- uiData.x = newState.x;
1538
- uiData.y = newState.y;
1539
- uiData.deltaX = newState.x - _this.state.x;
1540
- uiData.deltaY = newState.y - _this.state.y;
1541
- } // Short-circuit if user's callback killed it.
1542
-
1543
-
1544
- var shouldUpdate = _this.props.onDrag(e, uiData);
1545
-
1546
- if (shouldUpdate === false) return false;
1547
-
1548
- _this.setState(newState);
1549
- });
1550
-
1551
- _defineProperty(_assertThisInitialized(_this), "onDragStop", function (e, coreData) {
1552
- if (!_this.state.dragging) return false; // Short-circuit if user's callback killed it.
1553
-
1554
- var shouldContinue = _this.props.onStop(e, (0, _positionFns.createDraggableData)(_assertThisInitialized(_this), coreData));
1555
-
1556
- if (shouldContinue === false) return false;
1557
- (0, _log.default)('Draggable: onDragStop: %j', coreData);
1558
- var newState
1559
- /*: $Shape<DraggableState>*/
1560
- = {
1561
- dragging: false,
1562
- slackX: 0,
1563
- slackY: 0
1564
- }; // If this is a controlled component, the result of this operation will be to
1565
- // revert back to the old position. We expect a handler on `onDragStop`, at the least.
1566
-
1567
- var controlled = Boolean(_this.props.position);
1568
-
1569
- if (controlled) {
1570
- var _this$props$position = _this.props.position,
1571
- x = _this$props$position.x,
1572
- y = _this$props$position.y;
1573
- newState.x = x;
1574
- newState.y = y;
1575
- }
1576
-
1577
- _this.setState(newState);
1578
- });
1579
-
1580
- _this.state = {
1581
- // Whether or not we are currently dragging.
1582
- dragging: false,
1583
- // Whether or not we have been dragged before.
1584
- dragged: false,
1585
- // Current transform x and y.
1586
- x: props.position ? props.position.x : props.defaultPosition.x,
1587
- y: props.position ? props.position.y : props.defaultPosition.y,
1588
- prevPropsPosition: _objectSpread({}, props.position),
1589
- // Used for compensating for out-of-bounds drags
1590
- slackX: 0,
1591
- slackY: 0,
1592
- // Can only determine if SVG after mounting
1593
- isElementSVG: false
1594
- };
1595
-
1596
- if (props.position && !(props.onDrag || props.onStop)) {
1597
- // eslint-disable-next-line no-console
1598
- console.warn('A `position` was applied to this <Draggable>, without drag handlers. This will make this ' + 'component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the ' + '`position` of this element.');
1599
- }
1600
-
1601
- return _this;
1602
- }
1603
-
1604
- _createClass(Draggable, [{
1605
- key: "componentDidMount",
1606
- value: function componentDidMount() {
1607
- // Check to see if the element passed is an instanceof SVGElement
1608
- if (typeof window.SVGElement !== 'undefined' && this.findDOMNode() instanceof window.SVGElement) {
1609
- this.setState({
1610
- isElementSVG: true
1611
- });
1612
- }
1613
- }
1614
- }, {
1615
- key: "componentWillUnmount",
1616
- value: function componentWillUnmount() {
1617
- this.setState({
1618
- dragging: false
1619
- }); // prevents invariant if unmounted while dragging
1620
- } // React Strict Mode compatibility: if `nodeRef` is passed, we will use it instead of trying to find
1621
- // the underlying DOM node ourselves. See the README for more information.
1622
-
1623
- }, {
1624
- key: "findDOMNode",
1625
- value: function findDOMNode()
1626
- /*: ?HTMLElement*/
1627
- {
1628
- var _this$props$nodeRef$c, _this$props, _this$props$nodeRef;
1629
-
1630
- return (_this$props$nodeRef$c = (_this$props = this.props) === null || _this$props === void 0 ? void 0 : (_this$props$nodeRef = _this$props.nodeRef) === null || _this$props$nodeRef === void 0 ? void 0 : _this$props$nodeRef.current) !== null && _this$props$nodeRef$c !== void 0 ? _this$props$nodeRef$c : _reactDom.default.findDOMNode(this);
1631
- }
1632
- }, {
1633
- key: "render",
1634
- value: function render()
1635
- /*: ReactElement<any>*/
1636
- {
1637
- var _clsx;
1638
-
1639
- var _this$props2 = this.props;
1640
- _this$props2.axis;
1641
- _this$props2.bounds;
1642
- var children = _this$props2.children,
1643
- defaultPosition = _this$props2.defaultPosition,
1644
- defaultClassName = _this$props2.defaultClassName,
1645
- defaultClassNameDragging = _this$props2.defaultClassNameDragging,
1646
- defaultClassNameDragged = _this$props2.defaultClassNameDragged,
1647
- position = _this$props2.position,
1648
- positionOffset = _this$props2.positionOffset;
1649
- _this$props2.scale;
1650
- var draggableCoreProps = _objectWithoutProperties(_this$props2, _excluded);
1651
-
1652
- var style = {};
1653
- var svgTransform = null; // If this is controlled, we don't want to move it - unless it's dragging.
1654
-
1655
- var controlled = Boolean(position);
1656
- var draggable = !controlled || this.state.dragging;
1657
- var validPosition = position || defaultPosition;
1658
- var transformOpts = {
1659
- // Set left if horizontal drag is enabled
1660
- x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
1661
- // Set top if vertical drag is enabled
1662
- y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
1663
- }; // If this element was SVG, we use the `transform` attribute.
1664
-
1665
- if (this.state.isElementSVG) {
1666
- svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
1667
- } else {
1668
- // Add a CSS transform to move the element around. This allows us to move the element around
1669
- // without worrying about whether or not it is relatively or absolutely positioned.
1670
- // If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
1671
- // has a clean slate.
1672
- style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
1673
- } // Mark with class while dragging
1674
-
1675
-
1676
- var className = (0, _clsx2.default)(children.props.className || '', defaultClassName, (_clsx = {}, _defineProperty(_clsx, defaultClassNameDragging, this.state.dragging), _defineProperty(_clsx, defaultClassNameDragged, this.state.dragged), _clsx)); // Reuse the child provided
1677
- // This makes it flexible to use whatever element is wanted (div, ul, etc)
1678
-
1679
- return /*#__PURE__*/React.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
1680
- onStart: this.onDragStart,
1681
- onDrag: this.onDrag,
1682
- onStop: this.onDragStop
1683
- }), /*#__PURE__*/React.cloneElement(React.Children.only(children), {
1684
- className: className,
1685
- style: _objectSpread(_objectSpread({}, children.props.style), style),
1686
- transform: svgTransform
1687
- }));
1688
- }
1689
- }], [{
1690
- key: "getDerivedStateFromProps",
1691
- value: // React 16.3+
1692
- // Arity (props, state)
1693
- function getDerivedStateFromProps(_ref, _ref2)
1694
- /*: ?$Shape<DraggableState>*/
1695
- {
1696
- var position = _ref.position;
1697
- var prevPropsPosition = _ref2.prevPropsPosition;
1698
-
1699
- // Set x/y if a new position is provided in props that is different than the previous.
1700
- if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
1701
- (0, _log.default)('Draggable: getDerivedStateFromProps %j', {
1702
- position: position,
1703
- prevPropsPosition: prevPropsPosition
1704
- });
1705
- return {
1706
- x: position.x,
1707
- y: position.y,
1708
- prevPropsPosition: _objectSpread({}, position)
1709
- };
1710
- }
1711
-
1712
- return null;
1713
- }
1714
- }]);
1715
-
1716
- return Draggable;
1717
- }(React.Component);
1718
-
1719
- exports.default = Draggable;
1720
-
1721
- _defineProperty(Draggable, "displayName", 'Draggable');
1722
-
1723
- _defineProperty(Draggable, "propTypes", _objectSpread(_objectSpread({}, _DraggableCore.default.propTypes), {}, {
1724
- /**
1725
- * `axis` determines which axis the draggable can move.
1726
- *
1727
- * Note that all callbacks will still return data as normal. This only
1728
- * controls flushing to the DOM.
1729
- *
1730
- * 'both' allows movement horizontally and vertically.
1731
- * 'x' limits movement to horizontal axis.
1732
- * 'y' limits movement to vertical axis.
1733
- * 'none' limits all movement.
1734
- *
1735
- * Defaults to 'both'.
1736
- */
1737
- axis: _propTypes.default.oneOf(['both', 'x', 'y', 'none']),
1738
-
1739
- /**
1740
- * `bounds` determines the range of movement available to the element.
1741
- * Available values are:
1742
- *
1743
- * 'parent' restricts movement within the Draggable's parent node.
1744
- *
1745
- * Alternatively, pass an object with the following properties, all of which are optional:
1746
- *
1747
- * {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
1748
- *
1749
- * All values are in px.
1750
- *
1751
- * Example:
1752
- *
1753
- * ```jsx
1754
- * let App = React.createClass({
1755
- * render: function () {
1756
- * return (
1757
- * <Draggable bounds={{right: 300, bottom: 300}}>
1758
- * <div>Content</div>
1759
- * </Draggable>
1760
- * );
1761
- * }
1762
- * });
1763
- * ```
1764
- */
1765
- bounds: _propTypes.default.oneOfType([_propTypes.default.shape({
1766
- left: _propTypes.default.number,
1767
- right: _propTypes.default.number,
1768
- top: _propTypes.default.number,
1769
- bottom: _propTypes.default.number
1770
- }), _propTypes.default.string, _propTypes.default.oneOf([false])]),
1771
- defaultClassName: _propTypes.default.string,
1772
- defaultClassNameDragging: _propTypes.default.string,
1773
- defaultClassNameDragged: _propTypes.default.string,
1774
-
1775
- /**
1776
- * `defaultPosition` specifies the x and y that the dragged item should start at
1777
- *
1778
- * Example:
1779
- *
1780
- * ```jsx
1781
- * let App = React.createClass({
1782
- * render: function () {
1783
- * return (
1784
- * <Draggable defaultPosition={{x: 25, y: 25}}>
1785
- * <div>I start with transformX: 25px and transformY: 25px;</div>
1786
- * </Draggable>
1787
- * );
1788
- * }
1789
- * });
1790
- * ```
1791
- */
1792
- defaultPosition: _propTypes.default.shape({
1793
- x: _propTypes.default.number,
1794
- y: _propTypes.default.number
1795
- }),
1796
- positionOffset: _propTypes.default.shape({
1797
- x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
1798
- y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
1799
- }),
1800
-
1801
- /**
1802
- * `position`, if present, defines the current position of the element.
1803
- *
1804
- * This is similar to how form elements in React work - if no `position` is supplied, the component
1805
- * is uncontrolled.
1806
- *
1807
- * Example:
1808
- *
1809
- * ```jsx
1810
- * let App = React.createClass({
1811
- * render: function () {
1812
- * return (
1813
- * <Draggable position={{x: 25, y: 25}}>
1814
- * <div>I start with transformX: 25px and transformY: 25px;</div>
1815
- * </Draggable>
1816
- * );
1817
- * }
1818
- * });
1819
- * ```
1820
- */
1821
- position: _propTypes.default.shape({
1822
- x: _propTypes.default.number,
1823
- y: _propTypes.default.number
1824
- }),
1825
-
1826
- /**
1827
- * These properties should be defined on the child, not here.
1828
- */
1829
- className: _shims.dontSetMe,
1830
- style: _shims.dontSetMe,
1831
- transform: _shims.dontSetMe
1832
- }));
1833
-
1834
- _defineProperty(Draggable, "defaultProps", _objectSpread(_objectSpread({}, _DraggableCore.default.defaultProps), {}, {
1835
- axis: 'both',
1836
- bounds: false,
1837
- defaultClassName: 'react-draggable',
1838
- defaultClassNameDragging: 'react-draggable-dragging',
1839
- defaultClassNameDragged: 'react-draggable-dragged',
1840
- defaultPosition: {
1841
- x: 0,
1842
- y: 0
1843
- },
1844
- scale: 1
1845
- }));
1846
- } (Draggable$1));
1847
-
1848
- var _require = Draggable$1,
1849
- Draggable = _require.default,
1850
- DraggableCore = _require.DraggableCore; // Previous versions of this lib exported <Draggable> as the root export. As to no-// them, or TypeScript, we export *both* as the root and as 'default'.
1851
- // See https://github.com/mzabriskie/react-draggable/pull/254
1852
- // and https://github.com/mzabriskie/react-draggable/issues/266
1853
-
1854
-
1855
- cjs.exports = Draggable;
1856
- cjs.exports.default = Draggable;
1857
- var DraggableCore_1 = cjs.exports.DraggableCore = DraggableCore;
1858
-
1859
- /******************************************************************************
1860
- Copyright (c) Microsoft Corporation.
1861
-
1862
- Permission to use, copy, modify, and/or distribute this software for any
1863
- purpose with or without fee is hereby granted.
1864
-
1865
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1866
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1867
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1868
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1869
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1870
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1871
- PERFORMANCE OF THIS SOFTWARE.
1872
- ***************************************************************************** */
1873
- /* global Reflect, Promise */
1874
-
1875
- var extendStatics = function(d, b) {
1876
- extendStatics = Object.setPrototypeOf ||
1877
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1878
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1879
- return extendStatics(d, b);
1880
- };
1881
-
1882
- function __extends(d, b) {
1883
- if (typeof b !== "function" && b !== null)
1884
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1885
- extendStatics(d, b);
1886
- function __() { this.constructor = d; }
1887
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1888
- }
1889
-
1890
- var __assign = function() {
1891
- __assign = Object.assign || function __assign(t) {
1892
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1893
- s = arguments[i];
1894
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1895
- }
1896
- return t;
1897
- };
1898
- return __assign.apply(this, arguments);
1899
- };
1900
-
1901
- function __rest(s, e) {
1902
- var t = {};
1903
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1904
- t[p] = s[p];
1905
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
1906
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1907
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1908
- t[p[i]] = s[p[i]];
1909
- }
1910
- return t;
1911
- }
1912
-
1913
- function __spreadArray(to, from, pack) {
1914
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1915
- if (ar || !(i in from)) {
1916
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1917
- ar[i] = from[i];
1918
- }
1919
- }
1920
- return to.concat(ar || Array.prototype.slice.call(from));
1921
- }
1922
-
1923
- function _typeof(obj) {
1924
- "@babel/helpers - typeof";
1925
-
1926
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1927
- return typeof obj;
1928
- } : function (obj) {
1929
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1930
- }, _typeof(obj);
1931
- }
1932
-
1933
- var doc = (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object' ? document : null;
1934
- var isBrowser = typeof window !== 'undefined' && typeof navigator !== 'undefined' && typeof document !== 'undefined';
1935
- var isUndef = function isUndef(v) {
1936
- return typeof v === 'undefined';
1937
- };
1938
- var isFun = function isFun(v) {
1939
- return typeof v === 'function';
1940
- };
1941
- var isNum = function isNum(v) {
1942
- return typeof v === 'number';
1943
- };
1944
- /**
1945
- * @description Will return renderer result if presented, div element otherwise.
1946
- * If renderer is presented it'll receive `elementRef` function which should be used as HTMLElement's ref.
1947
- *
1948
- * @param props {ElementPropsWithElementRefAndRenderer}
1949
- * @param elementRef {ElementRef}
1950
- */
1951
-
1952
- var renderDivWithRenderer = function renderDivWithRenderer(props, elementRef) {
1953
- if (isFun(props.renderer)) {
1954
- props.elementRef = elementRef;
1955
- var renderer = props.renderer;
1956
- delete props.renderer;
1957
- return renderer(props);
1958
- }
1959
-
1960
- delete props.elementRef;
1961
- return React__namespace.createElement("div", __assign({}, props, {
1962
- ref: elementRef
1963
- }));
1964
- };
1965
-
1966
- var getInnerSize = function getInnerSize(el, dimension, padding1, padding2) {
1967
- var styles = getComputedStyle(el);
1968
-
1969
- if (styles.boxSizing === 'border-box') {
1970
- return Math.max(0, (Number.parseFloat(styles[dimension]) || 0) - (Number.parseFloat(styles[padding1]) || 0) - (Number.parseFloat(styles[padding2]) || 0));
1971
- }
1972
-
1973
- return Number.parseFloat(styles[dimension]) || 0;
1974
- };
1975
- /**
1976
- * @description Return element's height without padding
1977
- */
1978
-
1979
-
1980
- var getInnerHeight = function getInnerHeight(el) {
1981
- return getInnerSize(el, 'height', 'paddingTop', 'paddingBottom');
1982
- };
1983
- /**
1984
- * @description Return element's width without padding
1985
- */
1986
-
1987
- var getInnerWidth = function getInnerWidth(el) {
1988
- return getInnerSize(el, 'width', 'paddingLeft', 'paddingRight');
1989
- };
1990
- /**
1991
- * @description Return unique UUID v4
1992
- */
1993
-
1994
- var uuid = function uuid() {
1995
- // eslint-disable-next-line @typescript-eslint/no-shadow
1996
- var uuid = '';
1997
-
1998
- for (var i = 0; i < 32; i++) {
1999
- switch (i) {
2000
- case 8:
2001
- case 20:
2002
- {
2003
- uuid += "-".concat(Math.trunc(Math.random() * 16).toString(16));
2004
- break;
2005
- }
2006
-
2007
- case 12:
2008
- {
2009
- uuid += '-4';
2010
- break;
2011
- }
2012
-
2013
- case 16:
2014
- {
2015
- uuid += "-".concat((Math.random() * 16 | 0 & 3 | 8).toString(16));
2016
- break;
2017
- }
2018
-
2019
- default:
2020
- {
2021
- uuid += Math.trunc(Math.random() * 16).toString(16);
2022
- }
2023
- }
2024
- }
2025
-
2026
- return uuid;
2027
- };
2028
- /**
2029
- * @description Calculate thumb size for given viewport and track parameters
2030
- *
2031
- * @param {number} contentSize - Scrollable content size
2032
- * @param {number} viewportSize - Viewport size
2033
- * @param {number} trackSize - Track size thumb can move
2034
- * @param {number} minimalSize - Minimal thumb's size
2035
- * @param {number} maximalSize - Maximal thumb's size
2036
- */
2037
-
2038
- var calcThumbSize = function calcThumbSize(contentSize, viewportSize, trackSize, minimalSize, maximalSize) {
2039
- if (viewportSize >= contentSize) {
2040
- return 0;
2041
- }
2042
-
2043
- var thumbSize = viewportSize / contentSize * trackSize;
2044
-
2045
- if (isNum(maximalSize)) {
2046
- thumbSize = Math.min(maximalSize, thumbSize);
2047
- }
2048
-
2049
- if (isNum(minimalSize)) {
2050
- thumbSize = Math.max(minimalSize, thumbSize);
2051
- }
2052
-
2053
- return thumbSize;
2054
- };
2055
- /**
2056
- * @description Calculate thumb offset for given viewport, track and thumb parameters
2057
- *
2058
- * @param {number} contentSize - Scrollable content size
2059
- * @param {number} viewportSize - Viewport size
2060
- * @param {number} trackSize - Track size thumb can move
2061
- * @param {number} thumbSize - Thumb size
2062
- * @param {number} scroll - Scroll value to represent
2063
- */
2064
-
2065
- var calcThumbOffset = function calcThumbOffset(contentSize, viewportSize, trackSize, thumbSize, scroll) {
2066
- if (!scroll || !thumbSize || viewportSize >= contentSize) {
2067
- return 0;
2068
- }
2069
-
2070
- return (trackSize - thumbSize) * scroll / (contentSize - viewportSize);
2071
- };
2072
- /**
2073
- * @description Calculate scroll for given viewport, track and thumb parameters
2074
- *
2075
- * @param {number} contentSize - Scrollable content size
2076
- * @param {number} viewportSize - Viewport size
2077
- * @param {number} trackSize - Track size thumb can move
2078
- * @param {number} thumbSize - Thumb size
2079
- * @param {number} thumbOffset - Thumb's offset representing the scroll
2080
- */
2081
-
2082
- var calcScrollForThumbOffset = function calcScrollForThumbOffset(contentSize, viewportSize, trackSize, thumbSize, thumbOffset) {
2083
- if (!thumbOffset || !thumbSize || viewportSize >= contentSize) {
2084
- return 0;
2085
- }
2086
-
2087
- return thumbOffset * (contentSize - viewportSize) / (trackSize - thumbSize);
2088
- };
2089
- /**
2090
- * @description Returns scrollbar width specific for current environment. Can return undefined if DOM is not ready yet.
2091
- */
2092
-
2093
- var getScrollbarWidth = function getScrollbarWidth(force) {
2094
- if (force === void 0) {
2095
- force = false;
2096
- }
2097
-
2098
- if (!doc) {
2099
- getScrollbarWidth._cache = 0;
2100
- return getScrollbarWidth._cache;
2101
- }
2102
-
2103
- if (!force && !isUndef(getScrollbarWidth._cache)) {
2104
- return getScrollbarWidth._cache;
2105
- }
2106
-
2107
- var el = doc.createElement('div');
2108
- el.setAttribute('style', 'position:absolute;width:100px;height:100px;top:-999px;left:-999px;overflow:scroll;');
2109
- doc.body.append(el);
2110
- /* istanbul ignore next */
2111
-
2112
- if (el.clientWidth === 0) {
2113
- // Do not even cache this value because there is no calculations. Issue https://github.com/xobotyi/react-scrollbars-custom/issues/123
2114
- el.remove();
2115
- return;
2116
- }
2117
-
2118
- getScrollbarWidth._cache = 100 - el.clientWidth;
2119
- el.remove();
2120
- return getScrollbarWidth._cache;
2121
- };
2122
- /**
2123
- * @description Detect need of horizontal scroll reverse while RTL.
2124
- */
2125
-
2126
- var shouldReverseRtlScroll = function shouldReverseRtlScroll(force) {
2127
- if (force === void 0) {
2128
- force = false;
2129
- }
2130
-
2131
- if (!force && !isUndef(shouldReverseRtlScroll._cache)) {
2132
- return shouldReverseRtlScroll._cache;
2133
- }
2134
-
2135
- if (!doc) {
2136
- shouldReverseRtlScroll._cache = false;
2137
- return shouldReverseRtlScroll._cache;
2138
- }
2139
-
2140
- var el = doc.createElement('div');
2141
- var child = doc.createElement('div');
2142
- el.append(child);
2143
- el.setAttribute('style', 'position:absolute;width:100px;height:100px;top:-999px;left:-999px;overflow:scroll;direction:rtl');
2144
- child.setAttribute('style', 'width:1000px;height:1000px');
2145
- doc.body.append(el);
2146
- el.scrollLeft = -50;
2147
- shouldReverseRtlScroll._cache = el.scrollLeft === -50;
2148
- el.remove();
2149
- return shouldReverseRtlScroll._cache;
2150
- };
2151
-
2152
- var Emittr =
2153
- /** @class */
2154
- function () {
2155
- function Emittr(maxHandlers) {
2156
- if (maxHandlers === void 0) {
2157
- maxHandlers = 10;
2158
- }
2159
-
2160
- this.setMaxHandlers(maxHandlers);
2161
- this._handlers = Object.create(null);
2162
- }
2163
-
2164
- Emittr._callEventHandlers = function (emitter, handlers, args) {
2165
- if (!handlers.length) {
2166
- return;
2167
- }
2168
-
2169
- if (handlers.length === 1) {
2170
- Reflect.apply(handlers[0], emitter, args);
2171
- return;
2172
- }
2173
-
2174
- handlers = __spreadArray([], handlers, true);
2175
- var idx;
2176
-
2177
- for (idx = 0; idx < handlers.length; idx++) {
2178
- Reflect.apply(handlers[idx], emitter, args);
2179
- }
2180
- };
2181
-
2182
- Emittr.prototype.setMaxHandlers = function (count) {
2183
- if (!isNum(count) || count <= 0) {
2184
- throw new TypeError("Expected maxHandlers to be a positive number, got '".concat(count, "' of type ").concat(_typeof(count)));
2185
- }
2186
-
2187
- this._maxHandlers = count;
2188
- return this;
2189
- };
2190
-
2191
- Emittr.prototype.getMaxHandlers = function () {
2192
- return this._maxHandlers;
2193
- };
2194
-
2195
- Emittr.prototype.emit = function (name) {
2196
- var args = [];
2197
-
2198
- for (var _i = 1; _i < arguments.length; _i++) {
2199
- args[_i - 1] = arguments[_i];
2200
- }
2201
-
2202
- if (_typeof(this._handlers[name]) !== 'object' || !Array.isArray(this._handlers[name])) {
2203
- return false;
2204
- }
2205
-
2206
- Emittr._callEventHandlers(this, this._handlers[name], args);
2207
-
2208
- return true;
2209
- };
2210
-
2211
- Emittr.prototype.on = function (name, handler) {
2212
- Emittr._addHandler(this, name, handler);
2213
-
2214
- return this;
2215
- };
2216
-
2217
- Emittr.prototype.prependOn = function (name, handler) {
2218
- Emittr._addHandler(this, name, handler, true);
2219
-
2220
- return this;
2221
- };
2222
-
2223
- Emittr.prototype.once = function (name, handler) {
2224
- if (!isFun(handler)) {
2225
- throw new TypeError("Expected event handler to be a function, got ".concat(_typeof(handler)));
2226
- }
2227
-
2228
- Emittr._addHandler(this, name, this._wrapOnceHandler(name, handler));
2229
-
2230
- return this;
2231
- };
2232
-
2233
- Emittr.prototype.prependOnce = function (name, handler) {
2234
- if (!isFun(handler)) {
2235
- throw new TypeError("Expected event handler to be a function, got ".concat(_typeof(handler)));
2236
- }
2237
-
2238
- Emittr._addHandler(this, name, this._wrapOnceHandler(name, handler), true);
2239
-
2240
- return this;
2241
- };
2242
-
2243
- Emittr.prototype.off = function (name, handler) {
2244
- Emittr._removeHandler(this, name, handler);
2245
-
2246
- return this;
2247
- };
2248
-
2249
- Emittr.prototype.removeAllHandlers = function () {
2250
- var handlers = this._handlers;
2251
- this._handlers = Object.create(null);
2252
- var removeHandlers = handlers.removeHandler;
2253
- delete handlers.removeHandler;
2254
- var idx;
2255
- var eventName; // eslint-disable-next-line guard-for-in,no-restricted-syntax
2256
-
2257
- for (eventName in handlers) {
2258
- for (idx = handlers[eventName].length - 1; idx >= 0; idx--) {
2259
- Emittr._callEventHandlers(this, removeHandlers, [eventName, handlers[eventName][idx].handler || handlers[eventName][idx]]);
2260
- }
2261
- }
2262
-
2263
- return this;
2264
- };
2265
-
2266
- Emittr.prototype._wrapOnceHandler = function (name, handler) {
2267
- var onceState = {
2268
- fired: false,
2269
- handler: handler,
2270
- wrappedHandler: undefined,
2271
- emitter: this,
2272
- event: name
2273
- };
2274
-
2275
- var wrappedHandler = Emittr._onceWrapper.bind(onceState);
2276
-
2277
- onceState.wrappedHandler = wrappedHandler;
2278
- wrappedHandler.handler = handler;
2279
- wrappedHandler.event = name;
2280
- return wrappedHandler;
2281
- };
2282
-
2283
- Emittr._addHandler = function (emitter, name, handler, prepend) {
2284
- if (prepend === void 0) {
2285
- prepend = false;
2286
- }
2287
-
2288
- if (!isFun(handler)) {
2289
- throw new TypeError("Expected event handler to be a function, got ".concat(_typeof(handler)));
2290
- }
2291
-
2292
- emitter._handlers[name] = emitter._handlers[name] || [];
2293
- emitter.emit('addHandler', name, handler);
2294
-
2295
- if (prepend) {
2296
- emitter._handlers[name].unshift(handler);
2297
- } else {
2298
- emitter._handlers[name].push(handler);
2299
- }
2300
-
2301
- return emitter;
2302
- };
2303
-
2304
- Emittr._onceWrapper = function _onceWrapper() {
2305
- var args = [];
2306
-
2307
- for (var _i = 0; _i < arguments.length; _i++) {
2308
- args[_i] = arguments[_i];
2309
- }
2310
-
2311
- if (!this.fired) {
2312
- this.fired = true;
2313
- this.emitter.off(this.event, this.wrappedHandler);
2314
- Reflect.apply(this.handler, this.emitter, args);
2315
- }
2316
- };
2317
-
2318
- Emittr._removeHandler = function (emitter, name, handler) {
2319
- if (!isFun(handler)) {
2320
- throw new TypeError("Expected event handler to be a function, got ".concat(_typeof(handler)));
2321
- }
2322
-
2323
- if (isUndef(emitter._handlers[name]) || !emitter._handlers[name].length) {
2324
- return emitter;
2325
- }
2326
-
2327
- var idx = -1;
2328
-
2329
- if (emitter._handlers[name].length === 1) {
2330
- if (emitter._handlers[name][0] === handler || emitter._handlers[name][0].handler === handler) {
2331
- idx = 0;
2332
- handler = emitter._handlers[name][0].handler || emitter._handlers[name][0];
2333
- }
2334
- } else {
2335
- for (idx = emitter._handlers[name].length - 1; idx >= 0; idx--) {
2336
- if (emitter._handlers[name][idx] === handler || emitter._handlers[name][idx].handler === handler) {
2337
- handler = emitter._handlers[name][idx].handler || emitter._handlers[name][idx];
2338
- break;
2339
- }
2340
- }
2341
- }
2342
-
2343
- if (idx === -1) {
2344
- return emitter;
2345
- }
2346
-
2347
- if (idx === 0) {
2348
- emitter._handlers[name].shift();
2349
- } else {
2350
- emitter._handlers[name].splice(idx, 1);
2351
- }
2352
-
2353
- emitter.emit('removeHandler', name, handler);
2354
- return emitter;
2355
- };
2356
-
2357
- return Emittr;
2358
- }();
2359
-
2360
- var RAFLoop =
2361
- /** @class */
2362
- function () {
2363
- function RAFLoop() {
2364
- var _this = this;
2365
- /**
2366
- * @description List of targets to update
2367
- */
2368
-
2369
-
2370
- this.targets = [];
2371
- /**
2372
- * @description ID of requested animation frame. Valuable only if loop is active and has items to iterate.
2373
- */
2374
-
2375
- this.animationFrameID = 0;
2376
- /**
2377
- * @description Loop's state.
2378
- */
2379
-
2380
- this._isActive = false;
2381
- /**
2382
- * @description Start the loop if it wasn't yet.
2383
- */
2384
-
2385
- this.start = function () {
2386
- if (!_this._isActive && _this.targets.length) {
2387
- _this._isActive = true;
2388
- if (_this.animationFrameID) cancelAnimationFrame(_this.animationFrameID);
2389
- _this.animationFrameID = requestAnimationFrame(_this.rafCallback);
2390
- }
2391
-
2392
- return _this;
2393
- };
2394
- /**
2395
- * @description Stop the loop if is was active.
2396
- */
2397
-
2398
-
2399
- this.stop = function () {
2400
- if (_this._isActive) {
2401
- _this._isActive = false;
2402
- if (_this.animationFrameID) cancelAnimationFrame(_this.animationFrameID);
2403
- _this.animationFrameID = 0;
2404
- }
2405
-
2406
- return _this;
2407
- };
2408
- /**
2409
- * @description Add target to the iteration list if it's not there.
2410
- */
2411
-
2412
-
2413
- this.addTarget = function (target, silent) {
2414
- if (silent === void 0) {
2415
- silent = false;
2416
- }
2417
-
2418
- if (!_this.targets.includes(target)) {
2419
- _this.targets.push(target);
2420
-
2421
- if (_this.targets.length === 1 && !silent) _this.start();
2422
- }
2423
-
2424
- return _this;
2425
- };
2426
- /**
2427
- * @description Remove target from iteration list if it was there.
2428
- */
2429
-
2430
-
2431
- this.removeTarget = function (target) {
2432
- var idx = _this.targets.indexOf(target);
2433
-
2434
- if (idx !== -1) {
2435
- _this.targets.splice(idx, 1);
2436
-
2437
- if (_this.targets.length === 0) _this.stop();
2438
- }
2439
-
2440
- return _this;
2441
- };
2442
- /**
2443
- * @description Callback that called each animation frame.
2444
- */
2445
-
2446
-
2447
- this.rafCallback = function () {
2448
- if (!_this._isActive) {
2449
- return 0;
2450
- }
2451
-
2452
- for (var i = 0; i < _this.targets.length; i++) {
2453
- if (!_this.targets[i]._unmounted) _this.targets[i].update();
2454
- }
2455
-
2456
- _this.animationFrameID = requestAnimationFrame(_this.rafCallback);
2457
- return _this.animationFrameID;
2458
- };
2459
- }
2460
-
2461
- Object.defineProperty(RAFLoop.prototype, "isActive", {
2462
- /**
2463
- * @description Loop's state.
2464
- */
2465
- get: function get() {
2466
- return this._isActive;
2467
- },
2468
- enumerable: false,
2469
- configurable: true
2470
- });
2471
- return RAFLoop;
2472
- }();
2473
- var Loop = new RAFLoop();
2474
-
2475
- var AXIS_DIRECTION;
2476
-
2477
- (function (AXIS_DIRECTION) {
2478
- AXIS_DIRECTION["X"] = "x";
2479
- AXIS_DIRECTION["Y"] = "y";
2480
- })(AXIS_DIRECTION || (AXIS_DIRECTION = {}));
2481
-
2482
- var TRACK_CLICK_BEHAVIOR;
2483
-
2484
- (function (TRACK_CLICK_BEHAVIOR) {
2485
- TRACK_CLICK_BEHAVIOR["JUMP"] = "jump";
2486
- TRACK_CLICK_BEHAVIOR["STEP"] = "step";
2487
- })(TRACK_CLICK_BEHAVIOR || (TRACK_CLICK_BEHAVIOR = {}));
2488
-
2489
- var ScrollbarThumb =
2490
- /** @class */
2491
- function (_super) {
2492
- __extends(ScrollbarThumb, _super);
2493
-
2494
- function ScrollbarThumb() {
2495
- var _this = _super !== null && _super.apply(this, arguments) || this;
2496
-
2497
- _this.element = null;
2498
- _this.initialOffsetX = 0;
2499
- _this.initialOffsetY = 0;
2500
- _this.elementRefHack = React__namespace.createRef();
2501
- _this.lastDragData = {
2502
- x: 0,
2503
- y: 0,
2504
- deltaX: 0,
2505
- deltaY: 0,
2506
- lastX: 0,
2507
- lastY: 0
2508
- };
2509
-
2510
- _this.handleOnDragStart = function (ev, data) {
2511
- if (!_this.element) {
2512
- _this.handleOnDragStop(ev, data);
2513
-
2514
- return;
2515
- }
2516
-
2517
- if (isBrowser) {
2518
- _this.prevUserSelect = document.body.style.userSelect;
2519
- document.body.style.userSelect = 'none';
2520
- _this.prevOnSelectStart = document.onselectstart;
2521
- document.addEventListener('selectstart', ScrollbarThumb.selectStartReplacer);
2522
- }
2523
-
2524
- if (_this.props.onDragStart) {
2525
- _this.props.onDragStart(_this.lastDragData = {
2526
- x: data.x - _this.initialOffsetX,
2527
- y: data.y - _this.initialOffsetY,
2528
- lastX: data.lastX - _this.initialOffsetX,
2529
- lastY: data.lastY - _this.initialOffsetY,
2530
- deltaX: data.deltaX,
2531
- deltaY: data.deltaY
2532
- });
2533
- }
2534
-
2535
- _this.element.classList.add('dragging');
2536
- };
2537
-
2538
- _this.handleOnDrag = function (ev, data) {
2539
- if (!_this.element) {
2540
- _this.handleOnDragStop(ev, data);
2541
-
2542
- return;
2543
- }
2544
-
2545
- if (_this.props.onDrag) {
2546
- _this.props.onDrag(_this.lastDragData = {
2547
- x: data.x - _this.initialOffsetX,
2548
- y: data.y - _this.initialOffsetY,
2549
- lastX: data.lastX - _this.initialOffsetX,
2550
- lastY: data.lastY - _this.initialOffsetY,
2551
- deltaX: data.deltaX,
2552
- deltaY: data.deltaY
2553
- });
2554
- }
2555
- };
2556
-
2557
- _this.handleOnDragStop = function (ev, data) {
2558
- var resultData = data ? {
2559
- x: data.x - _this.initialOffsetX,
2560
- y: data.y - _this.initialOffsetY,
2561
- lastX: data.lastX - _this.initialOffsetX,
2562
- lastY: data.lastY - _this.initialOffsetY,
2563
- deltaX: data.deltaX,
2564
- deltaY: data.deltaY
2565
- } : _this.lastDragData;
2566
- if (_this.props.onDragEnd) _this.props.onDragEnd(resultData);
2567
- if (_this.element) _this.element.classList.remove('dragging');
2568
-
2569
- if (isBrowser) {
2570
- document.body.style.userSelect = _this.prevUserSelect;
2571
-
2572
- if (_this.prevOnSelectStart) {
2573
- document.addEventListener('selectstart', _this.prevOnSelectStart);
2574
- }
2575
-
2576
- _this.prevOnSelectStart = null;
2577
- }
2578
-
2579
- _this.initialOffsetX = 0;
2580
- _this.initialOffsetY = 0;
2581
- _this.lastDragData = {
2582
- x: 0,
2583
- y: 0,
2584
- deltaX: 0,
2585
- deltaY: 0,
2586
- lastX: 0,
2587
- lastY: 0
2588
- };
2589
- };
2590
-
2591
- _this.handleOnMouseDown = function (ev) {
2592
- if (!_this.element) {
2593
- return;
2594
- }
2595
-
2596
- ev.preventDefault();
2597
- ev.stopPropagation();
2598
-
2599
- if (!isUndef(ev.offsetX)) {
2600
- /* istanbul ignore next */
2601
- _this.initialOffsetX = ev.offsetX;
2602
- /* istanbul ignore next */
2603
-
2604
- _this.initialOffsetY = ev.offsetY;
2605
- } else {
2606
- var rect = _this.element.getBoundingClientRect();
2607
-
2608
- _this.initialOffsetX = (ev.clientX || ev.touches[0].clientX) - rect.left;
2609
- _this.initialOffsetY = (ev.clientY || ev.touches[0].clientY) - rect.top;
2610
- }
2611
- };
2612
-
2613
- _this.elementRef = function (ref) {
2614
- if (isFun(_this.props.elementRef)) _this.props.elementRef(ref);
2615
- _this.element = ref; // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2616
- // @ts-ignore
2617
-
2618
- _this.elementRefHack.current = ref;
2619
- };
2620
-
2621
- return _this;
2622
- }
2623
-
2624
- ScrollbarThumb.prototype.componentDidMount = function () {
2625
- if (!this.element) {
2626
- this.setState(function () {
2627
- throw new Error("<ScrollbarThumb> Element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
2628
- });
2629
- }
2630
- };
2631
-
2632
- ScrollbarThumb.prototype.componentWillUnmount = function () {
2633
- this.handleOnDragStop();
2634
- this.elementRef(null);
2635
- };
2636
-
2637
- ScrollbarThumb.prototype.render = function () {
2638
- var _a = this.props;
2639
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2640
- _a.elementRef;
2641
- var axis = _a.axis;
2642
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2643
- _a.onDrag;
2644
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2645
- _a.onDragEnd;
2646
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2647
- _a.onDragStart;
2648
- var props = __rest(_a, ["elementRef", "axis", "onDrag", "onDragEnd", "onDragStart"]);
2649
-
2650
- props.className = cnb('ScrollbarsCustom-Thumb', axis === AXIS_DIRECTION.X ? 'ScrollbarsCustom-ThumbX' : 'ScrollbarsCustom-ThumbY', props.className);
2651
-
2652
- if (props.renderer) {
2653
- props.axis = axis;
2654
- }
2655
-
2656
- return React__namespace.createElement(DraggableCore_1, {
2657
- allowAnyClick: false,
2658
- enableUserSelectHack: false,
2659
- onMouseDown: this.handleOnMouseDown,
2660
- onDrag: this.handleOnDrag,
2661
- onStart: this.handleOnDragStart,
2662
- onStop: this.handleOnDragStop,
2663
- nodeRef: this.elementRefHack
2664
- }, renderDivWithRenderer(props, this.elementRef));
2665
- };
2666
-
2667
- ScrollbarThumb.selectStartReplacer = function () {
2668
- return false;
2669
- };
2670
-
2671
- return ScrollbarThumb;
2672
- }(React__namespace.Component);
2673
-
2674
- var ScrollbarTrack =
2675
- /** @class */
2676
- function (_super) {
2677
- __extends(ScrollbarTrack, _super);
2678
-
2679
- function ScrollbarTrack() {
2680
- var _this = _super !== null && _super.apply(this, arguments) || this;
2681
-
2682
- _this.element = null;
2683
-
2684
- _this.elementRef = function (ref) {
2685
- if (isFun(_this.props.elementRef)) _this.props.elementRef(ref);
2686
- _this.element = ref;
2687
- };
2688
-
2689
- _this.handleClick = function (ev) {
2690
- if (!ev || !_this.element || ev.button !== 0) {
2691
- return;
2692
- }
2693
-
2694
- if (isFun(_this.props.onClick) && ev.target === _this.element) {
2695
- if (!isUndef(ev.offsetX)) {
2696
- _this.props.onClick(ev, {
2697
- axis: _this.props.axis,
2698
- offset: _this.props.axis === AXIS_DIRECTION.X ? ev.offsetX : ev.offsetY
2699
- });
2700
- } else {
2701
- // support for old browsers
2702
-
2703
- /* istanbul ignore next */
2704
- var rect = _this.element.getBoundingClientRect();
2705
- /* istanbul ignore next */
2706
-
2707
-
2708
- _this.props.onClick(ev, {
2709
- axis: _this.props.axis,
2710
- offset: _this.props.axis === AXIS_DIRECTION.X ? (ev.clientX || ev.touches[0].clientX) - rect.left : (ev.clientY || ev.touches[0].clientY) - rect.top
2711
- });
2712
- }
2713
- }
2714
-
2715
- return true;
2716
- };
2717
-
2718
- return _this;
2719
- }
2720
-
2721
- ScrollbarTrack.prototype.componentDidMount = function () {
2722
- if (!this.element) {
2723
- this.setState(function () {
2724
- throw new Error("Element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
2725
- });
2726
- return;
2727
- }
2728
-
2729
- this.element.addEventListener('click', this.handleClick);
2730
- };
2731
-
2732
- ScrollbarTrack.prototype.componentWillUnmount = function () {
2733
- if (this.element) {
2734
- this.element.removeEventListener('click', this.handleClick);
2735
- this.element = null;
2736
- this.elementRef(null);
2737
- }
2738
- };
2739
-
2740
- ScrollbarTrack.prototype.render = function () {
2741
- var _a = this.props;
2742
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2743
- _a.elementRef;
2744
- var axis = _a.axis;
2745
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2746
- _a.onClick;
2747
- var props = __rest(_a, ["elementRef", "axis", "onClick"]);
2748
-
2749
- props.className = cnb('ScrollbarsCustom-Track', axis === AXIS_DIRECTION.X ? 'ScrollbarsCustom-TrackX' : 'ScrollbarsCustom-TrackY', props.className);
2750
-
2751
- if (props.renderer) {
2752
- props.axis = axis;
2753
- }
2754
-
2755
- return renderDivWithRenderer(props, this.elementRef);
2756
- };
2757
-
2758
- return ScrollbarTrack;
2759
- }(React__namespace.Component);
2760
-
2761
- var style = {
2762
- holder: {
2763
- position: 'relative',
2764
- width: '100%',
2765
- height: '100%'
2766
- },
2767
- wrapper: {
2768
- position: 'absolute',
2769
- top: 0,
2770
- left: 0,
2771
- bottom: 0,
2772
- right: 0
2773
- },
2774
- content: {
2775
- boxSizing: 'border-box'
2776
- },
2777
- track: {
2778
- common: {
2779
- position: 'absolute',
2780
- overflow: 'hidden',
2781
- borderRadius: 4,
2782
- background: 'rgba(0,0,0,.1)',
2783
- userSelect: 'none'
2784
- },
2785
- x: {
2786
- height: 10,
2787
- width: 'calc(100% - 20px)',
2788
- bottom: 0,
2789
- left: 10
2790
- },
2791
- y: {
2792
- width: 10,
2793
- height: 'calc(100% - 20px)',
2794
- top: 10
2795
- }
2796
- },
2797
- thumb: {
2798
- common: {
2799
- cursor: 'pointer',
2800
- borderRadius: 4,
2801
- background: 'rgba(0,0,0,.4)'
2802
- },
2803
- x: {
2804
- height: '100%',
2805
- width: 0
2806
- },
2807
- y: {
2808
- width: '100%',
2809
- height: 0
2810
- }
2811
- }
2812
- };
2813
-
2814
- var pageZoomLevel = isBrowser ? i() : 1;
2815
-
2816
- if (isBrowser) {
2817
- window.addEventListener('resize', function () {
2818
- pageZoomLevel = i();
2819
- }, {
2820
- passive: true
2821
- });
2822
- }
2823
-
2824
- var ScrollbarContext = React__namespace.createContext({
2825
- parentScrollbar: null
2826
- });
2827
-
2828
- var Scrollbar$1 =
2829
- /** @class */
2830
- function (_super) {
2831
- __extends(Scrollbar, _super);
2832
-
2833
- function Scrollbar(props) {
2834
- var _this = _super.call(this, props) || this;
2835
- /**
2836
- * @description Get current scroll-related values.<br/>
2837
- * If <i>force</i> if truthy - will recalculate them instead of returning cached values.
2838
- *
2839
- * @return ScrollState
2840
- */
2841
-
2842
-
2843
- _this.getScrollState = function (force) {
2844
- if (force === void 0) {
2845
- force = false;
2846
- }
2847
-
2848
- if (_this.scrollValues && !force) {
2849
- return __assign({}, _this.scrollValues);
2850
- }
2851
-
2852
- var scrollState = {
2853
- clientHeight: 0,
2854
- clientWidth: 0,
2855
- contentScrollHeight: 0,
2856
- contentScrollWidth: 0,
2857
- scrollHeight: 0,
2858
- scrollWidth: 0,
2859
- scrollTop: 0,
2860
- scrollLeft: 0,
2861
- scrollYBlocked: false,
2862
- scrollXBlocked: false,
2863
- scrollYPossible: false,
2864
- scrollXPossible: false,
2865
- trackYVisible: false,
2866
- trackXVisible: false,
2867
- zoomLevel: pageZoomLevel * 1,
2868
- isRTL: undefined
2869
- };
2870
- var props = _this.props;
2871
- scrollState.isRTL = _this.state.isRTL;
2872
- scrollState.scrollYBlocked = props.noScroll || props.noScrollY;
2873
- scrollState.scrollXBlocked = props.noScroll || props.noScrollX;
2874
-
2875
- if (_this.scrollerElement) {
2876
- scrollState.clientHeight = _this.scrollerElement.clientHeight;
2877
- scrollState.clientWidth = _this.scrollerElement.clientWidth;
2878
- scrollState.scrollHeight = _this.scrollerElement.scrollHeight;
2879
- scrollState.scrollWidth = _this.scrollerElement.scrollWidth;
2880
- scrollState.scrollTop = _this.scrollerElement.scrollTop;
2881
- scrollState.scrollLeft = _this.scrollerElement.scrollLeft;
2882
- scrollState.scrollYPossible = !scrollState.scrollYBlocked && scrollState.scrollHeight > scrollState.clientHeight;
2883
- scrollState.scrollXPossible = !scrollState.scrollXBlocked && scrollState.scrollWidth > scrollState.clientWidth;
2884
- scrollState.trackYVisible = scrollState.scrollYPossible || props.permanentTracks || props.permanentTrackY;
2885
- scrollState.trackXVisible = scrollState.scrollXPossible || props.permanentTracks || props.permanentTrackX;
2886
- }
2887
-
2888
- if (_this.contentElement) {
2889
- scrollState.contentScrollHeight = _this.contentElement.scrollHeight;
2890
- scrollState.contentScrollWidth = _this.contentElement.scrollWidth;
2891
- }
2892
-
2893
- return scrollState;
2894
- };
2895
- /**
2896
- * @description Scroll to top border
2897
- */
2898
-
2899
-
2900
- _this.scrollToTop = function () {
2901
- if (_this.scrollerElement) {
2902
- _this.scrollerElement.scrollTop = 0;
2903
- }
2904
-
2905
- return _this;
2906
- };
2907
- /**
2908
- * @description Scroll to left border
2909
- */
2910
-
2911
-
2912
- _this.scrollToLeft = function () {
2913
- if (_this.scrollerElement) {
2914
- _this.scrollerElement.scrollLeft = 0;
2915
- }
2916
-
2917
- return _this;
2918
- };
2919
- /**
2920
- * @description Scroll to bottom border
2921
- */
2922
-
2923
-
2924
- _this.scrollToBottom = function () {
2925
- if (_this.scrollerElement) {
2926
- _this.scrollerElement.scrollTop = _this.scrollerElement.scrollHeight - _this.scrollerElement.clientHeight;
2927
- }
2928
-
2929
- return _this;
2930
- };
2931
- /**
2932
- * @description Scroll to right border
2933
- */
2934
-
2935
-
2936
- _this.scrollToRight = function () {
2937
- if (_this.scrollerElement) {
2938
- _this.scrollerElement.scrollLeft = _this.scrollerElement.scrollWidth - _this.scrollerElement.clientWidth;
2939
- }
2940
-
2941
- return _this;
2942
- };
2943
- /**
2944
- * @description Set the scrolls at given coordinates.<br/>
2945
- * If coordinate is undefined - current scroll value will persist.
2946
- */
2947
-
2948
-
2949
- _this.scrollTo = function (x, y) {
2950
- if (_this.scrollerElement) {
2951
- if (isNum(x)) _this.scrollerElement.scrollLeft = x;
2952
- if (isNum(y)) _this.scrollerElement.scrollTop = y;
2953
- }
2954
-
2955
- return _this;
2956
- };
2957
- /**
2958
- * @description Center the viewport at given coordinates.<br/>
2959
- * If coordinate is undefined - current scroll value will persist.
2960
- */
2961
-
2962
-
2963
- _this.centerAt = function (x, y) {
2964
- if (_this.scrollerElement) {
2965
- if (isNum(x)) _this.scrollerElement.scrollLeft = x - _this.scrollerElement.clientWidth / 2;
2966
- if (isNum(y)) _this.scrollerElement.scrollTop = y - _this.scrollerElement.clientHeight / 2;
2967
- }
2968
-
2969
- return _this;
2970
- };
2971
-
2972
- _this.update = function (force) {
2973
- if (force === void 0) {
2974
- force = false;
2975
- }
2976
-
2977
- if (!_this.scrollerElement) {
2978
- return;
2979
- } // autodetect direction if not defined
2980
-
2981
-
2982
- if (isUndef(_this.state.isRTL)) {
2983
- _this.setState({
2984
- isRTL: getComputedStyle(_this.scrollerElement).direction === 'rtl'
2985
- });
2986
-
2987
- return _this.getScrollState();
2988
- }
2989
-
2990
- var scrollState = _this.getScrollState(true);
2991
-
2992
- var prevScrollState = __assign({}, _this.scrollValues);
2993
-
2994
- var props = _this.props;
2995
- var bitmask = 0;
2996
-
2997
- if (!force) {
2998
- if (prevScrollState.clientHeight !== scrollState.clientHeight) bitmask |= Math.trunc(1);
2999
- if (prevScrollState.clientWidth !== scrollState.clientWidth) bitmask |= 1 << 1;
3000
- if (prevScrollState.scrollHeight !== scrollState.scrollHeight) bitmask |= 1 << 2;
3001
- if (prevScrollState.scrollWidth !== scrollState.scrollWidth) bitmask |= 1 << 3;
3002
- if (prevScrollState.scrollTop !== scrollState.scrollTop) bitmask |= 1 << 4;
3003
- if (prevScrollState.scrollLeft !== scrollState.scrollLeft) bitmask |= 1 << 5;
3004
- if (prevScrollState.scrollYBlocked !== scrollState.scrollYBlocked) bitmask |= 1 << 6;
3005
- if (prevScrollState.scrollXBlocked !== scrollState.scrollXBlocked) bitmask |= 1 << 7;
3006
- if (prevScrollState.scrollYPossible !== scrollState.scrollYPossible) bitmask |= 1 << 8;
3007
- if (prevScrollState.scrollXPossible !== scrollState.scrollXPossible) bitmask |= 1 << 9;
3008
- if (prevScrollState.trackYVisible !== scrollState.trackYVisible) bitmask |= 1 << 10;
3009
- if (prevScrollState.trackXVisible !== scrollState.trackXVisible) bitmask |= 1 << 11;
3010
- if (prevScrollState.isRTL !== scrollState.isRTL) bitmask |= 1 << 12;
3011
- if (prevScrollState.contentScrollHeight !== scrollState.contentScrollHeight) bitmask |= 1 << 13;
3012
- if (prevScrollState.contentScrollWidth !== scrollState.contentScrollWidth) bitmask |= 1 << 14;
3013
- if (prevScrollState.zoomLevel !== scrollState.zoomLevel) bitmask |= 1 << 15; // if not forced and nothing has changed - skip this update
3014
-
3015
- if (bitmask === 0) {
3016
- return prevScrollState;
3017
- }
3018
- } else {
3019
- bitmask = 32767;
3020
- }
3021
-
3022
- if (!props.native && _this.holderElement) {
3023
- if (bitmask & 1 << 13 && (props.translateContentSizesToHolder || props.translateContentSizeYToHolder)) {
3024
- _this.holderElement.style.height = "".concat(scrollState.contentScrollHeight, "px");
3025
- }
3026
-
3027
- if (bitmask & 1 << 14 && (props.translateContentSizesToHolder || props.translateContentSizeXToHolder)) {
3028
- _this.holderElement.style.width = "".concat(scrollState.contentScrollWidth, "px");
3029
- }
3030
-
3031
- if (props.translateContentSizesToHolder || props.translateContentSizeYToHolder || props.translateContentSizeXToHolder) {
3032
- if (!scrollState.clientHeight && scrollState.contentScrollHeight || !scrollState.clientWidth && scrollState.contentScrollWidth) {
3033
- return;
3034
- }
3035
- }
3036
- } // if scrollbars visibility has changed
3037
-
3038
-
3039
- if (bitmask & 1 << 10 || bitmask & 1 << 11) {
3040
- prevScrollState.scrollYBlocked = scrollState.scrollYBlocked;
3041
- prevScrollState.scrollXBlocked = scrollState.scrollXBlocked;
3042
- prevScrollState.scrollYPossible = scrollState.scrollYPossible;
3043
- prevScrollState.scrollXPossible = scrollState.scrollXPossible;
3044
-
3045
- if (_this.trackYElement && bitmask & 1 << 10) {
3046
- _this.trackYElement.style.display = scrollState.trackYVisible ? '' : 'none';
3047
- }
3048
-
3049
- if (_this.trackXElement && bitmask & 1 << 11) {
3050
- _this.trackXElement.style.display = scrollState.trackXVisible ? '' : 'none';
3051
- }
3052
-
3053
- _this.scrollValues = prevScrollState;
3054
-
3055
- _this.setState({
3056
- trackYVisible: _this.scrollValues.trackYVisible = scrollState.trackYVisible,
3057
- trackXVisible: _this.scrollValues.trackXVisible = scrollState.trackXVisible
3058
- });
3059
-
3060
- return;
3061
- }
3062
-
3063
- (props.native ? _this.updaterNative : _this.updaterCustom)(bitmask, scrollState);
3064
- _this.scrollValues = scrollState;
3065
-
3066
- if (!props.native && bitmask & 1 << 15) {
3067
- getScrollbarWidth(true);
3068
-
3069
- _this.forceUpdate();
3070
- }
3071
-
3072
- _this.eventEmitter.emit('update', __assign({}, scrollState), prevScrollState);
3073
-
3074
- if (bitmask & 1 << 4 || bitmask & 1 << 5) _this.eventEmitter.emit('scroll', __assign({}, scrollState), prevScrollState);
3075
- return _this.scrollValues;
3076
- }; // eslint-disable-next-line class-methods-use-this
3077
-
3078
-
3079
- _this.updaterNative = function () {
3080
- // just for future
3081
- return true;
3082
- };
3083
-
3084
- _this.updaterCustom = function (bitmask, scrollValues) {
3085
- var props = _this.props;
3086
-
3087
- if (_this.trackYElement) {
3088
- if (_this.thumbYElement && (bitmask & Math.trunc(1) || bitmask & 1 << 2 || bitmask & 1 << 4 || bitmask & 1 << 6 || bitmask & 1 << 8)) {
3089
- if (scrollValues.scrollYPossible) {
3090
- var trackInnerSize = getInnerHeight(_this.trackYElement);
3091
- var thumbSize = calcThumbSize(scrollValues.scrollHeight, scrollValues.clientHeight, trackInnerSize, props.minimalThumbYSize || props.minimalThumbSize, props.maximalThumbYSize || props.maximalThumbSize);
3092
- var thumbOffset = calcThumbOffset(scrollValues.scrollHeight, scrollValues.clientHeight, trackInnerSize, thumbSize, scrollValues.scrollTop);
3093
- _this.thumbYElement.style.transform = "translateY(".concat(thumbOffset, "px)");
3094
- _this.thumbYElement.style.height = "".concat(thumbSize, "px");
3095
- _this.thumbYElement.style.display = '';
3096
- } else {
3097
- _this.thumbYElement.style.transform = '';
3098
- _this.thumbYElement.style.height = '0px';
3099
- _this.thumbYElement.style.display = 'none';
3100
- }
3101
- }
3102
- }
3103
-
3104
- if (_this.trackXElement) {
3105
- if (_this.thumbXElement && (bitmask & 1 << 1 || bitmask & 1 << 3 || bitmask & 1 << 5 || bitmask & 1 << 7 || bitmask & 1 << 9 || bitmask & 1 << 12)) {
3106
- if (scrollValues.scrollXPossible) {
3107
- var trackInnerSize = getInnerWidth(_this.trackXElement);
3108
- var thumbSize = calcThumbSize(scrollValues.scrollWidth, scrollValues.clientWidth, trackInnerSize, props.minimalThumbXSize || props.minimalThumbSize, props.maximalThumbXSize || props.maximalThumbSize);
3109
- var thumbOffset = calcThumbOffset(scrollValues.scrollWidth, scrollValues.clientWidth, trackInnerSize, thumbSize, scrollValues.scrollLeft);
3110
-
3111
- if (_this.state.isRTL && shouldReverseRtlScroll()) {
3112
- thumbOffset += trackInnerSize - thumbSize;
3113
- }
3114
-
3115
- _this.thumbXElement.style.transform = "translateX(".concat(thumbOffset, "px)");
3116
- _this.thumbXElement.style.width = "".concat(thumbSize, "px");
3117
- _this.thumbXElement.style.display = '';
3118
- } else {
3119
- _this.thumbXElement.style.transform = '';
3120
- _this.thumbXElement.style.width = '0px';
3121
- _this.thumbXElement.style.display = 'none';
3122
- }
3123
- }
3124
- }
3125
-
3126
- return true;
3127
- };
3128
-
3129
- _this.elementRefHolder = function (ref) {
3130
- _this.holderElement = ref;
3131
-
3132
- if (isFun(_this.props.elementRef)) {
3133
- _this.props.elementRef(ref);
3134
- }
3135
- };
3136
-
3137
- _this.elementRefWrapper = function (ref) {
3138
- _this.wrapperElement = ref;
3139
-
3140
- if (isFun(_this.props.wrapperProps.elementRef)) {
3141
- _this.props.wrapperProps.elementRef(ref);
3142
- }
3143
- };
3144
-
3145
- _this.elementRefScroller = function (ref) {
3146
- _this.scrollerElement = ref;
3147
-
3148
- if (isFun(_this.props.scrollerProps.elementRef)) {
3149
- _this.props.scrollerProps.elementRef(ref);
3150
- }
3151
- };
3152
-
3153
- _this.elementRefContent = function (ref) {
3154
- _this.contentElement = ref;
3155
-
3156
- if (isFun(_this.props.contentProps.elementRef)) {
3157
- _this.props.contentProps.elementRef(ref);
3158
- }
3159
- };
3160
-
3161
- _this.elementRefTrackX = function (ref) {
3162
- _this.trackXElement = ref;
3163
-
3164
- if (isFun(_this.props.trackXProps.elementRef)) {
3165
- _this.props.trackXProps.elementRef(ref);
3166
- }
3167
- };
3168
-
3169
- _this.elementRefTrackY = function (ref) {
3170
- _this.trackYElement = ref;
3171
-
3172
- if (isFun(_this.props.trackYProps.elementRef)) {
3173
- _this.props.trackYProps.elementRef(ref);
3174
- }
3175
- };
3176
-
3177
- _this.elementRefThumbX = function (ref) {
3178
- _this.thumbXElement = ref;
3179
-
3180
- if (isFun(_this.props.thumbXProps.elementRef)) {
3181
- _this.props.thumbXProps.elementRef(ref);
3182
- }
3183
- };
3184
-
3185
- _this.elementRefThumbY = function (ref) {
3186
- _this.thumbYElement = ref;
3187
-
3188
- if (isFun(_this.props.thumbYProps.elementRef)) {
3189
- _this.props.thumbYProps.elementRef(ref);
3190
- }
3191
- };
3192
-
3193
- _this.handleTrackXClick = function (ev, values) {
3194
- if (_this.props.trackXProps.onClick) {
3195
- _this.props.trackXProps.onClick(ev, values);
3196
- }
3197
-
3198
- if (!_this.scrollerElement || !_this.trackXElement || !_this.thumbXElement || !_this.scrollValues || !_this.scrollValues.scrollXPossible) {
3199
- return;
3200
- }
3201
-
3202
- _this._scrollDetection();
3203
-
3204
- var thumbSize = _this.thumbXElement.clientWidth;
3205
- var trackInnerSize = getInnerWidth(_this.trackXElement);
3206
- var thumbOffset = (_this.scrollValues.isRTL && shouldReverseRtlScroll() ? values.offset + thumbSize / 2 - trackInnerSize : values.offset - thumbSize / 2) - (Number.parseFloat(getComputedStyle(_this.trackXElement).paddingLeft) || 0);
3207
- var target = calcScrollForThumbOffset(_this.scrollValues.scrollWidth, _this.scrollValues.clientWidth, trackInnerSize, thumbSize, thumbOffset);
3208
-
3209
- if (_this.props.trackClickBehavior === TRACK_CLICK_BEHAVIOR.STEP) {
3210
- target = (_this.scrollValues.isRTL ? _this.scrollValues.scrollLeft > target : _this.scrollValues.scrollLeft < target) ? _this.scrollValues.scrollLeft + _this.scrollValues.clientWidth : _this.scrollValues.scrollLeft - _this.scrollValues.clientWidth;
3211
- }
3212
-
3213
- _this.scrollerElement.scrollLeft = target;
3214
- };
3215
-
3216
- _this.handleTrackYClick = function (ev, values) {
3217
- if (_this.props.trackYProps.onClick) _this.props.trackYProps.onClick(ev, values);
3218
-
3219
- if (!_this.scrollerElement || !_this.trackYElement || !_this.thumbYElement || !_this.scrollValues || !_this.scrollValues.scrollYPossible) {
3220
- return;
3221
- }
3222
-
3223
- _this._scrollDetection();
3224
-
3225
- var thumbSize = _this.thumbYElement.clientHeight;
3226
- var target = calcScrollForThumbOffset(_this.scrollValues.scrollHeight, _this.scrollValues.clientHeight, getInnerHeight(_this.trackYElement), thumbSize, values.offset - thumbSize / 2) - (Number.parseFloat(getComputedStyle(_this.trackYElement).paddingTop) || 0);
3227
-
3228
- if (_this.props.trackClickBehavior === TRACK_CLICK_BEHAVIOR.JUMP) {
3229
- _this.scrollerElement.scrollTop = target;
3230
- } else {
3231
- _this.scrollerElement.scrollTop = _this.scrollValues.scrollTop < target ? _this.scrollValues.scrollTop + _this.scrollValues.clientHeight : _this.scrollValues.scrollTop - _this.scrollValues.clientHeight;
3232
- }
3233
- };
3234
-
3235
- _this.handleTrackYMouseWheel = function (ev) {
3236
- var props = _this.props;
3237
-
3238
- if (props.trackYProps && props.trackYProps.onWheel) {
3239
- props.trackYProps.onWheel(ev);
3240
- }
3241
-
3242
- if (props.disableTracksMousewheelScrolling || props.disableTrackYMousewheelScrolling) {
3243
- return;
3244
- }
3245
-
3246
- _this._scrollDetection();
3247
-
3248
- if (!_this.scrollerElement || _this.scrollValues.scrollYBlocked) {
3249
- return;
3250
- }
3251
-
3252
- _this.scrollTop += ev.deltaY;
3253
- };
3254
-
3255
- _this.handleTrackXMouseWheel = function (ev) {
3256
- var props = _this.props;
3257
-
3258
- if (props.trackXProps && props.trackXProps.onWheel) {
3259
- props.trackXProps.onWheel(ev);
3260
- }
3261
-
3262
- if (props.disableTracksMousewheelScrolling || props.disableTrackXMousewheelScrolling) {
3263
- return;
3264
- }
3265
-
3266
- _this._scrollDetection();
3267
-
3268
- if (!_this.scrollerElement || _this.scrollValues.scrollXBlocked) {
3269
- return;
3270
- }
3271
-
3272
- _this.scrollLeft += ev.deltaX;
3273
- };
3274
-
3275
- _this.handleThumbXDrag = function (data) {
3276
- var _a;
3277
-
3278
- if (!_this.trackXElement || !_this.thumbXElement || !_this.scrollerElement || !_this.scrollValues || !_this.scrollValues.scrollXPossible) {
3279
- return;
3280
- }
3281
-
3282
- _this._scrollDetection();
3283
-
3284
- var trackRect = _this.trackXElement.getBoundingClientRect();
3285
-
3286
- var styles = getComputedStyle(_this.trackXElement);
3287
- var paddingLeft = Number.parseFloat(styles.paddingLeft) || 0;
3288
- var paddingRight = Number.parseFloat(styles.paddingRight) || 0;
3289
- var trackInnerSize = trackRect.width - paddingLeft - paddingRight;
3290
- var thumbSize = _this.thumbXElement.clientWidth;
3291
- var offset = _this.scrollValues.isRTL && shouldReverseRtlScroll() ? data.x + thumbSize - trackInnerSize + paddingLeft : data.lastX - paddingLeft;
3292
- _this.scrollerElement.scrollLeft = calcScrollForThumbOffset(_this.scrollValues.scrollWidth, _this.scrollValues.clientWidth, trackInnerSize, thumbSize, offset);
3293
-
3294
- if ((_a = _this.props.thumbXProps) === null || _a === void 0 ? void 0 : _a.onDrag) {
3295
- _this.props.thumbXProps.onDrag(data);
3296
- }
3297
- };
3298
-
3299
- _this.handleThumbXDragEnd = function (data) {
3300
- var _a;
3301
-
3302
- _this.handleThumbXDrag(data);
3303
-
3304
- if ((_a = _this.props.thumbXProps) === null || _a === void 0 ? void 0 : _a.onDragEnd) {
3305
- _this.props.thumbXProps.onDragEnd(data);
3306
- }
3307
- };
3308
-
3309
- _this.handleThumbYDrag = function (data) {
3310
- var _a;
3311
-
3312
- if (!_this.scrollerElement || !_this.trackYElement || !_this.thumbYElement || !_this.scrollValues || !_this.scrollValues.scrollYPossible) {
3313
- return;
3314
- }
3315
-
3316
- _this._scrollDetection();
3317
-
3318
- var trackRect = _this.trackYElement.getBoundingClientRect();
3319
-
3320
- var styles = getComputedStyle(_this.trackYElement);
3321
- var paddingTop = Number.parseFloat(styles.paddingTop) || 0;
3322
- var paddingBottom = Number.parseFloat(styles.paddingBottom) || 0;
3323
- var trackInnerSize = trackRect.height - paddingTop - paddingBottom;
3324
- var thumbSize = _this.thumbYElement.clientHeight;
3325
- var offset = data.y - paddingTop;
3326
- _this.scrollerElement.scrollTop = calcScrollForThumbOffset(_this.scrollValues.scrollHeight, _this.scrollValues.clientHeight, trackInnerSize, thumbSize, offset);
3327
-
3328
- if ((_a = _this.props.thumbYProps) === null || _a === void 0 ? void 0 : _a.onDrag) {
3329
- _this.props.thumbYProps.onDrag(data);
3330
- }
3331
- };
3332
-
3333
- _this.handleThumbYDragEnd = function (data) {
3334
- var _a;
3335
-
3336
- _this.handleThumbYDrag(data);
3337
-
3338
- if ((_a = _this.props.thumbYProps) === null || _a === void 0 ? void 0 : _a.onDragEnd) {
3339
- _this.props.thumbYProps.onDragEnd(data);
3340
- }
3341
- };
3342
-
3343
- _this.handleScrollerScroll = function () {
3344
- _this._scrollDetection();
3345
- };
3346
-
3347
- _this._scrollDetection = function () {
3348
- if (!_this._scrollDetectionTO) {
3349
- _this.eventEmitter.emit('scrollStart', _this.getScrollState());
3350
- } else if (isBrowser) {
3351
- window.clearTimeout(_this._scrollDetectionTO);
3352
- }
3353
-
3354
- _this._scrollDetectionTO = isBrowser ? window.setTimeout(_this._scrollDetectionCallback, _this.props.scrollDetectionThreshold || 0) : null;
3355
- };
3356
-
3357
- _this._scrollDetectionCallback = function () {
3358
- _this._scrollDetectionTO = null;
3359
-
3360
- _this.eventEmitter.emit('scrollStop', _this.getScrollState());
3361
- };
3362
-
3363
- _this.state = {
3364
- trackXVisible: false,
3365
- trackYVisible: false,
3366
- isRTL: props.rtl
3367
- };
3368
- _this.scrollValues = _this.getScrollState(true);
3369
- _this.eventEmitter = new Emittr(15);
3370
- if (props.onUpdate) _this.eventEmitter.on('update', props.onUpdate);
3371
- if (props.onScroll) _this.eventEmitter.on('scroll', props.onScroll);
3372
- if (props.onScrollStart) _this.eventEmitter.on('scrollStart', props.onScrollStart);
3373
- if (props.onScrollStop) _this.eventEmitter.on('scrollStop', props.onScrollStop);
3374
- _this.id = uuid();
3375
- return _this;
3376
- }
3377
-
3378
- Object.defineProperty(Scrollbar.prototype, "scrollTop", {
3379
- // eslint-disable-next-line react/sort-comp
3380
- get: function get() {
3381
- if (this.scrollerElement) {
3382
- return this.scrollerElement.scrollTop;
3383
- }
3384
-
3385
- return 0;
3386
- },
3387
- set: function set(top) {
3388
- if (this.scrollerElement) {
3389
- this.scrollerElement.scrollTop = top;
3390
- this.update();
3391
- }
3392
- },
3393
- enumerable: false,
3394
- configurable: true
3395
- });
3396
- Object.defineProperty(Scrollbar.prototype, "scrollLeft", {
3397
- get: function get() {
3398
- if (this.scrollerElement) {
3399
- return this.scrollerElement.scrollLeft;
3400
- }
3401
-
3402
- return 0;
3403
- },
3404
- set: function set(left) {
3405
- if (this.scrollerElement) {
3406
- this.scrollerElement.scrollLeft = left;
3407
- }
3408
- },
3409
- enumerable: false,
3410
- configurable: true
3411
- });
3412
- Object.defineProperty(Scrollbar.prototype, "scrollHeight", {
3413
- get: function get() {
3414
- if (this.scrollerElement) {
3415
- return this.scrollerElement.scrollHeight;
3416
- }
3417
-
3418
- return 0;
3419
- },
3420
- enumerable: false,
3421
- configurable: true
3422
- });
3423
- Object.defineProperty(Scrollbar.prototype, "scrollWidth", {
3424
- get: function get() {
3425
- if (this.scrollerElement) {
3426
- return this.scrollerElement.scrollWidth;
3427
- }
3428
-
3429
- return 0;
3430
- },
3431
- enumerable: false,
3432
- configurable: true
3433
- });
3434
- Object.defineProperty(Scrollbar.prototype, "clientHeight", {
3435
- get: function get() {
3436
- if (this.scrollerElement) {
3437
- return this.scrollerElement.clientHeight;
3438
- }
3439
-
3440
- return 0;
3441
- },
3442
- enumerable: false,
3443
- configurable: true
3444
- });
3445
- Object.defineProperty(Scrollbar.prototype, "clientWidth", {
3446
- get: function get() {
3447
- if (this.scrollerElement) {
3448
- return this.scrollerElement.clientWidth;
3449
- }
3450
-
3451
- return 0;
3452
- },
3453
- enumerable: false,
3454
- configurable: true
3455
- }); // eslint-disable-next-line react/sort-comp
3456
-
3457
- Scrollbar.calculateStyles = function (props, state, scrollValues, scrollbarWidth) {
3458
- var _a, _b, _c, _d;
3459
-
3460
- var useDefaultStyles = !props.noDefaultStyles;
3461
- return {
3462
- holder: __assign(__assign(__assign({}, useDefaultStyles && style.holder), {
3463
- position: 'relative'
3464
- }), props.style),
3465
- wrapper: __assign(__assign(__assign({}, useDefaultStyles && __assign(__assign(__assign({}, style.wrapper), !props.disableTracksWidthCompensation && !props.disableTrackYWidthCompensation && (_a = {}, _a[state.isRTL ? 'left' : 'right'] = state.trackYVisible ? 10 : 0, _a)), !props.disableTracksWidthCompensation && !props.disableTrackXWidthCompensation && {
3466
- bottom: state.trackXVisible ? 10 : 0
3467
- })), props.wrapperProps.style), {
3468
- position: 'absolute',
3469
- overflow: 'hidden'
3470
- }),
3471
- content: __assign(__assign(__assign(__assign(__assign({}, useDefaultStyles && style.content), props.translateContentSizesToHolder || props.translateContentSizeYToHolder || props.translateContentSizeXToHolder ? {
3472
- display: 'table-cell'
3473
- } : {
3474
- padding: 0.05 // needed to disable margin collapsing without flexboxes, other possible solutions here: https://stackoverflow.com/questions/19718634/how-to-disable-margin-collapsing
3475
-
3476
- }), useDefaultStyles && !(props.translateContentSizesToHolder || props.translateContentSizeYToHolder) && {
3477
- minHeight: '100%'
3478
- }), useDefaultStyles && !(props.translateContentSizesToHolder || props.translateContentSizeXToHolder) && {
3479
- minWidth: '100%'
3480
- }), props.contentProps.style),
3481
- scroller: __assign(__assign(__assign(__assign((_b = {
3482
- position: 'absolute',
3483
- top: 0,
3484
- left: 0,
3485
- bottom: 0,
3486
- right: 0,
3487
- paddingBottom: !scrollbarWidth && scrollValues.scrollXPossible ? props.fallbackScrollbarWidth : undefined
3488
- }, _b[state.isRTL ? 'paddingLeft' : 'paddingRight'] = !scrollbarWidth && scrollValues.scrollYPossible ? props.fallbackScrollbarWidth : undefined, _b), props.scrollerProps.style), !isUndef(props.rtl) && {
3489
- direction: props.rtl ? 'rtl' : 'ltr'
3490
- }), props.momentum && {
3491
- WebkitOverflowScrolling: 'touch'
3492
- }), (_c = {
3493
- overflowY: scrollValues.scrollYPossible ? 'scroll' : 'hidden',
3494
- overflowX: scrollValues.scrollXPossible ? 'scroll' : 'hidden',
3495
- marginBottom: scrollValues.scrollXPossible ? -(scrollbarWidth || props.fallbackScrollbarWidth) - Number(scrollValues.zoomLevel !== 1) : undefined
3496
- }, _c[state.isRTL ? 'marginLeft' : 'marginRight'] = scrollValues.scrollYPossible ? -(scrollbarWidth || props.fallbackScrollbarWidth) - Number(scrollValues.zoomLevel !== 1) : undefined, _c)),
3497
- trackX: __assign(__assign(__assign(__assign({}, useDefaultStyles && style.track.common), useDefaultStyles && style.track.x), props.trackXProps.style), !state.trackXVisible && {
3498
- display: 'none'
3499
- }),
3500
- trackY: __assign(__assign(__assign(__assign(__assign({}, useDefaultStyles && style.track.common), useDefaultStyles && style.track.y), useDefaultStyles && (_d = {}, _d[state.isRTL ? 'left' : 'right'] = 0, _d)), props.trackYProps.style), !state.trackYVisible && {
3501
- display: 'none'
3502
- }),
3503
- thumbX: __assign(__assign(__assign({}, useDefaultStyles && style.thumb.common), useDefaultStyles && style.thumb.x), props.thumbXProps.style),
3504
- thumbY: __assign(__assign(__assign({}, useDefaultStyles && style.thumb.common), useDefaultStyles && style.thumb.y), props.thumbYProps.style)
3505
- };
3506
- };
3507
-
3508
- Scrollbar.prototype.componentDidMount = function () {
3509
- if (!this.scrollerElement) {
3510
- this.setState(function () {
3511
- throw new Error("scroller element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
3512
- });
3513
- return;
3514
- }
3515
-
3516
- if (!this.contentElement) {
3517
- this.setState(function () {
3518
- throw new Error("content element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
3519
- });
3520
- return;
3521
- }
3522
-
3523
- var props = this.props;
3524
-
3525
- if (!props.native && !props.mobileNative) {
3526
- // ToDo: move native state to the state so it can be synchronized
3527
- if (!this.holderElement) {
3528
- this.setState(function () {
3529
- throw new Error("holder element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
3530
- });
3531
- return;
3532
- }
3533
-
3534
- if (!this.wrapperElement) {
3535
- this.setState(function () {
3536
- throw new Error("wrapper element was not created. Possibly you haven't provided HTMLDivElement to renderer's `elementRef` function.");
3537
- });
3538
- return;
3539
- }
3540
- }
3541
-
3542
- Loop.addTarget(this);
3543
-
3544
- if (!isUndef(props.scrollTop)) {
3545
- this.scrollerElement.scrollTop = props.scrollTop;
3546
- }
3547
-
3548
- if (!isUndef(props.scrollLeft)) {
3549
- this.scrollerElement.scrollLeft = props.scrollLeft;
3550
- }
3551
-
3552
- this.update(true);
3553
- };
3554
-
3555
- Scrollbar.prototype.componentWillUnmount = function () {
3556
- Loop.removeTarget(this);
3557
- };
3558
-
3559
- Scrollbar.prototype.componentDidUpdate = function (prevProps, prevState) {
3560
- if (!this.scrollerElement) {
3561
- return;
3562
- }
3563
-
3564
- var props = this.props;
3565
-
3566
- if (props.rtl !== prevProps.rtl && props.rtl !== this.state.isRTL) {
3567
- this.setState({
3568
- isRTL: props.rtl
3569
- });
3570
- }
3571
-
3572
- if (this.state.isRTL !== prevState.isRTL) {
3573
- this.update();
3574
- }
3575
-
3576
- if (!isUndef(props.scrollTop) && props.scrollTop !== this.scrollerElement.scrollTop) {
3577
- this.scrollerElement.scrollTop = props.scrollTop;
3578
- }
3579
-
3580
- if (!isUndef(props.scrollLeft) && props.scrollLeft !== this.scrollerElement.scrollLeft) {
3581
- this.scrollerElement.scrollLeft = props.scrollLeft;
3582
- }
3583
-
3584
- if (prevProps.onUpdate !== props.onUpdate) {
3585
- if (prevProps.onUpdate) this.eventEmitter.off('update', prevProps.onUpdate);
3586
- if (props.onUpdate) this.eventEmitter.on('update', props.onUpdate);
3587
- }
3588
-
3589
- if (prevProps.onScroll !== props.onScroll) {
3590
- if (prevProps.onScroll) this.eventEmitter.off('scroll', prevProps.onScroll);
3591
- if (props.onScroll) this.eventEmitter.on('scroll', props.onScroll);
3592
- }
3593
-
3594
- if (prevProps.onScrollStart !== props.onScrollStart) {
3595
- if (prevProps.onScrollStart) this.eventEmitter.off('scrollStart', prevProps.onScrollStart);
3596
- if (props.onScrollStart) this.eventEmitter.on('scrollStart', props.onScrollStart);
3597
- }
3598
-
3599
- if (prevProps.onScrollStop !== props.onScrollStop) {
3600
- if (prevProps.onScrollStop) this.eventEmitter.off('scrollStop', prevProps.onScrollStop);
3601
- if (props.onScrollStop) this.eventEmitter.on('scrollStop', props.onScrollStop);
3602
- }
3603
- }; // eslint-disable-next-line react/sort-comp
3604
-
3605
-
3606
- Scrollbar.prototype.render = function () {
3607
- var _a = this.props,
3608
- createContext = _a.createContext,
3609
- rtl = _a.rtl,
3610
- native = _a.native,
3611
- mobileNative = _a.mobileNative,
3612
- momentum = _a.momentum;
3613
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3614
- _a.noDefaultStyles;
3615
- var disableTracksMousewheelScrolling = _a.disableTracksMousewheelScrolling,
3616
- disableTrackXMousewheelScrolling = _a.disableTrackXMousewheelScrolling,
3617
- disableTrackYMousewheelScrolling = _a.disableTrackYMousewheelScrolling;
3618
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3619
- _a.disableTracksWidthCompensation;
3620
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3621
- _a.disableTrackXWidthCompensation;
3622
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3623
- _a.disableTrackYWidthCompensation;
3624
- var noScrollX = _a.noScrollX,
3625
- noScrollY = _a.noScrollY,
3626
- noScroll = _a.noScroll,
3627
- permanentTrackX = _a.permanentTrackX,
3628
- permanentTrackY = _a.permanentTrackY,
3629
- permanentTracks = _a.permanentTracks,
3630
- removeTracksWhenNotUsed = _a.removeTracksWhenNotUsed,
3631
- removeTrackYWhenNotUsed = _a.removeTrackYWhenNotUsed,
3632
- removeTrackXWhenNotUsed = _a.removeTrackXWhenNotUsed;
3633
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3634
- _a.minimalThumbSize;
3635
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3636
- _a.maximalThumbSize;
3637
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3638
- _a.minimalThumbXSize;
3639
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3640
- _a.maximalThumbXSize;
3641
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3642
- _a.minimalThumbYSize;
3643
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3644
- _a.maximalThumbYSize;
3645
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3646
- _a.fallbackScrollbarWidth;
3647
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3648
- _a.scrollTop;
3649
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3650
- _a.scrollLeft;
3651
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3652
- _a.trackClickBehavior;
3653
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3654
- _a.scrollDetectionThreshold;
3655
- var propsWrapperProps = _a.wrapperProps,
3656
- propsScrollerProps = _a.scrollerProps,
3657
- propsContentProps = _a.contentProps,
3658
- propsTrackXProps = _a.trackXProps,
3659
- propsTrackYProps = _a.trackYProps,
3660
- propsThumbXProps = _a.thumbXProps,
3661
- propsThumbYProps = _a.thumbYProps,
3662
- propsScrollbarWidth = _a.scrollbarWidth;
3663
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3664
- _a.elementRef;
3665
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3666
- _a.onUpdate;
3667
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3668
- _a.onScroll;
3669
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3670
- _a.onScrollStart;
3671
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3672
- _a.onScrollStop;
3673
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3674
- _a.translateContentSizesToHolder;
3675
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3676
- _a.translateContentSizeYToHolder;
3677
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
3678
- _a.translateContentSizeXToHolder;
3679
- var children = _a.children,
3680
- propsHolderProps = __rest(_a, ["createContext", "rtl", "native", "mobileNative", "momentum", "noDefaultStyles", "disableTracksMousewheelScrolling", "disableTrackXMousewheelScrolling", "disableTrackYMousewheelScrolling", "disableTracksWidthCompensation", "disableTrackXWidthCompensation", "disableTrackYWidthCompensation", "noScrollX", "noScrollY", "noScroll", "permanentTrackX", "permanentTrackY", "permanentTracks", "removeTracksWhenNotUsed", "removeTrackYWhenNotUsed", "removeTrackXWhenNotUsed", "minimalThumbSize", "maximalThumbSize", "minimalThumbXSize", "maximalThumbXSize", "minimalThumbYSize", "maximalThumbYSize", "fallbackScrollbarWidth", "scrollTop", "scrollLeft", "trackClickBehavior", "scrollDetectionThreshold", "wrapperProps", "scrollerProps", "contentProps", "trackXProps", "trackYProps", "thumbXProps", "thumbYProps", "scrollbarWidth", "elementRef", "onUpdate", "onScroll", "onScrollStart", "onScrollStop", "translateContentSizesToHolder", "translateContentSizeYToHolder", "translateContentSizeXToHolder", "children"]);
3681
-
3682
- var scrollbarWidth = !isUndef(propsScrollbarWidth) ? propsScrollbarWidth : getScrollbarWidth() || 0;
3683
-
3684
- if (native || !scrollbarWidth && mobileNative) {
3685
- this.elementRefHolder(null);
3686
- this.elementRefWrapper(null);
3687
- this.elementRefTrackX(null);
3688
- this.elementRefTrackY(null);
3689
- this.elementRefThumbX(null);
3690
- this.elementRefThumbY(null);
3691
-
3692
- var contentProps_1 = __assign(__assign({}, propsContentProps), {
3693
- key: 'ScrollbarsCustom-Content',
3694
- className: cnb('ScrollbarsCustom-Content', propsContentProps.className),
3695
- children: children
3696
- });
3697
-
3698
- var scrollerProps_1 = __assign(__assign({}, propsHolderProps), {
3699
- className: cnb('ScrollbarsCustom native', this.state.trackYVisible && 'trackYVisible', this.state.trackXVisible && 'trackXVisible', this.state.isRTL && 'rtl', propsHolderProps.className),
3700
- style: __assign(__assign(__assign(__assign({}, propsHolderProps.style), !isUndef(rtl) && {
3701
- direction: rtl ? 'rtl' : 'ltr'
3702
- }), momentum && {
3703
- WebkitOverflowScrolling: 'touch'
3704
- }), {
3705
- overflowX: noScroll || noScrollX ? 'hidden' : permanentTracks || permanentTrackX ? 'scroll' : 'auto',
3706
- overflowY: noScroll || noScrollY ? 'hidden' : permanentTracks || permanentTrackY ? 'scroll' : 'auto'
3707
- }),
3708
- onScroll: this.handleScrollerScroll,
3709
- children: renderDivWithRenderer(contentProps_1, this.elementRefContent),
3710
- renderer: propsScrollerProps.renderer,
3711
- elementRef: propsScrollerProps.elementRef
3712
- });
3713
-
3714
- return renderDivWithRenderer(scrollerProps_1, this.elementRefScroller);
3715
- }
3716
-
3717
- var styles = Scrollbar.calculateStyles(this.props, this.state, this.scrollValues, scrollbarWidth);
3718
- var holderChildren = [];
3719
-
3720
- var contentProps = __assign(__assign({}, propsContentProps), {
3721
- key: 'ScrollbarsCustom-Content',
3722
- className: cnb('ScrollbarsCustom-Content', propsContentProps.className),
3723
- style: styles.content,
3724
- children: createContext ? // eslint-disable-next-line react/jsx-no-constructed-context-values
3725
- React__namespace.createElement(ScrollbarContext.Provider, {
3726
- value: {
3727
- parentScrollbar: this
3728
- }
3729
- }, children) : children
3730
- });
3731
-
3732
- var scrollerProps = __assign(__assign({}, propsScrollerProps), {
3733
- key: 'ScrollbarsCustom-Scroller',
3734
- className: cnb('ScrollbarsCustom-Scroller', propsScrollerProps.className),
3735
- style: styles.scroller,
3736
- children: renderDivWithRenderer(contentProps, this.elementRefContent),
3737
- onScroll: this.handleScrollerScroll
3738
- });
3739
-
3740
- var wrapperProps = __assign(__assign({}, propsWrapperProps), {
3741
- key: 'ScrollbarsCustom-Wrapper',
3742
- className: cnb('ScrollbarsCustom-Wrapper', propsWrapperProps.className),
3743
- style: styles.wrapper,
3744
- children: renderDivWithRenderer(scrollerProps, this.elementRefScroller)
3745
- });
3746
-
3747
- holderChildren.push(renderDivWithRenderer(wrapperProps, this.elementRefWrapper));
3748
-
3749
- if (this.state.trackYVisible || !removeTracksWhenNotUsed && !removeTrackYWhenNotUsed) {
3750
- var thumbYProps = __assign(__assign({}, propsThumbYProps), {
3751
- key: 'ScrollbarsCustom-ThumbY',
3752
- style: styles.thumbY,
3753
- elementRef: this.elementRefThumbY,
3754
- onDrag: this.handleThumbYDrag,
3755
- onDragEnd: this.handleThumbYDragEnd,
3756
- axis: AXIS_DIRECTION.Y
3757
- });
3758
-
3759
- var trackYProps = __assign(__assign(__assign(__assign({}, propsTrackYProps), {
3760
- key: 'ScrollbarsCustom-TrackY',
3761
- style: styles.trackY,
3762
- elementRef: this.elementRefTrackY,
3763
- onClick: this.handleTrackYClick
3764
- }), (disableTracksMousewheelScrolling || disableTrackYMousewheelScrolling) && {
3765
- onWheel: this.handleTrackYMouseWheel
3766
- }), {
3767
- axis: AXIS_DIRECTION.Y
3768
- });
3769
-
3770
- trackYProps.children = React__namespace.createElement(ScrollbarThumb, __assign({}, thumbYProps));
3771
- holderChildren.push(React__namespace.createElement(ScrollbarTrack, __assign({}, trackYProps)));
3772
- } else {
3773
- this.elementRefTrackY(null);
3774
- this.elementRefThumbY(null);
3775
- }
3776
-
3777
- if (this.state.trackXVisible || !removeTracksWhenNotUsed && !removeTrackXWhenNotUsed) {
3778
- var thumbXProps = __assign(__assign({}, propsThumbXProps), {
3779
- key: 'ScrollbarsCustom-ThumbX',
3780
- style: styles.thumbX,
3781
- elementRef: this.elementRefThumbX,
3782
- onDrag: this.handleThumbXDrag,
3783
- onDragEnd: this.handleThumbXDragEnd,
3784
- axis: AXIS_DIRECTION.X
3785
- });
3786
-
3787
- var trackXProps = __assign(__assign(__assign(__assign({}, propsTrackXProps), {
3788
- key: 'ScrollbarsCustom-TrackX',
3789
- style: styles.trackX,
3790
- elementRef: this.elementRefTrackX,
3791
- onClick: this.handleTrackXClick
3792
- }), (disableTracksMousewheelScrolling || disableTrackXMousewheelScrolling) && {
3793
- onWheel: this.handleTrackXMouseWheel
3794
- }), {
3795
- axis: AXIS_DIRECTION.X
3796
- });
3797
-
3798
- trackXProps.children = React__namespace.createElement(ScrollbarThumb, __assign({}, thumbXProps));
3799
- holderChildren.push(React__namespace.createElement(ScrollbarTrack, __assign({}, trackXProps)));
3800
- } else {
3801
- this.elementRefTrackX(null);
3802
- this.elementRefThumbX(null);
3803
- }
3804
-
3805
- var holderProps = __assign(__assign({}, propsHolderProps), {
3806
- className: cnb('ScrollbarsCustom', this.state.trackYVisible && 'trackYVisible', this.state.trackXVisible && 'trackXVisible', this.state.isRTL && 'rtl', propsHolderProps.className),
3807
- style: styles.holder,
3808
- children: holderChildren
3809
- });
3810
-
3811
- return renderDivWithRenderer(holderProps, this.elementRefHolder);
3812
- }; // eslint-disable-next-line react/static-property-placement
3813
-
3814
-
3815
- Scrollbar.contextType = ScrollbarContext; // eslint-disable-next-line react/static-property-placement
3816
-
3817
- Scrollbar.defaultProps = {
3818
- momentum: true,
3819
- minimalThumbSize: 30,
3820
- fallbackScrollbarWidth: 20,
3821
- trackClickBehavior: TRACK_CLICK_BEHAVIOR.JUMP,
3822
- scrollDetectionThreshold: 100,
3823
- wrapperProps: {},
3824
- scrollerProps: {},
3825
- contentProps: {},
3826
- trackXProps: {},
3827
- trackYProps: {},
3828
- thumbXProps: {},
3829
- thumbYProps: {}
3830
- };
3831
- return Scrollbar;
3832
- }(React__namespace.Component);
3833
12
 
3834
13
  function Scrollbar(props) {
3835
14
  var children = props.children,
3836
15
  className = props.className,
3837
16
  scrollHeight = props.scrollHeight,
3838
17
  onScroll = props.onScroll;
3839
- return /*#__PURE__*/React__namespace.default.createElement(Scrollbar$1, {
18
+ return /*#__PURE__*/React__default.default.createElement(reactScrollbarsCustom.Scrollbar, {
3840
19
  className: clsx__default.default('scrollbar', className),
3841
20
  onScroll: onScroll,
3842
21
  wrapperProps: {