@signalplus/params-about 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README-CN.md +81 -0
- package/README.md +81 -0
- package/index.d.ts +114 -0
- package/lib/css/index.css +1 -0
- package/lib/css/index.scss +319 -0
- package/lib/es/index.js +1125 -0
- package/package.json +120 -0
- package/pnpm-lock.yaml +11087 -0
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,1125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundle of @signalplus/params-about
|
|
3
|
+
* Generated: 2022-04-06
|
|
4
|
+
* Version: 0.1.0
|
|
5
|
+
* License: MIT
|
|
6
|
+
* Author: 2631541504@qq.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { PureComponent } from 'react';
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import dayjs from 'dayjs';
|
|
12
|
+
import Big from 'big.js';
|
|
13
|
+
import { PlusOutlined, DeleteOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons';
|
|
14
|
+
import { Popover } from 'antd';
|
|
15
|
+
|
|
16
|
+
function _defineProperty(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ownKeys(object, enumerableOnly) {
|
|
32
|
+
var keys = Object.keys(object);
|
|
33
|
+
|
|
34
|
+
if (Object.getOwnPropertySymbols) {
|
|
35
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
36
|
+
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
37
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
38
|
+
});
|
|
39
|
+
keys.push.apply(keys, symbols);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return keys;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _objectSpread2(target) {
|
|
46
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
47
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
48
|
+
|
|
49
|
+
if (i % 2) {
|
|
50
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
51
|
+
_defineProperty(target, key, source[key]);
|
|
52
|
+
});
|
|
53
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
54
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
55
|
+
} else {
|
|
56
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
57
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function _classCallCheck(instance, Constructor) {
|
|
66
|
+
if (!(instance instanceof Constructor)) {
|
|
67
|
+
throw new TypeError("Cannot call a class as a function");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _defineProperties(target, props) {
|
|
72
|
+
for (var i = 0; i < props.length; i++) {
|
|
73
|
+
var descriptor = props[i];
|
|
74
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
75
|
+
descriptor.configurable = true;
|
|
76
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
77
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
82
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
83
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
84
|
+
return Constructor;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _assertThisInitialized(self) {
|
|
88
|
+
if (self === void 0) {
|
|
89
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return self;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function _setPrototypeOf(o, p) {
|
|
96
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
97
|
+
o.__proto__ = p;
|
|
98
|
+
return o;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return _setPrototypeOf(o, p);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _inherits(subClass, superClass) {
|
|
105
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
106
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
110
|
+
constructor: {
|
|
111
|
+
value: subClass,
|
|
112
|
+
writable: true,
|
|
113
|
+
configurable: true
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function _getPrototypeOf(o) {
|
|
120
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
121
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
122
|
+
};
|
|
123
|
+
return _getPrototypeOf(o);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function _isNativeReflectConstruct() {
|
|
127
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
128
|
+
if (Reflect.construct.sham) return false;
|
|
129
|
+
if (typeof Proxy === "function") return true;
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
|
133
|
+
return true;
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _typeof(obj) {
|
|
140
|
+
"@babel/helpers - typeof";
|
|
141
|
+
|
|
142
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
143
|
+
_typeof = function _typeof(obj) {
|
|
144
|
+
return typeof obj;
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
_typeof = function _typeof(obj) {
|
|
148
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return _typeof(obj);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _possibleConstructorReturn(self, call) {
|
|
156
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
157
|
+
return call;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return _assertThisInitialized(self);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function _createSuper(Derived) {
|
|
164
|
+
return function () {
|
|
165
|
+
var Super = _getPrototypeOf(Derived),
|
|
166
|
+
result;
|
|
167
|
+
|
|
168
|
+
if (_isNativeReflectConstruct()) {
|
|
169
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
170
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
171
|
+
} else {
|
|
172
|
+
result = Super.apply(this, arguments);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return _possibleConstructorReturn(this, result);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
var ParamType;
|
|
180
|
+
|
|
181
|
+
(function (ParamType) {
|
|
182
|
+
ParamType[ParamType["ParamGroup"] = -1] = "ParamGroup";
|
|
183
|
+
ParamType[ParamType["Number"] = 1] = "Number";
|
|
184
|
+
ParamType[ParamType["Percentage"] = 2] = "Percentage";
|
|
185
|
+
ParamType[ParamType["Bool"] = 3] = "Bool";
|
|
186
|
+
ParamType[ParamType["NumberRange"] = 4] = "NumberRange";
|
|
187
|
+
ParamType[ParamType["PercentageRange"] = 5] = "PercentageRange";
|
|
188
|
+
ParamType[ParamType["ExpiryLimit"] = 6] = "ExpiryLimit";
|
|
189
|
+
ParamType[ParamType["Expiry"] = 7] = "Expiry";
|
|
190
|
+
ParamType[ParamType["Phone"] = 8] = "Phone";
|
|
191
|
+
})(ParamType || (ParamType = {}));
|
|
192
|
+
|
|
193
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
194
|
+
|
|
195
|
+
function createCommonjsModule(fn, module) {
|
|
196
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var utc = createCommonjsModule(function (module, exports) {
|
|
200
|
+
!function (t, i) {
|
|
201
|
+
module.exports = i() ;
|
|
202
|
+
}(commonjsGlobal, function () {
|
|
203
|
+
|
|
204
|
+
var t = "minute",
|
|
205
|
+
i = /[+-]\d\d(?::?\d\d)?/g,
|
|
206
|
+
e = /([+-]|\d\d)/g;
|
|
207
|
+
return function (s, f, n) {
|
|
208
|
+
var u = f.prototype;
|
|
209
|
+
n.utc = function (t) {
|
|
210
|
+
var i = {
|
|
211
|
+
date: t,
|
|
212
|
+
utc: !0,
|
|
213
|
+
args: arguments
|
|
214
|
+
};
|
|
215
|
+
return new f(i);
|
|
216
|
+
}, u.utc = function (i) {
|
|
217
|
+
var e = n(this.toDate(), {
|
|
218
|
+
locale: this.$L,
|
|
219
|
+
utc: !0
|
|
220
|
+
});
|
|
221
|
+
return i ? e.add(this.utcOffset(), t) : e;
|
|
222
|
+
}, u.local = function () {
|
|
223
|
+
return n(this.toDate(), {
|
|
224
|
+
locale: this.$L,
|
|
225
|
+
utc: !1
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
var o = u.parse;
|
|
229
|
+
|
|
230
|
+
u.parse = function (t) {
|
|
231
|
+
t.utc && (this.$u = !0), this.$utils().u(t.$offset) || (this.$offset = t.$offset), o.call(this, t);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var r = u.init;
|
|
235
|
+
|
|
236
|
+
u.init = function () {
|
|
237
|
+
if (this.$u) {
|
|
238
|
+
var t = this.$d;
|
|
239
|
+
this.$y = t.getUTCFullYear(), this.$M = t.getUTCMonth(), this.$D = t.getUTCDate(), this.$W = t.getUTCDay(), this.$H = t.getUTCHours(), this.$m = t.getUTCMinutes(), this.$s = t.getUTCSeconds(), this.$ms = t.getUTCMilliseconds();
|
|
240
|
+
} else r.call(this);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var a = u.utcOffset;
|
|
244
|
+
|
|
245
|
+
u.utcOffset = function (s, f) {
|
|
246
|
+
var n = this.$utils().u;
|
|
247
|
+
if (n(s)) return this.$u ? 0 : n(this.$offset) ? a.call(this) : this.$offset;
|
|
248
|
+
if ("string" == typeof s && (s = function (t) {
|
|
249
|
+
void 0 === t && (t = "");
|
|
250
|
+
var s = t.match(i);
|
|
251
|
+
if (!s) return null;
|
|
252
|
+
var f = ("" + s[0]).match(e) || ["-", 0, 0],
|
|
253
|
+
n = f[0],
|
|
254
|
+
u = 60 * +f[1] + +f[2];
|
|
255
|
+
return 0 === u ? 0 : "+" === n ? u : -u;
|
|
256
|
+
}(s), null === s)) return this;
|
|
257
|
+
var u = Math.abs(s) <= 16 ? 60 * s : s,
|
|
258
|
+
o = this;
|
|
259
|
+
if (f) return o.$offset = u, o.$u = 0 === s, o;
|
|
260
|
+
|
|
261
|
+
if (0 !== s) {
|
|
262
|
+
var r = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
|
|
263
|
+
(o = this.local().add(u + r, t)).$offset = u, o.$x.$localOffset = r;
|
|
264
|
+
} else o = this.utc();
|
|
265
|
+
|
|
266
|
+
return o;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
var h = u.format;
|
|
270
|
+
u.format = function (t) {
|
|
271
|
+
var i = t || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
|
|
272
|
+
return h.call(this, i);
|
|
273
|
+
}, u.valueOf = function () {
|
|
274
|
+
var t = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || new Date().getTimezoneOffset());
|
|
275
|
+
return this.$d.valueOf() - 6e4 * t;
|
|
276
|
+
}, u.isUTC = function () {
|
|
277
|
+
return !!this.$u;
|
|
278
|
+
}, u.toISOString = function () {
|
|
279
|
+
return this.toDate().toISOString();
|
|
280
|
+
}, u.toString = function () {
|
|
281
|
+
return this.toDate().toUTCString();
|
|
282
|
+
};
|
|
283
|
+
var l = u.toDate;
|
|
284
|
+
|
|
285
|
+
u.toDate = function (t) {
|
|
286
|
+
return "s" === t && this.$offset ? n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l.call(this);
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
var c = u.diff;
|
|
290
|
+
|
|
291
|
+
u.diff = function (t, i, e) {
|
|
292
|
+
if (t && this.$u === t.$u) return c.call(this, t, i, e);
|
|
293
|
+
var s = this.local(),
|
|
294
|
+
f = n(t).local();
|
|
295
|
+
return c.call(s, f, i, e);
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
dayjs.extend(utc);
|
|
302
|
+
function formatNum(val) {
|
|
303
|
+
var num = parseFloat(val);
|
|
304
|
+
return isNaN(num) ? undefined : num;
|
|
305
|
+
}
|
|
306
|
+
function isNullLike(val) {
|
|
307
|
+
return val === undefined || val === null;
|
|
308
|
+
}
|
|
309
|
+
function emptyValidator(val, enableEmpty) {
|
|
310
|
+
return !enableEmpty && (isNullLike(val) || val instanceof Array && !val.length || typeof val === 'string' && !val) ? 'should not be empty' : '';
|
|
311
|
+
}
|
|
312
|
+
function numRangeValidator(val, enableEmpty) {
|
|
313
|
+
var error = emptyValidator(val === null || val === void 0 ? void 0 : val.min, enableEmpty);
|
|
314
|
+
if (error) return {
|
|
315
|
+
min: error
|
|
316
|
+
};
|
|
317
|
+
error = emptyValidator(val === null || val === void 0 ? void 0 : val.max, enableEmpty);
|
|
318
|
+
if (error) return {
|
|
319
|
+
max: error
|
|
320
|
+
};
|
|
321
|
+
return val.min > val.max ? 'Max should bigger than Min' : '';
|
|
322
|
+
}
|
|
323
|
+
function expiryValidator(val, enableEmpty) {
|
|
324
|
+
var error = emptyValidator(val, enableEmpty);
|
|
325
|
+
if (error) return error;
|
|
326
|
+
var $val = dayjs(val, 'DDMMMYY').format('DDMMMYY').toUpperCase();
|
|
327
|
+
if ($val !== val) return 'out of format';
|
|
328
|
+
return '';
|
|
329
|
+
}
|
|
330
|
+
function expiriesValidator(val, enableEmpty) {
|
|
331
|
+
var error = emptyValidator(val, enableEmpty);
|
|
332
|
+
if (error) return error;
|
|
333
|
+
|
|
334
|
+
for (var i = 0; i < val.length; i++) {
|
|
335
|
+
error = expiryValidator(val[i]);
|
|
336
|
+
if (error) return _defineProperty({}, i, error);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return '';
|
|
340
|
+
}
|
|
341
|
+
function isExpired(val) {
|
|
342
|
+
var now = dayjs();
|
|
343
|
+
var expireTime = dayjs.utc("".concat(val, " 8:00"), 'DDMMMYY 8:00');
|
|
344
|
+
return now >= expireTime;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var Bool = /*#__PURE__*/function (_PureComponent) {
|
|
348
|
+
_inherits(Bool, _PureComponent);
|
|
349
|
+
|
|
350
|
+
var _super = _createSuper(Bool);
|
|
351
|
+
|
|
352
|
+
function Bool() {
|
|
353
|
+
var _this;
|
|
354
|
+
|
|
355
|
+
_classCallCheck(this, Bool);
|
|
356
|
+
|
|
357
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
358
|
+
args[_key] = arguments[_key];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
362
|
+
|
|
363
|
+
_defineProperty(_assertThisInitialized(_this), "options", [{
|
|
364
|
+
label: 'TRUE',
|
|
365
|
+
value: true
|
|
366
|
+
}, {
|
|
367
|
+
label: 'FALSE',
|
|
368
|
+
value: false
|
|
369
|
+
}]);
|
|
370
|
+
|
|
371
|
+
_defineProperty(_assertThisInitialized(_this), "RadioChecked", /*#__PURE__*/React.createElement("svg", {
|
|
372
|
+
width: "16",
|
|
373
|
+
height: "17",
|
|
374
|
+
viewBox: "0 0 16 17",
|
|
375
|
+
fill: "none",
|
|
376
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
377
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
378
|
+
clipPath: "url(#clip0_0_7934)"
|
|
379
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
380
|
+
cx: "8",
|
|
381
|
+
cy: "8.5",
|
|
382
|
+
r: "7.5",
|
|
383
|
+
fill: "none",
|
|
384
|
+
stroke: "currentColor"
|
|
385
|
+
}), /*#__PURE__*/React.createElement("circle", {
|
|
386
|
+
cx: "8",
|
|
387
|
+
cy: "8.5",
|
|
388
|
+
r: "4",
|
|
389
|
+
fill: "currentColor"
|
|
390
|
+
})), /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
|
391
|
+
id: "clip0_0_7934"
|
|
392
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
393
|
+
width: "16",
|
|
394
|
+
height: "16",
|
|
395
|
+
fill: "white",
|
|
396
|
+
transform: "translate(0 0.5)"
|
|
397
|
+
})))));
|
|
398
|
+
|
|
399
|
+
_defineProperty(_assertThisInitialized(_this), "RadioUnchecked", /*#__PURE__*/React.createElement("svg", {
|
|
400
|
+
width: "16",
|
|
401
|
+
height: "17",
|
|
402
|
+
viewBox: "0 0 16 17",
|
|
403
|
+
fill: "none",
|
|
404
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
405
|
+
}, /*#__PURE__*/React.createElement("circle", {
|
|
406
|
+
cx: "8",
|
|
407
|
+
cy: "8.5",
|
|
408
|
+
r: "7.5",
|
|
409
|
+
fill: "none",
|
|
410
|
+
stroke: "currentColor"
|
|
411
|
+
})));
|
|
412
|
+
|
|
413
|
+
return _this;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
_createClass(Bool, [{
|
|
417
|
+
key: "render",
|
|
418
|
+
value: function render() {
|
|
419
|
+
var _this2 = this;
|
|
420
|
+
|
|
421
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
422
|
+
className: classNames('param-bool', {
|
|
423
|
+
readonly: this.props.readonly
|
|
424
|
+
}, this.props.className),
|
|
425
|
+
style: this.props.style
|
|
426
|
+
}, this.props.readonly ? /*#__PURE__*/React.createElement("span", {
|
|
427
|
+
className: "param-bool-val"
|
|
428
|
+
}, !isNullLike(this.props.value) ? String(this.props.value).toUpperCase() : '-') : this.options.map(function (it) {
|
|
429
|
+
var _this2$props$onChange;
|
|
430
|
+
|
|
431
|
+
var active = it.value === _this2.props.value;
|
|
432
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
433
|
+
key: String(it.value),
|
|
434
|
+
className: classNames('param-bool-option', {
|
|
435
|
+
active: active
|
|
436
|
+
}),
|
|
437
|
+
onClick: (_this2$props$onChange = _this2.props.onChange) === null || _this2$props$onChange === void 0 ? void 0 : _this2$props$onChange.bind(null, it.value)
|
|
438
|
+
}, active ? _this2.RadioChecked : _this2.RadioUnchecked, it.label);
|
|
439
|
+
}));
|
|
440
|
+
}
|
|
441
|
+
}]);
|
|
442
|
+
|
|
443
|
+
return Bool;
|
|
444
|
+
}(PureComponent);
|
|
445
|
+
|
|
446
|
+
var NumCvt = /*#__PURE__*/function () {
|
|
447
|
+
function NumCvt() {
|
|
448
|
+
_classCallCheck(this, NumCvt);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
_createClass(NumCvt, null, [{
|
|
452
|
+
key: "show",
|
|
453
|
+
value: function show(val, isPercentage) {
|
|
454
|
+
if (val && isPercentage) return Big(val).times(100).valueOf();
|
|
455
|
+
return val;
|
|
456
|
+
}
|
|
457
|
+
}, {
|
|
458
|
+
key: "emit",
|
|
459
|
+
value: function emit(val, isPercentage) {
|
|
460
|
+
if (!val || !isPercentage) return +val;
|
|
461
|
+
return +Big(val).div(100);
|
|
462
|
+
}
|
|
463
|
+
}]);
|
|
464
|
+
|
|
465
|
+
return NumCvt;
|
|
466
|
+
}();
|
|
467
|
+
|
|
468
|
+
function initState(props) {
|
|
469
|
+
return {
|
|
470
|
+
preProps: props,
|
|
471
|
+
tempValue: NumCvt.show(props.value, props.isPercentage)
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
var Num = /*#__PURE__*/function (_PureComponent) {
|
|
476
|
+
_inherits(Num, _PureComponent);
|
|
477
|
+
|
|
478
|
+
var _super = _createSuper(Num);
|
|
479
|
+
|
|
480
|
+
function Num() {
|
|
481
|
+
var _this;
|
|
482
|
+
|
|
483
|
+
_classCallCheck(this, Num);
|
|
484
|
+
|
|
485
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
486
|
+
args[_key] = arguments[_key];
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
490
|
+
|
|
491
|
+
_defineProperty(_assertThisInitialized(_this), "state", initState(_this.props));
|
|
492
|
+
|
|
493
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (e) {
|
|
494
|
+
var _this$props$onChange, _this$props;
|
|
495
|
+
|
|
496
|
+
var $value = e.target.value;
|
|
497
|
+
var $val = $value.replace(/^(-?\d+(\.\d*)?|-?\d*).*$/, '$1');
|
|
498
|
+
if ($val !== $value) e.target.value = $val;
|
|
499
|
+
var value = NumCvt.emit($val, _this.props.isPercentage);
|
|
500
|
+
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);else _this.setState(function (pre) {
|
|
501
|
+
return _objectSpread2(_objectSpread2({}, pre), {}, {
|
|
502
|
+
tempValue: e.target.value
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
return _this;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
_createClass(Num, [{
|
|
511
|
+
key: "render",
|
|
512
|
+
value: function render() {
|
|
513
|
+
var _this$state$tempValue;
|
|
514
|
+
|
|
515
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
516
|
+
className: classNames('param-number', {
|
|
517
|
+
readonly: this.props.readonly
|
|
518
|
+
}, this.props.className),
|
|
519
|
+
style: this.props.style
|
|
520
|
+
}, this.props.readonly ? /*#__PURE__*/React.createElement("span", {
|
|
521
|
+
className: "param-number-val"
|
|
522
|
+
}, (_this$state$tempValue = this.state.tempValue) !== null && _this$state$tempValue !== void 0 ? _this$state$tempValue : '-') : /*#__PURE__*/React.createElement("input", {
|
|
523
|
+
className: "param-number-val",
|
|
524
|
+
type: "text",
|
|
525
|
+
placeholder: this.props.placeholder || 'Value',
|
|
526
|
+
value: this.state.tempValue || '',
|
|
527
|
+
onChange: this.onChange
|
|
528
|
+
}), this.props.isPercentage && /*#__PURE__*/React.createElement("span", {
|
|
529
|
+
className: "param-number-suffix"
|
|
530
|
+
}, "%"));
|
|
531
|
+
}
|
|
532
|
+
}], [{
|
|
533
|
+
key: "getDerivedStateFromProps",
|
|
534
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
535
|
+
if (props.value !== state.preProps.value) {
|
|
536
|
+
state.tempValue = NumCvt.show(props.value, props.isPercentage);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
540
|
+
preProps: props
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}]);
|
|
544
|
+
|
|
545
|
+
return Num;
|
|
546
|
+
}(PureComponent);
|
|
547
|
+
|
|
548
|
+
var NumRange = /*#__PURE__*/function (_PureComponent) {
|
|
549
|
+
_inherits(NumRange, _PureComponent);
|
|
550
|
+
|
|
551
|
+
var _super = _createSuper(NumRange);
|
|
552
|
+
|
|
553
|
+
function NumRange() {
|
|
554
|
+
var _this;
|
|
555
|
+
|
|
556
|
+
_classCallCheck(this, NumRange);
|
|
557
|
+
|
|
558
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
559
|
+
args[_key] = arguments[_key];
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
563
|
+
|
|
564
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (key, val) {
|
|
565
|
+
var _this$props$onChange, _this$props;
|
|
566
|
+
|
|
567
|
+
var value = _objectSpread2({}, _this.props.value);
|
|
568
|
+
|
|
569
|
+
value[key] = val;
|
|
570
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
return _this;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
_createClass(NumRange, [{
|
|
577
|
+
key: "render",
|
|
578
|
+
value: function render() {
|
|
579
|
+
var _this$props$value, _this$props$value2;
|
|
580
|
+
|
|
581
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
582
|
+
className: classNames('param-number-range', {
|
|
583
|
+
readonly: this.props.readonly
|
|
584
|
+
}, this.props.className),
|
|
585
|
+
style: this.props.style
|
|
586
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
587
|
+
className: "param-number-range-prefix"
|
|
588
|
+
}, "Min"), /*#__PURE__*/React.createElement(Num, {
|
|
589
|
+
placeholder: 'Min',
|
|
590
|
+
value: (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.min,
|
|
591
|
+
onChange: this.onChange.bind(null, 'min'),
|
|
592
|
+
isPercentage: this.props.isPercentage,
|
|
593
|
+
readonly: this.props.readonly
|
|
594
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
595
|
+
className: "param-number-range-sep"
|
|
596
|
+
}, this.props.readonly ? ',' : '-'), /*#__PURE__*/React.createElement("span", {
|
|
597
|
+
className: "param-number-range-prefix"
|
|
598
|
+
}, "Max"), /*#__PURE__*/React.createElement(Num, {
|
|
599
|
+
placeholder: 'Max',
|
|
600
|
+
value: (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2.max,
|
|
601
|
+
onChange: this.onChange.bind(null, 'max'),
|
|
602
|
+
isPercentage: this.props.isPercentage,
|
|
603
|
+
readonly: this.props.readonly
|
|
604
|
+
}));
|
|
605
|
+
}
|
|
606
|
+
}]);
|
|
607
|
+
|
|
608
|
+
return NumRange;
|
|
609
|
+
}(PureComponent);
|
|
610
|
+
|
|
611
|
+
function _arrayLikeToArray(arr, len) {
|
|
612
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
613
|
+
|
|
614
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
615
|
+
arr2[i] = arr[i];
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
return arr2;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function _arrayWithoutHoles(arr) {
|
|
622
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function _iterableToArray(iter) {
|
|
626
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
630
|
+
if (!o) return;
|
|
631
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
632
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
633
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
634
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
635
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function _nonIterableSpread() {
|
|
639
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function _toConsumableArray(arr) {
|
|
643
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
var TextArray = /*#__PURE__*/function (_PureComponent) {
|
|
647
|
+
_inherits(TextArray, _PureComponent);
|
|
648
|
+
|
|
649
|
+
var _super = _createSuper(TextArray);
|
|
650
|
+
|
|
651
|
+
function TextArray() {
|
|
652
|
+
var _this;
|
|
653
|
+
|
|
654
|
+
_classCallCheck(this, TextArray);
|
|
655
|
+
|
|
656
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
657
|
+
args[_key] = arguments[_key];
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
661
|
+
|
|
662
|
+
_defineProperty(_assertThisInitialized(_this), "value", []);
|
|
663
|
+
|
|
664
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (i, e) {
|
|
665
|
+
var _this$props$onChange, _this$props;
|
|
666
|
+
|
|
667
|
+
var val = e.target.value;
|
|
668
|
+
|
|
669
|
+
var value = _toConsumableArray(_this.value);
|
|
670
|
+
|
|
671
|
+
value[i] = val;
|
|
672
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
_defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
|
|
676
|
+
var _this$props$onChange2, _this$props2;
|
|
677
|
+
|
|
678
|
+
var value = _toConsumableArray(_this.value);
|
|
679
|
+
|
|
680
|
+
value.splice(i + 1, 0, '');
|
|
681
|
+
(_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value);
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
_defineProperty(_assertThisInitialized(_this), "onDel", function (i) {
|
|
685
|
+
var _this$props$onChange3, _this$props3;
|
|
686
|
+
|
|
687
|
+
var value = _toConsumableArray(_this.value);
|
|
688
|
+
|
|
689
|
+
value.splice(i, 1);
|
|
690
|
+
(_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
return _this;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
_createClass(TextArray, [{
|
|
697
|
+
key: "render",
|
|
698
|
+
value: function render() {
|
|
699
|
+
var _this2 = this;
|
|
700
|
+
|
|
701
|
+
this.value = this.props.value || [];
|
|
702
|
+
if (!this.value.length) this.value.push('');
|
|
703
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
704
|
+
className: classNames('param-text-array', {
|
|
705
|
+
readonly: this.props.readonly
|
|
706
|
+
}, this.props.className),
|
|
707
|
+
style: this.props.style
|
|
708
|
+
}, this.props.readonly ? /*#__PURE__*/React.createElement("span", {
|
|
709
|
+
className: "param-text-array-val"
|
|
710
|
+
}, this.value.filter(Boolean).join(', ') || '-') : this.value.map(function (it, i) {
|
|
711
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
712
|
+
className: "param-arr-item",
|
|
713
|
+
key: i
|
|
714
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
715
|
+
type: "text",
|
|
716
|
+
placeholder: "Phone",
|
|
717
|
+
value: it,
|
|
718
|
+
onChange: _this2.onChange.bind(null, i)
|
|
719
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
720
|
+
className: "param-arr-ops"
|
|
721
|
+
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
722
|
+
className: "param-arr-ops-add",
|
|
723
|
+
onClick: _this2.onAdd.bind(null, i)
|
|
724
|
+
}), /*#__PURE__*/React.createElement(DeleteOutlined, {
|
|
725
|
+
className: "param-arr-ops-del",
|
|
726
|
+
onClick: _this2.onDel.bind(null, i)
|
|
727
|
+
})));
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
}]);
|
|
731
|
+
|
|
732
|
+
return TextArray;
|
|
733
|
+
}(PureComponent);
|
|
734
|
+
|
|
735
|
+
var Expiries = /*#__PURE__*/function (_PureComponent) {
|
|
736
|
+
_inherits(Expiries, _PureComponent);
|
|
737
|
+
|
|
738
|
+
var _super = _createSuper(Expiries);
|
|
739
|
+
|
|
740
|
+
function Expiries() {
|
|
741
|
+
var _this;
|
|
742
|
+
|
|
743
|
+
_classCallCheck(this, Expiries);
|
|
744
|
+
|
|
745
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
746
|
+
args[_key] = arguments[_key];
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
750
|
+
|
|
751
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
752
|
+
visible: false
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
_defineProperty(_assertThisInitialized(_this), "handleVisibleChange", function (visible) {
|
|
756
|
+
return _this.setState({
|
|
757
|
+
visible: visible
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (val) {
|
|
762
|
+
var _this$props$onChange, _this$props;
|
|
763
|
+
|
|
764
|
+
var value = _toConsumableArray(_this.props.value || []);
|
|
765
|
+
|
|
766
|
+
var index = value.findIndex(function (it) {
|
|
767
|
+
return it === val;
|
|
768
|
+
});
|
|
769
|
+
if (index > -1) value.splice(index, 1);else value.push(val);
|
|
770
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
771
|
+
if (_this.props.multiple === false) _this.handleVisibleChange(false);
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
return _this;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
_createClass(Expiries, [{
|
|
778
|
+
key: "renderValue",
|
|
779
|
+
value: function renderValue() {
|
|
780
|
+
var _this$props$value;
|
|
781
|
+
|
|
782
|
+
var value = (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
783
|
+
return it && !isExpired(it);
|
|
784
|
+
});
|
|
785
|
+
|
|
786
|
+
if (this.props.readonly) {
|
|
787
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
788
|
+
className: "param-expiries-val"
|
|
789
|
+
}, (value === null || value === void 0 ? void 0 : value.join(', ')) || '-');
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
var placeholder = /*#__PURE__*/React.createElement("span", {
|
|
793
|
+
className: "param-expiries-placeholder"
|
|
794
|
+
}, "Choose an expiry");
|
|
795
|
+
|
|
796
|
+
if (this.props.multiple === false) {
|
|
797
|
+
var _this$props$value2;
|
|
798
|
+
|
|
799
|
+
var _val = (_this$props$value2 = this.props.value) === null || _this$props$value2 === void 0 ? void 0 : _this$props$value2[0];
|
|
800
|
+
|
|
801
|
+
return !_val || isExpired(_val) ? placeholder : /*#__PURE__*/React.createElement("span", {
|
|
802
|
+
className: "param-expiries-val"
|
|
803
|
+
}, _val);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (!(value === null || value === void 0 ? void 0 : value.length)) return placeholder;
|
|
807
|
+
return value.map(function (it) {
|
|
808
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
809
|
+
className: "param-expiries-multi-val",
|
|
810
|
+
key: it
|
|
811
|
+
}, it);
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
}, {
|
|
815
|
+
key: "render",
|
|
816
|
+
value: function render() {
|
|
817
|
+
var _this$props$options,
|
|
818
|
+
_this2 = this;
|
|
819
|
+
|
|
820
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
821
|
+
overlayClassName: "param-expiries-popover",
|
|
822
|
+
trigger: 'click',
|
|
823
|
+
placement: 'bottomLeft',
|
|
824
|
+
visible: !this.props.readonly && this.state.visible,
|
|
825
|
+
onVisibleChange: this.handleVisibleChange,
|
|
826
|
+
content: (_this$props$options = this.props.options) === null || _this$props$options === void 0 ? void 0 : _this$props$options.map(function (it) {
|
|
827
|
+
var _this2$props$value, _this2$onChange;
|
|
828
|
+
|
|
829
|
+
var checked = (_this2$props$value = _this2.props.value) === null || _this2$props$value === void 0 ? void 0 : _this2$props$value.includes(it);
|
|
830
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
831
|
+
className: classNames('param-expiries-option', {
|
|
832
|
+
'param-expiries-option-checked': checked
|
|
833
|
+
}),
|
|
834
|
+
key: it,
|
|
835
|
+
onClick: (_this2$onChange = _this2.onChange) === null || _this2$onChange === void 0 ? void 0 : _this2$onChange.bind(null, it)
|
|
836
|
+
}, it, checked && /*#__PURE__*/React.createElement(CheckOutlined, null));
|
|
837
|
+
})
|
|
838
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
839
|
+
className: classNames('param-expiries', {
|
|
840
|
+
readonly: this.props.readonly
|
|
841
|
+
}, this.props.className),
|
|
842
|
+
style: this.props.style
|
|
843
|
+
}, this.renderValue(), !this.props.readonly && this.props.options && /*#__PURE__*/React.createElement(DownOutlined, {
|
|
844
|
+
className: "param-expiries-arrow"
|
|
845
|
+
})));
|
|
846
|
+
}
|
|
847
|
+
}]);
|
|
848
|
+
|
|
849
|
+
return Expiries;
|
|
850
|
+
}(PureComponent);
|
|
851
|
+
|
|
852
|
+
var ExpiriesLimit = /*#__PURE__*/function (_PureComponent) {
|
|
853
|
+
_inherits(ExpiriesLimit, _PureComponent);
|
|
854
|
+
|
|
855
|
+
var _super = _createSuper(ExpiriesLimit);
|
|
856
|
+
|
|
857
|
+
function ExpiriesLimit() {
|
|
858
|
+
var _this;
|
|
859
|
+
|
|
860
|
+
_classCallCheck(this, ExpiriesLimit);
|
|
861
|
+
|
|
862
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
863
|
+
args[_key] = arguments[_key];
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
867
|
+
|
|
868
|
+
_defineProperty(_assertThisInitialized(_this), "value", []);
|
|
869
|
+
|
|
870
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (i, val, key) {
|
|
871
|
+
var _this$props$onChange, _this$props;
|
|
872
|
+
|
|
873
|
+
var value = _toConsumableArray(_this.value);
|
|
874
|
+
|
|
875
|
+
if (!value[i]) value[i] = {
|
|
876
|
+
expiry: ''
|
|
877
|
+
};
|
|
878
|
+
if (key) value[i][key] = val;else value[i] = _objectSpread2(_objectSpread2({}, value[i]), val);
|
|
879
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
_defineProperty(_assertThisInitialized(_this), "onAdd", function (i) {
|
|
883
|
+
var _this$props$onChange2, _this$props2;
|
|
884
|
+
|
|
885
|
+
var value = _toConsumableArray(_this.value);
|
|
886
|
+
|
|
887
|
+
value.splice(i + 1, 0, {
|
|
888
|
+
expiry: ''
|
|
889
|
+
});
|
|
890
|
+
(_this$props$onChange2 = (_this$props2 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props2, value);
|
|
891
|
+
});
|
|
892
|
+
|
|
893
|
+
_defineProperty(_assertThisInitialized(_this), "onDel", function (i) {
|
|
894
|
+
var _this$props$onChange3, _this$props3;
|
|
895
|
+
|
|
896
|
+
var value = _toConsumableArray(_this.value);
|
|
897
|
+
|
|
898
|
+
value.splice(i, 1);
|
|
899
|
+
(_this$props$onChange3 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props3, value);
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
return _this;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
_createClass(ExpiriesLimit, [{
|
|
906
|
+
key: "render",
|
|
907
|
+
value: function render() {
|
|
908
|
+
var _this$props$value,
|
|
909
|
+
_this2 = this;
|
|
910
|
+
|
|
911
|
+
this.value = ((_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value.filter(function (it) {
|
|
912
|
+
return (it === null || it === void 0 ? void 0 : it.expiry) && !isExpired(it.expiry);
|
|
913
|
+
})) || [];
|
|
914
|
+
if (!this.value.length) this.value.push({
|
|
915
|
+
expiry: ''
|
|
916
|
+
});
|
|
917
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
918
|
+
className: classNames('param-expiries-limit', {
|
|
919
|
+
readonly: this.props.readonly
|
|
920
|
+
}, this.props.className),
|
|
921
|
+
style: this.props.style
|
|
922
|
+
}, this.props.readonly ? this.value.filter(function (it) {
|
|
923
|
+
return it.expiry;
|
|
924
|
+
}).map(function (it, i) {
|
|
925
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
926
|
+
className: "param-expiries-limit-val",
|
|
927
|
+
key: i
|
|
928
|
+
}, it.expiry, " /", ' ', it.minAumPercentage && it.maxAumPercentage ? "(".concat(NumCvt.show(it.minAumPercentage, true), "%, ").concat(NumCvt.show(it.maxAumPercentage, true), "%)") : '-', ' ', "/", ' ', it.minAbs && it.maxAbs ? "(".concat(it.minAbs, ", ").concat(it.maxAbs, ")") : '-', ";");
|
|
929
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
930
|
+
className: "param-expiries-limit-inputs"
|
|
931
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
932
|
+
className: "param-expiries readonly"
|
|
933
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
934
|
+
className: "param-expiries-val"
|
|
935
|
+
}, "Expiry")), /*#__PURE__*/React.createElement("div", {
|
|
936
|
+
className: "param-number-range readonly"
|
|
937
|
+
}, "Limit(% of AUM)"), /*#__PURE__*/React.createElement("div", {
|
|
938
|
+
className: "param-number-range readonly"
|
|
939
|
+
}, "Limit(ABS)"), /*#__PURE__*/React.createElement("div", {
|
|
940
|
+
className: "param-arr-ops readonly"
|
|
941
|
+
}), this.value.map(function (it, i) {
|
|
942
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
943
|
+
key: i
|
|
944
|
+
}, /*#__PURE__*/React.createElement(Expiries, {
|
|
945
|
+
multiple: false,
|
|
946
|
+
options: _this2.props.options,
|
|
947
|
+
value: [it.expiry],
|
|
948
|
+
onChange: function onChange(val) {
|
|
949
|
+
return _this2.onChange(i, val[0], 'expiry');
|
|
950
|
+
}
|
|
951
|
+
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
952
|
+
value: {
|
|
953
|
+
min: it.minAumPercentage,
|
|
954
|
+
max: it.maxAumPercentage
|
|
955
|
+
},
|
|
956
|
+
onChange: function onChange(val) {
|
|
957
|
+
return _this2.onChange(i, {
|
|
958
|
+
minAumPercentage: val === null || val === void 0 ? void 0 : val.min,
|
|
959
|
+
maxAumPercentage: val === null || val === void 0 ? void 0 : val.max
|
|
960
|
+
});
|
|
961
|
+
},
|
|
962
|
+
isPercentage: true
|
|
963
|
+
}), /*#__PURE__*/React.createElement(NumRange, {
|
|
964
|
+
value: {
|
|
965
|
+
min: it.minAbs,
|
|
966
|
+
max: it.maxAbs
|
|
967
|
+
},
|
|
968
|
+
onChange: function onChange(val) {
|
|
969
|
+
return _this2.onChange(i, {
|
|
970
|
+
minAbs: val === null || val === void 0 ? void 0 : val.min,
|
|
971
|
+
maxAbs: val === null || val === void 0 ? void 0 : val.max
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
975
|
+
className: "param-arr-ops"
|
|
976
|
+
}, /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
977
|
+
className: "param-arr-ops-add",
|
|
978
|
+
onClick: _this2.onAdd.bind(null, i)
|
|
979
|
+
}), /*#__PURE__*/React.createElement(DeleteOutlined, {
|
|
980
|
+
className: "param-arr-ops-del",
|
|
981
|
+
onClick: _this2.onDel.bind(null, i)
|
|
982
|
+
})));
|
|
983
|
+
})));
|
|
984
|
+
}
|
|
985
|
+
}]);
|
|
986
|
+
|
|
987
|
+
return ExpiriesLimit;
|
|
988
|
+
}(PureComponent);
|
|
989
|
+
|
|
990
|
+
var _ParamTypeConfig;
|
|
991
|
+
var ParamTypeConfig = (_ParamTypeConfig = {}, _defineProperty(_ParamTypeConfig, ParamType.ParamGroup, {
|
|
992
|
+
name: '参数组',
|
|
993
|
+
Comp: function Comp() {
|
|
994
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
995
|
+
}
|
|
996
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.Number, {
|
|
997
|
+
name: '普通数值',
|
|
998
|
+
key: 'number',
|
|
999
|
+
Comp: Num,
|
|
1000
|
+
validator: emptyValidator
|
|
1001
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.Percentage, {
|
|
1002
|
+
name: '百分比数值',
|
|
1003
|
+
key: 'number',
|
|
1004
|
+
Comp: function Comp(props) {
|
|
1005
|
+
return /*#__PURE__*/React.createElement(Num, Object.assign({}, props, {
|
|
1006
|
+
isPercentage: true
|
|
1007
|
+
}));
|
|
1008
|
+
},
|
|
1009
|
+
validator: emptyValidator
|
|
1010
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.Bool, {
|
|
1011
|
+
name: 'TRUE/FALSE',
|
|
1012
|
+
key: 'bool',
|
|
1013
|
+
Comp: Bool,
|
|
1014
|
+
validator: emptyValidator
|
|
1015
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.NumberRange, {
|
|
1016
|
+
name: '数值范围',
|
|
1017
|
+
key: 'range',
|
|
1018
|
+
Comp: NumRange,
|
|
1019
|
+
validator: numRangeValidator
|
|
1020
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.PercentageRange, {
|
|
1021
|
+
name: '百分比范围',
|
|
1022
|
+
key: 'range',
|
|
1023
|
+
Comp: function Comp(props) {
|
|
1024
|
+
return /*#__PURE__*/React.createElement(NumRange, Object.assign({}, props, {
|
|
1025
|
+
isPercentage: true
|
|
1026
|
+
}));
|
|
1027
|
+
},
|
|
1028
|
+
validator: numRangeValidator
|
|
1029
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.ExpiryLimit, {
|
|
1030
|
+
name: '到期日 Limit',
|
|
1031
|
+
key: 'expiryLimitList',
|
|
1032
|
+
Comp: ExpiriesLimit,
|
|
1033
|
+
validator: function validator(val, enableEmpty) {
|
|
1034
|
+
var error = emptyValidator(val, enableEmpty);
|
|
1035
|
+
if (error) return error;
|
|
1036
|
+
|
|
1037
|
+
for (var i = 0; i < val.length; i++) {
|
|
1038
|
+
error = expiryValidator(val === null || val === void 0 ? void 0 : val.expiry);
|
|
1039
|
+
if (error) return _defineProperty({}, i, {
|
|
1040
|
+
expire: error
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
if (isNullLike(val === null || val === void 0 ? void 0 : val.minAumPercentage) && isNullLike(val === null || val === void 0 ? void 0 : val.maxAumPercentage) && isNullLike(val === null || val === void 0 ? void 0 : val.minAbs) && isNullLike(val === null || val === void 0 ? void 0 : val.maxAbs)) {
|
|
1044
|
+
return _defineProperty({}, i, 'at least one parameter must be specified between AUM and ABS');
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
if (val.minAbs > val.maxAbs) return _defineProperty({}, i, {
|
|
1048
|
+
minAbs: 'Min ABS should smaller than Max ABS'
|
|
1049
|
+
});
|
|
1050
|
+
|
|
1051
|
+
if (val.minAumPercentage > val.maxAumPercentage) {
|
|
1052
|
+
return _defineProperty({}, i, {
|
|
1053
|
+
minAumPercentage: 'Min AUM should smaller than Max AUM'
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return '';
|
|
1059
|
+
}
|
|
1060
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.Expiry, {
|
|
1061
|
+
name: '到期日',
|
|
1062
|
+
key: 'list',
|
|
1063
|
+
Comp: Expiries,
|
|
1064
|
+
validator: expiriesValidator
|
|
1065
|
+
}), _defineProperty(_ParamTypeConfig, ParamType.Phone, {
|
|
1066
|
+
name: '联系人电话',
|
|
1067
|
+
key: 'list',
|
|
1068
|
+
Comp: TextArray,
|
|
1069
|
+
validator: emptyValidator
|
|
1070
|
+
}), _ParamTypeConfig);
|
|
1071
|
+
|
|
1072
|
+
var ParamRenderer = /*#__PURE__*/function (_PureComponent) {
|
|
1073
|
+
_inherits(ParamRenderer, _PureComponent);
|
|
1074
|
+
|
|
1075
|
+
var _super = _createSuper(ParamRenderer);
|
|
1076
|
+
|
|
1077
|
+
function ParamRenderer() {
|
|
1078
|
+
var _this;
|
|
1079
|
+
|
|
1080
|
+
_classCallCheck(this, ParamRenderer);
|
|
1081
|
+
|
|
1082
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1083
|
+
args[_key] = arguments[_key];
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
1087
|
+
|
|
1088
|
+
_defineProperty(_assertThisInitialized(_this), "onChange", function (val) {
|
|
1089
|
+
var _this$props$onChange, _this$props;
|
|
1090
|
+
|
|
1091
|
+
var value = _this.typeConfig.key ? _objectSpread2(_objectSpread2({}, _this.props.value), {}, _defineProperty({}, _this.typeConfig.key, val)) : val;
|
|
1092
|
+
(_this$props$onChange = (_this$props = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, value);
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1095
|
+
return _this;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
_createClass(ParamRenderer, [{
|
|
1099
|
+
key: "typeConfig",
|
|
1100
|
+
get: function get() {
|
|
1101
|
+
return ParamTypeConfig[this.props.valueType] || ParamTypeConfig[ParamType.Number];
|
|
1102
|
+
}
|
|
1103
|
+
}, {
|
|
1104
|
+
key: "value",
|
|
1105
|
+
get: function get() {
|
|
1106
|
+
var _this$props$value;
|
|
1107
|
+
|
|
1108
|
+
return this.typeConfig.key ? (_this$props$value = this.props.value) === null || _this$props$value === void 0 ? void 0 : _this$props$value[this.typeConfig.key] : this.props.value;
|
|
1109
|
+
}
|
|
1110
|
+
}, {
|
|
1111
|
+
key: "render",
|
|
1112
|
+
value: function render() {
|
|
1113
|
+
var Comp = this.typeConfig.Comp;
|
|
1114
|
+
return /*#__PURE__*/React.createElement(Comp, Object.assign({}, this.props, {
|
|
1115
|
+
value: this.value,
|
|
1116
|
+
onChange: this.onChange,
|
|
1117
|
+
className: classNames('param-renderer', this.props.className)
|
|
1118
|
+
}));
|
|
1119
|
+
}
|
|
1120
|
+
}]);
|
|
1121
|
+
|
|
1122
|
+
return ParamRenderer;
|
|
1123
|
+
}(PureComponent);
|
|
1124
|
+
|
|
1125
|
+
export { ParamRenderer, ParamType, ParamTypeConfig, emptyValidator, expiriesValidator, expiryValidator, formatNum, isExpired, isNullLike, numRangeValidator };
|