@carbon/react
Version:
React components for the Carbon Design System
59 lines (57 loc) • 2.15 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_usePrefix = require("../../internal/usePrefix.js");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let react_jsx_runtime = require("react/jsx-runtime");
let _carbon_icons_react = require("@carbon/icons-react");
//#region src/components/ListBox/ListBoxMenuIcon.tsx
/**
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const translationIds = {
"close.menu": "close.menu",
"open.menu": "open.menu"
};
const defaultTranslations = {
[translationIds["close.menu"]]: "Close menu",
[translationIds["open.menu"]]: "Open menu"
};
const defaultTranslateWithId = (messageId) => {
return defaultTranslations[messageId];
};
/**
* `ListBoxMenuIcon` is used to orient the icon up or down depending on the
* state of the menu for a given `ListBox`
*/
const ListBoxMenuIcon = ({ isOpen, translateWithId: t = defaultTranslateWithId }) => {
const prefix = require_usePrefix.usePrefix();
const className = (0, classnames.default)(`${prefix}--list-box__menu-icon`, { [`${prefix}--list-box__menu-icon--open`]: isOpen });
const description = isOpen ? t("close.menu") : t("open.menu");
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.ChevronDown, {
name: "chevron--down",
"aria-label": description,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("title", { children: description })
})
});
};
ListBoxMenuIcon.propTypes = {
isOpen: prop_types.default.bool.isRequired,
translateWithId: prop_types.default.func
};
//#endregion
exports.default = ListBoxMenuIcon;