From 39b69d5bd003d1770c78c093e8de9a23e5ec5585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B1=9F=E8=BE=B0?= Date: Tue, 7 Jan 2025 10:51:03 +0800 Subject: [PATCH] fix(descriptions): fixes the issue related to the layout distribution of span (#3409) --- .../components/descriptions/README.en-US.md | 4 +- .../components/descriptions/README.zh-CN.md | 4 +- .../components/descriptions/TEMPLATE.md | 2 + .../descriptions/__demo__/example.md | 102 +++++++++++++++ .../__test__/__snapshots__/demo.test.ts.snap | 116 +++++++++++++++++- .../components/descriptions/context.ts | 10 -- .../descriptions/descriptions-item.vue | 52 +------- .../components/descriptions/descriptions.tsx | 103 +++++----------- .../components/descriptions/interface.ts | 1 + 9 files changed, 257 insertions(+), 137 deletions(-) create mode 100644 packages/web-vue/components/descriptions/__demo__/example.md delete mode 100644 packages/web-vue/components/descriptions/context.ts diff --git a/packages/web-vue/components/descriptions/README.en-US.md b/packages/web-vue/components/descriptions/README.en-US.md index 331fccd05..81a2b75e0 100644 --- a/packages/web-vue/components/descriptions/README.en-US.md +++ b/packages/web-vue/components/descriptions/README.en-US.md @@ -18,6 +18,8 @@ description: Generally used for the information display of the detail page. @import ./__demo__/layout.md +@import ./__demo__/example.md + ## API @@ -67,6 +69,6 @@ description: Generally used for the information display of the detail page. |---|---|---|:---:| |label|Label|`string \| RenderFunction`|`-`| |value|Data|`string \| RenderFunction`|`-`| -|span|number of columns|`number`|`-`| +|span|number of columns|`number`|`1`| diff --git a/packages/web-vue/components/descriptions/README.zh-CN.md b/packages/web-vue/components/descriptions/README.zh-CN.md index 26b180627..d6d3e6e19 100644 --- a/packages/web-vue/components/descriptions/README.zh-CN.md +++ b/packages/web-vue/components/descriptions/README.zh-CN.md @@ -16,6 +16,8 @@ description: 一般用于详情页的信息展示。 @import ./__demo__/layout.md +@import ./__demo__/example.md + ## API @@ -65,6 +67,6 @@ description: 一般用于详情页的信息展示。 |---|---|---|:---:| |label|标签|`string \| RenderFunction`|`-`| |value|数据|`string \| RenderFunction`|`-`| -|span|所占列数|`number`|`-`| +|span|所占列数|`number`|`1`| diff --git a/packages/web-vue/components/descriptions/TEMPLATE.md b/packages/web-vue/components/descriptions/TEMPLATE.md index bd47a4032..3eebdc89f 100644 --- a/packages/web-vue/components/descriptions/TEMPLATE.md +++ b/packages/web-vue/components/descriptions/TEMPLATE.md @@ -27,6 +27,8 @@ description: Generally used for the information display of the detail page. @import ./__demo__/layout.md +@import ./__demo__/example.md + ## API %%API(descriptions.tsx)%% diff --git a/packages/web-vue/components/descriptions/__demo__/example.md b/packages/web-vue/components/descriptions/__demo__/example.md new file mode 100644 index 000000000..436b11cd0 --- /dev/null +++ b/packages/web-vue/components/descriptions/__demo__/example.md @@ -0,0 +1,102 @@ +```yaml +title: + zh-CN: 布局示例 + en-US: Layout Example +``` + +## zh-CN +`span` 所占列数大于 `column` 可放置的数据个数时,`span` 会被设置为 `column` 的值,当行剩余列数不够放置下一列时将自动换行,每行末尾列会自动填充剩余量。 + +--- + +## en-US +When the number of columns occupied by `span` is greater than the number of data that can be placed in `column`, `span` will be set to the value of `column`. When the remaining columns in the row are not enough to place the next column, it will automatically wrap, and the last column of each row will automatically fill the remaining amount. + +--- + +```vue + + + +``` diff --git a/packages/web-vue/components/descriptions/__test__/__snapshots__/demo.test.ts.snap b/packages/web-vue/components/descriptions/__test__/__snapshots__/demo.test.ts.snap index 8b1ab6ab6..427a0a8d7 100644 --- a/packages/web-vue/components/descriptions/__test__/__snapshots__/demo.test.ts.snap +++ b/packages/web-vue/components/descriptions/__test__/__snapshots__/demo.test.ts.snap @@ -142,17 +142,17 @@ exports[` demo: render [basic] correctly 1`] = ` Name - Socrates + Socrates Mobile 123-1234-1234 + + Residence Beijing Hometown Beijing - - Address - Yingdu Building, Zhichun Road, Beijing + Yingdu Building, Zhichun Road, Beijing @@ -188,6 +188,114 @@ exports[` demo: render [bordered] correctly 1`] = ` " `; +exports[` demo: render [example] correctly 1`] = ` +"
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
Layout Example
+
+ + + + + + + + + + + + + + + + + + + + + +
Item1 +
Span:2 + +
+
Item2Span:2
Item3Span:3
Item4Span:2Item5Span:1Item6Span:1
+
+
+
" +`; + exports[` demo: render [layout] correctly 1`] = ` "
diff --git a/packages/web-vue/components/descriptions/context.ts b/packages/web-vue/components/descriptions/context.ts deleted file mode 100644 index de8a9c69a..000000000 --- a/packages/web-vue/components/descriptions/context.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { InjectionKey } from 'vue'; -import { DescItemData } from './interface'; - -export interface DescriptionsContext { - addItem: (id: number, data: DescItemData) => void; - removeItem: (id: number) => void; -} - -export const descriptionsInjectionKey: InjectionKey = - Symbol('ArcoDescriptions'); diff --git a/packages/web-vue/components/descriptions/descriptions-item.vue b/packages/web-vue/components/descriptions/descriptions-item.vue index 20e4db452..725c53e74 100644 --- a/packages/web-vue/components/descriptions/descriptions-item.vue +++ b/packages/web-vue/components/descriptions/descriptions-item.vue @@ -3,20 +3,8 @@