carbon-react 117.1.0 → 117.1.1

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.
@@ -1 +1,2 @@
1
1
  export { default } from "./sticky-footer.component";
2
+ export type { StickyFooterProps } from "./sticky-footer.component";
@@ -1,15 +1,11 @@
1
- export default StickyFooter;
2
- declare function StickyFooter({ children, containerRef, disableSticky, ...rest }: {
3
- [x: string]: any;
4
- children: any;
5
- containerRef: any;
6
- disableSticky: any;
7
- }): JSX.Element;
8
- declare namespace StickyFooter {
9
- namespace propTypes {
10
- const children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
11
- const containerRef: PropTypes.Validator<any>;
12
- const disableSticky: PropTypes.Requireable<boolean>;
13
- }
1
+ import React from "react";
2
+ export interface StickyFooterProps {
3
+ /** child elements */
4
+ children: React.ReactNode;
5
+ /** Ref of the container the footer should be sticky on */
6
+ containerRef: React.RefObject<HTMLElement>;
7
+ /** Disable the sticky behaviour manually */
8
+ disableSticky?: boolean;
14
9
  }
15
- import PropTypes from "prop-types";
10
+ declare const StickyFooter: ({ children, containerRef, disableSticky, ...rest }: StickyFooterProps) => JSX.Element;
11
+ export default StickyFooter;
@@ -13,18 +13,29 @@ const StickyFooter = ({
13
13
  ...rest
14
14
  }) => {
15
15
  const [isSticky, setIsSticky] = useState(true);
16
- const footerRef = useRef();
16
+ const footerRef = useRef(null);
17
17
  const checkFooterPosition = useCallback(throttle(() => {
18
18
  const content = containerRef.current;
19
- const stickyOffset = footerRef.current.clientHeight / 2;
20
- const fullyScrolled = content.scrollHeight - content.scrollTop - stickyOffset <= content.clientHeight;
19
+ /* Fallback to 0 to satisfy the TypeScript compiler */
20
+
21
+ /* footerRef will never be null in this method */
22
+
23
+ /* istanbul ignore next */
24
+
25
+ const stickyOffset = footerRef.current ? footerRef.current.clientHeight / 2 : 0;
26
+ let fullyScrolled; // istanbul ignore else
27
+
28
+ if (content) {
29
+ fullyScrolled = content.scrollHeight - content.scrollTop - stickyOffset <= content.clientHeight;
30
+ }
31
+
21
32
  setIsSticky(!fullyScrolled);
22
33
  }, SCROLL_THROTTLE), []);
23
34
  useEffect(() => {
24
35
  const content = containerRef.current;
25
- content.addEventListener("scroll", checkFooterPosition, false);
36
+ content === null || content === void 0 ? void 0 : content.addEventListener("scroll", checkFooterPosition, false);
26
37
  return () => {
27
- content.removeEventListener("scroll", checkFooterPosition, false);
38
+ content === null || content === void 0 ? void 0 : content.removeEventListener("scroll", checkFooterPosition, false);
28
39
  };
29
40
  }, [checkFooterPosition, containerRef]);
30
41
  return /*#__PURE__*/React.createElement(StyledStickyFooter, _extends({
@@ -35,13 +46,16 @@ const StickyFooter = ({
35
46
  };
36
47
 
37
48
  StickyFooter.propTypes = {
38
- /** child elements */
39
- children: PropTypes.node.isRequired,
40
-
41
- /** Ref of the container the footer should be sticky on */
42
- containerRef: PropTypes.any.isRequired,
43
-
44
- /** Disable the sticky behaviour manually */
45
- disableSticky: PropTypes.bool
49
+ "children": PropTypes.node,
50
+ "containerRef": PropTypes.shape({
51
+ "current": PropTypes.oneOfType([PropTypes.oneOf([null]), function (props, propName) {
52
+ if (props[propName] == null) {
53
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
54
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
55
+ return new Error("Expected prop '" + propName + "' to be of type Element");
56
+ }
57
+ }]).isRequired
58
+ }).isRequired,
59
+ "disableSticky": PropTypes.bool
46
60
  };
47
61
  export default StickyFooter;
@@ -1,2 +1,4 @@
1
+ declare const StyledStickyFooter: import("styled-components").StyledComponent<"div", any, {
2
+ sticky: boolean;
3
+ }, never>;
1
4
  export default StyledStickyFooter;
2
- declare const StyledStickyFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -45,6 +45,8 @@ export interface DateInputProps
45
45
  pickerProps?: DayPickerProps;
46
46
  }
47
47
 
48
- declare function DateInput(props: DateInputProps): JSX.Element;
48
+ declare function DateInput(
49
+ props: SimpleSelectProps & React.RefAttributes<HTMLInputElement>
50
+ ): JSX.Element;
49
51
 
50
52
  export default DateInput;
@@ -154,8 +154,7 @@ const Drawer = ({
154
154
  }
155
155
  }, sidebar), footer && /*#__PURE__*/React.createElement(StickyFooter, {
156
156
  containerRef: scrollableContentRef,
157
- disableSticky: !stickyFooter,
158
- isExpanded: isExpanded
157
+ disableSticky: !stickyFooter
159
158
  }, footer))), /*#__PURE__*/React.createElement(StyledDrawerChildren, null, children));
160
159
  };
161
160
 
@@ -1 +1,2 @@
1
1
  export { default } from "./sticky-footer.component";
