@ai-table/state 0.0.28 → 0.0.30
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/action/record.d.ts +2 -2
- package/action/record.d.ts.map +1 -1
- package/constants/context-menu-item.d.ts.map +1 -1
- package/esm2022/action/record.mjs +1 -1
- package/esm2022/constants/context-menu-item.mjs +3 -7
- package/esm2022/shared/to-table/array-event.mjs +1 -1
- package/esm2022/types/action.mjs +1 -1
- package/esm2022/types/view.mjs +1 -18
- package/esm2022/utils/build.mjs +3 -3
- package/esm2022/utils/common.mjs +1 -11
- package/esm2022/utils/index.mjs +1 -2
- package/esm2022/utils/record/filter.mjs +2 -4
- package/esm2022/utils/record/sort.mjs +7 -7
- package/fesm2022/ai-table-state.mjs +13 -422
- package/fesm2022/ai-table-state.mjs.map +1 -1
- package/package.json +1 -1
- package/types/action.d.ts +2 -2
- package/types/action.d.ts.map +1 -1
- package/types/view.d.ts +1 -22
- package/types/view.d.ts.map +1 -1
- package/utils/build.d.ts +2 -1
- package/utils/build.d.ts.map +1 -1
- package/utils/common.d.ts +0 -1
- package/utils/common.d.ts.map +1 -1
- package/utils/index.d.ts +0 -1
- package/utils/index.d.ts.map +1 -1
- package/utils/record/filter.d.ts +2 -2
- package/utils/record/filter.d.ts.map +1 -1
- package/utils/record/sort.d.ts +3 -3
- package/utils/record/sort.d.ts.map +1 -1
- package/esm2022/utils/field/model/date.mjs +0 -74
- package/esm2022/utils/field/model/field.mjs +0 -63
- package/esm2022/utils/field/model/index.mjs +0 -24
- package/esm2022/utils/field/model/link.mjs +0 -37
- package/esm2022/utils/field/model/member.mjs +0 -48
- package/esm2022/utils/field/model/number.mjs +0 -46
- package/esm2022/utils/field/model/rate.mjs +0 -40
- package/esm2022/utils/field/model/select.mjs +0 -55
- package/esm2022/utils/field/model/text.mjs +0 -27
- package/utils/field/model/date.d.ts +0 -11
- package/utils/field/model/date.d.ts.map +0 -1
- package/utils/field/model/field.d.ts +0 -12
- package/utils/field/model/field.d.ts.map +0 -1
- package/utils/field/model/index.d.ts +0 -4
- package/utils/field/model/index.d.ts.map +0 -1
- package/utils/field/model/link.d.ts +0 -10
- package/utils/field/model/link.d.ts.map +0 -1
- package/utils/field/model/member.d.ts +0 -8
- package/utils/field/model/member.d.ts.map +0 -1
- package/utils/field/model/number.d.ts +0 -10
- package/utils/field/model/number.d.ts.map +0 -1
- package/utils/field/model/rate.d.ts +0 -10
- package/utils/field/model/rate.d.ts.map +0 -1
- package/utils/field/model/select.d.ts +0 -12
- package/utils/field/model/select.d.ts.map +0 -1
- package/utils/field/model/text.d.ts +0 -10
- package/utils/field/model/text.d.ts.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
import { isArray
|
|
3
|
-
import { AITableQueries,
|
|
4
|
-
import * as _ from 'lodash';
|
|
5
|
-
import ___default, { isEqual } from 'lodash';
|
|
6
|
-
import { fromUnixTime, subDays } from 'date-fns';
|
|
2
|
+
import { isArray } from 'ngx-tethys/util';
|
|
3
|
+
import { AITableQueries, ViewOperationMap, isSystemField, AITableFieldType, isEmpty, getDefaultFieldValue, Direction as Direction$1, idsCreator, idCreator, shortIdCreator, shortIdsCreator, AI_TABLE_GRID_FIELD_SERVICE_MAP, AITable } from '@ai-table/grid';
|
|
7
4
|
import { createDraft, finishDraft } from 'immer';
|
|
5
|
+
import * as _ from 'lodash';
|
|
6
|
+
import ___default from 'lodash';
|
|
8
7
|
|
|
9
8
|
const IS_LOCAL = new WeakSet();
|
|
10
9
|
const IS_REMOTE = new WeakSet();
|
|
@@ -60,23 +59,6 @@ var AITableFilterLogical;
|
|
|
60
59
|
AITableFilterLogical["and"] = "and";
|
|
61
60
|
AITableFilterLogical["or"] = "or";
|
|
62
61
|
})(AITableFilterLogical || (AITableFilterLogical = {}));
|
|
63
|
-
var AITableFilterOperation;
|
|
64
|
-
(function (AITableFilterOperation) {
|
|
65
|
-
AITableFilterOperation["eq"] = "eq";
|
|
66
|
-
AITableFilterOperation["gte"] = "gte";
|
|
67
|
-
AITableFilterOperation["lte"] = "lte";
|
|
68
|
-
AITableFilterOperation["gt"] = "gt";
|
|
69
|
-
AITableFilterOperation["lt"] = "lt";
|
|
70
|
-
AITableFilterOperation["in"] = "in";
|
|
71
|
-
AITableFilterOperation["contain"] = "contain";
|
|
72
|
-
AITableFilterOperation["ne"] = "ne";
|
|
73
|
-
AITableFilterOperation["nin"] = "nin";
|
|
74
|
-
AITableFilterOperation["between"] = "between";
|
|
75
|
-
AITableFilterOperation["besides"] = "besides";
|
|
76
|
-
AITableFilterOperation["empty"] = "empty";
|
|
77
|
-
AITableFilterOperation["exists"] = "exists";
|
|
78
|
-
AITableFilterOperation["notContain"] = "not_contain";
|
|
79
|
-
})(AITableFilterOperation || (AITableFilterOperation = {}));
|
|
80
62
|
|
|
81
63
|
var ActionName;
|
|
82
64
|
(function (ActionName) {
|
|
@@ -706,15 +688,6 @@ function applyActionOps(aiTable, sharedType, actions) {
|
|
|
706
688
|
return sharedType;
|
|
707
689
|
}
|
|
708
690
|
|
|
709
|
-
function isEmpty(value) {
|
|
710
|
-
if (isArray(value)) {
|
|
711
|
-
return isEmpty$1(value);
|
|
712
|
-
}
|
|
713
|
-
if (isObject(value)) {
|
|
714
|
-
return Reflect.ownKeys(value).length === 0;
|
|
715
|
-
}
|
|
716
|
-
return isUndefinedOrNull(value) || value === '';
|
|
717
|
-
}
|
|
718
691
|
function isPathEqual(path, another) {
|
|
719
692
|
return path.length === another.length && path.every((n, i) => n === another[i]);
|
|
720
693
|
}
|
|
@@ -726,396 +699,17 @@ function sortByViewPosition(data, activeView) {
|
|
|
726
699
|
return data;
|
|
727
700
|
}
|
|
728
701
|
|
|
729
|
-
|
|
730
|
-
class Field {
|
|
731
|
-
stringInclude(str, searchStr) {
|
|
732
|
-
return str.toLowerCase().includes(searchStr.trim().toLowerCase());
|
|
733
|
-
}
|
|
734
|
-
isMeetFilter(condition, cellValue) {
|
|
735
|
-
switch (condition.operation) {
|
|
736
|
-
case AITableFilterOperation.empty:
|
|
737
|
-
case AITableFilterOperation.exists: {
|
|
738
|
-
return this.isEmptyOrNot(condition.operation, cellValue);
|
|
739
|
-
}
|
|
740
|
-
default: {
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
isEmptyOrNot(operation, cellValue) {
|
|
746
|
-
switch (operation) {
|
|
747
|
-
case AITableFilterOperation.empty: {
|
|
748
|
-
return isEmpty(cellValue);
|
|
749
|
-
}
|
|
750
|
-
case AITableFilterOperation.exists: {
|
|
751
|
-
return !isEmpty(cellValue);
|
|
752
|
-
}
|
|
753
|
-
default: {
|
|
754
|
-
throw new Error('compare operator type error');
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
eq(cv1, cv2) {
|
|
759
|
-
return isEqual(cv1, cv2);
|
|
760
|
-
}
|
|
761
|
-
compare(cellValue1, cellValue2, field, references) {
|
|
762
|
-
if (this.eq(cellValue1, cellValue2)) {
|
|
763
|
-
return 0;
|
|
764
|
-
}
|
|
765
|
-
if (cellValue1 == null) {
|
|
766
|
-
return -1;
|
|
767
|
-
}
|
|
768
|
-
if (cellValue2 == null) {
|
|
769
|
-
return 1;
|
|
770
|
-
}
|
|
771
|
-
let str1 = this.cellValueToString(cellValue1, field, references);
|
|
772
|
-
let str2 = this.cellValueToString(cellValue2, field, references);
|
|
773
|
-
if (str1 === str2) {
|
|
774
|
-
return 0;
|
|
775
|
-
}
|
|
776
|
-
if (str1 == null) {
|
|
777
|
-
return -1;
|
|
778
|
-
}
|
|
779
|
-
if (str2 == null) {
|
|
780
|
-
return 1;
|
|
781
|
-
}
|
|
782
|
-
str1 = str1.trim();
|
|
783
|
-
str2 = str2.trim();
|
|
784
|
-
// test pinyin sort
|
|
785
|
-
return str1 === str2 ? 0 : zhIntlCollator ? zhIntlCollator.compare(str1, str2) : str1.localeCompare(str2, 'zh-CN') > 0 ? 1 : -1;
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
class TextField extends Field {
|
|
790
|
-
isMeetFilter(condition, cellValue) {
|
|
791
|
-
switch (condition.operation) {
|
|
792
|
-
case AITableFilterOperation.empty:
|
|
793
|
-
return isEmpty(cellValue);
|
|
794
|
-
case AITableFilterOperation.exists:
|
|
795
|
-
return !isEmpty(cellValue);
|
|
796
|
-
case AITableFilterOperation.contain:
|
|
797
|
-
return !isEmpty(cellValue) && this.stringInclude(cellValue, condition.value);
|
|
798
|
-
default:
|
|
799
|
-
return super.isMeetFilter(condition, cellValue);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
static stringInclude(str, searchStr) {
|
|
803
|
-
return str.toLowerCase().includes(searchStr.trim().toLowerCase());
|
|
804
|
-
}
|
|
805
|
-
eq(cv1, cv2) {
|
|
806
|
-
return this.cellValueToString(cv1) === this.cellValueToString(cv2);
|
|
807
|
-
}
|
|
808
|
-
cellValueToString(cellValue) {
|
|
809
|
-
return cellValue;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
class SelectField extends Field {
|
|
814
|
-
isMeetFilter(condition, cellValue) {
|
|
815
|
-
switch (condition.operation) {
|
|
816
|
-
case AITableFilterOperation.empty:
|
|
817
|
-
return isEmpty(cellValue);
|
|
818
|
-
case AITableFilterOperation.exists:
|
|
819
|
-
return !isEmpty(cellValue);
|
|
820
|
-
case AITableFilterOperation.in:
|
|
821
|
-
return Array.isArray(condition.value) && hasIntersect$1(cellValue, condition.value);
|
|
822
|
-
case AITableFilterOperation.nin:
|
|
823
|
-
return Array.isArray(condition.value) && !hasIntersect$1(cellValue, condition.value);
|
|
824
|
-
default:
|
|
825
|
-
return super.isMeetFilter(condition, cellValue);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
cellValueToString(cellValue, field) {
|
|
829
|
-
return this.arrayValueToString(this.cellValueToArray(cellValue, field));
|
|
830
|
-
}
|
|
831
|
-
cellValueToArray(cellValue, field) {
|
|
832
|
-
if (!cellValue) {
|
|
833
|
-
return null;
|
|
834
|
-
}
|
|
835
|
-
const result = [];
|
|
836
|
-
for (let i = 0, l = cellValue.length; i < l; i++) {
|
|
837
|
-
const option = this.findOptionById(field, cellValue[i]);
|
|
838
|
-
if (option) {
|
|
839
|
-
result.push(option.text);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
return result;
|
|
843
|
-
}
|
|
844
|
-
findOptionById(field, id) {
|
|
845
|
-
return field.settings.options.find(option => option._id === id) || null;
|
|
846
|
-
}
|
|
847
|
-
arrayValueToString(cellValues) {
|
|
848
|
-
return cellValues && cellValues.length ? cellValues.join(', ') : null;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
function hasIntersect$1(array1, array2) {
|
|
852
|
-
if (!Array.isArray(array1) || !Array.isArray(array2)) {
|
|
853
|
-
return false;
|
|
854
|
-
}
|
|
855
|
-
const set1 = new Set(array1);
|
|
856
|
-
const set2 = new Set(array2);
|
|
857
|
-
for (const ele of set1) {
|
|
858
|
-
if (set2.has(ele)) {
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
class DateField extends Field {
|
|
866
|
-
isMeetFilter(condition, cellValue) {
|
|
867
|
-
const [left, right] = this.getTimeRange(condition.value);
|
|
868
|
-
switch (condition.operation) {
|
|
869
|
-
case AITableFilterOperation.empty:
|
|
870
|
-
return isEmpty(cellValue.timestamp) || cellValue.timestamp === 0;
|
|
871
|
-
case AITableFilterOperation.exists:
|
|
872
|
-
return !isEmpty(cellValue.timestamp) && cellValue.timestamp !== 0;
|
|
873
|
-
case AITableFilterOperation.eq:
|
|
874
|
-
return left <= cellValue.timestamp && cellValue.timestamp < right;
|
|
875
|
-
case AITableFilterOperation.gt:
|
|
876
|
-
return cellValue.timestamp > right;
|
|
877
|
-
case AITableFilterOperation.lt:
|
|
878
|
-
return cellValue.timestamp < left;
|
|
879
|
-
case AITableFilterOperation.between:
|
|
880
|
-
return left <= cellValue.timestamp && cellValue.timestamp < right;
|
|
881
|
-
default:
|
|
882
|
-
return super.isMeetFilter(condition, cellValue);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
getTimeRange(value) {
|
|
886
|
-
switch (value) {
|
|
887
|
-
case 'today':
|
|
888
|
-
return [new TinyDate(new Date()).startOfDay().getUnixTime(), new TinyDate(new Date()).endOfDay().getUnixTime()];
|
|
889
|
-
case 'current_week':
|
|
890
|
-
return [
|
|
891
|
-
new TinyDate().startOfWeek({ weekStartsOn: 1 }).getUnixTime(),
|
|
892
|
-
new TinyDate().endOfWeek({ weekStartsOn: 1 }).getUnixTime()
|
|
893
|
-
];
|
|
894
|
-
case 'yesterday':
|
|
895
|
-
return [
|
|
896
|
-
new TinyDate(subDays(new Date(), 1)).startOfDay().getUnixTime(),
|
|
897
|
-
new TinyDate(subDays(new Date(), 1)).endOfDay().getUnixTime()
|
|
898
|
-
];
|
|
899
|
-
case 'current_month':
|
|
900
|
-
return [new TinyDate().startOfMonth().getUnixTime(), new TinyDate().endOfMonth().getUnixTime()];
|
|
901
|
-
default:
|
|
902
|
-
if (isArray(value)) {
|
|
903
|
-
return [
|
|
904
|
-
new TinyDate(fromUnixTime(value[0])).startOfDay().getUnixTime(),
|
|
905
|
-
new TinyDate(fromUnixTime(value[1])).endOfDay().getUnixTime()
|
|
906
|
-
];
|
|
907
|
-
}
|
|
908
|
-
return [
|
|
909
|
-
new TinyDate(fromUnixTime(value)).startOfDay().getUnixTime(),
|
|
910
|
-
new TinyDate(fromUnixTime(value)).endOfDay().getUnixTime()
|
|
911
|
-
];
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
cellValueToString(_cellValue) {
|
|
915
|
-
return null;
|
|
916
|
-
}
|
|
917
|
-
static _compare(cellValue1, cellValue2) {
|
|
918
|
-
if (isEmpty(cellValue1?.timestamp) && isEmpty(cellValue2?.timestamp)) {
|
|
919
|
-
return 0;
|
|
920
|
-
}
|
|
921
|
-
if (isEmpty(cellValue1?.timestamp)) {
|
|
922
|
-
return -1;
|
|
923
|
-
}
|
|
924
|
-
if (isEmpty(cellValue2?.timestamp)) {
|
|
925
|
-
return 1;
|
|
926
|
-
}
|
|
927
|
-
return cellValue1.timestamp === cellValue2.timestamp ? 0 : cellValue1.timestamp > cellValue2.timestamp ? 1 : -1;
|
|
928
|
-
}
|
|
929
|
-
compare(cellValue1, cellValue2) {
|
|
930
|
-
return DateField._compare(cellValue1, cellValue2);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
class NumberField extends Field {
|
|
935
|
-
isMeetFilter(condition, cellValue) {
|
|
936
|
-
switch (condition.operation) {
|
|
937
|
-
case AITableFilterOperation.empty:
|
|
938
|
-
return isEmpty(cellValue);
|
|
939
|
-
case AITableFilterOperation.exists:
|
|
940
|
-
return !isEmpty(cellValue);
|
|
941
|
-
case AITableFilterOperation.eq:
|
|
942
|
-
return !Number.isNaN(condition.value) && cellValue != null && cellValue !== '' && condition.value === cellValue;
|
|
943
|
-
case AITableFilterOperation.gte:
|
|
944
|
-
return cellValue != null && cellValue !== '' && cellValue >= condition.value;
|
|
945
|
-
case AITableFilterOperation.lte:
|
|
946
|
-
return cellValue != null && cellValue !== '' && cellValue <= condition.value;
|
|
947
|
-
case AITableFilterOperation.gt:
|
|
948
|
-
return cellValue != null && cellValue !== '' && cellValue > condition.value;
|
|
949
|
-
case AITableFilterOperation.lt:
|
|
950
|
-
return cellValue != null && cellValue !== '' && cellValue < condition.value;
|
|
951
|
-
case AITableFilterOperation.ne:
|
|
952
|
-
return cellValue == null || cellValue == '' || Number.isNaN(condition.value) || cellValue !== condition.value;
|
|
953
|
-
default:
|
|
954
|
-
return super.isMeetFilter(condition, cellValue);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
cellValueToString(_cellValue) {
|
|
958
|
-
return null;
|
|
959
|
-
}
|
|
960
|
-
static _compare(cellValue1, cellValue2) {
|
|
961
|
-
if (isEmpty(cellValue1) && isEmpty(cellValue2)) {
|
|
962
|
-
return 0;
|
|
963
|
-
}
|
|
964
|
-
if (isEmpty(cellValue1)) {
|
|
965
|
-
return -1;
|
|
966
|
-
}
|
|
967
|
-
if (isEmpty(cellValue2)) {
|
|
968
|
-
return 1;
|
|
969
|
-
}
|
|
970
|
-
return cellValue1 === cellValue2 ? 0 : cellValue1 > cellValue2 ? 1 : -1;
|
|
971
|
-
}
|
|
972
|
-
compare(cellValue1, cellValue2) {
|
|
973
|
-
return NumberField._compare(cellValue1, cellValue2);
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
class RateField extends Field {
|
|
978
|
-
isMeetFilter(condition, cellValue) {
|
|
979
|
-
switch (condition.operation) {
|
|
980
|
-
case AITableFilterOperation.empty:
|
|
981
|
-
return isEmpty(cellValue);
|
|
982
|
-
case AITableFilterOperation.exists:
|
|
983
|
-
return !isEmpty(cellValue);
|
|
984
|
-
case AITableFilterOperation.in:
|
|
985
|
-
const isContain = condition.value.some((item) => String(item) === String(cellValue));
|
|
986
|
-
return !isEmpty(cellValue) && isContain;
|
|
987
|
-
case AITableFilterOperation.nin:
|
|
988
|
-
const noContain = condition.value.every((item) => String(item) !== String(cellValue));
|
|
989
|
-
return isEmpty(cellValue) || noContain;
|
|
990
|
-
default:
|
|
991
|
-
return super.isMeetFilter(condition, cellValue);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
cellValueToString(_cellValue) {
|
|
995
|
-
return null;
|
|
996
|
-
}
|
|
997
|
-
static _compare(cellValue1, cellValue2) {
|
|
998
|
-
if (isEmpty(cellValue1) && isEmpty(cellValue2)) {
|
|
999
|
-
return 0;
|
|
1000
|
-
}
|
|
1001
|
-
if (isEmpty(cellValue1)) {
|
|
1002
|
-
return -1;
|
|
1003
|
-
}
|
|
1004
|
-
if (isEmpty(cellValue2)) {
|
|
1005
|
-
return 1;
|
|
1006
|
-
}
|
|
1007
|
-
return cellValue1 === cellValue2 ? 0 : cellValue1 > cellValue2 ? 1 : -1;
|
|
1008
|
-
}
|
|
1009
|
-
compare(cellValue1, cellValue2) {
|
|
1010
|
-
return RateField._compare(cellValue1, cellValue2);
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
class LinkField extends Field {
|
|
1015
|
-
isMeetFilter(condition, cellValue) {
|
|
1016
|
-
const cellTextValue = this.cellValueToString(cellValue);
|
|
1017
|
-
switch (condition.operation) {
|
|
1018
|
-
case AITableFilterOperation.empty:
|
|
1019
|
-
return isEmpty(cellTextValue);
|
|
1020
|
-
case AITableFilterOperation.exists:
|
|
1021
|
-
return !isEmpty(cellTextValue);
|
|
1022
|
-
case AITableFilterOperation.contain:
|
|
1023
|
-
return !isEmpty(cellTextValue) && this.stringInclude(cellTextValue, condition.value);
|
|
1024
|
-
default:
|
|
1025
|
-
return super.isMeetFilter(condition, cellTextValue);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
eq(cv1, cv2) {
|
|
1029
|
-
return this.cellValueToString(cv1) === this.cellValueToString(cv2);
|
|
1030
|
-
}
|
|
1031
|
-
compare(cellValue1, cellValue2, field) {
|
|
1032
|
-
const cellTextValue1 = this.cellValueToString(cellValue1);
|
|
1033
|
-
const cellTextValue2 = this.cellValueToString(cellValue2);
|
|
1034
|
-
return super.compare(cellTextValue1, cellTextValue2, field);
|
|
1035
|
-
}
|
|
1036
|
-
cellValueToString(cellValue) {
|
|
1037
|
-
if (isString(cellValue)) {
|
|
1038
|
-
return cellValue;
|
|
1039
|
-
}
|
|
1040
|
-
if (isObject(cellValue)) {
|
|
1041
|
-
return cellValue.text;
|
|
1042
|
-
}
|
|
1043
|
-
return '';
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
class MemberField extends Field {
|
|
1048
|
-
isMeetFilter(condition, cellValue) {
|
|
1049
|
-
switch (condition.operation) {
|
|
1050
|
-
case AITableFilterOperation.empty:
|
|
1051
|
-
return isEmpty(cellValue);
|
|
1052
|
-
case AITableFilterOperation.exists:
|
|
1053
|
-
return !isEmpty(cellValue);
|
|
1054
|
-
case AITableFilterOperation.in:
|
|
1055
|
-
return Array.isArray(condition.value) && hasIntersect(cellValue, condition.value);
|
|
1056
|
-
case AITableFilterOperation.nin:
|
|
1057
|
-
return Array.isArray(condition.value) && !hasIntersect(cellValue, condition.value);
|
|
1058
|
-
default:
|
|
1059
|
-
return super.isMeetFilter(condition, cellValue);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
cellValueToString(cellValue, field, references) {
|
|
1063
|
-
let names = [];
|
|
1064
|
-
if (cellValue?.length && references) {
|
|
1065
|
-
for (let index = 0; index < cellValue.length; index++) {
|
|
1066
|
-
const userInfo = references?.members[cellValue[index]];
|
|
1067
|
-
if (!userInfo) {
|
|
1068
|
-
continue;
|
|
1069
|
-
}
|
|
1070
|
-
if (userInfo.display_name_pinyin) {
|
|
1071
|
-
names.push(userInfo.display_name_pinyin);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return names && names.length ? names.join(', ') : null;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
function hasIntersect(array1, array2) {
|
|
1079
|
-
if (!Array.isArray(array1) || !Array.isArray(array2)) {
|
|
1080
|
-
return false;
|
|
1081
|
-
}
|
|
1082
|
-
const set1 = new Set(array1);
|
|
1083
|
-
const set2 = new Set(array2);
|
|
1084
|
-
for (const ele of set1) {
|
|
1085
|
-
if (set2.has(ele)) {
|
|
1086
|
-
return true;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
return false;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
const ViewOperationMap = {
|
|
1093
|
-
[AITableFieldType.text]: new TextField(),
|
|
1094
|
-
[AITableFieldType.richText]: new TextField(),
|
|
1095
|
-
[AITableFieldType.select]: new SelectField(),
|
|
1096
|
-
[AITableFieldType.date]: new DateField(),
|
|
1097
|
-
[AITableFieldType.createdAt]: new DateField(),
|
|
1098
|
-
[AITableFieldType.updatedAt]: new DateField(),
|
|
1099
|
-
[AITableFieldType.number]: new NumberField(),
|
|
1100
|
-
[AITableFieldType.rate]: new RateField(),
|
|
1101
|
-
[AITableFieldType.link]: new LinkField(),
|
|
1102
|
-
[AITableFieldType.member]: new MemberField(),
|
|
1103
|
-
[AITableFieldType.progress]: new NumberField(),
|
|
1104
|
-
[AITableFieldType.createdBy]: new MemberField(),
|
|
1105
|
-
[AITableFieldType.updatedBy]: new MemberField()
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
function getSortRecords(aiTable, records, activeView) {
|
|
702
|
+
function getSortRecords(aiTable, records, activeView, sortKeysMap) {
|
|
1109
703
|
if (!activeView?.settings || !activeView.settings.sorts?.length) {
|
|
1110
704
|
return records;
|
|
1111
705
|
}
|
|
1112
706
|
const { is_keep_sort, sorts } = activeView.settings;
|
|
1113
707
|
if (is_keep_sort && sorts?.length) {
|
|
1114
|
-
return sortRecordsBySortInfo(aiTable, records, activeView);
|
|
708
|
+
return sortRecordsBySortInfo(aiTable, records, activeView, sortKeysMap);
|
|
1115
709
|
}
|
|
1116
710
|
return sortByViewPosition(records, activeView);
|
|
1117
711
|
}
|
|
1118
|
-
function sortRecordsBySortInfo(aiTable, records, activeView) {
|
|
712
|
+
function sortRecordsBySortInfo(aiTable, records, activeView, sortKeysMap) {
|
|
1119
713
|
const shallowRows = [...records];
|
|
1120
714
|
if (activeView.settings?.sorts?.length) {
|
|
1121
715
|
shallowRows.sort((prev, current) => {
|
|
@@ -1125,10 +719,11 @@ function sortRecordsBySortInfo(aiTable, records, activeView) {
|
|
|
1125
719
|
return acc;
|
|
1126
720
|
}
|
|
1127
721
|
const fieldMethod = ViewOperationMap[field.type];
|
|
722
|
+
const sortKey = sortKeysMap?.[field.type];
|
|
1128
723
|
const cellValue1 = AITableQueries.getFieldValue(aiTable, [prev._id, field._id]);
|
|
1129
724
|
const cellValue2 = AITableQueries.getFieldValue(aiTable, [current._id, field._id]);
|
|
1130
725
|
const references = aiTable.references();
|
|
1131
|
-
const res = fieldMethod.compare(cellValue1, cellValue2, field, references);
|
|
726
|
+
const res = fieldMethod.compare(cellValue1, cellValue2, field, references, sortKey);
|
|
1132
727
|
return res * rule.direction;
|
|
1133
728
|
}, 0);
|
|
1134
729
|
});
|
|
@@ -1218,9 +813,9 @@ function getSortFields(aiTable, fields, activeView) {
|
|
|
1218
813
|
return sortByViewPosition(fields, activeView);
|
|
1219
814
|
}
|
|
1220
815
|
|
|
1221
|
-
function buildRecordsByView(aiTable, records, fields, activeView) {
|
|
816
|
+
function buildRecordsByView(aiTable, records, fields, activeView, sortKeysMap) {
|
|
1222
817
|
const filteredRecords = getFilteredRecords(aiTable, records, fields, activeView);
|
|
1223
|
-
return getSortRecords(aiTable, filteredRecords, activeView);
|
|
818
|
+
return getSortRecords(aiTable, filteredRecords, activeView, sortKeysMap);
|
|
1224
819
|
}
|
|
1225
820
|
function buildFieldsByView(aiTable, fields, activeView) {
|
|
1226
821
|
return getSortFields(aiTable, fields, activeView);
|
|
@@ -1792,11 +1387,7 @@ const RemoveRecordsItem = {
|
|
|
1792
1387
|
name: '删除行',
|
|
1793
1388
|
icon: 'trash',
|
|
1794
1389
|
exec: (aiTable, targetName, position, aiTableGridSelectionService) => {
|
|
1795
|
-
let selectedRecordIds =
|
|
1796
|
-
if (!selectedRecordIds.length) {
|
|
1797
|
-
const recordId = getDetailByTargetName(targetName).recordId;
|
|
1798
|
-
selectedRecordIds = [recordId];
|
|
1799
|
-
}
|
|
1390
|
+
let selectedRecordIds = AITable.getActiveRecordIds(aiTable);
|
|
1800
1391
|
selectedRecordIds.forEach((id) => {
|
|
1801
1392
|
Actions.removeRecord(aiTable, [id]);
|
|
1802
1393
|
});
|
|
@@ -1810,5 +1401,5 @@ const VIEW_ACTIONS = [ActionName.SetView, ActionName.AddView, ActionName.RemoveV
|
|
|
1810
1401
|
* Generated bundle index. Do not edit.
|
|
1811
1402
|
*/
|
|
1812
1403
|
|
|
1813
|
-
export { AITableFilterLogical,
|
|
1404
|
+
export { AITableFilterLogical, AI_TABLE_CONTENT_FIELD_NAME, ActionName, Actions, Direction, DividerMenuItem, EditFieldPropertyItem, ExecuteType, FLUSHING, Positions, RemovePositions, RemoveRecordsItem, SystemFieldIndex, VIEW_ACTIONS, YjsAITable, actionMappers, addFields, addRecords, addView, applyActionOps, applyEvents, applyYjsEvents, buildFieldsByView, buildRecordsByView, buildRemoveFieldItem, createDefaultPositions, createSharedType, doFilter, getCustomFieldValues, getDataBySharedType, getDefaultRecordDataByFilter, getDefaultRecordValues, getFilteredRecords, getIdBySystemFieldValues, getIdBySystemFieldValuesType, getPosition, getPositionsByRecordSyncElement, getPositionsBySystemFieldValues, getRecordsBySharedJson, getShareTypeNumberPath, getSharedMapValueId, getSharedMapValueIndex, getSharedRecord, getSharedRecordId, getSharedRecordIndex, getSharedTypeByData, getShortIdBySystemFieldValues, getSortFields, getSortRecords, getSystemFieldValues, getTrackableEntityBySystemFieldValues, getValuesByCustomFieldValues, isPathEqual, removeView, setRecordPositions$1 as setRecordPositions, setRecordUpdatedInfo, sortByViewPosition, sortRecordsBySortInfo, toRecordSyncElement, toSharedType, toSyncElement, translatePositionToPath, translateYjsEvent, updateFieldValue, updateRecordsUpdatedInfo, withState };
|
|
1814
1405
|
//# sourceMappingURL=ai-table-state.mjs.map
|