UNPKG

@carbon/ibm-products

Version:
85 lines (83 loc) 2.46 kB
/** * Copyright IBM Corp. 2020, 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. */ import { __toESM } from "../../_virtual/_rolldown/runtime.js"; import { require_classnames } from "../../node_modules/classnames/index.js"; import { pkg } from "../../settings.js"; import { getDevtoolsProps } from "../../global/js/utils/devtools.js"; import React from "react"; import PropTypes from "prop-types"; import { CheckmarkOutline, CircleDash, Incomplete, Warning } from "@carbon/react/icons"; //#region src/components/Checklist/ChecklistIcon.jsx /** * Copyright IBM Corp. 2023, 2024 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ /** * TODO: Breakdown titles, icons, clickable items into sub-components * See * ModifiedTabs (ModifiedTabLabelNew, ModifiedTabLabelWithClose) * PageHeader (PageHeaderTitle, PageHeaderUtils) */ var import_classnames = /* @__PURE__ */ __toESM(require_classnames()); const blockClass = `${pkg.prefix}--checklist__icon`; const componentName = "ChecklistIcon"; const defaults = { theme: "light" }; /** * TODO: A description of the component. */ let ChecklistIcon = React.forwardRef( /** * @param {{className?: string, kind?: import('./Checklist.types').Kind, theme?: import('./Checklist.types').Theme}} props type description */ ({ className, kind, theme = defaults.theme, ...rest }, ref) => { let Icon; switch (kind) { case "error": Icon = Warning; break; case "indeterminate": Icon = Incomplete; break; case "checked": Icon = CheckmarkOutline; break; default: Icon = CircleDash; break; } return /* @__PURE__ */ React.createElement("span", { ...rest, className: (0, import_classnames.default)(blockClass, className, `${blockClass}--${kind}`, `${blockClass}__${theme}`), ref, ...getDevtoolsProps(componentName) }, /* @__PURE__ */ React.createElement(Icon, { size: 16 })); } ); ChecklistIcon.propTypes = { /** * Provide an optional class to be applied to the containing node. */ className: PropTypes.string, /** * The icon to be displayed. */ kind: PropTypes.oneOf([ "unchecked", "indeterminate", "checked", "disabled", "error" ]), /** * Determines the theme of the component. */ theme: PropTypes.oneOf(["light", "dark"]) }; //#endregion export { ChecklistIcon };