@canlooks/can-ui 0.0.138 → 0.0.140
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/cjs/components/curd/curd.d.ts +9 -7
- package/dist/cjs/components/dataGrid/dataGrid.d.ts +2 -0
- package/dist/cjs/components/dataGrid/dataGrid.js +3 -3
- package/dist/cjs/components/dataGrid/dataGridHead.d.ts +1 -0
- package/dist/cjs/components/dataGrid/dataGridHead.js +11 -4
- package/dist/cjs/components/dataGrid/dataGridRows.js +2 -2
- package/dist/esm/components/curd/curd.d.ts +9 -7
- package/dist/esm/components/dataGrid/dataGrid.d.ts +2 -0
- package/dist/esm/components/dataGrid/dataGrid.js +3 -3
- package/dist/esm/components/dataGrid/dataGridHead.d.ts +1 -0
- package/dist/esm/components/dataGrid/dataGridHead.js +12 -5
- package/dist/esm/components/dataGrid/dataGridRows.js +2 -2
- package/package.json +1 -1
|
@@ -40,13 +40,15 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
40
40
|
wrapperProps?: DivProps;
|
|
41
41
|
/** 嵌入式样式通常用于Dialog或Card组件内 */
|
|
42
42
|
variant?: 'standard' | 'embeded';
|
|
43
|
-
loadRows?:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
loadRows?: {
|
|
44
|
+
bivarianceHack(pagination?: {
|
|
45
|
+
page: number;
|
|
46
|
+
pageSize: number;
|
|
47
|
+
}, filterValue?: FormValue, sorter?: {
|
|
48
|
+
field: FieldPath;
|
|
49
|
+
type: OrderType;
|
|
50
|
+
}): LoadRowsReturn<R> | Promise<LoadRowsReturn<R>>;
|
|
51
|
+
}['bivarianceHack'];
|
|
50
52
|
columns?: (CurdColumn<R> | symbol)[];
|
|
51
53
|
toolbarLeft?: ReactNode;
|
|
52
54
|
toolbarRight?: ReactNode;
|
|
@@ -8,6 +8,7 @@ import { RadioProps } from '../radio';
|
|
|
8
8
|
import { FieldPath } from '../../utils';
|
|
9
9
|
import { FormProps, FormValue } from '../form';
|
|
10
10
|
import { FilterControlProps, FilterOptionsProps } from './filterBubbleContent';
|
|
11
|
+
import { BubbleProps } from '../bubble';
|
|
11
12
|
export type RowType = Obj;
|
|
12
13
|
export interface ColumnType<R extends RowType = RowType> extends Omit<ComponentProps<'td'>, 'key' | 'ref' | 'title' | 'children'>, Omit<ComponentProps<'th'>, 'key' | 'ref' | 'title' | 'children'> {
|
|
13
14
|
title?: ReactNode;
|
|
@@ -73,6 +74,7 @@ export interface DataGridBaseProps<R extends RowType = RowType> extends DataGrid
|
|
|
73
74
|
rows?: R[];
|
|
74
75
|
filterProps?: FormProps;
|
|
75
76
|
initialFilterValue?: FormValue;
|
|
77
|
+
filterBubbleProps?: BubbleProps;
|
|
76
78
|
onFilter?(filterValue: FormValue): void;
|
|
77
79
|
onFilterClick?(column: Id, e: React.MouseEvent<HTMLButtonElement>): void;
|
|
78
80
|
/** 若需要本地筛选,必须指定该方法 */
|
|
@@ -19,7 +19,7 @@ const DataGridContext = (0, react_1.createContext)({});
|
|
|
19
19
|
function useDataGridContext() {
|
|
20
20
|
return (0, react_1.useContext)(DataGridContext);
|
|
21
21
|
}
|
|
22
|
-
exports.DataGrid = (0, react_1.memo)(({ slots, slotProps, columns, rows, rowProps, primaryKey = 'id', childrenKey = null, filterProps, initialFilterValue, onFilter, onFilterClick, filterPredicate, defaultOrderColumn, orderColumn, defaultOrderType = 'descend', orderType, onOrderChange, selectable, relation = 'dependent', integration = 'shallowest', allowSelectAll = true, clickRowToSelect = true, selectorProps, indent = 24, renderExpandIcon, defaultExpanded, expanded, onExpandedChange, paginatable = true, paginationProps, renderPagination, loading, emptyPlaceholder, columnResizable = false, size, bordered, striped, tableProps, multiple, defaultValue, value, onChange, ...props }) => {
|
|
22
|
+
exports.DataGrid = (0, react_1.memo)(({ slots, slotProps, columns, rows, rowProps, primaryKey = 'id', childrenKey = null, filterProps, initialFilterValue, filterBubbleProps, onFilter, onFilterClick, filterPredicate, defaultOrderColumn, orderColumn, defaultOrderType = 'descend', orderType, onOrderChange, selectable, relation = 'dependent', integration = 'shallowest', allowSelectAll = true, clickRowToSelect = true, selectorProps, indent = 24, renderExpandIcon, defaultExpanded, expanded, onExpandedChange, paginatable = true, paginationProps, renderPagination, loading, emptyPlaceholder, columnResizable = false, size, bordered, striped, tableProps, multiple, defaultValue, value, onChange, ...props }) => {
|
|
23
23
|
/**
|
|
24
24
|
* ---------------------------------------------------------------
|
|
25
25
|
* 选择行
|
|
@@ -131,12 +131,12 @@ exports.DataGrid = (0, react_1.memo)(({ slots, slotProps, columns, rows, rowProp
|
|
|
131
131
|
return orderedRows?.slice((page - 1) * pageSize, page * pageSize);
|
|
132
132
|
}, [orderedRows, _paginationProps.page, _paginationProps.pageSize, paginatable]);
|
|
133
133
|
return ((0, jsx_runtime_1.jsxs)(loading_1.Loading, { fill: false, ...props, css: dataGrid_style_1.style, className: (0, utils_1.clsx)(dataGrid_style_1.classes.root, props.className), open: loading, "data-column-resizable": columnResizable, children: [(0, jsx_runtime_1.jsx)(form_1.Form, { ...(0, utils_1.mergeComponentProps)({
|
|
134
|
+
className: dataGrid_style_1.classes.filterForm,
|
|
134
135
|
variant: 'plain',
|
|
135
136
|
initialValue: innerFilterValue
|
|
136
137
|
}, filterProps, {
|
|
137
|
-
className: dataGrid_style_1.classes.filterForm,
|
|
138
138
|
onFinish: filterHandler
|
|
139
|
-
}), children: (0, jsx_runtime_1.jsx)(columnResize_1.ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => (0, jsx_runtime_1.jsxs)(table_1.TableContainer, { ref: scrollerRef, className: dataGrid_style_1.classes.container, children: [(0, jsx_runtime_1.jsx)(table_1.Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: (0, utils_1.cloneRef)(tableProps?.ref, tableRef), children: (0, jsx_runtime_1.jsxs)(selectionContext_1.SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [(0, jsx_runtime_1.jsx)(dataGridHead_1.DataGridHead, { rows: rows, flattedColumns: flattedColumns, completedColumns: completedColumns, primaryKey: primaryKey, allowSelectAll: allowSelectAll, columnResizable: columnResizable, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, onFilterClick: onFilterClick }), (0, jsx_runtime_1.jsx)("tbody", { children: (0, jsx_runtime_1.jsx)(DataGridContext, { value: (0, react_1.useMemo)(() => ({
|
|
139
|
+
}), children: (0, jsx_runtime_1.jsx)(columnResize_1.ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => (0, jsx_runtime_1.jsxs)(table_1.TableContainer, { ref: scrollerRef, className: dataGrid_style_1.classes.container, children: [(0, jsx_runtime_1.jsx)(table_1.Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: (0, utils_1.cloneRef)(tableProps?.ref, tableRef), children: (0, jsx_runtime_1.jsxs)(selectionContext_1.SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [(0, jsx_runtime_1.jsx)(dataGridHead_1.DataGridHead, { rows: rows, flattedColumns: flattedColumns, completedColumns: completedColumns, primaryKey: primaryKey, allowSelectAll: allowSelectAll, columnResizable: columnResizable, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, filterBubbleProps: filterBubbleProps, onFilterClick: onFilterClick }), (0, jsx_runtime_1.jsx)("tbody", { children: (0, jsx_runtime_1.jsx)(DataGridContext, { value: (0, react_1.useMemo)(() => ({
|
|
140
140
|
slots, slotProps,
|
|
141
141
|
rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
|
|
142
142
|
expandedSet, flattedColumns, toggleExpanded
|
|
@@ -6,6 +6,7 @@ interface DataGridHeadProps<R extends RowType, V extends Id = Id> extends Requir
|
|
|
6
6
|
orderColumn: Id | undefined;
|
|
7
7
|
flattedColumns: (symbol | ColumnType<R>)[] | undefined;
|
|
8
8
|
completedColumns: (symbol | ColumnType<R>)[] | undefined;
|
|
9
|
+
filterBubbleProps: DataGridProps<R, V>['filterBubbleProps'];
|
|
9
10
|
onFilterClick: DataGridProps<R, V>['onFilterClick'];
|
|
10
11
|
}
|
|
11
12
|
export declare const DataGridHead: <R extends RowType, V extends Id = Id>(props: DataGridHeadProps<R, V>) => ReactElement;
|
|
@@ -18,7 +18,7 @@ const bubble_1 = require("../bubble");
|
|
|
18
18
|
const filterBubbleContent_1 = require("./filterBubbleContent");
|
|
19
19
|
const form_1 = require("../form");
|
|
20
20
|
const utils_1 = require("../../utils");
|
|
21
|
-
exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, flattedColumns, completedColumns, rows, primaryKey, orderColumn, orderType, onOrderChange, onFilterClick }) => {
|
|
21
|
+
exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, flattedColumns, completedColumns, rows, primaryKey, orderColumn, orderType, onOrderChange, filterBubbleProps, onFilterClick }) => {
|
|
22
22
|
const { multiple, setValue, selectionStatus } = (0, selectionContext_1.useSelectionContext)();
|
|
23
23
|
const allSelectionStatus = (0, react_2.useMemo)(() => {
|
|
24
24
|
if (multiple && allowSelectAll) {
|
|
@@ -82,7 +82,7 @@ exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, fla
|
|
|
82
82
|
}
|
|
83
83
|
const {
|
|
84
84
|
// 排除无需加入dom节点的属性
|
|
85
|
-
title, key, children,
|
|
85
|
+
title, key, children, field, render, sorter, filter, _key, _negativeRowSpan = 0, ...colProps } = col;
|
|
86
86
|
const sortable = sorter && !children?.length;
|
|
87
87
|
const isOrderingColumn = orderColumn === _key;
|
|
88
88
|
const currentOrderType = isOrderingColumn ? orderType : 'descend';
|
|
@@ -92,7 +92,7 @@ exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, fla
|
|
|
92
92
|
onFilterClick?.(_key, e);
|
|
93
93
|
}, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faFilter_1.faFilter }) }));
|
|
94
94
|
return [
|
|
95
|
-
(0, react_1.createElement)(Column, { rowSpan: headRows.length - _negativeRowSpan, ...colProps, key: _key,
|
|
95
|
+
(0, react_1.createElement)(Column, { rowSpan: headRows.length - _negativeRowSpan, ...colProps, key: _key, "data-sortable": !!sortable, "data-ordering": isOrderingColumn, "data-order-type": currentOrderType, onClick: e => {
|
|
96
96
|
colProps.onClick?.(e);
|
|
97
97
|
sortable && onOrderChange?.(_key, currentOrderType === 'descend' ? 'ascend' : 'descend');
|
|
98
98
|
} }, sortable || filter
|
|
@@ -103,7 +103,14 @@ exports.DataGridHead = (0, react_2.memo)(({ allowSelectAll, columnResizable, fla
|
|
|
103
103
|
: (0, jsx_runtime_1.jsx)("div", { className: dataGrid_style_1.classes.title, children: title }), filter &&
|
|
104
104
|
(0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { title: "\u7B5B\u9009", placement: "top", clickToClose: true, children: filter === true
|
|
105
105
|
? filterButton
|
|
106
|
-
: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, {
|
|
106
|
+
: (0, jsx_runtime_1.jsx)(bubble_1.Bubble, { ...(0, utils_1.mergeComponentProps)({
|
|
107
|
+
style: { maxWidth: 360 },
|
|
108
|
+
trigger: 'click',
|
|
109
|
+
placement: 'bottomRight',
|
|
110
|
+
autoClose: false,
|
|
111
|
+
content: ((0, jsx_runtime_1.jsx)(filterBubbleContent_1.FilterBubbleContent, { columnKey: _key, columnFilterProps: filter })),
|
|
112
|
+
onClick: e => e.stopPropagation()
|
|
113
|
+
}, filterBubbleProps), children: filterButton }) })] })
|
|
107
114
|
: title)
|
|
108
115
|
];
|
|
109
116
|
}) }, i));
|
|
@@ -56,10 +56,10 @@ exports.DataGridRows = (0, react_2.memo)(({ rows, _level = 0 }) => {
|
|
|
56
56
|
// 排除无需加入dom节点的属性
|
|
57
57
|
// width属性只需加入thead列中,普通列需排除
|
|
58
58
|
// rowSpan与colSpan需排除
|
|
59
|
-
title, key, children,
|
|
59
|
+
title, key, children, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
|
|
60
60
|
const renderedContent = (0, utils_1.renderCell)({ render, field }, row, i, arr);
|
|
61
61
|
const shouldRenderExpand = expandableIndex === j - 1;
|
|
62
|
-
return ((0, react_1.createElement)(table_1.TdCell, { ..._colProps, key: _key, className: shouldRenderExpand
|
|
62
|
+
return ((0, react_1.createElement)(table_1.TdCell, { ..._colProps, key: _key, className: (0, utils_1.clsx)(_colProps.className, shouldRenderExpand && dataGrid_style_1.classes.expandable) }, shouldRenderExpand
|
|
63
63
|
? (0, jsx_runtime_1.jsxs)("div", { className: dataGrid_style_1.classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [(0, jsx_runtime_1.jsx)(button_1.Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
|
|
64
64
|
? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
|
|
65
65
|
: currentExpanded
|
|
@@ -40,13 +40,15 @@ export interface CurdBaseProps<R extends RowType = RowType, F extends FormValue
|
|
|
40
40
|
wrapperProps?: DivProps;
|
|
41
41
|
/** 嵌入式样式通常用于Dialog或Card组件内 */
|
|
42
42
|
variant?: 'standard' | 'embeded';
|
|
43
|
-
loadRows?:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
loadRows?: {
|
|
44
|
+
bivarianceHack(pagination?: {
|
|
45
|
+
page: number;
|
|
46
|
+
pageSize: number;
|
|
47
|
+
}, filterValue?: FormValue, sorter?: {
|
|
48
|
+
field: FieldPath;
|
|
49
|
+
type: OrderType;
|
|
50
|
+
}): LoadRowsReturn<R> | Promise<LoadRowsReturn<R>>;
|
|
51
|
+
}['bivarianceHack'];
|
|
50
52
|
columns?: (CurdColumn<R> | symbol)[];
|
|
51
53
|
toolbarLeft?: ReactNode;
|
|
52
54
|
toolbarRight?: ReactNode;
|
|
@@ -8,6 +8,7 @@ import { RadioProps } from '../radio';
|
|
|
8
8
|
import { FieldPath } from '../../utils';
|
|
9
9
|
import { FormProps, FormValue } from '../form';
|
|
10
10
|
import { FilterControlProps, FilterOptionsProps } from './filterBubbleContent';
|
|
11
|
+
import { BubbleProps } from '../bubble';
|
|
11
12
|
export type RowType = Obj;
|
|
12
13
|
export interface ColumnType<R extends RowType = RowType> extends Omit<ComponentProps<'td'>, 'key' | 'ref' | 'title' | 'children'>, Omit<ComponentProps<'th'>, 'key' | 'ref' | 'title' | 'children'> {
|
|
13
14
|
title?: ReactNode;
|
|
@@ -73,6 +74,7 @@ export interface DataGridBaseProps<R extends RowType = RowType> extends DataGrid
|
|
|
73
74
|
rows?: R[];
|
|
74
75
|
filterProps?: FormProps;
|
|
75
76
|
initialFilterValue?: FormValue;
|
|
77
|
+
filterBubbleProps?: BubbleProps;
|
|
76
78
|
onFilter?(filterValue: FormValue): void;
|
|
77
79
|
onFilterClick?(column: Id, e: React.MouseEvent<HTMLButtonElement>): void;
|
|
78
80
|
/** 若需要本地筛选,必须指定该方法 */
|
|
@@ -15,7 +15,7 @@ const DataGridContext = createContext({});
|
|
|
15
15
|
export function useDataGridContext() {
|
|
16
16
|
return useContext(DataGridContext);
|
|
17
17
|
}
|
|
18
|
-
export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, primaryKey = 'id', childrenKey = null, filterProps, initialFilterValue, onFilter, onFilterClick, filterPredicate, defaultOrderColumn, orderColumn, defaultOrderType = 'descend', orderType, onOrderChange, selectable, relation = 'dependent', integration = 'shallowest', allowSelectAll = true, clickRowToSelect = true, selectorProps, indent = 24, renderExpandIcon, defaultExpanded, expanded, onExpandedChange, paginatable = true, paginationProps, renderPagination, loading, emptyPlaceholder, columnResizable = false, size, bordered, striped, tableProps, multiple, defaultValue, value, onChange, ...props }) => {
|
|
18
|
+
export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, primaryKey = 'id', childrenKey = null, filterProps, initialFilterValue, filterBubbleProps, onFilter, onFilterClick, filterPredicate, defaultOrderColumn, orderColumn, defaultOrderType = 'descend', orderType, onOrderChange, selectable, relation = 'dependent', integration = 'shallowest', allowSelectAll = true, clickRowToSelect = true, selectorProps, indent = 24, renderExpandIcon, defaultExpanded, expanded, onExpandedChange, paginatable = true, paginationProps, renderPagination, loading, emptyPlaceholder, columnResizable = false, size, bordered, striped, tableProps, multiple, defaultValue, value, onChange, ...props }) => {
|
|
19
19
|
/**
|
|
20
20
|
* ---------------------------------------------------------------
|
|
21
21
|
* 选择行
|
|
@@ -127,12 +127,12 @@ export const DataGrid = memo(({ slots, slotProps, columns, rows, rowProps, prima
|
|
|
127
127
|
return orderedRows?.slice((page - 1) * pageSize, page * pageSize);
|
|
128
128
|
}, [orderedRows, _paginationProps.page, _paginationProps.pageSize, paginatable]);
|
|
129
129
|
return (_jsxs(Loading, { fill: false, ...props, css: style, className: clsx(classes.root, props.className), open: loading, "data-column-resizable": columnResizable, children: [_jsx(Form, { ...mergeComponentProps({
|
|
130
|
+
className: classes.filterForm,
|
|
130
131
|
variant: 'plain',
|
|
131
132
|
initialValue: innerFilterValue
|
|
132
133
|
}, filterProps, {
|
|
133
|
-
className: classes.filterForm,
|
|
134
134
|
onFinish: filterHandler
|
|
135
|
-
}), children: _jsx(ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => _jsxs(TableContainer, { ref: scrollerRef, className: classes.container, children: [_jsx(Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: cloneRef(tableProps?.ref, tableRef), children: _jsxs(SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [_jsx(DataGridHead, { rows: rows, flattedColumns: flattedColumns, completedColumns: completedColumns, primaryKey: primaryKey, allowSelectAll: allowSelectAll, columnResizable: columnResizable, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, onFilterClick: onFilterClick }), _jsx("tbody", { children: _jsx(DataGridContext, { value: useMemo(() => ({
|
|
135
|
+
}), children: _jsx(ColumnResizeContext, { columnResizable: columnResizable, children: ({ scrollerRef, tableRef }) => _jsxs(TableContainer, { ref: scrollerRef, className: classes.container, children: [_jsx(Table, { size: size, bordered: bordered, striped: striped, ...tableProps, ref: cloneRef(tableProps?.ref, tableRef), children: _jsxs(SelectionContext, { options: rows, primaryKey: primaryKey, childrenKey: childrenKey !== null ? childrenKey : void 0, relation: relation, integration: integration, disabled: !selectable, multiple: multiple, defaultValue: defaultValue, value: value, onChange: onChange, children: [_jsx(DataGridHead, { rows: rows, flattedColumns: flattedColumns, completedColumns: completedColumns, primaryKey: primaryKey, allowSelectAll: allowSelectAll, columnResizable: columnResizable, orderColumn: innerOrderColumn.current, orderType: innerOrderType.current, onOrderChange: orderChangeHandler, filterBubbleProps: filterBubbleProps, onFilterClick: onFilterClick }), _jsx("tbody", { children: _jsx(DataGridContext, { value: useMemo(() => ({
|
|
136
136
|
slots, slotProps,
|
|
137
137
|
rowProps, primaryKey, childrenKey, clickRowToSelect, indent, renderExpandIcon,
|
|
138
138
|
expandedSet, flattedColumns, toggleExpanded
|
|
@@ -6,6 +6,7 @@ interface DataGridHeadProps<R extends RowType, V extends Id = Id> extends Requir
|
|
|
6
6
|
orderColumn: Id | undefined;
|
|
7
7
|
flattedColumns: (symbol | ColumnType<R>)[] | undefined;
|
|
8
8
|
completedColumns: (symbol | ColumnType<R>)[] | undefined;
|
|
9
|
+
filterBubbleProps: DataGridProps<R, V>['filterBubbleProps'];
|
|
9
10
|
onFilterClick: DataGridProps<R, V>['onFilterClick'];
|
|
10
11
|
}
|
|
11
12
|
export declare const DataGridHead: <R extends RowType, V extends Id = Id>(props: DataGridHeadProps<R, V>) => ReactElement;
|
|
@@ -14,8 +14,8 @@ import { faFilter } from '@fortawesome/free-solid-svg-icons/faFilter';
|
|
|
14
14
|
import { Bubble } from '../bubble';
|
|
15
15
|
import { FilterBubbleContent } from './filterBubbleContent';
|
|
16
16
|
import { useFormValueContext } from '../form';
|
|
17
|
-
import { isUnset } from '../../utils';
|
|
18
|
-
export const DataGridHead = memo(({ allowSelectAll, columnResizable, flattedColumns, completedColumns, rows, primaryKey, orderColumn, orderType, onOrderChange, onFilterClick }) => {
|
|
17
|
+
import { isUnset, mergeComponentProps } from '../../utils';
|
|
18
|
+
export const DataGridHead = memo(({ allowSelectAll, columnResizable, flattedColumns, completedColumns, rows, primaryKey, orderColumn, orderType, onOrderChange, filterBubbleProps, onFilterClick }) => {
|
|
19
19
|
const { multiple, setValue, selectionStatus } = useSelectionContext();
|
|
20
20
|
const allSelectionStatus = useMemo(() => {
|
|
21
21
|
if (multiple && allowSelectAll) {
|
|
@@ -79,7 +79,7 @@ export const DataGridHead = memo(({ allowSelectAll, columnResizable, flattedColu
|
|
|
79
79
|
}
|
|
80
80
|
const {
|
|
81
81
|
// 排除无需加入dom节点的属性
|
|
82
|
-
title, key, children,
|
|
82
|
+
title, key, children, field, render, sorter, filter, _key, _negativeRowSpan = 0, ...colProps } = col;
|
|
83
83
|
const sortable = sorter && !children?.length;
|
|
84
84
|
const isOrderingColumn = orderColumn === _key;
|
|
85
85
|
const currentOrderType = isOrderingColumn ? orderType : 'descend';
|
|
@@ -89,7 +89,7 @@ export const DataGridHead = memo(({ allowSelectAll, columnResizable, flattedColu
|
|
|
89
89
|
onFilterClick?.(_key, e);
|
|
90
90
|
}, children: _jsx(Icon, { icon: faFilter }) }));
|
|
91
91
|
return [
|
|
92
|
-
_createElement(Column, { rowSpan: headRows.length - _negativeRowSpan, ...colProps, key: _key,
|
|
92
|
+
_createElement(Column, { rowSpan: headRows.length - _negativeRowSpan, ...colProps, key: _key, "data-sortable": !!sortable, "data-ordering": isOrderingColumn, "data-order-type": currentOrderType, onClick: e => {
|
|
93
93
|
colProps.onClick?.(e);
|
|
94
94
|
sortable && onOrderChange?.(_key, currentOrderType === 'descend' ? 'ascend' : 'descend');
|
|
95
95
|
} }, sortable || filter
|
|
@@ -100,7 +100,14 @@ export const DataGridHead = memo(({ allowSelectAll, columnResizable, flattedColu
|
|
|
100
100
|
: _jsx("div", { className: classes.title, children: title }), filter &&
|
|
101
101
|
_jsx(Tooltip, { title: "\u7B5B\u9009", placement: "top", clickToClose: true, children: filter === true
|
|
102
102
|
? filterButton
|
|
103
|
-
: _jsx(Bubble, {
|
|
103
|
+
: _jsx(Bubble, { ...mergeComponentProps({
|
|
104
|
+
style: { maxWidth: 360 },
|
|
105
|
+
trigger: 'click',
|
|
106
|
+
placement: 'bottomRight',
|
|
107
|
+
autoClose: false,
|
|
108
|
+
content: (_jsx(FilterBubbleContent, { columnKey: _key, columnFilterProps: filter })),
|
|
109
|
+
onClick: e => e.stopPropagation()
|
|
110
|
+
}, filterBubbleProps), children: filterButton }) })] })
|
|
104
111
|
: title)
|
|
105
112
|
];
|
|
106
113
|
}) }, i));
|
|
@@ -53,10 +53,10 @@ export const DataGridRows = memo(({ rows, _level = 0 }) => {
|
|
|
53
53
|
// 排除无需加入dom节点的属性
|
|
54
54
|
// width属性只需加入thead列中,普通列需排除
|
|
55
55
|
// rowSpan与colSpan需排除
|
|
56
|
-
title, key, children,
|
|
56
|
+
title, key, children, field, render, sorter, filter, width, _key, _negativeRowSpan, rowSpan, colSpan, ..._colProps } = col;
|
|
57
57
|
const renderedContent = renderCell({ render, field }, row, i, arr);
|
|
58
58
|
const shouldRenderExpand = expandableIndex === j - 1;
|
|
59
|
-
return (_createElement(TdCell, { ..._colProps, key: _key, className: shouldRenderExpand
|
|
59
|
+
return (_createElement(TdCell, { ..._colProps, key: _key, className: clsx(_colProps.className, shouldRenderExpand && classes.expandable) }, shouldRenderExpand
|
|
60
60
|
? _jsxs("div", { className: classes.expandableWrap, style: { paddingLeft: _level * indent }, children: [_jsx(Button, { variant: "text", shape: "circular", color: "text.disabled", onClick: () => toggleExpanded(trKey), style: expandable ? void 0 : { visibility: 'hidden' }, children: renderExpandIcon
|
|
61
61
|
? renderExpandIcon(trKey, currentExpanded, [...expandedSet])
|
|
62
62
|
: currentExpanded
|