@veeqo/transfigure 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/types.d.ts +4 -0
- package/dist/hooks/usePersistUnsavedChanges/usePersistUnsavedChanges.d.ts +1 -0
- package/dist/index100.cjs +1 -1
- package/dist/index100.js +19 -48
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +17 -28
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +24 -21
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +14 -17
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +49 -23
- package/dist/index108.cjs +1 -80
- package/dist/index108.js +28 -97
- package/dist/index109.cjs +80 -1
- package/dist/index109.js +98 -19
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index110.cjs +1 -1
- package/dist/index110.js +18 -7
- package/dist/index111.cjs +1 -1
- package/dist/index111.js +7 -60
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +57 -26
- package/dist/index113.cjs +1 -13
- package/dist/index113.js +30 -17
- package/dist/index115.cjs +13 -1
- package/dist/index115.js +15 -24
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +22 -32
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +36 -5
- package/dist/index118.cjs +1 -1
- package/dist/index118.js +5 -63
- package/dist/index119.cjs +1 -7
- package/dist/index119.js +63 -10
- package/dist/index120.cjs +7 -1
- package/dist/index120.js +10 -47
- package/dist/index121.cjs +1 -0
- package/dist/index121.js +49 -0
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +2 -2
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +1 -1
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +1 -1
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +1 -1
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +1 -1
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +1 -1
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +1 -1
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +2 -2
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +42 -44
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +41 -40
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +236 -209
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +1 -1
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +4 -116
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +115 -39
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +41 -9
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +9 -2
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +2 -5
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +2 -2
- package/dist/index94.cjs +1 -1
- package/dist/index94.js +2 -2
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +8 -14
- package/dist/mobx/Filters/Filters.d.ts +12 -1
- package/dist/storybookHelpers/StoryWrapper.d.ts +1 -1
- package/dist/utils/sortUtils/index.d.ts +2 -0
- package/dist/utils/sortUtils/sortUtils.d.ts +11 -0
- package/dist/utils/sortUtils/sortUtils.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/index61.js
CHANGED
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { parseDate as
|
|
3
|
-
import { NumberRangeFilter as
|
|
4
|
-
import { RangeFilter as
|
|
5
|
-
import { useViews as
|
|
6
|
-
import { useBusinessLogic as
|
|
7
|
-
import { useStores as
|
|
8
|
-
import { patchCustomView as
|
|
9
|
-
const
|
|
10
|
-
const {
|
|
11
|
-
DATE_RANGE_FILTERS: a,
|
|
12
|
-
NUMBER_RANGE_FILTERS: g,
|
|
13
|
-
SEARCH_FILTER_ID: u,
|
|
14
|
-
VIEW_TYPE: w
|
|
15
|
-
} = N(), {
|
|
1
|
+
import { useState as I } from "react";
|
|
2
|
+
import { parseDate as g } from "@internationalized/date";
|
|
3
|
+
import { NumberRangeFilter as M } from "./index70.js";
|
|
4
|
+
import { RangeFilter as V } from "./index71.js";
|
|
5
|
+
import { useViews as N } from "./index63.js";
|
|
6
|
+
import { useBusinessLogic as v } from "./index8.js";
|
|
7
|
+
import { useStores as C } from "./index62.js";
|
|
8
|
+
import { patchCustomView as O } from "./index5.js";
|
|
9
|
+
const B = () => {
|
|
10
|
+
const { DATE_RANGE_FILTERS: a, NUMBER_RANGE_FILTERS: u, SEARCH_FILTER_ID: w, VIEW_TYPE: y } = v(), {
|
|
16
11
|
Filters: {
|
|
17
12
|
activeViewId: o,
|
|
18
|
-
filters:
|
|
19
|
-
arrayFilters:
|
|
20
|
-
dateRangeFilters:
|
|
21
|
-
numberRangeFilters:
|
|
22
|
-
initFiltersFromView:
|
|
13
|
+
filters: F,
|
|
14
|
+
arrayFilters: b,
|
|
15
|
+
dateRangeFilters: d,
|
|
16
|
+
numberRangeFilters: E,
|
|
17
|
+
initFiltersFromView: A,
|
|
23
18
|
pageSize: l
|
|
24
19
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
Table: { sortParam: f },
|
|
21
|
+
Views: { draftViewsMap: S },
|
|
22
|
+
Notifications: { notify: h }
|
|
23
|
+
} = C(), { viewsMap: n, mutate: T } = N(), [R, c] = I(!1), m = () => {
|
|
28
24
|
if (!o) throw Error("No active view");
|
|
29
25
|
const r = {};
|
|
30
|
-
Array.from(
|
|
26
|
+
Array.from(F.entries()).filter(([e, t]) => t !== "" && e !== w).forEach(([e, t]) => {
|
|
31
27
|
r[e] = t;
|
|
32
|
-
}), Array.from(
|
|
28
|
+
}), Array.from(b.entries()).filter(([, e]) => e.length > 0).forEach(([e, t]) => {
|
|
33
29
|
r[e] = t;
|
|
34
|
-
}), Array.from(
|
|
30
|
+
}), Array.from(d.entries()).filter(([, e]) => e.filterType !== void 0).forEach(([e, t]) => {
|
|
35
31
|
t.filterType === "CUSTOM" ? r[e] = {
|
|
36
32
|
gte: t.gte.toString(),
|
|
37
33
|
lte: t.lte.toString()
|
|
38
34
|
} : r[e] = t.filterType;
|
|
39
|
-
}), Array.from(
|
|
35
|
+
}), Array.from(E.entries()).filter(([, e]) => e.gte !== void 0 || e.lte !== void 0).forEach(([e, t]) => {
|
|
40
36
|
r[e] = {}, t.gte !== void 0 && (r[e].gte = t.gte.toString()), t.isValidLte && t.lte && (r[e].lte = t.lte.toString());
|
|
41
37
|
});
|
|
42
|
-
let s =
|
|
43
|
-
return
|
|
44
|
-
type:
|
|
38
|
+
let s = n.get(o);
|
|
39
|
+
return n.has(o) || (s = S.get(o)), { arg: {
|
|
40
|
+
type: y,
|
|
45
41
|
filters: {
|
|
46
42
|
filter: r,
|
|
43
|
+
sort: f,
|
|
47
44
|
page: {
|
|
48
45
|
size: Number(l)
|
|
49
46
|
}
|
|
@@ -52,14 +49,14 @@ const x = () => {
|
|
|
52
49
|
}, currentView: s };
|
|
53
50
|
};
|
|
54
51
|
return {
|
|
55
|
-
getActiveViewInAPIFormat:
|
|
52
|
+
getActiveViewInAPIFormat: m,
|
|
56
53
|
saveChanges: async () => {
|
|
57
54
|
if (o)
|
|
58
55
|
try {
|
|
59
|
-
|
|
60
|
-
const { arg: r, currentView: s } =
|
|
61
|
-
await
|
|
62
|
-
const
|
|
56
|
+
c(!0);
|
|
57
|
+
const { arg: r, currentView: s } = m();
|
|
58
|
+
await O(o, { attributes: r }), await T();
|
|
59
|
+
const p = {
|
|
63
60
|
...s,
|
|
64
61
|
filterMaps: {
|
|
65
62
|
filters: new Map(
|
|
@@ -72,31 +69,32 @@ const x = () => {
|
|
|
72
69
|
),
|
|
73
70
|
rangeFilters: new Map(
|
|
74
71
|
Object.entries(r.filters.filter).filter(([e]) => a.includes(e)).map(([e, t]) => {
|
|
75
|
-
const i = new
|
|
76
|
-
return typeof t == "object" ? (i.setFilterType("CUSTOM"), i.setDates(
|
|
72
|
+
const i = new V();
|
|
73
|
+
return typeof t == "object" ? (i.setFilterType("CUSTOM"), i.setDates(g(t.gte), g(t.lte))) : i.setFilterType(t), [e, i];
|
|
77
74
|
})
|
|
78
75
|
),
|
|
79
76
|
numberRangeFilters: new Map(
|
|
80
|
-
Object.entries(r.filters.filter).filter(([e]) =>
|
|
81
|
-
const i = new
|
|
77
|
+
Object.entries(r.filters.filter).filter(([e]) => u.includes(e)).map(([e, t]) => {
|
|
78
|
+
const i = new M({ filterId: e });
|
|
82
79
|
return t.gte && i.setGte(Number(t.gte)), t.lte && i.setLte(Number(t.lte)), [e, i];
|
|
83
80
|
})
|
|
84
81
|
)
|
|
85
82
|
},
|
|
86
83
|
page: {
|
|
87
84
|
size: l
|
|
88
|
-
}
|
|
85
|
+
},
|
|
86
|
+
sort: f
|
|
89
87
|
};
|
|
90
|
-
|
|
88
|
+
A(p);
|
|
91
89
|
} catch (r) {
|
|
92
|
-
console.log(r),
|
|
90
|
+
console.log(r), h({ type: "error", text: "Failed to save changes to your view" });
|
|
93
91
|
} finally {
|
|
94
|
-
|
|
92
|
+
c(!1);
|
|
95
93
|
}
|
|
96
94
|
},
|
|
97
95
|
isSubmitting: R
|
|
98
96
|
};
|
|
99
97
|
};
|
|
100
98
|
export {
|
|
101
|
-
|
|
99
|
+
B as usePersistUnsavedChanges
|
|
102
100
|
};
|
package/dist/index68.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),a=require("./index2.cjs"),w=require("./index99.cjs"),M=require("qs"),y=require("./index8.cjs"),_=require("./index62.cjs"),k=e=>e&&e.__esModule?e:{default:e},n=k(M),p=()=>{const{SORT_FILTER_ID:e,SORTING_MODE:s}=y.useBusinessLogic(),{Filters:{queryParamsObject:d,activeViewId:g},Table:{sortParam:o,sortState:t,setSortState:u}}=_.useStores(),I=!!g,O=c.useMemo(()=>{const r={...d};switch(s){case a.SortingMode.CORAL:t.columnId&&(r.sort_order=t.direction,r.sort=t.columnId);break;case a.SortingMode.MONOLITH:default:o&&(r[e]=o)}return n.default.stringify(r,{arrayFormat:"brackets"})},[d,o,s,e,t]),l=c.useCallback(()=>{const r=n.default.parse(window.location.search,{ignoreQueryPrefix:!0});switch(s){case a.SortingMode.CORAL:if(!t.columnId||r.sort_order===t.direction&&r.sort===t.columnId)break;r.sort_order=t.direction,r.sort=t.columnId;break;case a.SortingMode.MONOLITH:default:if(!o)break;if(r[e]===o)return;r[e]=o}const i=n.default.stringify(r,{arrayFormat:"brackets"});i&&window.history.replaceState({},"",`${window.location.pathname}?${i}`)},[s,e,o,t]),f=c.useCallback(()=>{const r=n.default.parse(window.location.search,{ignoreQueryPrefix:!0}),i=r[e],S=r.sort_order,m=r.sort;switch(s){case a.SortingMode.CORAL:S&&m&&u({columnId:m,direction:S});break;case a.SortingMode.MONOLITH:default:{if(!i)break;const b=w.parseSortString(i);b.columnId&&u(b)}}},[s,e,u]);return c.useEffect(()=>{f()},[f]),c.useEffect(()=>{l()},[t,l]),{queryParams:O,hasActiveView:I,updateCurrentUrlWithTableSort:l}};exports.useUrlParams=p;
|
package/dist/index68.js
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { SortingMode as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { useMemo as h, useCallback as p, useEffect as I } from "react";
|
|
2
|
+
import { SortingMode as a } from "./index2.js";
|
|
3
|
+
import { parseSortString as k } from "./index99.js";
|
|
4
|
+
import c from "qs";
|
|
5
|
+
import { useBusinessLogic as y } from "./index8.js";
|
|
6
|
+
import { useStores as L } from "./index62.js";
|
|
6
7
|
const C = () => {
|
|
7
|
-
const { SORT_FILTER_ID:
|
|
8
|
-
Filters: { queryParamsObject:
|
|
9
|
-
Table: { sortParam:
|
|
10
|
-
} =
|
|
11
|
-
const r = { ...
|
|
12
|
-
switch (
|
|
13
|
-
case
|
|
8
|
+
const { SORT_FILTER_ID: o, SORTING_MODE: s } = y(), {
|
|
9
|
+
Filters: { queryParamsObject: m, activeViewId: b },
|
|
10
|
+
Table: { sortParam: e, sortState: t, setSortState: n }
|
|
11
|
+
} = L(), w = !!b, O = h(() => {
|
|
12
|
+
const r = { ...m };
|
|
13
|
+
switch (s) {
|
|
14
|
+
case a.CORAL:
|
|
14
15
|
t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
|
|
15
16
|
break;
|
|
16
|
-
case
|
|
17
|
+
case a.MONOLITH:
|
|
17
18
|
default:
|
|
18
|
-
|
|
19
|
+
e && (r[o] = e);
|
|
19
20
|
}
|
|
20
|
-
return
|
|
21
|
-
}, [
|
|
22
|
-
const r =
|
|
23
|
-
switch (
|
|
24
|
-
case
|
|
21
|
+
return c.stringify(r, { arrayFormat: "brackets" });
|
|
22
|
+
}, [m, e, s, o, t]), u = p(() => {
|
|
23
|
+
const r = c.parse(window.location.search, { ignoreQueryPrefix: !0 });
|
|
24
|
+
switch (s) {
|
|
25
|
+
case a.CORAL:
|
|
25
26
|
if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
|
|
26
27
|
break;
|
|
27
28
|
r.sort_order = t.direction, r.sort = t.columnId;
|
|
28
29
|
break;
|
|
29
|
-
case
|
|
30
|
+
case a.MONOLITH:
|
|
30
31
|
default:
|
|
31
|
-
if (!
|
|
32
|
-
if (r[
|
|
33
|
-
r[
|
|
32
|
+
if (!e) break;
|
|
33
|
+
if (r[o] === e) return;
|
|
34
|
+
r[o] = e;
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
const r =
|
|
39
|
-
switch (
|
|
40
|
-
case
|
|
41
|
-
|
|
36
|
+
const i = c.stringify(r, { arrayFormat: "brackets" });
|
|
37
|
+
i && window.history.replaceState({}, "", `${window.location.pathname}?${i}`);
|
|
38
|
+
}, [s, o, e, t]), d = p(() => {
|
|
39
|
+
const r = c.parse(window.location.search, { ignoreQueryPrefix: !0 }), i = r[o], l = r.sort_order, f = r.sort;
|
|
40
|
+
switch (s) {
|
|
41
|
+
case a.CORAL:
|
|
42
|
+
l && f && n({ columnId: f, direction: l });
|
|
42
43
|
break;
|
|
43
|
-
case
|
|
44
|
+
case a.MONOLITH:
|
|
44
45
|
default: {
|
|
45
|
-
if (!
|
|
46
|
-
const S =
|
|
47
|
-
|
|
46
|
+
if (!i) break;
|
|
47
|
+
const S = k(i);
|
|
48
|
+
S.columnId && n(S);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
}, [
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
}, [
|
|
51
|
+
}, [s, o, n]);
|
|
52
|
+
return I(() => {
|
|
53
|
+
d();
|
|
54
|
+
}, [d]), I(() => {
|
|
54
55
|
u();
|
|
55
56
|
}, [t, u]), {
|
|
56
|
-
queryParams:
|
|
57
|
-
hasActiveView:
|
|
57
|
+
queryParams: O,
|
|
58
|
+
hasActiveView: w,
|
|
58
59
|
updateCurrentUrlWithTableSort: u
|
|
59
60
|
};
|
|
60
61
|
};
|
package/dist/index69.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var I=(y,t,l)=>t in y?L(y,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):y[t]=l;var u=(y,t,l)=>I(y,typeof t!="symbol"?t+"":t,l);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("mobx"),N=require("@veeqo/ui"),_=require("@internationalized/date"),V=require("lodash/isEqual"),O=require("lodash/get"),U=require("lodash/set"),B=require("qs"),F=require("./index50.cjs"),P=require("./index2.cjs"),b=require("./index71.cjs"),v=require("./index70.cjs"),G=require("./index80.cjs"),C=require("./index78.cjs"),d=require("./index9.cjs"),T=y=>y&&y.__esModule?y:{default:y},D=T(V),q=T(O),M=T(U),R=T(B);class z{constructor(){u(this,"defaultPageSize");u(this,"pageSize");u(this,"currentPage");u(this,"defaultFilters");u(this,"defaultArrayFilters");u(this,"defaultDateRangeFilters");u(this,"defaultNumberRangeFilters");u(this,"filters");u(this,"arrayFilters");u(this,"dateRangeFilters");u(this,"numberRangeFilters");u(this,"activeViewId");u(this,"isFiltersDropdownVisible");u(this,"initDefaultFilterMaps",()=>{this.defaultFilters=new Map(this.filters),this.defaultArrayFilters=new Map(this.arrayFilters),this.defaultDateRangeFilters=new Map(this.dateRangeFilters),this.defaultNumberRangeFilters=new Map(this.numberRangeFilters)});u(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:l,SORTING_MODE:s}=d.BusinessLogicManager.getBusinessLogic(),e=R.default.parse(window.location.search,{ignoreQueryPrefix:!0}),r=e[l],g=e.sort_order,f=e.sort;let o="";switch(s){case P.SortingMode.CORAL:if(g&&f){const c={...this.queryParamsObject,sort:f,sort_order:g};o=`${window.location.pathname}?${R.default.stringify(c,{arrayFormat:"brackets"})}`}break;case P.SortingMode.MONOLITH:default:if(r){const c={...this.queryParamsObject,[l]:r};o=`${window.location.pathname}?${R.default.stringify(c,{arrayFormat:"brackets"})}`}}r||(o=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",o):window.history.replaceState({},"",o)}catch(l){console.log(l)}});u(this,"setCurrentPage",t=>{this.currentPage=t});u(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});u(this,"setFilter",(t,l)=>{this.filters.set(t,l),this.setCurrentPage(1),this.updateUrl()});u(this,"clearFilter",t=>{this.filters.set(t,""),this.setCurrentPage(1),this.updateUrl()});u(this,"setArrayFilter",(t,l)=>{this.arrayFilters.set(t,l),this.setCurrentPage(1),this.updateUrl()});u(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.setCurrentPage(1),this.updateUrl()});u(this,"setRangeFilter",({key:t,range:l,dates:s})=>{l.setFilterType(t),l.setDates(s.start,s.end),this.setCurrentPage(1),this.updateUrl()});u(this,"clearRangeFilter",t=>{const l=this.dateRangeFilters.get(t);l&&(l.clear(),this.setCurrentPage(1),this.updateUrl())});u(this,"setNumberRangeFilter",({numberRange:t,gte:l,lte:s})=>{t.setGte(l),t.setLte(s),this.setCurrentPage(1),this.updateUrl()});u(this,"clearNumberRangeFilter",t=>{const l=this.numberRangeFilters.get(t);l&&(l.clear(),this.setCurrentPage(1),this.updateUrl())});u(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic();this.filters.forEach((s,e)=>{e!==l&&this.filters.set(e,"")}),this.arrayFilters.forEach((s,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(s=>s.clear()),this.numberRangeFilters.forEach(s=>s.clear()),this.setCurrentPage(1),t||this.updateUrl()});u(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:l}=d.BusinessLogicManager.getBusinessLogic(),s=l.get(t);s&&s.fields.forEach(e=>{this.arrayFilters.has(e.id)?this.clearArrayFilter(e.id):this.dateRangeFilters.has(e.id)?this.clearRangeFilter(e.id):this.numberRangeFilters.has(e.id)?this.clearNumberRangeFilter(e.id):this.clearFilter(e.id)})});u(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});u(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});u(this,"getFiltersForGroup",t=>{const{GROUP_MAP:l}=d.BusinessLogicManager.getBusinessLogic(),s=l.get(t);if(!s)return{};const e={};return s.fields.forEach(r=>{this.arrayFilters.has(r.id)?e[r.id]=this.arrayFilters.get(r.id):this.dateRangeFilters.has(r.id)?e[r.id]=this.dateRangeFilters.get(r.id):this.numberRangeFilters.has(r.id)?e[r.id]=this.numberRangeFilters.get(r.id):e[r.id]=this.filters.get(r.id)}),e});u(this,"initFiltersFromView",t=>{var s;const{PAGE_SIZE_OPTIONS:l}=d.BusinessLogicManager.getBusinessLogic();(s=t.page)!=null&&s.size&&l.includes(t.page.size)&&(this.defaultPageSize=t.page.size,this.pageSize=t.page.size),this.setCurrentPage(1),this.defaultFilters=new Map(t.filterMaps.filters),this.defaultArrayFilters=new Map(t.filterMaps.arrayFilters),this.defaultDateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const g=new b.RangeFilter(r.filterType);return r.gte&&r.lte&&g.setDates(r.gte,r.lte),[e,g]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const g=r.clone();return r.gte&&g.setGte(r.gte),r.lte&&g.setLte(r.lte),[e,g]})),this.filters=new Map(t.filterMaps.filters),this.arrayFilters=new Map(t.filterMaps.arrayFilters),this.dateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const g=new b.RangeFilter(r.filterType);return r.gte&&r.lte&&g.setDates(r.gte,r.lte),[e,g]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const g=r.clone();return r.gte&&g.setGte(r.gte),r.lte&&g.setLte(r.lte),[e,g]})),this.activeViewId=t.id});u(this,"initFromUrl",(t=!0)=>{const{GROUP_MAP:l,PAGE_SIZE_OPTIONS:s,PAGE_SIZE_FILTER_ID:e}=d.BusinessLogicManager.getBusinessLogic(),r=R.default.parse(window.location.search,{ignoreQueryPrefix:!0}),g=Array.from(l.values()).flatMap(n=>n.fields),f=new Map,o=new Map,c=new Map,E=new Map;t&&r.view&&(this.activeViewId=r.view),r[e]&&s.includes(Number(r[e]))&&(this.pageSize=Number(r[e]));const S=r.filter||{};g.forEach(n=>{const i=q.default(S,n.id);if(i!==void 0)switch(n.filterType){case F.FilterChoiceValue.CHECKBOX:Array.isArray(i)?o.set(n.id,i):i&&o.set(n.id,[i]);break;case F.FilterChoiceValue.DATE_RANGE:if(typeof i=="string"&&C.isValidDateRange(i))c.set(n.id,new b.RangeFilter(i));else if(typeof i=="object"&&i!==null){const a=i;if(a.relative&&C.isValidDateRange(a.relative))c.set(n.id,new b.RangeFilter(a.relative));else if(a.gte&&a.lte)try{const p=_.parseDate(a.gte),w=_.parseDate(a.lte),m=new b.RangeFilter("CUSTOM");m.setDates(p,w),c.set(n.id,m)}catch{c.set(n.id,new b.RangeFilter(N.DateRanges.TODAY))}}break;case F.FilterChoiceValue.NUMBER_RANGE:if(typeof i=="object"&&i!==null){const a=i,p=new v.NumberRangeFilter({filterId:n.id});a.gte!==void 0&&p.setGte(Number(a.gte)),a.lte!==void 0&&p.setLte(Number(a.lte)),E.set(n.id,p)}break;case F.FilterChoiceValue.TEXT:case F.FilterChoiceValue.NUMBER:case F.FilterChoiceValue.RADIO:(typeof i=="string"||typeof i=="number")&&f.set(n.id,String(i));break}}),this.filters=f,this.arrayFilters=o,this.dateRangeFilters=c,this.numberRangeFilters=E,this.updateUrl()});u(this,"discardChanges",(t=!1)=>{this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic(),s=new Map(this.defaultFilters);this.filters.has(l)&&s.set(l,this.filters.get(l)),this.filters=s,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((e,r)=>{const g=new b.RangeFilter(e.filterType);g.setDates(e.gte,e.lte),this.dateRangeFilters.set(r,g)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((e,r)=>{this.numberRangeFilters.set(r,e.clone())}),this.updateUrl(t)});const{GROUP_MAP:t}=d.BusinessLogicManager.getBusinessLogic(),l=Array.from(t.values()).flatMap(s=>s.fields);this.filters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.TEXT||s.filterType===F.FilterChoiceValue.NUMBER||s.filterType===F.FilterChoiceValue.RADIO||s.filterType===F.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,""])),this.arrayFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.CHECKBOX).map(s=>[s.id,[]])),this.dateRangeFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,new b.RangeFilter])),this.numberRangeFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.NUMBER_RANGE).map(s=>{const e=new v.NumberRangeFilter({filterId:s.id});return[s.id,e]})),this.defaultArrayFilters=new Map,this.defaultFilters=new Map,this.defaultDateRangeFilters=new Map,this.defaultNumberRangeFilters=new Map,this.currentPage=1,this.pageSize=10,this.defaultPageSize=10,this.initDefaultFilterMaps(),this.isFiltersDropdownVisible=!1,this.activeViewId=void 0,h.makeObservable(this,{defaultPageSize:h.observable,pageSize:h.observable,currentPage:h.observable,defaultFilters:h.observable,defaultArrayFilters:h.observable,defaultDateRangeFilters:h.observable,defaultNumberRangeFilters:h.observable,filters:h.observable,arrayFilters:h.observable,numberRangeFilters:h.observable,dateRangeFilters:h.observable,isFiltersDropdownVisible:h.observable,activeViewId:h.observable,setPageSize:h.action,setCurrentPage:h.action,toggleFiltersDropdownVisible:h.action,setActiveViewId:h.action,setFilter:h.action,setArrayFilter:h.action,setRangeFilter:h.action,setNumberRangeFilter:h.action,clearFilter:h.action,clearArrayFilter:h.action,clearRangeFilter:h.action,clearNumberRangeFilter:h.action,clearAllFilters:h.action,getFiltersForGroup:h.action,clearFiltersForGroup:h.action,initFromUrl:h.action,initFiltersFromView:h.action,initDefaultFilterMaps:h.action,discardChanges:h.action,updateUrl:h.action,hasActiveFilters:h.computed,activeFilterKeysList:h.computed,queryParamsObject:h.computed,queryParams:h.computed,hasUnsavedChanges:h.computed})}get hasActiveFilters(){const{GROUP_MAP:t}=d.BusinessLogicManager.getBusinessLogic(),l=Array.from(t.values()).flatMap(e=>e.fields),s=new Set(l.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:l}=d.BusinessLogicManager.getBusinessLogic(),s=Array.from(this.filters.entries()).filter(([o,c])=>c!==""&&!t.includes(o)&&!l.includes(o)).map(([o])=>o),e=Array.from(this.arrayFilters.entries()).filter(([,o])=>o.length>0).map(([o])=>o),r=Array.from(this.dateRangeFilters.entries()).filter(([,o])=>o.filterType!==void 0).map(([o])=>o),g=Array.from(this.numberRangeFilters.entries()).filter(([,o])=>o.isActive).map(([o])=>o);return[...new Set([...s,...e,...r,...g])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:l,PAGE_SIZE_FILTER_ID:s,PAGE_NUMBER_FILTER_ID:e}=d.BusinessLogicManager.getBusinessLogic(),r={};Array.from(this.filters.entries()).filter(([f,o])=>o!==""&&!t.includes(f)&&!l.includes(f)).forEach(([f,o])=>{M.default(r,f,o)}),Array.from(this.arrayFilters.entries()).filter(([,f])=>f.length>0).forEach(([f,o])=>{M.default(r,f,o)}),Array.from(this.dateRangeFilters.entries()).filter(([,f])=>f.filterType!==void 0).forEach(([f,o])=>{o.filterType==="CUSTOM"?M.default(r,f,{gte:o.gte.toString(),lte:o.lte.toString()}):M.default(r,f,{relative:o.filterType})}),Array.from(this.numberRangeFilters.entries()).filter(([,f])=>f.isActive).forEach(([f,o])=>{const c={};o.gte!==void 0&&(c.gte=o.gte),o.isValidLte&&(c.lte=o.lte),M.default(r,f,c)});const g={filter:r,[s]:String(this.pageSize),[e]:String(this.currentPage)};return this.activeViewId&&(g.view=this.activeViewId),g}get queryParams(){return R.default.stringify(this.queryParamsObject,{arrayFormat:"brackets"})}get hasUnsavedChanges(){if(this.activeViewId===G.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize)return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(n=>n.fields),e=new Set(s.map(n=>n.id));if(Array.from(this.filters.entries()).filter(([n])=>n!==l&&e.has(n)).some(([n,i])=>{const a=this.defaultFilters.get(n);return a===void 0&&i!==""||a!==void 0&&i!==a}))return!0;const g=Array.from(this.defaultArrayFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultArrayFilters.get(n)||[];return i.length>0||a.length>0?i.length!==a.length||!D.default(i,a):!1}),f=Array.from(this.arrayFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultArrayFilters.get(n)||[];return i.length>0||a.length>0?i.length!==a.length||!D.default(i,a):!1});if(g||f)return!0;const o=Array.from(this.numberRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultNumberRangeFilters.get(n);return!i.isEqual(a)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.numberRangeFilters.get(n);return!i.isEqual(a)})||o)return!0;const E=Array.from(this.defaultDateRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{var p,w,m,A;const a=this.dateRangeFilters.get(n);return i!=null&&i.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(i!=null&&i.filterType)||(a==null?void 0:a.filterType)!==(i==null?void 0:i.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(i==null?void 0:i.filterType)==="CUSTOM"?((p=i.gte)==null?void 0:p.toString())!==((w=a.gte)==null?void 0:w.toString())||((m=i.lte)==null?void 0:m.toString())!==((A=a.lte)==null?void 0:A.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{var p,w,m,A;const a=this.defaultDateRangeFilters.get(n);return i!=null&&i.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(i!=null&&i.filterType)||(a==null?void 0:a.filterType)!==(i==null?void 0:i.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(i==null?void 0:i.filterType)==="CUSTOM"?((p=i.gte)==null?void 0:p.toString())!==((w=a.gte)==null?void 0:w.toString())||((m=i.lte)==null?void 0:m.toString())!==((A=a.lte)==null?void 0:A.toString()):!1})||E}}exports.Filters=z;
|
|
1
|
+
"use strict";var V=Object.defineProperty;var B=(b,t,s)=>t in b?V(b,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):b[t]=s;var h=(b,t,s)=>B(b,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("mobx"),G=require("@veeqo/ui"),I=require("@internationalized/date"),q=require("lodash/isEqual"),z=require("lodash/get"),j=require("lodash/set"),K=require("qs"),m=require("./index50.cjs"),C=require("./index2.cjs"),A=require("./index71.cjs"),D=require("./index70.cjs"),L=require("./index99.cjs"),k=require("./index80.cjs"),N=require("./index78.cjs"),p=require("./index9.cjs"),_=b=>b&&b.__esModule?b:{default:b},O=_(q),H=_(z),E=_(j),T=_(K);class ${constructor(t){h(this,"defaultPageSize");h(this,"pageSize");h(this,"currentPage");h(this,"defaultFilters");h(this,"defaultArrayFilters");h(this,"defaultDateRangeFilters");h(this,"defaultNumberRangeFilters");h(this,"filters");h(this,"arrayFilters");h(this,"dateRangeFilters");h(this,"numberRangeFilters");h(this,"activeViewId");h(this,"defaultSortState");h(this,"tableStore");h(this,"isFiltersDropdownVisible");h(this,"initDefaultFilterMaps",()=>{this.defaultFilters=new Map(this.filters),this.defaultArrayFilters=new Map(this.arrayFilters),this.defaultDateRangeFilters=new Map(this.dateRangeFilters),this.defaultNumberRangeFilters=new Map(this.numberRangeFilters),this.defaultSortState={columnId:"",direction:"asc"}});h(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:s,SORTING_MODE:n}=p.BusinessLogicManager.getBusinessLogic(),e=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),u=e[s],f=e.sort_order,i=e.sort;let r="";switch(n){case C.SortingMode.CORAL:if(f&&i){const d={...this.queryParamsObject,sort:i,sort_order:f};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}break;case C.SortingMode.MONOLITH:default:if(u){const d={...this.queryParamsObject,[s]:u};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}}u||(r=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",r):window.history.replaceState({},"",r)}catch(s){console.log(s)}});h(this,"setCurrentPage",t=>{this.currentPage=t});h(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});h(this,"setFilter",(t,s)=>{this.filters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearFilter",t=>{this.filters.set(t,""),this.setCurrentPage(1),this.updateUrl()});h(this,"setArrayFilter",(t,s)=>{this.arrayFilters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.setCurrentPage(1),this.updateUrl()});h(this,"setRangeFilter",({key:t,range:s,dates:n})=>{s.setFilterType(t),s.setDates(n.start,n.end),this.setCurrentPage(1),this.updateUrl()});h(this,"clearRangeFilter",t=>{const s=this.dateRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"setNumberRangeFilter",({numberRange:t,gte:s,lte:n})=>{t.setGte(s),t.setLte(n),this.setCurrentPage(1),this.updateUrl()});h(this,"clearNumberRangeFilter",t=>{const s=this.numberRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic();this.filters.forEach((n,e)=>{e!==s&&this.filters.set(e,"")}),this.arrayFilters.forEach((n,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(n=>n.clear()),this.numberRangeFilters.forEach(n=>n.clear()),this.setCurrentPage(1),t||this.updateUrl()});h(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);n&&n.fields.forEach(e=>{this.arrayFilters.has(e.id)?this.clearArrayFilter(e.id):this.dateRangeFilters.has(e.id)?this.clearRangeFilter(e.id):this.numberRangeFilters.has(e.id)?this.clearNumberRangeFilter(e.id):this.clearFilter(e.id)})});h(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});h(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});h(this,"getFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);if(!n)return{};const e={};return n.fields.forEach(u=>{this.arrayFilters.has(u.id)?e[u.id]=this.arrayFilters.get(u.id):this.dateRangeFilters.has(u.id)?e[u.id]=this.dateRangeFilters.get(u.id):this.numberRangeFilters.has(u.id)?e[u.id]=this.numberRangeFilters.get(u.id):e[u.id]=this.filters.get(u.id)}),e});h(this,"initFiltersFromView",t=>{var e,u;const{PAGE_SIZE_OPTIONS:s}=p.BusinessLogicManager.getBusinessLogic();(e=t.page)!=null&&e.size&&s.includes(t.page.size)&&(this.defaultPageSize=t.page.size,this.pageSize=t.page.size),this.setCurrentPage(1),this.defaultFilters=new Map(t.filterMaps.filters),this.defaultArrayFilters=new Map(t.filterMaps.arrayFilters),this.defaultDateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]})),this.filters=new Map(t.filterMaps.filters),this.arrayFilters=new Map(t.filterMaps.arrayFilters),this.dateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]}));const n=L.parseSortString(t.sort);this.defaultSortState=n,(u=this.tableStore)==null||u.setSortState(n),this.activeViewId=t.id});h(this,"initFromUrl",(t=!0)=>{var S,w;const{GROUP_MAP:s,PAGE_SIZE_OPTIONS:n,PAGE_SIZE_FILTER_ID:e,SORT_FILTER_ID:u}=p.BusinessLogicManager.getBusinessLogic(),f=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),i=Array.from(s.values()).flatMap(F=>F.fields),r=new Map,d=new Map,M=new Map,P=new Map;t&&f.view&&(this.activeViewId=f.view),f[e]&&n.includes(Number(f[e]))&&(this.pageSize=Number(f[e]));const c=f.filter||{};i.forEach(F=>{const g=H.default(c,F.id);if(g!==void 0)switch(F.filterType){case m.FilterChoiceValue.CHECKBOX:Array.isArray(g)?d.set(F.id,g):g&&d.set(F.id,[g]);break;case m.FilterChoiceValue.DATE_RANGE:if(typeof g=="string"&&N.isValidDateRange(g))M.set(F.id,new A.RangeFilter(g));else if(typeof g=="object"&&g!==null){const y=g;if(y.relative&&N.isValidDateRange(y.relative))M.set(F.id,new A.RangeFilter(y.relative));else if(y.gte&&y.lte)try{const R=I.parseDate(y.gte),U=I.parseDate(y.lte),v=new A.RangeFilter("CUSTOM");v.setDates(R,U),M.set(F.id,v)}catch{M.set(F.id,new A.RangeFilter(G.DateRanges.TODAY))}}break;case m.FilterChoiceValue.NUMBER_RANGE:if(typeof g=="object"&&g!==null){const y=g,R=new D.NumberRangeFilter({filterId:F.id});y.gte!==void 0&&R.setGte(Number(y.gte)),y.lte!==void 0&&R.setLte(Number(y.lte)),P.set(F.id,R)}break;case m.FilterChoiceValue.TEXT:case m.FilterChoiceValue.NUMBER:case m.FilterChoiceValue.RADIO:(typeof g=="string"||typeof g=="number")&&r.set(F.id,String(g));break}}),this.filters=r,this.arrayFilters=d,this.dateRangeFilters=M,this.numberRangeFilters=P;const l=f[u]||f.sort,a=f.sort_order;if(a&&f.sort)(S=this.tableStore)==null||S.setSortState({columnId:f.sort,direction:a});else if(l){const F=L.parseSortString(l);F.columnId&&((w=this.tableStore)==null||w.setSortState(F))}this.updateUrl()});h(this,"discardChanges",(t=!1)=>{var e;this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=new Map(this.defaultFilters);this.filters.has(s)&&n.set(s,this.filters.get(s)),this.filters=n,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((u,f)=>{const i=new A.RangeFilter(u.filterType);i.setDates(u.gte,u.lte),this.dateRangeFilters.set(f,i)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((u,f)=>{this.numberRangeFilters.set(f,u.clone())}),(e=this.tableStore)==null||e.setSortState(this.defaultSortState),this.updateUrl(t)});const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(s.values()).flatMap(e=>e.fields);this.filters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.TEXT||e.filterType===m.FilterChoiceValue.NUMBER||e.filterType===m.FilterChoiceValue.RADIO||e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,""])),this.arrayFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.CHECKBOX).map(e=>[e.id,[]])),this.dateRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,new A.RangeFilter])),this.numberRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.NUMBER_RANGE).map(e=>{const u=new D.NumberRangeFilter({filterId:e.id});return[e.id,u]})),this.defaultArrayFilters=new Map,this.defaultFilters=new Map,this.defaultDateRangeFilters=new Map,this.defaultNumberRangeFilters=new Map,this.currentPage=1,this.pageSize=10,this.defaultPageSize=10,this.initDefaultFilterMaps(),this.isFiltersDropdownVisible=!1,this.activeViewId=void 0,this.defaultSortState={columnId:"",direction:"asc"},this.tableStore=t,o.makeObservable(this,{defaultPageSize:o.observable,pageSize:o.observable,currentPage:o.observable,defaultFilters:o.observable,defaultArrayFilters:o.observable,defaultDateRangeFilters:o.observable,defaultNumberRangeFilters:o.observable,filters:o.observable,arrayFilters:o.observable,numberRangeFilters:o.observable,dateRangeFilters:o.observable,isFiltersDropdownVisible:o.observable,activeViewId:o.observable,defaultSortState:o.observable,tableStore:o.observable.ref,setPageSize:o.action,setCurrentPage:o.action,toggleFiltersDropdownVisible:o.action,setActiveViewId:o.action,setFilter:o.action,setArrayFilter:o.action,setRangeFilter:o.action,setNumberRangeFilter:o.action,clearFilter:o.action,clearArrayFilter:o.action,clearRangeFilter:o.action,clearNumberRangeFilter:o.action,clearAllFilters:o.action,getFiltersForGroup:o.action,clearFiltersForGroup:o.action,initFromUrl:o.action,initFiltersFromView:o.action,initDefaultFilterMaps:o.action,discardChanges:o.action,updateUrl:o.action,hasActiveFilters:o.computed,activeFilterKeysList:o.computed,queryParamsObject:o.computed,queryParams:o.computed,hasUnsavedChanges:o.computed})}get hasActiveFilters(){const{GROUP_MAP:t}=p.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(e=>e.fields),n=new Set(s.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(this.filters.entries()).filter(([r,d])=>d!==""&&!t.includes(r)&&!s.includes(r)).map(([r])=>r),e=Array.from(this.arrayFilters.entries()).filter(([,r])=>r.length>0).map(([r])=>r),u=Array.from(this.dateRangeFilters.entries()).filter(([,r])=>r.filterType!==void 0).map(([r])=>r),f=Array.from(this.numberRangeFilters.entries()).filter(([,r])=>r.isActive).map(([r])=>r);return[...new Set([...n,...e,...u,...f])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s,PAGE_SIZE_FILTER_ID:n,PAGE_NUMBER_FILTER_ID:e}=p.BusinessLogicManager.getBusinessLogic(),u={};Array.from(this.filters.entries()).filter(([i,r])=>r!==""&&!t.includes(i)&&!s.includes(i)).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.arrayFilters.entries()).filter(([,i])=>i.length>0).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.dateRangeFilters.entries()).filter(([,i])=>i.filterType!==void 0).forEach(([i,r])=>{r.filterType==="CUSTOM"?E.default(u,i,{gte:r.gte.toString(),lte:r.lte.toString()}):E.default(u,i,{relative:r.filterType})}),Array.from(this.numberRangeFilters.entries()).filter(([,i])=>i.isActive).forEach(([i,r])=>{const d={};r.gte!==void 0&&(d.gte=r.gte),r.isValidLte&&(d.lte=r.lte),E.default(u,i,d)});const f={filter:u,[n]:String(this.pageSize),[e]:String(this.currentPage)};return this.activeViewId&&(f.view=this.activeViewId),f}get queryParams(){return T.default.stringify(this.queryParamsObject,{arrayFormat:"brackets"})}get hasUnsavedChanges(){if(this.activeViewId===k.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize||this.tableStore&&(this.tableStore.sortState.columnId!==this.defaultSortState.columnId||this.tableStore.sortState.direction!==this.defaultSortState.direction))return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(t.values()).flatMap(c=>c.fields),e=new Set(n.map(c=>c.id));if(Array.from(this.filters.entries()).filter(([c])=>c!==s&&e.has(c)).some(([c,l])=>{const a=this.defaultFilters.get(c);return a===void 0&&l!==""||a!==void 0&&l!==a}))return!0;const f=Array.from(this.defaultArrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1}),i=Array.from(this.arrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1});if(f||i)return!0;const r=Array.from(this.numberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultNumberRangeFilters.get(c);return!l.isEqual(a)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.numberRangeFilters.get(c);return!l.isEqual(a)})||r)return!0;const M=Array.from(this.defaultDateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.dateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.defaultDateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1})||M}}exports.Filters=$;
|