carbon-react 123.1.0 → 123.2.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/components/confirm/confirm.component.d.ts +6 -1
- package/esm/components/confirm/confirm.component.js +13 -6
- package/esm/components/drawer/drawer.component.js +2 -1
- package/esm/components/navigation-bar/fixed-navigation-bar.context.d.ts +2 -2
- package/esm/components/navigation-bar/fixed-navigation-bar.context.js +8 -7
- package/esm/components/navigation-bar/navigation-bar.component.js +11 -11
- package/lib/components/confirm/confirm.component.d.ts +6 -1
- package/lib/components/confirm/confirm.component.js +13 -6
- package/lib/components/drawer/drawer.component.js +2 -1
- package/lib/components/navigation-bar/fixed-navigation-bar.context.d.ts +2 -2
- package/lib/components/navigation-bar/fixed-navigation-bar.context.js +7 -6
- package/lib/components/navigation-bar/navigation-bar.component.js +10 -10
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DialogProps } from "../dialog";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFocusTrap" | "bespokeFocusTrap" | "focusableSelectors" | "help" | "role" | "contentPadding" | "focusableContainers" | "ariaRole" | "timeout" | "enableBackgroundUI" | "disableClose"> {
|
|
5
6
|
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground" */
|
|
6
7
|
cancelButtonType?: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
@@ -22,6 +23,10 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
22
23
|
confirmButtonIconPosition?: "before" | "after";
|
|
23
24
|
/** Defines an Icon type within the confirm button (see Icon for options) */
|
|
24
25
|
confirmButtonIconType?: IconType;
|
|
26
|
+
/** Data tag prop bag for cancelButton */
|
|
27
|
+
cancelButtonDataProps?: TagProps;
|
|
28
|
+
/** Data tag prop bag for confirmButton */
|
|
29
|
+
confirmButtonDataProps?: TagProps;
|
|
25
30
|
/** Makes cancel button disabled */
|
|
26
31
|
disableCancel?: boolean;
|
|
27
32
|
/** Makes confirm button disabled */
|
|
@@ -33,5 +38,5 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
33
38
|
/** A custom event handler when a confirmation takes place */
|
|
34
39
|
onConfirm: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
35
40
|
}
|
|
36
|
-
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
41
|
+
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelButtonDataProps, confirmButtonDataProps, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
37
42
|
export default Confirm;
|
|
@@ -9,6 +9,7 @@ import Button from "../button/button.component";
|
|
|
9
9
|
import Icon from "../icon";
|
|
10
10
|
import Loader from "../loader";
|
|
11
11
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
12
|
+
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
12
13
|
export const Confirm = ({
|
|
13
14
|
"aria-labelledby": ariaLabelledBy,
|
|
14
15
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -23,6 +24,8 @@ export const Confirm = ({
|
|
|
23
24
|
cancelButtonIconPosition,
|
|
24
25
|
confirmButtonIconType,
|
|
25
26
|
confirmButtonIconPosition,
|
|
27
|
+
cancelButtonDataProps,
|
|
28
|
+
confirmButtonDataProps,
|
|
26
29
|
cancelLabel,
|
|
27
30
|
onCancel,
|
|
28
31
|
disableCancel,
|
|
@@ -57,26 +60,30 @@ export const Confirm = ({
|
|
|
57
60
|
}
|
|
58
61
|
const renderCancelButton = () => {
|
|
59
62
|
if (!onCancel) return null;
|
|
60
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
63
|
+
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
61
64
|
onClick: onCancel,
|
|
62
|
-
"data-element": "cancel",
|
|
63
65
|
buttonType: cancelButtonType,
|
|
64
66
|
destructive: cancelButtonDestructive,
|
|
65
67
|
disabled: disableCancel,
|
|
66
68
|
iconType: cancelButtonIconType,
|
|
67
69
|
iconPosition: cancelButtonIconPosition
|
|
68
|
-
},
|
|
70
|
+
}, tagComponent("cancel", {
|
|
71
|
+
"data-element": "cancel",
|
|
72
|
+
...cancelButtonDataProps
|
|
73
|
+
})), cancelLabel || l.confirm.no());
|
|
69
74
|
};
|
|
70
|
-
const renderConfirmButton = () => /*#__PURE__*/React.createElement(Button, {
|
|
75
|
+
const renderConfirmButton = () => /*#__PURE__*/React.createElement(Button, _extends({
|
|
71
76
|
onClick: onConfirm,
|
|
72
|
-
"data-element": "confirm",
|
|
73
77
|
buttonType: confirmButtonType,
|
|
74
78
|
destructive: confirmButtonDestructive,
|
|
75
79
|
disabled: isLoadingConfirm || disableConfirm,
|
|
76
80
|
ml: 2,
|
|
77
81
|
iconType: confirmButtonIconType,
|
|
78
82
|
iconPosition: confirmButtonIconPosition
|
|
79
|
-
},
|
|
83
|
+
}, tagComponent("confirm", {
|
|
84
|
+
"data-element": "confirm",
|
|
85
|
+
...confirmButtonDataProps
|
|
86
|
+
})), isLoadingConfirm ? /*#__PURE__*/React.createElement(Loader, {
|
|
80
87
|
isInsideButton: true,
|
|
81
88
|
isActive: true
|
|
82
89
|
}) : confirmLabel || l.confirm.yes());
|
|
@@ -122,7 +122,8 @@ export const Drawer = ({
|
|
|
122
122
|
animationDuration: animationDuration,
|
|
123
123
|
className: getClassNames(),
|
|
124
124
|
ref: drawerSidebarContentRef,
|
|
125
|
-
backgroundColor: backgroundColor
|
|
125
|
+
backgroundColor: backgroundColor,
|
|
126
|
+
"data-element": "drawer-content"
|
|
126
127
|
}, stickyHeader && /*#__PURE__*/React.createElement(StyledSidebarHeader, {
|
|
127
128
|
isExpanded: isExpanded
|
|
128
129
|
}, title && /*#__PURE__*/React.createElement(StyledSidebarTitle, null, title), getControls()), !stickyHeader && /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement(StyledSidebarTitle, null, title), getControls()), /*#__PURE__*/React.createElement(StyledDrawerSidebar, {
|
|
@@ -5,7 +5,7 @@ declare type FixedNavigationBarContextProps = {
|
|
|
5
5
|
};
|
|
6
6
|
declare const FixedNavigationBarContext: React.Context<FixedNavigationBarContextProps>;
|
|
7
7
|
export interface FixedNavigationBarContextProviderProps extends Pick<NavigationBarProps, "position" | "orientation" | "offset" | "children"> {
|
|
8
|
-
|
|
8
|
+
navbarRef: React.RefObject<HTMLElement>;
|
|
9
9
|
}
|
|
10
|
-
export declare const FixedNavigationBarContextProvider: ({ position, orientation, offset, children,
|
|
10
|
+
export declare const FixedNavigationBarContextProvider: ({ position, orientation, offset, children, navbarRef, }: FixedNavigationBarContextProviderProps) => React.JSX.Element;
|
|
11
11
|
export default FixedNavigationBarContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useState, useCallback } from "react";
|
|
1
|
+
import React, { createContext, useState, useCallback, useEffect } from "react";
|
|
2
2
|
import useResizeObserver from "../../hooks/__internal__/useResizeObserver/useResizeObserver";
|
|
3
3
|
const FixedNavigationBarContext = /*#__PURE__*/createContext({});
|
|
4
4
|
export const FixedNavigationBarContextProvider = ({
|
|
@@ -6,13 +6,14 @@ export const FixedNavigationBarContextProvider = ({
|
|
|
6
6
|
orientation,
|
|
7
7
|
offset,
|
|
8
8
|
children,
|
|
9
|
-
|
|
9
|
+
navbarRef
|
|
10
10
|
}) => {
|
|
11
|
-
const [navbarHeight, setNavbarHeight] = useState(
|
|
12
|
-
const updateHeight = useCallback(() => setNavbarHeight(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, updateHeight);
|
|
11
|
+
const [navbarHeight, setNavbarHeight] = useState(navbarRef.current?.offsetHeight);
|
|
12
|
+
const updateHeight = useCallback(() => setNavbarHeight(navbarRef.current?.offsetHeight), [navbarRef]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
updateHeight();
|
|
15
|
+
}, [updateHeight]);
|
|
16
|
+
useResizeObserver(navbarRef, updateHeight);
|
|
16
17
|
let submenuMaxHeight;
|
|
17
18
|
if (position === "fixed") {
|
|
18
19
|
if (orientation === "top" && navbarHeight !== undefined) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import StyledNavigationBar from "./navigation-bar.style";
|
|
5
5
|
import { FixedNavigationBarContextProvider } from "./fixed-navigation-bar.context";
|
|
@@ -9,13 +9,18 @@ const NavigationBar = ({
|
|
|
9
9
|
children,
|
|
10
10
|
ariaLabel,
|
|
11
11
|
position,
|
|
12
|
-
offset = "
|
|
12
|
+
offset = "0px",
|
|
13
13
|
orientation,
|
|
14
14
|
isGlobal,
|
|
15
15
|
...props
|
|
16
16
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
17
|
+
const navbarRef = useRef(null);
|
|
18
|
+
return /*#__PURE__*/React.createElement(FixedNavigationBarContextProvider, {
|
|
19
|
+
orientation: isGlobal ? "top" : orientation,
|
|
20
|
+
offset: isGlobal ? "0px" : offset,
|
|
21
|
+
position: isGlobal ? "fixed" : position,
|
|
22
|
+
navbarRef: navbarRef
|
|
23
|
+
}, /*#__PURE__*/React.createElement(StyledNavigationBar, _extends({
|
|
19
24
|
role: "navigation",
|
|
20
25
|
"data-component": isGlobal ? "global-header" : "navigation-bar",
|
|
21
26
|
"aria-label": isGlobal ? "Global Header" : ariaLabel,
|
|
@@ -25,13 +30,8 @@ const NavigationBar = ({
|
|
|
25
30
|
position: isGlobal ? "fixed" : position
|
|
26
31
|
}, props, {
|
|
27
32
|
isGlobal: isGlobal,
|
|
28
|
-
ref:
|
|
29
|
-
}),
|
|
30
|
-
orientation: isGlobal ? "top" : orientation,
|
|
31
|
-
offset: isGlobal ? "0px" : offset,
|
|
32
|
-
position: isGlobal ? "fixed" : position,
|
|
33
|
-
navbarElement: navbarElement
|
|
34
|
-
}, !isLoading && children));
|
|
33
|
+
ref: navbarRef
|
|
34
|
+
}), !isLoading && children));
|
|
35
35
|
};
|
|
36
36
|
NavigationBar.propTypes = {
|
|
37
37
|
"alignContent": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "baseline", "center", "end", "flex-end", "flex-start", "inherit", "initial", "normal", "revert", "space-around", "space-between", "space-evenly", "start", "stretch", "unset"]), PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "baseline", "center", "end", "flex-end", "flex-start", "inherit", "initial", "normal", "revert", "space-around", "space-between", "space-evenly", "start", "stretch", "unset", null]), PropTypes.shape({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { DialogProps } from "../dialog";
|
|
3
3
|
import { IconType } from "../icon";
|
|
4
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
5
|
export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFocusTrap" | "bespokeFocusTrap" | "focusableSelectors" | "help" | "role" | "contentPadding" | "focusableContainers" | "ariaRole" | "timeout" | "enableBackgroundUI" | "disableClose"> {
|
|
5
6
|
/** Color variants for new business themes: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground" */
|
|
6
7
|
cancelButtonType?: "primary" | "secondary" | "tertiary" | "dashed" | "darkBackground";
|
|
@@ -22,6 +23,10 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
22
23
|
confirmButtonIconPosition?: "before" | "after";
|
|
23
24
|
/** Defines an Icon type within the confirm button (see Icon for options) */
|
|
24
25
|
confirmButtonIconType?: IconType;
|
|
26
|
+
/** Data tag prop bag for cancelButton */
|
|
27
|
+
cancelButtonDataProps?: TagProps;
|
|
28
|
+
/** Data tag prop bag for confirmButton */
|
|
29
|
+
confirmButtonDataProps?: TagProps;
|
|
25
30
|
/** Makes cancel button disabled */
|
|
26
31
|
disableCancel?: boolean;
|
|
27
32
|
/** Makes confirm button disabled */
|
|
@@ -33,5 +38,5 @@ export interface ConfirmProps extends Omit<DialogProps, "className" | "disableFo
|
|
|
33
38
|
/** A custom event handler when a confirmation takes place */
|
|
34
39
|
onConfirm: (ev: React.MouseEvent<HTMLButtonElement>) => void;
|
|
35
40
|
}
|
|
36
|
-
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
41
|
+
export declare const Confirm: ({ "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, open, children, cancelButtonDestructive, confirmButtonDestructive, cancelButtonType, confirmButtonType, cancelButtonIconType, cancelButtonIconPosition, confirmButtonIconType, confirmButtonIconPosition, cancelButtonDataProps, confirmButtonDataProps, cancelLabel, onCancel, disableCancel, onConfirm, isLoadingConfirm, disableConfirm, confirmLabel, iconType, subtitle, title, size, showCloseIcon, ...rest }: ConfirmProps) => React.JSX.Element;
|
|
37
42
|
export default Confirm;
|
|
@@ -14,6 +14,7 @@ var _button = _interopRequireDefault(require("../button/button.component"));
|
|
|
14
14
|
var _icon = _interopRequireDefault(require("../icon"));
|
|
15
15
|
var _loader = _interopRequireDefault(require("../loader"));
|
|
16
16
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
17
|
+
var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
|
|
17
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -32,6 +33,8 @@ const Confirm = ({
|
|
|
32
33
|
cancelButtonIconPosition,
|
|
33
34
|
confirmButtonIconType,
|
|
34
35
|
confirmButtonIconPosition,
|
|
36
|
+
cancelButtonDataProps,
|
|
37
|
+
confirmButtonDataProps,
|
|
35
38
|
cancelLabel,
|
|
36
39
|
onCancel,
|
|
37
40
|
disableCancel,
|
|
@@ -66,26 +69,30 @@ const Confirm = ({
|
|
|
66
69
|
}
|
|
67
70
|
const renderCancelButton = () => {
|
|
68
71
|
if (!onCancel) return null;
|
|
69
|
-
return /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
70
73
|
onClick: onCancel,
|
|
71
|
-
"data-element": "cancel",
|
|
72
74
|
buttonType: cancelButtonType,
|
|
73
75
|
destructive: cancelButtonDestructive,
|
|
74
76
|
disabled: disableCancel,
|
|
75
77
|
iconType: cancelButtonIconType,
|
|
76
78
|
iconPosition: cancelButtonIconPosition
|
|
77
|
-
},
|
|
79
|
+
}, (0, _tags.default)("cancel", {
|
|
80
|
+
"data-element": "cancel",
|
|
81
|
+
...cancelButtonDataProps
|
|
82
|
+
})), cancelLabel || l.confirm.no());
|
|
78
83
|
};
|
|
79
|
-
const renderConfirmButton = () => /*#__PURE__*/_react.default.createElement(_button.default, {
|
|
84
|
+
const renderConfirmButton = () => /*#__PURE__*/_react.default.createElement(_button.default, _extends({
|
|
80
85
|
onClick: onConfirm,
|
|
81
|
-
"data-element": "confirm",
|
|
82
86
|
buttonType: confirmButtonType,
|
|
83
87
|
destructive: confirmButtonDestructive,
|
|
84
88
|
disabled: isLoadingConfirm || disableConfirm,
|
|
85
89
|
ml: 2,
|
|
86
90
|
iconType: confirmButtonIconType,
|
|
87
91
|
iconPosition: confirmButtonIconPosition
|
|
88
|
-
},
|
|
92
|
+
}, (0, _tags.default)("confirm", {
|
|
93
|
+
"data-element": "confirm",
|
|
94
|
+
...confirmButtonDataProps
|
|
95
|
+
})), isLoadingConfirm ? /*#__PURE__*/_react.default.createElement(_loader.default, {
|
|
89
96
|
isInsideButton: true,
|
|
90
97
|
isActive: true
|
|
91
98
|
}) : confirmLabel || l.confirm.yes());
|
|
@@ -132,7 +132,8 @@ const Drawer = ({
|
|
|
132
132
|
animationDuration: animationDuration,
|
|
133
133
|
className: getClassNames(),
|
|
134
134
|
ref: drawerSidebarContentRef,
|
|
135
|
-
backgroundColor: backgroundColor
|
|
135
|
+
backgroundColor: backgroundColor,
|
|
136
|
+
"data-element": "drawer-content"
|
|
136
137
|
}, stickyHeader && /*#__PURE__*/_react.default.createElement(_drawer.StyledSidebarHeader, {
|
|
137
138
|
isExpanded: isExpanded
|
|
138
139
|
}, title && /*#__PURE__*/_react.default.createElement(_drawer.StyledSidebarTitle, null, title), getControls()), !stickyHeader && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, title && /*#__PURE__*/_react.default.createElement(_drawer.StyledSidebarTitle, null, title), getControls()), /*#__PURE__*/_react.default.createElement(_drawer.StyledDrawerSidebar, {
|
|
@@ -5,7 +5,7 @@ declare type FixedNavigationBarContextProps = {
|
|
|
5
5
|
};
|
|
6
6
|
declare const FixedNavigationBarContext: React.Context<FixedNavigationBarContextProps>;
|
|
7
7
|
export interface FixedNavigationBarContextProviderProps extends Pick<NavigationBarProps, "position" | "orientation" | "offset" | "children"> {
|
|
8
|
-
|
|
8
|
+
navbarRef: React.RefObject<HTMLElement>;
|
|
9
9
|
}
|
|
10
|
-
export declare const FixedNavigationBarContextProvider: ({ position, orientation, offset, children,
|
|
10
|
+
export declare const FixedNavigationBarContextProvider: ({ position, orientation, offset, children, navbarRef, }: FixedNavigationBarContextProviderProps) => React.JSX.Element;
|
|
11
11
|
export default FixedNavigationBarContext;
|
|
@@ -15,13 +15,14 @@ const FixedNavigationBarContextProvider = ({
|
|
|
15
15
|
orientation,
|
|
16
16
|
offset,
|
|
17
17
|
children,
|
|
18
|
-
|
|
18
|
+
navbarRef
|
|
19
19
|
}) => {
|
|
20
|
-
const [navbarHeight, setNavbarHeight] = (0, _react.useState)(
|
|
21
|
-
const updateHeight = (0, _react.useCallback)(() => setNavbarHeight(
|
|
22
|
-
(0,
|
|
23
|
-
|
|
24
|
-
}, updateHeight);
|
|
20
|
+
const [navbarHeight, setNavbarHeight] = (0, _react.useState)(navbarRef.current?.offsetHeight);
|
|
21
|
+
const updateHeight = (0, _react.useCallback)(() => setNavbarHeight(navbarRef.current?.offsetHeight), [navbarRef]);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
updateHeight();
|
|
24
|
+
}, [updateHeight]);
|
|
25
|
+
(0, _useResizeObserver.default)(navbarRef, updateHeight);
|
|
25
26
|
let submenuMaxHeight;
|
|
26
27
|
if (position === "fixed") {
|
|
27
28
|
if (orientation === "top" && navbarHeight !== undefined) {
|
|
@@ -18,13 +18,18 @@ const NavigationBar = ({
|
|
|
18
18
|
children,
|
|
19
19
|
ariaLabel,
|
|
20
20
|
position,
|
|
21
|
-
offset = "
|
|
21
|
+
offset = "0px",
|
|
22
22
|
orientation,
|
|
23
23
|
isGlobal,
|
|
24
24
|
...props
|
|
25
25
|
}) => {
|
|
26
|
-
const
|
|
27
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
26
|
+
const navbarRef = (0, _react.useRef)(null);
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_fixedNavigationBar.FixedNavigationBarContextProvider, {
|
|
28
|
+
orientation: isGlobal ? "top" : orientation,
|
|
29
|
+
offset: isGlobal ? "0px" : offset,
|
|
30
|
+
position: isGlobal ? "fixed" : position,
|
|
31
|
+
navbarRef: navbarRef
|
|
32
|
+
}, /*#__PURE__*/_react.default.createElement(_navigationBar.default, _extends({
|
|
28
33
|
role: "navigation",
|
|
29
34
|
"data-component": isGlobal ? "global-header" : "navigation-bar",
|
|
30
35
|
"aria-label": isGlobal ? "Global Header" : ariaLabel,
|
|
@@ -34,13 +39,8 @@ const NavigationBar = ({
|
|
|
34
39
|
position: isGlobal ? "fixed" : position
|
|
35
40
|
}, props, {
|
|
36
41
|
isGlobal: isGlobal,
|
|
37
|
-
ref:
|
|
38
|
-
}),
|
|
39
|
-
orientation: isGlobal ? "top" : orientation,
|
|
40
|
-
offset: isGlobal ? "0px" : offset,
|
|
41
|
-
position: isGlobal ? "fixed" : position,
|
|
42
|
-
navbarElement: navbarElement
|
|
43
|
-
}, !isLoading && children));
|
|
42
|
+
ref: navbarRef
|
|
43
|
+
}), !isLoading && children));
|
|
44
44
|
};
|
|
45
45
|
exports.NavigationBar = NavigationBar;
|
|
46
46
|
NavigationBar.propTypes = {
|