@synerise/ds-scrollbar 0.6.6 → 0.6.8

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,25 @@
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.6.8](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.6.7...@synerise/ds-scrollbar@0.6.8) (2023-10-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **scrollbar:** fixed toggling rail visibility on resize ([8df2258](https://github.com/Synerise/synerise-design/commit/8df2258d9f9ae8837510f4ddd6786c3018bdf96a))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.6.7](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.6.6...@synerise/ds-scrollbar@0.6.7) (2023-09-26)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-scrollbar
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.6.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-scrollbar@0.6.5...@synerise/ds-scrollbar@0.6.6) (2023-09-05)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-scrollbar
package/dist/Scrollbar.js CHANGED
@@ -18,13 +18,11 @@ var Scrollbar = React.forwardRef(function (_ref, forwardedRef) {
18
18
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
19
19
 
20
20
  var Component = withDnd ? DnDScrollbar : VirtualScrollbar;
21
- var renderScrollbar = React.useMemo(function () {
22
- return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
23
- fetchData: fetchData,
24
- ref: forwardedRef
25
- }), children);
26
- }, [children, fetchData, forwardedRef, props]);
27
- return /*#__PURE__*/React.createElement(S.ScrollbarContainer, null, renderScrollbar, loading && /*#__PURE__*/React.createElement(S.LoaderWrapper, null, /*#__PURE__*/React.createElement(S.Loader, {
21
+ var scrollbar = /*#__PURE__*/React.createElement(Component, _extends({}, props, {
22
+ fetchData: fetchData,
23
+ ref: forwardedRef
24
+ }), children);
25
+ return /*#__PURE__*/React.createElement(S.ScrollbarContainer, null, scrollbar, loading && /*#__PURE__*/React.createElement(S.LoaderWrapper, null, /*#__PURE__*/React.createElement(S.Loader, {
28
26
  loading: loading
29
27
  }, /*#__PURE__*/React.createElement(Icon, {
30
28
  component: /*#__PURE__*/React.createElement(SpinnerM, null),
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export declare type ScrollbarAdditionalProps = {
2
+ export type ScrollbarAdditionalProps = {
3
3
  absolute?: boolean;
4
4
  classes?: string;
5
5
  hasMore?: boolean;
@@ -11,6 +11,6 @@ export declare type ScrollbarAdditionalProps = {
11
11
  onYReachEnd?: () => void;
12
12
  withDnd?: boolean;
13
13
  };
14
- export declare type ScrollbarProps = ScrollbarAdditionalProps & {
14
+ export type ScrollbarProps = ScrollbarAdditionalProps & {
15
15
  children: React.ReactNode | string;
16
16
  };
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import './style/index.less';
3
3
  export declare const VirtualScrollbar: React.ForwardRefExoticComponent<import("../Scrollbar.types").ScrollbarAdditionalProps & {
4
4
  children: React.ReactNode;
@@ -1,10 +1,11 @@
1
- import * as React from 'react';
1
+ import React, { useCallback, forwardRef, useRef, useEffect, useState } from 'react';
2
2
  import PerfectScrollbar from 'react-perfect-scrollbar';
3
+ import { debounce } from 'lodash';
3
4
  import { useCombinedRefs } from '@synerise/ds-utils';
4
5
  import "./style/index.css";
5
6
  import * as S from './VirtualScrollbar.styles';
6
7
  // eslint-disable-next-line import/prefer-default-export
7
- export var VirtualScrollbar = React.forwardRef(function (_ref, forwardedRef) {
8
+ export var VirtualScrollbar = forwardRef(function (_ref, forwardedRef) {
8
9
  var _ref$absolute = _ref.absolute,
9
10
  absolute = _ref$absolute === void 0 ? false : _ref$absolute,
10
11
  children = _ref.children,
@@ -16,14 +17,35 @@ export var VirtualScrollbar = React.forwardRef(function (_ref, forwardedRef) {
16
17
  fetchData = _ref.fetchData,
17
18
  onScroll = _ref.onScroll,
18
19
  onYReachEnd = _ref.onYReachEnd;
19
- var scrollRef = React.useRef();
20
+ var scrollRef = useRef();
21
+ var wrapperRef = useRef(null);
20
22
  var combinedScrollRef = useCombinedRefs(forwardedRef, scrollRef);
21
23
 
22
- var _React$useState = React.useState(0),
23
- lastScrollTop = _React$useState[0],
24
- setLastScrollTop = _React$useState[1];
24
+ var _useState = useState(0),
25
+ lastScrollTop = _useState[0],
26
+ setLastScrollTop = _useState[1];
25
27
 
26
- var handleReachEnd = React.useCallback(function () {
28
+ var debouncedResize = useRef(debounce(function () {
29
+ if (combinedScrollRef && combinedScrollRef.current) {
30
+ var scrollEvent = new window.Event('scroll');
31
+ combinedScrollRef.current.dispatchEvent(scrollEvent);
32
+ }
33
+ }, 100, {
34
+ leading: true,
35
+ trailing: true
36
+ })).current;
37
+ var resizeObserver = useRef(new window.ResizeObserver(debouncedResize)).current;
38
+ useEffect(function () {
39
+ if (wrapperRef.current) {
40
+ resizeObserver.observe(wrapperRef.current);
41
+ }
42
+
43
+ return function () {
44
+ resizeObserver.disconnect();
45
+ debouncedResize.cancel();
46
+ };
47
+ }, [resizeObserver, debouncedResize]);
48
+ var handleReachEnd = useCallback(function () {
27
49
  var _combinedScrollRef$cu;
28
50
 
29
51
  if ((combinedScrollRef == null ? void 0 : (_combinedScrollRef$cu = combinedScrollRef.current) == null ? void 0 : _combinedScrollRef$cu.scrollTop) === lastScrollTop) {
@@ -40,7 +62,7 @@ export var VirtualScrollbar = React.forwardRef(function (_ref, forwardedRef) {
40
62
  fetchData();
41
63
  }
42
64
  }, [loading, hasMore, lastScrollTop, fetchData, onYReachEnd, combinedScrollRef]);
43
- var handleScrollUp = React.useCallback(function () {
65
+ var handleScrollUp = useCallback(function () {
44
66
  var _combinedScrollRef$cu2;
45
67
 
46
68
  if ((combinedScrollRef == null ? void 0 : (_combinedScrollRef$cu2 = combinedScrollRef.current) == null ? void 0 : _combinedScrollRef$cu2.scrollTop) !== 0) {
@@ -65,6 +87,7 @@ export var VirtualScrollbar = React.forwardRef(function (_ref, forwardedRef) {
65
87
  },
66
88
  "data-testid": "virtual-scrollbar"
67
89
  }, /*#__PURE__*/React.createElement(S.ScrollbarWrapper, {
90
+ ref: wrapperRef,
68
91
  absolute: absolute,
69
92
  loading: loading,
70
93
  style: style
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-scrollbar",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "Scrollbar UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-icon": "^0.58.1",
35
+ "@synerise/ds-icon": "^0.58.3",
36
36
  "react-perfect-scrollbar": "^1.5.8"
37
37
  },
38
38
  "peerDependencies": {
@@ -41,9 +41,9 @@
41
41
  "styled-components": "5.0.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@synerise/ds-utils": "^0.24.15",
44
+ "@synerise/ds-utils": "^0.24.17",
45
45
  "@testing-library/jest-dom": "5.1.1",
46
46
  "@types/resize-observer-browser": "^0.1.7"
47
47
  },
48
- "gitHead": "a2b1a3a78d87edfdbe97ae2f66573f4736f30e8b"
48
+ "gitHead": "1c1adf344f447e404a1d6320ad1d3f8486f29f67"
49
49
  }