@veeqo/transfigure 1.1.5 → 1.1.7

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 (230) hide show
  1. package/dist/components/ActionsDropdown/ActionsDropdown.d.ts +2 -0
  2. package/dist/components/ActionsDropdown/index.d.ts +1 -0
  3. package/dist/components/ActionsDropdown/types.d.ts +7 -0
  4. package/dist/components/Filters/Fields/NumberRangeFilter/MuiSlider.d.ts +1 -1
  5. package/dist/components/Views/PillNotifications/variants/styled.d.ts +3 -3
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.css +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +146 -144
  10. package/dist/index100.cjs +1 -1
  11. package/dist/index100.js +29 -21
  12. package/dist/index101.cjs +1 -1
  13. package/dist/index101.js +21 -24
  14. package/dist/index102.cjs +16 -77
  15. package/dist/index102.js +19 -96
  16. package/dist/index103.cjs +12 -1
  17. package/dist/index103.js +16 -2
  18. package/dist/index104.cjs +80 -1
  19. package/dist/index104.js +101 -19
  20. package/dist/index105.cjs +1 -1
  21. package/dist/index105.js +18 -7
  22. package/dist/index106.cjs +1 -1
  23. package/dist/index106.js +7 -63
  24. package/dist/index107.cjs +1 -1
  25. package/dist/index107.js +60 -26
  26. package/dist/index108.cjs +1 -13
  27. package/dist/index108.js +30 -17
  28. package/dist/index109.cjs +13 -1
  29. package/dist/index109.js +15 -24
  30. package/dist/index11.cjs +1 -1
  31. package/dist/index11.js +27 -18
  32. package/dist/index110.cjs +1 -1
  33. package/dist/index110.js +2 -36
  34. package/dist/index111.cjs +1 -1
  35. package/dist/index111.js +35 -46
  36. package/dist/index112.cjs +1 -1
  37. package/dist/index112.js +25 -62
  38. package/dist/index113.cjs +1 -7
  39. package/dist/index113.js +47 -10
  40. package/dist/index114.cjs +1 -0
  41. package/dist/index114.js +65 -0
  42. package/dist/index115.cjs +7 -0
  43. package/dist/index115.js +12 -0
  44. package/dist/index12.cjs +1 -1
  45. package/dist/index12.js +18 -21
  46. package/dist/index13.cjs +1 -1
  47. package/dist/index13.js +19 -41
  48. package/dist/index14.cjs +1 -1
  49. package/dist/index14.js +41 -23
  50. package/dist/index15.cjs +1 -1
  51. package/dist/index15.js +24 -36
  52. package/dist/index16.cjs +1 -1
  53. package/dist/index16.js +37 -33
  54. package/dist/index17.cjs +1 -1
  55. package/dist/index17.js +32 -49
  56. package/dist/index18.cjs +1 -1
  57. package/dist/index18.js +47 -38
  58. package/dist/index19.cjs +1 -1
  59. package/dist/index19.js +29 -29
  60. package/dist/index20.cjs +1 -1
  61. package/dist/index20.js +41 -58
  62. package/dist/index21.cjs +1 -1
  63. package/dist/index21.js +48 -42
  64. package/dist/index22.cjs +1 -1
  65. package/dist/index22.js +50 -44
  66. package/dist/index23.cjs +1 -1
  67. package/dist/index23.js +46 -7
  68. package/dist/index24.cjs +1 -1
  69. package/dist/index24.js +7 -11
  70. package/dist/index25.cjs +1 -1
  71. package/dist/index25.js +11 -64
  72. package/dist/index26.cjs +1 -1
  73. package/dist/index26.js +40 -39
  74. package/dist/index27.cjs +1 -1
  75. package/dist/index27.js +60 -37
  76. package/dist/index28.cjs +1 -1
  77. package/dist/index28.js +36 -53
  78. package/dist/index29.cjs +1 -1
  79. package/dist/index29.js +54 -51
  80. package/dist/index3.cjs +1 -1
  81. package/dist/index3.js +2 -2
  82. package/dist/index30.cjs +1 -1
  83. package/dist/index30.js +50 -81
  84. package/dist/index31.cjs +1 -1
  85. package/dist/index31.js +81 -35
  86. package/dist/index32.cjs +1 -1
  87. package/dist/index32.js +38 -33
  88. package/dist/index33.cjs +1 -1
  89. package/dist/index33.js +33 -10
  90. package/dist/index34.cjs +1 -1
  91. package/dist/index34.js +10 -39
  92. package/dist/index35.cjs +1 -1
  93. package/dist/index35.js +38 -102
  94. package/dist/index36.cjs +1 -1
  95. package/dist/index36.js +103 -19
  96. package/dist/index37.cjs +1 -1
  97. package/dist/index37.js +17 -134
  98. package/dist/index38.cjs +1 -1
  99. package/dist/index38.js +135 -49
  100. package/dist/index39.cjs +1 -1
  101. package/dist/index39.js +51 -32
  102. package/dist/index4.cjs +1 -1
  103. package/dist/index4.js +2 -2
  104. package/dist/index40.cjs +1 -1
  105. package/dist/index40.js +31 -53
  106. package/dist/index41.cjs +1 -1
  107. package/dist/index41.js +54 -48
  108. package/dist/index42.cjs +1 -1
  109. package/dist/index42.js +41 -81
  110. package/dist/index43.cjs +1 -1
  111. package/dist/index43.js +81 -41
  112. package/dist/index44.cjs +1 -1
  113. package/dist/index44.js +48 -5
  114. package/dist/index45.cjs +1 -1
  115. package/dist/index45.js +5 -45
  116. package/dist/index46.cjs +1 -1
  117. package/dist/index46.js +44 -41
  118. package/dist/index47.cjs +1 -1
  119. package/dist/index47.js +42 -19
  120. package/dist/index48.cjs +1 -1
  121. package/dist/index48.js +19 -8
  122. package/dist/index49.cjs +1 -1
  123. package/dist/index49.js +7 -22
  124. package/dist/index5.cjs +1 -1
  125. package/dist/index5.js +2 -2
  126. package/dist/index50.cjs +1 -1
  127. package/dist/index50.js +23 -2
  128. package/dist/index51.cjs +1 -1
  129. package/dist/index51.js +2 -4
  130. package/dist/index52.cjs +1 -1
  131. package/dist/index52.js +4 -11
  132. package/dist/index53.cjs +1 -1
  133. package/dist/index53.js +10 -12
  134. package/dist/index54.cjs +1 -1
  135. package/dist/index54.js +12 -11
  136. package/dist/index55.cjs +1 -1
  137. package/dist/index55.js +11 -184
  138. package/dist/index56.cjs +1 -1
  139. package/dist/index56.js +183 -25
  140. package/dist/index57.cjs +1 -1
  141. package/dist/index57.js +26 -24
  142. package/dist/index58.cjs +1 -1
  143. package/dist/index58.js +19 -22
  144. package/dist/index59.cjs +1 -1
  145. package/dist/index59.js +25 -97
  146. package/dist/index6.cjs +1 -1
  147. package/dist/index6.js +2 -2
  148. package/dist/index60.cjs +1 -1
  149. package/dist/index60.js +99 -8
  150. package/dist/index61.cjs +1 -1
  151. package/dist/index61.js +8 -51
  152. package/dist/index62.cjs +1 -1
  153. package/dist/index62.js +50 -60
  154. package/dist/index63.cjs +1 -1
  155. package/dist/index63.js +57 -18
  156. package/dist/index64.cjs +1 -1
  157. package/dist/index64.js +22 -18
  158. package/dist/index65.cjs +1 -1
  159. package/dist/index65.js +16 -26
  160. package/dist/index66.cjs +1 -1
  161. package/dist/index66.js +27 -56
  162. package/dist/index67.cjs +1 -1
  163. package/dist/index67.js +57 -341
  164. package/dist/index68.cjs +1 -1
  165. package/dist/index68.js +337 -55
  166. package/dist/index69.cjs +1 -1
  167. package/dist/index69.js +50 -47
  168. package/dist/index7.cjs +1 -1
  169. package/dist/index7.js +4 -4
  170. package/dist/index70.cjs +1 -1
  171. package/dist/index70.js +51 -32
  172. package/dist/index71.cjs +1 -1
  173. package/dist/index71.js +30 -24
  174. package/dist/index72.cjs +1 -1
  175. package/dist/index72.js +26 -32
  176. package/dist/index73.cjs +1 -1
  177. package/dist/index73.js +37 -12
  178. package/dist/index74.cjs +1 -1
  179. package/dist/index74.js +13 -9
  180. package/dist/index75.cjs +1 -1
  181. package/dist/index75.js +9 -17
  182. package/dist/index76.cjs +1 -1
  183. package/dist/index76.js +14 -16
  184. package/dist/index77.cjs +1 -1
  185. package/dist/index77.js +18 -49
  186. package/dist/index78.cjs +1 -1
  187. package/dist/index78.js +50 -21
  188. package/dist/index79.cjs +1 -1
  189. package/dist/index79.js +21 -7
  190. package/dist/index80.cjs +1 -1
  191. package/dist/index80.js +7 -2
  192. package/dist/index81.cjs +1 -1
  193. package/dist/index81.js +2 -9
  194. package/dist/index82.cjs +1 -3
  195. package/dist/index82.js +8 -13
  196. package/dist/index83.cjs +3 -1
  197. package/dist/index83.js +13 -8
  198. package/dist/index84.cjs +1 -1
  199. package/dist/index84.js +9 -41
  200. package/dist/index85.cjs +1 -1
  201. package/dist/index85.js +4 -8
  202. package/dist/index86.cjs +1 -1
  203. package/dist/index86.js +39 -116
  204. package/dist/index87.cjs +1 -1
  205. package/dist/index87.js +9 -19
  206. package/dist/index88.cjs +1 -1
  207. package/dist/index88.js +118 -13
  208. package/dist/index89.cjs +1 -104
  209. package/dist/index89.js +17 -118
  210. package/dist/index90.cjs +1 -1
  211. package/dist/index90.js +13 -68
  212. package/dist/index91.cjs +104 -1
  213. package/dist/index91.js +119 -28
  214. package/dist/index92.cjs +1 -1
  215. package/dist/index92.js +68 -2
  216. package/dist/index93.cjs +1 -1
  217. package/dist/index93.js +27 -39
  218. package/dist/index94.cjs +1 -1
  219. package/dist/index94.js +2 -11
  220. package/dist/index95.cjs +1 -1
  221. package/dist/index95.js +37 -29
  222. package/dist/index96.cjs +1 -1
  223. package/dist/index96.js +11 -29
  224. package/dist/index97.cjs +1 -19
  225. package/dist/index97.js +24 -24
  226. package/dist/index98.cjs +1 -1
  227. package/dist/index98.js +1 -1
  228. package/dist/index99.cjs +1 -12
  229. package/dist/index99.js +33 -16
  230. package/package.json +1 -1
