@carbon-labs/react-ui-shell 0.56.0 → 0.57.0
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/components/HeaderContainer.d.ts +11 -1
- package/es/components/HeaderContainer.js +30 -6
- package/es/components/Profile.js +5 -4
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-0.js +272 -272
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-15.js +898 -927
- package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +615 -637
- package/es/node_modules/@carbon/icons-react/node_modules/@carbon/icon-helpers/es/index.js +3 -3
- package/lib/components/HeaderContainer.d.ts +11 -1
- package/lib/components/HeaderContainer.js +29 -5
- package/lib/components/Profile.js +5 -4
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-0.js +273 -273
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-15.js +926 -955
- package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +621 -643
- package/lib/node_modules/@carbon/icons-react/node_modules/@carbon/icon-helpers/es/index.js +3 -3
- package/package.json +2 -2
- package/scss/styles/_header.scss +5 -12
- package/scss/styles/_profile.scss +20 -15
|
@@ -9,19 +9,29 @@ import React from 'react';
|
|
|
9
9
|
export interface HeaderContainerRenderProps {
|
|
10
10
|
isSideNavExpanded: boolean;
|
|
11
11
|
isSwitcherExpanded: boolean;
|
|
12
|
+
isProfileExpanded: boolean;
|
|
12
13
|
onClickSideNavExpand: () => void;
|
|
13
14
|
onClickSwitcherExpand: () => void;
|
|
15
|
+
onClickProfileExpand: () => void;
|
|
16
|
+
themeSetting: string;
|
|
14
17
|
}
|
|
15
18
|
export type HeaderContainerProps<P extends HeaderContainerRenderProps> = {
|
|
16
19
|
isSideNavExpanded?: boolean;
|
|
17
20
|
isSwitcherExpanded?: boolean;
|
|
21
|
+
isProfileExpanded?: boolean;
|
|
18
22
|
render: React.ComponentType<P>;
|
|
23
|
+
themeSetting?: string;
|
|
19
24
|
} & {
|
|
20
25
|
[K in keyof Omit<P, keyof HeaderContainerRenderProps>]: P[K];
|
|
21
26
|
};
|
|
22
|
-
export declare function HeaderContainer<P extends HeaderContainerRenderProps>({ render: Children, isSideNavExpanded, isSwitcherExpanded,
|
|
27
|
+
export declare function HeaderContainer<P extends HeaderContainerRenderProps>({ render: Children, isSideNavExpanded, isSwitcherExpanded, isProfileExpanded, themeSetting, // <-- pass this in from the story
|
|
28
|
+
...rest }: HeaderContainerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
23
29
|
export declare namespace HeaderContainer {
|
|
24
30
|
var propTypes: {
|
|
31
|
+
/**
|
|
32
|
+
* `true` if the profile is expanded.
|
|
33
|
+
*/
|
|
34
|
+
isProfileExpanded: PropTypes.Requireable<boolean>;
|
|
25
35
|
/**
|
|
26
36
|
* `true` if the side navigation is expanded.
|
|
27
37
|
*/
|
|
@@ -7,40 +7,64 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useState, useCallback } from 'react';
|
|
10
|
+
import React, { useState, useCallback, useLayoutEffect } from 'react';
|
|
11
11
|
import { Escape } from '../internal/keyboard/keys.js';
|
|
12
12
|
import { match } from '../internal/keyboard/match.js';
|
|
13
13
|
import { useWindowEvent } from '../internal/useEvent.js';
|
|
14
|
+
import { usePrefix } from '../internal/usePrefix.js';
|
|
14
15
|
|
|
15
16
|
function HeaderContainer(_ref) {
|
|
16
17
|
let {
|
|
17
18
|
render: Children,
|
|
18
19
|
isSideNavExpanded = false,
|
|
19
20
|
isSwitcherExpanded = false,
|
|
21
|
+
isProfileExpanded = false,
|
|
22
|
+
themeSetting,
|
|
23
|
+
// <-- pass this in from the story
|
|
20
24
|
...rest
|
|
21
25
|
} = _ref;
|
|
26
|
+
const prefix = usePrefix();
|
|
22
27
|
const [isSideNavExpandedState, setIsSideNavExpandedState] = useState(isSideNavExpanded);
|
|
23
28
|
const [isSwitcherExpandedState, setSwitcherExpandedState] = useState(isSwitcherExpanded);
|
|
29
|
+
const [isProfileExpandedState, setIsProfileExpandedState] = useState(isProfileExpanded);
|
|
24
30
|
useWindowEvent('keydown', event => {
|
|
25
31
|
if (match(event, Escape)) {
|
|
26
32
|
setIsSideNavExpandedState(false);
|
|
27
33
|
setSwitcherExpandedState(false);
|
|
34
|
+
setIsProfileExpandedState(false); // close profile on ESC
|
|
28
35
|
}
|
|
29
36
|
});
|
|
30
37
|
const handleHeaderMenuButtonClick = useCallback(() => {
|
|
31
|
-
setIsSideNavExpandedState(
|
|
32
|
-
}, [
|
|
38
|
+
setIsSideNavExpandedState(prev => !prev);
|
|
39
|
+
}, []);
|
|
33
40
|
const handleSwitcherClick = useCallback(() => {
|
|
34
|
-
setSwitcherExpandedState(
|
|
35
|
-
}, [
|
|
41
|
+
setSwitcherExpandedState(prev => !prev);
|
|
42
|
+
}, []);
|
|
43
|
+
const handleProfileClick = useCallback(e => {
|
|
44
|
+
if (!e.target.closest(`.${prefix}--profile .${prefix}--popover`)) {
|
|
45
|
+
setIsProfileExpandedState(prev => !prev);
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
setTimeout(function () {
|
|
50
|
+
document.querySelector(`.${prefix}--profile .${prefix}--content-switcher--selected`).focus();
|
|
51
|
+
});
|
|
52
|
+
}, [themeSetting]);
|
|
36
53
|
return /*#__PURE__*/React.createElement(Children, _extends({}, rest, {
|
|
37
54
|
isSideNavExpanded: isSideNavExpandedState,
|
|
38
55
|
isSwitcherExpanded: isSwitcherExpandedState,
|
|
56
|
+
isProfileExpanded: isProfileExpandedState,
|
|
39
57
|
onClickSideNavExpand: handleHeaderMenuButtonClick,
|
|
40
|
-
onClickSwitcherExpand: handleSwitcherClick
|
|
58
|
+
onClickSwitcherExpand: handleSwitcherClick,
|
|
59
|
+
onClickProfileExpand: handleProfileClick,
|
|
60
|
+
themeSetting: themeSetting
|
|
41
61
|
}));
|
|
42
62
|
}
|
|
43
63
|
HeaderContainer.propTypes = {
|
|
64
|
+
/**
|
|
65
|
+
* `true` if the profile is expanded.
|
|
66
|
+
*/
|
|
67
|
+
isProfileExpanded: PropTypes.bool,
|
|
44
68
|
/**
|
|
45
69
|
* `true` if the side navigation is expanded.
|
|
46
70
|
*/
|
package/es/components/Profile.js
CHANGED
|
@@ -18,17 +18,18 @@ const Profile = /*#__PURE__*/React.forwardRef(function Profile(_ref) {
|
|
|
18
18
|
className: customClassName,
|
|
19
19
|
label,
|
|
20
20
|
children,
|
|
21
|
-
renderIcon: IconElement
|
|
21
|
+
renderIcon: IconElement,
|
|
22
|
+
...rest
|
|
22
23
|
} = _ref;
|
|
23
24
|
const prefix = usePrefix();
|
|
24
25
|
const className = cx({
|
|
25
|
-
[`${prefix}
|
|
26
|
+
[`${prefix}--profile`]: true,
|
|
26
27
|
[customClassName]: !!customClassName
|
|
27
28
|
});
|
|
28
|
-
return /*#__PURE__*/React.createElement(HeaderPopover, {
|
|
29
|
+
return /*#__PURE__*/React.createElement(HeaderPopover, _extends({
|
|
29
30
|
align: "bottom-right",
|
|
30
31
|
className: className
|
|
31
|
-
}, /*#__PURE__*/React.createElement(HeaderPopoverButton, {
|
|
32
|
+
}, rest), /*#__PURE__*/React.createElement(HeaderPopoverButton, {
|
|
32
33
|
align: "bottom",
|
|
33
34
|
label: label
|
|
34
35
|
}, IconElement), /*#__PURE__*/React.createElement(HeaderPopoverContent, null, children));
|