From 71bbb34247fd5f2255dde1b0876ebc926fe13f99 Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 17 Oct 2023 17:46:10 +0800 Subject: [PATCH] fix(form:array): fix invalid ui in `ui` schema - close https://github.com/ng-alain/ng-alain/issues/2429 --- packages/form/src/sf.component.ts | 5 ++--- packages/form/src/widgets/array/index.en-US.md | 2 +- packages/form/src/widgets/array/index.zh-CN.md | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/form/src/sf.component.ts b/packages/form/src/sf.component.ts index 21f6b9a65..f6f955a03 100644 --- a/packages/form/src/sf.component.ts +++ b/packages/form/src/sf.component.ts @@ -441,13 +441,12 @@ export class SFComponent implements OnInit, OnChanges, OnDestroy { } if (property.items) { - const uiSchemaInArr = (uiSchema[uiKey] || {}).$items || {}; ui.$items = { ...(property.items.ui as SFUISchemaItem), - ...uiSchemaInArr[uiKey], + ...uiSchema[uiKey], ...ui.$items }; - inFn(property.items, property.items, uiSchemaInArr, ui.$items, ui.$items); + inFn(property.items, property.items, uiSchema[uiKey]?.$items ?? {}, ui.$items, ui.$items); } if (property.properties && Object.keys(property.properties).length) { diff --git a/packages/form/src/widgets/array/index.en-US.md b/packages/form/src/widgets/array/index.en-US.md index e90197b54..88566b542 100644 --- a/packages/form/src/widgets/array/index.en-US.md +++ b/packages/form/src/widgets/array/index.en-US.md @@ -61,6 +61,6 @@ const ui = { | `[removable]` | Whether includes remove button | `boolean` | `true` | | `[removeTitle]` | Remove button title | `string` | `remove` | | `[required]` | Add required style to current item | `boolean` | - | -| `[$items]` | UI description of array element | `SFUISchema` | `remove` | +| `[$items]` | UI description of array element | `SFUISchema` | - | | `(add)` | Add callback,`property` indicates form property after add | `(property: FormProperty) => void` | - | | `(remove)` | Remove callback | `(index: number) => void` | - | diff --git a/packages/form/src/widgets/array/index.zh-CN.md b/packages/form/src/widgets/array/index.zh-CN.md index be6622f3e..fd179a3a5 100644 --- a/packages/form/src/widgets/array/index.zh-CN.md +++ b/packages/form/src/widgets/array/index.zh-CN.md @@ -61,6 +61,6 @@ const ui = { | `[removable]` | 是否包含移除按钮 | `boolean` | `true` | | `[removeTitle]` | 移除按钮文本 | `string` | `移除` | | `[required]` | 当前项是否为必填,仅影响样式 | `boolean` | - | -| `[$items]` | 数组元素类型UI描述 | `SFUISchema` | `移除` | +| `[$items]` | 数组元素类型UI描述 | `SFUISchema` | - | | `(add)` | 添加回调,`property` 表示添加后的表单属性 | `(property: FormProperty) => void` | - | | `(remove)` | 移除回调 | `(index: number) => void` | - |