@titaui/pc 1.6.28 → 1.6.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/components/dynamic/constant.js +30 -30
  2. package/lib/components/dynamic/dynamic-item/components/header/index.js +1 -1
  3. package/lib/components/dynamic/dynamic-item/dynamic-relative/index.js +5 -7
  4. package/lib/components/dynamic/dynamic-item/index.js +1 -1
  5. package/lib/components/dynamic/dynamic-list/index.js +2 -2
  6. package/lib/components/dynamic/dynamic.css +2 -2
  7. package/lib/components/dynamic/dynamic.js +1 -1
  8. package/lib/components/dynamic/new-ui.css +2 -2
  9. package/lib/components/menus/components/flip-menu-card/index.css +39 -0
  10. package/lib/components/menus/components/flip-menu-card/index.js +31 -11
  11. package/lib/components/menus/components/menu-card/index.css +0 -18
  12. package/lib/components/menus/components/menu-card/index.js +6 -19
  13. package/lib/components/menus/components/menu-close-btn/index.js +2 -1
  14. package/lib/components/menus/components/menu-tree/index.css +2 -0
  15. package/lib/components/menus/components/menu-tree/tree-node/index.css +3 -3
  16. package/lib/components/menus/export-modules/appraisal-menus/index.js +21 -4
  17. package/lib/components/menus/export-modules/{depart-menus → okr-menus/depart-menus}/helper.js +0 -0
  18. package/lib/components/menus/export-modules/{depart-menus → okr-menus/depart-menus}/index.css +0 -0
  19. package/lib/components/menus/export-modules/{depart-menus → okr-menus/depart-menus}/index.js +16 -27
  20. package/lib/components/menus/export-modules/okr-menus/index.js +3 -3
  21. package/lib/components/menus/export-modules/{subordinate-menus → okr-menus/subordinate-menus}/helper.js +0 -0
  22. package/lib/components/menus/export-modules/{subordinate-menus → okr-menus/subordinate-menus}/index.js +7 -16
  23. package/lib/components/menus/index.js +2 -6
  24. package/lib/components/menus/request-apis.js +2 -3
  25. package/lib/components/nav-top/components/user-message/components/empty/index.js +1 -1
  26. package/lib/components/nav-top/components/user-message/components/inform/index.js +1 -1
  27. package/lib/components/nav-top/components/user-message/components/inform/inform-item.js +50 -31
  28. package/lib/components/nav-top/components/user-message/components/remind/index.js +1 -1
  29. package/lib/components/nav-top/components/user-message/components/reply/index.js +1 -1
  30. package/lib/components/nav-top/components/user-message/components/tab-title/index.js +1 -1
  31. package/lib/components/nav-top/components/user-message/components/todos/index.js +1 -1
  32. package/lib/components/nav-top/components/user-message/index.js +1 -1
  33. package/lib/components/okrcase-library/new-ui.css +5 -2
  34. package/lib/components/photo-card/components/card/index.js +1 -1
  35. package/lib/components/photo-card/index.css +5 -0
  36. package/lib/components/photo-card/index.js +12 -4
  37. package/lib/components/scrollbar/index.css +3 -0
  38. package/lib/components/scrollbar/index.js +29 -0
  39. package/lib/components/scrollbar/simplebar/helpers.js +59 -0
  40. package/lib/components/scrollbar/simplebar/index.js +89 -0
  41. package/lib/components/scrollbar/simplebar/scrollbar-width.js +45 -0
  42. package/lib/components/scrollbar/simplebar/simplebar.js +852 -0
  43. package/lib/components/scrollbar/simplebar-react.js +163 -0
  44. package/lib/pages/new-okr-list/header/comments.js +8 -1
  45. package/lib/pages/new-okr-list/header/create-okr.js +5 -0
  46. package/lib/pages/new-okr-list/header/filter.js +9 -3
  47. package/lib/pages/new-okr-list/header/index.css +8 -2
  48. package/lib/pages/new-okr-list/header/index.js +9 -1
  49. package/lib/pages/new-okr-list/index.js +49 -3
  50. package/lib/pages/new-okr-list/list/index.js +1 -2
  51. package/package.json +1 -1
  52. package/lib/components/dynamic/components/condition-render/index.js +0 -20
