@pisell/materials 1.0.1034 → 1.0.1035
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +17 -17
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +18 -23
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +27 -32
- package/es/components/Pagination/index.js +1 -1
- package/es/components/PisellCards/index.d.ts +6 -6
- package/es/components/calendar/index.d.ts +2 -2
- package/es/components/checkbox/index.d.ts +2 -2
- package/es/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Input.Email/index.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Input.Password/index.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/Input.TextArea/index.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/es/components/date-picker/index.d.ts +2 -2
- package/es/components/filter/components/Dropdown/index.js +6 -2
- package/es/components/filter/components/FilterButton/index.js +3 -2
- package/es/components/filter/components/FilterButton/types.d.ts +5 -2
- package/es/components/filter/components/FilterItem/AsyncOptionsSelectWrapper.js +67 -0
- package/es/components/filter/components/FilterItem/index.js +105 -6
- package/es/components/filter/components/FilterItem/index.less +90 -0
- package/es/components/filter/types.d.ts +4 -2
- package/es/components/input/index.d.ts +2 -2
- package/es/components/pisell-config-provider/context.d.ts +2 -2
- package/es/components/pisellCurrency/PisellCurrency.less +163 -25
- package/es/components/pisellDatePicker/index.d.ts +2 -2
- package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +11 -10
- package/es/components/pisellDateTimeDisplay/types.d.ts +5 -0
- package/es/components/pisellEmail/PisellEmail.d.ts +2 -33
- package/es/components/pisellEmail/PisellEmail.js +1 -1
- package/es/components/pisellEmail/PisellEmail.less +119 -10
- package/es/components/pisellEmail/index.d.ts +1 -1
- package/es/components/pisellFilter/docs/PisellFilter.md +289 -232
- package/es/components/pisellFilter/index.js +66 -11
- package/es/components/pisellLongText/PisellLongText.less +72 -4
- package/es/components/pisellLookup/PisellLookup.js +3 -3
- package/es/components/pisellLookup/PisellLookup.less +14 -9
- package/es/components/pisellLookup/components/LookupTrigger.js +6 -2
- package/es/components/pisellMetricCard/PisellMetricCard.d.ts +38 -0
- package/es/components/pisellMetricCard/PisellMetricCard.js +136 -0
- package/es/components/pisellMetricCard/components/MetricComparison.js +54 -0
- package/es/components/pisellMetricCard/components/MetricTitle.js +41 -0
- package/es/components/pisellMetricCard/components/MetricValue.js +26 -0
- package/es/components/pisellMetricCard/components/TrendIcon.js +26 -0
- package/es/components/pisellMetricCard/docs/pisellMetricCard.$tab-design.md +2 -6
- package/es/components/pisellMetricCard/index.d.ts +2 -0
- package/es/components/pisellMetricCard/types.d.ts +143 -0
- package/es/components/pisellMetricCard/utils/calculateTrend.js +22 -0
- package/es/components/pisellMetricCard/utils/formatMetricValue.js +52 -0
- package/es/components/pisellMultipleSelect/PisellMultipleSelect.less +151 -124
- package/es/components/pisellMultipleSelect/components/EditView.js +8 -1
- package/es/components/pisellMultipleSelect/components/ReadOnlyView.js +18 -6
- package/es/components/pisellNumber/PisellNumber.less +135 -17
- package/es/components/pisellPercent/PisellPercent.less +142 -24
- package/es/components/pisellPhone/PisellPhone.less +122 -27
- package/es/components/pisellPhone/components/EditView.js +1 -1
- package/es/components/pisellPhone/components/ReadOnlyView.js +15 -5
- package/es/components/pisellPhone/utils/countryCodeHelper.js +1 -10
- package/es/components/pisellRating/PisellRating.less +20 -12
- package/es/components/pisellRecordBoard/PisellRecordBoard.js +148 -0
- package/es/components/pisellRecordBoard/README.md +183 -0
- package/es/components/pisellRecordBoard/context/RecordBoardContext.js +7 -0
- package/es/components/pisellRecordBoard/context/RecordBoardProvider.js +14 -0
- package/es/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-design.md +128 -0
- package/es/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-dev.md +82 -0
- package/es/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-test.md +70 -0
- package/es/components/pisellRecordBoard/docs/PisellRecordBoard.md +552 -0
- package/es/components/pisellRecordBoard/hooks/useRecordBoardContext.d.ts +20 -0
- package/es/components/pisellRecordBoard/hooks/useRecordBoardContext.js +16 -0
- package/es/components/pisellRecordBoard/index.d.ts +40 -0
- package/es/components/pisellRecordBoard/index.js +28 -0
- package/es/components/pisellRecordBoard/layouts/CardLayout/CardList.d.ts +15 -0
- package/es/components/pisellRecordBoard/layouts/CardLayout/CardList.js +24 -0
- package/es/components/pisellRecordBoard/layouts/CardLayout/index.d.ts +15 -0
- package/es/components/pisellRecordBoard/layouts/CardLayout/index.js +21 -0
- package/es/components/pisellRecordBoard/layouts/GridLayout/Grid.d.ts +17 -0
- package/es/components/pisellRecordBoard/layouts/GridLayout/Grid.js +105 -0
- package/es/components/pisellRecordBoard/layouts/GridLayout/Grid.less +13 -0
- package/es/components/pisellRecordBoard/layouts/GridLayout/index.d.ts +15 -0
- package/es/components/pisellRecordBoard/layouts/GridLayout/index.js +21 -0
- package/es/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +12 -0
- package/es/components/pisellRecordBoard/shellFrame/BatchActionBar/index.js +69 -0
- package/es/components/pisellRecordBoard/shellFrame/ColumnSetting/ColumnSettingPopover.js +40 -0
- package/es/components/pisellRecordBoard/shellFrame/ColumnSetting/index.js +60 -0
- package/es/components/pisellRecordBoard/shellFrame/ColumnSetting/index.less +2 -0
- package/es/components/pisellRecordBoard/shellFrame/Pagination/index.d.ts +17 -0
- package/es/components/pisellRecordBoard/shellFrame/Pagination/index.js +52 -0
- package/es/components/pisellRecordBoard/shellFrame/Pagination/index.less +61 -0
- package/es/components/pisellRecordBoard/shellFrame/Search/index.d.ts +13 -0
- package/es/components/pisellRecordBoard/shellFrame/Search/index.js +34 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBar/ToolBarFilter.less +77 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBar/index.d.ts +14 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBar/index.js +136 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBarQuickFilter/index.d.ts +2 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBarQuickFilter/index.js +62 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +2 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.js +45 -0
- package/es/components/pisellRecordBoard/shellFrame/ToolBarReset/index.less +41 -0
- package/es/components/pisellRecordBoard/shellFrame/index.d.ts +27 -0
- package/es/components/pisellRecordBoard/shellFrame/index.js +38 -0
- package/es/components/pisellRecordBoard/types.d.ts +259 -0
- package/es/components/pisellRecordBoard/utils/recordBoardColumns.js +287 -0
- package/es/components/pisellShellFrame/PisellShellFrame.d.ts +16 -0
- package/es/components/pisellShellFrame/PisellShellFrame.js +60 -0
- package/es/components/pisellShellFrame/PisellShellFrame.less +73 -0
- package/es/components/pisellShellFrame/README.md +58 -0
- package/es/components/pisellShellFrame/index.d.ts +2 -0
- package/es/components/pisellShellFrame/types.d.ts +60 -0
- package/es/components/pisellSingleSelect/PisellSingleSelect.less +88 -46
- package/es/components/pisellSingleSelect/components/EditView.js +8 -1
- package/es/components/pisellSingleSelect/components/ReadOnlyView.js +8 -2
- package/es/components/pisellUrl/PisellUrl.d.ts +2 -33
- package/es/components/pisellUrl/PisellUrl.js +1 -1
- package/es/components/pisellUrl/PisellUrl.less +120 -11
- package/es/components/pisellUrl/index.d.ts +1 -1
- package/es/components/radio/index.d.ts +2 -2
- package/es/components/section-footers/index.d.ts +2 -2
- package/es/components/skeleton/index.d.ts +2 -2
- package/es/components/sort/index.js +12 -1
- package/es/components/sort/types.d.ts +8 -2
- package/es/components/time-picker/index.d.ts +2 -2
- package/es/index.d.ts +19 -11
- package/es/index.js +19 -15
- package/es/locales/en-US.js +16 -2
- package/es/locales/zh-CN.js +18 -4
- package/es/locales/zh-TW.js +18 -4
- package/es/utils/tagColor.js +31 -0
- package/lib/components/Pagination/index.js +1 -1
- package/lib/components/checkbox/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/dataSourceShow/dataSourceQRCode/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Checkbox/WithMode.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.Password/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Input.TextArea/index.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/Select/index.d.ts +1 -1
- package/lib/components/filter/components/Dropdown/index.js +6 -2
- package/lib/components/filter/components/FilterButton/index.js +3 -2
- package/lib/components/filter/components/FilterButton/types.d.ts +5 -2
- package/lib/components/filter/components/FilterItem/AsyncOptionsSelectWrapper.js +69 -0
- package/lib/components/filter/components/FilterItem/index.js +106 -6
- package/lib/components/filter/components/FilterItem/index.less +90 -0
- package/lib/components/filter/types.d.ts +4 -2
- package/lib/components/input/index.d.ts +2 -2
- package/lib/components/pisell-config-provider/context.d.ts +2 -2
- package/lib/components/pisellCurrency/PisellCurrency.less +163 -25
- package/lib/components/pisellDatePicker/index.d.ts +2 -2
- package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +11 -10
- package/lib/components/pisellDateTimeDisplay/types.d.ts +5 -0
- package/lib/components/pisellEmail/PisellEmail.d.ts +2 -33
- package/lib/components/pisellEmail/PisellEmail.js +1 -1
- package/lib/components/pisellEmail/PisellEmail.less +119 -10
- package/lib/components/pisellEmail/index.d.ts +1 -1
- package/lib/components/pisellFilter/docs/PisellFilter.md +289 -232
- package/lib/components/pisellFilter/index.js +65 -10
- package/lib/components/pisellLongText/PisellLongText.less +72 -4
- package/lib/components/pisellLookup/PisellLookup.js +3 -3
- package/lib/components/pisellLookup/PisellLookup.less +14 -9
- package/lib/components/pisellLookup/components/LookupTrigger.js +6 -2
- package/lib/components/pisellMetricCard/PisellMetricCard.d.ts +38 -0
- package/lib/components/pisellMetricCard/PisellMetricCard.js +138 -0
- package/lib/components/pisellMetricCard/components/MetricComparison.js +56 -0
- package/lib/components/pisellMetricCard/components/MetricTitle.js +43 -0
- package/lib/components/pisellMetricCard/components/MetricValue.js +28 -0
- package/lib/components/pisellMetricCard/components/TrendIcon.js +28 -0
- package/lib/components/pisellMetricCard/docs/pisellMetricCard.$tab-design.md +2 -6
- package/lib/components/pisellMetricCard/index.d.ts +2 -0
- package/lib/components/pisellMetricCard/types.d.ts +143 -0
- package/lib/components/pisellMetricCard/utils/calculateTrend.js +23 -0
- package/lib/components/pisellMetricCard/utils/formatMetricValue.js +53 -0
- package/lib/components/pisellMultipleSelect/PisellMultipleSelect.less +151 -124
- package/lib/components/pisellMultipleSelect/components/EditView.js +7 -0
- package/lib/components/pisellMultipleSelect/components/ReadOnlyView.js +17 -5
- package/lib/components/pisellNumber/PisellNumber.less +135 -17
- package/lib/components/pisellPercent/PisellPercent.less +142 -24
- package/lib/components/pisellPhone/PisellPhone.less +122 -27
- package/lib/components/pisellPhone/components/EditView.js +1 -1
- package/lib/components/pisellPhone/components/ReadOnlyView.js +15 -5
- package/lib/components/pisellPhone/utils/countryCodeHelper.js +0 -10
- package/lib/components/pisellRating/PisellRating.less +20 -12
- package/lib/components/pisellRecordBoard/PisellRecordBoard.js +150 -0
- package/lib/components/pisellRecordBoard/README.md +183 -0
- package/lib/components/pisellRecordBoard/context/RecordBoardContext.js +8 -0
- package/lib/components/pisellRecordBoard/context/RecordBoardProvider.js +16 -0
- package/lib/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-design.md +128 -0
- package/lib/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-dev.md +82 -0
- package/lib/components/pisellRecordBoard/docs/PisellRecordBoard.$tab-test.md +70 -0
- package/lib/components/pisellRecordBoard/docs/PisellRecordBoard.md +552 -0
- package/lib/components/pisellRecordBoard/hooks/useRecordBoardContext.d.ts +20 -0
- package/lib/components/pisellRecordBoard/hooks/useRecordBoardContext.js +17 -0
- package/lib/components/pisellRecordBoard/index.d.ts +40 -0
- package/lib/components/pisellRecordBoard/index.js +28 -0
- package/lib/components/pisellRecordBoard/layouts/CardLayout/CardList.d.ts +15 -0
- package/lib/components/pisellRecordBoard/layouts/CardLayout/CardList.js +26 -0
- package/lib/components/pisellRecordBoard/layouts/CardLayout/index.d.ts +15 -0
- package/lib/components/pisellRecordBoard/layouts/CardLayout/index.js +23 -0
- package/lib/components/pisellRecordBoard/layouts/GridLayout/Grid.d.ts +17 -0
- package/lib/components/pisellRecordBoard/layouts/GridLayout/Grid.js +107 -0
- package/lib/components/pisellRecordBoard/layouts/GridLayout/Grid.less +13 -0
- package/lib/components/pisellRecordBoard/layouts/GridLayout/index.d.ts +15 -0
- package/lib/components/pisellRecordBoard/layouts/GridLayout/index.js +23 -0
- package/lib/components/pisellRecordBoard/shellFrame/BatchActionBar/index.d.ts +12 -0
- package/lib/components/pisellRecordBoard/shellFrame/BatchActionBar/index.js +71 -0
- package/lib/components/pisellRecordBoard/shellFrame/ColumnSetting/ColumnSettingPopover.js +43 -0
- package/lib/components/pisellRecordBoard/shellFrame/ColumnSetting/index.js +62 -0
- package/lib/components/pisellRecordBoard/shellFrame/ColumnSetting/index.less +2 -0
- package/lib/components/pisellRecordBoard/shellFrame/Pagination/index.d.ts +17 -0
- package/lib/components/pisellRecordBoard/shellFrame/Pagination/index.js +54 -0
- package/lib/components/pisellRecordBoard/shellFrame/Pagination/index.less +61 -0
- package/lib/components/pisellRecordBoard/shellFrame/Search/index.d.ts +13 -0
- package/lib/components/pisellRecordBoard/shellFrame/Search/index.js +36 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBar/ToolBarFilter.less +77 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBar/index.d.ts +14 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBar/index.js +139 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarQuickFilter/index.js +64 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.d.ts +2 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.js +47 -0
- package/lib/components/pisellRecordBoard/shellFrame/ToolBarReset/index.less +41 -0
- package/lib/components/pisellRecordBoard/shellFrame/index.d.ts +26 -0
- package/lib/components/pisellRecordBoard/shellFrame/index.js +40 -0
- package/lib/components/pisellRecordBoard/types.d.ts +259 -0
- package/lib/components/pisellRecordBoard/utils/recordBoardColumns.js +292 -0
- package/lib/components/pisellShellFrame/PisellShellFrame.d.ts +16 -0
- package/lib/components/pisellShellFrame/PisellShellFrame.js +62 -0
- package/lib/components/pisellShellFrame/PisellShellFrame.less +73 -0
- package/lib/components/pisellShellFrame/README.md +58 -0
- package/lib/components/pisellShellFrame/index.d.ts +2 -0
- package/lib/components/pisellShellFrame/types.d.ts +60 -0
- package/lib/components/pisellSingleSelect/PisellSingleSelect.less +88 -46
- package/lib/components/pisellSingleSelect/components/EditView.js +7 -0
- package/lib/components/pisellSingleSelect/components/ReadOnlyView.js +8 -2
- package/lib/components/pisellUrl/PisellUrl.d.ts +2 -33
- package/lib/components/pisellUrl/PisellUrl.js +1 -1
- package/lib/components/pisellUrl/PisellUrl.less +120 -11
- package/lib/components/pisellUrl/index.d.ts +1 -1
- package/lib/components/radio/index.d.ts +2 -2
- package/lib/components/section-footers/index.d.ts +2 -2
- package/lib/components/skeleton/index.d.ts +2 -2
- package/lib/components/sort/index.js +12 -1
- package/lib/components/sort/types.d.ts +8 -2
- package/lib/components/time-picker/index.d.ts +2 -2
- package/lib/components/upload/index.d.ts +2 -2
- package/lib/index.d.ts +19 -11
- package/lib/index.js +33 -25
- package/lib/locales/en-US.js +16 -2
- package/lib/locales/zh-CN.js +18 -4
- package/lib/locales/zh-TW.js +18 -4
- package/lib/utils/tagColor.js +32 -0
- package/package.json +3 -3
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js";
|
|
2
|
+
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutProperties.js";
|
|
3
|
+
import { RecordBoardProvider } from "./context/RecordBoardProvider.js";
|
|
4
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/pisellRecordBoard/PisellRecordBoard.tsx
|
|
7
|
+
const _excluded = [
|
|
8
|
+
"children",
|
|
9
|
+
"layoutType",
|
|
10
|
+
"rowKey",
|
|
11
|
+
"data",
|
|
12
|
+
"loading",
|
|
13
|
+
"total",
|
|
14
|
+
"pagination",
|
|
15
|
+
"onPageChange",
|
|
16
|
+
"searchParams",
|
|
17
|
+
"onSearch",
|
|
18
|
+
"onReset"
|
|
19
|
+
];
|
|
20
|
+
const defaultPagination = {
|
|
21
|
+
pageNumber: 1,
|
|
22
|
+
pageSize: 10
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 从打散 props 合并出 childComponentProps(供 context 使用)。
|
|
26
|
+
*/
|
|
27
|
+
function mergeChildComponentProps(props) {
|
|
28
|
+
if (!(props.grid != null || props.toolBar != null || props.search != null || props.paginationConfig != null || props.batchActionBar != null || props.cardList != null)) return void 0;
|
|
29
|
+
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, props.grid != null && { grid: props.grid }), props.toolBar != null && { toolBar: props.toolBar }), props.search != null && { search: props.search }), props.paginationConfig != null && { pagination: props.paginationConfig }), props.batchActionBar != null && { batchActionBar: props.batchActionBar }), props.cardList != null && { cardList: props.cardList });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 默认的 context 值(用于无数据源时的占位 / 设计态)
|
|
33
|
+
*/
|
|
34
|
+
function getDefaultRecordBoardContext(layoutType, selection, rowKey) {
|
|
35
|
+
return {
|
|
36
|
+
data: [],
|
|
37
|
+
loading: false,
|
|
38
|
+
total: 0,
|
|
39
|
+
pagination: defaultPagination,
|
|
40
|
+
onPageChange: () => {},
|
|
41
|
+
searchParams: {},
|
|
42
|
+
onSearch: () => {},
|
|
43
|
+
onReset: () => {},
|
|
44
|
+
layoutType,
|
|
45
|
+
selectedKeys: selection.selectedKeys,
|
|
46
|
+
selectedRows: selection.selectedRows,
|
|
47
|
+
onSelectionChange: selection.onSelectionChange,
|
|
48
|
+
rowKey,
|
|
49
|
+
childComponentProps: void 0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* RecordBoard 容器:提供统一的 data / pagination / search 上下文。
|
|
54
|
+
* 仅接受打散 props:列表/分页/搜索/多选/列显隐、以及 grid/toolBar/search/paginationConfig/batchActionBar/cardList。
|
|
55
|
+
*/
|
|
56
|
+
const PisellRecordBoard = (props) => {
|
|
57
|
+
const { children, layoutType = "grid", rowKey: rowKeyProp, data: dataProp, loading: loadingProp, total: totalProp, pagination: paginationProp, onPageChange: onPageChangeProp, searchParams: searchParamsProp, onSearch: onSearchProp, onReset: onResetProp } = props;
|
|
58
|
+
_objectWithoutProperties(props, _excluded);
|
|
59
|
+
const mergedChildComponentProps = useMemo(() => mergeChildComponentProps(props), [
|
|
60
|
+
props.grid,
|
|
61
|
+
props.toolBar,
|
|
62
|
+
props.search,
|
|
63
|
+
props.paginationConfig,
|
|
64
|
+
props.batchActionBar,
|
|
65
|
+
props.cardList
|
|
66
|
+
]);
|
|
67
|
+
const [internalSelectedKeys, setInternalSelectedKeys] = useState([]);
|
|
68
|
+
const [internalSelectedRows, setInternalSelectedRows] = useState([]);
|
|
69
|
+
const [internalColumnVisibility, setInternalColumnVisibility] = useState(() => {
|
|
70
|
+
var _props$grid;
|
|
71
|
+
const keys = (_props$grid = props.grid) === null || _props$grid === void 0 ? void 0 : _props$grid.defaultHiddenColumnKeys;
|
|
72
|
+
if (!Array.isArray(keys) || keys.length === 0) return {};
|
|
73
|
+
const vis = {};
|
|
74
|
+
keys.forEach((k) => {
|
|
75
|
+
vis[k] = false;
|
|
76
|
+
});
|
|
77
|
+
return vis;
|
|
78
|
+
});
|
|
79
|
+
const onSelectionChangeInternal = useCallback((keys, rows) => {
|
|
80
|
+
setInternalSelectedKeys(keys);
|
|
81
|
+
setInternalSelectedRows(rows);
|
|
82
|
+
}, []);
|
|
83
|
+
const onColumnVisibilityChangeInternal = useCallback((visibility) => {
|
|
84
|
+
setInternalColumnVisibility((prev) => _objectSpread2(_objectSpread2({}, prev), visibility));
|
|
85
|
+
}, []);
|
|
86
|
+
const contextValue = useMemo(() => {
|
|
87
|
+
var _gridSelection$select;
|
|
88
|
+
const defaultCtx = getDefaultRecordBoardContext(layoutType, {
|
|
89
|
+
selectedKeys: internalSelectedKeys,
|
|
90
|
+
selectedRows: internalSelectedRows,
|
|
91
|
+
onSelectionChange: onSelectionChangeInternal
|
|
92
|
+
}, rowKeyProp);
|
|
93
|
+
const data = dataProp !== void 0 ? dataProp : defaultCtx.data;
|
|
94
|
+
const loading = loadingProp !== void 0 ? loadingProp : defaultCtx.loading;
|
|
95
|
+
const total = totalProp !== void 0 ? totalProp : defaultCtx.total;
|
|
96
|
+
const pagination = paginationProp !== void 0 ? paginationProp : defaultCtx.pagination;
|
|
97
|
+
const onPageChange = onPageChangeProp !== null && onPageChangeProp !== void 0 ? onPageChangeProp : defaultCtx.onPageChange;
|
|
98
|
+
const searchParams = searchParamsProp !== void 0 ? searchParamsProp : defaultCtx.searchParams;
|
|
99
|
+
const onSearch = onSearchProp !== null && onSearchProp !== void 0 ? onSearchProp : defaultCtx.onSearch;
|
|
100
|
+
const onReset = onResetProp !== null && onResetProp !== void 0 ? onResetProp : defaultCtx.onReset;
|
|
101
|
+
const rowKey = rowKeyProp !== null && rowKeyProp !== void 0 ? rowKeyProp : defaultCtx.rowKey;
|
|
102
|
+
const gridSelection = props.grid;
|
|
103
|
+
const hasControlledSelection = (gridSelection === null || gridSelection === void 0 ? void 0 : gridSelection.selectedKeys) != null && Array.isArray(gridSelection.selectedKeys) && typeof gridSelection.onSelectionChange === "function";
|
|
104
|
+
const selectedKeys = hasControlledSelection ? gridSelection.selectedKeys : internalSelectedKeys;
|
|
105
|
+
const selectedRows = hasControlledSelection ? (_gridSelection$select = gridSelection.selectedRows) !== null && _gridSelection$select !== void 0 ? _gridSelection$select : [] : internalSelectedRows;
|
|
106
|
+
const onSelectionChange = hasControlledSelection ? gridSelection.onSelectionChange : onSelectionChangeInternal;
|
|
107
|
+
return _objectSpread2(_objectSpread2({}, defaultCtx), {}, {
|
|
108
|
+
layoutType,
|
|
109
|
+
rowKey,
|
|
110
|
+
data,
|
|
111
|
+
loading,
|
|
112
|
+
total,
|
|
113
|
+
pagination,
|
|
114
|
+
onPageChange,
|
|
115
|
+
searchParams,
|
|
116
|
+
onSearch,
|
|
117
|
+
onReset,
|
|
118
|
+
selectedKeys,
|
|
119
|
+
selectedRows,
|
|
120
|
+
onSelectionChange,
|
|
121
|
+
columnVisibility: internalColumnVisibility,
|
|
122
|
+
onColumnVisibilityChange: onColumnVisibilityChangeInternal,
|
|
123
|
+
childComponentProps: mergedChildComponentProps !== null && mergedChildComponentProps !== void 0 ? mergedChildComponentProps : defaultCtx.childComponentProps
|
|
124
|
+
});
|
|
125
|
+
}, [
|
|
126
|
+
layoutType,
|
|
127
|
+
rowKeyProp,
|
|
128
|
+
dataProp,
|
|
129
|
+
loadingProp,
|
|
130
|
+
totalProp,
|
|
131
|
+
paginationProp,
|
|
132
|
+
onPageChangeProp,
|
|
133
|
+
searchParamsProp,
|
|
134
|
+
onSearchProp,
|
|
135
|
+
onResetProp,
|
|
136
|
+
mergedChildComponentProps,
|
|
137
|
+
internalSelectedKeys,
|
|
138
|
+
internalSelectedRows,
|
|
139
|
+
onSelectionChangeInternal,
|
|
140
|
+
internalColumnVisibility,
|
|
141
|
+
onColumnVisibilityChangeInternal
|
|
142
|
+
]);
|
|
143
|
+
return /* @__PURE__ */ React.createElement(RecordBoardProvider, { value: contextValue }, children);
|
|
144
|
+
};
|
|
145
|
+
var PisellRecordBoard_default = PisellRecordBoard;
|
|
146
|
+
|
|
147
|
+
//#endregion
|
|
148
|
+
export { PisellRecordBoard_default as default };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# PisellRecordBoard 记录看板
|
|
2
|
+
|
|
3
|
+
记录看板容器组件,提供统一的列表数据、分页、搜索/筛选/排序、多选等上下文,支持 Grid(表格)与 Card 两种布局。ToolBar
|
|
4
|
+
左侧为快速筛选(QuickFilter)+ 搜索(PisellFind),右侧为排序、筛选弹层、重置。
|
|
5
|
+
|
|
6
|
+
## 快速开始
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import PisellRecordBoard from '@pisell/materials';
|
|
10
|
+
|
|
11
|
+
// 受控:打散传入 data、pagination、searchParams、onSearch 等;多选通过 grid 传入
|
|
12
|
+
const value = {
|
|
13
|
+
data: list,
|
|
14
|
+
loading: false,
|
|
15
|
+
total: 100,
|
|
16
|
+
pagination: { pageNumber: 1, pageSize: 10 },
|
|
17
|
+
onPageChange: (num, size) => {},
|
|
18
|
+
searchParams: {},
|
|
19
|
+
onSearch: (params) => {},
|
|
20
|
+
layoutType: 'grid',
|
|
21
|
+
rowKey: 'id',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
<PisellRecordBoard rowKey="id" {...value} grid={{ columns, selectedKeys, selectedRows, onSelectionChange }} />
|
|
25
|
+
<PisellRecordBoard.ShellFrame>
|
|
26
|
+
<PisellRecordBoard.GridLayout/>
|
|
27
|
+
</PisellRecordBoard.ShellFrame>
|
|
28
|
+
</PisellRecordBoard>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
通过 `grid.columns` 传入列配置,ToolBar 会根据 columns 自动派生筛选与排序;列上配置 `type` 时,表格会用对应
|
|
32
|
+
Pisell 组件只读渲染,筛选用编辑态。`grid` 支持 antd Table 其他 props 透传,如 `onRow`(行点击等)、`onHeaderRow`、`expandable`、`rowClassName`、`summary` 等。
|
|
33
|
+
|
|
34
|
+
## 核心特性
|
|
35
|
+
|
|
36
|
+
- **统一上下文**:data、pagination、searchParams、onSearch、多选等由 Context 提供,子组件通过 `useRecordBoardContext()` 消费。
|
|
37
|
+
- **列驱动筛选/排序**:列配置(`grid.columns`)驱动 ToolBar 内筛选项与排序项,无需单独维护 filter 列表。
|
|
38
|
+
- **有 type / 无 type**:有 `type` 时表格/筛选/排序可自动派生;无 `type` 时需自行配置 `render`、`filter`、`sort`;有 type
|
|
39
|
+
时也可传 `render`/`filter`/`sort` 覆盖。
|
|
40
|
+
- **快速筛选**:支持左侧内联 QuickFilter(如下单时间 RangePicker),右侧筛选弹层仅高级筛选。
|
|
41
|
+
- **多选**:支持表格/卡片多选,BatchActionBar 展示批量操作。
|
|
42
|
+
|
|
43
|
+
## 子组件
|
|
44
|
+
|
|
45
|
+
| 子组件 | 说明 |
|
|
46
|
+
|-------------------------------------------|--------------------------------------------------------------------|
|
|
47
|
+
| `PisellRecordBoard.ShellFrame` | 外壳:ToolBar + BatchActionBar + children(Layout)+ Pagination;分页使用定制样式(见 shellFrame/Pagination/index.less) |
|
|
48
|
+
| `PisellRecordBoard.GridLayout` | 表格布局(Grid + 分页) |
|
|
49
|
+
| `PisellRecordBoard.CardLayout` | 卡片列表布局 |
|
|
50
|
+
| `PisellRecordBoard.ToolBar` | 工具栏(搜索、QuickFilter、Sort、Filter、列设置、Reset、slots) |
|
|
51
|
+
| `PisellRecordBoard.Search` | 独立搜索槽(PisellFind) |
|
|
52
|
+
| `PisellRecordBoard.Pagination` | 独立分页槽 |
|
|
53
|
+
| `PisellRecordBoard.Grid` | 独立表格视图(支持 columnVisibility 列显示隐藏) |
|
|
54
|
+
| `PisellRecordBoard.CardList` | 独立卡片列表视图 |
|
|
55
|
+
| `PisellRecordBoard.BatchActionBar` | 多选操作栏 |
|
|
56
|
+
| `PisellRecordBoard.useRecordBoardContext` | 消费 RecordBoard 上下文的 Hook |
|
|
57
|
+
|
|
58
|
+
## 列配置逻辑(有 type / 无 type)
|
|
59
|
+
|
|
60
|
+
| 能力 | **有 type**(如 `singleLineText`) | **无 type** |
|
|
61
|
+
|----------|--------------------------------------------|--------------------------------------------------------------------------------------------|
|
|
62
|
+
| **表格展示** | 自动用对应 Pisell 组件只读渲染;可传 `render` 覆盖 | 无 `render` 则纯文本;可自定义 `render` |
|
|
63
|
+
| **筛选** | 自动用对应组件编辑态;可传 `filter`(type 或 component)覆盖 | 需配置 `filterable` + `filter`(`filter.type` 或 `filter.component`,component 需 value/onChange) |
|
|
64
|
+
| **排序** | 自动从组件 SortOptions 派生;可传 `sort` 覆盖 | 需配置 `sortable` + `sort`(`sort.type` 或 `sort.getSortItems`) |
|
|
65
|
+
|
|
66
|
+
### 支持的列 type(RecordBoardFieldType)
|
|
67
|
+
|
|
68
|
+
`singleLineText` | `longText` | `email` | `phone` | `url` | `number` | `currency` | `percent` | `rating` |
|
|
69
|
+
`singleSelect` | `multipleSelect` | `dateTime`
|
|
70
|
+
|
|
71
|
+
### 有 type 示例(options 或 getOptions)
|
|
72
|
+
|
|
73
|
+
列 type 为 singleSelect/multipleSelect 时,`fieldProps` 可传 `options` 或 `getOptions`(同步/异步返回选项列表);筛选同理,`filter.options` 或 `filter.getOptions`。
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
const columns = [
|
|
77
|
+
{title: '订单号', dataIndex: 'orderNo', key: 'orderNo', width: 160, type: 'singleLineText'},
|
|
78
|
+
{
|
|
79
|
+
title: '状态',
|
|
80
|
+
dataIndex: 'status',
|
|
81
|
+
key: 'status',
|
|
82
|
+
type: 'singleSelect',
|
|
83
|
+
fieldProps: {options: [{label: '全部', value: 'all'}, {label: '启用', value: 'enabled'}]},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: '下单时间',
|
|
87
|
+
dataIndex: 'createTime',
|
|
88
|
+
key: 'createTime',
|
|
89
|
+
type: 'dateTime',
|
|
90
|
+
fieldProps: {customFormat: 'YYYY-MM-DD HH:mm'},
|
|
91
|
+
filterable: true,
|
|
92
|
+
filter: {quickFilter: true}, // 放在左侧快筛
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 无 type + 自定义 filter 示例
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
const MyFilterInput = ({value, onChange}) => (
|
|
101
|
+
<Input value={value} onChange={(e) => onChange?.(e.target.value)} placeholder="自定义"/>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const columns = [
|
|
105
|
+
{
|
|
106
|
+
title: '备注',
|
|
107
|
+
dataIndex: 'remark',
|
|
108
|
+
key: 'remark',
|
|
109
|
+
filterable: true,
|
|
110
|
+
filter: {component: MyFilterInput},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
title: '状态',
|
|
114
|
+
dataIndex: 'status',
|
|
115
|
+
key: 'status',
|
|
116
|
+
sortable: true,
|
|
117
|
+
sort: {getSortItems: (key) => [{key: `${key}:asc`, label: 'A-Z'}, {key: `${key}:desc`, label: 'Z-A'}]},
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Props
|
|
123
|
+
|
|
124
|
+
仅支持**打散传参**(有明确关系的成组,其余独立)。
|
|
125
|
+
|
|
126
|
+
**列表/分页/搜索**:`data`、`loading`、`total`、`pagination`、`onPageChange`、`searchParams`、`onSearch`、`onReset`、`rowKey`、`layoutType`。**多选**:通过 `grid.selectedKeys`、`grid.selectedRows`、`grid.onSelectionChange` 传入。**列显示隐藏**:由容器内部维护,不通过 props 传入,通过 context 提供给 ToolBar 列设置与 Grid。
|
|
127
|
+
|
|
128
|
+
**子组件配置**:`grid`、`toolBar`、`search`、`paginationConfig`、`batchActionBar`、`cardList`。
|
|
129
|
+
|
|
130
|
+
| 属性 | 类型 | 说明 |
|
|
131
|
+
|------|------|------|
|
|
132
|
+
| `rowKey` | `string \| (record) => Key` | 行主键 |
|
|
133
|
+
| `layoutType` | `'grid' \| 'card'` | 布局类型 |
|
|
134
|
+
| `data` / `loading` / `total` / `pagination` / `onPageChange` / `searchParams` / `onSearch` / `onReset` | 各自类型 | 打散的数据与回调 |
|
|
135
|
+
| `grid` / `toolBar` / `search` / `paginationConfig` / `batchActionBar` / `cardList` | 各自类型 | 打散的子组件配置。**grid** 类型为 RecordBoardGridProps(基于 antd TableProps 省略 dataSource/loading/pagination/columns/scroll/size/rowSelection),多选在 grid 内;支持 Table 透传(onRow、onHeaderRow、expandable、rowClassName、summary 等) |
|
|
136
|
+
|
|
137
|
+
## Context(RecordBoardContextValue)
|
|
138
|
+
|
|
139
|
+
- `data`、`loading`、`total`、`pagination`、`onPageChange`
|
|
140
|
+
- `searchParams`(含 keyword、filter、sort)、`onSearch`、`onReset`
|
|
141
|
+
- `layoutType`、`selectedKeys`、`selectedRows`、`onSelectionChange`、`rowKey`
|
|
142
|
+
- `columnVisibility`、`onColumnVisibilityChange`(由容器内部维护并注入 context,供 Grid/CardList 与 ToolBar 列设置使用;不通过 props 传入)
|
|
143
|
+
- `childComponentProps`(由容器从打散 props 合并注入)
|
|
144
|
+
|
|
145
|
+
子组件通过 `PisellRecordBoard.useRecordBoardContext()` 获取。
|
|
146
|
+
|
|
147
|
+
## 文档
|
|
148
|
+
|
|
149
|
+
- [使用文档](./docs/PisellRecordBoard.md)
|
|
150
|
+
- [架构说明](./docs/architecture.md)
|
|
151
|
+
- [列与筛选/排序绑定](./docs/columns-filter-binding.md)
|
|
152
|
+
- [设计文档](./docs/PisellRecordBoard.$tab-design.md)
|
|
153
|
+
- [开发文档](./docs/PisellRecordBoard.$tab-dev.md)
|
|
154
|
+
- [测试文档](./docs/PisellRecordBoard.$tab-test.md)
|
|
155
|
+
|
|
156
|
+
## 目录结构
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
pisellRecordBoard/
|
|
160
|
+
├── index.tsx # 导出入口与子组件挂载
|
|
161
|
+
├── PisellRecordBoard.tsx # 主容器与 Provider
|
|
162
|
+
├── types.ts # RecordBoardColumnType、RecordBoardContextValue 等
|
|
163
|
+
├── context/ # RecordBoardContext、RecordBoardProvider
|
|
164
|
+
├── hooks/
|
|
165
|
+
│ └── useRecordBoardContext.ts
|
|
166
|
+
├── shellFrame/ # ToolBar、ColumnSetting、ToolBarQuickFilter、BatchActionBar、Pagination(含 index.less 分页样式)、Search
|
|
167
|
+
├── layouts/
|
|
168
|
+
│ ├── GridLayout/ # 表格布局
|
|
169
|
+
│ └── CardLayout/ # 卡片布局
|
|
170
|
+
├── utils/
|
|
171
|
+
│ ├── recordBoardColumns.tsx # processColumnsForGrid、deriveFilterFromColumns、deriveSortFromColumns
|
|
172
|
+
│ └── withRecordBoard.tsx
|
|
173
|
+
├── docs/
|
|
174
|
+
│ ├── architecture.md
|
|
175
|
+
│ ├── columns-filter-binding.md
|
|
176
|
+
│ └── PisellRecordBoard.$tab-design.md
|
|
177
|
+
├── PisellRecordBoard.stories.tsx
|
|
178
|
+
└── README.md # 本文档
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RecordBoardContext } from "./RecordBoardContext.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/pisellRecordBoard/context/RecordBoardProvider.tsx
|
|
5
|
+
/**
|
|
6
|
+
* 仅负责注入 RecordBoard 上下文。
|
|
7
|
+
* 实际的数据源、onSearch/onPageChange 由上层(如接 DataSourceContainer 或独立 fetch)提供。
|
|
8
|
+
*/
|
|
9
|
+
const RecordBoardProvider = ({ value, children }) => {
|
|
10
|
+
return /* @__PURE__ */ React.createElement(RecordBoardContext.Provider, { value }, children);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { RecordBoardProvider };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 设计文档
|
|
3
|
+
order: 2
|
|
4
|
+
category: pro
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PisellRecordBoard 组件设计文档
|
|
8
|
+
|
|
9
|
+
## 1 组件概述
|
|
10
|
+
|
|
11
|
+
### 1.1 组件定位
|
|
12
|
+
|
|
13
|
+
PisellRecordBoard 是记录看板容器组件,提供统一的 data / pagination / search 上下文,支持表格(Grid)与卡片(Card)两种内容区布局,并可搭配 Shell Frame 获得工具栏、批量操作栏、分页等外壳能力。
|
|
14
|
+
|
|
15
|
+
### 1.2 使用场景
|
|
16
|
+
|
|
17
|
+
- 列表页、数据看板(表格或卡片)
|
|
18
|
+
- 与 DataSourceContainer / useRequest 等对接的受控数据展示
|
|
19
|
+
- 需要搜索、筛选、分页、多选批量操作的记录视图
|
|
20
|
+
|
|
21
|
+
## 2 概念
|
|
22
|
+
|
|
23
|
+
- **RecordBoard**:记录看板容器,提供统一的 data / pagination / search 上下文。
|
|
24
|
+
- **Shell Frame**:与 Layouts 同级,对 Layout 的扩展。提供「外壳」能力:ToolBar(含搜索、筛选)、BatchActionBar、Pagination。包裹在 Layout 外层使用。
|
|
25
|
+
- **Layout**:一种「内容区视图的集合」。仅负责数据展示(表格/卡片),不包含 ToolBar / BatchActionBar / 分页。
|
|
26
|
+
- **Grid 布局**:仅内容区 = 表格。分页与工具栏、多选栏由 **Shell Frame** 提供。
|
|
27
|
+
- **Card 布局**:仅内容区 = 卡片列表。分页与工具栏、多选栏由 **Shell Frame** 提供。
|
|
28
|
+
- 后续可扩展 list、kanban 等 Layout;Shell Frame 可扩展更多外壳槽位。
|
|
29
|
+
|
|
30
|
+
## 3 数据流
|
|
31
|
+
|
|
32
|
+
- 容器通过 **RecordBoardProvider** 提供与 layout 类型无关的上下文:`data`、`loading`、`total`、`pagination`、`searchParams`、`onSearch`、`onPageChange`、`layoutType`、多选等;列显示隐藏(`columnVisibility`、`onColumnVisibilityChange`)由容器内部维护并注入 context,不通过 props 传入。
|
|
33
|
+
- **Shell Frame** 内使用 **PisellRecordBoard.ToolBar**、**PisellRecordBoard.BatchActionBar**、**PisellRecordBoard.Pagination**;ToolBar 内搜索默认 PisellFind,通过打散传入的 **toolBar.search** 透传或关闭;右侧默认 PisellFilter,筛选值存于 **searchParams.filter**;列设置入口由 **toolBar.columnSetting** 控制(默认 true,有 grid.columns 时显示)。Shell Frame 内分页使用定制样式(`shellFrame/Pagination/index.less`)。
|
|
34
|
+
- Layout(GridLayout / CardLayout)只渲染内容区(Grid / CardList,不含分页),通过 **useRecordBoardContext** 消费上下文。
|
|
35
|
+
- 也可单独使用 Search、ToolBar、BatchActionBar、Grid、CardList、Pagination 做自定义组合。
|
|
36
|
+
|
|
37
|
+
## 4 多选与 BatchActionBar
|
|
38
|
+
|
|
39
|
+
- 容器在 context 中提供 `selectedKeys`、`selectedRows`、`onSelectionChange`、`rowKey`(多选由 **grid.selectedKeys / grid.selectedRows / grid.onSelectionChange** 传入,容器合并进 context)。
|
|
40
|
+
- **PisellRecordBoard.BatchActionBar** 对接 **PisellBatchActionBar**:有选中项时展示,全选/反选/清空基于当前页 `data`;删除、自定义 actions 等通过打散传入的 **batchActionBar** 或直接传 props。
|
|
41
|
+
- 使用 **Shell Frame** 时已包含 BatchActionBar;Grid/卡片视图需将 `rowSelection` 与 context 的 `selectedKeys`、`onSelectionChange` 对接,多选勾选才会生效。
|
|
42
|
+
|
|
43
|
+
## 5 使用方式
|
|
44
|
+
|
|
45
|
+
以下示例自包含:所需类型与变量均在块内定义或从 `@pisell/materials`、`antd` 引入。
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import React from 'react';
|
|
49
|
+
import { PisellRecordBoard } from '@pisell/materials';
|
|
50
|
+
import { Button } from 'antd';
|
|
51
|
+
|
|
52
|
+
const list: { id: string; name: string }[] = [];
|
|
53
|
+
const contextValue = {
|
|
54
|
+
data: list,
|
|
55
|
+
loading: false,
|
|
56
|
+
total: 0,
|
|
57
|
+
pagination: { pageNumber: 1, pageSize: 10 },
|
|
58
|
+
onPageChange: () => {},
|
|
59
|
+
searchParams: {},
|
|
60
|
+
onSearch: () => {},
|
|
61
|
+
layoutType: 'grid' as const,
|
|
62
|
+
rowKey: 'id',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// 推荐:Shell Frame + Layout(工具栏、多选栏由 Shell Frame 提供)
|
|
66
|
+
function ExampleWithShellFrame() {
|
|
67
|
+
return (
|
|
68
|
+
<PisellRecordBoard layoutType="grid" rowKey="id" {...contextValue} grid={{ columns: [] }}>
|
|
69
|
+
<PisellRecordBoard.ShellFrame>
|
|
70
|
+
<PisellRecordBoard.GridLayout />
|
|
71
|
+
</PisellRecordBoard.ShellFrame>
|
|
72
|
+
</PisellRecordBoard>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 仅内容区(无 ToolBar / BatchActionBar)
|
|
77
|
+
function ExampleContentOnly() {
|
|
78
|
+
return (
|
|
79
|
+
<PisellRecordBoard {...contextValue}>
|
|
80
|
+
<PisellRecordBoard.GridLayout />
|
|
81
|
+
</PisellRecordBoard>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 自定义组合:ToolBar + BatchActionBar + Grid + 分页
|
|
86
|
+
function ExampleCustomCombo() {
|
|
87
|
+
return (
|
|
88
|
+
<PisellRecordBoard rowKey="id" {...contextValue}>
|
|
89
|
+
<PisellRecordBoard.ToolBar />
|
|
90
|
+
<PisellRecordBoard.BatchActionBar />
|
|
91
|
+
<PisellRecordBoard.Grid />
|
|
92
|
+
<PisellRecordBoard.Pagination />
|
|
93
|
+
</PisellRecordBoard>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 工具栏透传(打散传入 toolBar)
|
|
98
|
+
function ExampleWithToolBarProps() {
|
|
99
|
+
return (
|
|
100
|
+
<PisellRecordBoard
|
|
101
|
+
layoutType="grid"
|
|
102
|
+
rowKey="id"
|
|
103
|
+
{...contextValue}
|
|
104
|
+
toolBar={{
|
|
105
|
+
topLeft: <Button>新建</Button>,
|
|
106
|
+
search: { triggerType: 'input' },
|
|
107
|
+
filter: { hiddenOtherFilter: false },
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<PisellRecordBoard.ShellFrame>
|
|
111
|
+
<PisellRecordBoard.GridLayout />
|
|
112
|
+
</PisellRecordBoard.ShellFrame>
|
|
113
|
+
</PisellRecordBoard>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 默认导出:推荐用法(Shell Frame + GridLayout),便于文档/Story 直接渲染
|
|
118
|
+
export default ExampleWithShellFrame;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 6 扩展
|
|
122
|
+
|
|
123
|
+
- **扩展新 Layout**:在 `layouts/` 下新建 XXXLayout,只实现内容区(如列表 + 分页),在根 index 挂到 `PisellRecordBoard.XXXLayout`。使用时由 Shell Frame 包裹即可获得 ToolBar、BatchActionBar。
|
|
124
|
+
- **扩展 Shell Frame**:在 `shellFrame/` 中增加新槽位(如筛选栏、Tab),在 ShellFrame 组件内按需渲染。
|
|
125
|
+
|
|
126
|
+
## 7 与 DataSourceContainer 对接
|
|
127
|
+
|
|
128
|
+
容器支持受控用法:传入打散的 **data**、**loading**、**pagination**、**onPageChange**、**searchParams**、**onSearch**、**onReset** 等,由上层(如基于 `PisellDataSourceContainer` 或 useRequest)维护后再传给本组件即可;子组件配置通过 **grid**、**toolBar**、**search**、**paginationConfig**、**batchActionBar**、**cardList** 打散传入。
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 开发文档
|
|
3
|
+
order: 3
|
|
4
|
+
category: pro
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PisellRecordBoard 组件开发文档
|
|
8
|
+
|
|
9
|
+
## 1 组件信息
|
|
10
|
+
|
|
11
|
+
### 1.1 基本信息
|
|
12
|
+
|
|
13
|
+
- **组件名称**:PisellRecordBoard
|
|
14
|
+
- **组件分类**:Pro 容器 / 列表看板
|
|
15
|
+
- **开发状态**:维护中
|
|
16
|
+
|
|
17
|
+
### 1.2 组件描述
|
|
18
|
+
|
|
19
|
+
PisellRecordBoard 是记录看板容器,提供统一的 data、pagination、searchParams、onSearch、多选等上下文,支持 Grid 与 Card 两种布局。ToolBar 根据 grid.columns 自动派生筛选与排序;列上配置 type 时表格用 Pisell 组件只读渲染、筛选用编辑态、排序从 SortOptions 派生;无 type 时需自行配置 render、filter、sort,且支持 filter.component 自定义筛选组件。
|
|
20
|
+
|
|
21
|
+
## 2 功能点
|
|
22
|
+
|
|
23
|
+
### 2.1 核心功能
|
|
24
|
+
|
|
25
|
+
- 受控 Context:value 注入 data、pagination、searchParams、onSearch、onReset、多选等
|
|
26
|
+
- ShellFrame:ToolBar + BatchActionBar + Layout + Pagination
|
|
27
|
+
- GridLayout / CardLayout:表格布局、卡片布局
|
|
28
|
+
- 列驱动:processColumnsForGrid、deriveFilterFromColumns、deriveSortFromColumns
|
|
29
|
+
|
|
30
|
+
### 2.2 列配置
|
|
31
|
+
|
|
32
|
+
- 有 type:表格只读、筛选编辑态、排序 SortOptions,可被 render/filter/sort 覆盖
|
|
33
|
+
- 无 type:表格纯文本或 render;筛选需 filter(type 或 component);排序需 sort(type 或 getSortItems)
|
|
34
|
+
- filter.component:无 type 时可用,组件需 value/onChange,由 Form 注入
|
|
35
|
+
|
|
36
|
+
### 2.3 工具栏
|
|
37
|
+
|
|
38
|
+
- 左侧:QuickFilter(仅 quickFilter: true 的列)+ PisellFind + slots.topLeft
|
|
39
|
+
- 右侧:列设置(ColumnSetting,有 grid.columns 且 toolBar.columnSetting !== false 时显示)、Sort、PisellFilter(仅 otherFilter)、ToolBarReset、slots.topRight
|
|
40
|
+
- toolBar.quickFilter:true 或对象(filterList、formFiltersPrefix、size)
|
|
41
|
+
- toolBar.columnSetting:是否显示列显示隐藏入口,默认 true
|
|
42
|
+
|
|
43
|
+
## 3 组件 API
|
|
44
|
+
|
|
45
|
+
### 3.1 类型
|
|
46
|
+
|
|
47
|
+
- **RecordBoardColumnType**:列配置,兼容 antd Table Column,扩展 type、fieldProps(含 options/getOptions)、filterable、filter、sortable、sort
|
|
48
|
+
- **RecordBoardOptionItem**:选项格式 `{ label, value, color? }`,用于 options/getOptions;color 用于只读态 Tag
|
|
49
|
+
- **RecordBoardGetOptions**:同步或异步返回选项列表,用于 fieldProps.getOptions、filter.getOptions
|
|
50
|
+
- **RecordBoardColumnFilterConfig**:filter 配置,type 或 component(value/onChange);type 为 single 时支持 options 或 getOptions
|
|
51
|
+
- **RecordBoardContextValue**:Context 值,data、pagination、searchParams、onSearch、多选等;columnVisibility、onColumnVisibilityChange 由容器内部维护并注入
|
|
52
|
+
- **RecordBoardChildComponentProps**:grid、toolBar(含 columnSetting)、pagination、batchActionBar 等透传
|
|
53
|
+
|
|
54
|
+
### 3.2 工具函数(recordBoardColumns.tsx)
|
|
55
|
+
|
|
56
|
+
- **processColumnsForGrid(columns)**:对带 type 的列注入 Pisell 只读 render(有 render 则用 render);支持 getOptions 异步选项
|
|
57
|
+
- **getRecordBoardColumnKey(column)**:获取列唯一 key,供列显示隐藏等使用
|
|
58
|
+
- **deriveFilterFromColumns(columns)**:返回 quickFilter、otherFilter,有 type 可由 filter 覆盖;支持 filter.getOptions
|
|
59
|
+
- **deriveSortFromColumns(columns)**:返回 SortItemProps 数组,有 type 可由 sort 覆盖
|
|
60
|
+
|
|
61
|
+
## 4 目录结构
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
pisellRecordBoard/
|
|
65
|
+
├── index.tsx
|
|
66
|
+
├── PisellRecordBoard.tsx
|
|
67
|
+
├── types.ts
|
|
68
|
+
├── context/
|
|
69
|
+
├── hooks/
|
|
70
|
+
├── shellFrame/ # ToolBar、ColumnSetting、Pagination(含 index.less 分页样式)等
|
|
71
|
+
├── layouts/GridLayout | CardLayout
|
|
72
|
+
├── utils/recordBoardColumns.tsx, withRecordBoard.tsx
|
|
73
|
+
├── docs/
|
|
74
|
+
├── PisellRecordBoard.stories.tsx
|
|
75
|
+
└── README.md
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 5 扩展说明
|
|
79
|
+
|
|
80
|
+
- 扩展新 Layout:在 layouts 下新建 XXXLayout,挂到 PisellRecordBoard.XXXLayout
|
|
81
|
+
- 扩展 ToolBar 槽位:在 shellFrame/ToolBar 中增加 slots 或 quickFilter/search 配置
|
|
82
|
+
- 新增列 type:在 recordBoardColumns 与 FilterItem 的映射中注册
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 测试文档
|
|
3
|
+
order: 4
|
|
4
|
+
category: pro
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PisellRecordBoard 组件测试用例文档
|
|
8
|
+
|
|
9
|
+
## 1 测试概述
|
|
10
|
+
|
|
11
|
+
### 1.1 测试目标
|
|
12
|
+
|
|
13
|
+
确保 PisellRecordBoard 容器的 Context 注入、子组件组合、列驱动筛选/排序逻辑正确,覆盖有 type/无 type、覆盖行为及边界情况。
|
|
14
|
+
|
|
15
|
+
### 1.2 测试范围
|
|
16
|
+
|
|
17
|
+
- 打散传入的 data / pagination / grid / toolBar 等与默认占位 context
|
|
18
|
+
- ShellFrame + GridLayout / CardLayout 组合渲染
|
|
19
|
+
- 列配置:有 type 时表格/筛选/排序自动派生
|
|
20
|
+
- 列配置:无 type 时 filterable + filter、sortable + sort
|
|
21
|
+
- 列配置:有 type 时 render、filter、sort 覆盖
|
|
22
|
+
- processColumnsForGrid、deriveFilterFromColumns、deriveSortFromColumns 工具函数
|
|
23
|
+
- ToolBar QuickFilter 与 Filter 弹层(quickFilter / otherFilter 分配)
|
|
24
|
+
- 多选与 BatchActionBar 展示
|
|
25
|
+
|
|
26
|
+
### 1.3 测试方法
|
|
27
|
+
|
|
28
|
+
- 单元测试:Context 值、列派生结果、工具函数
|
|
29
|
+
- Storybook:交互与 UI 验证
|
|
30
|
+
- 人工测试:筛选/排序/分页/多选全流程
|
|
31
|
+
|
|
32
|
+
## 2 单元测试用例(建议)
|
|
33
|
+
|
|
34
|
+
### 2.1 工具函数
|
|
35
|
+
|
|
36
|
+
#### processColumnsForGrid
|
|
37
|
+
|
|
38
|
+
- 无 columns 或空数组返回原样
|
|
39
|
+
- 有 type 且无 render 时注入 Pisell 只读 render
|
|
40
|
+
- 有 type 且有 render 时保留 render,不注入
|
|
41
|
+
|
|
42
|
+
#### deriveFilterFromColumns
|
|
43
|
+
|
|
44
|
+
- filterable === false 的列不生成筛项
|
|
45
|
+
- 有 type 且无显式 filter 时按 FIELD_TYPE_TO_FILTER_TYPE 生成
|
|
46
|
+
- 有 type 且有 filter(type 或 component)时用 filter 生成
|
|
47
|
+
- 无 type 且 filterable + filter 时按 filter.type 或 filter.component 生成
|
|
48
|
+
- quickFilter: true 的项进入 quickFilter,否则进入 otherFilter
|
|
49
|
+
|
|
50
|
+
#### deriveSortFromColumns
|
|
51
|
+
|
|
52
|
+
- sortable === false 的列不生成排序项
|
|
53
|
+
- 有 type 且无 sort 时按 SortOptions 派生
|
|
54
|
+
- 有 type 且有 sort 时用 sort 生成
|
|
55
|
+
- 无 type 且 sortable + sort 时按 sort.type 或 sort.getSortItems 生成
|
|
56
|
+
|
|
57
|
+
### 2.2 容器与 Context
|
|
58
|
+
|
|
59
|
+
- 不传打散 props 时使用默认占位 context(data 空数组、空 searchParams)
|
|
60
|
+
- 传入打散 props 时 context 由容器合并得到(含 data、layoutType、rowKey、grid、toolBar 等)
|
|
61
|
+
- 多选由 grid.selectedKeys / grid.selectedRows / grid.onSelectionChange 传入;未传时使用内部 selectedKeys/selectedRows 与 onSelectionChange
|
|
62
|
+
|
|
63
|
+
### 2.3 子组件挂载
|
|
64
|
+
|
|
65
|
+
- PisellRecordBoard.ShellFrame、GridLayout、ToolBar、Grid、Pagination、BatchActionBar、useRecordBoardContext 等子组件存在且可调用
|
|
66
|
+
|
|
67
|
+
## 3 Storybook 覆盖
|
|
68
|
+
|
|
69
|
+
- GridLayoutWithTable、GridLayoutWithQuickFilterOnLeft、CustomFilterSortRender 等 story 覆盖列驱动、QuickFilter、自定义 filter/sort/render
|
|
70
|
+
- 排序、筛选、重置、分页、多选交互可在 Storybook 中人工验证
|