@veeqo/transfigure 2.2.0 → 2.3.1

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 (214) hide show
  1. package/dist/api/types.d.ts +4 -0
  2. package/dist/constants/viewConstants.d.ts +2 -0
  3. package/dist/hooks/index.d.ts +1 -0
  4. package/dist/hooks/useCreateEmptyDraftView/index.d.ts +1 -0
  5. package/dist/hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.d.ts +3 -0
  6. package/dist/hooks/usePersistUnsavedChanges/usePersistUnsavedChanges.d.ts +1 -0
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.js +72 -70
  9. package/dist/index100.cjs +1 -1
  10. package/dist/index100.js +9 -48
  11. package/dist/index101.cjs +1 -1
  12. package/dist/index101.js +8 -28
  13. package/dist/index102.cjs +1 -1
  14. package/dist/index102.js +48 -19
  15. package/dist/index103.cjs +1 -19
  16. package/dist/index103.js +28 -23
  17. package/dist/index104.cjs +19 -1
  18. package/dist/index104.js +23 -17
  19. package/dist/index105.cjs +1 -1
  20. package/dist/index105.js +15 -7
  21. package/dist/index106.cjs +1 -12
  22. package/dist/index106.js +18 -16
  23. package/dist/index107.cjs +12 -1
  24. package/dist/index107.js +16 -24
  25. package/dist/index108.cjs +1 -80
  26. package/dist/index108.js +21 -98
  27. package/dist/index109.cjs +1 -1
  28. package/dist/index109.js +23 -18
  29. package/dist/index11.cjs +1 -1
  30. package/dist/index11.js +1 -1
  31. package/dist/index110.cjs +80 -1
  32. package/dist/index110.js +98 -8
  33. package/dist/index111.cjs +1 -1
  34. package/dist/index111.js +17 -59
  35. package/dist/index112.cjs +1 -1
  36. package/dist/index112.js +7 -29
  37. package/dist/index113.cjs +1 -13
  38. package/dist/index113.js +60 -16
  39. package/dist/index114.cjs +1 -1
  40. package/dist/index114.js +30 -2
  41. package/dist/index115.cjs +13 -1
  42. package/dist/index115.js +15 -24
  43. package/dist/index116.cjs +1 -1
  44. package/dist/index116.js +2 -36
  45. package/dist/index117.cjs +1 -1
  46. package/dist/index117.js +36 -5
  47. package/dist/index118.cjs +1 -1
  48. package/dist/index118.js +25 -62
  49. package/dist/index119.cjs +1 -7
  50. package/dist/index119.js +5 -10
  51. package/dist/index120.cjs +7 -1
  52. package/dist/index120.js +10 -47
  53. package/dist/index121.cjs +1 -0
  54. package/dist/index121.js +65 -0
  55. package/dist/index122.cjs +1 -0
  56. package/dist/index122.js +49 -0
  57. package/dist/index13.cjs +1 -1
  58. package/dist/index13.js +2 -2
  59. package/dist/index14.cjs +1 -1
  60. package/dist/index14.js +1 -1
  61. package/dist/index15.cjs +1 -1
  62. package/dist/index15.js +1 -1
  63. package/dist/index16.cjs +1 -1
  64. package/dist/index16.js +1 -1
  65. package/dist/index17.cjs +1 -1
  66. package/dist/index17.js +1 -1
  67. package/dist/index19.cjs +1 -1
  68. package/dist/index19.js +4 -4
  69. package/dist/index20.cjs +1 -1
  70. package/dist/index20.js +3 -3
  71. package/dist/index21.cjs +1 -1
  72. package/dist/index21.js +2 -2
  73. package/dist/index22.cjs +1 -1
  74. package/dist/index22.js +3 -3
  75. package/dist/index23.cjs +1 -1
  76. package/dist/index23.js +2 -2
  77. package/dist/index26.cjs +1 -1
  78. package/dist/index26.js +3 -3
  79. package/dist/index27.cjs +1 -1
  80. package/dist/index27.js +3 -3
  81. package/dist/index28.cjs +1 -1
  82. package/dist/index28.js +1 -1
  83. package/dist/index29.cjs +1 -1
  84. package/dist/index29.js +2 -2
  85. package/dist/index30.cjs +1 -1
  86. package/dist/index30.js +2 -2
  87. package/dist/index31.cjs +1 -1
  88. package/dist/index31.js +3 -3
  89. package/dist/index32.cjs +1 -1
  90. package/dist/index32.js +1 -1
  91. package/dist/index33.cjs +1 -1
  92. package/dist/index33.js +1 -1
  93. package/dist/index34.cjs +1 -1
  94. package/dist/index34.js +1 -1
  95. package/dist/index36.cjs +1 -1
  96. package/dist/index36.js +35 -35
  97. package/dist/index37.cjs +1 -1
  98. package/dist/index37.js +10 -10
  99. package/dist/index38.cjs +1 -1
  100. package/dist/index38.js +40 -37
  101. package/dist/index39.cjs +1 -1
  102. package/dist/index39.js +1 -1
  103. package/dist/index40.cjs +1 -1
  104. package/dist/index40.js +3 -3
  105. package/dist/index41.cjs +1 -1
  106. package/dist/index41.js +4 -4
  107. package/dist/index42.cjs +1 -1
  108. package/dist/index42.js +2 -2
  109. package/dist/index44.cjs +1 -1
  110. package/dist/index44.js +4 -4
  111. package/dist/index46.cjs +1 -1
  112. package/dist/index46.js +3 -3
  113. package/dist/index47.cjs +1 -1
  114. package/dist/index47.js +1 -1
  115. package/dist/index57.cjs +1 -1
  116. package/dist/index57.js +33 -33
  117. package/dist/index58.cjs +1 -1
  118. package/dist/index58.js +2 -2
  119. package/dist/index59.cjs +1 -1
  120. package/dist/index59.js +10 -23
  121. package/dist/index60.cjs +1 -1
  122. package/dist/index60.js +19 -22
  123. package/dist/index61.cjs +1 -1
  124. package/dist/index61.js +25 -97
  125. package/dist/index62.cjs +1 -1
  126. package/dist/index62.js +97 -8
  127. package/dist/index63.cjs +1 -1
  128. package/dist/index63.js +8 -33
  129. package/dist/index64.cjs +1 -1
  130. package/dist/index64.js +33 -63
  131. package/dist/index65.cjs +1 -1
  132. package/dist/index65.js +59 -19
  133. package/dist/index66.cjs +1 -1
  134. package/dist/index66.js +23 -18
  135. package/dist/index67.cjs +1 -1
  136. package/dist/index67.js +16 -29
  137. package/dist/index68.cjs +1 -1
  138. package/dist/index68.js +30 -59
  139. package/dist/index69.cjs +1 -1
  140. package/dist/index69.js +61 -349
  141. package/dist/index7.cjs +1 -1
  142. package/dist/index7.js +4 -4
  143. package/dist/index70.cjs +1 -1
  144. package/dist/index70.js +372 -53
  145. package/dist/index71.cjs +1 -1
  146. package/dist/index71.js +48 -47
  147. package/dist/index72.cjs +1 -1
  148. package/dist/index72.js +51 -32
  149. package/dist/index73.cjs +1 -1
  150. package/dist/index73.js +40 -24
  151. package/dist/index74.cjs +1 -1
  152. package/dist/index74.js +26 -32
  153. package/dist/index75.cjs +1 -1
  154. package/dist/index75.js +38 -4
  155. package/dist/index76.cjs +1 -1
  156. package/dist/index76.js +4 -13
  157. package/dist/index77.cjs +1 -1
  158. package/dist/index77.js +12 -16
  159. package/dist/index78.cjs +1 -1
  160. package/dist/index78.js +14 -16
  161. package/dist/index79.cjs +1 -1
  162. package/dist/index79.js +18 -65
  163. package/dist/index80.cjs +1 -1
  164. package/dist/index80.js +66 -24
  165. package/dist/index81.cjs +1 -1
  166. package/dist/index81.js +24 -21
  167. package/dist/index82.cjs +1 -1
  168. package/dist/index82.js +19 -6
  169. package/dist/index83.cjs +1 -1
  170. package/dist/index83.js +7 -2
  171. package/dist/index84.cjs +1 -1
  172. package/dist/index84.js +2 -9
  173. package/dist/index85.cjs +1 -3
  174. package/dist/index85.js +8 -13
  175. package/dist/index86.cjs +3 -1
  176. package/dist/index86.js +13 -8
  177. package/dist/index87.cjs +1 -1
  178. package/dist/index87.js +7 -115
  179. package/dist/index88.cjs +1 -1
  180. package/dist/index88.js +2 -2
  181. package/dist/index90.cjs +1 -1
  182. package/dist/index90.js +117 -2
  183. package/dist/index91.cjs +1 -1
  184. package/dist/index91.js +2 -5
  185. package/dist/index92.cjs +1 -1
  186. package/dist/index92.js +5 -13
  187. package/dist/index93.cjs +1 -104
  188. package/dist/index93.js +12 -119
  189. package/dist/index94.cjs +1 -1
  190. package/dist/index94.js +13 -68
  191. package/dist/index95.cjs +104 -1
  192. package/dist/index95.js +118 -27
  193. package/dist/index96.cjs +1 -1
  194. package/dist/index96.js +68 -2
  195. package/dist/index97.cjs +1 -1
  196. package/dist/index97.js +26 -39
  197. package/dist/index98.cjs +1 -1
  198. package/dist/index98.js +2 -11
  199. package/dist/index99.cjs +1 -1
  200. package/dist/index99.js +40 -14
  201. package/dist/mobx/Filters/Filters.d.ts +12 -1
  202. package/dist/mobx/Views/Views.d.ts +1 -0
  203. package/dist/storybookHelpers/StoryWrapper.d.ts +1 -1
  204. package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.d.ts +6 -0
  205. package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.test.d.ts +1 -0
  206. package/dist/utils/createEmptyTransformedView/index.d.ts +1 -0
  207. package/dist/utils/index.d.ts +1 -1
  208. package/dist/utils/sortUtils/index.d.ts +2 -0
  209. package/dist/utils/sortUtils/sortUtils.d.ts +11 -0
  210. package/dist/utils/sortUtils/sortUtils.test.d.ts +1 -0
  211. package/package.json +1 -1
  212. package/dist/utils/createAllView/createAllView.d.ts +0 -3
  213. package/dist/utils/createAllView/index.d.ts +0 -1
  214. /package/dist/{utils/createAllView/createAllView.test.d.ts → hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.test.d.ts} +0 -0
