@lemon-fe/components 1.4.22 → 1.4.23

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.
@@ -245,7 +245,9 @@ export default function FieldModal(props) {
245
245
  label: " ",
246
246
  name: "summary",
247
247
  valuePropName: "checked"
248
- }, /*#__PURE__*/React.createElement(Checkbox, null, fieldModal.summaryText)), /*#__PURE__*/React.createElement(Form.Item, {
248
+ }, /*#__PURE__*/React.createElement(Checkbox, null, fieldModal.summaryText, /*#__PURE__*/React.createElement(TipMark, {
249
+ infoContent: fieldModal.summaryTextTooltip
250
+ }))), /*#__PURE__*/React.createElement(Form.Item, {
249
251
  name: "summaryType",
250
252
  label: /*#__PURE__*/React.createElement("span", null, fieldModal.summaryTypeText, /*#__PURE__*/React.createElement(TipMark, {
251
253
  infoContent: /*#__PURE__*/React.createElement("div", {
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { DataGridSearch, DataGridSearchRef } from '../typings';
3
- declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<DataGridSearch & React.RefAttributes<DataGridSearchRef>>>;
3
+ declare const _default: <TData>(props: DataGridSearch<TData> & {
4
+ ref: React.RefObject<DataGridSearchRef>;
5
+ }) => React.ReactElement;
4
6
  export default _default;
@@ -15,10 +15,12 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
15
15
  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; }
16
16
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- import { Button, Input, Space } from 'antd';
18
+ import { Button, Input, Select, Space } from 'antd';
19
19
  import React, { forwardRef, memo, useState, useImperativeHandle, useMemo, useRef } from 'react';
20
+ import InputCompact from "../../input-compact";
20
21
  import { useLocaleReceiver } from "../../locale-receiver";
21
22
  import { useGridStore } from "../hooks";
23
+ import { prefix } from "../utils";
22
24
  import { useDebounce } from '@lemon-fe/hooks';
23
25
  export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props, ref) {
24
26
  var placeholder = props.placeholder,
@@ -27,7 +29,8 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
27
29
  _props$clearSelection = props.clearSelection,
28
30
  clearSelection = _props$clearSelection === void 0 ? true : _props$clearSelection,
29
31
  defaultValue = props.defaultValue,
30
- onValueChange = props.onValueChange;
32
+ onValueChange = props.onValueChange,
33
+ dropdownConfig = props.dropdownConfig;
31
34
  // 单行搜索大致耗时
32
35
  var duration = useRef(0);
33
36
  var defaultState = useMemo(function () {
@@ -64,15 +67,33 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
64
67
  }
65
68
  return cols;
66
69
  };
70
+ var getLabel = function getLabel(node) {
71
+ var defaultVal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
72
+ if (dropdownConfig && node.data) {
73
+ var label = dropdownConfig.label;
74
+ if (typeof label === 'function') {
75
+ return label(node.data);
76
+ } else {
77
+ return grid.api.getValue(label, node);
78
+ }
79
+ }
80
+ return defaultVal;
81
+ };
67
82
  var checkNodes = function checkNodes(keywords, node, cols) {
83
+ var result = {
84
+ label: '',
85
+ matched: false
86
+ };
68
87
  for (var i = 0; i < cols.length; i++) {
69
88
  var col = cols[i];
70
89
  var value = grid.api.getValue(col, node);
71
90
  if (value !== undefined && value !== null && typeof value === 'string' && value.toUpperCase().includes(keywords.toUpperCase())) {
72
- return true;
91
+ result.label = getLabel(node, value);
92
+ result.matched = true;
93
+ return result;
73
94
  }
74
95
  }
75
- return false;
96
+ return result;
76
97
  };
77
98
  var handleSearch = useDebounce(function (str, prevState) {
78
99
  var keywords = str.trim();
@@ -107,9 +128,11 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
107
128
  if (id === undefined) {
108
129
  return;
109
130
  }
110
- if (checkNodes(keywords, node, cols)) {
131
+ var checkResult = checkNodes(keywords, node, cols);
132
+ if (checkResult.matched) {
111
133
  nodes.push({
112
- id: id
134
+ id: id,
135
+ label: checkResult.label
113
136
  });
114
137
  if (prevNodes.has(id)) {
115
138
  prevNodes.set(id, nodes.length - 1);
@@ -186,6 +209,23 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
186
209
  });
187
210
  });
188
211
  };
212
+ var jumpToItem = function jumpToItem(id) {
213
+ if (state.nodes.length <= 0) {
214
+ return;
215
+ }
216
+ var idx = state.nodes.findIndex(function (item) {
217
+ return item.id === id;
218
+ });
219
+ if (idx < 0) {
220
+ return;
221
+ }
222
+ focusCell(id);
223
+ setState(function (prev) {
224
+ return _objectSpread(_objectSpread({}, prev), {}, {
225
+ index: idx
226
+ });
227
+ });
228
+ };
189
229
  useImperativeHandle(ref, function () {
190
230
  return {
191
231
  reset: function reset() {
@@ -233,8 +273,10 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
233
273
  break;
234
274
  }
235
275
  }
276
+ var label = getLabel(node);
236
277
  _newNodes.splice(idx, 0, {
237
- id: id
278
+ id: id,
279
+ label: label
238
280
  });
239
281
  setState(function (prev) {
240
282
  return _objectSpread(_objectSpread({}, prev), {}, {
@@ -253,7 +295,12 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
253
295
  }
254
296
  };
255
297
  });
256
- return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Input, {
298
+ return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(InputCompact, {
299
+ className: "".concat(prefix('bottom-search')),
300
+ style: {
301
+ width: 264
302
+ }
303
+ }, /*#__PURE__*/React.createElement(Input, {
257
304
  placeholder: placeholder || dataGridLocale.searchPlaceholderText,
258
305
  value: state.keywords,
259
306
  defaultValue: defaultValue,
@@ -272,8 +319,24 @@ export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Search(props,
272
319
  if (e.key === 'Enter') {
273
320
  handleNext(searching.current ? handleSearch.flush() : state);
274
321
  }
322
+ },
323
+ bordered: false
324
+ }), /*#__PURE__*/React.createElement(Select, {
325
+ options: state.nodes,
326
+ bordered: false,
327
+ notFoundContent: null,
328
+ className: "".concat(prefix('bottom-search-select')),
329
+ fieldNames: {
330
+ label: 'label',
331
+ value: 'id'
332
+ },
333
+ placement: "topRight",
334
+ dropdownMatchSelectWidth: 264,
335
+ listHeight: 280,
336
+ onChange: function onChange(val) {
337
+ jumpToItem(val);
275
338
  }
276
- }), /*#__PURE__*/React.createElement(Button, {
339
+ })), /*#__PURE__*/React.createElement(Button, {
277
340
  size: "small",
278
341
  onClick: handlePrev
279
342
  }, dataGridLocale.searchPrevText), /*#__PURE__*/React.createElement(Button, {
@@ -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" | "mode" | "allowClear" | "showSearch" | "optionFilterProp" | "options" | "virtual" | "listHeight"> & {
21
21
  fieldNames?: {
22
22
  label: string;
23
23
  value: string;
@@ -538,6 +538,17 @@
538
538
  justify-content: center;
539
539
  background-color: rgba(255, 255, 255, 0.6);
540
540
  }
541
+
542
+ &-bottom-search {
543
+ &-select {
544
+ width: 32px;
545
+ overflow: hidden;
546
+
547
+ .@{ant-prefix}-select-selector {
548
+ opacity: 0;
549
+ }
550
+ }
551
+ }
541
552
  }
542
553
 
543
554
  .ag-theme-@{prefixCls} {
@@ -34,6 +34,7 @@ var locale = {
34
34
  customColumnDecimalPlacesText: 'Decimal places',
35
35
  customColumnParentHeaderText: 'The corresponding superior header',
36
36
  summaryText: 'Summary or not',
37
+ summaryTextTooltip: 'Fields used in custom formulas must display aggregated values; otherwise, the calculation of totals will not be possible',
37
38
  summaryTypeText: 'Rule',
38
39
  summaryTypeContentText: "\n <div>\n <p>1. The sum of custom column data values to get the total value</p>\n <p>\n 2. The total value is calculated based on a formula from the data source (this total value is not available for export)\n <br />\n The total value of the field columns added to the formula is calculated based on the formula to derive the custom column total. This is typically used when the custom column represents a percentage, such as gross margin percentage\n </p>\n </div>\n ",
39
40
  customSummaryDataText: 'Sum of custom column data values to get the total value',
@@ -13,6 +13,7 @@ export interface DataGridLocale {
13
13
  customColumnDecimalPlacesText: string;
14
14
  customColumnParentHeaderText: string;
15
15
  summaryText: string;
16
+ summaryTextTooltip: string;
16
17
  summaryTypeText: string;
17
18
  summaryTypeContentText: string;
18
19
  customSummaryDataText: string;
@@ -31,6 +31,7 @@ var locale = {
31
31
  customColumnDecimalPlacesText: 'Số chữ số thập phân',
32
32
  customColumnParentHeaderText: 'Tiêu đề bảng cấp trên mà nó thuộc về',
33
33
  summaryText: 'Có thống kê tổng cộng không?',
34
+ summaryTextTooltip: 'Các trường trong công thức tùy chỉnh cần hiển thị giá trị tổng hợp, nếu không sẽ không thể tính tổng (hoặc tổng hợp) giá trị',
34
35
  summaryTypeText: 'Quy tắc tính tổng cộng',
35
36
  summaryTypeContentText: "\n <div>\n <p>1. T\xEDnh t\u1ED5ng gi\xE1 tr\u1ECB d\u1EEF li\u1EC7u c\u1EE7a c\u1ED9t t\xF9y ch\u1EC9nh \u0111\u1EC3 c\xF3 \u0111\u01B0\u1EE3c gi\xE1 tr\u1ECB t\u1ED5ng c\u1ED9ng.</p>\n <p>\n 2. Gi\xE1 tr\u1ECB t\u1ED5ng \u0111\u01B0\u1EE3c t\xEDnh to\xE1n t\u1EEB ngu\u1ED3n d\u1EEF li\u1EC7u d\u1EF1a tr\xEAn c\xF4ng th\u1EE9c t\xEDnh (gi\xE1 tr\u1ECB t\u1ED5ng n\xE0y kh\xF4ng h\u1ED7 tr\u1EE3 xu\u1EA5t).\n <br />\n Gi\xE1 tr\u1ECB t\u1ED5ng c\u1EE7a c\xE1c c\u1ED9t d\u1EEF li\u1EC7u \u0111\u01B0\u1EE3c th\xEAm v\xE0o c\xF4ng th\u1EE9c \u0111\u01B0\u1EE3c t\xEDnh to\xE1n theo c\xF4ng th\u1EE9c \u0111\u1EC3 ra gi\xE1 tr\u1ECB t\u1ED5ng c\u1EE7a c\u1ED9t t\xF9y ch\u1EC9nh, th\u01B0\u1EDDng \u0111\u01B0\u1EE3c \xE1p d\u1EE5ng khi c\u1ED9t t\xF9y ch\u1EC9nh l\xE0 t\u1EF7 l\u1EC7 ph\u1EA7n tr\u0103m, ch\u1EB3ng h\u1EA1n nh\u01B0 t\u1EF7 su\u1EA5t l\u1EE3i nhu\u1EADn g\u1ED9p.\n </p>\n </div>\n ",
36
37
  customSummaryDataText: 'Tính tổng giá trị dữ liệu của cột tùy chỉnh để có được giá trị tổng cộng',
@@ -31,6 +31,7 @@ var locale = {
31
31
  customColumnDecimalPlacesText: '小数位数',
32
32
  customColumnParentHeaderText: '所属上级表头',
33
33
  summaryText: '是否统计合计',
34
+ summaryTextTooltip: '自定义公式内的字段需要显示合计值,否则无法合计值合计',
34
35
  summaryTypeText: '合计规则',
35
36
  summaryTypeContentText: "\n <div>\n <p>1\u3001\u81EA\u5B9A\u4E49\u5217\u6570\u636E\u503C\u6C42\u548C\u5F97\u51FA\u5408\u8BA1\u503C</p>\n <p>\n 2\u3001\u6570\u636E\u6E90\u6839\u636E\u8BA1\u7B97\u516C\u5F0F\u5F97\u51FA\u5408\u8BA1\u503C(\u8BE5\u5408\u8BA1\u503C\u4E0D\u652F\u6301\u5BFC\u51FA)\n <br />\n \u516C\u5F0F\u4E2D\u6DFB\u52A0\u7684\u5B57\u6BB5\u5217\u6570\u636E\u5408\u8BA1\u503C\u6309\u8BA1\u7B97\u516C\u5F0F\u7B97\u51FA\u81EA\u5B9A\u4E49\u5217\u5408\u8BA1\u503C\uFF0C\u4E00\u822C\u7528\u4E8E\u81EA\u5B9A\u4E49\u5217\u662F\u767E\u5206\u6BD4\u7684\u60C5\u51B5\uFF0C\u6BD4\u5982\u6BDB\u5229\u7387\n </p>\n </div>\n ",
36
37
  customSummaryDataText: '自定义列数据值求和得出合计值',
@@ -31,6 +31,7 @@ var locale = {
31
31
  customColumnDecimalPlacesText: '小數位數',
32
32
  customColumnParentHeaderText: '所屬上級表頭',
33
33
  summaryText: '是否統計合計',
34
+ summaryTextTooltip: '自定義公式內的字段需要顯示合計值,否則無法合計值合計',
34
35
  summaryTypeText: '合計規則',
35
36
  summaryTypeContentText: "\n <div>\n <p>1\u3001\u81EA\u5B9A\u7FA9\u5217\u6578\u64DA\u503C\u6C42\u548C\u5F97\u51FA\u5408\u8A08\u503C</p>\n <p>\n 2\u3001\u6578\u64DA\u6E90\u6839\u64DA\u8A08\u7B97\u516C\u5F0F\u5F97\u51FA\u7E3D\u8A08\u503C(\u8A72\u7E3D\u8A08\u503C\u4E0D\u652F\u63F4\u5C0E\u51FA)\n <br />\n \u516C\u5F0F\u4E2D\u6DFB\u52A0\u7684\u5B57\u6BB5\u5217\u6578\u64DA\u7E3D\u8A08\u503C\u6703\u6309\u8A08\u7B97\u516C\u5F0F\u5F97\u51FA\u81EA\u5B9A\u7FA9\u5217\u7684\u7E3D\u8A08\u503C\uFF0C\u6B64\u65B9\u6CD5\u901A\u5E38\u7528\u65BC\u81EA\u5B9A\u7FA9\u5217\u70BA\u767E\u5206\u6BD4\u7684\u60C5\u6CC1\uFF0C\u4F8B\u5982\u6BDB\u5229\u7387\n </p>\n </div>\n ",
36
37
  customSummaryDataText: '自定義列數據值求和得出合計值',
@@ -133,7 +133,7 @@ export declare type DetailCell<TData, Params = Record<string, never>> = {
133
133
  /** 这是一个render函数不是组件 */
134
134
  render: (params: ICellRendererParams<TData> & Params) => ReactNode;
135
135
  };
136
- export interface DataGridSearch {
136
+ export interface DataGridSearch<TData> {
137
137
  /**
138
138
  * @description
139
139
  * 不传入就根据所有字符类型的列数据搜索
@@ -156,6 +156,16 @@ export interface DataGridSearch {
156
156
  */
157
157
  defaultValue?: string;
158
158
  onValueChange?: (value: string) => void;
159
+ /**
160
+ * @description
161
+ * 是否显示搜索结果 上下键快速定位
162
+ */
163
+ dropdownConfig?: {
164
+ /**
165
+ * label字段
166
+ */
167
+ label: string | ((item: TData) => ReactNode | string);
168
+ };
159
169
  }
160
170
  export interface DataGridSearchRef {
161
171
  reset: () => void;
@@ -235,7 +245,7 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
235
245
  /**
236
246
  * @description 显示底部搜索栏,只支持非远程模式
237
247
  */
238
- showSearch?: boolean | DataGridSearch;
248
+ showSearch?: boolean | DataGridSearch<TData>;
239
249
  /**
240
250
  * @description 单元格是否表现成弹性盒子,从而便于垂直,此时也会导致文本ellipsis失效
241
251
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.22",
3
+ "version": "1.4.23",
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": "028b91754f651ef860b0e57a2a8e538087334e17"
61
+ "gitHead": "c3d8070a21dfdb8b63295e76dd0b8484a94d372a"
62
62
  }