@veeqo/transfigure 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/viewConstants.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCreateEmptyDraftView/index.d.ts +1 -0
- package/dist/hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.d.ts +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +72 -70
- package/dist/index100.cjs +1 -1
- package/dist/index100.js +48 -19
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +28 -17
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +15 -24
- package/dist/index103.cjs +11 -18
- package/dist/index103.js +12 -20
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +15 -14
- package/dist/index105.cjs +19 -1
- package/dist/index105.js +24 -7
- package/dist/index106.cjs +1 -12
- package/dist/index106.js +21 -16
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +23 -49
- package/dist/index108.cjs +1 -1
- package/dist/index108.js +12 -29
- package/dist/index109.cjs +1 -1
- package/dist/index109.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index110.cjs +1 -1
- package/dist/index110.js +8 -18
- package/dist/index111.cjs +1 -1
- package/dist/index111.js +2 -8
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +17 -59
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +7 -29
- package/dist/index114.cjs +1 -1
- package/dist/index114.js +61 -2
- package/dist/index115.cjs +1 -13
- package/dist/index115.js +30 -17
- package/dist/index116.cjs +13 -1
- package/dist/index116.js +15 -24
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +22 -32
- package/dist/index118.cjs +1 -1
- package/dist/index118.js +36 -5
- package/dist/index119.cjs +1 -1
- package/dist/index119.js +5 -63
- package/dist/index120.cjs +1 -7
- package/dist/index120.js +63 -10
- package/dist/index121.cjs +7 -1
- package/dist/index121.js +10 -47
- package/dist/index122.cjs +1 -0
- package/dist/index122.js +49 -0
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +3 -3
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +3 -3
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +2 -2
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +3 -3
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +2 -2
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +3 -3
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +3 -3
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +1 -1
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +2 -2
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +3 -3
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.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 +35 -35
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +10 -10
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +40 -37
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +3 -3
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +4 -4
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +1 -1
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +4 -4
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +3 -3
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +3 -3
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +33 -33
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +2 -2
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +10 -23
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +19 -22
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +26 -96
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +97 -8
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +8 -33
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +33 -63
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +59 -19
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +23 -18
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +16 -29
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +30 -60
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +61 -376
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +4 -4
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +372 -53
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +48 -47
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +51 -32
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +40 -24
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +26 -32
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +38 -4
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +4 -13
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +12 -16
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +14 -16
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +18 -65
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +67 -24
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +24 -21
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +19 -6
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +7 -2
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +2 -9
- package/dist/index85.cjs +1 -3
- package/dist/index85.js +8 -13
- package/dist/index86.cjs +3 -1
- package/dist/index86.js +13 -8
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +8 -4
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +39 -115
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +9 -41
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +116 -8
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +5 -13
- package/dist/index93.cjs +1 -104
- package/dist/index93.js +13 -119
- package/dist/index94.cjs +104 -1
- package/dist/index94.js +116 -65
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +63 -23
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +28 -2
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +2 -41
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +39 -9
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +10 -8
- package/dist/mobx/Views/Views.d.ts +1 -0
- package/dist/types.d.ts +4 -7
- package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.d.ts +6 -0
- package/dist/utils/createEmptyTransformedView/createEmptyTransformedView.test.d.ts +1 -0
- package/dist/utils/createEmptyTransformedView/index.d.ts +1 -0
- package/dist/utils/getViewTheme/getViewTheme.d.ts +10 -13
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/viewsAdapter/viewsAdapter.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/createAllView/createAllView.d.ts +0 -3
- package/dist/utils/createAllView/index.d.ts +0 -1
- /package/dist/{utils/createAllView/createAllView.test.d.ts → hooks/useCreateEmptyDraftView/useCreateEmptyDraftView.test.d.ts} +0 -0
package/dist/index69.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=Object.defineProperty;var B=(b,t,s)=>t in b?V(b,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):b[t]=s;var h=(b,t,s)=>B(b,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("mobx"),G=require("@veeqo/ui"),I=require("@internationalized/date"),q=require("lodash/isEqual"),z=require("lodash/get"),j=require("lodash/set"),K=require("qs"),m=require("./index50.cjs"),C=require("./index2.cjs"),A=require("./index71.cjs"),D=require("./index70.cjs"),L=require("./index99.cjs"),k=require("./index80.cjs"),N=require("./index78.cjs"),p=require("./index9.cjs"),_=b=>b&&b.__esModule?b:{default:b},O=_(q),H=_(z),E=_(j),T=_(K);class ${constructor(t){h(this,"defaultPageSize");h(this,"pageSize");h(this,"currentPage");h(this,"defaultFilters");h(this,"defaultArrayFilters");h(this,"defaultDateRangeFilters");h(this,"defaultNumberRangeFilters");h(this,"filters");h(this,"arrayFilters");h(this,"dateRangeFilters");h(this,"numberRangeFilters");h(this,"activeViewId");h(this,"defaultSortState");h(this,"tableStore");h(this,"isFiltersDropdownVisible");h(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),this.defaultSortState={columnId:"",direction:"asc"}});h(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:s,SORTING_MODE:n}=p.BusinessLogicManager.getBusinessLogic(),e=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),u=e[s],f=e.sort_order,i=e.sort;let r="";switch(n){case C.SortingMode.CORAL:if(f&&i){const d={...this.queryParamsObject,sort:i,sort_order:f};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}break;case C.SortingMode.MONOLITH:default:if(u){const d={...this.queryParamsObject,[s]:u};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}}u||(r=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",r):window.history.replaceState({},"",r)}catch(s){console.log(s)}});h(this,"setCurrentPage",t=>{this.currentPage=t});h(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});h(this,"setFilter",(t,s)=>{this.filters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearFilter",t=>{this.filters.set(t,""),this.setCurrentPage(1),this.updateUrl()});h(this,"setArrayFilter",(t,s)=>{this.arrayFilters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.setCurrentPage(1),this.updateUrl()});h(this,"setRangeFilter",({key:t,range:s,dates:n})=>{s.setFilterType(t),s.setDates(n.start,n.end),this.setCurrentPage(1),this.updateUrl()});h(this,"clearRangeFilter",t=>{const s=this.dateRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"setNumberRangeFilter",({numberRange:t,gte:s,lte:n})=>{t.setGte(s),t.setLte(n),this.setCurrentPage(1),this.updateUrl()});h(this,"clearNumberRangeFilter",t=>{const s=this.numberRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic();this.filters.forEach((n,e)=>{e!==s&&this.filters.set(e,"")}),this.arrayFilters.forEach((n,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(n=>n.clear()),this.numberRangeFilters.forEach(n=>n.clear()),this.setCurrentPage(1),t||this.updateUrl()});h(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);n&&n.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)})});h(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});h(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});h(this,"getFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);if(!n)return{};const e={};return n.fields.forEach(u=>{this.arrayFilters.has(u.id)?e[u.id]=this.arrayFilters.get(u.id):this.dateRangeFilters.has(u.id)?e[u.id]=this.dateRangeFilters.get(u.id):this.numberRangeFilters.has(u.id)?e[u.id]=this.numberRangeFilters.get(u.id):e[u.id]=this.filters.get(u.id)}),e});h(this,"initFiltersFromView",t=>{var e,u;const{PAGE_SIZE_OPTIONS:s}=p.BusinessLogicManager.getBusinessLogic();(e=t.page)!=null&&e.size&&s.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(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]})),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(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]}));const n=L.parseSortString(t.sort);this.defaultSortState=n,(u=this.tableStore)==null||u.setSortState(n),this.activeViewId=t.id});h(this,"initFromUrl",(t=!0)=>{var S,w;const{GROUP_MAP:s,PAGE_SIZE_OPTIONS:n,PAGE_SIZE_FILTER_ID:e,SORT_FILTER_ID:u}=p.BusinessLogicManager.getBusinessLogic(),f=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),i=Array.from(s.values()).flatMap(F=>F.fields),r=new Map,d=new Map,M=new Map,P=new Map;t&&f.view&&(this.activeViewId=f.view),f[e]&&n.includes(Number(f[e]))&&(this.pageSize=Number(f[e]));const c=f.filter||{};i.forEach(F=>{const g=H.default(c,F.id);if(g!==void 0)switch(F.filterType){case m.FilterChoiceValue.CHECKBOX:Array.isArray(g)?d.set(F.id,g):g&&d.set(F.id,[g]);break;case m.FilterChoiceValue.DATE_RANGE:if(typeof g=="string"&&N.isValidDateRange(g))M.set(F.id,new A.RangeFilter(g));else if(typeof g=="object"&&g!==null){const y=g;if(y.relative&&N.isValidDateRange(y.relative))M.set(F.id,new A.RangeFilter(y.relative));else if(y.gte&&y.lte)try{const R=I.parseDate(y.gte),U=I.parseDate(y.lte),v=new A.RangeFilter("CUSTOM");v.setDates(R,U),M.set(F.id,v)}catch{M.set(F.id,new A.RangeFilter(G.DateRanges.TODAY))}}break;case m.FilterChoiceValue.NUMBER_RANGE:if(typeof g=="object"&&g!==null){const y=g,R=new D.NumberRangeFilter({filterId:F.id});y.gte!==void 0&&R.setGte(Number(y.gte)),y.lte!==void 0&&R.setLte(Number(y.lte)),P.set(F.id,R)}break;case m.FilterChoiceValue.TEXT:case m.FilterChoiceValue.NUMBER:case m.FilterChoiceValue.RADIO:(typeof g=="string"||typeof g=="number")&&r.set(F.id,String(g));break}}),this.filters=r,this.arrayFilters=d,this.dateRangeFilters=M,this.numberRangeFilters=P;const l=f[u]||f.sort,a=f.sort_order;if(a&&f.sort)(S=this.tableStore)==null||S.setSortState({columnId:f.sort,direction:a});else if(l){const F=L.parseSortString(l);F.columnId&&((w=this.tableStore)==null||w.setSortState(F))}this.updateUrl()});h(this,"discardChanges",(t=!1)=>{var e;this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=new Map(this.defaultFilters);this.filters.has(s)&&n.set(s,this.filters.get(s)),this.filters=n,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((u,f)=>{const i=new A.RangeFilter(u.filterType);i.setDates(u.gte,u.lte),this.dateRangeFilters.set(f,i)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((u,f)=>{this.numberRangeFilters.set(f,u.clone())}),(e=this.tableStore)==null||e.setSortState(this.defaultSortState),this.updateUrl(t)});const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(s.values()).flatMap(e=>e.fields);this.filters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.TEXT||e.filterType===m.FilterChoiceValue.NUMBER||e.filterType===m.FilterChoiceValue.RADIO||e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,""])),this.arrayFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.CHECKBOX).map(e=>[e.id,[]])),this.dateRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,new A.RangeFilter])),this.numberRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.NUMBER_RANGE).map(e=>{const u=new D.NumberRangeFilter({filterId:e.id});return[e.id,u]})),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,this.defaultSortState={columnId:"",direction:"asc"},this.tableStore=t,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,defaultSortState:o.observable,tableStore:o.observable.ref,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}=p.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(e=>e.fields),n=new Set(s.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(this.filters.entries()).filter(([r,d])=>d!==""&&!t.includes(r)&&!s.includes(r)).map(([r])=>r),e=Array.from(this.arrayFilters.entries()).filter(([,r])=>r.length>0).map(([r])=>r),u=Array.from(this.dateRangeFilters.entries()).filter(([,r])=>r.filterType!==void 0).map(([r])=>r),f=Array.from(this.numberRangeFilters.entries()).filter(([,r])=>r.isActive).map(([r])=>r);return[...new Set([...n,...e,...u,...f])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s,PAGE_SIZE_FILTER_ID:n,PAGE_NUMBER_FILTER_ID:e}=p.BusinessLogicManager.getBusinessLogic(),u={};Array.from(this.filters.entries()).filter(([i,r])=>r!==""&&!t.includes(i)&&!s.includes(i)).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.arrayFilters.entries()).filter(([,i])=>i.length>0).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.dateRangeFilters.entries()).filter(([,i])=>i.filterType!==void 0).forEach(([i,r])=>{r.filterType==="CUSTOM"?E.default(u,i,{gte:r.gte.toString(),lte:r.lte.toString()}):E.default(u,i,{relative:r.filterType})}),Array.from(this.numberRangeFilters.entries()).filter(([,i])=>i.isActive).forEach(([i,r])=>{const d={};r.gte!==void 0&&(d.gte=r.gte),r.isValidLte&&(d.lte=r.lte),E.default(u,i,d)});const f={filter:u,[n]:String(this.pageSize),[e]:String(this.currentPage)};return this.activeViewId&&(f.view=this.activeViewId),f}get queryParams(){return T.default.stringify(this.queryParamsObject,{arrayFormat:"brackets"})}get hasUnsavedChanges(){if(this.activeViewId===k.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize||this.tableStore&&(this.tableStore.sortState.columnId!==this.defaultSortState.columnId||this.tableStore.sortState.direction!==this.defaultSortState.direction))return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(t.values()).flatMap(c=>c.fields),e=new Set(n.map(c=>c.id));if(Array.from(this.filters.entries()).filter(([c])=>c!==s&&e.has(c)).some(([c,l])=>{const a=this.defaultFilters.get(c);return a===void 0&&l!==""||a!==void 0&&l!==a}))return!0;const f=Array.from(this.defaultArrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1}),i=Array.from(this.arrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1});if(f||i)return!0;const r=Array.from(this.numberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultNumberRangeFilters.get(c);return!l.isEqual(a)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.numberRangeFilters.get(c);return!l.isEqual(a)})||r)return!0;const M=Array.from(this.defaultDateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.dateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.defaultDateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1})||M}}exports.Filters=$;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),a=require("./index2.cjs"),w=require("./index110.cjs"),M=require("qs"),y=require("./index8.cjs"),_=require("./index63.cjs"),k=e=>e&&e.__esModule?e:{default:e},n=k(M),p=()=>{const{SORT_FILTER_ID:e,SORTING_MODE:s}=y.useBusinessLogic(),{Filters:{queryParamsObject:d,activeViewId:g},Table:{sortParam:o,sortState:t,setSortState:u}}=_.useStores(),I=!!g,O=c.useMemo(()=>{const r={...d};switch(s){case a.SortingMode.CORAL:t.columnId&&(r.sort_order=t.direction,r.sort=t.columnId);break;case a.SortingMode.MONOLITH:default:o&&(r[e]=o)}return n.default.stringify(r,{arrayFormat:"brackets"})},[d,o,s,e,t]),l=c.useCallback(()=>{const r=n.default.parse(window.location.search,{ignoreQueryPrefix:!0});switch(s){case a.SortingMode.CORAL:if(!t.columnId||r.sort_order===t.direction&&r.sort===t.columnId)break;r.sort_order=t.direction,r.sort=t.columnId;break;case a.SortingMode.MONOLITH:default:if(!o)break;if(r[e]===o)return;r[e]=o}const i=n.default.stringify(r,{arrayFormat:"brackets"});i&&window.history.replaceState({},"",`${window.location.pathname}?${i}`)},[s,e,o,t]),f=c.useCallback(()=>{const r=n.default.parse(window.location.search,{ignoreQueryPrefix:!0}),i=r[e],S=r.sort_order,m=r.sort;switch(s){case a.SortingMode.CORAL:S&&m&&u({columnId:m,direction:S});break;case a.SortingMode.MONOLITH:default:{if(!i)break;const b=w.parseSortString(i);b.columnId&&u(b)}}},[s,e,u]);return c.useEffect(()=>{f()},[f]),c.useEffect(()=>{l()},[t,l]),{queryParams:O,hasActiveView:I,updateCurrentUrlWithTableSort:l}};exports.useUrlParams=p;
|
package/dist/index69.js
CHANGED
|
@@ -1,379 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
h(this, "isFiltersDropdownVisible");
|
|
50
|
-
h(this, "initDefaultFilterMaps", () => {
|
|
51
|
-
this.defaultFilters = new Map(this.filters), this.defaultArrayFilters = new Map(this.arrayFilters), this.defaultDateRangeFilters = new Map(this.dateRangeFilters), this.defaultNumberRangeFilters = new Map(this.numberRangeFilters), this.defaultSortState = { columnId: "", direction: "asc" };
|
|
52
|
-
});
|
|
53
|
-
h(this, "updateUrl", (t = !1) => {
|
|
54
|
-
try {
|
|
55
|
-
const { SORT_FILTER_ID: s, SORTING_MODE: n } = S.getBusinessLogic(), e = I.parse(window.location.search, { ignoreQueryPrefix: !0 }), o = e[s], g = e.sort_order, i = e.sort;
|
|
56
|
-
let r = "";
|
|
57
|
-
switch (n) {
|
|
58
|
-
case C.CORAL:
|
|
59
|
-
if (g && i) {
|
|
60
|
-
const m = { ...this.queryParamsObject, sort: i, sort_order: g };
|
|
61
|
-
r = `${window.location.pathname}?${I.stringify(m, { arrayFormat: "brackets" })}`;
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
case C.MONOLITH:
|
|
65
|
-
default:
|
|
66
|
-
if (o) {
|
|
67
|
-
const m = { ...this.queryParamsObject, [s]: o };
|
|
68
|
-
r = `${window.location.pathname}?${I.stringify(m, { arrayFormat: "brackets" })}`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
o || (r = `${window.location.pathname}?${this.queryParams}`), t ? window.history.pushState({}, "", r) : window.history.replaceState({}, "", r);
|
|
72
|
-
} catch (s) {
|
|
73
|
-
console.log(s);
|
|
1
|
+
import { useMemo as h, useCallback as p, useEffect as I } from "react";
|
|
2
|
+
import { SortingMode as a } from "./index2.js";
|
|
3
|
+
import { parseSortString as k } from "./index110.js";
|
|
4
|
+
import c from "qs";
|
|
5
|
+
import { useBusinessLogic as y } from "./index8.js";
|
|
6
|
+
import { useStores as L } from "./index63.js";
|
|
7
|
+
const C = () => {
|
|
8
|
+
const { SORT_FILTER_ID: o, SORTING_MODE: s } = y(), {
|
|
9
|
+
Filters: { queryParamsObject: m, activeViewId: b },
|
|
10
|
+
Table: { sortParam: e, sortState: t, setSortState: n }
|
|
11
|
+
} = L(), w = !!b, O = h(() => {
|
|
12
|
+
const r = { ...m };
|
|
13
|
+
switch (s) {
|
|
14
|
+
case a.CORAL:
|
|
15
|
+
t.columnId && (r.sort_order = t.direction, r.sort = t.columnId);
|
|
16
|
+
break;
|
|
17
|
+
case a.MONOLITH:
|
|
18
|
+
default:
|
|
19
|
+
e && (r[o] = e);
|
|
20
|
+
}
|
|
21
|
+
return c.stringify(r, { arrayFormat: "brackets" });
|
|
22
|
+
}, [m, e, s, o, t]), u = p(() => {
|
|
23
|
+
const r = c.parse(window.location.search, { ignoreQueryPrefix: !0 });
|
|
24
|
+
switch (s) {
|
|
25
|
+
case a.CORAL:
|
|
26
|
+
if (!t.columnId || r.sort_order === t.direction && r.sort === t.columnId)
|
|
27
|
+
break;
|
|
28
|
+
r.sort_order = t.direction, r.sort = t.columnId;
|
|
29
|
+
break;
|
|
30
|
+
case a.MONOLITH:
|
|
31
|
+
default:
|
|
32
|
+
if (!e) break;
|
|
33
|
+
if (r[o] === e) return;
|
|
34
|
+
r[o] = e;
|
|
35
|
+
}
|
|
36
|
+
const i = c.stringify(r, { arrayFormat: "brackets" });
|
|
37
|
+
i && window.history.replaceState({}, "", `${window.location.pathname}?${i}`);
|
|
38
|
+
}, [s, o, e, t]), d = p(() => {
|
|
39
|
+
const r = c.parse(window.location.search, { ignoreQueryPrefix: !0 }), i = r[o], l = r.sort_order, f = r.sort;
|
|
40
|
+
switch (s) {
|
|
41
|
+
case a.CORAL:
|
|
42
|
+
l && f && n({ columnId: f, direction: l });
|
|
43
|
+
break;
|
|
44
|
+
case a.MONOLITH:
|
|
45
|
+
default: {
|
|
46
|
+
if (!i) break;
|
|
47
|
+
const S = k(i);
|
|
48
|
+
S.columnId && n(S);
|
|
74
49
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
h(this, "clearFilter", (t) => {
|
|
88
|
-
this.filters.set(t, ""), this.setCurrentPage(1), this.updateUrl();
|
|
89
|
-
});
|
|
90
|
-
// ARRAY FILTERS
|
|
91
|
-
h(this, "setArrayFilter", (t, s) => {
|
|
92
|
-
this.arrayFilters.set(t, s), this.setCurrentPage(1), this.updateUrl();
|
|
93
|
-
});
|
|
94
|
-
h(this, "clearArrayFilter", (t) => {
|
|
95
|
-
this.arrayFilters.set(t, []), this.setCurrentPage(1), this.updateUrl();
|
|
96
|
-
});
|
|
97
|
-
// RANGE FILTERS
|
|
98
|
-
h(this, "setRangeFilter", ({
|
|
99
|
-
key: t,
|
|
100
|
-
range: s,
|
|
101
|
-
dates: n
|
|
102
|
-
}) => {
|
|
103
|
-
s.setFilterType(t), s.setDates(n.start, n.end), this.setCurrentPage(1), this.updateUrl();
|
|
104
|
-
});
|
|
105
|
-
h(this, "clearRangeFilter", (t) => {
|
|
106
|
-
const s = this.dateRangeFilters.get(t);
|
|
107
|
-
s && (s.clear(), this.setCurrentPage(1), this.updateUrl());
|
|
108
|
-
});
|
|
109
|
-
// NUMBER RANGE FILTERS
|
|
110
|
-
h(this, "setNumberRangeFilter", ({
|
|
111
|
-
numberRange: t,
|
|
112
|
-
gte: s,
|
|
113
|
-
lte: n
|
|
114
|
-
}) => {
|
|
115
|
-
t.setGte(s), t.setLte(n), this.setCurrentPage(1), this.updateUrl();
|
|
116
|
-
});
|
|
117
|
-
h(this, "clearNumberRangeFilter", (t) => {
|
|
118
|
-
const s = this.numberRangeFilters.get(t);
|
|
119
|
-
s && (s.clear(), this.setCurrentPage(1), this.updateUrl());
|
|
120
|
-
});
|
|
121
|
-
// CLEARING ALL FILTERS
|
|
122
|
-
h(this, "clearAllFilters", (t = !1) => {
|
|
123
|
-
const { SEARCH_FILTER_ID: s } = S.getBusinessLogic();
|
|
124
|
-
this.filters.forEach((n, e) => {
|
|
125
|
-
e !== s && this.filters.set(e, "");
|
|
126
|
-
}), this.arrayFilters.forEach((n, e) => this.arrayFilters.set(e, [])), this.dateRangeFilters.forEach((n) => n.clear()), this.numberRangeFilters.forEach((n) => n.clear()), this.setCurrentPage(1), t || this.updateUrl();
|
|
127
|
-
});
|
|
128
|
-
h(this, "clearFiltersForGroup", (t) => {
|
|
129
|
-
const { GROUP_MAP: s } = S.getBusinessLogic(), n = s.get(t);
|
|
130
|
-
n && n.fields.forEach((e) => {
|
|
131
|
-
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);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
// VIEWS
|
|
135
|
-
h(this, "setActiveViewId", (t) => {
|
|
136
|
-
this.activeViewId = t, this.updateUrl();
|
|
137
|
-
});
|
|
138
|
-
// VISIBILITY
|
|
139
|
-
h(this, "toggleFiltersDropdownVisible", (t) => {
|
|
140
|
-
this.isFiltersDropdownVisible = t;
|
|
141
|
-
});
|
|
142
|
-
// FILTER GROUPS
|
|
143
|
-
h(this, "getFiltersForGroup", (t) => {
|
|
144
|
-
const { GROUP_MAP: s } = S.getBusinessLogic(), n = s.get(t);
|
|
145
|
-
if (!n) return {};
|
|
146
|
-
const e = {};
|
|
147
|
-
return n.fields.forEach((o) => {
|
|
148
|
-
this.arrayFilters.has(o.id) ? e[o.id] = this.arrayFilters.get(o.id) : this.dateRangeFilters.has(o.id) ? e[o.id] = this.dateRangeFilters.get(o.id) : this.numberRangeFilters.has(o.id) ? e[o.id] = this.numberRangeFilters.get(o.id) : e[o.id] = this.filters.get(o.id);
|
|
149
|
-
}), e;
|
|
150
|
-
});
|
|
151
|
-
h(this, "initFiltersFromView", (t) => {
|
|
152
|
-
var e, o;
|
|
153
|
-
const { PAGE_SIZE_OPTIONS: s } = S.getBusinessLogic();
|
|
154
|
-
(e = t.page) != null && e.size && s.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(
|
|
155
|
-
Array.from(t.filterMaps.rangeFilters.entries()).map(([g, i]) => {
|
|
156
|
-
const r = new b(i.filterType);
|
|
157
|
-
return i.gte && i.lte && r.setDates(i.gte, i.lte), [g, r];
|
|
158
|
-
})
|
|
159
|
-
), this.defaultNumberRangeFilters = new Map(
|
|
160
|
-
Array.from(t.filterMaps.numberRangeFilters.entries()).map(([g, i]) => {
|
|
161
|
-
const r = i.clone();
|
|
162
|
-
return i.gte && r.setGte(i.gte), i.lte && r.setLte(i.lte), [g, r];
|
|
163
|
-
})
|
|
164
|
-
), this.filters = new Map(t.filterMaps.filters), this.arrayFilters = new Map(t.filterMaps.arrayFilters), this.dateRangeFilters = new Map(
|
|
165
|
-
Array.from(t.filterMaps.rangeFilters.entries()).map(([g, i]) => {
|
|
166
|
-
const r = new b(i.filterType);
|
|
167
|
-
return i.gte && i.lte && r.setDates(i.gte, i.lte), [g, r];
|
|
168
|
-
})
|
|
169
|
-
), this.numberRangeFilters = new Map(
|
|
170
|
-
Array.from(t.filterMaps.numberRangeFilters.entries()).map(([g, i]) => {
|
|
171
|
-
const r = i.clone();
|
|
172
|
-
return i.gte && r.setGte(i.gte), i.lte && r.setLte(i.lte), [g, r];
|
|
173
|
-
})
|
|
174
|
-
);
|
|
175
|
-
const n = U(t.sort);
|
|
176
|
-
this.defaultSortState = n, (o = this.tableStore) == null || o.setSortState(n), this.activeViewId = t.id;
|
|
177
|
-
});
|
|
178
|
-
h(this, "initFromUrl", (t = !0) => {
|
|
179
|
-
var w, A;
|
|
180
|
-
const { GROUP_MAP: s, PAGE_SIZE_OPTIONS: n, PAGE_SIZE_FILTER_ID: e, SORT_FILTER_ID: o } = S.getBusinessLogic(), g = I.parse(window.location.search, {
|
|
181
|
-
ignoreQueryPrefix: !0
|
|
182
|
-
}), i = Array.from(s.values()).flatMap((u) => u.fields), r = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
|
|
183
|
-
t && g.view && (this.activeViewId = g.view), g[e] && n.includes(Number(g[e])) && (this.pageSize = Number(g[e]));
|
|
184
|
-
const f = g.filter || {};
|
|
185
|
-
i.forEach((u) => {
|
|
186
|
-
const F = j(f, u.id);
|
|
187
|
-
if (F !== void 0)
|
|
188
|
-
switch (u.filterType) {
|
|
189
|
-
case p.CHECKBOX:
|
|
190
|
-
Array.isArray(F) ? m.set(u.id, F) : F && m.set(u.id, [F]);
|
|
191
|
-
break;
|
|
192
|
-
case p.DATE_RANGE:
|
|
193
|
-
if (typeof F == "string" && L(F))
|
|
194
|
-
E.set(u.id, new b(F));
|
|
195
|
-
else if (typeof F == "object" && F !== null) {
|
|
196
|
-
const y = F;
|
|
197
|
-
if (y.relative && L(y.relative))
|
|
198
|
-
E.set(u.id, new b(y.relative));
|
|
199
|
-
else if (y.gte && y.lte)
|
|
200
|
-
try {
|
|
201
|
-
const T = v(y.gte), G = v(y.lte), D = new b("CUSTOM");
|
|
202
|
-
D.setDates(T, G), E.set(u.id, D);
|
|
203
|
-
} catch {
|
|
204
|
-
E.set(u.id, new b(q.TODAY));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
break;
|
|
208
|
-
case p.NUMBER_RANGE:
|
|
209
|
-
if (typeof F == "object" && F !== null) {
|
|
210
|
-
const y = F, T = new O({ filterId: u.id });
|
|
211
|
-
y.gte !== void 0 && T.setGte(Number(y.gte)), y.lte !== void 0 && T.setLte(Number(y.lte)), _.set(u.id, T);
|
|
212
|
-
}
|
|
213
|
-
break;
|
|
214
|
-
case p.TEXT:
|
|
215
|
-
case p.NUMBER:
|
|
216
|
-
case p.RADIO:
|
|
217
|
-
(typeof F == "string" || typeof F == "number") && r.set(u.id, String(F));
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
}), this.filters = r, this.arrayFilters = m, this.dateRangeFilters = E, this.numberRangeFilters = _;
|
|
221
|
-
const l = g[o] || g.sort, a = g.sort_order;
|
|
222
|
-
if (a && g.sort)
|
|
223
|
-
(w = this.tableStore) == null || w.setSortState({ columnId: g.sort, direction: a });
|
|
224
|
-
else if (l) {
|
|
225
|
-
const u = U(l);
|
|
226
|
-
u.columnId && ((A = this.tableStore) == null || A.setSortState(u));
|
|
227
|
-
}
|
|
228
|
-
this.updateUrl();
|
|
229
|
-
});
|
|
230
|
-
h(this, "discardChanges", (t = !1) => {
|
|
231
|
-
var e;
|
|
232
|
-
this.pageSize = this.defaultPageSize;
|
|
233
|
-
const { SEARCH_FILTER_ID: s } = S.getBusinessLogic(), n = new Map(this.defaultFilters);
|
|
234
|
-
this.filters.has(s) && n.set(s, this.filters.get(s)), this.filters = n, this.arrayFilters = new Map(this.defaultArrayFilters), this.dateRangeFilters.clear(), this.defaultDateRangeFilters.forEach((o, g) => {
|
|
235
|
-
const i = new b(o.filterType);
|
|
236
|
-
i.setDates(o.gte, o.lte), this.dateRangeFilters.set(g, i);
|
|
237
|
-
}), this.numberRangeFilters.clear(), this.defaultNumberRangeFilters.forEach((o, g) => {
|
|
238
|
-
this.numberRangeFilters.set(g, o.clone());
|
|
239
|
-
}), (e = this.tableStore) == null || e.setSortState(this.defaultSortState), this.updateUrl(t);
|
|
240
|
-
});
|
|
241
|
-
const { GROUP_MAP: s } = S.getBusinessLogic(), n = Array.from(s.values()).flatMap((e) => e.fields);
|
|
242
|
-
this.filters = new Map(
|
|
243
|
-
n.filter(
|
|
244
|
-
(e) => e.filterType === p.TEXT || e.filterType === p.NUMBER || e.filterType === p.RADIO || e.filterType === p.DATE_RANGE
|
|
245
|
-
).map((e) => [e.id, ""])
|
|
246
|
-
), this.arrayFilters = new Map(
|
|
247
|
-
n.filter((e) => e.filterType === p.CHECKBOX).map((e) => [e.id, []])
|
|
248
|
-
), this.dateRangeFilters = new Map(
|
|
249
|
-
n.filter((e) => e.filterType === p.DATE_RANGE).map((e) => [e.id, new b()])
|
|
250
|
-
), this.numberRangeFilters = new Map(
|
|
251
|
-
n.filter((e) => e.filterType === p.NUMBER_RANGE).map((e) => {
|
|
252
|
-
const o = new O({ filterId: e.id });
|
|
253
|
-
return [e.id, o];
|
|
254
|
-
})
|
|
255
|
-
), this.defaultArrayFilters = /* @__PURE__ */ new Map(), this.defaultFilters = /* @__PURE__ */ new Map(), this.defaultDateRangeFilters = /* @__PURE__ */ new Map(), this.defaultNumberRangeFilters = /* @__PURE__ */ new Map(), this.currentPage = 1, this.pageSize = 10, this.defaultPageSize = 10, this.initDefaultFilterMaps(), this.isFiltersDropdownVisible = !1, this.activeViewId = void 0, this.defaultSortState = { columnId: "", direction: "asc" }, this.tableStore = t, z(this, {
|
|
256
|
-
defaultPageSize: d,
|
|
257
|
-
pageSize: d,
|
|
258
|
-
currentPage: d,
|
|
259
|
-
defaultFilters: d,
|
|
260
|
-
defaultArrayFilters: d,
|
|
261
|
-
defaultDateRangeFilters: d,
|
|
262
|
-
defaultNumberRangeFilters: d,
|
|
263
|
-
filters: d,
|
|
264
|
-
arrayFilters: d,
|
|
265
|
-
numberRangeFilters: d,
|
|
266
|
-
dateRangeFilters: d,
|
|
267
|
-
isFiltersDropdownVisible: d,
|
|
268
|
-
activeViewId: d,
|
|
269
|
-
defaultSortState: d,
|
|
270
|
-
tableStore: d.ref,
|
|
271
|
-
setPageSize: c,
|
|
272
|
-
setCurrentPage: c,
|
|
273
|
-
toggleFiltersDropdownVisible: c,
|
|
274
|
-
setActiveViewId: c,
|
|
275
|
-
setFilter: c,
|
|
276
|
-
setArrayFilter: c,
|
|
277
|
-
setRangeFilter: c,
|
|
278
|
-
setNumberRangeFilter: c,
|
|
279
|
-
clearFilter: c,
|
|
280
|
-
clearArrayFilter: c,
|
|
281
|
-
clearRangeFilter: c,
|
|
282
|
-
clearNumberRangeFilter: c,
|
|
283
|
-
clearAllFilters: c,
|
|
284
|
-
getFiltersForGroup: c,
|
|
285
|
-
clearFiltersForGroup: c,
|
|
286
|
-
initFromUrl: c,
|
|
287
|
-
initFiltersFromView: c,
|
|
288
|
-
initDefaultFilterMaps: c,
|
|
289
|
-
discardChanges: c,
|
|
290
|
-
updateUrl: c,
|
|
291
|
-
hasActiveFilters: M,
|
|
292
|
-
activeFilterKeysList: M,
|
|
293
|
-
queryParamsObject: M,
|
|
294
|
-
queryParams: M,
|
|
295
|
-
hasUnsavedChanges: M
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
get hasActiveFilters() {
|
|
299
|
-
const { GROUP_MAP: t } = S.getBusinessLogic(), s = Array.from(t.values()).flatMap((e) => e.fields), n = new Set(s.map((e) => e.id));
|
|
300
|
-
return Array.from(this.filters.entries()).filter(([e]) => n.has(e)).some(([, e]) => e !== "") || Array.from(this.arrayFilters.entries()).filter(([e]) => n.has(e)).some(([, e]) => e.length > 0) || Array.from(this.dateRangeFilters.entries()).filter(([e]) => n.has(e)).some(([, e]) => e.filterType !== void 0) || Array.from(this.numberRangeFilters.entries()).filter(([e]) => n.has(e)).some(([, e]) => e.isActive);
|
|
301
|
-
}
|
|
302
|
-
get activeFilterKeysList() {
|
|
303
|
-
const { DATE_RANGE_FILTERS: t, NUMBER_RANGE_FILTERS: s } = S.getBusinessLogic(), n = Array.from(this.filters.entries()).filter(
|
|
304
|
-
([r, m]) => m !== "" && !t.includes(r) && !s.includes(r)
|
|
305
|
-
).map(([r]) => r), e = Array.from(this.arrayFilters.entries()).filter(([, r]) => r.length > 0).map(([r]) => r), o = Array.from(this.dateRangeFilters.entries()).filter(([, r]) => r.filterType !== void 0).map(([r]) => r), g = Array.from(this.numberRangeFilters.entries()).filter(([, r]) => r.isActive).map(([r]) => r);
|
|
306
|
-
return [.../* @__PURE__ */ new Set([...n, ...e, ...o, ...g])];
|
|
307
|
-
}
|
|
308
|
-
get queryParamsObject() {
|
|
309
|
-
const { DATE_RANGE_FILTERS: t, NUMBER_RANGE_FILTERS: s, PAGE_SIZE_FILTER_ID: n, PAGE_NUMBER_FILTER_ID: e } = S.getBusinessLogic(), o = {};
|
|
310
|
-
Array.from(this.filters.entries()).filter(
|
|
311
|
-
([i, r]) => r !== "" && !t.includes(i) && !s.includes(i)
|
|
312
|
-
).forEach(([i, r]) => {
|
|
313
|
-
P(o, i, r);
|
|
314
|
-
}), Array.from(this.arrayFilters.entries()).filter(([, i]) => i.length > 0).forEach(([i, r]) => {
|
|
315
|
-
P(o, i, r);
|
|
316
|
-
}), Array.from(this.dateRangeFilters.entries()).filter(([, i]) => i.filterType !== void 0).forEach(([i, r]) => {
|
|
317
|
-
r.filterType === "CUSTOM" ? P(o, i, {
|
|
318
|
-
gte: r.gte.toString(),
|
|
319
|
-
lte: r.lte.toString()
|
|
320
|
-
}) : P(o, i, { relative: r.filterType });
|
|
321
|
-
}), Array.from(this.numberRangeFilters.entries()).filter(([, i]) => i.isActive).forEach(([i, r]) => {
|
|
322
|
-
const m = {};
|
|
323
|
-
r.gte !== void 0 && (m.gte = r.gte), r.isValidLte && (m.lte = r.lte), P(o, i, m);
|
|
324
|
-
});
|
|
325
|
-
const g = {
|
|
326
|
-
filter: o,
|
|
327
|
-
[n]: String(this.pageSize),
|
|
328
|
-
[e]: String(this.currentPage)
|
|
329
|
-
};
|
|
330
|
-
return this.activeViewId && (g.view = this.activeViewId), g;
|
|
331
|
-
}
|
|
332
|
-
get queryParams() {
|
|
333
|
-
return I.stringify(this.queryParamsObject, {
|
|
334
|
-
arrayFormat: "brackets"
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
get hasUnsavedChanges() {
|
|
338
|
-
if (this.activeViewId === K) return !1;
|
|
339
|
-
if (this.defaultPageSize !== this.pageSize || this.tableStore && (this.tableStore.sortState.columnId !== this.defaultSortState.columnId || this.tableStore.sortState.direction !== this.defaultSortState.direction))
|
|
340
|
-
return !0;
|
|
341
|
-
const { GROUP_MAP: t, SEARCH_FILTER_ID: s } = S.getBusinessLogic(), n = Array.from(t.values()).flatMap((f) => f.fields), e = new Set(n.map((f) => f.id));
|
|
342
|
-
if (Array.from(this.filters.entries()).filter(([f]) => f !== s && e.has(f)).some(([f, l]) => {
|
|
343
|
-
const a = this.defaultFilters.get(f);
|
|
344
|
-
return a === void 0 && l !== "" || a !== void 0 && l !== a;
|
|
345
|
-
}))
|
|
346
|
-
return !0;
|
|
347
|
-
const g = Array.from(this.defaultArrayFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
348
|
-
const a = this.defaultArrayFilters.get(f) || [];
|
|
349
|
-
return l.length > 0 || a.length > 0 ? l.length !== a.length || !N(l, a) : !1;
|
|
350
|
-
}), i = Array.from(this.arrayFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
351
|
-
const a = this.defaultArrayFilters.get(f) || [];
|
|
352
|
-
return l.length > 0 || a.length > 0 ? l.length !== a.length || !N(l, a) : !1;
|
|
353
|
-
});
|
|
354
|
-
if (g || i)
|
|
355
|
-
return !0;
|
|
356
|
-
const r = Array.from(this.numberRangeFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
357
|
-
const a = this.defaultNumberRangeFilters.get(f);
|
|
358
|
-
return !l.isEqual(a);
|
|
359
|
-
});
|
|
360
|
-
if (Array.from(this.defaultNumberRangeFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
361
|
-
const a = this.numberRangeFilters.get(f);
|
|
362
|
-
return !l.isEqual(a);
|
|
363
|
-
}) || r)
|
|
364
|
-
return !0;
|
|
365
|
-
const E = Array.from(this.defaultDateRangeFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
366
|
-
var w, A, u, F;
|
|
367
|
-
const a = this.dateRangeFilters.get(f);
|
|
368
|
-
return l != null && l.filterType && !(a != null && a.filterType) || a != null && a.filterType && !(l != null && l.filterType) || (a == null ? void 0 : a.filterType) !== (l == null ? void 0 : l.filterType) ? !0 : (a == null ? void 0 : a.filterType) === "CUSTOM" && (l == null ? void 0 : l.filterType) === "CUSTOM" ? ((w = l.gte) == null ? void 0 : w.toString()) !== ((A = a.gte) == null ? void 0 : A.toString()) || ((u = l.lte) == null ? void 0 : u.toString()) !== ((F = a.lte) == null ? void 0 : F.toString()) : !1;
|
|
369
|
-
});
|
|
370
|
-
return Array.from(this.dateRangeFilters.entries()).filter(([f]) => e.has(f)).some(([f, l]) => {
|
|
371
|
-
var w, A, u, F;
|
|
372
|
-
const a = this.defaultDateRangeFilters.get(f);
|
|
373
|
-
return l != null && l.filterType && !(a != null && a.filterType) || a != null && a.filterType && !(l != null && l.filterType) || (a == null ? void 0 : a.filterType) !== (l == null ? void 0 : l.filterType) ? !0 : (a == null ? void 0 : a.filterType) === "CUSTOM" && (l == null ? void 0 : l.filterType) === "CUSTOM" ? ((w = l.gte) == null ? void 0 : w.toString()) !== ((A = a.gte) == null ? void 0 : A.toString()) || ((u = l.lte) == null ? void 0 : u.toString()) !== ((F = a.lte) == null ? void 0 : F.toString()) : !1;
|
|
374
|
-
}) || E;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
50
|
+
}
|
|
51
|
+
}, [s, o, n]);
|
|
52
|
+
return I(() => {
|
|
53
|
+
d();
|
|
54
|
+
}, [d]), I(() => {
|
|
55
|
+
u();
|
|
56
|
+
}, [t, u]), {
|
|
57
|
+
queryParams: O,
|
|
58
|
+
hasActiveView: w,
|
|
59
|
+
updateCurrentUrlWithTableSort: u
|
|
60
|
+
};
|
|
61
|
+
};
|
|
377
62
|
export {
|
|
378
|
-
|
|
63
|
+
C as useUrlParams
|
|
379
64
|
};
|
package/dist/index7.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("axios"),i=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("axios"),i=require("./index84.cjs"),s=require("./index85.cjs"),l=require("./index86.cjs"),E=require("./index87.cjs"),p=t=>t&&t.__esModule?t:{default:t},c=p(u),y=async(t,a)=>{const o=new Error,r=s.filterOptionalArgsGetDelete(t,a);try{return await c.default.get(...r)}catch(e){throw l.filterErrorStack(o),E.injectIntoError({customError:o,originalError:e,type:i.AxiosErrorType.GET}),e}},f=async(t,a)=>{const o=new Error,r=s.filterOptionalArgsGetDelete(t,a);try{return await c.default.delete(...r)}catch(e){throw l.filterErrorStack(o),E.injectIntoError({customError:o,originalError:e,type:i.AxiosErrorType.DELETE}),e}},g=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.post(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.POST}),n}},w=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.patch(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.PATCH}),n}},A=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.put(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.PUT}),n}},d=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.postForm(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.POST_FORM}),n}},h=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.putForm(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.PUT_FORM}),n}},T=async(t,a,o)=>{const r=new Error,e=s.filterOptionalArgs(t,a,o);try{return await c.default.patchForm(...e)}catch(n){throw l.filterErrorStack(r),E.injectIntoError({customError:r,originalError:n,type:i.AxiosErrorType.PATCH_FORM}),n}},m={get:y,delete:f,post:g,patch:w,put:A,postForm:d,putForm:h,patchForm:T,CancelToken:c.default.CancelToken,isCancel:c.default.isCancel,getUri:c.default.getUri,isAxiosError:c.default.isAxiosError};exports.axios=m;
|
package/dist/index7.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import a from "axios";
|
|
2
|
-
import { AxiosErrorType as e } from "./
|
|
3
|
-
import { filterOptionalArgsGetDelete as y, filterOptionalArgs as p } from "./
|
|
4
|
-
import { filterErrorStack as i } from "./
|
|
5
|
-
import { injectIntoError as E } from "./
|
|
2
|
+
import { AxiosErrorType as e } from "./index84.js";
|
|
3
|
+
import { filterOptionalArgsGetDelete as y, filterOptionalArgs as p } from "./index85.js";
|
|
4
|
+
import { filterErrorStack as i } from "./index86.js";
|
|
5
|
+
import { injectIntoError as E } from "./index87.js";
|
|
6
6
|
const m = async (n, s) => {
|
|
7
7
|
const o = new Error(), r = y(n, s);
|
|
8
8
|
try {
|
package/dist/index70.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var M=(r,e,s)=>e in r?c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var t=(r,e,s)=>M(r,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("mobx"),d=require("./index9.cjs");class n{constructor({filterId:e}){t(this,"filterId");t(this,"gteMinLabel");t(this,"gteMin");t(this,"lteMaxLabel");t(this,"lteMax");t(this,"gte");t(this,"lte");t(this,"setGte",e=>{this.gte=e});t(this,"setLte",e=>{this.lte=e});t(this,"clear",()=>{this.setGte(void 0),this.setLte(void 0)});t(this,"clone",()=>{const e=new n({filterId:this.filterId});return e.setGte(this.gte),e.setLte(this.lte),e});t(this,"isEqual",e=>!(!e||this.lte!==e.lte||this.gte!==e.gte));var h,o;i.makeObservable(this,{filterId:i.observable,filterLabel:i.computed,gte:i.observable,lte:i.observable,lteMax:i.observable,gteMin:i.observable,setGte:i.action,setLte:i.action,clear:i.action}),this.filterId=e;const{FIELDS_MAP:s}=d.BusinessLogicManager.getBusinessLogic(),l=s.get(this.filterId),u=(h=l==null?void 0:l.options)==null?void 0:h.every(a=>a.value&&Number.isInteger(Number(a.value)));if(l&&u&&((o=l.options)==null?void 0:o.length)===2){const[a,g]=l.options,b=Number(a.value),f=Number(g.value);this.gteMin=b,this.gteMinLabel=a.label,this.lteMax=f,this.lteMaxLabel=g.label}else this.gte=0,this.gteMin=0,this.gteMinLabel="Min.",this.lte=100,this.lteMax=100,this.lteMaxLabel="Max."}get isValidLte(){return!(this.lte===void 0||this.lte===this.lteMax)}get filterLabel(){return this.gte===void 0&&this.lte===void 0?"":this.isValidLte?`Between ${this.gte} and ${this.lte}`:this.gte!==void 0?`${this.gte} or more`:""}get isActive(){return this.gte===this.gteMin&&this.lte===this.lteMax||this.gte===void 0&&this.lte===void 0?!1:this.gte!==void 0?!0:this.lte!==void 0&&this.lte<this.lteMax}}exports.NumberRangeFilter=n;
|
|
1
|
+
"use strict";var V=Object.defineProperty;var B=(b,t,s)=>t in b?V(b,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):b[t]=s;var h=(b,t,s)=>B(b,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("mobx"),G=require("@veeqo/ui"),C=require("@internationalized/date"),q=require("lodash/isEqual"),z=require("lodash/get"),j=require("lodash/set"),K=require("qs"),m=require("./index50.cjs"),I=require("./index2.cjs"),A=require("./index72.cjs"),D=require("./index71.cjs"),L=require("./index110.cjs"),k=require("./index108.cjs"),N=require("./index79.cjs"),p=require("./index9.cjs"),_=b=>b&&b.__esModule?b:{default:b},O=_(q),H=_(z),E=_(j),T=_(K);class ${constructor(t){h(this,"defaultPageSize");h(this,"pageSize");h(this,"currentPage");h(this,"defaultFilters");h(this,"defaultArrayFilters");h(this,"defaultDateRangeFilters");h(this,"defaultNumberRangeFilters");h(this,"filters");h(this,"arrayFilters");h(this,"dateRangeFilters");h(this,"numberRangeFilters");h(this,"activeViewId");h(this,"defaultSortState");h(this,"tableStore");h(this,"isFiltersDropdownVisible");h(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),this.defaultSortState={columnId:"",direction:"asc"}});h(this,"updateUrl",(t=!1)=>{try{const{SORT_FILTER_ID:s,SORTING_MODE:n}=p.BusinessLogicManager.getBusinessLogic(),e=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),u=e[s],f=e.sort_order,i=e.sort;let r="";switch(n){case I.SortingMode.CORAL:if(f&&i){const d={...this.queryParamsObject,sort:i,sort_order:f};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}break;case I.SortingMode.MONOLITH:default:if(u){const d={...this.queryParamsObject,[s]:u};r=`${window.location.pathname}?${T.default.stringify(d,{arrayFormat:"brackets"})}`}}u||(r=`${window.location.pathname}?${this.queryParams}`),t?window.history.pushState({},"",r):window.history.replaceState({},"",r)}catch(s){console.log(s)}});h(this,"setCurrentPage",t=>{this.currentPage=t});h(this,"setPageSize",t=>{this.pageSize=t,this.updateUrl()});h(this,"setFilter",(t,s)=>{this.filters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearFilter",t=>{this.filters.set(t,""),this.setCurrentPage(1),this.updateUrl()});h(this,"setArrayFilter",(t,s)=>{this.arrayFilters.set(t,s),this.setCurrentPage(1),this.updateUrl()});h(this,"clearArrayFilter",t=>{this.arrayFilters.set(t,[]),this.setCurrentPage(1),this.updateUrl()});h(this,"setRangeFilter",({key:t,range:s,dates:n})=>{s.setFilterType(t),s.setDates(n.start,n.end),this.setCurrentPage(1),this.updateUrl()});h(this,"clearRangeFilter",t=>{const s=this.dateRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"setNumberRangeFilter",({numberRange:t,gte:s,lte:n})=>{t.setGte(s),t.setLte(n),this.setCurrentPage(1),this.updateUrl()});h(this,"clearNumberRangeFilter",t=>{const s=this.numberRangeFilters.get(t);s&&(s.clear(),this.setCurrentPage(1),this.updateUrl())});h(this,"clearAllFilters",(t=!1)=>{const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic();this.filters.forEach((n,e)=>{e!==s&&this.filters.set(e,"")}),this.arrayFilters.forEach((n,e)=>this.arrayFilters.set(e,[])),this.dateRangeFilters.forEach(n=>n.clear()),this.numberRangeFilters.forEach(n=>n.clear()),this.setCurrentPage(1),t||this.updateUrl()});h(this,"clearFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);n&&n.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)})});h(this,"setActiveViewId",t=>{this.activeViewId=t,this.updateUrl()});h(this,"toggleFiltersDropdownVisible",t=>{this.isFiltersDropdownVisible=t});h(this,"getFiltersForGroup",t=>{const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=s.get(t);if(!n)return{};const e={};return n.fields.forEach(u=>{this.arrayFilters.has(u.id)?e[u.id]=this.arrayFilters.get(u.id):this.dateRangeFilters.has(u.id)?e[u.id]=this.dateRangeFilters.get(u.id):this.numberRangeFilters.has(u.id)?e[u.id]=this.numberRangeFilters.get(u.id):e[u.id]=this.filters.get(u.id)}),e});h(this,"initFiltersFromView",t=>{var e,u;const{PAGE_SIZE_OPTIONS:s}=p.BusinessLogicManager.getBusinessLogic();(e=t.page)!=null&&e.size&&s.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(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.defaultNumberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]})),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(([f,i])=>{const r=new A.RangeFilter(i.filterType);return i.gte&&i.lte&&r.setDates(i.gte,i.lte),[f,r]})),this.numberRangeFilters=new Map(Array.from(t.filterMaps.numberRangeFilters.entries()).map(([f,i])=>{const r=i.clone();return i.gte&&r.setGte(i.gte),i.lte&&r.setLte(i.lte),[f,r]}));const n=L.parseSortString(t.sort);this.defaultSortState=n,(u=this.tableStore)==null||u.setSortState(n),this.activeViewId=t.id});h(this,"initFromUrl",(t=!0)=>{var S,w;const{GROUP_MAP:s,PAGE_SIZE_OPTIONS:n,PAGE_SIZE_FILTER_ID:e,SORT_FILTER_ID:u}=p.BusinessLogicManager.getBusinessLogic(),f=T.default.parse(window.location.search,{ignoreQueryPrefix:!0}),i=Array.from(s.values()).flatMap(F=>F.fields),r=new Map,d=new Map,M=new Map,v=new Map;t&&f.view&&(this.activeViewId=f.view),f[e]&&n.includes(Number(f[e]))&&(this.pageSize=Number(f[e]));const c=f.filter||{};i.forEach(F=>{const g=H.default(c,F.id);if(g!==void 0)switch(F.filterType){case m.FilterChoiceValue.CHECKBOX:Array.isArray(g)?d.set(F.id,g):g&&d.set(F.id,[g]);break;case m.FilterChoiceValue.DATE_RANGE:if(typeof g=="string"&&N.isValidDateRange(g))M.set(F.id,new A.RangeFilter(g));else if(typeof g=="object"&&g!==null){const y=g;if(y.relative&&N.isValidDateRange(y.relative))M.set(F.id,new A.RangeFilter(y.relative));else if(y.gte&&y.lte)try{const R=C.parseDate(y.gte),U=C.parseDate(y.lte),P=new A.RangeFilter("CUSTOM");P.setDates(R,U),M.set(F.id,P)}catch{M.set(F.id,new A.RangeFilter(G.DateRanges.TODAY))}}break;case m.FilterChoiceValue.NUMBER_RANGE:if(typeof g=="object"&&g!==null){const y=g,R=new D.NumberRangeFilter({filterId:F.id});y.gte!==void 0&&R.setGte(Number(y.gte)),y.lte!==void 0&&R.setLte(Number(y.lte)),v.set(F.id,R)}break;case m.FilterChoiceValue.TEXT:case m.FilterChoiceValue.NUMBER:case m.FilterChoiceValue.RADIO:(typeof g=="string"||typeof g=="number")&&r.set(F.id,String(g));break}}),this.filters=r,this.arrayFilters=d,this.dateRangeFilters=M,this.numberRangeFilters=v;const l=f[u]||f.sort,a=f.sort_order;if(a&&f.sort)(S=this.tableStore)==null||S.setSortState({columnId:f.sort,direction:a});else if(l){const F=L.parseSortString(l);F.columnId&&((w=this.tableStore)==null||w.setSortState(F))}this.updateUrl()});h(this,"discardChanges",(t=!1)=>{var e;this.pageSize=this.defaultPageSize;const{SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=new Map(this.defaultFilters);this.filters.has(s)&&n.set(s,this.filters.get(s)),this.filters=n,this.arrayFilters=new Map(this.defaultArrayFilters),this.dateRangeFilters.clear(),this.defaultDateRangeFilters.forEach((u,f)=>{const i=new A.RangeFilter(u.filterType);i.setDates(u.gte,u.lte),this.dateRangeFilters.set(f,i)}),this.numberRangeFilters.clear(),this.defaultNumberRangeFilters.forEach((u,f)=>{this.numberRangeFilters.set(f,u.clone())}),(e=this.tableStore)==null||e.setSortState(this.defaultSortState),this.updateUrl(t)});const{GROUP_MAP:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(s.values()).flatMap(e=>e.fields);this.filters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.TEXT||e.filterType===m.FilterChoiceValue.NUMBER||e.filterType===m.FilterChoiceValue.RADIO||e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,""])),this.arrayFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.CHECKBOX).map(e=>[e.id,[]])),this.dateRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.DATE_RANGE).map(e=>[e.id,new A.RangeFilter])),this.numberRangeFilters=new Map(n.filter(e=>e.filterType===m.FilterChoiceValue.NUMBER_RANGE).map(e=>{const u=new D.NumberRangeFilter({filterId:e.id});return[e.id,u]})),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,this.defaultSortState={columnId:"",direction:"asc"},this.tableStore=t,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,defaultSortState:o.observable,tableStore:o.observable.ref,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}=p.BusinessLogicManager.getBusinessLogic(),s=Array.from(t.values()).flatMap(e=>e.fields),n=new Set(s.map(e=>e.id));return Array.from(this.filters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e!=="")||Array.from(this.arrayFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.length>0)||Array.from(this.dateRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.filterType!==void 0)||Array.from(this.numberRangeFilters.entries()).filter(([e])=>n.has(e)).some(([,e])=>e.isActive)}get activeFilterKeysList(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(this.filters.entries()).filter(([r,d])=>d!==""&&!t.includes(r)&&!s.includes(r)).map(([r])=>r),e=Array.from(this.arrayFilters.entries()).filter(([,r])=>r.length>0).map(([r])=>r),u=Array.from(this.dateRangeFilters.entries()).filter(([,r])=>r.filterType!==void 0).map(([r])=>r),f=Array.from(this.numberRangeFilters.entries()).filter(([,r])=>r.isActive).map(([r])=>r);return[...new Set([...n,...e,...u,...f])]}get queryParamsObject(){const{DATE_RANGE_FILTERS:t,NUMBER_RANGE_FILTERS:s,PAGE_SIZE_FILTER_ID:n,PAGE_NUMBER_FILTER_ID:e}=p.BusinessLogicManager.getBusinessLogic(),u={};Array.from(this.filters.entries()).filter(([i,r])=>r!==""&&!t.includes(i)&&!s.includes(i)).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.arrayFilters.entries()).filter(([,i])=>i.length>0).forEach(([i,r])=>{E.default(u,i,r)}),Array.from(this.dateRangeFilters.entries()).filter(([,i])=>i.filterType!==void 0).forEach(([i,r])=>{r.filterType==="CUSTOM"?E.default(u,i,{gte:r.gte.toString(),lte:r.lte.toString()}):E.default(u,i,{relative:r.filterType})}),Array.from(this.numberRangeFilters.entries()).filter(([,i])=>i.isActive).forEach(([i,r])=>{const d={};r.gte!==void 0&&(d.gte=r.gte),r.isValidLte&&(d.lte=r.lte),E.default(u,i,d)});const f={filter:u,[n]:String(this.pageSize),[e]:String(this.currentPage)};return this.activeViewId&&(f.view=this.activeViewId),f}get queryParams(){return T.default.stringify(this.queryParamsObject,{arrayFormat:"brackets"})}get hasUnsavedChanges(){if(this.activeViewId===k.ALL_VIEW_ID)return!1;if(this.defaultPageSize!==this.pageSize||this.tableStore&&(this.tableStore.sortState.columnId!==this.defaultSortState.columnId||this.tableStore.sortState.direction!==this.defaultSortState.direction))return!0;const{GROUP_MAP:t,SEARCH_FILTER_ID:s}=p.BusinessLogicManager.getBusinessLogic(),n=Array.from(t.values()).flatMap(c=>c.fields),e=new Set(n.map(c=>c.id));if(Array.from(this.filters.entries()).filter(([c])=>c!==s&&e.has(c)).some(([c,l])=>{const a=this.defaultFilters.get(c);return a===void 0&&l!==""||a!==void 0&&l!==a}))return!0;const f=Array.from(this.defaultArrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1}),i=Array.from(this.arrayFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultArrayFilters.get(c)||[];return l.length>0||a.length>0?l.length!==a.length||!O.default(l,a):!1});if(f||i)return!0;const r=Array.from(this.numberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.defaultNumberRangeFilters.get(c);return!l.isEqual(a)});if(Array.from(this.defaultNumberRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{const a=this.numberRangeFilters.get(c);return!l.isEqual(a)})||r)return!0;const M=Array.from(this.defaultDateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.dateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1});return Array.from(this.dateRangeFilters.entries()).filter(([c])=>e.has(c)).some(([c,l])=>{var S,w,F,g;const a=this.defaultDateRangeFilters.get(c);return l!=null&&l.filterType&&!(a!=null&&a.filterType)||a!=null&&a.filterType&&!(l!=null&&l.filterType)||(a==null?void 0:a.filterType)!==(l==null?void 0:l.filterType)?!0:(a==null?void 0:a.filterType)==="CUSTOM"&&(l==null?void 0:l.filterType)==="CUSTOM"?((S=l.gte)==null?void 0:S.toString())!==((w=a.gte)==null?void 0:w.toString())||((F=l.lte)==null?void 0:F.toString())!==((g=a.lte)==null?void 0:g.toString()):!1})||M}}exports.Filters=$;
|