@pointcloud/pcloud-components 1.0.2 → 1.0.3
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/AnimatedScrollList/index.js +16 -12
- package/dist/esm/CRUD/index.js +10 -7
- package/dist/esm/CRUD/toolbar.js +7 -7
- package/dist/esm/DForm/DItem/index.d.ts +3 -2
- package/dist/esm/DForm/DItem/index.js +2 -1
- package/dist/esm/DForm/DItem/itemType.d.ts +11 -13
- package/dist/esm/DForm/index.js +8 -5
- package/dist/esm/DInput/index.js +11 -3
- package/dist/esm/DModal/index.js +16 -9
- package/dist/esm/DModal/interface.d.ts +1 -1
- package/dist/esm/DModal/styles/index.less +33 -27
- package/dist/esm/DTable/index.js +15 -13
- package/dist/esm/ModalForm/index.js +40 -45
- package/dist/umd/pcloud-components.min.css +1 -1
- package/dist/umd/pcloud-components.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
import React, { useRef, useEffect, useCallback, useContext } from 'react';
|
|
3
|
+
import React, { useRef, useEffect, useCallback, useContext, useMemo } from 'react';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { ConfigContext } from "../ConfigProvider";
|
|
6
6
|
import "./styles/index.less";
|
|
@@ -286,19 +286,23 @@ function AnimatedScrollList(props) {
|
|
|
286
286
|
}, [data, renderItem, getItemKey]);
|
|
287
287
|
|
|
288
288
|
// 容器样式
|
|
289
|
-
var containerStyle =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
289
|
+
var containerStyle = useMemo(function () {
|
|
290
|
+
return _objectSpread({
|
|
291
|
+
height: containerHeight,
|
|
292
|
+
width: containerWidth,
|
|
293
|
+
overflow: showScrollbar ? 'auto' : 'hidden',
|
|
294
|
+
position: 'relative'
|
|
295
|
+
}, style);
|
|
296
|
+
}, [containerHeight, containerWidth, showScrollbar, style]);
|
|
295
297
|
|
|
296
298
|
// 内容容器样式
|
|
297
|
-
var contentStyle = {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
var contentStyle = useMemo(function () {
|
|
300
|
+
return {
|
|
301
|
+
display: 'flex',
|
|
302
|
+
flexDirection: isVertical ? 'column' : 'row',
|
|
303
|
+
willChange: 'transform'
|
|
304
|
+
};
|
|
305
|
+
}, [isVertical]);
|
|
302
306
|
return /*#__PURE__*/_jsxs("div", {
|
|
303
307
|
className: wrapperClass,
|
|
304
308
|
children: [header && /*#__PURE__*/_jsx("div", {
|
package/dist/esm/CRUD/index.js
CHANGED
|
@@ -137,7 +137,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
137
137
|
return classNames(_defineProperty({
|
|
138
138
|
fullscreen: fullScreen
|
|
139
139
|
}, "".concat(prefixCls, "-crud"), !!prefixCls), classname, className);
|
|
140
|
-
}, [fullScreen]);
|
|
140
|
+
}, [fullScreen, prefixCls, classname, className]);
|
|
141
141
|
var visible = useMemo(function () {
|
|
142
142
|
return conditionVisible ? 'visible' : 'hidden';
|
|
143
143
|
}, [conditionVisible]);
|
|
@@ -585,6 +585,14 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
585
585
|
}, modalFormProps === null || modalFormProps === void 0 ? void 0 : modalFormProps.formProps)
|
|
586
586
|
};
|
|
587
587
|
}, [modalConfig, detailData, handleCancel, handleModalOk, modalFormProps, classname]);
|
|
588
|
+
var onActions = useMemo(function () {
|
|
589
|
+
return {
|
|
590
|
+
setFullScreen: setFullScreen,
|
|
591
|
+
handleRefresh: handleRefresh,
|
|
592
|
+
onColumnSettingChanged: onColumnSettingChanged,
|
|
593
|
+
setConditionVisible: setConditionVisible
|
|
594
|
+
};
|
|
595
|
+
}, [setFullScreen, handleRefresh, onColumnSettingChanged, setConditionVisible]);
|
|
588
596
|
useImperativeHandle(ref, function () {
|
|
589
597
|
return {
|
|
590
598
|
refresh: function refresh(strategy, refreshOptions) {
|
|
@@ -657,12 +665,7 @@ var forwardCRUD = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
657
665
|
fullScreen: fullScreen,
|
|
658
666
|
conditionVisible: conditionVisible,
|
|
659
667
|
columns: originalColumnsRef.current,
|
|
660
|
-
onActions:
|
|
661
|
-
setFullScreen: setFullScreen,
|
|
662
|
-
handleRefresh: handleRefresh,
|
|
663
|
-
onColumnSettingChanged: onColumnSettingChanged,
|
|
664
|
-
setConditionVisible: setConditionVisible
|
|
665
|
-
}
|
|
668
|
+
onActions: onActions
|
|
666
669
|
})]
|
|
667
670
|
}), /*#__PURE__*/_jsx(DTable, _objectSpread(_objectSpread({
|
|
668
671
|
ref: tableRef
|
package/dist/esm/CRUD/toolbar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
-
import { memo, useState, useRef, useEffect, useMemo } from 'react';
|
|
4
|
+
import { memo, useState, useRef, useEffect, useMemo, useCallback } from 'react';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { Popover, Checkbox, Button } from 'antd';
|
|
7
7
|
import { ReloadOutlined, FullscreenOutlined, FullscreenExitOutlined, BarsOutlined, HolderOutlined, SearchOutlined } from '@ant-design/icons';
|
|
@@ -67,18 +67,18 @@ function Toolbar(_ref) {
|
|
|
67
67
|
setRotating(false);
|
|
68
68
|
}, 500);
|
|
69
69
|
};
|
|
70
|
-
var handleConfirm = function
|
|
70
|
+
var handleConfirm = useCallback(function () {
|
|
71
71
|
var _onActions$onColumnSe;
|
|
72
72
|
setColumnSettingVisible(false);
|
|
73
73
|
onActions === null || onActions === void 0 || (_onActions$onColumnSe = onActions.onColumnSettingChanged) === null || _onActions$onColumnSe === void 0 || _onActions$onColumnSe.call(onActions, columnSetting.checkedList, columnSetting.sortedColumns);
|
|
74
|
-
};
|
|
75
|
-
var handleReset = function
|
|
74
|
+
}, [columnSetting.checkedList, columnSetting.sortedColumns]);
|
|
75
|
+
var handleReset = useCallback(function () {
|
|
76
76
|
setColumnSetting({
|
|
77
77
|
sortedColumns: columns,
|
|
78
78
|
checkedList: checkedValues
|
|
79
79
|
});
|
|
80
|
-
};
|
|
81
|
-
var onCheckAllChange = function
|
|
80
|
+
}, [columns, checkedValues]);
|
|
81
|
+
var onCheckAllChange = useCallback(function (e) {
|
|
82
82
|
var checked = e.target.checked;
|
|
83
83
|
if (checked) {
|
|
84
84
|
// 全选所有列标题
|
|
@@ -100,7 +100,7 @@ function Toolbar(_ref) {
|
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
};
|
|
103
|
+
}, [columns]);
|
|
104
104
|
useEffect(function () {
|
|
105
105
|
return function () {
|
|
106
106
|
if (timer.current) clearTimeout(timer.current);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { DItemProps } from './itemType';
|
|
3
3
|
export type { DItemProps };
|
|
4
4
|
declare function DItem(props: DItemProps): JSX.Element;
|
|
5
|
-
|
|
5
|
+
declare const _default: React.MemoExoticComponent<typeof DItem>;
|
|
6
|
+
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import React from 'react';
|
|
4
5
|
import itemsRender from "./itemsRender";
|
|
5
6
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -33,4 +34,4 @@ function DItem(props) {
|
|
|
33
34
|
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
export default DItem;
|
|
37
|
+
export default /*#__PURE__*/React.memo(DItem);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
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';
|
|
3
3
|
import { PasswordProps, TextAreaProps } from 'antd/lib/input';
|
|
4
4
|
import { RangePickerProps } from 'antd/lib/date-picker';
|
|
@@ -10,21 +10,12 @@ 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 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';
|
|
13
|
+
export type RenderType = 'custom' | 'other' | '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
14
|
export type DItemBaseProps = Pick<FormItemProps, 'label' | 'name'> & {
|
|
15
15
|
formItemProps?: FormItemProps & {
|
|
16
16
|
grid?: Omit<ColProps, 'prefixCls'>;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
-
/** 自定义渲染的DItem */
|
|
20
|
-
type CustomItemProps = DItemBaseProps & HTMLAttributes<HTMLElement> & {
|
|
21
|
-
/** 渲染类型 */
|
|
22
|
-
renderType?: 'custom' | 'other';
|
|
23
|
-
/** 自定义渲染函数 */
|
|
24
|
-
render?: (props: any, formItemProps: FormItemProps, allProps?: DItemProps) => ReactNode;
|
|
25
|
-
children?: ReactNode;
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
};
|
|
28
19
|
export type DInputItemProps = {
|
|
29
20
|
renderType?: 'dInput';
|
|
30
21
|
} & DItemBaseProps & DInputProps;
|
|
@@ -115,5 +106,12 @@ export type ButtonItemProps = {
|
|
|
115
106
|
export type DividerItemProps = {
|
|
116
107
|
renderType?: 'divider';
|
|
117
108
|
} & DItemBaseProps & DividerProps;
|
|
118
|
-
export type DItemProps =
|
|
119
|
-
|
|
109
|
+
export type DItemProps = {
|
|
110
|
+
renderType?: RenderType;
|
|
111
|
+
formItemProps?: FormItemProps & {
|
|
112
|
+
grid?: Omit<ColProps, 'prefixCls'>;
|
|
113
|
+
};
|
|
114
|
+
children?: ReactNode;
|
|
115
|
+
render?: any;
|
|
116
|
+
[key: string]: any;
|
|
117
|
+
};
|
package/dist/esm/DForm/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var _excluded = ["className", "defaultItemProps", "items", "children", "layout",
|
|
|
10
10
|
* @Description : 基于antd的Form组件
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import React, { forwardRef, useContext, useState, useEffect, useImperativeHandle } from 'react';
|
|
13
|
+
import React, { forwardRef, useContext, useState, useMemo, useEffect, useImperativeHandle } from 'react';
|
|
14
14
|
import { Form, Row, Col } from 'antd';
|
|
15
15
|
import { ConfigContext } from "../ConfigProvider";
|
|
16
16
|
import helper from "./helper";
|
|
@@ -69,13 +69,16 @@ function InternalForm(props, ref) {
|
|
|
69
69
|
getPrefixCls = _useContext.getPrefixCls;
|
|
70
70
|
var _className = "".concat(getPrefixCls('form'), " ").concat(className, " ").concat(['inlineVertical', 'grid'].includes(layout) ? 'inlineVertical' : '');
|
|
71
71
|
var _layout = ['inlineVertical', 'grid'].includes(layout) ? 'inline' : layout;
|
|
72
|
-
var
|
|
72
|
+
var propsDerivedChildren = useMemo(function () {
|
|
73
|
+
return getChildren(items, children, defaultItemProps, layout);
|
|
74
|
+
}, [items, children, defaultItemProps, layout]);
|
|
75
|
+
var _useState = useState(propsDerivedChildren),
|
|
73
76
|
_useState2 = _slicedToArray(_useState, 2),
|
|
74
77
|
itemChildren = _useState2[0],
|
|
75
78
|
setItemChildren = _useState2[1];
|
|
76
79
|
useEffect(function () {
|
|
77
|
-
setItemChildren(
|
|
78
|
-
}, [
|
|
80
|
+
setItemChildren(propsDerivedChildren);
|
|
81
|
+
}, [propsDerivedChildren]);
|
|
79
82
|
useImperativeHandle(ref, function () {
|
|
80
83
|
return {
|
|
81
84
|
setItems: function setItems(value) {
|
|
@@ -93,7 +96,7 @@ function InternalForm(props, ref) {
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
|
-
}, [items, children, defaultItemProps]);
|
|
99
|
+
}, [items, children, defaultItemProps, layout]);
|
|
97
100
|
return /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
98
101
|
className: _className,
|
|
99
102
|
layout: _layout,
|
package/dist/esm/DInput/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var _excluded = ["className", "onChange", "onCompositionStart", "onCompositionEn
|
|
|
9
9
|
* @LastEditTime : 2023-08-16 16:48:52
|
|
10
10
|
* @Description : 基于antd的Input组件
|
|
11
11
|
*/
|
|
12
|
-
import React, { useRef, forwardRef, useState, useEffect, useContext } from 'react';
|
|
12
|
+
import React, { useRef, forwardRef, useState, useEffect, useContext, useCallback } from 'react';
|
|
13
13
|
import { Input } from 'antd';
|
|
14
14
|
import { ConfigContext } from "../ConfigProvider";
|
|
15
15
|
|
|
@@ -53,7 +53,7 @@ function InternalInput(props, ref) {
|
|
|
53
53
|
|
|
54
54
|
// debounce: 默认800ms,false或0表示不开启
|
|
55
55
|
var _debounce = getDebounceTime(debounce);
|
|
56
|
-
var emitChange = function
|
|
56
|
+
var emitChange = useCallback(function (_value, e) {
|
|
57
57
|
if (_debounce > 0) {
|
|
58
58
|
clearTimeout(debounceRef.current);
|
|
59
59
|
debounceRef.current = setTimeout(function () {
|
|
@@ -62,7 +62,7 @@ function InternalInput(props, ref) {
|
|
|
62
62
|
} else {
|
|
63
63
|
onChange === null || onChange === void 0 || onChange(_value, e);
|
|
64
64
|
}
|
|
65
|
-
};
|
|
65
|
+
}, [_debounce, onChange]);
|
|
66
66
|
|
|
67
67
|
// 监听用户onChange事件(如果正在进行合成输入,则不响应用户事件)
|
|
68
68
|
var _onChange = function _onChange(e) {
|
|
@@ -88,6 +88,14 @@ function InternalInput(props, ref) {
|
|
|
88
88
|
useEffect(function () {
|
|
89
89
|
return setValue(initValue);
|
|
90
90
|
}, [initValue]);
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
return function () {
|
|
93
|
+
if (debounceRef.current) {
|
|
94
|
+
clearTimeout(debounceRef.current);
|
|
95
|
+
debounceRef.current = null;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
91
99
|
return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
92
100
|
className: _className,
|
|
93
101
|
ref: ref,
|
package/dist/esm/DModal/index.js
CHANGED
|
@@ -14,16 +14,16 @@ function DModal(props) {
|
|
|
14
14
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
15
15
|
var _useContext = useContext(ConfigContext),
|
|
16
16
|
getPrefixCls = _useContext.getPrefixCls;
|
|
17
|
-
var containerRef = useRef();
|
|
17
|
+
var containerRef = useRef(null);
|
|
18
18
|
var style = useMemo(function () {
|
|
19
19
|
var _otherProps$style;
|
|
20
20
|
return _objectSpread({
|
|
21
|
-
getContainer: containerRef.current,
|
|
21
|
+
getContainer: containerRef.current || document.body,
|
|
22
22
|
width: ((_otherProps$style = otherProps.style) === null || _otherProps$style === void 0 ? void 0 : _otherProps$style.width) || '80%',
|
|
23
23
|
centered: true,
|
|
24
24
|
maskClosable: false
|
|
25
25
|
}, otherProps);
|
|
26
|
-
}, [otherProps]);
|
|
26
|
+
}, [otherProps.open, otherProps.title, otherProps.wrapClassName, otherProps.style, otherProps.centered, otherProps.width, otherProps.zIndex]);
|
|
27
27
|
useEffect(function () {
|
|
28
28
|
if (otherProps.open) {
|
|
29
29
|
document.body.style.overflow = 'hidden';
|
|
@@ -35,17 +35,24 @@ function DModal(props) {
|
|
|
35
35
|
};
|
|
36
36
|
}, [otherProps.open]);
|
|
37
37
|
useEffect(function () {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var _containerRef$current;
|
|
39
|
+
var parentElement = (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.parentElement;
|
|
40
|
+
if (parentElement) {
|
|
41
|
+
if (mode === 'absolute' || mode === 'fixed' || mode === 'panel') {
|
|
42
|
+
parentElement.style.position = '';
|
|
41
43
|
} else {
|
|
42
|
-
|
|
44
|
+
parentElement.style.position = 'relative';
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
}, [mode
|
|
47
|
+
}, [mode]);
|
|
48
|
+
var getContainerClass = function getContainerClass() {
|
|
49
|
+
if (mode === 'fixed') return 'fixed-modal-container';
|
|
50
|
+
if (mode === 'absolute' || mode === 'panel') return 'absolute-modal-container';
|
|
51
|
+
return 'relative-modal-container';
|
|
52
|
+
};
|
|
46
53
|
return /*#__PURE__*/_jsx("div", {
|
|
47
54
|
ref: containerRef,
|
|
48
|
-
className: "".concat(getPrefixCls('modal-container'), " ").concat(getPrefixCls(
|
|
55
|
+
className: "".concat(getPrefixCls('modal-container'), " ").concat(getPrefixCls(getContainerClass())),
|
|
49
56
|
children: /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({}, style), {}, {
|
|
50
57
|
children: children
|
|
51
58
|
}))
|
|
@@ -3,6 +3,6 @@ import type { ModalProps } from 'antd';
|
|
|
3
3
|
type IModalProps = Omit<ModalProps, 'className'>;
|
|
4
4
|
export interface DModalProps extends IModalProps {
|
|
5
5
|
children?: ReactNode | undefined;
|
|
6
|
-
mode?: 'absolute' | 'relative' | 'panel';
|
|
6
|
+
mode?: 'absolute' | 'relative' | 'panel' | 'fixed';
|
|
7
7
|
}
|
|
8
8
|
export {};
|
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
@import '../../commonStyle/index.less';
|
|
2
|
-
|
|
3
|
-
.@{prefix}-modal-container {
|
|
4
|
-
.ant-modal-wrap {
|
|
5
|
-
.ant-modal {
|
|
6
|
-
max-width: unset;
|
|
7
|
-
height: 100%;
|
|
8
|
-
|
|
9
|
-
.ant-modal-content {
|
|
10
|
-
width: 100%;
|
|
11
|
-
height: 100%;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.@{prefix}-absolute-modal-container {
|
|
18
|
-
.ant-modal-wrap {
|
|
19
|
-
position: fixed;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.@{prefix}-
|
|
24
|
-
.ant-modal-wrap {
|
|
25
|
-
position:
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
@import '../../commonStyle/index.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-modal-container {
|
|
4
|
+
.ant-modal-wrap {
|
|
5
|
+
.ant-modal {
|
|
6
|
+
max-width: unset;
|
|
7
|
+
height: 100%;
|
|
8
|
+
|
|
9
|
+
.ant-modal-content {
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.@{prefix}-absolute-modal-container {
|
|
18
|
+
.ant-modal-wrap {
|
|
19
|
+
position: fixed;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.@{prefix}-fixed-modal-container {
|
|
24
|
+
.ant-modal-wrap {
|
|
25
|
+
position: fixed;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.@{prefix}-relative-modal-container {
|
|
30
|
+
.ant-modal-wrap {
|
|
31
|
+
position: absolute;
|
|
32
|
+
}
|
|
33
|
+
}
|
package/dist/esm/DTable/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var _excluded = ["loadMore", "defaultColumnProps", "actionColumn", "showErrorMsg
|
|
|
9
9
|
* @LastEditTime : 2023-08-16 16:45:15
|
|
10
10
|
* @Description : 基于antd的Table组件
|
|
11
11
|
*/
|
|
12
|
-
import React, { forwardRef, useEffect, useRef, useState, useContext, useMemo, useImperativeHandle } from 'react';
|
|
12
|
+
import React, { forwardRef, useEffect, useRef, useState, useContext, useMemo, useImperativeHandle, useCallback } from 'react';
|
|
13
13
|
import { message, Table } from 'antd';
|
|
14
14
|
import { ConfigContext } from "../ConfigProvider";
|
|
15
15
|
import "./index.less";
|
|
@@ -131,19 +131,19 @@ function InternalTable(props, ref) {
|
|
|
131
131
|
// pcf-table 样式中已经包含对_scroll的支持
|
|
132
132
|
var _className = "".concat(getPrefixCls('table'), " ").concat(className || '', " ").concat(_pagination ? 'height-on-page' : '');
|
|
133
133
|
|
|
134
|
-
// loading 默认延迟
|
|
134
|
+
// loading 默认延迟 300ms
|
|
135
135
|
var _loading = useMemo(function () {
|
|
136
136
|
return typeof loading === 'boolean' ? {
|
|
137
137
|
spinning: loading,
|
|
138
|
-
delay:
|
|
138
|
+
delay: 300
|
|
139
139
|
} : _objectSpread({
|
|
140
|
-
delay:
|
|
140
|
+
delay: 300,
|
|
141
141
|
spinning: false
|
|
142
142
|
}, loading);
|
|
143
143
|
}, [loading]);
|
|
144
144
|
|
|
145
145
|
// 加载数据
|
|
146
|
-
var loadData = function
|
|
146
|
+
var loadData = useCallback(function (params) {
|
|
147
147
|
if (typeof loadMore === 'function') {
|
|
148
148
|
setTableSource(_objectSpread(_objectSpread({}, tableSource), {}, {
|
|
149
149
|
loading: true
|
|
@@ -165,9 +165,11 @@ function InternalTable(props, ref) {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
}).catch(function (err) {
|
|
168
|
-
setTableSource(
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
setTableSource(function (prev) {
|
|
169
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
170
|
+
loading: false
|
|
171
|
+
});
|
|
172
|
+
});
|
|
171
173
|
if (showErrorMsg) {
|
|
172
174
|
var _err$response;
|
|
173
175
|
var errMsg = (err === null || err === void 0 || (_err$response = err.response) === null || _err$response === void 0 || (_err$response = _err$response.data) === null || _err$response === void 0 ? void 0 : _err$response.msg) || (err === null || err === void 0 ? void 0 : err.msg) || (err === null || err === void 0 ? void 0 : err.message);
|
|
@@ -185,16 +187,16 @@ function InternalTable(props, ref) {
|
|
|
185
187
|
records: dataSource
|
|
186
188
|
});
|
|
187
189
|
}
|
|
188
|
-
};
|
|
190
|
+
}, [loadMore, dataSource, _pagination]);
|
|
189
191
|
|
|
190
192
|
// 手动刷新方法
|
|
191
|
-
var refresh = function
|
|
193
|
+
var refresh = useCallback(function (params) {
|
|
192
194
|
var refreshParams = _objectSpread(_objectSpread({}, tableParams), params);
|
|
193
195
|
loadData(refreshParams);
|
|
194
|
-
};
|
|
196
|
+
}, [tableParams, loadData]);
|
|
195
197
|
|
|
196
198
|
// 监听分页大小变化,如果外部也监听了onChange,则不会触发loadMore,但如果外部onChange返回值为undefined则正常触loadMore
|
|
197
|
-
var onChange = function
|
|
199
|
+
var onChange = useCallback(function (page, pageSize) {
|
|
198
200
|
if (_pagination && typeof (_pagination === null || _pagination === void 0 ? void 0 : _pagination.onChange) === 'function') {
|
|
199
201
|
var data = _pagination.onChange(page, pageSize);
|
|
200
202
|
if (data === undefined) loadData(_objectSpread(_objectSpread({}, tableParams), {}, {
|
|
@@ -207,7 +209,7 @@ function InternalTable(props, ref) {
|
|
|
207
209
|
size: pageSize
|
|
208
210
|
}));
|
|
209
211
|
}
|
|
210
|
-
};
|
|
212
|
+
}, [tableParams, loadData, _pagination]);
|
|
211
213
|
var _tablePagination = _pagination ? _objectSpread(_objectSpread({}, _pagination), {}, {
|
|
212
214
|
total: tableSource.total,
|
|
213
215
|
current: tableParams.current,
|
|
@@ -4,7 +4,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
import DForm from "../DForm";
|
|
6
6
|
import DModal from "../DModal";
|
|
7
|
-
import { useEffect, useState, useMemo } from 'react';
|
|
7
|
+
import { useEffect, useState, useMemo, useCallback } from 'react';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
export default (function (props) {
|
|
@@ -31,51 +31,46 @@ export default (function (props) {
|
|
|
31
31
|
var modalFooter = !!(formProps !== null && formProps !== void 0 && formProps.disabled) ? {
|
|
32
32
|
footer: null
|
|
33
33
|
} : {};
|
|
34
|
-
var handleOk = /*#__PURE__*/function () {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!onOk) {
|
|
46
|
-
_context.next = 8;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
// 如果外部没有提供loading状态,内部自动管理
|
|
50
|
-
if (modalProps.confirmLoading === undefined) {
|
|
51
|
-
setIsLoading(true);
|
|
52
|
-
}
|
|
34
|
+
var handleOk = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
35
|
+
var values;
|
|
36
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
_context.prev = 0;
|
|
40
|
+
_context.next = 3;
|
|
41
|
+
return form.validateFields();
|
|
42
|
+
case 3:
|
|
43
|
+
values = _context.sent;
|
|
44
|
+
if (!onOk) {
|
|
53
45
|
_context.next = 8;
|
|
54
|
-
return onOk === null || onOk === void 0 ? void 0 : onOk(values);
|
|
55
|
-
case 8:
|
|
56
|
-
_context.next = 14;
|
|
57
46
|
break;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
}
|
|
48
|
+
// 如果外部没有提供loading状态,内部自动管理
|
|
49
|
+
if (modalProps.confirmLoading === undefined) {
|
|
50
|
+
setIsLoading(true);
|
|
51
|
+
}
|
|
52
|
+
_context.next = 8;
|
|
53
|
+
return onOk === null || onOk === void 0 ? void 0 : onOk(values);
|
|
54
|
+
case 8:
|
|
55
|
+
_context.next = 14;
|
|
56
|
+
break;
|
|
57
|
+
case 10:
|
|
58
|
+
_context.prev = 10;
|
|
59
|
+
_context.t0 = _context["catch"](0);
|
|
60
|
+
console.error('Form validation failed:', _context.t0);
|
|
61
|
+
onError === null || onError === void 0 || onError(_context.t0);
|
|
62
|
+
case 14:
|
|
63
|
+
_context.prev = 14;
|
|
64
|
+
if (modalProps.confirmLoading === undefined) {
|
|
65
|
+
setIsLoading(false);
|
|
66
|
+
}
|
|
67
|
+
return _context.finish(14);
|
|
68
|
+
case 17:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
72
|
+
}, _callee, null, [[0, 10, 14, 17]]);
|
|
73
|
+
})), [form, modalProps.confirmLoading, onOk, onError]);
|
|
79
74
|
useEffect(function () {
|
|
80
75
|
if (open) {
|
|
81
76
|
var _Object$keys;
|
|
@@ -90,7 +85,7 @@ export default (function (props) {
|
|
|
90
85
|
} else {
|
|
91
86
|
setIsLoading(false);
|
|
92
87
|
}
|
|
93
|
-
}, [open
|
|
88
|
+
}, [open]);
|
|
94
89
|
return /*#__PURE__*/_jsxs(DModal, _objectSpread(_objectSpread(_objectSpread({
|
|
95
90
|
open: open,
|
|
96
91
|
style: {
|