UNPKG

@carbon/react

Version:

React components for the Carbon Design System

66 lines (64 loc) 2.6 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. */ const require_runtime = require("../../_virtual/_rolldown/runtime.js"); const require_usePrefix = require("../../internal/usePrefix.js"); const require_index = require("../Loading/index.js"); 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/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 = require_usePrefix.usePrefix(); switch (status) { case "uploading": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, { description: iconDescription, small: true, withOverlay: false, className: `${prefix}--file-loading` }); case "edit": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [invalid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.WarningFilled, { className: `${prefix}--file-invalid` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", { "aria-label": `${iconDescription} - ${name}`, className: `${prefix}--file-close`, type: "button", tabIndex, ...rest, "aria-describedby": invalid ? ariaDescribedBy : void 0, children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.Close, {}) })] }); case "complete": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.CheckmarkFilled, { "aria-label": iconDescription, className: `${prefix}--file-complete`, ...rest, tabIndex: -1, children: iconDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("title", { children: iconDescription }) }); default: return null; } } Filename.propTypes = { ["aria-describedby"]: prop_types.default.string, iconDescription: prop_types.default.string, invalid: prop_types.default.bool, name: prop_types.default.string, status: prop_types.default.oneOf([ "edit", "complete", "uploading" ]), tabIndex: prop_types.default.number }; //#endregion exports.default = Filename;