@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/lib/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/lib/list/ListView.js
CHANGED
|
@@ -16,18 +16,19 @@ var _usePagination = _interopRequireDefault(require("../utils/usePagination"));
|
|
|
16
16
|
var _useSelection = _interopRequireDefault(require("../utils/useSelection"));
|
|
17
17
|
var _constants = require("./constants");
|
|
18
18
|
var _Item = _interopRequireDefault(require("./Item"));
|
|
19
|
+
var _ProListBase = require("./ProListBase");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
/** 自定义列表项渲染,defaultDom 为 ProList 默认渲染的列表项元素 */
|
|
22
|
+
|
|
20
23
|
function ListView(props) {
|
|
21
24
|
const {
|
|
22
25
|
dataSource,
|
|
23
26
|
columns,
|
|
24
27
|
rowKey,
|
|
25
|
-
showActions,
|
|
26
|
-
showExtra,
|
|
27
28
|
prefixCls: customizePrefixCls,
|
|
28
29
|
actionRef,
|
|
29
30
|
itemTitleRender,
|
|
30
|
-
|
|
31
|
+
itemRender,
|
|
31
32
|
itemCardProps,
|
|
32
33
|
itemHeaderRender,
|
|
33
34
|
expandable: expandableConfig,
|
|
@@ -37,11 +38,13 @@ function ListView(props) {
|
|
|
37
38
|
onRow,
|
|
38
39
|
onItem,
|
|
39
40
|
rowClassName,
|
|
41
|
+
hashId: propHashId,
|
|
40
42
|
...rest
|
|
41
43
|
} = props;
|
|
42
44
|
const {
|
|
43
|
-
hashId
|
|
45
|
+
hashId: contextHashId
|
|
44
46
|
} = (0, _react.useContext)(_provider.ProProvider);
|
|
47
|
+
const hashId = propHashId ?? contextHashId;
|
|
45
48
|
const {
|
|
46
49
|
getPrefixCls
|
|
47
50
|
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
@@ -52,10 +55,9 @@ function ListView(props) {
|
|
|
52
55
|
return (record, index) => record[rowKey] || index;
|
|
53
56
|
}, [rowKey]);
|
|
54
57
|
const [getRecordByKey] = (0, _useLazyKVMap.default)(dataSource, 'children', getRowKey);
|
|
55
|
-
const usePaginationArgs = [() => {}, pagination];
|
|
56
58
|
|
|
57
|
-
//
|
|
58
|
-
const [mergedPagination] = (0, _usePagination.default)(dataSource.length,
|
|
59
|
+
// 合并分页配置,兼容 antd 的分页
|
|
60
|
+
const [mergedPagination] = (0, _usePagination.default)(dataSource.length, () => {}, pagination);
|
|
59
61
|
/** 根据分页来返回不同的数据,模拟 table */
|
|
60
62
|
const pageData = _react.default.useMemo(() => {
|
|
61
63
|
if (pagination === false || !mergedPagination.pageSize || dataSource.length < mergedPagination.total) {
|
|
@@ -71,7 +73,7 @@ function ListView(props) {
|
|
|
71
73
|
const prefixCls = getPrefixCls('pro-list', customizePrefixCls);
|
|
72
74
|
|
|
73
75
|
/** 提供和 table 一样的 rowSelection 配置 */
|
|
74
|
-
const
|
|
76
|
+
const [selectItemRender, selectedKeySet] = (0, _useSelection.default)({
|
|
75
77
|
getRowKey,
|
|
76
78
|
getRecordByKey,
|
|
77
79
|
prefixCls,
|
|
@@ -80,10 +82,7 @@ function ListView(props) {
|
|
|
80
82
|
expandType: 'row',
|
|
81
83
|
childrenColumnName: 'children',
|
|
82
84
|
locale: {}
|
|
83
|
-
}, rowSelection
|
|
84
|
-
// 这个 API 用的不好,先 any 一下
|
|
85
|
-
];
|
|
86
|
-
const [selectItemRender, selectedKeySet] = (0, _useSelection.default)(...useSelectionArgs);
|
|
85
|
+
}, rowSelection);
|
|
87
86
|
|
|
88
87
|
// 提供和 Table 一样的 expand 支持
|
|
89
88
|
const {
|
|
@@ -129,8 +128,9 @@ function ListView(props) {
|
|
|
129
128
|
|
|
130
129
|
/** 这个是 选择框的 render 方法 为了兼容 antd 的 table,用了同样的渲染逻辑 所以看起来有点奇怪 */
|
|
131
130
|
const selectItemDom = selectItemRender([])[0];
|
|
132
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
131
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProListBase.ProListContainer, {
|
|
133
132
|
...rest,
|
|
133
|
+
hashId: hashId,
|
|
134
134
|
className: (0, _clsx.clsx)(getPrefixCls('pro-list-container', customizePrefixCls), hashId, rest.className),
|
|
135
135
|
dataSource: pageData,
|
|
136
136
|
pagination: pagination && mergedPagination,
|
|
@@ -140,27 +140,21 @@ function ListView(props) {
|
|
|
140
140
|
};
|
|
141
141
|
columns?.forEach(column => {
|
|
142
142
|
const {
|
|
143
|
-
|
|
144
|
-
cardActionProps
|
|
143
|
+
listSlot
|
|
145
144
|
} = column;
|
|
146
|
-
if (!_constants.PRO_LIST_KEYS_MAP.has(
|
|
145
|
+
if (!_constants.PRO_LIST_KEYS_MAP.has(listSlot)) {
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
|
-
const dataIndex = column.dataIndex ||
|
|
148
|
+
const dataIndex = column.dataIndex || listSlot || column.key;
|
|
150
149
|
const rawData = Array.isArray(dataIndex) ? (0, _util.get)(item, dataIndex) : item[dataIndex];
|
|
151
150
|
|
|
152
|
-
/** 如果cardActionProps 需要直接使用源数组,因为 action 必须要源数组 */
|
|
153
|
-
if (cardActionProps === 'actions' && listKey === 'actions') {
|
|
154
|
-
listItemProps.cardActionProps = cardActionProps;
|
|
155
|
-
}
|
|
156
151
|
// 调用protable的列配置渲染数据
|
|
157
152
|
const data = column.render ? column.render(rawData, item, index) : rawData;
|
|
158
|
-
|
|
153
|
+
// aside 是 extra 的新名称,映射到 Item 的 extra 属性
|
|
154
|
+
const propKey = column.listSlot === 'aside' ? 'extra' : column.listSlot;
|
|
155
|
+
if (data !== '-') listItemProps[propKey] = data;
|
|
159
156
|
});
|
|
160
|
-
|
|
161
|
-
if (selectItemDom && selectItemDom.render) {
|
|
162
|
-
checkboxDom = selectItemDom.render(item, item, index);
|
|
163
|
-
}
|
|
157
|
+
const checkboxDom = selectItemDom?.render?.(item, item, index);
|
|
164
158
|
const {
|
|
165
159
|
isEditable,
|
|
166
160
|
recordKey
|
|
@@ -169,46 +163,40 @@ function ListView(props) {
|
|
|
169
163
|
index
|
|
170
164
|
}) || {};
|
|
171
165
|
const isChecked = selectedKeySet.has(recordKey || index);
|
|
166
|
+
const itemKey = getRowKey(item, index);
|
|
167
|
+
const cardProps = rest.grid ? {
|
|
168
|
+
...itemCardProps,
|
|
169
|
+
...rest.grid,
|
|
170
|
+
checked: isChecked,
|
|
171
|
+
onChange: /*#__PURE__*/_react.default.isValidElement(checkboxDom) ? changeChecked => checkboxDom?.props?.onChange({
|
|
172
|
+
nativeEvent: {},
|
|
173
|
+
target: {
|
|
174
|
+
checked: changeChecked
|
|
175
|
+
},
|
|
176
|
+
changeChecked
|
|
177
|
+
}) : undefined
|
|
178
|
+
} : undefined;
|
|
172
179
|
const defaultDom = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Item.default, {
|
|
173
|
-
cardProps:
|
|
174
|
-
...itemCardProps,
|
|
175
|
-
...rest.grid,
|
|
176
|
-
checked: isChecked,
|
|
177
|
-
onChange: /*#__PURE__*/_react.default.isValidElement(checkboxDom) ? changeChecked => {
|
|
178
|
-
return checkboxDom?.props?.onChange({
|
|
179
|
-
nativeEvent: {},
|
|
180
|
-
target: {
|
|
181
|
-
checked: changeChecked
|
|
182
|
-
},
|
|
183
|
-
changeChecked
|
|
184
|
-
});
|
|
185
|
-
} : undefined
|
|
186
|
-
} : undefined,
|
|
180
|
+
cardProps: cardProps,
|
|
187
181
|
...listItemProps,
|
|
188
182
|
recordKey: recordKey,
|
|
189
183
|
isEditable: isEditable || false,
|
|
190
184
|
expandable: expandableConfig,
|
|
191
|
-
expand: mergedExpandedKeys.has(
|
|
192
|
-
onExpand: () =>
|
|
193
|
-
onTriggerExpand(item);
|
|
194
|
-
},
|
|
185
|
+
expand: mergedExpandedKeys.has(itemKey),
|
|
186
|
+
onExpand: () => onTriggerExpand(item),
|
|
195
187
|
index: index,
|
|
196
188
|
record: item,
|
|
197
189
|
item: item,
|
|
198
|
-
showActions: showActions,
|
|
199
|
-
showExtra: showExtra,
|
|
200
190
|
itemTitleRender: itemTitleRender,
|
|
201
191
|
itemHeaderRender: itemHeaderRender,
|
|
202
|
-
rowSupportExpand: !rowExpandable || rowExpandable
|
|
203
|
-
selected: selectedKeySet.has(
|
|
192
|
+
rowSupportExpand: !rowExpandable || rowExpandable(item),
|
|
193
|
+
selected: selectedKeySet.has(itemKey),
|
|
204
194
|
checkbox: checkboxDom,
|
|
205
195
|
onRow: onRow,
|
|
206
196
|
onItem: onItem
|
|
207
197
|
}, recordKey);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
return defaultDom;
|
|
198
|
+
const renderedContent = itemRender ? itemRender(item, index, defaultDom) : defaultDom;
|
|
199
|
+
return renderedContent;
|
|
212
200
|
}
|
|
213
201
|
});
|
|
214
202
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ProListItemMeta = exports.ProListItem = exports.ProListContext = exports.ProListContainer = void 0;
|
|
8
|
+
var _antd = require("antd");
|
|
9
|
+
var _clsx = require("clsx");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _useMediaQuery = require("../utils/useMediaQuery");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
/**
|
|
14
|
+
* 内部 List 容器与 List.Item / List.Item.Meta 实现,用于替代 antd List(antd List 已停止维护)
|
|
15
|
+
* 保持与 antd List 相同的 DOM 结构及类名,以便复用 antd 的 list 样式
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const ProListContext = exports.ProListContext = /*#__PURE__*/_react.default.createContext({});
|
|
19
|
+
const ProListItemMeta = ({
|
|
20
|
+
prefixCls: customizePrefixCls,
|
|
21
|
+
className,
|
|
22
|
+
avatar,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
...rest
|
|
26
|
+
}) => {
|
|
27
|
+
const {
|
|
28
|
+
getPrefixCls
|
|
29
|
+
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
30
|
+
const prefixCls = getPrefixCls('pro-list', customizePrefixCls);
|
|
31
|
+
const classString = (0, _clsx.clsx)(`${prefixCls}-item-meta`, className);
|
|
32
|
+
const content = title || description ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
33
|
+
className: `${prefixCls}-item-meta-content`,
|
|
34
|
+
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)("h4", {
|
|
35
|
+
className: `${prefixCls}-item-meta-title`,
|
|
36
|
+
children: title
|
|
37
|
+
}), description && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
38
|
+
className: `${prefixCls}-item-meta-description`,
|
|
39
|
+
children: description
|
|
40
|
+
})]
|
|
41
|
+
}) : null;
|
|
42
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
43
|
+
...rest,
|
|
44
|
+
className: classString,
|
|
45
|
+
children: [avatar && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
46
|
+
className: `${prefixCls}-item-meta-avatar`,
|
|
47
|
+
children: avatar
|
|
48
|
+
}), content]
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.ProListItemMeta = ProListItemMeta;
|
|
52
|
+
const InternalProListItem = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
53
|
+
const {
|
|
54
|
+
prefixCls: customizePrefixCls,
|
|
55
|
+
children,
|
|
56
|
+
actions,
|
|
57
|
+
extra,
|
|
58
|
+
className,
|
|
59
|
+
colStyle,
|
|
60
|
+
...rest
|
|
61
|
+
} = props;
|
|
62
|
+
const {
|
|
63
|
+
grid,
|
|
64
|
+
itemLayout
|
|
65
|
+
} = (0, _react.useContext)(ProListContext);
|
|
66
|
+
const {
|
|
67
|
+
getPrefixCls
|
|
68
|
+
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
69
|
+
const prefixCls = getPrefixCls('pro-list', customizePrefixCls);
|
|
70
|
+
const actionsContent = actions && actions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
71
|
+
className: `${prefixCls}-item-action`,
|
|
72
|
+
onClick: e => e.stopPropagation(),
|
|
73
|
+
children: actions.map((action, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
74
|
+
className: `${prefixCls}-item-action-item`,
|
|
75
|
+
children: action
|
|
76
|
+
}, i))
|
|
77
|
+
}, "actions") : null;
|
|
78
|
+
const itemChildren = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
79
|
+
...rest,
|
|
80
|
+
className: (0, _clsx.clsx)(`${prefixCls}-item`, className),
|
|
81
|
+
children: itemLayout === 'vertical' && extra ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
82
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
83
|
+
className: `${prefixCls}-item-main`,
|
|
84
|
+
children: [children, actionsContent]
|
|
85
|
+
}, "content"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
86
|
+
className: `${prefixCls}-item-extra`,
|
|
87
|
+
children: extra
|
|
88
|
+
}, "extra")]
|
|
89
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
90
|
+
children: [children, actionsContent, extra != null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
91
|
+
children: extra
|
|
92
|
+
}, "extra")]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
if (grid) {
|
|
96
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
97
|
+
ref: ref,
|
|
98
|
+
style: {
|
|
99
|
+
width: '100%',
|
|
100
|
+
...colStyle
|
|
101
|
+
},
|
|
102
|
+
children: itemChildren
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return itemChildren;
|
|
106
|
+
});
|
|
107
|
+
InternalProListItem.displayName = 'ProListItem';
|
|
108
|
+
const ProListItem = exports.ProListItem = InternalProListItem;
|
|
109
|
+
ProListItem.Meta = ProListItemMeta;
|
|
110
|
+
function getRowKey(item, index, rowKey) {
|
|
111
|
+
if (typeof rowKey === 'function') {
|
|
112
|
+
return rowKey(item);
|
|
113
|
+
}
|
|
114
|
+
if (rowKey && typeof item === 'object' && item !== null && rowKey in item) {
|
|
115
|
+
return item[rowKey];
|
|
116
|
+
}
|
|
117
|
+
if (typeof item === 'object' && item !== null && 'key' in item) {
|
|
118
|
+
return item.key;
|
|
119
|
+
}
|
|
120
|
+
return `list-item-${index}`;
|
|
121
|
+
}
|
|
122
|
+
const defaultPaginationProps = {
|
|
123
|
+
current: 1,
|
|
124
|
+
total: 0,
|
|
125
|
+
position: 'bottom'
|
|
126
|
+
};
|
|
127
|
+
const ProListContainerInner = /*#__PURE__*/_react.default.forwardRef(function ProListContainerInner(props, ref) {
|
|
128
|
+
const {
|
|
129
|
+
pagination = false,
|
|
130
|
+
prefixCls: customizePrefixCls,
|
|
131
|
+
variant = 'borderless',
|
|
132
|
+
split = true,
|
|
133
|
+
className,
|
|
134
|
+
rootClassName,
|
|
135
|
+
style,
|
|
136
|
+
children,
|
|
137
|
+
itemLayout,
|
|
138
|
+
loadMore,
|
|
139
|
+
grid,
|
|
140
|
+
dataSource = [],
|
|
141
|
+
size: customizeSize = 'default',
|
|
142
|
+
header,
|
|
143
|
+
footer,
|
|
144
|
+
loading = false,
|
|
145
|
+
rowKey,
|
|
146
|
+
renderItem,
|
|
147
|
+
locale,
|
|
148
|
+
hashId: propHashId,
|
|
149
|
+
...rest
|
|
150
|
+
} = props;
|
|
151
|
+
const {
|
|
152
|
+
getPrefixCls
|
|
153
|
+
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
154
|
+
const prefixCls = getPrefixCls('pro-list', customizePrefixCls);
|
|
155
|
+
const paginationObj = pagination && typeof pagination === 'object' ? pagination : {};
|
|
156
|
+
const [paginationCurrent, setPaginationCurrent] = _react.default.useState(paginationObj.defaultCurrent ?? 1);
|
|
157
|
+
const [paginationSize, setPaginationSize] = _react.default.useState(paginationObj.defaultPageSize ?? 10);
|
|
158
|
+
const sizeCls = customizeSize === 'large' ? 'lg' : customizeSize === 'small' ? 'sm' : '';
|
|
159
|
+
const isSomethingAfterLastItem = !!(loadMore || pagination || footer);
|
|
160
|
+
const paginationProps = (0, _react.useMemo)(() => ({
|
|
161
|
+
...defaultPaginationProps,
|
|
162
|
+
total: dataSource.length,
|
|
163
|
+
current: paginationCurrent,
|
|
164
|
+
pageSize: paginationSize,
|
|
165
|
+
...(pagination && typeof pagination === 'object' ? pagination : {})
|
|
166
|
+
}), [dataSource.length, pagination, paginationCurrent, paginationSize]);
|
|
167
|
+
const largestPage = Math.ceil(paginationProps.total / (paginationProps.pageSize || 10));
|
|
168
|
+
const currentPage = Math.min(paginationProps.current ?? 1, Math.max(1, largestPage));
|
|
169
|
+
const splitDataSource = (0, _react.useMemo)(() => {
|
|
170
|
+
if (!pagination || !dataSource.length) {
|
|
171
|
+
return dataSource;
|
|
172
|
+
}
|
|
173
|
+
const pageSize = paginationProps.pageSize ?? 10;
|
|
174
|
+
const total = paginationProps.total ?? 0;
|
|
175
|
+
// 父组件已分页(如 ListView 传入 pageData)时不再二次 slice
|
|
176
|
+
if (total > 0 && dataSource.length <= pageSize && total > dataSource.length) {
|
|
177
|
+
return dataSource;
|
|
178
|
+
}
|
|
179
|
+
const start = (currentPage - 1) * pageSize;
|
|
180
|
+
return dataSource.slice(start, start + pageSize);
|
|
181
|
+
}, [dataSource, pagination, currentPage, paginationProps.pageSize, paginationProps.total]);
|
|
182
|
+
const renderInternalItem = (item, index) => {
|
|
183
|
+
if (!renderItem) return null;
|
|
184
|
+
const key = getRowKey(item, index, rowKey);
|
|
185
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.default.Fragment, {
|
|
186
|
+
children: renderItem(item, index, null)
|
|
187
|
+
}, key);
|
|
188
|
+
};
|
|
189
|
+
const breakpoint = (0, _useMediaQuery.useBreakpoint)();
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 根据当前断点获取列数
|
|
193
|
+
*/
|
|
194
|
+
const getResponsiveColumn = (0, _react.useMemo)(() => {
|
|
195
|
+
if (!grid) return 1;
|
|
196
|
+
const breakpoints = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
|
|
197
|
+
const currentBreakpoint = breakpoint || 'md';
|
|
198
|
+
const startIndex = breakpoints.indexOf(currentBreakpoint);
|
|
199
|
+
|
|
200
|
+
// 从当前断点开始,向下查找第一个已定义的列数
|
|
201
|
+
for (let i = startIndex; i < breakpoints.length; i++) {
|
|
202
|
+
const bp = breakpoints[i];
|
|
203
|
+
const colCount = grid[bp];
|
|
204
|
+
if (colCount !== undefined) {
|
|
205
|
+
return colCount;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 最后使用 column 默认值,确保不为 0(避免除以零)
|
|
210
|
+
return grid.column || 1;
|
|
211
|
+
}, [grid, breakpoint]);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 计算 grid 容器样式(flex 布局)
|
|
215
|
+
*/
|
|
216
|
+
const gridContainerStyle = (0, _react.useMemo)(() => {
|
|
217
|
+
if (!grid) return undefined;
|
|
218
|
+
const style = {
|
|
219
|
+
display: 'flex',
|
|
220
|
+
flexWrap: 'wrap'
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// 处理 gutter
|
|
224
|
+
if (grid.gutter) {
|
|
225
|
+
const [horizontal, vertical] = Array.isArray(grid.gutter) ? grid.gutter : [grid.gutter, 0];
|
|
226
|
+
const h = Number(horizontal) || 0;
|
|
227
|
+
const v = Number(vertical) || 0;
|
|
228
|
+
|
|
229
|
+
// flex 容器使用负 margin 来抵消子元素的 padding
|
|
230
|
+
style.marginLeft = -h / 2;
|
|
231
|
+
style.marginRight = -h / 2;
|
|
232
|
+
style.marginTop = -v / 2;
|
|
233
|
+
style.marginBottom = -v / 2;
|
|
234
|
+
}
|
|
235
|
+
return style;
|
|
236
|
+
}, [grid?.gutter]);
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 计算每个 item 的样式(flex 子项)
|
|
240
|
+
*/
|
|
241
|
+
const colStyle = (0, _react.useMemo)(() => {
|
|
242
|
+
if (!grid) return undefined;
|
|
243
|
+
const {
|
|
244
|
+
gutter
|
|
245
|
+
} = grid;
|
|
246
|
+
const column = getResponsiveColumn;
|
|
247
|
+
const style = {
|
|
248
|
+
display: 'flex'
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// 处理 gutter
|
|
252
|
+
if (gutter) {
|
|
253
|
+
const [horizontal, vertical] = Array.isArray(gutter) ? gutter : [gutter, 0];
|
|
254
|
+
const h = Number(horizontal) || 0;
|
|
255
|
+
const v = Number(vertical) || 0;
|
|
256
|
+
style.paddingLeft = h / 2;
|
|
257
|
+
style.paddingRight = h / 2;
|
|
258
|
+
style.paddingTop = v / 2;
|
|
259
|
+
style.paddingBottom = v / 2;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// 计算每列的宽度(确保 column 有效,避免除以零)
|
|
263
|
+
if (column > 0) {
|
|
264
|
+
// 使用 flex-basis 和 max-width 确保准确的宽度
|
|
265
|
+
const percentage = 100 / column;
|
|
266
|
+
style.flexBasis = `${percentage}%`;
|
|
267
|
+
style.maxWidth = `${percentage}%`;
|
|
268
|
+
}
|
|
269
|
+
return style;
|
|
270
|
+
}, [grid?.gutter, getResponsiveColumn]);
|
|
271
|
+
const {
|
|
272
|
+
renderEmpty
|
|
273
|
+
} = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext);
|
|
274
|
+
let childrenContent;
|
|
275
|
+
const isLoading = typeof loading === 'boolean' ? loading : !!loading?.spinning;
|
|
276
|
+
if (splitDataSource.length > 0) {
|
|
277
|
+
const items = splitDataSource.map((item, idx) => renderInternalItem(item, idx));
|
|
278
|
+
childrenContent = grid ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
279
|
+
style: gridContainerStyle,
|
|
280
|
+
children: items.map((child, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
281
|
+
style: colStyle,
|
|
282
|
+
children: child
|
|
283
|
+
}, child?.key ?? idx))
|
|
284
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
285
|
+
className: `${prefixCls}-items`,
|
|
286
|
+
children: items
|
|
287
|
+
});
|
|
288
|
+
} else if (!children && !isLoading) {
|
|
289
|
+
const emptyContent = locale?.emptyText ?? (typeof renderEmpty === 'function' ? renderEmpty('List') : null) ?? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Empty, {
|
|
290
|
+
description: "\u6682\u65E0\u6570\u636E"
|
|
291
|
+
});
|
|
292
|
+
childrenContent = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
293
|
+
className: `${prefixCls}-empty-text`,
|
|
294
|
+
children: emptyContent
|
|
295
|
+
});
|
|
296
|
+
} else if (isLoading) {
|
|
297
|
+
childrenContent = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
298
|
+
style: {
|
|
299
|
+
minHeight: 53
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
childrenContent = children;
|
|
304
|
+
}
|
|
305
|
+
const paginationPosition = paginationProps.position ?? 'bottom';
|
|
306
|
+
const showPaginationTop = pagination && (paginationPosition === 'top' || paginationPosition === 'both');
|
|
307
|
+
const showPaginationBottom = pagination && (paginationPosition === 'bottom' || paginationPosition === 'both');
|
|
308
|
+
const paginationNode = pagination && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
309
|
+
className: `${prefixCls}-pagination`,
|
|
310
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Pagination, {
|
|
311
|
+
align: "end",
|
|
312
|
+
...paginationProps,
|
|
313
|
+
current: currentPage,
|
|
314
|
+
onChange: (page, pageSize) => {
|
|
315
|
+
setPaginationCurrent(page);
|
|
316
|
+
setPaginationSize(pageSize ?? 10);
|
|
317
|
+
pagination?.onChange?.(page, pageSize ?? 10);
|
|
318
|
+
},
|
|
319
|
+
onShowSizeChange: (current, size) => {
|
|
320
|
+
setPaginationCurrent(current);
|
|
321
|
+
setPaginationSize(size);
|
|
322
|
+
pagination?.onShowSizeChange?.(current, size);
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
327
|
+
grid,
|
|
328
|
+
itemLayout
|
|
329
|
+
}), [JSON.stringify(grid), itemLayout]);
|
|
330
|
+
const classString = (0, _clsx.clsx)(prefixCls, {
|
|
331
|
+
[`${prefixCls}-vertical`]: itemLayout === 'vertical',
|
|
332
|
+
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
|
333
|
+
[`${prefixCls}-split`]: split,
|
|
334
|
+
[`${prefixCls}-${variant}`]: variant,
|
|
335
|
+
[`${prefixCls}-loading`]: isLoading,
|
|
336
|
+
[`${prefixCls}-grid`]: !!grid,
|
|
337
|
+
[`${prefixCls}-something-after-last-item`]: isSomethingAfterLastItem
|
|
338
|
+
}, propHashId, className, rootClassName);
|
|
339
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ProListContext.Provider, {
|
|
340
|
+
value: contextValue,
|
|
341
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
342
|
+
ref: ref,
|
|
343
|
+
style: style,
|
|
344
|
+
className: classString,
|
|
345
|
+
...rest,
|
|
346
|
+
children: [showPaginationTop && paginationNode, header && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
347
|
+
className: `${prefixCls}-header`,
|
|
348
|
+
children: header
|
|
349
|
+
}), childrenContent, children, footer && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
350
|
+
className: `${prefixCls}-footer`,
|
|
351
|
+
children: footer
|
|
352
|
+
}), loadMore, showPaginationBottom && paginationNode]
|
|
353
|
+
})
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
ProListContainerInner.displayName = 'ProListContainer';
|
|
357
|
+
const ProListContainer = exports.ProListContainer = ProListContainerInner;
|
package/lib/list/constants.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const PRO_LIST_KEYS:
|
|
2
|
-
declare const PRO_LIST_KEYS_MAP:
|
|
1
|
+
declare const PRO_LIST_KEYS: readonly ["title", "subTitle", "avatar", "description", "extra", "aside", "content", "actions", "type"];
|
|
2
|
+
declare const PRO_LIST_KEYS_MAP: Set<string>;
|
|
3
3
|
export { PRO_LIST_KEYS, PRO_LIST_KEYS_MAP };
|
package/lib/list/constants.js
CHANGED
|
@@ -4,8 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PRO_LIST_KEYS_MAP = exports.PRO_LIST_KEYS = void 0;
|
|
7
|
-
const PRO_LIST_KEYS = exports.PRO_LIST_KEYS = ['title', 'subTitle', 'avatar', 'description', 'extra', 'content', 'actions', 'type'];
|
|
8
|
-
const PRO_LIST_KEYS_MAP = exports.PRO_LIST_KEYS_MAP = PRO_LIST_KEYS
|
|
9
|
-
pre.set(next, true);
|
|
10
|
-
return pre;
|
|
11
|
-
}, new Map());
|
|
7
|
+
const PRO_LIST_KEYS = exports.PRO_LIST_KEYS = ['title', 'subTitle', 'avatar', 'description', 'extra', 'aside', 'content', 'actions', 'type'];
|
|
8
|
+
const PRO_LIST_KEYS_MAP = exports.PRO_LIST_KEYS_MAP = new Set(PRO_LIST_KEYS);
|