@veeqo/transfigure 2.1.2 → 2.2.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 (203) hide show
  1. package/dist/components/Views/OptionsDropdown/styled.d.ts +2 -2
  2. package/dist/components/Views/PillNotifications/variants/styled.d.ts +2 -2
  3. package/dist/constants/helpGuideUrls.d.ts +3 -0
  4. package/dist/constants/index.d.ts +1 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +81 -79
  7. package/dist/index100.cjs +1 -1
  8. package/dist/index100.js +49 -14
  9. package/dist/index101.cjs +1 -1
  10. package/dist/index101.js +29 -21
  11. package/dist/index102.cjs +1 -12
  12. package/dist/index102.js +21 -16
  13. package/dist/index103.cjs +19 -1
  14. package/dist/index103.js +24 -7
  15. package/dist/index104.cjs +1 -1
  16. package/dist/index104.js +16 -48
  17. package/dist/index105.cjs +1 -1
  18. package/dist/index105.js +7 -29
  19. package/dist/index106.cjs +10 -78
  20. package/dist/index106.js +13 -95
  21. package/dist/index107.cjs +1 -1
  22. package/dist/index107.js +1 -1
  23. package/dist/index108.cjs +80 -1
  24. package/dist/index108.js +98 -2
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +1 -1
  27. package/dist/index111.cjs +1 -1
  28. package/dist/index111.js +39 -42
  29. package/dist/index114.cjs +1 -1
  30. package/dist/index114.js +2 -26
  31. package/dist/index115.cjs +1 -1
  32. package/dist/index115.js +22 -32
  33. package/dist/index116.cjs +1 -7
  34. package/dist/index116.js +36 -10
  35. package/dist/index118.cjs +1 -1
  36. package/dist/index118.js +1 -1
  37. package/dist/index119.cjs +7 -1
  38. package/dist/index119.js +10 -47
  39. package/dist/index120.cjs +1 -0
  40. package/dist/index120.js +49 -0
  41. package/dist/index13.cjs +1 -1
  42. package/dist/index13.js +2 -2
  43. package/dist/index14.cjs +1 -1
  44. package/dist/index14.js +1 -1
  45. package/dist/index15.cjs +1 -1
  46. package/dist/index15.js +1 -1
  47. package/dist/index16.cjs +1 -1
  48. package/dist/index16.js +2 -2
  49. package/dist/index17.cjs +1 -1
  50. package/dist/index17.js +2 -2
  51. package/dist/index18.cjs +1 -1
  52. package/dist/index18.js +1 -1
  53. package/dist/index19.cjs +1 -1
  54. package/dist/index19.js +4 -4
  55. package/dist/index20.cjs +1 -1
  56. package/dist/index20.js +2 -2
  57. package/dist/index21.cjs +1 -1
  58. package/dist/index21.js +2 -2
  59. package/dist/index22.cjs +1 -1
  60. package/dist/index22.js +2 -2
  61. package/dist/index23.cjs +1 -1
  62. package/dist/index23.js +3 -3
  63. package/dist/index26.cjs +1 -1
  64. package/dist/index26.js +4 -4
  65. package/dist/index27.cjs +1 -1
  66. package/dist/index27.js +4 -4
  67. package/dist/index28.cjs +1 -1
  68. package/dist/index28.js +1 -1
  69. package/dist/index29.cjs +1 -1
  70. package/dist/index29.js +2 -2
  71. package/dist/index3.cjs +1 -1
  72. package/dist/index3.js +2 -2
  73. package/dist/index30.cjs +1 -1
  74. package/dist/index30.js +3 -3
  75. package/dist/index31.cjs +1 -1
  76. package/dist/index31.js +3 -3
  77. package/dist/index32.cjs +1 -1
  78. package/dist/index32.js +1 -1
  79. package/dist/index33.cjs +1 -1
  80. package/dist/index33.js +1 -1
  81. package/dist/index35.cjs +1 -1
  82. package/dist/index35.js +1 -1
  83. package/dist/index36.cjs +1 -1
  84. package/dist/index36.js +6 -6
  85. package/dist/index37.cjs +1 -1
  86. package/dist/index37.js +1 -1
  87. package/dist/index38.cjs +1 -1
  88. package/dist/index38.js +1 -1
  89. package/dist/index39.cjs +1 -1
  90. package/dist/index39.js +3 -3
  91. package/dist/index4.cjs +1 -1
  92. package/dist/index4.js +2 -2
  93. package/dist/index40.cjs +1 -1
  94. package/dist/index40.js +3 -3
  95. package/dist/index41.cjs +1 -1
  96. package/dist/index41.js +4 -4
  97. package/dist/index42.cjs +1 -1
  98. package/dist/index42.js +2 -2
  99. package/dist/index44.cjs +1 -1
  100. package/dist/index44.js +4 -4
  101. package/dist/index46.cjs +1 -1
  102. package/dist/index46.js +5 -5
  103. package/dist/index47.cjs +1 -1
  104. package/dist/index47.js +3 -3
  105. package/dist/index49.cjs +1 -1
  106. package/dist/index49.js +4 -9
  107. package/dist/index5.cjs +1 -1
  108. package/dist/index5.js +2 -2
  109. package/dist/index50.cjs +1 -1
  110. package/dist/index50.js +9 -23
  111. package/dist/index51.cjs +1 -1
  112. package/dist/index51.js +23 -2
  113. package/dist/index52.cjs +1 -1
  114. package/dist/index52.js +2 -4
  115. package/dist/index53.cjs +1 -1
  116. package/dist/index53.js +4 -11
  117. package/dist/index54.cjs +1 -1
  118. package/dist/index54.js +10 -12
  119. package/dist/index55.cjs +1 -1
  120. package/dist/index55.js +12 -11
  121. package/dist/index56.cjs +1 -1
  122. package/dist/index56.js +11 -184
  123. package/dist/index57.cjs +1 -1
  124. package/dist/index57.js +183 -25
  125. package/dist/index58.cjs +1 -1
  126. package/dist/index58.js +26 -24
  127. package/dist/index59.cjs +1 -1
  128. package/dist/index59.js +19 -22
  129. package/dist/index6.cjs +1 -1
  130. package/dist/index6.js +2 -2
  131. package/dist/index60.cjs +1 -1
  132. package/dist/index60.js +25 -97
  133. package/dist/index61.cjs +1 -1
  134. package/dist/index61.js +99 -8
  135. package/dist/index62.cjs +1 -1
  136. package/dist/index62.js +8 -33
  137. package/dist/index63.cjs +1 -1
  138. package/dist/index63.js +33 -63
  139. package/dist/index64.cjs +1 -1
  140. package/dist/index64.js +59 -19
  141. package/dist/index65.cjs +1 -1
  142. package/dist/index65.js +23 -18
  143. package/dist/index66.cjs +1 -1
  144. package/dist/index66.js +16 -29
  145. package/dist/index67.cjs +1 -1
  146. package/dist/index67.js +30 -59
  147. package/dist/index68.cjs +1 -1
  148. package/dist/index68.js +60 -349
  149. package/dist/index69.cjs +1 -1
  150. package/dist/index69.js +345 -53
  151. package/dist/index7.cjs +1 -1
  152. package/dist/index7.js +4 -4
  153. package/dist/index70.cjs +1 -1
  154. package/dist/index70.js +48 -47
  155. package/dist/index71.cjs +1 -1
  156. package/dist/index71.js +51 -32
  157. package/dist/index72.cjs +1 -1
  158. package/dist/index72.js +30 -24
  159. package/dist/index73.cjs +1 -1
  160. package/dist/index73.js +26 -32
  161. package/dist/index74.cjs +1 -1
  162. package/dist/index74.js +38 -4
  163. package/dist/index75.cjs +1 -1
  164. package/dist/index75.js +4 -13
  165. package/dist/index76.cjs +1 -1
  166. package/dist/index76.js +12 -16
  167. package/dist/index77.cjs +1 -1
  168. package/dist/index77.js +14 -16
  169. package/dist/index78.cjs +1 -1
  170. package/dist/index78.js +18 -65
  171. package/dist/index79.cjs +1 -1
  172. package/dist/index79.js +66 -24
  173. package/dist/index80.cjs +1 -1
  174. package/dist/index80.js +24 -21
  175. package/dist/index81.cjs +1 -1
  176. package/dist/index81.js +20 -6
  177. package/dist/index82.cjs +1 -1
  178. package/dist/index82.js +7 -2
  179. package/dist/index83.cjs +1 -1
  180. package/dist/index83.js +2 -9
  181. package/dist/index84.cjs +1 -3
  182. package/dist/index84.js +8 -13
  183. package/dist/index85.cjs +3 -1
  184. package/dist/index85.js +13 -8
  185. package/dist/index86.cjs +1 -1
  186. package/dist/index86.js +9 -2
  187. package/dist/index87.cjs +1 -1
  188. package/dist/index87.js +116 -4
  189. package/dist/index88.cjs +1 -1
  190. package/dist/index88.js +39 -114
  191. package/dist/index89.cjs +1 -1
  192. package/dist/index89.js +9 -41
  193. package/dist/index90.cjs +1 -1
  194. package/dist/index90.js +2 -9
  195. package/dist/index91.cjs +1 -1
  196. package/dist/index91.js +4 -17
  197. package/dist/index94.cjs +1 -1
  198. package/dist/index94.js +2 -2
  199. package/dist/index97.cjs +1 -1
  200. package/dist/index97.js +4 -4
  201. package/dist/index99.cjs +1 -19
  202. package/dist/index99.js +14 -23
  203. package/package.json +5 -5
