@univerjs/preset-sheets-filter 0.6.6-nightly.202503251606 → 0.6.7-experimental.20250402-cbaeae1
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/lib/index.css +1 -1
- package/lib/umd/index.js +4 -2
- package/package.json +7 -7
package/lib/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-hidden{display:none}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-full{height:100%}.univer-max-w-\[245px\]{max-width:245px}.univer-flex-1{flex:1 1 0%}.univer-flex-grow{flex-grow:1}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-between{justify-content:space-between}.univer-overflow-hidden{overflow:hidden}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-200{--tw-border-opacity: 1;border-color:#e3e5ea;border-color:rgba(227,229,234,var(--tw-border-opacity, 1))}.univer-px-1\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pr-2{padding-right:.5rem}.univer-text-\[13px\]{font-size:13px}.univer-text-primary-500{--tw-text-opacity: 1;color:#466af7;color:rgba(70,106,247,var(--tw-text-opacity, 1))}.hover\:univer-bg-gray-50:hover{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.\[\&\:hover_a\]\:univer-inline-block:hover a{display:inline-block}.univer-sheets-filter-panel{display:flex;
|
|
1
|
+
.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-hidden{display:none}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-full{height:100%}.univer-max-w-\[245px\]{max-width:245px}.univer-flex-1{flex:1 1 0%}.univer-flex-grow{flex-grow:1}.univer-cursor-pointer{cursor:pointer}.univer-flex-col{flex-direction:column}.univer-items-center{align-items:center}.univer-justify-between{justify-content:space-between}.univer-overflow-hidden{overflow:hidden}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-gray-200{--tw-border-opacity: 1;border-color:#e3e5ea;border-color:rgba(227,229,234,var(--tw-border-opacity, 1))}.univer-px-1\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pr-2{padding-right:.5rem}.univer-text-\[13px\]{font-size:13px}.univer-text-primary-500{--tw-text-opacity: 1;color:#466af7;color:rgba(70,106,247,var(--tw-text-opacity, 1))}.hover\:univer-bg-gray-50:hover{--tw-bg-opacity: 1;background-color:#f9fafb;background-color:rgba(249,250,251,var(--tw-bg-opacity, 1))}.\[\&\:hover_a\]\:univer-inline-block:hover a{display:inline-block}.univer-sheets-filter-panel{display:flex;width:312px;height:432px;flex-direction:column;background:rgb(var(--bg-color-secondary));border-radius:10px;box-sizing:border-box;box-shadow:var(--box-shadow-lg);padding:16px;overflow:hidden}.univer-sheets-filter-panel-header{flex-grow:0;flex-shrink:0;margin-bottom:4px}.univer-sheets-filter-panel-content{flex-grow:1;flex-shrink:1;overflow:hidden;padding-top:8px}.univer-sheets-filter-panel-select-all{font-size:13px;margin-right:4px}.univer-sheets-filter-panel-select-all-count{font-size:13px;color:rgb(var(--grey-400))}.univer-sheets-filter-panel-values-container{display:flex;height:100%;flex-direction:column}.univer-sheets-filter-panel-values-container>.univer-input-affix-wrapper{flex:0 0 32px}.univer-sheets-filter-panel-values-container .univer-select,.univer-sheets-filter-panel-values-container .univer-input-affix-wrapper,.univer-sheets-filter-panel-values-container .univer-radio-group{width:100%}.univer-sheets-filter-panel-values-find{height:32px;margin-bottom:8px}.univer-sheets-filter-panel-values-virtual{flex-grow:1}.univer-sheets-filter-panel-values-item{box-sizing:border-box;height:32px;padding:2px 0;width:100%}.univer-sheets-filter-panel-values-item-inner{align-items:center;padding:0 2px 0 20px;line-height:28px;box-sizing:border-box;border-radius:6px;height:28px;display:flex;font-size:13px}.univer-sheets-filter-panel-values-item-inner:hover{background-color:rgb(var(--grey-50))}.univer-sheets-filter-panel-values-item-inner:hover .univer-sheets-filter-panel-values-item-count{margin-right:2px}.univer-sheets-filter-panel-values-item-inner:hover .univer-sheets-filter-panel-values-item-exclude-button{box-sizing:border-box;margin-left:auto;display:inline-block;height:24px;font-size:12px;line-height:12px}.univer-sheets-filter-panel-values-item-inner:hover .univer-sheets-filter-panel-values-item-exclude-button:hover{background-color:rgb(var(--hyacinth-50))}.univer-sheets-filter-panel-values-item-inner:hover .univer-sheets-filter-panel-values-item-exclude-button:active{background-color:rgb(var(--hyacinth-100))}.univer-sheets-filter-panel-values-item-text{display:inline-block;height:100%;margin:0 4px;flex-shrink:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-sheets-filter-panel-values-item-count{color:rgb(var(--grey-400))}.univer-sheets-filter-panel-values-item-exclude-button{display:none}.univer-sheets-filter-panel-conditions-container{display:flex;flex-direction:column;height:100%}.univer-sheets-filter-panel-conditions-container .univer-select,.univer-sheets-filter-panel-conditions-container .univer-input-affix-wrapper,.univer-sheets-filter-panel-conditions-container .univer-radio-group{width:100%;margin-bottom:8px}.univer-sheets-filter-panel-conditions-container-inner{flex-grow:1;border-radius:6px;border:1px solid rgb(var(--grey-200));overflow:hidden;padding:8px}.univer-sheets-filter-panel-conditions-desc{margin-top:-6px;color:rgb(var(--grey-500));font-size:12px;line-height:18px}.univer-sheets-filter-panel-footer{margin-top:16px;flex-grow:0;flex-shrink:0;display:inline-flex;flex-wrap:nowrap;overflow:hidden;justify-content:space-between}.univer-sheets-filter-panel-footer-primary-buttons{display:flex}.univer-sheets-filter-panel-footer-primary-buttons>.univer-button{margin-left:12px}.univer-sheets-filter-panel .univer-select,.univer-sheets-filter-panel .univer-input{width:100%}.univer-sheets-filter-panel .univer-form-dual-column-layout{margin-bottom:8px}
|
package/lib/umd/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
// @univerjs/sheets-filter-ui/index
|
|
10
|
-
(function(_,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/ui","@univerjs/sheets-ui","rxjs","@univerjs/design","@univerjs/engine-render","react/jsx-runtime","react"],c):(_=typeof globalThis<"u"?globalThis:_||self,c(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverRpc,_.UniverSheetsFilter,_.UniverSheets,_.UniverUi,_.UniverSheetsUi,_.rxjs,_.UniverDesign,_.UniverEngineRender,_.React,_.React))})(this,function(_,c,Q,u,I,T,$,C,L,ie,d,y){"use strict";var jt=Object.defineProperty;var Gt=(_,c,Q)=>c in _?jt(_,c,{enumerable:!0,configurable:!0,writable:!0,value:Q}):_[c]=Q;var S=(_,c,Q)=>Gt(_,typeof c!="symbol"?c+"":c,Q);var ve;const Ue="sheets-filter-ui.config",ce={};var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=n;function F(U,M){for(const B of t.ALL_CONDITIONS)if(B.operator===U)return B.mapToFilterColumn({val1:M,operator1:U})}const v=!m||m===t.NONE.operator,O=!f||f===t.NONE.operator;if(v&&O)return t.NONE.mapToFilterColumn({});if(v)return F(f,h);if(O)return F(m,a);const E=F(m,a),A=F(f,h),P={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return o&&(P.and=c.BooleanNumber.TRUE),{customFilters:P}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function l(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function k(t){const{operator1:e,operator2:r,val1:i,val2:s}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,s]}function Te(t){const e=[],r=[];let i=0,s=0;function l(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var Ke=Object.getOwnPropertyDescriptor,Xe=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ke(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Ee=(t,e)=>(r,i)=>e(r,i,t);const Fe="sheets-filter.generate-filter-values.service",ue=c.createIdentifier(Fe),Ze=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Oe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:l,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),we(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Oe=Xe([Ee(0,c.Inject(c.LocaleService)),Ee(1,c.IUniverInstanceService),Ee(2,c.ILogService)],Oe);function we(t,e,r,i,s,l,n,o){var E,A,P,U,M,B,V,Se,ge;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(Ze),F="empty";let v=0;for(const w of i.iterateByColumn(r,!1,!1)){const{row:Vt,rowSpan:qe=1}=w;let re=0;for(;re<qe;){const Wt=Vt+re;if(s.has(Wt)){re++;continue}const X=w!=null&&w.value?c.extractPureTextFromCell(w.value):"";if(!X){v+=1,re+=qe;continue}const Ce=(E=w.value)!=null&&E.v&&!w.value.p?(U=(P=o.get((A=w.value)==null?void 0:A.s))==null?void 0:P.n)==null?void 0:U.pattern:"",Qt=Ce&&c.numfmt.isDate(Ce);if(Ce&&Qt&&f.has(Ce)){const q=(M=i.getCellRaw(w.row,w.col))==null?void 0:M.v;if(!q){re++;continue}const ne=c.numfmt.format(m,q),[b,W,le]=ne.split("-").map(Number);let Z=a.get(`${b}`);Z||(Z={title:`${b}`,key:`${b}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${b}`,Z),h.set(`${b}`,[`${b}`]));let G=(B=Z.children)==null?void 0:B.find(Le=>Le.key===`${b}-${W}`);G||(G={title:e.t(`sheets-filter.date.${W}`),key:`${b}-${W}`,children:[],count:0,leaf:!1,checked:!1},(V=Z.children)==null||V.push(G),h.set(`${b}-${W}`,[`${b}`,`${b}-${W}`]));const Me=(Se=G==null?void 0:G.children)==null?void 0:Se.find(Le=>Le.key===`${b}-${W}-${le}`);Me?(Me.originValues.add(X),Me.count++,G.count++,Z.count++):((ge=G.children)==null||ge.push({title:`${le}`,key:`${b}-${W}-${le}`,count:1,originValues:new Set([X]),leaf:!0,checked:l.size?l.has(X):!n}),G.count++,Z.count++,h.set(`${b}-${W}-${le}`,[`${b}`,`${b}-${W}`,`${b}-${W}-${le}`]))}else{const q=X;let ne=a.get(q);ne?ne.count++:(ne={title:X,leaf:!0,checked:l.size?l.has(X):!n,key:q,count:1},a.set(q,ne),h.set(q,[q]))}re++}}const O=t?n:!0;if(v>0){const w={title:e.t("sheets-filter.panel.empty"),count:v,leaf:!0,checked:O,key:F};a.set("empty",w),h.set("empty",[F])}return{filterTreeItems:ze(Array.from(a.values())),filterTreeMapCache:h}}function ze(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return s-l}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const l=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return l-n})}),e))}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ie(r.children,e);if(i)return i}}return null}function $e(t){return t.leaf?t.checked:t.children?t.children.every(e=>$e(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function De(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||l)r.push({...i});else if(i.children){const o=De(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var Je=Object.getOwnPropertyDescriptor,Pe=(t,e,r,i)=>{for(var s=i>1?void 0:i?Je(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},he=(t,e)=>(r,i)=>e(r,i,t),me=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(me||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let x=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new C.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new C.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new C.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new C.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,l=e.getRange(),n={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await de.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=pe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};x=Pe([he(0,c.Inject(c.Injector)),he(1,c.Inject(I.RefRangeService))],x);let pe=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"canApply$",C.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[l,n]=p.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(pe,r,i,l,n)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};pe=Pe([he(4,c.ICommandService)],pe);let de=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return De(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Te(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var B;const s=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),n=e.get(ue,c.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),F=i,v=(B=r.getFilterColumn(i))==null?void 0:B.getColumnData().filters,O=new Set(v==null?void 0:v.filters),E=!!(v&&v.blank),A=r.getFilteredOutRowsExceptCol(i),P={...f,startRow:f.startRow+1,startColumn:F,endColumn:F};let U,M;if(n){const V=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!v,blankChecked:E,iterateRange:P,alreadyChecked:Array.from(O)});U=V.filterTreeItems,M=V.filterTreeMapCache}else{const V=we(!!v,l,P,m,A,O,E,h.getStyles());U=V.filterTreeItems,M=V.filterTreeMapCache}return e.createInstance(de,r,i,U,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),i=Ie(r,e.key);if(!i)return;const s=$e(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Ie(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Te(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let l=0;for(const h of s)l+=h.count;const n=r===0,o=e.checked===l,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};de=Pe([he(4,c.ICommandService)],de);const z="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),i=t.get(u.SheetsFilterService),s=t.get(x);t.get(c.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(z)||r.setContextValue(z,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(x),i=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(z)?(e.setContextValue(z,!1),i==null||i.focus(),r.terminate()):!1}},Ne={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(x).changeFilterBy(r)}};var et=Object.getOwnPropertyDescriptor,tt=(t,e,r,i)=>{for(var s=i>1?void 0:i?et(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends c.Disposable{constructor(t,e,r,i,s,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=s,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(c.IUniverInstanceService),l=I.getSheetCommandTarget(s);if(!l)return;const{unitId:n,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let F={...f};F=f.startColumn===f.endColumn&&f.startRow===f.endRow?I.expandToContinuousRange(F,{left:!0,right:!0,up:!0,down:!0},a):F,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]},[F],n,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:l,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(l,n))==null?void 0:i.getRange(),a=c.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=tt([ee(0,c.Inject(u.SheetsFilterService)),ee(1,c.Inject(c.LocaleService)),ee(2,c.ICommandService),ee(3,c.Inject(I.SheetPermissionCheckController)),ee(4,c.Inject(c.Injector)),ee(5,c.Inject(I.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},rt=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},He=y.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,l=t.extend,n=rt(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=y.useRef("_".concat(st()));return ke(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),l)});function ke(t,e,r,i,s){return y.createElement(t.tag,H(H({key:e},nt(t,r,s)),i),(it(t,r).children||[]).map(function(l,n){return ke(l,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function nt(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1),t.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];n==="mask"&&typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function it(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function st(){return Math.random().toString(36).substring(2,8)}He.displayName="UniverIcon";var ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Be=y.forwardRef(function(t,e){return y.createElement(He,Object.assign({},t,{id:"filter-single",ref:e,icon:ot}))});Be.displayName="FilterSingle";const R={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons"};function at(t){var v,O;const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.conditionItem$,void 0),s=T.useObservable(e.filterConditionFormParams$,void 0),l=s!=null&&s.and?"AND":"OR",n=y.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),o=lt(r),a=y.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),h=ct(r),m=y.useCallback(E=>{e.onConditionFormChange(E)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function F(E,A,P){const U=p.getItemByOperator(E).numOfParameters===1;return d.jsxs(d.Fragment,{children:[P==="operator2"&&d.jsxs(L.RadioGroup,{value:l,onChange:n,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:E,options:h,onChange:M=>m({[P]:M})}),U&&d.jsx("div",{children:d.jsx(L.Input,{value:A,placeholder:f,onChange:M=>m({[P==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{className:R.sheetsFilterPanelConditionsContainer,children:i&&s&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:R.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&F(s.operator1,(v=s.val1)!=null?v:"","operator1"),i.numOfParameters>=2&&F(s.operator2,(O=s.val2)!=null?O:"","operator2"),d.jsxs("div",{className:R.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function lt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function ct(t){const e=t.getCurrentLocale();return y.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function ut(t){const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.searchString$,"",!0),s=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),n=Te(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=y.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=y.useCallback(v=>{e.setSearchString(v)},[e]);function F(v){let O=[];return v.forEach(E=>{E.checked&&O.push(E.key),E.children&&(O=O.concat(F(E.children)))}),O}return d.jsxs("div",{className:R.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:`
|
|
10
|
+
(function(_,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/ui","@univerjs/sheets-ui","rxjs","@univerjs/design","@univerjs/engine-render","react/jsx-runtime","react"],c):(_=typeof globalThis<"u"?globalThis:_||self,c(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverRpc,_.UniverSheetsFilter,_.UniverSheets,_.UniverUi,_.UniverSheetsUi,_.rxjs,_.UniverDesign,_.UniverEngineRender,_.React,_.React))})(this,function(_,c,Q,u,I,T,$,C,L,ie,d,y){"use strict";var xt=Object.defineProperty;var Yt=(_,c,Q)=>c in _?xt(_,c,{enumerable:!0,configurable:!0,writable:!0,value:Q}):_[c]=Q;var S=(_,c,Q)=>Yt(_,typeof c!="symbol"?c+"":c,Q);var ve;const Ue="sheets-filter-ui.config",ce={};var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=k(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=k(n);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=n;function F(U,M){for(const B of t.ALL_CONDITIONS)if(B.operator===U)return B.mapToFilterColumn({val1:M,operator1:U})}const v=!m||m===t.NONE.operator,O=!f||f===t.NONE.operator;if(v&&O)return t.NONE.mapToFilterColumn({});if(v)return F(f,h);if(O)return F(m,a);const E=F(m,a),A=F(f,h),P={customFilters:[E.customFilters.customFilters[0],A.customFilters.customFilters[0]]};return o&&(P.and=c.BooleanNumber.TRUE),{customFilters:P}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function l(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function k(t){const{operator1:e,operator2:r,val1:i,val2:s}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,s]}function Te(t){const e=[],r=[];let i=0,s=0;function l(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var Xe=Object.getOwnPropertyDescriptor,Ze=(t,e,r,i)=>{for(var s=i>1?void 0:i?Xe(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Ee=(t,e)=>(r,i)=>e(r,i,t);const Fe="sheets-filter.generate-filter-values.service",ue=c.createIdentifier(Fe),ze=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Oe=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:l,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),we(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Oe=Ze([Ee(0,c.Inject(c.LocaleService)),Ee(1,c.IUniverInstanceService),Ee(2,c.ILogService)],Oe);function we(t,e,r,i,s,l,n,o){var E,A,P,U,M,B,V,Se,ge;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(ze),F="empty";let v=0;for(const w of i.iterateByColumn(r,!1,!1)){const{row:Qt,rowSpan:Ke=1}=w;let re=0;for(;re<Ke;){const jt=Qt+re;if(s.has(jt)){re++;continue}const X=w!=null&&w.value?c.extractPureTextFromCell(w.value):"";if(!X){v+=1,re+=Ke;continue}const Ce=(E=w.value)!=null&&E.v&&!w.value.p?(U=(P=o.get((A=w.value)==null?void 0:A.s))==null?void 0:P.n)==null?void 0:U.pattern:"",Gt=Ce&&c.numfmt.isDate(Ce);if(Ce&&Gt&&f.has(Ce)){const q=(M=i.getCellRaw(w.row,w.col))==null?void 0:M.v;if(!q){re++;continue}const ne=c.numfmt.format(m,q),[b,W,le]=ne.split("-").map(Number);let Z=a.get(`${b}`);Z||(Z={title:`${b}`,key:`${b}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${b}`,Z),h.set(`${b}`,[`${b}`]));let G=(B=Z.children)==null?void 0:B.find(Le=>Le.key===`${b}-${W}`);G||(G={title:e.t(`sheets-filter.date.${W}`),key:`${b}-${W}`,children:[],count:0,leaf:!1,checked:!1},(V=Z.children)==null||V.push(G),h.set(`${b}-${W}`,[`${b}`,`${b}-${W}`]));const Me=(Se=G==null?void 0:G.children)==null?void 0:Se.find(Le=>Le.key===`${b}-${W}-${le}`);Me?(Me.originValues.add(X),Me.count++,G.count++,Z.count++):((ge=G.children)==null||ge.push({title:`${le}`,key:`${b}-${W}-${le}`,count:1,originValues:new Set([X]),leaf:!0,checked:l.size?l.has(X):!n}),G.count++,Z.count++,h.set(`${b}-${W}-${le}`,[`${b}`,`${b}-${W}`,`${b}-${W}-${le}`]))}else{const q=X;let ne=a.get(q);ne?ne.count++:(ne={title:X,leaf:!0,checked:l.size?l.has(X):!n,key:q,count:1},a.set(q,ne),h.set(q,[q]))}re++}}const O=t?n:!0;if(v>0){const w={title:e.t("sheets-filter.panel.empty"),count:v,leaf:!0,checked:O,key:F};a.set("empty",w),h.set("empty",[F])}return{filterTreeItems:Je(Array.from(a.values())),filterTreeMapCache:h}}function Je(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:et(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return s-l}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const l=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return l-n})}),e))}const $e=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function et(t,e){const r=$e(t),i=$e(e);return r&&i?Number.parseFloat(t)-Number.parseFloat(e):r&&!i?-1:!r&&i?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ie(r.children,e);if(i)return i}}return null}function De(t){return t.leaf?t.checked:t.children?t.children.every(e=>De(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function He(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||l)r.push({...i});else if(i.children){const o=He(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var tt=Object.getOwnPropertyDescriptor,Pe=(t,e,r,i)=>{for(var s=i>1?void 0:i?tt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},he=(t,e)=>(r,i)=>e(r,i,t),me=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(me||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let x=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new C.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new C.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new C.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new C.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,l=e.getRange(),n={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await de.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=pe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};x=Pe([he(0,c.Inject(c.Injector)),he(1,c.Inject(I.RefRangeService))],x);let pe=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"canApply$",C.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[l,n]=p.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(pe,r,i,l,n)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};pe=Pe([he(4,c.ICommandService)],pe);let de=class extends c.Disposable{constructor(e,r,i,s,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return He(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Te(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var B;const s=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),n=e.get(ue,c.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),F=i,v=(B=r.getFilterColumn(i))==null?void 0:B.getColumnData().filters,O=new Set(v==null?void 0:v.filters),E=!!(v&&v.blank),A=r.getFilteredOutRowsExceptCol(i),P={...f,startRow:f.startRow+1,startColumn:F,endColumn:F};let U,M;if(n){const V=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(A),filters:!!v,blankChecked:E,iterateRange:P,alreadyChecked:Array.from(O)});U=V.filterTreeItems,M=V.filterTreeMapCache}else{const V=we(!!v,l,P,m,A,O,E,h.getStyles());U=V.filterTreeItems,M=V.filterTreeMapCache}return e.createInstance(de,r,i,U,M)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),i=Ie(r,e.key);if(!i)return;const s=De(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Ie(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Te(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let l=0;for(const h of s)l+=h.count;const n=r===0,o=e.checked===l,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};de=Pe([he(4,c.ICommandService)],de);const z="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),i=t.get(u.SheetsFilterService),s=t.get(x);t.get(c.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(z)||r.setContextValue(z,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(x),i=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(z)?(e.setContextValue(z,!1),i==null||i.focus(),r.terminate()):!1}},Ne={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(x).changeFilterBy(r)}};var rt=Object.getOwnPropertyDescriptor,nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?rt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends c.Disposable{constructor(t,e,r,i,s,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=s,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(c.IUniverInstanceService),l=I.getSheetCommandTarget(s);if(!l)return;const{unitId:n,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let F={...f};F=f.startColumn===f.endColumn&&f.startRow===f.endRow?I.expandToContinuousRange(F,{left:!0,right:!0,up:!0,down:!0},a):F,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]},[F],n,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:l,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(l,n))==null?void 0:i.getRange(),a=c.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=nt([ee(0,c.Inject(u.SheetsFilterService)),ee(1,c.Inject(c.LocaleService)),ee(2,c.ICommandService),ee(3,c.Inject(I.SheetPermissionCheckController)),ee(4,c.Inject(c.Injector)),ee(5,c.Inject(I.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},it=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},ke=y.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,l=t.extend,n=it(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=y.useRef("_".concat(at()));return Be(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),l)});function Be(t,e,r,i,s){return y.createElement(t.tag,H(H({key:e},st(t,r,s)),i),(ot(t,r).children||[]).map(function(l,n){return Be(l,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function st(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1),t.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];n==="mask"&&typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function ot(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function at(){return Math.random().toString(36).substring(2,8)}ke.displayName="UniverIcon";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ve=y.forwardRef(function(t,e){return y.createElement(ke,Object.assign({},t,{id:"filter-single",ref:e,icon:lt}))});Ve.displayName="FilterSingle";const R={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons"};function ct(t){var v,O;const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.conditionItem$,void 0),s=T.useObservable(e.filterConditionFormParams$,void 0),l=s!=null&&s.and?"AND":"OR",n=y.useCallback(E=>{e.onConditionFormChange({and:E==="AND"})},[e]),o=ut(r),a=y.useCallback(E=>{e.onPrimaryConditionChange(E)},[e]),h=ht(r),m=y.useCallback(E=>{e.onConditionFormChange(E)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function F(E,A,P){const U=p.getItemByOperator(E).numOfParameters===1;return d.jsxs(d.Fragment,{children:[P==="operator2"&&d.jsxs(L.RadioGroup,{value:l,onChange:n,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:E,options:h,onChange:M=>m({[P]:M})}),U&&d.jsx("div",{children:d.jsx(L.Input,{value:A,placeholder:f,onChange:M=>m({[P==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{className:R.sheetsFilterPanelConditionsContainer,children:i&&s&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:R.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&F(s.operator1,(v=s.val1)!=null?v:"","operator1"),i.numOfParameters>=2&&F(s.operator2,(O=s.val2)!=null?O:"","operator2"),d.jsxs("div",{className:R.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function ut(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function ht(t){const e=t.getCurrentLocale();return y.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function mt(t){const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.searchString$,"",!0),s=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),n=Te(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=y.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=y.useCallback(v=>{e.setSearchString(v)},[e]);function F(v){let O=[];return v.forEach(E=>{E.checked&&O.push(E.key),E.children&&(O=O.concat(F(E.children)))}),O}return d.jsxs("div",{className:R.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:`
|
|
11
11
|
univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden
|
|
12
12
|
univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-px-2 univer-py-2.5
|
|
13
13
|
`,children:[d.jsx("div",{className:R.sheetsFilterPanelValuesItem,children:d.jsxs("div",{className:R.sheetsFilterPanelValuesItemInner,children:[d.jsx(L.Checkbox,{indeterminate:a,disabled:s.length===0,checked:o,onChange:m}),d.jsx("span",{className:R.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{className:R.sheetsFilterPanelValuesItemCount,children:`(${n.checked}/${n.checked+n.unchecked})`})]})}),d.jsx("div",{className:R.sheetsFilterPanelValuesVirtual,children:d.jsx(L.Tree,{data:s,defaultExpandAll:!1,valueGroup:F(s),height:180,onChange:v=>{e.onFilterCheckToggled(v)},defaultCache:h,itemHeight:28,treeNodeClassName:`
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
`,attachRender:v=>d.jsxs("div",{className:`
|
|
18
18
|
univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer
|
|
19
19
|
univer-items-center univer-justify-between univer-text-[13px] univer-text-primary-500
|
|
20
|
-
`,children:[d.jsx("span",{className:R.sheetsFilterPanelValuesItemCount,children:`(${v.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-px-1.5",onClick:()=>{const O=[];v.children?v.children.forEach(E=>{E.children?E.children.forEach(A=>{O.push(A.key)}):O.push(E.key)}):O.push(v.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function ht(){var A;const t=T.useDependency(x),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),s=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=mt(e),o=!T.useObservable(t.hasCriteria$),a=y.useCallback(P=>{r.executeCommand(Ne.id,{filterBy:P})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(J.id)},[r]),f=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),v=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,E=T.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:R.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:v,colIndex:O,onClose:m}}),d.jsx("div",{className:R.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,items:n,onChange:P=>a(P)})}),s?d.jsx("div",{className:R.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(ut,{model:s}):d.jsx(at,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:R.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:R.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function mt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function pt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission],rangeTypes:[I.RangeProtectionPermissionViewPoint]}))}}function dt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function ft(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const _t={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:pt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:dt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:ft}}}},Y=16,vt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Ve{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(vt),e.restore()}}var St=Object.getOwnPropertyDescriptor,gt=(t,e,r,i)=>{for(var s=i>1?void 0:i?St(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ye=(t,e)=>(r,i)=>e(r,i,t);const j=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=j-i,l=j-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?Ve.drawHasCriteria(e,j,a,h):Ve.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=gt([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Ae);var Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ct(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},K=(t,e)=>(r,i)=>e(r,i,t);const Et=1e3,Ft=5e3;let be=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===I.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new $.SelectionControl(i,Et,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const F=`sheets-filter-button-${f}`,v=$.getCoordByCell(m,f,o,l),{startX:O,startY:E,endX:A,endY:P}=v,U=A-O,M=P-E;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),V=A-j-fe,Se=P-j-fe,ge={left:V,top:Se,height:j,width:j,zIndex:Ft,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},w=this._injector.createInstance(Ae,F,ge);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:F,subUnitId:v}=a;return F!==e||v!==r||m!==s||f<l||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:j}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=Tt([K(1,c.Inject(c.Injector)),K(2,c.Inject($.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(I.SheetInterceptorService)),K(6,c.ICommandService),K(7,$.ISheetSelectionRenderService)],be);var Ot=Object.getOwnPropertyDescriptor,It=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ot(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},We=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=It([We(0,ie.IRenderManagerService),We(1,c.Inject($.SheetsRenderService))],ae);const Pt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var Nt=Object.getOwnPropertyDescriptor,yt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Nt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},D=(t,e)=>(r,i)=>e(r,i,t);const Qe="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,l,n,o,a,h,m,f,F,v){super(v,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Pt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(_t)}_initUI(){this.disposeWithMe(this._componentManager.register(Qe,ht)),this.disposeWithMe(this._componentManager.register("FilterSingle",Be)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:Qe,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=yt([D(0,c.Inject(c.Injector)),D(1,c.Inject(T.ComponentManager)),D(2,c.Inject(x)),D(3,c.Inject($.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,T.IShortcutService),D(7,c.ICommandService),D(8,T.IMenuManagerService),D(9,c.IContextService),D(10,T.IMessageService),D(11,c.Inject($.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var At=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,Rt=(t,e,r)=>e in t?At(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mt=(t,e,r,i)=>{for(var s=i>1?void 0:i?bt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Re=(t,e)=>(r,i)=>e(r,i,t),je=(t,e,r)=>Rt(t,typeof e!="symbol"?e+"":e,r);const Lt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>Q.toModule(this._rpcChannelService.requestChannel(Fe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},je(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),je(_.UniverSheetsFilterUIPlugin,"pluginName",Lt),_.UniverSheetsFilterUIPlugin=Mt([c.DependentOn(u.UniverSheetsFilterPlugin),Re(1,c.Inject(c.Injector)),Re(2,c.IConfigService),Re(3,c.Optional(Q.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var Ut=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,$t=(t,e,r)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dt=(t,e,r,i)=>{for(var s=i>1?void 0:i?wt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Ge=(t,e)=>(r,i)=>e(r,i,t),xe=(t,e,r)=>$t(t,typeof e!="symbol"?e+"":e,r);const Ht="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},xe(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),xe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Ht),_.UniverSheetsFilterMobileUIPlugin=Dt([c.DependentOn(u.UniverSheetsFilterPlugin),Ge(1,c.Inject(c.Injector)),Ge(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var kt=Object.getOwnPropertyDescriptor,Bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?kt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Ye=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(ve=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Fe,Q.fromModule(this._injector.get(ue)))}},S(ve,"type",c.UniverInstanceType.UNIVER_SHEET),S(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),_.UniverSheetsFilterUIWorkerPlugin=Bt([Ye(1,c.Inject(c.Injector)),Ye(2,Q.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
20
|
+
`,children:[d.jsx("span",{className:R.sheetsFilterPanelValuesItemCount,children:`(${v.count})`}),d.jsx("a",{className:`
|
|
21
|
+
univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5
|
|
22
|
+
`,onClick:()=>{const O=[];v.children?v.children.forEach(E=>{E.children?E.children.forEach(A=>{O.push(A.key)}):O.push(E.key)}):O.push(v.key),e.onFilterOnly(O)},children:l})]})})})]})]})}function pt(){var A;const t=T.useDependency(x),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),s=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=dt(e),o=!T.useObservable(t.hasCriteria$),a=y.useCallback(P=>{r.executeCommand(Ne.id,{filterBy:P})},[r]),h=y.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=y.useCallback(()=>{r.executeCommand(J.id)},[r]),f=y.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),v=(A=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:A.getRange(),O=t.col,E=T.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:R.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:E,sharedProps:{range:v,colIndex:O,onClose:m}}),d.jsx("div",{className:R.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,items:n,onChange:P=>a(P)})}),s?d.jsx("div",{className:R.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(mt,{model:s}):d.jsx(ct,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:R.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:R.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function dt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function ft(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission],rangeTypes:[I.RangeProtectionPermissionViewPoint]}))}}function _t(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function vt(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const St={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:ft,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:_t},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:vt}}}},Y=16,gt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class We{static drawNoCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Y,r/Y),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(gt),e.restore()}}var Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ct(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},ye=(t,e)=>(r,i)=>e(r,i,t);const j=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,s=j-i,l=j-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=Tt([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Ae);var Et=Object.getOwnPropertyDescriptor,Ft=(t,e,r,i)=>{for(var s=i>1?void 0:i?Et(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},K=(t,e)=>(r,i)=>e(r,i,t);const Ot=1e3,It=5e3;let be=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===I.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new $.SelectionControl(i,Ot,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const F=`sheets-filter-button-${f}`,v=$.getCoordByCell(m,f,o,l),{startX:O,startY:E,endX:A,endY:P}=v,U=A-O,M=P-E;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),V=A-j-fe,Se=P-j-fe,ge={left:V,top:Se,height:j,width:j,zIndex:It,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},w=this._injector.createInstance(Ae,F,ge);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:F,subUnitId:v}=a;return F!==e||v!==r||m!==s||f<l||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:j}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=Ft([K(1,c.Inject(c.Injector)),K(2,c.Inject($.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(I.SheetInterceptorService)),K(6,c.ICommandService),K(7,$.ISheetSelectionRenderService)],be);var Pt=Object.getOwnPropertyDescriptor,Nt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Pt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Qe=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=Nt([Qe(0,ie.IRenderManagerService),Qe(1,c.Inject($.SheetsRenderService))],ae);const yt={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var At=Object.getOwnPropertyDescriptor,bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?At(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,l,n,o,a,h,m,f,F,v){super(v,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[yt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(St)}_initUI(){this.disposeWithMe(this._componentManager.register(je,pt)),this.disposeWithMe(this._componentManager.register("FilterSingle",Ve)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=bt([D(0,c.Inject(c.Injector)),D(1,c.Inject(T.ComponentManager)),D(2,c.Inject(x)),D(3,c.Inject($.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,T.IShortcutService),D(7,c.ICommandService),D(8,T.IMenuManagerService),D(9,c.IContextService),D(10,T.IMessageService),D(11,c.Inject($.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var Rt=Object.defineProperty,Mt=Object.getOwnPropertyDescriptor,Lt=(t,e,r)=>e in t?Rt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ut=(t,e,r,i)=>{for(var s=i>1?void 0:i?Mt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},Re=(t,e)=>(r,i)=>e(r,i,t),Ge=(t,e,r)=>Lt(t,typeof e!="symbol"?e+"":e,r);const wt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>Q.toModule(this._rpcChannelService.requestChannel(Fe))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},Ge(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",wt),_.UniverSheetsFilterUIPlugin=Ut([c.DependentOn(u.UniverSheetsFilterPlugin),Re(1,c.Inject(c.Injector)),Re(2,c.IConfigService),Re(3,c.Optional(Q.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var $t=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Ht=(t,e,r)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Dt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},xe=(t,e)=>(r,i)=>e(r,i,t),Ye=(t,e,r)=>Ht(t,typeof e!="symbol"?e+"":e,r);const Bt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},Ye(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ye(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Bt),_.UniverSheetsFilterMobileUIPlugin=kt([c.DependentOn(u.UniverSheetsFilterPlugin),xe(1,c.Inject(c.Injector)),xe(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Wt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Vt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=n(s)||s);return s},qe=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(ve=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Oe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Fe,Q.fromModule(this._injector.get(ue)))}},S(ve,"type",c.UniverInstanceType.UNIVER_SHEET),S(ve,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ve),_.UniverSheetsFilterUIWorkerPlugin=Wt([qe(1,c.Inject(c.Injector)),qe(2,Q.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
// index
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/preset-sheets-filter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7-experimental.20250402-cbaeae1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
"lib"
|
|
53
53
|
],
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"react": "
|
|
56
|
-
"react-dom": "
|
|
55
|
+
"react": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
56
|
+
"react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
57
57
|
"rxjs": ">=7.0.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@univerjs/sheets-filter": "0.6.
|
|
61
|
-
"@univerjs/sheets-filter-ui": "0.6.
|
|
60
|
+
"@univerjs/sheets-filter": "0.6.7-experimental.20250402-cbaeae1",
|
|
61
|
+
"@univerjs/sheets-filter-ui": "0.6.7-experimental.20250402-cbaeae1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@univerjs/core": "0.6.
|
|
64
|
+
"@univerjs/core": "0.6.7-experimental.20250402-cbaeae1",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"react-dom": "18.3.1",
|
|
67
67
|
"typescript": "^5.8.2",
|
|
68
|
-
"@univerjs-infra/shared": "0.6.
|
|
68
|
+
"@univerjs-infra/shared": "0.6.9"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"prebuild:preset": "tsx prepare.ts",
|