carbon-react 147.2.0 → 147.3.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/action-popover/__internal__/action-popover-utils.d.ts +1 -0
- package/esm/components/action-popover/__internal__/action-popover-utils.js +8 -0
- package/esm/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +1 -1
- package/esm/components/action-popover/action-popover.component.d.ts +1 -1
- package/esm/components/action-popover/action-popover.component.js +15 -2
- package/esm/components/heading/heading.style.d.ts +1 -1
- package/esm/components/hr/hr.component.d.ts +3 -1
- package/esm/components/hr/hr.component.js +3 -0
- package/esm/components/hr/hr.style.d.ts +3 -1
- package/esm/components/hr/hr.style.js +8 -1
- package/lib/components/action-popover/__internal__/action-popover-utils.d.ts +1 -0
- package/lib/components/action-popover/__internal__/action-popover-utils.js +11 -2
- package/lib/components/action-popover/action-popover-menu-button/action-popover-menu-button.component.d.ts +1 -1
- package/lib/components/action-popover/action-popover.component.d.ts +1 -1
- package/lib/components/action-popover/action-popover.component.js +14 -1
- package/lib/components/heading/heading.style.d.ts +1 -1
- package/lib/components/hr/hr.component.d.ts +3 -1
- package/lib/components/hr/hr.component.js +3 -0
- package/lib/components/hr/hr.style.d.ts +3 -1
- package/lib/components/hr/hr.style.js +8 -1
- package/package.json +1 -1
|
@@ -4,4 +4,5 @@ export declare const getItems: (children: React.ReactNode | React.ReactNode[]) =
|
|
|
4
4
|
export declare const isItemDisabled: (item: ReactItem) => boolean;
|
|
5
5
|
export declare const findFirstFocusableItem: (items: ReactItem[]) => number;
|
|
6
6
|
export declare const findLastFocusableItem: (items: ReactItem[]) => number;
|
|
7
|
+
export declare const checkChildrenForString: (children: React.ReactNode) => boolean;
|
|
7
8
|
export {};
|
|
@@ -17,4 +17,12 @@ export const findLastFocusableItem = items => {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
return -1;
|
|
20
|
+
};
|
|
21
|
+
export const checkChildrenForString = children => {
|
|
22
|
+
return React.Children.toArray(children).some(child => {
|
|
23
|
+
if (typeof child === "string") {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/React.isValidElement(child) ? checkChildrenForString(child.props.children) : false;
|
|
27
|
+
});
|
|
20
28
|
};
|
|
@@ -3,7 +3,7 @@ import { ButtonIconPosition, ButtonTypes, SizeOptions } from "../../button/butto
|
|
|
3
3
|
import { IconType } from "../../icon";
|
|
4
4
|
export declare type ActionPopoverMenuButtonAria = {
|
|
5
5
|
"aria-haspopup": string;
|
|
6
|
-
"aria-label"
|
|
6
|
+
"aria-label"?: string;
|
|
7
7
|
"aria-labelledby"?: string;
|
|
8
8
|
"aria-describedby"?: string;
|
|
9
9
|
"aria-controls": string;
|
|
@@ -12,7 +12,7 @@ import ActionPopoverItem from "./action-popover-item/action-popover-item.compone
|
|
|
12
12
|
import ActionPopoverDivider from "./action-popover-divider/action-popover-divider.component";
|
|
13
13
|
import ActionPopoverContext from "./__internal__/action-popover.context";
|
|
14
14
|
import useModalManager from "../../hooks/__internal__/useModalManager";
|
|
15
|
-
import { findFirstFocusableItem, findLastFocusableItem, getItems } from "./__internal__/action-popover-utils";
|
|
15
|
+
import { findFirstFocusableItem, findLastFocusableItem, getItems, checkChildrenForString } from "./__internal__/action-popover-utils";
|
|
16
16
|
const onOpenDefault = () => {};
|
|
17
17
|
const onCloseDefault = () => {};
|
|
18
18
|
const ActionPopover = /*#__PURE__*/forwardRef(({
|
|
@@ -139,7 +139,7 @@ const ActionPopover = /*#__PURE__*/forwardRef(({
|
|
|
139
139
|
}, [setOpen]);
|
|
140
140
|
const menuButton = menuID => {
|
|
141
141
|
if (renderButton) {
|
|
142
|
-
|
|
142
|
+
const renderButtonComponent = renderButton({
|
|
143
143
|
tabIndex: isOpen ? -1 : 0,
|
|
144
144
|
"data-element": "action-popover-button",
|
|
145
145
|
ariaAttributes: {
|
|
@@ -151,6 +151,19 @@ const ActionPopover = /*#__PURE__*/forwardRef(({
|
|
|
151
151
|
"aria-expanded": `${isOpen}`
|
|
152
152
|
}
|
|
153
153
|
});
|
|
154
|
+
const buttonHasString = checkChildrenForString(renderButtonComponent);
|
|
155
|
+
return renderButton({
|
|
156
|
+
tabIndex: isOpen ? -1 : 0,
|
|
157
|
+
"data-element": "action-popover-button",
|
|
158
|
+
ariaAttributes: {
|
|
159
|
+
"aria-haspopup": "true",
|
|
160
|
+
"aria-label": buttonHasString ? undefined : ariaLabel || l.actionPopover.ariaLabel(),
|
|
161
|
+
"aria-labelledby": ariaLabelledBy,
|
|
162
|
+
"aria-describedby": ariaDescribedBy,
|
|
163
|
+
"aria-controls": menuID,
|
|
164
|
+
"aria-expanded": `${isOpen}`
|
|
165
|
+
}
|
|
166
|
+
});
|
|
154
167
|
}
|
|
155
168
|
return /*#__PURE__*/React.createElement(StyledButtonIcon, {
|
|
156
169
|
role: "button",
|
|
@@ -23,7 +23,7 @@ declare type StyledSubHeaderProps = {
|
|
|
23
23
|
declare const StyledSubHeader: import("styled-components").StyledComponent<"div", any, StyledSubHeaderProps, never>;
|
|
24
24
|
declare const StyledHeadingIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
25
25
|
declare const StyledSeparator: import("styled-components").StyledComponent<"hr", any, {}, never>;
|
|
26
|
-
declare const StyledDivider: import("styled-components").StyledComponent<({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, ...rest }: import("../hr").HrProps) => JSX.Element, any, {}, never>;
|
|
26
|
+
declare const StyledDivider: import("styled-components").StyledComponent<({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, height, ...rest }: import("../hr").HrProps) => JSX.Element, any, {}, never>;
|
|
27
27
|
declare const StyledHeaderHelp: import("styled-components").StyledComponent<{
|
|
28
28
|
({ as, ariaLabel, children, href, helpId, isFocused, tabIndex, tooltipBgColor, tooltipFontColor, tooltipFlipOverrides, tooltipId, tooltipPosition, type, ...rest }: import("../help").HelpProps): JSX.Element;
|
|
29
29
|
displayName: string;
|
|
@@ -6,6 +6,8 @@ export interface HrProps extends MarginProps {
|
|
|
6
6
|
/** Breakpoint for adaptive left and right margins (below the breakpoint they go to 0).
|
|
7
7
|
* Enables the adaptive behaviour when set */
|
|
8
8
|
adaptiveMxBreakpoint?: number;
|
|
9
|
+
/** Set the height of the component. Accepts one of "small", "medium", or "large" */
|
|
10
|
+
height?: "small" | "medium" | "large";
|
|
9
11
|
}
|
|
10
|
-
export declare const Hr: ({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, ...rest }: HrProps) => JSX.Element;
|
|
12
|
+
export declare const Hr: ({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, height, ...rest }: HrProps) => JSX.Element;
|
|
11
13
|
export default Hr;
|
|
@@ -8,6 +8,7 @@ const Hr = ({
|
|
|
8
8
|
ml,
|
|
9
9
|
mr,
|
|
10
10
|
"aria-hidden": ariaHidden,
|
|
11
|
+
height = "small",
|
|
11
12
|
...rest
|
|
12
13
|
}) => {
|
|
13
14
|
const largeScreen = useIsAboveBreakpoint(adaptiveMxBreakpoint);
|
|
@@ -21,6 +22,7 @@ const Hr = ({
|
|
|
21
22
|
"aria-hidden": ariaHidden,
|
|
22
23
|
"data-component": "hr",
|
|
23
24
|
"data-role": "hr",
|
|
25
|
+
height: height,
|
|
24
26
|
ml: marginLeft,
|
|
25
27
|
mr: marginRight,
|
|
26
28
|
mt: rest.mt || 3,
|
|
@@ -31,6 +33,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
31
33
|
Hr.propTypes = {
|
|
32
34
|
"adaptiveMxBreakpoint": PropTypes.number,
|
|
33
35
|
"aria-hidden": PropTypes.oneOf(["false", "true"]),
|
|
36
|
+
"height": PropTypes.oneOf(["large", "medium", "small"]),
|
|
34
37
|
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
35
38
|
"__@toStringTag": PropTypes.string.isRequired,
|
|
36
39
|
"description": PropTypes.string,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { MarginProps } from "styled-system";
|
|
2
|
-
declare const StyledHr: import("styled-components").StyledComponent<"hr", any, MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem
|
|
2
|
+
declare const StyledHr: import("styled-components").StyledComponent<"hr", any, MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
3
|
+
height: "small" | "medium" | "large";
|
|
4
|
+
}, never>;
|
|
3
5
|
export default StyledHr;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import { margin } from "styled-system";
|
|
3
3
|
import baseTheme from "../../style/themes/base";
|
|
4
|
+
const heightMap = {
|
|
5
|
+
small: 1,
|
|
6
|
+
medium: 2,
|
|
7
|
+
large: 3
|
|
8
|
+
};
|
|
4
9
|
const StyledHr = styled.hr`
|
|
5
10
|
${margin}
|
|
6
11
|
width: inherit;
|
|
7
12
|
border: 0;
|
|
8
|
-
height:
|
|
13
|
+
height: ${({
|
|
14
|
+
height
|
|
15
|
+
}) => heightMap[height]}px;
|
|
9
16
|
background: var(--colorsUtilityMajor100);
|
|
10
17
|
`;
|
|
11
18
|
StyledHr.defaultProps = {
|
|
@@ -4,4 +4,5 @@ export declare const getItems: (children: React.ReactNode | React.ReactNode[]) =
|
|
|
4
4
|
export declare const isItemDisabled: (item: ReactItem) => boolean;
|
|
5
5
|
export declare const findFirstFocusableItem: (items: ReactItem[]) => number;
|
|
6
6
|
export declare const findLastFocusableItem: (items: ReactItem[]) => number;
|
|
7
|
+
export declare const checkChildrenForString: (children: React.ReactNode) => boolean;
|
|
7
8
|
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isItemDisabled = exports.getItems = exports.findLastFocusableItem = exports.findFirstFocusableItem = void 0;
|
|
6
|
+
exports.isItemDisabled = exports.getItems = exports.findLastFocusableItem = exports.findFirstFocusableItem = exports.checkChildrenForString = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _actionPopoverItem = require("../action-popover-item/action-popover-item.component");
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -27,4 +27,13 @@ const findLastFocusableItem = items => {
|
|
|
27
27
|
}
|
|
28
28
|
return -1;
|
|
29
29
|
};
|
|
30
|
-
exports.findLastFocusableItem = findLastFocusableItem;
|
|
30
|
+
exports.findLastFocusableItem = findLastFocusableItem;
|
|
31
|
+
const checkChildrenForString = children => {
|
|
32
|
+
return _react.default.Children.toArray(children).some(child => {
|
|
33
|
+
if (typeof child === "string") {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return /*#__PURE__*/_react.default.isValidElement(child) ? checkChildrenForString(child.props.children) : false;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.checkChildrenForString = checkChildrenForString;
|
|
@@ -3,7 +3,7 @@ import { ButtonIconPosition, ButtonTypes, SizeOptions } from "../../button/butto
|
|
|
3
3
|
import { IconType } from "../../icon";
|
|
4
4
|
export declare type ActionPopoverMenuButtonAria = {
|
|
5
5
|
"aria-haspopup": string;
|
|
6
|
-
"aria-label"
|
|
6
|
+
"aria-label"?: string;
|
|
7
7
|
"aria-labelledby"?: string;
|
|
8
8
|
"aria-describedby"?: string;
|
|
9
9
|
"aria-controls": string;
|
|
@@ -148,7 +148,7 @@ const ActionPopover = exports.ActionPopover = /*#__PURE__*/(0, _react.forwardRef
|
|
|
148
148
|
}, [setOpen]);
|
|
149
149
|
const menuButton = menuID => {
|
|
150
150
|
if (renderButton) {
|
|
151
|
-
|
|
151
|
+
const renderButtonComponent = renderButton({
|
|
152
152
|
tabIndex: isOpen ? -1 : 0,
|
|
153
153
|
"data-element": "action-popover-button",
|
|
154
154
|
ariaAttributes: {
|
|
@@ -160,6 +160,19 @@ const ActionPopover = exports.ActionPopover = /*#__PURE__*/(0, _react.forwardRef
|
|
|
160
160
|
"aria-expanded": `${isOpen}`
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
|
+
const buttonHasString = (0, _actionPopoverUtils.checkChildrenForString)(renderButtonComponent);
|
|
164
|
+
return renderButton({
|
|
165
|
+
tabIndex: isOpen ? -1 : 0,
|
|
166
|
+
"data-element": "action-popover-button",
|
|
167
|
+
ariaAttributes: {
|
|
168
|
+
"aria-haspopup": "true",
|
|
169
|
+
"aria-label": buttonHasString ? undefined : ariaLabel || l.actionPopover.ariaLabel(),
|
|
170
|
+
"aria-labelledby": ariaLabelledBy,
|
|
171
|
+
"aria-describedby": ariaDescribedBy,
|
|
172
|
+
"aria-controls": menuID,
|
|
173
|
+
"aria-expanded": `${isOpen}`
|
|
174
|
+
}
|
|
175
|
+
});
|
|
163
176
|
}
|
|
164
177
|
return /*#__PURE__*/_react.default.createElement(_actionPopover.StyledButtonIcon, {
|
|
165
178
|
role: "button",
|
|
@@ -23,7 +23,7 @@ declare type StyledSubHeaderProps = {
|
|
|
23
23
|
declare const StyledSubHeader: import("styled-components").StyledComponent<"div", any, StyledSubHeaderProps, never>;
|
|
24
24
|
declare const StyledHeadingIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
25
25
|
declare const StyledSeparator: import("styled-components").StyledComponent<"hr", any, {}, never>;
|
|
26
|
-
declare const StyledDivider: import("styled-components").StyledComponent<({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, ...rest }: import("../hr").HrProps) => JSX.Element, any, {}, never>;
|
|
26
|
+
declare const StyledDivider: import("styled-components").StyledComponent<({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, height, ...rest }: import("../hr").HrProps) => JSX.Element, any, {}, never>;
|
|
27
27
|
declare const StyledHeaderHelp: import("styled-components").StyledComponent<{
|
|
28
28
|
({ as, ariaLabel, children, href, helpId, isFocused, tabIndex, tooltipBgColor, tooltipFontColor, tooltipFlipOverrides, tooltipId, tooltipPosition, type, ...rest }: import("../help").HelpProps): JSX.Element;
|
|
29
29
|
displayName: string;
|
|
@@ -6,6 +6,8 @@ export interface HrProps extends MarginProps {
|
|
|
6
6
|
/** Breakpoint for adaptive left and right margins (below the breakpoint they go to 0).
|
|
7
7
|
* Enables the adaptive behaviour when set */
|
|
8
8
|
adaptiveMxBreakpoint?: number;
|
|
9
|
+
/** Set the height of the component. Accepts one of "small", "medium", or "large" */
|
|
10
|
+
height?: "small" | "medium" | "large";
|
|
9
11
|
}
|
|
10
|
-
export declare const Hr: ({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, ...rest }: HrProps) => JSX.Element;
|
|
12
|
+
export declare const Hr: ({ adaptiveMxBreakpoint, ml, mr, "aria-hidden": ariaHidden, height, ...rest }: HrProps) => JSX.Element;
|
|
11
13
|
export default Hr;
|
|
@@ -15,6 +15,7 @@ const Hr = ({
|
|
|
15
15
|
ml,
|
|
16
16
|
mr,
|
|
17
17
|
"aria-hidden": ariaHidden,
|
|
18
|
+
height = "small",
|
|
18
19
|
...rest
|
|
19
20
|
}) => {
|
|
20
21
|
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveMxBreakpoint);
|
|
@@ -28,6 +29,7 @@ const Hr = ({
|
|
|
28
29
|
"aria-hidden": ariaHidden,
|
|
29
30
|
"data-component": "hr",
|
|
30
31
|
"data-role": "hr",
|
|
32
|
+
height: height,
|
|
31
33
|
ml: marginLeft,
|
|
32
34
|
mr: marginRight,
|
|
33
35
|
mt: rest.mt || 3,
|
|
@@ -39,6 +41,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
39
41
|
Hr.propTypes = {
|
|
40
42
|
"adaptiveMxBreakpoint": _propTypes.default.number,
|
|
41
43
|
"aria-hidden": _propTypes.default.oneOf(["false", "true"]),
|
|
44
|
+
"height": _propTypes.default.oneOf(["large", "medium", "small"]),
|
|
42
45
|
"m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
|
|
43
46
|
"__@toStringTag": _propTypes.default.string.isRequired,
|
|
44
47
|
"description": _propTypes.default.string,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { MarginProps } from "styled-system";
|
|
2
|
-
declare const StyledHr: import("styled-components").StyledComponent<"hr", any, MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem
|
|
2
|
+
declare const StyledHr: import("styled-components").StyledComponent<"hr", any, MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
3
|
+
height: "small" | "medium" | "large";
|
|
4
|
+
}, never>;
|
|
3
5
|
export default StyledHr;
|
|
@@ -8,11 +8,18 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
8
8
|
var _styledSystem = require("styled-system");
|
|
9
9
|
var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const heightMap = {
|
|
12
|
+
small: 1,
|
|
13
|
+
medium: 2,
|
|
14
|
+
large: 3
|
|
15
|
+
};
|
|
11
16
|
const StyledHr = _styledComponents.default.hr`
|
|
12
17
|
${_styledSystem.margin}
|
|
13
18
|
width: inherit;
|
|
14
19
|
border: 0;
|
|
15
|
-
height:
|
|
20
|
+
height: ${({
|
|
21
|
+
height
|
|
22
|
+
}) => heightMap[height]}px;
|
|
16
23
|
background: var(--colorsUtilityMajor100);
|
|
17
24
|
`;
|
|
18
25
|
StyledHr.defaultProps = {
|