@ai-table/grid 0.2.3 → 0.2.4
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"drag.component.d.ts","sourceRoot":"","sources":["../../../../packages/grid/src/components/drag/drag.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,UAAU,EAIV,SAAS,EACT,MAAM,EAIT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiB,WAAW,EAAY,MAAM,iBAAiB,CAAC;;AAiBvE,qBAQa,oBAAqB,YAAW,MAAM,EAAE,SAAS;IAC1D,aAAa,2EAAgD;IAE7D,WAAW,2EAAgD;IAE3D,OAAO,wDAAyB;IAEhC,OAAO,CAAC,uBAAuB,CAAmC;IAElE,OAAO,CAAC,OAAO,CAAqB;IAEpC,OAAO,CAAC,uBAAuB,CAA0C;IAEzE,UAAU,EAAE,UAAU,CAAC,WAAW,CAAC,CAAmC;IAEtE,OAAO,CAAC,IAAI,CAAe;IAE3B,OAAO,CAAC,aAAa,CAAe;IAEpC,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,sBAAsB,CAA4C;IAE1E,OAAO,CAAC,kBAAkB,CAAyC;IAEnE,OAAO,CAAC,WAAW,CAAiC;IAEpD,OAAO,CAAC,KAAK,CAAiB;IAE9B,OAAO,CAAC,gBAAgB,CAAa;IAErC,OAAO,CAAC,iBAAiB,CAAkB;IAE3C,OAAO,CAAC,cAAc,CAAa;IAEnC,OAAO,CAAC,eAAe,CAAa;IAEpC,OAAO,CAAC,oBAAoB,CAAC,CAAc;IAE3C,OAAO,CAAC,sBAAsB,CAAa;IAE3C,OAAO,CAAC,kBAAkB,CAAC,CAAc;IAEzC,OAAO,CAAC,oBAAoB,CAAa;IAEzC,OAAO,CAAC,iBAAiB,CAAC,CAAa;IACvC,OAAO,CAAC,iBAAiB,CAAC,CAAa;IACvC,OAAO,CAAC,eAAe,CAAC,CAAa;;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,eAAe,CAAC,CAAa;;IAMrC,QAAQ;IAKR,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,mBAAmB;IA8C3B,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,UAAU;IA8BlB,OAAO,CAAC,YAAY;IAoJpB,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,YAAY;IAwFpB,OAAO,CAAC,uBAAuB;IAoB/B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,kBAAkB;IAI1B,WAAW;yCApfF,oBAAoB;2CAApB,oBAAoB;CA+fhC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"field-stat.d.ts","sourceRoot":"","sources":["../../../packages/grid/src/constants/field-stat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,eAAe,EAAgB,MAAM,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"field-stat.d.ts","sourceRoot":"","sources":["../../../packages/grid/src/constants/field-stat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,eAAe,EAAgB,MAAM,iBAAiB,CAAC;AAI9F,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,4BAA4B,CAAC,CAyB9F,CAAC"}
|
@@ -48,7 +48,7 @@ import { ThyNotifyService } from 'ngx-tethys/notify';
|
|
48
48
|
import { ThyInputNumber } from 'ngx-tethys/input-number';
|
49
49
|
import { isKeyHotkey } from 'is-hotkey';
|
50
50
|
import { LRUCache } from 'lru-cache';
|
51
|
-
import {
|
51
|
+
import { differenceInDays, fromUnixTime, differenceInMonths, subDays } from 'date-fns';
|
52
52
|
import { isArray, TinyDate, helpers, hexToRgb } from 'ngx-tethys/util';
|
53
53
|
import { DEFAULT_COLORS } from 'ngx-tethys/color-picker';
|
54
54
|
import GraphemeSplitter from 'grapheme-splitter';
|
@@ -2681,6 +2681,62 @@ function cellValueToSortValue$5(cellValue, field, references, sortKey = 'title')
|
|
2681
2681
|
return values && values.length ? values.join(', ') : null;
|
2682
2682
|
}
|
2683
2683
|
|
2684
|
+
function getDateFieldValues(records, options, filterNull = false) {
|
2685
|
+
const { aiTable, field } = options;
|
2686
|
+
const result = ___default.map(records, (record) => {
|
2687
|
+
const cellValue = AITableQueries.getFieldValue(aiTable, [record._id, field._id]);
|
2688
|
+
return cellValue;
|
2689
|
+
});
|
2690
|
+
if (filterNull) {
|
2691
|
+
return result.filter((value) => value !== null);
|
2692
|
+
}
|
2693
|
+
return result;
|
2694
|
+
}
|
2695
|
+
function statEarliestTime(records, options) {
|
2696
|
+
const values = getDateFieldValues(records, options, true);
|
2697
|
+
const result = ___default.minBy(values, (value) => {
|
2698
|
+
return value.timestamp;
|
2699
|
+
});
|
2700
|
+
return transformToCellText(result, options);
|
2701
|
+
}
|
2702
|
+
function statLatestTime(records, options) {
|
2703
|
+
const { field } = options;
|
2704
|
+
const values = getDateFieldValues(records, options, true);
|
2705
|
+
const result = ___default.maxBy(values, (value) => {
|
2706
|
+
return value.timestamp;
|
2707
|
+
});
|
2708
|
+
return transformToCellText(result, options);
|
2709
|
+
}
|
2710
|
+
function statDateRangeOfDays(records, options) {
|
2711
|
+
const { field } = options;
|
2712
|
+
const values = getDateFieldValues(records, options, true);
|
2713
|
+
const start = ___default.minBy(values, (value) => {
|
2714
|
+
return value.timestamp;
|
2715
|
+
});
|
2716
|
+
const end = ___default.maxBy(values, (value) => {
|
2717
|
+
return value.timestamp;
|
2718
|
+
});
|
2719
|
+
if (start && end) {
|
2720
|
+
const days = differenceInDays(fromUnixTime(end.timestamp), fromUnixTime(start.timestamp));
|
2721
|
+
return days;
|
2722
|
+
}
|
2723
|
+
return 0;
|
2724
|
+
}
|
2725
|
+
function statDateRangeOfMonths(records, options) {
|
2726
|
+
const values = getDateFieldValues(records, options, true);
|
2727
|
+
const start = ___default.minBy(values, (value) => {
|
2728
|
+
return value.timestamp;
|
2729
|
+
});
|
2730
|
+
const end = ___default.maxBy(values, (value) => {
|
2731
|
+
return value.timestamp;
|
2732
|
+
});
|
2733
|
+
if (start && end) {
|
2734
|
+
const months = differenceInMonths(fromUnixTime(end.timestamp), fromUnixTime(start.timestamp));
|
2735
|
+
return months;
|
2736
|
+
}
|
2737
|
+
return 0;
|
2738
|
+
}
|
2739
|
+
|
2684
2740
|
const FIELD_STAT_TYPE_MAP = {
|
2685
2741
|
[AITableStatType.EarliestTime]: {
|
2686
2742
|
name: AITableGridI18nKey.earliestTime,
|
@@ -9465,7 +9521,9 @@ class AITableFieldStat {
|
|
9465
9521
|
const containerRect = coordinate.container.getBoundingClientRect();
|
9466
9522
|
const position = {
|
9467
9523
|
x: containerRect.x + statRect.x,
|
9468
|
-
y: containerRect.y + statRect.y + statRect.height - 50
|
9524
|
+
y: containerRect.y + statRect.y + statRect.height - 50,
|
9525
|
+
width: this.containerBoxWidth(),
|
9526
|
+
height: this.containerBoxHeight() + 10
|
9469
9527
|
};
|
9470
9528
|
const editFieldPosition = {
|
9471
9529
|
x: containerRect.x + fieldGroupRect.x - AI_TABLE_CELL_PADDING,
|
@@ -11082,62 +11140,6 @@ function aiTableRectConfigToKonvaConfig(rectConfig, options) {
|
|
11082
11140
|
return result;
|
11083
11141
|
}
|
11084
11142
|
|
11085
|
-
function getDateFieldValues(records, options, filterNull = false) {
|
11086
|
-
const { aiTable, field } = options;
|
11087
|
-
const result = ___default.map(records, (record) => {
|
11088
|
-
const cellValue = AITableQueries.getFieldValue(aiTable, [record._id, field._id]);
|
11089
|
-
return cellValue;
|
11090
|
-
});
|
11091
|
-
if (filterNull) {
|
11092
|
-
return result.filter((value) => value !== null);
|
11093
|
-
}
|
11094
|
-
return result;
|
11095
|
-
}
|
11096
|
-
function statEarliestTime(records, options) {
|
11097
|
-
const values = getDateFieldValues(records, options, true);
|
11098
|
-
const result = ___default.minBy(values, (value) => {
|
11099
|
-
return value.timestamp;
|
11100
|
-
});
|
11101
|
-
return transformToCellText(result, options);
|
11102
|
-
}
|
11103
|
-
function statLatestTime(records, options) {
|
11104
|
-
const { field } = options;
|
11105
|
-
const values = getDateFieldValues(records, options, true);
|
11106
|
-
const result = ___default.maxBy(values, (value) => {
|
11107
|
-
return value.timestamp;
|
11108
|
-
});
|
11109
|
-
return transformToCellText(result, options);
|
11110
|
-
}
|
11111
|
-
function statDateRangeOfDays(records, options) {
|
11112
|
-
const { field } = options;
|
11113
|
-
const values = getDateFieldValues(records, options, true);
|
11114
|
-
const start = ___default.minBy(values, (value) => {
|
11115
|
-
return value.timestamp;
|
11116
|
-
});
|
11117
|
-
const end = ___default.maxBy(values, (value) => {
|
11118
|
-
return value.timestamp;
|
11119
|
-
});
|
11120
|
-
if (start && end) {
|
11121
|
-
const days = differenceInDays(fromUnixTime(end.timestamp), fromUnixTime(start.timestamp));
|
11122
|
-
return days;
|
11123
|
-
}
|
11124
|
-
return 0;
|
11125
|
-
}
|
11126
|
-
function statDateRangeOfMonths(records, options) {
|
11127
|
-
const values = getDateFieldValues(records, options, true);
|
11128
|
-
const start = ___default.minBy(values, (value) => {
|
11129
|
-
return value.timestamp;
|
11130
|
-
});
|
11131
|
-
const end = ___default.maxBy(values, (value) => {
|
11132
|
-
return value.timestamp;
|
11133
|
-
});
|
11134
|
-
if (start && end) {
|
11135
|
-
const months = differenceInMonths(fromUnixTime(end.timestamp), fromUnixTime(start.timestamp));
|
11136
|
-
return months;
|
11137
|
-
}
|
11138
|
-
return 0;
|
11139
|
-
}
|
11140
|
-
|
11141
11143
|
function getFillDirection(aiTable, sourceCells, mouseUpRecordId) {
|
11142
11144
|
const { startCell: sourceStartCell, endCell: sourceEndCell } = getStartAndEndCell(sourceCells);
|
11143
11145
|
const currentRowIndex = aiTable.context.visibleRowsIndexMap().get(mouseUpRecordId);
|
@@ -12715,17 +12717,15 @@ class AITableDragComponent {
|
|
12715
12717
|
top: '0',
|
12716
12718
|
left: `${currentRectLeft}px`
|
12717
12719
|
});
|
12718
|
-
|
12719
|
-
|
12720
|
-
|
12721
|
-
|
12722
|
-
|
12723
|
-
|
12724
|
-
? -AI_TABLE_AUTO_SCROLL_LEFT_THRESHOLD
|
12725
|
-
: AI_TABLE_AUTO_SCROLL_LEFT_THRESHOLD);
|
12720
|
+
const currentRectLeftIsInFrozenArea = currentRectLeft <
|
12721
|
+
frozenColumnWidth +
|
12722
|
+
rowHeadWidth +
|
12723
|
+
(direction === DragDirection.left || direction === DragDirection.none
|
12724
|
+
? -AI_TABLE_AUTO_SCROLL_LEFT_THRESHOLD
|
12725
|
+
: AI_TABLE_AUTO_SCROLL_LEFT_THRESHOLD);
|
12726
12726
|
// 计算目标列和辅助线
|
12727
12727
|
const updateTargetAndLine = (rectLeft, scrollPosition) => {
|
12728
|
-
if (
|
12728
|
+
if (currentRectLeftIsInFrozenArea) {
|
12729
12729
|
// 冻结列区域内滚动,清空滚动位置
|
12730
12730
|
scrollPosition.x = 0;
|
12731
12731
|
}
|
@@ -12745,10 +12745,9 @@ class AITableDragComponent {
|
|
12745
12745
|
isLastColumn) {
|
12746
12746
|
let lineLeft = targetColumnStartX - scrollPosition.x;
|
12747
12747
|
const lineForFrozenX = lineLeft - frozenColumnWidth - rowHeadWidth;
|
12748
|
-
const rectDistanceFrozenX = rectLeft - frozenColumnWidth - rowHeadWidth;
|
12749
12748
|
if (lineForFrozenX < 0) {
|
12750
|
-
if (
|
12751
|
-
//
|
12749
|
+
if (!currentRectLeftIsInFrozenArea && lineLeft < frozenColumnWidth + rowHeadWidth) {
|
12750
|
+
// 非冻结区拖拽需要控制辅助线不要显示到冻结区,需要保持在上个位置
|
12752
12751
|
const nextColumnStartX = coordinate.getColumnOffset(targetColumnIndex + 1);
|
12753
12752
|
this.setAuxiliaryLineStyles({
|
12754
12753
|
left: `${nextColumnStartX - scrollPosition.x}px`
|
@@ -12785,7 +12784,7 @@ class AITableDragComponent {
|
|
12785
12784
|
}
|
12786
12785
|
};
|
12787
12786
|
updateTargetAndLine(currentRectLeft, newScrollPosition);
|
12788
|
-
if (
|
12787
|
+
if (currentRectLeftIsInFrozenArea) {
|
12789
12788
|
// 冻结列区域内拖拽取消滚动
|
12790
12789
|
this.scrollControllerService.stopAutoScroll();
|
12791
12790
|
return;
|