Skip to content

Commit 0fa333b

Browse files
authored
docs: fix slot warning of setup demo (#372)
1 parent 39eb2f4 commit 0fa333b

File tree

9 files changed

+29
-22
lines changed

9 files changed

+29
-22
lines changed

docs/examples-setup/bubble/bubble-custom.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const roles: BubbleListProps['roles'] = {
2727
},
2828
},
2929
loadingRender: () =>
30-
h(Space, null, [h(Spin, { size: 'small' }), 'Custom loading...']),
30+
h(Space, null, () => [h(Spin, { size: 'small' }), 'Custom loading...']),
3131
},
3232
user: {
3333
placement: 'end',
@@ -49,7 +49,7 @@ const listRef = ref<InstanceType<typeof BubbleList>>(null);
4949
key: 'welcome',
5050
role: 'ai',
5151
content: 'Mock welcome content. '.repeat(10),
52-
footer: h(Flex, null, [
52+
footer: h(Flex, null, () => [
5353
h(Button, {
5454
size: 'small',
5555
type: 'text',

docs/examples-setup/bubble/list-custom.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const roles: BubbleListProps['roles'] = {
3333
h(
3434
Flex,
3535
{ vertical: true, gap: 'middle' },
36-
items.map((item: any) =>
36+
() => items.map((item: any) =>
3737
h(Attachments.FileCard, { key: item.uid, item: item }),
3838
),
3939
),
@@ -56,7 +56,7 @@ const roles: BubbleListProps['roles'] = {
5656
{
5757
key: 1,
5858
role: 'ai',
59-
content: h(Typography.Text, { type: 'danger' }, 'ReactNode message'),
59+
content: h(Typography.Text, { type: 'danger' }, () => 'ReactNode message'),
6060
},
6161
6262
// Role: suggestion

docs/examples-setup/bubble/list.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const rolesAsObject: BubbleListProps['roles'] = {
2525
2626
const rolesAsFunction = (bubbleData: BubbleProps, index: number) => {
2727
const RenderIndex: BubbleProps['messageRender'] = (content) =>
28-
h(Flex, null, [h('text', null, `#${index}: ${content}`)]);
29-
switch (bubbleData.role) {
28+
h(Flex, null, () => [h('text', null, `#${index}: ${content}`)]);
29+
switch (bubbleData.role) {
3030
case 'ai':
3131
return {
3232
placement: 'start' as const,

docs/examples-setup/sender/headerFixed.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { EnterOutlined } from '@ant-design/icons-vue';
33
import { App, Flex, Space, Switch, Typography, message } from 'ant-design-vue';
44
import { Sender } from 'ant-design-x-vue';
5-
import { computed, ref, h } from 'vue';
5+
import { ref, h } from 'vue';
66
77
defineOptions({ name: 'AXSenderHeaderFixedSetup' });
88
@@ -11,16 +11,16 @@ const hasRef = ref(true);
1111
const [messageApi, contextHolder] = message.useMessage();
1212
1313
const toggleChecked = () => {
14-
hasRef.value =!hasRef.value;
14+
hasRef.value =!hasRef.value;
1515
}
1616
17-
const openChange = (v) => {
17+
const openChange = (v: boolean) => {
1818
hasRef.value = v;
1919
}
2020
21-
const headerTitle = h(Space, {}, [
21+
const headerTitle = h(Space, {}, () => [
2222
h(EnterOutlined),
23-
h(Typography.Text, { type: 'secondary' }, '"Tell more about Ant Design X"')
23+
h(Typography.Text, { type: 'secondary' }, () => '"Tell more about Ant Design X"')
2424
])
2525
</script>
2626
<template>

docs/examples-setup/sender/pasteImage.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
<script setup lang="ts">
22
import { CloudUploadOutlined, LinkOutlined } from '@ant-design/icons-vue';
33
import { App, Button, Flex } from 'ant-design-vue';
4-
import { Attachments, Sender } from 'ant-design-x-vue';
5-
import { computed, ref, h } from 'vue';
4+
import { Attachments, AttachmentsProps, Sender, SenderProps } from 'ant-design-x-vue';
5+
import { ref, h } from 'vue';
66
77
defineOptions({ name: 'AXSenderPasteImageSetup' });
88
9+
type GetFunction<T> = T extends (...args: any[]) => any ? T : never;
10+
type PlaceholderType = Parameters<GetFunction<AttachmentsProps['placeholder']>>[0];
11+
type PastFile = SenderProps['onPasteFile'];
12+
type FileChange = AttachmentsProps['onChange'];
13+
914
const open = ref(false);
1015
const items = ref([]);
1116
const text = ref('');
1217
1318
const attachmentsRef = ref(null);
1419
const senderRef = ref<InstanceType<typeof Sender>>(null);
1520
16-
const placeholder = (type) =>
21+
const placeholder = (type: PlaceholderType) =>
1722
type === 'drop'
1823
? {
1924
title: 'Drop file here',
@@ -26,7 +31,7 @@ const placeholder = (type) =>
2631
2732
const getDropContainer = () => senderRef.value?.nativeElement;
2833
29-
const pastFile = (_, files) => {
34+
const pastFile: PastFile = (_, files) => {
3035
console.log("past")
3136
for (const file of files) {
3237
attachmentsRef.value?.upload(file);
@@ -36,10 +41,10 @@ const pastFile = (_, files) => {
3641
3742
const submit = () => {
3843
items.value = [];
39-
text.value = '';
44+
text.value = '';
4045
}
4146
42-
const fileChange = ({ fileList }) => items.value = fileList
47+
const fileChange: FileChange = ({ fileList }) => items.value = fileList
4348
</script>
4449
<template>
4550
<App>

docs/examples-setup/sender/speechCustom.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<script setup lang="ts">
22
import { App, message } from 'ant-design-vue';
3-
import { Sender } from 'ant-design-x-vue';
3+
import { Sender, SenderProps } from 'ant-design-x-vue';
44
import { ref, computed } from 'vue';
55
66
defineOptions({ name: 'AXSenderSpeechCustomSetup' });
77
8+
type SpeechConfig = SenderProps['allowSpeech'];
9+
810
const [messageApi, contextHolder] = message.useMessage();
911
const recording = ref(false);
1012
1113
const submit = () => {
1214
messageApi.success('Send message successfully!');
1315
}
1416
15-
const speechConfig = computed(
17+
const speechConfig = computed<SpeechConfig>(
1618
() => ({
1719
// When setting `recording`, the built-in speech recognition feature will be disabled
1820
recording: recording.value,

docs/examples-setup/use-x-agent/preset.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async function request() {
8787
status === 'error' &&
8888
agent.config.baseURL === BASE_URL + PATH &&
8989
'Please replace the BASE_URL, PATH, MODEL, API_KEY with your own values.',
90-
content: h(Descriptions, { column: 1 }, [
90+
content: h(Descriptions, { column: 1 }, () => [
9191
h(
9292
Descriptions.Item,
9393
{

docs/examples-setup/x-request/basic.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function request() {
7474
status === 'error' &&
7575
exampleRequest.baseURL === BASE_URL + PATH &&
7676
'Please replace the BASE_URL, PATH, MODEL, API_KEY with your own values.',
77-
content: h(Descriptions, { column: 1 }, [
77+
content: h(Descriptions, { column: 1 }, () => [
7878
h(Descriptions.Item, { label: 'Status' }, status || '-'),
7979
h(Descriptions.Item, { label: 'Update Times' }, lines.length.toString())
8080
]),

src/bubble/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface TypingOption {
1515
/**
1616
* @default null
1717
*/
18-
suffix?: VNode;
18+
suffix?: VNode | string;
1919
}
2020

2121
export type SemanticType = 'avatar' | 'content' | 'header' | 'footer';

0 commit comments

Comments
 (0)