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.
- package/esm/__internal__/sticky-footer/index.d.ts +1 -0
- package/esm/__internal__/sticky-footer/sticky-footer.component.d.ts +10 -14
- package/esm/__internal__/sticky-footer/sticky-footer.component.js +27 -13
- package/esm/__internal__/sticky-footer/sticky-footer.style.d.ts +3 -1
- package/esm/components/date/date.d.ts +3 -1
- package/esm/components/drawer/drawer.component.js +1 -2
- package/lib/__internal__/sticky-footer/index.d.ts +1 -0
- package/lib/__internal__/sticky-footer/sticky-footer.component.d.ts +10 -14
- package/lib/__internal__/sticky-footer/sticky-footer.component.js +27 -13
- package/lib/__internal__/sticky-footer/sticky-footer.style.d.ts +3 -1
- package/lib/components/date/date.d.ts +3 -1
- package/lib/components/drawer/drawer.component.js +1 -2
- package/package.json +1 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
children:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|
|
@@ -45,6 +45,8 @@ export interface DateInputProps
|
|
|
45
45
|
pickerProps?: DayPickerProps;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
declare function DateInput(
|
|
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,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
children:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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;
|
|
@@ -45,6 +45,8 @@ export interface DateInputProps
|
|
|
45
45
|
pickerProps?: DayPickerProps;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
declare function DateInput(
|
|
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
|
|