@veeqo/transfigure 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BusinessLogic/mocks.d.ts +10 -0
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +88 -78
- package/dist/index100.cjs +1 -1
- package/dist/index100.js +29 -33
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +21 -29
- package/dist/index103.cjs +1 -19
- package/dist/index103.js +14 -23
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +24 -21
- package/dist/index105.cjs +1 -1
- package/dist/index105.js +7 -15
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +1 -1
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +2 -2
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +1 -1
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +2 -2
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +36 -35
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +11 -10
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +46 -44
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +194 -193
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +41 -29
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +1 -1
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +41 -5
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +9 -41
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +4 -8
- package/dist/index98.cjs +19 -1
- package/dist/index98.js +24 -7
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +36 -22
- package/dist/mobx/Filters/Filters.d.ts +1 -1
- package/dist/storybookHelpers/apiMocks/views/custom_views.d.ts +45 -4
- package/package.json +5 -2
package/dist/index36.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),c=require("react"),u=require("@veeqo/ui"),U=require("mobx-react"),z=require("./index65.cjs"),G=require("./index62.cjs"),J=require("./index40.cjs"),K=require("./index43.cjs"),Q=require("./index56.cjs"),X=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),c=require("react"),u=require("@veeqo/ui"),U=require("mobx-react"),z=require("./index65.cjs"),G=require("./index62.cjs"),J=require("./index40.cjs"),K=require("./index43.cjs"),Q=require("./index56.cjs"),X=require("./index99.cjs"),Z=require("./index8.cjs"),$=require("./index61.cjs"),b=require("./index100.cjs"),ee=U.observer(({view:e})=>{const{VIEW_TYPE:x,IS_VIEWS_READONLY:r,SEARCH_FILTER_ID:d}=Z.useBusinessLogic(),{Filters:{activeViewId:w,initFiltersFromView:f,discardChanges:m,initFromUrl:V,filters:L,setFilter:y},Views:{draftViewsMap:T},Notifications:{notify:E}}=$.useStores(),{viewsMap:h,defaultCustomViewId:F,isLoading:N}=G.useViews(),{isLoading:j}=z.useCustomViews({type:x}),{viewCounts:M,isLoadingViewCounts:R}=X.useViewCounts(),[s,k]=c.useState(null),A=o=>{const q=L.get(d);if(h.has(o)){const n=h.get(o);n&&(f(n),m(!0),V())}else{const n=T.get(o);n?(f(n),m(!0),V()):E({type:"error",text:"Failed to load view"})}q&&y(d,q)},a=(e==null?void 0:e.id)===w,t=e.originalView!==void 0,g=e.originalView===void 0,I=M,l=(e==null?void 0:e.label)||"",P=N||j,p=c.useRef(!1);!P&&!p.current&&a&&e.id===F&&s&&(p.current=!0,s&&w===e.id&&window.requestAnimationFrame(()=>{var o;(o=s.parentElement)==null||o.scrollBy({behavior:"smooth",left:s.offsetLeft})}));const D=c.useMemo(()=>t?"draft":e.editable?"saved":"fixed",[t,e.editable]),{actions:{create:{handleSaveDraft:_},menu:{toggleDropdown:v},delete:{closeDeleteConfirmation:B,handleDelete:O,handleDeleteDraftView:C}},state:{shouldShowDeleteConfirmation:H},actions:W,state:S}=Q.useDropdownManager(e),Y=c.useMemo(()=>{if(!r){if(g)return v;if(t)return C}},[C,t,g,v,r]);return i.jsxs(i.Fragment,{children:[i.jsx(u.ViewTab,{colourPalette:u.theme.colors.secondary.blue,className:"act-react-listing-custom-view",active:a,id:e==null?void 0:e.id,name:l,type:r?void 0:D,count:R?i.jsx(u.Loader,{type:"ThreeDots",width:12,height:12,color:a?"#fff":u.theme.colors.neutral.ink.dark}):I,onClick:A,subAction:Y,ariaContext:"orders",ref:k,"aria-controls":"options-dropdown","aria-expanded":S.shouldShowDropdown,"aria-haspopup":"dialog"},e==null?void 0:e.id),i.jsx(b.Confirmation,{shouldShow:H,viewName:l,onCancel:B,onDelete:O}),i.jsx(J.PillNotifications,{tabType:D,isActive:a,initialViewName:l,shouldShowCreateViewNotification:t,handleSaveDraft:_}),!r&&i.jsx(K.ViewDropdowns,{referenceElement:s,tab:e,...W,...S})]})});exports.ViewTab=ee;
|
package/dist/index36.js
CHANGED
|
@@ -7,10 +7,10 @@ import { useViews as Z } from "./index62.js";
|
|
|
7
7
|
import { PillNotifications as b } from "./index40.js";
|
|
8
8
|
import { ViewDropdowns as ee } from "./index43.js";
|
|
9
9
|
import { useDropdownManager as oe } from "./index56.js";
|
|
10
|
-
import { useViewCounts as ie } from "./
|
|
10
|
+
import { useViewCounts as ie } from "./index99.js";
|
|
11
11
|
import { useBusinessLogic as te } from "./index8.js";
|
|
12
12
|
import { useStores as re } from "./index61.js";
|
|
13
|
-
import { Confirmation as se } from "./
|
|
13
|
+
import { Confirmation as se } from "./index100.js";
|
|
14
14
|
const ve = Q(({ view: e }) => {
|
|
15
15
|
const { VIEW_TYPE: y, IS_VIEWS_READONLY: n, SEARCH_FILTER_ID: c } = te(), {
|
|
16
16
|
Filters: { activeViewId: d, initFiltersFromView: f, discardChanges: m, initFromUrl: u, filters: E, setFilter: F },
|
package/dist/index39.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index98.cjs"),g=require("./index52.cjs"),j=require("./index51.cjs"),M=({tab:i,onMakeDefault:l,onEdit:n,onDuplicate:s,onDelete:o,shouldShowDropdown:a,handleCloseDropdown:c})=>{const{openModal:r}=g.useModal(),d=()=>{r(j.ModalId.ORDERS_TABLE_MANAGEMENT),c()},m=i.label!=="Picking In Progress"&&i.editable,u=i.default!==!1&&i.editable,p=i.editable,b=i.editable;return a?e.jsxs(t.MenuItems,{children:[u&&e.jsx(t.Item,{onClick:l,className:"act-react-listing-custom-view-make-default-menu-item",children:"Make default view"}),b&&e.jsx(t.Item,{onClick:n,className:"act-react-listing-custom-view-edit-menu-item",role:"option",children:"Edit"}),e.jsx(t.Item,{onClick:s,className:"act-react-listing-custom-view-duplicate-menu-item",role:"option",children:"Duplicate"}),m&&e.jsx(t.Item,{onClick:o,className:"act-react-listing-custom-view-delete-menu-item",role:"option",children:"Delete"}),p&&e.jsxs(e.Fragment,{children:[e.jsx(t.Divider,{}),e.jsx(t.Item,{onClick:d,role:"option",children:"Table management"})]})]}):null};exports.OptionsDropdown=M;
|
package/dist/index39.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as t, jsx as i, Fragment as f } from "react/jsx-runtime";
|
|
2
|
-
import { MenuItems as M, Item as l, Divider as h } from "./
|
|
2
|
+
import { MenuItems as M, Item as l, Divider as h } from "./index98.js";
|
|
3
3
|
import { useModal as k } from "./index52.js";
|
|
4
4
|
import { ModalId as T } from "./index51.js";
|
|
5
5
|
const N = ({
|
package/dist/index40.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),P=require("mobx-react"),g=require("./index62.cjs"),o=require("framer-motion"),m=require("./index61.cjs"),v=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),P=require("mobx-react"),g=require("./index62.cjs"),o=require("framer-motion"),m=require("./index61.cjs"),v=require("./index101.cjs"),f=require("./index42.cjs"),h=P.observer(({tabType:s,isActive:r,shouldShowCreateViewNotification:a,handleSaveDraft:i})=>{var t;const{Filters:{hasUnsavedChanges:c,discardChanges:l,activeViewId:n}}=m.useStores(),{viewsMap:u}=g.useViews(),d=n&&((t=u.get(n))==null?void 0:t.label);return e.jsxs(e.Fragment,{children:[e.jsx(o.AnimatePresence,{children:s==="draft"&&r&&a&&e.jsx(v.DraftPill,{onClick:i})}),e.jsx(o.AnimatePresence,{children:c&&r&&s==="saved"&&e.jsx(f.UnsavedChangesPill,{viewName:d,onDiscard:()=>l(),onSaveDraft:i})})]})});exports.PillNotifications=h;
|
package/dist/index40.js
CHANGED
|
@@ -3,7 +3,7 @@ import { observer as h } from "mobx-react";
|
|
|
3
3
|
import { useViews as v } from "./index62.js";
|
|
4
4
|
import { AnimatePresence as n } from "framer-motion";
|
|
5
5
|
import { useStores as g } from "./index61.js";
|
|
6
|
-
import { DraftPill as w } from "./
|
|
6
|
+
import { DraftPill as w } from "./index101.js";
|
|
7
7
|
import { UnsavedChangesPill as C } from "./index42.js";
|
|
8
8
|
const U = h(
|
|
9
9
|
({
|
package/dist/index41.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("react"),m=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("react"),m=require("./index103.cjs"),g=require("./index65.cjs"),S=require("./index62.cjs"),b=require("./index4.cjs"),y=require("./index8.cjs"),V=require("./index61.cjs"),p=require("./index12.cjs"),q=()=>{const{VIEW_TYPE:u}=y.useBusinessLogic(),{sortedCustomViews:s,isLoading:a}=S.useViews(),{mutate:c}=g.useCustomViews({type:u}),[l,t]=n.useState(s);n.useEffect(()=>{t(s)},[s]);const{Notifications:{notify:w}}=V.useStores(),d=async o=>{t(o);const r=o.map(e=>e.id);try{await b.patchCurrentUser({user_setting_attributes:{custom_view_positions:{order:r}}}),await c(e=>({...e,settings:{...e.settings,custom_view_positions:{...e.settings.custom_view_positions,order:r}}}),{revalidate:!1})}catch{t(s),w({type:"error",text:"Failed to update order of views"})}};return a||!s.length?null:i.jsx(p.ErrorBoundary,{children:i.jsx(m.LegacySortableViews,{views:l,onChange:d,className:"act-sortable-views"})})};exports.SortableViews=q;
|
package/dist/index41.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useState as f, useEffect as l } from "react";
|
|
3
|
-
import { LegacySortableViews as w } from "./
|
|
3
|
+
import { LegacySortableViews as w } from "./index103.js";
|
|
4
4
|
import { useCustomViews as d } from "./index65.js";
|
|
5
5
|
import { useViews as g } from "./index62.js";
|
|
6
6
|
import { patchCurrentUser as _ } from "./index4.js";
|
package/dist/index47.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("./index86.cjs"),e=require("@veeqo/ui"),o=require("./index87.cjs"),d=require("./index61.cjs"),m=({isLoading:a,refetch:n,trackMetricClick:s,tooltipText:l="Refresh data",buttonProps:i={size:"sm",variant:"default"}})=>{const{hasChanges:r,acknowledgeButtonClick:u}=h.usePollData(),{Notifications:{notify:c}}=d.useStores(),f=async()=>{try{await n(),await u(),s==null||s()}catch{c({type:"error",text:"Failed to refresh data"})}};return t.jsxs(e.Tooltip,{className:o.default.refreshTooltip,text:l,children:[t.jsx(e.Button,{className:o.default.refreshButton,onClick:f,loading:a,disabled:a,iconSlot:t.jsx(e.RefreshIcon,{color:e.theme.colors.neutral.ink.base}),"aria-label":r?"refresh table with changes":"refresh table","aria-live":"polite",...i}),t.jsx(e.Indicator,{className:o.default.refreshIndicator,color:"red",size:"xs",style:{opacity:r?1:0}})]})};exports.RefreshButton=m;
|
package/dist/index47.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as m, jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { usePollData as c } from "./
|
|
2
|
+
import { usePollData as c } from "./index86.js";
|
|
3
3
|
import { Tooltip as d, Button as p, RefreshIcon as u, theme as y, Indicator as x } from "@veeqo/ui";
|
|
4
|
-
import t from "./
|
|
4
|
+
import t from "./index87.js";
|
|
5
5
|
import { useStores as b } from "./index61.js";
|
|
6
6
|
const j = ({
|
|
7
7
|
isLoading: s,
|
package/dist/index63.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),E=require("./index79.cjs"),I=require("./index65.cjs"),C=require("./index62.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),q=require("qs"),E=require("./index79.cjs"),I=require("./index65.cjs"),C=require("./index62.cjs"),D=require("./index8.cjs"),F=require("./index61.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;
|
package/dist/index63.js
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
import { useEffect as g } from "react";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import V from "qs";
|
|
3
|
+
import { ALL_VIEW_ID as E } from "./index79.js";
|
|
4
|
+
import { useCustomViews as F } from "./index65.js";
|
|
5
|
+
import { useViews as C } from "./index62.js";
|
|
6
|
+
import { useBusinessLogic as D } from "./index8.js";
|
|
7
|
+
import { useStores as P } from "./index61.js";
|
|
8
|
+
const R = () => {
|
|
9
|
+
const { VIEW_TYPE: v, SEARCH_FILTER_ID: c } = D(), {
|
|
9
10
|
Filters: {
|
|
10
|
-
activeViewId:
|
|
11
|
+
activeViewId: d,
|
|
11
12
|
initFiltersFromView: e,
|
|
12
13
|
initFromUrl: i,
|
|
13
|
-
discardChanges:
|
|
14
|
-
updateUrl:
|
|
14
|
+
discardChanges: w,
|
|
15
|
+
updateUrl: L,
|
|
15
16
|
setFilter: p
|
|
16
17
|
}
|
|
17
|
-
} =
|
|
18
|
+
} = P(), { isLoading: I } = F({ type: v }), { viewsMap: t, defaultCustomViewId: m, isLoading: h, viewsArray: r } = C(), l = h || I;
|
|
18
19
|
g(() => {
|
|
19
|
-
if (
|
|
20
|
-
const s =
|
|
21
|
-
if (!
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
e(
|
|
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();
|
|
26
27
|
else {
|
|
27
|
-
const
|
|
28
|
-
|
|
28
|
+
const f = t.get(m);
|
|
29
|
+
f && (e(f), o && i(!1));
|
|
29
30
|
}
|
|
30
31
|
} else {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
33
|
-
e(
|
|
32
|
+
const a = t.get(m);
|
|
33
|
+
if (a)
|
|
34
|
+
e(a), w(!0), o && i();
|
|
34
35
|
else {
|
|
35
|
-
const
|
|
36
|
-
|
|
36
|
+
const f = t.get(E);
|
|
37
|
+
f ? e(f) : r != null && r[0] && e(r[0]);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
n && p(
|
|
40
|
+
n && p(c, n);
|
|
40
41
|
}
|
|
41
42
|
}, [
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
c,
|
|
44
|
+
d,
|
|
44
45
|
m,
|
|
45
|
-
|
|
46
|
+
w,
|
|
46
47
|
e,
|
|
47
48
|
i,
|
|
48
|
-
|
|
49
|
+
l,
|
|
49
50
|
p,
|
|
50
|
-
|
|
51
|
+
L,
|
|
51
52
|
t,
|
|
52
|
-
|
|
53
|
+
r
|
|
53
54
|
]), g(() => {
|
|
54
55
|
const s = () => {
|
|
55
|
-
const n =
|
|
56
|
+
const n = V.parse(window.location.search, { ignoreQueryPrefix: !0 }).view;
|
|
56
57
|
if (!n) return;
|
|
57
58
|
const o = t.get(n);
|
|
58
59
|
o && (e(o), i());
|
|
59
60
|
};
|
|
60
61
|
return window.addEventListener("popstate", s), () => window.removeEventListener("popstate", s);
|
|
61
|
-
}, [
|
|
62
|
+
}, [w, e, i, t]);
|
|
62
63
|
};
|
|
63
64
|
export {
|
|
64
|
-
|
|
65
|
+
R as useViewUrlChange
|
|
65
66
|
};
|
package/dist/index64.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),i=require("qs"),u=require("./index8.cjs"),a=require("./index61.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/index64.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { useEffect as n } from "react";
|
|
2
|
+
import i from "qs";
|
|
2
3
|
import { useBusinessLogic as a } from "./index8.js";
|
|
3
|
-
import { useStores as
|
|
4
|
-
const
|
|
4
|
+
import { useStores as p } from "./index61.js";
|
|
5
|
+
const d = () => {
|
|
5
6
|
const { SEARCH_FILTER_ID: t } = a(), {
|
|
6
7
|
Filters: {
|
|
7
8
|
initFromUrl: e,
|
|
8
|
-
setFilter:
|
|
9
|
+
setFilter: o
|
|
9
10
|
}
|
|
10
|
-
} =
|
|
11
|
+
} = p();
|
|
11
12
|
n(() => {
|
|
12
|
-
const
|
|
13
|
-
e(),
|
|
13
|
+
const s = i.parse(window.location.search, { ignoreQueryPrefix: !0 })[t];
|
|
14
|
+
e(), s && o(t, s);
|
|
14
15
|
}, [
|
|
15
16
|
t,
|
|
16
17
|
e,
|
|
17
|
-
|
|
18
|
+
o
|
|
18
19
|
]), n(() => {
|
|
19
|
-
const
|
|
20
|
-
return window.addEventListener("popstate",
|
|
20
|
+
const r = () => e();
|
|
21
|
+
return window.addEventListener("popstate", r), () => window.removeEventListener("popstate", r);
|
|
21
22
|
}, [e]);
|
|
22
23
|
};
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
+
d as useUrlChange
|
|
25
26
|
};
|
package/dist/index67.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),c=require("./index2.cjs"),M=require("qs"),y=require("./index8.cjs"),_=require("./index61.cjs"),k=e=>e&&e.__esModule?e:{default:e},i=k(M),w=()=>{const{SORT_FILTER_ID:e,SORTING_MODE:a}=y.useBusinessLogic(),{Filters:{queryParamsObject:d},Table:{sortParam:o,sortState:t,setSortState:u}}=_.useStores(),g=n.useMemo(()=>{const r={...d};switch(a){case c.SortingMode.CORAL:t.columnId&&(r.sort_order=t.direction,r.sort=t.columnId);break;case c.SortingMode.MONOLITH:default:o&&(r[e]=o)}return i.default.stringify(r,{arrayFormat:"brackets"})},[d,o,a,e,t]),l=n.useCallback(()=>{const r=i.default.parse(window.location.search,{ignoreQueryPrefix:!0});switch(a){case c.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 c.SortingMode.MONOLITH:default:if(!o)break;if(r[e]===o)return;r[e]=o}const s=i.default.stringify(r,{arrayFormat:"brackets"});s&&window.history.replaceState({},"",`${window.location.pathname}?${s}`)},[a,e,o,t]),f=n.useCallback(()=>{const r=i.default.parse(window.location.search,{ignoreQueryPrefix:!0}),s=r[e],S=r.sort_order,m=r.sort;switch(a){case c.SortingMode.CORAL:S&&m&&u({columnId:m,direction:S});break;case c.SortingMode.MONOLITH:default:{if(!s)break;const b=s.startsWith("-"),I=b?"desc":"asc",O=b?s.slice(1):s;u({columnId:O,direction:I})}}},[a,e,u]);return n.useEffect(()=>{f()},[f]),n.useEffect(()=>{l()},[t,l]),{queryParams:g,updateCurrentUrlWithTableSort:l}};exports.useUrlParams=w;
|
package/dist/index67.js
CHANGED
|
@@ -1,60 +1,62 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { SortingMode as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useMemo as h, useCallback as b, useEffect as I } from "react";
|
|
2
|
+
import { SortingMode as c } from "./index2.js";
|
|
3
|
+
import i from "qs";
|
|
4
|
+
import { useBusinessLogic as k } from "./index8.js";
|
|
5
|
+
import { useStores as y } from "./index61.js";
|
|
6
|
+
const _ = () => {
|
|
7
|
+
const { SORT_FILTER_ID: o, SORTING_MODE: a } = k(), {
|
|
8
|
+
Filters: { queryParamsObject: l },
|
|
9
|
+
Table: { sortParam: e, sortState: t, setSortState: n }
|
|
10
|
+
} = y(), O = h(() => {
|
|
11
|
+
const r = { ...l };
|
|
12
|
+
switch (a) {
|
|
13
|
+
case c.CORAL:
|
|
14
|
+
t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
|
|
14
15
|
break;
|
|
15
|
-
case
|
|
16
|
+
case c.MONOLITH:
|
|
16
17
|
default:
|
|
17
|
-
|
|
18
|
+
e && (r[o] = e);
|
|
18
19
|
}
|
|
19
|
-
return
|
|
20
|
-
}, [
|
|
21
|
-
const
|
|
22
|
-
switch (
|
|
23
|
-
case
|
|
24
|
-
if (!
|
|
20
|
+
return i.stringify(r, { arrayFormat: "brackets" });
|
|
21
|
+
}, [l, e, a, o, t]), u = b(() => {
|
|
22
|
+
const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 });
|
|
23
|
+
switch (a) {
|
|
24
|
+
case c.CORAL:
|
|
25
|
+
if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
|
|
25
26
|
break;
|
|
26
|
-
|
|
27
|
+
r.sort_order = t.direction, r.sort = t.columnId;
|
|
27
28
|
break;
|
|
28
|
-
case
|
|
29
|
+
case c.MONOLITH:
|
|
29
30
|
default:
|
|
30
|
-
if (!
|
|
31
|
-
if (
|
|
32
|
-
|
|
31
|
+
if (!e) break;
|
|
32
|
+
if (r[o] === e) return;
|
|
33
|
+
r[o] = e;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const s = i.stringify(r, { arrayFormat: "brackets" });
|
|
36
|
+
s && window.history.replaceState({}, "", `${window.location.pathname}?${s}`);
|
|
37
|
+
}, [a, o, e, t]), d = b(() => {
|
|
38
|
+
const r = i.parse(window.location.search, { ignoreQueryPrefix: !0 }), s = r[o], m = r.sort_order, f = r.sort;
|
|
39
|
+
switch (a) {
|
|
40
|
+
case c.CORAL:
|
|
41
|
+
m && f && n({ columnId: f, direction: m });
|
|
40
42
|
break;
|
|
41
|
-
case
|
|
43
|
+
case c.MONOLITH:
|
|
42
44
|
default: {
|
|
43
|
-
if (!
|
|
44
|
-
const S =
|
|
45
|
-
n({ columnId:
|
|
45
|
+
if (!s) break;
|
|
46
|
+
const S = s.startsWith("-"), p = S ? "desc" : "asc", w = S ? s.slice(1) : s;
|
|
47
|
+
n({ columnId: w, direction: p });
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
|
-
}, [
|
|
50
|
+
}, [a, o, n]);
|
|
49
51
|
return I(() => {
|
|
50
|
-
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
queryParams:
|
|
55
|
-
updateCurrentUrlWithTableSort:
|
|
52
|
+
d();
|
|
53
|
+
}, [d]), I(() => {
|
|
54
|
+
u();
|
|
55
|
+
}, [t, u]), {
|
|
56
|
+
queryParams: O,
|
|
57
|
+
updateCurrentUrlWithTableSort: u
|
|
56
58
|
};
|
|
57
59
|
};
|
|
58
60
|
export {
|
|
59
|
-
|
|
61
|
+
_ as useUrlParams
|
|
60
62
|
};
|
package/dist/index68.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var O=Object.defineProperty;var V=(A,t,a)=>t in A?O(A,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):A[t]=a;var g=(A,t,a)=>V(A,typeof t!="symbol"?t+"":t,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("mobx"),L=require("@veeqo/ui"),I=require("@internationalized/date"),B=require("lodash/isEqual"),p=require("./index49.cjs"),P=require("./index2.cjs"),w=require("./index70.cjs"),N=require("./index69.cjs"),G=require("./index79.cjs"),q=require("./index77.cjs"),b=require("./index9.cjs"),z=A=>A&&A.__esModule?A:{default:A},C=z(B);class ${constructor(){g(this,"defaultPageSize");g(this,"pageSize");g(this,"currentPage");g(this,"defaultFilters");g(this,"defaultArrayFilters");g(this,"defaultDateRangeFilters");g(this,"defaultNumberRangeFilters");g(this,"filters");g(this,"arrayFilters");g(this,"dateRangeFilters");g(this,"numberRangeFilters");g(this,"activeViewId");g(this,"isFiltersDropdownVisible");g(this,"initDefaultFilterMaps",()=>{this.defaultFilters=new Map(this.filters),this.defaultArrayFilters=new Map(this.arrayFilters),this.defaultDateRangeFilters=new Map(this.dateRangeFilters),this.defaultNumberRangeFilters=new Map(this.numberRangeFilters)});g(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:a,SORTING_MODE:s}=b.BusinessLogicManager.getBusinessLogic(),e=new URLSearchParams(window.location.search),r=e.get(a),n=e.get("sort_order"),f=e.get("sort");let c="";switch(s){case P.SortingMode.CORAL:if(n&&f){const m=this.queryParamsObject;m.set("sort",f),m.set("sort_order",n),c=`${window.location.pathname}?${m.toString()}`}break;case P.SortingMode.MONOLITH:default:if(r){const m=this.queryParamsObject;m.set(a,r),c=`${window.location.pathname}?${m.toString()}`}}r||(c=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",c):window.history.replaceState({},"",c)}catch(a){console.log(a)}});g(this,"setCurrentPage",t=>{this.currentPage=t});g(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});g(this,"setFilter",(t,a)=>{this.filters.set(t,a),this.updateUrl()});g(this,"clearFilter",t=>{this.filters.set(t,""),this.updateUrl()});g(this,"setArrayFilter",(t,a)=>{this.arrayFilters.set(t,a),this.updateUrl()});g(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.updateUrl()});g(this,"setRangeFilter",({key:t,range:a,dates:s})=>{a.setFilterType(t),a.setDates(s.start,s.end),this.updateUrl()});g(this,"clearRangeFilter",t=>{const a=this.dateRangeFilters.get(t);a&&(a.clear(),this.updateUrl())});g(this,"setNumberRangeFilter",({numberRange:t,gte:a,lte:s})=>{t.setGte(a),t.setLte(s),this.updateUrl()});g(this,"clearNumberRangeFilter",t=>{const a=this.numberRangeFilters.get(t);a&&(a.clear(),this.updateUrl())});g(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:a}=b.BusinessLogicManager.getBusinessLogic();this.filters.forEach((s,e)=>{e!==a&&this.filters.set(e,"")}),this.arrayFilters.forEach((s,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(s=>s.clear()),this.numberRangeFilters.forEach(s=>s.clear()),t||this.updateUrl()});g(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:a}=b.BusinessLogicManager.getBusinessLogic(),s=a.get(t);s&&s.fields.forEach(e=>{this.arrayFilters.has(e.id)?this.clearArrayFilter(e.id):this.dateRangeFilters.has(e.id)?this.clearRangeFilter(e.id):this.numberRangeFilters.has(e.id)?this.clearNumberRangeFilter(e.id):this.clearFilter(e.id)})});g(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});g(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});g(this,"getFiltersForGroup",t=>{const{GROUP_MAP:a}=b.BusinessLogicManager.getBusinessLogic(),s=a.get(t);if(!s)return{};const e={};return s.fields.forEach(r=>{this.arrayFilters.has(r.id)?e[r.id]=this.arrayFilters.get(r.id):this.dateRangeFilters.has(r.id)?e[r.id]=this.dateRangeFilters.get(r.id):this.numberRangeFilters.has(r.id)?e[r.id]=this.numberRangeFilters.get(r.id):e[r.id]=this.filters.get(r.id)}),e});g(this,"initFiltersFromView",t=>{var s;const{PAGE_SIZE_OPTIONS:a}=b.BusinessLogicManager.getBusinessLogic();(s=t.page)!=null&&s.size&&a.includes(t.page.size)&&(this.defaultPageSize=t.page.size,this.pageSize=t.page.size),this.defaultFilters=new Map(t.filterMaps.filters),this.defaultArrayFilters=new Map(t.filterMaps.arrayFilters),this.defaultDateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const n=new w.RangeFilter(r.filterType);return r.gte&&r.lte&&n.setDates(r.gte,r.lte),[e,n]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const n=r.clone();return r.gte&&n.setGte(r.gte),r.lte&&n.setLte(r.lte),[e,n]})),this.filters=new Map(t.filterMaps.filters),this.arrayFilters=new Map(t.filterMaps.arrayFilters),this.dateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const n=new w.RangeFilter(r.filterType);return r.gte&&r.lte&&n.setDates(r.gte,r.lte),[e,n]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const n=r.clone();return r.gte&&n.setGte(r.gte),r.lte&&n.setLte(r.lte),[e,n]})),this.activeViewId=t.id});g(this,"initFromUrl",(t=!0)=>{const{GROUP_MAP:a,NUMBER_RANGE_FILTERS:s,DATE_RANGE_FILTERS:e,PAGE_SIZE_OPTIONS:r,PAGE_SIZE_FILTER_ID:n}=b.BusinessLogicManager.getBusinessLogic(),f=new URLSearchParams(window.location.search),c=Array.from(a.values()).flatMap(i=>i.fields),m=new Map,R=new Map,E=new Map,h=new Map,l=new Map;Array.from(f.entries()).forEach(([i,u])=>{(i.includes("[gte]")||i.includes("[lte]")||i.includes("[relative]"))&&l.set(i,u)}),Array.from(f.entries()).forEach(([i,u])=>{if(i==="view"&&t){this.activeViewId=u;return}if(i===n&&r.includes(Number(u))){this.pageSize=Number(u);return}let y=c.find(F=>F.id===i);const d=i.replace(/\[(gte|lte|relative)\]$/,"");if(y||(s.includes(d)?y=c.find(F=>F.id===d):e.includes(d)&&(y=c.find(F=>F.id===d))),!!y)switch(y.filterType){case p.FilterChoiceValue.CHECKBOX:if(u)if(R.has(i)){const M=R.get(i);M==null||M.push(u)}else R.set(i,[u]);break;case p.FilterChoiceValue.DATE_RANGE:let F;if(q.isValidDateRange(u))F=new w.RangeFilter(u);else{const M=l.get(`${d}[gte]`),D=l.get(`${d}[lte]`);if(M&&D)try{const U=I.parseDate(M),v=I.parseDate(D);F=new w.RangeFilter("CUSTOM"),F.setDates(U,v)}catch{F=new w.RangeFilter(L.DateRanges.TODAY)}else F=new w.RangeFilter(L.DateRanges.TODAY)}E.set(d,F);break;case p.FilterChoiceValue.NUMBER_RANGE:const S=new N.NumberRangeFilter({filterId:y.id}),T=l.get(`${d}[gte]`),_=l.get(`${d}[lte]`);T&&S.setGte(Number(T)),_&&S.setLte(Number(_)),h.set(d,S);break;case p.FilterChoiceValue.TEXT:case p.FilterChoiceValue.NUMBER:case p.FilterChoiceValue.RADIO:m.set(i,u);break}}),this.filters=m,this.arrayFilters=R,this.dateRangeFilters=E,this.numberRangeFilters=h,this.updateUrl()});g(this,"discardChanges",(t=!1)=>{this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:a}=b.BusinessLogicManager.getBusinessLogic(),s=new Map(this.defaultFilters);this.filters.has(a)&&s.set(a,this.filters.get(a)),this.filters=s,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((e,r)=>{const n=new w.RangeFilter(e.filterType);n.setDates(e.gte,e.lte),this.dateRangeFilters.set(r,n)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((e,r)=>{this.numberRangeFilters.set(r,e.clone())}),this.updateUrl(t)});const{GROUP_MAP:t}=b.BusinessLogicManager.getBusinessLogic(),a=Array.from(t.values()).flatMap(s=>s.fields);this.filters=new Map(a.filter(s=>s.filterType===p.FilterChoiceValue.TEXT||s.filterType===p.FilterChoiceValue.NUMBER||s.filterType===p.FilterChoiceValue.RADIO||s.filterType===p.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,""])),this.arrayFilters=new Map(a.filter(s=>s.filterType===p.FilterChoiceValue.CHECKBOX).map(s=>[s.id,[]])),this.dateRangeFilters=new Map(a.filter(s=>s.filterType===p.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,new w.RangeFilter])),this.numberRangeFilters=new Map(a.filter(s=>s.filterType===p.FilterChoiceValue.NUMBER_RANGE).map(s=>{const e=new N.NumberRangeFilter({filterId:s.id});return[s.id,e]})),this.defaultArrayFilters=new Map,this.defaultFilters=new Map,this.defaultDateRangeFilters=new Map,this.defaultNumberRangeFilters=new Map,this.currentPage=1,this.pageSize=10,this.defaultPageSize=10,this.initDefaultFilterMaps(),this.isFiltersDropdownVisible=!1,this.activeViewId=void 0,o.makeObservable(this,{defaultPageSize:o.observable,pageSize:o.observable,currentPage:o.observable,defaultFilters:o.observable,defaultArrayFilters:o.observable,defaultDateRangeFilters:o.observable,defaultNumberRangeFilters:o.observable,filters:o.observable,arrayFilters:o.observable,numberRangeFilters:o.observable,dateRangeFilters:o.observable,isFiltersDropdownVisible:o.observable,activeViewId:o.observable,setPageSize:o.action,setCurrentPage:o.action,toggleFiltersDropdownVisible:o.action,setActiveViewId:o.action,setFilter:o.action,setArrayFilter:o.action,setRangeFilter:o.action,setNumberRangeFilter:o.action,clearFilter:o.action,clearArrayFilter:o.action,clearRangeFilter:o.action,clearNumberRangeFilter:o.action,clearAllFilters:o.action,getFiltersForGroup:o.action,clearFiltersForGroup:o.action,initFromUrl:o.action,initFiltersFromView:o.action,initDefaultFilterMaps:o.action,discardChanges:o.action,updateUrl:o.action,hasActiveFilters:o.computed,activeFilterKeysList:o.computed,queryParamsObject:o.computed,queryParams:o.computed,hasUnsavedChanges:o.computed})}get hasActiveFilters(){const{GROUP_MAP:t}=b.BusinessLogicManager.getBusinessLogic(),a=Array.from(t.values()).flatMap(e=>e.fields),s=new Set(a.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:a}=b.BusinessLogicManager.getBusinessLogic(),s=Array.from(this.filters.entries()).filter(([c,m])=>m!==""&&!t.includes(c)&&!a.includes(c)).map(([c])=>c),e=Array.from(this.arrayFilters.entries()).filter(([,c])=>c.length>0).map(([c])=>c),r=Array.from(this.dateRangeFilters.entries()).filter(([,c])=>c.filterType!==void 0).map(([c])=>c),n=Array.from(this.numberRangeFilters.entries()).filter(([,c])=>c.isActive).map(([c])=>c);return[...new Set([...s,...e,...r,...n])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:a,PAGE_SIZE_FILTER_ID:s,PAGE_NUMBER_FILTER_ID:e}=b.BusinessLogicManager.getBusinessLogic(),r=new URLSearchParams;return Array.from(this.filters.entries()).filter(([n,f])=>f!==""&&!t.includes(n)&&!a.includes(n)).forEach(([n,f])=>{r.append(n,f)}),Array.from(this.arrayFilters.entries()).filter(([,n])=>n.length>0).forEach(([n,f])=>{f.forEach(c=>{r.append(n,c)})}),Array.from(this.dateRangeFilters.entries()).filter(([,n])=>n.filterType!==void 0).forEach(([n,f])=>{f.filterType==="CUSTOM"?(r.set(`${n}[gte]`,f.gte.toString()),r.set(`${n}[lte]`,f.lte.toString())):r.set(`${n}[relative]`,f.filterType)}),Array.from(this.numberRangeFilters.entries()).filter(([,n])=>n.isActive).forEach(([n,f])=>{f.gte!==void 0&&r.set(`${n}[gte]`,f.gte.toString()),f.isValidLte&&r.set(`${n}[lte]`,f.lte.toString())}),this.activeViewId&&r.set("view",this.activeViewId),r.set(s,this.pageSize.toString()),r.set(e,this.currentPage.toString()),r}get queryParams(){return this.queryParamsObject.toString()}get hasUnsavedChanges(){if(this.activeViewId===G.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize)return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:a}=b.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(h=>h.fields),e=new Set(s.map(h=>h.id));if(Array.from(this.filters.entries()).filter(([h])=>h!==a&&e.has(h)).some(([h,l])=>{const i=this.defaultFilters.get(h);return i===void 0&&l!==""||i!==void 0&&l!==i}))return!0;const n=Array.from(this.defaultArrayFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{const i=this.defaultArrayFilters.get(h)||[];return l.length>0||i.length>0?l.length!==i.length||!C.default(l,i):!1}),f=Array.from(this.arrayFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{const i=this.defaultArrayFilters.get(h)||[];return l.length>0||i.length>0?l.length!==i.length||!C.default(l,i):!1});if(n||f)return!0;const c=Array.from(this.numberRangeFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{const i=this.defaultNumberRangeFilters.get(h);return!l.isEqual(i)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{const i=this.numberRangeFilters.get(h);return!l.isEqual(i)})||c)return!0;const R=Array.from(this.defaultDateRangeFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{var u,y,d,F;const i=this.dateRangeFilters.get(h);return l!=null&&l.filterType&&!(i!=null&&i.filterType)||i!=null&&i.filterType&&!(l!=null&&l.filterType)||(i==null?void 0:i.filterType)!==(l==null?void 0:l.filterType)?!0:(i==null?void 0:i.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((u=l.gte)==null?void 0:u.toString())!==((y=i.gte)==null?void 0:y.toString())||((d=l.lte)==null?void 0:d.toString())!==((F=i.lte)==null?void 0:F.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([h])=>e.has(h)).some(([h,l])=>{var u,y,d,F;const i=this.defaultDateRangeFilters.get(h);return l!=null&&l.filterType&&!(i!=null&&i.filterType)||i!=null&&i.filterType&&!(l!=null&&l.filterType)||(i==null?void 0:i.filterType)!==(l==null?void 0:l.filterType)?!0:(i==null?void 0:i.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((u=l.gte)==null?void 0:u.toString())!==((y=i.gte)==null?void 0:y.toString())||((d=l.lte)==null?void 0:d.toString())!==((F=i.lte)==null?void 0:F.toString()):!1})||R}}exports.Filters=$;
|
|
1
|
+
"use strict";var L=Object.defineProperty;var I=(y,t,l)=>t in y?L(y,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):y[t]=l;var u=(y,t,l)=>I(y,typeof t!="symbol"?t+"":t,l);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("mobx"),N=require("@veeqo/ui"),_=require("@internationalized/date"),V=require("lodash/isEqual"),O=require("lodash/get"),U=require("lodash/set"),B=require("qs"),F=require("./index49.cjs"),P=require("./index2.cjs"),b=require("./index70.cjs"),v=require("./index69.cjs"),G=require("./index79.cjs"),C=require("./index77.cjs"),d=require("./index9.cjs"),T=y=>y&&y.__esModule?y:{default:y},D=T(V),q=T(O),M=T(U),R=T(B);class z{constructor(){u(this,"defaultPageSize");u(this,"pageSize");u(this,"currentPage");u(this,"defaultFilters");u(this,"defaultArrayFilters");u(this,"defaultDateRangeFilters");u(this,"defaultNumberRangeFilters");u(this,"filters");u(this,"arrayFilters");u(this,"dateRangeFilters");u(this,"numberRangeFilters");u(this,"activeViewId");u(this,"isFiltersDropdownVisible");u(this,"initDefaultFilterMaps",()=>{this.defaultFilters=new Map(this.filters),this.defaultArrayFilters=new Map(this.arrayFilters),this.defaultDateRangeFilters=new Map(this.dateRangeFilters),this.defaultNumberRangeFilters=new Map(this.numberRangeFilters)});u(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:l,SORTING_MODE:s}=d.BusinessLogicManager.getBusinessLogic(),e=R.default.parse(window.location.search,{ignoreQueryPrefix:!0}),r=e[l],g=e.sort_order,f=e.sort;let o="";switch(s){case P.SortingMode.CORAL:if(g&&f){const c={...this.queryParamsObject,sort:f,sort_order:g};o=`${window.location.pathname}?${R.default.stringify(c,{arrayFormat:"brackets"})}`}break;case P.SortingMode.MONOLITH:default:if(r){const c={...this.queryParamsObject,[l]:r};o=`${window.location.pathname}?${R.default.stringify(c,{arrayFormat:"brackets"})}`}}r||(o=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",o):window.history.replaceState({},"",o)}catch(l){console.log(l)}});u(this,"setCurrentPage",t=>{this.currentPage=t});u(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});u(this,"setFilter",(t,l)=>{this.filters.set(t,l),this.setCurrentPage(1),this.updateUrl()});u(this,"clearFilter",t=>{this.filters.set(t,""),this.setCurrentPage(1),this.updateUrl()});u(this,"setArrayFilter",(t,l)=>{this.arrayFilters.set(t,l),this.setCurrentPage(1),this.updateUrl()});u(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.setCurrentPage(1),this.updateUrl()});u(this,"setRangeFilter",({key:t,range:l,dates:s})=>{l.setFilterType(t),l.setDates(s.start,s.end),this.setCurrentPage(1),this.updateUrl()});u(this,"clearRangeFilter",t=>{const l=this.dateRangeFilters.get(t);l&&(l.clear(),this.setCurrentPage(1),this.updateUrl())});u(this,"setNumberRangeFilter",({numberRange:t,gte:l,lte:s})=>{t.setGte(l),t.setLte(s),this.setCurrentPage(1),this.updateUrl()});u(this,"clearNumberRangeFilter",t=>{const l=this.numberRangeFilters.get(t);l&&(l.clear(),this.setCurrentPage(1),this.updateUrl())});u(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic();this.filters.forEach((s,e)=>{e!==l&&this.filters.set(e,"")}),this.arrayFilters.forEach((s,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(s=>s.clear()),this.numberRangeFilters.forEach(s=>s.clear()),this.setCurrentPage(1),t||this.updateUrl()});u(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:l}=d.BusinessLogicManager.getBusinessLogic(),s=l.get(t);s&&s.fields.forEach(e=>{this.arrayFilters.has(e.id)?this.clearArrayFilter(e.id):this.dateRangeFilters.has(e.id)?this.clearRangeFilter(e.id):this.numberRangeFilters.has(e.id)?this.clearNumberRangeFilter(e.id):this.clearFilter(e.id)})});u(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});u(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});u(this,"getFiltersForGroup",t=>{const{GROUP_MAP:l}=d.BusinessLogicManager.getBusinessLogic(),s=l.get(t);if(!s)return{};const e={};return s.fields.forEach(r=>{this.arrayFilters.has(r.id)?e[r.id]=this.arrayFilters.get(r.id):this.dateRangeFilters.has(r.id)?e[r.id]=this.dateRangeFilters.get(r.id):this.numberRangeFilters.has(r.id)?e[r.id]=this.numberRangeFilters.get(r.id):e[r.id]=this.filters.get(r.id)}),e});u(this,"initFiltersFromView",t=>{var s;const{PAGE_SIZE_OPTIONS:l}=d.BusinessLogicManager.getBusinessLogic();(s=t.page)!=null&&s.size&&l.includes(t.page.size)&&(this.defaultPageSize=t.page.size,this.pageSize=t.page.size),this.setCurrentPage(1),this.defaultFilters=new Map(t.filterMaps.filters),this.defaultArrayFilters=new Map(t.filterMaps.arrayFilters),this.defaultDateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const g=new b.RangeFilter(r.filterType);return r.gte&&r.lte&&g.setDates(r.gte,r.lte),[e,g]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const g=r.clone();return r.gte&&g.setGte(r.gte),r.lte&&g.setLte(r.lte),[e,g]})),this.filters=new Map(t.filterMaps.filters),this.arrayFilters=new Map(t.filterMaps.arrayFilters),this.dateRangeFilters=new Map(Array.from(t.filterMaps.rangeFilters.entries()).map(([e,r])=>{const g=new b.RangeFilter(r.filterType);return r.gte&&r.lte&&g.setDates(r.gte,r.lte),[e,g]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([e,r])=>{const g=r.clone();return r.gte&&g.setGte(r.gte),r.lte&&g.setLte(r.lte),[e,g]})),this.activeViewId=t.id});u(this,"initFromUrl",(t=!0)=>{const{GROUP_MAP:l,PAGE_SIZE_OPTIONS:s,PAGE_SIZE_FILTER_ID:e}=d.BusinessLogicManager.getBusinessLogic(),r=R.default.parse(window.location.search,{ignoreQueryPrefix:!0}),g=Array.from(l.values()).flatMap(n=>n.fields),f=new Map,o=new Map,c=new Map,E=new Map;t&&r.view&&(this.activeViewId=r.view),r[e]&&s.includes(Number(r[e]))&&(this.pageSize=Number(r[e]));const S=r.filter||{};g.forEach(n=>{const i=q.default(S,n.id);if(i!==void 0)switch(n.filterType){case F.FilterChoiceValue.CHECKBOX:Array.isArray(i)?o.set(n.id,i):i&&o.set(n.id,[i]);break;case F.FilterChoiceValue.DATE_RANGE:if(typeof i=="string"&&C.isValidDateRange(i))c.set(n.id,new b.RangeFilter(i));else if(typeof i=="object"&&i!==null){const a=i;if(a.relative&&C.isValidDateRange(a.relative))c.set(n.id,new b.RangeFilter(a.relative));else if(a.gte&&a.lte)try{const p=_.parseDate(a.gte),w=_.parseDate(a.lte),m=new b.RangeFilter("CUSTOM");m.setDates(p,w),c.set(n.id,m)}catch{c.set(n.id,new b.RangeFilter(N.DateRanges.TODAY))}}break;case F.FilterChoiceValue.NUMBER_RANGE:if(typeof i=="object"&&i!==null){const a=i,p=new v.NumberRangeFilter({filterId:n.id});a.gte!==void 0&&p.setGte(Number(a.gte)),a.lte!==void 0&&p.setLte(Number(a.lte)),E.set(n.id,p)}break;case F.FilterChoiceValue.TEXT:case F.FilterChoiceValue.NUMBER:case F.FilterChoiceValue.RADIO:(typeof i=="string"||typeof i=="number")&&f.set(n.id,String(i));break}}),this.filters=f,this.arrayFilters=o,this.dateRangeFilters=c,this.numberRangeFilters=E,this.updateUrl()});u(this,"discardChanges",(t=!1)=>{this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic(),s=new Map(this.defaultFilters);this.filters.has(l)&&s.set(l,this.filters.get(l)),this.filters=s,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((e,r)=>{const g=new b.RangeFilter(e.filterType);g.setDates(e.gte,e.lte),this.dateRangeFilters.set(r,g)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((e,r)=>{this.numberRangeFilters.set(r,e.clone())}),this.updateUrl(t)});const{GROUP_MAP:t}=d.BusinessLogicManager.getBusinessLogic(),l=Array.from(t.values()).flatMap(s=>s.fields);this.filters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.TEXT||s.filterType===F.FilterChoiceValue.NUMBER||s.filterType===F.FilterChoiceValue.RADIO||s.filterType===F.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,""])),this.arrayFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.CHECKBOX).map(s=>[s.id,[]])),this.dateRangeFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.DATE_RANGE).map(s=>[s.id,new b.RangeFilter])),this.numberRangeFilters=new Map(l.filter(s=>s.filterType===F.FilterChoiceValue.NUMBER_RANGE).map(s=>{const e=new v.NumberRangeFilter({filterId:s.id});return[s.id,e]})),this.defaultArrayFilters=new Map,this.defaultFilters=new Map,this.defaultDateRangeFilters=new Map,this.defaultNumberRangeFilters=new Map,this.currentPage=1,this.pageSize=10,this.defaultPageSize=10,this.initDefaultFilterMaps(),this.isFiltersDropdownVisible=!1,this.activeViewId=void 0,h.makeObservable(this,{defaultPageSize:h.observable,pageSize:h.observable,currentPage:h.observable,defaultFilters:h.observable,defaultArrayFilters:h.observable,defaultDateRangeFilters:h.observable,defaultNumberRangeFilters:h.observable,filters:h.observable,arrayFilters:h.observable,numberRangeFilters:h.observable,dateRangeFilters:h.observable,isFiltersDropdownVisible:h.observable,activeViewId:h.observable,setPageSize:h.action,setCurrentPage:h.action,toggleFiltersDropdownVisible:h.action,setActiveViewId:h.action,setFilter:h.action,setArrayFilter:h.action,setRangeFilter:h.action,setNumberRangeFilter:h.action,clearFilter:h.action,clearArrayFilter:h.action,clearRangeFilter:h.action,clearNumberRangeFilter:h.action,clearAllFilters:h.action,getFiltersForGroup:h.action,clearFiltersForGroup:h.action,initFromUrl:h.action,initFiltersFromView:h.action,initDefaultFilterMaps:h.action,discardChanges:h.action,updateUrl:h.action,hasActiveFilters:h.computed,activeFilterKeysList:h.computed,queryParamsObject:h.computed,queryParams:h.computed,hasUnsavedChanges:h.computed})}get hasActiveFilters(){const{GROUP_MAP:t}=d.BusinessLogicManager.getBusinessLogic(),l=Array.from(t.values()).flatMap(e=>e.fields),s=new Set(l.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>s.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:l}=d.BusinessLogicManager.getBusinessLogic(),s=Array.from(this.filters.entries()).filter(([o,c])=>c!==""&&!t.includes(o)&&!l.includes(o)).map(([o])=>o),e=Array.from(this.arrayFilters.entries()).filter(([,o])=>o.length>0).map(([o])=>o),r=Array.from(this.dateRangeFilters.entries()).filter(([,o])=>o.filterType!==void 0).map(([o])=>o),g=Array.from(this.numberRangeFilters.entries()).filter(([,o])=>o.isActive).map(([o])=>o);return[...new Set([...s,...e,...r,...g])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:l,PAGE_SIZE_FILTER_ID:s,PAGE_NUMBER_FILTER_ID:e}=d.BusinessLogicManager.getBusinessLogic(),r={};Array.from(this.filters.entries()).filter(([f,o])=>o!==""&&!t.includes(f)&&!l.includes(f)).forEach(([f,o])=>{M.default(r,f,o)}),Array.from(this.arrayFilters.entries()).filter(([,f])=>f.length>0).forEach(([f,o])=>{M.default(r,f,o)}),Array.from(this.dateRangeFilters.entries()).filter(([,f])=>f.filterType!==void 0).forEach(([f,o])=>{o.filterType==="CUSTOM"?M.default(r,f,{gte:o.gte.toString(),lte:o.lte.toString()}):M.default(r,f,{relative:o.filterType})}),Array.from(this.numberRangeFilters.entries()).filter(([,f])=>f.isActive).forEach(([f,o])=>{const c={};o.gte!==void 0&&(c.gte=o.gte),o.isValidLte&&(c.lte=o.lte),M.default(r,f,c)});const g={filter:r,[s]:String(this.pageSize),[e]:String(this.currentPage)};return this.activeViewId&&(g.view=this.activeViewId),g}get queryParams(){return R.default.stringify(this.queryParamsObject,{arrayFormat:"brackets"})}get hasUnsavedChanges(){if(this.activeViewId===G.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize)return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:l}=d.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(n=>n.fields),e=new Set(s.map(n=>n.id));if(Array.from(this.filters.entries()).filter(([n])=>n!==l&&e.has(n)).some(([n,i])=>{const a=this.defaultFilters.get(n);return a===void 0&&i!==""||a!==void 0&&i!==a}))return!0;const g=Array.from(this.defaultArrayFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultArrayFilters.get(n)||[];return i.length>0||a.length>0?i.length!==a.length||!D.default(i,a):!1}),f=Array.from(this.arrayFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultArrayFilters.get(n)||[];return i.length>0||a.length>0?i.length!==a.length||!D.default(i,a):!1});if(g||f)return!0;const o=Array.from(this.numberRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.defaultNumberRangeFilters.get(n);return!i.isEqual(a)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{const a=this.numberRangeFilters.get(n);return!i.isEqual(a)})||o)return!0;const E=Array.from(this.defaultDateRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{var p,w,m,A;const a=this.dateRangeFilters.get(n);return i!=null&&i.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(i!=null&&i.filterType)||(a==null?void 0:a.filterType)!==(i==null?void 0:i.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(i==null?void 0:i.filterType)==="CUSTOM"?((p=i.gte)==null?void 0:p.toString())!==((w=a.gte)==null?void 0:w.toString())||((m=i.lte)==null?void 0:m.toString())!==((A=a.lte)==null?void 0:A.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([n])=>e.has(n)).some(([n,i])=>{var p,w,m,A;const a=this.defaultDateRangeFilters.get(n);return i!=null&&i.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(i!=null&&i.filterType)||(a==null?void 0:a.filterType)!==(i==null?void 0:i.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(i==null?void 0:i.filterType)==="CUSTOM"?((p=i.gte)==null?void 0:p.toString())!==((w=a.gte)==null?void 0:w.toString())||((m=i.lte)==null?void 0:m.toString())!==((A=a.lte)==null?void 0:A.toString()):!1})||E}}exports.Filters=z;
|