@univerjs/preset-sheets-sort 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-extend-confirm-content{font-size:14px}.univer-extend-confirm-radio-group{margin-top:16px}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext{display:flex;justify-content:space-between;align-items:center}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition{color:var(---Hyacinth-Blue-500, #274fee);font-size:16px;display:flex;align-items:center;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition-text{margin-left:6px;font-size:12px}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition-disable{color:var(---Black, #1e222b);opacity:.3;cursor:not-allowed}.univer-custom-sort-panel-container .univer-custom-sort-panel-footer{margin-top:20px;display:flex;justify-content:end}.univer-custom-sort-panel-container .univer-custom-sort-panel-footer-btn{margin-left:12px}.univer-custom-sort-panel-container .univer-custom-sort-panel-item{display:flex;align-items:center;border-bottom:1px solid var(--gray-200)}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-head{display:flex;align-items:center}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-handler{font-size:16px;display:flex;align-items:center;justify-content:center;color:#1e222b;cursor:pointer}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-remove{font-size:14px;color:#4b4b4b;cursor:pointer;width:14px;height:14px;position:absolute;right:0}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input{display:flex;width:236px;padding:6px 10px;justify-content:space-between;align-items:center;margin-left:8px;border-radius:6px;border:1px solid var(---Grey-200, #e5e5e5);background:var(---White, #fff);color:var(---Black, #1e222b);font-family:PingFang SC;font-size:13px;font-style:normal;font-weight:400;line-height:20px;overflow:hidden}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input-dropdown{width:16px;height:16px;color:#4b4b4b}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input-text{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-order-radio{display:flex;padding:0 10px}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-order-radio-cn{display:flex;padding:0 20px}.univer-custom-sort-panel-container .univer-condition-list{max-height:310px;overflow-y:auto;overflow-x:hidden}.univer-embed-sort-btn-container{display:flex;margin-bottom:12px}.univer-embed-sort-btn-container .univer-embed-sort-btn{font-size:13px;font-style:normal;font-weight:400;display:flex;width:140px;padding:6px 0;justify-content:center;align-items:center;gap:4px;border:1px solid var(---Grey-200, #e5e5e5);cursor:default}.univer-embed-sort-btn-container .univer-embed-sort-btn:active{background:#1e222b17}.univer-embed-sort-btn-container .univer-embed-sort-btn:hover{background:var(--black-6, rgba(30, 34, 43, .06))}.univer-embed-sort-btn-container .univer-embed-sort-btn-asc{border-radius:6px 0 0 6px}.univer-embed-sort-btn-container .univer-embed-sort-btn-desc{border-radius:0 6px 6px 0;margin-left:-1px}.univer-embed-sort-btn-container .univer-embed-sort-btn-icon{font-size:16px;color:#1e222b;margin-right:4px}.univer-custom-sort-col-menu{display:grid;gap:var(--margin-xxs);align-items:center;box-sizing:border-box;margin-top:0;margin-bottom:0;padding:var(--padding-sm);font-size:var(--font-size-base);background:var(---White, #fff);border:1px solid var(--black-6, rgba(30, 34, 43, .06));border-radius:var(--Radius-4, 8px);box-shadow:0 4px 12px 2px #1e222b1a;max-height:310px;overflow-y:auto;overflow-x:hidden}.univer-custom-sort-col-menu li{list-style:none}.univer-custom-sort-col-menu-item{cursor:pointer;position:relative;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;height:28px;padding:0 8px;font-size:13px;font-weight:400;font-style:normal;line-height:20px;color:var(---Black, #1e222b);text-align:left;border-radius:4px;border-radius:var(--border-radius-base);transition:background .2s}.univer-custom-sort-col-menu-item:hover{background:#f5f5f5}.univer-custom-sort-col-menu-item-desc{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1
+ .univer-extend-confirm-content{font-size:14px}.univer-extend-confirm-radio-group{margin-top:16px}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext{display:flex;justify-content:space-between;align-items:center}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition{color:#274fee;color:var(---Hyacinth-Blue-500, #274fee);font-size:16px;display:flex;align-items:center;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition-text{margin-left:6px;font-size:12px}.univer-custom-sort-panel-container .univer-custom-sort-panel-ext .univer-add-condition-disable{color:#1e222b;color:var(---Black, #1e222b);opacity:.3;cursor:not-allowed}.univer-custom-sort-panel-container .univer-custom-sort-panel-footer{margin-top:20px;display:flex;justify-content:end}.univer-custom-sort-panel-container .univer-custom-sort-panel-footer-btn{margin-left:12px}.univer-custom-sort-panel-container .univer-custom-sort-panel-item{display:flex;align-items:center;border-bottom:1px solid var(--gray-200)}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-head{display:flex;align-items:center}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-handler{font-size:16px;display:flex;align-items:center;justify-content:center;color:#1e222b;cursor:pointer}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-remove{font-size:14px;color:#4b4b4b;cursor:pointer;width:14px;height:14px;position:absolute;right:0}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input{display:flex;width:236px;padding:6px 10px;justify-content:space-between;align-items:center;margin-left:8px;border-radius:6px;border:1px solid #e5e5e5;border:1px solid var(---Grey-200, #e5e5e5);background:#fff;background:var(---White, #fff);color:#1e222b;color:var(---Black, #1e222b);font-family:PingFang SC;font-size:13px;font-style:normal;font-weight:400;line-height:20px;overflow:hidden}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input-dropdown{width:16px;height:16px;color:#4b4b4b}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-column-input-text{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-order-radio{display:flex;padding:0 10px}.univer-custom-sort-panel-container .univer-custom-sort-panel-item-order-radio-cn{display:flex;padding:0 20px}.univer-custom-sort-panel-container .univer-condition-list{max-height:310px;overflow-y:auto;overflow-x:hidden}.univer-embed-sort-btn-container{display:flex;margin-bottom:12px}.univer-embed-sort-btn-container .univer-embed-sort-btn{font-size:13px;font-style:normal;font-weight:400;display:flex;width:140px;padding:6px 0;justify-content:center;align-items:center;gap:4px;border:1px solid #e5e5e5;border:1px solid var(---Grey-200, #e5e5e5);cursor:default}.univer-embed-sort-btn-container .univer-embed-sort-btn:active{background:#1e222b17}.univer-embed-sort-btn-container .univer-embed-sort-btn:hover{background:#1e222b0f;background:var(--black-6, rgba(30, 34, 43, .06))}.univer-embed-sort-btn-container .univer-embed-sort-btn-asc{border-radius:6px 0 0 6px}.univer-embed-sort-btn-container .univer-embed-sort-btn-desc{border-radius:0 6px 6px 0;margin-left:-1px}.univer-embed-sort-btn-container .univer-embed-sort-btn-icon{font-size:16px;color:#1e222b;margin-right:4px}.univer-custom-sort-col-menu{display:grid;grid-gap:var(--margin-xxs);gap:var(--margin-xxs);align-items:center;box-sizing:border-box;margin-top:0;margin-bottom:0;padding:var(--padding-sm);font-size:var(--font-size-base);background:#fff;background:var(---White, #fff);border:1px solid rgba(30,34,43,.06);border:1px solid var(--black-6, rgba(30, 34, 43, .06));border-radius:8px;border-radius:var(--Radius-4, 8px);box-shadow:0 4px 12px 2px #1e222b1a;max-height:310px;overflow-y:auto;overflow-x:hidden}.univer-custom-sort-col-menu li{list-style:none}.univer-custom-sort-col-menu-item{cursor:pointer;position:relative;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;height:28px;padding:0 8px;font-size:13px;font-weight:400;font-style:normal;line-height:20px;color:#1e222b;color:var(---Black, #1e222b);text-align:left;border-radius:4px;border-radius:var(--border-radius-base);transition:background .2s}.univer-custom-sort-col-menu-item:hover{background:#f5f5f5}.univer-custom-sort-col-menu-item-desc{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@@ -1,4 +1,5 @@
1
1
  import { IPreset } from './types';
2
2
  import '@univerjs/sheets-sort/facade';
3
3
  import '@univerjs/sheets-sort-ui/lib/index.css';
4
+ export type * from '@univerjs/sheets-sort/facade';
4
5
  export declare function UniverSheetsSortPreset(): IPreset;
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @univerjs/sheets-sort/index
2
- (function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/engine-formula"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l.UniverSheetsSort={},l.UniverCore,l.UniverSheets,l.UniverEngineFormula))})(this,function(l,i,g,j){"use strict";var ne=Object.defineProperty;var re=(l,i,g)=>i in l?ne(l,i,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[i]=g;var _=(l,i,g)=>re(l,typeof i!="symbol"?i+"":i,g);var C;const D="sheets-sort.config",b={};var S=(e=>(e.DESC="desc",e.ASC="asc",e))(S||{});const A=e=>e.replace(/-/gi,"").replace(/'/gi,""),N=(e,s)=>{const t=e===null||e==="",r=s===null||s==="";return t&&r?0:t?1:r?-1:null},O=(e,s,t)=>{const r=typeof e=="number",n=typeof s=="number";return r&&n?e<s?t===S.ASC?-1:1:e>s?t===S.ASC?1:-1:0:r?t===S.ASC?1:-1:n?t===S.ASC?-1:1:null},E=(e,s,t)=>{const r=typeof e=="string",n=typeof s=="string";if(r&&(e=A(e.toLocaleLowerCase())),n&&(s=A(s.toLocaleLowerCase())),!r&&!n)return null;if(r&&n){const o=e,u=s;return o<u?t===S.ASC?-1:1:o>u?t===S.ASC?1:-1:0}return r?t===S.ASC?1:-1:n?t===S.ASC?-1:1:null},y=e=>!e||Object.keys(e).length===0||(e==null?void 0:e.v)==null&&(e==null?void 0:e.p)==null;var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,V=(e,s,t,r)=>{for(var n=r>1?void 0:r?$(s,t):s,o=e.length-1,u;o>=0;o--)(u=e[o])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&M(s,t,n),n},p=(e,s)=>(t,r)=>s(t,r,e);l.SheetsSortService=class extends i.Disposable{constructor(t,r,n){super();_(this,"_compareFns",[]);this._univerInstanceService=t,this._commandService=r,this._formulaDataModel=n}mergeCheck(t){var a;const{unitId:r,subUnitId:n,range:o}=t,u=(a=this._univerInstanceService.getUnit(r))==null?void 0:a.getSheetBySheetId(n);if(!u)return!1;const c=u.getMergeData().filter(f=>i.Rectangle.contains(o,f));return c.length===0?!0:L(o,c)}emptyCheck(t){var c;const{unitId:r,subUnitId:n,range:o}=t,u=(c=this._univerInstanceService.getUnit(r))==null?void 0:c.getSheetBySheetId(n);if(!u)return!1;for(let a=o.startRow;a<=o.endRow;a++)for(let f=o.startColumn;f<=o.endColumn;f++)if(!y(u.getCellRaw(a,f)))return!0;return!1}singleCheck(t){return t.range.startRow!==t.range.endRow}formulaCheck(t){var c,a;const{unitId:r,subUnitId:n,range:o}=t,u=(a=(c=this._formulaDataModel.getArrayFormulaRange())==null?void 0:c[r])==null?void 0:a[n];for(const f in u){const d=u[Number(f)];for(const I in d){const v=d[Number(I)];if(v&&i.Rectangle.intersects(o,v))return!1}}return!0}registerCompareFn(t){this._compareFns.unshift(t)}getAllCompareFns(){return this._compareFns}applySort(t,r,n){var c;const{unitId:o,subUnitId:u}=g.getSheetCommandTarget(this._univerInstanceService)||{};this._commandService.executeCommand(R.id,{orderRules:t.orderRules,range:t.range,hasTitle:(c=t.hasTitle)!=null?c:!1,unitId:r||o,subUnitId:n||u})}},l.SheetsSortService=V([p(0,i.IUniverInstanceService),p(1,i.ICommandService),p(2,i.Inject(j.FormulaDataModel))],l.SheetsSortService);function L(e,s){const t=e.endRow-e.startRow+1,r=e.endColumn-e.startColumn+1;let n=null,o=null;const u=t*r;let c=0;for(const a of s)if(a.startRow>=e.startRow&&a.endRow<=e.endRow&&a.startColumn>=e.startColumn&&a.endColumn<=e.endColumn){const f=a.endRow-a.startRow+1,d=a.endColumn-a.startColumn+1;if(n===null&&o===null)n=f,o=d;else if(f!==n||d!==o)return!1;c+=f*d}return c===u}const R={id:"sheet.command.sort-range",type:i.CommandType.COMMAND,handler:(e,s)=>{const{range:t,orderRules:r,hasTitle:n,unitId:o,subUnitId:u}=s,c=e.get(l.SheetsSortService),a=e.get(i.IUniverInstanceService),{worksheet:f}=g.getSheetCommandTarget(a,s)||{};if(!f)return!1;const d=f.getMergeData().filter(m=>i.Rectangle.contains(t,m)),I=d.map(m=>m.startRow),{startRow:v,endRow:Q}=t,X=n?v+1:v,w=[],F=[];for(let m=X;m<=Q;m++)f.getRowFiltered(m)||f.getRowRawVisible(m)!==!1&&(d.length&&!I.includes(m)||(w.push({index:m,value:G(f,m,r)}),F.push(m)));const Z=c.getAllCompareFns();w.sort(B(r,q(Z)));const T={};w.forEach(({index:m,value:oe},te)=>{T[F[te]]=m});const k={id:g.ReorderRangeCommand.id,params:{unitId:o,subUnitId:u,range:t,order:T}},ee=e.get(i.ICommandService);return i.sequenceExecute([k],ee).result}};function G(e,s,t){const r=[];return t.forEach(({colIndex:n})=>{r.push(e.getCellRaw(s,n))}),r}function q(e){return(s,t,r)=>{for(let n=0;n<e.length;n++){const o=e[n](s,t,r);if(o!=null)return o}return 0}}function B(e,s){return function(t,r){let n=null;for(let o=0;o<e.length;o++){const u=t.value[o],c=r.value[o];if(n=s(e[o].type,u,c),n!==0&&n!==null&&n!==void 0)return n}return 0}}var H=Object.defineProperty,x=Object.getOwnPropertyDescriptor,K=(e,s,t,r)=>{for(var n=r>1?void 0:r?x(s,t):s,o=e.length-1,u;o>=0;o--)(u=e[o])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&H(s,t,n),n},P=(e,s)=>(t,r)=>s(t,r,e);let h=class extends i.Disposable{constructor(e,s){super(),this._commandService=e,this._sortService=s,this._initCommands(),this._registerCompareFns()}_initCommands(){[R].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_registerCompareFns(){const e=(s,t,r)=>{const n=this._getCommonValue(t),o=this._getCommonValue(r),u=[N,E,O];for(let c=0;c<u.length;c++){const a=u[c](n,o,s);if(a!==null)return a}return null};this._sortService.registerCompareFn(e)}_getCommonValue(e){var t,r;if(y(e))return null;const s=(r=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:r.dataStream;return s||((e==null?void 0:e.t)===i.CellValueType.NUMBER?Number.parseFloat(`${e.v}`):(e==null?void 0:e.t)===i.CellValueType.STRING?typeof e.v=="number"?e.v:`${e.v}`:(e==null?void 0:e.t)===i.CellValueType.BOOLEAN?`${e.v}`:(e==null?void 0:e.t)===i.CellValueType.FORCE_STRING?Number.parseFloat(`${e.v}`):`${e==null?void 0:e.v}`)}};h=K([P(0,i.ICommandService),P(1,i.Inject(l.SheetsSortService))],h);var W=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,z=(e,s,t,r)=>{for(var n=r>1?void 0:r?Y(s,t):s,o=e.length-1,u;o>=0;o--)(u=e[o])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&W(s,t,n),n},U=(e,s)=>(t,r)=>s(t,r,e);const J="SHEET_SORT_PLUGIN";l.UniverSheetsSortPlugin=(C=class extends i.Plugin{constructor(s=b,t,r){super(),this._config=s,this._injector=t,this._configService=r;const{...n}=i.merge({},b,this._config);this._configService.setConfig(D,n)}onStarting(){[[h],[l.SheetsSortService]].forEach(s=>this._injector.add(s))}onReady(){this._injector.get(h)}},_(C,"type",i.UniverInstanceType.UNIVER_SHEET),_(C,"pluginName",J),C),l.UniverSheetsSortPlugin=z([U(1,i.Inject(i.Injector)),U(2,i.IConfigService)],l.UniverSheetsSortPlugin),l.SortRangeCommand=R,l.SortType=S,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
2
+ (function(l,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/engine-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/engine-formula"],o):(l=typeof globalThis<"u"?globalThis:l||self,o(l.UniverSheetsSort={},l.UniverCore,l.UniverSheets,l.UniverEngineFormula))})(this,function(l,o,g,j){"use strict";var ne=Object.defineProperty;var re=(l,o,g)=>o in l?ne(l,o,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[o]=g;var _=(l,o,g)=>re(l,typeof o!="symbol"?o+"":o,g);var C;const D="sheets-sort.config",b={};var d=(e=>(e.DESC="desc",e.ASC="asc",e))(d||{});const A=e=>e.replace(/-/gi,"").replace(/'/gi,""),N=(e,s)=>{const t=e===null||e==="",r=s===null||s==="";return t&&r?0:t?1:r?-1:null},O=(e,s,t)=>{const r=typeof e=="number",n=typeof s=="number";return r&&n?e<s?t===d.ASC?-1:1:e>s?t===d.ASC?1:-1:0:r?t===d.ASC?1:-1:n?t===d.ASC?-1:1:null},E=(e,s,t)=>{const r=typeof e=="string",n=typeof s=="string";if(r&&(e=A(e.toLocaleLowerCase())),n&&(s=A(s.toLocaleLowerCase())),!r&&!n)return null;if(r&&n){const i=e,u=s;return i<u?t===d.ASC?-1:1:i>u?t===d.ASC?1:-1:0}return r?t===d.ASC?1:-1:n?t===d.ASC?-1:1:null},y=e=>!e||Object.keys(e).length===0||(e==null?void 0:e.v)==null&&(e==null?void 0:e.p)==null;var M=Object.defineProperty,$=Object.getOwnPropertyDescriptor,V=(e,s,t,r)=>{for(var n=r>1?void 0:r?$(s,t):s,i=e.length-1,u;i>=0;i--)(u=e[i])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&M(s,t,n),n},p=(e,s)=>(t,r)=>s(t,r,e);l.SheetsSortService=class extends o.Disposable{constructor(t,r,n){super();_(this,"_compareFns",[]);this._univerInstanceService=t,this._commandService=r,this._formulaDataModel=n}mergeCheck(t){var a;const{unitId:r,subUnitId:n,range:i}=t,u=(a=this._univerInstanceService.getUnit(r))==null?void 0:a.getSheetBySheetId(n);if(!u)return!1;const c=u.getMergeData().filter(f=>o.Rectangle.contains(i,f));return c.length===0?!0:L(i,c)}emptyCheck(t){var c;const{unitId:r,subUnitId:n,range:i}=t,u=(c=this._univerInstanceService.getUnit(r))==null?void 0:c.getSheetBySheetId(n);if(!u)return!1;for(let a=i.startRow;a<=i.endRow;a++)for(let f=i.startColumn;f<=i.endColumn;f++)if(!y(u.getCellRaw(a,f)))return!0;return!1}singleCheck(t){return t.range.startRow!==t.range.endRow}formulaCheck(t){var c,a;const{unitId:r,subUnitId:n,range:i}=t,u=(a=(c=this._formulaDataModel.getArrayFormulaRange())==null?void 0:c[r])==null?void 0:a[n];for(const f in u){const S=u[Number(f)];for(const I in S){const v=S[Number(I)];if(v&&o.Rectangle.intersects(i,v))return!1}}return!0}registerCompareFn(t){this._compareFns.unshift(t)}getAllCompareFns(){return this._compareFns}applySort(t,r,n){var c;const{unitId:i,subUnitId:u}=g.getSheetCommandTarget(this._univerInstanceService)||{};this._commandService.executeCommand(R.id,{orderRules:t.orderRules,range:t.range,hasTitle:(c=t.hasTitle)!=null?c:!1,unitId:r||i,subUnitId:n||u})}},l.SheetsSortService=V([p(0,o.IUniverInstanceService),p(1,o.ICommandService),p(2,o.Inject(j.FormulaDataModel))],l.SheetsSortService);function L(e,s){const t=e.endRow-e.startRow+1,r=e.endColumn-e.startColumn+1;let n=null,i=null;const u=t*r;let c=0;for(const a of s)if(a.startRow>=e.startRow&&a.endRow<=e.endRow&&a.startColumn>=e.startColumn&&a.endColumn<=e.endColumn){const f=a.endRow-a.startRow+1,S=a.endColumn-a.startColumn+1;if(n===null&&i===null)n=f,i=S;else if(f!==n||S!==i)return!1;c+=f*S}return c===u}const R={id:"sheet.command.sort-range",type:o.CommandType.COMMAND,handler:(e,s)=>{const{range:t,orderRules:r,hasTitle:n,unitId:i,subUnitId:u}=s,c=e.get(l.SheetsSortService),a=e.get(o.IUniverInstanceService),{worksheet:f}=g.getSheetCommandTarget(a,s)||{};if(!f)return!1;const S=f.getMergeData().filter(m=>o.Rectangle.contains(t,m)),I=S.map(m=>m.startRow),{startRow:v,endRow:Q}=t,X=n?v+1:v,w=[],F=[];for(let m=X;m<=Q;m++)f.getRowFiltered(m)||f.getRowRawVisible(m)!==!1&&(S.length&&!I.includes(m)||(w.push({index:m,value:G(f,m,r)}),F.push(m)));const Z=c.getAllCompareFns();w.sort(B(r,q(Z)));const T={};w.forEach(({index:m,value:ie},te)=>{T[F[te]]=m});const k={id:g.ReorderRangeCommand.id,params:{unitId:i,subUnitId:u,range:t,order:T}},ee=e.get(o.ICommandService);return o.sequenceExecute([k],ee).result}};function G(e,s,t){const r=[];return t.forEach(({colIndex:n})=>{r.push(e.getCellRaw(s,n))}),r}function q(e){return(s,t,r)=>{for(let n=0;n<e.length;n++){const i=e[n](s,t,r);if(i!=null)return i}return 0}}function B(e,s){return function(t,r){let n=null;for(let i=0;i<e.length;i++){const u=t.value[i],c=r.value[i];if(n=s(e[i].type,u,c),n!==0&&n!==null&&n!==void 0)return n}return 0}}var H=Object.defineProperty,x=Object.getOwnPropertyDescriptor,K=(e,s,t,r)=>{for(var n=r>1?void 0:r?x(s,t):s,i=e.length-1,u;i>=0;i--)(u=e[i])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&H(s,t,n),n},P=(e,s)=>(t,r)=>s(t,r,e);let h=class extends o.Disposable{constructor(e,s){super(),this._commandService=e,this._sortService=s,this._initCommands(),this._registerCompareFns()}_initCommands(){[R].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_registerCompareFns(){const e=(s,t,r)=>{const n=this._getCommonValue(t),i=this._getCommonValue(r),u=[N,E,O];for(let c=0;c<u.length;c++){const a=u[c](n,i,s);if(a!==null)return a}return null};this._sortService.registerCompareFn(e)}_getCommonValue(e){var t,r;if(y(e))return null;const s=(r=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:r.dataStream;return s||((e==null?void 0:e.t)===o.CellValueType.NUMBER?Number.parseFloat(`${e.v}`):(e==null?void 0:e.t)===o.CellValueType.STRING?typeof e.v=="number"?e.v:`${e.v}`:(e==null?void 0:e.t)===o.CellValueType.BOOLEAN?`${e.v}`:(e==null?void 0:e.t)===o.CellValueType.FORCE_STRING?Number.parseFloat(`${e.v}`):`${e==null?void 0:e.v}`)}};h=K([P(0,o.ICommandService),P(1,o.Inject(l.SheetsSortService))],h);var W=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,z=(e,s,t,r)=>{for(var n=r>1?void 0:r?Y(s,t):s,i=e.length-1,u;i>=0;i--)(u=e[i])&&(n=(r?u(s,t,n):u(n))||n);return r&&n&&W(s,t,n),n},U=(e,s)=>(t,r)=>s(t,r,e);const J="SHEET_SORT_PLUGIN";l.UniverSheetsSortPlugin=(C=class extends o.Plugin{constructor(s=b,t,r){super(),this._config=s,this._injector=t,this._configService=r;const{...n}=o.merge({},b,this._config);this._configService.setConfig(D,n)}onStarting(){[[h],[l.SheetsSortService]].forEach(s=>this._injector.add(s))}onReady(){this._injector.get(h)}},_(C,"type",o.UniverInstanceType.UNIVER_SHEET),_(C,"pluginName",J),C),l.UniverSheetsSortPlugin=z([U(1,o.Inject(o.Injector)),U(2,o.IConfigService)],l.UniverSheetsSortPlugin),l.SortRangeCommand=R,l.SortType=d,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
3
3
 
4
4
 
5
5
  // @univerjs/sheets-sort/facade
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/preset-sheets-sort",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -57,17 +57,18 @@
57
57
  "rxjs": ">=7.0.0"
58
58
  },
59
59
  "dependencies": {
60
- "@univerjs/sheets-sort": "0.5.3",
61
- "@univerjs/sheets-sort-ui": "0.5.3"
60
+ "@univerjs/sheets-sort": "0.5.5",
61
+ "@univerjs/sheets-sort-ui": "0.5.5"
62
62
  },
63
63
  "devDependencies": {
64
- "@univerjs/core": "0.5.3",
64
+ "@univerjs/core": "0.5.5",
65
65
  "typescript": "^5.7.2",
66
- "@univerjs-infra/shared": "0.5.3"
66
+ "@univerjs-infra/shared": "0.5.5"
67
67
  },
68
68
  "scripts": {
69
69
  "prebuild:preset": "tsx prepare.ts",
70
- "build:preset": "tsx build.ts"
70
+ "build:preset": "tsx build.ts",
71
+ "lint:types": "tsc --noEmit"
71
72
  },
72
73
  "module": "./lib/es/index.js"
73
74
  }