@mskcc/carbon-react
Version:
Carbon react components for the MSKCC DSM
44 lines (38 loc) • 939 B
JavaScript
/**
* MSKCC 2021, 2024
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
const invalidProps = invalidId => ({
'data-invalid': true,
'aria-invalid': true,
'aria-describedby': invalidId
});
const warnProps = warnId => ({
'aria-describedby': warnId
});
const helperProps = helperId => ({
'aria-describedby': helperId
});
/**
* @param {{sharedTextInputProps: object, invalid?: boolean, invalidId?: string, warn?: boolean, warnId?: string, hasHelper?: boolean, helperId?: string}} config
* @returns {object}
*/
const textInputProps = _ref => {
let {
sharedTextInputProps,
invalid,
invalidId,
warn,
warnId,
hasHelper,
helperId
} = _ref;
return {
...sharedTextInputProps,
...(invalid ? invalidProps(invalidId) : {}),
...(warn ? warnProps(warnId) : {}),
...(hasHelper ? helperProps(helperId) : {})
};
};
exports.textInputProps = textInputProps;