@carbon-labs/react-ui-shell 0.24.0 → 0.25.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 +43 -0
- package/es/components/HeaderContainer.js +62 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/node_modules/@carbon/icons-react/es/Icon.js +1 -1
- package/lib/components/HeaderContainer.d.ts +43 -0
- package/lib/components/HeaderContainer.js +67 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/node_modules/@carbon/icons-react/es/Icon.js +1 -1
- package/package.json +2 -2
- /package/es/node_modules/@carbon/{icons-react/node_modules/@carbon/icon-helpers → icon-helpers}/es/index.js +0 -0
- /package/lib/node_modules/@carbon/{icons-react/node_modules/@carbon/icon-helpers → icon-helpers}/es/index.js +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export interface HeaderContainerRenderProps {
|
|
10
|
+
isSideNavExpanded: boolean;
|
|
11
|
+
isSwitcherExpanded: boolean;
|
|
12
|
+
onClickSideNavExpand: () => void;
|
|
13
|
+
onClickSwitcherExpand: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type HeaderContainerProps<P extends HeaderContainerRenderProps> = {
|
|
16
|
+
isSideNavExpanded?: boolean;
|
|
17
|
+
isSwitcherExpanded?: boolean;
|
|
18
|
+
render: React.ComponentType<P>;
|
|
19
|
+
} & {
|
|
20
|
+
[K in keyof Omit<P, keyof HeaderContainerRenderProps>]: P[K];
|
|
21
|
+
};
|
|
22
|
+
export declare function HeaderContainer<P extends HeaderContainerRenderProps>({ render: Children, isSideNavExpanded, isSwitcherExpanded, ...rest }: HeaderContainerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare namespace HeaderContainer {
|
|
24
|
+
var propTypes: {
|
|
25
|
+
/**
|
|
26
|
+
* `true` if the side navigation is expanded.
|
|
27
|
+
*/
|
|
28
|
+
isSideNavExpanded: PropTypes.Requireable<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* `true` if the switcher is expanded.
|
|
31
|
+
*/
|
|
32
|
+
isSwitcherExpanded: PropTypes.Requireable<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
|
|
35
|
+
* The function or component can then use those properties to within the components it
|
|
36
|
+
* returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
|
|
37
|
+
* into this component for convenience.
|
|
38
|
+
*/
|
|
39
|
+
render: PropTypes.Validator<NonNullable<PropTypes.ReactComponentLike>>;
|
|
40
|
+
};
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
export default HeaderContainer;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2024
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import React, { useState, useCallback } from 'react';
|
|
11
|
+
import { Escape } from '../internal/keyboard/keys.js';
|
|
12
|
+
import { match } from '../internal/keyboard/match.js';
|
|
13
|
+
import { useWindowEvent } from '../internal/useEvent.js';
|
|
14
|
+
|
|
15
|
+
function HeaderContainer(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
render: Children,
|
|
18
|
+
isSideNavExpanded = false,
|
|
19
|
+
isSwitcherExpanded = false,
|
|
20
|
+
...rest
|
|
21
|
+
} = _ref;
|
|
22
|
+
const [isSideNavExpandedState, setIsSideNavExpandedState] = useState(isSideNavExpanded);
|
|
23
|
+
const [isSwitcherExpandedState, setSwitcherExpandedState] = useState(isSwitcherExpanded);
|
|
24
|
+
useWindowEvent('keydown', event => {
|
|
25
|
+
if (match(event, Escape)) {
|
|
26
|
+
setIsSideNavExpandedState(false);
|
|
27
|
+
setSwitcherExpandedState(false);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const handleHeaderMenuButtonClick = useCallback(() => {
|
|
31
|
+
setIsSideNavExpandedState(prevIsSideNavExpanded => !prevIsSideNavExpanded);
|
|
32
|
+
}, [setIsSideNavExpandedState]);
|
|
33
|
+
const handleSwitcherClick = useCallback(() => {
|
|
34
|
+
setSwitcherExpandedState(prevIsSwitcherExpanded => !prevIsSwitcherExpanded);
|
|
35
|
+
}, [setSwitcherExpandedState]);
|
|
36
|
+
return /*#__PURE__*/React.createElement(Children, _extends({}, rest, {
|
|
37
|
+
isSideNavExpanded: isSideNavExpandedState,
|
|
38
|
+
isSwitcherExpanded: isSwitcherExpandedState,
|
|
39
|
+
onClickSideNavExpand: handleHeaderMenuButtonClick,
|
|
40
|
+
onClickSwitcherExpand: handleSwitcherClick
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
HeaderContainer.propTypes = {
|
|
44
|
+
/**
|
|
45
|
+
* `true` if the side navigation is expanded.
|
|
46
|
+
*/
|
|
47
|
+
isSideNavExpanded: PropTypes.bool,
|
|
48
|
+
/**
|
|
49
|
+
* `true` if the switcher is expanded.
|
|
50
|
+
*/
|
|
51
|
+
isSwitcherExpanded: PropTypes.bool,
|
|
52
|
+
/**
|
|
53
|
+
* A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
|
|
54
|
+
* The function or component can then use those properties to within the components it
|
|
55
|
+
* returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
|
|
56
|
+
* into this component for convenience.
|
|
57
|
+
*/
|
|
58
|
+
render: PropTypes.elementType.isRequired
|
|
59
|
+
};
|
|
60
|
+
HeaderContainer.displayName = 'HeaderContainer';
|
|
61
|
+
|
|
62
|
+
export { HeaderContainer, HeaderContainer as default };
|
package/es/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export { SideNavLink } from './components/SideNavLink.js';
|
|
|
12
12
|
export { SideNavLinkPopover } from './components/SideNavLinkPopover.js';
|
|
13
13
|
export { SideNavMenu } from './components/SideNavMenu.js';
|
|
14
14
|
export { SideNavMenuItem } from './components/SideNavMenuItem.js';
|
|
15
|
+
export { HeaderContainer } from './components/HeaderContainer';
|
|
15
16
|
export { HeaderPanel } from './components/HeaderPanel';
|
package/es/index.js
CHANGED
|
@@ -11,4 +11,5 @@ export { SideNavLink } from './components/SideNavLink.js';
|
|
|
11
11
|
export { SideNavLinkPopover } from './components/SideNavLinkPopover.js';
|
|
12
12
|
export { SideNavMenu } from './components/SideNavMenu.js';
|
|
13
13
|
export { SideNavMenuItem } from './components/SideNavMenuItem.js';
|
|
14
|
+
export { HeaderContainer } from './components/HeaderContainer.js';
|
|
14
15
|
export { HeaderPanel } from './components/HeaderPanel.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { getAttributes } from '
|
|
8
|
+
import { getAttributes } from '../../icon-helpers/es/index.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2025
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export interface HeaderContainerRenderProps {
|
|
10
|
+
isSideNavExpanded: boolean;
|
|
11
|
+
isSwitcherExpanded: boolean;
|
|
12
|
+
onClickSideNavExpand: () => void;
|
|
13
|
+
onClickSwitcherExpand: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type HeaderContainerProps<P extends HeaderContainerRenderProps> = {
|
|
16
|
+
isSideNavExpanded?: boolean;
|
|
17
|
+
isSwitcherExpanded?: boolean;
|
|
18
|
+
render: React.ComponentType<P>;
|
|
19
|
+
} & {
|
|
20
|
+
[K in keyof Omit<P, keyof HeaderContainerRenderProps>]: P[K];
|
|
21
|
+
};
|
|
22
|
+
export declare function HeaderContainer<P extends HeaderContainerRenderProps>({ render: Children, isSideNavExpanded, isSwitcherExpanded, ...rest }: HeaderContainerProps<P>): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare namespace HeaderContainer {
|
|
24
|
+
var propTypes: {
|
|
25
|
+
/**
|
|
26
|
+
* `true` if the side navigation is expanded.
|
|
27
|
+
*/
|
|
28
|
+
isSideNavExpanded: PropTypes.Requireable<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* `true` if the switcher is expanded.
|
|
31
|
+
*/
|
|
32
|
+
isSwitcherExpanded: PropTypes.Requireable<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
|
|
35
|
+
* The function or component can then use those properties to within the components it
|
|
36
|
+
* returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
|
|
37
|
+
* into this component for convenience.
|
|
38
|
+
*/
|
|
39
|
+
render: PropTypes.Validator<NonNullable<PropTypes.ReactComponentLike>>;
|
|
40
|
+
};
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
export default HeaderContainer;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2024
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
+
var PropTypes = require('prop-types');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var keys = require('../internal/keyboard/keys.js');
|
|
16
|
+
var match = require('../internal/keyboard/match.js');
|
|
17
|
+
var useEvent = require('../internal/useEvent.js');
|
|
18
|
+
|
|
19
|
+
function HeaderContainer(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
render: Children,
|
|
22
|
+
isSideNavExpanded = false,
|
|
23
|
+
isSwitcherExpanded = false,
|
|
24
|
+
...rest
|
|
25
|
+
} = _ref;
|
|
26
|
+
const [isSideNavExpandedState, setIsSideNavExpandedState] = React.useState(isSideNavExpanded);
|
|
27
|
+
const [isSwitcherExpandedState, setSwitcherExpandedState] = React.useState(isSwitcherExpanded);
|
|
28
|
+
useEvent.useWindowEvent('keydown', event => {
|
|
29
|
+
if (match.match(event, keys.Escape)) {
|
|
30
|
+
setIsSideNavExpandedState(false);
|
|
31
|
+
setSwitcherExpandedState(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const handleHeaderMenuButtonClick = React.useCallback(() => {
|
|
35
|
+
setIsSideNavExpandedState(prevIsSideNavExpanded => !prevIsSideNavExpanded);
|
|
36
|
+
}, [setIsSideNavExpandedState]);
|
|
37
|
+
const handleSwitcherClick = React.useCallback(() => {
|
|
38
|
+
setSwitcherExpandedState(prevIsSwitcherExpanded => !prevIsSwitcherExpanded);
|
|
39
|
+
}, [setSwitcherExpandedState]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(Children, _rollupPluginBabelHelpers.extends({}, rest, {
|
|
41
|
+
isSideNavExpanded: isSideNavExpandedState,
|
|
42
|
+
isSwitcherExpanded: isSwitcherExpandedState,
|
|
43
|
+
onClickSideNavExpand: handleHeaderMenuButtonClick,
|
|
44
|
+
onClickSwitcherExpand: handleSwitcherClick
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
HeaderContainer.propTypes = {
|
|
48
|
+
/**
|
|
49
|
+
* `true` if the side navigation is expanded.
|
|
50
|
+
*/
|
|
51
|
+
isSideNavExpanded: PropTypes.bool,
|
|
52
|
+
/**
|
|
53
|
+
* `true` if the switcher is expanded.
|
|
54
|
+
*/
|
|
55
|
+
isSwitcherExpanded: PropTypes.bool,
|
|
56
|
+
/**
|
|
57
|
+
* A function or a component that is invoked with `isSideNavExpanded` and `onClickSideNavExpand`.
|
|
58
|
+
* The function or component can then use those properties to within the components it
|
|
59
|
+
* returns, such as with the HeaderMenuButton and SideNav components. Additional props will also be passed
|
|
60
|
+
* into this component for convenience.
|
|
61
|
+
*/
|
|
62
|
+
render: PropTypes.elementType.isRequired
|
|
63
|
+
};
|
|
64
|
+
HeaderContainer.displayName = 'HeaderContainer';
|
|
65
|
+
|
|
66
|
+
exports.HeaderContainer = HeaderContainer;
|
|
67
|
+
exports.default = HeaderContainer;
|
package/lib/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export { SideNavLink } from './components/SideNavLink.js';
|
|
|
12
12
|
export { SideNavLinkPopover } from './components/SideNavLinkPopover.js';
|
|
13
13
|
export { SideNavMenu } from './components/SideNavMenu.js';
|
|
14
14
|
export { SideNavMenuItem } from './components/SideNavMenuItem.js';
|
|
15
|
+
export { HeaderContainer } from './components/HeaderContainer';
|
|
15
16
|
export { HeaderPanel } from './components/HeaderPanel';
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var SideNavLink = require('./components/SideNavLink.js');
|
|
|
13
13
|
var SideNavLinkPopover = require('./components/SideNavLinkPopover.js');
|
|
14
14
|
var SideNavMenu = require('./components/SideNavMenu.js');
|
|
15
15
|
var SideNavMenuItem = require('./components/SideNavMenuItem.js');
|
|
16
|
+
var HeaderContainer = require('./components/HeaderContainer.js');
|
|
16
17
|
var HeaderPanel = require('./components/HeaderPanel.js');
|
|
17
18
|
|
|
18
19
|
|
|
@@ -24,4 +25,5 @@ exports.SideNavLink = SideNavLink.SideNavLink;
|
|
|
24
25
|
exports.SideNavLinkPopover = SideNavLinkPopover.SideNavLinkPopover;
|
|
25
26
|
exports.SideNavMenu = SideNavMenu.SideNavMenu;
|
|
26
27
|
exports.SideNavMenuItem = SideNavMenuItem.SideNavMenuItem;
|
|
28
|
+
exports.HeaderContainer = HeaderContainer.HeaderContainer;
|
|
27
29
|
exports.HeaderPanel = HeaderPanel.HeaderPanel;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
|
-
var index = require('
|
|
12
|
+
var index = require('../../icon-helpers/es/index.js');
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon-labs/react-ui-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ibm/telemetry-js": "^1.9.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "787747477de6fb9f6b8d775082cf9872b3317565"
|
|
37
37
|
}
|
|
File without changes
|
|
File without changes
|