@ai-table/state 0.4.0-0 → 0.4.0-2
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/group.d.ts +0 -15
- package/action/group.d.ts.map +1 -1
- package/action/index.d.ts +1 -8
- package/action/index.d.ts.map +1 -1
- package/action/record.d.ts.map +1 -1
- package/action/view.d.ts +2 -2
- package/action/view.d.ts.map +1 -1
- package/fesm2022/ai-table-state.mjs +6 -86
- package/fesm2022/ai-table-state.mjs.map +1 -1
- package/package.json +1 -1
package/action/group.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { AITableGroupField, SortDirection } from '@ai-table/utils';
|
|
2
1
|
import { AIViewTable } from '../types/ai-table';
|
|
3
|
-
declare function setViewGroup(aiTable: AIViewTable, groups: AITableGroupField[] | null): void;
|
|
4
|
-
declare function setCollapsedGroup(aiTable: AIViewTable, collapsedGroupIds: string[]): void;
|
|
5
2
|
declare function toggleGroupCollapse(aiTable: AIViewTable, groupId: string): void;
|
|
6
|
-
declare function addGroupField(aiTable: AIViewTable, fieldId: string, direction?: SortDirection): void;
|
|
7
|
-
declare function removeGroupField(aiTable: AIViewTable, fieldId: string): void;
|
|
8
|
-
declare function updateGroupFieldDirection(aiTable: AIViewTable, fieldId: string, direction: SortDirection): void;
|
|
9
|
-
declare function reorderGroupFields(aiTable: AIViewTable, fromIndex: number, toIndex: number): void;
|
|
10
|
-
declare function clearAllGroups(aiTable: AIViewTable): void;
|
|
11
3
|
export declare const GroupActions: {
|
|
12
|
-
setViewGroup: typeof setViewGroup;
|
|
13
|
-
setCollapsedGroup: typeof setCollapsedGroup;
|
|
14
4
|
toggleGroupCollapse: typeof toggleGroupCollapse;
|
|
15
|
-
addGroupField: typeof addGroupField;
|
|
16
|
-
removeGroupField: typeof removeGroupField;
|
|
17
|
-
updateGroupFieldDirection: typeof updateGroupFieldDirection;
|
|
18
|
-
reorderGroupFields: typeof reorderGroupFields;
|
|
19
|
-
clearAllGroups: typeof clearAllGroups;
|
|
20
5
|
};
|
|
21
6
|
export {};
|
|
22
7
|
//# sourceMappingURL=group.d.ts.map
|
package/action/group.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/group.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/group.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAsBhD,iBAAS,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,QAOjE;AAED,eAAO,MAAM,YAAY;;CAExB,CAAC"}
|
package/action/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
export declare const Actions: {
|
|
2
|
-
setViewGroup: (aiTable: import("@ai-table/state").AIViewTable, groups: import("@ai-table/utils").AITableGroupField[] | null) => void;
|
|
3
|
-
setCollapsedGroup: (aiTable: import("@ai-table/state").AIViewTable, collapsedGroupIds: string[]) => void;
|
|
4
2
|
toggleGroupCollapse: (aiTable: import("@ai-table/state").AIViewTable, groupId: string) => void;
|
|
5
|
-
addGroupField: (aiTable: import("@ai-table/state").AIViewTable, fieldId: string, direction?: import("@ai-table/utils").SortDirection) => void;
|
|
6
|
-
removeGroupField: (aiTable: import("@ai-table/state").AIViewTable, fieldId: string) => void;
|
|
7
|
-
updateGroupFieldDirection: (aiTable: import("@ai-table/state").AIViewTable, fieldId: string, direction: import("@ai-table/utils").SortDirection) => void;
|
|
8
|
-
reorderGroupFields: (aiTable: import("@ai-table/state").AIViewTable, fromIndex: number, toIndex: number) => void;
|
|
9
|
-
clearAllGroups: (aiTable: import("@ai-table/state").AIViewTable) => void;
|
|
10
3
|
setRecordPositions: typeof import("./position").setRecordPositions;
|
|
11
4
|
resetAllRecordsPositions: typeof import("./position").resetAllRecordsPositions;
|
|
12
5
|
resetAllFieldsPositions: typeof import("./position").resetAllFieldsPositions;
|
|
@@ -14,7 +7,7 @@ export declare const Actions: {
|
|
|
14
7
|
setView: (aiTable: import("@ai-table/state").AIViewTable, value: Partial<import("@ai-table/utils").AITableView>, path: [string]) => void;
|
|
15
8
|
addView: (aiTable: import("@ai-table/state").AIViewTable, originId: string, newView: import("@ai-table/utils").AITableView, isDuplicate?: boolean) => void;
|
|
16
9
|
removeView: (aiTable: import("@ai-table/state").AIViewTable, path: [string]) => void;
|
|
17
|
-
setRecordHeightType: (aiTable: import("@ai-table/state").AIViewTable, recordHeightType: import("@ai-table/utils").
|
|
10
|
+
setRecordHeightType: (aiTable: import("@ai-table/state").AIViewTable, recordHeightType: import("@ai-table/utils").AITableRecordHeightType) => void;
|
|
18
11
|
addField: typeof import("./field").addField;
|
|
19
12
|
removeField: typeof import("./field").removeField;
|
|
20
13
|
setField: typeof import("./field").setField;
|
package/action/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;CAOnB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
|
package/action/record.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/record.ts"],"names":[],"mappings":"AACA,OAAO,EAMH,aAAa,EACb,MAAM,EAEN,gBAAgB,EAChB,uBAAuB,EACvB,6BAA6B,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/record.ts"],"names":[],"mappings":"AACA,OAAO,EAMH,aAAa,EACb,MAAM,EAEN,gBAAgB,EAChB,uBAAuB,EACvB,6BAA6B,EAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,uBAAuB,EAAE,QAsBzF;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,6BAA6B,EAAE,QAYrG;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,QAEpE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,OAAO,CAAC,EAAE,gBAAgB,QAoCpG;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,QAM9D;AAED,eAAO,MAAM,aAAa;;;;;;CAMzB,CAAC"}
|
package/action/view.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AITableRecordHeightType, AITableView, SetViewAction } from '@ai-table/utils';
|
|
2
2
|
import { AIViewTable } from '../types/ai-table';
|
|
3
3
|
export declare function buildSetViewAction(aiTable: AIViewTable, value: Partial<AITableView>, path: [string]): SetViewAction | null;
|
|
4
4
|
declare function setView(aiTable: AIViewTable, value: Partial<AITableView>, path: [string]): void;
|
|
5
5
|
declare function addView(aiTable: AIViewTable, originId: string, newView: AITableView, isDuplicate?: boolean): void;
|
|
6
6
|
declare function removeView(aiTable: AIViewTable, path: [string]): void;
|
|
7
|
-
declare function setRecordHeightType(aiTable: AIViewTable, recordHeightType:
|
|
7
|
+
declare function setRecordHeightType(aiTable: AIViewTable, recordHeightType: AITableRecordHeightType): void;
|
|
8
8
|
export declare const ViewActions: {
|
|
9
9
|
setView: typeof setView;
|
|
10
10
|
addView: typeof addView;
|
package/action/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/view.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/view.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,WAAW,EAIX,aAAa,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,wBA0BnG;AAED,iBAAS,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,QAKjF;AAED,iBAAS,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,OAAO,QAwCnG;AAED,iBAAS,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,QAMvD;AAED,iBAAS,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,QAkB3F;AAED,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
2
|
import { UndoManager } from 'yjs';
|
|
3
|
-
import { getShareTypeNumberPath, ActionName, translateArrayEvent, getSharedRecordIndex, getSharedMapValueIndex, toMapSyncElement, getIdBySystemFieldValuesType, setRecordUpdatedInfo, getPositionsByRecordSyncElement, setRecordPositions as setRecordPositions$1, toRecordSyncElement, AI_TABLE_CONTENT_FIELD_NAME, getValuesByCustomFieldValues, getPositionsBySystemFieldValues, getTrackableEntityBySystemFieldValues, getShortIdBySystemFieldValues, getIdBySystemFieldValues, AITableFilterLogical, AITableFilterOperation, AITableFieldType, isEmpty, sortByViewPosition, idCreator,
|
|
3
|
+
import { getShareTypeNumberPath, ActionName, translateArrayEvent, getSharedRecordIndex, getSharedMapValueIndex, toMapSyncElement, getIdBySystemFieldValuesType, setRecordUpdatedInfo, getPositionsByRecordSyncElement, setRecordPositions as setRecordPositions$1, toRecordSyncElement, AI_TABLE_CONTENT_FIELD_NAME, getValuesByCustomFieldValues, getPositionsBySystemFieldValues, getTrackableEntityBySystemFieldValues, getShortIdBySystemFieldValues, getIdBySystemFieldValues, AITableFilterLogical, AITableFilterOperation, AITableFieldType, isEmpty, sortByViewPosition, idCreator, AI_TABLE_DEFAULT_MIN_UNFROZEN_WIDTH, AI_TABLE_MIN_FROZEN_COLUMN_COUNT } from '@ai-table/utils';
|
|
4
4
|
import * as i0 from '@angular/core';
|
|
5
5
|
import { signal, Injectable } from '@angular/core';
|
|
6
|
-
import { FieldModelMap, AITableQueries, isSystemField, AITableRowType, shortIdCreator, generateNewName,
|
|
6
|
+
import { FieldModelMap, AITableQueries, isSystemField, AITableRowType, shortIdCreator, generateNewName, idsCreator, shortIdsCreator, closeExpendCell, setSelection, buildNormalLinearRows, AITable, getColumnIndicesSizeMap, getI18nTextByKey, AITableGridI18nKey, generateNewFieldName, AI_TABLE_GRID_FIELD_SERVICE_MAP, clearSelection, isMac } from '@ai-table/grid';
|
|
7
7
|
import { nanoid } from 'nanoid';
|
|
8
8
|
import * as _ from 'lodash';
|
|
9
9
|
import ___default, { map, unionBy } from 'lodash';
|
|
@@ -462,8 +462,8 @@ function getFilteredRecords(aiTable, records, fields, activeView) {
|
|
|
462
462
|
if (!conditions) {
|
|
463
463
|
return records;
|
|
464
464
|
}
|
|
465
|
-
const
|
|
466
|
-
if (!
|
|
465
|
+
const validConditions = conditions.filter((item) => item.operation) || [];
|
|
466
|
+
if (!validConditions.length) {
|
|
467
467
|
return records;
|
|
468
468
|
}
|
|
469
469
|
const recordsWillHidden = aiTable.recordsWillHidden();
|
|
@@ -471,7 +471,7 @@ function getFilteredRecords(aiTable, records, fields, activeView) {
|
|
|
471
471
|
if (recordsWillHidden && recordsWillHidden.length && recordsWillHidden.includes(record._id)) {
|
|
472
472
|
return true;
|
|
473
473
|
}
|
|
474
|
-
return checkConditions(aiTable, fields, record, { conditions:
|
|
474
|
+
return checkConditions(aiTable, fields, record, { conditions: validConditions, condition_logical });
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
477
|
function checkConditions(aiTable, fields, record, filterConditions) {
|
|
@@ -1724,25 +1724,6 @@ const RecordActions = {
|
|
|
1724
1724
|
updateSystemFieldValues
|
|
1725
1725
|
};
|
|
1726
1726
|
|
|
1727
|
-
function setViewGroup(aiTable, groups) {
|
|
1728
|
-
const viewId = aiTable.activeViewId();
|
|
1729
|
-
const view = aiTable.views().find((v) => v._id === viewId);
|
|
1730
|
-
if (!view)
|
|
1731
|
-
return;
|
|
1732
|
-
const currentSettings = view.settings || {};
|
|
1733
|
-
const newSettings = {
|
|
1734
|
-
...currentSettings,
|
|
1735
|
-
groups: groups || [],
|
|
1736
|
-
collapsed_group_ids: [] // 重置折叠
|
|
1737
|
-
};
|
|
1738
|
-
const operation = {
|
|
1739
|
-
type: ActionName.SetView,
|
|
1740
|
-
properties: { settings: currentSettings },
|
|
1741
|
-
newProperties: { settings: newSettings },
|
|
1742
|
-
path: [viewId]
|
|
1743
|
-
};
|
|
1744
|
-
aiTable.apply(operation);
|
|
1745
|
-
}
|
|
1746
1727
|
function setCollapsedGroup(aiTable, collapsedGroupIds) {
|
|
1747
1728
|
const viewId = aiTable.activeViewId();
|
|
1748
1729
|
const view = aiTable.views().find((v) => v._id === viewId);
|
|
@@ -1761,7 +1742,6 @@ function setCollapsedGroup(aiTable, collapsedGroupIds) {
|
|
|
1761
1742
|
};
|
|
1762
1743
|
aiTable.apply(operation);
|
|
1763
1744
|
}
|
|
1764
|
-
// 折叠
|
|
1765
1745
|
function toggleGroupCollapse(aiTable, groupId) {
|
|
1766
1746
|
const activeView = aiTable.viewsMap()[aiTable.activeViewId()];
|
|
1767
1747
|
if (!activeView)
|
|
@@ -1770,68 +1750,8 @@ function toggleGroupCollapse(aiTable, groupId) {
|
|
|
1770
1750
|
const newCollapse = currentCollapse.includes(groupId) ? currentCollapse.filter((id) => id !== groupId) : [...currentCollapse, groupId];
|
|
1771
1751
|
setCollapsedGroup(aiTable, newCollapse);
|
|
1772
1752
|
}
|
|
1773
|
-
// 添加分组
|
|
1774
|
-
function addGroupField(aiTable, fieldId, direction = SortDirection.ascending) {
|
|
1775
|
-
const activeView = aiTable.viewsMap()[aiTable.activeViewId()];
|
|
1776
|
-
if (!activeView)
|
|
1777
|
-
return;
|
|
1778
|
-
const currentGroups = activeView.settings?.groups || [];
|
|
1779
|
-
// 是否已存在
|
|
1780
|
-
if (currentGroups.some((group) => group.field_id === fieldId)) {
|
|
1781
|
-
throw new Error('The field has been used for grouping.');
|
|
1782
|
-
}
|
|
1783
|
-
// 层级限制
|
|
1784
|
-
if (currentGroups.length >= AI_TABLE_GROUP_MAX_LEVEL) {
|
|
1785
|
-
throw new Error(`The maximum number of groups is ${AI_TABLE_GROUP_MAX_LEVEL}.`);
|
|
1786
|
-
}
|
|
1787
|
-
const newGroups = [...currentGroups, { field_id: fieldId, direction }];
|
|
1788
|
-
setViewGroup(aiTable, newGroups);
|
|
1789
|
-
}
|
|
1790
|
-
// 删除分组
|
|
1791
|
-
function removeGroupField(aiTable, fieldId) {
|
|
1792
|
-
const view = aiTable.views().find((v) => v._id === aiTable.activeViewId());
|
|
1793
|
-
if (!view)
|
|
1794
|
-
return;
|
|
1795
|
-
const currentGroups = view.settings?.groups || [];
|
|
1796
|
-
const newGroups = currentGroups.filter((group) => group.field_id !== fieldId);
|
|
1797
|
-
setViewGroup(aiTable, newGroups.length > 0 ? newGroups : null);
|
|
1798
|
-
}
|
|
1799
|
-
// 更新排序方向
|
|
1800
|
-
function updateGroupFieldDirection(aiTable, fieldId, direction) {
|
|
1801
|
-
const view = aiTable.views().find((v) => v._id === aiTable.activeViewId());
|
|
1802
|
-
if (!view)
|
|
1803
|
-
return;
|
|
1804
|
-
const currentGroups = view.settings?.groups || [];
|
|
1805
|
-
const newGroups = currentGroups.map((group) => (group.field_id === fieldId ? { ...group, direction } : group));
|
|
1806
|
-
setViewGroup(aiTable, newGroups);
|
|
1807
|
-
}
|
|
1808
|
-
// 重新排序,拖拽顺序
|
|
1809
|
-
function reorderGroupFields(aiTable, fromIndex, toIndex) {
|
|
1810
|
-
const view = aiTable.views().find((v) => v._id === aiTable.activeViewId());
|
|
1811
|
-
if (!view)
|
|
1812
|
-
return;
|
|
1813
|
-
const currentGroups = view.settings?.groups || [];
|
|
1814
|
-
if (fromIndex < 0 || fromIndex >= currentGroups.length || toIndex < 0 || toIndex >= currentGroups.length) {
|
|
1815
|
-
return;
|
|
1816
|
-
}
|
|
1817
|
-
const newGroups = [...currentGroups];
|
|
1818
|
-
const [movedItem] = newGroups.splice(fromIndex, 1);
|
|
1819
|
-
newGroups.splice(toIndex, 0, movedItem);
|
|
1820
|
-
setViewGroup(aiTable, newGroups);
|
|
1821
|
-
}
|
|
1822
|
-
// 清空分组
|
|
1823
|
-
function clearAllGroups(aiTable) {
|
|
1824
|
-
setViewGroup(aiTable, null);
|
|
1825
|
-
}
|
|
1826
1753
|
const GroupActions = {
|
|
1827
|
-
|
|
1828
|
-
setCollapsedGroup,
|
|
1829
|
-
toggleGroupCollapse,
|
|
1830
|
-
addGroupField,
|
|
1831
|
-
removeGroupField,
|
|
1832
|
-
updateGroupFieldDirection,
|
|
1833
|
-
reorderGroupFields,
|
|
1834
|
-
clearAllGroups
|
|
1754
|
+
toggleGroupCollapse
|
|
1835
1755
|
};
|
|
1836
1756
|
|
|
1837
1757
|
const Actions = {
|