@carbon/ibm-products
Version:
Carbon for IBM Products
54 lines (50 loc) • 1.45 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 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.
*/
import React__default from 'react';
import { TextArea, TextInput } from '@carbon/react';
import PropTypes from '../../../../_virtual/index.js';
import { checkIsValid, blockClass } from '../../utils/util.js';
const ConditionBuilderItemText = _ref => {
let {
conditionState,
onChange,
config,
type
} = _ref;
const inputProps = {
...config,
hideLabel: true,
value: checkIsValid(conditionState.value) ? conditionState.value : '',
id: conditionState.property?.replace(/\s/g, ''),
onChange: evt => {
onChange(evt.target.value);
},
labelText: conditionState.property
};
return /*#__PURE__*/React__default.createElement("div", {
className: `${blockClass}__item-text`
}, type == 'textarea' ? /*#__PURE__*/React__default.createElement(TextArea, inputProps) : /*#__PURE__*/React__default.createElement(TextInput, inputProps));
};
ConditionBuilderItemText.propTypes = {
/**
* current condition object
*/
conditionState: PropTypes.object,
/**
* config of the current property
*/
config: PropTypes.object,
/**
* callback to update state oin date change
*/
onChange: PropTypes.func,
/**
* current input type
*/
type: PropTypes.string
};
export { ConditionBuilderItemText };