UNPKG

@carbon/react

Version:

React components for the Carbon Design System

63 lines (61 loc) 2.11 kB
/** * 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. */ import { usePrefix } from "../../internal/usePrefix.js"; import Loading_default from "../Loading/index.js"; import "react"; import PropTypes from "prop-types"; import { Fragment, jsx, jsxs } from "react/jsx-runtime"; import { CheckmarkFilled, Close, WarningFilled } from "@carbon/icons-react"; //#region src/components/FileUploader/Filename.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. */ function Filename({ iconDescription = "Uploading file", status = "uploading", invalid, name, tabIndex = 0, ["aria-describedby"]: ariaDescribedBy, ...rest }) { const prefix = usePrefix(); switch (status) { case "uploading": return /* @__PURE__ */ jsx(Loading_default, { description: iconDescription, small: true, withOverlay: false, className: `${prefix}--file-loading` }); case "edit": return /* @__PURE__ */ jsxs(Fragment, { children: [invalid && /* @__PURE__ */ jsx(WarningFilled, { className: `${prefix}--file-invalid` }), /* @__PURE__ */ jsx("button", { "aria-label": `${iconDescription} - ${name}`, className: `${prefix}--file-close`, type: "button", tabIndex, ...rest, "aria-describedby": invalid ? ariaDescribedBy : void 0, children: /* @__PURE__ */ jsx(Close, {}) })] }); case "complete": return /* @__PURE__ */ jsx(CheckmarkFilled, { "aria-label": iconDescription, className: `${prefix}--file-complete`, ...rest, tabIndex: -1, children: iconDescription && /* @__PURE__ */ jsx("title", { children: iconDescription }) }); default: return null; } } Filename.propTypes = { ["aria-describedby"]: PropTypes.string, iconDescription: PropTypes.string, invalid: PropTypes.bool, name: PropTypes.string, status: PropTypes.oneOf([ "edit", "complete", "uploading" ]), tabIndex: PropTypes.number }; //#endregion export { Filename as default };