From 5d7503bf51fe2fea508fba6e21bf8f06c29638f8 Mon Sep 17 00:00:00 2001 From: kousum Date: Mon, 16 Dec 2024 13:56:40 +0800 Subject: [PATCH] fix: Add the necessary expose --- packages/semi-ui-vue/src/App.tsx | 9 +- .../jsonViewer/__test__/JsonViewerDemo.tsx | 18 ++-- .../src/components/jsonViewer/index.tsx | 7 +- .../components/toast/__test__/ToastDemo.tsx | 84 +++++++++++-------- .../src/components/withVModel/WithVModel.tsx | 5 +- pnpm-lock.yaml | 3 + 6 files changed, 81 insertions(+), 45 deletions(-) diff --git a/packages/semi-ui-vue/src/App.tsx b/packages/semi-ui-vue/src/App.tsx index 359b04f7..a3f39699 100755 --- a/packages/semi-ui-vue/src/App.tsx +++ b/packages/semi-ui-vue/src/App.tsx @@ -167,6 +167,7 @@ import TreeCheckSimpleJsonDemo from './components/tree/__test__/TreeCheckSimpleJ import DragMoveDemo from './components/dragMove/__test__/DragMoveDemo'; import JsonViewerDemo from './components/jsonViewer/__test__/JsonViewerDemo'; import SelectTest from './components/select/__test__/SelectTest'; +import { InputVModel } from './components'; export interface ExampleProps { name?: string @@ -189,9 +190,15 @@ const App = defineComponent((props, {slots}) => { // }) // console.log(ConfigProvider); const a = ref('sdsd') + const testRef = ref() + watch(testRef, (v)=>{ + console.log(v, v?.getRef()); + }) return () => (
+ {a.value} + {/**/} {/**/} {/**/} @@ -328,7 +335,7 @@ const App = defineComponent((props, {slots}) => { {/**/} {/**/} {/**/} - + {/**/} {/**/} {/**/} {/**/} diff --git a/packages/semi-ui-vue/src/components/jsonViewer/__test__/JsonViewerDemo.tsx b/packages/semi-ui-vue/src/components/jsonViewer/__test__/JsonViewerDemo.tsx index ef3a7282..c05ba571 100644 --- a/packages/semi-ui-vue/src/components/jsonViewer/__test__/JsonViewerDemo.tsx +++ b/packages/semi-ui-vue/src/components/jsonViewer/__test__/JsonViewerDemo.tsx @@ -1,4 +1,4 @@ -import { defineComponent, ref, h, Fragment, useSlots } from 'vue'; +import { defineComponent, ref, h, Fragment, useSlots, onMounted, nextTick } from 'vue'; import { CombineProps } from '../../interface'; import JsonViewer from '../index'; @@ -6,10 +6,10 @@ interface JsonViewerDemoProps { name?: string; } -const data = `{ - "name": "Semi", - "version": "0.0.0" -}`; +const data = '{' + + '"name": "Semi",' + + '"version": "0.0.0"' + + '}'; export const vuePropsType: CombineProps = { name: String, }; @@ -18,11 +18,17 @@ const JsonViewerDemo = defineComponent({ name: 'JsonViewerDemo', setup(props, { attrs }) { const slots = useSlots(); + const j = ref() + onMounted(()=>{ + nextTick(()=>{ + // j.value?.format() + }) + }) return () => (
- +
); }, diff --git a/packages/semi-ui-vue/src/components/jsonViewer/index.tsx b/packages/semi-ui-vue/src/components/jsonViewer/index.tsx index 9e1ee0b5..3ab6cd0b 100644 --- a/packages/semi-ui-vue/src/components/jsonViewer/index.tsx +++ b/packages/semi-ui-vue/src/components/jsonViewer/index.tsx @@ -90,7 +90,7 @@ export const vuePropsType = vuePropsMake(propTypes, defaultProps); const JsonViewerCom = defineComponent({ props: { ...vuePropsType }, name: 'JsonViewerCom', - setup(props, { attrs }) { + setup(props, { expose, attrs }) { const slots = useSlots(); const state = reactive({ searchOptions: { @@ -155,6 +155,11 @@ const JsonViewerCom = defineComponent({ foundation.jsonViewer.format(); } + expose({ + getValue, + format, + }) + function getStyle() { const { width, height } = props; return { diff --git a/packages/semi-ui-vue/src/components/toast/__test__/ToastDemo.tsx b/packages/semi-ui-vue/src/components/toast/__test__/ToastDemo.tsx index 5cb09a9b..5e3ca63b 100644 --- a/packages/semi-ui-vue/src/components/toast/__test__/ToastDemo.tsx +++ b/packages/semi-ui-vue/src/components/toast/__test__/ToastDemo.tsx @@ -12,7 +12,7 @@ export const vuePropsType = { } const ToastDemo = defineComponent((props, {}) => { const slots = useSlots() - const Toast = useToastHook() + // const Toast = useToastHook() const id = Toast.info({ content:
useToastHook
}) @@ -46,46 +46,58 @@ const ToastDemo = defineComponent((props, {}) => { title: 'This is a success message', content: 123, }; - return () => ( -
- - { - instance?.add({...{ - motion: true, - zIndex: 1010, - content: 'test', - }, id: 'id'}); - }}/> + return () => { + + return + return (
- -
- - -
- - + { + instance?.add({...{ + motion: true, + zIndex: 1010, + content: 'test', + }, id: 'id'}); + }}/>
- + +
+ + +
+ + + +
+ +
+ {contextHolder.value}
- {contextHolder.value}
-
- ) + ) + } }) diff --git a/packages/semi-ui-vue/src/components/withVModel/WithVModel.tsx b/packages/semi-ui-vue/src/components/withVModel/WithVModel.tsx index b6ed52af..bb9fd650 100644 --- a/packages/semi-ui-vue/src/components/withVModel/WithVModel.tsx +++ b/packages/semi-ui-vue/src/components/withVModel/WithVModel.tsx @@ -16,13 +16,16 @@ export default function WithVModel(Comp: DefineSetupFnComponent, opt?: Wit const instance = ref(); expose({ - ...instance.value, + getRef(){ + return instance.value + }, }); return () => { if (props['onUpdate:modelValue']) { return ( //@ts-ignore