@synerise/ds-scrollbar 0.11.19 → 0.11.21

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.11.21](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.11.20...@synerise/ds-scrollbar@0.11.21) (2024-11-29)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-scrollbar
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.11.20](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.11.19...@synerise/ds-scrollbar@0.11.20) (2024-11-28)
15
+
16
+ **Note:** Version bump only for package @synerise/ds-scrollbar
17
+
18
+
19
+
20
+
21
+
6
22
  ## [0.11.19](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.11.18...@synerise/ds-scrollbar@0.11.19) (2024-11-21)
7
23
 
8
24
  **Note:** Version bump only for package @synerise/ds-scrollbar
@@ -1,54 +1,44 @@
1
1
  var _excluded = ["children", "classes", "maxHeight", "absolute", "loading", "largeSize", "onScroll", "onYReachEnd", "fetchData", "hasMore", "confineScroll"];
2
-
3
2
  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); }
4
-
5
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
4
  import React, { useRef, useState, useCallback, useEffect } from 'react';
8
5
  import * as S from './DnDScrollbar.styles';
9
6
  // eslint-disable-next-line import/prefer-default-export
10
7
  export var DnDScrollbar = function DnDScrollbar(_ref) {
11
8
  var children = _ref.children,
12
- classes = _ref.classes,
13
- maxHeight = _ref.maxHeight,
14
- absolute = _ref.absolute,
15
- loading = _ref.loading,
16
- largeSize = _ref.largeSize,
17
- onScroll = _ref.onScroll,
18
- onYReachEnd = _ref.onYReachEnd,
19
- fetchData = _ref.fetchData,
20
- hasMore = _ref.hasMore,
21
- confineScroll = _ref.confineScroll,
22
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
23
-
9
+ classes = _ref.classes,
10
+ maxHeight = _ref.maxHeight,
11
+ absolute = _ref.absolute,
12
+ loading = _ref.loading,
13
+ largeSize = _ref.largeSize,
14
+ onScroll = _ref.onScroll,
15
+ onYReachEnd = _ref.onYReachEnd,
16
+ fetchData = _ref.fetchData,
17
+ hasMore = _ref.hasMore,
18
+ confineScroll = _ref.confineScroll,
19
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
24
20
  var contentRef = useRef(null);
25
21
  var wrapperRef = useRef(null);
26
22
  var scrollTrackRef = useRef(null);
27
23
  var scrollThumbRef = useRef(null);
28
24
  var observer = useRef(null);
29
-
30
25
  var _useState = useState(48),
31
- thumbHeight = _useState[0],
32
- setThumbHeight = _useState[1];
33
-
26
+ thumbHeight = _useState[0],
27
+ setThumbHeight = _useState[1];
34
28
  var _useState2 = useState(0),
35
- scrollStartPosition = _useState2[0],
36
- setScrollStartPosition = _useState2[1];
37
-
29
+ scrollStartPosition = _useState2[0],
30
+ setScrollStartPosition = _useState2[1];
38
31
  var _useState3 = useState(0),
39
- initialScrollTop = _useState3[0],
40
- setInitialScrollTop = _useState3[1];
41
-
32
+ initialScrollTop = _useState3[0],
33
+ setInitialScrollTop = _useState3[1];
42
34
  var _useState4 = useState(false),
43
- isDragging = _useState4[0],
44
- setIsDragging = _useState4[1];
45
-
35
+ isDragging = _useState4[0],
36
+ setIsDragging = _useState4[1];
46
37
  var handleTrackClick = useCallback(function (event) {
47
38
  event.preventDefault();
48
39
  event.stopPropagation();
49
40
  var trackCurrent = scrollTrackRef.current;
50
41
  var contentCurrent = contentRef.current;
51
-
52
42
  if (trackCurrent && contentCurrent) {
53
43
  var clientY = event.clientY;
54
44
  var target = event.target;
@@ -67,10 +57,9 @@ export var DnDScrollbar = function DnDScrollbar(_ref) {
67
57
  if (!contentRef.current || !scrollTrackRef.current || !scrollThumbRef.current) {
68
58
  return;
69
59
  }
70
-
71
60
  var _contentRef$current = contentRef.current,
72
- contentTop = _contentRef$current.scrollTop,
73
- contentHeight = _contentRef$current.scrollHeight;
61
+ contentTop = _contentRef$current.scrollTop,
62
+ contentHeight = _contentRef$current.scrollHeight;
74
63
  var trackHeight = scrollTrackRef.current.clientHeight;
75
64
  var newTop = +contentTop / +contentHeight * trackHeight;
76
65
  newTop = Math.min(newTop, trackHeight - thumbHeight);
@@ -85,18 +74,16 @@ export var DnDScrollbar = function DnDScrollbar(_ref) {
85
74
  }, []);
86
75
  var handleThumbMouseup = useCallback(function (event) {
87
76
  event.stopPropagation();
88
-
89
77
  if (isDragging) {
90
78
  setIsDragging(false);
91
79
  }
92
80
  }, [isDragging]);
93
81
  var handleThumbMousemove = useCallback(function (event) {
94
82
  event.stopPropagation();
95
-
96
83
  if (isDragging && contentRef.current !== null) {
97
84
  var _contentRef$current2 = contentRef.current,
98
- contentScrollHeight = _contentRef$current2.scrollHeight,
99
- contentOffsetHeight = _contentRef$current2.offsetHeight;
85
+ contentScrollHeight = _contentRef$current2.scrollHeight,
86
+ contentOffsetHeight = _contentRef$current2.offsetHeight;
100
87
  var deltaY = (event.clientY - scrollStartPosition) * (contentOffsetHeight / thumbHeight);
101
88
  contentRef.current.scrollTop = Math.min(initialScrollTop + deltaY, contentScrollHeight - contentOffsetHeight);
102
89
  }
@@ -104,25 +91,22 @@ export var DnDScrollbar = function DnDScrollbar(_ref) {
104
91
  var handleScroll = useCallback(function (event) {
105
92
  if (contentRef.current !== null) {
106
93
  var _contentRef$current3 = contentRef.current,
107
- scrollHeight = _contentRef$current3.scrollHeight,
108
- offsetHeight = _contentRef$current3.offsetHeight,
109
- scrollTop = _contentRef$current3.scrollTop;
94
+ scrollHeight = _contentRef$current3.scrollHeight,
95
+ offsetHeight = _contentRef$current3.offsetHeight,
96
+ scrollTop = _contentRef$current3.scrollTop;
110
97
  var progress = Math.round((scrollTop + offsetHeight) / scrollHeight * 100) / 100;
111
-
112
98
  if (progress === 1 && hasMore) {
113
99
  onYReachEnd && onYReachEnd();
114
100
  fetchData && fetchData();
115
101
  }
116
102
  }
117
-
118
103
  onScroll && onScroll(event);
119
104
  }, [fetchData, hasMore, onScroll, onYReachEnd]);
120
105
  var handleResize = useCallback(function (trackSize) {
121
106
  if (contentRef.current !== null) {
122
107
  var _contentRef$current4 = contentRef.current,
123
- clientHeightContent = _contentRef$current4.clientHeight,
124
- scrollHeightContent = _contentRef$current4.scrollHeight;
125
-
108
+ clientHeightContent = _contentRef$current4.clientHeight,
109
+ scrollHeightContent = _contentRef$current4.scrollHeight;
126
110
  if (clientHeightContent === scrollHeightContent) {
127
111
  setThumbHeight(0);
128
112
  } else {
@@ -131,19 +115,17 @@ export var DnDScrollbar = function DnDScrollbar(_ref) {
131
115
  }
132
116
  }
133
117
  }, [handleThumbPosition]);
134
-
135
118
  var handleWheel = function handleWheel(event) {
136
119
  if (confineScroll) {
137
120
  event.stopPropagation();
138
121
  }
139
122
  };
140
-
141
123
  useEffect(function () {
142
124
  if (contentRef.current !== null && scrollTrackRef.current !== null && wrapperRef.current !== null) {
143
125
  var ref = wrapperRef.current;
144
126
  var content = contentRef.current;
145
- var trackSize = scrollTrackRef.current.clientHeight; // eslint-disable-next-line no-undef
146
-
127
+ var trackSize = scrollTrackRef.current.clientHeight;
128
+ // eslint-disable-next-line no-undef
147
129
  observer.current = new ResizeObserver(function () {
148
130
  handleResize(trackSize);
149
131
  });
@@ -153,11 +135,9 @@ export var DnDScrollbar = function DnDScrollbar(_ref) {
153
135
  if (observer.current !== null) {
154
136
  observer.current.unobserve(ref);
155
137
  }
156
-
157
138
  content.removeEventListener('scroll', handleThumbPosition);
158
139
  };
159
140
  }
160
-
161
141
  return undefined;
162
142
  }, [handleResize, handleThumbPosition]);
163
143
  useEffect(function () {
@@ -14,13 +14,11 @@ export var ScrollbarWrapper = styled.div.withConfig({
14
14
  if (props.absolute) {
15
15
  return '';
16
16
  }
17
-
18
17
  return props.largeSize ? '24px !important' : '11px !important';
19
18
  }, function (props) {
20
19
  if (props.absolute) {
21
20
  return '';
22
21
  }
23
-
24
22
  return props.largeSize ? '20px !important' : '11px !important';
25
23
  }, function (props) {
26
24
  return props.loading ? '0.2' : '1';
package/dist/Scrollbar.js CHANGED
@@ -1,9 +1,6 @@
1
1
  var _excluded = ["children", "className", "loading", "withDnd", "fetchData"];
2
-
3
2
  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); }
4
-
5
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
4
  import React from 'react';
8
5
  import Icon, { SpinnerM } from '@synerise/ds-icon';
9
6
  import { theme } from '@synerise/ds-core';
@@ -12,12 +9,11 @@ import { DnDScrollbar } from './DnDScrollbar';
12
9
  import { VirtualScrollbar } from './VirtualScrollbar';
13
10
  var Scrollbar = React.forwardRef(function (_ref, forwardedRef) {
14
11
  var children = _ref.children,
15
- className = _ref.className,
16
- loading = _ref.loading,
17
- withDnd = _ref.withDnd,
18
- fetchData = _ref.fetchData,
19
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
20
-
12
+ className = _ref.className,
13
+ loading = _ref.loading,
14
+ withDnd = _ref.withDnd,
15
+ fetchData = _ref.fetchData,
16
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
21
17
  var Component = withDnd ? DnDScrollbar : VirtualScrollbar;
22
18
  var scrollbar = /*#__PURE__*/React.createElement(Component, _extends({}, props, {
23
19
  fetchData: fetchData,
@@ -1,13 +1,8 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  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; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  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); }
10
-
11
6
  import React, { useCallback, forwardRef, useRef, useEffect, useState } from 'react';
12
7
  import PerfectScrollbar from '@ofsajd/react-perfect-scrollbar';
13
8
  import { debounce } from 'lodash';
@@ -17,27 +12,25 @@ import * as S from './VirtualScrollbar.styles';
17
12
  // eslint-disable-next-line import/prefer-default-export
18
13
  export var VirtualScrollbar = forwardRef(function (_ref, forwardedRef) {
19
14
  var _ref$absolute = _ref.absolute,
20
- absolute = _ref$absolute === void 0 ? false : _ref$absolute,
21
- children = _ref.children,
22
- classes = _ref.classes,
23
- hasMore = _ref.hasMore,
24
- loading = _ref.loading,
25
- maxHeight = _ref.maxHeight,
26
- largeSize = _ref.largeSize,
27
- style = _ref.style,
28
- fetchData = _ref.fetchData,
29
- onScroll = _ref.onScroll,
30
- scrollbarOptions = _ref.scrollbarOptions,
31
- onYReachEnd = _ref.onYReachEnd,
32
- confineScroll = _ref.confineScroll;
15
+ absolute = _ref$absolute === void 0 ? false : _ref$absolute,
16
+ children = _ref.children,
17
+ classes = _ref.classes,
18
+ hasMore = _ref.hasMore,
19
+ loading = _ref.loading,
20
+ maxHeight = _ref.maxHeight,
21
+ largeSize = _ref.largeSize,
22
+ style = _ref.style,
23
+ fetchData = _ref.fetchData,
24
+ onScroll = _ref.onScroll,
25
+ scrollbarOptions = _ref.scrollbarOptions,
26
+ onYReachEnd = _ref.onYReachEnd,
27
+ confineScroll = _ref.confineScroll;
33
28
  var scrollRef = useRef();
34
29
  var wrapperRef = useRef(null);
35
30
  var combinedScrollRef = useCombinedRefs(forwardedRef, scrollRef);
36
-
37
31
  var _useState = useState(0),
38
- lastScrollTop = _useState[0],
39
- setLastScrollTop = _useState[1];
40
-
32
+ lastScrollTop = _useState[0],
33
+ setLastScrollTop = _useState[1];
41
34
  var debouncedResize = useRef(debounce(function () {
42
35
  if (combinedScrollRef && combinedScrollRef.current) {
43
36
  var scrollEvent = new window.Event('scroll');
@@ -52,7 +45,6 @@ export var VirtualScrollbar = forwardRef(function (_ref, forwardedRef) {
52
45
  if (wrapperRef.current) {
53
46
  resizeObserver.observe(wrapperRef.current);
54
47
  }
55
-
56
48
  return function () {
57
49
  resizeObserver.disconnect();
58
50
  debouncedResize.cancel();
@@ -60,24 +52,19 @@ export var VirtualScrollbar = forwardRef(function (_ref, forwardedRef) {
60
52
  }, [resizeObserver, debouncedResize]);
61
53
  var handleReachEnd = useCallback(function () {
62
54
  var _combinedScrollRef$cu;
63
-
64
55
  if ((combinedScrollRef == null || (_combinedScrollRef$cu = combinedScrollRef.current) == null ? void 0 : _combinedScrollRef$cu.scrollTop) === lastScrollTop) {
65
56
  return;
66
57
  }
67
-
68
58
  combinedScrollRef.current && setLastScrollTop(combinedScrollRef.current.scrollTop);
69
-
70
59
  if (typeof onYReachEnd === 'function') {
71
60
  onYReachEnd();
72
61
  }
73
-
74
62
  if (!loading && hasMore && fetchData) {
75
63
  fetchData();
76
64
  }
77
65
  }, [loading, hasMore, lastScrollTop, fetchData, onYReachEnd, combinedScrollRef]);
78
66
  var handleScrollUp = useCallback(function () {
79
67
  var _combinedScrollRef$cu2;
80
-
81
68
  if ((combinedScrollRef == null || (_combinedScrollRef$cu2 = combinedScrollRef.current) == null ? void 0 : _combinedScrollRef$cu2.scrollTop) !== 0) {
82
69
  setLastScrollTop(0);
83
70
  }
@@ -86,7 +73,6 @@ export var VirtualScrollbar = forwardRef(function (_ref, forwardedRef) {
86
73
  var handleWheel = confineScroll && function (event) {
87
74
  event.preventDefault();
88
75
  };
89
-
90
76
  var wrapper = wrapperRef.current;
91
77
  wrapper && handleWheel && wrapper.addEventListener('wheel', handleWheel);
92
78
  return function () {
@@ -10,13 +10,11 @@ export var ScrollbarWrapper = styled.div.withConfig({
10
10
  if (props.absolute) {
11
11
  return '';
12
12
  }
13
-
14
13
  return props.largeSize ? '24px !important' : '11px !important';
15
14
  }, function (props) {
16
15
  if (props.absolute) {
17
16
  return '';
18
17
  }
19
-
20
18
  return props.largeSize ? '20px !important' : '11px !important';
21
19
  }, function (props) {
22
20
  return props.loading ? '0.2' : '1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-scrollbar",
3
- "version": "0.11.19",
3
+ "version": "0.11.21",
4
4
  "description": "Scrollbar UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -35,7 +35,7 @@
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
37
  "@ofsajd/react-perfect-scrollbar": "1.0.0",
38
- "@synerise/ds-icon": "^0.67.0",
38
+ "@synerise/ds-icon": "^0.68.0",
39
39
  "@synerise/ds-utils": "^0.31.2",
40
40
  "lodash": "^4.7.21"
41
41
  },
@@ -44,5 +44,5 @@
44
44
  "react": ">=16.9.0 <= 17.0.2",
45
45
  "styled-components": "5.0.1"
46
46
  },
47
- "gitHead": "05f083c767e2cec3c2f91c9475aee89852a77d6c"
47
+ "gitHead": "9ebd107163650754a5f55680d62d30812d740084"
48
48
  }