@carbon-labs/react-ui-shell 0.57.0 → 0.58.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/README.md +0 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -2
- package/package.json +2 -2
- package/es/components/HeaderPanel.d.ts +0 -35
- package/es/components/HeaderPanel.js +0 -104
- package/lib/components/HeaderPanel.d.ts +0 -35
- package/lib/components/HeaderPanel.js +0 -106
package/README.md
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { SideNavMenu } from './components/SideNavMenu';
|
|
|
14
14
|
export { SideNavMenuItem } from './components/SideNavMenuItem';
|
|
15
15
|
export { HeaderContainer } from './components/HeaderContainer';
|
|
16
16
|
export { HeaderPopover, HeaderPopoverActions, HeaderPopoverButton, HeaderPopoverContent, } from './components/HeaderPopover';
|
|
17
|
-
export { HeaderPanel } from './components/HeaderPanel';
|
|
18
17
|
export { SharkFinIcon } from './components/SharkFinIcon';
|
|
19
18
|
export { HeaderDivider } from './components/HeaderDivider';
|
|
20
19
|
export { TrialCountdown } from './components/TrialCountdown';
|
package/es/index.js
CHANGED
|
@@ -13,7 +13,6 @@ export { SideNavMenu } from './components/SideNavMenu.js';
|
|
|
13
13
|
export { SideNavMenuItem } from './components/SideNavMenuItem.js';
|
|
14
14
|
export { HeaderContainer } from './components/HeaderContainer.js';
|
|
15
15
|
export { HeaderPopover, HeaderPopoverActions, HeaderPopoverButton, HeaderPopoverContent } from './components/HeaderPopover.js';
|
|
16
|
-
export { HeaderPanel } from './components/HeaderPanel.js';
|
|
17
16
|
export { SharkFinIcon } from './components/SharkFinIcon.js';
|
|
18
17
|
export { HeaderDivider } from './components/HeaderDivider.js';
|
|
19
18
|
export { TrialCountdown } from './components/TrialCountdown.js';
|
package/lib/index.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { SideNavMenu } from './components/SideNavMenu';
|
|
|
14
14
|
export { SideNavMenuItem } from './components/SideNavMenuItem';
|
|
15
15
|
export { HeaderContainer } from './components/HeaderContainer';
|
|
16
16
|
export { HeaderPopover, HeaderPopoverActions, HeaderPopoverButton, HeaderPopoverContent, } from './components/HeaderPopover';
|
|
17
|
-
export { HeaderPanel } from './components/HeaderPanel';
|
|
18
17
|
export { SharkFinIcon } from './components/SharkFinIcon';
|
|
19
18
|
export { HeaderDivider } from './components/HeaderDivider';
|
|
20
19
|
export { TrialCountdown } from './components/TrialCountdown';
|
package/lib/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var SideNavMenu = require('./components/SideNavMenu.js');
|
|
|
15
15
|
var SideNavMenuItem = require('./components/SideNavMenuItem.js');
|
|
16
16
|
var HeaderContainer = require('./components/HeaderContainer.js');
|
|
17
17
|
var HeaderPopover = require('./components/HeaderPopover.js');
|
|
18
|
-
var HeaderPanel = require('./components/HeaderPanel.js');
|
|
19
18
|
var SharkFinIcon = require('./components/SharkFinIcon.js');
|
|
20
19
|
var HeaderDivider = require('./components/HeaderDivider.js');
|
|
21
20
|
var TrialCountdown = require('./components/TrialCountdown.js');
|
|
@@ -36,7 +35,6 @@ exports.HeaderPopover = HeaderPopover.HeaderPopover;
|
|
|
36
35
|
exports.HeaderPopoverActions = HeaderPopover.HeaderPopoverActions;
|
|
37
36
|
exports.HeaderPopoverButton = HeaderPopover.HeaderPopoverButton;
|
|
38
37
|
exports.HeaderPopoverContent = HeaderPopover.HeaderPopoverContent;
|
|
39
|
-
exports.HeaderPanel = HeaderPanel.HeaderPanel;
|
|
40
38
|
exports.SharkFinIcon = SharkFinIcon.SharkFinIcon;
|
|
41
39
|
exports.HeaderDivider = HeaderDivider.HeaderDivider;
|
|
42
40
|
exports.TrialCountdown = TrialCountdown.TrialCountdown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon-labs/react-ui-shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ibm/telemetry-js": "^1.9.1"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "d0cbc0ae2d4ee86c3a28429fb07a0896e91506bf"
|
|
46
46
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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 React, { ReactNode } from 'react';
|
|
8
|
-
export interface HeaderPanelProps {
|
|
9
|
-
/**
|
|
10
|
-
* Specify whether focus and blur listeners are added. They are by default.
|
|
11
|
-
*/
|
|
12
|
-
addFocusListeners?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The content that will render inside of the `HeaderPanel`
|
|
15
|
-
*/
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
19
|
-
*/
|
|
20
|
-
className?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Specify whether the panel is expanded
|
|
23
|
-
*/
|
|
24
|
-
expanded?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Provide the `href` to the id of the element on your package that could
|
|
27
|
-
* be target.
|
|
28
|
-
*/
|
|
29
|
-
href?: string;
|
|
30
|
-
/**
|
|
31
|
-
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
32
|
-
*/
|
|
33
|
-
onHeaderPanelFocus?: () => void;
|
|
34
|
-
}
|
|
35
|
-
export declare const HeaderPanel: React.FC<HeaderPanelProps>;
|
|
@@ -1,104 +0,0 @@
|
|
|
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 cx from '../_virtual/index.js';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
11
|
-
import React, { useRef, useState } from 'react';
|
|
12
|
-
import { usePrefix } from '../internal/usePrefix.js';
|
|
13
|
-
import { Escape } from '../internal/keyboard/keys.js';
|
|
14
|
-
import { match } from '../internal/keyboard/match.js';
|
|
15
|
-
import { useWindowEvent } from '../internal/useEvent.js';
|
|
16
|
-
import { useMergedRefs } from '../internal/useMergedRefs.js';
|
|
17
|
-
|
|
18
|
-
const noopFn = () => {};
|
|
19
|
-
const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel(_ref, ref) {
|
|
20
|
-
let {
|
|
21
|
-
children,
|
|
22
|
-
className: customClassName,
|
|
23
|
-
expanded,
|
|
24
|
-
addFocusListeners = true,
|
|
25
|
-
onHeaderPanelFocus = noopFn,
|
|
26
|
-
href,
|
|
27
|
-
...rest
|
|
28
|
-
} = _ref;
|
|
29
|
-
const prefix = usePrefix();
|
|
30
|
-
const headerPanelReference = useRef(null);
|
|
31
|
-
const headerPanelRef = useMergedRefs([headerPanelReference, ref]);
|
|
32
|
-
const controlled = useRef(expanded !== undefined).current;
|
|
33
|
-
const [expandedState, setExpandedState] = useState(expanded);
|
|
34
|
-
const expandedProp = controlled ? expanded : expandedState;
|
|
35
|
-
const [lastClickedElement, setLastClickedElement] = useState(null);
|
|
36
|
-
const className = cx(`${prefix}--header-panel`, {
|
|
37
|
-
[`${prefix}--header-panel--expanded`]: expandedProp,
|
|
38
|
-
[customClassName]: !!customClassName
|
|
39
|
-
});
|
|
40
|
-
const eventHandlers = {};
|
|
41
|
-
if (addFocusListeners) {
|
|
42
|
-
eventHandlers.onBlur = event => {
|
|
43
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement?.classList?.contains(`${prefix}--switcher__item-link`)) {
|
|
44
|
-
setExpandedState(false);
|
|
45
|
-
setLastClickedElement(null);
|
|
46
|
-
if (expanded) {
|
|
47
|
-
onHeaderPanelFocus();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
eventHandlers.onKeyDown = event => {
|
|
52
|
-
if (match(event, Escape)) {
|
|
53
|
-
setExpandedState(false);
|
|
54
|
-
onHeaderPanelFocus();
|
|
55
|
-
if (href) {
|
|
56
|
-
window.location.href = href;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
useWindowEvent('click', () => {
|
|
62
|
-
const focusedElement = document.activeElement;
|
|
63
|
-
setLastClickedElement(focusedElement);
|
|
64
|
-
const childJsxElement = children;
|
|
65
|
-
if (childJsxElement?.type?.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
66
|
-
setExpandedState(false);
|
|
67
|
-
onHeaderPanelFocus();
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
|
71
|
-
className: className,
|
|
72
|
-
ref: headerPanelRef
|
|
73
|
-
}, eventHandlers), children);
|
|
74
|
-
});
|
|
75
|
-
HeaderPanel.propTypes = {
|
|
76
|
-
/**
|
|
77
|
-
* Specify whether focus and blur listeners are added. They are by default.
|
|
78
|
-
*/
|
|
79
|
-
addFocusListeners: PropTypes.bool,
|
|
80
|
-
/**
|
|
81
|
-
* The content that will render inside of the `HeaderPanel`
|
|
82
|
-
*/
|
|
83
|
-
children: PropTypes.any,
|
|
84
|
-
/**
|
|
85
|
-
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
86
|
-
*/
|
|
87
|
-
className: PropTypes.string,
|
|
88
|
-
/**
|
|
89
|
-
* Specify whether the panel is expanded
|
|
90
|
-
*/
|
|
91
|
-
expanded: PropTypes.bool,
|
|
92
|
-
/**
|
|
93
|
-
* Provide the `href` to the id of the element on your package that could
|
|
94
|
-
* be target.
|
|
95
|
-
*/
|
|
96
|
-
href: PropTypes.string,
|
|
97
|
-
/**
|
|
98
|
-
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
99
|
-
*/
|
|
100
|
-
onHeaderPanelFocus: PropTypes.func
|
|
101
|
-
};
|
|
102
|
-
HeaderPanel.displayName = 'HeaderPanel';
|
|
103
|
-
|
|
104
|
-
export { HeaderPanel };
|
|
@@ -1,35 +0,0 @@
|
|
|
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 React, { ReactNode } from 'react';
|
|
8
|
-
export interface HeaderPanelProps {
|
|
9
|
-
/**
|
|
10
|
-
* Specify whether focus and blur listeners are added. They are by default.
|
|
11
|
-
*/
|
|
12
|
-
addFocusListeners?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The content that will render inside of the `HeaderPanel`
|
|
15
|
-
*/
|
|
16
|
-
children?: ReactNode;
|
|
17
|
-
/**
|
|
18
|
-
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
19
|
-
*/
|
|
20
|
-
className?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Specify whether the panel is expanded
|
|
23
|
-
*/
|
|
24
|
-
expanded?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Provide the `href` to the id of the element on your package that could
|
|
27
|
-
* be target.
|
|
28
|
-
*/
|
|
29
|
-
href?: string;
|
|
30
|
-
/**
|
|
31
|
-
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
32
|
-
*/
|
|
33
|
-
onHeaderPanelFocus?: () => void;
|
|
34
|
-
}
|
|
35
|
-
export declare const HeaderPanel: React.FC<HeaderPanelProps>;
|
|
@@ -1,106 +0,0 @@
|
|
|
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
|
-
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
11
|
-
var index = require('../_virtual/index.js');
|
|
12
|
-
var PropTypes = require('prop-types');
|
|
13
|
-
var React = require('react');
|
|
14
|
-
var usePrefix = require('../internal/usePrefix.js');
|
|
15
|
-
var keys = require('../internal/keyboard/keys.js');
|
|
16
|
-
var match = require('../internal/keyboard/match.js');
|
|
17
|
-
var useEvent = require('../internal/useEvent.js');
|
|
18
|
-
var useMergedRefs = require('../internal/useMergedRefs.js');
|
|
19
|
-
|
|
20
|
-
const noopFn = () => {};
|
|
21
|
-
const HeaderPanel = /*#__PURE__*/React.forwardRef(function HeaderPanel(_ref, ref) {
|
|
22
|
-
let {
|
|
23
|
-
children,
|
|
24
|
-
className: customClassName,
|
|
25
|
-
expanded,
|
|
26
|
-
addFocusListeners = true,
|
|
27
|
-
onHeaderPanelFocus = noopFn,
|
|
28
|
-
href,
|
|
29
|
-
...rest
|
|
30
|
-
} = _ref;
|
|
31
|
-
const prefix = usePrefix.usePrefix();
|
|
32
|
-
const headerPanelReference = React.useRef(null);
|
|
33
|
-
const headerPanelRef = useMergedRefs.useMergedRefs([headerPanelReference, ref]);
|
|
34
|
-
const controlled = React.useRef(expanded !== undefined).current;
|
|
35
|
-
const [expandedState, setExpandedState] = React.useState(expanded);
|
|
36
|
-
const expandedProp = controlled ? expanded : expandedState;
|
|
37
|
-
const [lastClickedElement, setLastClickedElement] = React.useState(null);
|
|
38
|
-
const className = index.default(`${prefix}--header-panel`, {
|
|
39
|
-
[`${prefix}--header-panel--expanded`]: expandedProp,
|
|
40
|
-
[customClassName]: !!customClassName
|
|
41
|
-
});
|
|
42
|
-
const eventHandlers = {};
|
|
43
|
-
if (addFocusListeners) {
|
|
44
|
-
eventHandlers.onBlur = event => {
|
|
45
|
-
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement?.classList?.contains(`${prefix}--switcher__item-link`)) {
|
|
46
|
-
setExpandedState(false);
|
|
47
|
-
setLastClickedElement(null);
|
|
48
|
-
if (expanded) {
|
|
49
|
-
onHeaderPanelFocus();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
eventHandlers.onKeyDown = event => {
|
|
54
|
-
if (match.match(event, keys.Escape)) {
|
|
55
|
-
setExpandedState(false);
|
|
56
|
-
onHeaderPanelFocus();
|
|
57
|
-
if (href) {
|
|
58
|
-
window.location.href = href;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
useEvent.useWindowEvent('click', () => {
|
|
64
|
-
const focusedElement = document.activeElement;
|
|
65
|
-
setLastClickedElement(focusedElement);
|
|
66
|
-
const childJsxElement = children;
|
|
67
|
-
if (childJsxElement?.type?.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelReference?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
68
|
-
setExpandedState(false);
|
|
69
|
-
onHeaderPanelFocus();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
73
|
-
className: className,
|
|
74
|
-
ref: headerPanelRef
|
|
75
|
-
}, eventHandlers), children);
|
|
76
|
-
});
|
|
77
|
-
HeaderPanel.propTypes = {
|
|
78
|
-
/**
|
|
79
|
-
* Specify whether focus and blur listeners are added. They are by default.
|
|
80
|
-
*/
|
|
81
|
-
addFocusListeners: PropTypes.bool,
|
|
82
|
-
/**
|
|
83
|
-
* The content that will render inside of the `HeaderPanel`
|
|
84
|
-
*/
|
|
85
|
-
children: PropTypes.any,
|
|
86
|
-
/**
|
|
87
|
-
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
88
|
-
*/
|
|
89
|
-
className: PropTypes.string,
|
|
90
|
-
/**
|
|
91
|
-
* Specify whether the panel is expanded
|
|
92
|
-
*/
|
|
93
|
-
expanded: PropTypes.bool,
|
|
94
|
-
/**
|
|
95
|
-
* Provide the `href` to the id of the element on your package that could
|
|
96
|
-
* be target.
|
|
97
|
-
*/
|
|
98
|
-
href: PropTypes.string,
|
|
99
|
-
/**
|
|
100
|
-
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
101
|
-
*/
|
|
102
|
-
onHeaderPanelFocus: PropTypes.func
|
|
103
|
-
};
|
|
104
|
-
HeaderPanel.displayName = 'HeaderPanel';
|
|
105
|
-
|
|
106
|
-
exports.HeaderPanel = HeaderPanel;
|