UNPKG

@carbon/ibm-products

Version:
52 lines (50 loc) 1.61 kB
/** * Copyright IBM Corp. 2020, 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 { blockClass, checkIsValid } from "../../utils/util.js"; import React from "react"; import PropTypes from "prop-types"; import { TextArea, TextInput } from "@carbon/react"; //#region src/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemText/ConditionBuilderItemText.tsx /** * Copyright IBM Corp. 2024 * * 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 ConditionBuilderItemText = ({ conditionState, onChange, config, type }) => { 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.createElement("div", { className: `${blockClass}__item-text` }, type == "textarea" ? /* @__PURE__ */ React.createElement(TextArea, inputProps) : /* @__PURE__ */ React.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 }; //#endregion export { ConditionBuilderItemText };