Skip to content

Commit

Permalink
feat: 新增 SmartDescriptions 组件
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 改名 ProDescriptions 为 SmartDescriptions
  • Loading branch information
tolerance-go committed Apr 14, 2024
1 parent 2694644 commit 162fd95
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 53 deletions.
6 changes: 3 additions & 3 deletions src/FullscreenImage/demos/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { DrawerForm, FullscreenImage, ProDescriptions, SearchTable } from 'widgets-v3';
import { DrawerForm, FullscreenImage, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';
import img1 from './img1.webp';
import img2 from './img2.webp';
Expand Down Expand Up @@ -81,7 +81,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -161,7 +161,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
2 changes: 1 addition & 1 deletion src/FullscreenImage/demos/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { DrawerForm, FullscreenImage, ProDescriptions, SearchTable } from 'widgets-v3';
import { DrawerForm, FullscreenImage, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';
import img1 from './img1.webp';

Expand Down
2 changes: 1 addition & 1 deletion src/SchemaDescriptions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ group:

# SchemaDescriptions

内部组件,请用 ProDescriptions
内部组件,请用 SmartDescriptions

目标是用 json 来描述展示数据的视图

Expand Down
6 changes: 3 additions & 3 deletions src/SearchTable/demos/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { DrawerForm, ProDescriptions, SearchTable } from 'widgets-v3';
import { DrawerForm, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';

const residences = [
Expand Down Expand Up @@ -72,7 +72,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -152,7 +152,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SearchTable/demos/requestData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { DrawerForm, ProDescriptions, SearchTable } from 'widgets-v3';
import { DrawerForm, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';

const residences = [
Expand Down Expand Up @@ -80,7 +80,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -160,7 +160,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SearchTable/demos/row-selection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { Action, DrawerForm, ProDescriptions, SearchTable } from 'widgets-v3';
import { Action, DrawerForm, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';

const residences = [
Expand Down Expand Up @@ -131,7 +131,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -211,7 +211,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SearchTable/demos/throwError.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import React from 'react';
import { DrawerForm, ProDescriptions, SearchTable } from 'widgets-v3';
import { DrawerForm, SmartDescriptions, SearchTable } from 'widgets-v3';
import delay from 'delay';

const residences = [
Expand Down Expand Up @@ -72,7 +72,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -152,7 +152,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SelectableTable/demos/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
EditableGroups,
GroupsForm,
SelectableTable,
ProDescriptions,
SmartDescriptions,
} from 'widgets-v3';
import delay from 'delay';

Expand Down Expand Up @@ -127,7 +127,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -219,7 +219,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SelectableTable/demos/methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
EditableGroups,
GroupsForm,
SelectableTable,
ProDescriptions,
SmartDescriptions,
SelectableTableMethods,
} from 'widgets-v3';
import delay from 'delay';
Expand Down Expand Up @@ -132,7 +132,7 @@ export default () => {
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -224,7 +224,7 @@ export default () => {
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SelectableTable/demos/params.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from 'react';
import {
BackendFilteredSelectListItem,
DrawerForm,
ProDescriptions,
SmartDescriptions,
SmartForm,
SelectableTable,
} from 'widgets-v3';
Expand Down Expand Up @@ -91,7 +91,7 @@ export default () => {
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -183,7 +183,7 @@ export default () => {
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
6 changes: 3 additions & 3 deletions src/SelectableTable/demos/radioSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import {
BackendFilteredSelectListItem,
DrawerForm,
ProDescriptions,
SmartDescriptions,
SmartForm,
SelectableTable,
} from 'widgets-v3';
Expand Down Expand Up @@ -124,7 +124,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -216,7 +216,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import delay from 'delay';
import React from 'react';
import { ProDescriptions } from 'widgets-v3';
import { SmartDescriptions } from 'widgets-v3';

export default () => (
<>
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand All @@ -18,9 +18,9 @@ export default () => (
{(data) => {
return <div>{JSON.stringify(data)}</div>;
}}
</ProDescriptions>
</SmartDescriptions>

<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand All @@ -33,6 +33,6 @@ export default () => (
{(data) => {
return [<div key={1}>{JSON.stringify(data)}</div>, <div key={2}>{JSON.stringify(data)}</div>];
}}
</ProDescriptions>
</SmartDescriptions>
</>
);
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Button, Cascader, Form, Icon, Input, Tooltip } from 'antd';
import delay from 'delay';
import React from 'react';
import { ProDescriptions } from 'widgets-v3';
import { SmartDescriptions } from 'widgets-v3';

export default () => (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -121,5 +121,5 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ group:
order: 6
---

# ProDescriptions
# SmartDescriptions

## 基本使用

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ export interface RequestParams<T> {}

export interface RequestResult<T> {}

export type ProDescriptionsProps<T> = {
export type SmartDescriptionsProps<T> = {
request?: (params: RequestParams<T>) => Promise<RequestResult<T>>;
children?: (dataSource?: Record<string, any>) => ReactNode | DescriptionsComponentSchema[];
};

export type ProDescriptionsMethods<T> = {};
export type SmartDescriptionsMethods<T> = {};

const ProDescriptions = forwardRef(
const SmartDescriptions = forwardRef(
<T extends {} = {}>(
{ request, children, ...tableProps }: ProDescriptionsProps<T>,
ref: ForwardedRef<ProDescriptionsProps<T>>,
{ request, children, ...tableProps }: SmartDescriptionsProps<T>,
ref: ForwardedRef<SmartDescriptionsProps<T>>,
) => {
const [loading, setLoading] = useState(false);
const [dataSource, setDataSource] = useState<Record<string, any>>();
Expand All @@ -41,7 +41,7 @@ const ProDescriptions = forwardRef(
};

// 在组件内部创建methods对象
const methods: ProDescriptionsMethods<T> = {};
const methods: SmartDescriptionsMethods<T> = {};

// 更新useImperativeHandle钩子,直接使用methods对象
useImperativeHandle(ref, () => methods);
Expand Down Expand Up @@ -86,4 +86,4 @@ const ProDescriptions = forwardRef(
},
);

export default ProDescriptions;
export default SmartDescriptions;
6 changes: 3 additions & 3 deletions src/Store/demos/nested.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Form, Icon, Input, Tooltip } from 'antd';
import delay from 'delay';
import React from 'react';
import { DrawerForm, ProDescriptions, SearchTable, Store, useStore } from 'widgets-v3';
import { DrawerForm, SmartDescriptions, SearchTable, Store, useStore } from 'widgets-v3';

const User = () => {
const global = useStore('global');
Expand Down Expand Up @@ -121,7 +121,7 @@ export default () => (
trigger={<Button type="link">查看</Button>}
renderFormItems={() => {
return (
<ProDescriptions
<SmartDescriptions
request={async () => {
await delay(1000);
return {
Expand Down Expand Up @@ -213,7 +213,7 @@ export default () => (
},
];
}}
</ProDescriptions>
</SmartDescriptions>
);
}}
></DrawerForm>
Expand Down
Loading

0 comments on commit 162fd95

Please sign in to comment.