@pointcloud/pcloud-components 1.0.12 → 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.
@@ -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: any[];
18
+ selectedRows: T[];
19
19
  };
20
20
  getSearchValues: () => Record<string, any>;
21
- openAddModal: (_record?: any) => void;
22
- openEditModal: (_record?: any) => void;
23
- openDeleteModal: (_record?: any) => void;
24
- openDetailModal: (_record?: any) => void;
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: any) => boolean;
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: any) => boolean;
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: any) => boolean;
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: any) => Promise<any>;
99
+ delete?: (_currentRecord: T) => Promise<any>;
100
100
  /** 新增数据接口 */
101
101
  add?: (_params: any) => Promise<any>;
102
102
  /** 编辑数据接口 */
103
- edit?: (_params: any, _currentRecord: any) => Promise<any>;
103
+ edit?: (_params: any, _currentRecord: T) => Promise<any>;
104
104
  /** 详情数据接口 */
105
- detail?: (_currentRecord: any) => Promise<any>;
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
- declare const forwardCRUD: React.ForwardRefExoticComponent<CRUDProps & React.RefAttributes<CRUDRefProps>>;
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;
@@ -36,7 +36,7 @@ var defaultStrategies = {
36
36
  keepPage: true
37
37
  }
38
38
  };
39
- var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
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);
@@ -104,7 +104,7 @@ export default (function (props) {
104
104
  onOk: handleOk
105
105
  })), {}, {
106
106
  children: [children, /*#__PURE__*/_jsx(DForm, _objectSpread(_objectSpread({}, formProps), {}, {
107
- form: form
107
+ form: formInstance
108
108
  }))]
109
109
  }));
110
110
  });