@univerjs/sheets-sort 0.20.1 → 0.21.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/facade.js +125 -1
- package/lib/cjs/index.js +406 -1
- package/lib/cjs/locale/ca-ES.js +18 -1
- package/lib/cjs/locale/en-US.js +33 -1
- package/lib/cjs/locale/es-ES.js +18 -1
- package/lib/cjs/locale/fa-IR.js +18 -1
- package/lib/cjs/locale/fr-FR.js +18 -1
- package/lib/cjs/locale/ja-JP.js +18 -1
- package/lib/cjs/locale/ko-KR.js +18 -1
- package/lib/cjs/locale/ru-RU.js +18 -1
- package/lib/cjs/locale/sk-SK.js +18 -1
- package/lib/cjs/locale/vi-VN.js +18 -1
- package/lib/cjs/locale/zh-CN.js +18 -1
- package/lib/cjs/locale/zh-TW.js +18 -1
- package/lib/es/facade.js +126 -1
- package/lib/es/index.js +392 -1
- package/lib/es/locale/ca-ES.js +17 -1
- package/lib/es/locale/en-US.js +32 -1
- package/lib/es/locale/es-ES.js +17 -1
- package/lib/es/locale/fa-IR.js +17 -1
- package/lib/es/locale/fr-FR.js +17 -1
- package/lib/es/locale/ja-JP.js +17 -1
- package/lib/es/locale/ko-KR.js +17 -1
- package/lib/es/locale/ru-RU.js +17 -1
- package/lib/es/locale/sk-SK.js +17 -1
- package/lib/es/locale/vi-VN.js +17 -1
- package/lib/es/locale/zh-CN.js +17 -1
- package/lib/es/locale/zh-TW.js +17 -1
- package/lib/facade.js +126 -1
- package/lib/index.js +392 -1
- package/lib/locale/ca-ES.js +17 -1
- package/lib/locale/en-US.js +32 -1
- package/lib/locale/es-ES.js +17 -1
- package/lib/locale/fa-IR.js +17 -1
- package/lib/locale/fr-FR.js +17 -1
- package/lib/locale/ja-JP.js +17 -1
- package/lib/locale/ko-KR.js +17 -1
- package/lib/locale/ru-RU.js +17 -1
- package/lib/locale/sk-SK.js +17 -1
- package/lib/locale/vi-VN.js +17 -1
- package/lib/locale/zh-CN.js +17 -1
- package/lib/locale/zh-TW.js +17 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
package/lib/es/locale/ca-ES.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/ca-ES.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Ordena",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "ordre ascendent",
|
|
6
|
+
"sort-desc": "ordre descendent",
|
|
7
|
+
"sort-custom": "ordre personalitzat"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "ordre ascendent",
|
|
11
|
+
"sort-desc": "ordre descendent",
|
|
12
|
+
"sort-custom": "ordre personalitzat"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/en-US.js
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/en-US.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
const locale = { sheetsSort: {
|
|
18
|
+
title: "Sort",
|
|
19
|
+
toolbar: {
|
|
20
|
+
"sort-asc": "ascending order",
|
|
21
|
+
"sort-desc": "descending order",
|
|
22
|
+
"sort-custom": "custom order"
|
|
23
|
+
},
|
|
24
|
+
"context-menu": {
|
|
25
|
+
"sort-asc": "ascending order",
|
|
26
|
+
"sort-desc": "descending order",
|
|
27
|
+
"sort-custom": "custom order"
|
|
28
|
+
}
|
|
29
|
+
} };
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { locale as default };
|
package/lib/es/locale/es-ES.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/es-ES.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Ordenar",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "orden ascendente",
|
|
6
|
+
"sort-desc": "orden descendente",
|
|
7
|
+
"sort-custom": "orden personalizado"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "orden ascendente",
|
|
11
|
+
"sort-desc": "orden descendente",
|
|
12
|
+
"sort-custom": "orden personalizado"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/fa-IR.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/fa-IR.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "مرتبسازی",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "ترتیب صعودی",
|
|
6
|
+
"sort-desc": "ترتیب نزولی",
|
|
7
|
+
"sort-custom": "ترتیب سفارشی"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "ترتیب صعودی",
|
|
11
|
+
"sort-desc": "ترتیب نزولی",
|
|
12
|
+
"sort-custom": "ترتیب سفارشی"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/fr-FR.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/fr-FR.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Trier",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "ordre croissant",
|
|
6
|
+
"sort-desc": "ordre décroissant",
|
|
7
|
+
"sort-custom": "ordre personnalisé"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "ordre croissant",
|
|
11
|
+
"sort-desc": "ordre décroissant",
|
|
12
|
+
"sort-custom": "ordre personnalisé"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/ja-JP.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/ja-JP.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "並べ替え",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "昇順",
|
|
6
|
+
"sort-desc": "降順",
|
|
7
|
+
"sort-custom": "カスタム順序"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "昇順",
|
|
11
|
+
"sort-desc": "降順",
|
|
12
|
+
"sort-custom": "カスタム順序"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/ko-KR.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/ko-KR.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "정렬",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "오름차순",
|
|
6
|
+
"sort-desc": "내림차순",
|
|
7
|
+
"sort-custom": "사용자 정의 순서"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "오름차순",
|
|
11
|
+
"sort-desc": "내림차순",
|
|
12
|
+
"sort-custom": "사용자 정의 순서"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/ru-RU.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/ru-RU.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Sort",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "по возрастанию",
|
|
6
|
+
"sort-desc": "по убыванию",
|
|
7
|
+
"sort-custom": "пользовательский выбор"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "по возрастанию",
|
|
11
|
+
"sort-desc": "по убыванию",
|
|
12
|
+
"sort-custom": "пользовательский выбор"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/sk-SK.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/sk-SK.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Triedenie",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "vzostupné poradie",
|
|
6
|
+
"sort-desc": "zostupné poradie",
|
|
7
|
+
"sort-custom": "vlastné poradie"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "vzostupné poradie",
|
|
11
|
+
"sort-desc": "zostupné poradie",
|
|
12
|
+
"sort-custom": "vlastné poradie"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/vi-VN.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/vi-VN.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Sort",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "ascending order",
|
|
6
|
+
"sort-desc": "descending order",
|
|
7
|
+
"sort-custom": "custom order"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "ascending order",
|
|
11
|
+
"sort-desc": "descending order",
|
|
12
|
+
"sort-custom": "custom order"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/zh-CN.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/zh-CN.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "排序",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "升序",
|
|
6
|
+
"sort-desc": "降序",
|
|
7
|
+
"sort-custom": "自定义排序"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "升序",
|
|
11
|
+
"sort-desc": "降序",
|
|
12
|
+
"sort-custom": "自定义排序"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/es/locale/zh-TW.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/locale/zh-TW.ts
|
|
2
|
+
const locale = { sheetsSort: {
|
|
3
|
+
title: "Sắp xếp",
|
|
4
|
+
toolbar: {
|
|
5
|
+
"sort-asc": "Tăng dần",
|
|
6
|
+
"sort-desc": "Giảm dần",
|
|
7
|
+
"sort-custom": "Sắp xếp tùy chỉnh"
|
|
8
|
+
},
|
|
9
|
+
"context-menu": {
|
|
10
|
+
"sort-asc": "Tăng dần",
|
|
11
|
+
"sort-desc": "Giảm dần",
|
|
12
|
+
"sort-custom": "Sắp xếp tùy chỉnh"
|
|
13
|
+
}
|
|
14
|
+
} };
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { locale as default };
|
package/lib/facade.js
CHANGED
|
@@ -1 +1,126 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ICommandService, RANGE_TYPE } from "@univerjs/core";
|
|
2
|
+
import { FEventName, FUniver } from "@univerjs/core/facade";
|
|
3
|
+
import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
|
|
4
|
+
import { FRange, FWorksheet } from "@univerjs/sheets/facade";
|
|
5
|
+
|
|
6
|
+
//#region src/facade/f-univer.ts
|
|
7
|
+
var FUniverSheetsSortMixin = class extends FUniver {
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
_initialize(injector) {
|
|
12
|
+
const commandService = injector.get(ICommandService);
|
|
13
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetBeforeRangeSort, () => commandService.beforeCommandExecuted((commandInfo) => {
|
|
14
|
+
if (commandInfo.id !== SortRangeCommand.id) return;
|
|
15
|
+
this._beforeRangeSort(commandInfo);
|
|
16
|
+
})));
|
|
17
|
+
this.disposeWithMe(this.registerEventHandler(this.Event.SheetRangeSorted, () => commandService.onCommandExecuted((commandInfo) => {
|
|
18
|
+
if (commandInfo.id !== SortRangeCommand.id) return;
|
|
19
|
+
this._onRangeSorted(commandInfo);
|
|
20
|
+
})));
|
|
21
|
+
}
|
|
22
|
+
_beforeRangeSort(commandInfo) {
|
|
23
|
+
const params = commandInfo.params;
|
|
24
|
+
const fWorkbook = this.getUniverSheet(params.unitId);
|
|
25
|
+
const fWorksheet = fWorkbook.getSheetBySheetId(params.subUnitId);
|
|
26
|
+
const { startColumn, endColumn, startRow, endRow } = params.range;
|
|
27
|
+
const eventParams = {
|
|
28
|
+
workbook: fWorkbook,
|
|
29
|
+
worksheet: fWorksheet,
|
|
30
|
+
range: fWorksheet.getRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1),
|
|
31
|
+
sortColumn: params.orderRules.map((rule) => ({
|
|
32
|
+
column: rule.colIndex - startColumn,
|
|
33
|
+
ascending: rule.type === SortType.ASC
|
|
34
|
+
}))
|
|
35
|
+
};
|
|
36
|
+
this.fireEvent(this.Event.SheetBeforeRangeSort, eventParams);
|
|
37
|
+
if (eventParams.cancel) throw new Error("SortRangeCommand canceled.");
|
|
38
|
+
}
|
|
39
|
+
_onRangeSorted(commandInfo) {
|
|
40
|
+
const params = commandInfo.params;
|
|
41
|
+
const fWorkbook = this.getUniverSheet(params.unitId);
|
|
42
|
+
const fWorksheet = fWorkbook.getSheetBySheetId(params.subUnitId);
|
|
43
|
+
const { startColumn, endColumn, startRow, endRow } = params.range;
|
|
44
|
+
const eventParams = {
|
|
45
|
+
workbook: fWorkbook,
|
|
46
|
+
worksheet: fWorksheet,
|
|
47
|
+
range: fWorksheet.getRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1),
|
|
48
|
+
sortColumn: params.orderRules.map((rule) => ({
|
|
49
|
+
column: rule.colIndex - startColumn,
|
|
50
|
+
ascending: rule.type === SortType.ASC
|
|
51
|
+
}))
|
|
52
|
+
};
|
|
53
|
+
this.fireEvent(this.Event.SheetRangeSorted, eventParams);
|
|
54
|
+
if (eventParams.cancel) throw new Error("SortRangeCommand canceled.");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
FUniver.extend(FUniverSheetsSortMixin);
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/facade/f-range.ts
|
|
61
|
+
var FRangeSheetsSortMixin = class extends FRange {
|
|
62
|
+
sort(column) {
|
|
63
|
+
const columnBase = this._range.startColumn;
|
|
64
|
+
const orderRules = (Array.isArray(column) ? column : [column]).map((c) => {
|
|
65
|
+
if (typeof c === "number") return {
|
|
66
|
+
colIndex: c + columnBase,
|
|
67
|
+
type: SortType.ASC
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
colIndex: c.column + columnBase,
|
|
71
|
+
type: c.ascending ? SortType.ASC : SortType.DESC
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
this._commandService.syncExecuteCommand(SortRangeCommand.id, {
|
|
75
|
+
orderRules,
|
|
76
|
+
range: this._range,
|
|
77
|
+
hasTitle: false,
|
|
78
|
+
unitId: this._workbook.getUnitId(),
|
|
79
|
+
subUnitId: this._worksheet.getSheetId()
|
|
80
|
+
});
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
FRange.extend(FRangeSheetsSortMixin);
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/facade/f-worksheet.ts
|
|
88
|
+
var FWorksheetSortMixin = class extends FWorksheet {
|
|
89
|
+
sort(colIndex, asc = true) {
|
|
90
|
+
const orderRules = [{
|
|
91
|
+
colIndex,
|
|
92
|
+
type: asc ? SortType.ASC : SortType.DESC
|
|
93
|
+
}];
|
|
94
|
+
const range = {
|
|
95
|
+
startRow: 0,
|
|
96
|
+
startColumn: 0,
|
|
97
|
+
endRow: this._worksheet.getRowCount() - 1,
|
|
98
|
+
endColumn: this._worksheet.getColumnCount() - 1,
|
|
99
|
+
rangeType: RANGE_TYPE.ALL
|
|
100
|
+
};
|
|
101
|
+
this._commandService.syncExecuteCommand(SortRangeCommand.id, {
|
|
102
|
+
orderRules,
|
|
103
|
+
range,
|
|
104
|
+
hasTitle: false,
|
|
105
|
+
unitId: this._workbook.getUnitId(),
|
|
106
|
+
subUnitId: this._worksheet.getSheetId()
|
|
107
|
+
});
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
FWorksheet.extend(FWorksheetSortMixin);
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/facade/f-event.ts
|
|
115
|
+
var FSheetsSortEventNameMixin = class {
|
|
116
|
+
get SheetRangeSorted() {
|
|
117
|
+
return "SheetRangeSorted";
|
|
118
|
+
}
|
|
119
|
+
get SheetBeforeRangeSort() {
|
|
120
|
+
return "SheetBeforeRangeSort";
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
FEventName.extend(FSheetsSortEventNameMixin);
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
export { };
|