@lemon-fe/components 1.4.29 → 1.5.2

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.
@@ -17,7 +17,7 @@ declare const Editors: {
17
17
  Text: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").TextEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
18
18
  Date: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").DateEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
19
19
  Number: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & import("..").NumberEditorParams<any> & React.RefAttributes<import("ag-grid-react").ICellEditorReactComp>>;
20
- Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "virtual" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "listHeight"> & {
20
+ Select: React.ForwardRefExoticComponent<import("ag-grid-community").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "showSearch" | "virtual" | "optionFilterProp" | "options" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -1,9 +1,17 @@
1
1
  import React from 'react';
2
- import type { CSSProperties, ForwardedRef, ReactElement } from 'react';
2
+ import type { CSSProperties, ForwardedRef, ReactElement, ReactNode } from 'react';
3
3
  import { type DataGridRef } from '../data-grid';
4
4
  import type { ColType, CustomColumnData, DataGridProps, PaginationType, SortType } from '../data-grid/typings';
5
5
  import type { FilterProps } from '../filter/typings';
6
6
  import type { SideBarDef } from 'ag-grid-community';
7
+ export interface SelectViewBodyOpts<RecordType, ParamsType> {
8
+ loading: boolean;
9
+ setLoading: (loading: boolean) => void;
10
+ params: ParamsType;
11
+ selectedData: RecordType[];
12
+ selectedKeys: string[];
13
+ onSelectChange: (keys: string[] | Set<string>, records: RecordType[], rowDoubleClicked?: boolean) => void;
14
+ }
7
15
  export interface SelectViewProps<RecordType, ParamsType> extends Pick<DataGridProps<RecordType>, 'defaultColDef' | 'rowHeight' | 'cellDisplayFlex' | 'isRowSelectable' | 'rowMultiSelectWithClick' | 'suppressRowClickSelection'> {
8
16
  value?: RecordType[];
9
17
  onChange?: (value: RecordType[], rowDoubleClicked?: boolean) => void;
@@ -89,6 +97,10 @@ export interface SelectViewProps<RecordType, ParamsType> extends Pick<DataGridPr
89
97
  * @description 自定义主datagrid
90
98
  */
91
99
  customDataGridProps?: DataGridProps<RecordType>;
100
+ /**
101
+ * @description 自定义body区域,支持函数形式获取组件内部状态
102
+ */
103
+ body?: ReactElement | ((opts: SelectViewBodyOpts<RecordType, ParamsType>) => ReactNode);
92
104
  }
93
105
  declare function SelectView<RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(originalProps: SelectViewProps<RecordType, ParamsType>, ref?: ForwardedRef<DataGridRef<RecordType>>): JSX.Element;
94
106
  declare const _default: <RecordType extends Record<string | number, any>, ParamsType extends Record<string, any>>(props: SelectViewProps<RecordType, ParamsType> & {
@@ -61,7 +61,8 @@ function SelectView(originalProps, ref) {
61
61
  customColumnPanelStorage = props.customColumnPanelStorage,
62
62
  _props$suppressRowCli = props.suppressRowClickSelection,
63
63
  suppressRowClickSelection = _props$suppressRowCli === void 0 ? false : _props$suppressRowCli,
64
- rowMultiSelectWithClick = props.rowMultiSelectWithClick;
64
+ rowMultiSelectWithClick = props.rowMultiSelectWithClick,
65
+ bodyProp = props.body;
65
66
  var prefix = prefixClassName("select-view");
66
67
  var _useState = useState(value || emptyValue),
67
68
  _useState2 = _slicedToArray(_useState, 2),
@@ -218,6 +219,18 @@ function SelectView(originalProps, ref) {
218
219
  ref.current = val;
219
220
  }
220
221
  };
222
+ var bodyNode = useMemo(function () {
223
+ if (!bodyProp) return null;
224
+ return typeof bodyProp === 'function' ? bodyProp({
225
+ loading: loading,
226
+ setLoading: setLoading,
227
+ params: cParams,
228
+ selectedData: data,
229
+ selectedKeys: dataKeys,
230
+ onSelectChange: handleChangeData
231
+ }) : bodyProp;
232
+ // eslint-disable-next-line react-hooks/exhaustive-deps
233
+ }, [bodyProp, loading, cParams, data, dataKeys]);
221
234
  var renderList = function renderList() {
222
235
  return /*#__PURE__*/React.createElement("div", {
223
236
  className: prefix('layout')
@@ -245,7 +258,7 @@ function SelectView(originalProps, ref) {
245
258
  className: prefix('head')
246
259
  }, headerNode), /*#__PURE__*/React.createElement("div", {
247
260
  className: prefix('body')
248
- }, /*#__PURE__*/React.createElement(DataGrid, _extends({
261
+ }, bodyNode ? bodyNode : /*#__PURE__*/React.createElement(DataGrid, _extends({
249
262
  ref: function ref(val) {
250
263
  if (!readOnly) {
251
264
  initRef(val);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.29",
3
+ "version": "1.5.2",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://registry.npmjs.org"
60
60
  },
61
- "gitHead": "dae2c5d9ba0de9059c879c6148a0e0df01ebe0f1"
61
+ "gitHead": "f1d68fc8b34f14b697a46df4c0d2bad9bc698426"
62
62
  }