@veeqo/transfigure 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/constants/viewConstants.d.ts +2 -0
  2. package/dist/hooks/index.d.ts +1 -0
  3. package/dist/hooks/useCreateEmptyDraftView/index.d.ts +1 -0
  4. package/dist/hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.d.ts +3 -0
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +72 -70
  7. package/dist/index100.cjs +1 -1
  8. package/dist/index100.js +48 -19
  9. package/dist/index101.cjs +1 -1
  10. package/dist/index101.js +28 -17
  11. package/dist/index102.cjs +1 -1
  12. package/dist/index102.js +15 -24
  13. package/dist/index103.cjs +11 -18
  14. package/dist/index103.js +12 -20
  15. package/dist/index104.cjs +1 -1
  16. package/dist/index104.js +15 -14
  17. package/dist/index105.cjs +19 -1
  18. package/dist/index105.js +24 -7
  19. package/dist/index106.cjs +1 -12
  20. package/dist/index106.js +21 -16
  21. package/dist/index107.cjs +1 -1
  22. package/dist/index107.js +23 -49
  23. package/dist/index108.cjs +1 -1
  24. package/dist/index108.js +12 -29
  25. package/dist/index109.cjs +1 -1
  26. package/dist/index109.js +1 -1
  27. package/dist/index11.cjs +1 -1
  28. package/dist/index11.js +1 -1
  29. package/dist/index110.cjs +1 -1
  30. package/dist/index110.js +8 -18
  31. package/dist/index111.cjs +1 -1
  32. package/dist/index111.js +2 -8
  33. package/dist/index112.cjs +1 -1
  34. package/dist/index112.js +17 -59
  35. package/dist/index113.cjs +1 -1
  36. package/dist/index113.js +7 -29
  37. package/dist/index114.cjs +1 -1
  38. package/dist/index114.js +61 -2
  39. package/dist/index115.cjs +1 -13
  40. package/dist/index115.js +30 -17
  41. package/dist/index116.cjs +13 -1
  42. package/dist/index116.js +15 -24
  43. package/dist/index117.cjs +1 -1
  44. package/dist/index117.js +22 -32
  45. package/dist/index118.cjs +1 -1
  46. package/dist/index118.js +36 -5
  47. package/dist/index119.cjs +1 -1
  48. package/dist/index119.js +5 -63
  49. package/dist/index120.cjs +1 -7
  50. package/dist/index120.js +63 -10
  51. package/dist/index121.cjs +7 -1
  52. package/dist/index121.js +10 -47
  53. package/dist/index122.cjs +1 -0
  54. package/dist/index122.js +49 -0
  55. package/dist/index13.cjs +1 -1
  56. package/dist/index13.js +1 -1
  57. package/dist/index14.cjs +1 -1
  58. package/dist/index14.js +1 -1
  59. package/dist/index15.cjs +1 -1
  60. package/dist/index15.js +1 -1
  61. package/dist/index16.cjs +1 -1
  62. package/dist/index16.js +1 -1
  63. package/dist/index17.cjs +1 -1
  64. package/dist/index17.js +1 -1
  65. package/dist/index19.cjs +1 -1
  66. package/dist/index19.js +3 -3
  67. package/dist/index20.cjs +1 -1
  68. package/dist/index20.js +3 -3
  69. package/dist/index21.cjs +1 -1
  70. package/dist/index21.js +2 -2
  71. package/dist/index22.cjs +1 -1
  72. package/dist/index22.js +3 -3
  73. package/dist/index23.cjs +1 -1
  74. package/dist/index23.js +2 -2
  75. package/dist/index26.cjs +1 -1
  76. package/dist/index26.js +3 -3
  77. package/dist/index27.cjs +1 -1
  78. package/dist/index27.js +3 -3
  79. package/dist/index28.cjs +1 -1
  80. package/dist/index28.js +1 -1
  81. package/dist/index29.cjs +1 -1
  82. package/dist/index29.js +2 -2
  83. package/dist/index30.cjs +1 -1
  84. package/dist/index30.js +1 -1
  85. package/dist/index31.cjs +1 -1
  86. package/dist/index31.js +3 -3
  87. package/dist/index32.cjs +1 -1
  88. package/dist/index32.js +1 -1
  89. package/dist/index33.cjs +1 -1
  90. package/dist/index33.js +1 -1
  91. package/dist/index34.cjs +1 -1
  92. package/dist/index34.js +1 -1
  93. package/dist/index36.cjs +1 -1
  94. package/dist/index36.js +35 -35
  95. package/dist/index37.cjs +1 -1
  96. package/dist/index37.js +10 -10
  97. package/dist/index38.cjs +1 -1
  98. package/dist/index38.js +40 -37
  99. package/dist/index39.cjs +1 -1
  100. package/dist/index39.js +1 -1
  101. package/dist/index40.cjs +1 -1
  102. package/dist/index40.js +3 -3
  103. package/dist/index41.cjs +1 -1
  104. package/dist/index41.js +4 -4
  105. package/dist/index42.cjs +1 -1
  106. package/dist/index42.js +1 -1
  107. package/dist/index44.cjs +1 -1
  108. package/dist/index44.js +4 -4
  109. package/dist/index46.cjs +1 -1
  110. package/dist/index46.js +3 -3
  111. package/dist/index47.cjs +1 -1
  112. package/dist/index47.js +3 -3
  113. package/dist/index57.cjs +1 -1
  114. package/dist/index57.js +33 -33
  115. package/dist/index58.cjs +1 -1
  116. package/dist/index58.js +2 -2
  117. package/dist/index59.cjs +1 -1
  118. package/dist/index59.js +10 -23
  119. package/dist/index60.cjs +1 -1
  120. package/dist/index60.js +19 -22
  121. package/dist/index61.cjs +1 -1
  122. package/dist/index61.js +26 -96
  123. package/dist/index62.cjs +1 -1
  124. package/dist/index62.js +97 -8
  125. package/dist/index63.cjs +1 -1
  126. package/dist/index63.js +8 -33
  127. package/dist/index64.cjs +1 -1
  128. package/dist/index64.js +33 -63
  129. package/dist/index65.cjs +1 -1
  130. package/dist/index65.js +59 -19
  131. package/dist/index66.cjs +1 -1
  132. package/dist/index66.js +23 -18
  133. package/dist/index67.cjs +1 -1
  134. package/dist/index67.js +16 -29
  135. package/dist/index68.cjs +1 -1
  136. package/dist/index68.js +30 -60
  137. package/dist/index69.cjs +1 -1
  138. package/dist/index69.js +61 -376
  139. package/dist/index7.cjs +1 -1
  140. package/dist/index7.js +4 -4
  141. package/dist/index70.cjs +1 -1
  142. package/dist/index70.js +372 -53
  143. package/dist/index71.cjs +1 -1
  144. package/dist/index71.js +48 -47
  145. package/dist/index72.cjs +1 -1
  146. package/dist/index72.js +51 -32
  147. package/dist/index73.cjs +1 -1
  148. package/dist/index73.js +40 -24
  149. package/dist/index74.cjs +1 -1
  150. package/dist/index74.js +26 -32
  151. package/dist/index75.cjs +1 -1
  152. package/dist/index75.js +38 -4
  153. package/dist/index76.cjs +1 -1
  154. package/dist/index76.js +4 -13
  155. package/dist/index77.cjs +1 -1
  156. package/dist/index77.js +12 -16
  157. package/dist/index78.cjs +1 -1
  158. package/dist/index78.js +14 -16
  159. package/dist/index79.cjs +1 -1
  160. package/dist/index79.js +18 -65
  161. package/dist/index80.cjs +1 -1
  162. package/dist/index80.js +67 -24
  163. package/dist/index81.cjs +1 -1
  164. package/dist/index81.js +24 -21
  165. package/dist/index82.cjs +1 -1
  166. package/dist/index82.js +19 -6
  167. package/dist/index83.cjs +1 -1
  168. package/dist/index83.js +7 -2
  169. package/dist/index84.cjs +1 -1
  170. package/dist/index84.js +2 -9
  171. package/dist/index85.cjs +1 -3
  172. package/dist/index85.js +8 -13
  173. package/dist/index86.cjs +3 -1
  174. package/dist/index86.js +13 -8
  175. package/dist/index87.cjs +1 -1
  176. package/dist/index87.js +8 -4
  177. package/dist/index88.cjs +1 -1
  178. package/dist/index88.js +39 -115
  179. package/dist/index89.cjs +1 -1
  180. package/dist/index89.js +9 -41
  181. package/dist/index90.cjs +1 -1
  182. package/dist/index90.js +116 -8
  183. package/dist/index92.cjs +1 -1
  184. package/dist/index92.js +5 -13
  185. package/dist/index93.cjs +1 -104
  186. package/dist/index93.js +13 -119
  187. package/dist/index94.cjs +104 -1
  188. package/dist/index94.js +116 -65
  189. package/dist/index95.cjs +1 -1
  190. package/dist/index95.js +63 -23
  191. package/dist/index96.cjs +1 -1
  192. package/dist/index96.js +28 -2
  193. package/dist/index97.cjs +1 -1
  194. package/dist/index97.js +2 -41
  195. package/dist/index98.cjs +1 -1
  196. package/dist/index98.js +39 -9
  197. package/dist/index99.cjs +1 -1
  198. package/dist/index99.js +10 -8
  199. package/dist/mobx/Views/Views.d.ts +1 -0
  200. package/dist/types.d.ts +4 -7
  201. package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.d.ts +6 -0
  202. package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.test.d.ts +1 -0
  203. package/dist/utils/createEmptyTransformedView/index.d.ts +1 -0
  204. package/dist/utils/getViewTheme/getViewTheme.d.ts +10 -13
  205. package/dist/utils/index.d.ts +1 -1
  206. package/dist/utils/viewsAdapter/viewsAdapter.d.ts +1 -1
  207. package/package.json +1 -1
  208. package/dist/utils/createAllView/createAllView.d.ts +0 -3
  209. package/dist/utils/createAllView/index.d.ts +0 -1
  210. /package/dist/{utils/createAllView/createAllView.test.d.ts → hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.test.d.ts} +0 -0