package/dist/index57.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import { useState as w } from "react";
2
- import { ALL_VIEW_ID as f } from "./index80.js";
3
- import { viewsAdapter as R } from "./index79.js";
4
- import { useCustomViews as q } from "./index66.js";
2
+ import { ALL_VIEW_ID as f } from "./index93.js";
3
+ import { viewsAdapter as R } from "./index80.js";
4
+ import { useCustomViews as q } from "./index67.js";
5
5
  import { useDuplicateActiveView as B } from "./index58.js";
6
- import { usePersistUnsavedChanges as T } from "./index61.js";
7
- import { useViews as W } from "./index63.js";
6
+ import { usePersistUnsavedChanges as T } from "./index62.js";
7
+ import { useViews as W } from "./index64.js";
8
8
  import { SHARING_OPTIONS as n } from "./index45.js";
9
- import { patchCurrentUser as N } from "./index4.js";
9
+ import { patchCurrentUser as g } from "./index4.js";
10
10
  import { deleteCustomView as G } from "./index3.js";
11
11
  import { useBusinessLogic as H } from "./index8.js";
12
- import { useStores as b } from "./index62.js";
12
+ import { useStores as b } from "./index63.js";
13
13
  import { createCustomView as j } from "./index6.js";
14
14
  import { patchCustomView as z } from "./index5.js";
