@react-awesome-query-builder/ui
Version:
User-friendly query builder for React. Core React UI
59 lines • 3.01 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
var _excluded = ["factory"];
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
import React, { PureComponent } from "react";
import { Utils } from "@react-awesome-query-builder/core";
import PropTypes from "prop-types";
var getOperatorConfig = Utils.ConfigUtils.getOperatorConfig;
var OperatorOptions = /*#__PURE__*/function (_PureComponent) {
function OperatorOptions() {
_classCallCheck(this, OperatorOptions);
return _callSuper(this, OperatorOptions, arguments);
}
_inherits(OperatorOptions, _PureComponent);
return _createClass(OperatorOptions, [{
key: "render",
value: function render() {
if (!this.props.selectedOperator) return null;
var operatorDefinitions = getOperatorConfig(this.props.config, this.props.selectedOperator, this.props.selectedField);
if (typeof operatorDefinitions.options === "undefined") {
return null;
}
var _operatorDefinitions$ = operatorDefinitions.options,
optionsFactory = _operatorDefinitions$.factory,
basicOptionsProps = _objectWithoutProperties(_operatorDefinitions$, _excluded);
var optionsProps = Object.assign({}, basicOptionsProps, {
config: this.props.config,
field: this.props.selectedField,
fieldSrc: this.props.selectedFieldSrc,
operator: this.props.selectedOperator,
options: this.props.operatorOptions,
setOption: this.props.setOperatorOption,
readonly: this.props.readonly
});
var optionsCmp = optionsFactory(optionsProps, this.props.config.ctx);
var name = this.props.selectedOperator;
return /*#__PURE__*/React.createElement("div", {
className: "rule--operator rule--operator--".concat(name.toUpperCase())
}, optionsCmp);
}
}]);
}(PureComponent);
OperatorOptions.propTypes = {
config: PropTypes.object.isRequired,
operatorOptions: PropTypes.any.isRequired,
//instanceOf(Immutable.Map)
selectedField: PropTypes.any,
selectedFieldSrc: PropTypes.string,
selectedOperator: PropTypes.string.isRequired,
readonly: PropTypes.bool,
//actions
setOperatorOption: PropTypes.func.isRequired
};
export { OperatorOptions as default };