@canlooks/can-ui 0.0.139 → 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.
@@ -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) {
@@ -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, { style: { maxWidth: 360 }, trigger: "click", placement: "bottomRight", autoClose: false, content: (0, jsx_runtime_1.jsx)(filterBubbleContent_1.FilterBubbleContent, { columnKey: _key, columnFilterProps: filter }), onClick: e => e.stopPropagation(), children: filterButton }) })] })
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));
@@ -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) {
@@ -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, { style: { maxWidth: 360 }, trigger: "click", placement: "bottomRight", autoClose: false, content: _jsx(FilterBubbleContent, { columnKey: _key, columnFilterProps: filter }), onClick: e => e.stopPropagation(), children: filterButton }) })] })
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.139",
3
+ "version": "0.0.140",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",