From 519841706ab4fb0087b07150cbd1253bbb2229fe Mon Sep 17 00:00:00 2001 From: sunhao Date: Tue, 27 Aug 2024 15:09:24 +0800 Subject: [PATCH] * common-list: add getItems option to common list. --- lib/common-list/src/component/common-list.tsx | 7 +++++++ lib/common-list/src/types/common-list-props.ts | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/common-list/src/component/common-list.tsx b/lib/common-list/src/component/common-list.tsx index 81d69844c4..f331b985c0 100644 --- a/lib/common-list/src/component/common-list.tsx +++ b/lib/common-list/src/component/common-list.tsx @@ -276,6 +276,13 @@ export class CommonList

ext } else if (!Array.isArray(items)) { items = []; } + const {getItems} = props; + if (getItems) { + const result = getItems.call(this, items as Item[]); + if (result !== undefined) { + return result; + } + } return items as Item[]; } diff --git a/lib/common-list/src/types/common-list-props.ts b/lib/common-list/src/types/common-list-props.ts index 1bbfd4530b..a463b986fc 100644 --- a/lib/common-list/src/types/common-list-props.ts +++ b/lib/common-list/src/types/common-list-props.ts @@ -50,6 +50,14 @@ export interface CommonListProps extends HElementProps { */ getItem?: (item: T, index: number) => T | false | undefined; + /** + * Get items, can convert original items. + * + * @param items - The list items. + * @returns The modified list items. + */ + getItems?: (items: Item[]) => Item[] | undefined; + /** * Item render functions. */