@univerjs/sheets-sort 0.4.2-nightly.202411061606 → 0.4.2-nightly.202411081606
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 +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +186 -191
- package/lib/{locale → es/locale}/en-US.js +2 -2
- package/lib/{locale → es/locale}/fa-IR.js +2 -2
- package/lib/{locale → es/locale}/ru-RU.js +2 -2
- package/lib/{locale → es/locale}/vi-VN.js +2 -2
- package/lib/{locale → es/locale}/zh-CN.js +2 -2
- package/lib/{locale → es/locale}/zh-TW.js +2 -2
- package/package.json +18 -12
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var j=Object.defineProperty;var M=(e,r,t)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var d=(e,r,t)=>M(e,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),R=require("@univerjs/sheets"),$=require("@univerjs/engine-formula"),V="sheets-sort.config",x={};var f=(e=>(e.DESC="desc",e.ASC="asc",e))(f||{});const A=e=>e.replace(/-/gi,"").replace(/'/gi,""),L=(e,r)=>{const t=e===null||e==="",o=r===null||r==="";return t&&o?0:t?1:o?-1:null},G=(e,r,t)=>{const o=typeof e=="number",n=typeof r=="number";return o&&n?e<r?t===f.ASC?-1:1:e>r?t===f.ASC?1:-1:0:o?t===f.ASC?1:-1:n?t===f.ASC?-1:1:null},q=(e,r,t)=>{const o=typeof e=="string",n=typeof r=="string";if(o&&(e=A(e.toLocaleLowerCase())),n&&(r=A(r.toLocaleLowerCase())),!o&&!n)return null;if(o&&n){const s=e,i=r;return s<i?t===f.ASC?-1:1:s>i?t===f.ASC?1:-1:0}return o?t===f.ASC?1:-1:n?t===f.ASC?-1:1:null},F=e=>!e||Object.keys(e).length===0||(e==null?void 0:e.v)==null&&(e==null?void 0:e.p)==null;var B=Object.defineProperty,H=Object.getOwnPropertyDescriptor,K=(e,r,t,o)=>{for(var n=o>1?void 0:o?H(r,t):r,s=e.length-1,i;s>=0;s--)(i=e[s])&&(n=(o?i(r,t,n):i(n))||n);return o&&n&&B(r,t,n),n},p=(e,r)=>(t,o)=>r(t,o,e);exports.SheetsSortService=class extends c.Disposable{constructor(t,o,n){super();d(this,"_compareFns",[]);this._univerInstanceService=t,this._commandService=o,this._formulaDataModel=n}mergeCheck(t){var u;const{unitId:o,subUnitId:n,range:s}=t,i=(u=this._univerInstanceService.getUnit(o))==null?void 0:u.getSheetBySheetId(n);if(!i)return!1;const l=i.getMergeData().filter(a=>c.Rectangle.contains(s,a));return l.length===0?!0:W(s,l)}emptyCheck(t){var l;const{unitId:o,subUnitId:n,range:s}=t,i=(l=this._univerInstanceService.getUnit(o))==null?void 0:l.getSheetBySheetId(n);if(!i)return!1;for(let u=s.startRow;u<=s.endRow;u++)for(let a=s.startColumn;a<=s.endColumn;a++)if(!F(i.getCellRaw(u,a)))return!0;return!1}singleCheck(t){return t.range.startRow!==t.range.endRow}formulaCheck(t){var l,u;const{unitId:o,subUnitId:n,range:s}=t,i=(u=(l=this._formulaDataModel.getArrayFormulaRange())==null?void 0:l[o])==null?void 0:u[n];for(const a in i){const g=i[Number(a)];for(const C in g){const S=g[Number(C)];if(S&&c.Rectangle.intersects(s,S))return!1}}return!0}registerCompareFn(t){this._compareFns.unshift(t)}getAllCompareFns(){return this._compareFns}applySort(t,o,n){var l;const{unitId:s,subUnitId:i}=R.getSheetCommandTarget(this._univerInstanceService)||{};this._commandService.executeCommand(I.id,{orderRules:t.orderRules,range:t.range,hasTitle:(l=t.hasTitle)!=null?l:!1,unitId:o||s,subUnitId:n||i})}};exports.SheetsSortService=K([p(0,c.IUniverInstanceService),p(1,c.ICommandService),p(2,c.Inject($.FormulaDataModel))],exports.SheetsSortService);function W(e,r){const t=e.endRow-e.startRow+1,o=e.endColumn-e.startColumn+1;let n=null,s=null;const i=t*o;let l=0;for(const u of r)if(u.startRow>=e.startRow&&u.endRow<=e.endRow&&u.startColumn>=e.startColumn&&u.endColumn<=e.endColumn){const a=u.endRow-u.startRow+1,g=u.endColumn-u.startColumn+1;if(n===null&&s===null)n=a,s=g;else if(a!==n||g!==s)return!1;l+=a*g}return l===i}const I={id:"sheet.command.sort-range",type:c.CommandType.COMMAND,handler:(e,r)=>{const{range:t,orderRules:o,hasTitle:n,unitId:s,subUnitId:i}=r,l=e.get(exports.SheetsSortService),u=e.get(c.IUniverInstanceService),{worksheet:a}=R.getSheetCommandTarget(u,r)||{};if(!a)return!1;const g=a.getMergeData().filter(m=>c.Rectangle.contains(t,m)),C=g.map(m=>m.startRow),{startRow:S,endRow:D}=t,N=n?S+1:S,_=[],w=[];for(let m=N;m<=D;m++)a.getRowFiltered(m)||a.getRowRawVisible(m)!==!1&&(g.length&&!C.includes(m)||(_.push({index:m,value:Y(a,m,o)}),w.push(m)));const O=l.getAllCompareFns();_.sort(J(o,z(O)));const b={};_.forEach(({index:m,value:oe},E)=>{b[w[E]]=m});const U={id:R.ReorderRangeCommand.id,params:{unitId:s,subUnitId:i,range:t,order:b}},T=e.get(c.ICommandService);return c.sequenceExecute([U],T).result}};function Y(e,r,t){const o=[];return t.forEach(({colIndex:n})=>{o.push(e.getCellRaw(r,n))}),o}function z(e){return(r,t,o)=>{for(let n=0;n<e.length;n++){const s=e[n](r,t,o);if(s!=null)return s}return 0}}function J(e,r){return function(t,o){let n=null;for(let s=0;s<e.length;s++){const i=t.value[s],l=o.value[s];if(n=r(e[s].type,i,l),n!==0&&n!==null&&n!==void 0)return n}return 0}}var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,Z=(e,r,t,o)=>{for(var n=o>1?void 0:o?X(r,t):r,s=e.length-1,i;s>=0;s--)(i=e[s])&&(n=(o?i(r,t,n):i(n))||n);return o&&n&&Q(r,t,n),n},P=(e,r)=>(t,o)=>r(t,o,e);let h=class extends c.Disposable{constructor(e,r){super(),this._commandService=e,this._sortService=r,this._initCommands(),this._registerCompareFns()}_initCommands(){[I].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_registerCompareFns(){const e=(r,t,o)=>{const n=this._getCommonValue(t),s=this._getCommonValue(o),i=[L,q,G];for(let l=0;l<i.length;l++){const u=i[l](n,s,r);if(u!==null)return u}return null};this._sortService.registerCompareFn(e)}_getCommonValue(e){var t,o;if(F(e))return null;const r=(o=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:o.dataStream;return r||((e==null?void 0:e.t)===c.CellValueType.NUMBER?Number.parseFloat(`${e.v}`):(e==null?void 0:e.t)===c.CellValueType.STRING?typeof e.v=="number"?e.v:`${e.v}`:(e==null?void 0:e.t)===c.CellValueType.BOOLEAN?`${e.v}`:(e==null?void 0:e.t)===c.CellValueType.FORCE_STRING?Number.parseFloat(`${e.v}`):`${e==null?void 0:e.v}`)}};h=Z([P(0,c.ICommandService),P(1,c.Inject(exports.SheetsSortService))],h);var k=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=(e,r,t,o)=>{for(var n=o>1?void 0:o?ee(r,t):r,s=e.length-1,i;s>=0;s--)(i=e[s])&&(n=(o?i(r,t,n):i(n))||n);return o&&n&&k(r,t,n),n},y=(e,r)=>(t,o)=>r(t,o,e);const re="SHEET_SORT_PLUGIN";var v;exports.UniverSheetsSortPlugin=(v=class extends c.Plugin{constructor(r=x,t,o){super(),this._config=r,this._injector=t,this._configService=o;const{...n}=this._config;this._configService.setConfig(V,n)}onStarting(){[[h],[exports.SheetsSortService]].forEach(r=>this._injector.add(r))}onReady(){this._injector.get(h)}},d(v,"type",c.UniverInstanceType.UNIVER_SHEET),d(v,"pluginName",re),v);exports.UniverSheetsSortPlugin=te([y(1,c.Inject(c.Injector)),y(2,c.IConfigService)],exports.UniverSheetsSortPlugin);exports.SortRangeCommand=I;exports.SortType=f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o={sheetsSort:{title:"Sort",toolbar:{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"},"context-menu":{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"}}};module.exports=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={sheetsSort:{title:"مرتبسازی",toolbar:{"sort-asc":"ترتیب صعودی","sort-desc":"ترتیب نزولی","sort-custom":"ترتیب سفارشی"},"context-menu":{"sort-asc":"ترتیب صعودی","sort-desc":"ترتیب نزولی","sort-custom":"ترتیب سفارشی"}}};module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o={sheetsSort:{title:"Sort",toolbar:{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"},"context-menu":{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"}}};module.exports=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o={sheetsSort:{title:"Sort",toolbar:{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"},"context-menu":{"sort-asc":"ascending order","sort-desc":"descending order","sort-custom":"custom order"}}};module.exports=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={sheetsSort:{title:"排序",toolbar:{"sort-asc":"升序","sort-desc":"降序","sort-custom":"自定义排序"},"context-menu":{"sort-asc":"升序","sort-desc":"降序","sort-custom":"自定义排序"}}};module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={sheetsSort:{title:"Sắp xếp",toolbar:{"sort-asc":"Tăng dần","sort-desc":"Giảm dần","sort-custom":"Sắp xếp tùy chỉnh"},"context-menu":{"sort-asc":"Tăng dần","sort-desc":"Giảm dần","sort-custom":"Sắp xếp tùy chỉnh"}}};module.exports=t;
|
package/lib/es/index.js
CHANGED
|
@@ -1,247 +1,242 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (isA1Str && (a1 = removeStringSymbol(a1.toLocaleLowerCase())), isA2Str && (a2 = removeStringSymbol(a2.toLocaleLowerCase())), !isA1Str && !isA2Str)
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var q = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var h = (e, t, r) => q(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { Inject as w, Disposable as y, Rectangle as R, IUniverInstanceService as E, ICommandService as I, CommandType as H, sequenceExecute as K, CellValueType as v, Plugin as W, UniverInstanceType as Y, Injector as z, IConfigService as J } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as U, ReorderRangeCommand as Q } from "@univerjs/sheets";
|
|
6
|
+
import { FormulaDataModel as X } from "@univerjs/engine-formula";
|
|
7
|
+
const Z = "sheets-sort.config", k = {};
|
|
8
|
+
var f = /* @__PURE__ */ ((e) => (e.DESC = "desc", e.ASC = "asc", e))(f || {});
|
|
9
|
+
const N = (e) => e.replace(/-/gi, "").replace(/'/gi, ""), ee = (e, t) => {
|
|
10
|
+
const r = e === null || e === "", o = t === null || t === "";
|
|
11
|
+
return r && o ? 0 : r ? 1 : o ? -1 : null;
|
|
12
|
+
}, te = (e, t, r) => {
|
|
13
|
+
const o = typeof e == "number", n = typeof t == "number";
|
|
14
|
+
return o && n ? e < t ? r === f.ASC ? -1 : 1 : e > t ? r === f.ASC ? 1 : -1 : 0 : o ? r === f.ASC ? 1 : -1 : n ? r === f.ASC ? -1 : 1 : null;
|
|
15
|
+
}, re = (e, t, r) => {
|
|
16
|
+
const o = typeof e == "string", n = typeof t == "string";
|
|
17
|
+
if (o && (e = N(e.toLocaleLowerCase())), n && (t = N(t.toLocaleLowerCase())), !o && !n)
|
|
19
18
|
return null;
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
var
|
|
27
|
-
for (var
|
|
28
|
-
(
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
let
|
|
32
|
-
constructor(
|
|
19
|
+
if (o && n) {
|
|
20
|
+
const s = e, i = t;
|
|
21
|
+
return s < i ? r === f.ASC ? -1 : 1 : s > i ? r === f.ASC ? 1 : -1 : 0;
|
|
22
|
+
}
|
|
23
|
+
return o ? r === f.ASC ? 1 : -1 : n ? r === f.ASC ? -1 : 1 : null;
|
|
24
|
+
}, M = (e) => !e || Object.keys(e).length === 0 || (e == null ? void 0 : e.v) == null && (e == null ? void 0 : e.p) == null;
|
|
25
|
+
var ne = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, se = (e, t, r, o) => {
|
|
26
|
+
for (var n = o > 1 ? void 0 : o ? oe(t, r) : t, s = e.length - 1, i; s >= 0; s--)
|
|
27
|
+
(i = e[s]) && (n = (o ? i(t, r, n) : i(n)) || n);
|
|
28
|
+
return o && n && ne(t, r, n), n;
|
|
29
|
+
}, p = (e, t) => (r, o) => t(r, o, e);
|
|
30
|
+
let g = class extends y {
|
|
31
|
+
constructor(t, r, o) {
|
|
33
32
|
super();
|
|
34
|
-
|
|
35
|
-
this._univerInstanceService =
|
|
33
|
+
h(this, "_compareFns", []);
|
|
34
|
+
this._univerInstanceService = t, this._commandService = r, this._formulaDataModel = o;
|
|
36
35
|
}
|
|
37
|
-
mergeCheck(
|
|
38
|
-
var
|
|
39
|
-
const { unitId, subUnitId, range } =
|
|
40
|
-
if (!
|
|
36
|
+
mergeCheck(t) {
|
|
37
|
+
var c;
|
|
38
|
+
const { unitId: r, subUnitId: o, range: n } = t, s = (c = this._univerInstanceService.getUnit(r)) == null ? void 0 : c.getSheetBySheetId(o);
|
|
39
|
+
if (!s)
|
|
41
40
|
return !1;
|
|
42
|
-
const
|
|
43
|
-
return
|
|
41
|
+
const i = s.getMergeData().filter((u) => R.contains(n, u));
|
|
42
|
+
return i.length === 0 ? !0 : ie(n, i);
|
|
44
43
|
}
|
|
45
|
-
emptyCheck(
|
|
46
|
-
var
|
|
47
|
-
const { unitId, subUnitId, range } =
|
|
48
|
-
if (!
|
|
44
|
+
emptyCheck(t) {
|
|
45
|
+
var i;
|
|
46
|
+
const { unitId: r, subUnitId: o, range: n } = t, s = (i = this._univerInstanceService.getUnit(r)) == null ? void 0 : i.getSheetBySheetId(o);
|
|
47
|
+
if (!s)
|
|
49
48
|
return !1;
|
|
50
|
-
for (let
|
|
51
|
-
for (let
|
|
52
|
-
if (!
|
|
49
|
+
for (let c = n.startRow; c <= n.endRow; c++)
|
|
50
|
+
for (let u = n.startColumn; u <= n.endColumn; u++)
|
|
51
|
+
if (!M(s.getCellRaw(c, u)))
|
|
53
52
|
return !0;
|
|
54
53
|
return !1;
|
|
55
54
|
}
|
|
56
|
-
singleCheck(
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
formulaCheck(
|
|
60
|
-
var
|
|
61
|
-
const { unitId, subUnitId, range } =
|
|
62
|
-
for (const
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
55
|
+
singleCheck(t) {
|
|
56
|
+
return t.range.startRow !== t.range.endRow;
|
|
57
|
+
}
|
|
58
|
+
formulaCheck(t) {
|
|
59
|
+
var i, c;
|
|
60
|
+
const { unitId: r, subUnitId: o, range: n } = t, s = (c = (i = this._formulaDataModel.getArrayFormulaRange()) == null ? void 0 : i[r]) == null ? void 0 : c[o];
|
|
61
|
+
for (const u in s) {
|
|
62
|
+
const a = s[Number(u)];
|
|
63
|
+
for (const m in a) {
|
|
64
|
+
const d = a[Number(m)];
|
|
65
|
+
if (d && R.intersects(n, d))
|
|
67
66
|
return !1;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
return !0;
|
|
71
70
|
}
|
|
72
|
-
registerCompareFn(
|
|
73
|
-
this._compareFns.unshift(
|
|
71
|
+
registerCompareFn(t) {
|
|
72
|
+
this._compareFns.unshift(t);
|
|
74
73
|
}
|
|
75
74
|
getAllCompareFns() {
|
|
76
75
|
return this._compareFns;
|
|
77
76
|
}
|
|
78
|
-
applySort(
|
|
79
|
-
var
|
|
80
|
-
const { unitId:
|
|
81
|
-
this._commandService.executeCommand(
|
|
82
|
-
orderRules:
|
|
83
|
-
range:
|
|
84
|
-
hasTitle: (
|
|
85
|
-
unitId:
|
|
86
|
-
subUnitId:
|
|
77
|
+
applySort(t, r, o) {
|
|
78
|
+
var i;
|
|
79
|
+
const { unitId: n, subUnitId: s } = U(this._univerInstanceService) || {};
|
|
80
|
+
this._commandService.executeCommand(T.id, {
|
|
81
|
+
orderRules: t.orderRules,
|
|
82
|
+
range: t.range,
|
|
83
|
+
hasTitle: (i = t.hasTitle) != null ? i : !1,
|
|
84
|
+
unitId: r || n,
|
|
85
|
+
subUnitId: o || s
|
|
87
86
|
});
|
|
88
87
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
let
|
|
98
|
-
const
|
|
99
|
-
let
|
|
100
|
-
for (const
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
else if (
|
|
88
|
+
};
|
|
89
|
+
g = se([
|
|
90
|
+
p(0, E),
|
|
91
|
+
p(1, I),
|
|
92
|
+
p(2, w(X))
|
|
93
|
+
], g);
|
|
94
|
+
function ie(e, t) {
|
|
95
|
+
const r = e.endRow - e.startRow + 1, o = e.endColumn - e.startColumn + 1;
|
|
96
|
+
let n = null, s = null;
|
|
97
|
+
const i = r * o;
|
|
98
|
+
let c = 0;
|
|
99
|
+
for (const u of t)
|
|
100
|
+
if (u.startRow >= e.startRow && u.endRow <= e.endRow && u.startColumn >= e.startColumn && u.endColumn <= e.endColumn) {
|
|
101
|
+
const a = u.endRow - u.startRow + 1, m = u.endColumn - u.startColumn + 1;
|
|
102
|
+
if (n === null && s === null)
|
|
103
|
+
n = a, s = m;
|
|
104
|
+
else if (a !== n || m !== s)
|
|
106
105
|
return !1;
|
|
107
|
-
|
|
106
|
+
c += a * m;
|
|
108
107
|
}
|
|
109
|
-
return
|
|
108
|
+
return c === i;
|
|
110
109
|
}
|
|
111
|
-
|
|
112
|
-
const SortRangeCommand = {
|
|
110
|
+
const T = {
|
|
113
111
|
id: "sheet.command.sort-range",
|
|
114
|
-
type:
|
|
115
|
-
handler:
|
|
116
|
-
const { range, orderRules, hasTitle, unitId, subUnitId } =
|
|
117
|
-
if (!
|
|
112
|
+
type: H.COMMAND,
|
|
113
|
+
handler: (e, t) => {
|
|
114
|
+
const { range: r, orderRules: o, hasTitle: n, unitId: s, subUnitId: i } = t, c = e.get(g), u = e.get(E), { worksheet: a } = U(u, t) || {};
|
|
115
|
+
if (!a)
|
|
118
116
|
return !1;
|
|
119
|
-
const
|
|
120
|
-
for (let
|
|
121
|
-
|
|
122
|
-
index:
|
|
123
|
-
value:
|
|
124
|
-
}),
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
117
|
+
const m = a.getMergeData().filter((l) => R.contains(r, l)), d = m.map((l) => l.startRow), { startRow: b, endRow: $ } = r, j = n ? b + 1 : b, S = [], A = [];
|
|
118
|
+
for (let l = j; l <= $; l++)
|
|
119
|
+
a.getRowFiltered(l) || a.getRowRawVisible(l) !== !1 && (m.length && !d.includes(l) || (S.push({
|
|
120
|
+
index: l,
|
|
121
|
+
value: ue(a, l, o)
|
|
122
|
+
}), A.push(l)));
|
|
123
|
+
const x = c.getAllCompareFns();
|
|
124
|
+
S.sort(le(o, ce(x)));
|
|
125
|
+
const F = {};
|
|
126
|
+
S.forEach(({ index: l, value: _e }, G) => {
|
|
127
|
+
F[A[G]] = l;
|
|
130
128
|
});
|
|
131
|
-
const
|
|
132
|
-
id:
|
|
129
|
+
const V = {
|
|
130
|
+
id: Q.id,
|
|
133
131
|
params: {
|
|
134
|
-
unitId,
|
|
135
|
-
subUnitId,
|
|
136
|
-
range,
|
|
137
|
-
order
|
|
132
|
+
unitId: s,
|
|
133
|
+
subUnitId: i,
|
|
134
|
+
range: r,
|
|
135
|
+
order: F
|
|
138
136
|
}
|
|
139
|
-
},
|
|
140
|
-
return
|
|
141
|
-
}
|
|
137
|
+
}, L = e.get(I);
|
|
138
|
+
return K([V], L).result;
|
|
139
|
+
}
|
|
142
140
|
};
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
}),
|
|
141
|
+
function ue(e, t, r) {
|
|
142
|
+
const o = [];
|
|
143
|
+
return r.forEach(({ colIndex: n }) => {
|
|
144
|
+
o.push(e.getCellRaw(t, n));
|
|
145
|
+
}), o;
|
|
148
146
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return res;
|
|
147
|
+
function ce(e) {
|
|
148
|
+
return (t, r, o) => {
|
|
149
|
+
for (let n = 0; n < e.length; n++) {
|
|
150
|
+
const s = e[n](t, r, o);
|
|
151
|
+
if (s != null)
|
|
152
|
+
return s;
|
|
156
153
|
}
|
|
157
154
|
return 0;
|
|
158
155
|
};
|
|
159
156
|
}
|
|
160
|
-
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return ret;
|
|
157
|
+
function le(e, t) {
|
|
158
|
+
return function(r, o) {
|
|
159
|
+
let n = null;
|
|
160
|
+
for (let s = 0; s < e.length; s++) {
|
|
161
|
+
const i = r.value[s], c = o.value[s];
|
|
162
|
+
if (n = t(e[s].type, i, c), n !== 0 && n !== null && n !== void 0)
|
|
163
|
+
return n;
|
|
168
164
|
}
|
|
169
165
|
return 0;
|
|
170
166
|
};
|
|
171
167
|
}
|
|
172
|
-
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
super(), this._commandService = _commandService, this._sortService = _sortService, this._initCommands(), this._registerCompareFns();
|
|
168
|
+
var ae = Object.defineProperty, fe = Object.getOwnPropertyDescriptor, me = (e, t, r, o) => {
|
|
169
|
+
for (var n = o > 1 ? void 0 : o ? fe(t, r) : t, s = e.length - 1, i; s >= 0; s--)
|
|
170
|
+
(i = e[s]) && (n = (o ? i(t, r, n) : i(n)) || n);
|
|
171
|
+
return o && n && ae(t, r, n), n;
|
|
172
|
+
}, D = (e, t) => (r, o) => t(r, o, e);
|
|
173
|
+
let _ = class extends y {
|
|
174
|
+
constructor(e, t) {
|
|
175
|
+
super(), this._commandService = e, this._sortService = t, this._initCommands(), this._registerCompareFns();
|
|
181
176
|
}
|
|
182
177
|
_initCommands() {
|
|
183
178
|
[
|
|
184
|
-
|
|
185
|
-
].forEach((
|
|
179
|
+
T
|
|
180
|
+
].forEach((e) => this.disposeWithMe(this._commandService.registerCommand(e)));
|
|
186
181
|
}
|
|
187
182
|
_registerCompareFns() {
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
183
|
+
const e = (t, r, o) => {
|
|
184
|
+
const n = this._getCommonValue(r), s = this._getCommonValue(o), i = [
|
|
185
|
+
ee,
|
|
186
|
+
re,
|
|
187
|
+
te
|
|
193
188
|
];
|
|
194
|
-
for (let
|
|
195
|
-
const
|
|
196
|
-
if (
|
|
197
|
-
return
|
|
189
|
+
for (let c = 0; c < i.length; c++) {
|
|
190
|
+
const u = i[c](n, s, t);
|
|
191
|
+
if (u !== null)
|
|
192
|
+
return u;
|
|
198
193
|
}
|
|
199
194
|
return null;
|
|
200
|
-
}
|
|
201
|
-
this._sortService.registerCompareFn(
|
|
195
|
+
};
|
|
196
|
+
this._sortService.registerCompareFn(e);
|
|
202
197
|
}
|
|
203
|
-
_getCommonValue(
|
|
204
|
-
var
|
|
205
|
-
if (
|
|
198
|
+
_getCommonValue(e) {
|
|
199
|
+
var r, o;
|
|
200
|
+
if (M(e))
|
|
206
201
|
return null;
|
|
207
|
-
const
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
],
|
|
215
|
-
var
|
|
216
|
-
for (var
|
|
217
|
-
(
|
|
218
|
-
return
|
|
219
|
-
},
|
|
220
|
-
const
|
|
221
|
-
var
|
|
222
|
-
let
|
|
223
|
-
constructor(
|
|
224
|
-
super(), this._config =
|
|
225
|
-
const { ...
|
|
226
|
-
this._configService.setConfig(
|
|
202
|
+
const t = (o = (r = e == null ? void 0 : e.p) == null ? void 0 : r.body) == null ? void 0 : o.dataStream;
|
|
203
|
+
return t || ((e == null ? void 0 : e.t) === v.NUMBER ? Number.parseFloat(`${e.v}`) : (e == null ? void 0 : e.t) === v.STRING ? typeof e.v == "number" ? e.v : `${e.v}` : (e == null ? void 0 : e.t) === v.BOOLEAN ? `${e.v}` : (e == null ? void 0 : e.t) === v.FORCE_STRING ? Number.parseFloat(`${e.v}`) : `${e == null ? void 0 : e.v}`);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
_ = me([
|
|
207
|
+
D(0, I),
|
|
208
|
+
D(1, w(g))
|
|
209
|
+
], _);
|
|
210
|
+
var ge = Object.defineProperty, de = Object.getOwnPropertyDescriptor, he = (e, t, r, o) => {
|
|
211
|
+
for (var n = o > 1 ? void 0 : o ? de(t, r) : t, s = e.length - 1, i; s >= 0; s--)
|
|
212
|
+
(i = e[s]) && (n = (o ? i(t, r, n) : i(n)) || n);
|
|
213
|
+
return o && n && ge(t, r, n), n;
|
|
214
|
+
}, P = (e, t) => (r, o) => t(r, o, e);
|
|
215
|
+
const ve = "SHEET_SORT_PLUGIN";
|
|
216
|
+
var C;
|
|
217
|
+
let O = (C = class extends W {
|
|
218
|
+
constructor(e = k, t, r) {
|
|
219
|
+
super(), this._config = e, this._injector = t, this._configService = r;
|
|
220
|
+
const { ...o } = this._config;
|
|
221
|
+
this._configService.setConfig(Z, o);
|
|
227
222
|
}
|
|
228
223
|
onStarting() {
|
|
229
224
|
[
|
|
230
|
-
[
|
|
231
|
-
[
|
|
232
|
-
].forEach((
|
|
225
|
+
[_],
|
|
226
|
+
[g]
|
|
227
|
+
].forEach((e) => this._injector.add(e));
|
|
233
228
|
}
|
|
234
229
|
onReady() {
|
|
235
|
-
this._injector.get(
|
|
230
|
+
this._injector.get(_);
|
|
236
231
|
}
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
],
|
|
232
|
+
}, h(C, "type", Y.UNIVER_SHEET), h(C, "pluginName", ve), C);
|
|
233
|
+
O = he([
|
|
234
|
+
P(1, w(z)),
|
|
235
|
+
P(2, J)
|
|
236
|
+
], O);
|
|
242
237
|
export {
|
|
243
|
-
SheetsSortService,
|
|
244
|
-
SortRangeCommand,
|
|
245
|
-
SortType,
|
|
246
|
-
UniverSheetsSortPlugin
|
|
238
|
+
g as SheetsSortService,
|
|
239
|
+
T as SortRangeCommand,
|
|
240
|
+
f as SortType,
|
|
241
|
+
O as UniverSheetsSortPlugin
|
|
247
242
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-sort",
|
|
3
|
-
"version": "0.4.2-nightly.
|
|
3
|
+
"version": "0.4.2-nightly.202411081606",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library for sorting data in Univer Sheet",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -21,17 +21,20 @@
|
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
23
|
"import": "./lib/es/index.js",
|
|
24
|
+
"require": "./lib/cjs/index.js",
|
|
24
25
|
"types": "./lib/types/index.d.ts"
|
|
25
26
|
},
|
|
26
27
|
"./*": {
|
|
27
28
|
"import": "./lib/es/*",
|
|
29
|
+
"require": "./lib/cjs/*",
|
|
28
30
|
"types": "./lib/types/index.d.ts"
|
|
29
31
|
},
|
|
30
|
-
"./lib/*": "./lib/*",
|
|
31
32
|
"./locale/*": {
|
|
32
|
-
"import": "./lib/locale/*.js",
|
|
33
|
+
"import": "./lib/es/locale/*.js",
|
|
34
|
+
"require": "./lib/cjs/locale/*.js",
|
|
33
35
|
"types": "./lib/types/locale/*.d.ts"
|
|
34
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"./lib/*": "./lib/*"
|
|
35
38
|
},
|
|
36
39
|
"main": "./lib/es/index.js",
|
|
37
40
|
"types": "./lib/types/index.d.ts",
|
|
@@ -46,9 +49,9 @@
|
|
|
46
49
|
],
|
|
47
50
|
"dependencies": {
|
|
48
51
|
"@vitejs/plugin-react": "4.3.3",
|
|
49
|
-
"@univerjs/core": "0.4.2-nightly.
|
|
50
|
-
"@univerjs/
|
|
51
|
-
"@univerjs/
|
|
52
|
+
"@univerjs/core": "0.4.2-nightly.202411081606",
|
|
53
|
+
"@univerjs/engine-formula": "0.4.2-nightly.202411081606",
|
|
54
|
+
"@univerjs/sheets": "0.4.2-nightly.202411081606"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"typescript": "^5.6.3",
|
|
@@ -56,27 +59,30 @@
|
|
|
56
59
|
"vitest": "^2.1.4",
|
|
57
60
|
"@univerjs-infra/shared": "0.4.2"
|
|
58
61
|
},
|
|
59
|
-
"
|
|
62
|
+
"space": {
|
|
60
63
|
".": {
|
|
61
64
|
"import": "./lib/es/index.js",
|
|
65
|
+
"require": "./lib/cjs/index.js",
|
|
62
66
|
"types": "./lib/types/index.d.ts"
|
|
63
67
|
},
|
|
64
68
|
"./*": {
|
|
65
69
|
"import": "./lib/es/*",
|
|
70
|
+
"require": "./lib/cjs/*",
|
|
66
71
|
"types": "./lib/types/index.d.ts"
|
|
67
72
|
},
|
|
68
|
-
"./lib/*": "./lib/*",
|
|
69
73
|
"./locale/*": {
|
|
70
|
-
"import": "./lib/locale/*.js",
|
|
74
|
+
"import": "./lib/es/locale/*.js",
|
|
75
|
+
"require": "./lib/cjs/locale/*.js",
|
|
71
76
|
"types": "./lib/types/locale/*.d.ts"
|
|
72
|
-
}
|
|
77
|
+
},
|
|
78
|
+
"./lib/*": "./lib/*"
|
|
73
79
|
},
|
|
74
80
|
"scripts": {
|
|
75
81
|
"test": "vitest run",
|
|
76
82
|
"test:watch": "vitest",
|
|
77
83
|
"coverage": "vitest run --coverage",
|
|
78
84
|
"lint:types": "tsc --noEmit",
|
|
79
|
-
"build": "
|
|
85
|
+
"build": "tsx build.ts"
|
|
80
86
|
},
|
|
81
87
|
"module": "./lib/es/index.js"
|
|
82
88
|
}
|