|
14 | 14 | template(v-else) {{ title }} |
15 | 15 | div(:class="styles.Items") |
16 | 16 | template(v-if="slots.default && hasSlot(slots.default)") |
17 | | - template( |
18 | | - v-for="item, index in slots.default()", |
| 17 | + Item( |
| 18 | + v-for="item, index in slotsElms", |
19 | 19 | :key="index", |
20 | 20 | ) |
21 | | - Item( |
22 | | - v-if="item.type.toString() === 'Symbol(Fragment)' && item.el === null && item.children", |
23 | | - v-for="child, childIndex in item.children", |
24 | | - :key="`${index}-${childIndex.toString()}`", |
25 | | - ) |
26 | | - component(:is="child") |
27 | | - Item(v-else) |
28 | | - component(:is="item") |
| 21 | + component(:is="item") |
29 | 22 | slot(v-else) |
30 | 23 | div( |
31 | 24 | v-if="slots['help-text'] || helpText", |
|
38 | 31 |
|
39 | 32 | <script setup lang="ts"> |
40 | 33 | import { computed, useSlots } from 'vue'; |
| 34 | +import type { VNodeArrayChildren } from 'vue'; |
41 | 35 | import { classNames } from 'polaris/polaris-react/src/utilities/css'; |
42 | 36 | import { Item } from '../Item'; |
43 | 37 | import { hasSlot } from '@/utilities/has-slot'; |
| 38 | +import { extractElement } from '@/utilities/extract-fragment'; |
44 | 39 | import styles from '@/classes/FormLayout.json'; |
45 | 40 | import { UseUniqueId } from '@/use'; |
46 | 41 |
|
@@ -71,4 +66,16 @@ defineExpose({ name: 'FormGroup' }); |
71 | 66 | const className = computed(() => { |
72 | 67 | return classNames(props.condensed ? styles.condensed : styles.grouped); |
73 | 68 | }); |
| 69 | +
|
| 70 | +const slotsElms = computed(() => { |
| 71 | + let elms : VNodeArrayChildren = []; |
| 72 | + if (slots.default) { |
| 73 | + const groups = slots.default().map(group => { |
| 74 | + return extractElement(group); |
| 75 | + }); |
| 76 | + elms = groups.flat(); |
| 77 | + } |
| 78 | +
|
| 79 | + return elms; |
| 80 | +}); |
74 | 81 | </script> |
0 commit comments