carbon-react 147.3.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/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/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",
|
|
@@ -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",
|