ant-design/components/config-provider/defaultRenderEmpty.tsx

52 lines
1.4 KiB
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
import type { ConfigConsumerProps } from '.';
chore: migrate to vitest (#42506) * chore: migrate to vitest * chore: update ci * fix: test correctly * test: support puppeteer * chore: update coverage * chore: update include/exclude * chore: update config * test: update incorrect tests * chore: update script * chore: update * fix: should close browser at the ended * chore: improve * fix: test cause tsc error * fix: eslint error * chore: exclude correctly * test: update snap and fix some tests * chore: update test config * fix: countup.js * fix: incorrect test * chore: update reference * test: update * fix: countup.js * fix: timeout * chore: update site test * fix: fixed countup version * chore: remove unsed code * test: update * test: update demo timeout * test: update timeout * chore: update image test * chore: update threads * fix: image/svg+xml test failed * chore: limits threads * test: update test coverage include * chore: remove jest files * chore: rename jest to vi * chore: update document * chore: fix missing @types/jsdom * chore: update coverage * chore: update snap * fix:watermark test cases are incorrect * feat: update ignore comment * test: fix test case * test: reset body scrollTop * test: clean up * test: use vi * test: update snapshot * test: update snapshot * test: fix dropdown test failed * fix: toHaveStyle cause test fail * test: improve test case * test: fix * fix: color failed, refer to https://github.com/jsdom/jsdom/pull/3560 * test: fix * test: fix * test: fix circular import * test: revert * ci: coverage failed * test: fix c8 ignore comment * chore: incorrect config * chore: fix ignore ci * test: revert svg+xml * test: fix realTimers * feat: rc-trigger should be remove * test: fix some failed test * chore: remove unused deps and configure eslint-plugin-vitest * test: update snap * chore: remove jest * test: fix lint error --------- Co-authored-by: 二货机器人 <smith3816@gmail.com> Co-authored-by: afc163 <afc163@gmail.com>
2023-06-07 11:54:50 +08:00
import { ConfigContext } from '.';
2022-06-22 14:57:09 +08:00
import Empty from '../empty';
2018-12-26 16:01:00 +08:00
type ComponentName =
| 'Table'
| 'Table.filter' /* 👈 5.20.0+ */
| 'List'
| 'Select'
| 'TreeSelect'
| 'Cascader'
| 'Transfer'
| 'Mentions';
interface EmptyProps {
componentName?: ComponentName;
}
2018-12-26 16:01:00 +08:00
const DefaultRenderEmpty: React.FC<EmptyProps> = (props) => {
const { componentName } = props;
const { getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext);
const prefix = getPrefixCls('empty');
switch (componentName) {
case 'Table':
case 'List':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />;
case 'Select':
case 'TreeSelect':
case 'Cascader':
case 'Transfer':
case 'Mentions':
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} className={`${prefix}-small`} />;
feat(table-filter): support custom Empty (#49613) * fix: Table empty node in filter dropdown not following ConfigProvider renderEmpty (#49548) * 修复自定义全局组件,过滤里面没有生效 * 新增测试用例 * 重新提交测试用例 * 测试用例添加断言判断 * update Table.filter.test.tsx * commit snapshot * update Table.filter.test.tsx * update Table.filter.test.tsx * update Table.filter.test.tsx (cherry picked from commit 7790934b0bbb9684eed50844cb616fd3a77dea70) * chore: update case * feat(table-filter): support custom Empty * chore(type): improve TS type definition (#49602) (cherry picked from commit a15fcfa1dc40274f5a38d0766ed3020f9b3caa32) * fixup! feat(table-filter): support custom Empty * Squashed commit of the following: commit 1b9706f22d0e4022fedde8a2db0fee6420e25432 Merge: e76e386966 cc54bef826 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed Jun 26 10:10:48 2024 +0000 chore: auto merge branches (#49609) chore: sync master to feature commit cc54bef826c12454ccf832bdaccdbc5d3442b4b8 Author: 照明胧 <25151442+mmmml-zhao@users.noreply.github.com> Date: Wed Jun 26 14:19:22 2024 +0800 fix: The emptyText field of the table (#49599) * fix: The emptyText field of the table when emptyText is null * test: update test case(#49599) commit ff7fea18f379ab7e20b2a8f3f1a7d60c2a7bf030 Author: afc163 <afc163@gmail.com> Date: Wed Jun 26 12:40:24 2024 +0800 Revert "bug: fix-table-bug ref filters" (#49600) This reverts commit 7790934b0bbb9684eed50844cb616fd3a77dea70. commit a15fcfa1dc40274f5a38d0766ed3020f9b3caa32 Author: 红 <wxh1220@gmail.com> Date: Wed Jun 26 12:40:11 2024 +0800 chore(type): improve TS type definition (#49602) commit 9ce5cbcf6436303f6911d842d56cf2758d0526b1 Author: Andrey <aaa144855@gmail.com> Date: Wed Jun 26 06:05:39 2024 +0300 fix: remove redundant transformations in ```UploadList```, which led to decrease in performance (#49598) * fix: remove unnecessary transformations for upload list with previews * chore: revert miss convert --------- Co-authored-by: 二货机器人 <smith3816@gmail.com> commit 4145305b16a67e310b1156cd5b84c629ad2ad232 Author: MadCcc <madccc@foxmail.com> Date: Tue Jun 25 16:59:30 2024 +0800 docs: fix site FOUC (#49595) commit 44e96b7b0649bf15ce37ed30679f7c81f30b49c2 Author: enhongchen <106970098+enhongchen@users.noreply.github.com> Date: Tue Jun 25 14:24:14 2024 +0800 docs: Update use-with-rsbuild.zh-CN.md (#49592) https://ant.design/docs/react/use-with-rsbuild-cn?theme=happy-work#%E5%AE%89%E8%A3%85%E5%92%8C%E5%88%9D%E5%A7%8B%E5%8C%96 Signed-off-by: enhongchen <106970098+enhongchen@users.noreply.github.com> commit 6a0af781d14b3be5c537267c59ed35b25b201314 Author: 红 <wxh1220@gmail.com> Date: Tue Jun 25 13:34:28 2024 +0800 chore: improve tabs demo (#49590) ref: https://docs.dndkit.com/presets/sortable#collision-detection-algorithm commit 7127603b76796316426546d8f544abdd272ab4e9 Author: Tantatorn Suksangwarn <timefear007@gmail.com> Date: Tue Jun 25 12:32:59 2024 +0700 fix: add missing Thai translations (#49588) commit 7790934b0bbb9684eed50844cb616fd3a77dea70 Author: duqigit <916475145@qq.com> Date: Tue Jun 25 10:44:43 2024 +0800 fix: Table empty node in filter dropdown not following ConfigProvider renderEmpty (#49548) * 修复自定义全局组件,过滤里面没有生效 * 新增测试用例 * 重新提交测试用例 * 测试用例添加断言判断 * update Table.filter.test.tsx * commit snapshot * update Table.filter.test.tsx * update Table.filter.test.tsx * update Table.filter.test.tsx commit b09913db068f2ad79db50d70c2b637c433d9dec3 Author: lijianan <574980606@qq.com> Date: Tue Jun 25 10:42:19 2024 +0800 test: update test case code (#49585) commit b420c573540312aad01c2a2def6b9ca360baa380 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue Jun 25 10:39:47 2024 +0800 chore(deps): bump oven-sh/setup-bun from 1 to 2 (#49578) Bumps [oven-sh/setup-bun](https://github.com/oven-sh/setup-bun) from 1 to 2. - [Release notes](https://github.com/oven-sh/setup-bun/releases) - [Commits](https://github.com/oven-sh/setup-bun/compare/v1...v2) --- updated-dependencies: - dependency-name: oven-sh/setup-bun dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> commit a81603d7209f2802438e0f437454266a54c58028 Author: afc163 <afc163@gmail.com> Date: Mon Jun 24 13:33:56 2024 +0800 docs: fix nav menu cannot click (#49569) * chore: remove * test: add more unit test * chore: lint * chore: fix legacy16 bug * chore: update logic * test: update unit test --------- Co-authored-by: duqigit <916475145@qq.com>
2024-07-01 17:47:59 +08:00
/**
* This type of component should satisfy the nullish coalescing operator(??) on the left-hand side.
* to let the component itself implement the logic.
* For example `Table.filter`.
*/
case 'Table.filter':
// why `null`? legacy react16 node type `undefined` is not allowed.
return null;
default:
// Should never hit if we take all the component into consider.
return <Empty />;
}
};
2018-12-26 16:01:00 +08:00
export type RenderEmptyHandler = (componentName?: ComponentName) => React.ReactNode;
export default DefaultRenderEmpty;