package/dist/index62.js CHANGED
@@ -1,11 +1,100 @@
1
- import { useContext as o } from "react";
2
- import { MobXProviderContext as t } from "mobx-react";
3
- const i = () => {
4
- const r = o(t);
5
- if (!r)
6
- throw new Error("useStores must be used within a StoresProvider.");
7
- return r;
1
+ import { useState as I } from "react";
2
+ import { parseDate as g } from "@internationalized/date";
3
+ import { NumberRangeFilter as M } from "./index71.js";
4
+ import { RangeFilter as V } from "./index72.js";
5
+ import { useViews as N } from "./index64.js";
6
+ import { useBusinessLogic as v } from "./index8.js";
7
+ import { useStores as C } from "./index63.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(), {
11
+ Filters: {
12
+ activeViewId: o,
13
+ filters: F,
14
+ arrayFilters: b,
15
+ dateRangeFilters: d,
16
+ numberRangeFilters: E,
17
+ initFiltersFromView: A,
18
+ pageSize: l
19
+ },
20
+ Table: { sortParam: f },
21
+ Views: { draftViewsMap: S },
22
+ Notifications: { notify: h }
23
+ } = C(), { viewsMap: n, mutate: T } = N(), [R, c] = I(!1), m = () => {
24
+ if (!o) throw Error("No active view");
25
+ const r = {};
26
+ Array.from(F.entries()).filter(([e, t]) => t !== "" && e !== w).forEach(([e, t]) => {
27
+ r[e] = t;
28
+ }), Array.from(b.entries()).filter(([, e]) => e.length > 0).forEach(([e, t]) => {
29
+ r[e] = t;
30
+ }), Array.from(d.entries()).filter(([, e]) => e.filterType !== void 0).forEach(([e, t]) => {
31
+ t.filterType === "CUSTOM" ? r[e] = {
32
+ gte: t.gte.toString(),
33
+ lte: t.lte.toString()
34
+ } : r[e] = t.filterType;
35
+ }), Array.from(E.entries()).filter(([, e]) => e.gte !== void 0 || e.lte !== void 0).forEach(([e, t]) => {
36
+ r[e] = {}, t.gte !== void 0 && (r[e].gte = t.gte.toString()), t.isValidLte && t.lte && (r[e].lte = t.lte.toString());
37
+ });
38
+ let s = n.get(o);
39
+ return n.has(o) || (s = S.get(o)), { arg: {
40
+ type: y,
41
+ filters: {
42
+ filter: r,
43
+ sort: f,
44
+ page: {
45
+ size: Number(l)
46
+ }
47
+ },
48
+ title: s == null ? void 0 : s.label
49
+ }, currentView: s };
50
+ };
51
+ return {
52
+ getActiveViewInAPIFormat: m,
53
+ saveChanges: async () => {
54
+ if (o)
55
+ try {
56
+ c(!0);
57
+ const { arg: r, currentView: s } = m();
58
+ await O(o, { attributes: r }), await T();
59
+ const p = {
60
+ ...s,
61
+ filterMaps: {
62
+ filters: new Map(
63
+ Object.entries(r.filters.filter).filter(
64
+ ([e, t]) => !Array.isArray(t) && typeof t == "string" && !a.includes(e)
65
+ ).map(([e, t]) => [e, t])
66
+ ),
67
+ arrayFilters: new Map(
68
+ Object.entries(r.filters.filter).filter(([, e]) => Array.isArray(e)).map(([e, t]) => [e, t])
69
+ ),
70
+ rangeFilters: new Map(
71
+ Object.entries(r.filters.filter).filter(([e]) => a.includes(e)).map(([e, t]) => {
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];
74
+ })
75
+ ),
76
+ numberRangeFilters: new Map(
77
+ Object.entries(r.filters.filter).filter(([e]) => u.includes(e)).map(([e, t]) => {
78
+ const i = new M({ filterId: e });
79
+ return t.gte && i.setGte(Number(t.gte)), t.lte && i.setLte(Number(t.lte)), [e, i];
80
+ })
81
+ )
82
+ },
83
+ page: {
84
+ size: l
85
+ },
86
+ sort: f
87
+ };
88
+ A(p);
89
+ } catch (r) {
90
+ console.log(r), h({ type: "error", text: "Failed to save changes to your view" });
91
+ } finally {
92
+ c(!1);
93
+ }
94
+ },
95
+ isSubmitting: R
96
+ };
8
97
  };
