Skip to content

Commit

Permalink
feat(ConfigProvider): sfc changed to tsx (#1450)
Browse files Browse the repository at this point in the history
* feat(ConfigProvider): sfc changed to tsx

* feat(Guide): sfc changed to tsx
  • Loading branch information
anlyyao authored Jun 17, 2024
1 parent 9c4f03d commit f5f54e1
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 12 deletions.
12 changes: 12 additions & 0 deletions src/config-provider/__test__/__snapshots__/demo.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
>
<div
class="upload-demo"
data-v-41cb315a=""
Expand Down Expand Up @@ -325,6 +326,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
</div>
</div>
</div>
<div
Expand All @@ -345,6 +347,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
>
<!-- 全局配置:空数据呈现,演示 -->
<div
class="t-table t-vertical-align-middle t-table--bordered"
Expand Down Expand Up @@ -421,6 +424,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
</div>
</div>
</div>
<div
Expand All @@ -441,6 +445,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
>
<div
class="rate-demo-cell rate-demo-cell--space"
data-v-0f72cd9e=""
Expand Down Expand Up @@ -3580,6 +3585,7 @@ exports[`ConfigProvider > ConfigProvider mobileVue demo works fine 1`] = `
</teleport-stub>
</div>
</div>
</div>
Expand All @@ -3590,6 +3596,7 @@ exports[`ConfigProvider > ConfigProvider otherEnVue demo works fine 1`] = `
data-v-app=""
>
<div
class="rate-demo-cell rate-demo-cell--space"
data-v-0f72cd9e=""
Expand Down Expand Up @@ -6728,6 +6735,7 @@ exports[`ConfigProvider > ConfigProvider otherEnVue demo works fine 1`] = `
</div>
</teleport-stub>
</div>
`;

Expand All @@ -6736,6 +6744,7 @@ exports[`ConfigProvider > ConfigProvider tableEnVue demo works fine 1`] = `
data-v-app=""
>
<!-- 全局配置:空数据呈现,演示 -->
<div
class="t-table t-vertical-align-middle t-table--bordered"
Expand Down Expand Up @@ -6811,6 +6820,7 @@ exports[`ConfigProvider > ConfigProvider tableEnVue demo works fine 1`] = `
</div>
</div>
</div>
`;

Expand All @@ -6819,6 +6829,7 @@ exports[`ConfigProvider > ConfigProvider uploadEnVue demo works fine 1`] = `
data-v-app=""
>
<div
class="upload-demo"
data-v-41cb315a=""
Expand Down Expand Up @@ -7107,5 +7118,6 @@ exports[`ConfigProvider > ConfigProvider uploadEnVue demo works fine 1`] = `
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<template>
<slot />
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import config from '../config';
import { GlobalConfigProvider } from './type';
import { provideConfig } from './useConfig';
import { useTNodeJSX } from '../hooks/tnode';

const { prefix } = config;
const name = `${prefix}-config-provider`;
Expand All @@ -26,9 +22,8 @@ export default defineComponent({
setup(props) {
provideConfig(props);

return {
name,
};
const renderTNodeJSX = useTNodeJSX();

return () => <>{renderTNodeJSX('default')}</>;
},
});
</script>
2 changes: 1 addition & 1 deletion src/config-provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withInstall } from '../shared';
import _ConfigProvider from './config-provider.vue';
import _ConfigProvider from './config-provider';

export * from './type';

Expand Down
2 changes: 1 addition & 1 deletion src/config-provider/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import isString from 'lodash/isString';

import { defaultGlobalConfig, configProviderInjectKey, mergeWith } from './context';
import { GlobalConfigProvider } from './type';
import type { ConfigProviderProps } from './config-provider.vue';
import type { ConfigProviderProps } from './config-provider';

// 这是为了解决在非component里调用useConfig hook时发出的警告
// https://github.com/Tencent/tdesign-vue-next/issues/2025
Expand Down
Loading

0 comments on commit f5f54e1

Please sign in to comment.