@univerjs/sheets-sort-ui 0.2.4-alpha.0 → 0.2.4

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/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ie=Object.defineProperty;var ye=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var B=(e,t,n)=>ye(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@univerjs/core"),M=require("@univerjs/sheets-sort"),d=require("@univerjs/sheets"),_=require("@univerjs/sheets-ui"),o=require("react"),S=require("@univerjs/ui"),ae=require("rxjs"),R=require("@univerjs/design"),_e=require("@univerjs/engine-formula"),Ee="univer-extend-confirm-content",Re="univer-extend-confirm-radio-group",Me="univer-custom-sort-panel-container",Te="univer-custom-sort-panel-ext",xe="univer-add-condition",Pe="univer-add-condition-text",be="univer-add-condition-disable",Oe="univer-custom-sort-panel-footer",we="univer-custom-sort-panel-footer-btn",Ne="univer-custom-sort-panel-item",De="univer-custom-sort-panel-item-head",Le="univer-custom-sort-panel-item-handler",ke="univer-custom-sort-panel-item-remove",He="univer-custom-sort-panel-item-column-input",Ue="univer-custom-sort-panel-item-column-input-dropdown",Ae="univer-custom-sort-panel-item-column-input-text",$e="univer-custom-sort-panel-item-order-radio",Be="univer-custom-sort-panel-item-order-radio-cn",je="univer-condition-list",We="univer-embed-sort-btn-container",Fe="univer-embed-sort-btn",Ve="univer-embed-sort-btn-asc",ze="univer-embed-sort-btn-desc",Ze="univer-embed-sort-btn-icon",Ge="univer-custom-sort-col-menu",qe="univer-custom-sort-col-menu-item",Xe="univer-custom-sort-col-menu-item-desc",l={extendConfirmContent:Ee,extendConfirmRadioGroup:Re,customSortPanelContainer:Me,customSortPanelExt:Te,addCondition:xe,addConditionText:Pe,addConditionDisable:be,customSortPanelFooter:Oe,customSortPanelFooterBtn:we,customSortPanelItem:Ne,customSortPanelItemHead:De,customSortPanelItemHandler:Le,customSortPanelItemRemove:ke,customSortPanelItemColumnInput:He,customSortPanelItemColumnInputDropdown:Ue,customSortPanelItemColumnInputText:Ae,customSortPanelItemOrderRadio:$e,customSortPanelItemOrderRadioCn:Be,conditionList:je,embedSortBtnContainer:We,embedSortBtn:Fe,embedSortBtnAsc:Ve,embedSortBtnDesc:ze,embedSortBtnIcon:Ze,customSortColMenu:Ge,customSortColMenuItem:qe,customSortColMenuItemDesc:Xe},Ye=e=>{const[t,n]=o.useState("0"),r=i.useDependency(i.LocaleService);return o.createElement("div",{className:l.extendConfirmContent},o.createElement("div",{className:"extend-confirm-desc"},r.t("sheets-sort.dialog.sort-reminder-desc")),o.createElement(R.RadioGroup,{className:l.extendConfirmRadioGroup,value:t,direction:"vertical",onChange:s=>{n(s),e.onChange(s)}},o.createElement(R.Radio,{value:"0"},r.t("sheets-sort.dialog.sort-reminder-no")),o.createElement(R.Radio,{value:"1"},r.t("sheets-sort.dialog.sort-reminder-ext"))))};var Ke=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(e,t,n,r)=>{for(var s=r>1?void 0:r?Je(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&Ke(t,n,s),s},b=(e,t)=>(n,r)=>t(n,r,e);const U={MERGE_ERROR:"sheets-sort.error.merge-size",EMPTY_ERROR:"sheets-sort.error.empty",SINGLE_ERROR:"sheets-sort.error.single",FORMULA_ARRAY:"sheets-sort.error.formula-array"};let f=class extends i.Disposable{constructor(t,n,r,s,a,c,u){super();B(this,"_customSortState$",new ae.BehaviorSubject(null));B(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=t,this._confirmService=n,this._logService=r,this._selectionManagerService=s,this._sheetsSortService=a,this._localeService=c,this._commandService=u}async triggerSortDirectly(t,n,r){const s=r||await this._detectSortLocation(n);if(!s||!this._check(s))return!1;const c={orderRules:[{type:t?M.SortType.ASC:M.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(c,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const t=await this._detectSortLocation();return!t||!this._check(t)?!1:(this.showCustomSortPanel(t),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(t){var C,m;const n=(C=this.customSortState())==null?void 0:C.location;if(!n)return[];const{unitId:r,subUnitId:s,range:a}=n,c=(m=this._univerInstanceService.getUnit(r))==null?void 0:m.getSheetBySheetId(s);if(!c)return[];const u=et(this._localeService);return Array.from({length:a.endColumn-a.startColumn+1},(p,I)=>{var v;const P=(v=c.getCell(a.startRow,I+a.startColumn))==null?void 0:v.v;return{index:I+a.startColumn,label:t?`${P!=null?P:u(I+a.startColumn)}`:u(I+a.startColumn)}})}setSelection(t,n,r){var c;const s=(c=this._univerInstanceService.getUnit(t))==null?void 0:c.getSheetBySheetId(n);if(!s)return;const a={unitId:t,subUnitId:n,selections:[{range:r,primary:d.getPrimaryForRange(r,s),style:null}]};this._commandService.executeCommand(d.SetSelectionsOperation.id,a)}async showCheckError(t){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:o.createElement("div",null,this._localeService.t(t))}})}async showExtendConfirm(){let t=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:o.createElement(Ye,{onChange:r=>{t=r==="1"}})},width:400})?t?"extend":"keep":"cancel"}showCustomSortPanel(t){this._customSortState$.next({location:t,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(t){return this._sheetsSortService.singleCheck(t)?this._sheetsSortService.mergeCheck(t)?this._sheetsSortService.formulaCheck(t)?this._sheetsSortService.emptyCheck(t)?!0:(this.showCheckError(U.EMPTY_ERROR),!1):(this.showCheckError(U.FORMULA_ARRAY),!1):(this.showCheckError(U.MERGE_ERROR),!1):(this.showCheckError(U.SINGLE_ERROR),!1)}async _detectSortLocation(t){var m;const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),s=n.getUnitId(),a=r.getSheetId(),c=this._selectionManagerService.getCurrentLastSelection();if(!c)return null;let u;if(t===!0)u=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,a,u);else if(t===!1)u=c.range;else{const p=await this.showExtendConfirm();if(p==="cancel")return null;p==="keep"?u=c.range:(u=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,a,u))}const C=(m=this._selectionManagerService.getCurrentLastSelection())==null?void 0:m.primary;return C?{range:u,unitId:s,subUnitId:a,colIndex:C.actualColumn}:null}};f=Qe([i.OnLifecycle(i.LifecycleStages.Ready,M.SheetsSortService),b(0,i.IUniverInstanceService),b(1,S.IConfirmService),b(2,i.ILogService),b(3,i.Inject(d.SheetsSelectionsService)),b(4,i.Inject(M.SheetsSortService)),b(5,i.Inject(i.LocaleService)),b(6,i.ICommandService)],f);function et(e){return t=>{const n=i.Tools.chatAtABC(t);switch(e.getCurrentLocale()){case i.LocaleType.ZH_CN:return`"${n}"列`;case i.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}var y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},y.apply(this,arguments)},tt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n},T=o.forwardRef(function(e,t){var n=e.icon,r=e.id,s=e.className,a=e.extend,c=tt(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),C=o.useRef("_".concat(ot()));return ce(n,"".concat(r),{defIds:n.defIds,idSuffix:C.current},y({ref:t,className:u},c),a)});function ce(e,t,n,r,s){return o.createElement(e.tag,y(y({key:t},nt(e,n,s)),r),(rt(e,n).children||[]).map(function(a,c){return ce(a,"".concat(t,"-").concat(e.tag,"-").concat(c),n,void 0,s)}))}function nt(e,t,n){var r=y({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=t.defIds;return!s||s.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(a){var c=a[0],u=a[1];typeof u=="string"&&(r[c]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function rt(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?y(y({},e),{children:e.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?y(y({},s),{attrs:y(y({},s.attrs),{id:s.attrs.id+t.idSuffix})}):s})}):e}function ot(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var st={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 14.4667C12.4208 14.798 12.1522 15.0667 11.8208 15.0667C11.4895 15.0667 11.2208 14.798 11.2208 14.4667V2.98193L9.97861 4.22417C9.7443 4.45848 9.3644 4.45848 9.13008 4.22417C8.89577 3.98985 8.89577 3.60995 9.13008 3.37564L11.3967 1.10897C11.6311 0.874657 12.011 0.874657 12.2453 1.10897L14.5119 3.37564C14.7463 3.60995 14.7463 3.98985 14.5119 4.22417C14.2776 4.45848 13.8977 4.45848 13.6634 4.22417L12.4208 2.9816V14.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},W=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"ascending- single",ref:t,icon:st}))});W.displayName="AscendingSingle";var it={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},le=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"check-mark-single",ref:t,icon:it}))});le.displayName="CheckMarkSingle";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.77445 9.24306L9.77457 11.9573C9.77458 12.2887 9.50597 12.5574 9.17459 12.5574 8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507 9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661 11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306zM6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512 7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574 6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588 4.88808 9.55156 5.26798 9.55156 5.50229 9.78588L6.22584 10.5094z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.14014 3.73989C1.14014 2.30396 2.3042 1.13989 3.74014 1.13989H12.2601C13.6961 1.13989 14.8601 2.30395 14.8601 3.73989V12.2599C14.8601 13.6958 13.6961 14.8599 12.2601 14.8599H3.74014C2.3042 14.8599 1.14014 13.6958 1.14014 12.2599V3.73989ZM2.34014 5.86724V12.2599C2.34014 13.0331 2.96694 13.6599 3.74014 13.6599H12.2601C13.0333 13.6599 13.6601 13.0331 13.6601 12.2599V5.86724H2.34014ZM13.6601 4.66724H2.34014V3.73989C2.34014 2.9667 2.96694 2.33989 3.74014 2.33989H12.2601C13.0333 2.33989 13.6601 2.96669 13.6601 3.73989V4.66724Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"custom-sort-single",ref:t,icon:at}))});ue.displayName="CustomSortSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V13.1332C3.15332 14.2377 4.04875 15.1332 5.15332 15.1332H10.8465C11.9511 15.1332 12.8465 14.2377 12.8465 13.1331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V13.1331C11.6465 13.575 11.2884 13.9331 10.8465 13.9331H5.15332C4.71149 13.9331 4.35332 13.575 4.35332 13.1332V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"delete-empty-single",ref:t,icon:ct}))});de.displayName="DeleteEmptySingle";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 1.53335C12.4208 1.20198 12.1522 0.93335 11.8208 0.93335C11.4895 0.93335 11.2208 1.20198 11.2208 1.53335V13.0181L9.97861 11.7758C9.7443 11.5415 9.3644 11.5415 9.13008 11.7758C8.89577 12.0101 8.89577 12.39 9.13008 12.6244L11.3967 14.891C11.6311 15.1253 12.011 15.1253 12.2453 14.891L14.5119 12.6244C14.7463 12.39 14.7463 12.0101 14.5119 11.7758C14.2776 11.5415 13.8977 11.5415 13.6634 11.7758L12.4208 13.0184V1.53335Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},F=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"descending-single",ref:t,icon:lt}))});F.displayName="DescendingSingle";var ut={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 3.20024C1.57503 3.20024 1.3064 2.93161 1.3064 2.60024C1.3064 2.26887 1.57503 2.00024 1.9064 2.00024H4.57306C4.90443 2.00024 5.17306 2.26887 5.17306 2.60024C5.17306 2.93161 4.90443 3.20024 4.57306 3.20024H1.9064ZM1.3064 6.19985C1.3064 6.53122 1.57503 6.79985 1.9064 6.79985H5.9064C6.23777 6.79985 6.5064 6.53122 6.5064 6.19985C6.5064 5.86848 6.23777 5.59985 5.9064 5.59985H1.9064C1.57503 5.59985 1.3064 5.86848 1.3064 6.19985ZM1.9064 10.3997C1.57503 10.3997 1.3064 10.1311 1.3064 9.79971C1.3064 9.46834 1.57503 9.19971 1.9064 9.19971H7.23973C7.5711 9.19971 7.83973 9.46834 7.83973 9.79971C7.83973 10.1311 7.5711 10.3997 7.23973 10.3997H1.9064ZM1.9064 13.9996C1.57503 13.9996 1.3064 13.7309 1.3064 13.3996C1.3064 13.0682 1.57503 12.7996 1.9064 12.7996H8.57306C8.90443 12.7996 9.17306 13.0682 9.17306 13.3996C9.17306 13.7309 8.90443 13.9996 8.57306 13.9996H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 14.2667C12.4267 14.5981 12.1581 14.8667 11.8267 14.8667C11.4953 14.8667 11.2267 14.5981 11.2267 14.2667V3.18198L9.98447 4.42422C9.75015 4.65853 9.37026 4.65853 9.13594 4.42422C8.90163 4.1899 8.90163 3.81 9.13594 3.57569L11.4026 1.30902C11.6369 1.07471 12.0168 1.07471 12.2511 1.30902L14.5178 3.57569C14.7521 3.81 14.7521 4.1899 14.5178 4.42422C14.2835 4.65853 13.9036 4.65853 13.6693 4.42422L12.4267 3.18165V14.2667Z"}}]},me=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"expand-ascending-single",ref:t,icon:ut}))});me.displayName="ExpandAscendingSingle";var dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 12.7998C1.57503 12.7998 1.3064 13.0684 1.3064 13.3998C1.3064 13.7311 1.57503 13.9998 1.9064 13.9998H4.57306C4.90443 13.9998 5.17306 13.7311 5.17306 13.3998C5.17306 13.0684 4.90443 12.7998 4.57306 12.7998H1.9064ZM1.3064 9.80015C1.3064 9.46878 1.57503 9.20015 1.9064 9.20015H5.9064C6.23777 9.20015 6.5064 9.46878 6.5064 9.80015C6.5064 10.1315 6.23777 10.4001 5.9064 10.4001H1.9064C1.57503 10.4001 1.3064 10.1315 1.3064 9.80015ZM1.9064 5.60029C1.57503 5.60029 1.3064 5.86892 1.3064 6.20029C1.3064 6.53166 1.57503 6.80029 1.9064 6.80029H7.23973C7.5711 6.80029 7.83973 6.53166 7.83973 6.20029C7.83973 5.86892 7.5711 5.60029 7.23973 5.60029H1.9064ZM1.9064 2.00044C1.57503 2.00044 1.3064 2.26907 1.3064 2.60044C1.3064 2.93181 1.57503 3.20044 1.9064 3.20044H8.57306C8.90443 3.20044 9.17306 2.93181 9.17306 2.60044C9.17306 2.26907 8.90443 2.00044 8.57306 2.00044H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 1.7333C12.4267 1.40193 12.1581 1.1333 11.8267 1.1333C11.4953 1.1333 11.2267 1.40193 11.2267 1.7333V12.818L9.98447 11.5758C9.75015 11.3415 9.37026 11.3415 9.13594 11.5758C8.90163 11.8101 8.90163 12.19 9.13594 12.4243L11.4026 14.691C11.6369 14.9253 12.0168 14.9253 12.2511 14.691L14.5178 12.4243C14.7521 12.19 14.7521 11.8101 14.5178 11.5758C14.2835 11.3415 13.9036 11.3415 13.6693 11.5758L12.4267 12.8183V1.7333Z"}}]},Se=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"expand-descending-single",ref:t,icon:dt}))});Se.displayName="ExpandDescendingSingle";var mt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},j=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"increase-single",ref:t,icon:mt}))});j.displayName="IncreaseSingle";var St={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ge=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"more-down-single",ref:t,icon:St}))});ge.displayName="MoreDownSingle";var gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Ce=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"sequence-single",ref:t,icon:gt}))});Ce.displayName="SequenceSingle";const V={id:"sheet.command.sort-range-asc",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!1)},z={id:"sheet.command.sort-range-asc-ext",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!0)},Z={id:"sheet.command.sort-range-desc",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!1)},G={id:"sheet.command.sort-range-desc-ext",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!0)},q={id:"sheet.command.sort-range-custom",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortCustomize()},X={id:"sheet.command.sort-range-asc-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!1)},Y={id:"sheet.command.sort-range-asc-ext-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!0)},K={id:"sheet.command.sort-range-desc-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!1)},J={id:"sheet.command.sort-range-desc-ext-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!0)},Q={id:"sheet.command.sort-range-custom-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortCustomize()};function Ct(){const e=i.useDependency(f),t=i.useDependency(M.SheetsSortService),n=i.useDependency(i.LocaleService),[r,s]=o.useState(!1),[a,c]=o.useState(0),u=o.useRef(null),C=e.customSortState();if(!C||!C.location)return null;const{range:m,unitId:p,subUnitId:I}=C.location,P=e.getTitles(r),[v,N]=o.useState([{type:M.SortType.ASC,colIndex:m.startColumn}]),A=o.useCallback((g,E)=>{const D=[...v];E===null?D.splice(g,1):D[g]=E,N(D)},[v]),H=o.useCallback(i.throttle(()=>{const g=[...v],E=ft(m,v);E!==null&&(g.push({type:M.SortType.ASC,colIndex:E}),N(g))},200),[v,m]),h=o.useCallback((g,E)=>{t.applySort({range:m,orderRules:g,hasTitle:E}),e.closeCustomSortPanel()},[t,e,m]),$=o.useCallback(()=>{e.closeCustomSortPanel()},[e]),pe=o.useCallback(g=>{s(g),g?e.setSelection(p,I,{...m,startRow:m.startRow+1}):e.setSelection(p,I,m)},[e,m,I,p]);o.useEffect(()=>{u.current&&v.length>5&&(u.current.scrollTop=u.current.scrollHeight)},[v]);const ve=v.length<P.length,oe=v.map(g=>({...g,id:`${g.colIndex}`}));return o.createElement("div",{className:l.customSortPanelContainer},o.createElement("div",{className:l.customSortPanelContent,onMouseDown:g=>{g.stopPropagation()}},o.createElement("div",{className:l.customSortPanelExt},o.createElement("div",{className:l.firstRowCheck},o.createElement(R.Checkbox,{checked:r,onChange:g=>pe(!!g)},n.t("sheets-sort.dialog.first-row-check"))),ve?o.createElement("div",{className:l.addCondition,onClick:H},o.createElement(j,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition"))):o.createElement("div",{className:`${l.addCondition} ${l.addConditionDisable}`},o.createElement(j,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition")))),o.createElement("div",{className:l.conditionList,onScroll:g=>{const E=g.currentTarget.scrollTop;c(E)},ref:u},o.createElement(R.DraggableList,{list:oe,onListChange:N,idKey:"id",draggableHandle:`.${l.customSortPanelItemHandler}`,itemRender:g=>o.createElement(ht,{titles:P,list:oe,item:g,onChange:(E,D)=>A(D,E),scrollPosition:a}),rowHeight:32,margin:[0,12]}))),o.createElement("div",{className:l.customSortPanelFooter},o.createElement(R.Button,{className:l.customSortPanelFooterBtn,type:"default",onClick:()=>$()},n.t("sheets-sort.dialog.cancel")),o.createElement(R.Button,{className:l.customSortPanelFooterBtn,type:"primary",onClick:()=>h(v,r)},n.t("sheets-sort.dialog.confirm"))))}function ht(e){var H;const{list:t,item:n,titles:r,onChange:s,scrollPosition:a}=e,c=i.useDependency(i.LocaleService),u=r.filter(h=>!t.some($=>$.colIndex===h.index)||h.index===n.colIndex),C=t.findIndex(h=>h.colIndex===n.colIndex),m=o.useCallback(h=>{s({...n,colIndex:h.index},C),I(!1)},[C,n,s]),[p,I]=o.useState(!1),P=h=>{I(h)};o.useEffect(()=>{I(!1)},[a]);const v=t.length>1,N=(H=r.find(h=>h.index===n.colIndex))==null?void 0:H.label,A=c.getCurrentLocale()===i.LocaleType.ZH_CN?l.customSortPanelItemOrderRadioCn:l.customSortPanelItemOrderRadio;return o.createElement("div",{className:l.customSortPanelItem},o.createElement("div",{className:l.customSortPanelItemHead},o.createElement("div",{className:l.customSortPanelItemHandler},o.createElement(Ce,null)),o.createElement("div",{className:l.customSortPanelItemColumn},o.createElement(R.Dropdown,{placement:"bottomLeft",trigger:["click"],visible:p,onVisibleChange:P,overlay:o.createElement("ul",{className:l.customSortColMenu},u.map(h=>o.createElement("li",{key:h.index,onClick:()=>m(h),className:l.customSortColMenuItem},o.createElement("span",{className:l.customSortColMenuItemDesc},h.label),o.createElement("span",{className:l.customSortColMenuItemCheck},h.index===n.colIndex&&o.createElement(le,null)))))},o.createElement("div",{className:l.customSortPanelItemColumnInput},o.createElement("span",{className:l.customSortPanelItemColumnInputText},N),o.createElement(ge,{className:l.customSortPanelItemColumnInputDropdown}))))),o.createElement("div",{className:l.customSortPanelItemOrder},o.createElement(R.RadioGroup,{className:A,value:n.type,onChange:h=>{s({...n,type:h},C)}},o.createElement(R.Radio,{value:M.SortType.ASC},c.t("sheets-sort.general.sort-asc")),o.createElement(R.Radio,{value:M.SortType.DESC},c.t("sheets-sort.general.sort-desc")))),o.createElement("div",{className:l.customSortPanelItemRemove},v&&o.createElement(de,{onClick:()=>s(null,C)})))}function ft(e,t){const{startColumn:n,endColumn:r}=e,s=new Set(t.map(a=>a==null?void 0:a.colIndex));for(let a=n;a<=r;a++)if(!s.has(a))return a;return null}function pt(e){const{range:t,colIndex:n,onClose:r}=e,s=i.useDependency(f),a=i.useDependency(i.IUniverInstanceService),c=i.useDependency(i.LocaleService),u=o.useCallback(C=>{const{unitId:m,subUnitId:p}=d.getSheetCommandTarget(a)||{};if(t&&m&&p){const I={...t,startRow:t.startRow+1};s.triggerSortDirectly(C,!1,{unitId:m,subUnitId:p,range:I,colIndex:n})}else console.warn(`Cannot find the target to sort. unitId: ${m}, subUnitId: ${p}, range: ${t}, colIndex: ${n}`);r()},[t,n,s,a,r]);return o.createElement("div",{className:l.embedSortBtnContainer},o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnAsc}`,onClick:()=>u(!0)},o.createElement(W,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-asc")),o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnDesc}`,onClick:()=>u(!1)},o.createElement(F,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-desc")))}const O="sheet.menu.sheets-sort",w="sheet.menu.sheets-sort-ctx",k="AscendingSingle",ee="ExpandAscendingSingle",te="DescendingSingle",ne="ExpandDescendingSingle",re="CustomSortSingle";function vt(e){return{id:O,type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.TOOLBAR_START],group:S.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:k,tooltip:"sheets-sort.general.sort",hidden$:S.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function It(e){return{id:V.id,icon:k,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,positions:[O]}}function yt(e){return{id:z.id,title:"sheets-sort.general.sort-asc-ext",icon:ee,type:S.MenuItemType.BUTTON,positions:[O]}}function _t(e){return{id:Z.id,title:"sheets-sort.general.sort-desc-cur",icon:te,type:S.MenuItemType.BUTTON,positions:[O]}}function Et(e){return{id:G.id,title:"sheets-sort.general.sort-desc-ext",icon:ne,type:S.MenuItemType.BUTTON,positions:[O]}}function Rt(e){return{id:q.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[O],icon:re}}function Mt(e){return{id:w,title:"sheets-sort.general.sort",type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.CONTEXT_MENU,_.SheetMenuPosition.COL_HEADER_CONTEXT_MENU,_.SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],group:S.MenuGroup.CONTEXT_MENU_DATA,icon:k}}function Tt(e){return{id:X.id,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,icon:k,positions:[w],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function xt(e){return{id:Y.id,title:"sheets-sort.general.sort-asc-ext",type:S.MenuItemType.BUTTON,icon:ee,positions:[w],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Pt(e){return{id:K.id,title:"sheets-sort.general.sort-desc-cur",type:S.MenuItemType.BUTTON,positions:[w],icon:te,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function bt(e){return{id:J.id,title:"sheets-sort.general.sort-desc-ext",type:S.MenuItemType.BUTTON,positions:[w],icon:ne,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Ot(e){return{id:Q.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[w],icon:re,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}var wt=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Dt=(e,t,n,r)=>{for(var s=r>1?void 0:r?Nt(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&wt(t,n,s),s},x=(e,t)=>(n,r)=>t(n,r,e);const Lt={menu:{}},se="custom-sort-dialog",kt=560;let L=class extends i.RxDisposable{constructor(e,t,n,r,s,a,c,u,C,m,p){super(),this._config=e,this._commandService=t,this._menuService=n,this._dialogService=r,this._layoutService=s,this._uiPartsService=a,this._sheetRenderService=c,this._localeService=u,this._sheetsSortUIService=C,this._injector=m,this._componentManager=p,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){const{menu:e={}}=this._config;[vt,It,_t,yt,Et,Rt,Mt,Tt,Pt,xt,bt,Ot].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),e))})}_initCommands(){[V,z,Z,G,q,X,Y,K,J,Q].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(M.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._componentManager.register("CustomSortPanel",Ct)),this.disposeWithMe(this._uiPartsService.registerComponent(_.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>i.connectInjector(pt,this._injector))),this.disposeWithMe(this._componentManager.register(k,W)),this.disposeWithMe(this._componentManager.register(ee,me)),this.disposeWithMe(this._componentManager.register(te,F)),this.disposeWithMe(this._componentManager.register(ne,Se)),this.disposeWithMe(this._componentManager.register(re,ue)),this._sheetsSortUIService.customSortState$.pipe(ae.takeUntil(this.dispose$)).subscribe(e=>{e&&e.show&&e.location?this._openCustomSortPanel(e.location):e&&!(e!=null&&e.show)&&this._closePanel()})}_openCustomSortPanel(e){this._dialogService.open({id:se,draggable:!0,width:kt,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${_e.serializeRange(e.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:Ht(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(se),queueMicrotask(()=>this._layoutService.focus())}};L=Dt([i.OnLifecycle(i.LifecycleStages.Ready,L),x(1,i.ICommandService),x(2,S.IMenuService),x(3,S.IDialogService),x(4,S.ILayoutService),x(5,S.IUIPartsService),x(6,i.Inject(_.SheetsRenderService)),x(7,i.Inject(i.LocaleService)),x(8,i.Inject(f)),x(9,i.Inject(i.Injector)),x(10,i.Inject(S.ComponentManager))],L);function Ht(){return{x:0,y:0}}var he=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,At=(e,t,n)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$t=(e,t,n,r)=>{for(var s=r>1?void 0:r?Ut(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&he(t,n,s),s},ie=(e,t)=>(n,r)=>t(n,r,e),fe=(e,t,n)=>At(e,typeof t!="symbol"?t+"":t,n);const Bt="UNIVER_SHEETS_SORT_UI_PLUGIN";exports.UniverSheetsSortUIPlugin=class extends i.Plugin{constructor(t={},n,r){super(),this._config=t,this._injector=n,this._localeService=r,this._config=i.Tools.deepMerge({},Lt,this._config)}onStarting(t){[[f],[L,{useFactory:()=>this._injector.createInstance(L,this._config)}]].forEach(n=>t.add(n))}};fe(exports.UniverSheetsSortUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET);fe(exports.UniverSheetsSortUIPlugin,"pluginName",Bt);exports.UniverSheetsSortUIPlugin=$t([i.DependentOn(M.UniverSheetsSortPlugin),ie(1,i.Inject(i.Injector)),ie(2,i.Inject(i.LocaleService))],exports.UniverSheetsSortUIPlugin);exports.SortRangeAscCommand=V;exports.SortRangeAscExtCommand=z;exports.SortRangeAscExtInCtxMenuCommand=Y;exports.SortRangeAscInCtxMenuCommand=X;exports.SortRangeCustomCommand=q;exports.SortRangeCustomInCtxMenuCommand=Q;exports.SortRangeDescCommand=Z;exports.SortRangeDescExtCommand=G;exports.SortRangeDescExtInCtxMenuCommand=J;exports.SortRangeDescInCtxMenuCommand=K;
1
+ "use strict";var _e=Object.defineProperty;var Ee=(e,t,n)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var W=(e,t,n)=>Ee(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),y=require("@wendellhu/redi"),T=require("@univerjs/sheets-sort"),d=require("@univerjs/sheets"),E=require("@univerjs/sheets-ui"),o=require("react"),S=require("@univerjs/ui"),le=require("rxjs"),M=require("@univerjs/design"),b=require("@wendellhu/redi/react-bindings"),Re=require("@univerjs/engine-formula"),Me="univer-extend-confirm-content",Te="univer-extend-confirm-radio-group",xe="univer-custom-sort-panel-container",Pe="univer-custom-sort-panel-ext",be="univer-add-condition",Oe="univer-add-condition-text",we="univer-add-condition-disable",Ne="univer-custom-sort-panel-footer",De="univer-custom-sort-panel-footer-btn",Le="univer-custom-sort-panel-item",ke="univer-custom-sort-panel-item-head",He="univer-custom-sort-panel-item-handler",Ue="univer-custom-sort-panel-item-remove",Ae="univer-custom-sort-panel-item-column-input",$e="univer-custom-sort-panel-item-column-input-dropdown",Be="univer-custom-sort-panel-item-column-input-text",je="univer-custom-sort-panel-item-order-radio",We="univer-custom-sort-panel-item-order-radio-cn",Fe="univer-condition-list",Ve="univer-embed-sort-btn-container",ze="univer-embed-sort-btn",Ze="univer-embed-sort-btn-asc",qe="univer-embed-sort-btn-desc",Ge="univer-embed-sort-btn-icon",Xe="univer-custom-sort-col-menu",Ye="univer-custom-sort-col-menu-item",Ke="univer-custom-sort-col-menu-item-desc",l={extendConfirmContent:Me,extendConfirmRadioGroup:Te,customSortPanelContainer:xe,customSortPanelExt:Pe,addCondition:be,addConditionText:Oe,addConditionDisable:we,customSortPanelFooter:Ne,customSortPanelFooterBtn:De,customSortPanelItem:Le,customSortPanelItemHead:ke,customSortPanelItemHandler:He,customSortPanelItemRemove:Ue,customSortPanelItemColumnInput:Ae,customSortPanelItemColumnInputDropdown:$e,customSortPanelItemColumnInputText:Be,customSortPanelItemOrderRadio:je,customSortPanelItemOrderRadioCn:We,conditionList:Fe,embedSortBtnContainer:Ve,embedSortBtn:ze,embedSortBtnAsc:Ze,embedSortBtnDesc:qe,embedSortBtnIcon:Ge,customSortColMenu:Xe,customSortColMenuItem:Ye,customSortColMenuItemDesc:Ke},Je=e=>{const[t,n]=o.useState("0"),r=b.useDependency(c.LocaleService);return o.createElement("div",{className:l.extendConfirmContent},o.createElement("div",{className:"extend-confirm-desc"},r.t("sheets-sort.dialog.sort-reminder-desc")),o.createElement(M.RadioGroup,{className:l.extendConfirmRadioGroup,value:t,direction:"vertical",onChange:s=>{n(s),e.onChange(s)}},o.createElement(M.Radio,{value:"0"},r.t("sheets-sort.dialog.sort-reminder-no")),o.createElement(M.Radio,{value:"1"},r.t("sheets-sort.dialog.sort-reminder-ext"))))};var Qe=Object.defineProperty,et=Object.getOwnPropertyDescriptor,tt=(e,t,n,r)=>{for(var s=r>1?void 0:r?et(t,n):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(s=(r?a(t,n,s):a(s))||s);return r&&s&&Qe(t,n,s),s},w=(e,t)=>(n,r)=>t(n,r,e);const $={MERGE_ERROR:"sheets-sort.error.merge-size",EMPTY_ERROR:"sheets-sort.error.empty",SINGLE_ERROR:"sheets-sort.error.single",FORMULA_ARRAY:"sheets-sort.error.formula-array"};let f=class extends c.Disposable{constructor(t,n,r,s,i,a,u){super();W(this,"_customSortState$",new le.BehaviorSubject(null));W(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=t,this._confirmService=n,this._logService=r,this._selectionManagerService=s,this._sheetsSortService=i,this._localeService=a,this._commandService=u}async triggerSortDirectly(t,n,r){const s=r||await this._detectSortLocation(n);if(!s||!this._check(s))return!1;const a={orderRules:[{type:t?T.SortType.ASC:T.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(a,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const t=await this._detectSortLocation();return!t||!this._check(t)?!1:(this.showCustomSortPanel(t),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(t){var C,m;const n=(C=this.customSortState())==null?void 0:C.location;if(!n)return[];const{unitId:r,subUnitId:s,range:i}=n,a=(m=this._univerInstanceService.getUnit(r))==null?void 0:m.getSheetBySheetId(s);if(!a)return[];const u=nt(this._localeService);return Array.from({length:i.endColumn-i.startColumn+1},(p,I)=>{var v;const O=(v=a.getCell(i.startRow,I+i.startColumn))==null?void 0:v.v;return{index:I+i.startColumn,label:t?`${O!=null?O:u(I+i.startColumn)}`:u(I+i.startColumn)}})}setSelection(t,n,r){var a;const s=(a=this._univerInstanceService.getUnit(t))==null?void 0:a.getSheetBySheetId(n);if(!s)return;const i={unitId:t,subUnitId:n,selections:[{range:r,primary:d.getPrimaryForRange(r,s),style:null}]};this._commandService.executeCommand(d.SetSelectionsOperation.id,i)}async showCheckError(t){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:o.createElement("div",null,this._localeService.t(t))}})}async showExtendConfirm(){let t=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:o.createElement(Je,{onChange:r=>{t=r==="1"}})},width:400})?t?"extend":"keep":"cancel"}showCustomSortPanel(t){this._customSortState$.next({location:t,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(t){return this._sheetsSortService.singleCheck(t)?this._sheetsSortService.mergeCheck(t)?this._sheetsSortService.formulaCheck(t)?this._sheetsSortService.emptyCheck(t)?!0:(this.showCheckError($.EMPTY_ERROR),!1):(this.showCheckError($.FORMULA_ARRAY),!1):(this.showCheckError($.MERGE_ERROR),!1):(this.showCheckError($.SINGLE_ERROR),!1)}async _detectSortLocation(t){var m;const n=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),s=n.getUnitId(),i=r.getSheetId(),a=this._selectionManagerService.getCurrentLastSelection();if(!a)return null;let u;if(t===!0)u=E.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,i,u);else if(t===!1)u=a.range;else{const p=await this.showExtendConfirm();if(p==="cancel")return null;p==="keep"?u=a.range:(u=E.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,i,u))}const C=(m=this._selectionManagerService.getCurrentLastSelection())==null?void 0:m.primary;return C?{range:u,unitId:s,subUnitId:i,colIndex:C.actualColumn}:null}};f=tt([c.OnLifecycle(c.LifecycleStages.Ready,T.SheetsSortService),w(0,c.IUniverInstanceService),w(1,S.IConfirmService),w(2,c.ILogService),w(3,y.Inject(d.SheetsSelectionsService)),w(4,y.Inject(T.SheetsSortService)),w(5,y.Inject(c.LocaleService)),w(6,c.ICommandService)],f);function nt(e){return t=>{const n=c.Tools.chatAtABC(t);switch(e.getCurrentLocale()){case c.LocaleType.ZH_CN:return`"${n}"列`;case c.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},_.apply(this,arguments)},rt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n},x=o.forwardRef(function(e,t){var n=e.icon,r=e.id,s=e.className,i=e.extend,a=rt(e,["icon","id","className","extend"]),u="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),C=o.useRef("_".concat(it()));return ue(n,"".concat(r),{defIds:n.defIds,idSuffix:C.current},_({ref:t,className:u},a),i)});function ue(e,t,n,r,s){return o.createElement(e.tag,_(_({key:t},ot(e,n,s)),r),(st(e,n).children||[]).map(function(i,a){return ue(i,"".concat(t,"-").concat(e.tag,"-").concat(a),n,void 0,s)}))}function ot(e,t,n){var r=_({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=t.defIds;return!s||s.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(i){var a=i[0],u=i[1];typeof u=="string"&&(r[a]=u.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function st(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?_(_({},e),{children:e.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?_(_({},s),{attrs:_(_({},s.attrs),{id:s.attrs.id+t.idSuffix})}):s})}):e}function it(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var at={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 14.4667C12.4208 14.798 12.1522 15.0667 11.8208 15.0667C11.4895 15.0667 11.2208 14.798 11.2208 14.4667V2.98193L9.97861 4.22417C9.7443 4.45848 9.3644 4.45848 9.13008 4.22417C8.89577 3.98985 8.89577 3.60995 9.13008 3.37564L11.3967 1.10897C11.6311 0.874657 12.011 0.874657 12.2453 1.10897L14.5119 3.37564C14.7463 3.60995 14.7463 3.98985 14.5119 4.22417C14.2776 4.45848 13.8977 4.45848 13.6634 4.22417L12.4208 2.9816V14.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},V=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"ascending- single",ref:t,icon:at}))});V.displayName="AscendingSingle";var ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},de=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"check-mark-single",ref:t,icon:ct}))});de.displayName="CheckMarkSingle";var lt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.77445 9.24306L9.77457 11.9573C9.77458 12.2887 9.50597 12.5574 9.17459 12.5574 8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507 9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661 11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306zM6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512 7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574 6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588 4.88808 9.55156 5.26798 9.55156 5.50229 9.78588L6.22584 10.5094z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.14014 3.73989C1.14014 2.30396 2.3042 1.13989 3.74014 1.13989H12.2601C13.6961 1.13989 14.8601 2.30395 14.8601 3.73989V12.2599C14.8601 13.6958 13.6961 14.8599 12.2601 14.8599H3.74014C2.3042 14.8599 1.14014 13.6958 1.14014 12.2599V3.73989ZM2.34014 5.86724V12.2599C2.34014 13.0331 2.96694 13.6599 3.74014 13.6599H12.2601C13.0333 13.6599 13.6601 13.0331 13.6601 12.2599V5.86724H2.34014ZM13.6601 4.66724H2.34014V3.73989C2.34014 2.9667 2.96694 2.33989 3.74014 2.33989H12.2601C13.0333 2.33989 13.6601 2.96669 13.6601 3.73989V4.66724Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"custom-sort-single",ref:t,icon:lt}))});me.displayName="CustomSortSingle";var ut={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V13.1332C3.15332 14.2377 4.04875 15.1332 5.15332 15.1332H10.8465C11.9511 15.1332 12.8465 14.2377 12.8465 13.1331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V13.1331C11.6465 13.575 11.2884 13.9331 10.8465 13.9331H5.15332C4.71149 13.9331 4.35332 13.575 4.35332 13.1332V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Se=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"delete-empty-single",ref:t,icon:ut}))});Se.displayName="DeleteEmptySingle";var dt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 1.53335C12.4208 1.20198 12.1522 0.93335 11.8208 0.93335C11.4895 0.93335 11.2208 1.20198 11.2208 1.53335V13.0181L9.97861 11.7758C9.7443 11.5415 9.3644 11.5415 9.13008 11.7758C8.89577 12.0101 8.89577 12.39 9.13008 12.6244L11.3967 14.891C11.6311 15.1253 12.011 15.1253 12.2453 14.891L14.5119 12.6244C14.7463 12.39 14.7463 12.0101 14.5119 11.7758C14.2776 11.5415 13.8977 11.5415 13.6634 11.7758L12.4208 13.0184V1.53335Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},z=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"descending-single",ref:t,icon:dt}))});z.displayName="DescendingSingle";var mt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 3.20024C1.57503 3.20024 1.3064 2.93161 1.3064 2.60024C1.3064 2.26887 1.57503 2.00024 1.9064 2.00024H4.57306C4.90443 2.00024 5.17306 2.26887 5.17306 2.60024C5.17306 2.93161 4.90443 3.20024 4.57306 3.20024H1.9064ZM1.3064 6.19985C1.3064 6.53122 1.57503 6.79985 1.9064 6.79985H5.9064C6.23777 6.79985 6.5064 6.53122 6.5064 6.19985C6.5064 5.86848 6.23777 5.59985 5.9064 5.59985H1.9064C1.57503 5.59985 1.3064 5.86848 1.3064 6.19985ZM1.9064 10.3997C1.57503 10.3997 1.3064 10.1311 1.3064 9.79971C1.3064 9.46834 1.57503 9.19971 1.9064 9.19971H7.23973C7.5711 9.19971 7.83973 9.46834 7.83973 9.79971C7.83973 10.1311 7.5711 10.3997 7.23973 10.3997H1.9064ZM1.9064 13.9996C1.57503 13.9996 1.3064 13.7309 1.3064 13.3996C1.3064 13.0682 1.57503 12.7996 1.9064 12.7996H8.57306C8.90443 12.7996 9.17306 13.0682 9.17306 13.3996C9.17306 13.7309 8.90443 13.9996 8.57306 13.9996H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 14.2667C12.4267 14.5981 12.1581 14.8667 11.8267 14.8667C11.4953 14.8667 11.2267 14.5981 11.2267 14.2667V3.18198L9.98447 4.42422C9.75015 4.65853 9.37026 4.65853 9.13594 4.42422C8.90163 4.1899 8.90163 3.81 9.13594 3.57569L11.4026 1.30902C11.6369 1.07471 12.0168 1.07471 12.2511 1.30902L14.5178 3.57569C14.7521 3.81 14.7521 4.1899 14.5178 4.42422C14.2835 4.65853 13.9036 4.65853 13.6693 4.42422L12.4267 3.18165V14.2667Z"}}]},ge=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"expand-ascending-single",ref:t,icon:mt}))});ge.displayName="ExpandAscendingSingle";var St={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 12.7998C1.57503 12.7998 1.3064 13.0684 1.3064 13.3998C1.3064 13.7311 1.57503 13.9998 1.9064 13.9998H4.57306C4.90443 13.9998 5.17306 13.7311 5.17306 13.3998C5.17306 13.0684 4.90443 12.7998 4.57306 12.7998H1.9064ZM1.3064 9.80015C1.3064 9.46878 1.57503 9.20015 1.9064 9.20015H5.9064C6.23777 9.20015 6.5064 9.46878 6.5064 9.80015C6.5064 10.1315 6.23777 10.4001 5.9064 10.4001H1.9064C1.57503 10.4001 1.3064 10.1315 1.3064 9.80015ZM1.9064 5.60029C1.57503 5.60029 1.3064 5.86892 1.3064 6.20029C1.3064 6.53166 1.57503 6.80029 1.9064 6.80029H7.23973C7.5711 6.80029 7.83973 6.53166 7.83973 6.20029C7.83973 5.86892 7.5711 5.60029 7.23973 5.60029H1.9064ZM1.9064 2.00044C1.57503 2.00044 1.3064 2.26907 1.3064 2.60044C1.3064 2.93181 1.57503 3.20044 1.9064 3.20044H8.57306C8.90443 3.20044 9.17306 2.93181 9.17306 2.60044C9.17306 2.26907 8.90443 2.00044 8.57306 2.00044H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 1.7333C12.4267 1.40193 12.1581 1.1333 11.8267 1.1333C11.4953 1.1333 11.2267 1.40193 11.2267 1.7333V12.818L9.98447 11.5758C9.75015 11.3415 9.37026 11.3415 9.13594 11.5758C8.90163 11.8101 8.90163 12.19 9.13594 12.4243L11.4026 14.691C11.6369 14.9253 12.0168 14.9253 12.2511 14.691L14.5178 12.4243C14.7521 12.19 14.7521 11.8101 14.5178 11.5758C14.2835 11.3415 13.9036 11.3415 13.6693 11.5758L12.4267 12.8183V1.7333Z"}}]},Ce=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"expand-descending-single",ref:t,icon:St}))});Ce.displayName="ExpandDescendingSingle";var gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},F=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"increase-single",ref:t,icon:gt}))});F.displayName="IncreaseSingle";var Ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},he=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"more-down-single",ref:t,icon:Ct}))});he.displayName="MoreDownSingle";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},fe=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"sequence-single",ref:t,icon:ht}))});fe.displayName="SequenceSingle";const Z={id:"sheet.command.sort-range-asc",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!1)},q={id:"sheet.command.sort-range-asc-ext",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!0)},G={id:"sheet.command.sort-range-desc",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!1)},X={id:"sheet.command.sort-range-desc-ext",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!0)},Y={id:"sheet.command.sort-range-custom",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortCustomize()},K={id:"sheet.command.sort-range-asc-ctx",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!1)},J={id:"sheet.command.sort-range-asc-ext-ctx",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!0,!0)},Q={id:"sheet.command.sort-range-desc-ctx",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!1)},ee={id:"sheet.command.sort-range-desc-ext-ctx",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortDirectly(!1,!0)},te={id:"sheet.command.sort-range-custom-ctx",type:c.CommandType.COMMAND,handler:async e=>await e.get(f).triggerSortCustomize()};function ft(){const e=b.useDependency(f),t=b.useDependency(T.SheetsSortService),n=b.useDependency(c.LocaleService),[r,s]=o.useState(!1),[i,a]=o.useState(0),u=o.useRef(null),C=e.customSortState();if(!C||!C.location)return null;const{range:m,unitId:p,subUnitId:I}=C.location,O=e.getTitles(r),[v,L]=o.useState([{type:T.SortType.ASC,colIndex:m.startColumn}]),B=o.useCallback((g,R)=>{const k=[...v];R===null?k.splice(g,1):k[g]=R,L(k)},[v]),A=o.useCallback(c.throttle(()=>{const g=[...v],R=vt(m,v);R!==null&&(g.push({type:T.SortType.ASC,colIndex:R}),L(g))},200),[v,m]),h=o.useCallback((g,R)=>{t.applySort({range:m,orderRules:g,hasTitle:R}),e.closeCustomSortPanel()},[t,e,m]),j=o.useCallback(()=>{e.closeCustomSortPanel()},[e]),Ie=o.useCallback(g=>{s(g),g?e.setSelection(p,I,{...m,startRow:m.startRow+1}):e.setSelection(p,I,m)},[e,m,I,p]);o.useEffect(()=>{u.current&&v.length>5&&(u.current.scrollTop=u.current.scrollHeight)},[v]);const ye=v.length<O.length,ie=v.map(g=>({...g,id:`${g.colIndex}`}));return o.createElement("div",{className:l.customSortPanelContainer},o.createElement("div",{className:l.customSortPanelContent,onMouseDown:g=>{g.stopPropagation()}},o.createElement("div",{className:l.customSortPanelExt},o.createElement("div",{className:l.firstRowCheck},o.createElement(M.Checkbox,{checked:r,onChange:g=>Ie(!!g)},n.t("sheets-sort.dialog.first-row-check"))),ye?o.createElement("div",{className:l.addCondition,onClick:A},o.createElement(F,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition"))):o.createElement("div",{className:`${l.addCondition} ${l.addConditionDisable}`},o.createElement(F,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition")))),o.createElement("div",{className:l.conditionList,onScroll:g=>{const R=g.currentTarget.scrollTop;a(R)},ref:u},o.createElement(M.DraggableList,{list:ie,onListChange:L,idKey:"id",draggableHandle:`.${l.customSortPanelItemHandler}`,itemRender:g=>o.createElement(pt,{titles:O,list:ie,item:g,onChange:(R,k)=>B(k,R),scrollPosition:i}),rowHeight:32,margin:[0,12]}))),o.createElement("div",{className:l.customSortPanelFooter},o.createElement(M.Button,{className:l.customSortPanelFooterBtn,type:"default",onClick:()=>j()},n.t("sheets-sort.dialog.cancel")),o.createElement(M.Button,{className:l.customSortPanelFooterBtn,type:"primary",onClick:()=>h(v,r)},n.t("sheets-sort.dialog.confirm"))))}function pt(e){var A;const{list:t,item:n,titles:r,onChange:s,scrollPosition:i}=e,a=b.useDependency(c.LocaleService),u=r.filter(h=>!t.some(j=>j.colIndex===h.index)||h.index===n.colIndex),C=t.findIndex(h=>h.colIndex===n.colIndex),m=o.useCallback(h=>{s({...n,colIndex:h.index},C),I(!1)},[C,n,s]),[p,I]=o.useState(!1),O=h=>{I(h)};o.useEffect(()=>{I(!1)},[i]);const v=t.length>1,L=(A=r.find(h=>h.index===n.colIndex))==null?void 0:A.label,B=a.getCurrentLocale()===c.LocaleType.ZH_CN?l.customSortPanelItemOrderRadioCn:l.customSortPanelItemOrderRadio;return o.createElement("div",{className:l.customSortPanelItem},o.createElement("div",{className:l.customSortPanelItemHead},o.createElement("div",{className:l.customSortPanelItemHandler},o.createElement(fe,null)),o.createElement("div",{className:l.customSortPanelItemColumn},o.createElement(M.Dropdown,{placement:"bottomLeft",trigger:["click"],visible:p,onVisibleChange:O,overlay:o.createElement("ul",{className:l.customSortColMenu},u.map(h=>o.createElement("li",{key:h.index,onClick:()=>m(h),className:l.customSortColMenuItem},o.createElement("span",{className:l.customSortColMenuItemDesc},h.label),o.createElement("span",{className:l.customSortColMenuItemCheck},h.index===n.colIndex&&o.createElement(de,null)))))},o.createElement("div",{className:l.customSortPanelItemColumnInput},o.createElement("span",{className:l.customSortPanelItemColumnInputText},L),o.createElement(he,{className:l.customSortPanelItemColumnInputDropdown}))))),o.createElement("div",{className:l.customSortPanelItemOrder},o.createElement(M.RadioGroup,{className:B,value:n.type,onChange:h=>{s({...n,type:h},C)}},o.createElement(M.Radio,{value:T.SortType.ASC},a.t("sheets-sort.general.sort-asc")),o.createElement(M.Radio,{value:T.SortType.DESC},a.t("sheets-sort.general.sort-desc")))),o.createElement("div",{className:l.customSortPanelItemRemove},v&&o.createElement(Se,{onClick:()=>s(null,C)})))}function vt(e,t){const{startColumn:n,endColumn:r}=e,s=new Set(t.map(i=>i==null?void 0:i.colIndex));for(let i=n;i<=r;i++)if(!s.has(i))return i;return null}function It(e){const{range:t,colIndex:n,onClose:r}=e,s=b.useDependency(f),i=b.useDependency(c.IUniverInstanceService),a=b.useDependency(c.LocaleService),u=o.useCallback(C=>{const{unitId:m,subUnitId:p}=d.getSheetCommandTarget(i)||{};if(t&&m&&p){const I={...t,startRow:t.startRow+1};s.triggerSortDirectly(C,!1,{unitId:m,subUnitId:p,range:I,colIndex:n})}else console.warn(`Cannot find the target to sort. unitId: ${m}, subUnitId: ${p}, range: ${t}, colIndex: ${n}`);r()},[t,n,s,i,r]);return o.createElement("div",{className:l.embedSortBtnContainer},o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnAsc}`,onClick:()=>u(!0)},o.createElement(V,{className:l.embedSortBtnIcon}),a.t("sheets-sort.general.sort-asc")),o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnDesc}`,onClick:()=>u(!1)},o.createElement(z,{className:l.embedSortBtnIcon}),a.t("sheets-sort.general.sort-desc")))}const N="sheet.menu.sheets-sort",D="sheet.menu.sheets-sort-ctx",U="AscendingSingle",ne="ExpandAscendingSingle",re="DescendingSingle",oe="ExpandDescendingSingle",se="CustomSortSingle";function yt(e){return{id:N,type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.TOOLBAR_START],group:S.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:U,tooltip:"sheets-sort.general.sort",hidden$:S.getMenuHiddenObservable(e,c.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function _t(e){return{id:Z.id,icon:U,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,positions:[N]}}function Et(e){return{id:q.id,title:"sheets-sort.general.sort-asc-ext",icon:ne,type:S.MenuItemType.BUTTON,positions:[N]}}function Rt(e){return{id:G.id,title:"sheets-sort.general.sort-desc-cur",icon:re,type:S.MenuItemType.BUTTON,positions:[N]}}function Mt(e){return{id:X.id,title:"sheets-sort.general.sort-desc-ext",icon:oe,type:S.MenuItemType.BUTTON,positions:[N]}}function Tt(e){return{id:Y.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[N],icon:se}}function xt(e){return{id:D,title:"sheets-sort.general.sort",type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.CONTEXT_MENU,E.SheetMenuPosition.COL_HEADER_CONTEXT_MENU,E.SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],group:S.MenuGroup.CONTEXT_MENU_DATA,icon:U}}function Pt(e){return{id:K.id,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,icon:U,positions:[D],disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function bt(e){return{id:J.id,title:"sheets-sort.general.sort-asc-ext",type:S.MenuItemType.BUTTON,icon:ne,positions:[D],disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Ot(e){return{id:Q.id,title:"sheets-sort.general.sort-desc-cur",type:S.MenuItemType.BUTTON,positions:[D],icon:re,disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function wt(e){return{id:ee.id,title:"sheets-sort.general.sort-desc-ext",type:S.MenuItemType.BUTTON,positions:[D],icon:oe,disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Nt(e){return{id:te.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[D],icon:se,disabled$:E.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}var Dt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,kt=(e,t,n,r)=>{for(var s=r>1?void 0:r?Lt(t,n):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(s=(r?a(t,n,s):a(s))||s);return r&&s&&Dt(t,n,s),s},P=(e,t)=>(n,r)=>t(n,r,e);const Ht={menu:{}},ae="custom-sort-dialog",Ut=560;let H=class extends c.RxDisposable{constructor(e,t,n,r,s,i,a,u,C,m,p){super(),this._config=e,this._commandService=t,this._menuService=n,this._dialogService=r,this._layoutService=s,this._uiPartsService=i,this._sheetRenderService=a,this._localeService=u,this._sheetsSortUIService=C,this._injector=m,this._componentManager=p,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){const{menu:e={}}=this._config;[yt,_t,Rt,Et,Mt,Tt,xt,Pt,Ot,bt,wt,Nt].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),e))})}_initCommands(){[Z,q,G,X,Y,K,J,Q,ee,te].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(T.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._componentManager.register("CustomSortPanel",ft)),this.disposeWithMe(this._uiPartsService.registerComponent(E.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>b.connectInjector(It,this._injector))),this.disposeWithMe(this._componentManager.register(U,V)),this.disposeWithMe(this._componentManager.register(ne,ge)),this.disposeWithMe(this._componentManager.register(re,z)),this.disposeWithMe(this._componentManager.register(oe,Ce)),this.disposeWithMe(this._componentManager.register(se,me)),this._sheetsSortUIService.customSortState$.pipe(le.takeUntil(this.dispose$)).subscribe(e=>{e&&e.show&&e.location?this._openCustomSortPanel(e.location):e&&!(e!=null&&e.show)&&this._closePanel()})}_openCustomSortPanel(e){this._dialogService.open({id:ae,draggable:!0,width:Ut,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${Re.serializeRange(e.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:At(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(ae),queueMicrotask(()=>this._layoutService.focus())}};H=kt([c.OnLifecycle(c.LifecycleStages.Ready,H),P(1,c.ICommandService),P(2,S.IMenuService),P(3,S.IDialogService),P(4,S.ILayoutService),P(5,S.IUIPartsService),P(6,y.Inject(E.SheetsRenderService)),P(7,y.Inject(c.LocaleService)),P(8,y.Inject(f)),P(9,y.Inject(y.Injector)),P(10,y.Inject(S.ComponentManager))],H);function At(){return{x:0,y:0}}var pe=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jt=(e,t,n,r)=>{for(var s=r>1?void 0:r?$t(t,n):t,i=e.length-1,a;i>=0;i--)(a=e[i])&&(s=(r?a(t,n,s):a(s))||s);return r&&s&&pe(t,n,s),s},ce=(e,t)=>(n,r)=>t(n,r,e),ve=(e,t,n)=>Bt(e,typeof t!="symbol"?t+"":t,n);const Wt="UNIVER_SHEETS_SORT_UI_PLUGIN";exports.UniverSheetsSortUIPlugin=class extends c.Plugin{constructor(t={},n,r){super(),this._config=t,this._injector=n,this._localeService=r,this._config=c.Tools.deepMerge({},Ht,this._config)}onStarting(t){[[f],[H,{useFactory:()=>this._injector.createInstance(H,this._config)}]].forEach(n=>t.add(n))}};ve(exports.UniverSheetsSortUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);ve(exports.UniverSheetsSortUIPlugin,"pluginName",Wt);exports.UniverSheetsSortUIPlugin=jt([c.DependentOn(T.UniverSheetsSortPlugin),ce(1,y.Inject(y.Injector)),ce(2,y.Inject(c.LocaleService))],exports.UniverSheetsSortUIPlugin);exports.SortRangeAscCommand=Z;exports.SortRangeAscExtCommand=q;exports.SortRangeAscExtInCtxMenuCommand=J;exports.SortRangeAscInCtxMenuCommand=K;exports.SortRangeCustomCommand=Y;exports.SortRangeCustomInCtxMenuCommand=te;exports.SortRangeDescCommand=G;exports.SortRangeDescExtCommand=X;exports.SortRangeDescExtInCtxMenuCommand=ee;exports.SortRangeDescInCtxMenuCommand=Q;
package/lib/es/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  var Ge = Object.defineProperty;
2
2
  var Xe = (e, t, n) => t in e ? Ge(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var K = (e, t, n) => Xe(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { useDependency as O, LocaleService as P, Disposable as qe, UniverInstanceType as te, OnLifecycle as ge, LifecycleStages as Ce, Inject as x, Tools as Se, LocaleType as J, IUniverInstanceService as fe, ILogService as Ye, ICommandService as pe, CommandType as R, throttle as Ke, RxDisposable as Je, connectInjector as Qe, Injector as ve, Plugin as et, DependentOn as tt } from "@univerjs/core";
5
- import { SortType as w, SheetsSortService as Q, SortRangeCommand as nt, UniverSheetsSortPlugin as rt } from "@univerjs/sheets-sort";
6
- import { getPrimaryForRange as ot, SetSelectionsOperation as st, SheetsSelectionsService as it, getSheetCommandTarget as ct, WorkbookEditablePermission as L, WorksheetSortPermission as D, WorksheetEditPermission as H, RangeProtectionPermissionEditPoint as k } from "@univerjs/sheets";
7
- import { expandToContinuousRange as le, getCurrentRangeDisable$ as U, SheetMenuPosition as de, SheetsUIPart as at, SheetsRenderService as lt } from "@univerjs/sheets-ui";
4
+ import { LocaleService as P, Disposable as qe, UniverInstanceType as te, OnLifecycle as ge, LifecycleStages as Ce, Tools as Se, LocaleType as J, IUniverInstanceService as fe, ILogService as Ye, ICommandService as pe, CommandType as R, throttle as Ke, RxDisposable as Je, Plugin as Qe, DependentOn as et } from "@univerjs/core";
5
+ import { Inject as x, Injector as ve } from "@wendellhu/redi";
6
+ import { SortType as w, SheetsSortService as Q, SortRangeCommand as tt, UniverSheetsSortPlugin as nt } from "@univerjs/sheets-sort";
7
+ import { getPrimaryForRange as rt, SetSelectionsOperation as ot, SheetsSelectionsService as st, getSheetCommandTarget as it, WorkbookEditablePermission as L, WorksheetSortPermission as D, WorksheetEditPermission as H, RangeProtectionPermissionEditPoint as k } from "@univerjs/sheets";
8
+ import { expandToContinuousRange as le, getCurrentRangeDisable$ as U, SheetMenuPosition as de, SheetsUIPart as ct, SheetsRenderService as at } from "@univerjs/sheets-ui";
8
9
  import i, { useState as F, forwardRef as E, useRef as _e, createElement as I, useCallback as N, useEffect as Ee } from "react";
9
- import { IConfirmService as dt, MenuItemType as v, MenuPosition as Ie, MenuGroup as ye, getMenuHiddenObservable as ut, ComponentManager as mt, IMenuService as ht, IDialogService as gt, ILayoutService as Ct, IUIPartsService as St } from "@univerjs/ui";
10
- import { BehaviorSubject as ft, takeUntil as pt } from "rxjs";
11
- import { RadioGroup as Me, Radio as G, Checkbox as vt, DraggableList as _t, Button as ue, Dropdown as Et } from "@univerjs/design";
10
+ import { IConfirmService as lt, MenuItemType as v, MenuPosition as Ie, MenuGroup as ye, getMenuHiddenObservable as dt, ComponentManager as ut, IMenuService as mt, IDialogService as ht, ILayoutService as gt, IUIPartsService as Ct } from "@univerjs/ui";
11
+ import { BehaviorSubject as St, takeUntil as ft } from "rxjs";
12
+ import { RadioGroup as Me, Radio as G, Checkbox as pt, DraggableList as vt, Button as ue, Dropdown as _t } from "@univerjs/design";
13
+ import { useDependency as O, connectInjector as Et } from "@wendellhu/redi/react-bindings";
12
14
  import { serializeRange as It } from "@univerjs/engine-formula";
13
15
  const yt = "univer-extend-confirm-content", Mt = "univer-extend-confirm-radio-group", xt = "univer-custom-sort-panel-container", Rt = "univer-custom-sort-panel-ext", Tt = "univer-add-condition", Ot = "univer-add-condition-text", bt = "univer-add-condition-disable", Nt = "univer-custom-sort-panel-footer", Pt = "univer-custom-sort-panel-footer-btn", wt = "univer-custom-sort-panel-item", Lt = "univer-custom-sort-panel-item-head", Dt = "univer-custom-sort-panel-item-handler", Ht = "univer-custom-sort-panel-item-remove", kt = "univer-custom-sort-panel-item-column-input", Ut = "univer-custom-sort-panel-item-column-input-dropdown", At = "univer-custom-sort-panel-item-column-input-text", Bt = "univer-custom-sort-panel-item-order-radio", $t = "univer-custom-sort-panel-item-order-radio-cn", jt = "univer-condition-list", Ft = "univer-embed-sort-btn-container", Vt = "univer-embed-sort-btn", zt = "univer-embed-sort-btn-asc", Zt = "univer-embed-sort-btn-desc", Wt = "univer-embed-sort-btn-icon", Gt = "univer-custom-sort-col-menu", Xt = "univer-custom-sort-col-menu-item", qt = "univer-custom-sort-col-menu-item-desc", a = {
14
16
  extendConfirmContent: yt,
@@ -74,7 +76,7 @@ const W = {
74
76
  let g = class extends qe {
75
77
  constructor(t, n, r, o, s, c, l) {
76
78
  super();
77
- K(this, "_customSortState$", new ft(null));
79
+ K(this, "_customSortState$", new St(null));
78
80
  K(this, "customSortState$", this._customSortState$.asObservable());
79
81
  this._univerInstanceService = t, this._confirmService = n, this._logService = r, this._selectionManagerService = o, this._sheetsSortService = s, this._localeService = c, this._commandService = l;
80
82
  }
@@ -127,9 +129,9 @@ let g = class extends qe {
127
129
  const s = {
128
130
  unitId: t,
129
131
  subUnitId: n,
130
- selections: [{ range: r, primary: ot(r, o), style: null }]
132
+ selections: [{ range: r, primary: rt(r, o), style: null }]
131
133
  };
132
- this._commandService.executeCommand(st.id, s);
134
+ this._commandService.executeCommand(ot.id, s);
133
135
  }
134
136
  async showCheckError(t) {
135
137
  return await this._confirmService.confirm({
@@ -199,9 +201,9 @@ let g = class extends qe {
199
201
  g = Qt([
200
202
  ge(Ce.Ready, Q),
201
203
  b(0, fe),
202
- b(1, dt),
204
+ b(1, lt),
203
205
  b(2, Ye),
204
- b(3, x(it)),
206
+ b(3, x(st)),
205
207
  b(4, x(Q)),
206
208
  b(5, x(P)),
207
209
  b(6, pe)
@@ -411,7 +413,7 @@ function Sn() {
411
413
  const We = S.length < T.length, ae = S.map((u) => ({ ...u, id: `${u.colIndex}` }));
412
414
  return /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelContainer }, /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelContent, onMouseDown: (u) => {
413
415
  u.stopPropagation();
414
- } }, /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelExt }, /* @__PURE__ */ i.createElement("div", { className: a.firstRowCheck }, /* @__PURE__ */ i.createElement(vt, { checked: r, onChange: (u) => Ze(!!u) }, n.t("sheets-sort.dialog.first-row-check"))), We ? /* @__PURE__ */ i.createElement("div", { className: a.addCondition, onClick: Z }, /* @__PURE__ */ i.createElement(ee, null), /* @__PURE__ */ i.createElement("span", { className: a.addConditionText }, n.t("sheets-sort.dialog.add-condition"))) : /* @__PURE__ */ i.createElement("div", { className: `${a.addCondition} ${a.addConditionDisable}` }, /* @__PURE__ */ i.createElement(ee, null), /* @__PURE__ */ i.createElement("span", { className: a.addConditionText }, n.t("sheets-sort.dialog.add-condition")))), /* @__PURE__ */ i.createElement(
416
+ } }, /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelExt }, /* @__PURE__ */ i.createElement("div", { className: a.firstRowCheck }, /* @__PURE__ */ i.createElement(pt, { checked: r, onChange: (u) => Ze(!!u) }, n.t("sheets-sort.dialog.first-row-check"))), We ? /* @__PURE__ */ i.createElement("div", { className: a.addCondition, onClick: Z }, /* @__PURE__ */ i.createElement(ee, null), /* @__PURE__ */ i.createElement("span", { className: a.addConditionText }, n.t("sheets-sort.dialog.add-condition"))) : /* @__PURE__ */ i.createElement("div", { className: `${a.addCondition} ${a.addConditionDisable}` }, /* @__PURE__ */ i.createElement(ee, null), /* @__PURE__ */ i.createElement("span", { className: a.addConditionText }, n.t("sheets-sort.dialog.add-condition")))), /* @__PURE__ */ i.createElement(
415
417
  "div",
416
418
  {
417
419
  className: a.conditionList,
@@ -422,7 +424,7 @@ function Sn() {
422
424
  ref: l
423
425
  },
424
426
  /* @__PURE__ */ i.createElement(
425
- _t,
427
+ vt,
426
428
  {
427
429
  list: ae,
428
430
  onListChange: $,
@@ -456,7 +458,7 @@ function fn(e) {
456
458
  }, [s]);
457
459
  const S = t.length > 1, $ = (Z = r.find((h) => h.index === n.colIndex)) == null ? void 0 : Z.label, q = c.getCurrentLocale() === J.ZH_CN ? a.customSortPanelItemOrderRadioCn : a.customSortPanelItemOrderRadio;
458
460
  return /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelItem }, /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelItemHead }, /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelItemHandler }, /* @__PURE__ */ i.createElement(we, null)), /* @__PURE__ */ i.createElement("div", { className: a.customSortPanelItemColumn }, /* @__PURE__ */ i.createElement(
459
- Et,
461
+ _t,
460
462
  {
461
463
  placement: "bottomLeft",
462
464
  trigger: ["click"],
@@ -496,7 +498,7 @@ function pn(e, t) {
496
498
  }
497
499
  function vn(e) {
498
500
  const { range: t, colIndex: n, onClose: r } = e, o = O(g), s = O(fe), c = O(P), l = N((m) => {
499
- const { unitId: d, subUnitId: C } = ct(s) || {};
501
+ const { unitId: d, subUnitId: C } = it(s) || {};
500
502
  if (t && d && C) {
501
503
  const f = { ...t, startRow: t.startRow + 1 };
502
504
  o.triggerSortDirectly(m, !1, { unitId: d, subUnitId: C, range: f, colIndex: n });
@@ -515,7 +517,7 @@ function _n(e) {
515
517
  group: ye.TOOLBAR_FORMULAS_INSERT,
516
518
  icon: z,
517
519
  tooltip: "sheets-sort.general.sort",
518
- hidden$: ut(e, te.UNIVER_SHEET),
520
+ hidden$: dt(e, te.UNIVER_SHEET),
519
521
  disabled$: U(e, { workbookTypes: [L], worksheetTypes: [D, H], rangeTypes: [k] })
520
522
  };
521
523
  }
@@ -676,10 +678,10 @@ let V = class extends Je {
676
678
  $e,
677
679
  je,
678
680
  Fe
679
- ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(nt.id));
681
+ ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(tt.id));
680
682
  }
681
683
  _initUI() {
682
- this.disposeWithMe(this._componentManager.register("CustomSortPanel", Sn)), this.disposeWithMe(this._uiPartsService.registerComponent(at.FILTER_PANEL_EMBED_POINT, () => Qe(vn, this._injector))), this.disposeWithMe(this._componentManager.register(z, ne)), this.disposeWithMe(this._componentManager.register(oe, be)), this.disposeWithMe(this._componentManager.register(se, re)), this.disposeWithMe(this._componentManager.register(ie, Ne)), this.disposeWithMe(this._componentManager.register(ce, Te)), this._sheetsSortUIService.customSortState$.pipe(pt(this.dispose$)).subscribe((e) => {
684
+ this.disposeWithMe(this._componentManager.register("CustomSortPanel", Sn)), this.disposeWithMe(this._uiPartsService.registerComponent(ct.FILTER_PANEL_EMBED_POINT, () => Et(vn, this._injector))), this.disposeWithMe(this._componentManager.register(z, ne)), this.disposeWithMe(this._componentManager.register(oe, be)), this.disposeWithMe(this._componentManager.register(se, re)), this.disposeWithMe(this._componentManager.register(ie, Ne)), this.disposeWithMe(this._componentManager.register(ce, Te)), this._sheetsSortUIService.customSortState$.pipe(ft(this.dispose$)).subscribe((e) => {
683
685
  e && e.show && e.location ? this._openCustomSortPanel(e.location) : e && !(e != null && e.show) && this._closePanel();
684
686
  });
685
687
  }
@@ -704,15 +706,15 @@ let V = class extends Je {
704
706
  V = Dn([
705
707
  ge(Ce.Ready, V),
706
708
  M(1, pe),
707
- M(2, ht),
708
- M(3, gt),
709
- M(4, Ct),
710
- M(5, St),
711
- M(6, x(lt)),
709
+ M(2, mt),
710
+ M(3, ht),
711
+ M(4, gt),
712
+ M(5, Ct),
713
+ M(6, x(at)),
712
714
  M(7, x(P)),
713
715
  M(8, x(g)),
714
716
  M(9, x(ve)),
715
- M(10, x(mt))
717
+ M(10, x(ut))
716
718
  ], V);
717
719
  function Un() {
718
720
  return { x: 0, y: 0 };
@@ -723,7 +725,7 @@ var Ve = Object.defineProperty, An = Object.getOwnPropertyDescriptor, Bn = (e, t
723
725
  return r && o && Ve(t, n, o), o;
724
726
  }, he = (e, t) => (n, r) => t(n, r, e), ze = (e, t, n) => Bn(e, typeof t != "symbol" ? t + "" : t, n);
725
727
  const jn = "UNIVER_SHEETS_SORT_UI_PLUGIN";
726
- let X = class extends et {
728
+ let X = class extends Qe {
727
729
  constructor(e = {}, t, n) {
728
730
  super(), this._config = e, this._injector = t, this._localeService = n, this._config = Se.deepMerge({}, Hn, this._config);
729
731
  }
@@ -739,7 +741,7 @@ let X = class extends et {
739
741
  ze(X, "type", te.UNIVER_SHEET);
740
742
  ze(X, "pluginName", jn);
741
743
  X = $n([
742
- tt(rt),
744
+ et(nt),
743
745
  he(1, x(ve)),
744
746
  he(2, x(P))
745
747
  ], X);
@@ -1,4 +1,5 @@
1
- import { ICommandService, Injector, LocaleService, RxDisposable } from '@univerjs/core';
1
+ import { ICommandService, LocaleService, RxDisposable } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
2
3
  import { MenuConfig, UIPartsService, ComponentManager, IDialogService, ILayoutService, IMenuService } from '@univerjs/ui';
3
4
  import { SheetsRenderService } from '@univerjs/sheets-ui';
4
5
  import { SheetsSortUIService } from '../services/sheets-sort-ui.service';
@@ -1,5 +1,5 @@
1
1
  import { IMenuItem } from '@univerjs/ui';
2
- import { IAccessor } from '@univerjs/core';
2
+ import { IAccessor } from '@wendellhu/redi';
3
3
 
4
4
  export declare const SHEETS_SORT_ASC_ICON = "AscendingSingle";
5
5
  export declare const SHEETS_SORT_ASC_EXT_ICON = "ExpandAscendingSingle";
@@ -1,4 +1,5 @@
1
- import { Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
2
+ import { Injector } from '@wendellhu/redi';
2
3
  import { IUniverSheetsSortUIConfig } from './controllers/sheets-sort-ui.controller';
3
4
 
4
5
  export declare class UniverSheetsSortUIPlugin extends Plugin {
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(u,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets-sort"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("react"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-sort","@univerjs/sheets","@univerjs/sheets-ui","react","@univerjs/ui","rxjs","@univerjs/design","@univerjs/engine-formula"],i):(u=typeof globalThis<"u"?globalThis:u||self,i(u.UniverSheetsSortUi={},u.UniverCore,u.UniverSheetsSort,u.UniverSheets,u.UniverSheetsUi,u.React,u.UniverUi,u.rxjs,u.UniverDesign,u.UniverEngineFormula))})(this,function(u,i,v,m,_,o,S,se,P,pe){"use strict";var St=Object.defineProperty;var Ct=(u,i,v)=>i in u?St(u,i,{enumerable:!0,configurable:!0,writable:!0,value:v}):u[i]=v;var oe=(u,i,v)=>Ct(u,typeof i!="symbol"?i+"":i,v);const l={extendConfirmContent:"univer-extend-confirm-content",extendConfirmRadioGroup:"univer-extend-confirm-radio-group",customSortPanelContainer:"univer-custom-sort-panel-container",customSortPanelExt:"univer-custom-sort-panel-ext",addCondition:"univer-add-condition",addConditionText:"univer-add-condition-text",addConditionDisable:"univer-add-condition-disable",customSortPanelFooter:"univer-custom-sort-panel-footer",customSortPanelFooterBtn:"univer-custom-sort-panel-footer-btn",customSortPanelItem:"univer-custom-sort-panel-item",customSortPanelItemHead:"univer-custom-sort-panel-item-head",customSortPanelItemHandler:"univer-custom-sort-panel-item-handler",customSortPanelItemRemove:"univer-custom-sort-panel-item-remove",customSortPanelItemColumnInput:"univer-custom-sort-panel-item-column-input",customSortPanelItemColumnInputDropdown:"univer-custom-sort-panel-item-column-input-dropdown",customSortPanelItemColumnInputText:"univer-custom-sort-panel-item-column-input-text",customSortPanelItemOrderRadio:"univer-custom-sort-panel-item-order-radio",customSortPanelItemOrderRadioCn:"univer-custom-sort-panel-item-order-radio-cn",conditionList:"univer-condition-list",embedSortBtnContainer:"univer-embed-sort-btn-container",embedSortBtn:"univer-embed-sort-btn",embedSortBtnAsc:"univer-embed-sort-btn-asc",embedSortBtnDesc:"univer-embed-sort-btn-desc",embedSortBtnIcon:"univer-embed-sort-btn-icon",customSortColMenu:"univer-custom-sort-col-menu",customSortColMenuItem:"univer-custom-sort-col-menu-item",customSortColMenuItemDesc:"univer-custom-sort-col-menu-item-desc"},Ie=e=>{const[t,n]=o.useState("0"),r=i.useDependency(i.LocaleService);return o.createElement("div",{className:l.extendConfirmContent},o.createElement("div",{className:"extend-confirm-desc"},r.t("sheets-sort.dialog.sort-reminder-desc")),o.createElement(P.RadioGroup,{className:l.extendConfirmRadioGroup,value:t,direction:"vertical",onChange:s=>{n(s),e.onChange(s)}},o.createElement(P.Radio,{value:"0"},r.t("sheets-sort.dialog.sort-reminder-no")),o.createElement(P.Radio,{value:"1"},r.t("sheets-sort.dialog.sort-reminder-ext"))))};var ye=Object.defineProperty,Ee=Object.getOwnPropertyDescriptor,_e=(e,t,n,r)=>{for(var s=r>1?void 0:r?Ee(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&ye(t,n,s),s},w=(e,t)=>(n,r)=>t(n,r,e);const U={MERGE_ERROR:"sheets-sort.error.merge-size",EMPTY_ERROR:"sheets-sort.error.empty",SINGLE_ERROR:"sheets-sort.error.single",FORMULA_ARRAY:"sheets-sort.error.formula-array"};let p=class extends i.Disposable{constructor(t,n,r,s,a,c,d){super();oe(this,"_customSortState$",new se.BehaviorSubject(null));oe(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=t,this._confirmService=n,this._logService=r,this._selectionManagerService=s,this._sheetsSortService=a,this._localeService=c,this._commandService=d}async triggerSortDirectly(t,n,r){const s=r||await this._detectSortLocation(n);if(!s||!this._check(s))return!1;const c={orderRules:[{type:t?v.SortType.ASC:v.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(c,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const t=await this._detectSortLocation();return!t||!this._check(t)?!1:(this.showCustomSortPanel(t),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(t){var h,C;const n=(h=this.customSortState())==null?void 0:h.location;if(!n)return[];const{unitId:r,subUnitId:s,range:a}=n,c=(C=this._univerInstanceService.getUnit(r))==null?void 0:C.getSheetBySheetId(s);if(!c)return[];const d=Me(this._localeService);return Array.from({length:a.endColumn-a.startColumn+1},(I,E)=>{var y;const O=(y=c.getCell(a.startRow,E+a.startColumn))==null?void 0:y.v;return{index:E+a.startColumn,label:t?`${O!=null?O:d(E+a.startColumn)}`:d(E+a.startColumn)}})}setSelection(t,n,r){var c;const s=(c=this._univerInstanceService.getUnit(t))==null?void 0:c.getSheetBySheetId(n);if(!s)return;const a={unitId:t,subUnitId:n,selections:[{range:r,primary:m.getPrimaryForRange(r,s),style:null}]};this._commandService.executeCommand(m.SetSelectionsOperation.id,a)}async showCheckError(t){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:o.createElement("div",null,this._localeService.t(t))}})}async showExtendConfirm(){let t=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:o.createElement(Ie,{onChange:r=>{t=r==="1"}})},width:400})?t?"extend":"keep":"cancel"}showCustomSortPanel(t){this._customSortState$.next({location:t,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(t){return this._sheetsSortService.singleCheck(t)?this._sheetsSortService.mergeCheck(t)?this._sheetsSortService.formulaCheck(t)?this._sheetsSortService.emptyCheck(t)?!0:(this.showCheckError(U.EMPTY_ERROR),!1):(this.showCheckError(U.FORMULA_ARRAY),!1):(this.showCheckError(U.MERGE_ERROR),!1):(this.showCheckError(U.SINGLE_ERROR),!1)}async _detectSortLocation(t){var C;const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),s=n.getUnitId(),a=r.getSheetId(),c=this._selectionManagerService.getCurrentLastSelection();if(!c)return null;let d;if(t===!0)d=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,a,d);else if(t===!1)d=c.range;else{const I=await this.showExtendConfirm();if(I==="cancel")return null;I==="keep"?d=c.range:(d=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,a,d))}const h=(C=this._selectionManagerService.getCurrentLastSelection())==null?void 0:C.primary;return h?{range:d,unitId:s,subUnitId:a,colIndex:h.actualColumn}:null}};p=_e([i.OnLifecycle(i.LifecycleStages.Ready,v.SheetsSortService),w(0,i.IUniverInstanceService),w(1,S.IConfirmService),w(2,i.ILogService),w(3,i.Inject(m.SheetsSelectionsService)),w(4,i.Inject(v.SheetsSortService)),w(5,i.Inject(i.LocaleService)),w(6,i.ICommandService)],p);function Me(e){return t=>{const n=i.Tools.chatAtABC(t);switch(e.getCurrentLocale()){case i.LocaleType.ZH_CN:return`"${n}"列`;case i.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}var M=function(){return M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},M.apply(this,arguments)},Pe=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n},T=o.forwardRef(function(e,t){var n=e.icon,r=e.id,s=e.className,a=e.extend,c=Pe(e,["icon","id","className","extend"]),d="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),h=o.useRef("_".concat(be()));return ie(n,"".concat(r),{defIds:n.defIds,idSuffix:h.current},M({ref:t,className:d},c),a)});function ie(e,t,n,r,s){return o.createElement(e.tag,M(M({key:t},Te(e,n,s)),r),(xe(e,n).children||[]).map(function(a,c){return ie(a,"".concat(t,"-").concat(e.tag,"-").concat(c),n,void 0,s)}))}function Te(e,t,n){var r=M({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=t.defIds;return!s||s.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(a){var c=a[0],d=a[1];typeof d=="string"&&(r[c]=d.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function xe(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?M(M({},e),{children:e.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?M(M({},s),{attrs:M(M({},s.attrs),{id:s.attrs.id+t.idSuffix})}):s})}):e}function be(){return Math.random().toString(36).substring(2,8)}T.displayName="UniverIcon";var Oe={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 14.4667C12.4208 14.798 12.1522 15.0667 11.8208 15.0667C11.4895 15.0667 11.2208 14.798 11.2208 14.4667V2.98193L9.97861 4.22417C9.7443 4.45848 9.3644 4.45848 9.13008 4.22417C8.89577 3.98985 8.89577 3.60995 9.13008 3.37564L11.3967 1.10897C11.6311 0.874657 12.011 0.874657 12.2453 1.10897L14.5119 3.37564C14.7463 3.60995 14.7463 3.98985 14.5119 4.22417C14.2776 4.45848 13.8977 4.45848 13.6634 4.22417L12.4208 2.9816V14.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},j=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"ascending- single",ref:t,icon:Oe}))});j.displayName="AscendingSingle";var we={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ae=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"check-mark-single",ref:t,icon:we}))});ae.displayName="CheckMarkSingle";var De={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.77445 9.24306L9.77457 11.9573C9.77458 12.2887 9.50597 12.5574 9.17459 12.5574 8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507 9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661 11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306zM6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512 7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574 6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588 4.88808 9.55156 5.26798 9.55156 5.50229 9.78588L6.22584 10.5094z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.14014 3.73989C1.14014 2.30396 2.3042 1.13989 3.74014 1.13989H12.2601C13.6961 1.13989 14.8601 2.30395 14.8601 3.73989V12.2599C14.8601 13.6958 13.6961 14.8599 12.2601 14.8599H3.74014C2.3042 14.8599 1.14014 13.6958 1.14014 12.2599V3.73989ZM2.34014 5.86724V12.2599C2.34014 13.0331 2.96694 13.6599 3.74014 13.6599H12.2601C13.0333 13.6599 13.6601 13.0331 13.6601 12.2599V5.86724H2.34014ZM13.6601 4.66724H2.34014V3.73989C2.34014 2.9667 2.96694 2.33989 3.74014 2.33989H12.2601C13.0333 2.33989 13.6601 2.96669 13.6601 3.73989V4.66724Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ce=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"custom-sort-single",ref:t,icon:De}))});ce.displayName="CustomSortSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V13.1332C3.15332 14.2377 4.04875 15.1332 5.15332 15.1332H10.8465C11.9511 15.1332 12.8465 14.2377 12.8465 13.1331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V13.1331C11.6465 13.575 11.2884 13.9331 10.8465 13.9331H5.15332C4.71149 13.9331 4.35332 13.575 4.35332 13.1332V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},le=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"delete-empty-single",ref:t,icon:Ne}))});le.displayName="DeleteEmptySingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 1.53335C12.4208 1.20198 12.1522 0.93335 11.8208 0.93335C11.4895 0.93335 11.2208 1.20198 11.2208 1.53335V13.0181L9.97861 11.7758C9.7443 11.5415 9.3644 11.5415 9.13008 11.7758C8.89577 12.0101 8.89577 12.39 9.13008 12.6244L11.3967 14.891C11.6311 15.1253 12.011 15.1253 12.2453 14.891L14.5119 12.6244C14.7463 12.39 14.7463 12.0101 14.5119 11.7758C14.2776 11.5415 13.8977 11.5415 13.6634 11.7758L12.4208 13.0184V1.53335Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},B=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"descending-single",ref:t,icon:Le}))});B.displayName="DescendingSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 3.20024C1.57503 3.20024 1.3064 2.93161 1.3064 2.60024C1.3064 2.26887 1.57503 2.00024 1.9064 2.00024H4.57306C4.90443 2.00024 5.17306 2.26887 5.17306 2.60024C5.17306 2.93161 4.90443 3.20024 4.57306 3.20024H1.9064ZM1.3064 6.19985C1.3064 6.53122 1.57503 6.79985 1.9064 6.79985H5.9064C6.23777 6.79985 6.5064 6.53122 6.5064 6.19985C6.5064 5.86848 6.23777 5.59985 5.9064 5.59985H1.9064C1.57503 5.59985 1.3064 5.86848 1.3064 6.19985ZM1.9064 10.3997C1.57503 10.3997 1.3064 10.1311 1.3064 9.79971C1.3064 9.46834 1.57503 9.19971 1.9064 9.19971H7.23973C7.5711 9.19971 7.83973 9.46834 7.83973 9.79971C7.83973 10.1311 7.5711 10.3997 7.23973 10.3997H1.9064ZM1.9064 13.9996C1.57503 13.9996 1.3064 13.7309 1.3064 13.3996C1.3064 13.0682 1.57503 12.7996 1.9064 12.7996H8.57306C8.90443 12.7996 9.17306 13.0682 9.17306 13.3996C9.17306 13.7309 8.90443 13.9996 8.57306 13.9996H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 14.2667C12.4267 14.5981 12.1581 14.8667 11.8267 14.8667C11.4953 14.8667 11.2267 14.5981 11.2267 14.2667V3.18198L9.98447 4.42422C9.75015 4.65853 9.37026 4.65853 9.13594 4.42422C8.90163 4.1899 8.90163 3.81 9.13594 3.57569L11.4026 1.30902C11.6369 1.07471 12.0168 1.07471 12.2511 1.30902L14.5178 3.57569C14.7521 3.81 14.7521 4.1899 14.5178 4.42422C14.2835 4.65853 13.9036 4.65853 13.6693 4.42422L12.4267 3.18165V14.2667Z"}}]},ue=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"expand-ascending-single",ref:t,icon:ke}))});ue.displayName="ExpandAscendingSingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 12.7998C1.57503 12.7998 1.3064 13.0684 1.3064 13.3998C1.3064 13.7311 1.57503 13.9998 1.9064 13.9998H4.57306C4.90443 13.9998 5.17306 13.7311 5.17306 13.3998C5.17306 13.0684 4.90443 12.7998 4.57306 12.7998H1.9064ZM1.3064 9.80015C1.3064 9.46878 1.57503 9.20015 1.9064 9.20015H5.9064C6.23777 9.20015 6.5064 9.46878 6.5064 9.80015C6.5064 10.1315 6.23777 10.4001 5.9064 10.4001H1.9064C1.57503 10.4001 1.3064 10.1315 1.3064 9.80015ZM1.9064 5.60029C1.57503 5.60029 1.3064 5.86892 1.3064 6.20029C1.3064 6.53166 1.57503 6.80029 1.9064 6.80029H7.23973C7.5711 6.80029 7.83973 6.53166 7.83973 6.20029C7.83973 5.86892 7.5711 5.60029 7.23973 5.60029H1.9064ZM1.9064 2.00044C1.57503 2.00044 1.3064 2.26907 1.3064 2.60044C1.3064 2.93181 1.57503 3.20044 1.9064 3.20044H8.57306C8.90443 3.20044 9.17306 2.93181 9.17306 2.60044C9.17306 2.26907 8.90443 2.00044 8.57306 2.00044H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 1.7333C12.4267 1.40193 12.1581 1.1333 11.8267 1.1333C11.4953 1.1333 11.2267 1.40193 11.2267 1.7333V12.818L9.98447 11.5758C9.75015 11.3415 9.37026 11.3415 9.13594 11.5758C8.90163 11.8101 8.90163 12.19 9.13594 12.4243L11.4026 14.691C11.6369 14.9253 12.0168 14.9253 12.2511 14.691L14.5178 12.4243C14.7521 12.19 14.7521 11.8101 14.5178 11.5758C14.2835 11.3415 13.9036 11.3415 13.6693 11.5758L12.4267 12.8183V1.7333Z"}}]},de=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"expand-descending-single",ref:t,icon:Re}))});de.displayName="ExpandDescendingSingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},$=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"increase-single",ref:t,icon:He}))});$.displayName="IncreaseSingle";var Ue={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"more-down-single",ref:t,icon:Ue}))});me.displayName="MoreDownSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},Se=o.forwardRef(function(e,t){return o.createElement(T,Object.assign({},e,{id:"sequence-single",ref:t,icon:Ae}))});Se.displayName="SequenceSingle";const F={id:"sheet.command.sort-range-asc",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!1)},W={id:"sheet.command.sort-range-asc-ext",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!0)},V={id:"sheet.command.sort-range-desc",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!1)},z={id:"sheet.command.sort-range-desc-ext",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!0)},Z={id:"sheet.command.sort-range-custom",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortCustomize()},G={id:"sheet.command.sort-range-asc-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!1)},q={id:"sheet.command.sort-range-asc-ext-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!0)},X={id:"sheet.command.sort-range-desc-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!1)},Y={id:"sheet.command.sort-range-desc-ext-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!0)},K={id:"sheet.command.sort-range-custom-ctx",type:i.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortCustomize()};function je(){const e=i.useDependency(p),t=i.useDependency(v.SheetsSortService),n=i.useDependency(i.LocaleService),[r,s]=o.useState(!1),[a,c]=o.useState(0),d=o.useRef(null),h=e.customSortState();if(!h||!h.location)return null;const{range:C,unitId:I,subUnitId:E}=h.location,O=e.getTitles(r),[y,R]=o.useState([{type:v.SortType.ASC,colIndex:C.startColumn}]),ne=o.useCallback((g,x)=>{const H=[...y];x===null?H.splice(g,1):H[g]=x,R(H)},[y]),A=o.useCallback(i.throttle(()=>{const g=[...y],x=$e(C,y);x!==null&&(g.push({type:v.SortType.ASC,colIndex:x}),R(g))},200),[y,C]),f=o.useCallback((g,x)=>{t.applySort({range:C,orderRules:g,hasTitle:x}),e.closeCustomSortPanel()},[t,e,C]),re=o.useCallback(()=>{e.closeCustomSortPanel()},[e]),dt=o.useCallback(g=>{s(g),g?e.setSelection(I,E,{...C,startRow:C.startRow+1}):e.setSelection(I,E,C)},[e,C,E,I]);o.useEffect(()=>{d.current&&y.length>5&&(d.current.scrollTop=d.current.scrollHeight)},[y]);const mt=y.length<O.length,ve=y.map(g=>({...g,id:`${g.colIndex}`}));return o.createElement("div",{className:l.customSortPanelContainer},o.createElement("div",{className:l.customSortPanelContent,onMouseDown:g=>{g.stopPropagation()}},o.createElement("div",{className:l.customSortPanelExt},o.createElement("div",{className:l.firstRowCheck},o.createElement(P.Checkbox,{checked:r,onChange:g=>dt(!!g)},n.t("sheets-sort.dialog.first-row-check"))),mt?o.createElement("div",{className:l.addCondition,onClick:A},o.createElement($,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition"))):o.createElement("div",{className:`${l.addCondition} ${l.addConditionDisable}`},o.createElement($,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition")))),o.createElement("div",{className:l.conditionList,onScroll:g=>{const x=g.currentTarget.scrollTop;c(x)},ref:d},o.createElement(P.DraggableList,{list:ve,onListChange:R,idKey:"id",draggableHandle:`.${l.customSortPanelItemHandler}`,itemRender:g=>o.createElement(Be,{titles:O,list:ve,item:g,onChange:(x,H)=>ne(H,x),scrollPosition:a}),rowHeight:32,margin:[0,12]}))),o.createElement("div",{className:l.customSortPanelFooter},o.createElement(P.Button,{className:l.customSortPanelFooterBtn,type:"default",onClick:()=>re()},n.t("sheets-sort.dialog.cancel")),o.createElement(P.Button,{className:l.customSortPanelFooterBtn,type:"primary",onClick:()=>f(y,r)},n.t("sheets-sort.dialog.confirm"))))}function Be(e){var A;const{list:t,item:n,titles:r,onChange:s,scrollPosition:a}=e,c=i.useDependency(i.LocaleService),d=r.filter(f=>!t.some(re=>re.colIndex===f.index)||f.index===n.colIndex),h=t.findIndex(f=>f.colIndex===n.colIndex),C=o.useCallback(f=>{s({...n,colIndex:f.index},h),E(!1)},[h,n,s]),[I,E]=o.useState(!1),O=f=>{E(f)};o.useEffect(()=>{E(!1)},[a]);const y=t.length>1,R=(A=r.find(f=>f.index===n.colIndex))==null?void 0:A.label,ne=c.getCurrentLocale()===i.LocaleType.ZH_CN?l.customSortPanelItemOrderRadioCn:l.customSortPanelItemOrderRadio;return o.createElement("div",{className:l.customSortPanelItem},o.createElement("div",{className:l.customSortPanelItemHead},o.createElement("div",{className:l.customSortPanelItemHandler},o.createElement(Se,null)),o.createElement("div",{className:l.customSortPanelItemColumn},o.createElement(P.Dropdown,{placement:"bottomLeft",trigger:["click"],visible:I,onVisibleChange:O,overlay:o.createElement("ul",{className:l.customSortColMenu},d.map(f=>o.createElement("li",{key:f.index,onClick:()=>C(f),className:l.customSortColMenuItem},o.createElement("span",{className:l.customSortColMenuItemDesc},f.label),o.createElement("span",{className:l.customSortColMenuItemCheck},f.index===n.colIndex&&o.createElement(ae,null)))))},o.createElement("div",{className:l.customSortPanelItemColumnInput},o.createElement("span",{className:l.customSortPanelItemColumnInputText},R),o.createElement(me,{className:l.customSortPanelItemColumnInputDropdown}))))),o.createElement("div",{className:l.customSortPanelItemOrder},o.createElement(P.RadioGroup,{className:ne,value:n.type,onChange:f=>{s({...n,type:f},h)}},o.createElement(P.Radio,{value:v.SortType.ASC},c.t("sheets-sort.general.sort-asc")),o.createElement(P.Radio,{value:v.SortType.DESC},c.t("sheets-sort.general.sort-desc")))),o.createElement("div",{className:l.customSortPanelItemRemove},y&&o.createElement(le,{onClick:()=>s(null,h)})))}function $e(e,t){const{startColumn:n,endColumn:r}=e,s=new Set(t.map(a=>a==null?void 0:a.colIndex));for(let a=n;a<=r;a++)if(!s.has(a))return a;return null}function Fe(e){const{range:t,colIndex:n,onClose:r}=e,s=i.useDependency(p),a=i.useDependency(i.IUniverInstanceService),c=i.useDependency(i.LocaleService),d=o.useCallback(h=>{const{unitId:C,subUnitId:I}=m.getSheetCommandTarget(a)||{};if(t&&C&&I){const E={...t,startRow:t.startRow+1};s.triggerSortDirectly(h,!1,{unitId:C,subUnitId:I,range:E,colIndex:n})}else console.warn(`Cannot find the target to sort. unitId: ${C}, subUnitId: ${I}, range: ${t}, colIndex: ${n}`);r()},[t,n,s,a,r]);return o.createElement("div",{className:l.embedSortBtnContainer},o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnAsc}`,onClick:()=>d(!0)},o.createElement(j,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-asc")),o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnDesc}`,onClick:()=>d(!1)},o.createElement(B,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-desc")))}const D="sheet.menu.sheets-sort",N="sheet.menu.sheets-sort-ctx",L="AscendingSingle",J="ExpandAscendingSingle",Q="DescendingSingle",ee="ExpandDescendingSingle",te="CustomSortSingle";function We(e){return{id:D,type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.TOOLBAR_START],group:S.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:L,tooltip:"sheets-sort.general.sort",hidden$:S.getMenuHiddenObservable(e,i.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Ve(e){return{id:F.id,icon:L,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,positions:[D]}}function ze(e){return{id:W.id,title:"sheets-sort.general.sort-asc-ext",icon:J,type:S.MenuItemType.BUTTON,positions:[D]}}function Ze(e){return{id:V.id,title:"sheets-sort.general.sort-desc-cur",icon:Q,type:S.MenuItemType.BUTTON,positions:[D]}}function Ge(e){return{id:z.id,title:"sheets-sort.general.sort-desc-ext",icon:ee,type:S.MenuItemType.BUTTON,positions:[D]}}function qe(e){return{id:Z.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[D],icon:te}}function Xe(e){return{id:N,title:"sheets-sort.general.sort",type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.CONTEXT_MENU,_.SheetMenuPosition.COL_HEADER_CONTEXT_MENU,_.SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],group:S.MenuGroup.CONTEXT_MENU_DATA,icon:L}}function Ye(e){return{id:G.id,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,icon:L,positions:[N],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Ke(e){return{id:q.id,title:"sheets-sort.general.sort-asc-ext",type:S.MenuItemType.BUTTON,icon:J,positions:[N],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Je(e){return{id:X.id,title:"sheets-sort.general.sort-desc-cur",type:S.MenuItemType.BUTTON,positions:[N],icon:Q,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Qe(e){return{id:Y.id,title:"sheets-sort.general.sort-desc-ext",type:S.MenuItemType.BUTTON,positions:[N],icon:ee,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function et(e){return{id:K.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[N],icon:te,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSortPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}var tt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,rt=(e,t,n,r)=>{for(var s=r>1?void 0:r?nt(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&tt(t,n,s),s},b=(e,t)=>(n,r)=>t(n,r,e);const ot={menu:{}},Ce="custom-sort-dialog",st=560;let k=class extends i.RxDisposable{constructor(e,t,n,r,s,a,c,d,h,C,I){super(),this._config=e,this._commandService=t,this._menuService=n,this._dialogService=r,this._layoutService=s,this._uiPartsService=a,this._sheetRenderService=c,this._localeService=d,this._sheetsSortUIService=h,this._injector=C,this._componentManager=I,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){const{menu:e={}}=this._config;[We,Ve,Ze,ze,Ge,qe,Xe,Ye,Je,Ke,Qe,et].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),e))})}_initCommands(){[F,W,V,z,Z,G,q,X,Y,K].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(v.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._componentManager.register("CustomSortPanel",je)),this.disposeWithMe(this._uiPartsService.registerComponent(_.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>i.connectInjector(Fe,this._injector))),this.disposeWithMe(this._componentManager.register(L,j)),this.disposeWithMe(this._componentManager.register(J,ue)),this.disposeWithMe(this._componentManager.register(Q,B)),this.disposeWithMe(this._componentManager.register(ee,de)),this.disposeWithMe(this._componentManager.register(te,ce)),this._sheetsSortUIService.customSortState$.pipe(se.takeUntil(this.dispose$)).subscribe(e=>{e&&e.show&&e.location?this._openCustomSortPanel(e.location):e&&!(e!=null&&e.show)&&this._closePanel()})}_openCustomSortPanel(e){this._dialogService.open({id:Ce,draggable:!0,width:st,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${pe.serializeRange(e.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:it(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(Ce),queueMicrotask(()=>this._layoutService.focus())}};k=rt([i.OnLifecycle(i.LifecycleStages.Ready,k),b(1,i.ICommandService),b(2,S.IMenuService),b(3,S.IDialogService),b(4,S.ILayoutService),b(5,S.IUIPartsService),b(6,i.Inject(_.SheetsRenderService)),b(7,i.Inject(i.LocaleService)),b(8,i.Inject(p)),b(9,i.Inject(i.Injector)),b(10,i.Inject(S.ComponentManager))],k);function it(){return{x:0,y:0}}var ge=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ct=(e,t,n)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lt=(e,t,n,r)=>{for(var s=r>1?void 0:r?at(t,n):t,a=e.length-1,c;a>=0;a--)(c=e[a])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&ge(t,n,s),s},he=(e,t)=>(n,r)=>t(n,r,e),fe=(e,t,n)=>ct(e,typeof t!="symbol"?t+"":t,n);const ut="UNIVER_SHEETS_SORT_UI_PLUGIN";u.UniverSheetsSortUIPlugin=class extends i.Plugin{constructor(t={},n,r){super(),this._config=t,this._injector=n,this._localeService=r,this._config=i.Tools.deepMerge({},ot,this._config)}onStarting(t){[[p],[k,{useFactory:()=>this._injector.createInstance(k,this._config)}]].forEach(n=>t.add(n))}},fe(u.UniverSheetsSortUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),fe(u.UniverSheetsSortUIPlugin,"pluginName",ut),u.UniverSheetsSortUIPlugin=lt([i.DependentOn(v.UniverSheetsSortPlugin),he(1,i.Inject(i.Injector)),he(2,i.Inject(i.LocaleService))],u.UniverSheetsSortUIPlugin),u.SortRangeAscCommand=F,u.SortRangeAscExtCommand=W,u.SortRangeAscExtInCtxMenuCommand=q,u.SortRangeAscInCtxMenuCommand=G,u.SortRangeCustomCommand=Z,u.SortRangeCustomInCtxMenuCommand=K,u.SortRangeDescCommand=V,u.SortRangeDescExtCommand=z,u.SortRangeDescExtInCtxMenuCommand=Y,u.SortRangeDescInCtxMenuCommand=X,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/sheets-sort"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("react"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/sheets-sort","@univerjs/sheets","@univerjs/sheets-ui","react","@univerjs/ui","rxjs","@univerjs/design","@wendellhu/redi/react-bindings","@univerjs/engine-formula"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u.UniverSheetsSortUi={},u.UniverCore,u["@wendellhu/redi"],u.UniverSheetsSort,u.UniverSheets,u.UniverSheetsUi,u.React,u.UniverUi,u.rxjs,u.UniverDesign,u["@wendellhu/redi/react-bindings"],u.UniverEngineFormula))})(this,function(u,a,v,P,d,_,o,S,ae,T,w,ye){"use strict";var gt=Object.defineProperty;var ht=(u,a,v)=>a in u?gt(u,a,{enumerable:!0,configurable:!0,writable:!0,value:v}):u[a]=v;var ie=(u,a,v)=>ht(u,typeof a!="symbol"?a+"":a,v);const l={extendConfirmContent:"univer-extend-confirm-content",extendConfirmRadioGroup:"univer-extend-confirm-radio-group",customSortPanelContainer:"univer-custom-sort-panel-container",customSortPanelExt:"univer-custom-sort-panel-ext",addCondition:"univer-add-condition",addConditionText:"univer-add-condition-text",addConditionDisable:"univer-add-condition-disable",customSortPanelFooter:"univer-custom-sort-panel-footer",customSortPanelFooterBtn:"univer-custom-sort-panel-footer-btn",customSortPanelItem:"univer-custom-sort-panel-item",customSortPanelItemHead:"univer-custom-sort-panel-item-head",customSortPanelItemHandler:"univer-custom-sort-panel-item-handler",customSortPanelItemRemove:"univer-custom-sort-panel-item-remove",customSortPanelItemColumnInput:"univer-custom-sort-panel-item-column-input",customSortPanelItemColumnInputDropdown:"univer-custom-sort-panel-item-column-input-dropdown",customSortPanelItemColumnInputText:"univer-custom-sort-panel-item-column-input-text",customSortPanelItemOrderRadio:"univer-custom-sort-panel-item-order-radio",customSortPanelItemOrderRadioCn:"univer-custom-sort-panel-item-order-radio-cn",conditionList:"univer-condition-list",embedSortBtnContainer:"univer-embed-sort-btn-container",embedSortBtn:"univer-embed-sort-btn",embedSortBtnAsc:"univer-embed-sort-btn-asc",embedSortBtnDesc:"univer-embed-sort-btn-desc",embedSortBtnIcon:"univer-embed-sort-btn-icon",customSortColMenu:"univer-custom-sort-col-menu",customSortColMenuItem:"univer-custom-sort-col-menu-item",customSortColMenuItemDesc:"univer-custom-sort-col-menu-item-desc"},Ee=e=>{const[t,n]=o.useState("0"),r=w.useDependency(a.LocaleService);return o.createElement("div",{className:l.extendConfirmContent},o.createElement("div",{className:"extend-confirm-desc"},r.t("sheets-sort.dialog.sort-reminder-desc")),o.createElement(T.RadioGroup,{className:l.extendConfirmRadioGroup,value:t,direction:"vertical",onChange:s=>{n(s),e.onChange(s)}},o.createElement(T.Radio,{value:"0"},r.t("sheets-sort.dialog.sort-reminder-no")),o.createElement(T.Radio,{value:"1"},r.t("sheets-sort.dialog.sort-reminder-ext"))))};var _e=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,Pe=(e,t,n,r)=>{for(var s=r>1?void 0:r?Me(t,n):t,i=e.length-1,c;i>=0;i--)(c=e[i])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&_e(t,n,s),s},N=(e,t)=>(n,r)=>t(n,r,e);const j={MERGE_ERROR:"sheets-sort.error.merge-size",EMPTY_ERROR:"sheets-sort.error.empty",SINGLE_ERROR:"sheets-sort.error.single",FORMULA_ARRAY:"sheets-sort.error.formula-array"};let p=class extends a.Disposable{constructor(t,n,r,s,i,c,m){super();ie(this,"_customSortState$",new ae.BehaviorSubject(null));ie(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=t,this._confirmService=n,this._logService=r,this._selectionManagerService=s,this._sheetsSortService=i,this._localeService=c,this._commandService=m}async triggerSortDirectly(t,n,r){const s=r||await this._detectSortLocation(n);if(!s||!this._check(s))return!1;const c={orderRules:[{type:t?P.SortType.ASC:P.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(c,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const t=await this._detectSortLocation();return!t||!this._check(t)?!1:(this.showCustomSortPanel(t),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(t){var h,C;const n=(h=this.customSortState())==null?void 0:h.location;if(!n)return[];const{unitId:r,subUnitId:s,range:i}=n,c=(C=this._univerInstanceService.getUnit(r))==null?void 0:C.getSheetBySheetId(s);if(!c)return[];const m=Te(this._localeService);return Array.from({length:i.endColumn-i.startColumn+1},(I,E)=>{var y;const D=(y=c.getCell(i.startRow,E+i.startColumn))==null?void 0:y.v;return{index:E+i.startColumn,label:t?`${D!=null?D:m(E+i.startColumn)}`:m(E+i.startColumn)}})}setSelection(t,n,r){var c;const s=(c=this._univerInstanceService.getUnit(t))==null?void 0:c.getSheetBySheetId(n);if(!s)return;const i={unitId:t,subUnitId:n,selections:[{range:r,primary:d.getPrimaryForRange(r,s),style:null}]};this._commandService.executeCommand(d.SetSelectionsOperation.id,i)}async showCheckError(t){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:o.createElement("div",null,this._localeService.t(t))}})}async showExtendConfirm(){let t=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:o.createElement(Ee,{onChange:r=>{t=r==="1"}})},width:400})?t?"extend":"keep":"cancel"}showCustomSortPanel(t){this._customSortState$.next({location:t,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(t){return this._sheetsSortService.singleCheck(t)?this._sheetsSortService.mergeCheck(t)?this._sheetsSortService.formulaCheck(t)?this._sheetsSortService.emptyCheck(t)?!0:(this.showCheckError(j.EMPTY_ERROR),!1):(this.showCheckError(j.FORMULA_ARRAY),!1):(this.showCheckError(j.MERGE_ERROR),!1):(this.showCheckError(j.SINGLE_ERROR),!1)}async _detectSortLocation(t){var C;const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),s=n.getUnitId(),i=r.getSheetId(),c=this._selectionManagerService.getCurrentLastSelection();if(!c)return null;let m;if(t===!0)m=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,i,m);else if(t===!1)m=c.range;else{const I=await this.showExtendConfirm();if(I==="cancel")return null;I==="keep"?m=c.range:(m=_.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(s,i,m))}const h=(C=this._selectionManagerService.getCurrentLastSelection())==null?void 0:C.primary;return h?{range:m,unitId:s,subUnitId:i,colIndex:h.actualColumn}:null}};p=Pe([a.OnLifecycle(a.LifecycleStages.Ready,P.SheetsSortService),N(0,a.IUniverInstanceService),N(1,S.IConfirmService),N(2,a.ILogService),N(3,v.Inject(d.SheetsSelectionsService)),N(4,v.Inject(P.SheetsSortService)),N(5,v.Inject(a.LocaleService)),N(6,a.ICommandService)],p);function Te(e){return t=>{const n=a.Tools.chatAtABC(t);switch(e.getCurrentLocale()){case a.LocaleType.ZH_CN:return`"${n}"列`;case a.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}var M=function(){return M=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},M.apply(this,arguments)},xe=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n},x=o.forwardRef(function(e,t){var n=e.icon,r=e.id,s=e.className,i=e.extend,c=xe(e,["icon","id","className","extend"]),m="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),h=o.useRef("_".concat(we()));return ce(n,"".concat(r),{defIds:n.defIds,idSuffix:h.current},M({ref:t,className:m},c),i)});function ce(e,t,n,r,s){return o.createElement(e.tag,M(M({key:t},be(e,n,s)),r),(Oe(e,n).children||[]).map(function(i,c){return ce(i,"".concat(t,"-").concat(e.tag,"-").concat(c),n,void 0,s)}))}function be(e,t,n){var r=M({},e.attrs);n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1);var s=t.defIds;return!s||s.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(function(i){var c=i[0],m=i[1];typeof m=="string"&&(r[c]=m.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),r}function Oe(e,t){var n,r=t.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((n=e.children)===null||n===void 0)&&n.length)?M(M({},e),{children:e.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?M(M({},s),{attrs:M(M({},s.attrs),{id:s.attrs.id+t.idSuffix})}):s})}):e}function we(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var De={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 14.4667C12.4208 14.798 12.1522 15.0667 11.8208 15.0667C11.4895 15.0667 11.2208 14.798 11.2208 14.4667V2.98193L9.97861 4.22417C9.7443 4.45848 9.3644 4.45848 9.13008 4.22417C8.89577 3.98985 8.89577 3.60995 9.13008 3.37564L11.3967 1.10897C11.6311 0.874657 12.011 0.874657 12.2453 1.10897L14.5119 3.37564C14.7463 3.60995 14.7463 3.98985 14.5119 4.22417C14.2776 4.45848 13.8977 4.45848 13.6634 4.22417L12.4208 2.9816V14.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},B=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"ascending- single",ref:t,icon:De}))});B.displayName="AscendingSingle";var Ne={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},le=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"check-mark-single",ref:t,icon:Ne}))});le.displayName="CheckMarkSingle";var Le={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.77445 9.24306L9.77457 11.9573C9.77458 12.2887 9.50597 12.5574 9.17459 12.5574 8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507 9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661 11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306zM6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512 7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574 6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588 4.88808 9.55156 5.26798 9.55156 5.50229 9.78588L6.22584 10.5094z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.14014 3.73989C1.14014 2.30396 2.3042 1.13989 3.74014 1.13989H12.2601C13.6961 1.13989 14.8601 2.30395 14.8601 3.73989V12.2599C14.8601 13.6958 13.6961 14.8599 12.2601 14.8599H3.74014C2.3042 14.8599 1.14014 13.6958 1.14014 12.2599V3.73989ZM2.34014 5.86724V12.2599C2.34014 13.0331 2.96694 13.6599 3.74014 13.6599H12.2601C13.0333 13.6599 13.6601 13.0331 13.6601 12.2599V5.86724H2.34014ZM13.6601 4.66724H2.34014V3.73989C2.34014 2.9667 2.96694 2.33989 3.74014 2.33989H12.2601C13.0333 2.33989 13.6601 2.96669 13.6601 3.73989V4.66724Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ue=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"custom-sort-single",ref:t,icon:Le}))});ue.displayName="CustomSortSingle";var ke={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V13.1332C3.15332 14.2377 4.04875 15.1332 5.15332 15.1332H10.8465C11.9511 15.1332 12.8465 14.2377 12.8465 13.1331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V13.1331C11.6465 13.575 11.2884 13.9331 10.8465 13.9331H5.15332C4.71149 13.9331 4.35332 13.575 4.35332 13.1332V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"delete-empty-single",ref:t,icon:ke}))});me.displayName="DeleteEmptySingle";var Re={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.4208 1.53335C12.4208 1.20198 12.1522 0.93335 11.8208 0.93335C11.4895 0.93335 11.2208 1.20198 11.2208 1.53335V13.0181L9.97861 11.7758C9.7443 11.5415 9.3644 11.5415 9.13008 11.7758C8.89577 12.0101 8.89577 12.39 9.13008 12.6244L11.3967 14.891C11.6311 15.1253 12.011 15.1253 12.2453 14.891L14.5119 12.6244C14.7463 12.39 14.7463 12.0101 14.5119 11.7758C14.2776 11.5415 13.8977 11.5415 13.6634 11.7758L12.4208 13.0184V1.53335Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.98967 10.2798C1.6583 10.2798 1.38967 10.0112 1.38967 9.67983 1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022 7.14858 9.67443 7.09725 9.9325 6.92565 10.1041L3.43819 13.5916H6.50138C6.83276 13.5916 7.10138 13.8602 7.10138 14.1916 7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212 1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967zM5.1846 1.86439C4.8641.989866 3.62725.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655 2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055 3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655 7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439zM4.98996 4.82056L4.24567 2.78971 3.50138 4.82056H4.98996z",fillRule:"evenodd",clipRule:"evenodd"}}]},F=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"descending-single",ref:t,icon:Re}))});F.displayName="DescendingSingle";var He={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 3.20024C1.57503 3.20024 1.3064 2.93161 1.3064 2.60024C1.3064 2.26887 1.57503 2.00024 1.9064 2.00024H4.57306C4.90443 2.00024 5.17306 2.26887 5.17306 2.60024C5.17306 2.93161 4.90443 3.20024 4.57306 3.20024H1.9064ZM1.3064 6.19985C1.3064 6.53122 1.57503 6.79985 1.9064 6.79985H5.9064C6.23777 6.79985 6.5064 6.53122 6.5064 6.19985C6.5064 5.86848 6.23777 5.59985 5.9064 5.59985H1.9064C1.57503 5.59985 1.3064 5.86848 1.3064 6.19985ZM1.9064 10.3997C1.57503 10.3997 1.3064 10.1311 1.3064 9.79971C1.3064 9.46834 1.57503 9.19971 1.9064 9.19971H7.23973C7.5711 9.19971 7.83973 9.46834 7.83973 9.79971C7.83973 10.1311 7.5711 10.3997 7.23973 10.3997H1.9064ZM1.9064 13.9996C1.57503 13.9996 1.3064 13.7309 1.3064 13.3996C1.3064 13.0682 1.57503 12.7996 1.9064 12.7996H8.57306C8.90443 12.7996 9.17306 13.0682 9.17306 13.3996C9.17306 13.7309 8.90443 13.9996 8.57306 13.9996H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 14.2667C12.4267 14.5981 12.1581 14.8667 11.8267 14.8667C11.4953 14.8667 11.2267 14.5981 11.2267 14.2667V3.18198L9.98447 4.42422C9.75015 4.65853 9.37026 4.65853 9.13594 4.42422C8.90163 4.1899 8.90163 3.81 9.13594 3.57569L11.4026 1.30902C11.6369 1.07471 12.0168 1.07471 12.2511 1.30902L14.5178 3.57569C14.7521 3.81 14.7521 4.1899 14.5178 4.42422C14.2835 4.65853 13.9036 4.65853 13.6693 4.42422L12.4267 3.18165V14.2667Z"}}]},de=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"expand-ascending-single",ref:t,icon:He}))});de.displayName="ExpandAscendingSingle";var Ue={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.9064 12.7998C1.57503 12.7998 1.3064 13.0684 1.3064 13.3998C1.3064 13.7311 1.57503 13.9998 1.9064 13.9998H4.57306C4.90443 13.9998 5.17306 13.7311 5.17306 13.3998C5.17306 13.0684 4.90443 12.7998 4.57306 12.7998H1.9064ZM1.3064 9.80015C1.3064 9.46878 1.57503 9.20015 1.9064 9.20015H5.9064C6.23777 9.20015 6.5064 9.46878 6.5064 9.80015C6.5064 10.1315 6.23777 10.4001 5.9064 10.4001H1.9064C1.57503 10.4001 1.3064 10.1315 1.3064 9.80015ZM1.9064 5.60029C1.57503 5.60029 1.3064 5.86892 1.3064 6.20029C1.3064 6.53166 1.57503 6.80029 1.9064 6.80029H7.23973C7.5711 6.80029 7.83973 6.53166 7.83973 6.20029C7.83973 5.86892 7.5711 5.60029 7.23973 5.60029H1.9064ZM1.9064 2.00044C1.57503 2.00044 1.3064 2.26907 1.3064 2.60044C1.3064 2.93181 1.57503 3.20044 1.9064 3.20044H8.57306C8.90443 3.20044 9.17306 2.93181 9.17306 2.60044C9.17306 2.26907 8.90443 2.00044 8.57306 2.00044H1.9064Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4267 1.7333C12.4267 1.40193 12.1581 1.1333 11.8267 1.1333C11.4953 1.1333 11.2267 1.40193 11.2267 1.7333V12.818L9.98447 11.5758C9.75015 11.3415 9.37026 11.3415 9.13594 11.5758C8.90163 11.8101 8.90163 12.19 9.13594 12.4243L11.4026 14.691C11.6369 14.9253 12.0168 14.9253 12.2511 14.691L14.5178 12.4243C14.7521 12.19 14.7521 11.8101 14.5178 11.5758C14.2835 11.3415 13.9036 11.3415 13.6693 11.5758L12.4267 12.8183V1.7333Z"}}]},Se=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"expand-descending-single",ref:t,icon:Ue}))});Se.displayName="ExpandDescendingSingle";var Ae={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},W=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"increase-single",ref:t,icon:Ae}))});W.displayName="IncreaseSingle";var je={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ce=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"more-down-single",ref:t,icon:je}))});Ce.displayName="MoreDownSingle";var $e={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ge=o.forwardRef(function(e,t){return o.createElement(x,Object.assign({},e,{id:"sequence-single",ref:t,icon:$e}))});ge.displayName="SequenceSingle";const V={id:"sheet.command.sort-range-asc",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!1)},z={id:"sheet.command.sort-range-asc-ext",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!0)},Z={id:"sheet.command.sort-range-desc",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!1)},q={id:"sheet.command.sort-range-desc-ext",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!0)},G={id:"sheet.command.sort-range-custom",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortCustomize()},X={id:"sheet.command.sort-range-asc-ctx",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!1)},Y={id:"sheet.command.sort-range-asc-ext-ctx",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!0,!0)},K={id:"sheet.command.sort-range-desc-ctx",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!1)},J={id:"sheet.command.sort-range-desc-ext-ctx",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortDirectly(!1,!0)},Q={id:"sheet.command.sort-range-custom-ctx",type:a.CommandType.COMMAND,handler:async e=>await e.get(p).triggerSortCustomize()};function Be(){const e=w.useDependency(p),t=w.useDependency(P.SheetsSortService),n=w.useDependency(a.LocaleService),[r,s]=o.useState(!1),[i,c]=o.useState(0),m=o.useRef(null),h=e.customSortState();if(!h||!h.location)return null;const{range:C,unitId:I,subUnitId:E}=h.location,D=e.getTitles(r),[y,U]=o.useState([{type:P.SortType.ASC,colIndex:C.startColumn}]),oe=o.useCallback((g,b)=>{const A=[...y];b===null?A.splice(g,1):A[g]=b,U(A)},[y]),$=o.useCallback(a.throttle(()=>{const g=[...y],b=We(C,y);b!==null&&(g.push({type:P.SortType.ASC,colIndex:b}),U(g))},200),[y,C]),f=o.useCallback((g,b)=>{t.applySort({range:C,orderRules:g,hasTitle:b}),e.closeCustomSortPanel()},[t,e,C]),se=o.useCallback(()=>{e.closeCustomSortPanel()},[e]),St=o.useCallback(g=>{s(g),g?e.setSelection(I,E,{...C,startRow:C.startRow+1}):e.setSelection(I,E,C)},[e,C,E,I]);o.useEffect(()=>{m.current&&y.length>5&&(m.current.scrollTop=m.current.scrollHeight)},[y]);const Ct=y.length<D.length,Ie=y.map(g=>({...g,id:`${g.colIndex}`}));return o.createElement("div",{className:l.customSortPanelContainer},o.createElement("div",{className:l.customSortPanelContent,onMouseDown:g=>{g.stopPropagation()}},o.createElement("div",{className:l.customSortPanelExt},o.createElement("div",{className:l.firstRowCheck},o.createElement(T.Checkbox,{checked:r,onChange:g=>St(!!g)},n.t("sheets-sort.dialog.first-row-check"))),Ct?o.createElement("div",{className:l.addCondition,onClick:$},o.createElement(W,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition"))):o.createElement("div",{className:`${l.addCondition} ${l.addConditionDisable}`},o.createElement(W,null),o.createElement("span",{className:l.addConditionText},n.t("sheets-sort.dialog.add-condition")))),o.createElement("div",{className:l.conditionList,onScroll:g=>{const b=g.currentTarget.scrollTop;c(b)},ref:m},o.createElement(T.DraggableList,{list:Ie,onListChange:U,idKey:"id",draggableHandle:`.${l.customSortPanelItemHandler}`,itemRender:g=>o.createElement(Fe,{titles:D,list:Ie,item:g,onChange:(b,A)=>oe(A,b),scrollPosition:i}),rowHeight:32,margin:[0,12]}))),o.createElement("div",{className:l.customSortPanelFooter},o.createElement(T.Button,{className:l.customSortPanelFooterBtn,type:"default",onClick:()=>se()},n.t("sheets-sort.dialog.cancel")),o.createElement(T.Button,{className:l.customSortPanelFooterBtn,type:"primary",onClick:()=>f(y,r)},n.t("sheets-sort.dialog.confirm"))))}function Fe(e){var $;const{list:t,item:n,titles:r,onChange:s,scrollPosition:i}=e,c=w.useDependency(a.LocaleService),m=r.filter(f=>!t.some(se=>se.colIndex===f.index)||f.index===n.colIndex),h=t.findIndex(f=>f.colIndex===n.colIndex),C=o.useCallback(f=>{s({...n,colIndex:f.index},h),E(!1)},[h,n,s]),[I,E]=o.useState(!1),D=f=>{E(f)};o.useEffect(()=>{E(!1)},[i]);const y=t.length>1,U=($=r.find(f=>f.index===n.colIndex))==null?void 0:$.label,oe=c.getCurrentLocale()===a.LocaleType.ZH_CN?l.customSortPanelItemOrderRadioCn:l.customSortPanelItemOrderRadio;return o.createElement("div",{className:l.customSortPanelItem},o.createElement("div",{className:l.customSortPanelItemHead},o.createElement("div",{className:l.customSortPanelItemHandler},o.createElement(ge,null)),o.createElement("div",{className:l.customSortPanelItemColumn},o.createElement(T.Dropdown,{placement:"bottomLeft",trigger:["click"],visible:I,onVisibleChange:D,overlay:o.createElement("ul",{className:l.customSortColMenu},m.map(f=>o.createElement("li",{key:f.index,onClick:()=>C(f),className:l.customSortColMenuItem},o.createElement("span",{className:l.customSortColMenuItemDesc},f.label),o.createElement("span",{className:l.customSortColMenuItemCheck},f.index===n.colIndex&&o.createElement(le,null)))))},o.createElement("div",{className:l.customSortPanelItemColumnInput},o.createElement("span",{className:l.customSortPanelItemColumnInputText},U),o.createElement(Ce,{className:l.customSortPanelItemColumnInputDropdown}))))),o.createElement("div",{className:l.customSortPanelItemOrder},o.createElement(T.RadioGroup,{className:oe,value:n.type,onChange:f=>{s({...n,type:f},h)}},o.createElement(T.Radio,{value:P.SortType.ASC},c.t("sheets-sort.general.sort-asc")),o.createElement(T.Radio,{value:P.SortType.DESC},c.t("sheets-sort.general.sort-desc")))),o.createElement("div",{className:l.customSortPanelItemRemove},y&&o.createElement(me,{onClick:()=>s(null,h)})))}function We(e,t){const{startColumn:n,endColumn:r}=e,s=new Set(t.map(i=>i==null?void 0:i.colIndex));for(let i=n;i<=r;i++)if(!s.has(i))return i;return null}function Ve(e){const{range:t,colIndex:n,onClose:r}=e,s=w.useDependency(p),i=w.useDependency(a.IUniverInstanceService),c=w.useDependency(a.LocaleService),m=o.useCallback(h=>{const{unitId:C,subUnitId:I}=d.getSheetCommandTarget(i)||{};if(t&&C&&I){const E={...t,startRow:t.startRow+1};s.triggerSortDirectly(h,!1,{unitId:C,subUnitId:I,range:E,colIndex:n})}else console.warn(`Cannot find the target to sort. unitId: ${C}, subUnitId: ${I}, range: ${t}, colIndex: ${n}`);r()},[t,n,s,i,r]);return o.createElement("div",{className:l.embedSortBtnContainer},o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnAsc}`,onClick:()=>m(!0)},o.createElement(B,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-asc")),o.createElement("div",{className:`${l.embedSortBtn} ${l.embedSortBtnDesc}`,onClick:()=>m(!1)},o.createElement(F,{className:l.embedSortBtnIcon}),c.t("sheets-sort.general.sort-desc")))}const L="sheet.menu.sheets-sort",k="sheet.menu.sheets-sort-ctx",R="AscendingSingle",ee="ExpandAscendingSingle",te="DescendingSingle",ne="ExpandDescendingSingle",re="CustomSortSingle";function ze(e){return{id:L,type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.TOOLBAR_START],group:S.MenuGroup.TOOLBAR_FORMULAS_INSERT,icon:R,tooltip:"sheets-sort.general.sort",hidden$:S.getMenuHiddenObservable(e,a.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Ze(e){return{id:V.id,icon:R,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,positions:[L]}}function qe(e){return{id:z.id,title:"sheets-sort.general.sort-asc-ext",icon:ee,type:S.MenuItemType.BUTTON,positions:[L]}}function Ge(e){return{id:Z.id,title:"sheets-sort.general.sort-desc-cur",icon:te,type:S.MenuItemType.BUTTON,positions:[L]}}function Xe(e){return{id:q.id,title:"sheets-sort.general.sort-desc-ext",icon:ne,type:S.MenuItemType.BUTTON,positions:[L]}}function Ye(e){return{id:G.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[L],icon:re}}function Ke(e){return{id:k,title:"sheets-sort.general.sort",type:S.MenuItemType.SUBITEMS,positions:[S.MenuPosition.CONTEXT_MENU,_.SheetMenuPosition.COL_HEADER_CONTEXT_MENU,_.SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],group:S.MenuGroup.CONTEXT_MENU_DATA,icon:R}}function Je(e){return{id:X.id,title:"sheets-sort.general.sort-asc-cur",type:S.MenuItemType.BUTTON,icon:R,positions:[k],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Qe(e){return{id:Y.id,title:"sheets-sort.general.sort-asc-ext",type:S.MenuItemType.BUTTON,icon:ee,positions:[k],disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function et(e){return{id:K.id,title:"sheets-sort.general.sort-desc-cur",type:S.MenuItemType.BUTTON,positions:[k],icon:te,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function tt(e){return{id:J.id,title:"sheets-sort.general.sort-desc-ext",type:S.MenuItemType.BUTTON,positions:[k],icon:ne,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function nt(e){return{id:Q.id,title:"sheets-sort.general.sort-custom",type:S.MenuItemType.BUTTON,positions:[k],icon:re,disabled$:_.getCurrentRangeDisable$(e,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}var rt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,st=(e,t,n,r)=>{for(var s=r>1?void 0:r?ot(t,n):t,i=e.length-1,c;i>=0;i--)(c=e[i])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&rt(t,n,s),s},O=(e,t)=>(n,r)=>t(n,r,e);const it={menu:{}},he="custom-sort-dialog",at=560;let H=class extends a.RxDisposable{constructor(e,t,n,r,s,i,c,m,h,C,I){super(),this._config=e,this._commandService=t,this._menuService=n,this._dialogService=r,this._layoutService=s,this._uiPartsService=i,this._sheetRenderService=c,this._localeService=m,this._sheetsSortUIService=h,this._injector=C,this._componentManager=I,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){const{menu:e={}}=this._config;[ze,Ze,Ge,qe,Xe,Ye,Ke,Je,et,Qe,tt,nt].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),e))})}_initCommands(){[V,z,Z,q,G,X,Y,K,J,Q].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(P.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._componentManager.register("CustomSortPanel",Be)),this.disposeWithMe(this._uiPartsService.registerComponent(_.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>w.connectInjector(Ve,this._injector))),this.disposeWithMe(this._componentManager.register(R,B)),this.disposeWithMe(this._componentManager.register(ee,de)),this.disposeWithMe(this._componentManager.register(te,F)),this.disposeWithMe(this._componentManager.register(ne,Se)),this.disposeWithMe(this._componentManager.register(re,ue)),this._sheetsSortUIService.customSortState$.pipe(ae.takeUntil(this.dispose$)).subscribe(e=>{e&&e.show&&e.location?this._openCustomSortPanel(e.location):e&&!(e!=null&&e.show)&&this._closePanel()})}_openCustomSortPanel(e){this._dialogService.open({id:he,draggable:!0,width:at,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${ye.serializeRange(e.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:ct(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(he),queueMicrotask(()=>this._layoutService.focus())}};H=st([a.OnLifecycle(a.LifecycleStages.Ready,H),O(1,a.ICommandService),O(2,S.IMenuService),O(3,S.IDialogService),O(4,S.ILayoutService),O(5,S.IUIPartsService),O(6,v.Inject(_.SheetsRenderService)),O(7,v.Inject(a.LocaleService)),O(8,v.Inject(p)),O(9,v.Inject(v.Injector)),O(10,v.Inject(S.ComponentManager))],H);function ct(){return{x:0,y:0}}var fe=Object.defineProperty,lt=Object.getOwnPropertyDescriptor,ut=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mt=(e,t,n,r)=>{for(var s=r>1?void 0:r?lt(t,n):t,i=e.length-1,c;i>=0;i--)(c=e[i])&&(s=(r?c(t,n,s):c(s))||s);return r&&s&&fe(t,n,s),s},ve=(e,t)=>(n,r)=>t(n,r,e),pe=(e,t,n)=>ut(e,typeof t!="symbol"?t+"":t,n);const dt="UNIVER_SHEETS_SORT_UI_PLUGIN";u.UniverSheetsSortUIPlugin=class extends a.Plugin{constructor(t={},n,r){super(),this._config=t,this._injector=n,this._localeService=r,this._config=a.Tools.deepMerge({},it,this._config)}onStarting(t){[[p],[H,{useFactory:()=>this._injector.createInstance(H,this._config)}]].forEach(n=>t.add(n))}},pe(u.UniverSheetsSortUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),pe(u.UniverSheetsSortUIPlugin,"pluginName",dt),u.UniverSheetsSortUIPlugin=mt([a.DependentOn(P.UniverSheetsSortPlugin),ve(1,v.Inject(v.Injector)),ve(2,v.Inject(a.LocaleService))],u.UniverSheetsSortUIPlugin),u.SortRangeAscCommand=V,u.SortRangeAscExtCommand=z,u.SortRangeAscExtInCtxMenuCommand=Y,u.SortRangeAscInCtxMenuCommand=X,u.SortRangeCustomCommand=G,u.SortRangeCustomInCtxMenuCommand=Q,u.SortRangeDescCommand=Z,u.SortRangeDescExtCommand=q,u.SortRangeDescExtInCtxMenuCommand=J,u.SortRangeDescInCtxMenuCommand=K,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-sort-ui",
3
- "version": "0.2.4-alpha.0",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "description": "Univer Sheets Sort UI",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -48,21 +48,23 @@
48
48
  "lib"
49
49
  ],
50
50
  "peerDependencies": {
51
+ "@wendellhu/redi": "0.16.0",
51
52
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
52
53
  "rxjs": ">=7.0.0",
53
- "@univerjs/core": "0.2.4-alpha.0",
54
- "@univerjs/design": "0.2.4-alpha.0",
55
- "@univerjs/engine-formula": "0.2.4-alpha.0",
56
- "@univerjs/sheets-sort": "0.2.4-alpha.0",
57
- "@univerjs/sheets": "0.2.4-alpha.0",
58
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
59
- "@univerjs/ui": "0.2.4-alpha.0"
54
+ "@univerjs/core": "0.2.4",
55
+ "@univerjs/design": "0.2.4",
56
+ "@univerjs/engine-formula": "0.2.4",
57
+ "@univerjs/sheets": "0.2.4",
58
+ "@univerjs/sheets-sort": "0.2.4",
59
+ "@univerjs/sheets-ui": "0.2.4",
60
+ "@univerjs/ui": "0.2.4"
60
61
  },
61
62
  "dependencies": {
62
- "@univerjs/icons": "^0.1.64",
63
+ "@univerjs/icons": "^0.1.65",
63
64
  "rc-virtual-list": "^3.14.5"
64
65
  },
65
66
  "devDependencies": {
67
+ "@wendellhu/redi": "0.16.0",
66
68
  "clsx": "^2.1.1",
67
69
  "less": "^4.2.0",
68
70
  "react": "18.3.1",
@@ -70,14 +72,14 @@
70
72
  "typescript": "^5.5.3",
71
73
  "vite": "^5.3.4",
72
74
  "vitest": "^2.0.3",
73
- "@univerjs/core": "0.2.4-alpha.0",
74
- "@univerjs/engine-render": "0.2.4-alpha.0",
75
- "@univerjs/shared": "0.2.4-alpha.0",
76
- "@univerjs/design": "0.2.4-alpha.0",
77
- "@univerjs/sheets": "0.2.4-alpha.0",
78
- "@univerjs/sheets-sort": "0.2.4-alpha.0",
79
- "@univerjs/sheets-ui": "0.2.4-alpha.0",
80
- "@univerjs/ui": "0.2.4-alpha.0"
75
+ "@univerjs/core": "0.2.4",
76
+ "@univerjs/design": "0.2.4",
77
+ "@univerjs/engine-render": "0.2.4",
78
+ "@univerjs/shared": "0.2.4",
79
+ "@univerjs/sheets": "0.2.4",
80
+ "@univerjs/sheets-sort": "0.2.4",
81
+ "@univerjs/sheets-ui": "0.2.4",
82
+ "@univerjs/ui": "0.2.4"
81
83
  },
82
84
  "univerSpace": {
83
85
  ".": {