package/dist/index66.js CHANGED
@@ -1,34 +1,21 @@
1
- import c from "lodash/isArray";
2
- import { useBusinessLogic as C } from "./index8.js";
3
- import { useStores as I } from "./index61.js";
4
- import { useViews as f } from "./index62.js";
5
- const v = () => {
6
- var i;
7
- const { DEFAULT_HIDDEN_COLUMNS: r, DEFAULT_VISIBLE_COLUMNS: l } = C(), { Filters: { activeViewId: d } } = I(), { viewsMap: t, isLoading: o, error: n } = f();
8
- if (!d || o)
9
- return {
10
- isLoading: o,
11
- error: n,
12
- orderedColumnIds: void 0,
13
- hiddenColumnIds: []
14
- };
15
- const e = t.get(d), s = (i = e == null ? void 0 : e.columns) == null ? void 0 : i.columnIds;
16
- if (c(s) && s.length > 0) {
17
- const m = [...r, ...l].filter((u) => !s.includes(u));
18
- return {
19
- isLoading: o,
20
- error: n,
21
- orderedColumnIds: s,
22
- hiddenColumnIds: m
23
- };
24
- }
1
+ import { SWR_HOOK_OPTIONS as O } from "./index50.js";
2
+ import S from "swr";
3
+ import { fetcherV1 as h } from "./index56.js";
4
+ const R = ({ type: e }) => {
5
+ var o, t, i, n, r, m, u, c;
6
+ const { data: s, isLoading: _, isValidating: p, error: w, mutate: l } = S("/current_user", h, O), V = (t = (o = s == null ? void 0 : s.settings) == null ? void 0 : o.custom_view_positions) == null ? void 0 : t[e], f = (r = (n = (i = s == null ? void 0 : s.settings) == null ? void 0 : i.default_custom_views) == null ? void 0 : n[e]) == null ? void 0 : r.toString(), C = !!((m = s == null ? void 0 : s.permissions) != null && m.delete_company_custom_views), g = !!((u = s == null ? void 0 : s.permissions) != null && u.update_company_custom_views), v = !!((c = s == null ? void 0 : s.permissions) != null && c.share_custom_views);
25
7
  return {
26
- isLoading: o,
27
- error: n,
28
- orderedColumnIds: void 0,
29
- hiddenColumnIds: r
8
+ canDeleteCustomViews: C,
9
+ canUpdateCustomViews: g,
10
+ canShareCustomViews: v,
11
+ orderedListOfCustomViews: V,
12
+ defaultCustomViewId: f,
13
+ isLoading: _,
14
+ isValidating: p,
15
+ error: w,
16
+ mutate: l
30
17
  };
31
18
  };
32
19
  export {
33
- v as useColumns
20
+ R as useCustomViews
34
21
  };
package/dist/index67.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),c=require("./index2.cjs"),y=require("qs"),_=require("./index8.cjs"),h=require("./index61.cjs"),k=r=>r&&r.__esModule?r:{default:r},n=k(y),L=()=>{const{SORT_FILTER_ID:r,SORTING_MODE:a}=_.useBusinessLogic(),{Filters:{queryParamsObject:l,activeViewId:g},Table:{sortParam:o,sortState:t,setSortState:u}}=h.useStores(),I=!!g,O=i.useMemo(()=>{const e={...l};switch(a){case c.SortingMode.CORAL:t.columnId&&(e.sort_order=t.direction,e.sort=t.columnId);break;case c.SortingMode.MONOLITH:default:o&&(e[r]=o)}return n.default.stringify(e,{arrayFormat:"brackets"})},[l,o,a,r,t]),d=i.useCallback(()=>{const e=n.default.parse(window.location.search,{ignoreQueryPrefix:!0});switch(a){case c.SortingMode.CORAL:if(!t.columnId||e.sort_order===t.direction&&e.sort===t.columnId)break;e.sort_order=t.direction,e.sort=t.columnId;break;case c.SortingMode.MONOLITH:default:if(!o)break;if(e[r]===o)return;e[r]=o}const s=n.default.stringify(e,{arrayFormat:"brackets"});s&&window.history.replaceState({},"",`${window.location.pathname}?${s}`)},[a,r,o,t]),f=i.useCallback(()=>{const e=n.default.parse(window.location.search,{ignoreQueryPrefix:!0}),s=e[r],S=e.sort_order,m=e.sort;switch(a){case c.SortingMode.CORAL:S&&m&&u({columnId:m,direction:S});break;case c.SortingMode.MONOLITH:default:{if(!s)break;const b=s.startsWith("-"),w=b?"desc":"asc",M=b?s.slice(1):s;u({columnId:M,direction:w})}}},[a,r,u]);return i.useEffect(()=>{f()},[f]),i.useEffect(()=>{d()},[t,d]),{queryParams:O,hasActiveView:I,updateCurrentUrlWithTableSort:d}};exports.useUrlParams=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("lodash/isArray"),a=require("./index8.cjs"),C=require("./index62.cjs"),I=require("./index63.cjs"),_=s=>s&&s.__esModule?s:{default:s},f=_(m),L=()=>{var t;const{DEFAULT_HIDDEN_COLUMNS:s,DEFAULT_VISIBLE_COLUMNS:i}=a.useBusinessLogic(),{Filters:{activeViewId:r}}=C.useStores(),{viewsMap:d,isLoading:e,error:n}=I.useViews();if(!r||e)return{isLoading:e,error:n,orderedColumnIds:void 0,hiddenColumnIds:[]};const u=d.get(r),o=(t=u==null?void 0:u.columns)==null?void 0:t.columnIds;if(f.default(o)&&o.length>0){const l=[...s,...i].filter(c=>!o.includes(c));return{isLoading:e,error:n,orderedColumnIds:o,hiddenColumnIds:l}}return{isLoading:e,error:n,orderedColumnIds:void 0,hiddenColumnIds:s}};exports.useColumns=L;
package/dist/index67.js CHANGED
@@ -1,63 +1,34 @@
1
- import { useMemo as y, useCallback as I, useEffect as b } from "react";
2
- import { SortingMode as c } from "./index2.js";
3
- import i from "qs";
4
- import { useBusinessLogic as L } from "./index8.js";
5
- import { useStores as T } from "./index61.js";
6
- const C = () => {
7
- const { SORT_FILTER_ID: e, SORTING_MODE: a } = L(), {
8
- Filters: { queryParamsObject: d, activeViewId: w },
9
- Table: { sortParam: o, sortState: t, setSortState: n }
10
- } = T(), O = !!w, p = y(() => {
11
- const r = { ...d };
12
- switch (a) {
13
- case c.CORAL:
14
- t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
15
- break;
16
- case c.MONOLITH:
17
- default:
18
- o && (r[e] = o);
19
- }
20
- return i.stringify(r, { arrayFormat: "brackets" });
21
- }, [d, o, a, e, t]), u = I(() => {
22
- const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 });
23
- switch (a) {
24
- case c.CORAL:
25
- if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
26
- break;
27
- r.sort_order = t.direction, r.sort = t.columnId;
28
- break;
29
- case c.MONOLITH:
30
- default:
31
- if (!o) break;
32
- if (r[e] === o) return;
33
- r[e] = o;
34
- }
35
- const s = i.stringify(r, { arrayFormat: "brackets" });
36
- s && window.history.replaceState({}, "", `${window.location.pathname}?${s}`);
37
- }, [a, e, o, t]), l = I(() => {
38
- const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 }), s = r[e], m = r.sort_order, f = r.sort;
39
- switch (a) {
40
- case c.CORAL:
41
- m && f && n({ columnId: f, direction: m });
42
- break;
43
- case c.MONOLITH:
44
- default: {
45
- if (!s) break;
46
- const S = s.startsWith("-"), h = S ? "desc" : "asc", k = S ? s.slice(1) : s;
47
- n({ columnId: k, direction: h });
48
- }
49
- }
50
- }, [a, e, n]);
51
- return b(() => {
52
- l();
53
- }, [l]), b(() => {
54
- u();
55
- }, [t, u]), {
56
- queryParams: p,
57
- hasActiveView: O,
58
- updateCurrentUrlWithTableSort: u
1
+ import c from "lodash/isArray";
2
+ import { useBusinessLogic as C } from "./index8.js";
3
+ import { useStores as I } from "./index62.js";
4
+ import { useViews as f } from "./index63.js";
5
+ const v = () => {
6
+ var i;
7
+ const { DEFAULT_HIDDEN_COLUMNS: r, DEFAULT_VISIBLE_COLUMNS: l } = C(), { Filters: { activeViewId: d } } = I(), { viewsMap: t, isLoading: o, error: n } = f();
8
+ if (!d || o)
9
+ return {
10
+ isLoading: o,
11
+ error: n,
12
+ orderedColumnIds: void 0,
13
+ hiddenColumnIds: []
14
+ };
15
+ const e = t.get(d), s = (i = e == null ? void 0 : e.columns) == null ? void 0 : i.columnIds;
16
+ if (c(s) && s.length > 0) {
17
+ const m = [...r, ...l].filter((u) => !s.includes(u));
18
+ return {
19
+ isLoading: o,
20
+ error: n,
21
+ orderedColumnIds: s,
22
+ hiddenColumnIds: m
23
+ };
24
+ }
25
+ return {
26
+ isLoading: o,
27
+ error: n,
28
+ orderedColumnIds: void 0,
29
+ hiddenColumnIds: r
59
30
  };
60
31
  };
61
32
  export {
62
- C as useUrlParams
33
+ v as useColumns
63
34
  };
package/dist/index68.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("./index49.cjs"),P=require("./index2.cjs"),b=require("./index70.cjs"),v=require("./index69.cjs"),G=require("./index79.cjs"),C=require("./index77.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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),c=require("./index2.cjs"),y=require("qs"),_=require("./index8.cjs"),h=require("./index62.cjs"),k=r=>r&&r.__esModule?r:{default:r},n=k(y),L=()=>{const{SORT_FILTER_ID:r,SORTING_MODE:a}=_.useBusinessLogic(),{Filters:{queryParamsObject:l,activeViewId:g},Table:{sortParam:o,sortState:t,setSortState:u}}=h.useStores(),I=!!g,O=i.useMemo(()=>{const e={...l};switch(a){case c.SortingMode.CORAL:t.columnId&&(e.sort_order=t.direction,e.sort=t.columnId);break;case c.SortingMode.MONOLITH:default:o&&(e[r]=o)}return n.default.stringify(e,{arrayFormat:"brackets"})},[l,o,a,r,t]),d=i.useCallback(()=>{const e=n.default.parse(window.location.search,{ignoreQueryPrefix:!0});switch(a){case c.SortingMode.CORAL:if(!t.columnId||e.sort_order===t.direction&&e.sort===t.columnId)break;e.sort_order=t.direction,e.sort=t.columnId;break;case c.SortingMode.MONOLITH:default:if(!o)break;if(e[r]===o)return;e[r]=o}const s=n.default.stringify(e,{arrayFormat:"brackets"});s&&window.history.replaceState({},"",`${window.location.pathname}?${s}`)},[a,r,o,t]),f=i.useCallback(()=>{const e=n.default.parse(window.location.search,{ignoreQueryPrefix:!0}),s=e[r],S=e.sort_order,m=e.sort;switch(a){case c.SortingMode.CORAL:S&&m&&u({columnId:m,direction:S});break;case c.SortingMode.MONOLITH:default:{if(!s)break;const b=s.startsWith("-"),w=b?"desc":"asc",M=b?s.slice(1):s;u({columnId:M,direction:w})}}},[a,r,u]);return i.useEffect(()=>{f()},[f]),i.useEffect(()=>{d()},[t,d]),{queryParams:O,hasActiveView:I,updateCurrentUrlWithTableSort:d}};exports.useUrlParams=L;
package/dist/index68.js CHANGED
@@ -1,352 +1,63 @@
1
- var C = Object.defineProperty;
2
- var U = (b, t, l) => t in b ? C(b, t, { enumerable: !0, configurable: !0, writable: !0, value: l }) : b[t] = l;
3
- var h = (b, t, l) => U(b, typeof t != "symbol" ? t + "" : t, l);
4
- import { makeObservable as O, computed as M, action as F, observable as c } from "mobx";
5
- import { DateRanges as L } from "@veeqo/ui";
6
- import { parseDate as _ } from "@internationalized/date";
7
- import D from "lodash/isEqual";
8
- import G from "lodash/get";
9
- import R from "lodash/set";
10
- import T from "qs";
11
- import { FilterChoiceValue as m } from "./index49.js";
12
- import { SortingMode as I } from "./index2.js";
13
- import { RangeFilter as w } from "./index70.js";
14
- import { NumberRangeFilter as v } from "./index69.js";
15
- import { ALL_VIEW_ID as V } from "./index79.js";
16
- import { isValidDateRange as N } from "./index77.js";
17
- import { BusinessLogicManager as d } from "./index9.js";
18
- class ee {
19
- constructor() {
20
- // PAGINATION
21
- h(this, "defaultPageSize");
22
- h(this, "pageSize");
23
- h(this, "currentPage");
24
- // DEFAULT FILTERS
25
- h(this, "defaultFilters");
26
- h(this, "defaultArrayFilters");
27
- h(this, "defaultDateRangeFilters");
28
- h(this, "defaultNumberRangeFilters");
29
- // CURRENT FILTERS
30
- h(this, "filters");
31
- h(this, "arrayFilters");
32
- h(this, "dateRangeFilters");
33
- h(this, "numberRangeFilters");
34
- // VIEWS
35
- h(this, "activeViewId");
36
- // VISIBILITY STATE
37
- h(this, "isFiltersDropdownVisible");
38
- h(this, "initDefaultFilterMaps", () => {
39
- this.defaultFilters = new Map(this.filters), this.defaultArrayFilters = new Map(this.arrayFilters), this.defaultDateRangeFilters = new Map(this.dateRangeFilters), this.defaultNumberRangeFilters = new Map(this.numberRangeFilters);
40
- });
41
- h(this, "updateUrl", (t = !1) => {
42
- try {
43
- const { SORT_FILTER_ID: l, SORTING_MODE: s } = d.getBusinessLogic(), e = T.parse(window.location.search, { ignoreQueryPrefix: !0 }), i = e[l], f = e.sort_order, g = e.sort;
44
- let o = "";
45
- switch (s) {
46
- case I.CORAL:
47
- if (f && g) {
48
- const u = { ...this.queryParamsObject, sort: g, sort_order: f };
49
- o = `${window.location.pathname}?${T.stringify(u, { arrayFormat: "brackets" })}`;
50
- }
51
- break;
52
- case I.MONOLITH:
53
- default:
54
- if (i) {
55
- const u = { ...this.queryParamsObject, [l]: i };
56
- o = `${window.location.pathname}?${T.stringify(u, { arrayFormat: "brackets" })}`;
57
- }
58
- }
59
- i || (o = `${window.location.pathname}?${this.queryParams}`), t ? window.history.pushState({}, "", o) : window.history.replaceState({}, "", o);
60
- } catch (l) {
61
- console.log(l);
1
+ import { useMemo as y, useCallback as I, useEffect as b } from "react";
2
+ import { SortingMode as c } from "./index2.js";
3
+ import i from "qs";
4
+ import { useBusinessLogic as L } from "./index8.js";
5
+ import { useStores as T } from "./index62.js";
6
+ const C = () => {
7
+ const { SORT_FILTER_ID: e, SORTING_MODE: a } = L(), {
8
+ Filters: { queryParamsObject: d, activeViewId: w },
9
+ Table: { sortParam: o, sortState: t, setSortState: n }
10
+ } = T(), O = !!w, p = y(() => {
11
+ const r = { ...d };
12
+ switch (a) {
13
+ case c.CORAL:
14
+ t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
15
+ break;
16
+ case c.MONOLITH:
17
+ default:
18
+ o && (r[e] = o);
19
+ }
20
+ return i.stringify(r, { arrayFormat: "brackets" });
21
+ }, [d, o, a, e, t]), u = I(() => {
22
+ const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 });
23
+ switch (a) {
24
+ case c.CORAL:
25
+ if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
26
+ break;
27
+ r.sort_order = t.direction, r.sort = t.columnId;
28
+ break;
29
+ case c.MONOLITH:
30
+ default:
31
+ if (!o) break;
32
+ if (r[e] === o) return;
33
+ r[e] = o;
34
+ }
35
+ const s = i.stringify(r, { arrayFormat: "brackets" });
36
+ s && window.history.replaceState({}, "", `${window.location.pathname}?${s}`);
37
+ }, [a, e, o, t]), l = I(() => {
38
+ const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 }), s = r[e], m = r.sort_order, f = r.sort;
39
+ switch (a) {
40
+ case c.CORAL:
41
+ m && f && n({ columnId: f, direction: m });
42
+ break;
43
+ case c.MONOLITH:
44
+ default: {
45
+ if (!s) break;
46
+ const S = s.startsWith("-"), h = S ? "desc" : "asc", k = S ? s.slice(1) : s;
47
+ n({ columnId: k, direction: h });
62
48
  }
63
- });
64
- // PAGINATION
65
- h(this, "setCurrentPage", (t) => {
66
- this.currentPage = t;
67
- });
68
- h(this, "setPageSize", (t) => {
69
- this.pageSize = t, this.updateUrl();
70
- });
71
- // TEXT FILTERS
72
- h(this, "setFilter", (t, l) => {
73
- this.filters.set(t, l), this.setCurrentPage(1), this.updateUrl();
74
- });
75
- h(this, "clearFilter", (t) => {
76
- this.filters.set(t, ""), this.setCurrentPage(1), this.updateUrl();
77
- });
78
- // ARRAY FILTERS
79
- h(this, "setArrayFilter", (t, l) => {
80
- this.arrayFilters.set(t, l), this.setCurrentPage(1), this.updateUrl();
81
- });
82
- h(this, "clearArrayFilter", (t) => {
83
- this.arrayFilters.set(t, []), this.setCurrentPage(1), this.updateUrl();
84
- });
85
- // RANGE FILTERS
86
- h(this, "setRangeFilter", ({
87
- key: t,
88
- range: l,
89
- dates: s
90
- }) => {
91
- l.setFilterType(t), l.setDates(s.start, s.end), this.setCurrentPage(1), this.updateUrl();
92
- });
93
- h(this, "clearRangeFilter", (t) => {
94
- const l = this.dateRangeFilters.get(t);
95
- l && (l.clear(), this.setCurrentPage(1), this.updateUrl());
96
- });
97
- // NUMBER RANGE FILTERS
98
- h(this, "setNumberRangeFilter", ({
99
- numberRange: t,
100
- gte: l,
101
- lte: s
102
- }) => {
103
- t.setGte(l), t.setLte(s), this.setCurrentPage(1), this.updateUrl();
104
- });
105
- h(this, "clearNumberRangeFilter", (t) => {
106
- const l = this.numberRangeFilters.get(t);
107
- l && (l.clear(), this.setCurrentPage(1), this.updateUrl());
108
- });
109
- // CLEARING ALL FILTERS
110
- h(this, "clearAllFilters", (t = !1) => {
111
- const { SEARCH_FILTER_ID: l } = d.getBusinessLogic();
112
- this.filters.forEach((s, e) => {
113
- e !== l && this.filters.set(e, "");
114
- }), 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();
115
- });
116
- h(this, "clearFiltersForGroup", (t) => {
117
- const { GROUP_MAP: l } = d.getBusinessLogic(), s = l.get(t);
118
- s && s.fields.forEach((e) => {
119
- 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);
120
- });
121
- });
122
- // VIEWS
123
- h(this, "setActiveViewId", (t) => {
124
- this.activeViewId = t, this.updateUrl();
125
- });
126
- // VISIBILITY
127
- h(this, "toggleFiltersDropdownVisible", (t) => {
128
- this.isFiltersDropdownVisible = t;
129
- });
130
- // FILTER GROUPS
131
- h(this, "getFiltersForGroup", (t) => {
132
- const { GROUP_MAP: l } = d.getBusinessLogic(), s = l.get(t);
133
- if (!s) return {};
134
- const e = {};
135
- return s.fields.forEach((i) => {
136
- this.arrayFilters.has(i.id) ? e[i.id] = this.arrayFilters.get(i.id) : this.dateRangeFilters.has(i.id) ? e[i.id] = this.dateRangeFilters.get(i.id) : this.numberRangeFilters.has(i.id) ? e[i.id] = this.numberRangeFilters.get(i.id) : e[i.id] = this.filters.get(i.id);
137
- }), e;
138
- });
139
- h(this, "initFiltersFromView", (t) => {
140
- var s;
141
- const { PAGE_SIZE_OPTIONS: l } = d.getBusinessLogic();
142
- (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(
143
- Array.from(t.filterMaps.rangeFilters.entries()).map(([e, i]) => {
144
- const f = new w(i.filterType);
145
- return i.gte && i.lte && f.setDates(i.gte, i.lte), [e, f];
146
- })
147
- ), this.defaultNumberRangeFilters = new Map(
148
- Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e, i]) => {
149
- const f = i.clone();
150
- return i.gte && f.setGte(i.gte), i.lte && f.setLte(i.lte), [e, f];
151
- })
152
- ), this.filters = new Map(t.filterMaps.filters), this.arrayFilters = new Map(t.filterMaps.arrayFilters), this.dateRangeFilters = new Map(
153
- Array.from(t.filterMaps.rangeFilters.entries()).map(([e, i]) => {
154
- const f = new w(i.filterType);
155
- return i.gte && i.lte && f.setDates(i.gte, i.lte), [e, f];
156
- })
157
- ), this.numberRangeFilters = new Map(
158
- Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e, i]) => {
159
- const f = i.clone();
160
- return i.gte && f.setGte(i.gte), i.lte && f.setLte(i.lte), [e, f];
161
- })
162
- ), this.activeViewId = t.id;
163
- });
164
- h(this, "initFromUrl", (t = !0) => {
165
- const { GROUP_MAP: l, PAGE_SIZE_OPTIONS: s, PAGE_SIZE_FILTER_ID: e } = d.getBusinessLogic(), i = T.parse(window.location.search, {
166
- ignoreQueryPrefix: !0
167
- }), f = Array.from(l.values()).flatMap((n) => n.fields), g = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
168
- t && i.view && (this.activeViewId = i.view), i[e] && s.includes(Number(i[e])) && (this.pageSize = Number(i[e]));
169
- const P = i.filter || {};
170
- f.forEach((n) => {
171
- const r = G(P, n.id);
172
- if (r !== void 0)
173
- switch (n.filterType) {
174
- case m.CHECKBOX:
175
- Array.isArray(r) ? o.set(n.id, r) : r && o.set(n.id, [r]);
176
- break;
177
- case m.DATE_RANGE:
178
- if (typeof r == "string" && N(r))
179
- u.set(n.id, new w(r));
180
- else if (typeof r == "object" && r !== null) {
181
- const a = r;
182
- if (a.relative && N(a.relative))
183
- u.set(n.id, new w(a.relative));
184
- else if (a.gte && a.lte)
185
- try {
186
- const p = _(a.gte), A = _(a.lte), y = new w("CUSTOM");
187
- y.setDates(p, A), u.set(n.id, y);
188
- } catch {
189
- u.set(n.id, new w(L.TODAY));
190
- }
191
- }
192
- break;
193
- case m.NUMBER_RANGE:
194
- if (typeof r == "object" && r !== null) {
195
- const a = r, p = new v({ filterId: n.id });
196
- a.gte !== void 0 && p.setGte(Number(a.gte)), a.lte !== void 0 && p.setLte(Number(a.lte)), S.set(n.id, p);
197
- }
198
- break;
199
- case m.TEXT:
200
- case m.NUMBER:
201
- case m.RADIO:
202
- (typeof r == "string" || typeof r == "number") && g.set(n.id, String(r));
203
- break;
204
- }
205
- }), this.filters = g, this.arrayFilters = o, this.dateRangeFilters = u, this.numberRangeFilters = S, this.updateUrl();
206
- });
207
- h(this, "discardChanges", (t = !1) => {
208
- this.pageSize = this.defaultPageSize;
209
- const { SEARCH_FILTER_ID: l } = d.getBusinessLogic(), s = new Map(this.defaultFilters);
210
- 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, i) => {
211
- const f = new w(e.filterType);
212
- f.setDates(e.gte, e.lte), this.dateRangeFilters.set(i, f);
213
- }), this.numberRangeFilters.clear(), this.defaultNumberRangeFilters.forEach((e, i) => {
214
- this.numberRangeFilters.set(i, e.clone());
215
- }), this.updateUrl(t);
216
- });
217
- const { GROUP_MAP: t } = d.getBusinessLogic(), l = Array.from(t.values()).flatMap((s) => s.fields);
218
- this.filters = new Map(
219
- l.filter(
220
- (s) => s.filterType === m.TEXT || s.filterType === m.NUMBER || s.filterType === m.RADIO || s.filterType === m.DATE_RANGE
221
- ).map((s) => [s.id, ""])
222
- ), this.arrayFilters = new Map(
223
- l.filter((s) => s.filterType === m.CHECKBOX).map((s) => [s.id, []])
224
- ), this.dateRangeFilters = new Map(
225
- l.filter((s) => s.filterType === m.DATE_RANGE).map((s) => [s.id, new w()])
226
- ), this.numberRangeFilters = new Map(
227
- l.filter((s) => s.filterType === m.NUMBER_RANGE).map((s) => {
228
- const e = new v({ filterId: s.id });
229
- return [s.id, e];
230
- })
231
- ), this.defaultArrayFilters = /* @__PURE__ */ new Map(), this.defaultFilters = /* @__PURE__ */ new Map(), this.defaultDateRangeFilters = /* @__PURE__ */ new Map(), this.defaultNumberRangeFilters = /* @__PURE__ */ new Map(), this.currentPage = 1, this.pageSize = 10, this.defaultPageSize = 10, this.initDefaultFilterMaps(), this.isFiltersDropdownVisible = !1, this.activeViewId = void 0, O(this, {
232
- defaultPageSize: c,
233
- pageSize: c,
234
- currentPage: c,
235
- defaultFilters: c,
236
- defaultArrayFilters: c,
237
- defaultDateRangeFilters: c,
238
- defaultNumberRangeFilters: c,
239
- filters: c,
240
- arrayFilters: c,
241
- numberRangeFilters: c,
242
- dateRangeFilters: c,
243
- isFiltersDropdownVisible: c,
244
- activeViewId: c,
245
- setPageSize: F,
246
- setCurrentPage: F,
247
- toggleFiltersDropdownVisible: F,
248
- setActiveViewId: F,
249
- setFilter: F,
250
- setArrayFilter: F,
251
- setRangeFilter: F,
252
- setNumberRangeFilter: F,
253
- clearFilter: F,
254
- clearArrayFilter: F,
255
- clearRangeFilter: F,
256
- clearNumberRangeFilter: F,
257
- clearAllFilters: F,
258
- getFiltersForGroup: F,
259
- clearFiltersForGroup: F,
260
- initFromUrl: F,
261
- initFiltersFromView: F,
262
- initDefaultFilterMaps: F,
263
- discardChanges: F,
264
- updateUrl: F,
265
- hasActiveFilters: M,
266
- activeFilterKeysList: M,
267
- queryParamsObject: M,
268
- queryParams: M,
269
- hasUnsavedChanges: M
270
- });
271
- }
272
- get hasActiveFilters() {
273
- const { GROUP_MAP: t } = d.getBusinessLogic(), l = Array.from(t.values()).flatMap((e) => e.fields), s = new Set(l.map((e) => e.id));
274
- 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);
275
- }
276
- get activeFilterKeysList() {
277
- const { DATE_RANGE_FILTERS: t, NUMBER_RANGE_FILTERS: l } = d.getBusinessLogic(), s = Array.from(this.filters.entries()).filter(
278
- ([o, u]) => u !== "" && !t.includes(o) && !l.includes(o)
279
- ).map(([o]) => o), e = Array.from(this.arrayFilters.entries()).filter(([, o]) => o.length > 0).map(([o]) => o), i = Array.from(this.dateRangeFilters.entries()).filter(([, o]) => o.filterType !== void 0).map(([o]) => o), f = Array.from(this.numberRangeFilters.entries()).filter(([, o]) => o.isActive).map(([o]) => o);
280
- return [.../* @__PURE__ */ new Set([...s, ...e, ...i, ...f])];
281
- }
282
- get queryParamsObject() {
283
- const { DATE_RANGE_FILTERS: t, NUMBER_RANGE_FILTERS: l, PAGE_SIZE_FILTER_ID: s, PAGE_NUMBER_FILTER_ID: e } = d.getBusinessLogic(), i = {};
284
- Array.from(this.filters.entries()).filter(
285
- ([g, o]) => o !== "" && !t.includes(g) && !l.includes(g)
286
- ).forEach(([g, o]) => {
287
- R(i, g, o);
288
- }), Array.from(this.arrayFilters.entries()).filter(([, g]) => g.length > 0).forEach(([g, o]) => {
289
- R(i, g, o);
290
- }), Array.from(this.dateRangeFilters.entries()).filter(([, g]) => g.filterType !== void 0).forEach(([g, o]) => {
291
- o.filterType === "CUSTOM" ? R(i, g, {
292
- gte: o.gte.toString(),
293
- lte: o.lte.toString()
294
- }) : R(i, g, { relative: o.filterType });
295
- }), Array.from(this.numberRangeFilters.entries()).filter(([, g]) => g.isActive).forEach(([g, o]) => {
296
- const u = {};
297
- o.gte !== void 0 && (u.gte = o.gte), o.isValidLte && (u.lte = o.lte), R(i, g, u);
298
- });
299
- const f = {
300
- filter: i,
301
- [s]: String(this.pageSize),
302
- [e]: String(this.currentPage)
303
- };
304
- return this.activeViewId && (f.view = this.activeViewId), f;
305
- }
306
- get queryParams() {
307
- return T.stringify(this.queryParamsObject, {
308
- arrayFormat: "brackets"
309
- });
310
- }
311
- get hasUnsavedChanges() {
312
- if (this.activeViewId === V) return !1;
313
- if (this.defaultPageSize !== this.pageSize) return !0;
314
- const { GROUP_MAP: t, SEARCH_FILTER_ID: l } = d.getBusinessLogic(), s = Array.from(t.values()).flatMap((n) => n.fields), e = new Set(s.map((n) => n.id));
315
- if (Array.from(this.filters.entries()).filter(([n]) => n !== l && e.has(n)).some(([n, r]) => {
316
- const a = this.defaultFilters.get(n);
317
- return a === void 0 && r !== "" || a !== void 0 && r !== a;
318
- }))
319
- return !0;
320
- const f = Array.from(this.defaultArrayFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
321
- const a = this.defaultArrayFilters.get(n) || [];
322
- return r.length > 0 || a.length > 0 ? r.length !== a.length || !D(r, a) : !1;
323
- }), g = Array.from(this.arrayFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
324
- const a = this.defaultArrayFilters.get(n) || [];
325
- return r.length > 0 || a.length > 0 ? r.length !== a.length || !D(r, a) : !1;
326
- });
327
- if (f || g)
328
- return !0;
329
- const o = Array.from(this.numberRangeFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
330
- const a = this.defaultNumberRangeFilters.get(n);
331
- return !r.isEqual(a);
332
- });
333
- if (Array.from(this.defaultNumberRangeFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
334
- const a = this.numberRangeFilters.get(n);
335
- return !r.isEqual(a);
336
- }) || o)
337
- return !0;
338
- const S = Array.from(this.defaultDateRangeFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
339
- var p, A, y, E;
340
- const a = this.dateRangeFilters.get(n);
341
- return r != null && r.filterType && !(a != null && a.filterType) || a != null && a.filterType && !(r != null && r.filterType) || (a == null ? void 0 : a.filterType) !== (r == null ? void 0 : r.filterType) ? !0 : (a == null ? void 0 : a.filterType) === "CUSTOM" && (r == null ? void 0 : r.filterType) === "CUSTOM" ? ((p = r.gte) == null ? void 0 : p.toString()) !== ((A = a.gte) == null ? void 0 : A.toString()) || ((y = r.lte) == null ? void 0 : y.toString()) !== ((E = a.lte) == null ? void 0 : E.toString()) : !1;
342
- });
343
- return Array.from(this.dateRangeFilters.entries()).filter(([n]) => e.has(n)).some(([n, r]) => {
344
- var p, A, y, E;
345
- const a = this.defaultDateRangeFilters.get(n);
346
- return r != null && r.filterType && !(a != null && a.filterType) || a != null && a.filterType && !(r != null && r.filterType) || (a == null ? void 0 : a.filterType) !== (r == null ? void 0 : r.filterType) ? !0 : (a == null ? void 0 : a.filterType) === "CUSTOM" && (r == null ? void 0 : r.filterType) === "CUSTOM" ? ((p = r.gte) == null ? void 0 : p.toString()) !== ((A = a.gte) == null ? void 0 : A.toString()) || ((y = r.lte) == null ? void 0 : y.toString()) !== ((E = a.lte) == null ? void 0 : E.toString()) : !1;
347
- }) || S;
348
- }
349
- }
49
+ }
50
+ }, [a, e, n]);
51
+ return b(() => {
52
+ l();
53
+ }, [l]), b(() => {
54
+ u();
55
+ }, [t, u]), {
56
+ queryParams: p,
57
+ hasActiveView: O,
58
+ updateCurrentUrlWithTableSort: u
59
+ };
60
+ };
350
61
  export {
351
- ee as Filters
62
+ C as useUrlParams
352
63
  };