amis-formula 1.2.8 → 1.3.2

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * amis-formula v1.2.8
2
+ * amis-formula v1.3.2
3
3
  * Copyright 2021 fex
4
4
  */
5
5
 
@@ -9,6 +9,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
10
  var tslib = require('tslib');
11
11
  var moment = require('moment');
12
+ var upperFirst = require('lodash/upperFirst');
13
+ var padStart = require('lodash/padStart');
14
+ var capitalize = require('lodash/capitalize');
15
+ var escape = require('lodash/escape');
16
+ var truncate = require('lodash/truncate');
12
17
  var transform = require('lodash/transform');
13
18
  var groupBy = require('lodash/groupBy');
14
19
  var uniqBy = require('lodash/uniqBy');
@@ -18,1166 +23,17 @@ var isPlainObject = require('lodash/isPlainObject');
18
23
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
24
 
20
25
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
26
+ var upperFirst__default = /*#__PURE__*/_interopDefaultLegacy(upperFirst);
27
+ var padStart__default = /*#__PURE__*/_interopDefaultLegacy(padStart);
28
+ var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
29
+ var escape__default = /*#__PURE__*/_interopDefaultLegacy(escape);
30
+ var truncate__default = /*#__PURE__*/_interopDefaultLegacy(truncate);
21
31
  var transform__default = /*#__PURE__*/_interopDefaultLegacy(transform);
22
32
  var groupBy__default = /*#__PURE__*/_interopDefaultLegacy(groupBy);
23
33
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
24
34
  var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
25
35
  var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
26
36
 
