@ai-table/state 0.3.2 → 0.4.0-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/action/index.d.ts +1 -1
- package/action/record.d.ts.map +1 -1
- package/action/view.d.ts +3 -2
- package/action/view.d.ts.map +1 -1
- package/constants/field-menu-item.d.ts +2 -2
- package/constants/field-menu-item.d.ts.map +1 -1
- package/fesm2022/ai-table-state.mjs +79 -56
- package/fesm2022/ai-table-state.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/build.d.ts +1 -1
- package/utils/build.d.ts.map +1 -1
- package/utils/field/build-fields.d.ts +3 -0
- package/utils/field/build-fields.d.ts.map +1 -0
- package/utils/field/index.d.ts +1 -0
- package/utils/field/index.d.ts.map +1 -1
- package/utils/field/position-field.d.ts +1 -2
- package/utils/field/position-field.d.ts.map +1 -1
- package/utils/record/add-records.d.ts +2 -2
- package/utils/record/add-records.d.ts.map +1 -1
- package/utils/record/filter.d.ts.map +1 -1
- package/utils/record/update-field-value.d.ts.map +1 -1
- package/utils/field/stat-field.d.ts +0 -3
- package/utils/field/stat-field.d.ts.map +0 -1
package/action/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const Actions: {
|
|
|
14
14
|
setView: (aiTable: import("@ai-table/state").AIViewTable, value: Partial<import("@ai-table/utils").AITableView>, path: [string]) => void;
|
|
15
15
|
addView: (aiTable: import("@ai-table/state").AIViewTable, originId: string, newView: import("@ai-table/utils").AITableView, isDuplicate?: boolean) => void;
|
|
16
16
|
removeView: (aiTable: import("@ai-table/state").AIViewTable, path: [string]) => void;
|
|
17
|
-
|
|
17
|
+
setRecordHeightType: (aiTable: import("@ai-table/state").AIViewTable, recordHeightType: import("@ai-table/utils").AITableRowHeightType) => void;
|
|
18
18
|
addField: typeof import("./field").addField;
|
|
19
19
|
removeField: typeof import("./field").removeField;
|
|
20
20
|
setField: typeof import("./field").setField;
|
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,EAKhC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,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,14 +1,15 @@
|
|
|
1
|
-
import { AITableView, SetViewAction } from '@ai-table/utils';
|
|
1
|
+
import { AITableRowHeightType, 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: AITableRowHeightType): void;
|
|
7
8
|
export declare const ViewActions: {
|
|
8
9
|
setView: typeof setView;
|
|
9
10
|
addView: typeof addView;
|
|
10
11
|
removeView: typeof removeView;
|
|
11
|
-
|
|
12
|
+
setRecordHeightType: typeof setRecordHeightType;
|
|
12
13
|
};
|
|
13
14
|
export {};
|
|
14
15
|
//# sourceMappingURL=view.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../packages/state/src/action/view.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,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,oBAAoB,QAkBxF;AAED,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AITable, AITableActions } from '@ai-table/grid';
|
|
2
2
|
import { ElementRef, Signal } from '@angular/core';
|
|
3
3
|
import { AIViewTable } from '../types';
|
|
4
|
-
import {
|
|
4
|
+
import { AITableField, AITableReferences, SetFieldOptions } from '@ai-table/utils';
|
|
5
5
|
export declare const DividerMenuItem: {
|
|
6
6
|
type: string;
|
|
7
7
|
};
|
|
@@ -15,7 +15,7 @@ export declare const EditFieldPropertyItem: (aiTable: AITable, actions: AITableA
|
|
|
15
15
|
}) => import("ngx-tethys/popover").ThyPopoverRef<unknown, unknown, unknown> | undefined;
|
|
16
16
|
};
|
|
17
17
|
export declare const updateFieldAndValues: (aiTable: AIViewTable, references: AITableReferences, actions: AITableActions, options: SetFieldOptions) => void;
|
|
18
|
-
export declare const CopyFieldPropertyItem: (aiTable: AITable,
|
|
18
|
+
export declare const CopyFieldPropertyItem: (aiTable: AITable, actions: AITableActions) => {
|
|
19
19
|
type: string;
|
|
20
20
|
name: string;
|
|
21
21
|
icon: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-menu-item.d.ts","sourceRoot":"","sources":["../../../packages/state/src/constants/field-menu-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EACP,cAAc,EAKjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,
|
|
1
|
+
{"version":3,"file":"field-menu-item.d.ts","sourceRoot":"","sources":["../../../packages/state/src/constants/field-menu-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,OAAO,EACP,cAAc,EAKjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAEH,YAAY,EACZ,iBAAiB,EAIjB,eAAe,EAIlB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,eAAe;;CAE3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,EAAE,SAAS,cAAc,EAAE,YAAY,iBAAiB;;;;oBAK7F,WAAW,SACb,MAAM,CAAC,YAAY,CAAC,WAClB,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,aAC3B;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;CAqBzC,CAAC;AAEH,eAAO,MAAM,oBAAoB,GAC7B,SAAS,WAAW,EACpB,YAAY,iBAAiB,EAC7B,SAAS,cAAc,EACvB,SAAS,eAAe,SA6C3B,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,OAAO,EAAE,SAAS,cAAc;;;;oBAMvD,WAAW,SAAS,MAAM,CAAC,YAAY,CAAC;;CA2B/D,CAAC"}
|
|
@@ -478,6 +478,9 @@ function checkConditions(aiTable, fields, record, filterConditions) {
|
|
|
478
478
|
if (!record) {
|
|
479
479
|
return false;
|
|
480
480
|
}
|
|
481
|
+
if (!aiTable.activeViewId?.() || !aiTable.viewsMap?.()) {
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
481
484
|
if (!filterConditions?.conditions) {
|
|
482
485
|
const conditions = aiTable.viewsMap()[aiTable.activeViewId()].settings?.conditions;
|
|
483
486
|
const conditionLogical = aiTable.viewsMap()[aiTable.activeViewId()].settings?.condition_logical;
|
|
@@ -589,18 +592,19 @@ function getSortFields(aiTable, fields, activeView) {
|
|
|
589
592
|
return sortByViewPosition(fields, activeView);
|
|
590
593
|
}
|
|
591
594
|
|
|
592
|
-
function
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
595
|
+
function buildViewFields(fields, activeView) {
|
|
596
|
+
const activeViewId = activeView._id;
|
|
597
|
+
return fields.map((field) => {
|
|
598
|
+
const statType = field.stat_types?.[activeViewId];
|
|
599
|
+
const width = field.widths?.[activeViewId];
|
|
600
|
+
const newField = { ...field };
|
|
601
|
+
if (statType) {
|
|
602
|
+
newField.stat_type = statType;
|
|
603
|
+
}
|
|
604
|
+
if (width) {
|
|
605
|
+
newField.width = width;
|
|
606
|
+
}
|
|
607
|
+
return newField;
|
|
604
608
|
});
|
|
605
609
|
}
|
|
606
610
|
|
|
@@ -880,7 +884,7 @@ function setFieldWidth(aiTable, path, width) {
|
|
|
880
884
|
}
|
|
881
885
|
function setFieldStatType(aiTable, path, statType) {
|
|
882
886
|
const field = AITableQueries.getField(aiTable, path);
|
|
883
|
-
setField(aiTable, {
|
|
887
|
+
setField(aiTable, { stat_types: { ...field.stat_types, [aiTable.activeViewId()]: statType } }, [field._id]);
|
|
884
888
|
}
|
|
885
889
|
function removeField(aiTable, path) {
|
|
886
890
|
const operation = {
|
|
@@ -1068,7 +1072,7 @@ const GeneralActions = {
|
|
|
1068
1072
|
transform(aiTable, actions) {
|
|
1069
1073
|
const records = createDraft(aiTable.records());
|
|
1070
1074
|
const fields = createDraft(aiTable.fields());
|
|
1071
|
-
const views = createDraft(aiTable.views());
|
|
1075
|
+
const views = createDraft(aiTable.views?.() || []);
|
|
1072
1076
|
actions.forEach((action) => {
|
|
1073
1077
|
apply(aiTable, records, fields, views, action);
|
|
1074
1078
|
});
|
|
@@ -1081,8 +1085,8 @@ const GeneralActions = {
|
|
|
1081
1085
|
if (newRecords !== aiTable.records()) {
|
|
1082
1086
|
aiTable.records.set(newRecords);
|
|
1083
1087
|
}
|
|
1084
|
-
if (newViews !== aiTable.views()) {
|
|
1085
|
-
aiTable.views
|
|
1088
|
+
if (newViews !== (aiTable.views?.() || [])) {
|
|
1089
|
+
aiTable.views?.set(newViews);
|
|
1086
1090
|
}
|
|
1087
1091
|
}
|
|
1088
1092
|
};
|
|
@@ -1169,11 +1173,29 @@ function removeView$1(aiTable, path) {
|
|
|
1169
1173
|
};
|
|
1170
1174
|
aiTable.apply(operation);
|
|
1171
1175
|
}
|
|
1176
|
+
function setRecordHeightType(aiTable, recordHeightType) {
|
|
1177
|
+
const viewId = aiTable.activeViewId();
|
|
1178
|
+
const view = aiTable.views().find((v) => v._id === viewId);
|
|
1179
|
+
if (!view)
|
|
1180
|
+
return;
|
|
1181
|
+
const currentSettings = view.settings || {};
|
|
1182
|
+
const newSettings = {
|
|
1183
|
+
...currentSettings,
|
|
1184
|
+
record_height_type: recordHeightType
|
|
1185
|
+
};
|
|
1186
|
+
const operation = {
|
|
1187
|
+
type: ActionName.SetView,
|
|
1188
|
+
properties: { settings: currentSettings },
|
|
1189
|
+
newProperties: { settings: newSettings },
|
|
1190
|
+
path: [viewId]
|
|
1191
|
+
};
|
|
1192
|
+
aiTable.apply(operation);
|
|
1193
|
+
}
|
|
1172
1194
|
const ViewActions = {
|
|
1173
1195
|
setView,
|
|
1174
1196
|
addView: addView$1,
|
|
1175
1197
|
removeView: removeView$1,
|
|
1176
|
-
|
|
1198
|
+
setRecordHeightType
|
|
1177
1199
|
};
|
|
1178
1200
|
|
|
1179
1201
|
function buildSetRecordPositionsAction(aiTable, positions, path) {
|
|
@@ -1448,14 +1470,14 @@ function addView(aiTable, type, viewId) {
|
|
|
1448
1470
|
ViewActions.addView(aiTable, originViewId, newView, type === 'duplicate');
|
|
1449
1471
|
const actions = [];
|
|
1450
1472
|
aiTable.records().forEach((record, index) => {
|
|
1451
|
-
const action = buildSetRecordPositionsAction(aiTable, { [newId]: record
|
|
1473
|
+
const action = buildSetRecordPositionsAction(aiTable, { [newId]: record?.positions?.[originViewId] }, [index]);
|
|
1452
1474
|
actions.push(action);
|
|
1453
1475
|
});
|
|
1454
1476
|
aiTable.fields().forEach((field) => {
|
|
1455
1477
|
const action = buildSetFieldAction(aiTable, {
|
|
1456
1478
|
positions: {
|
|
1457
1479
|
...field.positions,
|
|
1458
|
-
[newId]: field
|
|
1480
|
+
[newId]: field?.positions?.[originViewId]
|
|
1459
1481
|
}
|
|
1460
1482
|
}, [field._id]);
|
|
1461
1483
|
if (action) {
|
|
@@ -1489,31 +1511,31 @@ function sortViews(data) {
|
|
|
1489
1511
|
}
|
|
1490
1512
|
|
|
1491
1513
|
function findNextItemByPosition(aiTable, targetId, items, itemsMap) {
|
|
1492
|
-
const viewId = aiTable.activeViewId();
|
|
1514
|
+
const viewId = aiTable.activeViewId?.();
|
|
1493
1515
|
const targetItem = itemsMap[targetId];
|
|
1494
|
-
const targetPosition = targetItem
|
|
1516
|
+
const targetPosition = targetItem?.positions?.[viewId] || 0;
|
|
1495
1517
|
let nextItem = null;
|
|
1496
1518
|
for (const item of items) {
|
|
1497
|
-
const pos = item
|
|
1498
|
-
if (pos > targetPosition && (nextItem === null || pos < nextItem
|
|
1519
|
+
const pos = item?.positions?.[viewId] || 0;
|
|
1520
|
+
if (pos > targetPosition && (nextItem === null || pos < nextItem?.positions?.[viewId])) {
|
|
1499
1521
|
nextItem = item;
|
|
1500
1522
|
}
|
|
1501
1523
|
}
|
|
1502
1524
|
return nextItem;
|
|
1503
1525
|
}
|
|
1504
1526
|
function findMaxItemByPosition(aiTable, items) {
|
|
1505
|
-
const viewId = aiTable.activeViewId();
|
|
1527
|
+
const viewId = aiTable.activeViewId?.();
|
|
1506
1528
|
let maxItem = items[0];
|
|
1507
1529
|
for (const item of items) {
|
|
1508
|
-
const pos = item
|
|
1509
|
-
if (pos > maxItem
|
|
1530
|
+
const pos = item?.positions?.[viewId] || 0;
|
|
1531
|
+
if (pos > maxItem?.positions?.[viewId]) {
|
|
1510
1532
|
maxItem = item;
|
|
1511
1533
|
}
|
|
1512
1534
|
}
|
|
1513
1535
|
return maxItem;
|
|
1514
1536
|
}
|
|
1515
1537
|
function findPrevItemByPosition(aiTable, targetId, items, itemsMap) {
|
|
1516
|
-
const viewId = aiTable.activeViewId();
|
|
1538
|
+
const viewId = aiTable.activeViewId?.();
|
|
1517
1539
|
const targetItem = itemsMap[targetId];
|
|
1518
1540
|
const targetPosition = targetItem.positions[viewId] || 0;
|
|
1519
1541
|
let prevItem = null;
|
|
@@ -1526,7 +1548,7 @@ function findPrevItemByPosition(aiTable, targetId, items, itemsMap) {
|
|
|
1526
1548
|
return prevItem;
|
|
1527
1549
|
}
|
|
1528
1550
|
function getPreviousAndNextPosition(aiTable, options, items, itemsMap) {
|
|
1529
|
-
const activeViewId = aiTable.activeViewId();
|
|
1551
|
+
const activeViewId = aiTable.activeViewId?.();
|
|
1530
1552
|
const { afterItemId, beforeItemId } = options;
|
|
1531
1553
|
let nextPosition = null;
|
|
1532
1554
|
let previousPosition = null;
|
|
@@ -1535,10 +1557,10 @@ function getPreviousAndNextPosition(aiTable, options, items, itemsMap) {
|
|
|
1535
1557
|
if (!previousItem) {
|
|
1536
1558
|
throw new Error(`Target item with id ${afterItemId} not found`);
|
|
1537
1559
|
}
|
|
1538
|
-
previousPosition = previousItem
|
|
1560
|
+
previousPosition = previousItem?.positions?.[activeViewId] || 0;
|
|
1539
1561
|
const nextItem = findNextItemByPosition(aiTable, afterItemId, items, itemsMap);
|
|
1540
1562
|
if (nextItem !== null) {
|
|
1541
|
-
nextPosition = nextItem
|
|
1563
|
+
nextPosition = nextItem?.positions?.[activeViewId] || 0;
|
|
1542
1564
|
}
|
|
1543
1565
|
}
|
|
1544
1566
|
else if (beforeItemId) {
|
|
@@ -1546,15 +1568,15 @@ function getPreviousAndNextPosition(aiTable, options, items, itemsMap) {
|
|
|
1546
1568
|
if (!nextItem) {
|
|
1547
1569
|
throw new Error(`Target item with id ${beforeItemId} not found`);
|
|
1548
1570
|
}
|
|
1549
|
-
nextPosition = nextItem
|
|
1571
|
+
nextPosition = nextItem?.positions?.[activeViewId] || 0;
|
|
1550
1572
|
const previousItem = findPrevItemByPosition(aiTable, beforeItemId, items, itemsMap);
|
|
1551
1573
|
if (previousItem !== null) {
|
|
1552
|
-
previousPosition = previousItem
|
|
1574
|
+
previousPosition = previousItem?.positions?.[activeViewId] || 0;
|
|
1553
1575
|
}
|
|
1554
1576
|
}
|
|
1555
1577
|
else {
|
|
1556
1578
|
const maxItem = findMaxItemByPosition(aiTable, items);
|
|
1557
|
-
previousPosition = maxItem
|
|
1579
|
+
previousPosition = maxItem?.positions?.[activeViewId] || 0;
|
|
1558
1580
|
}
|
|
1559
1581
|
return {
|
|
1560
1582
|
nextPosition,
|
|
@@ -1592,8 +1614,8 @@ function getNewItemsPosition(aiTable, options, items, itemsMap) {
|
|
|
1592
1614
|
if (positions.length === 0) {
|
|
1593
1615
|
return [];
|
|
1594
1616
|
}
|
|
1595
|
-
const views = aiTable.views();
|
|
1596
|
-
const activeViewId = aiTable.activeViewId();
|
|
1617
|
+
const views = aiTable.views?.() || [];
|
|
1618
|
+
const activeViewId = aiTable.activeViewId?.();
|
|
1597
1619
|
const viewsMaxPosition = {};
|
|
1598
1620
|
views.forEach((view) => {
|
|
1599
1621
|
viewsMaxPosition[view._id] = getMaxPosition(items, view._id);
|
|
@@ -1852,12 +1874,12 @@ function buildRecordsWithWillMoveRecords(records, willMoveRecordsMap) {
|
|
|
1852
1874
|
});
|
|
1853
1875
|
}
|
|
1854
1876
|
|
|
1855
|
-
function addRecords(aiTable,
|
|
1877
|
+
function addRecords(aiTable, options, recordCreatedInfo) {
|
|
1856
1878
|
options = options || {};
|
|
1857
1879
|
const newRecords = [];
|
|
1858
|
-
const activeViewId = aiTable.activeViewId();
|
|
1859
|
-
const activeView = aiTable.viewsMap()[activeViewId];
|
|
1860
|
-
const groups = activeView
|
|
1880
|
+
const activeViewId = aiTable.activeViewId?.();
|
|
1881
|
+
const activeView = aiTable.viewsMap?.()?.[activeViewId];
|
|
1882
|
+
const groups = activeView?.settings?.groups;
|
|
1861
1883
|
let { originId, isDuplicate, count = 1 } = options;
|
|
1862
1884
|
const recordCount = aiTable.records().length;
|
|
1863
1885
|
const maxRecordCount = aiTable.context?.maxRecords();
|
|
@@ -1884,7 +1906,7 @@ function addRecords(aiTable, trackableEntity, options) {
|
|
|
1884
1906
|
_id: id,
|
|
1885
1907
|
short_id: newRecordShortIds[index],
|
|
1886
1908
|
values: newRecordValues,
|
|
1887
|
-
...
|
|
1909
|
+
...recordCreatedInfo
|
|
1888
1910
|
};
|
|
1889
1911
|
if (needCopyGroupValuesMap) {
|
|
1890
1912
|
groups?.forEach((group) => {
|
|
@@ -1921,15 +1943,20 @@ function getDefaultRecordValues(aiTable, isDuplicate = false, recordId) {
|
|
|
1921
1943
|
newRecordValues = aiTable.recordsMap()[recordId].values;
|
|
1922
1944
|
}
|
|
1923
1945
|
else {
|
|
1924
|
-
|
|
1925
|
-
const
|
|
1946
|
+
let fields = aiTable.fields();
|
|
1947
|
+
const activeView = aiTable.viewsMap?.()?.[aiTable.activeViewId?.()];
|
|
1948
|
+
if (activeView) {
|
|
1949
|
+
fields = getSortFields(aiTable, fields, activeView);
|
|
1950
|
+
}
|
|
1926
1951
|
fields.map((field) => {
|
|
1927
1952
|
const defaultValue = FieldModelMap[field.type].getDefaultValue();
|
|
1928
1953
|
newRecordValues[field._id] = defaultValue;
|
|
1929
1954
|
});
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1955
|
+
if (activeView) {
|
|
1956
|
+
const { conditions, condition_logical } = activeView.settings || {};
|
|
1957
|
+
if (conditions && conditions.length) {
|
|
1958
|
+
newRecordValues = getDefaultRecordDataByFilter(newRecordValues, conditions, fields, condition_logical);
|
|
1959
|
+
}
|
|
1933
1960
|
}
|
|
1934
1961
|
}
|
|
1935
1962
|
return newRecordValues;
|
|
@@ -1963,6 +1990,9 @@ function updateWillHiddenRecordIds(aiTable, needUpdateOptions, updatedInfo) {
|
|
|
1963
1990
|
});
|
|
1964
1991
|
}
|
|
1965
1992
|
function updateWillMoveRecords(aiTable, needUpdateOptions, updatedInfo) {
|
|
1993
|
+
if (!aiTable.activeViewId?.() || !aiTable.viewsMap?.()) {
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1966
1996
|
const activeView = aiTable.viewsMap()[aiTable.activeViewId()];
|
|
1967
1997
|
const groups = activeView.settings?.groups ?? [];
|
|
1968
1998
|
const sorts = activeView.settings?.sorts ?? [];
|
|
@@ -2124,7 +2154,7 @@ function buildRecordsByView(aiTable, records, fields, activeView) {
|
|
|
2124
2154
|
}
|
|
2125
2155
|
function buildFieldsByView(aiTable, fields, activeView) {
|
|
2126
2156
|
const sortFields = getSortFields(aiTable, fields, activeView);
|
|
2127
|
-
return
|
|
2157
|
+
return buildViewFields(sortFields, activeView);
|
|
2128
2158
|
}
|
|
2129
2159
|
function buildLinearRows(aiTable, activeView, records) {
|
|
2130
2160
|
if (aiTable && activeView?.settings?.groups?.length) {
|
|
@@ -2445,13 +2475,6 @@ function getFieldPositionInView(viewId, fields, path, newPath) {
|
|
|
2445
2475
|
}
|
|
2446
2476
|
return newPosition;
|
|
2447
2477
|
}
|
|
2448
|
-
function getFieldsSizeMap(fields, activeView) {
|
|
2449
|
-
const fieldsSizeMap = {};
|
|
2450
|
-
fields?.forEach((field) => {
|
|
2451
|
-
fieldsSizeMap[field._id] = field.widths?.[activeView._id];
|
|
2452
|
-
});
|
|
2453
|
-
return fieldsSizeMap;
|
|
2454
|
-
}
|
|
2455
2478
|
|
|
2456
2479
|
function addFields(aiTable, options) {
|
|
2457
2480
|
const maxFieldsCount = aiTable.context?.maxFields();
|
|
@@ -2579,7 +2602,7 @@ const updateFieldAndValues = (aiTable, references, actions, options) => {
|
|
|
2579
2602
|
actions.updateFieldValues(fieldValueOptions);
|
|
2580
2603
|
}
|
|
2581
2604
|
};
|
|
2582
|
-
const CopyFieldPropertyItem = (aiTable,
|
|
2605
|
+
const CopyFieldPropertyItem = (aiTable, actions) => {
|
|
2583
2606
|
const name = getStateI18nTextByKey(aiTable, AITableStateI18nKey.copyField);
|
|
2584
2607
|
return {
|
|
2585
2608
|
type: 'copyFieldProperty',
|
|
@@ -2603,7 +2626,7 @@ const CopyFieldPropertyItem = (aiTable, addFieldFn) => {
|
|
|
2603
2626
|
name: newFieldName
|
|
2604
2627
|
}
|
|
2605
2628
|
};
|
|
2606
|
-
|
|
2629
|
+
actions.addField(fieldOptions);
|
|
2607
2630
|
},
|
|
2608
2631
|
disabled: () => {
|
|
2609
2632
|
const fieldLength = aiTable.fields()?.length || 0;
|
|
@@ -2712,5 +2735,5 @@ const VIEW_ACTIONS = [ActionName.SetView, ActionName.AddView, ActionName.RemoveV
|
|
|
2712
2735
|
* Generated bundle index. Do not edit.
|
|
2713
2736
|
*/
|
|
2714
2737
|
|
|
2715
|
-
export { AITableStateI18nKey, AITableStateI18nText, Actions, CopyCellsItem, CopyFieldPropertyItem, DEFAULT_INITIAL_GAP, DEFAULT_PRECISION_THRESHOLD, DividerMenuItem, EditFieldPropertyItem, FLUSHING, GroupCalculator, InsertDownwardRecords, InsertUpwardRecords, PasteCellsItem, RemoveRecordsItem, UndoManagerService, VIEW_ACTIONS, YjsAITable, actionMappers, addFields, addRecords, addView, applyActionOps, applyActions, applyEvents, applyYjsEvents, buildFieldsByView, buildLinearRows, buildRecordsByView, buildRecordsWithWillMoveRecords, buildRemoveFieldItem, buildSetFieldAction, buildSetRecordPositionsAction, buildSorts, calculateAdaptiveFrozenColumnCount, checkConditions, createMultiplePositions, createPositions, createSharedType, doFilter, freezeToThisColumn, generateCopyName, getDataBySharedType, getDefaultI18nTextByKey, getDefaultRecordDataByFilter, getDefaultRecordValues, getFieldPositionInView,
|
|
2738
|
+
export { AITableStateI18nKey, AITableStateI18nText, Actions, CopyCellsItem, CopyFieldPropertyItem, DEFAULT_INITIAL_GAP, DEFAULT_PRECISION_THRESHOLD, DividerMenuItem, EditFieldPropertyItem, FLUSHING, GroupCalculator, InsertDownwardRecords, InsertUpwardRecords, PasteCellsItem, RemoveRecordsItem, UndoManagerService, VIEW_ACTIONS, YjsAITable, actionMappers, addFields, addRecords, addView, applyActionOps, applyActions, applyEvents, applyYjsEvents, buildFieldsByView, buildLinearRows, buildRecordsByView, buildRecordsWithWillMoveRecords, buildRemoveFieldItem, buildSetFieldAction, buildSetRecordPositionsAction, buildSorts, calculateAdaptiveFrozenColumnCount, checkConditions, createMultiplePositions, createPositions, createSharedType, doFilter, freezeToThisColumn, generateCopyName, getDataBySharedType, getDefaultI18nTextByKey, getDefaultRecordDataByFilter, getDefaultRecordValues, getFieldPositionInView, getFilteredRecords, getFrozenFieldId, getGroupRecordLength, getMaxPosition, getParentGroupValuesByGroupId, getParentLinearRowGroups, getPosition, getPositions, getPrevRecordIdByAddGroupId, getRecordsBySharedJson, getSharedTypeByData, getSortFields, getStateI18nTextByKey, insertAtEnd, insertAtStart, insertBetween, isPathEqual, isSameParentGroup, mergeSorts, moveFields, moveRecords, removeView, restoreDefaultFrozenColumn, sortRecordsByConditions, sortViews, toSharedType, translateYjsEvent, updateFieldAndValues, updateFieldValues, withState };
|
|
2716
2739
|
//# sourceMappingURL=ai-table-state.mjs.map
|