@pointcloud/pcloud-components 0.1.36 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,153 +1,157 @@
1
- # @pointcloud/pcloud-components
2
-
3
- [![NPM version](https://img.shields.io/npm/v/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
4
- [![NPM downloads](https://img.shields.io/npm/dm/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
5
- ![Jest Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen?style=flat)
6
- [![License](https://img.shields.io/npm/l/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
7
-
8
- 一套基于 Ant Design v4.24.16 和 React v17.0.2 开发的业务组件库,包含 30+ 个高质量组件,可帮助您快速构建企业级中后台产品原型。
9
-
10
- ## 🎁 组件列表
11
-
12
- ### 表单组件
13
-
14
- | 组件名称 | 描述 |
15
- | ------------ | ----------------------------------- |
16
- | DForm | 基于 Ant Design Form 的增强表单组件 |
17
- | DInput | 增强版输入框组件 |
18
- | DSelect | 支持异步加载的下拉选择组件 |
19
- | DCascader | 支持异步加载的级联选择组件 |
20
- | DTreeSelect | 支持异步加载的树选择组件 |
21
- | DUpload | 文件上传组件 |
22
- | DRangePicker | 日期选择组件 |
23
- | ColorPicker | 颜色选择器组件 |
24
-
25
- ### 数据展示组件
26
-
27
- | 组件名称 | 描述 |
28
- | ------------------ | ---------------- |
29
- | DTable | 增强版表格组件 |
30
- | LabelValue | 标签值展示组件 |
31
- | WordCloud | 词云组件 |
32
- | ScrollNumber | 数字滚动动画组件 |
33
- | AspectRatio | 宽高比容器组件 |
34
- | NoData | 无数据展示组件 |
35
- | IPAddress | IP 地址输入组件 |
36
- | AnimatedScrollList | 动画滚动列表组件 |
37
- | OrgTree | 组织树组件 |
38
- | TypewriterText | 打字机组件 |
39
-
40
- ### 模态框组件
41
-
42
- | 组件名称 | 描述 |
43
- | --------- | ---------------- |
44
- | DModal | 增强版模态框组件 |
45
- | ModalForm | 表单模态框组件 |
46
- | LoginForm | 登录表单组件 |
47
-
48
- ### 其他业务组件
49
-
50
- | 组件名称 | 描述 |
51
- | ------------------ | ------------------ |
52
- | Loading | 全局加载组件 |
53
- | ContextMenu | 右键菜单组件 |
54
- | AdvancedFilter | 高级筛选组件 |
55
- | InfiniteScrollList | 无限滚动列表组件 |
56
- | PictureCard | 图片卡片组件 |
57
- | SignaturePad | 签名板组件 |
58
- | RndDrag | 可拖拽调整大小组件 |
59
- | RCropper | 图片裁剪组件 |
60
- | CRUD | CRUD 组件 |
61
-
62
- ## 🚀 安装
63
-
64
- ```bash
65
- # 使用 npm
66
- npm install @pointcloud/pcloud-components
67
-
68
- # 使用 yarn
69
- yarn add @pointcloud/pcloud-components
70
-
71
- # 使用 pnpm
72
- pnpm add @pointcloud/pcloud-components
73
- ```
74
-
75
- ## 🔨 快速开始
76
-
77
- 通过 umd 引入时,需要先引入`react`和`react-dom`, 示例:
78
-
79
- ```html
80
- <link rel="stylesheet" href="https://unpkg.com/@pointcloud/pcloud-components@0.1.30/dist/umd/pcloud-components.min.css" />
81
- <script src="https://unpkg.com/react@17.0.2/umd/react.production.min.js"></script>
82
- <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
83
- <script src="https://unpkg.com/@pointcloud/pcloud-components@0.1.30/dist/umd/pcloud-components.min.js"></script>
84
- ```
85
-
86
- ### 1. 基础使用
87
-
88
- ```jsx
89
- import React from 'react';
90
- import { DCascader } from '@pointcloud/pcloud-components';
91
-
92
- const App = () => {
93
- const handleChange = (value, selectedOptions) => {
94
- console.log(value, selectedOptions);
95
- };
96
-
97
- return <DCascader showSearch placeholder="请选择" onChange={handleChange} />;
98
- };
99
-
100
- export default App;
101
- ```
102
-
103
- ### 2. 使用表单组件
104
-
105
- ```jsx
106
- import React from 'react';
107
- import { DForm, DInput, DSelect } from '@pointcloud/pcloud-components';
108
-
109
- const App = () => {
110
- const onFinish = (values) => {
111
- console.log('表单值:', values);
112
- };
113
- const items = [
114
- {
115
- label: '用户名',
116
- name: 'username',
117
- rules: [{ required: true, message: '请输入用户名' }],
118
- renderType: 'input',
119
- },
120
- {
121
- label: '状态',
122
- name: 'status',
123
- rules: [{ required: true, message: '请选择状态' }],
124
- renderType: 'select',
125
- options: [
126
- { label: '启用', value: 1 },
127
- { label: '禁用', value: 0 },
128
- ],
129
- },
130
- {
131
- label: '提交',
132
- renderType: 'button',
133
- type: 'primary',
134
- htmlType: 'submit',
135
- },
136
- ];
137
-
138
- return <DForm onFinish={onFinish} items={items}></DForm>;
139
- };
140
-
141
- export default App;
142
- ```
143
-
144
- ## 📖 详细文档
145
-
146
- 访问我们的[在线文档](https://frank17008.github.io/pcloud-components)查看完整的组件列表和使用示例。
147
-
148
- ## ⚙️ 环境支持
149
-
150
- - React < 18
151
- - Ant Design <= 4.24.16
152
- - Node >= 16.20.0
153
- - Modern browsers
1
+ # @pointcloud/pcloud-components
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
4
+ [![NPM downloads](https://img.shields.io/npm/dm/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
5
+ ![Jest Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen?style=flat)
6
+ [![License](https://img.shields.io/npm/l/@pointcloud/pcloud-components.svg?style=flat)](https://npmjs.org/package/@pointcloud/pcloud-components)
7
+
8
+ 一套基于 Ant Design v4.24.16 和 React v18 开发的业务组件库,包含 30+ 个高质量组件,可帮助您快速构建企业级中后台产品原型。
9
+
10
+ ## 🎁 组件列表
11
+
12
+ ### 表单组件
13
+
14
+ | 组件名称 | 描述 |
15
+ | --------------- | ----------------------------------- |
16
+ | DForm | 基于 Ant Design Form 的增强表单组件 |
17
+ | DInput | 增强版输入框组件 |
18
+ | DSelect | 支持异步加载的下拉选择组件 |
19
+ | DCascader | 支持异步加载的级联选择组件 |
20
+ | DTreeSelect | 支持异步加载的树选择组件 |
21
+ | DUpload | 文件上传组件 |
22
+ | DRangePicker | 日期选择组件 |
23
+ | DynamicFormItem | 动态表单组件 |
24
+
25
+ ### 数据展示类
26
+
27
+ | 组件名称 | 描述 |
28
+ | ------------------ | ---------------- |
29
+ | DTable | 增强版表格组件 |
30
+ | LabelValue | 标签值展示组件 |
31
+ | WordCloud | 词云组件 |
32
+ | ScrollNumber | 数字滚动动画组件 |
33
+ | AspectRatio | 宽高比容器组件 |
34
+ | NoData | 无数据展示组件 |
35
+ | IPAddress | IP 地址输入组件 |
36
+ | AnimatedScrollList | 动画滚动列表组件 |
37
+ | OrgTree | 组织树组件 |
38
+ | TypewriterText | 打字机组件 |
39
+ | ErrorBoundary | 错误边界组件 |
40
+ | IconFont | 自定义图标组件 |
41
+
42
+ ### 模态框
43
+
44
+ | 组件名称 | 描述 |
45
+ | --------- | ---------------- |
46
+ | DModal | 增强版模态框组件 |
47
+ | ModalForm | 表单模态框组件 |
48
+ | LoginForm | 登录表单组件 |
49
+
50
+ ### 其他
51
+
52
+ | 组件名称 | 描述 |
53
+ | ------------------ | ------------------ |
54
+ | Loading | 全局加载组件 |
55
+ | ContextMenu | 右键菜单组件 |
56
+ | AdvancedFilter | 高级筛选组件 |
57
+ | InfiniteScrollList | 无限滚动列表组件 |
58
+ | PictureCard | 图片卡片组件 |
59
+ | SignaturePad | 签名板组件 |
60
+ | RndDrag | 可拖拽调整大小组件 |
61
+ | RCropper | 图片裁剪组件 |
62
+ | CRUD | CRUD 组件 |
63
+ | AuthComponent | 权限组件 |
64
+ | ColorPicker | 颜色选择器组件 |
65
+
66
+ ## 🚀 安装
67
+
68
+ ```bash
69
+ # 使用 npm
70
+ npm install @pointcloud/pcloud-components
71
+
72
+ # 使用 yarn
73
+ yarn add @pointcloud/pcloud-components
74
+
75
+ # 使用 pnpm
76
+ pnpm add @pointcloud/pcloud-components
77
+ ```
78
+
79
+ ## 🔨 快速开始
80
+
81
+ 通过 umd 引入时,需要先引入`react`和`react-dom`, 示例:
82
+
83
+ ```html
84
+ <link rel="stylesheet" href="https://unpkg.com/@pointcloud/pcloud-components@1.0.0/dist/umd/pcloud-components.min.css" />
85
+ <script src="https://unpkg.com/react@18.3.1/umd/react.production.min.js"></script>
86
+ <script src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.production.min.js"></script>
87
+ <script src="https://unpkg.com/@pointcloud/pcloud-components@1.0.0/dist/umd/pcloud-components.min.js"></script>
88
+ ```
89
+
90
+ ### 1. 基础使用
91
+
92
+ ```jsx
93
+ import React from 'react';
94
+ import { DCascader } from '@pointcloud/pcloud-components';
95
+
96
+ const App = () => {
97
+ const handleChange = (value, selectedOptions) => {
98
+ console.log(value, selectedOptions);
99
+ };
100
+
101
+ return <DCascader showSearch placeholder="请选择" onChange={handleChange} />;
102
+ };
103
+
104
+ export default App;
105
+ ```
106
+
107
+ ### 2. 使用表单组件
108
+
109
+ ```jsx
110
+ import React from 'react';
111
+ import { DForm } from '@pointcloud/pcloud-components';
112
+
113
+ const App = () => {
114
+ const onFinish = (values) => {
115
+ console.log('表单值:', values);
116
+ };
117
+ const items = [
118
+ {
119
+ label: '用户名',
120
+ name: 'username',
121
+ rules: [{ required: true, message: '请输入用户名' }],
122
+ renderType: 'input',
123
+ },
124
+ {
125
+ label: '状态',
126
+ name: 'status',
127
+ rules: [{ required: true, message: '请选择状态' }],
128
+ renderType: 'select',
129
+ options: [
130
+ { label: '启用', value: 1 },
131
+ { label: '禁用', value: 0 },
132
+ ],
133
+ },
134
+ {
135
+ label: '提交',
136
+ renderType: 'button',
137
+ type: 'primary',
138
+ htmlType: 'submit',
139
+ },
140
+ ];
141
+
142
+ return <DForm onFinish={onFinish} items={items}></DForm>;
143
+ };
144
+
145
+ export default App;
146
+ ```
147
+
148
+ ## 📖 详细文档
149
+
150
+ 访问我们的[在线文档](https://frank17008.github.io/pcloud-components)查看完整的组件列表和使用示例。
151
+
152
+ ## ⚙️ 环境支持
153
+
154
+ - React >= 18
155
+ - Ant Design <= 4.24.16
156
+ - Node >= 16.20.0
157
+ - Modern browsers
@@ -1,6 +1,8 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["inputSearch"];
4
6
  import React, { useState, useRef, useImperativeHandle, useContext } from 'react';
5
7
  import { Input, Button, Collapse } from 'antd';
6
8
  import classNames from 'classnames';
@@ -12,13 +14,16 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
12
14
  var AdvancedFilter = function AdvancedFilter(props) {
13
15
  var left = props.left,
14
16
  right = props.right,
15
- inputProps = props.inputProps,
17
+ _props$inputProps = props.inputProps,
18
+ inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
16
19
  formItemConfig = props.formItemConfig,
17
20
  fRef = props.fRef,
18
21
  icon = props.icon,
19
22
  onValuesChange = props.onValuesChange,
20
23
  onSearch = props.onSearch,
21
24
  onReset = props.onReset;
25
+ var inputSearch = inputProps.inputSearch,
26
+ otherInputProps = _objectWithoutProperties(inputProps, _excluded);
22
27
  var _useContext = useContext(ConfigContext),
23
28
  prefixCls = _useContext.prefixCls,
24
29
  getPrefixCls = _useContext.getPrefixCls;
@@ -49,12 +54,12 @@ var AdvancedFilter = function AdvancedFilter(props) {
49
54
  var handleSearch = function handleSearch(values) {
50
55
  var _inputRef$current;
51
56
  var value = inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.input) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value;
52
- // eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
53
- onSearch && onSearch(_objectSpread(_objectSpread({}, values), _defineProperty({}, inputProps.name, value)));
57
+ onSearch === null || onSearch === void 0 || onSearch(_objectSpread(_objectSpread({}, values), _defineProperty({}, inputProps.name, value)));
54
58
  };
55
- var inputSearch = function inputSearch(v) {
56
- // eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
57
- (inputProps === null || inputProps === void 0 ? void 0 : inputProps.inputSearch) && inputProps.inputSearch(_defineProperty({}, inputProps.name, v));
59
+ var _inputSearch = function _inputSearch(v) {
60
+ if (typeof inputSearch === 'function') {
61
+ inputSearch(_defineProperty({}, inputProps.name, v));
62
+ }
58
63
  };
59
64
  return /*#__PURE__*/_jsx(Collapse, {
60
65
  className: wrapperClass,
@@ -78,20 +83,17 @@ var AdvancedFilter = function AdvancedFilter(props) {
78
83
  children: left
79
84
  }), /*#__PURE__*/_jsxs("div", {
80
85
  className: "right right-content",
81
- children: [/*#__PURE__*/_jsx(Input.Search, {
86
+ children: [/*#__PURE__*/_jsx(Input.Search, _objectSpread({
82
87
  className: "input",
83
88
  ref: inputRef,
84
89
  allowClear: true,
85
- placeholder: inputProps === null || inputProps === void 0 ? void 0 : inputProps.placeholder,
86
90
  onChange: function onChange(e) {
87
91
  setInputValue(e.target.value);
88
- // eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions
89
- onValuesChange && onValuesChange(e.target.value);
92
+ onValuesChange === null || onValuesChange === void 0 || onValuesChange(e.target.value);
90
93
  },
91
- onSearch: inputSearch,
92
- name: inputProps === null || inputProps === void 0 ? void 0 : inputProps.name,
94
+ onSearch: _inputSearch,
93
95
  value: inputValue
94
- }), /*#__PURE__*/_jsxs(Button, {
96
+ }, otherInputProps)), /*#__PURE__*/_jsxs(Button, {
95
97
  className: "button",
96
98
  onClick: function onClick() {
97
99
  return setPanelVisible(!panelVisible);
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { InputProps as AntdInputProps } from 'antd';
2
3
  export type FormItemType = 'input' | 'inputNumber' | 'radio' | 'select' | 'checkbox' | 'datePicker' | 'rangePicker' | 'switch' | 'treeSelect';
3
4
  export interface FormItem {
4
5
  /**
@@ -55,15 +56,7 @@ export interface FProps extends FormProps {
55
56
  */
56
57
  formRef?: any;
57
58
  }
58
- export interface InputProps {
59
- /**
60
- * @description input检索框placeholder
61
- */
62
- placeholder?: string;
63
- /**
64
- * @description input检索框字段名
65
- */
66
- name: string;
59
+ export interface InputProps extends AntdInputProps {
67
60
  /**
68
61
  * @description input检索框回车时或点击检索图标时触发
69
62
  */
@@ -11,7 +11,7 @@ export type DCascaderProps = Omit<CascaderProps<any>, 'options' | 'loadData' | '
11
11
  /** antd的loading属性,是否显示加载中:传入数字表示延迟加载,单位毫秒,0等同于false */
12
12
  loading?: boolean | number;
13
13
  };
14
- declare const DCascader: React.ForwardRefExoticComponent<Omit<CascaderProps<any>, "options" | "loading" | "loadData"> & {
14
+ declare const DCascader: React.ForwardRefExoticComponent<Omit<CascaderProps<any>, "loading" | "options" | "loadData"> & {
15
15
  /** antd的options属性,同onSearch属性,可以是一个options数组,或一个返回等价options数组的promise */
16
16
  options?: DefaultOptionType[] | ((value?: string, option?: DefaultOptionType, options?: DefaultOptionType[]) => Promise<DefaultOptionType[]>) | undefined;
17
17
  /** antd的loadData属性,动态加载子级列表数据,默认使用options所提供的方法,如果传入null,则表示不进行动态加载,该方法要求返回一个options数组或与其等价的Promise */
@@ -10,12 +10,8 @@ import { DTreeSelectProps } from '../../DTreeSelect';
10
10
  import { DUploadProps } from '../../DUpload';
11
11
  import { IPAddressProps } from '../../IPAddress';
12
12
  import { DRangePickerProps } from '../../DRangePicker/interface';
13
- export type DItemBaseProps = {
14
- /** label标签文本,同antd Form.Item的label,只能是string */
15
- label?: string;
16
- /** name标签文本,同antd Form.Item的name */
17
- name?: string | number | (string | number)[];
18
- /** Form.Item 的其他属性 */
13
+ export type RenderType = 'custom' | 'dInput' | 'ipAddress' | 'input' | 'textArea' | 'password' | 'inputNumber' | 'autoComplete' | 'dSelect' | 'select' | 'dCascader' | 'cascader' | 'dTreeSelect' | 'treeSelect' | 'datePicker' | 'dRangePicker' | 'timePicker' | 'rangePicker' | 'mentions' | 'checkbox' | 'checkboxGroup' | 'radio' | 'radioGroup' | 'rate' | 'slider' | 'switch' | 'transfer' | 'upload' | 'dUpload' | 'button' | 'divider';
14
+ export type DItemBaseProps = Pick<FormItemProps, 'label' | 'name'> & {
19
15
  formItemProps?: FormItemProps & {
20
16
  grid?: Omit<ColProps, 'prefixCls'>;
21
17
  };
@@ -11,7 +11,7 @@ export type DSelectProps = Omit<SelectProps, 'options' | 'onSearch' | 'loading'>
11
11
  /** 是否开启防抖: true表示800毫秒,true表示默认值,false或0表示不开启 */
12
12
  debounce?: boolean | number;
13
13
  };
14
- declare const DSelect: React.ForwardRefExoticComponent<Omit<SelectProps<any, DefaultOptionType>, "options" | "onSearch" | "loading"> & {
14
+ declare const DSelect: React.ForwardRefExoticComponent<Omit<SelectProps<any, DefaultOptionType>, "loading" | "options" | "onSearch"> & {
15
15
  /** antd的onSearch属性,onSearch有效时showSearch自动为true */
16
16
  onSearch?: ((params?: any) => Promise<DefaultOptionType[] | any[]>) | undefined;
17
17
  /** antd的options属性,可以是一个options数组,或一个返回等价options数组的promise */
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Button } from 'antd';
3
+ import type { FormListProps } from 'antd/lib/form/FormList';
4
+ import type { DItemProps } from '../DForm/DItem';
5
+ import './index.less';
6
+ export interface DynamicFormItemProps extends Omit<FormListProps, 'children'> {
7
+ /** 表单项配置 */
8
+ itemConfig: DItemProps | DItemProps[];
9
+ /** 初始值 */
10
+ value?: any[];
11
+ /** 新增按钮文本 */
12
+ addButtonText?: string;
13
+ /** 新增按钮属性 */
14
+ addButtonProps?: React.ComponentProps<typeof Button>;
15
+ /** 是否添加到头部 */
16
+ addAtHead?: boolean;
17
+ /** 删除按钮文本 */
18
+ removeButtonText?: string;
19
+ /** 删除按钮属性 */
20
+ removeButtonProps?: React.ComponentProps<typeof Button>;
21
+ /** 最小项数 */
22
+ minItems?: number;
23
+ /** 最大项数 */
24
+ maxItems?: number;
25
+ /** 是否显示添加按钮 */
26
+ showAdd?: boolean;
27
+ /** 是否显示删除按钮 */
28
+ showRemove?: boolean;
29
+ /** 添加按钮位置 */
30
+ addPosition?: 'top' | 'bottom';
31
+ }
32
+ declare const DynamicFormItem: React.FC<DynamicFormItemProps>;
33
+ export default DynamicFormItem;
@@ -0,0 +1,98 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["name"];
4
+ import React from 'react';
5
+ import { Button, Form, Space } from 'antd';
6
+ import { PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons';
7
+ import DForm from "../DForm";
8
+ import "./index.less";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ import { jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { Fragment as _Fragment } from "react/jsx-runtime";
12
+ var DynamicFormItem = function DynamicFormItem(props) {
13
+ var _props$name = props.name,
14
+ name = _props$name === void 0 ? 'dynamicItems' : _props$name,
15
+ _props$initialValue = props.initialValue,
16
+ initialValue = _props$initialValue === void 0 ? [undefined] : _props$initialValue,
17
+ rules = props.rules,
18
+ itemConfig = props.itemConfig,
19
+ _props$addButtonText = props.addButtonText,
20
+ addButtonText = _props$addButtonText === void 0 ? '添加' : _props$addButtonText,
21
+ _props$addButtonProps = props.addButtonProps,
22
+ addButtonProps = _props$addButtonProps === void 0 ? {} : _props$addButtonProps,
23
+ _props$addAtHead = props.addAtHead,
24
+ addAtHead = _props$addAtHead === void 0 ? false : _props$addAtHead,
25
+ removeButtonText = props.removeButtonText,
26
+ _props$removeButtonPr = props.removeButtonProps,
27
+ removeButtonProps = _props$removeButtonPr === void 0 ? {} : _props$removeButtonPr,
28
+ _props$minItems = props.minItems,
29
+ minItems = _props$minItems === void 0 ? 0 : _props$minItems,
30
+ maxItems = props.maxItems,
31
+ _props$showAdd = props.showAdd,
32
+ showAdd = _props$showAdd === void 0 ? true : _props$showAdd,
33
+ _props$showRemove = props.showRemove,
34
+ showRemove = _props$showRemove === void 0 ? true : _props$showRemove,
35
+ _props$addPosition = props.addPosition,
36
+ addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition;
37
+ var renderItem = function renderItem(_ref, index, _ref2, totalFieldsCount) {
38
+ var key = _ref.key,
39
+ name = _ref.name;
40
+ var remove = _ref2.remove;
41
+ var nested = Array.isArray(itemConfig) && itemConfig.length > 0;
42
+ return /*#__PURE__*/_jsxs(Space, {
43
+ align: "start",
44
+ className: "".concat(nested ? 'dynamic-form-item nested' : 'dynamic-form-item single'),
45
+ children: [nested ? itemConfig.map(function (config, idx) {
46
+ var configName = config.name,
47
+ restConfig = _objectWithoutProperties(config, _excluded);
48
+ return /*#__PURE__*/_jsx(DForm.Item, _objectSpread(_objectSpread({}, restConfig), {}, {
49
+ name: [name, configName]
50
+ }), "dynamic-item-".concat(idx));
51
+ }) : /*#__PURE__*/_jsx(DForm.Item, _objectSpread({}, itemConfig)), showRemove && totalFieldsCount > minItems && /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
52
+ type: "link",
53
+ danger: true,
54
+ icon: /*#__PURE__*/_jsx(MinusCircleOutlined, {}),
55
+ onClick: function onClick() {
56
+ return remove(name);
57
+ },
58
+ title: removeButtonText || '移除'
59
+ }, removeButtonProps), {}, {
60
+ children: removeButtonText
61
+ }))]
62
+ }, key);
63
+ };
64
+ var renderAddButton = function renderAddButton(_ref3, totalFieldsCount, position) {
65
+ var add = _ref3.add;
66
+ if (!showAdd || maxItems && totalFieldsCount >= maxItems) return null;
67
+ return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
68
+ type: "dashed",
69
+ block: true,
70
+ onClick: function onClick() {
71
+ if (addAtHead) {
72
+ add('', 0);
73
+ } else {
74
+ add();
75
+ }
76
+ },
77
+ icon: /*#__PURE__*/_jsx(PlusCircleOutlined, {}),
78
+ style: {
79
+ marginBottom: position === 'top' ? '8px' : 0
80
+ }
81
+ }, addButtonProps), {}, {
82
+ children: addButtonText
83
+ }));
84
+ };
85
+ return /*#__PURE__*/_jsx(Form.List, {
86
+ name: name,
87
+ initialValue: initialValue,
88
+ rules: rules,
89
+ children: function children(fields, operation) {
90
+ return /*#__PURE__*/_jsxs(_Fragment, {
91
+ children: [addPosition === 'top' && renderAddButton(operation, fields.length, 'top'), fields.map(function (field, index) {
92
+ return renderItem(field, index, operation, fields.length);
93
+ }), addPosition === 'bottom' && renderAddButton(operation, fields.length, 'bottom')]
94
+ });
95
+ }
96
+ });
97
+ };
98
+ export default DynamicFormItem;
@@ -0,0 +1,28 @@
1
+ .dynamic-form-item {
2
+ width: 100%;
3
+ display: flex;
4
+ align-items: flex-start;
5
+ gap: 8px;
6
+ margin-bottom: 8px;
7
+
8
+ .ant-form-item {
9
+ flex: 1;
10
+ margin-bottom: 0;
11
+ }
12
+
13
+ .ant-btn-link {
14
+ flex-shrink: 0;
15
+ }
16
+
17
+ &.single {
18
+ .ant-space-item:first-of-type {
19
+ display: flex;
20
+ flex: 1;
21
+ }
22
+ }
23
+ }
24
+
25
+ // 隐藏其他label,只显示第一个但占位
26
+ .dynamic-form-item ~ .dynamic-form-item .ant-col.ant-form-item-label {
27
+ visibility: hidden;
28
+ }
@@ -1,3 +1,4 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
1
2
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
4
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
@@ -15,8 +16,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
15
16
  var InfiniteScrollList = function InfiniteScrollList(props) {
16
17
  var _listData$data, _listData$data2;
17
18
  var loadMore = props.loadMore,
18
- _props$initialParams = props.initialParams,
19
- initialParams = _props$initialParams === void 0 ? {} : _props$initialParams,
19
+ initialParams = props.initialParams,
20
20
  _props$itemKey = props.itemKey,
21
21
  itemKey = _props$itemKey === void 0 ? 'id' : _props$itemKey,
22
22
  _props$containerId = props.containerId,
@@ -41,7 +41,7 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
41
41
  var pageParamsRef = useRef(_objectSpread({
42
42
  current: 1,
43
43
  size: 10
44
- }, initialParams));
44
+ }, initialParams || {}));
45
45
  var loadingRef = useRef(false);
46
46
  var scrollRef = useRef(null);
47
47
  var _useState = useState({
@@ -112,7 +112,8 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
112
112
  }
113
113
  }, [listData]);
114
114
  useEffect(function () {
115
- if (Reflect.ownKeys(initialParams).length > 0) {
115
+ var currentInitialParams = initialParams && _typeof(initialParams) === 'object' ? initialParams : {};
116
+ if (Reflect.ownKeys(currentInitialParams).length > 0) {
116
117
  var _scrollRef$current;
117
118
  scrollRef === null || scrollRef === void 0 || (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 || _scrollRef$current.scrollTo({
118
119
  top: 0,
@@ -121,10 +122,10 @@ var InfiniteScrollList = function InfiniteScrollList(props) {
121
122
  pageParamsRef.current = _objectSpread({
122
123
  current: 1,
123
124
  size: 10
124
- }, initialParams);
125
+ }, currentInitialParams);
125
126
  }
126
127
  handleLoadMore();
127
- }, [initialParams]);
128
+ }, [initialParams, handleLoadMore]);
128
129
  return /*#__PURE__*/_jsxs("div", {
129
130
  id: containerId,
130
131
  className: "scroll-container",