27
- /**
28
- * The base implementation of `_.slice` without an iteratee call guard.
29
- *
30
- * @private
31
- * @param {Array} array The array to slice.
32
- * @param {number} [start=0] The start position.
33
- * @param {number} [end=array.length] The end position.
34
- * @returns {Array} Returns the slice of `array`.
35
- */
36
- function baseSlice(array, start, end) {
37
- var index = -1,
38
- length = array.length;
39
-
40
- if (start < 0) {
41
- start = -start > length ? 0 : (length + start);
42
- }
43
- end = end > length ? length : end;
44
- if (end < 0) {
45
- end += length;
46
- }
47
- length = start > end ? 0 : ((end - start) >>> 0);
48
- start >>>= 0;
49
-
50
- var result = Array(length);
51
- while (++index < length) {
52
- result[index] = array[index + start];
53
- }
54
- return result;
55
- }
56
-
57
- var _baseSlice = baseSlice;
58
-
59
- /**
60
- * Casts `array` to a slice if it's needed.
61
- *
62
- * @private
63
- * @param {Array} array The array to inspect.
64
- * @param {number} start The start position.
65
- * @param {number} [end=array.length] The end position.
66
- * @returns {Array} Returns the cast slice.
67
- */
68
- function castSlice(array, start, end) {
69
- var length = array.length;
70
- end = end === undefined ? length : end;
71
- return (!start && end >= length) ? array : _baseSlice(array, start, end);
72
- }
73
-
74
- var _castSlice = castSlice;
75
-
76
- /** Used to compose unicode character classes. */
77
- var rsAstralRange$2 = '\\ud800-\\udfff',
78
- rsComboMarksRange$2 = '\\u0300-\\u036f',
79
- reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f',
80
- rsComboSymbolsRange$2 = '\\u20d0-\\u20ff',
81
- rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2,
82
- rsVarRange$2 = '\\ufe0e\\ufe0f';
83
-
84
- /** Used to compose unicode capture groups. */
85
- var rsZWJ$2 = '\\u200d';
86
-
87
- /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
88
- var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$2 + rsVarRange$2 + ']');
89
-
90
- /**
91
- * Checks if `string` contains Unicode symbols.
92
- *
93
- * @private
94
- * @param {string} string The string to inspect.
95
- * @returns {boolean} Returns `true` if a symbol is found, else `false`.
96
- */
97
- function hasUnicode(string) {
98
- return reHasUnicode.test(string);
99
- }
100
-
101
- var _hasUnicode = hasUnicode;
102
-
103
- /**
104
- * Converts an ASCII `string` to an array.
105
- *
106
- * @private
107
- * @param {string} string The string to convert.
108
- * @returns {Array} Returns the converted array.
109
- */
110
- function asciiToArray(string) {
111
- return string.split('');
112
- }
113
-
114
- var _asciiToArray = asciiToArray;
115
-
116
- /** Used to compose unicode character classes. */
117
- var rsAstralRange$1 = '\\ud800-\\udfff',
118
- rsComboMarksRange$1 = '\\u0300-\\u036f',
119
- reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
120
- rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
121
- rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
122
- rsVarRange$1 = '\\ufe0e\\ufe0f';
123
-
124
- /** Used to compose unicode capture groups. */
125
- var rsAstral$1 = '[' + rsAstralRange$1 + ']',
126
- rsCombo$1 = '[' + rsComboRange$1 + ']',
127
- rsFitz$1 = '\\ud83c[\\udffb-\\udfff]',
128
- rsModifier$1 = '(?:' + rsCombo$1 + '|' + rsFitz$1 + ')',
129
- rsNonAstral$1 = '[^' + rsAstralRange$1 + ']',
130
- rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}',
131
- rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]',
132
- rsZWJ$1 = '\\u200d';
133
-
134
- /** Used to compose unicode regexes. */
135
- var reOptMod$1 = rsModifier$1 + '?',
136
- rsOptVar$1 = '[' + rsVarRange$1 + ']?',
137
- rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*',
138
- rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1,
139
- rsSymbol$1 = '(?:' + [rsNonAstral$1 + rsCombo$1 + '?', rsCombo$1, rsRegional$1, rsSurrPair$1, rsAstral$1].join('|') + ')';
140
-
141
- /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
142
- var reUnicode$1 = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol$1 + rsSeq$1, 'g');
143
-
144
- /**
145
- * Converts a Unicode `string` to an array.
146
- *
147
- * @private
148
- * @param {string} string The string to convert.
149
- * @returns {Array} Returns the converted array.
150
- */
151
- function unicodeToArray(string) {
152
- return string.match(reUnicode$1) || [];
153
- }
154
-
155
- var _unicodeToArray = unicodeToArray;
156
-
157
- /**
158
- * Converts `string` to an array.
159
- *
160
- * @private
161
- * @param {string} string The string to convert.
162
- * @returns {Array} Returns the converted array.
163
- */
164
- function stringToArray(string) {
165
- return _hasUnicode(string)
166
- ? _unicodeToArray(string)
167
- : _asciiToArray(string);
168
- }
169
-
170
- var _stringToArray = stringToArray;
171
-
172
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
173
-
174
- function createCommonjsModule(fn, module) {
175
- return module = { exports: {} }, fn(module, module.exports), module.exports;
176
- }
177
-
178
- /** Detect free variable `global` from Node.js. */
179
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
180
-
181
- var _freeGlobal = freeGlobal;
182
-
183
- /** Detect free variable `self`. */
184
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
185
-
186
- /** Used as a reference to the global object. */
187
- var root = _freeGlobal || freeSelf || Function('return this')();
188
-
189
- var _root = root;
190
-
191
- /** Built-in value references. */
192
- var Symbol = _root.Symbol;
193
-
194
- var _Symbol = Symbol;
195
-
196
- /**
197
- * A specialized version of `_.map` for arrays without support for iteratee
198
- * shorthands.
199
- *
200
- * @private
201
- * @param {Array} [array] The array to iterate over.
202
- * @param {Function} iteratee The function invoked per iteration.
203
- * @returns {Array} Returns the new mapped array.
204
- */
205
- function arrayMap(array, iteratee) {
206
- var index = -1,
207
- length = array == null ? 0 : array.length,
208
- result = Array(length);
209
-
210
- while (++index < length) {
211
- result[index] = iteratee(array[index], index, array);
212
- }
213
- return result;
214
- }
215
-
216
- var _arrayMap = arrayMap;
217
-
218
- /**
219
- * Checks if `value` is classified as an `Array` object.
220
- *
221
- * @static
222
- * @memberOf _
223
- * @since 0.1.0
224
- * @category Lang
225
- * @param {*} value The value to check.
226
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
227
- * @example
228
- *
229
- * _.isArray([1, 2, 3]);
230
- * // => true
231
- *
232
- * _.isArray(document.body.children);
233
- * // => false
234
- *
235
- * _.isArray('abc');
236
- * // => false
237
- *
238
- * _.isArray(_.noop);
239
- * // => false
240
- */
241
- var isArray = Array.isArray;
242
-
243
- var isArray_1 = isArray;
244
-
245
- /** Used for built-in method references. */
246
- var objectProto$1 = Object.prototype;
247
-
248
- /** Used to check objects for own properties. */
249
- var hasOwnProperty = objectProto$1.hasOwnProperty;
250
-
251
- /**
252
- * Used to resolve the
253
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
254
- * of values.
255
- */
256
- var nativeObjectToString$1 = objectProto$1.toString;
257
-
258
- /** Built-in value references. */
259
- var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
260
-
261
- /**
262
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
263
- *
264
- * @private
265
- * @param {*} value The value to query.
266
- * @returns {string} Returns the raw `toStringTag`.
267
- */
268
- function getRawTag(value) {
269
- var isOwn = hasOwnProperty.call(value, symToStringTag$1),
270
- tag = value[symToStringTag$1];
271
-
272
- try {
273
- value[symToStringTag$1] = undefined;
274
- var unmasked = true;
275
- } catch (e) {}
276
-
277
- var result = nativeObjectToString$1.call(value);
278
- if (unmasked) {
279
- if (isOwn) {
280
- value[symToStringTag$1] = tag;
281
- } else {
282
- delete value[symToStringTag$1];
283
- }
284
- }
285
- return result;
286
- }
287
-
288
- var _getRawTag = getRawTag;
289
-
290
- /** Used for built-in method references. */
291
- var objectProto = Object.prototype;
292
-
293
- /**
294
- * Used to resolve the
295
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
296
- * of values.
297
- */
298
- var nativeObjectToString = objectProto.toString;
299
-
300
- /**
301
- * Converts `value` to a string using `Object.prototype.toString`.
302
- *
303
- * @private
304
- * @param {*} value The value to convert.
305
- * @returns {string} Returns the converted string.
306
- */
307
- function objectToString(value) {
308
- return nativeObjectToString.call(value);
309
- }
310
-
311
- var _objectToString = objectToString;
312
-
313
- /** `Object#toString` result references. */
314
- var nullTag = '[object Null]',
315
- undefinedTag = '[object Undefined]';
316
-
317
- /** Built-in value references. */
318
- var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
319
-
320
- /**
321
- * The base implementation of `getTag` without fallbacks for buggy environments.
322
- *
323
- * @private
324
- * @param {*} value The value to query.
325
- * @returns {string} Returns the `toStringTag`.
326
- */
327
- function baseGetTag(value) {
328
- if (value == null) {
329
- return value === undefined ? undefinedTag : nullTag;
330
- }
331
- return (symToStringTag && symToStringTag in Object(value))
332
- ? _getRawTag(value)
333
- : _objectToString(value);
334
- }
335
-
336
- var _baseGetTag = baseGetTag;
337
-
338
- /**
339
- * Checks if `value` is object-like. A value is object-like if it's not `null`
340
- * and has a `typeof` result of "object".
341
- *
342
- * @static
343
- * @memberOf _
344
- * @since 4.0.0
345
- * @category Lang
346
- * @param {*} value The value to check.
347
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
348
- * @example
349
- *
350
- * _.isObjectLike({});
351
- * // => true
352
- *
353
- * _.isObjectLike([1, 2, 3]);
354
- * // => true
355
- *
356
- * _.isObjectLike(_.noop);
357
- * // => false
358
- *
359
- * _.isObjectLike(null);
360
- * // => false
361
- */
362
- function isObjectLike(value) {
363
- return value != null && typeof value == 'object';
364
- }
365
-
366
- var isObjectLike_1 = isObjectLike;
367
-
368
- /** `Object#toString` result references. */
369
- var symbolTag = '[object Symbol]';
370
-
371
- /**
372
- * Checks if `value` is classified as a `Symbol` primitive or object.
373
- *
374
- * @static
375
- * @memberOf _
376
- * @since 4.0.0
377
- * @category Lang
378
- * @param {*} value The value to check.
379
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
380
- * @example
381
- *
382
- * _.isSymbol(Symbol.iterator);
383
- * // => true
384
- *
385
- * _.isSymbol('abc');
386
- * // => false
387
- */
388
- function isSymbol(value) {
389
- return typeof value == 'symbol' ||
390
- (isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
391
- }
392
-
393
- var isSymbol_1 = isSymbol;
394
-
395
- /** Used as references for various `Number` constants. */
396
- var INFINITY$1 = 1 / 0;
397
-
398
- /** Used to convert symbols to primitives and strings. */
399
- var symbolProto = _Symbol ? _Symbol.prototype : undefined,
400
- symbolToString = symbolProto ? symbolProto.toString : undefined;
401
-
402
- /**
403
- * The base implementation of `_.toString` which doesn't convert nullish
404
- * values to empty strings.
405
- *
406
- * @private
407
- * @param {*} value The value to process.
408
- * @returns {string} Returns the string.
409
- */
410
- function baseToString(value) {
411
- // Exit early for strings to avoid a performance hit in some environments.
412
- if (typeof value == 'string') {
413
- return value;
414
- }
415
- if (isArray_1(value)) {
416
- // Recursively convert values (susceptible to call stack limits).
417
- return _arrayMap(value, baseToString) + '';
418
- }
419
- if (isSymbol_1(value)) {
420
- return symbolToString ? symbolToString.call(value) : '';
421
- }
422
- var result = (value + '');
423
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
424
- }
425
-
426
- var _baseToString = baseToString;
427
-
428
- /**
429
- * Converts `value` to a string. An empty string is returned for `null`
430
- * and `undefined` values. The sign of `-0` is preserved.
431
- *
432
- * @static
433
- * @memberOf _
434
- * @since 4.0.0
435
- * @category Lang
436
- * @param {*} value The value to convert.
437
- * @returns {string} Returns the converted string.
438
- * @example
439
- *
440
- * _.toString(null);
441
- * // => ''
442
- *
443
- * _.toString(-0);
444
- * // => '-0'
445
- *
446
- * _.toString([1, 2, 3]);
447
- * // => '1,2,3'
448
- */
449
- function toString(value) {
450
- return value == null ? '' : _baseToString(value);
451
- }
452
-
453
- var toString_1 = toString;
454
-
455
- /**
456
- * Creates a function like `_.lowerFirst`.
457
- *
458
- * @private
459
- * @param {string} methodName The name of the `String` case method to use.
460
- * @returns {Function} Returns the new case function.
461
- */
462
- function createCaseFirst(methodName) {
463
- return function(string) {
464
- string = toString_1(string);
465
-
466
- var strSymbols = _hasUnicode(string)
467
- ? _stringToArray(string)
468
- : undefined;
469
-
470
- var chr = strSymbols
471
- ? strSymbols[0]
472
- : string.charAt(0);
473
-
474
- var trailing = strSymbols
475
- ? _castSlice(strSymbols, 1).join('')
476
- : string.slice(1);
477
-
478
- return chr[methodName]() + trailing;
479
- };
480
- }
481
-
482
- var _createCaseFirst = createCaseFirst;
483
-
484
- /**
485
- * Converts the first character of `string` to upper case.
486
- *
487
- * @static
488
- * @memberOf _
489
- * @since 4.0.0
490
- * @category String
491
- * @param {string} [string=''] The string to convert.
492
- * @returns {string} Returns the converted string.
493
- * @example
494
- *
495
- * _.upperFirst('fred');
496
- * // => 'Fred'
497
- *
498
- * _.upperFirst('FRED');
499
- * // => 'FRED'
500
- */
501
- var upperFirst = _createCaseFirst('toUpperCase');
502
-
503
- var upperFirst_1 = upperFirst;
504
-
505
- /** Used as references for various `Number` constants. */
506
- var MAX_SAFE_INTEGER = 9007199254740991;
507
-
508
- /* Built-in method references for those with the same name as other `lodash` methods. */
509
- var nativeFloor = Math.floor;
510
-
511
- /**
512
- * The base implementation of `_.repeat` which doesn't coerce arguments.
513
- *
514
- * @private
515
- * @param {string} string The string to repeat.
516
- * @param {number} n The number of times to repeat the string.
517
- * @returns {string} Returns the repeated string.
518
- */
519
- function baseRepeat(string, n) {
520
- var result = '';
521
- if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
522
- return result;
523
- }
524
- // Leverage the exponentiation by squaring algorithm for a faster repeat.
525
- // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
526
- do {
527
- if (n % 2) {
528
- result += string;
529
- }
530
- n = nativeFloor(n / 2);
531
- if (n) {
532
- string += string;
533
- }
534
- } while (n);
535
-
536
- return result;
537
- }
538
-
539
- var _baseRepeat = baseRepeat;
540
-
541
- /**
542
- * The base implementation of `_.property` without support for deep paths.
543
- *
544
- * @private
545
- * @param {string} key The key of the property to get.
546
- * @returns {Function} Returns the new accessor function.
547
- */
548
- function baseProperty(key) {
549
- return function(object) {
550
- return object == null ? undefined : object[key];
551
- };
552
- }
553
-
554
- var _baseProperty = baseProperty;
555
-
556
- /**
557
- * Gets the size of an ASCII `string`.
558
- *
559
- * @private
560
- * @param {string} string The string inspect.
561
- * @returns {number} Returns the string size.
562
- */
563
- var asciiSize = _baseProperty('length');
564
-
565
- var _asciiSize = asciiSize;
566
-
567
- /** Used to compose unicode character classes. */
568
- var rsAstralRange = '\\ud800-\\udfff',
569
- rsComboMarksRange = '\\u0300-\\u036f',
570
- reComboHalfMarksRange = '\\ufe20-\\ufe2f',
571
- rsComboSymbolsRange = '\\u20d0-\\u20ff',
572
- rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
573
- rsVarRange = '\\ufe0e\\ufe0f';
574
-
575
- /** Used to compose unicode capture groups. */
576
- var rsAstral = '[' + rsAstralRange + ']',
577
- rsCombo = '[' + rsComboRange + ']',
578
- rsFitz = '\\ud83c[\\udffb-\\udfff]',
579
- rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
580
- rsNonAstral = '[^' + rsAstralRange + ']',
581
- rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
582
- rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
583
- rsZWJ = '\\u200d';
584
-
585
- /** Used to compose unicode regexes. */
586
- var reOptMod = rsModifier + '?',
587
- rsOptVar = '[' + rsVarRange + ']?',
588
- rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
589
- rsSeq = rsOptVar + reOptMod + rsOptJoin,
590
- rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
591
-
592
- /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
593
- var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
594
-
595
- /**
596
- * Gets the size of a Unicode `string`.
597
- *
598
- * @private
599
- * @param {string} string The string inspect.
600
- * @returns {number} Returns the string size.
601
- */
602
- function unicodeSize(string) {
603
- var result = reUnicode.lastIndex = 0;
604
- while (reUnicode.test(string)) {
605
- ++result;
606
- }
607
- return result;
608
- }
609
-
610
- var _unicodeSize = unicodeSize;
611
-
612
- /**
613
- * Gets the number of symbols in `string`.
614
- *
615
- * @private
616
- * @param {string} string The string to inspect.
617
- * @returns {number} Returns the string size.
618
- */
619
- function stringSize(string) {
620
- return _hasUnicode(string)
621
- ? _unicodeSize(string)
622
- : _asciiSize(string);
623
- }
624
-
625
- var _stringSize = stringSize;
626
-
627
- /* Built-in method references for those with the same name as other `lodash` methods. */
628
- var nativeCeil = Math.ceil;
629
-
630
- /**
631
- * Creates the padding for `string` based on `length`. The `chars` string
632
- * is truncated if the number of characters exceeds `length`.
633
- *
634
- * @private
635
- * @param {number} length The padding length.
636
- * @param {string} [chars=' '] The string used as padding.
637
- * @returns {string} Returns the padding for `string`.
638
- */
639
- function createPadding(length, chars) {
640
- chars = chars === undefined ? ' ' : _baseToString(chars);
641
-
642
- var charsLength = chars.length;
643
- if (charsLength < 2) {
644
- return charsLength ? _baseRepeat(chars, length) : chars;
645
- }
646
- var result = _baseRepeat(chars, nativeCeil(length / _stringSize(chars)));
647
- return _hasUnicode(chars)
648
- ? _castSlice(_stringToArray(result), 0, length).join('')
649
- : result.slice(0, length);
650
- }
651
-
652
- var _createPadding = createPadding;
653
-
654
- /** Used to match a single whitespace character. */
655
- var reWhitespace = /\s/;
656
-
657
- /**
658
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
659
- * character of `string`.
660
- *
661
- * @private
662
- * @param {string} string The string to inspect.
663
- * @returns {number} Returns the index of the last non-whitespace character.
664
- */
665
- function trimmedEndIndex(string) {
666
- var index = string.length;
667
-
668
- while (index-- && reWhitespace.test(string.charAt(index))) {}
669
- return index;
670
- }
671
-
672
- var _trimmedEndIndex = trimmedEndIndex;
673
-
674
- /** Used to match leading whitespace. */
675
- var reTrimStart = /^\s+/;
676
-
677
- /**
678
- * The base implementation of `_.trim`.
679
- *
680
- * @private
681
- * @param {string} string The string to trim.
682
- * @returns {string} Returns the trimmed string.
683
- */
684
- function baseTrim(string) {
685
- return string
686
- ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
687
- : string;
688
- }
689
-
690
- var _baseTrim = baseTrim;
691
-
692
- /**
693
- * Checks if `value` is the
694
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
695
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
696
- *
697
- * @static
698
- * @memberOf _
699
- * @since 0.1.0
700
- * @category Lang
701
- * @param {*} value The value to check.
702
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
703
- * @example
704
- *
705
- * _.isObject({});
706
- * // => true
707
- *
708
- * _.isObject([1, 2, 3]);
709
- * // => true
710
- *
711
- * _.isObject(_.noop);
712
- * // => true
713
- *
714
- * _.isObject(null);
715
- * // => false
716
- */
717
- function isObject$1(value) {
718
- var type = typeof value;
719
- return value != null && (type == 'object' || type == 'function');
720
- }
721
-
722
- var isObject_1 = isObject$1;
723
-
724
- /** Used as references for various `Number` constants. */
725
- var NAN = 0 / 0;
726
-
727
- /** Used to detect bad signed hexadecimal string values. */
728
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
729
-
730
- /** Used to detect binary string values. */
731
- var reIsBinary = /^0b[01]+$/i;
732
-
733
- /** Used to detect octal string values. */
734
- var reIsOctal = /^0o[0-7]+$/i;
735
-
736
- /** Built-in method references without a dependency on `root`. */
737
- var freeParseInt = parseInt;
738
-
739
- /**
740
- * Converts `value` to a number.
741
- *
742
- * @static
743
- * @memberOf _
744
- * @since 4.0.0
745
- * @category Lang
746
- * @param {*} value The value to process.
747
- * @returns {number} Returns the number.
748
- * @example
749
- *
750
- * _.toNumber(3.2);
751
- * // => 3.2
752
- *
753
- * _.toNumber(Number.MIN_VALUE);
754
- * // => 5e-324
755
- *
756
- * _.toNumber(Infinity);
757
- * // => Infinity
758
- *
759
- * _.toNumber('3.2');
760
- * // => 3.2
761
- */
762
- function toNumber(value) {
763
- if (typeof value == 'number') {
764
- return value;
765
- }
766
- if (isSymbol_1(value)) {
767
- return NAN;
768
- }
769
- if (isObject_1(value)) {
770
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
771
- value = isObject_1(other) ? (other + '') : other;
772
- }
773
- if (typeof value != 'string') {
774
- return value === 0 ? value : +value;
775
- }
776
- value = _baseTrim(value);
777
- var isBinary = reIsBinary.test(value);
778
- return (isBinary || reIsOctal.test(value))
779
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
780
- : (reIsBadHex.test(value) ? NAN : +value);
781
- }
782
-
783
- var toNumber_1 = toNumber;
784
-
785
- /** Used as references for various `Number` constants. */
786
- var INFINITY = 1 / 0,
787
- MAX_INTEGER = 1.7976931348623157e+308;
788
-
789
- /**
790
- * Converts `value` to a finite number.
791
- *
792
- * @static
793
- * @memberOf _
794
- * @since 4.12.0
795
- * @category Lang
796
- * @param {*} value The value to convert.
797
- * @returns {number} Returns the converted number.
798
- * @example
799
- *
800
- * _.toFinite(3.2);
801
- * // => 3.2
802
- *
803
- * _.toFinite(Number.MIN_VALUE);
804
- * // => 5e-324
805
- *
806
- * _.toFinite(Infinity);
807
- * // => 1.7976931348623157e+308
808
- *
809
- * _.toFinite('3.2');
810
- * // => 3.2
811
- */
812
- function toFinite(value) {
813
- if (!value) {
814
- return value === 0 ? value : 0;
815
- }
816
- value = toNumber_1(value);
817
- if (value === INFINITY || value === -INFINITY) {
818
- var sign = (value < 0 ? -1 : 1);
819
- return sign * MAX_INTEGER;
820
- }
821
- return value === value ? value : 0;
822
- }
823
-
824
- var toFinite_1 = toFinite;
825
-
826
- /**
827
- * Converts `value` to an integer.
828
- *
829
- * **Note:** This method is loosely based on
830
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
831
- *
832
- * @static
833
- * @memberOf _
834
- * @since 4.0.0
835
- * @category Lang
836
- * @param {*} value The value to convert.
837
- * @returns {number} Returns the converted integer.
838
- * @example
839
- *
840
- * _.toInteger(3.2);
841
- * // => 3
842
- *
843
- * _.toInteger(Number.MIN_VALUE);
844
- * // => 0
845
- *
846
- * _.toInteger(Infinity);
847
- * // => 1.7976931348623157e+308
848
- *
849
- * _.toInteger('3.2');
850
- * // => 3
851
- */
852
- function toInteger(value) {
853
- var result = toFinite_1(value),
854
- remainder = result % 1;
855
-
856
- return result === result ? (remainder ? result - remainder : result) : 0;
857
- }
858
-
859
- var toInteger_1 = toInteger;
860
-
861
- /**
862
- * Pads `string` on the left side if it's shorter than `length`. Padding
863
- * characters are truncated if they exceed `length`.
864
- *
865
- * @static
866
- * @memberOf _
867
- * @since 4.0.0
868
- * @category String
869
- * @param {string} [string=''] The string to pad.
870
- * @param {number} [length=0] The padding length.
871
- * @param {string} [chars=' '] The string used as padding.
872
- * @returns {string} Returns the padded string.
873
- * @example
874
- *
875
- * _.padStart('abc', 6);
876
- * // => ' abc'
877
- *
878
- * _.padStart('abc', 6, '_-');
879
- * // => '_-_abc'
880
- *
881
- * _.padStart('abc', 3);
882
- * // => 'abc'
883
- */
884
- function padStart(string, length, chars) {
885
- string = toString_1(string);
886
- length = toInteger_1(length);
887
-
888
- var strLength = length ? _stringSize(string) : 0;
889
- return (length && strLength < length)
890
- ? (_createPadding(length - strLength, chars) + string)
891
- : string;
892
- }
893
-
894
- var padStart_1 = padStart;
895
-
896
- /**
897
- * Converts the first character of `string` to upper case and the remaining
898
- * to lower case.
899
- *
900
- * @static
901
- * @memberOf _
902
- * @since 3.0.0
903
- * @category String
904
- * @param {string} [string=''] The string to capitalize.
905
- * @returns {string} Returns the capitalized string.
906
- * @example
907
- *
908
- * _.capitalize('FRED');
909
- * // => 'Fred'
910
- */
911
- function capitalize(string) {
912
- return upperFirst_1(toString_1(string).toLowerCase());
913
- }
914
-
915
- var capitalize_1 = capitalize;
916
-
917
- /**
918
- * The base implementation of `_.propertyOf` without support for deep paths.
919
- *
920
- * @private
921
- * @param {Object} object The object to query.
922
- * @returns {Function} Returns the new accessor function.
923
- */
924
- function basePropertyOf(object) {
925
- return function(key) {
926
- return object == null ? undefined : object[key];
927
- };
928
- }
929
-
930
- var _basePropertyOf = basePropertyOf;
931
-
932
- /** Used to map characters to HTML entities. */
933
- var htmlEscapes = {
934
- '&': '&amp;',
935
- '<': '&lt;',
936
- '>': '&gt;',
937
- '"': '&quot;',
938
- "'": '&#39;'
939
- };
940
-
941
- /**
942
- * Used by `_.escape` to convert characters to HTML entities.
943
- *
944
- * @private
945
- * @param {string} chr The matched character to escape.
946
- * @returns {string} Returns the escaped character.
947
- */
948
- var escapeHtmlChar = _basePropertyOf(htmlEscapes);
949
-
950
- var _escapeHtmlChar = escapeHtmlChar;
951
-
952
- /** Used to match HTML entities and HTML characters. */
953
- var reUnescapedHtml = /[&<>"']/g,
954
- reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
955
-
956
- /**
957
- * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
958
- * corresponding HTML entities.
959
- *
960
- * **Note:** No other characters are escaped. To escape additional
961
- * characters use a third-party library like [_he_](https://mths.be/he).
962
- *
963
- * Though the ">" character is escaped for symmetry, characters like
964
- * ">" and "/" don't need escaping in HTML and have no special meaning
965
- * unless they're part of a tag or unquoted attribute value. See
966
- * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
967
- * (under "semi-related fun fact") for more details.
968
- *
969
- * When working with HTML you should always
970
- * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
971
- * XSS vectors.
972
- *
973
- * @static
974
- * @since 0.1.0
975
- * @memberOf _
976
- * @category String
977
- * @param {string} [string=''] The string to escape.
978
- * @returns {string} Returns the escaped string.
979
- * @example
980
- *
981
- * _.escape('fred, barney, & pebbles');
982
- * // => 'fred, barney, &amp; pebbles'
983
- */
984
- function escape(string) {
985
- string = toString_1(string);
986
- return (string && reHasUnescapedHtml.test(string))
987
- ? string.replace(reUnescapedHtml, _escapeHtmlChar)
988
- : string;
989
- }
990
-
991
- var _escape = escape;
992
-
993
- /** `Object#toString` result references. */
994
- var regexpTag = '[object RegExp]';
995
-
996
- /**
997
- * The base implementation of `_.isRegExp` without Node.js optimizations.
998
- *
999
- * @private
1000
- * @param {*} value The value to check.
1001
- * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
1002
- */
1003
- function baseIsRegExp(value) {
1004
- return isObjectLike_1(value) && _baseGetTag(value) == regexpTag;
1005
- }
1006
-
1007
- var _baseIsRegExp = baseIsRegExp;
1008
-
1009
- /**
1010
- * The base implementation of `_.unary` without support for storing metadata.
1011
- *
1012
- * @private
1013
- * @param {Function} func The function to cap arguments for.
1014
- * @returns {Function} Returns the new capped function.
1015
- */
1016
- function baseUnary(func) {
1017
- return function(value) {
1018
- return func(value);
1019
- };
1020
- }
1021
-
1022
- var _baseUnary = baseUnary;
1023
-
1024
- var _nodeUtil = createCommonjsModule(function (module, exports) {
1025
- /** Detect free variable `exports`. */
1026
- var freeExports = exports && !exports.nodeType && exports;
1027
-
1028
- /** Detect free variable `module`. */
1029
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1030
-
1031
- /** Detect the popular CommonJS extension `module.exports`. */
1032
- var moduleExports = freeModule && freeModule.exports === freeExports;
1033
-
1034
- /** Detect free variable `process` from Node.js. */
1035
- var freeProcess = moduleExports && _freeGlobal.process;
1036
-
1037
- /** Used to access faster Node.js helpers. */
1038
- var nodeUtil = (function() {
1039
- try {
1040
- // Use `util.types` for Node.js 10+.
1041
- var types = freeModule && freeModule.require && freeModule.require('util').types;
1042
-
1043
- if (types) {
1044
- return types;
1045
- }
1046
-
1047
- // Legacy `process.binding('util')` for Node.js < 10.
1048
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
1049
- } catch (e) {}
1050
- }());
1051
-
1052
- module.exports = nodeUtil;
1053
- });
1054
-
1055
- /* Node.js helper references. */
1056
- var nodeIsRegExp = _nodeUtil && _nodeUtil.isRegExp;
1057
-
1058
- /**
1059
- * Checks if `value` is classified as a `RegExp` object.
1060
- *
1061
- * @static
1062
- * @memberOf _
1063
- * @since 0.1.0
1064
- * @category Lang
1065
- * @param {*} value The value to check.
1066
- * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
1067
- * @example
1068
- *
1069
- * _.isRegExp(/abc/);
1070
- * // => true
1071
- *
1072
- * _.isRegExp('/abc/');
1073
- * // => false
1074
- */
1075
- var isRegExp = nodeIsRegExp ? _baseUnary(nodeIsRegExp) : _baseIsRegExp;
1076
-
1077
- var isRegExp_1 = isRegExp;
1078
-
1079
- /** Used as default options for `_.truncate`. */
1080
- var DEFAULT_TRUNC_LENGTH = 30,
1081
- DEFAULT_TRUNC_OMISSION = '...';
1082
-
1083
- /** Used to match `RegExp` flags from their coerced string values. */
1084
- var reFlags = /\w*$/;
1085
-
1086
- /**
1087
- * Truncates `string` if it's longer than the given maximum string length.
1088
- * The last characters of the truncated string are replaced with the omission
1089
- * string which defaults to "...".
1090
- *
1091
- * @static
1092
- * @memberOf _
1093
- * @since 4.0.0
1094
- * @category String
1095
- * @param {string} [string=''] The string to truncate.
1096
- * @param {Object} [options={}] The options object.
1097
- * @param {number} [options.length=30] The maximum string length.
1098
- * @param {string} [options.omission='...'] The string to indicate text is omitted.
1099
- * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
1100
- * @returns {string} Returns the truncated string.
1101
- * @example
1102
- *
1103
- * _.truncate('hi-diddly-ho there, neighborino');
1104
- * // => 'hi-diddly-ho there, neighbo...'
1105
- *
1106
- * _.truncate('hi-diddly-ho there, neighborino', {
1107
- * 'length': 24,
1108
- * 'separator': ' '
1109
- * });
1110
- * // => 'hi-diddly-ho there,...'
1111
- *
1112
- * _.truncate('hi-diddly-ho there, neighborino', {
1113
- * 'length': 24,
1114
- * 'separator': /,? +/
1115
- * });
1116
- * // => 'hi-diddly-ho there...'
1117
- *
1118
- * _.truncate('hi-diddly-ho there, neighborino', {
1119
- * 'omission': ' [...]'
1120
- * });
1121
- * // => 'hi-diddly-ho there, neig [...]'
1122
- */
1123
- function truncate(string, options) {
1124
- var length = DEFAULT_TRUNC_LENGTH,
1125
- omission = DEFAULT_TRUNC_OMISSION;
1126
-
1127
- if (isObject_1(options)) {
1128
- var separator = 'separator' in options ? options.separator : separator;
1129
- length = 'length' in options ? toInteger_1(options.length) : length;
1130
- omission = 'omission' in options ? _baseToString(options.omission) : omission;
1131
- }
1132
- string = toString_1(string);
1133
-
1134
- var strLength = string.length;
1135
- if (_hasUnicode(string)) {
1136
- var strSymbols = _stringToArray(string);
1137
- strLength = strSymbols.length;
1138
- }
1139
- if (length >= strLength) {
1140
- return string;
1141
- }
1142
- var end = length - _stringSize(omission);
1143
- if (end < 1) {
1144
- return omission;
1145
- }
1146
- var result = strSymbols
1147
- ? _castSlice(strSymbols, 0, end).join('')
1148
- : string.slice(0, end);
1149
-
1150
- if (separator === undefined) {
1151
- return result + omission;
1152
- }
1153
- if (strSymbols) {
1154
- end += (result.length - end);
1155
- }
1156
- if (isRegExp_1(separator)) {
1157
- if (string.slice(end).search(separator)) {
1158
- var match,
1159
- substring = result;
1160
-
1161
- if (!separator.global) {
1162
- separator = RegExp(separator.source, toString_1(reFlags.exec(separator)) + 'g');
1163
- }
1164
- separator.lastIndex = 0;
1165
- while ((match = separator.exec(substring))) {
1166
- var newEnd = match.index;
1167
- }
1168
- result = result.slice(0, newEnd === undefined ? end : newEnd);
1169
- }
1170
- } else if (string.indexOf(_baseToString(separator), end) != end) {
1171
- var index = result.lastIndexOf(separator);
1172
- if (index > -1) {
1173
- result = result.slice(0, index);
1174
- }
1175
- }
1176
- return result + omission;
1177
- }
1178
-
1179
- var truncate_1 = truncate;
1180
-
1181
37
  /**
1182
38
  * @file 公式内置函数
1183
39
  */
@@ -1236,6 +92,7 @@ var Evaluator = /** @class */ (function () {
1236
92
  var input = this.evalute(ast.input);
1237
93
  var filters = ast.filters.concat();
1238
94
  var context = {
95
+ filter: undefined,
1239
96
  data: this.context,
1240
97
  restFilters: filters
1241
98
  };
@@ -1245,6 +102,7 @@ var Evaluator = /** @class */ (function () {
1245
102
  if (!fn) {
1246
103
  throw new Error("filter `".concat(filter.name, "` not exits"));
1247
104
  }
105
+ context.filter = filter;
1248
106
  input = fn.apply(context, [input].concat(filter.args.map(function (item) {
1249
107
  if ((item === null || item === void 0 ? void 0 : item.type) === 'mixed') {
1250
108
  return item.body
@@ -1267,7 +125,8 @@ var Evaluator = /** @class */ (function () {
1267
125
  Evaluator.prototype.script = function (ast) {
1268
126
  var _a;
1269
127
  var defaultFilter = this.options.defaultFilter;
1270
- if (defaultFilter && ((_a = ast.body) === null || _a === void 0 ? void 0 : _a.type) !== 'filter') {
128
+ // 只给简单的变量取值用法自动补fitler
129
+ if (defaultFilter && ~['getter', 'variable'].indexOf((_a = ast.body) === null || _a === void 0 ? void 0 : _a.type)) {
1271
130
  ast.body = {
1272
131
  type: 'filter',
1273
132
  input: ast.body,
@@ -2116,7 +975,7 @@ var Evaluator = /** @class */ (function () {
2116
975
  */
2117
976
  Evaluator.prototype.fnUPPERFIRST = function (text) {
2118
977
  text = this.normalizeText(text);
2119
- return upperFirst_1(text);
978
+ return upperFirst__default["default"](text);
2120
979
  };
2121
980
  /**
2122
981
  * 向前补齐文本长度
@@ -2135,7 +994,7 @@ var Evaluator = /** @class */ (function () {
2135
994
  */
2136
995
  Evaluator.prototype.fnPADSTART = function (text, num, pad) {
2137
996
  text = this.normalizeText(text);
2138
- return padStart_1(text, num, pad);
997
+ return padStart__default["default"](text, num, pad);
2139
998
  };
2140
999
  /**
2141
1000
  * 将文本转成标题
@@ -2152,7 +1011,7 @@ var Evaluator = /** @class */ (function () {
2152
1011
  */
2153
1012
  Evaluator.prototype.fnCAPITALIZE = function (text) {
2154
1013
  text = this.normalizeText(text);
2155
- return capitalize_1(text);
1014
+ return capitalize__default["default"](text);
2156
1015
  };
2157
1016
  /**
2158
1017
  * 对文本进行 HTML 转义
@@ -2169,7 +1028,7 @@ var Evaluator = /** @class */ (function () {
2169
1028
  */
2170
1029
  Evaluator.prototype.fnESCAPE = function (text) {
2171
1030
  text = this.normalizeText(text);
2172
- return _escape(text);
1031
+ return escape__default["default"](text);
2173
1032
  };
2174
1033
  /**
2175
1034
  * 对文本长度进行截断
@@ -2187,7 +1046,7 @@ var Evaluator = /** @class */ (function () {
2187
1046
  */
2188
1047
  Evaluator.prototype.fnTRUNCATE = function (text, length) {
2189
1048
  text = this.normalizeText(text);
2190
- return truncate_1(text, { length: length });
1049
+ return truncate__default["default"](text, { length: length });
2191
1050
  };
2192
1051
  /**
2193
1052
  * 取在某个分隔符之前的所有字符串
@@ -4668,20 +3527,28 @@ var filters = {
4668
3527
  },
4669
3528
  last: function (input) { return input && (input.length ? input[input.length - 1] : null); },
4670
3529
  minus: function (input, step) {
3530
+ var _a;
4671
3531
  if (step === void 0) { step = 1; }
4672
- return stripNumber((Number(input) || 0) - Number(getStrOrVariable(step, this.data)));
3532
+ return stripNumber((Number(input) || 0) -
3533
+ Number(getStrOrVariable(step, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])));
4673
3534
  },
4674
3535
  plus: function (input, step) {
3536
+ var _a;
4675
3537
  if (step === void 0) { step = 1; }
4676
- return stripNumber((Number(input) || 0) + Number(getStrOrVariable(step, this.data)));
3538
+ return stripNumber((Number(input) || 0) +
3539
+ Number(getStrOrVariable(step, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])));
4677
3540
  },
4678
3541
  times: function (input, step) {
3542
+ var _a;
4679
3543
  if (step === void 0) { step = 1; }
4680
- return stripNumber((Number(input) || 0) * Number(getStrOrVariable(step, this.data)));
3544
+ return stripNumber((Number(input) || 0) *
3545
+ Number(getStrOrVariable(step, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])));
4681
3546
  },
4682
3547
  division: function (input, step) {
3548
+ var _a;
4683
3549
  if (step === void 0) { step = 1; }
4684
- return stripNumber((Number(input) || 0) / Number(getStrOrVariable(step, this.data)));
3550
+ return stripNumber((Number(input) || 0) /
3551
+ Number(getStrOrVariable(step, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])));
4685
3552
  },
4686
3553
  count: function (input) {
4687
3554
  return Array.isArray(input) || typeof input === 'string' ? input.length : 0;
@@ -4725,9 +3592,10 @@ var filters = {
4725
3592
  args[_i - 1] = arguments[_i];
4726
3593
  }
4727
3594
  return Array.isArray(input)
4728
- ? input.concat.apply(input, args.map(function (arg) { return getStrOrVariable(arg, _this.data); })) : input;
3595
+ ? input.concat.apply(input, args.map(function (arg, index) { var _a; return getStrOrVariable(arg, _this.data, (_a = _this.filter) === null || _a === void 0 ? void 0 : _a.args[index]); })) : input;
4729
3596
  },
4730
3597
  filter: function (input, keys, expOrDirective, arg1) {
3598
+ var _a, _b, _c, _d;
4731
3599
  if (!Array.isArray(input) || !keys || !expOrDirective) {
4732
3600
  return input;
4733
3601
  }
@@ -4743,17 +3611,23 @@ var filters = {
4743
3611
  fn = function (value) { return typeof value !== 'undefined'; };
4744
3612
  }
4745
3613
  else if (directive === 'equals' || directive === 'equal') {
4746
- arg1 = arg1 ? getStrOrVariable(arg1, this.data) : '';
3614
+ arg1 = arg1
3615
+ ? getStrOrVariable(arg1, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[2])
3616
+ : '';
4747
3617
  fn = function (value) { return arg1 == value; };
4748
3618
  }
4749
3619
  else if (directive === 'isIn') {
4750
- var list_1 = arg1 ? getStrOrVariable(arg1, this.data) : [];
3620
+ var list_1 = arg1
3621
+ ? getStrOrVariable(arg1, this.data, (_b = this.filter) === null || _b === void 0 ? void 0 : _b.args[2])
3622
+ : [];
4751
3623
  list_1 = str2array(list_1);
4752
3624
  list_1 = Array.isArray(list_1) ? list_1 : list_1 ? [list_1] : [];
4753
3625
  fn = function (value) { return (list_1.length ? !!~list_1.indexOf(value) : true); };
4754
3626
  }
4755
3627
  else if (directive === 'notIn') {
4756
- var list_2 = arg1 ? getStrOrVariable(arg1, this.data) : [];
3628
+ var list_2 = arg1
3629
+ ? getStrOrVariable(arg1, this.data, (_c = this.filter) === null || _c === void 0 ? void 0 : _c.args[2])
3630
+ : [];
4757
3631
  list_2 = str2array(list_2);
4758
3632
  list_2 = Array.isArray(list_2) ? list_2 : list_2 ? [list_2] : [];
4759
3633
  fn = function (value) { return !~list_2.indexOf(value); };
@@ -4763,7 +3637,9 @@ var filters = {
4763
3637
  directive = 'match';
4764
3638
  arg1 = expOrDirective;
4765
3639
  }
4766
- arg1 = arg1 ? getStrOrVariable(arg1, this.data) : '';
3640
+ arg1 = arg1
3641
+ ? getStrOrVariable(arg1, this.data, (_d = this.filter) === null || _d === void 0 ? void 0 : _d.args[2])
3642
+ : '';
4767
3643
  // 比对的值是空时直接返回。
4768
3644
  if (!arg1) {
4769
3645
  return input;
@@ -4814,38 +3690,43 @@ var filters = {
4814
3690
  return conditionalFilter(input, hasAlternate, this, !input, trueValue, falseValue);
4815
3691
  },
4816
3692
  isMatch: function (input, matchArg, trueValue, falseValue) {
4817
- var _a;
3693
+ var _a, _b;
4818
3694
  var hasAlternate = arguments.length > 3;
4819
- matchArg = (_a = getStrOrVariable(matchArg, this.data)) !== null && _a !== void 0 ? _a : matchArg;
3695
+ matchArg =
3696
+ (_b = getStrOrVariable(matchArg, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])) !== null && _b !== void 0 ? _b : matchArg;
4820
3697
  return conditionalFilter(input, hasAlternate, this, matchArg && string2regExp("".concat(matchArg), false).test(String(input)), trueValue, falseValue);
4821
3698
  },
4822
3699
  notMatch: function (input, matchArg, trueValue, falseValue) {
4823
- var _a;
3700
+ var _a, _b;
4824
3701
  var hasAlternate = arguments.length > 3;
4825
- matchArg = (_a = getStrOrVariable(matchArg, this.data)) !== null && _a !== void 0 ? _a : matchArg;
3702
+ matchArg =
3703
+ (_b = getStrOrVariable(matchArg, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])) !== null && _b !== void 0 ? _b : matchArg;
4826
3704
  return conditionalFilter(input, hasAlternate, this, matchArg && !string2regExp("".concat(matchArg), false).test(String(input)), trueValue, falseValue);
4827
3705
  },
4828
3706
  isEquals: function (input, equalsValue, trueValue, falseValue) {
4829
- var _a;
3707
+ var _a, _b;
4830
3708
  equalsValue =
4831
- (_a = getStrOrVariable(equalsValue, this.data)) !== null && _a !== void 0 ? _a : equalsValue;
3709
+ (_b = getStrOrVariable(equalsValue, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])) !== null && _b !== void 0 ? _b : equalsValue;
4832
3710
  var hasAlternate = arguments.length > 3;
4833
3711
  return conditionalFilter(input, hasAlternate, this, input === equalsValue, trueValue, falseValue);
4834
3712
  },
4835
3713
  notEquals: function (input, equalsValue, trueValue, falseValue) {
4836
- var _a;
3714
+ var _a, _b;
4837
3715
  equalsValue =
4838
- (_a = getStrOrVariable(equalsValue, this.data)) !== null && _a !== void 0 ? _a : equalsValue;
3716
+ (_b = getStrOrVariable(equalsValue, this.data, (_a = this.filter) === null || _a === void 0 ? void 0 : _a.args[0])) !== null && _b !== void 0 ? _b : equalsValue;
4839
3717
  var hasAlternate = arguments.length > 3;
4840
3718
  return conditionalFilter(input, hasAlternate, this, input !== equalsValue, trueValue, falseValue);
4841
3719
  }
4842
3720
  };
4843
3721
  function conditionalFilter(input, hasAlternate, filterContext, test, trueValue, falseValue) {
4844
- var _a;
4845
- hasAlternate && skipRestTest(filterContext.restFilters);
3722
+ var _a, _b, _c;
3723
+ (hasAlternate || test) && skipRestTest(filterContext.restFilters);
4846
3724
  var result = test ? trueValue : falseValue;
3725
+ var ast = test
3726
+ ? (_a = filterContext.filter) === null || _a === void 0 ? void 0 : _a.args[1]
3727
+ : (_b = filterContext.filter) === null || _b === void 0 ? void 0 : _b.args[2];
4847
3728
  return test || hasAlternate
4848
- ? (_a = getStrOrVariable(result, filterContext.data)) !== null && _a !== void 0 ? _a : result
3729
+ ? (_c = getStrOrVariable(result, filterContext.data, ast)) !== null && _c !== void 0 ? _c : result
4849
3730
  : input;
4850
3731
  }
4851
3732
  /**
@@ -4855,7 +3736,12 @@ function conditionalFilter(input, hasAlternate, filterContext, test, trueValue,
4855
3736
  * @param value 传入字符
4856
3737
  * @param data 数据域
4857
3738
  */
4858
- function getStrOrVariable(value, data) {
3739
+ function getStrOrVariable(value, data, ast) {
3740
+ // 通过读取 ast 来判断,只有 literal 才可能是变量,也可能是字符串
3741
+ // 其他的直接返回值即可。
3742
+ if ((ast === null || ast === void 0 ? void 0 : ast.type) && ast.type !== 'literal') {
3743
+ return value;
3744
+ }
4859
3745
  return typeof value === 'string' && /,/.test(value)
4860
3746
  ? value.split(/\s*,\s*/).filter(function (item) { return item; })
4861
3747
  : typeof value === 'string'