package/dist/index57.js CHANGED
@@ -1,27 +1,29 @@
1
- import { useMemo as i } from "react";
2
- import { getAsyncOptions as m } from "./index74.js";
3
- import { getFetcherFunction as p } from "./index75.js";
4
- import l from "swr/immutable";
5
- import { useStores as f } from "./index60.js";
6
- const a = ({ filterData: e }) => {
7
- var s;
8
- 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]) };
1
+ import { useViews as a } from "./index62.js";
2
+ import { useStores as f } from "./index61.js";
3
+ const d = () => {
4
+ const { viewsMap: r } = a(), {
5
+ Filters: { activeViewId: i, initFiltersFromView: o, updateUrl: s },
6
+ Views: { addDraftView: w, draftViewsMap: n }
7
+ } = f();
8
+ return { duplicateView: () => {
9
+ if (!i)
10
+ throw Error("Creating views from all is not supported...implement me");
11
+ if (r.has(i)) {
12
+ const e = r.get(i);
13
+ if (!e)
14
+ throw Error("Could not find view in viewsMap");
15
+ const t = w({ ...e });
16
+ o(t);
17
+ } else {
18
+ const e = n.get(i);
19
+ if (!e)
20
+ throw Error("Could not find view in draftViewsMap");
21
+ const t = w({ ...e });
22
+ o(t);
23
+ }
24
+ s();
25
+ } };
24
26
  };
