Skip to content

Commit

Permalink
improve(ui): ProTable should inherit style from Table
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Apr 8, 2024
1 parent 0dba270 commit b370188
Show file tree
Hide file tree
Showing 19 changed files with 1,225 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export default defineConfig({
{ title: 'Welcome 欢迎页', link: '/biz-components/welcome' },
],
},
{
title: 'ProComponents 组件',
children: [{ title: 'ProTable 高级表格', link: '/biz-components/pro-table' }],
},
{
title: '可视化',
children: [
Expand Down
2 changes: 2 additions & 0 deletions packages/design/src/config-provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
ThemeConfig as AntThemeConfig,
} from 'antd/es/config-provider';
import type { ComponentStyleConfig } from 'antd/es/config-provider/context';
import type { PaginationConfig } from 'antd/es/pagination';
import type { SpinIndicator } from 'antd/es/spin';
import { StyleProvider } from '@ant-design/cssinjs';
import type { StyleProviderProps } from '@ant-design/cssinjs';
Expand Down Expand Up @@ -58,6 +59,7 @@ export interface ConfigProviderProps extends AntConfigProviderProps {
// for react-router-dom v6: navigate
navigate?: NavigateFunction;
hideOnSinglePage?: boolean;
pagination?: PaginationConfig;
spin?: SpinConfig;
table?: TableConfig;
// inject static function to consume ConfigProvider
Expand Down
12 changes: 3 additions & 9 deletions packages/design/src/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@ type CompoundedComponent = React.FC<FormProps> & {
create: typeof AntForm.create;
};

const Form: CompoundedComponent = ({ hideRequiredMark, ...restProps }) => {
const Form: CompoundedComponent = props => {
const { form: contextForm } = useContext(ConfigProvider.ConfigContext);
return (
// @ts-ignore to ignore children type error
<AntForm
requiredMark={
// could remove hideRequiredMark logic after https://github.com/ant-design/ant-design/pull/46299 is published
hideRequiredMark
? false
: contextForm?.requiredMark !== undefined
? contextForm?.requiredMark
: 'optional'
contextForm?.requiredMark !== undefined ? contextForm?.requiredMark : 'optional'
}
hideRequiredMark={hideRequiredMark}
preserve={false}
{...restProps}
{...props}
/>
);
};
Expand Down
4 changes: 4 additions & 0 deletions packages/design/src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default {
...enUS.global,
inputPlaceholder: 'Please enter',
},
Pagination: {
...enUS.Pagination,
total: '${total} in Total',
},
Drawer: {
okText: 'OK',
cancelText: 'Cancel',
Expand Down
6 changes: 6 additions & 0 deletions packages/design/src/locale/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Locale as AntLocale } from 'antd/es/locale';
import type { PaginationLocale as AntPaginationLocale } from 'antd/es/pagination/Pagination';
import type { DrawerLocale } from '../drawer';
import type { InputLocale } from '../input';
import type { InputNumberLocale } from '../input-number';
Expand All @@ -12,8 +13,13 @@ export type GlobalLocale = AntLocale['global'] & {
inputPlaceholder?: string;
};

export interface PaginationLocale extends AntPaginationLocale {
total?: string;
}

export interface Locale extends AntLocale {
global?: GlobalLocale;
Pagination?: PaginationLocale;
Drawer?: DrawerLocale;
Input?: InputLocale;
InputNumber?: InputNumberLocale;
Expand Down
4 changes: 4 additions & 0 deletions packages/design/src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default {
...zhCN.global,
inputPlaceholder: '请输入',
},
Pagination: {
...zhCN.Pagination,
total: '共 ${total} 条',
},
Drawer: {
okText: '确定',
cancelText: '取消',
Expand Down
4 changes: 4 additions & 0 deletions packages/design/src/locale/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default {
...zhTW.global,
inputPlaceholder: '請輸入',
},
Pagination: {
...zhTW.Pagination,
total: '共 ${total} 條',
},
Drawer: {
okText: '确定',
cancelText: '取消',
Expand Down
Loading

0 comments on commit b370188

Please sign in to comment.