15
- const Ve = (e) => {
16
- const { VIEW_TYPE: d } = H(), { duplicateView: A } = B(), { getActiveViewInAPIFormat: P } = T(), {
15
+ const ye = (e) => {
16
+ const { VIEW_TYPE: d } = H(), { duplicateView: P } = B(), { getActiveViewInAPIFormat: M } = T(), {
17
17
  canDeleteCustomViews: O,
18
- defaultCustomViewId: M,
19
- canUpdateCustomViews: F,
20
- mutate: Y
18
+ defaultCustomViewId: F,
19
+ canUpdateCustomViews: Y,
20
+ mutate: k
21
21
  } = q({
22
22
  type: d
23
- }), { mutate: p, viewsMap: l, viewsArray: t } = W(), [x, a] = w(!1), [E, m] = w(!1), [h, c] = w(!1), [k, D] = w(!1), {
24
- Views: { removeDraftViewById: V, draftViewsMap: L },
25
- Filters: { initFiltersFromView: r, updateUrl: u, setActiveViewId: y },
23
+ }), { mutate: p, viewsMap: l, viewsArray: t } = W(), [x, a] = w(!1), [E, m] = w(!1), [h, c] = w(!1), [L, D] = w(!1), {
24
+ Views: { removeDraftViewById: y, draftViewsMap: I },
25
+ Filters: { initFiltersFromView: r, updateUrl: u, setActiveViewId: V },
26
26
  Notifications: { notify: s }
27
27
  } = b();
28
28
  return {
29
29
  actions: {
30
30
  delete: {
31
31
  handleDeleteDraftView: () => {
32
- if (!e.originalView) throw Error("No draft view found");
33
- V(e.id);
34
- const o = l.get(M);
32
+ if (!I.has(e.id)) throw Error("No draft view found");
33
+ y(e.id);
34
+ const o = l.get(F);
35
35
  if (o)
36
36
  o && r(o);
37
37
  else {
@@ -62,8 +62,8 @@ const Ve = (e) => {
62
62
  }
63
63
  },
64
64
  handleShowDeleteConfirmation: () => {
65
- if (L.has(e.id)) {
66
- V(e.id), e.originalView ? y(e.originalView.id) : l.has(f) ? y(f) : t != null && t[0] && y(t[0].id);
65
+ if (I.has(e.id)) {
66
+ y(e.id), e.originalView ? V(e.originalView.id) : l.has(f) ? V(f) : t != null && t[0] && V(t[0].id);
67
67
  return;
68
68
  }
69
69
  O ? m(!0) : s({
@@ -88,14 +88,14 @@ const Ve = (e) => {
88
88
  shared: C.key === n.COMPANY.key
89
89
  }
90
90
  };
91
- await z(e.id, _), v && (await N({
91
+ await z(e.id, _), v && (await g({
92
92
  user_setting_attributes: {
93
93
  default_custom_view: {
94
94
  id: Number(e.id),
95
95
  type: d
96
96
  }
97
97
  }
98
- }), await Y()), await p(), u(), s({
98
+ }), await k()), await p(), u(), s({
99
99
  type: "success",
100
100
  text: `'${i}' view updated`
101
101
  }), c(!1);
@@ -107,11 +107,11 @@ const Ve = (e) => {
107
107
  }
108
108
  },
109
109
  handleDuplicate: () => {
110
- A(), a(!1);
110
+ P(), a(!1);
111
111
  },
112
112
  handleMakeDefault: async () => {
113
113
  try {
114
- await N({
114
+ await g({
115
115
  user_setting_attributes: {
116
116
  default_custom_view: {
117
117
  id: Number(e.id),
@@ -136,27 +136,27 @@ const Ve = (e) => {
136
136
  create: {
137
137
  handleCreate: async (o) => {
138
138
  try {
139
- const { viewName: i, shareOption: S, isDefault: v } = o, C = S === "company" ? n.COMPANY : n.PERSONAL, { arg: _ } = P(), { data: g } = await j({
139
+ const { viewName: i, shareOption: S, isDefault: v } = o, C = S === "company" ? n.COMPANY : n.PERSONAL, { arg: _ } = M(), { data: N } = await j({
140
140
  attributes: {
141
141
  ..._,
142
142
  title: i,
143
143
  shared: C.key === n.COMPANY.key
144
144
  }
145
- }), I = t.map(($) => $.id);
146
- I.push(g.id), await N({
145
+ }), A = t.map(($) => $.id);
146
+ A.push(N.id), await g({
147
147
  user_setting_attributes: {
148
148
  custom_view_positions: {
149
- order: I
149
+ order: A
150
150
  },
151
151
  ...v ? {
152
152
  default_custom_view: {
153
- id: Number(g.id),
153
+ id: Number(N.id),
154
154
  type: d
155
155
  }
156
156
  } : {}
157
157
  }
158
- }), await p(), V(e.id);
159
- const U = R({ view: g, canUpdateCustomViews: F });
158
+ }), await p(), y(e.id);
159
+ const U = R({ view: N, canUpdateCustomViews: Y });
160
160
  r(U), u(), D(!1), s({
161
161
  type: "success",
162
162
  text: `New view '${i}' created`
@@ -177,11 +177,11 @@ const Ve = (e) => {
177
177
  state: {
178
178
  shouldShowDropdown: x,
179
179
  shouldShowEditDropdown: h,
180
- shouldShowCreateDropdown: k,
180
+ shouldShowCreateDropdown: L,
181
181
  shouldShowDeleteConfirmation: E
182
182
  }
183
183
  };
184
184
  };
185
185
  export {
186
- Ve as useDropdownManager
186
+ ye as useDropdownManager
187
187
  };
package/dist/index58.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index63.cjs"),u=require("./index62.cjs"),c=()=>{const{viewsMap:r}=a.useViews(),{Filters:{activeViewId:i,initFiltersFromView:s,updateUrl:w},Views:{addDraftView:o,draftViewsMap:n}}=u.useStores();return{duplicateView:()=>{if(!i)throw Error("Creating views from all is not supported...implement me");if(r.has(i)){const e=r.get(i);if(!e)throw Error("Could not find view in viewsMap");const t=o({...e});s(t)}else{const e=n.get(i);if(!e)throw Error("Could not find view in draftViewsMap");const t=o({...e});s(t)}w()}}};exports.useDuplicateActiveView=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index64.cjs"),u=require("./index63.cjs"),c=()=>{const{viewsMap:r}=a.useViews(),{Filters:{activeViewId:i,initFiltersFromView:s,updateUrl:w},Views:{addDraftView:o,draftViewsMap:n}}=u.useStores();return{duplicateView:()=>{if(!i)throw Error("Creating views from all is not supported...implement me");if(r.has(i)){const e=r.get(i);if(!e)throw Error("Could not find view in viewsMap");const t=o({...e});s(t)}else{const e=n.get(i);if(!e)throw Error("Could not find view in draftViewsMap");const t=o({...e});s(t)}w()}}};exports.useDuplicateActiveView=c;
package/dist/index58.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useViews as a } from "./index63.js";
2
- import { useStores as f } from "./index62.js";
1
+ import { useViews as a } from "./index64.js";
2
+ import { useStores as f } from "./index63.js";
3
3
  const d = () => {
4
4
  const { viewsMap: r } = a(), {
5
5
  Filters: { activeViewId: i, initFiltersFromView: o, updateUrl: s },
package/dist/index59.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),u=require("./index76.cjs"),l=require("./index77.cjs"),a=require("swr/immutable"),F=require("./index62.cjs"),y=e=>e&&e.__esModule?e:{default:e},d=y(a),f=({filterData:e})=>{var c;const{Filters:{arrayFilters:o}}=F.useStores(),s=o.get(e.id),{data:r}=d.default((c=e.fetchAsyncFilterOptions)==null?void 0:c.URL,()=>{var t;return l.getFetcherFunction({fetcherName:(t=e.fetchAsyncFilterOptions)==null?void 0:t.fetcher})(e.fetchAsyncFilterOptions.URL)},{revalidateOnFocus:!1});return{filterLabel:i.useMemo(()=>{const n=r?u.getAsyncOptions({data:r,config:e.fetchAsyncFilterOptions}):e.options;return(n==null?void 0:n.filter(t=>s==null?void 0:s.includes(t.value.toString())).map(t=>t.label).join(", "))||""},[r,e.options,s,e.fetchAsyncFilterOptions])}};exports.useFilterArrayLabel=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index63.cjs"),a=()=>{const{Filters:{initFiltersFromView:e,updateUrl:t},Views:{addEmptyDraftView:r}}=s.useStores();return{createEmptyDraftView:()=>{const i=r();e(i),t()}}};exports.useCreateEmptyDraftView=a;
package/dist/index59.js CHANGED
@@ -1,27 +1,14 @@
1
- import { useMemo as i } from "react";
2
- import { getAsyncOptions as m } from "./index76.js";
3
- import { getFetcherFunction as p } from "./index77.js";
4
- import l from "swr/immutable";
5
- import { useStores as f } from "./index62.js";
6
- const a = ({ filterData: e }) => {
7
- var s;
1
+ import { useStores as s } from "./index63.js";
2
+ const w = () => {
8
3
  const {
9
- Filters: { arrayFilters: c }
10
- } = f(), o = c.get(e.id), { data: n } = l(
11
- (s = e.fetchAsyncFilterOptions) == null ? void 0 : s.URL,
12
- () => {
13
- var t;
14
- return p({
15
- fetcherName: (t = e.fetchAsyncFilterOptions) == null ? void 0 : t.fetcher
16
- })(e.fetchAsyncFilterOptions.URL);
17
- },
18
- { revalidateOnFocus: !1 }
19
- );
20
- return { filterLabel: i(() => {
21
- const r = n ? m({ data: n, config: e.fetchAsyncFilterOptions }) : e.options;
22
- return (r == null ? void 0 : r.filter((t) => o == null ? void 0 : o.includes(t.value.toString())).map((t) => t.label).join(", ")) || "";
23
- }, [n, e.options, o, e.fetchAsyncFilterOptions]) };
4
+ Filters: { initFiltersFromView: t, updateUrl: e },
5
+ Views: { addEmptyDraftView: r }
6
+ } = s();
7
+ return { createEmptyDraftView: () => {
8
+ const i = r();
9
+ t(i), e();
10
+ } };
24
11
  };
25
12
  export {
26
- a as useFilterArrayLabel
13
+ w as useCreateEmptyDraftView
27
14
  };
package/dist/index60.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),l=require("./index76.cjs"),F=require("./index77.cjs"),f=require("swr/immutable"),h=require("./index62.cjs"),p=e=>e&&e.__esModule?e:{default:e},d=p(f),y=({filterData:e})=>{var o;const{Filters:{filters:r}}=h.useStores(),t=r.get(e.id),{data:c}=d.default((o=e.fetchAsyncFilterOptions)==null?void 0:o.URL,()=>{var n;return F.getFetcherFunction({fetcherName:(n=e.fetchAsyncFilterOptions)==null?void 0:n.fetcher})(e.fetchAsyncFilterOptions.URL)},{revalidateOnFocus:!1});return{filterLabel:u.useMemo(()=>{var n;if(!e.options&&!e.fetchAsyncFilterOptions)return t;const s=c?l.getAsyncOptions({data:c,config:e.fetchAsyncFilterOptions}):e.options;return((n=s==null?void 0:s.find(i=>i.value.toString()===(t==null?void 0:t.toString())))==null?void 0:n.label)||""},[c,e.options,t,e.fetchAsyncFilterOptions])}};exports.useFilterLabel=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),u=require("./index77.cjs"),l=require("./index78.cjs"),a=require("swr/immutable"),F=require("./index63.cjs"),y=e=>e&&e.__esModule?e:{default:e},d=y(a),f=({filterData:e})=>{var c;const{Filters:{arrayFilters:o}}=F.useStores(),s=o.get(e.id),{data:r}=d.default((c=e.fetchAsyncFilterOptions)==null?void 0:c.URL,()=>{var t;return l.getFetcherFunction({fetcherName:(t=e.fetchAsyncFilterOptions)==null?void 0:t.fetcher})(e.fetchAsyncFilterOptions.URL)},{revalidateOnFocus:!1});return{filterLabel:i.useMemo(()=>{const n=r?u.getAsyncOptions({data:r,config:e.fetchAsyncFilterOptions}):e.options;return(n==null?void 0:n.filter(t=>s==null?void 0:s.includes(t.value.toString())).map(t=>t.label).join(", "))||""},[r,e.options,s,e.fetchAsyncFilterOptions])}};exports.useFilterArrayLabel=f;
package/dist/index60.js CHANGED
@@ -1,30 +1,27 @@
1
- import { useMemo as p } from "react";
2
- import { getAsyncOptions as m } from "./index76.js";
3
- import { getFetcherFunction as f } from "./index77.js";
4
- import h from "swr/immutable";
5
- import { useStores as u } from "./index62.js";
6
- const b = ({ filterData: t }) => {
7
- var c;
1
+ import { useMemo as i } from "react";
2
+ import { getAsyncOptions as m } from "./index77.js";
3
+ import { getFetcherFunction as p } from "./index78.js";
4
+ import l from "swr/immutable";
5
+ import { useStores as f } from "./index63.js";
6
+ const a = ({ filterData: e }) => {
7
+ var s;
8
8
  const {
9
- Filters: { filters: r }
10
- } = u(), e = r.get(t.id), { data: s } = h(
11
- (c = t.fetchAsyncFilterOptions) == null ? void 0 : c.URL,
9
+ Filters: { arrayFilters: c }
10
+ } = f(), o = c.get(e.id), { data: n } = l(
11
+ (s = e.fetchAsyncFilterOptions) == null ? void 0 : s.URL,
12
12
  () => {
13
- var o;
14
- return f({
15
- fetcherName: (o = t.fetchAsyncFilterOptions) == null ? void 0 : o.fetcher
16
- })(t.fetchAsyncFilterOptions.URL);
13
+ var t;
14
+ return p({
15
+ fetcherName: (t = e.fetchAsyncFilterOptions) == null ? void 0 : t.fetcher
16
+ })(e.fetchAsyncFilterOptions.URL);
17
17
  },
18
18
  { revalidateOnFocus: !1 }
19
19
  );
20
- return { filterLabel: p(() => {
21
- var o;
22
- if (!t.options && !t.fetchAsyncFilterOptions)
23
- return e;
24
- const n = s ? m({ data: s, config: t.fetchAsyncFilterOptions }) : t.options;
25
- return ((o = n == null ? void 0 : n.find((i) => i.value.toString() === (e == null ? void 0 : e.toString()))) == null ? void 0 : o.label) || "";
26
- }, [s, t.options, e, t.fetchAsyncFilterOptions]) };
20
+ return { filterLabel: i(() => {
21
+ const r = n ? m({ data: n, config: e.fetchAsyncFilterOptions }) : e.options;
22
+ return (r == null ? void 0 : r.filter((t) => o == null ? void 0 : o.includes(t.value.toString())).map((t) => t.label).join(", ")) || "";
23
+ }, [n, e.options, o, e.fetchAsyncFilterOptions]) };
27
24
  };
28
25
  export {
29
- b as useFilterLabel
26
+ a as useFilterArrayLabel
30
27
  };
package/dist/index61.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),g=require("@internationalized/date"),V=require("./index70.cjs"),M=require("./index71.cjs"),I=require("./index63.cjs"),N=require("./index8.cjs"),v=require("./index62.cjs"),C=require("./index5.cjs"),q=()=>{const{DATE_RANGE_FILTERS:a,NUMBER_RANGE_FILTERS:p,SEARCH_FILTER_ID:m,VIEW_TYPE:w}=N.useBusinessLogic(),{Filters:{activeViewId:n,filters:y,arrayFilters:F,dateRangeFilters:d,numberRangeFilters:b,initFiltersFromView:S,pageSize:l},Views:{draftViewsMap:h},Notifications:{notify:E}}=v.useStores(),{viewsMap:o,mutate:A}=I.useViews(),[R,f]=T.useState(!1),c=()=>{if(!n)throw Error("No active view");const r={};Array.from(y.entries()).filter(([e,t])=>t!==""&&e!==m).forEach(([e,t])=>{r[e]=t}),Array.from(F.entries()).filter(([,e])=>e.length>0).forEach(([e,t])=>{r[e]=t}),Array.from(d.entries()).filter(([,e])=>e.filterType!==void 0).forEach(([e,t])=>{t.filterType==="CUSTOM"?r[e]={gte:t.gte.toString(),lte:t.lte.toString()}:r[e]=t.filterType}),Array.from(b.entries()).filter(([,e])=>e.gte!==void 0||e.lte!==void 0).forEach(([e,t])=>{r[e]={},t.gte!==void 0&&(r[e].gte=t.gte.toString()),t.isValidLte&&t.lte&&(r[e].lte=t.lte.toString())});let s=o.get(n);return o.has(n)||(s=h.get(n)),{arg:{type:w,filters:{filter:r,page:{size:Number(l)}},title:s==null?void 0:s.label},currentView:s}};return{getActiveViewInAPIFormat:c,saveChanges:async()=>{if(n)try{f(!0);const{arg:r,currentView:s}=c();await C.patchCustomView(n,{attributes:r}),await A();const u={...s,filterMaps:{filters:new Map(Object.entries(r.filters.filter).filter(([e,t])=>!Array.isArray(t)&&typeof t=="string"&&!a.includes(e)).map(([e,t])=>[e,t])),arrayFilters:new Map(Object.entries(r.filters.filter).filter(([,e])=>Array.isArray(e)).map(([e,t])=>[e,t])),rangeFilters:new Map(Object.entries(r.filters.filter).filter(([e])=>a.includes(e)).map(([e,t])=>{const i=new M.RangeFilter;return typeof t=="object"?(i.setFilterType("CUSTOM"),i.setDates(g.parseDate(t.gte),g.parseDate(t.lte))):i.setFilterType(t),[e,i]})),numberRangeFilters:new Map(Object.entries(r.filters.filter).filter(([e])=>p.includes(e)).map(([e,t])=>{const i=new V.NumberRangeFilter({filterId:e});return t.gte&&i.setGte(Number(t.gte)),t.lte&&i.setLte(Number(t.lte)),[e,i]}))},page:{size:l}};S(u)}catch(r){console.log(r),E({type:"error",text:"Failed to save changes to your view"})}finally{f(!1)}},isSubmitting:R}};exports.usePersistUnsavedChanges=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),l=require("./index77.cjs"),F=require("./index78.cjs"),f=require("swr/immutable"),h=require("./index63.cjs"),p=e=>e&&e.__esModule?e:{default:e},d=p(f),y=({filterData:e})=>{var o;const{Filters:{filters:r}}=h.useStores(),t=r.get(e.id),{data:c}=d.default((o=e.fetchAsyncFilterOptions)==null?void 0:o.URL,()=>{var n;return F.getFetcherFunction({fetcherName:(n=e.fetchAsyncFilterOptions)==null?void 0:n.fetcher})(e.fetchAsyncFilterOptions.URL)},{revalidateOnFocus:!1});return{filterLabel:u.useMemo(()=>{var n;if(!e.options&&!e.fetchAsyncFilterOptions)return t;const s=c?l.getAsyncOptions({data:c,config:e.fetchAsyncFilterOptions}):e.options;return((n=s==null?void 0:s.find(i=>i.value.toString()===(t==null?void 0:t.toString())))==null?void 0:n.label)||""},[c,e.options,t,e.fetchAsyncFilterOptions])}};exports.useFilterLabel=y;
package/dist/index61.js CHANGED
@@ -1,102 +1,30 @@
1
- import { useState as T } from "react";
2
- import { parseDate as p } from "@internationalized/date";
3
- import { NumberRangeFilter as I } from "./index70.js";
4
- import { RangeFilter as M } from "./index71.js";
5
- import { useViews as V } from "./index63.js";
6
- import { useBusinessLogic as N } from "./index8.js";
7
- import { useStores as v } from "./index62.js";
8
- import { patchCustomView as C } from "./index5.js";
9
- const x = () => {
1
+ import { useMemo as p } from "react";
2
+ import { getAsyncOptions as m } from "./index77.js";
3
+ import { getFetcherFunction as f } from "./index78.js";
4
+ import h from "swr/immutable";
5
+ import { useStores as u } from "./index63.js";
6
+ const b = ({ filterData: t }) => {
7
+ var c;
10
8
  const {
11
- DATE_RANGE_FILTERS: a,
12
- NUMBER_RANGE_FILTERS: g,
13
- SEARCH_FILTER_ID: u,
14
- VIEW_TYPE: w
15
- } = N(), {
16
- Filters: {
17
- activeViewId: o,
18
- filters: y,
19
- arrayFilters: F,
20
- dateRangeFilters: b,
21
- numberRangeFilters: d,
22
- initFiltersFromView: E,
23
- pageSize: l
9
+ Filters: { filters: r }
10
+ } = u(), e = r.get(t.id), { data: s } = h(
11
+ (c = t.fetchAsyncFilterOptions) == null ? void 0 : c.URL,
12
+ () => {
13
+ var o;
14
+ return f({
15
+ fetcherName: (o = t.fetchAsyncFilterOptions) == null ? void 0 : o.fetcher
16
+ })(t.fetchAsyncFilterOptions.URL);
24
17
  },
25
- Views: { draftViewsMap: A },
26
- Notifications: { notify: S }
27
- } = v(), { viewsMap: f, mutate: h } = V(), [R, n] = T(!1), c = () => {
28
- if (!o) throw Error("No active view");
29
- const r = {};
30
- Array.from(y.entries()).filter(([e, t]) => t !== "" && e !== u).forEach(([e, t]) => {
31
- r[e] = t;
32
- }), Array.from(F.entries()).filter(([, e]) => e.length > 0).forEach(([e, t]) => {
33
- r[e] = t;
34
- }), Array.from(b.entries()).filter(([, e]) => e.filterType !== void 0).forEach(([e, t]) => {
35
- t.filterType === "CUSTOM" ? r[e] = {
36
- gte: t.gte.toString(),
37
- lte: t.lte.toString()
38
- } : r[e] = t.filterType;
39
- }), Array.from(d.entries()).filter(([, e]) => e.gte !== void 0 || e.lte !== void 0).forEach(([e, t]) => {
40
- r[e] = {}, t.gte !== void 0 && (r[e].gte = t.gte.toString()), t.isValidLte && t.lte && (r[e].lte = t.lte.toString());
41
- });
42
- let s = f.get(o);
43
- return f.has(o) || (s = A.get(o)), { arg: {
44
- type: w,
45
- filters: {
46
- filter: r,
47
- page: {
48
- size: Number(l)
49
- }
50
- },
51
- title: s == null ? void 0 : s.label
52
- }, currentView: s };
53
- };
54
- return {
55
- getActiveViewInAPIFormat: c,
56
- saveChanges: async () => {
57
- if (o)
58
- try {
59
- n(!0);
60
- const { arg: r, currentView: s } = c();
61
- await C(o, { attributes: r }), await h();
62
- const m = {
63
- ...s,
64
- filterMaps: {
65
- filters: new Map(
66
- Object.entries(r.filters.filter).filter(
67
- ([e, t]) => !Array.isArray(t) && typeof t == "string" && !a.includes(e)
68
- ).map(([e, t]) => [e, t])
69
- ),
70
- arrayFilters: new Map(
71
- Object.entries(r.filters.filter).filter(([, e]) => Array.isArray(e)).map(([e, t]) => [e, t])
72
- ),
73
- rangeFilters: new Map(
74
- Object.entries(r.filters.filter).filter(([e]) => a.includes(e)).map(([e, t]) => {
75
- const i = new M();
76
- return typeof t == "object" ? (i.setFilterType("CUSTOM"), i.setDates(p(t.gte), p(t.lte))) : i.setFilterType(t), [e, i];
77
- })
78
- ),
79
- numberRangeFilters: new Map(
80
- Object.entries(r.filters.filter).filter(([e]) => g.includes(e)).map(([e, t]) => {
81
- const i = new I({ filterId: e });
82
- return t.gte && i.setGte(Number(t.gte)), t.lte && i.setLte(Number(t.lte)), [e, i];
83
- })
84
- )
85
- },
86
- page: {
87
- size: l
88
- }
89
- };
90
- E(m);
91
- } catch (r) {
92
- console.log(r), S({ type: "error", text: "Failed to save changes to your view" });
93
- } finally {
94
- n(!1);
95
- }
96
- },
97
- isSubmitting: R
98
- };
18
+ { revalidateOnFocus: !1 }
19
+ );
20
+ return { filterLabel: p(() => {
21
+ var o;
22
+ if (!t.options && !t.fetchAsyncFilterOptions)
23
+ return e;
24
+ const n = s ? m({ data: s, config: t.fetchAsyncFilterOptions }) : t.options;
25
+ return ((o = n == null ? void 0 : n.find((i) => i.value.toString() === (e == null ? void 0 : e.toString()))) == null ? void 0 : o.label) || "";
26
+ }, [s, t.options, e, t.fetchAsyncFilterOptions]) };
99
27
  };
100
28
  export {
101
- x as usePersistUnsavedChanges
29
+ b as useFilterLabel
102
30
  };
package/dist/index62.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),p=require("@internationalized/date"),M=require("./index71.cjs"),I=require("./index72.cjs"),N=require("./index64.cjs"),v=require("./index8.cjs"),C=require("./index63.cjs"),q=require("./index5.cjs"),O=()=>{const{DATE_RANGE_FILTERS:n,NUMBER_RANGE_FILTERS:m,SEARCH_FILTER_ID:w,VIEW_TYPE:y}=v.useBusinessLogic(),{Filters:{activeViewId:a,filters:F,arrayFilters:b,dateRangeFilters:d,numberRangeFilters:S,initFiltersFromView:h,pageSize:o},Table:{sortParam:l},Views:{draftViewsMap:E},Notifications:{notify:A}}=C.useStores(),{viewsMap:f,mutate:R}=N.useViews(),[T,c]=V.useState(!1),u=()=>{if(!a)throw Error("No active view");const r={};Array.from(F.entries()).filter(([e,t])=>t!==""&&e!==w).forEach(([e,t])=>{r[e]=t}),Array.from(b.entries()).filter(([,e])=>e.length>0).forEach(([e,t])=>{r[e]=t}),Array.from(d.entries()).filter(([,e])=>e.filterType!==void 0).forEach(([e,t])=>{t.filterType==="CUSTOM"?r[e]={gte:t.gte.toString(),lte:t.lte.toString()}:r[e]=t.filterType}),Array.from(S.entries()).filter(([,e])=>e.gte!==void 0||e.lte!==void 0).forEach(([e,t])=>{r[e]={},t.gte!==void 0&&(r[e].gte=t.gte.toString()),t.isValidLte&&t.lte&&(r[e].lte=t.lte.toString())});let s=f.get(a);return f.has(a)||(s=E.get(a)),{arg:{type:y,filters:{filter:r,sort:l,page:{size:Number(o)}},title:s==null?void 0:s.label},currentView:s}};return{getActiveViewInAPIFormat:u,saveChanges:async()=>{if(a)try{c(!0);const{arg:r,currentView:s}=u();await q.patchCustomView(a,{attributes:r}),await R();const g={...s,filterMaps:{filters:new Map(Object.entries(r.filters.filter).filter(([e,t])=>!Array.isArray(t)&&typeof t=="string"&&!n.includes(e)).map(([e,t])=>[e,t])),arrayFilters:new Map(Object.entries(r.filters.filter).filter(([,e])=>Array.isArray(e)).map(([e,t])=>[e,t])),rangeFilters:new Map(Object.entries(r.filters.filter).filter(([e])=>n.includes(e)).map(([e,t])=>{const i=new I.RangeFilter;return typeof t=="object"?(i.setFilterType("CUSTOM"),i.setDates(p.parseDate(t.gte),p.parseDate(t.lte))):i.setFilterType(t),[e,i]})),numberRangeFilters:new Map(Object.entries(r.filters.filter).filter(([e])=>m.includes(e)).map(([e,t])=>{const i=new M.NumberRangeFilter({filterId:e});return t.gte&&i.setGte(Number(t.gte)),t.lte&&i.setLte(Number(t.lte)),[e,i]}))},page:{size:o},sort:l};h(g)}catch(r){console.log(r),A({type:"error",text:"Failed to save changes to your view"})}finally{c(!1)}},isSubmitting:T}};exports.usePersistUnsavedChanges=O;
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;