25
27
  export {
26
- a as useFilterArrayLabel
28
+ d as useDuplicateActiveView
27
29
  };
package/dist/index58.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),l=require("./index74.cjs"),F=require("./index75.cjs"),f=require("swr/immutable"),h=require("./index60.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("./index75.cjs"),l=require("./index76.cjs"),a=require("swr/immutable"),F=require("./index61.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/index58.js CHANGED
@@ -1,30 +1,27 @@
1
- import { useMemo as p } from "react";
2
- import { getAsyncOptions as m } from "./index74.js";
3
- import { getFetcherFunction as f } from "./index75.js";
4
- import h from "swr/immutable";
5
- import { useStores as u } from "./index60.js";
6
- const b = ({ filterData: t }) => {
7
- var c;
1
+ import { useMemo as i } from "react";
2
+ import { getAsyncOptions as m } from "./index75.js";
3
+ import { getFetcherFunction as p } from "./index76.js";
4
+ import l from "swr/immutable";
5
+ import { useStores as f } from "./index61.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/index59.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react"),g=require("@internationalized/date"),V=require("./index68.cjs"),M=require("./index69.cjs"),I=require("./index61.cjs"),N=require("./index8.cjs"),v=require("./index60.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("./index75.cjs"),F=require("./index76.cjs"),f=require("swr/immutable"),h=require("./index61.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/index59.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 "./index68.js";
4
- import { RangeFilter as M } from "./index69.js";
5
- import { useViews as V } from "./index61.js";
6
- import { useBusinessLogic as N } from "./index8.js";
7
- import { useStores as v } from "./index60.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 "./index75.js";
3
+ import { getFetcherFunction as f } from "./index76.js";
4
+ import h from "swr/immutable";
5
+ import { useStores as u } from "./index61.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/index6.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("kitsu-core"),r=require("./index7.cjs"),i=require("./index52.cjs"),o=require("./index53.cjs"),a=async({attributes:e})=>{const t=await r.axios.post("/api/v2/custom_views",{data:{attributes:e,type:"custom_view"}},i.withCSRF(o.vndAPI));return s.deserialise(t.data)};exports.createCustomView=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("kitsu-core"),r=require("./index7.cjs"),i=require("./index53.cjs"),o=require("./index54.cjs"),a=async({attributes:e})=>{const t=await r.axios.post("/api/v2/custom_views",{data:{attributes:e,type:"custom_view"}},i.withCSRF(o.vndAPI));return s.deserialise(t.data)};exports.createCustomView=a;
package/dist/index6.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { deserialise as r } from "kitsu-core";
2
2
  import { axios as e } from "./index7.js";
3
- import { withCSRF as i } from "./index52.js";
4
- import { vndAPI as s } from "./index53.js";
3
+ import { withCSRF as i } from "./index53.js";
4
+ import { vndAPI as s } from "./index54.js";
5
5
  const n = async ({ attributes: t }) => {
6
6
  const o = await e.post("/api/v2/custom_views", { data: { attributes: t, type: "custom_view" } }, i(s));
7
7
  return r(o.data);
package/dist/index60.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 T=require("react"),g=require("@internationalized/date"),V=require("./index69.cjs"),M=require("./index70.cjs"),I=require("./index62.cjs"),N=require("./index8.cjs"),v=require("./index61.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;
package/dist/index60.js CHANGED
@@ -1,11 +1,102 @@
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 T } from "react";
2
+ import { parseDate as p } from "@internationalized/date";
3
+ import { NumberRangeFilter as I } from "./index69.js";
4
+ import { RangeFilter as M } from "./index70.js";
5
+ import { useViews as V } from "./index62.js";
6
+ import { useBusinessLogic as N } from "./index8.js";
7
+ import { useStores as v } from "./index61.js";
8
+ import { patchCustomView as C } from "./index5.js";
9
+ const x = () => {
10
+ 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
24
+ },
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
+ };
8
99
  };
9
100
  export {
10
- i as useStores
101
+ x as usePersistUnsavedChanges
11
102
  };
package/dist/index61.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("swr"),c=require("react"),x=require("./index78.cjs"),E=require("./index77.cjs"),O=require("./index64.cjs"),S=require("./index48.cjs"),y=require("./index8.cjs"),C=require("./index54.cjs"),I=e=>e&&e.__esModule?e:{default:e},b=I(v),i=x.createAllView(),P=()=>{const{DEFAULT_PAGE_NUMBER:e,DEFAULT_PAGE_SIZE:m,VIEW_TYPE:w}=y.useBusinessLogic(),{canUpdateCustomViews:V,orderedListOfCustomViews:u,defaultCustomViewId:p,isLoading:_}=O.useCustomViews({type:w}),{data:n,isLoading:M,error:A,mutate:g}=b.default(`/api/v2/custom_views?filter[type]=${w}&page[number]=${e}&page[size]=${m}`,C.fetcherV2,S.SWR_HOOK_OPTIONS),f=c.useMemo(()=>({fixedViews:[i],customViews:[],viewsMap:new Map([[i.id,i]])}),[]),{viewsMap:L,customViews:o,fixedViews:l}=c.useMemo(()=>n?n.reduce((s,r)=>{const t=E.viewsAdapter({view:r,canUpdateCustomViews:V});return s.viewsMap.set(r.id,t),r.editable?s.customViews.push(t):s.fixedViews.push(t),s},{fixedViews:[i],customViews:[],viewsMap:new Map([[i.id,i]])}):f,[n,f,V]),q=c.useMemo(()=>o.sort((s,r)=>{const t=Array.isArray(u)?u:[],a=t.indexOf(s.id),d=t.indexOf(r.id);return a===-1&&d===-1?0:a===-1?1:d===-1?-1:a-d}),[o,u]);return{defaultCustomViewId:p,viewsArray:[...l,...o],fixedViews:l,customViews:o,sortedCustomViews:q,viewsMap:L,isLoading:M||_,error:A,mutate:g}};exports.useViews=P;
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/index61.js CHANGED
@@ -1,54 +1,11 @@
1
- import g from "swr";
2
- import { useMemo as d } from "react";
3
- import { createAllView as O } from "./index78.js";
4
- import { viewsAdapter as v } from "./index77.js";
5
- import { useCustomViews as C } from "./index64.js";
6
- import { SWR_HOOK_OPTIONS as I } from "./index48.js";
7
- import { useBusinessLogic as y } from "./index8.js";
8
- import { fetcherV2 as S } from "./index54.js";
9
- const s = O(), B = () => {
10
- const { DEFAULT_PAGE_NUMBER: V, DEFAULT_PAGE_SIZE: c, VIEW_TYPE: a } = y(), {
11
- canUpdateCustomViews: w,
12
- orderedListOfCustomViews: o,
13
- defaultCustomViewId: l,
14
- isLoading: x
15
- } = C({ type: a }), { data: n, isLoading: A, error: L, mutate: E } = g(
16
- `/api/v2/custom_views?filter[type]=${a}&page[number]=${V}&page[size]=${c}`,
17
- S,
18
- I
19
- ), f = d(
20
- () => ({
21
- fixedViews: [s],
22
- customViews: [],
23
- viewsMap: /* @__PURE__ */ new Map([[s.id, s]])
24
- }),
25
- []
26
- ), { viewsMap: M, customViews: r, fixedViews: p } = d(() => n ? n.reduce(
27
- (e, t) => {
28
- const i = v({ view: t, canUpdateCustomViews: w });
29
- return e.viewsMap.set(t.id, i), t.editable ? e.customViews.push(i) : e.fixedViews.push(i), e;
30
- },
31
- {
32
- fixedViews: [s],
33
- customViews: [],
34
- viewsMap: /* @__PURE__ */ new Map([[s.id, s]])
35
- }
36
- ) : f, [n, f, w]), _ = d(() => r.sort((e, t) => {
37
- const i = Array.isArray(o) ? o : [], u = i.indexOf(e.id), m = i.indexOf(t.id);
38
- return u === -1 && m === -1 ? 0 : u === -1 ? 1 : m === -1 ? -1 : u - m;
39
- }), [r, o]);
40
- return {
41
- defaultCustomViewId: l,
42
- viewsArray: [...p, ...r],
43
- fixedViews: p,
44
- customViews: r,
45
- sortedCustomViews: _,
46
- viewsMap: M,
47
- isLoading: A || x,
48
- error: L,
49
- mutate: E
50
- };
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;
51
8
  };
52
9
  export {
53
- B as useViews
10
+ i as useStores
54
11
  };
package/dist/index62.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),h=require("./index78.cjs"),E=require("./index64.cjs"),I=require("./index61.cjs"),C=require("./index8.cjs"),S=require("./index60.cjs"),F=()=>{const{VIEW_TYPE:m,SEARCH_FILTER_ID:c}=C.useBusinessLogic(),{Filters:{activeViewId:d,initFiltersFromView:e,initFromUrl:t,discardChanges:u,updateUrl:L,setFilter:f}}=S.useStores(),{isLoading:v}=E.useCustomViews({type:m}),{viewsMap:s,defaultCustomViewId:w,isLoading:p}=I.useViews(),g=p||v;V.useEffect(()=>{if(g)return;const i=new URLSearchParams(window.location.search),l=i.get("view"),o=i.get(c),n=i.size>0;if(!d){if(l){const r=s.get(l);if(r)e(r),n&&t();else{const a=s.get(w);a&&(e(a),n&&t(!1))}}else{const r=s.get(w);if(r)e(r),u(!0),n&&t();else{const a=s.get(h.ALL_VIEW_ID);a&&e(a)}}o&&f(c,o)}},[c,d,w,u,e,t,g,f,L,s]),V.useEffect(()=>{const i=()=>{const o=new URLSearchParams(window.location.search).get("view");if(!o)return;const n=s.get(o);n&&(e(n),t())};return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[u,e,t,s])};exports.useViewUrlChange=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("swr"),c=require("react"),x=require("./index79.cjs"),E=require("./index78.cjs"),O=require("./index65.cjs"),S=require("./index49.cjs"),y=require("./index8.cjs"),C=require("./index55.cjs"),I=e=>e&&e.__esModule?e:{default:e},b=I(v),i=x.createAllView(),P=()=>{const{DEFAULT_PAGE_NUMBER:e,DEFAULT_PAGE_SIZE:m,VIEW_TYPE:w}=y.useBusinessLogic(),{canUpdateCustomViews:V,orderedListOfCustomViews:u,defaultCustomViewId:p,isLoading:_}=O.useCustomViews({type:w}),{data:n,isLoading:M,error:A,mutate:g}=b.default(`/api/v2/custom_views?filter[type]=${w}&page[number]=${e}&page[size]=${m}`,C.fetcherV2,S.SWR_HOOK_OPTIONS),f=c.useMemo(()=>({fixedViews:[i],customViews:[],viewsMap:new Map([[i.id,i]])}),[]),{viewsMap:L,customViews:o,fixedViews:l}=c.useMemo(()=>n?n.reduce((s,r)=>{const t=E.viewsAdapter({view:r,canUpdateCustomViews:V});return s.viewsMap.set(r.id,t),r.editable?s.customViews.push(t):s.fixedViews.push(t),s},{fixedViews:[i],customViews:[],viewsMap:new Map([[i.id,i]])}):f,[n,f,V]),q=c.useMemo(()=>o.sort((s,r)=>{const t=Array.isArray(u)?u:[],a=t.indexOf(s.id),d=t.indexOf(r.id);return a===-1&&d===-1?0:a===-1?1:d===-1?-1:a-d}),[o,u]);return{defaultCustomViewId:p,viewsArray:[...l,...o],fixedViews:l,customViews:o,sortedCustomViews:q,viewsMap:L,isLoading:M||_,error:A,mutate:g}};exports.useViews=P;
package/dist/index62.js CHANGED
@@ -1,64 +1,54 @@
1
- import { useEffect as u } from "react";
2
- import { ALL_VIEW_ID as h } from "./index78.js";
3
- import { useCustomViews as I } from "./index64.js";
4
- import { useViews as E } from "./index61.js";
5
- import { useBusinessLogic as F } from "./index8.js";
6
- import { useStores as C } from "./index60.js";
7
- const A = () => {
8
- const { VIEW_TYPE: g, SEARCH_FILTER_ID: c } = F(), {
9
- Filters: {
10
- activeViewId: d,
11
- initFiltersFromView: e,
12
- initFromUrl: i,
13
- discardChanges: w,
14
- updateUrl: L,
15
- setFilter: l
1
+ import g from "swr";
2
+ import { useMemo as d } from "react";
3
+ import { createAllView as O } from "./index79.js";
4
+ import { viewsAdapter as v } from "./index78.js";
5
+ import { useCustomViews as C } from "./index65.js";
6
+ import { SWR_HOOK_OPTIONS as I } from "./index49.js";
7
+ import { useBusinessLogic as y } from "./index8.js";
8
+ import { fetcherV2 as S } from "./index55.js";
9
+ const s = O(), B = () => {
10
+ const { DEFAULT_PAGE_NUMBER: V, DEFAULT_PAGE_SIZE: c, VIEW_TYPE: a } = y(), {
11
+ canUpdateCustomViews: w,
12
+ orderedListOfCustomViews: o,
13
+ defaultCustomViewId: l,
14
+ isLoading: x
15
+ } = C({ type: a }), { data: n, isLoading: A, error: L, mutate: E } = g(
16
+ `/api/v2/custom_views?filter[type]=${a}&page[number]=${V}&page[size]=${c}`,
17
+ S,
18
+ I
19
+ ), f = d(
20
+ () => ({
21
+ fixedViews: [s],
22
+ customViews: [],
23
+ viewsMap: /* @__PURE__ */ new Map([[s.id, s]])
24
+ }),
25
+ []
26
+ ), { viewsMap: M, customViews: r, fixedViews: p } = d(() => n ? n.reduce(
27
+ (e, t) => {
28
+ const i = v({ view: t, canUpdateCustomViews: w });
29
+ return e.viewsMap.set(t.id, i), t.editable ? e.customViews.push(i) : e.fixedViews.push(i), e;
30
+ },
31
+ {
32
+ fixedViews: [s],
33
+ customViews: [],
34
+ viewsMap: /* @__PURE__ */ new Map([[s.id, s]])
16
35
  }
17
- } = C(), { isLoading: v } = I({ type: g }), { viewsMap: t, defaultCustomViewId: f, isLoading: V } = E(), p = V || v;
18
- u(() => {
19
- if (p) return;
20
- const s = new URLSearchParams(window.location.search), m = s.get("view"), a = s.get(c), o = s.size > 0;
21
- if (!d) {
22
- if (m) {
23
- const r = t.get(m);
24
- if (r)
25
- e(r), o && i();
26
- else {
27
- const n = t.get(f);
28
- n && (e(n), o && i(!1));
29
- }
30
- } else {
31
- const r = t.get(f);
32
- if (r)
33
- e(r), w(!0), o && i();
34
- else {
35
- const n = t.get(h);
36
- n && e(n);
37
- }
38
- }
39
- a && l(c, a);
40
- }
41
- }, [
42
- c,
43
- d,
44
- f,
45
- w,
46
- e,
47
- i,
48
- p,
49
- l,
50
- L,
51
- t
52
- ]), u(() => {
53
- const s = () => {
54
- const a = new URLSearchParams(window.location.search).get("view");
55
- if (!a) return;
56
- const o = t.get(a);
57
- o && (e(o), i());
58
- };
59
- return window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
60
- }, [w, e, i, t]);
36
+ ) : f, [n, f, w]), _ = d(() => r.sort((e, t) => {
37
+ const i = Array.isArray(o) ? o : [], u = i.indexOf(e.id), m = i.indexOf(t.id);
38
+ return u === -1 && m === -1 ? 0 : u === -1 ? 1 : m === -1 ? -1 : u - m;
39
+ }), [r, o]);
40
+ return {
41
+ defaultCustomViewId: l,
42
+ viewsArray: [...p, ...r],
43
+ fixedViews: p,
44
+ customViews: r,
45
+ sortedCustomViews: _,
46
+ viewsMap: M,
47
+ isLoading: A || x,
48
+ error: L,
49
+ mutate: E
50
+ };
61
51
  };
62
52
  export {
63
- A as useViewUrlChange
53
+ B as useViews
64
54
  };
package/dist/index63.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),i=require("./index8.cjs"),a=require("./index60.cjs"),c=()=>{const{SEARCH_FILTER_ID:s}=i.useBusinessLogic(),{Filters:{initFromUrl:e,setFilter:r}}=a.useStores();o.useEffect(()=>{const n=new URLSearchParams(window.location.search).get(s);e(),n&&r(s,n)},[s,e,r]),o.useEffect(()=>{const t=()=>e();return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[e])};exports.useUrlChange=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),h=require("./index79.cjs"),E=require("./index65.cjs"),I=require("./index62.cjs"),C=require("./index8.cjs"),S=require("./index61.cjs"),F=()=>{const{VIEW_TYPE:m,SEARCH_FILTER_ID:c}=C.useBusinessLogic(),{Filters:{activeViewId:d,initFiltersFromView:e,initFromUrl:t,discardChanges:u,updateUrl:L,setFilter:f}}=S.useStores(),{isLoading:v}=E.useCustomViews({type:m}),{viewsMap:s,defaultCustomViewId:w,isLoading:p}=I.useViews(),g=p||v;V.useEffect(()=>{if(g)return;const i=new URLSearchParams(window.location.search),l=i.get("view"),o=i.get(c),n=i.size>0;if(!d){if(l){const r=s.get(l);if(r)e(r),n&&t();else{const a=s.get(w);a&&(e(a),n&&t(!1))}}else{const r=s.get(w);if(r)e(r),u(!0),n&&t();else{const a=s.get(h.ALL_VIEW_ID);a&&e(a)}}o&&f(c,o)}},[c,d,w,u,e,t,g,f,L,s]),V.useEffect(()=>{const i=()=>{const o=new URLSearchParams(window.location.search).get("view");if(!o)return;const n=s.get(o);n&&(e(n),t())};return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[u,e,t,s])};exports.useViewUrlChange=F;