2
+ export type { StickyFooterProps } from "./sticky-footer.component";
@@ -1,15 +1,11 @@
1
- export default StickyFooter;
2
- declare function StickyFooter({ children, containerRef, disableSticky, ...rest }: {
3
- [x: string]: any;
4
- children: any;
5
- containerRef: any;
6
- disableSticky: any;
7
- }): JSX.Element;
8
- declare namespace StickyFooter {
9
- namespace propTypes {
10
- const children: PropTypes.Validator<string | number | boolean | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
11
- const containerRef: PropTypes.Validator<any>;
12
- const disableSticky: PropTypes.Requireable<boolean>;
13
- }
1
+ import React from "react";
2
+ export interface StickyFooterProps {
3
+ /** child elements */
4
+ children: React.ReactNode;
5
+ /** Ref of the container the footer should be sticky on */
6
+ containerRef: React.RefObject<HTMLElement>;
7
+ /** Disable the sticky behaviour manually */
8
+ disableSticky?: boolean;
14
9
  }
15
- import PropTypes from "prop-types";
10
+ declare const StickyFooter: ({ children, containerRef, disableSticky, ...rest }: StickyFooterProps) => JSX.Element;
11
+ export default StickyFooter;
@@ -30,18 +30,29 @@ const StickyFooter = ({
30
30
  ...rest
31
31
  }) => {
32
32
  const [isSticky, setIsSticky] = (0, _react.useState)(true);
33
- const footerRef = (0, _react.useRef)();
33
+ const footerRef = (0, _react.useRef)(null);
34
34
  const checkFooterPosition = (0, _react.useCallback)((0, _throttle.default)(() => {
35
35
  const content = containerRef.current;
36
- const stickyOffset = footerRef.current.clientHeight / 2;
37
- const fullyScrolled = content.scrollHeight - content.scrollTop - stickyOffset <= content.clientHeight;
36
+ /* Fallback to 0 to satisfy the TypeScript compiler */
37
+
38
+ /* footerRef will never be null in this method */
39
+
40
+ /* istanbul ignore next */
41
+
42
+ const stickyOffset = footerRef.current ? footerRef.current.clientHeight / 2 : 0;
43
+ let fullyScrolled; // istanbul ignore else
44
+
45
+ if (content) {
46
+ fullyScrolled = content.scrollHeight - content.scrollTop - stickyOffset <= content.clientHeight;
47
+ }
48
+
38
49
  setIsSticky(!fullyScrolled);
39
50
  }, SCROLL_THROTTLE), []);
40
51
  (0, _react.useEffect)(() => {
41
52
  const content = containerRef.current;
42
- content.addEventListener("scroll", checkFooterPosition, false);
53
+ content === null || content === void 0 ? void 0 : content.addEventListener("scroll", checkFooterPosition, false);
43
54
  return () => {
44
- content.removeEventListener("scroll", checkFooterPosition, false);
55
+ content === null || content === void 0 ? void 0 : content.removeEventListener("scroll", checkFooterPosition, false);
45
56
  };
46
57
  }, [checkFooterPosition, containerRef]);
47
58
  return /*#__PURE__*/_react.default.createElement(_stickyFooter.default, _extends({
@@ -52,14 +63,17 @@ const StickyFooter = ({
52
63
  };
53
64
 
54
65
  StickyFooter.propTypes = {
55
- /** child elements */
56
- children: _propTypes.default.node.isRequired,
57
-
58
- /** Ref of the container the footer should be sticky on */
59
- containerRef: _propTypes.default.any.isRequired,
60
-
61
- /** Disable the sticky behaviour manually */
62
- disableSticky: _propTypes.default.bool
66
+ "children": _propTypes.default.node,
67
+ "containerRef": _propTypes.default.shape({
68
+ "current": _propTypes.default.oneOfType([_propTypes.default.oneOf([null]), function (props, propName) {
69
+ if (props[propName] == null) {
70
+ return new Error("Prop '" + propName + "' is required but wasn't specified");
71
+ } else if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
72
+ return new Error("Expected prop '" + propName + "' to be of type Element");
73
+ }
74
+ }]).isRequired
75
+ }).isRequired,
76
+ "disableSticky": _propTypes.default.bool
63
77
  };
64
78
  var _default = StickyFooter;
65
79
  exports.default = _default;
@@ -1,2 +1,4 @@
1
+ declare const StyledStickyFooter: import("styled-components").StyledComponent<"div", any, {
2
+ sticky: boolean;
3
+ }, never>;
1
4
  export default StyledStickyFooter;
2
- declare const StyledStickyFooter: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -45,6 +45,8 @@ export interface DateInputProps
45
45
  pickerProps?: DayPickerProps;
46
46
  }
47
47
 
48
- declare function DateInput(props: DateInputProps): JSX.Element;
48
+ declare function DateInput(
49
+ props: SimpleSelectProps & React.RefAttributes<HTMLInputElement>
50
+ ): JSX.Element;
49
51
 
50
52
  export default DateInput;
@@ -177,8 +177,7 @@ const Drawer = ({
177
177
  }
178
178
  }, sidebar), footer && /*#__PURE__*/_react.default.createElement(_stickyFooter.default, {
179
179
  containerRef: scrollableContentRef,
180
- disableSticky: !stickyFooter,
181
- isExpanded: isExpanded
180
+ disableSticky: !stickyFooter
182
181
  }, footer))), /*#__PURE__*/_react.default.createElement(_drawer.StyledDrawerChildren, null, children));
183
182
  };
184
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "117.1.0",
3
+ "version": "117.1.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",