@univerjs/sheets-sort-ui 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var xe=Object.defineProperty;var ye=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var q=(t,e,r)=>ye(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),i=require("react/jsx-runtime"),u=require("@univerjs/sheets"),R=require("@univerjs/sheets-sort"),d=require("@univerjs/ui"),se=require("rxjs"),S=require("@univerjs/design"),l=require("react"),Ie=require("@univerjs/engine-formula"),E=require("@univerjs/sheets-ui"),_e=t=>{const[e,r]=l.useState("0"),n=d.useDependency(a.LocaleService);return i.jsxs("div",{className:"univer-text-sm",children:[i.jsx("div",{className:"extend-confirm-desc",children:n.t("sheets-sort.dialog.sort-reminder-desc")}),i.jsxs(S.RadioGroup,{className:"univer-mt-4",value:e,direction:"vertical",onChange:s=>{r(s),t.onChange(s)},children:[i.jsx(S.Radio,{value:"0",children:n.t("sheets-sort.dialog.sort-reminder-no")}),i.jsx(S.Radio,{value:"1",children:n.t("sheets-sort.dialog.sort-reminder-ext")})]})]})};var we=Object.getOwnPropertyDescriptor,Re=(t,e,r,n)=>{for(var s=n>1?void 0:n?we(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=c(s)||s);return s},T=(t,e)=>(r,n)=>e(r,n,t);const O={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 a.Disposable{constructor(e,r,n,s,o,c){super();q(this,"_customSortState$",new se.BehaviorSubject(null));q(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=e,this._confirmService=r,this._selectionManagerService=n,this._sheetsSortService=s,this._localeService=o,this._commandService=c}async triggerSortDirectly(e,r,n){const s=n||await this._detectSortLocation(r);if(!s||!this._check(s))return!1;const c={orderRules:[{type:e?R.SortType.ASC:R.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(c,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const e=await this._detectSortLocation();return!e||!this._check(e)?!1:(this.showCustomSortPanel(e),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(e){var m,C;const r=(m=this.customSortState())==null?void 0:m.location;if(!r)return[];const{unitId:n,subUnitId:s,range:o}=r,c=(C=this._univerInstanceService.getUnit(n))==null?void 0:C.getSheetBySheetId(s);if(!c)return[];const h=Ee(this._localeService);return Array.from({length:o.endColumn-o.startColumn+1},(_,x)=>{var p;const M=(p=c.getCell(o.startRow,x+o.startColumn))==null?void 0:p.v;return{index:x+o.startColumn,label:e?`${M!=null?M:h(x+o.startColumn)}`:h(x+o.startColumn)}})}setSelection(e,r,n){var c;const s=(c=this._univerInstanceService.getUnit(e))==null?void 0:c.getSheetBySheetId(r);if(!s)return;const o={unitId:e,subUnitId:r,selections:[{range:n,primary:u.getPrimaryForRange(n,s),style:null}]};this._commandService.executeCommand(u.SetSelectionsOperation.id,o)}async showCheckError(e){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:i.jsx("div",{children:this._localeService.t(e)})},cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})}async showExtendConfirm(){let e=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:i.jsx(_e,{onChange:n=>{e=n==="1"}})},width:400,cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})?e?"extend":"keep":"cancel"}showCustomSortPanel(e){this._customSortState$.next({location:e,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(e){return this._sheetsSortService.singleCheck(e)?this._sheetsSortService.mergeCheck(e)?this._sheetsSortService.formulaCheck(e)?this._sheetsSortService.emptyCheck(e)?!0:(this.showCheckError(O.EMPTY_ERROR),!1):(this.showCheckError(O.FORMULA_ARRAY),!1):(this.showCheckError(O.MERGE_ERROR),!1):(this.showCheckError(O.SINGLE_ERROR),!1)}async _detectSortLocation(e){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),n=r.getActiveSheet(),s=r.getUnitId(),o=n.getSheetId(),c=this._selectionManagerService.getCurrentLastSelection();if(!c)return null;let h;if(e===!0)h=u.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},n),this.setSelection(s,o,h);else if(e===!1)h=c.range;else{const m=await this.showExtendConfirm();if(m==="cancel")return null;m==="keep"?h=c.range:(h=u.expandToContinuousRange(c.range,{up:!0,down:!0,left:!0,right:!0},n),this.setSelection(s,o,h))}return{range:h,unitId:s,subUnitId:o,colIndex:c.primary.actualColumn}}};f=Re([T(0,a.IUniverInstanceService),T(1,d.IConfirmService),T(2,a.Inject(u.SheetsSelectionsService)),T(3,a.Inject(R.SheetsSortService)),T(4,a.Inject(a.LocaleService)),T(5,a.ICommandService)],f);function Ee(t){return e=>{const r=a.Tools.chatAtABC(e);switch(t.getCurrentLocale()){case a.LocaleType.ZH_CN:return`"${r}"列`;case a.LocaleType.EN_US:return`Column "${r}"`;default:return`Column "${r}"`}}}const N={id:"sheet.command.sort-range-asc",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!1)},L={id:"sheet.command.sort-range-asc-ext",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!0)},$={id:"sheet.command.sort-range-desc",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!1)},U={id:"sheet.command.sort-range-desc-ext",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!0)},H={id:"sheet.command.sort-range-custom",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortCustomize()},A={id:"sheet.command.sort-range-asc-ctx",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!1)},Z={id:"sheet.command.sort-range-asc-ext-ctx",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!0)},B={id:"sheet.command.sort-range-desc-ctx",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!1)},F={id:"sheet.command.sort-range-desc-ext-ctx",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!0)},W={id:"sheet.command.sort-range-custom-ctx",type:a.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortCustomize()},Me="sheets-sort-ui.config",te={};function I({ref:t,...e}){const{icon:r,id:n,className:s,extend:o,...c}=e,h=`univerjs-icon univerjs-icon-${n} ${s||""}`.trim(),m=l.useRef(`_${ke()}`);return oe(r,`${n}`,{defIds:r.defIds,idSuffix:m.current},{ref:t,className:h,...c},o)}function oe(t,e,r,n,s){return l.createElement(t.tag,{key:e,...Te(t,r,s),...n},(be(t,r).children||[]).map((o,c)=>oe(o,`${e}-${t.tag}-${c}`,r,void 0,s)))}function Te(t,e,r){const n={...t.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([o,c])=>{o==="mask"&&typeof c=="string"&&(n[o]=c.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([o,c])=>{typeof c=="string"&&(n[o]=c.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function be(t,e){var n;const{defIds:r}=e;return!r||r.length===0?t:t.tag==="defs"&&((n=t.children)!=null&&n.length)?{...t,children:t.children.map(s=>typeof s.attrs.id=="string"&&r&&r.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:t}function ke(){return Math.random().toString(36).substring(2,8)}I.displayName="UniverIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},z=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"ascending-icon",ref:r,icon:Pe}))});z.displayName="AscendingIcon";const De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ie=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"check-mark-icon",ref:r,icon:De}))});ie.displayName="CheckMarkIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.5574C8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507C9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661C11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512C7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574C6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588C4.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=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"custom-sort-icon",ref:r,icon:Oe}))});ce.displayName="CustomSortIcon";const je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.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"}}]},ae=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"delete-empty-icon",ref:r,icon:je}))});ae.displayName="DeleteEmptyIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Y=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"descending-icon",ref:r,icon:Ne}))});Y.displayName="DescendingIcon";const Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},le=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"expand-ascending-icon",ref:r,icon:Le}))});le.displayName="ExpandAscendingIcon";const $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"expand-descending-icon",ref:r,icon:$e}))});de.displayName="ExpandDescendingIcon";const Ue={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},G=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"increase-icon",ref:r,icon:Ue}))});G.displayName="IncreaseIcon";const He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ue=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"more-down-icon",ref:r,icon:He}))});ue.displayName="MoreDownIcon";const Ae={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},he=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"sequence-icon",ref:r,icon:Ae}))});he.displayName="SequenceIcon";function Ze(){const t=d.useDependency(f),e=d.useObservable(t.customSortState$);return!e||!e.location?null:i.jsx(Be,{state:e})}function Be({state:t}){const e=d.useDependency(R.SheetsSortService),r=d.useDependency(a.LocaleService),n=d.useDependency(f),[s,o]=l.useState(!1),[c,h]=l.useState(0),m=l.useRef(null),{range:C,unitId:_,subUnitId:x}=t.location,M=n.getTitles(s),[p,b]=l.useState([{type:R.SortType.ASC,colIndex:C.startColumn}]),D=l.useCallback((g,y)=>{const k=[...p];y===null?k.splice(g,1):k[g]=y,b(k)},[p]),v=l.useCallback(a.throttle(()=>{const g=[...p],y=We(C,p);y!==null&&(g.push({type:R.SortType.ASC,colIndex:y}),b(g))},200),[p,C]),V=l.useCallback((g,y)=>{e.applySort({range:C,orderRules:g,hasTitle:y}),n.closeCustomSortPanel()},[e,n,C]),Se=l.useCallback(()=>{n.closeCustomSortPanel()},[n]),fe=l.useCallback(g=>{o(g),g?n.setSelection(_,x,{...C,startRow:C.startRow+1}):n.setSelection(_,x,C)},[n,C,x,_]);l.useEffect(()=>{m.current&&p.length>5&&(m.current.scrollTop=m.current.scrollHeight)},[p]);const pe=p.length<M.length,ee=p.map(g=>({...g,id:`${g.colIndex}`}));return i.jsxs("div",{children:[i.jsxs("div",{onMouseDown:g=>{g.stopPropagation()},children:[i.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between",children:[i.jsx(S.Checkbox,{checked:s,onChange:g=>fe(!!g),children:r.t("sheets-sort.dialog.first-row-check")}),pe?i.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base",onClick:v,children:[i.jsx(G,{}),i.jsx("span",{className:"univer-ml-1.5",children:r.t("sheets-sort.dialog.add-condition")})]}):i.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base univer-text-primary-500 disabled:univer-cursor-not-allowed disabled:univer-divide-opacity-30 disabled:univer-text-gray-800",children:[i.jsx(G,{}),i.jsx("span",{className:"univer-ml-1.5 univer-text-xs",children:r.t("sheets-sort.dialog.add-condition")})]})]}),i.jsx("div",{ref:m,className:S.clsx("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden",S.scrollbarClassName),onScroll:g=>{const y=g.currentTarget.scrollTop;h(y)},children:i.jsx(S.DraggableList,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",list:ee,onListChange:b,idKey:"id",draggableHandle:"[data-u-comp=sort-panel-item-handler]",itemRender:g=>i.jsx(Fe,{titles:M,list:ee,item:g,onChange:(y,k)=>D(k,y),scrollPosition:c}),rowHeight:32,margin:[0,12]})})]}),i.jsxs("div",{className:"univer-mt-5 univer-flex univer-justify-end",children:[i.jsx(S.Button,{className:"univer-ml-3",onClick:()=>Se(),children:r.t("sheets-sort.dialog.cancel")}),i.jsx(S.Button,{className:"univer-ml-3",variant:"primary",onClick:()=>V(p,s),children:r.t("sheets-sort.dialog.confirm")})]})]})}function Fe(t){var D;const{list:e,item:r,titles:n,onChange:s,scrollPosition:o}=t,c=d.useDependency(a.LocaleService),h=n.filter(v=>!e.some(V=>V.colIndex===v.index)||v.index===r.colIndex),m=e.findIndex(v=>v.colIndex===r.colIndex),C=l.useCallback(v=>{s({...r,colIndex:v.index},m),x(!1)},[m,r,s]),[_,x]=l.useState(!1),M=v=>{x(v)};l.useEffect(()=>{x(!1)},[o]);const p=e.length>1,b=(D=n.find(v=>v.index===r.colIndex))==null?void 0:D.label;return i.jsxs("div",{className:"univer-grid univer-grid-flow-col univer-grid-cols-2 univer-items-center univer-gap-2",children:[i.jsxs("div",{className:"univer-flex univer-items-center",children:[i.jsx("div",{"data-u-comp":"sort-panel-item-handler",className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-text-base univer-text-gray-700",children:i.jsx(he,{})}),i.jsx(S.Dropdown,{overlay:i.jsx("ul",{className:S.clsx("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg",S.scrollbarClassName),children:h.map(v=>i.jsxs("li",{onClick:()=>C(v),className:"univer-relative univer-box-border univer-flex univer-h-7 univer-cursor-pointer univer-list-none univer-items-center univer-justify-between univer-rounded univer-px-2 univer-text-sm univer-transition-all hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:[i.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:v.label}),i.jsx("span",{children:v.index===r.colIndex&&i.jsx(ie,{})})]},v.index))}),open:_,onOpenChange:M,children:i.jsxs("div",{className:S.clsx("univer-ml-2 univer-flex univer-w-full univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-text-sm univer-text-gray-900 dark:!univer-text-white"),children:[i.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:b}),i.jsx(ue,{})]})})]}),i.jsxs("div",{className:"univer-flex univer-items-center univer-justify-end univer-gap-2",children:[i.jsxs(S.RadioGroup,{value:r.type,onChange:v=>{s({...r,type:v},m)},children:[i.jsx(S.Radio,{value:R.SortType.ASC,children:c.t("sheets-sort.general.sort-asc")}),i.jsx(S.Radio,{value:R.SortType.DESC,children:c.t("sheets-sort.general.sort-desc")})]}),i.jsx("a",{className:"univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-transition-colors hover:univer-text-red-500",onClick:()=>s(null,m),children:!p&&i.jsx(ae,{})})]})]})}function We(t,e){const{startColumn:r,endColumn:n}=t,s=new Set(e.map(o=>o==null?void 0:o.colIndex));for(let o=r;o<=n;o++)if(!s.has(o))return o;return null}function Ve(t){const{range:e,colIndex:r,onClose:n}=t,s=d.useDependency(f),o=d.useDependency(a.IUniverInstanceService),c=d.useDependency(a.LocaleService),h=l.useCallback(m=>{const{unitId:C,subUnitId:_}=u.getSheetCommandTarget(o)||{};if(e&&C&&_){const x={...e,startRow:e.startRow+1};s.triggerSortDirectly(m,!1,{unitId:C,subUnitId:_,range:x,colIndex:r})}else throw new Error(`Cannot find the target to sort. unitId: ${C}, subUnitId: ${_}, range: ${e}, colIndex: ${r}`);n()},[e,r,s,o,n]);return i.jsxs(S.ButtonGroup,{className:"univer-mb-3 univer-w-full univer-grid-cols-2",children:[i.jsxs(S.Button,{onClick:()=>h(!0),children:[i.jsx(z,{}),c.t("sheets-sort.general.sort-asc")]}),i.jsxs(S.Button,{onClick:()=>h(!1),children:[i.jsx(Y,{}),c.t("sheets-sort.general.sort-desc")]})]})}const me="sheet.menu.sheets-sort",ge="sheet.menu.sheets-sort-ctx",P="AscendingIcon",X="ExpandAscendingIcon",K="DescendingIcon",J="ExpandDescendingIcon",Q="CustomSortIcon";function qe(t){return{id:me,type:d.MenuItemType.SUBITEMS,icon:P,tooltip:"sheets-sort.general.sort",hidden$:d.getMenuHiddenObservable(t,a.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Ge(t){return{id:N.id,icon:P,title:"sheets-sort.general.sort-asc-cur",type:d.MenuItemType.BUTTON,hidden$:E.getCurrentExclusiveRangeInterest$(t)}}function ze(t){return{id:L.id,title:"sheets-sort.general.sort-asc-ext",icon:X,type:d.MenuItemType.BUTTON}}function Ye(t){return{id:$.id,title:"sheets-sort.general.sort-desc-cur",icon:K,type:d.MenuItemType.BUTTON}}function Xe(t){return{id:U.id,title:"sheets-sort.general.sort-desc-ext",icon:J,type:d.MenuItemType.BUTTON}}function Ke(t){return{id:H.id,title:"sheets-sort.general.sort-custom",type:d.MenuItemType.BUTTON,icon:Q}}function Je(t){return{id:ge,title:"sheets-sort.general.sort",type:d.MenuItemType.SUBITEMS,icon:P,hidden$:d.getMenuHiddenObservable(t,a.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Qe(t){return{id:A.id,title:"sheets-sort.general.sort-asc-cur",type:d.MenuItemType.BUTTON,icon:P,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function et(t){return{id:Z.id,title:"sheets-sort.general.sort-asc-ext",type:d.MenuItemType.BUTTON,icon:X,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function tt(t){return{id:B.id,title:"sheets-sort.general.sort-desc-cur",type:d.MenuItemType.BUTTON,icon:K,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function rt(t){return{id:F.id,title:"sheets-sort.general.sort-desc-ext",type:d.MenuItemType.BUTTON,icon:J,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function nt(t){return{id:W.id,title:"sheets-sort.general.sort-custom",type:d.MenuItemType.BUTTON,icon:Q,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}const st={[d.RibbonDataGroup.ORGANIZATION]:{[me]:{order:3,menuItemFactory:qe,[N.id]:{order:0,menuItemFactory:Ge},[L.id]:{order:1,menuItemFactory:ze},[$.id]:{order:2,menuItemFactory:Ye},[U.id]:{order:3,menuItemFactory:Xe},[H.id]:{order:4,menuItemFactory:Ke}}},[d.ContextMenuPosition.MAIN_AREA]:{[d.ContextMenuGroup.DATA]:{[ge]:{order:0,menuItemFactory:Je,[A.id]:{order:0,menuItemFactory:Qe},[Z.id]:{order:1,menuItemFactory:et},[B.id]:{order:2,menuItemFactory:tt},[F.id]:{order:3,menuItemFactory:rt},[W.id]:{order:4,menuItemFactory:nt}}}}};var ot=Object.getOwnPropertyDescriptor,it=(t,e,r,n)=>{for(var s=n>1?void 0:n?ot(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=c(s)||s);return s},w=(t,e)=>(r,n)=>e(r,n,t);const re="custom-sort-dialog",Ce=560,ct=128;let j=class extends a.RxDisposable{constructor(t,e,r,n,s,o,c,h,m,C){super(),this._commandService=t,this._menuManagerService=e,this._dialogService=r,this._layoutService=n,this._uiPartsService=s,this._sheetRenderService=o,this._localeService=c,this._sheetsSortUIService=h,this._injector=m,this._componentManager=C,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){this._menuManagerService.mergeMenu(st)}_initCommands(){[N,L,$,U,H,A,Z,B,F,W].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(R.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._uiPartsService.registerComponent(E.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>d.connectInjector(Ve,this._injector))),[["CustomSortPanel",Ze],[P,z],[X,le],[K,Y],[J,de],[Q,ce]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))}),this._sheetsSortUIService.customSortState$.pipe(se.takeUntil(this.dispose$)).subscribe(t=>{t&&t.show&&t.location?this._openCustomSortPanel(t.location):t&&!(t!=null&&t.show)&&this._closePanel()})}_openCustomSortPanel(t){this._dialogService.open({id:re,draggable:!0,width:Ce,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${Ie.serializeRange(t.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:at(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(re),queueMicrotask(()=>this._layoutService.focus())}};j=it([w(0,a.ICommandService),w(1,d.IMenuManagerService),w(2,d.IDialogService),w(3,d.ILayoutService),w(4,d.IUIPartsService),w(5,a.Inject(E.SheetsRenderService)),w(6,a.Inject(a.LocaleService)),w(7,a.Inject(f)),w(8,a.Inject(a.Injector)),w(9,a.Inject(d.ComponentManager))],j);function at(){return{x:(window.innerWidth-Ce)/2,y:ct}}var lt=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,ut=(t,e,r)=>e in t?lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e,r,n)=>{for(var s=n>1?void 0:n?dt(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(s=c(s)||s);return s},ne=(t,e)=>(r,n)=>e(r,n,t),ve=(t,e,r)=>ut(t,typeof e!="symbol"?e+"":e,r);const mt="SHEET_SORT_UI_PLUGIN";exports.UniverSheetsSortUIPlugin=class extends a.Plugin{constructor(e=te,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{...s}=a.merge({},te,this._config);this._configService.setConfig(Me,s)}onStarting(){[[f],[j]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(j)}};ve(exports.UniverSheetsSortUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);ve(exports.UniverSheetsSortUIPlugin,"pluginName",mt);exports.UniverSheetsSortUIPlugin=ht([a.DependentOn(R.UniverSheetsSortPlugin),ne(1,a.Inject(a.Injector)),ne(2,a.IConfigService)],exports.UniverSheetsSortUIPlugin);exports.SortRangeAscCommand=N;exports.SortRangeAscExtCommand=L;exports.SortRangeAscExtInCtxMenuCommand=Z;exports.SortRangeAscInCtxMenuCommand=A;exports.SortRangeCustomCommand=H;exports.SortRangeCustomInCtxMenuCommand=W;exports.SortRangeDescCommand=$;exports.SortRangeDescExtCommand=U;exports.SortRangeDescExtInCtxMenuCommand=F;exports.SortRangeDescInCtxMenuCommand=B;
1
+ "use strict";var xe=Object.defineProperty;var ye=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var q=(t,e,r)=>ye(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),i=require("react/jsx-runtime"),d=require("@univerjs/sheets"),R=require("@univerjs/sheets-sort"),se=require("rxjs"),S=require("@univerjs/design"),u=require("@univerjs/ui"),l=require("react"),Ie=require("@univerjs/engine-formula"),E=require("@univerjs/sheets-ui"),_e=t=>{const[e,r]=l.useState("0"),n=u.useDependency(c.LocaleService);return i.jsxs("div",{className:"univer-text-sm",children:[i.jsx("div",{className:"extend-confirm-desc",children:n.t("sheets-sort.dialog.sort-reminder-desc")}),i.jsxs(S.RadioGroup,{className:"univer-mt-4",value:e,direction:"vertical",onChange:s=>{r(s),t.onChange(s)},children:[i.jsx(S.Radio,{value:"0",children:n.t("sheets-sort.dialog.sort-reminder-no")}),i.jsx(S.Radio,{value:"1",children:n.t("sheets-sort.dialog.sort-reminder-ext")})]})]})};var we=Object.getOwnPropertyDescriptor,Re=(t,e,r,n)=>{for(var s=n>1?void 0:n?we(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=a(s)||s);return s},T=(t,e)=>(r,n)=>e(r,n,t);const O={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(e,r,n,s,o,a){super();q(this,"_customSortState$",new se.BehaviorSubject(null));q(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=e,this._confirmService=r,this._selectionManagerService=n,this._sheetsSortService=s,this._localeService=o,this._commandService=a}async triggerSortDirectly(e,r,n){const s=n||await this._detectSortLocation(r);if(!s||!this._check(s))return!1;const a={orderRules:[{type:e?R.SortType.ASC:R.SortType.DESC,colIndex:s.colIndex}],range:s.range};return this._sheetsSortService.applySort(a,s.unitId,s.subUnitId),!0}async triggerSortCustomize(){const e=await this._detectSortLocation();return!e||!this._check(e)?!1:(this.showCustomSortPanel(e),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(e){var m,C;const r=(m=this.customSortState())==null?void 0:m.location;if(!r)return[];const{unitId:n,subUnitId:s,range:o}=r,a=(C=this._univerInstanceService.getUnit(n))==null?void 0:C.getSheetBySheetId(s);if(!a)return[];const h=Ee(this._localeService);return Array.from({length:o.endColumn-o.startColumn+1},(_,x)=>{var p;const M=(p=a.getCell(o.startRow,x+o.startColumn))==null?void 0:p.v;return{index:x+o.startColumn,label:e?`${M!=null?M:h(x+o.startColumn)}`:h(x+o.startColumn)}})}setSelection(e,r,n){var a;const s=(a=this._univerInstanceService.getUnit(e))==null?void 0:a.getSheetBySheetId(r);if(!s)return;const o={unitId:e,subUnitId:r,selections:[{range:n,primary:d.getPrimaryForRange(n,s),style:null}]};this._commandService.executeCommand(d.SetSelectionsOperation.id,o)}async showCheckError(e){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:i.jsx("div",{children:this._localeService.t(e)})},cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})}async showExtendConfirm(){let e=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:i.jsx(_e,{onChange:n=>{e=n==="1"}})},width:400,cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})?e?"extend":"keep":"cancel"}showCustomSortPanel(e){this._customSortState$.next({location:e,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(e){return this._sheetsSortService.singleCheck(e)?this._sheetsSortService.mergeCheck(e)?this._sheetsSortService.formulaCheck(e)?this._sheetsSortService.emptyCheck(e)?!0:(this.showCheckError(O.EMPTY_ERROR),!1):(this.showCheckError(O.FORMULA_ARRAY),!1):(this.showCheckError(O.MERGE_ERROR),!1):(this.showCheckError(O.SINGLE_ERROR),!1)}async _detectSortLocation(e){const r=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET),n=r.getActiveSheet(),s=r.getUnitId(),o=n.getSheetId(),a=this._selectionManagerService.getCurrentLastSelection();if(!a)return null;let h;if(e===!0)h=d.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},n),this.setSelection(s,o,h);else if(e===!1)h=a.range;else{const m=await this.showExtendConfirm();if(m==="cancel")return null;m==="keep"?h=a.range:(h=d.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},n),this.setSelection(s,o,h))}return{range:h,unitId:s,subUnitId:o,colIndex:a.primary.actualColumn}}};f=Re([T(0,c.IUniverInstanceService),T(1,c.IConfirmService),T(2,c.Inject(d.SheetsSelectionsService)),T(3,c.Inject(R.SheetsSortService)),T(4,c.Inject(c.LocaleService)),T(5,c.ICommandService)],f);function Ee(t){return e=>{const r=c.Tools.chatAtABC(e);switch(t.getCurrentLocale()){case c.LocaleType.ZH_CN:return`"${r}"列`;case c.LocaleType.EN_US:return`Column "${r}"`;default:return`Column "${r}"`}}}const N={id:"sheet.command.sort-range-asc",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!1)},L={id:"sheet.command.sort-range-asc-ext",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!0)},$={id:"sheet.command.sort-range-desc",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!1)},U={id:"sheet.command.sort-range-desc-ext",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!0)},H={id:"sheet.command.sort-range-custom",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortCustomize()},A={id:"sheet.command.sort-range-asc-ctx",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!1)},Z={id:"sheet.command.sort-range-asc-ext-ctx",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!0,!0)},B={id:"sheet.command.sort-range-desc-ctx",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!1)},F={id:"sheet.command.sort-range-desc-ext-ctx",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortDirectly(!1,!0)},W={id:"sheet.command.sort-range-custom-ctx",type:c.CommandType.COMMAND,handler:async t=>await t.get(f).triggerSortCustomize()},Me="sheets-sort-ui.config",te={};function I({ref:t,...e}){const{icon:r,id:n,className:s,extend:o,...a}=e,h=`univerjs-icon univerjs-icon-${n} ${s||""}`.trim(),m=l.useRef(`_${ke()}`);return oe(r,`${n}`,{defIds:r.defIds,idSuffix:m.current},{ref:t,className:h,...a},o)}function oe(t,e,r,n,s){return l.createElement(t.tag,{key:e,...Te(t,r,s),...n},(be(t,r).children||[]).map((o,a)=>oe(o,`${e}-${t.tag}-${a}`,r,void 0,s)))}function Te(t,e,r){const n={...t.attrs};r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([o,a])=>{o==="mask"&&typeof a=="string"&&(n[o]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:s}=e;return!s||s.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([o,a])=>{typeof a=="string"&&(n[o]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function be(t,e){var n;const{defIds:r}=e;return!r||r.length===0?t:t.tag==="defs"&&((n=t.children)!=null&&n.length)?{...t,children:t.children.map(s=>typeof s.attrs.id=="string"&&r&&r.includes(s.attrs.id)?{...s,attrs:{...s.attrs,id:s.attrs.id+e.idSuffix}}:s)}:t}function ke(){return Math.random().toString(36).substring(2,8)}I.displayName="UniverIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},z=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"ascending-icon",ref:r,icon:Pe}))});z.displayName="AscendingIcon";const De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ie=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"check-mark-icon",ref:r,icon:De}))});ie.displayName="CheckMarkIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.5574C8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507C9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661C11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512C7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574C6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588C4.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=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"custom-sort-icon",ref:r,icon:Oe}))});ce.displayName="CustomSortIcon";const je={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.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"}}]},ae=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"delete-empty-icon",ref:r,icon:je}))});ae.displayName="DeleteEmptyIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Y=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"descending-icon",ref:r,icon:Ne}))});Y.displayName="DescendingIcon";const Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},le=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"expand-ascending-icon",ref:r,icon:Le}))});le.displayName="ExpandAscendingIcon";const $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"expand-descending-icon",ref:r,icon:$e}))});de.displayName="ExpandDescendingIcon";const Ue={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},G=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"increase-icon",ref:r,icon:Ue}))});G.displayName="IncreaseIcon";const He={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ue=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"more-down-icon",ref:r,icon:He}))});ue.displayName="MoreDownIcon";const Ae={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},he=l.forwardRef(function(e,r){return l.createElement(I,Object.assign({},e,{id:"sequence-icon",ref:r,icon:Ae}))});he.displayName="SequenceIcon";function Ze(){const t=u.useDependency(f),e=u.useObservable(t.customSortState$);return!e||!e.location?null:i.jsx(Be,{state:e})}function Be({state:t}){const e=u.useDependency(R.SheetsSortService),r=u.useDependency(c.LocaleService),n=u.useDependency(f),[s,o]=l.useState(!1),[a,h]=l.useState(0),m=l.useRef(null),{range:C,unitId:_,subUnitId:x}=t.location,M=n.getTitles(s),[p,b]=l.useState([{type:R.SortType.ASC,colIndex:C.startColumn}]),D=l.useCallback((g,y)=>{const k=[...p];y===null?k.splice(g,1):k[g]=y,b(k)},[p]),v=l.useCallback(c.throttle(()=>{const g=[...p],y=We(C,p);y!==null&&(g.push({type:R.SortType.ASC,colIndex:y}),b(g))},200),[p,C]),V=l.useCallback((g,y)=>{e.applySort({range:C,orderRules:g,hasTitle:y}),n.closeCustomSortPanel()},[e,n,C]),Se=l.useCallback(()=>{n.closeCustomSortPanel()},[n]),fe=l.useCallback(g=>{o(g),g?n.setSelection(_,x,{...C,startRow:C.startRow+1}):n.setSelection(_,x,C)},[n,C,x,_]);l.useEffect(()=>{m.current&&p.length>5&&(m.current.scrollTop=m.current.scrollHeight)},[p]);const pe=p.length<M.length,ee=p.map(g=>({...g,id:`${g.colIndex}`}));return i.jsxs("div",{children:[i.jsxs("div",{onMouseDown:g=>{g.stopPropagation()},children:[i.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between",children:[i.jsx(S.Checkbox,{checked:s,onChange:g=>fe(!!g),children:r.t("sheets-sort.dialog.first-row-check")}),pe?i.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base",onClick:v,children:[i.jsx(G,{}),i.jsx("span",{className:"univer-ml-1.5",children:r.t("sheets-sort.dialog.add-condition")})]}):i.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base univer-text-primary-500 disabled:univer-cursor-not-allowed disabled:univer-divide-opacity-30 disabled:univer-text-gray-800",children:[i.jsx(G,{}),i.jsx("span",{className:"univer-ml-1.5 univer-text-xs",children:r.t("sheets-sort.dialog.add-condition")})]})]}),i.jsx("div",{ref:m,className:S.clsx("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden",S.scrollbarClassName),onScroll:g=>{const y=g.currentTarget.scrollTop;h(y)},children:i.jsx(S.DraggableList,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",list:ee,onListChange:b,idKey:"id",draggableHandle:"[data-u-comp=sort-panel-item-handler]",itemRender:g=>i.jsx(Fe,{titles:M,list:ee,item:g,onChange:(y,k)=>D(k,y),scrollPosition:a}),rowHeight:32,margin:[0,12]})})]}),i.jsxs("div",{className:"univer-mt-5 univer-flex univer-justify-end",children:[i.jsx(S.Button,{className:"univer-ml-3",onClick:()=>Se(),children:r.t("sheets-sort.dialog.cancel")}),i.jsx(S.Button,{className:"univer-ml-3",variant:"primary",onClick:()=>V(p,s),children:r.t("sheets-sort.dialog.confirm")})]})]})}function Fe(t){var D;const{list:e,item:r,titles:n,onChange:s,scrollPosition:o}=t,a=u.useDependency(c.LocaleService),h=n.filter(v=>!e.some(V=>V.colIndex===v.index)||v.index===r.colIndex),m=e.findIndex(v=>v.colIndex===r.colIndex),C=l.useCallback(v=>{s({...r,colIndex:v.index},m),x(!1)},[m,r,s]),[_,x]=l.useState(!1),M=v=>{x(v)};l.useEffect(()=>{x(!1)},[o]);const p=e.length>1,b=(D=n.find(v=>v.index===r.colIndex))==null?void 0:D.label;return i.jsxs("div",{className:"univer-grid univer-grid-flow-col univer-grid-cols-2 univer-items-center univer-gap-2",children:[i.jsxs("div",{className:"univer-flex univer-items-center",children:[i.jsx("div",{"data-u-comp":"sort-panel-item-handler",className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-text-base univer-text-gray-700",children:i.jsx(he,{})}),i.jsx(S.Dropdown,{overlay:i.jsx("ul",{className:S.clsx("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg",S.scrollbarClassName),children:h.map(v=>i.jsxs("li",{onClick:()=>C(v),className:"univer-relative univer-box-border univer-flex univer-h-7 univer-cursor-pointer univer-list-none univer-items-center univer-justify-between univer-rounded univer-px-2 univer-text-sm univer-transition-all hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:[i.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:v.label}),i.jsx("span",{children:v.index===r.colIndex&&i.jsx(ie,{})})]},v.index))}),open:_,onOpenChange:M,children:i.jsxs("div",{className:S.clsx("univer-ml-2 univer-flex univer-w-full univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-text-sm univer-text-gray-900 dark:!univer-text-white"),children:[i.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:b}),i.jsx(ue,{})]})})]}),i.jsxs("div",{className:"univer-flex univer-items-center univer-justify-end univer-gap-2",children:[i.jsxs(S.RadioGroup,{value:r.type,onChange:v=>{s({...r,type:v},m)},children:[i.jsx(S.Radio,{value:R.SortType.ASC,children:a.t("sheets-sort.general.sort-asc")}),i.jsx(S.Radio,{value:R.SortType.DESC,children:a.t("sheets-sort.general.sort-desc")})]}),i.jsx("a",{className:"univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-transition-colors hover:univer-text-red-500",onClick:()=>s(null,m),children:!p&&i.jsx(ae,{})})]})]})}function We(t,e){const{startColumn:r,endColumn:n}=t,s=new Set(e.map(o=>o==null?void 0:o.colIndex));for(let o=r;o<=n;o++)if(!s.has(o))return o;return null}function Ve(t){const{range:e,colIndex:r,onClose:n}=t,s=u.useDependency(f),o=u.useDependency(c.IUniverInstanceService),a=u.useDependency(c.LocaleService),h=l.useCallback(m=>{const{unitId:C,subUnitId:_}=d.getSheetCommandTarget(o)||{};if(e&&C&&_){const x={...e,startRow:e.startRow+1};s.triggerSortDirectly(m,!1,{unitId:C,subUnitId:_,range:x,colIndex:r})}else throw new Error(`Cannot find the target to sort. unitId: ${C}, subUnitId: ${_}, range: ${e}, colIndex: ${r}`);n()},[e,r,s,o,n]);return i.jsxs(S.ButtonGroup,{className:"univer-mb-3 univer-w-full univer-grid-cols-2",children:[i.jsxs(S.Button,{onClick:()=>h(!0),children:[i.jsx(z,{}),a.t("sheets-sort.general.sort-asc")]}),i.jsxs(S.Button,{onClick:()=>h(!1),children:[i.jsx(Y,{}),a.t("sheets-sort.general.sort-desc")]})]})}const me="sheet.menu.sheets-sort",ge="sheet.menu.sheets-sort-ctx",P="AscendingIcon",X="ExpandAscendingIcon",K="DescendingIcon",J="ExpandDescendingIcon",Q="CustomSortIcon";function qe(t){return{id:me,type:u.MenuItemType.SUBITEMS,icon:P,tooltip:"sheets-sort.general.sort",hidden$:u.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Ge(t){return{id:N.id,icon:P,title:"sheets-sort.general.sort-asc-cur",type:u.MenuItemType.BUTTON,hidden$:E.getCurrentExclusiveRangeInterest$(t)}}function ze(t){return{id:L.id,title:"sheets-sort.general.sort-asc-ext",icon:X,type:u.MenuItemType.BUTTON}}function Ye(t){return{id:$.id,title:"sheets-sort.general.sort-desc-cur",icon:K,type:u.MenuItemType.BUTTON}}function Xe(t){return{id:U.id,title:"sheets-sort.general.sort-desc-ext",icon:J,type:u.MenuItemType.BUTTON}}function Ke(t){return{id:H.id,title:"sheets-sort.general.sort-custom",type:u.MenuItemType.BUTTON,icon:Q}}function Je(t){return{id:ge,title:"sheets-sort.general.sort",type:u.MenuItemType.SUBITEMS,icon:P,hidden$:u.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function Qe(t){return{id:A.id,title:"sheets-sort.general.sort-asc-cur",type:u.MenuItemType.BUTTON,icon:P,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function et(t){return{id:Z.id,title:"sheets-sort.general.sort-asc-ext",type:u.MenuItemType.BUTTON,icon:X,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function tt(t){return{id:B.id,title:"sheets-sort.general.sort-desc-cur",type:u.MenuItemType.BUTTON,icon:K,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function rt(t){return{id:F.id,title:"sheets-sort.general.sort-desc-ext",type:u.MenuItemType.BUTTON,icon:J,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}function nt(t){return{id:W.id,title:"sheets-sort.general.sort-custom",type:u.MenuItemType.BUTTON,icon:Q,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[d.WorkbookEditablePermission],worksheetTypes:[d.WorksheetSortPermission,d.WorksheetEditPermission],rangeTypes:[d.RangeProtectionPermissionEditPoint]})}}const st={[u.RibbonDataGroup.ORGANIZATION]:{[me]:{order:3,menuItemFactory:qe,[N.id]:{order:0,menuItemFactory:Ge},[L.id]:{order:1,menuItemFactory:ze},[$.id]:{order:2,menuItemFactory:Ye},[U.id]:{order:3,menuItemFactory:Xe},[H.id]:{order:4,menuItemFactory:Ke}}},[u.ContextMenuPosition.MAIN_AREA]:{[u.ContextMenuGroup.DATA]:{[ge]:{order:0,menuItemFactory:Je,[A.id]:{order:0,menuItemFactory:Qe},[Z.id]:{order:1,menuItemFactory:et},[B.id]:{order:2,menuItemFactory:tt},[F.id]:{order:3,menuItemFactory:rt},[W.id]:{order:4,menuItemFactory:nt}}}}};var ot=Object.getOwnPropertyDescriptor,it=(t,e,r,n)=>{for(var s=n>1?void 0:n?ot(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=a(s)||s);return s},w=(t,e)=>(r,n)=>e(r,n,t);const re="custom-sort-dialog",Ce=560,ct=128;let j=class extends c.RxDisposable{constructor(t,e,r,n,s,o,a,h,m,C){super(),this._commandService=t,this._menuManagerService=e,this._dialogService=r,this._layoutService=n,this._uiPartsService=s,this._sheetRenderService=o,this._localeService=a,this._sheetsSortUIService=h,this._injector=m,this._componentManager=C,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){this._menuManagerService.mergeMenu(st)}_initCommands(){[N,L,$,U,H,A,Z,B,F,W].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(R.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._uiPartsService.registerComponent(E.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>u.connectInjector(Ve,this._injector))),[["CustomSortPanel",Ze],[P,z],[X,le],[K,Y],[J,de],[Q,ce]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))}),this._sheetsSortUIService.customSortState$.pipe(se.takeUntil(this.dispose$)).subscribe(t=>{t&&t.show&&t.location?this._openCustomSortPanel(t.location):t&&!(t!=null&&t.show)&&this._closePanel()})}_openCustomSortPanel(t){this._dialogService.open({id:re,draggable:!0,width:Ce,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${Ie.serializeRange(t.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:at(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(re),queueMicrotask(()=>this._layoutService.focus())}};j=it([w(0,c.ICommandService),w(1,u.IMenuManagerService),w(2,u.IDialogService),w(3,u.ILayoutService),w(4,u.IUIPartsService),w(5,c.Inject(E.SheetsRenderService)),w(6,c.Inject(c.LocaleService)),w(7,c.Inject(f)),w(8,c.Inject(c.Injector)),w(9,c.Inject(u.ComponentManager))],j);function at(){return{x:(window.innerWidth-Ce)/2,y:ct}}var lt=Object.defineProperty,dt=Object.getOwnPropertyDescriptor,ut=(t,e,r)=>e in t?lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ht=(t,e,r,n)=>{for(var s=n>1?void 0:n?dt(e,r):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(s=a(s)||s);return s},ne=(t,e)=>(r,n)=>e(r,n,t),ve=(t,e,r)=>ut(t,typeof e!="symbol"?e+"":e,r);const mt="SHEET_SORT_UI_PLUGIN";exports.UniverSheetsSortUIPlugin=class extends c.Plugin{constructor(e=te,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{...s}=c.merge({},te,this._config);this._configService.setConfig(Me,s)}onStarting(){[[f],[j]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(j)}};ve(exports.UniverSheetsSortUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);ve(exports.UniverSheetsSortUIPlugin,"pluginName",mt);exports.UniverSheetsSortUIPlugin=ht([c.DependentOn(R.UniverSheetsSortPlugin),ne(1,c.Inject(c.Injector)),ne(2,c.IConfigService)],exports.UniverSheetsSortUIPlugin);exports.SortRangeAscCommand=N;exports.SortRangeAscExtCommand=L;exports.SortRangeAscExtInCtxMenuCommand=Z;exports.SortRangeAscInCtxMenuCommand=A;exports.SortRangeCustomCommand=H;exports.SortRangeCustomInCtxMenuCommand=W;exports.SortRangeDescCommand=$;exports.SortRangeDescExtCommand=U;exports.SortRangeDescExtInCtxMenuCommand=F;exports.SortRangeDescInCtxMenuCommand=B;
package/lib/es/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var Ve = Object.defineProperty;
2
2
  var Ge = (e, t, r) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var Y = (e, t, r) => Ge(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { LocaleService as H, IUniverInstanceService as xe, Inject as M, ICommandService as _e, Disposable as We, UniverInstanceType as q, Tools as qe, LocaleType as me, CommandType as I, throttle as ze, Injector as ye, RxDisposable as Ye, DependentOn as Xe, IConfigService as Ke, Plugin as Je, merge as Qe } from "@univerjs/core";
4
+ import { LocaleService as H, IUniverInstanceService as xe, IConfirmService as We, Inject as M, ICommandService as _e, Disposable as qe, UniverInstanceType as q, Tools as ze, LocaleType as me, CommandType as I, throttle as Ye, Injector as ye, RxDisposable as Xe, DependentOn as Ke, IConfigService as Je, Plugin as Qe, merge as et } from "@univerjs/core";
5
5
  import { jsxs as g, jsx as c } from "react/jsx-runtime";
6
- import { SheetsSelectionsService as et, getPrimaryForRange as tt, SetSelectionsOperation as rt, expandToContinuousRange as ve, getSheetCommandTarget as nt, RangeProtectionPermissionEditPoint as b, WorksheetSortPermission as O, WorksheetEditPermission as N, WorkbookEditablePermission as L } from "@univerjs/sheets";
7
- import { SheetsSortService as Ie, SortType as $, SortRangeCommand as ot, UniverSheetsSortPlugin as st } from "@univerjs/sheets-sort";
8
- import { useDependency as R, IConfirmService as it, useObservable as ct, MenuItemType as f, getMenuHiddenObservable as we, ContextMenuPosition as at, ContextMenuGroup as lt, RibbonDataGroup as dt, IMenuManagerService as ut, IDialogService as ht, ILayoutService as gt, IUIPartsService as Ct, ComponentManager as mt, connectInjector as vt } from "@univerjs/ui";
9
- import { BehaviorSubject as ft, takeUntil as St } from "rxjs";
10
- import { RadioGroup as Me, Radio as F, Checkbox as pt, clsx as X, DraggableList as xt, scrollbarClassName as Re, Button as V, Dropdown as _t, ButtonGroup as yt } from "@univerjs/design";
6
+ import { SheetsSelectionsService as tt, getPrimaryForRange as rt, SetSelectionsOperation as nt, expandToContinuousRange as ve, getSheetCommandTarget as ot, RangeProtectionPermissionEditPoint as b, WorksheetSortPermission as O, WorksheetEditPermission as N, WorkbookEditablePermission as L } from "@univerjs/sheets";
7
+ import { SheetsSortService as Ie, SortType as $, SortRangeCommand as st, UniverSheetsSortPlugin as it } from "@univerjs/sheets-sort";
8
+ import { BehaviorSubject as ct, takeUntil as at } from "rxjs";
9
+ import { RadioGroup as we, Radio as F, Checkbox as lt, clsx as X, DraggableList as dt, scrollbarClassName as Me, Button as V, Dropdown as ut, ButtonGroup as ht } from "@univerjs/design";
10
+ import { useDependency as R, useObservable as gt, MenuItemType as f, getMenuHiddenObservable as Re, ContextMenuPosition as Ct, ContextMenuGroup as mt, RibbonDataGroup as vt, IMenuManagerService as ft, IDialogService as St, ILayoutService as pt, IUIPartsService as xt, ComponentManager as _t, connectInjector as yt } from "@univerjs/ui";
11
11
  import { useState as P, useRef as Ee, createElement as p, forwardRef as w, useCallback as T, useEffect as Te } from "react";
12
12
  import { serializeRange as It } from "@univerjs/engine-formula";
13
13
  import { getCurrentRangeDisable$ as k, getCurrentExclusiveRangeInterest$ as wt, SheetsRenderService as Mt, SheetsUIPart as Rt } from "@univerjs/sheets-ui";
@@ -16,7 +16,7 @@ const Et = (e) => {
16
16
  return /* @__PURE__ */ g("div", { className: "univer-text-sm", children: [
17
17
  /* @__PURE__ */ c("div", { className: "extend-confirm-desc", children: n.t("sheets-sort.dialog.sort-reminder-desc") }),
18
18
  /* @__PURE__ */ g(
19
- Me,
19
+ we,
20
20
  {
21
21
  className: "univer-mt-4",
22
22
  value: t,
@@ -43,10 +43,10 @@ const B = {
43
43
  SINGLE_ERROR: "sheets-sort.error.single",
44
44
  FORMULA_ARRAY: "sheets-sort.error.formula-array"
45
45
  };
46
- let C = class extends We {
46
+ let C = class extends qe {
47
47
  constructor(t, r, n, o, s, i) {
48
48
  super();
49
- Y(this, "_customSortState$", new ft(null));
49
+ Y(this, "_customSortState$", new ct(null));
50
50
  Y(this, "customSortState$", this._customSortState$.asObservable());
51
51
  this._univerInstanceService = t, this._confirmService = r, this._selectionManagerService = n, this._sheetsSortService = o, this._localeService = s, this._commandService = i;
52
52
  }
@@ -96,9 +96,9 @@ let C = class extends We {
96
96
  const s = {
97
97
  unitId: t,
98
98
  subUnitId: r,
99
- selections: [{ range: n, primary: tt(n, o), style: null }]
99
+ selections: [{ range: n, primary: rt(n, o), style: null }]
100
100
  };
101
- this._commandService.executeCommand(rt.id, s);
101
+ this._commandService.executeCommand(nt.id, s);
102
102
  }
103
103
  async showCheckError(t) {
104
104
  return await this._confirmService.confirm({
@@ -169,15 +169,15 @@ let C = class extends We {
169
169
  };
170
170
  C = bt([
171
171
  D(0, xe),
172
- D(1, it),
173
- D(2, M(et)),
172
+ D(1, We),
173
+ D(2, M(tt)),
174
174
  D(3, M(Ie)),
175
175
  D(4, M(H)),
176
176
  D(5, _e)
177
177
  ], C);
178
178
  function Ot(e) {
179
179
  return (t) => {
180
- const r = qe.chatAtABC(t);
180
+ const r = ze.chatAtABC(t);
181
181
  switch (e.getCurrentLocale()) {
182
182
  case me.ZH_CN:
183
183
  return `"${r}"列`;
@@ -649,7 +649,7 @@ const Vt = {
649
649
  });
650
650
  He.displayName = "SequenceIcon";
651
651
  function Gt() {
652
- const e = R(C), t = ct(e.customSortState$);
652
+ const e = R(C), t = gt(e.customSortState$);
653
653
  return !t || !t.location ? null : /* @__PURE__ */ c(Wt, { state: t });
654
654
  }
655
655
  function Wt({ state: e }) {
@@ -659,7 +659,7 @@ function Wt({ state: e }) {
659
659
  const U = [...m];
660
660
  S === null ? U.splice(d, 1) : U[d] = S, A(U);
661
661
  }, [m]), h = T(
662
- ze(() => {
662
+ Ye(() => {
663
663
  const d = [...m], S = zt(u, m);
664
664
  S !== null && (d.push({ type: $.ASC, colIndex: S }), A(d));
665
665
  }, 200),
@@ -680,7 +680,7 @@ function Wt({ state: e }) {
680
680
  d.stopPropagation();
681
681
  }, children: [
682
682
  /* @__PURE__ */ g("div", { className: "univer-flex univer-items-center univer-justify-between", children: [
683
- /* @__PURE__ */ c(pt, { checked: o, onChange: (d) => Be(!!d), children: r.t("sheets-sort.dialog.first-row-check") }),
683
+ /* @__PURE__ */ c(lt, { checked: o, onChange: (d) => Be(!!d), children: r.t("sheets-sort.dialog.first-row-check") }),
684
684
  Fe ? /* @__PURE__ */ g(
685
685
  "div",
686
686
  {
@@ -706,13 +706,13 @@ function Wt({ state: e }) {
706
706
  "div",
707
707
  {
708
708
  ref: l,
709
- className: X("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden", Re),
709
+ className: X("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden", Me),
710
710
  onScroll: (d) => {
711
711
  const S = d.currentTarget.scrollTop;
712
712
  a(S);
713
713
  },
714
714
  children: /* @__PURE__ */ c(
715
- xt,
715
+ dt,
716
716
  {
717
717
  className: "[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",
718
718
  list: Ce,
@@ -779,12 +779,12 @@ function qt(e) {
779
779
  }
780
780
  ),
781
781
  /* @__PURE__ */ c(
782
- _t,
782
+ ut,
783
783
  {
784
784
  overlay: /* @__PURE__ */ c(
785
785
  "ul",
786
786
  {
787
- className: X("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg", Re),
787
+ className: X("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg", Me),
788
788
  children: a.map((h) => /* @__PURE__ */ g(
789
789
  "li",
790
790
  {
@@ -822,7 +822,7 @@ function qt(e) {
822
822
  ] }),
823
823
  /* @__PURE__ */ g("div", { className: "univer-flex univer-items-center univer-justify-end univer-gap-2", children: [
824
824
  /* @__PURE__ */ g(
825
- Me,
825
+ we,
826
826
  {
827
827
  value: r.type,
828
828
  onChange: (h) => {
@@ -854,7 +854,7 @@ function zt(e, t) {
854
854
  }
855
855
  function Yt(e) {
856
856
  const { range: t, colIndex: r, onClose: n } = e, o = R(C), s = R(xe), i = R(H), a = T((l) => {
857
- const { unitId: u, subUnitId: _ } = nt(s) || {};
857
+ const { unitId: u, subUnitId: _ } = ot(s) || {};
858
858
  if (t && u && _) {
859
859
  const v = { ...t, startRow: t.startRow + 1 };
860
860
  o.triggerSortDirectly(l, !1, { unitId: u, subUnitId: _, range: v, colIndex: r });
@@ -862,7 +862,7 @@ function Yt(e) {
862
862
  throw new Error(`Cannot find the target to sort. unitId: ${u}, subUnitId: ${_}, range: ${t}, colIndex: ${r}`);
863
863
  n();
864
864
  }, [t, r, o, s, n]);
865
- return /* @__PURE__ */ g(yt, { className: "univer-mb-3 univer-w-full univer-grid-cols-2", children: [
865
+ return /* @__PURE__ */ g(ht, { className: "univer-mb-3 univer-w-full univer-grid-cols-2", children: [
866
866
  /* @__PURE__ */ g(V, { onClick: () => a(!0), children: [
867
867
  /* @__PURE__ */ c(ae, {}),
868
868
  i.t("sheets-sort.general.sort-asc")
@@ -880,7 +880,7 @@ function Xt(e) {
880
880
  type: f.SUBITEMS,
881
881
  icon: Z,
882
882
  tooltip: "sheets-sort.general.sort",
883
- hidden$: we(e, q.UNIVER_SHEET),
883
+ hidden$: Re(e, q.UNIVER_SHEET),
884
884
  disabled$: k(e, { workbookTypes: [L], worksheetTypes: [O, N], rangeTypes: [b] })
885
885
  };
886
886
  }
@@ -931,7 +931,7 @@ function rr(e) {
931
931
  title: "sheets-sort.general.sort",
932
932
  type: f.SUBITEMS,
933
933
  icon: Z,
934
- hidden$: we(e, q.UNIVER_SHEET),
934
+ hidden$: Re(e, q.UNIVER_SHEET),
935
935
  disabled$: k(e, {
936
936
  workbookTypes: [L],
937
937
  worksheetTypes: [O, N],
@@ -985,7 +985,7 @@ function cr(e) {
985
985
  };
986
986
  }
987
987
  const ar = {
988
- [dt.ORGANIZATION]: {
988
+ [vt.ORGANIZATION]: {
989
989
  [Ae]: {
990
990
  order: 3,
991
991
  menuItemFactory: Xt,
@@ -1011,8 +1011,8 @@ const ar = {
1011
1011
  }
1012
1012
  }
1013
1013
  },
1014
- [at.MAIN_AREA]: {
1015
- [lt.DATA]: {
1014
+ [Ct.MAIN_AREA]: {
1015
+ [mt.DATA]: {
1016
1016
  [Ue]: {
1017
1017
  order: 0,
1018
1018
  menuItemFactory: rr,
@@ -1046,7 +1046,7 @@ var lr = Object.getOwnPropertyDescriptor, dr = (e, t, r, n) => {
1046
1046
  return o;
1047
1047
  }, y = (e, t) => (r, n) => t(r, n, e);
1048
1048
  const Se = "custom-sort-dialog", Pe = 560, ur = 128;
1049
- let G = class extends Ye {
1049
+ let G = class extends Xe {
1050
1050
  constructor(e, t, r, n, o, s, i, a, l, u) {
1051
1051
  super(), this._commandService = e, this._menuManagerService = t, this._dialogService = r, this._layoutService = n, this._uiPartsService = o, this._sheetRenderService = s, this._localeService = i, this._sheetsSortUIService = a, this._injector = l, this._componentManager = u, this._initCommands(), this._initMenu(), this._initUI();
1052
1052
  }
@@ -1065,11 +1065,11 @@ let G = class extends Ye {
1065
1065
  se,
1066
1066
  ie,
1067
1067
  ce
1068
- ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(ot.id));
1068
+ ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(st.id));
1069
1069
  }
1070
1070
  _initUI() {
1071
1071
  this.disposeWithMe(
1072
- this._uiPartsService.registerComponent(Rt.FILTER_PANEL_EMBED_POINT, () => vt(Yt, this._injector))
1072
+ this._uiPartsService.registerComponent(Rt.FILTER_PANEL_EMBED_POINT, () => yt(Yt, this._injector))
1073
1073
  ), [
1074
1074
  ["CustomSortPanel", Gt],
1075
1075
  [Z, ae],
@@ -1081,7 +1081,7 @@ let G = class extends Ye {
1081
1081
  this.disposeWithMe(
1082
1082
  this._componentManager.register(e, t)
1083
1083
  );
1084
- }), this._sheetsSortUIService.customSortState$.pipe(St(this.dispose$)).subscribe((e) => {
1084
+ }), this._sheetsSortUIService.customSortState$.pipe(at(this.dispose$)).subscribe((e) => {
1085
1085
  e && e.show && e.location ? this._openCustomSortPanel(e.location) : e && !(e != null && e.show) && this._closePanel();
1086
1086
  });
1087
1087
  }
@@ -1105,15 +1105,15 @@ let G = class extends Ye {
1105
1105
  };
1106
1106
  G = dr([
1107
1107
  y(0, _e),
1108
- y(1, ut),
1109
- y(2, ht),
1110
- y(3, gt),
1111
- y(4, Ct),
1108
+ y(1, ft),
1109
+ y(2, St),
1110
+ y(3, pt),
1111
+ y(4, xt),
1112
1112
  y(5, M(Mt)),
1113
1113
  y(6, M(H)),
1114
1114
  y(7, M(C)),
1115
1115
  y(8, M(ye)),
1116
- y(9, M(mt))
1116
+ y(9, M(_t))
1117
1117
  ], G);
1118
1118
  function hr() {
1119
1119
  return { x: (window.innerWidth - Pe) / 2, y: ur };
@@ -1124,10 +1124,10 @@ var gr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, mr = (e, t
1124
1124
  return o;
1125
1125
  }, pe = (e, t) => (r, n) => t(r, n, e), Ze = (e, t, r) => mr(e, typeof t != "symbol" ? t + "" : t, r);
1126
1126
  const fr = "SHEET_SORT_UI_PLUGIN";
1127
- let W = class extends Je {
1127
+ let W = class extends Qe {
1128
1128
  constructor(e = fe, t, r) {
1129
1129
  super(), this._config = e, this._injector = t, this._configService = r;
1130
- const { ...n } = Qe(
1130
+ const { ...n } = et(
1131
1131
  {},
1132
1132
  fe,
1133
1133
  this._config
@@ -1147,9 +1147,9 @@ let W = class extends Je {
1147
1147
  Ze(W, "type", q.UNIVER_SHEET);
1148
1148
  Ze(W, "pluginName", fr);
1149
1149
  W = vr([
1150
- Xe(st),
1150
+ Ke(it),
1151
1151
  pe(1, M(ye)),
1152
- pe(2, Ke)
1152
+ pe(2, Je)
1153
1153
  ], W);
1154
1154
  export {
1155
1155
  J as SortRangeAscCommand,
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-relative{position:relative}.univer-my-0{margin-top:0;margin-bottom:0}.univer-mb-3{margin-bottom:.75rem}.univer-ml-1\.5{margin-left:.375rem}.univer-ml-2{margin-left:.5rem}.univer-ml-3{margin-left:.75rem}.univer-mt-4{margin-top:1rem}.univer-mt-5{margin-top:1.25rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-grid{display:grid}.univer-h-7{height:1.75rem}.univer-max-h-\[310px\]{max-height:310px}.univer-w-\[640px\]{width:640px}.univer-w-\[var\(--radix-popper-anchor-width\)\]{width:var(--radix-popper-anchor-width)}.univer-w-full{width:100%}.univer-max-w-\[220px\]{max-width:220px}.univer-cursor-pointer{cursor:pointer}.univer-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-list-none{list-style-type:none}.univer-grid-flow-col{grid-auto-flow:column}.univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-1{gap:.25rem}.univer-gap-2{gap:.5rem}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-1{padding:.25rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-text-base{font-size:1rem;line-height:1.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-700{color:var(--univer-gray-700)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-shadow-lg{--univer-tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--univer-tw-shadow-colored: 0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-shadow)}.univer-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-text-red-500:hover{color:var(--univer-red-500)}.disabled\:univer-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:univer-divide-opacity-30:disabled>:not([hidden])~:not([hidden]){--univer-tw-divide-opacity: .3 }.disabled\:univer-text-gray-800:disabled{color:var(--univer-gray-800)}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.\[\&_\.react-grid-item\]\:univer-transition-none .react-grid-item{transition-property:none}.\[\&_\.react-grid-placeholder\]\:univer-rounded .react-grid-placeholder{border-radius:.25rem}.\[\&_\.react-grid-placeholder\]\:\!univer-bg-gray-200 .react-grid-placeholder{background-color:var(--univer-gray-200)!important}
1
+ .univer-relative{position:relative}.univer-my-0{margin-top:0;margin-bottom:0}.univer-mb-3{margin-bottom:.75rem}.univer-ml-1\.5{margin-left:.375rem}.univer-ml-2{margin-left:.5rem}.univer-ml-3{margin-left:.75rem}.univer-mt-4{margin-top:1rem}.univer-mt-5{margin-top:1.25rem}.univer-box-border{box-sizing:border-box}.univer-flex{display:flex}.univer-grid{display:grid}.univer-h-7{height:1.75rem}.univer-max-h-\[310px\]{max-height:310px}.univer-w-\[var\(--radix-popper-anchor-width\)\]{width:var(--radix-popper-anchor-width)}.univer-w-full{width:100%}.univer-max-w-\[220px\]{max-width:220px}.univer-cursor-pointer{cursor:pointer}.univer-select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-list-none{list-style-type:none}.univer-grid-flow-col{grid-auto-flow:column}.univer-grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.univer-items-center{align-items:center}.univer-justify-end{justify-content:flex-end}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-1{gap:.25rem}.univer-gap-2{gap:.5rem}.univer-overflow-hidden{overflow:hidden}.univer-overflow-y-auto{overflow-y:auto}.univer-overflow-x-hidden{overflow-x:hidden}.univer-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-rounded{border-radius:.25rem}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-bg-white{background-color:var(--univer-white)}.univer-p-1{padding:.25rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.univer-text-base{font-size:1rem;line-height:1.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-text-gray-700{color:var(--univer-gray-700)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-shadow-lg{--univer-tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--univer-tw-shadow-colored: 0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-shadow)}.univer-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.univer-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-bg-gray-100:hover{background-color:var(--univer-gray-100)}.hover\:univer-text-red-500:hover{color:var(--univer-red-500)}.disabled\:univer-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:univer-divide-opacity-30:disabled>:not([hidden])~:not([hidden]){--univer-tw-divide-opacity: .3 }.disabled\:univer-text-gray-800:disabled{color:var(--univer-gray-800)}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-700:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.\[\&_\.react-grid-item\]\:univer-transition-none .react-grid-item{transition-property:none}.\[\&_\.react-grid-placeholder\]\:univer-rounded .react-grid-placeholder{border-radius:.25rem}.\[\&_\.react-grid-placeholder\]\:\!univer-bg-gray-200 .react-grid-placeholder{background-color:var(--univer-gray-200)!important}
package/lib/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var Ve = Object.defineProperty;
2
2
  var Ge = (e, t, r) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var Y = (e, t, r) => Ge(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { LocaleService as H, IUniverInstanceService as xe, Inject as M, ICommandService as _e, Disposable as We, UniverInstanceType as q, Tools as qe, LocaleType as me, CommandType as I, throttle as ze, Injector as ye, RxDisposable as Ye, DependentOn as Xe, IConfigService as Ke, Plugin as Je, merge as Qe } from "@univerjs/core";
4
+ import { LocaleService as H, IUniverInstanceService as xe, IConfirmService as We, Inject as M, ICommandService as _e, Disposable as qe, UniverInstanceType as q, Tools as ze, LocaleType as me, CommandType as I, throttle as Ye, Injector as ye, RxDisposable as Xe, DependentOn as Ke, IConfigService as Je, Plugin as Qe, merge as et } from "@univerjs/core";
5
5
  import { jsxs as g, jsx as c } from "react/jsx-runtime";
6
- import { SheetsSelectionsService as et, getPrimaryForRange as tt, SetSelectionsOperation as rt, expandToContinuousRange as ve, getSheetCommandTarget as nt, RangeProtectionPermissionEditPoint as b, WorksheetSortPermission as O, WorksheetEditPermission as N, WorkbookEditablePermission as L } from "@univerjs/sheets";
7
- import { SheetsSortService as Ie, SortType as $, SortRangeCommand as ot, UniverSheetsSortPlugin as st } from "@univerjs/sheets-sort";
8
- import { useDependency as R, IConfirmService as it, useObservable as ct, MenuItemType as f, getMenuHiddenObservable as we, ContextMenuPosition as at, ContextMenuGroup as lt, RibbonDataGroup as dt, IMenuManagerService as ut, IDialogService as ht, ILayoutService as gt, IUIPartsService as Ct, ComponentManager as mt, connectInjector as vt } from "@univerjs/ui";
9
- import { BehaviorSubject as ft, takeUntil as St } from "rxjs";
10
- import { RadioGroup as Me, Radio as F, Checkbox as pt, clsx as X, DraggableList as xt, scrollbarClassName as Re, Button as V, Dropdown as _t, ButtonGroup as yt } from "@univerjs/design";
6
+ import { SheetsSelectionsService as tt, getPrimaryForRange as rt, SetSelectionsOperation as nt, expandToContinuousRange as ve, getSheetCommandTarget as ot, RangeProtectionPermissionEditPoint as b, WorksheetSortPermission as O, WorksheetEditPermission as N, WorkbookEditablePermission as L } from "@univerjs/sheets";
7
+ import { SheetsSortService as Ie, SortType as $, SortRangeCommand as st, UniverSheetsSortPlugin as it } from "@univerjs/sheets-sort";
8
+ import { BehaviorSubject as ct, takeUntil as at } from "rxjs";
9
+ import { RadioGroup as we, Radio as F, Checkbox as lt, clsx as X, DraggableList as dt, scrollbarClassName as Me, Button as V, Dropdown as ut, ButtonGroup as ht } from "@univerjs/design";
10
+ import { useDependency as R, useObservable as gt, MenuItemType as f, getMenuHiddenObservable as Re, ContextMenuPosition as Ct, ContextMenuGroup as mt, RibbonDataGroup as vt, IMenuManagerService as ft, IDialogService as St, ILayoutService as pt, IUIPartsService as xt, ComponentManager as _t, connectInjector as yt } from "@univerjs/ui";
11
11
  import { useState as P, useRef as Ee, createElement as p, forwardRef as w, useCallback as T, useEffect as Te } from "react";
12
12
  import { serializeRange as It } from "@univerjs/engine-formula";
13
13
  import { getCurrentRangeDisable$ as k, getCurrentExclusiveRangeInterest$ as wt, SheetsRenderService as Mt, SheetsUIPart as Rt } from "@univerjs/sheets-ui";
@@ -16,7 +16,7 @@ const Et = (e) => {
16
16
  return /* @__PURE__ */ g("div", { className: "univer-text-sm", children: [
17
17
  /* @__PURE__ */ c("div", { className: "extend-confirm-desc", children: n.t("sheets-sort.dialog.sort-reminder-desc") }),
18
18
  /* @__PURE__ */ g(
19
- Me,
19
+ we,
20
20
  {
21
21
  className: "univer-mt-4",
22
22
  value: t,
@@ -43,10 +43,10 @@ const B = {
43
43
  SINGLE_ERROR: "sheets-sort.error.single",
44
44
  FORMULA_ARRAY: "sheets-sort.error.formula-array"
45
45
  };
46
- let C = class extends We {
46
+ let C = class extends qe {
47
47
  constructor(t, r, n, o, s, i) {
48
48
  super();
49
- Y(this, "_customSortState$", new ft(null));
49
+ Y(this, "_customSortState$", new ct(null));
50
50
  Y(this, "customSortState$", this._customSortState$.asObservable());
51
51
  this._univerInstanceService = t, this._confirmService = r, this._selectionManagerService = n, this._sheetsSortService = o, this._localeService = s, this._commandService = i;
52
52
  }
@@ -96,9 +96,9 @@ let C = class extends We {
96
96
  const s = {
97
97
  unitId: t,
98
98
  subUnitId: r,
99
- selections: [{ range: n, primary: tt(n, o), style: null }]
99
+ selections: [{ range: n, primary: rt(n, o), style: null }]
100
100
  };
101
- this._commandService.executeCommand(rt.id, s);
101
+ this._commandService.executeCommand(nt.id, s);
102
102
  }
103
103
  async showCheckError(t) {
104
104
  return await this._confirmService.confirm({
@@ -169,15 +169,15 @@ let C = class extends We {
169
169
  };
170
170
  C = bt([
171
171
  D(0, xe),
172
- D(1, it),
173
- D(2, M(et)),
172
+ D(1, We),
173
+ D(2, M(tt)),
174
174
  D(3, M(Ie)),
175
175
  D(4, M(H)),
176
176
  D(5, _e)
177
177
  ], C);
178
178
  function Ot(e) {
179
179
  return (t) => {
180
- const r = qe.chatAtABC(t);
180
+ const r = ze.chatAtABC(t);
181
181
  switch (e.getCurrentLocale()) {
182
182
  case me.ZH_CN:
183
183
  return `"${r}"列`;
@@ -649,7 +649,7 @@ const Vt = {
649
649
  });
650
650
  He.displayName = "SequenceIcon";
651
651
  function Gt() {
652
- const e = R(C), t = ct(e.customSortState$);
652
+ const e = R(C), t = gt(e.customSortState$);
653
653
  return !t || !t.location ? null : /* @__PURE__ */ c(Wt, { state: t });
654
654
  }
655
655
  function Wt({ state: e }) {
@@ -659,7 +659,7 @@ function Wt({ state: e }) {
659
659
  const U = [...m];
660
660
  S === null ? U.splice(d, 1) : U[d] = S, A(U);
661
661
  }, [m]), h = T(
662
- ze(() => {
662
+ Ye(() => {
663
663
  const d = [...m], S = zt(u, m);
664
664
  S !== null && (d.push({ type: $.ASC, colIndex: S }), A(d));
665
665
  }, 200),
@@ -680,7 +680,7 @@ function Wt({ state: e }) {
680
680
  d.stopPropagation();
681
681
  }, children: [
682
682
  /* @__PURE__ */ g("div", { className: "univer-flex univer-items-center univer-justify-between", children: [
683
- /* @__PURE__ */ c(pt, { checked: o, onChange: (d) => Be(!!d), children: r.t("sheets-sort.dialog.first-row-check") }),
683
+ /* @__PURE__ */ c(lt, { checked: o, onChange: (d) => Be(!!d), children: r.t("sheets-sort.dialog.first-row-check") }),
684
684
  Fe ? /* @__PURE__ */ g(
685
685
  "div",
686
686
  {
@@ -706,13 +706,13 @@ function Wt({ state: e }) {
706
706
  "div",
707
707
  {
708
708
  ref: l,
709
- className: X("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden", Re),
709
+ className: X("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden", Me),
710
710
  onScroll: (d) => {
711
711
  const S = d.currentTarget.scrollTop;
712
712
  a(S);
713
713
  },
714
714
  children: /* @__PURE__ */ c(
715
- xt,
715
+ dt,
716
716
  {
717
717
  className: "[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",
718
718
  list: Ce,
@@ -779,12 +779,12 @@ function qt(e) {
779
779
  }
780
780
  ),
781
781
  /* @__PURE__ */ c(
782
- _t,
782
+ ut,
783
783
  {
784
784
  overlay: /* @__PURE__ */ c(
785
785
  "ul",
786
786
  {
787
- className: X("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg", Re),
787
+ className: X("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg", Me),
788
788
  children: a.map((h) => /* @__PURE__ */ g(
789
789
  "li",
790
790
  {
@@ -822,7 +822,7 @@ function qt(e) {
822
822
  ] }),
823
823
  /* @__PURE__ */ g("div", { className: "univer-flex univer-items-center univer-justify-end univer-gap-2", children: [
824
824
  /* @__PURE__ */ g(
825
- Me,
825
+ we,
826
826
  {
827
827
  value: r.type,
828
828
  onChange: (h) => {
@@ -854,7 +854,7 @@ function zt(e, t) {
854
854
  }
855
855
  function Yt(e) {
856
856
  const { range: t, colIndex: r, onClose: n } = e, o = R(C), s = R(xe), i = R(H), a = T((l) => {
857
- const { unitId: u, subUnitId: _ } = nt(s) || {};
857
+ const { unitId: u, subUnitId: _ } = ot(s) || {};
858
858
  if (t && u && _) {
859
859
  const v = { ...t, startRow: t.startRow + 1 };
860
860
  o.triggerSortDirectly(l, !1, { unitId: u, subUnitId: _, range: v, colIndex: r });
@@ -862,7 +862,7 @@ function Yt(e) {
862
862
  throw new Error(`Cannot find the target to sort. unitId: ${u}, subUnitId: ${_}, range: ${t}, colIndex: ${r}`);
863
863
  n();
864
864
  }, [t, r, o, s, n]);
865
- return /* @__PURE__ */ g(yt, { className: "univer-mb-3 univer-w-full univer-grid-cols-2", children: [
865
+ return /* @__PURE__ */ g(ht, { className: "univer-mb-3 univer-w-full univer-grid-cols-2", children: [
866
866
  /* @__PURE__ */ g(V, { onClick: () => a(!0), children: [
867
867
  /* @__PURE__ */ c(ae, {}),
868
868
  i.t("sheets-sort.general.sort-asc")
@@ -880,7 +880,7 @@ function Xt(e) {
880
880
  type: f.SUBITEMS,
881
881
  icon: Z,
882
882
  tooltip: "sheets-sort.general.sort",
883
- hidden$: we(e, q.UNIVER_SHEET),
883
+ hidden$: Re(e, q.UNIVER_SHEET),
884
884
  disabled$: k(e, { workbookTypes: [L], worksheetTypes: [O, N], rangeTypes: [b] })
885
885
  };
886
886
  }
@@ -931,7 +931,7 @@ function rr(e) {
931
931
  title: "sheets-sort.general.sort",
932
932
  type: f.SUBITEMS,
933
933
  icon: Z,
934
- hidden$: we(e, q.UNIVER_SHEET),
934
+ hidden$: Re(e, q.UNIVER_SHEET),
935
935
  disabled$: k(e, {
936
936
  workbookTypes: [L],
937
937
  worksheetTypes: [O, N],
@@ -985,7 +985,7 @@ function cr(e) {
985
985
  };
986
986
  }
987
987
  const ar = {
988
- [dt.ORGANIZATION]: {
988
+ [vt.ORGANIZATION]: {
989
989
  [Ae]: {
990
990
  order: 3,
991
991
  menuItemFactory: Xt,
@@ -1011,8 +1011,8 @@ const ar = {
1011
1011
  }
1012
1012
  }
1013
1013
  },
1014
- [at.MAIN_AREA]: {
1015
- [lt.DATA]: {
1014
+ [Ct.MAIN_AREA]: {
1015
+ [mt.DATA]: {
1016
1016
  [Ue]: {
1017
1017
  order: 0,
1018
1018
  menuItemFactory: rr,
@@ -1046,7 +1046,7 @@ var lr = Object.getOwnPropertyDescriptor, dr = (e, t, r, n) => {
1046
1046
  return o;
1047
1047
  }, y = (e, t) => (r, n) => t(r, n, e);
1048
1048
  const Se = "custom-sort-dialog", Pe = 560, ur = 128;
1049
- let G = class extends Ye {
1049
+ let G = class extends Xe {
1050
1050
  constructor(e, t, r, n, o, s, i, a, l, u) {
1051
1051
  super(), this._commandService = e, this._menuManagerService = t, this._dialogService = r, this._layoutService = n, this._uiPartsService = o, this._sheetRenderService = s, this._localeService = i, this._sheetsSortUIService = a, this._injector = l, this._componentManager = u, this._initCommands(), this._initMenu(), this._initUI();
1052
1052
  }
@@ -1065,11 +1065,11 @@ let G = class extends Ye {
1065
1065
  se,
1066
1066
  ie,
1067
1067
  ce
1068
- ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(ot.id));
1068
+ ].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e))), this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(st.id));
1069
1069
  }
1070
1070
  _initUI() {
1071
1071
  this.disposeWithMe(
1072
- this._uiPartsService.registerComponent(Rt.FILTER_PANEL_EMBED_POINT, () => vt(Yt, this._injector))
1072
+ this._uiPartsService.registerComponent(Rt.FILTER_PANEL_EMBED_POINT, () => yt(Yt, this._injector))
1073
1073
  ), [
1074
1074
  ["CustomSortPanel", Gt],
1075
1075
  [Z, ae],
@@ -1081,7 +1081,7 @@ let G = class extends Ye {
1081
1081
  this.disposeWithMe(
1082
1082
  this._componentManager.register(e, t)
1083
1083
  );
1084
- }), this._sheetsSortUIService.customSortState$.pipe(St(this.dispose$)).subscribe((e) => {
1084
+ }), this._sheetsSortUIService.customSortState$.pipe(at(this.dispose$)).subscribe((e) => {
1085
1085
  e && e.show && e.location ? this._openCustomSortPanel(e.location) : e && !(e != null && e.show) && this._closePanel();
1086
1086
  });
1087
1087
  }
@@ -1105,15 +1105,15 @@ let G = class extends Ye {
1105
1105
  };
1106
1106
  G = dr([
1107
1107
  y(0, _e),
1108
- y(1, ut),
1109
- y(2, ht),
1110
- y(3, gt),
1111
- y(4, Ct),
1108
+ y(1, ft),
1109
+ y(2, St),
1110
+ y(3, pt),
1111
+ y(4, xt),
1112
1112
  y(5, M(Mt)),
1113
1113
  y(6, M(H)),
1114
1114
  y(7, M(C)),
1115
1115
  y(8, M(ye)),
1116
- y(9, M(mt))
1116
+ y(9, M(_t))
1117
1117
  ], G);
1118
1118
  function hr() {
1119
1119
  return { x: (window.innerWidth - Pe) / 2, y: ur };
@@ -1124,10 +1124,10 @@ var gr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, mr = (e, t
1124
1124
  return o;
1125
1125
  }, pe = (e, t) => (r, n) => t(r, n, e), Ze = (e, t, r) => mr(e, typeof t != "symbol" ? t + "" : t, r);
1126
1126
  const fr = "SHEET_SORT_UI_PLUGIN";
1127
- let W = class extends Je {
1127
+ let W = class extends Qe {
1128
1128
  constructor(e = fe, t, r) {
1129
1129
  super(), this._config = e, this._injector = t, this._configService = r;
1130
- const { ...n } = Qe(
1130
+ const { ...n } = et(
1131
1131
  {},
1132
1132
  fe,
1133
1133
  this._config
@@ -1147,9 +1147,9 @@ let W = class extends Je {
1147
1147
  Ze(W, "type", q.UNIVER_SHEET);
1148
1148
  Ze(W, "pluginName", fr);
1149
1149
  W = vr([
1150
- Xe(st),
1150
+ Ke(it),
1151
1151
  pe(1, M(ye)),
1152
- pe(2, Ke)
1152
+ pe(2, Je)
1153
1153
  ], W);
1154
1154
  export {
1155
1155
  J as SortRangeAscCommand,
@@ -1,7 +1,6 @@
1
- import { IRange, Nullable, Disposable, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { IRange, Nullable, Disposable, ICommandService, IConfirmService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { ISheetRangeLocation, SheetsSelectionsService } from '@univerjs/sheets';
3
3
  import { SheetsSortService } from '@univerjs/sheets-sort';
4
- import { IConfirmService } from '@univerjs/ui';
5
4
  export declare enum EXTEND_TYPE {
6
5
  KEEP = "keep",
7
6
  EXTEND = "extend",
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("react/jsx-runtime"),require("@univerjs/sheets"),require("@univerjs/sheets-sort"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/design"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","react/jsx-runtime","@univerjs/sheets","@univerjs/sheets-sort","@univerjs/ui","rxjs","@univerjs/design","react","@univerjs/engine-formula","@univerjs/sheets-ui"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsSortUi={},d.UniverCore,d.React,d.UniverSheets,d.UniverSheetsSort,d.UniverUi,d.rxjs,d.UniverDesign,d.React,d.UniverEngineFormula,d.UniverSheetsUi))})(this,(function(d,s,c,u,w,C,te,S,l,fe,E){"use strict";var ht=Object.defineProperty;var gt=(d,s,c)=>s in d?ht(d,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[s]=c;var ee=(d,s,c)=>gt(d,typeof s!="symbol"?s+"":s,c);const pe=t=>{const[e,n]=l.useState("0"),r=C.useDependency(s.LocaleService);return c.jsxs("div",{className:"univer-text-sm",children:[c.jsx("div",{className:"extend-confirm-desc",children:r.t("sheets-sort.dialog.sort-reminder-desc")}),c.jsxs(S.RadioGroup,{className:"univer-mt-4",value:e,direction:"vertical",onChange:o=>{n(o),t.onChange(o)},children:[c.jsx(S.Radio,{value:"0",children:r.t("sheets-sort.dialog.sort-reminder-no")}),c.jsx(S.Radio,{value:"1",children:r.t("sheets-sort.dialog.sort-reminder-ext")})]})]})};var ye=Object.getOwnPropertyDescriptor,Ie=(t,e,n,r)=>{for(var o=r>1?void 0:r?ye(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},R=(t,e)=>(n,r)=>e(n,r,t);const O={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 s.Disposable{constructor(e,n,r,o,i,a){super();ee(this,"_customSortState$",new te.BehaviorSubject(null));ee(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=e,this._confirmService=n,this._selectionManagerService=r,this._sheetsSortService=o,this._localeService=i,this._commandService=a}async triggerSortDirectly(e,n,r){const o=r||await this._detectSortLocation(n);if(!o||!this._check(o))return!1;const a={orderRules:[{type:e?w.SortType.ASC:w.SortType.DESC,colIndex:o.colIndex}],range:o.range};return this._sheetsSortService.applySort(a,o.unitId,o.subUnitId),!0}async triggerSortCustomize(){const e=await this._detectSortLocation();return!e||!this._check(e)?!1:(this.showCustomSortPanel(e),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(e){var g,v;const n=(g=this.customSortState())==null?void 0:g.location;if(!n)return[];const{unitId:r,subUnitId:o,range:i}=n,a=(v=this._univerInstanceService.getUnit(r))==null?void 0:v.getSheetBySheetId(o);if(!a)return[];const h=xe(this._localeService);return Array.from({length:i.endColumn-i.startColumn+1},(M,I)=>{var y;const b=(y=a.getCell(i.startRow,I+i.startColumn))==null?void 0:y.v;return{index:I+i.startColumn,label:e?`${b!=null?b:h(I+i.startColumn)}`:h(I+i.startColumn)}})}setSelection(e,n,r){var a;const o=(a=this._univerInstanceService.getUnit(e))==null?void 0:a.getSheetBySheetId(n);if(!o)return;const i={unitId:e,subUnitId:n,selections:[{range:r,primary:u.getPrimaryForRange(r,o),style:null}]};this._commandService.executeCommand(u.SetSelectionsOperation.id,i)}async showCheckError(e){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:c.jsx("div",{children:this._localeService.t(e)})},cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})}async showExtendConfirm(){let e=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:c.jsx(pe,{onChange:r=>{e=r==="1"}})},width:400,cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})?e?"extend":"keep":"cancel"}showCustomSortPanel(e){this._customSortState$.next({location:e,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(e){return this._sheetsSortService.singleCheck(e)?this._sheetsSortService.mergeCheck(e)?this._sheetsSortService.formulaCheck(e)?this._sheetsSortService.emptyCheck(e)?!0:(this.showCheckError(O.EMPTY_ERROR),!1):(this.showCheckError(O.FORMULA_ARRAY),!1):(this.showCheckError(O.MERGE_ERROR),!1):(this.showCheckError(O.SINGLE_ERROR),!1)}async _detectSortLocation(e){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),o=n.getUnitId(),i=r.getSheetId(),a=this._selectionManagerService.getCurrentLastSelection();if(!a)return null;let h;if(e===!0)h=u.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(o,i,h);else if(e===!1)h=a.range;else{const g=await this.showExtendConfirm();if(g==="cancel")return null;g==="keep"?h=a.range:(h=u.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(o,i,h))}return{range:h,unitId:o,subUnitId:i,colIndex:a.primary.actualColumn}}};p=Ie([R(0,s.IUniverInstanceService),R(1,C.IConfirmService),R(2,s.Inject(u.SheetsSelectionsService)),R(3,s.Inject(w.SheetsSortService)),R(4,s.Inject(s.LocaleService)),R(5,s.ICommandService)],p);function xe(t){return e=>{const n=s.Tools.chatAtABC(e);switch(t.getCurrentLocale()){case s.LocaleType.ZH_CN:return`"${n}"列`;case s.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}const N={id:"sheet.command.sort-range-asc",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!1)},L={id:"sheet.command.sort-range-asc-ext",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!0)},$={id:"sheet.command.sort-range-desc",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!1)},U={id:"sheet.command.sort-range-desc-ext",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!0)},H={id:"sheet.command.sort-range-custom",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortCustomize()},j={id:"sheet.command.sort-range-asc-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!1)},A={id:"sheet.command.sort-range-asc-ext-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!0)},Z={id:"sheet.command.sort-range-desc-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!1)},B={id:"sheet.command.sort-range-desc-ext-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!0)},F={id:"sheet.command.sort-range-custom-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortCustomize()},_e="sheets-sort-ui.config",ne={};function x({ref:t,...e}){const{icon:n,id:r,className:o,extend:i,...a}=e,h=`univerjs-icon univerjs-icon-${r} ${o||""}`.trim(),g=l.useRef(`_${Te()}`);return re(n,`${r}`,{defIds:n.defIds,idSuffix:g.current},{ref:t,className:h,...a},i)}function re(t,e,n,r,o){return l.createElement(t.tag,{key:e,...we(t,n,o),...r},(Ee(t,n).children||[]).map((i,a)=>re(i,`${e}-${t.tag}-${a}`,n,void 0,o)))}function we(t,e,n){const r={...t.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(r[i]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([i,a])=>{typeof a=="string"&&(r[i]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function Ee(t,e){var r;const{defIds:n}=e;return!n||n.length===0?t:t.tag==="defs"&&((r=t.children)!=null&&r.length)?{...t,children:t.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:t}function Te(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},q=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"ascending-icon",ref:n,icon:Me}))});q.displayName="AscendingIcon";const be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},oe=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"check-mark-icon",ref:n,icon:be}))});oe.displayName="CheckMarkIcon";const Re={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.5574C8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507C9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661C11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512C7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574C6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588C4.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"}}]},se=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"custom-sort-icon",ref:n,icon:Re}))});se.displayName="CustomSortIcon";const ke={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.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"}}]},ie=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"delete-empty-icon",ref:n,icon:ke}))});ie.displayName="DeleteEmptyIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},G=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"descending-icon",ref:n,icon:Pe}))});G.displayName="DescendingIcon";const De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ce=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"expand-ascending-icon",ref:n,icon:De}))});ce.displayName="ExpandAscendingIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ae=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"expand-descending-icon",ref:n,icon:Oe}))});ae.displayName="ExpandDescendingIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},z=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"increase-icon",ref:n,icon:Ne}))});z.displayName="IncreaseIcon";const Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},le=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Le}))});le.displayName="MoreDownIcon";const $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},de=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"sequence-icon",ref:n,icon:$e}))});de.displayName="SequenceIcon";function Ue(){const t=C.useDependency(p),e=C.useObservable(t.customSortState$);return!e||!e.location?null:c.jsx(He,{state:e})}function He({state:t}){const e=C.useDependency(w.SheetsSortService),n=C.useDependency(s.LocaleService),r=C.useDependency(p),[o,i]=l.useState(!1),[a,h]=l.useState(0),g=l.useRef(null),{range:v,unitId:M,subUnitId:I}=t.location,b=r.getTitles(o),[y,P]=l.useState([{type:w.SortType.ASC,colIndex:v.startColumn}]),V=l.useCallback((m,_)=>{const D=[...y];_===null?D.splice(m,1):D[m]=_,P(D)},[y]),f=l.useCallback(s.throttle(()=>{const m=[...y],_=Ae(v,y);_!==null&&(m.push({type:w.SortType.ASC,colIndex:_}),P(m))},200),[y,v]),Q=l.useCallback((m,_)=>{e.applySort({range:v,orderRules:m,hasTitle:_}),r.closeCustomSortPanel()},[e,r,v]),dt=l.useCallback(()=>{r.closeCustomSortPanel()},[r]),ut=l.useCallback(m=>{i(m),m?r.setSelection(M,I,{...v,startRow:v.startRow+1}):r.setSelection(M,I,v)},[r,v,I,M]);l.useEffect(()=>{g.current&&y.length>5&&(g.current.scrollTop=g.current.scrollHeight)},[y]);const Ct=y.length<b.length,Se=y.map(m=>({...m,id:`${m.colIndex}`}));return c.jsxs("div",{children:[c.jsxs("div",{onMouseDown:m=>{m.stopPropagation()},children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between",children:[c.jsx(S.Checkbox,{checked:o,onChange:m=>ut(!!m),children:n.t("sheets-sort.dialog.first-row-check")}),Ct?c.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base",onClick:f,children:[c.jsx(z,{}),c.jsx("span",{className:"univer-ml-1.5",children:n.t("sheets-sort.dialog.add-condition")})]}):c.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base univer-text-primary-500 disabled:univer-cursor-not-allowed disabled:univer-divide-opacity-30 disabled:univer-text-gray-800",children:[c.jsx(z,{}),c.jsx("span",{className:"univer-ml-1.5 univer-text-xs",children:n.t("sheets-sort.dialog.add-condition")})]})]}),c.jsx("div",{ref:g,className:S.clsx("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden",S.scrollbarClassName),onScroll:m=>{const _=m.currentTarget.scrollTop;h(_)},children:c.jsx(S.DraggableList,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",list:Se,onListChange:P,idKey:"id",draggableHandle:"[data-u-comp=sort-panel-item-handler]",itemRender:m=>c.jsx(je,{titles:b,list:Se,item:m,onChange:(_,D)=>V(D,_),scrollPosition:a}),rowHeight:32,margin:[0,12]})})]}),c.jsxs("div",{className:"univer-mt-5 univer-flex univer-justify-end",children:[c.jsx(S.Button,{className:"univer-ml-3",onClick:()=>dt(),children:n.t("sheets-sort.dialog.cancel")}),c.jsx(S.Button,{className:"univer-ml-3",variant:"primary",onClick:()=>Q(y,o),children:n.t("sheets-sort.dialog.confirm")})]})]})}function je(t){var V;const{list:e,item:n,titles:r,onChange:o,scrollPosition:i}=t,a=C.useDependency(s.LocaleService),h=r.filter(f=>!e.some(Q=>Q.colIndex===f.index)||f.index===n.colIndex),g=e.findIndex(f=>f.colIndex===n.colIndex),v=l.useCallback(f=>{o({...n,colIndex:f.index},g),I(!1)},[g,n,o]),[M,I]=l.useState(!1),b=f=>{I(f)};l.useEffect(()=>{I(!1)},[i]);const y=e.length>1,P=(V=r.find(f=>f.index===n.colIndex))==null?void 0:V.label;return c.jsxs("div",{className:"univer-grid univer-grid-flow-col univer-grid-cols-2 univer-items-center univer-gap-2",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{"data-u-comp":"sort-panel-item-handler",className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-text-base univer-text-gray-700",children:c.jsx(de,{})}),c.jsx(S.Dropdown,{overlay:c.jsx("ul",{className:S.clsx("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg",S.scrollbarClassName),children:h.map(f=>c.jsxs("li",{onClick:()=>v(f),className:"univer-relative univer-box-border univer-flex univer-h-7 univer-cursor-pointer univer-list-none univer-items-center univer-justify-between univer-rounded univer-px-2 univer-text-sm univer-transition-all hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:[c.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:f.label}),c.jsx("span",{children:f.index===n.colIndex&&c.jsx(oe,{})})]},f.index))}),open:M,onOpenChange:b,children:c.jsxs("div",{className:S.clsx("univer-ml-2 univer-flex univer-w-full univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-text-sm univer-text-gray-900 dark:!univer-text-white"),children:[c.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:P}),c.jsx(le,{})]})})]}),c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-end univer-gap-2",children:[c.jsxs(S.RadioGroup,{value:n.type,onChange:f=>{o({...n,type:f},g)},children:[c.jsx(S.Radio,{value:w.SortType.ASC,children:a.t("sheets-sort.general.sort-asc")}),c.jsx(S.Radio,{value:w.SortType.DESC,children:a.t("sheets-sort.general.sort-desc")})]}),c.jsx("a",{className:"univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-transition-colors hover:univer-text-red-500",onClick:()=>o(null,g),children:!y&&c.jsx(ie,{})})]})]})}function Ae(t,e){const{startColumn:n,endColumn:r}=t,o=new Set(e.map(i=>i==null?void 0:i.colIndex));for(let i=n;i<=r;i++)if(!o.has(i))return i;return null}function Ze(t){const{range:e,colIndex:n,onClose:r}=t,o=C.useDependency(p),i=C.useDependency(s.IUniverInstanceService),a=C.useDependency(s.LocaleService),h=l.useCallback(g=>{const{unitId:v,subUnitId:M}=u.getSheetCommandTarget(i)||{};if(e&&v&&M){const I={...e,startRow:e.startRow+1};o.triggerSortDirectly(g,!1,{unitId:v,subUnitId:M,range:I,colIndex:n})}else throw new Error(`Cannot find the target to sort. unitId: ${v}, subUnitId: ${M}, range: ${e}, colIndex: ${n}`);r()},[e,n,o,i,r]);return c.jsxs(S.ButtonGroup,{className:"univer-mb-3 univer-w-full univer-grid-cols-2",children:[c.jsxs(S.Button,{onClick:()=>h(!0),children:[c.jsx(q,{}),a.t("sheets-sort.general.sort-asc")]}),c.jsxs(S.Button,{onClick:()=>h(!1),children:[c.jsx(G,{}),a.t("sheets-sort.general.sort-desc")]})]})}const ue="sheet.menu.sheets-sort",Ce="sheet.menu.sheets-sort-ctx",k="AscendingIcon",Y="ExpandAscendingIcon",X="DescendingIcon",K="ExpandDescendingIcon",J="CustomSortIcon";function Be(t){return{id:ue,type:C.MenuItemType.SUBITEMS,icon:k,tooltip:"sheets-sort.general.sort",hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Fe(t){return{id:N.id,icon:k,title:"sheets-sort.general.sort-asc-cur",type:C.MenuItemType.BUTTON,hidden$:E.getCurrentExclusiveRangeInterest$(t)}}function We(t){return{id:L.id,title:"sheets-sort.general.sort-asc-ext",icon:Y,type:C.MenuItemType.BUTTON}}function Ve(t){return{id:$.id,title:"sheets-sort.general.sort-desc-cur",icon:X,type:C.MenuItemType.BUTTON}}function qe(t){return{id:U.id,title:"sheets-sort.general.sort-desc-ext",icon:K,type:C.MenuItemType.BUTTON}}function Ge(t){return{id:H.id,title:"sheets-sort.general.sort-custom",type:C.MenuItemType.BUTTON,icon:J}}function ze(t){return{id:Ce,title:"sheets-sort.general.sort",type:C.MenuItemType.SUBITEMS,icon:k,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Ye(t){return{id:j.id,title:"sheets-sort.general.sort-asc-cur",type:C.MenuItemType.BUTTON,icon:k,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Xe(t){return{id:A.id,title:"sheets-sort.general.sort-asc-ext",type:C.MenuItemType.BUTTON,icon:Y,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Ke(t){return{id:Z.id,title:"sheets-sort.general.sort-desc-cur",type:C.MenuItemType.BUTTON,icon:X,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Je(t){return{id:B.id,title:"sheets-sort.general.sort-desc-ext",type:C.MenuItemType.BUTTON,icon:K,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Qe(t){return{id:F.id,title:"sheets-sort.general.sort-custom",type:C.MenuItemType.BUTTON,icon:J,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}const et={[C.RibbonDataGroup.ORGANIZATION]:{[ue]:{order:3,menuItemFactory:Be,[N.id]:{order:0,menuItemFactory:Fe},[L.id]:{order:1,menuItemFactory:We},[$.id]:{order:2,menuItemFactory:Ve},[U.id]:{order:3,menuItemFactory:qe},[H.id]:{order:4,menuItemFactory:Ge}}},[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.DATA]:{[Ce]:{order:0,menuItemFactory:ze,[j.id]:{order:0,menuItemFactory:Ye},[A.id]:{order:1,menuItemFactory:Xe},[Z.id]:{order:2,menuItemFactory:Ke},[B.id]:{order:3,menuItemFactory:Je},[F.id]:{order:4,menuItemFactory:Qe}}}}};var tt=Object.getOwnPropertyDescriptor,nt=(t,e,n,r)=>{for(var o=r>1?void 0:r?tt(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},T=(t,e)=>(n,r)=>e(n,r,t);const he="custom-sort-dialog",ge=560,rt=128;let W=class extends s.RxDisposable{constructor(t,e,n,r,o,i,a,h,g,v){super(),this._commandService=t,this._menuManagerService=e,this._dialogService=n,this._layoutService=r,this._uiPartsService=o,this._sheetRenderService=i,this._localeService=a,this._sheetsSortUIService=h,this._injector=g,this._componentManager=v,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){this._menuManagerService.mergeMenu(et)}_initCommands(){[N,L,$,U,H,j,A,Z,B,F].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(w.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._uiPartsService.registerComponent(E.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>C.connectInjector(Ze,this._injector))),[["CustomSortPanel",Ue],[k,q],[Y,ce],[X,G],[K,ae],[J,se]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))}),this._sheetsSortUIService.customSortState$.pipe(te.takeUntil(this.dispose$)).subscribe(t=>{t&&t.show&&t.location?this._openCustomSortPanel(t.location):t&&!(t!=null&&t.show)&&this._closePanel()})}_openCustomSortPanel(t){this._dialogService.open({id:he,draggable:!0,width:ge,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${fe.serializeRange(t.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:ot(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(he),queueMicrotask(()=>this._layoutService.focus())}};W=nt([T(0,s.ICommandService),T(1,C.IMenuManagerService),T(2,C.IDialogService),T(3,C.ILayoutService),T(4,C.IUIPartsService),T(5,s.Inject(E.SheetsRenderService)),T(6,s.Inject(s.LocaleService)),T(7,s.Inject(p)),T(8,s.Inject(s.Injector)),T(9,s.Inject(C.ComponentManager))],W);function ot(){return{x:(window.innerWidth-ge)/2,y:rt}}var st=Object.defineProperty,it=Object.getOwnPropertyDescriptor,ct=(t,e,n)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,at=(t,e,n,r)=>{for(var o=r>1?void 0:r?it(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},me=(t,e)=>(n,r)=>e(n,r,t),ve=(t,e,n)=>ct(t,typeof e!="symbol"?e+"":e,n);const lt="SHEET_SORT_UI_PLUGIN";d.UniverSheetsSortUIPlugin=class extends s.Plugin{constructor(e=ne,n,r){super(),this._config=e,this._injector=n,this._configService=r;const{...o}=s.merge({},ne,this._config);this._configService.setConfig(_e,o)}onStarting(){[[p],[W]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(W)}},ve(d.UniverSheetsSortUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),ve(d.UniverSheetsSortUIPlugin,"pluginName",lt),d.UniverSheetsSortUIPlugin=at([s.DependentOn(w.UniverSheetsSortPlugin),me(1,s.Inject(s.Injector)),me(2,s.IConfigService)],d.UniverSheetsSortUIPlugin),d.SortRangeAscCommand=N,d.SortRangeAscExtCommand=L,d.SortRangeAscExtInCtxMenuCommand=A,d.SortRangeAscInCtxMenuCommand=j,d.SortRangeCustomCommand=H,d.SortRangeCustomInCtxMenuCommand=F,d.SortRangeDescCommand=$,d.SortRangeDescExtCommand=U,d.SortRangeDescExtInCtxMenuCommand=B,d.SortRangeDescInCtxMenuCommand=Z,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(d,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("react/jsx-runtime"),require("@univerjs/sheets"),require("@univerjs/sheets-sort"),require("rxjs"),require("@univerjs/design"),require("@univerjs/ui"),require("react"),require("@univerjs/engine-formula"),require("@univerjs/sheets-ui")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","react/jsx-runtime","@univerjs/sheets","@univerjs/sheets-sort","rxjs","@univerjs/design","@univerjs/ui","react","@univerjs/engine-formula","@univerjs/sheets-ui"],s):(d=typeof globalThis<"u"?globalThis:d||self,s(d.UniverSheetsSortUi={},d.UniverCore,d.React,d.UniverSheets,d.UniverSheetsSort,d.rxjs,d.UniverDesign,d.UniverUi,d.React,d.UniverEngineFormula,d.UniverSheetsUi))})(this,(function(d,s,c,u,w,te,S,C,l,fe,E){"use strict";var ht=Object.defineProperty;var gt=(d,s,c)=>s in d?ht(d,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[s]=c;var ee=(d,s,c)=>gt(d,typeof s!="symbol"?s+"":s,c);const pe=t=>{const[e,n]=l.useState("0"),r=C.useDependency(s.LocaleService);return c.jsxs("div",{className:"univer-text-sm",children:[c.jsx("div",{className:"extend-confirm-desc",children:r.t("sheets-sort.dialog.sort-reminder-desc")}),c.jsxs(S.RadioGroup,{className:"univer-mt-4",value:e,direction:"vertical",onChange:o=>{n(o),t.onChange(o)},children:[c.jsx(S.Radio,{value:"0",children:r.t("sheets-sort.dialog.sort-reminder-no")}),c.jsx(S.Radio,{value:"1",children:r.t("sheets-sort.dialog.sort-reminder-ext")})]})]})};var ye=Object.getOwnPropertyDescriptor,Ie=(t,e,n,r)=>{for(var o=r>1?void 0:r?ye(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},R=(t,e)=>(n,r)=>e(n,r,t);const O={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 s.Disposable{constructor(e,n,r,o,i,a){super();ee(this,"_customSortState$",new te.BehaviorSubject(null));ee(this,"customSortState$",this._customSortState$.asObservable());this._univerInstanceService=e,this._confirmService=n,this._selectionManagerService=r,this._sheetsSortService=o,this._localeService=i,this._commandService=a}async triggerSortDirectly(e,n,r){const o=r||await this._detectSortLocation(n);if(!o||!this._check(o))return!1;const a={orderRules:[{type:e?w.SortType.ASC:w.SortType.DESC,colIndex:o.colIndex}],range:o.range};return this._sheetsSortService.applySort(a,o.unitId,o.subUnitId),!0}async triggerSortCustomize(){const e=await this._detectSortLocation();return!e||!this._check(e)?!1:(this.showCustomSortPanel(e),!0)}customSortState(){return this._customSortState$.getValue()}getTitles(e){var g,v;const n=(g=this.customSortState())==null?void 0:g.location;if(!n)return[];const{unitId:r,subUnitId:o,range:i}=n,a=(v=this._univerInstanceService.getUnit(r))==null?void 0:v.getSheetBySheetId(o);if(!a)return[];const h=xe(this._localeService);return Array.from({length:i.endColumn-i.startColumn+1},(M,I)=>{var y;const b=(y=a.getCell(i.startRow,I+i.startColumn))==null?void 0:y.v;return{index:I+i.startColumn,label:e?`${b!=null?b:h(I+i.startColumn)}`:h(I+i.startColumn)}})}setSelection(e,n,r){var a;const o=(a=this._univerInstanceService.getUnit(e))==null?void 0:a.getSheetBySheetId(n);if(!o)return;const i={unitId:e,subUnitId:n,selections:[{range:r,primary:u.getPrimaryForRange(r,o),style:null}]};this._commandService.executeCommand(u.SetSelectionsOperation.id,i)}async showCheckError(e){return await this._confirmService.confirm({id:"sort-range-check-error",title:{title:this._localeService.t("info.tooltip")},children:{title:c.jsx("div",{children:this._localeService.t(e)})},cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})}async showExtendConfirm(){let e=!1;return await this._confirmService.confirm({id:"extend-sort-range-dialog",title:{title:this._localeService.t("sheets-sort.dialog.sort-reminder")},children:{title:c.jsx(pe,{onChange:r=>{e=r==="1"}})},width:400,cancelText:this._localeService.t("sheets-sort.dialog.cancel"),confirmText:this._localeService.t("sheets-sort.dialog.confirm")})?e?"extend":"keep":"cancel"}showCustomSortPanel(e){this._customSortState$.next({location:e,show:!0})}closeCustomSortPanel(){this._customSortState$.next({show:!1})}_check(e){return this._sheetsSortService.singleCheck(e)?this._sheetsSortService.mergeCheck(e)?this._sheetsSortService.formulaCheck(e)?this._sheetsSortService.emptyCheck(e)?!0:(this.showCheckError(O.EMPTY_ERROR),!1):(this.showCheckError(O.FORMULA_ARRAY),!1):(this.showCheckError(O.MERGE_ERROR),!1):(this.showCheckError(O.SINGLE_ERROR),!1)}async _detectSortLocation(e){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),r=n.getActiveSheet(),o=n.getUnitId(),i=r.getSheetId(),a=this._selectionManagerService.getCurrentLastSelection();if(!a)return null;let h;if(e===!0)h=u.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(o,i,h);else if(e===!1)h=a.range;else{const g=await this.showExtendConfirm();if(g==="cancel")return null;g==="keep"?h=a.range:(h=u.expandToContinuousRange(a.range,{up:!0,down:!0,left:!0,right:!0},r),this.setSelection(o,i,h))}return{range:h,unitId:o,subUnitId:i,colIndex:a.primary.actualColumn}}};p=Ie([R(0,s.IUniverInstanceService),R(1,s.IConfirmService),R(2,s.Inject(u.SheetsSelectionsService)),R(3,s.Inject(w.SheetsSortService)),R(4,s.Inject(s.LocaleService)),R(5,s.ICommandService)],p);function xe(t){return e=>{const n=s.Tools.chatAtABC(e);switch(t.getCurrentLocale()){case s.LocaleType.ZH_CN:return`"${n}"列`;case s.LocaleType.EN_US:return`Column "${n}"`;default:return`Column "${n}"`}}}const N={id:"sheet.command.sort-range-asc",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!1)},L={id:"sheet.command.sort-range-asc-ext",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!0)},$={id:"sheet.command.sort-range-desc",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!1)},U={id:"sheet.command.sort-range-desc-ext",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!0)},H={id:"sheet.command.sort-range-custom",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortCustomize()},j={id:"sheet.command.sort-range-asc-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!1)},A={id:"sheet.command.sort-range-asc-ext-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!0,!0)},Z={id:"sheet.command.sort-range-desc-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!1)},B={id:"sheet.command.sort-range-desc-ext-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortDirectly(!1,!0)},F={id:"sheet.command.sort-range-custom-ctx",type:s.CommandType.COMMAND,handler:async t=>await t.get(p).triggerSortCustomize()},_e="sheets-sort-ui.config",ne={};function x({ref:t,...e}){const{icon:n,id:r,className:o,extend:i,...a}=e,h=`univerjs-icon univerjs-icon-${r} ${o||""}`.trim(),g=l.useRef(`_${Te()}`);return re(n,`${r}`,{defIds:n.defIds,idSuffix:g.current},{ref:t,className:h,...a},i)}function re(t,e,n,r,o){return l.createElement(t.tag,{key:e,...we(t,n,o),...r},(Ee(t,n).children||[]).map((i,a)=>re(i,`${e}-${t.tag}-${a}`,n,void 0,o)))}function we(t,e,n){const r={...t.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),t.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([i,a])=>{i==="mask"&&typeof a=="string"&&(r[i]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(t.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([i,a])=>{typeof a=="string"&&(r[i]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function Ee(t,e){var r;const{defIds:n}=e;return!n||n.length===0?t:t.tag==="defs"&&((r=t.children)!=null&&r.length)?{...t,children:t.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:t}function Te(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";const Me={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},q=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"ascending-icon",ref:n,icon:Me}))});q.displayName="AscendingIcon";const be={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},oe=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"check-mark-icon",ref:n,icon:be}))});oe.displayName="CheckMarkIcon";const Re={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.5574C8.84322 12.5574 8.57458 12.2888 8.57457 11.9574L8.57439 7.79509C8.57438 7.46372 8.84299 7.19508 9.17436 7.19507C9.3281 7.19493 9.48196 7.25351 9.59925 7.3708L11.3465 9.11808C11.5808 9.3524 11.5808 9.7323 11.3465 9.96661C11.1122 10.2009 10.7323 10.2009 10.498 9.96661L9.77445 9.24306Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.22584 10.5094L6.22572 7.79514C6.22571 7.46377 6.49433 7.19513 6.8257 7.19512C7.15707 7.1951 7.42571 7.46372 7.42572 7.79509L7.4259 11.9574C7.42592 12.2888 7.1573 12.5574 6.82593 12.5574C6.67228 12.5575 6.51828 12.4989 6.40104 12.3817L4.65376 10.6344C4.41945 10.4001 4.41945 10.0202 4.65376 9.78588C4.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"}}]},se=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"custom-sort-icon",ref:n,icon:Re}))});se.displayName="CustomSortIcon";const ke={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.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.64443C14.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"}}]},ie=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"delete-empty-icon",ref:n,icon:ke}))});ie.displayName="DeleteEmptyIcon";const Pe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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.67983C1.38967 9.34846 1.6583 9.07983 1.98967 9.07983H6.50138C6.74406 9.07983 6.96284 9.22602 7.05571 9.45022C7.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.1916C7.10138 14.5229 6.83276 14.7916 6.50138 14.7916H1.98967C1.74699 14.7916 1.52821 14.6454 1.43534 14.4212C1.34247 14.197 1.3938 13.9389 1.5654 13.7673L5.05286 10.2798H1.98967Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M5.1846 1.86439C4.8641 0.989866 3.62725 0.989866 3.30674 1.86439L1.34882 7.20672C1.23479 7.51786 1.39458 7.86252 1.70571 7.97655C2.01684 8.09058 2.3615 7.93079 2.47553 7.61966L3.06159 6.02055L3.06338 6.02056H5.42975L6.01581 7.61966C6.12984 7.93079 6.4745 8.09058 6.78563 7.97655C7.09677 7.86252 7.25655 7.51786 7.14252 7.20672L5.1846 1.86439ZM4.98996 4.82056L4.24567 2.78971L3.50138 4.82056H4.98996Z",fillRule:"evenodd",clipRule:"evenodd"}}]},G=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"descending-icon",ref:n,icon:Pe}))});G.displayName="DescendingIcon";const De={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ce=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"expand-ascending-icon",ref:n,icon:De}))});ce.displayName="ExpandAscendingIcon";const Oe={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},ae=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"expand-descending-icon",ref:n,icon:Oe}))});ae.displayName="ExpandDescendingIcon";const Ne={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},z=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"increase-icon",ref:n,icon:Ne}))});z.displayName="IncreaseIcon";const Le={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",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"}}]},le=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Le}))});le.displayName="MoreDownIcon";const $e={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},de=l.forwardRef(function(e,n){return l.createElement(x,Object.assign({},e,{id:"sequence-icon",ref:n,icon:$e}))});de.displayName="SequenceIcon";function Ue(){const t=C.useDependency(p),e=C.useObservable(t.customSortState$);return!e||!e.location?null:c.jsx(He,{state:e})}function He({state:t}){const e=C.useDependency(w.SheetsSortService),n=C.useDependency(s.LocaleService),r=C.useDependency(p),[o,i]=l.useState(!1),[a,h]=l.useState(0),g=l.useRef(null),{range:v,unitId:M,subUnitId:I}=t.location,b=r.getTitles(o),[y,P]=l.useState([{type:w.SortType.ASC,colIndex:v.startColumn}]),V=l.useCallback((m,_)=>{const D=[...y];_===null?D.splice(m,1):D[m]=_,P(D)},[y]),f=l.useCallback(s.throttle(()=>{const m=[...y],_=Ae(v,y);_!==null&&(m.push({type:w.SortType.ASC,colIndex:_}),P(m))},200),[y,v]),Q=l.useCallback((m,_)=>{e.applySort({range:v,orderRules:m,hasTitle:_}),r.closeCustomSortPanel()},[e,r,v]),dt=l.useCallback(()=>{r.closeCustomSortPanel()},[r]),ut=l.useCallback(m=>{i(m),m?r.setSelection(M,I,{...v,startRow:v.startRow+1}):r.setSelection(M,I,v)},[r,v,I,M]);l.useEffect(()=>{g.current&&y.length>5&&(g.current.scrollTop=g.current.scrollHeight)},[y]);const Ct=y.length<b.length,Se=y.map(m=>({...m,id:`${m.colIndex}`}));return c.jsxs("div",{children:[c.jsxs("div",{onMouseDown:m=>{m.stopPropagation()},children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between",children:[c.jsx(S.Checkbox,{checked:o,onChange:m=>ut(!!m),children:n.t("sheets-sort.dialog.first-row-check")}),Ct?c.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base",onClick:f,children:[c.jsx(z,{}),c.jsx("span",{className:"univer-ml-1.5",children:n.t("sheets-sort.dialog.add-condition")})]}):c.jsxs("div",{className:"univer-flex univer-cursor-pointer univer-select-none univer-items-center univer-text-base univer-text-primary-500 disabled:univer-cursor-not-allowed disabled:univer-divide-opacity-30 disabled:univer-text-gray-800",children:[c.jsx(z,{}),c.jsx("span",{className:"univer-ml-1.5 univer-text-xs",children:n.t("sheets-sort.dialog.add-condition")})]})]}),c.jsx("div",{ref:g,className:S.clsx("univer-max-h-[310px] univer-overflow-y-auto univer-overflow-x-hidden",S.scrollbarClassName),onScroll:m=>{const _=m.currentTarget.scrollTop;h(_)},children:c.jsx(S.DraggableList,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",list:Se,onListChange:P,idKey:"id",draggableHandle:"[data-u-comp=sort-panel-item-handler]",itemRender:m=>c.jsx(je,{titles:b,list:Se,item:m,onChange:(_,D)=>V(D,_),scrollPosition:a}),rowHeight:32,margin:[0,12]})})]}),c.jsxs("div",{className:"univer-mt-5 univer-flex univer-justify-end",children:[c.jsx(S.Button,{className:"univer-ml-3",onClick:()=>dt(),children:n.t("sheets-sort.dialog.cancel")}),c.jsx(S.Button,{className:"univer-ml-3",variant:"primary",onClick:()=>Q(y,o),children:n.t("sheets-sort.dialog.confirm")})]})]})}function je(t){var V;const{list:e,item:n,titles:r,onChange:o,scrollPosition:i}=t,a=C.useDependency(s.LocaleService),h=r.filter(f=>!e.some(Q=>Q.colIndex===f.index)||f.index===n.colIndex),g=e.findIndex(f=>f.colIndex===n.colIndex),v=l.useCallback(f=>{o({...n,colIndex:f.index},g),I(!1)},[g,n,o]),[M,I]=l.useState(!1),b=f=>{I(f)};l.useEffect(()=>{I(!1)},[i]);const y=e.length>1,P=(V=r.find(f=>f.index===n.colIndex))==null?void 0:V.label;return c.jsxs("div",{className:"univer-grid univer-grid-flow-col univer-grid-cols-2 univer-items-center univer-gap-2",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{"data-u-comp":"sort-panel-item-handler",className:"univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-text-base univer-text-gray-700",children:c.jsx(de,{})}),c.jsx(S.Dropdown,{overlay:c.jsx("ul",{className:S.clsx("univer-my-0 univer-box-border univer-grid univer-max-h-[310px] univer-w-[var(--radix-popper-anchor-width)] univer-items-center univer-gap-1 univer-overflow-y-auto univer-overflow-x-hidden univer-rounded-lg univer-border univer-bg-white univer-p-1 univer-text-base univer-shadow-lg",S.scrollbarClassName),children:h.map(f=>c.jsxs("li",{onClick:()=>v(f),className:"univer-relative univer-box-border univer-flex univer-h-7 univer-cursor-pointer univer-list-none univer-items-center univer-justify-between univer-rounded univer-px-2 univer-text-sm univer-transition-all hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:[c.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:f.label}),c.jsx("span",{children:f.index===n.colIndex&&c.jsx(oe,{})})]},f.index))}),open:M,onOpenChange:b,children:c.jsxs("div",{className:S.clsx("univer-ml-2 univer-flex univer-w-full univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-text-sm univer-text-gray-900 dark:!univer-text-white"),children:[c.jsx("span",{className:"univer-max-w-[220px] univer-truncate",children:P}),c.jsx(le,{})]})})]}),c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-end univer-gap-2",children:[c.jsxs(S.RadioGroup,{value:n.type,onChange:f=>{o({...n,type:f},g)},children:[c.jsx(S.Radio,{value:w.SortType.ASC,children:a.t("sheets-sort.general.sort-asc")}),c.jsx(S.Radio,{value:w.SortType.DESC,children:a.t("sheets-sort.general.sort-desc")})]}),c.jsx("a",{className:"univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-transition-colors hover:univer-text-red-500",onClick:()=>o(null,g),children:!y&&c.jsx(ie,{})})]})]})}function Ae(t,e){const{startColumn:n,endColumn:r}=t,o=new Set(e.map(i=>i==null?void 0:i.colIndex));for(let i=n;i<=r;i++)if(!o.has(i))return i;return null}function Ze(t){const{range:e,colIndex:n,onClose:r}=t,o=C.useDependency(p),i=C.useDependency(s.IUniverInstanceService),a=C.useDependency(s.LocaleService),h=l.useCallback(g=>{const{unitId:v,subUnitId:M}=u.getSheetCommandTarget(i)||{};if(e&&v&&M){const I={...e,startRow:e.startRow+1};o.triggerSortDirectly(g,!1,{unitId:v,subUnitId:M,range:I,colIndex:n})}else throw new Error(`Cannot find the target to sort. unitId: ${v}, subUnitId: ${M}, range: ${e}, colIndex: ${n}`);r()},[e,n,o,i,r]);return c.jsxs(S.ButtonGroup,{className:"univer-mb-3 univer-w-full univer-grid-cols-2",children:[c.jsxs(S.Button,{onClick:()=>h(!0),children:[c.jsx(q,{}),a.t("sheets-sort.general.sort-asc")]}),c.jsxs(S.Button,{onClick:()=>h(!1),children:[c.jsx(G,{}),a.t("sheets-sort.general.sort-desc")]})]})}const ue="sheet.menu.sheets-sort",Ce="sheet.menu.sheets-sort-ctx",k="AscendingIcon",Y="ExpandAscendingIcon",X="DescendingIcon",K="ExpandDescendingIcon",J="CustomSortIcon";function Be(t){return{id:ue,type:C.MenuItemType.SUBITEMS,icon:k,tooltip:"sheets-sort.general.sort",hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Fe(t){return{id:N.id,icon:k,title:"sheets-sort.general.sort-asc-cur",type:C.MenuItemType.BUTTON,hidden$:E.getCurrentExclusiveRangeInterest$(t)}}function We(t){return{id:L.id,title:"sheets-sort.general.sort-asc-ext",icon:Y,type:C.MenuItemType.BUTTON}}function Ve(t){return{id:$.id,title:"sheets-sort.general.sort-desc-cur",icon:X,type:C.MenuItemType.BUTTON}}function qe(t){return{id:U.id,title:"sheets-sort.general.sort-desc-ext",icon:K,type:C.MenuItemType.BUTTON}}function Ge(t){return{id:H.id,title:"sheets-sort.general.sort-custom",type:C.MenuItemType.BUTTON,icon:J}}function ze(t){return{id:Ce,title:"sheets-sort.general.sort",type:C.MenuItemType.SUBITEMS,icon:k,hidden$:C.getMenuHiddenObservable(t,s.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Ye(t){return{id:j.id,title:"sheets-sort.general.sort-asc-cur",type:C.MenuItemType.BUTTON,icon:k,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Xe(t){return{id:A.id,title:"sheets-sort.general.sort-asc-ext",type:C.MenuItemType.BUTTON,icon:Y,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Ke(t){return{id:Z.id,title:"sheets-sort.general.sort-desc-cur",type:C.MenuItemType.BUTTON,icon:X,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Je(t){return{id:B.id,title:"sheets-sort.general.sort-desc-ext",type:C.MenuItemType.BUTTON,icon:K,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}function Qe(t){return{id:F.id,title:"sheets-sort.general.sort-custom",type:C.MenuItemType.BUTTON,icon:J,disabled$:E.getCurrentRangeDisable$(t,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetSortPermission,u.WorksheetEditPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}}const et={[C.RibbonDataGroup.ORGANIZATION]:{[ue]:{order:3,menuItemFactory:Be,[N.id]:{order:0,menuItemFactory:Fe},[L.id]:{order:1,menuItemFactory:We},[$.id]:{order:2,menuItemFactory:Ve},[U.id]:{order:3,menuItemFactory:qe},[H.id]:{order:4,menuItemFactory:Ge}}},[C.ContextMenuPosition.MAIN_AREA]:{[C.ContextMenuGroup.DATA]:{[Ce]:{order:0,menuItemFactory:ze,[j.id]:{order:0,menuItemFactory:Ye},[A.id]:{order:1,menuItemFactory:Xe},[Z.id]:{order:2,menuItemFactory:Ke},[B.id]:{order:3,menuItemFactory:Je},[F.id]:{order:4,menuItemFactory:Qe}}}}};var tt=Object.getOwnPropertyDescriptor,nt=(t,e,n,r)=>{for(var o=r>1?void 0:r?tt(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},T=(t,e)=>(n,r)=>e(n,r,t);const he="custom-sort-dialog",ge=560,rt=128;let W=class extends s.RxDisposable{constructor(t,e,n,r,o,i,a,h,g,v){super(),this._commandService=t,this._menuManagerService=e,this._dialogService=n,this._layoutService=r,this._uiPartsService=o,this._sheetRenderService=i,this._localeService=a,this._sheetsSortUIService=h,this._injector=g,this._componentManager=v,this._initCommands(),this._initMenu(),this._initUI()}_initMenu(){this._menuManagerService.mergeMenu(et)}_initCommands(){[N,L,$,U,H,j,A,Z,B,F].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetRenderService.registerSkeletonChangingMutations(w.SortRangeCommand.id))}_initUI(){this.disposeWithMe(this._uiPartsService.registerComponent(E.SheetsUIPart.FILTER_PANEL_EMBED_POINT,()=>C.connectInjector(Ze,this._injector))),[["CustomSortPanel",Ue],[k,q],[Y,ce],[X,G],[K,ae],[J,se]].forEach(([t,e])=>{this.disposeWithMe(this._componentManager.register(t,e))}),this._sheetsSortUIService.customSortState$.pipe(te.takeUntil(this.dispose$)).subscribe(t=>{t&&t.show&&t.location?this._openCustomSortPanel(t.location):t&&!(t!=null&&t.show)&&this._closePanel()})}_openCustomSortPanel(t){this._dialogService.open({id:he,draggable:!0,width:ge,title:{title:`${this._localeService.t("sheets-sort.general.sort-custom")}: ${fe.serializeRange(t.range)}`},children:{label:"CustomSortPanel"},destroyOnClose:!0,defaultPosition:ot(),preservePositionOnDestroy:!1,onClose:()=>this._closePanel(),mask:!0})}_closePanel(){this._dialogService.close(he),queueMicrotask(()=>this._layoutService.focus())}};W=nt([T(0,s.ICommandService),T(1,C.IMenuManagerService),T(2,C.IDialogService),T(3,C.ILayoutService),T(4,C.IUIPartsService),T(5,s.Inject(E.SheetsRenderService)),T(6,s.Inject(s.LocaleService)),T(7,s.Inject(p)),T(8,s.Inject(s.Injector)),T(9,s.Inject(C.ComponentManager))],W);function ot(){return{x:(window.innerWidth-ge)/2,y:rt}}var st=Object.defineProperty,it=Object.getOwnPropertyDescriptor,ct=(t,e,n)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,at=(t,e,n,r)=>{for(var o=r>1?void 0:r?it(e,n):e,i=t.length-1,a;i>=0;i--)(a=t[i])&&(o=a(o)||o);return o},me=(t,e)=>(n,r)=>e(n,r,t),ve=(t,e,n)=>ct(t,typeof e!="symbol"?e+"":e,n);const lt="SHEET_SORT_UI_PLUGIN";d.UniverSheetsSortUIPlugin=class extends s.Plugin{constructor(e=ne,n,r){super(),this._config=e,this._injector=n,this._configService=r;const{...o}=s.merge({},ne,this._config);this._configService.setConfig(_e,o)}onStarting(){[[p],[W]].forEach(e=>this._injector.add(e))}onRendered(){this._injector.get(W)}},ve(d.UniverSheetsSortUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),ve(d.UniverSheetsSortUIPlugin,"pluginName",lt),d.UniverSheetsSortUIPlugin=at([s.DependentOn(w.UniverSheetsSortPlugin),me(1,s.Inject(s.Injector)),me(2,s.IConfigService)],d.UniverSheetsSortUIPlugin),d.SortRangeAscCommand=N,d.SortRangeAscExtCommand=L,d.SortRangeAscExtInCtxMenuCommand=A,d.SortRangeAscInCtxMenuCommand=j,d.SortRangeCustomCommand=H,d.SortRangeCustomInCtxMenuCommand=F,d.SortRangeDescCommand=$,d.SortRangeDescExtCommand=U,d.SortRangeDescExtInCtxMenuCommand=B,d.SortRangeDescInCtxMenuCommand=Z,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-sort-ui",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "private": false,
5
5
  "description": "Univer Sheets Sort UI",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,13 +53,13 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^1.0.2",
56
- "@univerjs/core": "0.13.0",
57
- "@univerjs/design": "0.13.0",
58
- "@univerjs/engine-formula": "0.13.0",
59
- "@univerjs/sheets-sort": "0.13.0",
60
- "@univerjs/sheets": "0.13.0",
61
- "@univerjs/ui": "0.13.0",
62
- "@univerjs/sheets-ui": "0.13.0"
56
+ "@univerjs/core": "0.14.0",
57
+ "@univerjs/design": "0.14.0",
58
+ "@univerjs/engine-formula": "0.14.0",
59
+ "@univerjs/sheets": "0.14.0",
60
+ "@univerjs/sheets-sort": "0.14.0",
61
+ "@univerjs/sheets-ui": "0.14.0",
62
+ "@univerjs/ui": "0.14.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "postcss": "^8.5.6",
@@ -69,8 +69,8 @@
69
69
  "typescript": "^5.9.3",
70
70
  "vite": "^7.2.7",
71
71
  "vitest": "^4.0.15",
72
- "@univerjs-infra/shared": "0.13.0",
73
- "@univerjs/sheets-formula-ui": "0.13.0"
72
+ "@univerjs/sheets-formula-ui": "0.14.0",
73
+ "@univerjs-infra/shared": "0.14.0"
74
74
  },
75
75
  "scripts": {
76
76
  "test": "vitest run",
@@ -1,7 +0,0 @@
1
- import { Meta } from '@storybook/react';
2
- import { CustomSortPanel } from './CustomSortPanel';
3
- declare const meta: Meta<typeof CustomSortPanel>;
4
- export default meta;
5
- export declare const Demo: {
6
- render(): import("react/jsx-runtime").JSX.Element;
7
- };