@pointcloud/pcloud-components 1.0.11 → 1.0.13
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/dist/esm/CRUD/index.d.ts
CHANGED
|
@@ -10,18 +10,18 @@ export type RefreshStrategy = {
|
|
|
10
10
|
/** 是否保持当前页码,默认为false(回到第一页) */
|
|
11
11
|
keepPage?: boolean;
|
|
12
12
|
};
|
|
13
|
-
export type CRUDRefProps = {
|
|
13
|
+
export type CRUDRefProps<T = Record<string, any>> = {
|
|
14
14
|
/** 刷新表格数据 */
|
|
15
15
|
refresh: (_strategy?: RefreshStrategy) => void;
|
|
16
16
|
getSelectedRows: () => {
|
|
17
17
|
selectedRowKeys: string[];
|
|
18
|
-
selectedRows:
|
|
18
|
+
selectedRows: T[];
|
|
19
19
|
};
|
|
20
20
|
getSearchValues: () => Record<string, any>;
|
|
21
|
-
openAddModal: (_record?:
|
|
22
|
-
openEditModal: (_record
|
|
23
|
-
openDeleteModal: (_record
|
|
24
|
-
openDetailModal: (_record
|
|
21
|
+
openAddModal: (_record?: Partial<T>) => void;
|
|
22
|
+
openEditModal: (_record: T) => void;
|
|
23
|
+
openDeleteModal: (_record: T) => void;
|
|
24
|
+
openDetailModal: (_record: T) => void;
|
|
25
25
|
};
|
|
26
26
|
export type MoreActionColumnRender<T = Record<string, any>> = (_text: any, _record: T) => React.ReactNode;
|
|
27
27
|
export type MoreActionProps<T = Record<string, any>> = MoreActionColumnRender<T> | {
|
|
@@ -34,7 +34,7 @@ export type MoreActionProps<T = Record<string, any>> = MoreActionColumnRender<T>
|
|
|
34
34
|
/** 更多按钮配置 */
|
|
35
35
|
buttonProps?: ButtonProps;
|
|
36
36
|
};
|
|
37
|
-
export type CRUDProps = {
|
|
37
|
+
export type CRUDProps<T = Record<string, any>> = {
|
|
38
38
|
className?: string;
|
|
39
39
|
style?: React.CSSProperties;
|
|
40
40
|
/** 查询表单配置 */
|
|
@@ -43,7 +43,7 @@ export type CRUDProps = {
|
|
|
43
43
|
};
|
|
44
44
|
/** 表格配置 */
|
|
45
45
|
tableProps: DTableProps & {
|
|
46
|
-
moreActionColumn?: MoreActionProps
|
|
46
|
+
moreActionColumn?: MoreActionProps<T>;
|
|
47
47
|
};
|
|
48
48
|
/** 新增/编辑表单配置 */
|
|
49
49
|
modalFormProps?: {
|
|
@@ -68,7 +68,7 @@ export type CRUDProps = {
|
|
|
68
68
|
/** 显示行编辑 */
|
|
69
69
|
showEdit?: boolean;
|
|
70
70
|
/** 根据行数据动态控制编辑按钮显隐 */
|
|
71
|
-
showEditPerRow?: (_record:
|
|
71
|
+
showEditPerRow?: (_record: T) => boolean;
|
|
72
72
|
/** 行编辑按钮文本 */
|
|
73
73
|
editButtonText?: string;
|
|
74
74
|
/** 编辑按钮配置 */
|
|
@@ -76,7 +76,7 @@ export type CRUDProps = {
|
|
|
76
76
|
/** 显示行删除 */
|
|
77
77
|
showDelete?: boolean;
|
|
78
78
|
/** 根据行数据动态控制删除按钮显隐 */
|
|
79
|
-
showDeletePerRow?: (_record:
|
|
79
|
+
showDeletePerRow?: (_record: T) => boolean;
|
|
80
80
|
/** 删除按钮文本 */
|
|
81
81
|
deleteButtonText?: string;
|
|
82
82
|
/** 删除按钮配置 */
|
|
@@ -84,7 +84,7 @@ export type CRUDProps = {
|
|
|
84
84
|
/** 显示行查看 */
|
|
85
85
|
showView?: boolean;
|
|
86
86
|
/** 根据行数据动态控制查看按钮显隐 */
|
|
87
|
-
showViewPerRow?: (_record:
|
|
87
|
+
showViewPerRow?: (_record: T) => boolean;
|
|
88
88
|
/** 行查看按钮文本 */
|
|
89
89
|
viewButtonText?: string;
|
|
90
90
|
/** 行查看按钮配置 */
|
|
@@ -96,13 +96,13 @@ export type CRUDProps = {
|
|
|
96
96
|
crudApi: {
|
|
97
97
|
list: (_params: any) => Promise<DTableSourceProps>;
|
|
98
98
|
/** 删除数据接口 */
|
|
99
|
-
delete?: (_currentRecord:
|
|
99
|
+
delete?: (_currentRecord: T) => Promise<any>;
|
|
100
100
|
/** 新增数据接口 */
|
|
101
101
|
add?: (_params: any) => Promise<any>;
|
|
102
102
|
/** 编辑数据接口 */
|
|
103
|
-
edit?: (_params: any, _currentRecord:
|
|
103
|
+
edit?: (_params: any, _currentRecord: T) => Promise<any>;
|
|
104
104
|
/** 详情数据接口 */
|
|
105
|
-
detail?: (_currentRecord:
|
|
105
|
+
detail?: (_currentRecord: T) => Promise<any>;
|
|
106
106
|
};
|
|
107
107
|
/** 全局刷新策略 */
|
|
108
108
|
refreshStrategy?: RefreshStrategy;
|
|
@@ -113,5 +113,11 @@ export type CRUDProps = {
|
|
|
113
113
|
/** 删除场景刷新策略,优先级高于全局配置 */
|
|
114
114
|
deleteRefreshStrategy?: RefreshStrategy;
|
|
115
115
|
};
|
|
116
|
-
|
|
116
|
+
interface CRUDType {
|
|
117
|
+
<T extends Record<string, any> = Record<string, any>>(_props: CRUDProps<T> & {
|
|
118
|
+
ref?: React.Ref<CRUDRefProps<T>>;
|
|
119
|
+
}): React.ReactElement;
|
|
120
|
+
displayName?: string;
|
|
121
|
+
}
|
|
122
|
+
declare const forwardCRUD: CRUDType;
|
|
117
123
|
export default forwardCRUD;
|
package/dist/esm/CRUD/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var defaultStrategies = {
|
|
|
36
36
|
keepPage: true
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
function CRUDInner(props, ref) {
|
|
40
40
|
var _props$tableProps;
|
|
41
41
|
var className = props.className,
|
|
42
42
|
_props$style = props.style,
|
|
@@ -746,5 +746,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
746
746
|
className: "".concat(classname, "-table")
|
|
747
747
|
})), mergedModalFormProps && /*#__PURE__*/_jsx(ModalForm, _objectSpread({}, mergedModalFormProps))]
|
|
748
748
|
});
|
|
749
|
-
}
|
|
749
|
+
}
|
|
750
|
+
var forwardCRUD = /*#__PURE__*/forwardRef(CRUDInner);
|
|
751
|
+
forwardCRUD.displayName = 'CRUD';
|
|
750
752
|
export default forwardCRUD;
|
|
@@ -21,6 +21,7 @@ function DItem(props) {
|
|
|
21
21
|
name: name
|
|
22
22
|
}, formItemProps);
|
|
23
23
|
var hasShouldUpdate = typeof (formItemProps === null || formItemProps === void 0 ? void 0 : formItemProps.shouldUpdate) !== 'undefined';
|
|
24
|
+
var form = Form.useFormInstance();
|
|
24
25
|
if (['custom', 'other'].includes(renderType) && hasShouldUpdate) {
|
|
25
26
|
return /*#__PURE__*/_jsx(Form.Item, {
|
|
26
27
|
noStyle: true,
|
|
@@ -33,12 +34,12 @@ function DItem(props) {
|
|
|
33
34
|
}
|
|
34
35
|
if (renderType === 'custom') {
|
|
35
36
|
return render ? /*#__PURE__*/_jsx(_Fragment, {
|
|
36
|
-
children: render(otherProps, _formItemProps, props)
|
|
37
|
+
children: render(otherProps, _formItemProps, props, form)
|
|
37
38
|
}) : /*#__PURE__*/_jsx(_Fragment, {
|
|
38
39
|
children: children
|
|
39
40
|
});
|
|
40
41
|
} else if (renderType === 'other') {
|
|
41
|
-
var _children = render ? render(otherProps, _formItemProps, props) : children;
|
|
42
|
+
var _children = render ? render(otherProps, _formItemProps, props, form) : children;
|
|
42
43
|
return itemsRender.other(_formItemProps, _children);
|
|
43
44
|
} else if (renderType) {
|
|
44
45
|
return itemsRender[renderType](otherProps, _formItemProps, label, render, children);
|
|
@@ -12,8 +12,7 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
12
12
|
var DynamicFormItem = function DynamicFormItem(props) {
|
|
13
13
|
var _props$name = props.name,
|
|
14
14
|
name = _props$name === void 0 ? 'dynamicItems' : _props$name,
|
|
15
|
-
|
|
16
|
-
initialValue = _props$initialValue === void 0 ? [undefined] : _props$initialValue,
|
|
15
|
+
initialValue = props.initialValue,
|
|
17
16
|
rules = props.rules,
|
|
18
17
|
itemConfig = props.itemConfig,
|
|
19
18
|
_props$addButtonText = props.addButtonText,
|
|
@@ -26,7 +25,7 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
26
25
|
_props$removeButtonPr = props.removeButtonProps,
|
|
27
26
|
removeButtonProps = _props$removeButtonPr === void 0 ? {} : _props$removeButtonPr,
|
|
28
27
|
_props$minItems = props.minItems,
|
|
29
|
-
minItems = _props$minItems === void 0 ?
|
|
28
|
+
minItems = _props$minItems === void 0 ? 1 : _props$minItems,
|
|
30
29
|
maxItems = props.maxItems,
|
|
31
30
|
_props$showAdd = props.showAdd,
|
|
32
31
|
showAdd = _props$showAdd === void 0 ? true : _props$showAdd,
|
|
@@ -34,6 +33,9 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
34
33
|
showRemove = _props$showRemove === void 0 ? true : _props$showRemove,
|
|
35
34
|
_props$addPosition = props.addPosition,
|
|
36
35
|
addPosition = _props$addPosition === void 0 ? 'bottom' : _props$addPosition;
|
|
36
|
+
var _initialValue = initialValue !== null && initialValue !== void 0 ? initialValue : minItems === 0 ? [] : Array.from({
|
|
37
|
+
length: minItems
|
|
38
|
+
});
|
|
37
39
|
var renderItem = function renderItem(_ref, index, _ref2, totalFieldsCount) {
|
|
38
40
|
var key = _ref.key,
|
|
39
41
|
name = _ref.name;
|
|
@@ -86,7 +88,7 @@ var DynamicFormItem = function DynamicFormItem(props) {
|
|
|
86
88
|
};
|
|
87
89
|
return /*#__PURE__*/_jsx(Form.List, {
|
|
88
90
|
name: name,
|
|
89
|
-
initialValue:
|
|
91
|
+
initialValue: _initialValue,
|
|
90
92
|
rules: rules,
|
|
91
93
|
children: function children(fields, operation) {
|
|
92
94
|
return /*#__PURE__*/_jsxs(_Fragment, {
|