@@ -0,0 +1,852 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
9
+
10
+ var _lodash2 = _interopRequireDefault(require("lodash.debounce"));
11
+
12
+ var _lodash3 = _interopRequireDefault(require("lodash.memoize"));
13
+
14
+ var _resizeObserver = require("@juggle/resize-observer");
15
+
16
+ var _canUseDom = _interopRequireDefault(require("can-use-dom"));
17
+
18
+ var _scrollbarWidth = _interopRequireDefault(require("./scrollbar-width"));
19
+
20
+ var _helpers = require("./helpers");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
24
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25
+
26
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
+
28
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+
30
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
31
+
32
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
33
+
34
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
35
+
36
+ var SimpleBar = /*#__PURE__*/function () {
37
+ function SimpleBar(element, options) {
38
+ var _this = this;
39
+
40
+ _classCallCheck(this, SimpleBar);
41
+
42
+ this.onScroll = function () {
43
+ var elWindow = (0, _helpers.getElementWindow)(_this.el);
44
+
45
+ if (!_this.scrollXTicking) {
46
+ elWindow.requestAnimationFrame(_this.scrollX);
47
+ _this.scrollXTicking = true;
48
+ }
49
+
50
+ if (!_this.scrollYTicking) {
51
+ elWindow.requestAnimationFrame(_this.scrollY);
52
+ _this.scrollYTicking = true;
53
+ }
54
+ };
55
+
56
+ this.scrollX = function () {
57
+ if (_this.axis.x.isOverflowing) {
58
+ _this.showScrollbar('x');
59
+
60
+ _this.positionScrollbar('x');
61
+ }
62
+
63
+ _this.scrollXTicking = false;
64
+ };
65
+
66
+ this.scrollY = function () {
67
+ if (_this.axis.y.isOverflowing) {
68
+ _this.showScrollbar('y');
69
+
70
+ _this.positionScrollbar('y');
71
+ }
72
+
73
+ _this.scrollYTicking = false;
74
+ };
75
+
76
+ this.onMouseEnter = function () {
77
+ _this.showScrollbar('x');
78
+
79
+ _this.showScrollbar('y');
80
+ };
81
+
82
+ this.onMouseMove = function (e) {
83
+ _this.mouseX = e.clientX;
84
+ _this.mouseY = e.clientY;
85
+
86
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
87
+ _this.onMouseMoveForAxis('x');
88
+ }
89
+
90
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
91
+ _this.onMouseMoveForAxis('y');
92
+ }
93
+ };
94
+
95
+ this.onMouseLeave = function () {
96
+ _this.onMouseMove.cancel();
97
+
98
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
99
+ _this.onMouseLeaveForAxis('x');
100
+ }
101
+
102
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
103
+ _this.onMouseLeaveForAxis('y');
104
+ }
105
+
106
+ _this.mouseX = -1;
107
+ _this.mouseY = -1;
108
+ };
109
+
110
+ this.onWindowResize = function () {
111
+ // Recalculate scrollbarWidth in case it's a zoom
112
+ _this.scrollbarWidth = _this.getScrollbarWidth();
113
+
114
+ _this.hideNativeScrollbar();
115
+ };
116
+
117
+ this.hideScrollbars = function () {
118
+ _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
119
+ _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
120
+
121
+ if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
122
+ _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
123
+
124
+ _this.axis.y.isVisible = false;
125
+ }
126
+
127
+ if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
128
+ _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
129
+
130
+ _this.axis.x.isVisible = false;
131
+ }
132
+ };
133
+
134
+ this.onPointerEvent = function (e) {
135
+ var isWithinTrackXBounds, isWithinTrackYBounds;
136
+ _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
137
+ _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
138
+
139
+ if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
140
+ isWithinTrackXBounds = _this.isWithinBounds(_this.axis.x.track.rect);
141
+ }
142
+
143
+ if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
144
+ isWithinTrackYBounds = _this.isWithinBounds(_this.axis.y.track.rect);
145
+ } // If any pointer event is called on the scrollbar
146
+
147
+
148
+ if (isWithinTrackXBounds || isWithinTrackYBounds) {
149
+ // Preventing the event's default action stops text being
150
+ // selectable during the drag.
151
+ e.preventDefault(); // Prevent event leaking
152
+
153
+ e.stopPropagation();
154
+
155
+ if (e.type === 'mousedown') {
156
+ if (isWithinTrackXBounds) {
157
+ _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
158
+
159
+ if (_this.isWithinBounds(_this.axis.x.scrollbar.rect)) {
160
+ _this.onDragStart(e, 'x');
161
+ } else {
162
+ _this.onTrackClick(e, 'x');
163
+ }
164
+ }
165
+
166
+ if (isWithinTrackYBounds) {
167
+ _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
168
+
169
+ if (_this.isWithinBounds(_this.axis.y.scrollbar.rect)) {
170
+ _this.onDragStart(e, 'y');
171
+ } else {
172
+ _this.onTrackClick(e, 'y');
173
+ }
174
+ }
175
+ }
176
+ }
177
+ };
178
+
179
+ this.drag = function (e) {
180
+ var eventOffset;
181
+ var track = _this.axis[_this.draggedAxis].track;
182
+ var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
183
+ var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
184
+ var contentSize = _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr];
185
+ var hostSize = parseInt(_this.elStyles[_this.axis[_this.draggedAxis].sizeAttr], 10);
186
+ e.preventDefault();
187
+ e.stopPropagation();
188
+
189
+ if (_this.draggedAxis === 'y') {
190
+ eventOffset = e.pageY;
191
+ } else {
192
+ eventOffset = e.pageX;
193
+ } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
194
+
195
+
196
+ var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
197
+
198
+ var dragPerc = dragPos / (trackSize - scrollbar.size); // Scroll the content by the same percentage.
199
+
200
+ var scrollPos = dragPerc * (contentSize - hostSize); // Fix browsers inconsistency on RTL
201
+
202
+ if (_this.draggedAxis === 'x') {
203
+ scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
204
+ scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
205
+ }
206
+
207
+ _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
208
+ };
209
+
210
+ this.onEndDrag = function (e) {
211
+ var elDocument = (0, _helpers.getElementDocument)(_this.el);
212
+ var elWindow = (0, _helpers.getElementWindow)(_this.el);
213
+ e.preventDefault();
214
+ e.stopPropagation();
215
+
216
+ _this.el.classList.remove(_this.classNames.dragging);
217
+
218
+ elDocument.removeEventListener('mousemove', _this.drag, true);
219
+ elDocument.removeEventListener('mouseup', _this.onEndDrag, true);
220
+ _this.removePreventClickId = elWindow.setTimeout(function () {
221
+ // Remove these asynchronously so we still suppress click events
222
+ // generated simultaneously with mouseup.
223
+ elDocument.removeEventListener('click', _this.preventClick, true);
224
+ elDocument.removeEventListener('dblclick', _this.preventClick, true);
225
+ _this.removePreventClickId = null;
226
+ });
227
+ };
228
+
229
+ this.preventClick = function (e) {
230
+ e.preventDefault();
231
+ e.stopPropagation();
232
+ };
233
+
234
+ this.el = element;
235
+ this.minScrollbarWidth = 20;
236
+ this.options = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions), options);
237
+ this.classNames = _objectSpread(_objectSpread({}, SimpleBar.defaultOptions.classNames), this.options.classNames);
238
+ this.axis = {
239
+ x: {
240
+ scrollOffsetAttr: 'scrollLeft',
241
+ sizeAttr: 'width',
242
+ scrollSizeAttr: 'scrollWidth',
243
+ offsetSizeAttr: 'offsetWidth',
244
+ offsetAttr: 'left',
245
+ overflowAttr: 'overflowX',
246
+ dragOffset: 0,
247
+ isOverflowing: true,
248
+ isVisible: false,
249
+ forceVisible: false,
250
+ track: {},
251
+ scrollbar: {}
252
+ },
253
+ y: {
254
+ scrollOffsetAttr: 'scrollTop',
255
+ sizeAttr: 'height',
256
+ scrollSizeAttr: 'scrollHeight',
257
+ offsetSizeAttr: 'offsetHeight',
258
+ offsetAttr: 'top',
259
+ overflowAttr: 'overflowY',
260
+ dragOffset: 0,
261
+ isOverflowing: true,
262
+ isVisible: false,
263
+ forceVisible: false,
264
+ track: {},
265
+ scrollbar: {}
266
+ }
267
+ };
268
+ this.removePreventClickId = null; // Don't re-instantiate over an existing one
269
+
270
+ if (SimpleBar.instances.has(this.el)) {
271
+ return;
272
+ }
273
+
274
+ this.recalculate = (0, _lodash["default"])(this.recalculate.bind(this), 64);
275
+ this.onMouseMove = (0, _lodash["default"])(this.onMouseMove.bind(this), 64);
276
+ this.hideScrollbars = (0, _lodash2["default"])(this.hideScrollbars.bind(this), this.options.timeout);
277
+ this.onWindowResize = (0, _lodash2["default"])(this.onWindowResize.bind(this), 64, {
278
+ leading: true
279
+ });
280
+ SimpleBar.getRtlHelpers = (0, _lodash3["default"])(SimpleBar.getRtlHelpers);
281
+ this.init();
282
+ }
283
+ /**
284
+ * Static properties
285
+ */
286
+
287
+ /**
288
+ * Helper to fix browsers inconsistency on RTL:
289
+ * - Firefox inverts the scrollbar initial position
290
+ * - IE11 inverts both scrollbar position and scrolling offset
291
+ * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
292
+ */
293
+
294
+
295
+ _createClass(SimpleBar, [{
296
+ key: "init",
297
+ value: function init() {
298
+ // Save a reference to the instance, so we know this DOM node has already been instancied
299
+ SimpleBar.instances.set(this.el, this); // We stop here on server-side
300
+
301
+ if (_canUseDom["default"]) {
302
+ this.initDOM();
303
+ this.setAccessibilityAttributes();
304
+ this.scrollbarWidth = this.getScrollbarWidth();
305
+ this.recalculate();
306
+ this.initListeners();
307
+ }
308
+ }
309
+ }, {
310
+ key: "initDOM",
311
+ value: function initDOM() {
312
+ var _this2 = this;
313
+
314
+ // make sure this element doesn't have the elements yet
315
+ if (Array.prototype.filter.call(this.el.children, function (child) {
316
+ return child.classList.contains(_this2.classNames.wrapper);
317
+ }).length) {
318
+ // assume that element has his DOM already initiated
319
+ this.wrapperEl = this.el.querySelector(".".concat(this.classNames.wrapper));
320
+ this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector(".".concat(this.classNames.contentWrapper));
321
+ this.contentEl = this.options.contentNode || this.el.querySelector(".".concat(this.classNames.contentEl));
322
+ this.offsetEl = this.el.querySelector(".".concat(this.classNames.offset));
323
+ this.maskEl = this.el.querySelector(".".concat(this.classNames.mask));
324
+ this.placeholderEl = this.findChild(this.wrapperEl, ".".concat(this.classNames.placeholder));
325
+ this.heightAutoObserverWrapperEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverWrapperEl));
326
+ this.heightAutoObserverEl = this.el.querySelector(".".concat(this.classNames.heightAutoObserverEl));
327
+ this.axis.x.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.horizontal));
328
+ this.axis.y.track.el = this.findChild(this.el, ".".concat(this.classNames.track, ".").concat(this.classNames.vertical));
329
+ } else {
330
+ // Prepare DOM
331
+ this.wrapperEl = document.createElement('div');
332
+ this.contentWrapperEl = document.createElement('div');
333
+ this.offsetEl = document.createElement('div');
334
+ this.maskEl = document.createElement('div');
335
+ this.contentEl = document.createElement('div');
336
+ this.placeholderEl = document.createElement('div');
337
+ this.heightAutoObserverWrapperEl = document.createElement('div');
338
+ this.heightAutoObserverEl = document.createElement('div');
339
+ this.wrapperEl.classList.add(this.classNames.wrapper);
340
+ this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
341
+ this.offsetEl.classList.add(this.classNames.offset);
342
+ this.maskEl.classList.add(this.classNames.mask);
343
+ this.contentEl.classList.add(this.classNames.contentEl);
344
+ this.placeholderEl.classList.add(this.classNames.placeholder);
345
+ this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
346
+ this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
347
+
348
+ while (this.el.firstChild) {
349
+ this.contentEl.appendChild(this.el.firstChild);
350
+ }
351
+
352
+ this.contentWrapperEl.appendChild(this.contentEl);
353
+ this.offsetEl.appendChild(this.contentWrapperEl);
354
+ this.maskEl.appendChild(this.offsetEl);
355
+ this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
356
+ this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
357
+ this.wrapperEl.appendChild(this.maskEl);
358
+ this.wrapperEl.appendChild(this.placeholderEl);
359
+ this.el.appendChild(this.wrapperEl);
360
+ }
361
+
362
+ if (!this.axis.x.track.el || !this.axis.y.track.el) {
363
+ var track = document.createElement('div');
364
+ var scrollbar = document.createElement('div');
365
+ track.classList.add(this.classNames.track);
366
+ scrollbar.classList.add(this.classNames.scrollbar);
367
+ track.appendChild(scrollbar);
368
+ this.axis.x.track.el = track.cloneNode(true);
369
+ this.axis.x.track.el.classList.add(this.classNames.horizontal);
370
+ this.axis.y.track.el = track.cloneNode(true);
371
+ this.axis.y.track.el.classList.add(this.classNames.vertical);
372
+ this.el.appendChild(this.axis.x.track.el);
373
+ this.el.appendChild(this.axis.y.track.el);
374
+ }
375
+
376
+ this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(".".concat(this.classNames.scrollbar));
377
+ this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(".".concat(this.classNames.scrollbar));
378
+
379
+ if (!this.options.autoHide) {
380
+ this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
381
+ this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
382
+ }
383
+
384
+ this.el.setAttribute('data-simplebar', 'init');
385
+ }
386
+ }, {
387
+ key: "setAccessibilityAttributes",
388
+ value: function setAccessibilityAttributes() {
389
+ var ariaLabel = this.options.ariaLabel || 'scrollable content';
390
+ this.contentWrapperEl.setAttribute('tabindex', '0');
391
+ this.contentWrapperEl.setAttribute('role', 'region');
392
+ this.contentWrapperEl.setAttribute('aria-label', ariaLabel);
393
+ }
394
+ }, {
395
+ key: "initListeners",
396
+ value: function initListeners() {
397
+ var _this3 = this;
398
+
399
+ var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
400
+
401
+ if (this.options.autoHide) {
402
+ this.el.addEventListener('mouseenter', this.onMouseEnter);
403
+ }
404
+
405
+ ['mousedown', 'click', 'dblclick'].forEach(function (e) {
406
+ _this3.el.addEventListener(e, _this3.onPointerEvent, true);
407
+ });
408
+ ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
409
+ _this3.el.addEventListener(e, _this3.onPointerEvent, {
410
+ capture: true,
411
+ passive: true
412
+ });
413
+ });
414
+ this.el.addEventListener('mousemove', this.onMouseMove);
415
+ this.el.addEventListener('mouseleave', this.onMouseLeave);
416
+ this.contentWrapperEl.addEventListener('scroll', this.onScroll); // Browser zoom triggers a window resize
417
+
418
+ elWindow.addEventListener('resize', this.onWindowResize); // Hack for https://github.com/WICG/ResizeObserver/issues/38
419
+
420
+ var resizeObserverStarted = false;
421
+ var resizeObserver = elWindow.ResizeObserver || _resizeObserver.ResizeObserver;
422
+ this.resizeObserver = new resizeObserver(function () {
423
+ if (!resizeObserverStarted) return;
424
+
425
+ _this3.recalculate();
426
+ });
427
+ this.resizeObserver.observe(this.el);
428
+ this.resizeObserver.observe(this.contentEl);
429
+ elWindow.requestAnimationFrame(function () {
430
+ resizeObserverStarted = true;
431
+ }); // This is required to detect horizontal scroll. Vertical scroll only needs the resizeObserver.
432
+
433
+ this.mutationObserver = new elWindow.MutationObserver(this.recalculate);
434
+ this.mutationObserver.observe(this.contentEl, {
435
+ childList: true,
436
+ subtree: true,
437
+ characterData: true
438
+ });
439
+ }
440
+ }, {
441
+ key: "recalculate",
442
+ value: function recalculate() {
443
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
444
+ this.elStyles = elWindow.getComputedStyle(this.el);
445
+ this.isRtl = this.elStyles.direction === 'rtl';
446
+ var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
447
+ var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1;
448
+ var contentElOffsetWidth = this.contentEl.offsetWidth;
449
+ var contentWrapperElOffsetWidth = this.contentWrapperEl.offsetWidth;
450
+ var elOverflowX = this.elStyles.overflowX;
451
+ var elOverflowY = this.elStyles.overflowY;
452
+ this.contentEl.style.padding = "".concat(this.elStyles.paddingTop, " ").concat(this.elStyles.paddingRight, " ").concat(this.elStyles.paddingBottom, " ").concat(this.elStyles.paddingLeft);
453
+ this.wrapperEl.style.margin = "-".concat(this.elStyles.paddingTop, " -").concat(this.elStyles.paddingRight, " -").concat(this.elStyles.paddingBottom, " -").concat(this.elStyles.paddingLeft);
454
+ var contentElScrollHeight = this.contentEl.scrollHeight;
455
+ var contentElScrollWidth = this.contentEl.scrollWidth;
456
+ this.contentWrapperEl.style.height = isHeightAuto ? 'auto' : '100%'; // Determine placeholder size
457
+
458
+ this.placeholderEl.style.width = isWidthAuto ? "".concat(contentElOffsetWidth, "px") : 'auto';
459
+ this.placeholderEl.style.height = "".concat(contentElScrollHeight, "px");
460
+ var contentWrapperElOffsetHeight = this.contentWrapperEl.offsetHeight;
461
+ this.axis.x.isOverflowing = contentElScrollWidth > contentElOffsetWidth;
462
+ this.axis.y.isOverflowing = contentElScrollHeight > contentWrapperElOffsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
463
+
464
+ this.axis.x.isOverflowing = elOverflowX === 'hidden' ? false : this.axis.x.isOverflowing;
465
+ this.axis.y.isOverflowing = elOverflowY === 'hidden' ? false : this.axis.y.isOverflowing;
466
+ this.axis.x.forceVisible = this.options.forceVisible === 'x' || this.options.forceVisible === true;
467
+ this.axis.y.forceVisible = this.options.forceVisible === 'y' || this.options.forceVisible === true;
468
+ this.hideNativeScrollbar(); // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
469
+
470
+ var offsetForXScrollbar = this.axis.x.isOverflowing ? this.scrollbarWidth : 0;
471
+ var offsetForYScrollbar = this.axis.y.isOverflowing ? this.scrollbarWidth : 0;
472
+ this.axis.x.isOverflowing = this.axis.x.isOverflowing && contentElScrollWidth > contentWrapperElOffsetWidth - offsetForYScrollbar;
473
+ this.axis.y.isOverflowing = this.axis.y.isOverflowing && contentElScrollHeight > contentWrapperElOffsetHeight - offsetForXScrollbar;
474
+ this.axis.x.scrollbar.size = this.getScrollbarSize('x');
475
+ this.axis.y.scrollbar.size = this.getScrollbarSize('y');
476
+ this.axis.x.scrollbar.el.style.width = "".concat(this.axis.x.scrollbar.size, "px");
477
+ this.axis.y.scrollbar.el.style.height = "".concat(this.axis.y.scrollbar.size, "px");
478
+ this.positionScrollbar('x');
479
+ this.positionScrollbar('y');
480
+ this.toggleTrackVisibility('x');
481
+ this.toggleTrackVisibility('y');
482
+ }
483
+ /**
484
+ * Calculate scrollbar size
485
+ */
486
+
487
+ }, {
488
+ key: "getScrollbarSize",
489
+ value: function getScrollbarSize() {
490
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
491
+
492
+ if (!this.axis[axis].isOverflowing) {
493
+ return 0;
494
+ }
495
+
496
+ var contentSize = this.contentEl[this.axis[axis].scrollSizeAttr];
497
+ var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
498
+ var scrollbarSize;
499
+ var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
500
+
501
+ scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
502
+
503
+ if (this.options.scrollbarMaxSize) {
504
+ scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
505
+ }
506
+
507
+ return scrollbarSize;
508
+ }
509
+ }, {
510
+ key: "positionScrollbar",
511
+ value: function positionScrollbar() {
512
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
513
+
514
+ if (!this.axis[axis].isOverflowing) {
515
+ return;
516
+ }
517
+
518
+ var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
519
+ var trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
520
+ var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
521
+ var scrollbar = this.axis[axis].scrollbar;
522
+ var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
523
+ scrollOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
524
+ var scrollPourcent = scrollOffset / (contentSize - hostSize);
525
+ var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
526
+ handleOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
527
+ scrollbar.el.style.transform = axis === 'x' ? "translate3d(".concat(handleOffset, "px, 0, 0)") : "translate3d(0, ".concat(handleOffset, "px, 0)");
528
+ }
529
+ }, {
530
+ key: "toggleTrackVisibility",
531
+ value: function toggleTrackVisibility() {
532
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
533
+ var track = this.axis[axis].track.el;
534
+ var scrollbar = this.axis[axis].scrollbar.el;
535
+
536
+ if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
537
+ track.style.visibility = 'visible';
538
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'scroll';
539
+ } else {
540
+ track.style.visibility = 'hidden';
541
+ this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'hidden';
542
+ } // Even if forceVisible is enabled, scrollbar itself should be hidden
543
+
544
+
545
+ if (this.axis[axis].isOverflowing) {
546
+ scrollbar.style.display = 'block';
547
+ } else {
548
+ scrollbar.style.display = 'none';
549
+ }
550
+ }
551
+ }, {
552
+ key: "hideNativeScrollbar",
553
+ value: function hideNativeScrollbar() {
554
+ this.offsetEl.style[this.isRtl ? 'left' : 'right'] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
555
+ this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-".concat(this.scrollbarWidth, "px") : 0;
556
+ }
557
+ /**
558
+ * On scroll event handling
559
+ */
560
+
561
+ }, {
562
+ key: "onMouseMoveForAxis",
563
+ value: function onMouseMoveForAxis() {
564
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
565
+ this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
566
+ this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
567
+ var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
568
+
569
+ if (isWithinScrollbarBoundsX) {
570
+ this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
571
+ } else {
572
+ this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
573
+ }
574
+
575
+ if (this.isWithinBounds(this.axis[axis].track.rect)) {
576
+ this.showScrollbar(axis);
577
+ this.axis[axis].track.el.classList.add(this.classNames.hover);
578
+ } else {
579
+ this.axis[axis].track.el.classList.remove(this.classNames.hover);
580
+ }
581
+ }
582
+ }, {
583
+ key: "onMouseLeaveForAxis",
584
+ value: function onMouseLeaveForAxis() {
585
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
586
+ this.axis[axis].track.el.classList.remove(this.classNames.hover);
587
+ this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
588
+ }
589
+ }, {
590
+ key: "showScrollbar",
591
+ value:
592
+ /**
593
+ * Show scrollbar
594
+ */
595
+ function showScrollbar() {
596
+ var axis = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'y';
597
+ var scrollbar = this.axis[axis].scrollbar.el;
598
+
599
+ if (!this.axis[axis].isVisible) {
600
+ scrollbar.classList.add(this.classNames.visible);
601
+ this.axis[axis].isVisible = true;
602
+ }
603
+
604
+ if (this.options.autoHide) {
605
+ this.hideScrollbars();
606
+ }
607
+ }
608
+ /**
609
+ * Hide Scrollbar
610
+ */
611
+
612
+ }, {
613
+ key: "onDragStart",
614
+ value:
615
+ /**
616
+ * on scrollbar handle drag movement starts
617
+ */
618
+ function onDragStart(e) {
619
+ var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'y';
620
+ var elDocument = (0, _helpers.getElementDocument)(this.el);
621
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
622
+ var scrollbar = this.axis[axis].scrollbar; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
623
+
624
+ var eventOffset = axis === 'y' ? e.pageY : e.pageX;
625
+ this.axis[axis].dragOffset = eventOffset - scrollbar.rect[this.axis[axis].offsetAttr];
626
+ this.draggedAxis = axis;
627
+ this.el.classList.add(this.classNames.dragging);
628
+ elDocument.addEventListener('mousemove', this.drag, true);
629
+ elDocument.addEventListener('mouseup', this.onEndDrag, true);
630
+
631
+ if (this.removePreventClickId === null) {
632
+ elDocument.addEventListener('click', this.preventClick, true);
633
+ elDocument.addEventListener('dblclick', this.preventClick, true);
634
+ } else {
635
+ elWindow.clearTimeout(this.removePreventClickId);
636
+ this.removePreventClickId = null;
637
+ }
638
+ }
639
+ /**
640
+ * Drag scrollbar handle
641
+ */
642
+
643
+ }, {
644
+ key: "onTrackClick",
645
+ value: function onTrackClick(e) {
646
+ var _this4 = this;
647
+
648
+ var axis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'y';
649
+ if (!this.options.clickOnTrack) return;
650
+ var elWindow = (0, _helpers.getElementWindow)(this.el);
651
+ this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
652
+ var scrollbar = this.axis[axis].scrollbar;
653
+ var scrollbarOffset = scrollbar.rect[this.axis[axis].offsetAttr];
654
+ var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
655
+ var scrolled = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
656
+ var t = axis === 'y' ? this.mouseY - scrollbarOffset : this.mouseX - scrollbarOffset;
657
+ var dir = t < 0 ? -1 : 1;
658
+ var scrollSize = dir === -1 ? scrolled - hostSize : scrolled + hostSize;
659
+
660
+ var scrollTo = function scrollTo() {
661
+ if (dir === -1) {
662
+ if (scrolled > scrollSize) {
663
+ scrolled -= _this4.options.clickOnTrackSpeed;
664
+
665
+ _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
666
+
667
+ elWindow.requestAnimationFrame(scrollTo);
668
+ }
669
+ } else {
670
+ if (scrolled < scrollSize) {
671
+ scrolled += _this4.options.clickOnTrackSpeed;
672
+
673
+ _this4.contentWrapperEl.scrollTo(_defineProperty({}, _this4.axis[axis].offsetAttr, scrolled));
674
+
675
+ elWindow.requestAnimationFrame(scrollTo);
676
+ }
677
+ }
678
+ };
679
+
680
+ scrollTo();
681
+ }
682
+ /**
683
+ * Getter for content element
684
+ */
685
+
686
+ }, {
687
+ key: "getContentElement",
688
+ value: function getContentElement() {
689
+ return this.contentEl;
690
+ }
691
+ /**
692
+ * Getter for original scrolling element
693
+ */
694
+
695
+ }, {
696
+ key: "getScrollElement",
697
+ value: function getScrollElement() {
698
+ return this.contentWrapperEl;
699
+ }
700
+ }, {
701
+ key: "getScrollbarWidth",
702
+ value: function getScrollbarWidth() {
703
+ // Try/catch for FF 56 throwing on undefined computedStyles
704
+ try {
705
+ // Detect browsers supporting CSS scrollbar styling and do not calculate
706
+ if (getComputedStyle(this.contentWrapperEl, '::-webkit-scrollbar').display === 'none' || 'scrollbarWidth' in document.documentElement.style || '-ms-overflow-style' in document.documentElement.style) {
707
+ return 0;
708
+ } else {
709
+ return (0, _scrollbarWidth["default"])(this.el);
710
+ }
711
+ } catch (e) {
712
+ return (0, _scrollbarWidth["default"])(this.el);
713
+ }
714
+ }
715
+ }, {
716
+ key: "removeListeners",
717
+ value: function removeListeners() {
718
+ var _this5 = this;
719
+
720
+ var elWindow = (0, _helpers.getElementWindow)(this.el); // Event listeners
721
+
722
+ if (this.options.autoHide) {
723
+ this.el.removeEventListener('mouseenter', this.onMouseEnter);
724
+ }
725
+
726
+ ['mousedown', 'click', 'dblclick'].forEach(function (e) {
727
+ _this5.el.removeEventListener(e, _this5.onPointerEvent, true);
728
+ });
729
+ ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
730
+ _this5.el.removeEventListener(e, _this5.onPointerEvent, {
731
+ capture: true,
732
+ passive: true
733
+ });
734
+ });
735
+ this.el.removeEventListener('mousemove', this.onMouseMove);
736
+ this.el.removeEventListener('mouseleave', this.onMouseLeave);
737
+
738
+ if (this.contentWrapperEl) {
739
+ this.contentWrapperEl.removeEventListener('scroll', this.onScroll);
740
+ }
741
+
742
+ elWindow.removeEventListener('resize', this.onWindowResize);
743
+
744
+ if (this.mutationObserver) {
745
+ this.mutationObserver.disconnect();
746
+ }
747
+
748
+ if (this.resizeObserver) {
749
+ this.resizeObserver.disconnect();
750
+ } // Cancel all debounced functions
751
+
752
+
753
+ this.recalculate.cancel();
754
+ this.onMouseMove.cancel();
755
+ this.hideScrollbars.cancel();
756
+ this.onWindowResize.cancel();
757
+ }
758
+ /**
759
+ * UnMount mutation observer and delete SimpleBar instance from DOM element
760
+ */
761
+
762
+ }, {
763
+ key: "unMount",
764
+ value: function unMount() {
765
+ this.removeListeners();
766
+ SimpleBar.instances["delete"](this.el);
767
+ }
768
+ /**
769
+ * Check if mouse is within bounds
770
+ */
771
+
772
+ }, {
773
+ key: "isWithinBounds",
774
+ value: function isWithinBounds(bbox) {
775
+ return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
776
+ }
777
+ /**
778
+ * Find element children matches query
779
+ */
780
+
781
+ }, {
782
+ key: "findChild",
783
+ value: function findChild(el, query) {
784
+ var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
785
+ return Array.prototype.filter.call(el.children, function (child) {
786
+ return matches.call(child, query);
787
+ })[0];
788
+ }
789
+ }], [{
790
+ key: "getRtlHelpers",
791
+ value: function getRtlHelpers() {
792
+ var dummyDiv = document.createElement('div');
793
+ dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
794
+ var scrollbarDummyEl = dummyDiv.firstElementChild;
795
+ document.body.appendChild(scrollbarDummyEl);
796
+ var dummyContainerChild = scrollbarDummyEl.firstElementChild;
797
+ scrollbarDummyEl.scrollLeft = 0;
798
+ var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
799
+ var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
800
+ scrollbarDummyEl.scrollLeft = 999;
801
+ var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
802
+ return {
803
+ // determines if the scrolling is responding with negative values
804
+ isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
805
+ // determines if the origin scrollbar position is inverted or not (positioned on left or right)
806
+ isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
807
+ };
808
+ }
809
+ }, {
810
+ key: "getOffset",
811
+ value: function getOffset(el) {
812
+ var rect = el.getBoundingClientRect();
813
+ var elDocument = (0, _helpers.getElementDocument)(el);
814
+ var elWindow = (0, _helpers.getElementWindow)(el);
815
+ return {
816
+ top: rect.top + (elWindow.pageYOffset || elDocument.documentElement.scrollTop),
817
+ left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
818
+ };
819
+ }
820
+ }]);
821
+
822
+ return SimpleBar;
823
+ }();
824
+
825
+ exports["default"] = SimpleBar;
826
+ SimpleBar.defaultOptions = {
827
+ autoHide: true,
828
+ forceVisible: false,
829
+ clickOnTrack: true,
830
+ clickOnTrackSpeed: 40,
831
+ classNames: {
832
+ contentEl: 'simplebar-content',
833
+ contentWrapper: 'simplebar-content-wrapper',
834
+ offset: 'simplebar-offset',
835
+ mask: 'simplebar-mask',
836
+ wrapper: 'simplebar-wrapper',
837
+ placeholder: 'simplebar-placeholder',
838
+ scrollbar: 'simplebar-scrollbar',
839
+ track: 'simplebar-track',
840
+ heightAutoObserverWrapperEl: 'simplebar-height-auto-observer-wrapper',
841
+ heightAutoObserverEl: 'simplebar-height-auto-observer',
842
+ visible: 'simplebar-visible',
843
+ horizontal: 'simplebar-horizontal',
844
+ vertical: 'simplebar-vertical',
845
+ hover: 'simplebar-hover',
846
+ dragging: 'simplebar-dragging'
847
+ },
848
+ scrollbarMinSize: 25,
849
+ scrollbarMaxSize: 0,
850
+ timeout: 1000
851
+ };
852
+ SimpleBar.instances = new WeakMap();