import { TextInput } from '@carbon/react';
import * as React from 'react';
import PropTypes from 'prop-types';
import { RulesPropType } from './RuleBuilderPropTypes.js';

var propTypes = {
  rule: RulesPropType.isRequired,
  onChange: PropTypes.func.isRequired,
  renderColumnField: PropTypes.func,
  renderOperandField: PropTypes.func,
  i18n: PropTypes.shape({
    valuePlaceholder: PropTypes.string
  })
};
var defaultProps = {
  renderColumnField: undefined,
  renderOperandField: undefined,
  i18n: {
    valuePlaceholder: 'Enter a value'
  }
};
var RuleValueField = function RuleValueField(_ref) {
  var rule = _ref.rule,
    _onChange = _ref.onChange,
    renderColumnField = _ref.renderColumnField,
    renderOperandField = _ref.renderOperandField,
    i18n = _ref.i18n;
  if (renderOperandField) {
    return renderOperandField({
      value: rule.value,
      onChange: _onChange
    });
  }
  if (renderColumnField) {
    return renderColumnField({
      value: rule.value,
      onChange: _onChange
    });
  }
  return /*#__PURE__*/React.createElement(TextInput, {
    id: "".concat(rule.id, "-value"),
    placeholder: i18n.valuePlaceholder,
    light: true,
    labelText: "",
    defaultValue: rule.value,
    onChange: function onChange(e) {
      return _onChange(e.target.value);
    },
    "data-testid": "".concat(rule.id, "-value")
  });
};
RuleValueField.propTypes = propTypes;
RuleValueField.defaultProps = defaultProps;
RuleValueField.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "RuleValueField",
  "props": {
    "renderColumnField": {
      "defaultValue": {
        "value": "undefined",
        "computed": true
      },
      "description": "",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "renderOperandField": {
      "defaultValue": {
        "value": "undefined",
        "computed": true
      },
      "description": "",
      "type": {
        "name": "func"
      },
      "required": false
    },
    "i18n": {
      "defaultValue": {
        "value": "{\n  valuePlaceholder: 'Enter a value',\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "valuePlaceholder": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "rule": {
      "description": "",
      "type": {
        "name": "custom",
        "raw": "RulesPropType.isRequired"
      },
      "required": false
    },
    "onChange": {
      "description": "",
      "type": {
        "name": "func"
      },
      "required": true
    }
  }
};
var RuleValueField$1 = RuleValueField;

export { RuleValueField$1 as default };
