UNPKG

@signalplus/params-about

Version:

A description for the module

1,374 lines (1,147 loc) 177 kB
/** * Bundle of @signalplus/params-about * Generated: 2025-11-11 * Version: 1.0.26 * License: MIT * Author: 2631541504@qq.com */ import React, { PureComponent, useMemo, useState, useEffect } from 'react'; import classNames from 'classnames'; import dayjs from 'dayjs'; import Big from 'big.js'; import { PlusOutlined, DeleteOutlined, CloseOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons'; import { Popover, Cascader, Checkbox, Input, Select, Form, Button, message, Modal } from 'antd'; import { isArray, capitalize, isEqual } from 'lodash-es'; import ReactGlobalComp from 'react-global-comp'; import ReactFileInput from '@livelybone/react-file-input'; import { useRequest } from 'ahooks'; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } var ParamType; (function (ParamType) { ParamType[ParamType["ParamGroup"] = -1] = "ParamGroup"; ParamType[ParamType["Number"] = 1] = "Number"; ParamType[ParamType["Percentage"] = 2] = "Percentage"; ParamType[ParamType["Bool"] = 3] = "Bool"; ParamType[ParamType["NumberRange"] = 4] = "NumberRange"; ParamType[ParamType["PercentageRange"] = 5] = "PercentageRange"; ParamType[ParamType["ExpiryLimit"] = 6] = "ExpiryLimit"; ParamType[ParamType["Expiry"] = 7] = "Expiry"; ParamType[ParamType["Phone"] = 8] = "Phone"; ParamType[ParamType["Text"] = 9] = "Text"; ParamType[ParamType["ExpiryValue"] = 10] = "ExpiryValue"; ParamType[ParamType["InstrumentValue"] = 11] = "InstrumentValue"; ParamType[ParamType["TextNumberList"] = 12] = "TextNumberList"; ParamType[ParamType["TextPercentageList"] = 13] = "TextPercentageList"; ParamType[ParamType["HardLimitHandler"] = 15] = "HardLimitHandler"; ParamType[ParamType["InstrumentArray"] = 14] = "InstrumentArray"; ParamType[ParamType["OneWayHandler"] = 16] = "OneWayHandler"; ParamType[ParamType["TenorBucketHandlerList"] = 17] = "TenorBucketHandlerList"; ParamType[ParamType["ExpiryVegaAlphaByEdgeList"] = 18] = "ExpiryVegaAlphaByEdgeList"; })(ParamType || (ParamType = {})); function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function formatNum(val) { var num = parseFloat(val); return isNaN(num) ? undefined : num; } function isNullLike(val) { return val === undefined || val === null; } function isEmpty(val) { return val === undefined || val === null || val === ''; } function emptyValidator(val, enableEmpty) { return !enableEmpty && (isNullLike(val) || val instanceof Array && !val.length || typeof val === 'string' && !val) ? 'Should not be empty' : ''; } function numRangeValidator(val, enableEmpty) { var error = emptyValidator(val === null || val === void 0 ? void 0 : val.min, enableEmpty); if (error) { // return { min: error } return "Min: ".concat(error); } error = emptyValidator(val === null || val === void 0 ? void 0 : val.max, enableEmpty); if (error) { // return { max: error } return "Max: ".concat(error); } return +val.min > +val.max ? 'Max should bigger than Min' : ''; } function expiryValidator(val, enableEmpty) { var error = emptyValidator(val, enableEmpty); if (error) return error; // const $val = dayjs(val.replace(/([a-zA-Z]+)/, ' $1 '), 'D MMM YY') // .format('DMMMYY') // .toUpperCase(); // if ($val !== val && `0${$val}` !== val) return 'Out of format'; return ''; } function expiriesValidator(val) { if (!(val === null || val === void 0 ? void 0 : val.length)) return ''; for (var i = 0; i < val.length; i++) { var error = emptyValidator(val[i]); if (error) { // return { [i]: error } return "The ".concat(i + 1).concat(i === 0 ? 'st' : i === 1 ? 'nd' : i === 2 ? 'rd' : 'th', " item: ").concat(error); } } return ''; } function keyValidator(val, allKeys) { var error = emptyValidator(val); if (error) return error; if (!/^[_.a-zA-Z0-9]+$/.test(val)) { return 'Out of format: should be a combination of the following chars `_.0-9a-zA-Z`'; } var has = allKeys.some(function (it) { return val === it; }); if (has) return 'This key has been used'; return ''; } function isExpired(val) { var _val$match; if (!val) return false; var now = dayjs(); var expiry = dayjs(((_val$match = val.match(/\d+|[a-zA-Z]+/g)) === null || _val$match === void 0 ? void 0 : _val$match.slice(0, 3).join('-')) || '', 'D-MMM-YY'); var expireTime = dayjs("".concat(expiry.format('YYYY-MM-DD'), "T08:00Z")); return now >= expireTime; } function sameGroupNameValidator(val, paramList, projectName, templateName, parentNames) { var error = emptyValidator(val); if (error) return error; var hasSame = paramList === null || paramList === void 0 ? void 0 : paramList.some(function (_it) { return _it.name === val; }); return hasSame ? "\u8BE5\u53C2\u6570\u7EC4\u540D\u79F0\u5728".concat(projectName, ">").concat(templateName).concat(parentNames ? '>' + parentNames : '', "\u4E0B\u5DF2\u5B58\u5728") : ''; } function validatorCvt(validator, form) { return function (_, val) { var $form = form === null || form === void 0 ? void 0 : form(); var error = validator(val, $form === null || $form === void 0 ? void 0 : $form.getFieldsValue()); if (!error) return Promise.resolve(); var traverse = function traverse(obj) { if (typeof obj === 'string' && obj) return Promise.reject(new Error(obj)); if (obj && _typeof(obj) === 'object') { for (var key in obj) { var res = traverse(obj[key]); if (res) return res; } } }; return traverse(error) || Promise.resolve(); }; } var Bool = /*#__PURE__*/function (_PureComponent) { _inherits(Bool, _PureComponent); var _super = _createSuper(Bool); function Bool() { var _this; _classCallCheck(this, Bool); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "options", [{ label: 'TRUE', value: true }, { label: 'FALSE', value: false }]); _defineProperty(_assertThisInitialized(_this), "RadioChecked", /*#__PURE__*/React.createElement("svg", { width: "16", height: "17", viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /*#__PURE__*/React.createElement("g", { clipPath: "url(#clip0_0_7934)" }, /*#__PURE__*/React.createElement("circle", { cx: "8", cy: "8.5", r: "7.5", fill: "none", stroke: "#006FA7", strokeWidth: "1" }), /*#__PURE__*/React.createElement("circle", { cx: "8", cy: "8.5", r: "4", fill: "#006FA7" })), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", { id: "clip0_0_7934" }, /*#__PURE__*/React.createElement("rect", { width: "16", height: "16", fill: "white", transform: "translate(0 0.5)" }))))); _defineProperty(_assertThisInitialized(_this), "RadioUnchecked", /*#__PURE__*/React.createElement("svg", { width: "16", height: "17", viewBox: "0 0 16 17", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /*#__PURE__*/React.createElement("circle", { cx: "8", cy: "8.5", r: "7.5", fill: "none", stroke: "#CCCCCC", strokeWidth: "1" }))); _defineProperty(_assertThisInitialized(_this), "onChange", function (val) { var _this$props$onChange, _this$props, _this$props$onBlur, _this$props2; (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, val); (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2); }); return _this; } _createClass(Bool, [{ key: "render", value: function render() { var _this2 = this; return /*#__PURE__*/React.createElement("div", { className: classNames('param-bool', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? /*#__PURE__*/React.createElement("span", { className: "param-bool-val" }, !isNullLike(this.props.value) ? String(this.props.value).toUpperCase() : 'N/A') : this.options.map(function (it) { var active = it.value === _this2.props.value; return /*#__PURE__*/React.createElement("div", { key: String(it.value), className: classNames('param-bool-option', { active: active }), onClick: _this2.onChange.bind(null, it.value) }, active ? _this2.RadioChecked : _this2.RadioUnchecked, it.label); })); } }]); return Bool; }(PureComponent); var NumCvt = /*#__PURE__*/function () { function NumCvt() { _classCallCheck(this, NumCvt); } _createClass(NumCvt, null, [{ key: "show", value: function show(val, isPercentage) { if (val && isPercentage) return Big(val).times(100).valueOf(); return String(val !== null && val !== void 0 ? val : ''); } }, { key: "emit", value: function emit(val, isPercentage) { if (!val || val === '-') return undefined; if (!isPercentage) return +val; return +Big(val).div(100); } }]); return NumCvt; }(); function initState$2(props) { return { preProps: props, tempValue: NumCvt.show(props.value, props.isPercentage) }; } var Num = /*#__PURE__*/function (_PureComponent) { _inherits(Num, _PureComponent); var _super = _createSuper(Num); function Num() { var _this; _classCallCheck(this, Num); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "state", initState$2(_this.props)); _defineProperty(_assertThisInitialized(_this), "onChange", function (e) { var $value = e.target.value; var $val = $value.replace(/^(-?\d+(\.\d*)?|-?\d*).*$/, '$1'); if ($val !== $value) e.target.value = $val; var value = NumCvt.emit($val, _this.props.isPercentage); _this.setState(function (pre) { return _objectSpread2(_objectSpread2({}, pre), {}, { tempValue: e.target.value }); }, function () { var _this$props$onChange, _this$props; if (value !== _this.props.value) (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value); }); }); _defineProperty(_assertThisInitialized(_this), "onBlur", function (e) { var _this$props$onBlur, _this$props2; var value = e.target.value; if (value === '-') e.target.value = ''; (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2); }); return _this; } _createClass(Num, [{ key: "render", value: function render() { return /*#__PURE__*/React.createElement("div", { className: classNames('param-number', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? /*#__PURE__*/React.createElement("span", { className: "param-number-val" }, this.state.tempValue || 'N/A') : /*#__PURE__*/React.createElement("input", { style: { width: this.props.singleWidth || this.props.isPercentage ? 50 : 90 }, className: "param-number-val", type: "text", placeholder: this.props.placeholder || 'Value', value: this.state.tempValue || '', onChange: this.onChange, onBlur: this.onBlur, autoComplete: "off" }), this.props.isPercentage && /*#__PURE__*/React.createElement("span", { className: "param-number-suffix" }, "%")); } }], [{ key: "getDerivedStateFromProps", value: function getDerivedStateFromProps(props, state) { if (props.value !== state.preProps.value && NumCvt.emit(state.tempValue, props.isPercentage) !== props.value) { state.tempValue = NumCvt.show(props.value, props.isPercentage); } return _objectSpread2(_objectSpread2({}, state), {}, { preProps: props }); } }]); return Num; }(PureComponent); var NumRange = /*#__PURE__*/function (_PureComponent) { _inherits(NumRange, _PureComponent); var _super = _createSuper(NumRange); function NumRange() { var _this; _classCallCheck(this, NumRange); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "onChange", function (key, val) { var _this$props$onChange, _this$props; var value = _objectSpread2({}, _this.props.value); value[key] = val; (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value); }); return _this; } _createClass(NumRange, [{ key: "render", value: function render() { var _this$props$value, _this$props$value2; return /*#__PURE__*/React.createElement("div", { className: classNames('param-number-range', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? '(' : '', /*#__PURE__*/React.createElement(Num, { placeholder: this.props.minName || 'Min', value: (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.min, onChange: this.onChange.bind(null, 'min'), isPercentage: this.props.isPercentage, readonly: this.props.readonly, onBlur: this.props.onBlur, singleWidth: this.props.singleWidth }), /*#__PURE__*/React.createElement("span", { className: "param-number-range-sep", style: this.props.readonly ? { marginLeft: 0, marginRight: 4 } : undefined }, this.props.readonly ? ',' : '~'), /*#__PURE__*/React.createElement(Num, { placeholder: this.props.maxName || 'Max', value: (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.max, onChange: this.onChange.bind(null, 'max'), isPercentage: this.props.isPercentage, readonly: this.props.readonly, onBlur: this.props.onBlur, singleWidth: this.props.singleWidth }), this.props.readonly ? ')' : ''); } }]); return NumRange; }(PureComponent); function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } var TextArray = /*#__PURE__*/function (_PureComponent) { _inherits(TextArray, _PureComponent); var _super = _createSuper(TextArray); function TextArray() { var _this; _classCallCheck(this, TextArray); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "value", []); _defineProperty(_assertThisInitialized(_this), "isEmptyItem", function (item) { return !item.trim(); }); _defineProperty(_assertThisInitialized(_this), "onChange", function (i, e) { var _this$props$onChange, _this$props; var val = e.target.value; var value = _toConsumableArray(_this.value); value[i] = val; (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); }); _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) { var _this$props$onChange2, _this$props2; var value = _toConsumableArray(_this.value); value.splice(i + 1, 0, ''); (_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value); }); _defineProperty(_assertThisInitialized(_this), "onDel", function (i) { var _this$props$onChange3, _this$props3; var value = _toConsumableArray(_this.value); value.splice(i, 1); (_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); }); return _this; } _createClass(TextArray, [{ key: "render", value: function render() { var _this$props$value, _this2 = this; this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.slice()) || []; if (!this.value.length) this.value.push(''); return /*#__PURE__*/React.createElement("div", { className: classNames('param-text-array', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? /*#__PURE__*/React.createElement("span", { className: "param-text-array-val" }, this.value.filter(Boolean).join(', ') || '-') : this.value.map(function (it, i) { return /*#__PURE__*/React.createElement("div", { className: "param-arr-item", key: i }, /*#__PURE__*/React.createElement("input", { type: "text", placeholder: "", value: it, onChange: _this2.onChange.bind(null, i), onBlur: _this2.props.onBlur, autoComplete: "off" }), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops" }, /*#__PURE__*/React.createElement(PlusOutlined, { className: "param-arr-ops-add", onClick: _this2.onAdd.bind(null, i) }), /*#__PURE__*/React.createElement(DeleteOutlined, { className: "param-arr-ops-del", onClick: _this2.onDel.bind(null, i) }))); })); } }]); return TextArray; }(PureComponent); var Expiries = /*#__PURE__*/function (_PureComponent) { _inherits(Expiries, _PureComponent); var _super = _createSuper(Expiries); function Expiries() { var _this; _classCallCheck(this, Expiries); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "state", { visible: false }); _defineProperty(_assertThisInitialized(_this), "handleVisibleChange", function (visible) { return _this.setState({ visible: visible }); }); _defineProperty(_assertThisInitialized(_this), "onChange", function (val) { var _this$props$value, _this$props$onChange, _this$props, _this$props$onBlur, _this$props2; var value = _toConsumableArray(((_this$props$value = _this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (item) { var _this$props$options; return (_this$props$options = _this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.includes(item); })) || []); if (_this.props.multiple !== false) { var index = value.findIndex(function (it) { return it === val; }); if (index > -1) value.splice(index, 1);else value.push(val); } else { value = [val]; } (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value); (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2); if (_this.props.multiple === false) _this.handleVisibleChange(false); }); return _this; } _createClass(Expiries, [{ key: "renderValue", value: function renderValue() { var _this$props$value2, _this2 = this; var value = (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.filter(function (it) { return it && !isExpired(it); }); if (this.props.readonly) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, (value === null || value === void 0 ? void 0 : value.join(', ')) || '-'); } var placeholder = /*#__PURE__*/React.createElement("span", { className: "param-expiries-placeholder" }, "Choose"); if (this.props.multiple === false) { var _this$props$value3; var _val = (_this$props$value3 = this.props.value) === null || _this$props$value3 === void 0 ? void 0 : _this$props$value3[0]; return !_val || isExpired(_val) ? placeholder : /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, _val); } if (!(value === null || value === void 0 ? void 0 : value.length)) return placeholder; return value.map(function (it) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-multi-val", key: it, onClick: function onClick(e) { return e.stopPropagation(); } }, it, /*#__PURE__*/React.createElement(CloseOutlined, { onClick: _this2.onChange.bind(null, it) })); }); } }, { key: "render", value: function render() { var _this$props$options2, _this3 = this; return /*#__PURE__*/React.createElement(Popover, { overlayClassName: "param-expiries-popover", trigger: 'click', placement: 'bottomLeft', visible: !this.props.readonly && this.state.visible, onVisibleChange: this.handleVisibleChange, content: (_this$props$options2 = this.props.options) === null || _this$props$options2 === void 0 ? void 0 : _this$props$options2.map(function (it) { var _this3$props$value, _this3$props$calcDisa, _this3$props, _this3$onChange; var checked = (_this3$props$value = _this3.props.value) === null || _this3$props$value === void 0 ? void 0 : _this3$props$value.includes(it); var disabled = (_this3$props$calcDisa = (_this3$props = _this3.props).calcDisabled) === null || _this3$props$calcDisa === void 0 ? void 0 : _this3$props$calcDisa.call(_this3$props, it); return /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries-option', { 'param-expiries-option-checked': checked, 'param-expiries-option-disabled': disabled }), key: it, onClick: disabled ? undefined : (_this3$onChange = _this3.onChange) === null || _this3$onChange === void 0 ? void 0 : _this3$onChange.bind(null, it) }, it, checked && /*#__PURE__*/React.createElement(CheckOutlined, null)); }) }, /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries', { readonly: this.props.readonly, multiple: this.props.multiple !== false }, this.props.className), style: this.props.style }, this.renderValue(), !this.props.readonly && this.props.options && /*#__PURE__*/React.createElement(DownOutlined, { className: "param-expiries-arrow" }))); } }]); return Expiries; }(PureComponent); var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) { _inherits(ExpiriesLimit, _PureComponent); var _super = _createSuper(ExpiriesLimit); function ExpiriesLimit() { var _this; _classCallCheck(this, ExpiriesLimit); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "value", []); _defineProperty(_assertThisInitialized(_this), "isEmptyItem", function (item) { var _item$expiry; return !((_item$expiry = item.expiry) === null || _item$expiry === void 0 ? void 0 : _item$expiry.trim()) && isNullLike(item.minAumPercentage) && isNullLike(item.maxAumPercentage) && isNullLike(item.minAbs) && isNullLike(item.maxAbs); }); _defineProperty(_assertThisInitialized(_this), "onChange", function (i, val, key) { var _this$props$onChange, _this$props; var value = _toConsumableArray(_this.value); if (!value[i]) value[i] = { expiry: '' }; if (key) value[i][key] = val;else value[i] = _objectSpread2(_objectSpread2({}, value[i]), val); (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); }); _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) { var _this$props$onChange2, _this$props2, _this$props$onBlur, _this$props3; var value = _toConsumableArray(_this.value); value.splice(i + 1, 0, { expiry: '' }); (_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value); (_this$props$onBlur = (_this$props3 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3); }); _defineProperty(_assertThisInitialized(_this), "onDel", function (i) { var _this$props$onChange3, _this$props4, _this$props$onBlur2, _this$props5; var value = _toConsumableArray(_this.value); value.splice(i, 1); (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); (_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5); }); return _this; } _createClass(ExpiriesLimit, [{ key: "render", value: function render() { var _this$props$value, _this$props$value2, _this2 = this; this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) { return !isExpired(it.expiry); })) || []; if (!this.value.length && !this.props.readonly) this.value.push({ expiry: '' }); return /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries-limit', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? ((_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.length) ? this.value.filter(function (it) { return it.expiry; }).map(function (it, i) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-limit-val", key: i }, it.expiry, /*#__PURE__*/React.createElement("span", { className: "param-expiries-limit-val-sep" }, "/"), !isNullLike(it.minAumPercentage) && !isNullLike(it.maxAumPercentage) ? "(".concat(NumCvt.show(it.minAumPercentage, true), "%, ").concat(NumCvt.show(it.maxAumPercentage, true), "%)") : '-', /*#__PURE__*/React.createElement("span", { className: "param-expiries-limit-val-sep" }, "/"), !isNullLike(it.minAbs) && !isNullLike(it.maxAbs) ? "(".concat(it.minAbs, ", ").concat(it.maxAbs, ")") : '-'); }) : '-' : /*#__PURE__*/React.createElement("div", { className: "param-expiries-limit-inputs" }, /*#__PURE__*/React.createElement("div", { className: "param-expiries readonly" }, /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, "Expiry")), /*#__PURE__*/React.createElement("div", { className: "param-number-range readonly" }, "Limit(% of AUM)"), /*#__PURE__*/React.createElement("div", { className: "param-number-range readonly" }, "Limit(ABS)"), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops readonly" }), this.value.map(function (it, i) { return /*#__PURE__*/React.createElement(React.Fragment, { key: i }, /*#__PURE__*/React.createElement(Expiries, { multiple: false, options: _this2.props.options, value: [it.expiry], onChange: function onChange(val) { return _this2.onChange(i, val[0], 'expiry'); }, calcDisabled: function calcDisabled(expiry) { return _this2.value.some(function (item) { return item !== it && item.expiry === expiry; }); }, onBlur: _this2.props.onBlur }), /*#__PURE__*/React.createElement(NumRange, { value: { min: it.minAumPercentage, max: it.maxAumPercentage }, onChange: function onChange(val) { return _this2.onChange(i, { minAumPercentage: val === null || val === void 0 ? void 0 : val.min, maxAumPercentage: val === null || val === void 0 ? void 0 : val.max }); }, isPercentage: true, onBlur: _this2.props.onBlur }), /*#__PURE__*/React.createElement(NumRange, { value: { min: it.minAbs, max: it.maxAbs }, onChange: function onChange(val) { return _this2.onChange(i, { minAbs: val === null || val === void 0 ? void 0 : val.min, maxAbs: val === null || val === void 0 ? void 0 : val.max }); }, onBlur: _this2.props.onBlur }), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops" }, /*#__PURE__*/React.createElement(PlusOutlined, { className: "param-arr-ops-add", onClick: _this2.onAdd.bind(null, i) }), /*#__PURE__*/React.createElement(DeleteOutlined, { className: "param-arr-ops-del", onClick: _this2.onDel.bind(null, i) }))); }))); } }]); return ExpiriesLimit; }(PureComponent); var ExpiriesValueList = /*#__PURE__*/function (_PureComponent) { _inherits(ExpiriesValueList, _PureComponent); var _super = _createSuper(ExpiriesValueList); function ExpiriesValueList() { var _this; _classCallCheck(this, ExpiriesValueList); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "value", []); _defineProperty(_assertThisInitialized(_this), "isEmptyItem", function (item) { var _item$expiry; return !((_item$expiry = item.expiry) === null || _item$expiry === void 0 ? void 0 : _item$expiry.trim()) && isNullLike(item.value); }); _defineProperty(_assertThisInitialized(_this), "onChange", function (i, val, key) { var _this$props$onChange, _this$props; var value = _toConsumableArray(_this.value); if (!value[i]) value[i] = { expiry: '' }; if (key) value[i][key] = val;else value[i] = _objectSpread2(_objectSpread2({}, value[i]), val); (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); }); _defineProperty(_assertThisInitialized(_this), "onAdd", function (i) { var _this$props$onChange2, _this$props2, _this$props$onBlur, _this$props3; var value = _toConsumableArray(_this.value); value.splice(i + 1, 0, { expiry: '' }); (_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value); (_this$props$onBlur = (_this$props3 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props3); }); _defineProperty(_assertThisInitialized(_this), "onDel", function (i) { var _this$props$onChange3, _this$props4, _this$props$onBlur2, _this$props5; var value = _toConsumableArray(_this.value); value.splice(i, 1); (_this$props$onChange3 = (_this$props4 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props4, value.length === 1 && _this.isEmptyItem(value[0]) ? [] : value); (_this$props$onBlur2 = (_this$props5 = _this.props).onBlur) === null || _this$props$onBlur2 === void 0 ? void 0 : _this$props$onBlur2.call(_this$props5); }); return _this; } _createClass(ExpiriesValueList, [{ key: "render", value: function render() { var _this$props$value, _this$props$value2, _this2 = this; this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) { return !isExpired(it.expiry); })) || []; if (!this.value.length && !this.props.readonly) this.value.push({ expiry: '' }); return /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries-limit', { readonly: this.props.readonly }, this.props.className), style: this.props.style }, this.props.readonly ? ((_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.length) ? this.value.filter(function (it) { return it.expiry; }).map(function (it, i) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-limit-val", key: i }, it.expiry, /*#__PURE__*/React.createElement("span", { className: "param-expiries-limit-val-sep" }, "/"), !isNullLike(it.value) ? it.value : '-'); }) : '-' : /*#__PURE__*/React.createElement("div", { className: "param-expiries-limit-inputs" }, /*#__PURE__*/React.createElement("div", { className: "param-expiries readonly" }, /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, "Expiry")), /*#__PURE__*/React.createElement("div", { className: "param-number-range readonly" }, "Value"), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops readonly" }), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops readonly" }), this.value.map(function (it, i) { return /*#__PURE__*/React.createElement(React.Fragment, { key: i }, /*#__PURE__*/React.createElement(Expiries, { style: { width: 240 }, multiple: false, options: _this2.props.options, value: [it.expiry], onChange: function onChange(val) { return _this2.onChange(i, val[0], 'expiry'); }, calcDisabled: function calcDisabled(expiry) { return _this2.value.some(function (item) { return item !== it && item.expiry === expiry; }); }, onBlur: _this2.props.onBlur }), /*#__PURE__*/React.createElement(Num, { style: { height: 30, width: 180 }, value: it.value, onChange: function onChange(val) { return _this2.onChange(i, { value: val }); }, onBlur: _this2.props.onBlur }), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops readonly" }), /*#__PURE__*/React.createElement("div", { className: "param-arr-ops" }, /*#__PURE__*/React.createElement(PlusOutlined, { className: "param-arr-ops-add", onClick: _this2.onAdd.bind(null, i) }), /*#__PURE__*/React.createElement(DeleteOutlined, { className: "param-arr-ops-del", onClick: _this2.onDel.bind(null, i) }))); }))); } }]); return ExpiriesValueList; }(PureComponent); var Instruments = /*#__PURE__*/function (_PureComponent) { _inherits(Instruments, _PureComponent); var _super = _createSuper(Instruments); function Instruments() { var _this; _classCallCheck(this, Instruments); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "state", { visible: false, showList: _toConsumableArray(_this.props.options || []) }); _defineProperty(_assertThisInitialized(_this), "handleVisibleChange", function (visible) { return _this.setState({ visible: visible }); }); _defineProperty(_assertThisInitialized(_this), "onChange", function (val) { var _this$props$value, _this$props$onChange, _this$props, _this$props$onBlur, _this$props2; var value = _toConsumableArray(((_this$props$value = _this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (item) { var _this$props$options; return (_this$props$options = _this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.includes(item); })) || []); if (_this.props.multiple !== false) { var index = value.findIndex(function (it) { return it === val; }); if (index > -1) value.splice(index, 1);else value.push(val); } else { value = [val]; } (_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value); (_this$props$onBlur = (_this$props2 = _this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2); if (_this.props.multiple === false) _this.handleVisibleChange(false); }); _defineProperty(_assertThisInitialized(_this), "inputValueChange", function (val) { var _this$props$options2; var showList = ((_this$props$options2 = _this.props.options) === null || _this$props$options2 === void 0 ? void 0 : _this$props$options2.filter(function (it) { return it.includes(val.toUpperCase()); })) || []; _this.setState({ showList: showList }); }); return _this; } _createClass(Instruments, [{ key: "renderValue", value: function renderValue() { var _this$props$value2, _this2 = this; var value = (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.filter(function (it) { return it; }); if (this.props.readonly) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, (value === null || value === void 0 ? void 0 : value.join(', ')) || '-'); } var placeholder = /*#__PURE__*/React.createElement("span", { className: "param-expiries-placeholder" }, "Choose"); if (this.props.multiple === false) { var _this$props$value3; var _val = (_this$props$value3 = this.props.value) === null || _this$props$value3 === void 0 ? void 0 : _this$props$value3[0]; return !_val ? placeholder : /*#__PURE__*/React.createElement("span", { className: "param-expiries-val" }, _val); } if (!(value === null || value === void 0 ? void 0 : value.length)) return placeholder; return value.map(function (it) { return /*#__PURE__*/React.createElement("span", { className: "param-expiries-multi-val", key: it, onClick: function onClick(e) { return e.stopPropagation(); } }, it, /*#__PURE__*/React.createElement(CloseOutlined, { onClick: _this2.onChange.bind(null, it) })); }); } }, { key: "render", value: function render() { var _this3 = this, _this$state$showList; return /*#__PURE__*/React.createElement(Popover, { overlayClassName: "param-expiries-popover", trigger: 'click', placement: 'bottomLeft', visible: !this.props.readonly && this.state.visible, onVisibleChange: this.handleVisibleChange, content: /*#__PURE__*/React.createElement("div", { className: "param-renderer" }, /*#__PURE__*/React.createElement("input", { style: { width: '180px', height: '30px' }, onChange: function onChange(e) { return _this3.inputValueChange(e.target.value); } }), /*#__PURE__*/React.createElement("div", { style: { marginTop: 2, width: 220, height: 300, overflowY: 'auto', overflowX: 'hidden' } }, (_this$state$showList = this.state.showList) === null || _this$state$showList === void 0 ? void 0 : _this$state$showList.map(function (it) { var _this3$props$value, _this3$props$calcDisa, _this3$props, _this3$onChange; var checked = (_this3$props$value = _this3.props.value) === null || _this3$props$value === void 0 ? void 0 : _this3$props$value.includes(it); var disabled = (_this3$props$calcDisa = (_this3$props = _this3.props).calcDisabled) === null || _this3$props$calcDisa === void 0 ? void 0 : _this3$props$calcDisa.call(_this3$props, it); return /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries-option', { 'param-expiries-option-checked': checked, 'param-expiries-option-disabled': disabled }), key: it, onClick: disabled ? undefined : (_this3$onChange = _this3.onChange) === null || _this3$onChange === void 0 ? void 0 : _this3$onChange.bind(null, it) }, it, checked && /*#__PURE__*/React.createElement(CheckOutlined, null)); }))) }, /*#__PURE__*/React.createElement("div", { className: classNames('param-expiries', { readonly: this.props.readonly, multiple: this.props.multiple !== false }, this.props.className), style: this.props.style }, this.renderValue(), !this.props.readonly && this.pro