@revolist/revogrid 3.0.99 → 3.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.
Files changed (40) hide show
  1. package/custom-element/index.js +475 -300
  2. package/dist/cjs/debounce-e9b040d9.js +575 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/revo-grid.cjs.js +1 -1
  5. package/dist/cjs/revo-grid_11.cjs.entry.js +159 -634
  6. package/dist/cjs/revogr-filter-panel.cjs.entry.js +158 -43
  7. package/dist/collection/components/revo-grid/revo-grid.js +1 -1
  8. package/dist/collection/plugins/filter/conditions/equal.js +5 -1
  9. package/dist/collection/plugins/filter/filter.button.js +10 -0
  10. package/dist/collection/plugins/filter/filter.plugin.js +93 -47
  11. package/dist/collection/plugins/filter/filter.pop.js +196 -47
  12. package/dist/collection/plugins/filter/filter.style.css +51 -4
  13. package/dist/esm/debounce-8dadcda7.js +558 -0
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/revo-grid.js +1 -1
  16. package/dist/esm/revo-grid_11.entry.js +113 -588
  17. package/dist/esm/revogr-filter-panel.entry.js +157 -42
  18. package/dist/esm-es5/debounce-8dadcda7.js +1 -0
  19. package/dist/esm-es5/loader.js +1 -1
  20. package/dist/esm-es5/revo-grid.js +1 -1
  21. package/dist/esm-es5/revo-grid_11.entry.js +1 -1
  22. package/dist/esm-es5/revogr-filter-panel.entry.js +1 -1
  23. package/dist/revo-grid/debounce-d097578d.js +1 -0
  24. package/dist/revo-grid/debounce-f40a88f6.system.js +1 -0
  25. package/dist/revo-grid/revo-grid.esm.js +1 -1
  26. package/dist/revo-grid/revo-grid.system.js +1 -1
  27. package/dist/revo-grid/revo-grid_11.entry.js +1 -1
  28. package/dist/revo-grid/revo-grid_11.system.entry.js +1 -1
  29. package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
  30. package/dist/revo-grid/revogr-filter-panel.system.entry.js +1 -1
  31. package/dist/types/components.d.ts +4 -2
  32. package/dist/types/plugins/filter/filter.button.d.ts +4 -0
  33. package/dist/types/plugins/filter/filter.plugin.d.ts +5 -8
  34. package/dist/types/plugins/filter/filter.pop.d.ts +26 -7
  35. package/package.json +1 -1
  36. package/dist/cjs/filter.button-2396a488.js +0 -27
  37. package/dist/esm/filter.button-53ebca66.js +0 -23
  38. package/dist/esm-es5/filter.button-53ebca66.js +0 -1
  39. package/dist/revo-grid/filter.button-1509c206.js +0 -1
  40. package/dist/revo-grid/filter.button-4bd87101.system.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { g as getRenderingRef, f as forceUpdate, h, r as registerInstance, c as createEvent, H as Host, e as getElement } from './index-42c84e7c.js';
2
- import { i as isFilterBtn, F as FILTER_PROP, a as FilterButton } from './filter.button-53ebca66.js';
2
+ import { i as isObjectLike_1, _ as _baseGetTag, c as createCommonjsModule, a as _root, b as _freeGlobal, d as isObject_1, e as _Symbol, f as isSymbol_1, t as toNumber_1, g as isFilterBtn, F as FILTER_PROP, h as commonjsGlobal, j as FilterButton, k as debounce_1 } from './debounce-8dadcda7.js';
3
3
 
