@geneui/components 3.0.0-next-65b0240-02122024 → 3.0.0-next-b9961e0-15012025

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