@micromag/element-scroll 0.3.348 → 0.3.354

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/es/index.js CHANGED
@@ -17,10 +17,12 @@ var propTypes = {
17
17
  children: PropTypes.node,
18
18
  onScrolledBottom: PropTypes.func,
19
19
  onScrolledNotBottom: PropTypes.func,
20
+ onScrollHeightChange: PropTypes.func,
20
21
  contain: PropTypes.bool,
21
22
  scrollContainerRef: PropTypes.any,
22
23
  // eslint-disable-line
23
- withShadow: PropTypes.bool
24
+ withShadow: PropTypes.bool,
25
+ withArrow: PropTypes.bool
24
26
  };
25
27
  var defaultProps = {
26
28
  width: null,
@@ -31,9 +33,11 @@ var defaultProps = {
31
33
  children: null,
32
34
  onScrolledBottom: null,
33
35
  onScrolledNotBottom: null,
36
+ onScrollHeightChange: null,
34
37
  contain: false,
35
38
  scrollContainerRef: null,
36
- withShadow: false
39
+ withShadow: false,
40
+ withArrow: true
37
41
  };
38
42
  function Scroll(_ref) {
39
43
  var _ref3;
@@ -45,9 +49,11 @@ function Scroll(_ref) {
45
49
  children = _ref.children,
46
50
  onScrolledBottom = _ref.onScrolledBottom,
47
51
  onScrolledNotBottom = _ref.onScrolledNotBottom,
52
+ onScrollHeightChange = _ref.onScrollHeightChange,
48
53
  contain = _ref.contain,
49
54
  scrollContainerRef = _ref.scrollContainerRef,
50
- withShadow = _ref.withShadow;
55
+ withShadow = _ref.withShadow,
56
+ showArrow = _ref.withArrow;
51
57
  var finalStyle = {
52
58
  width: width,
53
59
  height: height
@@ -92,7 +98,7 @@ function Scroll(_ref) {
92
98
  }
93
99
  scrolledNotBottomOnce.current = true;
94
100
  }
95
- if (newWithArrow !== withArrow) {
101
+ if (newWithArrow !== withArrow && showArrow) {
96
102
  setWithArrow(newWithArrow);
97
103
  }
98
104
  reachedBottom.current = nowReachedBottom;
@@ -120,8 +126,18 @@ function Scroll(_ref) {
120
126
  }
121
127
  }
122
128
  }, [scrollableHeight, scrolleeHeight, setWithArrow, disabled]);
129
+ useEffect(function () {
130
+ if (onScrollHeightChange !== null) {
131
+ var canScroll = (scrolleeHeight || 0) > (scrollableHeight || 0);
132
+ onScrollHeightChange({
133
+ scrollableHeight: scrollableHeight,
134
+ scrolleeHeight: scrolleeHeight,
135
+ canScroll: canScroll
136
+ });
137
+ }
138
+ }, [scrollableHeight, scrolleeHeight, onScrollHeightChange]);
123
139
  return /*#__PURE__*/React.createElement("div", {
124
- className: classNames([styles.container, (_ref3 = {}, _defineProperty(_ref3, styles.withScroll, !disabled), _defineProperty(_ref3, styles.containOverscroll, contain), _defineProperty(_ref3, className, className !== null), _defineProperty(_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty(_ref3, styles.withArrow, withArrow), _defineProperty(_ref3, styles.withShadow, withShadow), _ref3)]),
140
+ className: classNames([styles.container, (_ref3 = {}, _defineProperty(_ref3, styles.withScroll, !disabled), _defineProperty(_ref3, styles.containOverscroll, contain), _defineProperty(_ref3, className, className !== null), _defineProperty(_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty(_ref3, styles.withArrow, showArrow && withArrow), _defineProperty(_ref3, styles.withShadow, withShadow), _ref3)]),
125
141
  style: finalStyle
126
142
  }, /*#__PURE__*/React.createElement("div", Object.assign({
127
143
  className: styles.scrollable,
@@ -129,7 +145,7 @@ function Scroll(_ref) {
129
145
  }, bind()), /*#__PURE__*/React.createElement("div", {
130
146
  className: styles.scrollee,
131
147
  ref: scrolleeRef
132
- }, children)), !disabled ? /*#__PURE__*/React.createElement("div", {
148
+ }, children)), !disabled && showArrow ? /*#__PURE__*/React.createElement("div", {
133
149
  className: styles.arrowContainer
134
150
  }, /*#__PURE__*/React.createElement("svg", {
135
151
  xmlns: "http://www.w3.org/2000/svg",
package/lib/index.js CHANGED
@@ -27,10 +27,12 @@ var propTypes = {
27
27
  children: PropTypes__default["default"].node,
28
28
  onScrolledBottom: PropTypes__default["default"].func,
29
29
  onScrolledNotBottom: PropTypes__default["default"].func,
30
+ onScrollHeightChange: PropTypes__default["default"].func,
30
31
  contain: PropTypes__default["default"].bool,
31
32
  scrollContainerRef: PropTypes__default["default"].any,
32
33
  // eslint-disable-line
33
- withShadow: PropTypes__default["default"].bool
34
+ withShadow: PropTypes__default["default"].bool,
35
+ withArrow: PropTypes__default["default"].bool
34
36
  };
35
37
  var defaultProps = {
36
38
  width: null,
@@ -41,9 +43,11 @@ var defaultProps = {
41
43
  children: null,
42
44
  onScrolledBottom: null,
43
45
  onScrolledNotBottom: null,
46
+ onScrollHeightChange: null,
44
47
  contain: false,
45
48
  scrollContainerRef: null,
46
- withShadow: false
49
+ withShadow: false,
50
+ withArrow: true
47
51
  };
48
52
  function Scroll(_ref) {
49
53
  var _ref3;
@@ -55,9 +59,11 @@ function Scroll(_ref) {
55
59
  children = _ref.children,
56
60
  onScrolledBottom = _ref.onScrolledBottom,
57
61
  onScrolledNotBottom = _ref.onScrolledNotBottom,
62
+ onScrollHeightChange = _ref.onScrollHeightChange,
58
63
  contain = _ref.contain,
59
64
  scrollContainerRef = _ref.scrollContainerRef,
60
- withShadow = _ref.withShadow;
65
+ withShadow = _ref.withShadow,
66
+ showArrow = _ref.withArrow;
61
67
  var finalStyle = {
62
68
  width: width,
63
69
  height: height
@@ -102,7 +108,7 @@ function Scroll(_ref) {
102
108
  }
103
109
  scrolledNotBottomOnce.current = true;
104
110
  }
105
- if (newWithArrow !== withArrow) {
111
+ if (newWithArrow !== withArrow && showArrow) {
106
112
  setWithArrow(newWithArrow);
107
113
  }
108
114
  reachedBottom.current = nowReachedBottom;
@@ -130,8 +136,18 @@ function Scroll(_ref) {
130
136
  }
131
137
  }
132
138
  }, [scrollableHeight, scrolleeHeight, setWithArrow, disabled]);
139
+ React.useEffect(function () {
140
+ if (onScrollHeightChange !== null) {
141
+ var canScroll = (scrolleeHeight || 0) > (scrollableHeight || 0);
142
+ onScrollHeightChange({
143
+ scrollableHeight: scrollableHeight,
144
+ scrolleeHeight: scrolleeHeight,
145
+ canScroll: canScroll
146
+ });
147
+ }
148
+ }, [scrollableHeight, scrolleeHeight, onScrollHeightChange]);
133
149
  return /*#__PURE__*/React__default["default"].createElement("div", {
134
- className: classNames__default["default"]([styles.container, (_ref3 = {}, _defineProperty__default["default"](_ref3, styles.withScroll, !disabled), _defineProperty__default["default"](_ref3, styles.containOverscroll, contain), _defineProperty__default["default"](_ref3, className, className !== null), _defineProperty__default["default"](_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty__default["default"](_ref3, styles.withArrow, withArrow), _defineProperty__default["default"](_ref3, styles.withShadow, withShadow), _ref3)]),
150
+ className: classNames__default["default"]([styles.container, (_ref3 = {}, _defineProperty__default["default"](_ref3, styles.withScroll, !disabled), _defineProperty__default["default"](_ref3, styles.containOverscroll, contain), _defineProperty__default["default"](_ref3, className, className !== null), _defineProperty__default["default"](_ref3, styles[verticalAlign], verticalAlign !== null), _defineProperty__default["default"](_ref3, styles.withArrow, showArrow && withArrow), _defineProperty__default["default"](_ref3, styles.withShadow, withShadow), _ref3)]),
135
151
  style: finalStyle
136
152
  }, /*#__PURE__*/React__default["default"].createElement("div", Object.assign({
137
153
  className: styles.scrollable,
@@ -139,7 +155,7 @@ function Scroll(_ref) {
139
155
  }, bind()), /*#__PURE__*/React__default["default"].createElement("div", {
140
156
  className: styles.scrollee,
141
157
  ref: scrolleeRef
142
- }, children)), !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
158
+ }, children)), !disabled && showArrow ? /*#__PURE__*/React__default["default"].createElement("div", {
143
159
  className: styles.arrowContainer
144
160
  }, /*#__PURE__*/React__default["default"].createElement("svg", {
145
161
  xmlns: "http://www.w3.org/2000/svg",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-scroll",
3
- "version": "0.3.348",
3
+ "version": "0.3.354",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,7 +52,7 @@
52
52
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
53
53
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
54
54
  "@fortawesome/react-fontawesome": "^0.1.13",
55
- "@micromag/core": "^0.3.348",
55
+ "@micromag/core": "^0.3.354",
56
56
  "@use-gesture/react": "^10.2.4",
57
57
  "classnames": "^2.2.6",
58
58
  "lodash": "^4.17.21",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "20ef008fdf5c678004b740f395f51cb548591dad"
66
+ "gitHead": "ccf852d0a7df8f222365088e7de3843492e720e7"
67
67
  }