4
4
  class ThemeCompact {
5
5
  constructor() {
@@ -149,163 +149,6 @@ function baseTimes(n, iteratee) {
149
149
 
150
150
  var _baseTimes = baseTimes;
151
151
 
152
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
153
-
154
- function createCommonjsModule(fn, basedir, module) {
155
- return module = {
156
- path: basedir,
157
- exports: {},
158
- require: function (path, base) {
159
- return commonjsRequire();
160
- }
161
- }, fn(module, module.exports), module.exports;
162
- }
163
-
164
- function commonjsRequire () {
165
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
166
- }
167
-
168
- /** Detect free variable `global` from Node.js. */
169
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
170
-
171
- var _freeGlobal = freeGlobal;
172
-
173
- /** Detect free variable `self`. */
174
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
175
-
176
- /** Used as a reference to the global object. */
177
- var root = _freeGlobal || freeSelf || Function('return this')();
178
-
179
- var _root = root;
180
-
181
- /** Built-in value references. */
182
- var Symbol = _root.Symbol;
183
-
184
- var _Symbol = Symbol;
185
-
186
- /** Used for built-in method references. */
187
- var objectProto$b = Object.prototype;
188
-
189
- /** Used to check objects for own properties. */
190
- var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
191
-
192
- /**
193
- * Used to resolve the
194
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
195
- * of values.
196
- */
197
- var nativeObjectToString$1 = objectProto$b.toString;
198
-
199
- /** Built-in value references. */
200
- var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
201
-
202
- /**
203
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
204
- *
205
- * @private
206
- * @param {*} value The value to query.
207
- * @returns {string} Returns the raw `toStringTag`.
208
- */
209
- function getRawTag(value) {
210
- var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
211
- tag = value[symToStringTag$1];
212
-
213
- try {
214
- value[symToStringTag$1] = undefined;
215
- var unmasked = true;
216
- } catch (e) {}
217
-
218
- var result = nativeObjectToString$1.call(value);
219
- if (unmasked) {
220
- if (isOwn) {
221
- value[symToStringTag$1] = tag;
222
- } else {
223
- delete value[symToStringTag$1];
224
- }
225
- }
226
- return result;
227
- }
228
-
229
- var _getRawTag = getRawTag;
230
-
231
- /** Used for built-in method references. */
232
- var objectProto$a = Object.prototype;
233
-
234
- /**
235
- * Used to resolve the
236
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
237
- * of values.
238
- */
239
- var nativeObjectToString = objectProto$a.toString;
240
-
241
- /**
242
- * Converts `value` to a string using `Object.prototype.toString`.
243
- *
244
- * @private
245
- * @param {*} value The value to convert.
246
- * @returns {string} Returns the converted string.
247
- */
248
- function objectToString(value) {
249
- return nativeObjectToString.call(value);
250
- }
251
-
252
- var _objectToString = objectToString;
253
-
254
- /** `Object#toString` result references. */
255
- var nullTag = '[object Null]',
256
- undefinedTag = '[object Undefined]';
257
-
258
- /** Built-in value references. */
259
- var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
260
-
261
- /**
262
- * The base implementation of `getTag` without fallbacks for buggy environments.
263
- *
264
- * @private
265
- * @param {*} value The value to query.
266
- * @returns {string} Returns the `toStringTag`.
267
- */
268
- function baseGetTag(value) {
269
- if (value == null) {
270
- return value === undefined ? undefinedTag : nullTag;
271
- }
272
- return (symToStringTag && symToStringTag in Object(value))
273
- ? _getRawTag(value)
274
- : _objectToString(value);
275
- }
276
-
277
- var _baseGetTag = baseGetTag;
278
-
279
- /**
280
- * Checks if `value` is object-like. A value is object-like if it's not `null`
281
- * and has a `typeof` result of "object".
282
- *
283
- * @static
284
- * @memberOf _
285
- * @since 4.0.0
286
- * @category Lang
287
- * @param {*} value The value to check.
288
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
289
- * @example
290
- *
291
- * _.isObjectLike({});
292
- * // => true
293
- *
294
- * _.isObjectLike([1, 2, 3]);
295
- * // => true
296
- *
297
- * _.isObjectLike(_.noop);
298
- * // => false
299
- *
300
- * _.isObjectLike(null);
301
- * // => false
302
- */
303
- function isObjectLike(value) {
304
- return value != null && typeof value == 'object';
305
- }
306
-
307
- var isObjectLike_1 = isObjectLike;
308
-
309
152
  /** `Object#toString` result references. */
310
153
  var argsTag$2 = '[object Arguments]';
311
154
 
@@ -740,38 +583,6 @@ function baseKeys(object) {
740
583
 
741
584
  var _baseKeys = baseKeys;
742
585
 
743
- /**
744
- * Checks if `value` is the
745
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
746
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
747
- *
748
- * @static
749
- * @memberOf _
750
- * @since 0.1.0
751
- * @category Lang
752
- * @param {*} value The value to check.
753
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
754
- * @example
755
- *
756
- * _.isObject({});
757
- * // => true
758
- *
759
- * _.isObject([1, 2, 3]);
760
- * // => true
761
- *
762
- * _.isObject(_.noop);
763
- * // => true
764
- *
765
- * _.isObject(null);
766
- * // => false
767
- */
768
- function isObject(value) {
769
- var type = typeof value;
770
- return value != null && (type == 'object' || type == 'function');
771
- }
772
-
773
- var isObject_1 = isObject;
774
-
775
586
  /** `Object#toString` result references. */
776
587
  var asyncTag = '[object AsyncFunction]',
777
588
  funcTag = '[object Function]',
@@ -1880,7 +1691,7 @@ var boolTag = '[object Boolean]',
1880
1691
  regexpTag = '[object RegExp]',
1881
1692
  setTag$2 = '[object Set]',
1882
1693
  stringTag$1 = '[object String]',
1883
- symbolTag$1 = '[object Symbol]';
1694
+ symbolTag = '[object Symbol]';
1884
1695
 
1885
1696
  var arrayBufferTag = '[object ArrayBuffer]',
1886
1697
  dataViewTag$1 = '[object DataView]';
@@ -1963,7 +1774,7 @@ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1963
1774
  stack['delete'](object);
1964
1775
  return result;
1965
1776
 
1966
- case symbolTag$1:
1777
+ case symbolTag:
1967
1778
  if (symbolValueOf) {
1968
1779
  return symbolValueOf.call(object) == symbolValueOf.call(other);
1969
1780
  }
@@ -2500,33 +2311,6 @@ function baseMatches(source) {
2500
2311
 
2501
2312
  var _baseMatches = baseMatches;
2502
2313
 
2503
- /** `Object#toString` result references. */
2504
- var symbolTag = '[object Symbol]';
2505
-
2506
- /**
2507
- * Checks if `value` is classified as a `Symbol` primitive or object.
2508
- *
2509
- * @static
2510
- * @memberOf _
2511
- * @since 4.0.0
2512
- * @category Lang
2513
- * @param {*} value The value to check.
2514
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2515
- * @example
2516
- *
2517
- * _.isSymbol(Symbol.iterator);
2518
- * // => true
2519
- *
2520
- * _.isSymbol('abc');
2521
- * // => false
2522
- */
2523
- function isSymbol(value) {
2524
- return typeof value == 'symbol' ||
2525
- (isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
2526
- }
2527
-
2528
- var isSymbol_1 = isSymbol;
2529
-
2530
2314
  /** Used to match property names within property paths. */
2531
2315
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
2532
2316
  reIsPlainProp = /^\w*$/;
@@ -2555,7 +2339,7 @@ function isKey(value, object) {
2555
2339
  var _isKey = isKey;
2556
2340
 
2557
2341
  /** Error message constants. */
2558
- var FUNC_ERROR_TEXT$2 = 'Expected a function';
2342
+ var FUNC_ERROR_TEXT$1 = 'Expected a function';
2559
2343
 
2560
2344
  /**
2561
2345
  * Creates a function that memoizes the result of `func`. If `resolver` is
@@ -2603,7 +2387,7 @@ var FUNC_ERROR_TEXT$2 = 'Expected a function';
2603
2387
  */
2604
2388
  function memoize(func, resolver) {
2605
2389
  if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
2606
- throw new TypeError(FUNC_ERROR_TEXT$2);
2390
+ throw new TypeError(FUNC_ERROR_TEXT$1);
2607
2391
  }
2608
2392
  var memoized = function() {
2609
2393
  var args = arguments,
@@ -3253,105 +3037,6 @@ function baseFindIndex(array, predicate, fromIndex, fromRight) {
3253
3037
 
3254
3038
  var _baseFindIndex = baseFindIndex;
3255
3039
 
3256
- /** Used to match a single whitespace character. */
3257
- var reWhitespace = /\s/;
3258
-
3259
- /**
3260
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
3261
- * character of `string`.
3262
- *
3263
- * @private
3264
- * @param {string} string The string to inspect.
3265
- * @returns {number} Returns the index of the last non-whitespace character.
3266
- */
3267
- function trimmedEndIndex(string) {
3268
- var index = string.length;
3269
-
3270
- while (index-- && reWhitespace.test(string.charAt(index))) {}
3271
- return index;
3272
- }
3273
-
3274
- var _trimmedEndIndex = trimmedEndIndex;
3275
-
3276
- /** Used to match leading whitespace. */
3277
- var reTrimStart = /^\s+/;
3278
-
3279
- /**
3280
- * The base implementation of `_.trim`.
3281
- *
3282
- * @private
3283
- * @param {string} string The string to trim.
3284
- * @returns {string} Returns the trimmed string.
3285
- */
3286
- function baseTrim(string) {
3287
- return string
3288
- ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
3289
- : string;
3290
- }
3291
-
3292
- var _baseTrim = baseTrim;
3293
-
3294
- /** Used as references for various `Number` constants. */
3295
- var NAN = 0 / 0;
3296
-
3297
- /** Used to detect bad signed hexadecimal string values. */
3298
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
3299
-
3300
- /** Used to detect binary string values. */
3301
- var reIsBinary = /^0b[01]+$/i;
3302
-
3303
- /** Used to detect octal string values. */
3304
- var reIsOctal = /^0o[0-7]+$/i;
3305
-
3306
- /** Built-in method references without a dependency on `root`. */
3307
- var freeParseInt = parseInt;
3308
-
3309
- /**
3310
- * Converts `value` to a number.
3311
- *
3312
- * @static
3313
- * @memberOf _
3314
- * @since 4.0.0
3315
- * @category Lang
3316
- * @param {*} value The value to process.
3317
- * @returns {number} Returns the number.
3318
- * @example
3319
- *
3320
- * _.toNumber(3.2);
3321
- * // => 3.2
3322
- *
3323
- * _.toNumber(Number.MIN_VALUE);
3324
- * // => 5e-324
3325
- *
3326
- * _.toNumber(Infinity);
3327
- * // => Infinity
3328
- *
3329
- * _.toNumber('3.2');
3330
- * // => 3.2
3331
- */
3332
- function toNumber(value) {
3333
- if (typeof value == 'number') {
3334
- return value;
3335
- }
3336
- if (isSymbol_1(value)) {
3337
- return NAN;
3338
- }
3339
- if (isObject_1(value)) {
3340
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
3341
- value = isObject_1(other) ? (other + '') : other;
3342
- }
3343
- if (typeof value != 'string') {
3344
- return value === 0 ? value : +value;
3345
- }
3346
- value = _baseTrim(value);
3347
- var isBinary = reIsBinary.test(value);
3348
- return (isBinary || reIsOctal.test(value))
3349
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
3350
- : (reIsBadHex.test(value) ? NAN : +value);
3351
- }
3352
-
3353
- var toNumber_1 = toNumber;
3354
-
3355
3040
  /** Used as references for various `Number` constants. */
3356
3041
  var INFINITY = 1 / 0,
3357
3042
  MAX_INTEGER = 1.7976931348623157e+308;
@@ -3429,7 +3114,7 @@ function toInteger(value) {
3429
3114
  var toInteger_1 = toInteger;
3430
3115
 
3431
3116
  /* Built-in method references for those with the same name as other `lodash` methods. */
3432
- var nativeMax$3 = Math.max;
3117
+ var nativeMax$2 = Math.max;
3433
3118
 
3434
3119
  /**
3435
3120
  * This method is like `_.find` except that it returns the index of the first
@@ -3473,7 +3158,7 @@ function findIndex(array, predicate, fromIndex) {
3473
3158
  }
3474
3159
  var index = fromIndex == null ? 0 : toInteger_1(fromIndex);
3475
3160
  if (index < 0) {
3476
- index = nativeMax$3(length + index, 0);
3161
+ index = nativeMax$2(length + index, 0);
3477
3162
  }
3478
3163
  return _baseFindIndex(array, _baseIteratee(predicate), index);
3479
3164
  }
@@ -3529,7 +3214,7 @@ const appendToMap = (map, propName, value) => {
3529
3214
  items.push(value);
3530
3215
  }
3531
3216
  };
3532
- const debounce$1 = (fn, ms) => {
3217
+ const debounce = (fn, ms) => {
3533
3218
  let timeoutId;
3534
3219
  return (...args) => {
3535
3220
  if (timeoutId) {
@@ -3552,7 +3237,7 @@ const debounce$1 = (fn, ms) => {
3552
3237
  * Better leak in Edge than to be useless.
3553
3238
  */
3554
3239
  const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
3555
- const cleanupElements = debounce$1((map) => {
3240
+ const cleanupElements = debounce((map) => {
3556
3241
  for (let key of map.keys()) {
3557
3242
  map.set(key, map.get(key).filter(isConnected));
3558
3243
  }
@@ -3693,7 +3378,7 @@ const createStore = (defaultState, shouldUpdate) => {
3693
3378
 
3694
3379
  /* Built-in method references for those with the same name as other `lodash` methods. */
3695
3380
  var nativeCeil = Math.ceil,
3696
- nativeMax$2 = Math.max;
3381
+ nativeMax$1 = Math.max;
3697
3382
 
3698
3383
  /**
3699
3384
  * The base implementation of `_.range` and `_.rangeRight` which doesn't
@@ -3708,7 +3393,7 @@ var nativeCeil = Math.ceil,
3708
3393
  */
3709
3394
  function baseRange(start, end, step, fromRight) {
3710
3395
  var index = -1,
3711
- length = nativeMax$2(nativeCeil((end - start) / (step || 1)), 0),
3396
+ length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0),
3712
3397
  result = Array(length);
3713
3398
 
3714
3399
  while (length--) {
@@ -4373,7 +4058,7 @@ var MAX_ARRAY_LENGTH$2 = 4294967295,
4373
4058
 
4374
4059
  /* Built-in method references for those with the same name as other `lodash` methods. */
4375
4060
  var nativeFloor = Math.floor,
4376
- nativeMin$1 = Math.min;
4061
+ nativeMin = Math.min;
4377
4062
 
4378
4063
  /**
4379
4064
  * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
@@ -4428,7 +4113,7 @@ function baseSortedIndexBy(array, value, iteratee, retHighest) {
4428
4113
  high = mid;
4429
4114
  }
4430
4115
  }
4431
- return nativeMin$1(high, MAX_ARRAY_INDEX);
4116
+ return nativeMin(high, MAX_ARRAY_INDEX);
4432
4117
  }
4433
4118
 
4434
4119
  var _baseSortedIndexBy = baseSortedIndexBy;
@@ -5338,7 +5023,11 @@ const eq = (value, extra) => {
5338
5023
  if (typeof value !== 'string') {
5339
5024
  value = JSON.stringify(value);
5340
5025
  }
5341
- return value.toLocaleLowerCase() === extra.toString().toLocaleLowerCase();
5026
+ const filterVal = extra.toString().toLocaleLowerCase();
5027
+ if (filterVal.length === 0) {
5028
+ return true;
5029
+ }
5030
+ return value.toLocaleLowerCase() === filterVal;
5342
5031
  };
5343
5032
  const notEq = (value, extra) => !eq(value, extra);
5344
5033
  notEq.extra = 'input';
@@ -5458,6 +5147,7 @@ class FilterPlugin extends BasePlugin {
5458
5147
  super(revogrid);
5459
5148
  this.revogrid = revogrid;
5460
5149
  this.filterCollection = {};
5150
+ this.multiFilterItems = {};
5461
5151
  this.possibleFilters = Object.assign({}, filterTypes);
5462
5152
  this.possibleFilterNames = Object.assign({}, filterNames);
5463
5153
  this.possibleFilterEntities = Object.assign({}, filterEntities);
@@ -5465,21 +5155,38 @@ class FilterPlugin extends BasePlugin {
5465
5155
  this.initConfig(config);
5466
5156
  }
5467
5157
  const headerclick = (e) => this.headerclick(e);
5468
- const aftersourceset = () => {
5469
- if (Object.keys(this.filterCollection).length) {
5470
- this.filterByProps(this.filterCollection);
5158
+ const aftersourceset = async () => {
5159
+ const filterCollectionProps = Object.keys(this.filterCollection);
5160
+ if (filterCollectionProps.length > 0) {
5161
+ // handle old way of filtering by reworking FilterCollection to new MultiFilterItem
5162
+ filterCollectionProps.forEach((prop, index) => {
5163
+ if (!this.multiFilterItems[prop]) {
5164
+ this.multiFilterItems[prop] = [
5165
+ {
5166
+ id: index,
5167
+ type: this.filterCollection[prop].type,
5168
+ value: this.filterCollection[prop].value,
5169
+ relation: 'and',
5170
+ },
5171
+ ];
5172
+ }
5173
+ });
5471
5174
  }
5175
+ await this.runFiltering();
5472
5176
  };
5473
5177
  this.addEventListener('headerclick', headerclick);
5474
5178
  this.addEventListener('aftersourceset', aftersourceset);
5475
5179
  this.revogrid.registerVNode([
5476
- h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), ref: e => (this.pop = e) }),
5180
+ h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterItems: this.multiFilterItems, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), ref: e => (this.pop = e) }),
5477
5181
  ]);
5478
5182
  }
5479
5183
  initConfig(config) {
5480
5184
  if (config.collection) {
5481
5185
  this.filterCollection = Object.assign({}, config.collection);
5482
5186
  }
5187
+ if (config.multiFilterItems) {
5188
+ this.multiFilterItems = Object.assign({}, config.multiFilterItems);
5189
+ }
5483
5190
  if (config.customFilters) {
5484
5191
  for (let cType in config.customFilters) {
5485
5192
  const cFilter = config.customFilters[cType];
@@ -5563,43 +5270,18 @@ class FilterPlugin extends BasePlugin {
5563
5270
  return !!(typeof type === 'string' && this.possibleFilters[type]);
5564
5271
  }
5565
5272
  // called on internal component change
5566
- async onFilterChange(filterItem) {
5567
- this.filterByProps({ [filterItem.prop]: filterItem });
5568
- }
5569
- /**
5570
- * Apply filters collection to extend existing one or override
5571
- * @method
5572
- * @param conditions - list of filters to apply
5573
- */
5574
- async filterByProps(conditions, override = false) {
5575
- if (override) {
5576
- this.filterCollection = {};
5577
- }
5578
- for (const prop in conditions) {
5579
- const { type, value } = conditions[prop];
5580
- if (type === 'none') {
5581
- delete this.filterCollection[prop];
5582
- }
5583
- else {
5584
- const filter = this.possibleFilterEntities[type];
5585
- this.filterCollection[prop] = {
5586
- filter,
5587
- value,
5588
- type,
5589
- };
5590
- }
5591
- }
5592
- await this.runFiltering();
5273
+ async onFilterChange(filterItems) {
5274
+ this.multiFilterItems = filterItems;
5275
+ this.runFiltering();
5593
5276
  }
5594
5277
  /**
5595
5278
  * Triggers grid filtering
5596
5279
  */
5597
- async doFiltering(collection, items, columns) {
5280
+ async doFiltering(collection, items, columns, filterItems) {
5598
5281
  const columnsToUpdate = [];
5599
- // todo improvement: loop through collection of props
5600
5282
  columns.forEach(rgCol => {
5601
5283
  const column = Object.assign({}, rgCol);
5602
- const hasFilter = collection[column.prop];
5284
+ const hasFilter = filterItems[column.prop];
5603
5285
  if (column[FILTER_PROP] && !hasFilter) {
5604
5286
  delete column[FILTER_PROP];
5605
5287
  columnsToUpdate.push(column);
@@ -5609,9 +5291,9 @@ class FilterPlugin extends BasePlugin {
5609
5291
  column[FILTER_PROP] = true;
5610
5292
  }
5611
5293
  });
5612
- const itemsToFilter = this.getRowFilter(items, collection);
5294
+ const itemsToFilter = this.getRowFilter(items, filterItems);
5613
5295
  // check is filter event prevented
5614
- const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items });
5296
+ const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items, filterItems });
5615
5297
  if (defaultPrevented) {
5616
5298
  return;
5617
5299
  }
@@ -5620,39 +5302,92 @@ class FilterPlugin extends BasePlugin {
5620
5302
  if (isAddedEvent.defaultPrevented) {
5621
5303
  return;
5622
5304
  }
5305
+ // applies the hasFilter to the columns to show filter icon
5623
5306
  await this.revogrid.updateColumns(columnsToUpdate);
5624
5307
  this.emit('afterFilterApply');
5625
5308
  }
5626
5309
  async clearFiltering() {
5627
- this.filterCollection = {};
5310
+ this.multiFilterItems = {};
5628
5311
  await this.runFiltering();
5629
5312
  }
5630
5313
  async runFiltering() {
5314
+ const collection = {};
5315
+ // handle old filterCollection to return the first filter only (if any) from multiFilterItems
5316
+ const filterProps = Object.keys(this.multiFilterItems);
5317
+ for (const prop of filterProps) {
5318
+ // check if we have any filter for a column
5319
+ if (this.multiFilterItems[prop].length > 0) {
5320
+ const firstFilterItem = this.multiFilterItems[prop][0];
5321
+ collection[prop] = {
5322
+ filter: filterEntities[firstFilterItem.type],
5323
+ type: firstFilterItem.type,
5324
+ value: firstFilterItem.value,
5325
+ };
5326
+ }
5327
+ }
5328
+ this.filterCollection = collection;
5631
5329
  const { source, columns } = await this.getData();
5632
- const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns });
5330
+ const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns, filterItems: this.multiFilterItems });
5633
5331
  if (defaultPrevented) {
5634
5332
  return;
5635
5333
  }
5636
- this.doFiltering(detail.collection, detail.source, detail.columns);
5334
+ this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
5637
5335
  }
5638
5336
  async getData() {
5639
5337
  const source = await this.revogrid.getSource();
5640
5338
  const columns = await this.revogrid.getColumns();
5641
5339
  return {
5642
5340
  source,
5643
- columns
5341
+ columns,
5644
5342
  };
5645
5343
  }
5646
- getRowFilter(rows, collection) {
5344
+ getRowFilter(rows, filterItems) {
5345
+ const propKeys = Object.keys(filterItems);
5647
5346
  const trimmed = {};
5347
+ let propFilterSatisfiedCount = 0;
5348
+ let lastFilterResults = [];
5349
+ // each rows
5648
5350
  rows.forEach((model, rowIndex) => {
5649
- for (const prop in collection) {
5650
- const filterItem = collection[prop];
5651
- const filter = filterItem.filter;
5652
- if (!filter(model[prop], filterItem.value)) {
5351
+ // working on all props
5352
+ for (const prop of propKeys) {
5353
+ const propFilters = filterItems[prop];
5354
+ propFilterSatisfiedCount = 0;
5355
+ lastFilterResults = [];
5356
+ // testing each filter for a prop
5357
+ for (const [filterIndex, filterData] of propFilters.entries()) {
5358
+ // the filter LogicFunction based on the type
5359
+ const filter = filterEntities[filterData.type];
5360
+ // THE MAGIC OF FILTERING IS HERE
5361
+ if (filterData.relation === 'or') {
5362
+ lastFilterResults = [];
5363
+ if (filter(model[prop], filterData.value)) {
5364
+ continue;
5365
+ }
5366
+ propFilterSatisfiedCount++;
5367
+ }
5368
+ else {
5369
+ // 'and' relation will need to know the next filter
5370
+ // so we save this current filter to include it in the next filter
5371
+ lastFilterResults.push(!filter(model[prop], filterData.value));
5372
+ // check first if we have a filter on the next index to pair it with this current filter
5373
+ const nextFilterData = propFilters[filterIndex + 1];
5374
+ // stop the sequence if there is no next filter or if the next filter is not an 'and' relation
5375
+ if (!nextFilterData || nextFilterData.relation !== 'and') {
5376
+ // let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
5377
+ if (lastFilterResults.indexOf(true) === -1) {
5378
+ lastFilterResults = [];
5379
+ continue;
5380
+ }
5381
+ // we need to add all of the lastFilterResults since we need to satisfy all
5382
+ propFilterSatisfiedCount += lastFilterResults.length;
5383
+ lastFilterResults = [];
5384
+ }
5385
+ }
5386
+ } // end of propFilters forEach
5387
+ // add to the list of removed/trimmed rows of filter condition is satisfied
5388
+ if (propFilterSatisfiedCount === propFilters.length)
5653
5389
  trimmed[rowIndex] = true;
5654
- }
5655
- }
5390
+ } // end of for-of propKeys
5656
5391
  });
5657
5392
  return trimmed;
5658
5393
  }
@@ -26011,7 +25746,7 @@ function values(object) {
26011
25746
  var values_1 = values;
26012
25747
 
26013
25748
  /* Built-in method references for those with the same name as other `lodash` methods. */
26014
- var nativeMax$1 = Math.max;
25749
+ var nativeMax = Math.max;
26015
25750
 
26016
25751
  /**
26017
25752
  * Checks if `value` is in `collection`. If `collection` is a string, it's
@@ -26049,7 +25784,7 @@ function includes(collection, value, fromIndex, guard) {
26049
25784
 
26050
25785
  var length = collection.length;
26051
25786
  if (fromIndex < 0) {
26052
- fromIndex = nativeMax$1(length + fromIndex, 0);
25787
+ fromIndex = nativeMax(length + fromIndex, 0);
26053
25788
  }
26054
25789
  return isString_1(collection)
26055
25790
  ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
@@ -26832,216 +26567,6 @@ const RevogrHeaderComponent = class {
26832
26567
  };
26833
26568
  RevogrHeaderComponent.style = revogrHeaderStyleCss;
26834
26569
 
26835
- /**
26836
- * Gets the timestamp of the number of milliseconds that have elapsed since
26837
- * the Unix epoch (1 January 1970 00:00:00 UTC).
26838
- *
26839
- * @static
26840
- * @memberOf _
26841
- * @since 2.4.0
26842
- * @category Date
26843
- * @returns {number} Returns the timestamp.
26844
- * @example
26845
- *
26846
- * _.defer(function(stamp) {
26847
- * console.log(_.now() - stamp);
26848
- * }, _.now());
26849
- * // => Logs the number of milliseconds it took for the deferred invocation.
26850
- */
26851
- var now = function() {
26852
- return _root.Date.now();
26853
- };
26854
-
26855
- var now_1 = now;
26856
-
26857
- /** Error message constants. */
26858
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
26859
-
26860
- /* Built-in method references for those with the same name as other `lodash` methods. */
26861
- var nativeMax = Math.max,
26862
- nativeMin = Math.min;
26863
-
26864
- /**
26865
- * Creates a debounced function that delays invoking `func` until after `wait`
26866
- * milliseconds have elapsed since the last time the debounced function was
26867
- * invoked. The debounced function comes with a `cancel` method to cancel
26868
- * delayed `func` invocations and a `flush` method to immediately invoke them.
26869
- * Provide `options` to indicate whether `func` should be invoked on the
26870
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
26871
- * with the last arguments provided to the debounced function. Subsequent
26872
- * calls to the debounced function return the result of the last `func`
26873
- * invocation.
26874
- *
26875
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
26876
- * invoked on the trailing edge of the timeout only if the debounced function
26877
- * is invoked more than once during the `wait` timeout.
26878
- *
26879
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
26880
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
26881
- *
26882
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
26883
- * for details over the differences between `_.debounce` and `_.throttle`.
26884
- *
26885
- * @static
26886
- * @memberOf _
26887
- * @since 0.1.0
26888
- * @category Function
26889
- * @param {Function} func The function to debounce.
26890
- * @param {number} [wait=0] The number of milliseconds to delay.
26891
- * @param {Object} [options={}] The options object.
26892
- * @param {boolean} [options.leading=false]
26893
- * Specify invoking on the leading edge of the timeout.
26894
- * @param {number} [options.maxWait]
26895
- * The maximum time `func` is allowed to be delayed before it's invoked.
26896
- * @param {boolean} [options.trailing=true]
26897
- * Specify invoking on the trailing edge of the timeout.
26898
- * @returns {Function} Returns the new debounced function.
26899
- * @example
26900
- *
26901
- * // Avoid costly calculations while the window size is in flux.
26902
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
26903
- *
26904
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
26905
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
26906
- * 'leading': true,
26907
- * 'trailing': false
26908
- * }));
26909
- *
26910
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
26911
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
26912
- * var source = new EventSource('/stream');
26913
- * jQuery(source).on('message', debounced);
26914
- *
26915
- * // Cancel the trailing debounced invocation.
26916
- * jQuery(window).on('popstate', debounced.cancel);
26917
- */
26918
- function debounce(func, wait, options) {
26919
- var lastArgs,
26920
- lastThis,
26921
- maxWait,
26922
- result,
26923
- timerId,
26924
- lastCallTime,
26925
- lastInvokeTime = 0,
26926
- leading = false,
26927
- maxing = false,
26928
- trailing = true;
26929
-
26930
- if (typeof func != 'function') {
26931
- throw new TypeError(FUNC_ERROR_TEXT$1);
26932
- }
26933
- wait = toNumber_1(wait) || 0;
26934
- if (isObject_1(options)) {
26935
- leading = !!options.leading;
26936
- maxing = 'maxWait' in options;
26937
- maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait;
26938
- trailing = 'trailing' in options ? !!options.trailing : trailing;
26939
- }
26940
-
26941
- function invokeFunc(time) {
26942
- var args = lastArgs,
26943
- thisArg = lastThis;
26944
-
26945
- lastArgs = lastThis = undefined;
26946
- lastInvokeTime = time;
26947
- result = func.apply(thisArg, args);
26948
- return result;
26949
- }
26950
-
26951
- function leadingEdge(time) {
26952
- // Reset any `maxWait` timer.
26953
- lastInvokeTime = time;
26954
- // Start the timer for the trailing edge.
26955
- timerId = setTimeout(timerExpired, wait);
26956
- // Invoke the leading edge.
26957
- return leading ? invokeFunc(time) : result;
26958
- }
26959
-
26960
- function remainingWait(time) {
26961
- var timeSinceLastCall = time - lastCallTime,
26962
- timeSinceLastInvoke = time - lastInvokeTime,
26963
- timeWaiting = wait - timeSinceLastCall;
26964
-
26965
- return maxing
26966
- ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
26967
- : timeWaiting;
26968
- }
26969
-
26970
- function shouldInvoke(time) {
26971
- var timeSinceLastCall = time - lastCallTime,
26972
- timeSinceLastInvoke = time - lastInvokeTime;
26973
-
26974
- // Either this is the first call, activity has stopped and we're at the
26975
- // trailing edge, the system time has gone backwards and we're treating
26976
- // it as the trailing edge, or we've hit the `maxWait` limit.
26977
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
26978
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
26979
- }
26980
-
26981
- function timerExpired() {
26982
- var time = now_1();
26983
- if (shouldInvoke(time)) {
26984
- return trailingEdge(time);
26985
- }
26986
- // Restart the timer.
26987
- timerId = setTimeout(timerExpired, remainingWait(time));
26988
- }
26989
-
26990
- function trailingEdge(time) {
26991
- timerId = undefined;
26992
-
26993
- // Only invoke if we have `lastArgs` which means `func` has been
26994
- // debounced at least once.
26995
- if (trailing && lastArgs) {
26996
- return invokeFunc(time);
26997
- }
26998
- lastArgs = lastThis = undefined;
26999
- return result;
27000
- }
27001
-
27002
- function cancel() {
27003
- if (timerId !== undefined) {
27004
- clearTimeout(timerId);
27005
- }
27006
- lastInvokeTime = 0;
27007
- lastArgs = lastCallTime = lastThis = timerId = undefined;
27008
- }
27009
-
27010
- function flush() {
27011
- return timerId === undefined ? result : trailingEdge(now_1());
27012
- }
27013
-
27014
- function debounced() {
27015
- var time = now_1(),
27016
- isInvoking = shouldInvoke(time);
27017
-
27018
- lastArgs = arguments;
27019
- lastThis = this;
27020
- lastCallTime = time;
27021
-
27022
- if (isInvoking) {
27023
- if (timerId === undefined) {
27024
- return leadingEdge(lastCallTime);
27025
- }
27026
- if (maxing) {
27027
- // Handle invocations in a tight loop.
27028
- clearTimeout(timerId);
27029
- timerId = setTimeout(timerExpired, wait);
27030
- return invokeFunc(lastCallTime);
27031
- }
27032
- }
27033
- if (timerId === undefined) {
27034
- timerId = setTimeout(timerExpired, wait);
27035
- }
27036
- return result;
27037
- }
27038
- debounced.cancel = cancel;
27039
- debounced.flush = flush;
27040
- return debounced;
27041
- }
27042
-
27043
- var debounce_1 = debounce;
27044
-
27045
26570
  class RowOrderService {
27046
26571
  constructor(config) {
27047
26572
  this.config = config;