@lemon-fe/kits 1.0.0-157 → 1.0.0-159

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.
@@ -60,6 +60,9 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
60
60
  } & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
61
61
  Wrapper: typeof EditorWrapper;
62
62
  };
63
+ static isSummaryRow({ node }: {
64
+ node?: IRowNode<any>;
65
+ }): boolean;
63
66
  constructor(props: DataGridProps<TData>);
64
67
  private getPagination;
65
68
  componentDidUpdate(prevProps: DataGridProps<TData>): void;
@@ -74,9 +77,6 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
74
77
  afterReady(cb: () => void): void;
75
78
  private isPreserveSelected;
76
79
  private updateRowData;
77
- isSummaryRow({ node }: {
78
- node?: IRowNode<any>;
79
- }): boolean;
80
80
  private getSummaryRowData;
81
81
  private getDataFromServer;
82
82
  private pagination;
@@ -367,7 +367,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
367
367
  return shallowEqual(prev[0], next[0]);
368
368
  }));
369
369
 
370
- _defineProperty(_assertThisInitialized(_this), "getMemoizedDetailCellParams", memoizeOne(function (detailCell, params) {
370
+ _defineProperty(_assertThisInitialized(_this), "getMemoizedDetailCellParams", memoizeOne(function (detailCell, params, autoHeight) {
371
371
  if (detailCell === undefined) {
372
372
  return params;
373
373
  }
@@ -376,6 +376,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
376
376
  masterDetail: true,
377
377
  detailCellRenderer: DetailCellRenderer,
378
378
  detailCellRendererParams: _objectSpread(_objectSpread(_objectSpread({}, params), detailCell.params), {}, {
379
+ autoHeight: autoHeight,
379
380
  render: detailCell.render
380
381
  })
381
382
  };
@@ -963,17 +964,6 @@ var DataGrid = /*#__PURE__*/function (_Component) {
963
964
  }
964
965
  });
965
966
  }
966
- }, {
967
- key: "isSummaryRow",
968
- value: function isSummaryRow(_ref3) {
969
- var node = _ref3.node;
970
-
971
- if (node && node.data && node.data[DataGrid.SummaryFlag]) {
972
- return true;
973
- }
974
-
975
- return false;
976
- }
977
967
  }, {
978
968
  key: "getSummaryRowData",
979
969
  value: function getSummaryRowData() {
@@ -1009,6 +999,16 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1009
999
  onLoading = _this$props7.onLoading,
1010
1000
  onLoad = _this$props7.onLoad;
1011
1001
 
1002
+ var loadingChange = function loadingChange(flag) {
1003
+ if (onLoading) {
1004
+ onLoading(flag);
1005
+ } else {
1006
+ _this5.setState({
1007
+ loading: flag
1008
+ });
1009
+ }
1010
+ };
1011
+
1012
1012
  if (typeof fetch === 'function') {
1013
1013
  if (this.requestId < Number.MAX_SAFE_INTEGER) {
1014
1014
  this.requestId += 1;
@@ -1019,10 +1019,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1019
1019
  pageSize = _this$state.pageSize;
1020
1020
  var columnState = this.columnApi.getColumnState();
1021
1021
  var id = this.requestId;
1022
- this.setState({
1023
- loading: true
1024
- });
1025
- onLoading === null || onLoading === void 0 ? void 0 : onLoading(true);
1022
+ loadingChange(true);
1026
1023
  fetch({
1027
1024
  current: page,
1028
1025
  pageSize: pageSize,
@@ -1039,11 +1036,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1039
1036
  return;
1040
1037
  }
1041
1038
 
1042
- onLoading === null || onLoading === void 0 ? void 0 : onLoading(false);
1043
-
1044
- _this5.setState({
1045
- loading: false
1046
- });
1039
+ loadingChange(false);
1047
1040
 
1048
1041
  if (res.total !== undefined) {
1049
1042
  _this5.setState({
@@ -1075,11 +1068,10 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1075
1068
  fetchError: err
1076
1069
  });
1077
1070
 
1078
- onLoading === null || onLoading === void 0 ? void 0 : onLoading(false);
1071
+ loadingChange(false);
1079
1072
 
1080
1073
  _this5.setState(function (prev) {
1081
1074
  return {
1082
- loading: false,
1083
1075
  total: prev.page === 1 ? 0 : prev.total
1084
1076
  };
1085
1077
  });
@@ -1149,8 +1141,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1149
1141
  _this7.store.setState({
1150
1142
  errors: errors
1151
1143
  });
1152
- }).catch(function (_ref4) {
1153
- var fields = _ref4.fields;
1144
+ }).catch(function (_ref3) {
1145
+ var fields = _ref3.fields;
1154
1146
  var errors = new Map(_this7.store.getState().errors);
1155
1147
  var error = new Map();
1156
1148
  Object.entries(fields).forEach(function (item) {
@@ -1191,8 +1183,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1191
1183
  if (_this8.validator === null) {
1192
1184
  promises.push(Promise.resolve(true));
1193
1185
  } else {
1194
- promises.push(_this8.validator.validate(record).catch(function (_ref5) {
1195
- var fields = _ref5.fields;
1186
+ promises.push(_this8.validator.validate(record).catch(function (_ref4) {
1187
+ var fields = _ref4.fields;
1196
1188
  return Promise.reject({
1197
1189
  id: rowId,
1198
1190
  fields: fields
@@ -1210,14 +1202,14 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1210
1202
  failed = [];
1211
1203
  result.forEach(function (item) {
1212
1204
  if (item.status === 'rejected') {
1213
- var _ref6 = item.reason,
1214
- id = _ref6.id,
1215
- fields = _ref6.fields;
1205
+ var _ref5 = item.reason,
1206
+ id = _ref5.id,
1207
+ fields = _ref5.fields;
1216
1208
  var error = new Map();
1217
- Object.entries(fields).forEach(function (_ref7) {
1218
- var _ref8 = _slicedToArray(_ref7, 2),
1219
- field = _ref8[0],
1220
- errs = _ref8[1];
1209
+ Object.entries(fields).forEach(function (_ref6) {
1210
+ var _ref7 = _slicedToArray(_ref6, 2),
1211
+ field = _ref7[0],
1212
+ errs = _ref7[1];
1221
1213
 
1222
1214
  error.set(field, errs.map(function (err) {
1223
1215
  return err.message || "".concat(field, "\u8F93\u5165\u9519\u8BEF");
@@ -1426,7 +1418,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1426
1418
  sideBar: sideBarProp === true ? this.sideBarDef : sideBarProp,
1427
1419
  pinnedBottomRowData: this.getSummaryRowData(summary),
1428
1420
  masterDetail: detailCell !== undefined
1429
- }, this.getMemoizedDetailCellParams(detailCell, detailCellRendererParams), restProps, {
1421
+ }, this.getMemoizedDetailCellParams(detailCell, detailCellRendererParams, restProps.detailRowAutoHeight), restProps, {
1430
1422
  getRowStyle: this.getRowStyle,
1431
1423
  stopEditingWhenCellsLoseFocus: false,
1432
1424
  onRowDataUpdated: this.rowDataUpdated,
@@ -1449,6 +1441,17 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1449
1441
  className: prefix('spin')
1450
1442
  }) : null));
1451
1443
  }
1444
+ }], [{
1445
+ key: "isSummaryRow",
1446
+ value: function isSummaryRow(_ref8) {
1447
+ var node = _ref8.node;
1448
+
1449
+ if (node && node.data && node.data[DataGrid.SummaryFlag]) {
1450
+ return true;
1451
+ }
1452
+
1453
+ return false;
1454
+ }
1452
1455
  }]);
1453
1456
 
1454
1457
  return DataGrid;
@@ -282,6 +282,10 @@
282
282
  &-cell-detail {
283
283
  height: 100%;
284
284
  padding: 10px;
285
+
286
+ &-auto-height {
287
+ height: auto;
288
+ }
285
289
  }
286
290
 
287
291
  &-spin {
@@ -2,6 +2,7 @@ import type { ICellEditorParams } from '@ag-grid-community/core';
2
2
  import React, { type ReactNode } from 'react';
3
3
  declare const DetailCellRenderer: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & {
4
4
  render: (params: any) => ReactNode;
5
+ autoHeight?: boolean | undefined;
5
6
  } & React.RefAttributes<{
6
7
  refresh: () => boolean;
7
8
  }>>;
@@ -16,12 +16,14 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
- import { useGridStore } from "../hooks";
19
+ import classNames from 'classnames';
20
20
  import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
21
+ import { useGridStore } from "../hooks";
21
22
  import { prefix } from "../utils";
22
23
  var DetailCellRenderer = /*#__PURE__*/forwardRef(function (params, ref) {
23
24
  var node = params.node,
24
- render = params.render;
25
+ render = params.render,
26
+ autoHeight = params.autoHeight;
25
27
 
26
28
  var _useState = useState(params.data),
27
29
  _useState2 = _slicedToArray(_useState, 2),
@@ -60,7 +62,7 @@ var DetailCellRenderer = /*#__PURE__*/forwardRef(function (params, ref) {
60
62
  }
61
63
 
62
64
  return /*#__PURE__*/React.createElement("div", {
63
- className: prefix('cell-detail')
65
+ className: classNames(prefix('cell-detail'), _defineProperty({}, prefix('cell-detail-auto-height'), autoHeight))
64
66
  }, render(_objectSpread(_objectSpread({}, params), {}, {
65
67
  context: context
66
68
  })));
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+ interface Props<RecordType> {
3
+ header: ReactNode;
4
+ body: ReactNode;
5
+ value?: RecordType[];
6
+ onChange?: (value: RecordType[]) => void;
7
+ fieldsName: {
8
+ label: string;
9
+ value: string;
10
+ };
11
+ }
12
+ export default function SelectPanel<RecordType>(props: Props<RecordType>): JSX.Element;
13
+ export {};
@@ -0,0 +1,61 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
+
13
+ import { get } from 'lodash';
14
+ import React from 'react';
15
+ import { prefixClassName } from "../utils";
16
+ var emptyValue = [];
17
+ export default function SelectPanel(props) {
18
+ var header = props.header,
19
+ body = props.body,
20
+ _props$value = props.value,
21
+ value = _props$value === void 0 ? emptyValue : _props$value,
22
+ onChange = props.onChange,
23
+ fieldsName = props.fieldsName;
24
+ var prefix = prefixClassName('select-panel');
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: prefix()
27
+ }, /*#__PURE__*/React.createElement("div", {
28
+ className: prefix('left')
29
+ }, header ? /*#__PURE__*/React.createElement("div", {
30
+ className: prefix('header')
31
+ }, header) : null, body ? /*#__PURE__*/React.createElement("div", {
32
+ className: prefix('body')
33
+ }, body) : null), /*#__PURE__*/React.createElement("div", {
34
+ className: prefix('right')
35
+ }, /*#__PURE__*/React.createElement("div", {
36
+ className: prefix('right-header')
37
+ }, /*#__PURE__*/React.createElement("span", null, "\u5DF2\u9009\u62E9", value.length, "\u4E2A"), /*#__PURE__*/React.createElement("a", {
38
+ onClick: function onClick() {
39
+ if (value.length > 0) {
40
+ onChange === null || onChange === void 0 ? void 0 : onChange(emptyValue);
41
+ }
42
+ }
43
+ }, "\u6E05\u7A7A")), /*#__PURE__*/React.createElement("div", {
44
+ className: prefix('right-body')
45
+ }, value.map(function (item, idx) {
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ key: get(item, fieldsName.value),
48
+ className: prefix('item')
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ className: prefix('item-name')
51
+ }, get(item, fieldsName.label)), /*#__PURE__*/React.createElement("div", {
52
+ className: prefix('item-delete'),
53
+ onClick: function onClick() {
54
+ var newValue = _toConsumableArray(value);
55
+
56
+ newValue.splice(idx, 1);
57
+ onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
58
+ }
59
+ }));
60
+ }))));
61
+ }
@@ -0,0 +1,96 @@
1
+ .@{prefixCls}-select-panel {
2
+ display: flex;
3
+ height: 100%;
4
+
5
+ &-left {
6
+ display: flex;
7
+ flex: 1;
8
+ flex-direction: column;
9
+ overflow: hidden;
10
+ border: 1px solid @border-color-base;
11
+ border-radius: @border-radius-base;
12
+ }
13
+
14
+ &-header {
15
+ min-height: 36px;
16
+ padding: 6px 12px;
17
+ background: #f9f9fb;
18
+ border-bottom: 1px solid @border-color-split;
19
+ }
20
+
21
+ &-body {
22
+ flex: 1;
23
+ min-height: 0;
24
+ padding: 8px @padding-md;
25
+ }
26
+
27
+ &-content {
28
+ width: 100%;
29
+ height: 100%;
30
+ .scrollBar();
31
+ }
32
+
33
+ &-right {
34
+ display: flex;
35
+ flex-direction: column;
36
+ width: 180px;
37
+ margin-left: 8px;
38
+ padding: 8px 0;
39
+ font-size: 12px;
40
+ line-height: 20px;
41
+ background: #f9f9fb;
42
+ border: 1px solid @border-color-base;
43
+ border-radius: @border-radius-base;
44
+
45
+ &-header {
46
+ display: flex;
47
+ justify-content: space-between;
48
+ margin-bottom: 8px;
49
+ padding: 0 @padding-md;
50
+
51
+ span {
52
+ color: rgba(102, 102, 102, 0.7);
53
+ }
54
+ }
55
+
56
+ &-body {
57
+ flex: 1;
58
+ min-height: 0;
59
+ padding: 0 @padding-md;
60
+ overflow: auto;
61
+ .scrollBar();
62
+ }
63
+ }
64
+
65
+ &-item {
66
+ display: flex;
67
+ align-items: center;
68
+ justify-content: space-between;
69
+ margin-bottom: 8px;
70
+
71
+ &-name {
72
+ flex: 1;
73
+ min-width: 0;
74
+ }
75
+
76
+ &-delete {
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ width: 12px;
81
+ height: 12px;
82
+ margin-left: 8px;
83
+ background-color: #bfc4ce;
84
+ border-radius: 50%;
85
+ cursor: pointer;
86
+
87
+ &::after {
88
+ display: block;
89
+ width: 6px;
90
+ height: 1px;
91
+ background: #fff;
92
+ content: '';
93
+ }
94
+ }
95
+ }
96
+ }
@@ -1,15 +1,11 @@
1
1
  .@{prefixCls}-select-view {
2
2
  height: 100%;
3
3
 
4
- .@{ant-prefix}-modal-body > & {
5
- margin: -@padding-md;
6
- }
7
-
8
4
  & > .@{ant-prefix}-tabs {
9
5
  .fullTabs();
10
6
 
11
7
  & > .@{ant-prefix}-tabs-nav {
12
- margin: @padding-md @padding-md 0;
8
+ margin-bottom: 0;
13
9
  }
14
10
  }
15
11
 
@@ -20,7 +16,7 @@
20
16
 
21
17
  &-sider {
22
18
  width: 228px;
23
- padding: @padding-md;
19
+ padding: @padding-md @padding-md @padding-md 0;
24
20
  overflow: auto;
25
21
  border-right: 1px solid @border-color-split;
26
22
  }
@@ -30,7 +26,11 @@
30
26
  flex: 1;
31
27
  flex-direction: column;
32
28
  min-width: 0;
33
- padding: @padding-md;
29
+ padding: @padding-md 0;
30
+ }
31
+
32
+ &-sider + &-main {
33
+ padding-left: @padding-md;
34
34
  }
35
35
 
36
36
  &-head + &-body {
package/es/index.d.ts CHANGED
@@ -34,7 +34,7 @@ export { default as SelectView } from './components/SelectView';
34
34
  export { default as DataGrid } from './components/DataGrid';
35
35
  export * from './components/DataGrid/typings';
36
36
  export * from './components/DataGrid/hooks';
37
- export type { ColDef, ColGroupDef, ColumnState, GridOptions, GridReadyEvent, ICellEditorParams, ICellRendererParams, IHeaderParams, RowDataUpdatedEvent, CellValueChangedEvent, NavigateToNextCellParams, TabToNextCellParams, AgGridEvent, GroupCellRendererParams as IGroupCellRendererParams, Column, CellPosition, } from '@ag-grid-community/core';
37
+ export type { ColDef, ColGroupDef, ColumnState, GridOptions, GridReadyEvent, ICellEditorParams, ICellRendererParams, IHeaderParams, RowDataUpdatedEvent, CellValueChangedEvent, NavigateToNextCellParams, TabToNextCellParams, AgGridEvent, GroupCellRendererParams as IGroupCellRendererParams, Column, CellPosition, IRowNode, } from '@ag-grid-community/core';
38
38
  export { GridApi, ColumnApi } from '@ag-grid-community/core';
39
39
  export * from '@ag-grid-community/react';
40
40
  export { default as TipMark } from './components/TipMark';
@@ -49,3 +49,4 @@ export { default as BlankLayout } from './layouts/BlankLayout';
49
49
  export { default as MicroLayout } from './layouts/MicroLayout';
50
50
  export { default as Breadcrumb } from './layouts/Breadcrumb';
51
51
  export { default as useBatchOperator } from './hooks/useBatchOperator';
52
+ export { default as SelectPanel } from './components/SelectPanel';
package/es/index.js CHANGED
@@ -40,4 +40,5 @@ export { default as BasicLayout } from "./layouts/BasicLayout";
40
40
  export { default as BlankLayout } from "./layouts/BlankLayout";
41
41
  export { default as MicroLayout } from "./layouts/MicroLayout";
42
42
  export { default as Breadcrumb } from "./layouts/Breadcrumb";
43
- export { default as useBatchOperator } from "./hooks/useBatchOperator";
43
+ export { default as useBatchOperator } from "./hooks/useBatchOperator";
44
+ export { default as SelectPanel } from "./components/SelectPanel";
package/es/index.less CHANGED
@@ -25,6 +25,7 @@
25
25
  @import './components/GreyPanel/index.less';
26
26
  @import './components/InputNumber/index.less';
27
27
  @import './components//InputCompact/index.less';
28
+ @import './components/SelectPanel/index.less';
28
29
 
29
30
  @import './layouts/BasicLayout/components/MainFramework/index.less';
30
31
  @import './layouts/Breadcrumb/index.less';
@@ -90,7 +90,7 @@
90
90
  }
91
91
  }
92
92
 
93
- .scrollBar (@width: 6px) {
93
+ .scrollBar (@width: 8px) {
94
94
  scrollbar-width: thin;
95
95
 
96
96
  &::-webkit-scrollbar {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-157",
3
+ "version": "1.0.0-159",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",