UNPKG

@carbon/react

Version:

React components for the Carbon Design System

30 lines (28 loc) 952 B
/** * 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. */ //#region src/components/TextInput/util.ts /** * Copyright IBM Corp. 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 invalidProps = (invalidId) => ({ "data-invalid": true, "aria-invalid": true, "aria-describedby": invalidId }); const warnProps = (warnId) => ({ "aria-describedby": warnId }); const helperProps = (helperId) => ({ "aria-describedby": helperId }); const getTextInputProps = ({ sharedTextInputProps, invalid, invalidId, warn, warnId, hasHelper, helperId }) => ({ ...sharedTextInputProps, ...invalid ? invalidProps(invalidId) : {}, ...warn ? warnProps(warnId) : {}, ...hasHelper ? helperProps(helperId) : {} }); //#endregion export { getTextInputProps };