@ant-design/pro-components 3.1.3-1 → 3.1.4-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/dist/pro-components.min.js +1 -1
- package/es/card/components/Actions/index.js +1 -4
- package/es/card/components/Card/index.js +23 -15
- package/es/card/components/Card/style.js +34 -8
- package/es/card/components/CheckCard/Group.js +1 -3
- package/es/card/components/CheckCard/index.js +0 -1
- package/es/card/components/Divider/index.d.ts +1 -1
- package/es/card/components/Divider/index.js +2 -2
- package/es/card/components/Divider/style.d.ts +4 -1
- package/es/card/components/Divider/style.js +6 -39
- package/es/card/components/Statistic/index.js +1 -1
- package/es/card/typing.d.ts +2 -6
- package/es/descriptions/index.d.ts +3 -5
- package/es/descriptions/index.js +6 -6
- package/es/descriptions/useFetchData.js +0 -1
- package/es/field/AllProField.js +0 -4
- package/es/field/PureProField.js +0 -5
- package/es/field/components/Checkbox/index.js +2 -5
- package/es/field/components/DatePicker/index.d.ts +1 -1
- package/es/field/components/DigitRange/index.js +1 -0
- package/es/field/components/Options/index.js +0 -3
- package/es/field/components/Percent/util.d.ts +1 -1
- package/es/field/components/RangePicker/index.d.ts +1 -1
- package/es/field/components/Select/SearchSelect/index.js +0 -1
- package/es/field/components/Switch/index.js +0 -1
- package/es/field/components/Text/index.js +4 -1
- package/es/form/BaseForm/BaseForm.js +0 -3
- package/es/form/BaseForm/LightWrapper/index.d.ts +2 -1
- package/es/form/components/Captcha/index.js +0 -3
- package/es/form/components/Checkbox/index.js +5 -1
- package/es/form/components/DatePicker/index.js +0 -2
- package/es/form/components/FieldSet/index.js +16 -6
- package/es/form/components/FormItem/index.js +9 -7
- package/es/form/components/FormItem/warpField.js +3 -15
- package/es/form/components/List/index.d.ts +1 -1
- package/es/form/components/List/index.js +0 -2
- package/es/form/components/Radio/index.js +5 -4
- package/es/form/components/SchemaForm/index.js +0 -1
- package/es/form/components/SchemaForm/layoutType/StepsForm.js +0 -1
- package/es/form/components/Select/index.js +0 -1
- package/es/form/components/Text/index.js +0 -3
- package/es/form/components/UploadButton/index.js +4 -2
- package/es/form/components/UploadDragger/index.js +0 -1
- package/es/form/helpers/grid.js +1 -5
- package/es/form/layouts/DrawerForm/index.js +1 -5
- package/es/form/layouts/LightFilter/index.js +0 -1
- package/es/form/layouts/ModalForm/index.js +1 -4
- package/es/form/layouts/ProForm/index.d.ts +1 -1
- package/es/form/layouts/QueryFilter/index.js +0 -1
- package/es/form/layouts/StepsForm/StepForm.js +0 -1
- package/es/form/layouts/StepsForm/index.js +3 -12
- package/es/layout/ProLayout.js +1 -6
- package/es/layout/components/AppsLogoComponents/style/index.js +4 -0
- package/es/layout/components/FooterToolbar/index.js +0 -3
- package/es/layout/components/GlobalHeader/ActionsContent.js +0 -1
- package/es/layout/components/Header/index.js +1 -3
- package/es/layout/components/PageContainer/index.js +0 -1
- package/es/layout/components/PageContainer/style/index.js +4 -0
- package/es/layout/components/SettingDrawer/BlockCheckbox.js +0 -1
- package/es/layout/components/SettingDrawer/index.js +0 -1
- package/es/layout/components/SettingDrawer/style/index.js +4 -0
- package/es/layout/components/SiderMenu/BaseMenu.js +2 -6
- package/es/layout/components/SiderMenu/SiderMenu.js +1 -3
- package/es/layout/components/SiderMenu/index.js +0 -1
- package/es/layout/components/TopNavHeader/index.js +1 -2
- package/es/layout/style/index.js +4 -0
- package/es/layout/utils/getMenuData.js +0 -1
- package/es/list/Item.d.ts +1 -4
- package/es/list/Item.js +75 -104
- package/es/list/ListView.d.ts +6 -4
- package/es/list/ListView.js +41 -53
- package/es/list/ProListBase.d.ts +74 -0
- package/es/list/ProListBase.js +350 -0
- package/es/list/constants.d.ts +2 -2
- package/es/list/constants.js +2 -5
- package/es/list/index.d.ts +23 -13
- package/es/list/index.js +78 -41
- package/es/list/style/index.d.ts +0 -1
- package/es/list/style/index.js +215 -86
- package/es/provider/index.js +0 -3
- package/es/provider/useStyle/index.d.ts +1 -21
- package/es/provider/useStyle/index.js +6 -3
- package/es/skeleton/components/Descriptions/index.js +1 -4
- package/es/skeleton/components/List/index.js +1 -4
- package/es/table/Store/Provide.js +0 -2
- package/es/table/Table.js +5 -14
- package/es/table/components/ColumnSetting/index.js +0 -1
- package/es/table/components/EditableTable/index.js +0 -1
- package/es/table/components/ListToolBar/index.d.ts +1 -1
- package/es/table/components/ListToolBar/index.js +4 -10
- package/es/table/components/ListToolBar/style.js +1 -1
- package/es/table/components/ToolBar/index.d.ts +1 -1
- package/es/table/style/index.js +4 -0
- package/es/table/typing.d.ts +10 -5
- package/es/table/useFetchData.js +0 -3
- package/es/table/utils/cellRenderToFromItem.js +1 -3
- package/es/table/utils/index.js +0 -1
- package/es/utils/components/LabelIconTip/index.d.ts +3 -4
- package/es/utils/genCopyable/index.d.ts +6 -0
- package/es/utils/genCopyable/index.js +28 -8
- package/es/utils/hooks/useDebounceValue/index.js +1 -3
- package/es/utils/hooks/useDeepCompareEffect/index.js +0 -2
- package/es/utils/index.d.ts +2 -1
- package/es/utils/isDeepEqualReact/index.js +0 -8
- package/es/utils/merge/index.js +0 -3
- package/es/utils/nanoid/index.d.ts +1 -3
- package/es/utils/nanoid/index.js +2 -10
- package/es/utils/proFieldParsingText/index.js +1 -3
- package/es/utils/typing.d.ts +2 -1
- package/es/utils/useEditableArray/index.js +1 -1
- package/es/utils/useEditableMap/index.js +1 -1
- package/guidelines/overview-components.md +1 -1
- package/lib/card/components/Actions/index.js +1 -4
- package/lib/card/components/Card/index.js +23 -15
- package/lib/card/components/Card/style.js +34 -8
- package/lib/card/components/CheckCard/Group.js +1 -3
- package/lib/card/components/CheckCard/index.js +0 -1
- package/lib/card/components/Divider/index.d.ts +1 -1
- package/lib/card/components/Divider/index.js +2 -2
- package/lib/card/components/Divider/style.d.ts +4 -1
- package/lib/card/components/Divider/style.js +5 -39
- package/lib/card/components/Statistic/index.js +1 -1
- package/lib/card/typing.d.ts +2 -6
- package/lib/descriptions/index.d.ts +3 -5
- package/lib/descriptions/index.js +6 -6
- package/lib/descriptions/useFetchData.js +0 -1
- package/lib/field/AllProField.js +0 -4
- package/lib/field/PureProField.js +0 -5
- package/lib/field/components/Checkbox/index.js +2 -5
- package/lib/field/components/DatePicker/index.d.ts +1 -1
- package/lib/field/components/DigitRange/index.js +1 -0
- package/lib/field/components/Options/index.js +0 -3
- package/lib/field/components/Percent/util.d.ts +1 -1
- package/lib/field/components/RangePicker/index.d.ts +1 -1
- package/lib/field/components/Select/SearchSelect/index.js +0 -1
- package/lib/field/components/Switch/index.js +0 -1
- package/lib/field/components/Text/index.js +4 -1
- package/lib/form/BaseForm/BaseForm.js +0 -4
- package/lib/form/BaseForm/LightWrapper/index.d.ts +2 -1
- package/lib/form/components/Captcha/index.js +0 -3
- package/lib/form/components/Checkbox/index.js +5 -1
- package/lib/form/components/DatePicker/index.js +0 -2
- package/lib/form/components/FieldSet/index.js +16 -6
- package/lib/form/components/FormItem/index.js +9 -7
- package/lib/form/components/FormItem/warpField.js +3 -15
- package/lib/form/components/List/index.d.ts +1 -1
- package/lib/form/components/List/index.js +0 -2
- package/lib/form/components/Radio/index.js +5 -4
- package/lib/form/components/SchemaForm/index.js +0 -1
- package/lib/form/components/SchemaForm/layoutType/StepsForm.js +0 -1
- package/lib/form/components/Select/index.js +0 -1
- package/lib/form/components/Text/index.js +0 -3
- package/lib/form/components/UploadButton/index.js +4 -2
- package/lib/form/components/UploadDragger/index.js +0 -1
- package/lib/form/helpers/grid.js +1 -5
- package/lib/form/layouts/DrawerForm/index.js +1 -5
- package/lib/form/layouts/LightFilter/index.js +0 -1
- package/lib/form/layouts/ModalForm/index.js +1 -4
- package/lib/form/layouts/ProForm/index.d.ts +1 -1
- package/lib/form/layouts/QueryFilter/index.js +0 -2
- package/lib/form/layouts/StepsForm/StepForm.js +0 -1
- package/lib/form/layouts/StepsForm/index.js +3 -12
- package/lib/layout/ProLayout.js +1 -6
- package/lib/layout/components/AppsLogoComponents/style/index.js +4 -0
- package/lib/layout/components/FooterToolbar/index.js +0 -4
- package/lib/layout/components/GlobalHeader/ActionsContent.js +0 -1
- package/lib/layout/components/Header/index.js +1 -3
- package/lib/layout/components/PageContainer/index.js +0 -1
- package/lib/layout/components/PageContainer/style/index.js +4 -0
- package/lib/layout/components/SettingDrawer/BlockCheckbox.js +0 -1
- package/lib/layout/components/SettingDrawer/index.js +0 -1
- package/lib/layout/components/SettingDrawer/style/index.js +4 -0
- package/lib/layout/components/SiderMenu/BaseMenu.js +2 -6
- package/lib/layout/components/SiderMenu/SiderMenu.js +1 -3
- package/lib/layout/components/SiderMenu/index.js +0 -1
- package/lib/layout/components/TopNavHeader/index.js +1 -2
- package/lib/layout/style/index.js +4 -0
- package/lib/layout/utils/getMenuData.js +0 -1
- package/lib/list/Item.d.ts +1 -4
- package/lib/list/Item.js +74 -103
- package/lib/list/ListView.d.ts +6 -4
- package/lib/list/ListView.js +40 -52
- package/lib/list/ProListBase.d.ts +74 -0
- package/lib/list/ProListBase.js +357 -0
- package/lib/list/constants.d.ts +2 -2
- package/lib/list/constants.js +2 -5
- package/lib/list/index.d.ts +23 -13
- package/lib/list/index.js +77 -40
- package/lib/list/style/index.d.ts +0 -1
- package/lib/list/style/index.js +214 -86
- package/lib/provider/index.js +0 -3
- package/lib/provider/useStyle/index.d.ts +1 -21
- package/lib/provider/useStyle/index.js +6 -3
- package/lib/skeleton/components/Descriptions/index.js +1 -4
- package/lib/skeleton/components/List/index.js +1 -4
- package/lib/table/Store/Provide.js +0 -2
- package/lib/table/Table.js +5 -14
- package/lib/table/components/ColumnSetting/index.js +0 -1
- package/lib/table/components/EditableTable/index.js +0 -1
- package/lib/table/components/ListToolBar/index.d.ts +1 -1
- package/lib/table/components/ListToolBar/index.js +4 -10
- package/lib/table/components/ListToolBar/style.js +1 -1
- package/lib/table/components/ToolBar/index.d.ts +1 -1
- package/lib/table/style/index.js +4 -0
- package/lib/table/typing.d.ts +10 -5
- package/lib/table/useFetchData.js +0 -3
- package/lib/table/utils/cellRenderToFromItem.js +1 -3
- package/lib/table/utils/index.js +0 -1
- package/lib/utils/components/LabelIconTip/index.d.ts +3 -4
- package/lib/utils/genCopyable/index.d.ts +6 -0
- package/lib/utils/genCopyable/index.js +28 -8
- package/lib/utils/hooks/useDebounceValue/index.js +1 -3
- package/lib/utils/hooks/useDeepCompareEffect/index.js +0 -2
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/isDeepEqualReact/index.js +0 -8
- package/lib/utils/merge/index.js +0 -3
- package/lib/utils/nanoid/index.d.ts +1 -3
- package/lib/utils/nanoid/index.js +2 -10
- package/lib/utils/proFieldParsingText/index.js +1 -3
- package/lib/utils/typing.d.ts +2 -1
- package/lib/utils/useEditableArray/index.js +0 -2
- package/lib/utils/useEditableMap/index.js +0 -2
- package/package.json +4 -5
package/es/list/Item.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { RightOutlined } from '@ant-design/icons';
|
|
2
2
|
import { useControlledState } from '@rc-component/util';
|
|
3
|
-
import { ConfigProvider,
|
|
3
|
+
import { ConfigProvider, Skeleton } from 'antd';
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
import React, { useCallback, useContext, useMemo } from 'react';
|
|
6
6
|
import { CheckCard } from "../card";
|
|
7
7
|
import { ProProvider } from "../provider";
|
|
8
|
+
import { ProListItem as BaseListItem, ProListItemMeta as BaseListItemMeta } from "./ProListBase";
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -39,26 +40,26 @@ export function renderExpandIcon({
|
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
function ProListItem(props) {
|
|
42
|
-
const {
|
|
43
|
-
prefixCls: customizePrefixCls
|
|
44
|
-
} = props;
|
|
45
43
|
const {
|
|
46
44
|
getPrefixCls
|
|
47
45
|
} = useContext(ConfigProvider.ConfigContext);
|
|
48
46
|
const {
|
|
49
47
|
hashId
|
|
50
48
|
} = useContext(ProProvider);
|
|
51
|
-
const prefixCls = getPrefixCls('pro-list',
|
|
49
|
+
const prefixCls = getPrefixCls('pro-list', props.prefixCls);
|
|
52
50
|
const defaultClassName = `${prefixCls}-row`;
|
|
53
51
|
const {
|
|
54
52
|
title,
|
|
55
53
|
subTitle,
|
|
56
54
|
content,
|
|
57
55
|
itemTitleRender,
|
|
58
|
-
prefixCls:
|
|
56
|
+
prefixCls: _prefixCls,
|
|
57
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
59
58
|
actions,
|
|
60
|
-
item,
|
|
61
|
-
|
|
59
|
+
item: _item,
|
|
60
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
61
|
+
recordKey: _recordKey,
|
|
62
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
62
63
|
avatar,
|
|
63
64
|
cardProps,
|
|
64
65
|
description,
|
|
@@ -71,8 +72,6 @@ function ProListItem(props) {
|
|
|
71
72
|
onExpand: propsOnExpand,
|
|
72
73
|
expandable: expandableConfig,
|
|
73
74
|
rowSupportExpand,
|
|
74
|
-
showActions,
|
|
75
|
-
showExtra,
|
|
76
75
|
type,
|
|
77
76
|
style,
|
|
78
77
|
className: propsClassName = defaultClassName,
|
|
@@ -80,7 +79,6 @@ function ProListItem(props) {
|
|
|
80
79
|
onRow,
|
|
81
80
|
onItem,
|
|
82
81
|
itemHeaderRender,
|
|
83
|
-
cardActionProps,
|
|
84
82
|
extra,
|
|
85
83
|
...rest
|
|
86
84
|
} = props;
|
|
@@ -101,37 +99,14 @@ function ProListItem(props) {
|
|
|
101
99
|
}, [propsOnExpand]);
|
|
102
100
|
const className = clsx({
|
|
103
101
|
[`${defaultClassName}-selected`]: !cardProps && selected,
|
|
104
|
-
[`${defaultClassName}-show-action-hover`]: showActions === 'hover',
|
|
105
102
|
[`${defaultClassName}-type-${type}`]: !!type,
|
|
106
|
-
[`${defaultClassName}-editable`]: isEditable
|
|
107
|
-
[`${defaultClassName}-show-extra-hover`]: showExtra === 'hover'
|
|
103
|
+
[`${defaultClassName}-editable`]: isEditable
|
|
108
104
|
}, hashId, defaultClassName);
|
|
109
|
-
const extraClassName = clsx(hashId, {
|
|
110
|
-
[`${propsClassName}-extra`]: showExtra === 'hover'
|
|
111
|
-
});
|
|
112
105
|
const needExpanded = expanded || Object.values(expandableConfig || {}).length === 0;
|
|
113
106
|
const expandedRowDom = expandedRowRender && expandedRowRender(record, index, indentSize, expanded);
|
|
114
|
-
const
|
|
115
|
-
if (!actions || cardActionProps === 'actions') {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
return [/*#__PURE__*/_jsx("div", {
|
|
119
|
-
onClick: e => e.stopPropagation(),
|
|
120
|
-
children: actions
|
|
121
|
-
}, "action")];
|
|
122
|
-
}, [actions, cardActionProps]);
|
|
123
|
-
const actionsDom = useMemo(() => {
|
|
124
|
-
if (!actions || !cardActionProps || cardActionProps === 'extra') {
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
return [/*#__PURE__*/_jsx("div", {
|
|
128
|
-
className: `${defaultClassName}-actions ${hashId}`.trim(),
|
|
129
|
-
onClick: e => e.stopPropagation(),
|
|
130
|
-
children: actions
|
|
131
|
-
}, "action")];
|
|
132
|
-
}, [actions, cardActionProps, defaultClassName, hashId]);
|
|
107
|
+
const actionsArray = useMemo(() => actions ? React.Children.toArray(actions) : undefined, [actions]);
|
|
133
108
|
const titleDom = title || subTitle ? /*#__PURE__*/_jsxs("div", {
|
|
134
|
-
className: `${defaultClassName}-header-container
|
|
109
|
+
className: clsx(`${defaultClassName}-header-container`, hashId),
|
|
135
110
|
children: [title && /*#__PURE__*/_jsx("div", {
|
|
136
111
|
className: clsx(`${defaultClassName}-title`, hashId, {
|
|
137
112
|
[`${defaultClassName}-title-editable`]: isEditable
|
|
@@ -145,41 +120,77 @@ function ProListItem(props) {
|
|
|
145
120
|
})]
|
|
146
121
|
}) : null;
|
|
147
122
|
const metaTitle = (itemTitleRender && itemTitleRender?.(record, index, titleDom)) ?? titleDom;
|
|
148
|
-
const metaDom = metaTitle || avatar || subTitle || description ? /*#__PURE__*/_jsx(
|
|
123
|
+
const metaDom = metaTitle || avatar || subTitle || description ? /*#__PURE__*/_jsx(BaseListItemMeta, {
|
|
149
124
|
avatar: avatar,
|
|
150
125
|
title: metaTitle,
|
|
151
126
|
description: description && needExpanded && /*#__PURE__*/_jsx("div", {
|
|
152
|
-
className: `${className}-description
|
|
127
|
+
className: clsx(`${className}-description`, hashId),
|
|
153
128
|
children: description
|
|
154
129
|
})
|
|
155
130
|
}) : null;
|
|
131
|
+
const itemProps = onItem?.(record, index);
|
|
132
|
+
const hasExpandableConfig = Object.keys(expandableConfig || {}).length > 0;
|
|
133
|
+
const expandedRowClassStr = typeof expandedRowClassName === 'function' ? expandedRowClassName(record, index, indentSize) : expandedRowClassName;
|
|
134
|
+
const headerDom = typeof itemHeaderRender === 'function' ? itemHeaderRender(record, index, metaDom) : metaDom;
|
|
135
|
+
|
|
136
|
+
// 卡片模式渲染
|
|
137
|
+
if (cardProps) {
|
|
138
|
+
const cardTitleDom = avatar || title ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
139
|
+
children: [avatar, /*#__PURE__*/_jsx("span", {
|
|
140
|
+
className: clsx(`${prefixCls}-item-meta-title`, hashId),
|
|
141
|
+
children: title
|
|
142
|
+
})]
|
|
143
|
+
}) : null;
|
|
144
|
+
return /*#__PURE__*/_jsx("div", {
|
|
145
|
+
className: clsx(hashId, `${className}-card-container`, {
|
|
146
|
+
[propsClassName]: propsClassName !== defaultClassName
|
|
147
|
+
}),
|
|
148
|
+
style: style,
|
|
149
|
+
children: /*#__PURE__*/_jsx(CheckCard, {
|
|
150
|
+
bordered: true,
|
|
151
|
+
style: {
|
|
152
|
+
width: '100%'
|
|
153
|
+
},
|
|
154
|
+
className: clsx(`${defaultClassName}-card`, hashId),
|
|
155
|
+
...cardProps,
|
|
156
|
+
title: cardTitleDom,
|
|
157
|
+
subTitle: subTitle,
|
|
158
|
+
extra: actionsArray,
|
|
159
|
+
bodyStyle: {
|
|
160
|
+
padding: 24,
|
|
161
|
+
...cardProps.bodyStyle
|
|
162
|
+
},
|
|
163
|
+
...itemProps,
|
|
164
|
+
onClick: e => {
|
|
165
|
+
cardProps?.onClick?.(e);
|
|
166
|
+
itemProps?.onClick?.(e);
|
|
167
|
+
},
|
|
168
|
+
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
169
|
+
avatar: true,
|
|
170
|
+
title: false,
|
|
171
|
+
loading: loading,
|
|
172
|
+
active: true,
|
|
173
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
174
|
+
className: clsx(`${className}-header`, hashId),
|
|
175
|
+
children: [typeof itemTitleRender === 'function' && itemTitleRender(record, index, titleDom), content]
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// 列表模式渲染
|
|
156
183
|
const rowClassName = clsx(hashId, {
|
|
157
184
|
[`${defaultClassName}-item-has-checkbox`]: checkbox,
|
|
158
185
|
[`${defaultClassName}-item-has-avatar`]: avatar,
|
|
159
186
|
[className]: className
|
|
160
187
|
});
|
|
161
|
-
|
|
162
|
-
if (avatar || title) {
|
|
163
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
164
|
-
children: [avatar, /*#__PURE__*/_jsx("span", {
|
|
165
|
-
className: `${getPrefixCls('list-item-meta-title')} ${hashId}`.trim(),
|
|
166
|
-
children: title
|
|
167
|
-
})]
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
171
|
-
}, [avatar, getPrefixCls, hashId, title]);
|
|
172
|
-
const itemProps = onItem?.(record, index);
|
|
173
|
-
const defaultDom = !cardProps ? /*#__PURE__*/_jsx(List.Item, {
|
|
188
|
+
return /*#__PURE__*/_jsx(BaseListItem, {
|
|
174
189
|
className: clsx(rowClassName, hashId, {
|
|
175
190
|
[propsClassName]: propsClassName !== defaultClassName
|
|
176
191
|
}),
|
|
177
192
|
...rest,
|
|
178
|
-
|
|
179
|
-
extra: !!extra && /*#__PURE__*/_jsx("div", {
|
|
180
|
-
className: extraClassName,
|
|
181
|
-
children: extra
|
|
182
|
-
}),
|
|
193
|
+
extra: extra,
|
|
183
194
|
...onRow?.(record, index),
|
|
184
195
|
...itemProps,
|
|
185
196
|
onClick: e => {
|
|
@@ -195,13 +206,13 @@ function ProListItem(props) {
|
|
|
195
206
|
loading: loading,
|
|
196
207
|
active: true,
|
|
197
208
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
198
|
-
className: `${className}-header
|
|
209
|
+
className: clsx(`${className}-header`, hashId),
|
|
199
210
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
200
|
-
className: `${className}-header-option
|
|
211
|
+
className: clsx(`${className}-header-option`, hashId),
|
|
201
212
|
children: [!!checkbox && /*#__PURE__*/_jsx("div", {
|
|
202
|
-
className: `${className}-checkbox
|
|
213
|
+
className: clsx(`${className}-checkbox`, hashId),
|
|
203
214
|
children: checkbox
|
|
204
|
-
}),
|
|
215
|
+
}), hasExpandableConfig && rowSupportExpand && renderExpandIcon({
|
|
205
216
|
prefixCls,
|
|
206
217
|
hashId,
|
|
207
218
|
expandIcon,
|
|
@@ -209,55 +220,15 @@ function ProListItem(props) {
|
|
|
209
220
|
expanded,
|
|
210
221
|
record
|
|
211
222
|
})]
|
|
212
|
-
}),
|
|
223
|
+
}), headerDom, actionsArray]
|
|
213
224
|
}), needExpanded && (content || expandedRowDom) && /*#__PURE__*/_jsxs("div", {
|
|
214
|
-
className: `${className}-content
|
|
225
|
+
className: clsx(`${className}-content`, hashId),
|
|
215
226
|
children: [content, expandedRowRender && rowSupportExpand && /*#__PURE__*/_jsx("div", {
|
|
216
|
-
className:
|
|
227
|
+
className: expandedRowClassStr,
|
|
217
228
|
children: expandedRowDom
|
|
218
229
|
})]
|
|
219
230
|
})]
|
|
220
231
|
})
|
|
221
|
-
}) : /*#__PURE__*/_jsx(CheckCard, {
|
|
222
|
-
bordered: true,
|
|
223
|
-
style: {
|
|
224
|
-
width: '100%'
|
|
225
|
-
},
|
|
226
|
-
...cardProps,
|
|
227
|
-
title: cardTitleDom,
|
|
228
|
-
subTitle: subTitle,
|
|
229
|
-
extra: extraDom,
|
|
230
|
-
actions: actionsDom,
|
|
231
|
-
bodyStyle: {
|
|
232
|
-
padding: 24,
|
|
233
|
-
...cardProps.bodyStyle
|
|
234
|
-
},
|
|
235
|
-
...itemProps,
|
|
236
|
-
onClick: e => {
|
|
237
|
-
cardProps?.onClick?.(e);
|
|
238
|
-
itemProps?.onClick?.(e);
|
|
239
|
-
},
|
|
240
|
-
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
241
|
-
avatar: true,
|
|
242
|
-
title: false,
|
|
243
|
-
loading: loading,
|
|
244
|
-
active: true,
|
|
245
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
246
|
-
className: `${className}-header ${hashId}`.trim(),
|
|
247
|
-
children: [itemTitleRender && itemTitleRender?.(record, index, titleDom), content]
|
|
248
|
-
})
|
|
249
|
-
})
|
|
250
|
-
});
|
|
251
|
-
if (!cardProps) {
|
|
252
|
-
return defaultDom;
|
|
253
|
-
}
|
|
254
|
-
return /*#__PURE__*/_jsx("div", {
|
|
255
|
-
className: clsx(hashId, {
|
|
256
|
-
[`${className}-card`]: cardProps,
|
|
257
|
-
[propsClassName]: propsClassName !== defaultClassName
|
|
258
|
-
}),
|
|
259
|
-
style: style,
|
|
260
|
-
children: defaultDom
|
|
261
232
|
});
|
|
262
233
|
}
|
|
263
234
|
export default ProListItem;
|
package/es/list/ListView.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TableProps } from 'antd';
|
|
2
2
|
import type { AnyObject } from 'antd/lib/_util/type';
|
|
3
3
|
import type { PaginationConfig } from 'antd/lib/pagination';
|
|
4
4
|
import type { GetRowKey, TableRowSelection } from 'antd/lib/table/interface';
|
|
@@ -7,15 +7,16 @@ import type { CheckCardProps } from '../card';
|
|
|
7
7
|
import type { ActionType } from '../table';
|
|
8
8
|
import type { GetComponentProps } from './index';
|
|
9
9
|
import type { ItemProps } from './Item';
|
|
10
|
+
import type { ListProps } from './ProListBase';
|
|
10
11
|
type AntdListProps<RecordType> = Omit<ListProps<RecordType>, 'rowKey'>;
|
|
12
|
+
/** 自定义列表项渲染,defaultDom 为 ProList 默认渲染的列表项元素 */
|
|
13
|
+
export type ProListItemRender<RecordType> = (item: RecordType, index: number, defaultDom: React.ReactElement) => React.ReactNode;
|
|
11
14
|
export type ListViewProps<RecordType> = Omit<AntdListProps<RecordType>, 'renderItem'> & Pick<TableProps<RecordType>, 'columns' | 'dataSource' | 'expandable' | 'pagination'> & {
|
|
12
15
|
rowKey?: string | keyof RecordType | GetRowKey<RecordType>;
|
|
13
|
-
showActions?: 'hover' | 'always';
|
|
14
|
-
showExtra?: 'hover' | 'always';
|
|
15
16
|
rowSelection?: TableRowSelection<RecordType>;
|
|
16
17
|
prefixCls?: string;
|
|
17
18
|
dataSource: readonly RecordType[];
|
|
18
|
-
|
|
19
|
+
itemRender?: ProListItemRender<RecordType>;
|
|
19
20
|
actionRef: React.MutableRefObject<ActionType | undefined>;
|
|
20
21
|
onRow?: GetComponentProps<RecordType>;
|
|
21
22
|
onItem?: GetComponentProps<RecordType>;
|
|
@@ -25,6 +26,7 @@ export type ListViewProps<RecordType> = Omit<AntdListProps<RecordType>, 'renderI
|
|
|
25
26
|
itemTitleRender?: ItemProps<RecordType>['itemTitleRender'];
|
|
26
27
|
itemCardProps?: CheckCardProps;
|
|
27
28
|
pagination?: PaginationConfig;
|
|
29
|
+
hashId?: string;
|
|
28
30
|
};
|
|
29
31
|
declare function ListView<RecordType extends AnyObject>(props: ListViewProps<RecordType>): import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
export default ListView;
|
package/es/list/ListView.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { get } from '@rc-component/util';
|
|
2
|
-
import { ConfigProvider
|
|
2
|
+
import { ConfigProvider } from 'antd';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import React, { useContext } from 'react';
|
|
5
5
|
import { ProProvider } from "../provider";
|
|
@@ -8,18 +8,19 @@ import usePagination from "../utils/usePagination";
|
|
|
8
8
|
import useSelection from "../utils/useSelection";
|
|
9
9
|
import { PRO_LIST_KEYS_MAP } from "./constants";
|
|
10
10
|
import ProListItem from "./Item";
|
|
11
|
+
import { ProListContainer } from "./ProListBase";
|
|
12
|
+
|
|
13
|
+
/** 自定义列表项渲染,defaultDom 为 ProList 默认渲染的列表项元素 */
|
|
11
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
15
|
function ListView(props) {
|
|
13
16
|
const {
|
|
14
17
|
dataSource,
|
|
15
18
|
columns,
|
|
16
19
|
rowKey,
|
|
17
|
-
showActions,
|
|
18
|
-
showExtra,
|
|
19
20
|
prefixCls: customizePrefixCls,
|
|
20
21
|
actionRef,
|
|
21
22
|
itemTitleRender,
|
|
22
|
-
|
|
23
|
+
itemRender,
|
|
23
24
|
itemCardProps,
|
|
24
25
|
itemHeaderRender,
|
|
25
26
|
expandable: expandableConfig,
|
|
@@ -29,11 +30,13 @@ function ListView(props) {
|
|
|
29
30
|
onRow,
|
|
30
31
|
onItem,
|
|
31
32
|
rowClassName,
|
|
33
|
+
hashId: propHashId,
|
|
32
34
|
...rest
|
|
33
35
|
} = props;
|
|
34
36
|
const {
|
|
35
|
-
hashId
|
|
37
|
+
hashId: contextHashId
|
|
36
38
|
} = useContext(ProProvider);
|
|
39
|
+
const hashId = propHashId ?? contextHashId;
|
|
37
40
|
const {
|
|
38
41
|
getPrefixCls
|
|
39
42
|
} = useContext(ConfigProvider.ConfigContext);
|
|
@@ -44,10 +47,9 @@ function ListView(props) {
|
|
|
44
47
|
return (record, index) => record[rowKey] || index;
|
|
45
48
|
}, [rowKey]);
|
|
46
49
|
const [getRecordByKey] = useLazyKVMap(dataSource, 'children', getRowKey);
|
|
47
|
-
const usePaginationArgs = [() => {}, pagination];
|
|
48
50
|
|
|
49
|
-
//
|
|
50
|
-
const [mergedPagination] = usePagination(dataSource.length,
|
|
51
|
+
// 合并分页配置,兼容 antd 的分页
|
|
52
|
+
const [mergedPagination] = usePagination(dataSource.length, () => {}, pagination);
|
|
51
53
|
/** 根据分页来返回不同的数据,模拟 table */
|
|
52
54
|
const pageData = React.useMemo(() => {
|
|
53
55
|
if (pagination === false || !mergedPagination.pageSize || dataSource.length < mergedPagination.total) {
|
|
@@ -63,7 +65,7 @@ function ListView(props) {
|
|
|
63
65
|
const prefixCls = getPrefixCls('pro-list', customizePrefixCls);
|
|
64
66
|
|
|
65
67
|
/** 提供和 table 一样的 rowSelection 配置 */
|
|
66
|
-
const
|
|
68
|
+
const [selectItemRender, selectedKeySet] = useSelection({
|
|
67
69
|
getRowKey,
|
|
68
70
|
getRecordByKey,
|
|
69
71
|
prefixCls,
|
|
@@ -72,10 +74,7 @@ function ListView(props) {
|
|
|
72
74
|
expandType: 'row',
|
|
73
75
|
childrenColumnName: 'children',
|
|
74
76
|
locale: {}
|
|
75
|
-
}, rowSelection
|
|
76
|
-
// 这个 API 用的不好,先 any 一下
|
|
77
|
-
];
|
|
78
|
-
const [selectItemRender, selectedKeySet] = useSelection(...useSelectionArgs);
|
|
77
|
+
}, rowSelection);
|
|
79
78
|
|
|
80
79
|
// 提供和 Table 一样的 expand 支持
|
|
81
80
|
const {
|
|
@@ -121,8 +120,9 @@ function ListView(props) {
|
|
|
121
120
|
|
|
122
121
|
/** 这个是 选择框的 render 方法 为了兼容 antd 的 table,用了同样的渲染逻辑 所以看起来有点奇怪 */
|
|
123
122
|
const selectItemDom = selectItemRender([])[0];
|
|
124
|
-
return /*#__PURE__*/_jsx(
|
|
123
|
+
return /*#__PURE__*/_jsx(ProListContainer, {
|
|
125
124
|
...rest,
|
|
125
|
+
hashId: hashId,
|
|
126
126
|
className: clsx(getPrefixCls('pro-list-container', customizePrefixCls), hashId, rest.className),
|
|
127
127
|
dataSource: pageData,
|
|
128
128
|
pagination: pagination && mergedPagination,
|
|
@@ -132,27 +132,21 @@ function ListView(props) {
|
|
|
132
132
|
};
|
|
133
133
|
columns?.forEach(column => {
|
|
134
134
|
const {
|
|
135
|
-
|
|
136
|
-
cardActionProps
|
|
135
|
+
listSlot
|
|
137
136
|
} = column;
|
|
138
|
-
if (!PRO_LIST_KEYS_MAP.has(
|
|
137
|
+
if (!PRO_LIST_KEYS_MAP.has(listSlot)) {
|
|
139
138
|
return;
|
|
140
139
|
}
|
|
141
|
-
const dataIndex = column.dataIndex ||
|
|
140
|
+
const dataIndex = column.dataIndex || listSlot || column.key;
|
|
142
141
|
const rawData = Array.isArray(dataIndex) ? get(item, dataIndex) : item[dataIndex];
|
|
143
142
|
|
|
144
|
-
/** 如果cardActionProps 需要直接使用源数组,因为 action 必须要源数组 */
|
|
145
|
-
if (cardActionProps === 'actions' && listKey === 'actions') {
|
|
146
|
-
listItemProps.cardActionProps = cardActionProps;
|
|
147
|
-
}
|
|
148
143
|
// 调用protable的列配置渲染数据
|
|
149
144
|
const data = column.render ? column.render(rawData, item, index) : rawData;
|
|
150
|
-
|
|
145
|
+
// aside 是 extra 的新名称,映射到 Item 的 extra 属性
|
|
146
|
+
const propKey = column.listSlot === 'aside' ? 'extra' : column.listSlot;
|
|
147
|
+
if (data !== '-') listItemProps[propKey] = data;
|
|
151
148
|
});
|
|
152
|
-
|
|
153
|
-
if (selectItemDom && selectItemDom.render) {
|
|
154
|
-
checkboxDom = selectItemDom.render(item, item, index);
|
|
155
|
-
}
|
|
149
|
+
const checkboxDom = selectItemDom?.render?.(item, item, index);
|
|
156
150
|
const {
|
|
157
151
|
isEditable,
|
|
158
152
|
recordKey
|
|
@@ -161,46 +155,40 @@ function ListView(props) {
|
|
|
161
155
|
index
|
|
162
156
|
}) || {};
|
|
163
157
|
const isChecked = selectedKeySet.has(recordKey || index);
|
|
158
|
+
const itemKey = getRowKey(item, index);
|
|
159
|
+
const cardProps = rest.grid ? {
|
|
160
|
+
...itemCardProps,
|
|
161
|
+
...rest.grid,
|
|
162
|
+
checked: isChecked,
|
|
163
|
+
onChange: /*#__PURE__*/React.isValidElement(checkboxDom) ? changeChecked => checkboxDom?.props?.onChange({
|
|
164
|
+
nativeEvent: {},
|
|
165
|
+
target: {
|
|
166
|
+
checked: changeChecked
|
|
167
|
+
},
|
|
168
|
+
changeChecked
|
|
169
|
+
}) : undefined
|
|
170
|
+
} : undefined;
|
|
164
171
|
const defaultDom = /*#__PURE__*/_jsx(ProListItem, {
|
|
165
|
-
cardProps:
|
|
166
|
-
...itemCardProps,
|
|
167
|
-
...rest.grid,
|
|
168
|
-
checked: isChecked,
|
|
169
|
-
onChange: /*#__PURE__*/React.isValidElement(checkboxDom) ? changeChecked => {
|
|
170
|
-
return checkboxDom?.props?.onChange({
|
|
171
|
-
nativeEvent: {},
|
|
172
|
-
target: {
|
|
173
|
-
checked: changeChecked
|
|
174
|
-
},
|
|
175
|
-
changeChecked
|
|
176
|
-
});
|
|
177
|
-
} : undefined
|
|
178
|
-
} : undefined,
|
|
172
|
+
cardProps: cardProps,
|
|
179
173
|
...listItemProps,
|
|
180
174
|
recordKey: recordKey,
|
|
181
175
|
isEditable: isEditable || false,
|
|
182
176
|
expandable: expandableConfig,
|
|
183
|
-
expand: mergedExpandedKeys.has(
|
|
184
|
-
onExpand: () =>
|
|
185
|
-
onTriggerExpand(item);
|
|
186
|
-
},
|
|
177
|
+
expand: mergedExpandedKeys.has(itemKey),
|
|
178
|
+
onExpand: () => onTriggerExpand(item),
|
|
187
179
|
index: index,
|
|
188
180
|
record: item,
|
|
189
181
|
item: item,
|
|
190
|
-
showActions: showActions,
|
|
191
|
-
showExtra: showExtra,
|
|
192
182
|
itemTitleRender: itemTitleRender,
|
|
193
183
|
itemHeaderRender: itemHeaderRender,
|
|
194
|
-
rowSupportExpand: !rowExpandable || rowExpandable
|
|
195
|
-
selected: selectedKeySet.has(
|
|
184
|
+
rowSupportExpand: !rowExpandable || rowExpandable(item),
|
|
185
|
+
selected: selectedKeySet.has(itemKey),
|
|
196
186
|
checkbox: checkboxDom,
|
|
197
187
|
onRow: onRow,
|
|
198
188
|
onItem: onItem
|
|
199
189
|
}, recordKey);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
return defaultDom;
|
|
190
|
+
const renderedContent = itemRender ? itemRender(item, index, defaultDom) : defaultDom;
|
|
191
|
+
return renderedContent;
|
|
204
192
|
}
|
|
205
193
|
});
|
|
206
194
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { PaginationConfig } from 'antd/lib/pagination';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type ColumnCount = number;
|
|
4
|
+
export type ColumnType = 'gutter' | 'column' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
5
|
+
export interface ListGridType {
|
|
6
|
+
gutter?: number | [number, number];
|
|
7
|
+
column?: ColumnCount;
|
|
8
|
+
xs?: ColumnCount;
|
|
9
|
+
sm?: ColumnCount;
|
|
10
|
+
md?: ColumnCount;
|
|
11
|
+
lg?: ColumnCount;
|
|
12
|
+
xl?: ColumnCount;
|
|
13
|
+
xxl?: ColumnCount;
|
|
14
|
+
}
|
|
15
|
+
export type ListSize = 'small' | 'default' | 'large';
|
|
16
|
+
export type ListItemLayout = 'horizontal' | 'vertical';
|
|
17
|
+
export interface ListLocale {
|
|
18
|
+
emptyText?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface ListProps<T = any> {
|
|
21
|
+
variant?: 'outlined' | 'borderless' | 'filled';
|
|
22
|
+
className?: string;
|
|
23
|
+
rootClassName?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
dataSource?: T[];
|
|
27
|
+
extra?: React.ReactNode;
|
|
28
|
+
grid?: ListGridType;
|
|
29
|
+
id?: string;
|
|
30
|
+
itemLayout?: ListItemLayout;
|
|
31
|
+
loading?: boolean | {
|
|
32
|
+
spinning?: boolean;
|
|
33
|
+
};
|
|
34
|
+
loadMore?: React.ReactNode;
|
|
35
|
+
pagination?: PaginationConfig | false;
|
|
36
|
+
prefixCls?: string;
|
|
37
|
+
rowKey?: ((item: T) => React.Key) | keyof T;
|
|
38
|
+
renderItem?: (item: T, index: number, defaultDom: JSX.Element | null) => React.ReactNode;
|
|
39
|
+
size?: ListSize;
|
|
40
|
+
split?: boolean;
|
|
41
|
+
header?: React.ReactNode;
|
|
42
|
+
footer?: React.ReactNode;
|
|
43
|
+
locale?: ListLocale;
|
|
44
|
+
hashId?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare const ProListContext: React.Context<{
|
|
47
|
+
grid?: ListGridType | undefined;
|
|
48
|
+
itemLayout?: ListItemLayout | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
export interface ListItemMetaProps {
|
|
51
|
+
avatar?: React.ReactNode;
|
|
52
|
+
className?: string;
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
description?: React.ReactNode;
|
|
55
|
+
prefixCls?: string;
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
title?: React.ReactNode;
|
|
58
|
+
}
|
|
59
|
+
export declare const ProListItemMeta: React.FC<ListItemMetaProps>;
|
|
60
|
+
export interface ListItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
61
|
+
className?: string;
|
|
62
|
+
children?: React.ReactNode;
|
|
63
|
+
prefixCls?: string;
|
|
64
|
+
style?: React.CSSProperties;
|
|
65
|
+
extra?: React.ReactNode;
|
|
66
|
+
actions?: React.ReactNode[];
|
|
67
|
+
colStyle?: React.CSSProperties;
|
|
68
|
+
}
|
|
69
|
+
export declare const ProListItem: React.ForwardRefExoticComponent<ListItemProps & React.RefAttributes<HTMLDivElement>> & {
|
|
70
|
+
Meta: typeof ProListItemMeta;
|
|
71
|
+
};
|
|
72
|
+
export declare const ProListContainer: <T>(props: ListProps<T> & {
|
|
73
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
74
|
+
}) => React.ReactElement;
|