### ProFormList with actionRef for List Operations Source: https://procomponents.ant.design/components/group This example shows how to use actionRef to get a handle on the ProFormList instance, enabling programmatic control over adding, removing, moving, and retrieving list items. It includes buttons to trigger these actions. ```tsx const actionRef = useRef< FormListActionType<{ name: string; }> >(); return ( <> ``` -------------------------------- ### CheckCard Composition Examples Source: https://procomponents.ant.design/components/check-card Examples showcasing different combinations of avatar, title, and description in CheckCard. ```APIDOC ## Composition Examples ### Only Avatar ```jsx ``` ### Avatar and Description ```jsx ``` ### Title and Description ```jsx ``` ### Title and Avatar ```jsx ``` ### Only Title ```jsx ``` ### Only Description ```jsx ``` ``` -------------------------------- ### ProForm Basic Usage Example Source: https://procomponents.ant.design/components/form A simple example demonstrating the basic usage of the ProForm component. ```tsx import React from 'react'; import { ProForm, ProFormText, ProFormDateRangePicker, ProFormSelect, } from '@ant-design/pro-components'; const BasicForm: React.FC = () => { return ( { console.log(values); }} > ``` -------------------------------- ### ProForm Method Call with formRef Source: https://procomponents.ant.design/components/form Demonstrates how to use formRef to get the form instance and call methods like reset, set values, and get values. ```tsx import React from 'react'; import { ProForm, ProFormText, ProFormDateRangePicker, ProFormInstance, } from '@ant-design/pro-components'; const FormMethods: React.FC = () => { const formRef = React.useRef(); return ( { console.log(values); }} params={{ // request will be called when the component is mounted request: async () => ({ name: 'Ant Design Co., Ltd.', dateRange: [ new Date('2023-01-01'), new Date('2023-12-31'), ], }), }} > { formRef.current?.resetFields(); }} > 重置 ); }; export default FormMethods; ``` -------------------------------- ### ProFormMoney Source: https://procomponents.ant.design/components/field-set Example of ProFormMoney for currency input. ```jsx ``` -------------------------------- ### Upload Button - With Extra Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadButton with additional extra content. ```jsx ``` -------------------------------- ### ProFormRate Source: https://procomponents.ant.design/components/field-set Example of ProFormRate for star rating input. ```jsx ``` -------------------------------- ### Basic Data Form - InputNumber Source: https://procomponents.ant.design/components/field-set Example of ProFormDigit for numerical input. ```jsx ``` -------------------------------- ### ProFormSelect - With Search Source: https://procomponents.ant.design/components/field-set Example of ProFormSelect with search functionality enabled. ```jsx ``` -------------------------------- ### Query Selector - Options Source: https://procomponents.ant.design/components/field-set Example of a query selector using static options. ```jsx ``` -------------------------------- ### Read Only Form - Filter Example Source: https://procomponents.ant.design/components/field-set Example of a read-only form with a filter input. ```jsx 包含 123 ``` -------------------------------- ### ProFormSwitch Source: https://procomponents.ant.design/components/field-set Example of ProFormSwitch for boolean input (true/false). ```jsx ``` -------------------------------- ### Basic Data Form - Dynamic List Source: https://procomponents.ant.design/components/field-set Example of ProFormList for dynamically adding items. ```jsx ``` -------------------------------- ### ProFormRadio.Group - Basic Source: https://procomponents.ant.design/components/field-set Example of ProFormRadio.Group for single selection from a list of options. ```jsx ``` -------------------------------- ### ProFormUploadDragger - With Extra Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadDragger with additional extra content. ```jsx ``` -------------------------------- ### Basic Data Form - Switch Source: https://procomponents.ant.design/components/field-set Example of ProFormSwitch for boolean input. ```jsx ``` -------------------------------- ### ProFormDigit - InputNumber Source: https://procomponents.ant.design/components/field-set Example of ProFormDigit for numerical input, with default formatting. ```jsx ``` -------------------------------- ### Update Dependencies Source: https://procomponents.ant.design/docs/api-changes Install the latest versions of antd and ProComponents to align with v3.0 requirements. ```bash # 更新依赖 npm install antd@^6.0.0 npm install @ant-design/pro-components@^3.0.0-beta.1 ``` -------------------------------- ### ProFormText - Read Only Example Source: https://procomponents.ant.design/components/field-set Demonstrates the read-only display of a ProFormText field. ```jsx ``` -------------------------------- ### Basic Data Form - Rate Source: https://procomponents.ant.design/components/field-set Example of ProFormRate for star rating. ```jsx ``` -------------------------------- ### Basic Data Form - Select Source: https://procomponents.ant.design/components/field-set Example of ProFormSelect for country selection. ```jsx ``` -------------------------------- ### Basic Data Form - Address List Source: https://procomponents.ant.design/components/field-set Example of ProFormText for address input in a list. ```jsx ``` -------------------------------- ### Input Group Example Source: https://procomponents.ant.design/components/field-set Demonstrates using Input.Group within ProForm for grouped inputs. ```jsx ``` -------------------------------- ### ProFormDigitRange - InputNumberRange Source: https://procomponents.ant.design/components/field-set Example of ProFormDigitRange for inputting a range of numbers. ```jsx ``` -------------------------------- ### ProFormUploadButton Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadButton for file uploads using a button interface. ```jsx ``` -------------------------------- ### ProForm with Form Linking Source: https://procomponents.ant.design/components/form Example of implementing form linking using ProFormDependency. ```tsx import React from 'react'; import { ProForm, ProFormText, ProFormSelect, ProFormDependency, } from '@ant-design/pro-components'; const FormLinking: React.FC = () => { return ( { console.log(values); }} > ); }} ``` -------------------------------- ### Basic Data Form - Options Select Source: https://procomponents.ant.design/components/field-set Example of ProFormSelect using static options. ```jsx ``` -------------------------------- ### ProFormRadio.Group - Button Style Source: https://procomponents.ant.design/components/field-set Example of ProFormRadio.Group using button style for options. ```jsx ``` -------------------------------- ### Upload Button - Custom Text Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadButton with custom button text. ```jsx ``` -------------------------------- ### ProFormText.Password Input Source: https://procomponents.ant.design/components/field-set Example of using ProFormText.Password for a password input field. ```jsx ``` -------------------------------- ### Query Selector - Request Data Source: https://procomponents.ant.design/components/field-set Example of a query selector fetching data via a request. ```jsx [ { label: '请选择', value: '请选择' }, ]} /> ``` -------------------------------- ### Basic Data Form - Radio Button Source: https://procomponents.ant.design/components/field-set Example of ProFormRadio.Group using button style. ```jsx ``` -------------------------------- ### Basic StepsForm Example Source: https://procomponents.ant.design/components/steps-form A standard StepsForm with three steps: Create Experiment, Set Parameters, and Publish Experiment. Includes various form fields like experiment name, date, migration type, and deployment units. ```javascript 1 Create Experiment All basic information is filled in here 2 Set Parameters Fill in the operation parameters here 3 Publish Experiment Fill in the release criteria here Experiment Name Date Time Range Remarks Migration Type Structural MigrationFull MigrationIncremental MigrationFull Verification Business DB Username Record Retention Time Migration Type Complete LOBDo Not Sync LOBRestricted LOB Deployment Units Deployment Unit 1Deployment Unit 2Deployment Unit 3 Deployment Group Strategy Strategy One Pod Scheduling Strategy Strategy Two 下一步 ``` -------------------------------- ### 演示文件目录结构 Source: https://procomponents.ant.design/docs 示例代码应放置在 `demos/` 目录下,并按组件进行分类,便于管理和查找。 ```bash demos/ ├── card/ │ ├── basic.tsx │ └── advanced.tsx ├── form/ │ ├── basic.tsx │ └── complex.tsx └── table/ ├── basic.tsx └── search.tsx ``` -------------------------------- ### ProFormSelect - Basic Usage Source: https://procomponents.ant.design/components/field-set Example of ProFormSelect for single selection, supporting request or valueEnum for options. ```jsx ``` -------------------------------- ### ProFormCheckbox.Group Source: https://procomponents.ant.design/components/field-set Example of ProFormCheckbox.Group for multiple selections. ```jsx ``` -------------------------------- ### Update Dependencies with pnpm Source: https://procomponents.ant.design/docs/migration-guide Example of updating antd and ProComponents to their latest versions using pnpm. Replace with npm or yarn commands if necessary. ```bash pnpm up antd@^6.0.0 pnpm up @ant-design/pro-components@^3.0.0-beta.1 pnpm install ``` -------------------------------- ### ProFormSegmented Source: https://procomponents.ant.design/components/field-set Example of ProFormSegmented for segmented control selection. ```jsx ``` -------------------------------- ### ProFormSlider Source: https://procomponents.ant.design/components/field-set Example of ProFormSlider for selecting a value within a range. ```jsx ``` -------------------------------- ### actionRef - Accessing List Instance Source: https://procomponents.ant.design/components/group Demonstrates how to use the `actionRef` to get a reference to the ProFormList instance, enabling programmatic control over list items such as adding, removing, and moving. ```APIDOC ### actionRef 操作项目实例 可用于获取 `ProFormList` 的操作实例,从而进行增删改查等操作。 ### Usage ```tsx const actionRef = useRef>(); return ( <> ); ``` ``` -------------------------------- ### ProList Import Source: https://procomponents.ant.design/components/list How to import the ProList component into your project. ```APIDOC ## ProList Import ### Description Import the ProList component from the `@ant-design/pro-components` package. ### Code ```javascript import { ProList } from '@ant-design/pro-components'; ``` ``` -------------------------------- ### Basic Data Form - Name and Prefix/Suffix Source: https://procomponents.ant.design/components/field-set Example of basic form fields including text input with prefix and suffix. ```jsx ``` -------------------------------- ### Other Related Group - Input Group Source: https://procomponents.ant.design/components/field-set Example of ProForm.Group for input grouping. ```jsx ``` -------------------------------- ### Basic Data Form - Slider Source: https://procomponents.ant.design/components/field-set Example of ProFormSlider for range selection. ```jsx ``` -------------------------------- ### Basic ProDescriptions Usage Source: https://procomponents.ant.design/components/descriptions A simple example of ProDescriptions displaying order details with various data types including text, currency, percentage, status, dates, and code snippets. ```typescript 这是一段文本 客户要求在一季度内完成全部部署上线工作,优先安排专属技术支持团队跟进对接,确保各环节顺利推进客户要求在一季度内完成全部部署上线工作,优先安排专属技术支持团队跟进对接,确保各环节顺利推进 ¥128,000.00 75.00% 处理中 bank 75% 2024-01-15 00:00:00 2024-01-15 2024-01-15 00:00:002025-01-14 00:00:00 00:00:00 ``` pnpm install pnpm run build pnpm run deploy --env production ``` ```json { "service": { "name": "user-auth-service", "port": 8080, "replicas": 3, "healthCheck": "/api/health", "env": "production", "resources": { "cpu": "500m", "memory": "512Mi" } } } ``` ``` -------------------------------- ### Drag Sort Table with Request Data Source: https://procomponents.ant.design/components/drag-sort-table This example shows how to use the DragSortTable with data fetched via a `request` function. It includes the necessary configuration for asynchronous data loading. ```javascript const columns = [ { title: '排序', dataIndex: 'sort', key: 'sort', }, { title: '姓名', dataIndex: 'name', key: 'name', }, { title: '年龄', dataIndex: 'age', key: 'age', }, { title: '地址', dataIndex: 'address', key: 'address', }, ]; const request = async (params) => { // Simulate API call return new Promise((resolve) => { setTimeout(() => { resolve({ data: [ { key: '1', name: 'John Brown', age: 32, address: 'New York No. 1 Lake Park' }, { key: '2', name: 'Jim Green', age: 42, address: 'London No. 1 Lake Park' }, { key: '3', name: 'Joe Black', age: 32, address: 'Sidney No. 1 Lake Park' }, ], success: true, }); }, 1000); }); }; { console.log('Sorting finished:', { beforeIndex, afterIndex, newDataSource }); // You can perform further actions here, like saving the new order }} />; ``` -------------------------------- ### ProFormList Basic Usage Source: https://procomponents.ant.design/components/group Demonstrates the basic usage of ProFormList for structured data entry, including initial values and custom creator button text. ```APIDOC ## ProFormList ProFormList与Form.ListAPI基本相同,增加了自带的操作按钮:删除和复制,并且自带了了一个`新建一行`按钮。 ### Usage ```tsx ``` ``` -------------------------------- ### Date Related Group - Year Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a year. ```jsx ``` -------------------------------- ### Array dataIndex Example Source: https://procomponents.ant.design/components/descriptions Demonstrates how to use array dataIndex for displaying multiple values, such as in a list of items or properties. ```typescript 这是一段文本 日期2020-07-30 money¥12,121.00 ``` -------------------------------- ### Date Related Group - Quarter Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a quarter. ```jsx ``` -------------------------------- ### Date Related Group - Month Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a month. ```jsx ``` -------------------------------- ### Date Related Group - Week Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a week. ```jsx ``` -------------------------------- ### Responsive Grid Layout Source: https://procomponents.ant.design/components/card Configure responsive grid columns using an object with breakpoint keys (xs, sm, md, lg, xl, xxl) in the `colSpan` prop. This allows cards to adapt their width across different screen sizes. ```jsx 响应式卡片 ``` -------------------------------- ### Date Related Group - Time Source: https://procomponents.ant.design/components/field-set Example of ProFormTimePicker for selecting a time. ```jsx ``` -------------------------------- ### Date Related Group - Date Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a date. ```jsx ``` -------------------------------- ### ProFormUploadDragger Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadDragger for file uploads using a drag-and-drop area. ```jsx ``` -------------------------------- ### StepsForm for Editing Scenarios Source: https://procomponents.ant.design/components/steps-form An example of using StepsForm in an editing context, where existing data might be pre-filled. Features steps like 'Job Information' and 'Sync Table Information'. ```javascript 1 Job Information 2 Sync Table Information Name Job Type State-owned enterprise Time Range Title 下一步 ``` -------------------------------- ### Rollback Dependencies Source: https://procomponents.ant.design/docs/api-changes Revert to previous versions of ProComponents and antd if necessary. ```bash npm install @ant-design/pro-components@^2.8.10 npm install antd@^4.24.0 ``` -------------------------------- ### CheckCard in a Form Source: https://procomponents.ant.design/components/check-card Example of integrating CheckCard with an Ant Design Form. ```APIDOC ## Form Integration ```jsx import { Form, Button } from 'antd'; import { CheckCard } from '@ant-design/pro-components'; const App = () => { const [form] = Form.useForm(); const onFinish = (values) => { console.log('Received values of form: ', values); }; return (
); }; export default App; ``` ``` -------------------------------- ### ActionRef Table Control Example Source: https://procomponents.ant.design/components/table Demonstrates how to use ActionRef to manually trigger table operations like reload, reset, and editing. ```tsx // 示例 const ref = useRef(); ; // 刷新 ref.current?.reload(); // 刷新并清空,页码也会重置,不包括表单 ref.current?.reloadAndRest(); // 重置到默认值,包括表单 ref.current?.reset(); // 清空选中项 ref.current?.clearSelected(); // 开始编辑 ref.current?.startEditable(rowKey); // 结束编辑 ref.current?.cancelEditable(rowKey); ``` -------------------------------- ### Date Related Group - Basic Year Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a year. ```jsx ``` -------------------------------- ### Date Related Group - Basic Quarter Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a quarter. ```jsx ``` -------------------------------- ### ProForm with Amount Input Source: https://procomponents.ant.design/components/form Demonstrates using ProFormText with a specific format for amount input. ```tsx import React from 'react'; import { ProForm, ProFormText, } from '@ant-design/pro-components'; const AmountForm: React.FC = () => { return ( { console.log(values); }} > ``` -------------------------------- ### Import ProDescriptions Component Source: https://procomponents.ant.design/components/descriptions Import the ProDescriptions component from '@ant-design/pro-components'. ```javascript import { ProDescriptions } from '@ant-design/pro-components'; ``` -------------------------------- ### Date Related Group - Basic Week Source: https://procomponents.ant.design/components/field-set Example of ProFormDatePicker for selecting a week. ```jsx ``` -------------------------------- ### CheckCard with Different Sizes Source: https://procomponents.ant.design/components/check-card Demonstrates how to use the `size` prop to change the appearance of CheckCards. ```APIDOC ## Different Sizes ```jsx import { CheckCard } from '@ant-design/pro-components'; const App = () => ( <> ); export default App; ``` ``` -------------------------------- ### Date Related Group - Basic Time Source: https://procomponents.ant.design/components/field-set Example of ProFormTimePicker for selecting time. ```jsx ``` -------------------------------- ### Basic Data Form - Dragger Upload Source: https://procomponents.ant.design/components/field-set Example of ProFormUploadDragger for file uploads. ```jsx ``` -------------------------------- ### Import LoginForm and LoginFormPage Source: https://procomponents.ant.design/components/login-form Import the necessary components from '@ant-design/pro-components' to use LoginForm and LoginFormPage in your project. ```javascript import { LoginForm,PageForm } from '@ant-design/pro-components'; ``` -------------------------------- ### ProSkeleton Component Usage Source: https://procomponents.ant.design/components/skeleton This snippet demonstrates how to import and use the ProSkeleton component with a 'list' type. Note that the documentation states this is an internal component and not intended for direct use. ```APIDOC ## ProSkeleton - Skeleton Screen > This component is an internal component and should not be used directly. ### Installation and Initialization ```typescript import Skeleton from '@ant-design/pro-skeleton'; return ; ``` ### API | Parameter | Description | Type | Default Value | |---|---|---|---| | type | Different types of skeleton screens | `'list' | 'result' | 'descriptions'` | `list` | | active | Whether to show dynamic animations | `boolean` | `true` | | pageHeader | Whether to show the pageHeader skeleton screen (descriptions and list are valid) | `boolean` | `true` | | statistic | The number of statistic skeleton screens | `number` | `false` (4) | | list | The number of list skeleton screens | `number` | `false` (5) | | toolbar | The toolbar skeleton screen for lists | `boolean` | `true` | | formItemRender | Custom DOM rendering for `mode=update` or `mode=edit`, generally used for rendering edit boxes | `(item: any, config: any) => ReactNode` | `-` | | render | Custom DOM rendering for `mode=read`, purely for display | `(item: any, config: any) => ReactNode` | `-` | ``` -------------------------------- ### Basic Data Form - Checkbox Group Source: https://procomponents.ant.design/components/field-set Example of ProFormCheckbox.Group for multiple selections. ```jsx ``` -------------------------------- ### Use ActionRef to Reload ProDescriptions Source: https://procomponents.ant.design/components/descriptions This snippet shows how to use the ActionRef to manually reload the ProDescriptions component. It demonstrates setting up a ref using `useRef` and calling the `reload` method at intervals or on demand. ```tsx const ref = useRef(); // 两秒刷新一次 useEffect(() => { setInterval(() => { ref.current.reload(); }, 2000); }, []); // hooks 绑定 ; // class (this.ref = ref)} />; ``` ```tsx // 刷新 ref.current.reload(); ```