9
98
  export {
10
- i as useStores
99
+ B as usePersistUnsavedChanges
11
100
  };
package/dist/index63.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("swr"),d=require("react"),q=require("./index50.cjs"),y=require("./index8.cjs"),A=require("./index66.cjs"),C=require("./index56.cjs"),S=require("./index81.cjs"),I=e=>e&&e.__esModule?e:{default:e},M=I(O),v=()=>{const{DEFAULT_PAGE_NUMBER:e,DEFAULT_PAGE_SIZE:f,VIEW_TYPE:o}=y.useBusinessLogic(),{canUpdateCustomViews:u,orderedListOfCustomViews:t,defaultCustomViewId:w,isLoading:V}=A.useCustomViews({type:o}),{data:n,isLoading:m,error:_,mutate:g}=M.default(`/api/v2/custom_views?filter[type]=${o}&page[number]=${e}&page[size]=${f}`,C.fetcherV2,q.SWR_HOOK_OPTIONS),{viewsMap:l,customViews:s,fixedViews:c}=d.useMemo(()=>S.organiseViews({data:n,canUpdateCustomViews:u}),[n,u]),L=d.useMemo(()=>s.sort((p,E)=>{const a=Array.isArray(t)?t:[],i=a.indexOf(p.id),r=a.indexOf(E.id);return i===-1&&r===-1?0:i===-1?1:r===-1?-1:i-r}),[s,t]);return{defaultCustomViewId:w,viewsArray:[...c,...s],fixedViews:c,customViews:s,sortedCustomViews:L,viewsMap:l,isLoading:m||V,error:_,mutate:g}};exports.useViews=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),r=require("mobx-react"),o=()=>{const e=t.useContext(r.MobXProviderContext);if(!e)throw new Error("useStores must be used within a StoresProvider.");return e};exports.useStores=o;
package/dist/index63.js CHANGED
@@ -1,36 +1,11 @@
1
- import O from "swr";
2
- import { useMemo as a } from "react";
3
- import { SWR_HOOK_OPTIONS as x } from "./index50.js";
4
- import { useBusinessLogic as C } from "./index8.js";
5
- import { useCustomViews as I } from "./index66.js";
6
- import { fetcherV2 as y } from "./index56.js";
7
- import { organiseViews as v } from "./index81.js";
8
- const $ = () => {
9
- const { DEFAULT_PAGE_NUMBER: d, DEFAULT_PAGE_SIZE: f, VIEW_TYPE: t } = C(), {
10
- canUpdateCustomViews: o,
11
- orderedListOfCustomViews: r,
12
- defaultCustomViewId: p,
13
- isLoading: c
14
- } = I({ type: t }), { data: n, isLoading: w, error: V, mutate: L } = O(
15
- `/api/v2/custom_views?filter[type]=${t}&page[number]=${d}&page[size]=${f}`,
16
- y,
17
- x
18
- ), { viewsMap: g, customViews: e, fixedViews: m } = a(() => v({ data: n, canUpdateCustomViews: o }), [n, o]), E = a(() => e.sort((_, A) => {
19
- const u = Array.isArray(r) ? r : [], s = u.indexOf(_.id), i = u.indexOf(A.id);
20
- return s === -1 && i === -1 ? 0 : s === -1 ? 1 : i === -1 ? -1 : s - i;
21
- }), [e, r]);
22
- return {
23
- defaultCustomViewId: p,
24
- viewsArray: [...m, ...e],
25
- fixedViews: m,
26
- customViews: e,
27
- sortedCustomViews: E,
28
- viewsMap: g,
29
- isLoading: w || c,
30
- error: V,
31
- mutate: L
32
- };
1
+ import { useContext as o } from "react";
2
+ import { MobXProviderContext as t } from "mobx-react";
3
+ const i = () => {
4
+ const r = o(t);
5
+ if (!r)
6
+ throw new Error("useStores must be used within a StoresProvider.");
7
+ return r;
33
8
  };
34
9
  export {
35
- $ as useViews
10
+ i as useStores
36
11
  };
package/dist/index64.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),q=require("qs"),E=require("./index80.cjs"),I=require("./index66.cjs"),C=require("./index63.cjs"),D=require("./index8.cjs"),F=require("./index62.cjs"),P=t=>t&&t.__esModule?t:{default:t},v=P(q),S=()=>{const{VIEW_TYPE:t,SEARCH_FILTER_ID:l}=D.useBusinessLogic(),{Filters:{activeViewId:g,initFiltersFromView:e,initFromUrl:i,discardChanges:f,updateUrl:L,setFilter:V}}=F.useStores(),{isLoading:_}=I.useCustomViews({type:t}),{viewsMap:s,defaultCustomViewId:w,isLoading:h,viewsArray:n}=C.useViews(),p=h||_;m.useEffect(()=>{if(p)return;const o=v.default.parse(window.location.search,{ignoreQueryPrefix:!0}),d=o.view,a=o[l],r=Object.keys(o).length>0;if(!g){if(d){const u=s.get(d);if(u)e(u),r&&i();else{const c=s.get(w);c&&(e(c),r&&i(!1))}}else{const u=s.get(w);if(u)e(u),f(!0),r&&i();else{const c=s.get(E.ALL_VIEW_ID);c?e(c):n!=null&&n[0]&&e(n[0])}}a&&V(l,a)}},[l,g,w,f,e,i,p,V,L,s,n]),m.useEffect(()=>{const o=()=>{const a=v.default.parse(window.location.search,{ignoreQueryPrefix:!0}).view;if(!a)return;const r=s.get(a);r&&(e(r),i())};return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[f,e,i,s])};exports.useViewUrlChange=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("swr"),d=require("react"),q=require("./index50.cjs"),y=require("./index8.cjs"),A=require("./index67.cjs"),C=require("./index56.cjs"),S=require("./index82.cjs"),I=e=>e&&e.__esModule?e:{default:e},M=I(O),v=()=>{const{DEFAULT_PAGE_NUMBER:e,DEFAULT_PAGE_SIZE:f,VIEW_TYPE:o}=y.useBusinessLogic(),{canUpdateCustomViews:u,orderedListOfCustomViews:t,defaultCustomViewId:w,isLoading:V}=A.useCustomViews({type:o}),{data:n,isLoading:m,error:_,mutate:g}=M.default(`/api/v2/custom_views?filter[type]=${o}&page[number]=${e}&page[size]=${f}`,C.fetcherV2,q.SWR_HOOK_OPTIONS),{viewsMap:l,customViews:s,fixedViews:c}=d.useMemo(()=>S.organiseViews({data:n,canUpdateCustomViews:u}),[n,u]),L=d.useMemo(()=>s.sort((p,E)=>{const a=Array.isArray(t)?t:[],i=a.indexOf(p.id),r=a.indexOf(E.id);return i===-1&&r===-1?0:i===-1?1:r===-1?-1:i-r}),[s,t]);return{defaultCustomViewId:w,viewsArray:[...c,...s],fixedViews:c,customViews:s,sortedCustomViews:L,viewsMap:l,isLoading:m||V,error:_,mutate:g}};exports.useViews=v;
package/dist/index64.js CHANGED
@@ -1,66 +1,36 @@
1
- import { useEffect as g } from "react";
2
- import V from "qs";
3
- import { ALL_VIEW_ID as E } from "./index80.js";
4
- import { useCustomViews as F } from "./index66.js";
5
- import { useViews as C } from "./index63.js";
6
- import { useBusinessLogic as D } from "./index8.js";
7
- import { useStores as P } from "./index62.js";
8
- const R = () => {
9
- const { VIEW_TYPE: v, SEARCH_FILTER_ID: c } = D(), {
10
- Filters: {
11
- activeViewId: d,
12
- initFiltersFromView: e,
13
- initFromUrl: i,
14
- discardChanges: w,
15
- updateUrl: L,
16
- setFilter: p
17
- }
18
- } = P(), { isLoading: I } = F({ type: v }), { viewsMap: t, defaultCustomViewId: m, isLoading: h, viewsArray: r } = C(), l = h || I;
19
- g(() => {
20
- if (l) return;
21
- const s = V.parse(window.location.search, { ignoreQueryPrefix: !0 }), u = s.view, n = s[c], o = Object.keys(s).length > 0;
22
- if (!d) {
23
- if (u) {
24
- const a = t.get(u);
25
- if (a)
26
- e(a), o && i();
27
- else {
28
- const f = t.get(m);
29
- f && (e(f), o && i(!1));
30
- }
31
- } else {
32
- const a = t.get(m);
33
- if (a)
34
- e(a), w(!0), o && i();
35
- else {
36
- const f = t.get(E);
37
- f ? e(f) : r != null && r[0] && e(r[0]);
38
- }
39
- }
40
- n && p(c, n);
41
- }
42
- }, [
43
- c,
44
- d,
45
- m,
46
- w,
47
- e,
48
- i,
49
- l,
50
- p,
51
- L,
52
- t,
53
- r
54
- ]), g(() => {
55
- const s = () => {
56
- const n = V.parse(window.location.search, { ignoreQueryPrefix: !0 }).view;
57
- if (!n) return;
58
- const o = t.get(n);
59
- o && (e(o), i());
60
- };
61
- return window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
62
- }, [w, e, i, t]);
1
+ import O from "swr";
2
+ import { useMemo as a } from "react";
3
+ import { SWR_HOOK_OPTIONS as x } from "./index50.js";
4
+ import { useBusinessLogic as C } from "./index8.js";
5
+ import { useCustomViews as I } from "./index67.js";
6
+ import { fetcherV2 as y } from "./index56.js";
7
+ import { organiseViews as v } from "./index82.js";
8
+ const $ = () => {
9
+ const { DEFAULT_PAGE_NUMBER: d, DEFAULT_PAGE_SIZE: f, VIEW_TYPE: t } = C(), {
10
+ canUpdateCustomViews: o,
11
+ orderedListOfCustomViews: r,
12
+ defaultCustomViewId: p,
13
+ isLoading: c
14
+ } = I({ type: t }), { data: n, isLoading: w, error: V, mutate: L } = O(
15
+ `/api/v2/custom_views?filter[type]=${t}&page[number]=${d}&page[size]=${f}`,
16
+ y,
17
+ x
18
+ ), { viewsMap: g, customViews: e, fixedViews: m } = a(() => v({ data: n, canUpdateCustomViews: o }), [n, o]), E = a(() => e.sort((_, A) => {
19
+ const u = Array.isArray(r) ? r : [], s = u.indexOf(_.id), i = u.indexOf(A.id);
20
+ return s === -1 && i === -1 ? 0 : s === -1 ? 1 : i === -1 ? -1 : s - i;
21
+ }), [e, r]);
22
+ return {
23
+ defaultCustomViewId: p,
24
+ viewsArray: [...m, ...e],
25
+ fixedViews: m,
26
+ customViews: e,
27
+ sortedCustomViews: E,
28
+ viewsMap: g,
29
+ isLoading: w || c,
30
+ error: V,
31
+ mutate: L
32
+ };
63
33
  };
64
34
  export {
65
- R as useViewUrlChange
35
+ $ as useViews
66
36
  };
package/dist/index65.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),i=require("qs"),u=require("./index8.cjs"),a=require("./index62.cjs"),c=e=>e&&e.__esModule?e:{default:e},l=c(i),d=()=>{const{SEARCH_FILTER_ID:e}=u.useBusinessLogic(),{Filters:{initFromUrl:t,setFilter:r}}=a.useStores();n.useEffect(()=>{const o=l.default.parse(window.location.search,{ignoreQueryPrefix:!0})[e];t(),o&&r(e,o)},[e,t,r]),n.useEffect(()=>{const s=()=>t();return window.addEventListener("popstate",s),()=>window.removeEventListener("popstate",s)},[t])};exports.useUrlChange=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),q=require("qs"),C=require("./index108.cjs"),E=require("./index67.cjs"),I=require("./index64.cjs"),D=require("./index8.cjs"),F=require("./index63.cjs"),P=t=>t&&t.__esModule?t:{default:t},m=P(q),S=()=>{const{VIEW_TYPE:t,SEARCH_FILTER_ID:f}=D.useBusinessLogic(),{Filters:{activeViewId:g,initFiltersFromView:e,initFromUrl:i,discardChanges:l,updateUrl:L,setFilter:p}}=F.useStores(),{isLoading:_}=E.useCustomViews({type:t}),{viewsMap:s,defaultCustomViewId:w,isLoading:h,viewsArray:r}=I.useViews(),V=h||_;v.useEffect(()=>{if(V)return;const o=m.default.parse(window.location.search,{ignoreQueryPrefix:!0}),d=o.view,a=o[f],n=Object.keys(o).length>0;if(!g){if(d){const u=s.get(d);if(u)e(u),n&&i();else{const c=s.get(w);c&&(e(c),n&&i(!1))}}else{const u=s.get(w);if(u)e(u),l(!0),n&&i();else{const c=s.get(C.ALL_VIEW_ID);c?e(c):r!=null&&r[0]&&e(r[0])}}a&&p(f,a)}},[f,g,w,l,e,i,V,p,L,s,r]),v.useEffect(()=>{const o=()=>{const a=m.default.parse(window.location.search,{ignoreQueryPrefix:!0}).view;if(!a)return;const n=s.get(a);n&&(e(n),i())};return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[l,e,i,s])};exports.useViewUrlChange=S;
package/dist/index65.js CHANGED
@@ -1,26 +1,66 @@
1
- import { useEffect as n } from "react";
2
- import i from "qs";
3
- import { useBusinessLogic as a } from "./index8.js";
4
- import { useStores as p } from "./index62.js";
5
- const d = () => {
6
- const { SEARCH_FILTER_ID: t } = a(), {
1
+ import { useEffect as g } from "react";
2
+ import V from "qs";
3
+ import { ALL_VIEW_ID as E } from "./index108.js";
4
+ import { useCustomViews as F } from "./index67.js";
5
+ import { useViews as C } from "./index64.js";
6
+ import { useBusinessLogic as D } from "./index8.js";
7
+ import { useStores as P } from "./index63.js";
8
+ const R = () => {
9
+ const { VIEW_TYPE: v, SEARCH_FILTER_ID: c } = D(), {
7
10
  Filters: {
8
- initFromUrl: e,
9
- setFilter: o
11
+ activeViewId: d,
12
+ initFiltersFromView: e,
13
+ initFromUrl: i,
14
+ discardChanges: w,
15
+ updateUrl: L,
16
+ setFilter: p
17
+ }
18
+ } = P(), { isLoading: I } = F({ type: v }), { viewsMap: t, defaultCustomViewId: m, isLoading: h, viewsArray: r } = C(), l = h || I;
19
+ g(() => {
20
+ if (l) return;
21
+ const s = V.parse(window.location.search, { ignoreQueryPrefix: !0 }), u = s.view, n = s[c], o = Object.keys(s).length > 0;
22
+ if (!d) {
23
+ if (u) {
24
+ const a = t.get(u);
25
+ if (a)
26
+ e(a), o && i();
27
+ else {
28
+ const f = t.get(m);
29
+ f && (e(f), o && i(!1));
30
+ }
31
+ } else {
32
+ const a = t.get(m);
33
+ if (a)
34
+ e(a), w(!0), o && i();
35
+ else {
36
+ const f = t.get(E);
37
+ f ? e(f) : r != null && r[0] && e(r[0]);
38
+ }
39
+ }
40
+ n && p(c, n);
10
41
  }
11
- } = p();
12
- n(() => {
13
- const s = i.parse(window.location.search, { ignoreQueryPrefix: !0 })[t];
14
- e(), s && o(t, s);
15
42
  }, [
16
- t,
43
+ c,
44
+ d,
45
+ m,
46
+ w,
17
47
  e,
18
- o
19
- ]), n(() => {
20
- const r = () => e();
21
- return window.addEventListener("popstate", r), () => window.removeEventListener("popstate", r);
22
- }, [e]);
48
+ i,
49
+ l,
50
+ p,
51
+ L,
52
+ t,
53
+ r
54
+ ]), g(() => {
55
+ const s = () => {
56
+ const n = V.parse(window.location.search, { ignoreQueryPrefix: !0 }).view;
57
+ if (!n) return;
58
+ const o = t.get(n);
59
+ o && (e(o), i());
60
+ };
61
+ return window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
62
+ }, [w, e, i, t]);
23
63
  };
24
64
  export {
25
- d as useUrlChange
65
+ R as useViewUrlChange
26
66
  };
package/dist/index66.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./index50.cjs"),C=require("swr"),v=require("./index56.cjs"),O=e=>e&&e.__esModule?e:{default:e},h=O(C),q=({type:e})=>{var o,t,i,n,u,r,c,_;const{data:s,isLoading:m,isValidating:l,error:w,mutate:f}=h.default("/current_user",v.fetcherV1,g.SWR_HOOK_OPTIONS),p=(t=(o=s==null?void 0:s.settings)==null?void 0:o.custom_view_positions)==null?void 0:t[e],V=(u=(n=(i=s==null?void 0:s.settings)==null?void 0:i.default_custom_views)==null?void 0:n[e])==null?void 0:u.toString(),S=!!((r=s==null?void 0:s.permissions)!=null&&r.delete_company_custom_views),a=!!((c=s==null?void 0:s.permissions)!=null&&c.update_company_custom_views),d=!!((_=s==null?void 0:s.permissions)!=null&&_.share_custom_views);return{canDeleteCustomViews:S,canUpdateCustomViews:a,canShareCustomViews:d,orderedListOfCustomViews:p,defaultCustomViewId:V,isLoading:m,isValidating:l,error:w,mutate:f}};exports.useCustomViews=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),i=require("qs"),u=require("./index8.cjs"),a=require("./index63.cjs"),c=e=>e&&e.__esModule?e:{default:e},l=c(i),d=()=>{const{SEARCH_FILTER_ID:e}=u.useBusinessLogic(),{Filters:{initFromUrl:t,setFilter:r}}=a.useStores();n.useEffect(()=>{const o=l.default.parse(window.location.search,{ignoreQueryPrefix:!0})[e];t(),o&&r(e,o)},[e,t,r]),n.useEffect(()=>{const s=()=>t();return window.addEventListener("popstate",s),()=>window.removeEventListener("popstate",s)},[t])};exports.useUrlChange=d;
package/dist/index66.js CHANGED
@@ -1,21 +1,26 @@
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);
7
- return {
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
17
- };
1
+ import { useEffect as n } from "react";
2
+ import i from "qs";
3
+ import { useBusinessLogic as a } from "./index8.js";
4
+ import { useStores as p } from "./index63.js";
5
+ const d = () => {
6
+ const { SEARCH_FILTER_ID: t } = a(), {
7
+ Filters: {
8
+ initFromUrl: e,
9
+ setFilter: o
10
+ }
11
+ } = p();
12
+ n(() => {
13
+ const s = i.parse(window.location.search, { ignoreQueryPrefix: !0 })[t];
14
+ e(), s && o(t, s);
15
+ }, [
16
+ t,
17
+ e,
18
+ o
19
+ ]), n(() => {
20
+ const r = () => e();
21
+ return window.addEventListener("popstate", r), () => window.removeEventListener("popstate", r);
22
+ }, [e]);
18
23
  };
19
24
  export {
20
- R as useCustomViews
25
+ d as useUrlChange
21
26
  };
package/dist/index67.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./index50.cjs"),C=require("swr"),v=require("./index56.cjs"),O=e=>e&&e.__esModule?e:{default:e},h=O(C),q=({type:e})=>{var o,t,i,n,u,r,c,_;const{data:s,isLoading:m,isValidating:l,error:w,mutate:f}=h.default("/current_user",v.fetcherV1,g.SWR_HOOK_OPTIONS),p=(t=(o=s==null?void 0:s.settings)==null?void 0:o.custom_view_positions)==null?void 0:t[e],V=(u=(n=(i=s==null?void 0:s.settings)==null?void 0:i.default_custom_views)==null?void 0:n[e])==null?void 0:u.toString(),S=!!((r=s==null?void 0:s.permissions)!=null&&r.delete_company_custom_views),a=!!((c=s==null?void 0:s.permissions)!=null&&c.update_company_custom_views),d=!!((_=s==null?void 0:s.permissions)!=null&&_.share_custom_views);return{canDeleteCustomViews:S,canUpdateCustomViews:a,canShareCustomViews:d,orderedListOfCustomViews:p,defaultCustomViewId:V,isLoading:m,isValidating:l,error:w,mutate:f}};exports.useCustomViews=q;
package/dist/index67.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 "./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
- }
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/index68.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("lodash/isArray"),a=require("./index8.cjs"),C=require("./index63.cjs"),I=require("./index64.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/index68.js CHANGED
@@ -1,64 +1,34 @@
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";
7
- const C = () => {
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:
15
- t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
16
- break;
17
- case a.MONOLITH:
18
- default:
19
- e && (r[o] = e);
20
- }
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:
26
- if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
27
- break;
28
- r.sort_order = t.direction, r.sort = t.columnId;
29
- break;
30
- case a.MONOLITH:
31
- default:
32
- if (!e) break;
33
- if (r[o] === e) return;
34
- r[o] = e;
35
- }
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 });
43
- break;
44
- case a.MONOLITH:
45
- default: {
46
- if (!i) break;
47
- const S = k(i);
48
- S.columnId && n(S);
49
- }
50
- }
51
- }, [s, o, n]);
52
- return I(() => {
53
- d();
54
- }, [d]), I(() => {
55
- u();
56
- }, [t, u]), {
57
- queryParams: O,
58
- hasActiveView: w,
59
- updateCurrentUrlWithTableSort: u
1
+ import c from "lodash/isArray";
2
+ import { useBusinessLogic as C } from "./index8.js";
3
+ import { useStores as I } from "./index63.js";
4
+ import { useViews as f } from "./index64.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
60
30
  };
61
31
  };
62
32
  export {
63
- C as useUrlParams
33
+ v as useColumns
64
34
  };