@progress/kendo-react-data-tools 9.4.0-develop.9 → 9.4.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.
@@ -5,47 +5,47 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { orderBy as s, filterBy as D } from "@progress/kendo-data-query";
9
- import { extendDataItem as y, mapTree as v, getItemPath as P, getNestedValue as i } from "@progress/kendo-react-common";
10
- function g(r, n, t) {
11
- return t ? { ...r, [n]: t.length ? [...t] : void 0 } : r && r[n] ? [...r[n]] : [];
8
+ import { orderBy as v, filterBy as s } from "@progress/kendo-data-query";
9
+ import { extendDataItem as y, mapTree as C, getItemPath as P, getNestedValue as g } from "@progress/kendo-react-common";
10
+ function i(t, n, r) {
11
+ return r ? { ...t, [n]: r.length ? [...r] : void 0 } : t && t[n] ? [...t[n]] : [];
12
12
  }
13
- function C(r, n, t) {
14
- if (r[t]) {
15
- const o = g(r, t, s(g(r, t), n)), e = g(o, t).map((c) => C(c, n, t));
16
- return { ...o, [t]: e };
13
+ function B(t, n, r) {
14
+ if (t[r]) {
15
+ const o = i(t, r, v(i(t, r), n)), e = i(o, r).map((c) => B(c, n, r));
16
+ return { ...o, [r]: e };
17
17
  }
18
- return r;
18
+ return t;
19
19
  }
20
- function $(r, n, t) {
21
- let o = s(r, n);
22
- return o = o.map((e) => C(e, n, t)), o;
20
+ function E(t, n, r) {
21
+ let o = v(t, n);
22
+ return o = o.map((e) => B(e, n, r)), o;
23
23
  }
24
- function B(r, n, t) {
25
- let o = g(r, t);
24
+ function x(t, n, r) {
25
+ let o = i(t, r);
26
26
  if (o && o.length) {
27
- o = o.map((h) => B(h, n, t));
28
- const a = D(o, {
29
- filters: [{ filters: n, logic: "and" }, { operator: (h) => !!(h[t] || []).length }],
27
+ o = o.map((a) => x(a, n, r));
28
+ const l = s(o, {
29
+ filters: [{ filters: n, logic: "and" }, { operator: (a) => !!(a[r] || []).length }],
30
30
  logic: "or"
31
31
  });
32
- return g(r, t, a);
32
+ return i(t, r, l);
33
33
  }
34
- return r;
34
+ return t;
35
35
  }
36
- function k(r, n, t) {
37
- let o = { [t]: [...r] };
38
- return o = B(o, n, t), o[t] || [];
36
+ function $(t, n, r) {
37
+ let o = { [r]: [...t] };
38
+ return o = x(o, n, r), o[r] || [];
39
39
  }
40
- function N(r, n, t) {
40
+ function k(t, n, r) {
41
41
  const o = [], e = [];
42
- for (let c = r.length - 1; c >= 0; c--) {
43
- const a = r[c];
42
+ for (let c = t.length - 1; c >= 0; c--) {
43
+ const l = t[c];
44
44
  o.push({
45
- root: a,
46
- data: n(a),
45
+ root: l,
46
+ data: n(l),
47
47
  level: [c],
48
- levelCount: r.length
48
+ levelCount: t.length
49
49
  });
50
50
  }
51
51
  for (; o.length > 0; ) {
@@ -53,70 +53,86 @@ function N(r, n, t) {
53
53
  if (e.push({
54
54
  dataItem: c.root,
55
55
  level: [...c.level],
56
- ...t(c.root),
56
+ ...r(c.root),
57
57
  levelCount: c.levelCount
58
58
  }), c.data.length)
59
- for (let a = c.data.length - 1; a >= 0; a--) {
60
- const h = c.data[a];
59
+ for (let l = c.data.length - 1; l >= 0; l--) {
60
+ const a = c.data[l];
61
61
  o.push({
62
- root: h,
63
- data: n(h),
64
- level: [...c.level, a],
62
+ root: a,
63
+ data: n(a),
64
+ level: [...c.level, l],
65
65
  levelCount: c.data.length
66
66
  });
67
67
  }
68
68
  }
69
69
  return e;
70
70
  }
71
- const S = (r, n, t) => {
72
- const o = (l) => !!i(n, l), e = (l) => !!i(t, l), c = (l) => {
71
+ const N = (t, n, r) => {
72
+ const o = (h) => !!g(n, h), e = (h) => !!g(r, h), c = (h) => {
73
73
  const f = [];
74
- return o(l) && e(l) && f.push(...i(t, l)), f;
75
- }, a = (l, f, p) => {
76
- f.push({ ...l, level: p }), c(l).forEach((x) => a(x, f, p + 1));
77
- }, h = [];
78
- return r.forEach((l) => a(l, h, 0)), h;
79
- }, V = (r, n, t, o) => {
80
- let e = {}, c = [], a;
81
- return r.forEach((h) => e[n(h)] = { ...h }), r.forEach((h) => {
82
- a = e[t(h)], a ? (a[o] = a[o] || [], a[o].push(e[n(h)])) : c.push(e[n(h)]);
74
+ return o(h) && e(h) && f.push(...g(r, h)), f;
75
+ }, l = (h, f, p) => {
76
+ f.push({ ...h, level: p }), c(h).forEach((D) => l(D, f, p + 1));
77
+ }, a = [];
78
+ return t.forEach((h) => l(h, a, 0)), a;
79
+ }, V = (t, n, r, o) => {
80
+ let e = {}, c = [], l;
81
+ return t.forEach((a) => e[n(a)] = { ...a }), t.forEach((a) => {
82
+ l = e[r(a)], l ? (l[o] = l[o] || [], l[o].push(e[n(a)])) : c.push(e[n(a)]);
83
83
  }), c;
84
- }, j = (r, n, t) => y(r, n, t), q = (r, n, t) => [...v(
85
- [{ [n]: [...r] }],
84
+ }, j = (t, n, r) => y(t, n, r), q = (t, n, r) => [...C(
85
+ [{ [n]: [...t] }],
86
86
  n,
87
- (e) => T(e, t, n)
88
- )[0][n]], T = (r, n, t) => {
89
- const o = r[t] || [], e = o.findIndex(n);
87
+ (e) => T(e, r, n)
88
+ )[0][n]], T = (t, n, r) => {
89
+ const o = t[r] || [], e = o.findIndex(n);
90
90
  if (e !== -1) {
91
91
  const c = [...o];
92
92
  return c.splice(e, 1), {
93
- ...r,
94
- [t]: c
93
+ ...t,
94
+ [r]: c
95
95
  };
96
96
  }
97
- return r;
98
- }, z = (r, n, t, o) => v(
99
- r,
97
+ return t;
98
+ }, z = (t, n, r, o) => C(
99
+ t,
100
100
  n,
101
- (e) => t(e) ? { ...e, [n]: o(e[n] || []) } : e
102
- ), u = (r, n, t) => P(r, n, t), A = (r, n, t, o) => {
103
- const e = [...r], c = u(e, n, o), a = c.pop(), h = c.pop(), l = n[n.length - 1];
104
- if (t) {
105
- const p = u(e, t, o).pop();
106
- (h ? h[o] : e).splice(l, 1), p[o] = p[o] || [], p[o].push(a);
101
+ (e) => r(e) ? { ...e, [n]: o(e[n] || []) } : e
102
+ ), u = (t, n, r) => P(t, n, r), A = (t, n, r, o) => {
103
+ const e = [...t], c = u(e, n, o), l = c.pop(), a = c.pop(), h = n[n.length - 1];
104
+ if (r) {
105
+ const p = u(e, r, o).pop();
106
+ (a ? a[o] : e).splice(h, 1), p[o] = p[o] || [], p[o].push(l);
107
107
  } else
108
- (h ? h[o] : e).splice(l, 1), e.push(a);
108
+ (a ? a[o] : e).splice(h, 1), e.push(l);
109
109
  return e;
110
+ }, G = (t, n) => ({
111
+ ...t,
112
+ filters: t.filters.map((r) => ({ ...r, value: n }))
113
+ }), H = (t) => t != null && t.filters.length && t.filters[0].value || "", J = (t, n) => {
114
+ if (n && !t)
115
+ return n;
116
+ if (t && !n)
117
+ return t;
118
+ if (t && n)
119
+ return {
120
+ logic: "and",
121
+ filters: [t, n]
122
+ };
110
123
  };
111
124
  export {
125
+ J as combineFilters,
112
126
  V as createDataTree,
113
127
  j as extendDataItem,
114
- k as filterBy,
115
- N as flatData,
128
+ $ as filterBy,
129
+ k as flatData,
116
130
  u as getItemPath,
131
+ G as getSearchFromString,
132
+ H as getStringFromSearch,
117
133
  z as modifySubItems,
118
134
  A as moveTreeItem,
119
- $ as orderBy,
135
+ E as orderBy,
120
136
  q as removeItems,
121
- S as treeToFlat
137
+ N as treeToFlat
122
138
  };