@pointcloud/pcloud-components 1.0.6 → 1.0.7
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 +4 -1
- package/dist/esm/CRUD/index.js +18 -7
- package/dist/esm/DForm/DItem/index.js +15 -3
- package/dist/esm/DForm/DItem/itemType.d.ts +3 -2
- package/dist/esm/DForm/DItem/itemsRender.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +1 -1
package/dist/esm/CRUD/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ModalFuncProps, type ButtonProps } from 'antd';
|
|
3
3
|
import { type DFormProps } from '../DForm';
|
|
4
|
-
import { DTableSourceProps, type DTableProps } from '../DTable';
|
|
4
|
+
import { type DTableSourceProps, type DTableProps } from '../DTable';
|
|
5
5
|
import type { DModalProps } from '../DModal/interface';
|
|
6
6
|
import './index.less';
|
|
7
7
|
export type RefreshStrategy = {
|
|
@@ -23,6 +23,7 @@ export type CRUDRefProps = {
|
|
|
23
23
|
openDeleteModal: (_record?: any) => void;
|
|
24
24
|
openDetailModal: (_record?: any) => void;
|
|
25
25
|
};
|
|
26
|
+
export type MoreActionColumnRender = (_text: any, _record: Record<string, any>) => React.ReactNode;
|
|
26
27
|
export type CRUDProps = {
|
|
27
28
|
className?: string;
|
|
28
29
|
style?: React.CSSProperties;
|
|
@@ -70,6 +71,8 @@ export type CRUDProps = {
|
|
|
70
71
|
viewButtonText?: string;
|
|
71
72
|
/** 行查看按钮配置 */
|
|
72
73
|
viewButtonProps?: ButtonProps;
|
|
74
|
+
/** 更多操作列自定义渲染,参数为(text, record),返回ReactNode */
|
|
75
|
+
moreActionColumn?: MoreActionColumnRender;
|
|
73
76
|
/** 自定义操作栏 */
|
|
74
77
|
actionBar?: React.ReactNode;
|
|
75
78
|
/** 数据刷新回调 */
|
package/dist/esm/CRUD/index.js
CHANGED
|
@@ -9,8 +9,8 @@ var _excluded = ["immediate"],
|
|
|
9
9
|
_excluded2 = ["columns", "extraParams"];
|
|
10
10
|
import React, { useMemo, useState, useContext, useCallback, useRef, forwardRef, useImperativeHandle, useEffect } from 'react';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
|
-
import { Button } from 'antd';
|
|
13
|
-
import { PlusOutlined, EditOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons';
|
|
12
|
+
import { Button, Popover } from 'antd';
|
|
13
|
+
import { PlusOutlined, EditOutlined, DeleteOutlined, EyeOutlined, MoreOutlined } from '@ant-design/icons';
|
|
14
14
|
import { ConfigContext } from "../ConfigProvider";
|
|
15
15
|
import { SearchButtons } from "./config";
|
|
16
16
|
import DForm from "../DForm";
|
|
@@ -74,6 +74,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
74
74
|
viewButtonText = _props$viewButtonText === void 0 ? '查看' : _props$viewButtonText,
|
|
75
75
|
_props$batchDeleteBut = props.batchDeleteButtonText,
|
|
76
76
|
batchDeleteButtonText = _props$batchDeleteBut === void 0 ? '批量删除' : _props$batchDeleteBut,
|
|
77
|
+
moreActionColumn = props.moreActionColumn,
|
|
77
78
|
actionBar = props.actionBar,
|
|
78
79
|
onRefresh = props.onRefresh,
|
|
79
80
|
crudApi = props.crudApi,
|
|
@@ -193,7 +194,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
193
194
|
});
|
|
194
195
|
}, [deleteRefreshStrategy.keepSearchValues, deleteRefreshStrategy.keepPage]);
|
|
195
196
|
var mergedFormProps = useMemo(function () {
|
|
196
|
-
var _restSearchFormProps
|
|
197
|
+
var _restSearchFormProps$, _restSearchFormProps$2;
|
|
197
198
|
if (!searchFormProps) return {};
|
|
198
199
|
var immediate = searchFormProps.immediate,
|
|
199
200
|
restSearchFormProps = _objectWithoutProperties(searchFormProps, _excluded);
|
|
@@ -202,9 +203,10 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
202
203
|
});
|
|
203
204
|
var searchBtns = immediate || isExistFormButton ? [] : SearchButtons;
|
|
204
205
|
return _objectSpread(_objectSpread({}, restSearchFormProps), {}, {
|
|
206
|
+
layout: (_restSearchFormProps$2 = restSearchFormProps.layout) !== null && _restSearchFormProps$2 !== void 0 ? _restSearchFormProps$2 : 'inline',
|
|
205
207
|
items: [].concat(_toConsumableArray((searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps['items']) || []), _toConsumableArray(searchBtns))
|
|
206
208
|
});
|
|
207
|
-
}, [searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.immediate, searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.items, searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.initialValues]);
|
|
209
|
+
}, [searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.immediate, searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.items, searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.initialValues, searchFormProps === null || searchFormProps === void 0 ? void 0 : searchFormProps.layout]);
|
|
208
210
|
var isNeedRefreshToPage = useCallback(function () {
|
|
209
211
|
var _tableRef$current, _tableRef$current$get;
|
|
210
212
|
var deletedCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
@@ -503,7 +505,6 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
503
505
|
};
|
|
504
506
|
}(), [detailApi]);
|
|
505
507
|
var actionColumn = useMemo(function () {
|
|
506
|
-
// 捕获当前的API方法引用,避免闭包问题
|
|
507
508
|
var currentHandleEdit = handleEdit;
|
|
508
509
|
var currentHandleDelete = handleDelete;
|
|
509
510
|
var currentHandleView = handleView;
|
|
@@ -538,10 +539,20 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
538
539
|
size: "small"
|
|
539
540
|
}, viewButtonProps), {}, {
|
|
540
541
|
children: viewButtonText
|
|
541
|
-
}))
|
|
542
|
+
})), moreActionColumn && /*#__PURE__*/_jsx(Popover, {
|
|
543
|
+
trigger: "click",
|
|
544
|
+
placement: "bottomRight",
|
|
545
|
+
content: moreActionColumn(_text, record),
|
|
546
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
547
|
+
type: "link",
|
|
548
|
+
icon: /*#__PURE__*/_jsx(MoreOutlined, {}),
|
|
549
|
+
size: "small",
|
|
550
|
+
children: "\u66F4\u591A"
|
|
551
|
+
})
|
|
552
|
+
})]
|
|
542
553
|
});
|
|
543
554
|
};
|
|
544
|
-
}, [handleEdit, handleDelete, handleView, showEdit, showDelete, showView, editButtonText, deleteButtonText, viewButtonText]);
|
|
555
|
+
}, [handleEdit, handleDelete, handleView, showEdit, showDelete, showView, editButtonText, deleteButtonText, viewButtonText, moreActionColumn]);
|
|
545
556
|
var tablePropsWithSearch = useMemo(function () {
|
|
546
557
|
var _ref6 = tableProps || {},
|
|
547
558
|
_ref6$columns = _ref6.columns,
|
|
@@ -2,16 +2,17 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["formItemProps", "label", "name", "renderType", "render", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { Form } from 'antd';
|
|
5
6
|
import itemsRender from "./itemsRender";
|
|
6
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
9
|
function DItem(props) {
|
|
9
|
-
// @ts-ignore
|
|
10
10
|
var formItemProps = props.formItemProps,
|
|
11
11
|
_props$label = props.label,
|
|
12
12
|
label = _props$label === void 0 ? '' : _props$label,
|
|
13
13
|
name = props.name,
|
|
14
|
-
renderType = props.renderType,
|
|
14
|
+
_props$renderType = props.renderType,
|
|
15
|
+
renderType = _props$renderType === void 0 ? '' : _props$renderType,
|
|
15
16
|
render = props.render,
|
|
16
17
|
children = props.children,
|
|
17
18
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
@@ -19,6 +20,17 @@ function DItem(props) {
|
|
|
19
20
|
label: label,
|
|
20
21
|
name: name
|
|
21
22
|
}, formItemProps);
|
|
23
|
+
var hasShouldUpdate = typeof (formItemProps === null || formItemProps === void 0 ? void 0 : formItemProps.shouldUpdate) !== 'undefined';
|
|
24
|
+
if (['custom', 'other'].includes(renderType) && hasShouldUpdate) {
|
|
25
|
+
return /*#__PURE__*/_jsx(Form.Item, {
|
|
26
|
+
noStyle: true,
|
|
27
|
+
shouldUpdate: formItemProps.shouldUpdate,
|
|
28
|
+
children: function children(form) {
|
|
29
|
+
var renderResult = render ? render(otherProps, _formItemProps, props, form) : null;
|
|
30
|
+
return renderResult;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
22
34
|
if (renderType === 'custom') {
|
|
23
35
|
return render ? /*#__PURE__*/_jsx(_Fragment, {
|
|
24
36
|
children: render(otherProps, _formItemProps, props)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { InputProps, InputNumberProps, AutoCompleteProps, CascaderProps, SelectProps, TreeSelectProps, DatePickerProps, TimePickerProps, MentionProps, CheckboxProps, RadioProps, RateProps, SliderSingleProps, SwitchProps, TransferProps, UploadProps, ButtonProps, DividerProps, FormItemProps, RadioGroupProps, ColProps } from 'antd';
|
|
2
|
+
import { InputProps, InputNumberProps, AutoCompleteProps, CascaderProps, SelectProps, TreeSelectProps, DatePickerProps, TimePickerProps, MentionProps, CheckboxProps, RadioProps, RateProps, SliderSingleProps, SwitchProps, TransferProps, UploadProps, ButtonProps, DividerProps, FormItemProps, RadioGroupProps, ColProps, FormInstance } from 'antd';
|
|
3
3
|
import { PasswordProps, TextAreaProps } from 'antd/lib/input';
|
|
4
4
|
import { RangePickerProps } from 'antd/lib/date-picker';
|
|
5
5
|
import { CheckboxGroupProps } from 'antd/lib/checkbox';
|
|
@@ -112,6 +112,7 @@ export type DItemProps = {
|
|
|
112
112
|
grid?: Omit<ColProps, 'prefixCls'>;
|
|
113
113
|
};
|
|
114
114
|
children?: ReactNode;
|
|
115
|
-
render?: any;
|
|
115
|
+
render?: (_props: any, _formItemProps: FormItemProps, _allProps?: DItemProps, _form?: FormInstance) => ReactNode;
|
|
116
|
+
} & {
|
|
116
117
|
[key: string]: any;
|
|
117
118
|
};
|
|
@@ -39,7 +39,7 @@ declare const renderMap: {
|
|
|
39
39
|
switch: (props: SwitchProps, formItemProps: FormItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
40
|
transfer: (props: TransferProps<any>, formItemProps: FormItemProps, label: DItemBaseProps['label'], render: TransferProps<any>['render']) => import("react/jsx-runtime").JSX.Element;
|
|
41
41
|
upload: (props: UploadProps, formItemProps: FormItemProps, label: DItemBaseProps['label'], render: () => void, children: UploadProps['children']) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
-
dUpload: (props: DUploadProps, formItemProps: FormItemProps, render: (
|
|
42
|
+
dUpload: (props: DUploadProps, formItemProps: FormItemProps, render: (_props: any) => ReactNode, children: DUploadProps['children']) => import("react/jsx-runtime").JSX.Element;
|
|
43
43
|
button: (props: ButtonProps, formItemProps: FormItemProps, label: DItemBaseProps['label']) => import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
divider: (props: DividerProps, formItemProps: FormItemProps, label: DItemBaseProps['label']) => import("react/jsx-runtime").JSX.Element;
|
|
45
45
|
other: (formItemProps: FormItemProps, children: ReactNode) => import("react/jsx-runtime").JSX.Element;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -65,6 +65,6 @@ export type { AnimatedScrollListProps } from './AnimatedScrollList/interface';
|
|
|
65
65
|
export { default as DRangePicker } from './DRangePicker';
|
|
66
66
|
export type { DRangePickerProps } from './DRangePicker/interface';
|
|
67
67
|
export { default as CRUD } from './CRUD';
|
|
68
|
-
export { type CRUDProps, type CRUDRefProps } from './CRUD';
|
|
68
|
+
export { type CRUDProps, type CRUDRefProps, type MoreActionColumnRender } from './CRUD';
|
|
69
69
|
export { default as DynamicFormItem } from './DynamicFormItem';
|
|
70
70
|
export type { DynamicFormItemProps } from './DynamicFormItem';
|