From f4b2feca272139ad70b7814e3ce5f407e07ef931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1=E8=89=B2?= Date: Thu, 1 Feb 2024 18:33:09 +0800 Subject: [PATCH] feat(abc:st): add `trackBy` property (#1760) --- .github/workflows/ci.yml | 2 +- packages/abc/st/index.en-US.md | 1 + packages/abc/st/index.zh-CN.md | 1 + packages/abc/st/st.component.html | 4 ++-- packages/abc/st/st.component.ts | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 030988959..7edacf004 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: jwalton/gh-find-current-pr@v1 + - uses: jwalton/gh-find-current-pr@master id: findPr with: state: all diff --git a/packages/abc/st/index.en-US.md b/packages/abc/st/index.en-US.md index d3134f9bf..68ba90eff 100644 --- a/packages/abc/st/index.en-US.md +++ b/packages/abc/st/index.en-US.md @@ -86,6 +86,7 @@ When an exception is thrown when parsing column data, *INVALID DATA* will be for | `[responsive]` | Whether to turn on responsive | `boolean` | `true` | ✅ | | `[responsiveHideHeaderFooter]` | Whether to display the header and footer under the small screen | `boolean` | `false` | ✅ | | `[resizable]` | Resize header of the current table, **Multiple headers not supported** | `STResizable, boolean` | - | - | +| `[trackBy]` | `TrackByFunction` function of list loop `@for` | `TrackByFunction` | - | - | | `(change)` | Events | `EventEmitter` | - | - | | `(error)` | Error event | `EventEmitter` | - | - | diff --git a/packages/abc/st/index.zh-CN.md b/packages/abc/st/index.zh-CN.md index 8e102c053..653874b6a 100644 --- a/packages/abc/st/index.zh-CN.md +++ b/packages/abc/st/index.zh-CN.md @@ -86,6 +86,7 @@ module: import { STModule } from '@delon/abc/st'; | `[responsive]` | 是否开启响应式 | `boolean` | `true` | ✅ | | `[responsiveHideHeaderFooter]` | 是否在小屏幕下才显示顶部与底部 | `boolean` | `false` | ✅ | | `[resizable]` | 当前表格所有列的调整表头配置项,**不支持多表头** | `STResizable, boolean` | - | - | +| `[trackBy]` | `@for` 列表循环的 `TrackByFunction` 函数 | `TrackByFunction` | - | - | | `(change)` | 变化时回调,包括:`pi`、`ps`、`checkbox`、`radio`、`sort`、`filter`、`click`、`dblClick`、`expand` 变动 | `EventEmitter` | - | - | | `(error)` | 异常时回调 | `EventEmitter` | - | - | diff --git a/packages/abc/st/st.component.html b/packages/abc/st/st.component.html index 7ed7489c1..559b0e934 100644 --- a/packages/abc/st/st.component.html +++ b/packages/abc/st/st.component.html @@ -55,7 +55,7 @@ > @if (showHeader) { - @for (row of _headers; track $index) { + @for (row of _headers; track row) { @if ($first && expand) { @@ -194,7 +194,7 @@ } @else { - @for (i of _data; track $index) { + @for (i of _data; track trackBy($index, i)) { } } diff --git a/packages/abc/st/st.component.ts b/packages/abc/st/st.component.ts index 9dbc73c27..863e2e290 100644 --- a/packages/abc/st/st.component.ts +++ b/packages/abc/st/st.component.ts @@ -225,6 +225,7 @@ export class STComponent implements AfterViewInit, OnChanges { @Input({ transform: numberAttribute }) virtualMinBufferPx = 100; @Input() customRequest?: (options: STCustomRequestOptions) => Observable; @Input() virtualForTrackBy: TrackByFunction = index => index; + @Input() trackBy: TrackByFunction = (_, item) => item; /** * Get the number of the current page