@lemon-fe/components 1.2.0-alpha.2 → 1.2.0

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.
@@ -9,7 +9,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
9
9
  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; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
11
  import { Button, Space, Tooltip, message } from 'antd';
12
- import React, { useEffect, useMemo, useState } from 'react';
12
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { createPortal } from 'react-dom';
14
14
  import Icons from "../../../icons";
15
15
  import { useLocaleReceiver } from "../../../locale-receiver";
@@ -52,6 +52,11 @@ export default function CustomColumnPanel(params) {
52
52
  var _useLocaleReceiver = useLocaleReceiver('DataGrid'),
53
53
  _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
54
54
  dataGridLocale = _useLocaleReceiver2[0];
55
+ var listContainer = useRef(null);
56
+ var _useState13 = useState(new Set()),
57
+ _useState14 = _slicedToArray(_useState13, 2),
58
+ highlights = _useState14[0],
59
+ setHighlights = _useState14[1];
55
60
  var handleColumnState = useDebounce(function () {
56
61
  setState(columnApi.getColumnState());
57
62
  }, 16);
@@ -95,9 +100,6 @@ export default function CustomColumnPanel(params) {
95
100
  return;
96
101
  }
97
102
  var title = def.headerName || def.field || '';
98
- if (keywords && !title.includes(keywords)) {
99
- return;
100
- }
101
103
  var originNode = {
102
104
  index: idx,
103
105
  key: item.colId,
@@ -146,7 +148,41 @@ export default function CustomColumnPanel(params) {
146
148
  prevPath = path;
147
149
  });
148
150
  return items;
149
- }, [state, keywords]);
151
+ }, [state, columnApi]);
152
+ var handleSearch = function handleSearch() {
153
+ var index = -1;
154
+ var highlight = [];
155
+ if (keywords) {
156
+ var idx = 0;
157
+ var traverse = function traverse(items) {
158
+ items.forEach(function (item) {
159
+ var flag = item.title ? item.title.toUpperCase().includes(keywords.toUpperCase()) : false;
160
+ if (flag) {
161
+ highlight.push(item);
162
+ if (index === -1) {
163
+ index = idx;
164
+ }
165
+ }
166
+ idx += 1;
167
+ traverse(item.children);
168
+ });
169
+ };
170
+ traverse(list);
171
+ }
172
+ if (listContainer.current === null) {
173
+ return;
174
+ }
175
+ setHighlights(new Set(highlight.map(function (item) {
176
+ return item.key;
177
+ })));
178
+ if (index < 0) {
179
+ listContainer.current.scrollTop = 0;
180
+ return;
181
+ }
182
+ var _listContainer$curren = listContainer.current.getBoundingClientRect(),
183
+ height = _listContainer$curren.height;
184
+ listContainer.current.scrollTop = Math.max(24 * index - height / 2, 0);
185
+ };
150
186
  var grid = useGridStore(function (val) {
151
187
  return val.grid;
152
188
  });
@@ -193,10 +229,16 @@ export default function CustomColumnPanel(params) {
193
229
  placeholder: dataGridLocale.searchText,
194
230
  onChange: function onChange(e) {
195
231
  handleChangeKeywords(e.target.value);
232
+ },
233
+ onKeyUp: function onKeyUp(e) {
234
+ if (e.key === 'Enter') {
235
+ handleSearch();
236
+ }
196
237
  }
197
238
  }), /*#__PURE__*/React.createElement("div", {
198
239
  className: prefix('column-panel-icon'),
199
240
  onClick: function onClick() {
241
+ setHighlights(new Set());
200
242
  setSearching(false);
201
243
  handleChangeKeywords('');
202
244
  }
@@ -279,9 +321,11 @@ export default function CustomColumnPanel(params) {
279
321
  }, /*#__PURE__*/React.createElement(DragContext.Provider, {
280
322
  value: dragActive
281
323
  }, /*#__PURE__*/React.createElement("div", {
282
- className: prefix('column-panel-body')
324
+ className: prefix('column-panel-body'),
325
+ ref: listContainer
283
326
  }, list.map(function (node) {
284
327
  return /*#__PURE__*/React.createElement(ItemWrapper, {
328
+ highlights: highlights,
285
329
  onEdit: function onEdit(v) {
286
330
  var data = grid.getField(v.id);
287
331
  if (data !== undefined) {
@@ -9,6 +9,7 @@ interface ItemProps {
9
9
  dragActive?: DragActive;
10
10
  onEdit: (node: Node) => void;
11
11
  onDelete: (node: Node) => void;
12
+ highlights: Set<string>;
12
13
  }
13
14
  export default function ItemWrapper(props: Omit<ItemProps, 'dragActive'>): JSX.Element;
14
15
  export {};
@@ -21,7 +21,8 @@ var Item = /*#__PURE__*/memo(function (props) {
21
21
  level = props.level,
22
22
  dragActive = props.dragActive,
23
23
  onDelete = props.onDelete,
24
- onEdit = props.onEdit;
24
+ onEdit = props.onEdit,
25
+ highlights = props.highlights;
25
26
  var column = node.column;
26
27
  var colDef = (column === null || column === void 0 ? void 0 : column.getColDef()) || {};
27
28
  var _useDraggable = useDraggable({
@@ -82,7 +83,7 @@ var Item = /*#__PURE__*/memo(function (props) {
82
83
  style: {
83
84
  paddingLeft: level * 20 + 8
84
85
  },
85
- className: classNames(prefix('column-panel-item'), dragActive ? prefix("column-panel-item-active-".concat(dragActive.indicator)) : undefined),
86
+ className: classNames(prefix('column-panel-item'), dragActive ? prefix("column-panel-item-active-".concat(dragActive.indicator)) : undefined, highlights.has(node.key) ? prefix('column-panel-item-highlight') : undefined),
86
87
  ref: setDropRef
87
88
  }, /*#__PURE__*/React.createElement("div", {
88
89
  className: classNames('ag-wrapper ag-input-wrapper ag-checkbox-input-wrapper', {
@@ -130,7 +130,7 @@
130
130
  display: flex;
131
131
  align-items: center;
132
132
  height: 24px;
133
- margin-top: 1px;
133
+ // margin-top: 1px;
134
134
  padding: 0 8px;
135
135
 
136
136
  &:hover {
@@ -175,6 +175,10 @@
175
175
  &:hover &-operator {
176
176
  opacity: 1;
177
177
  }
178
+
179
+ &-highlight {
180
+ background-color: ~'var(--@{ant-prefix}-primary-2)';
181
+ }
178
182
  }
179
183
 
180
184
  &-drag-overlay {
@@ -38,7 +38,7 @@ var locale = {
38
38
  maxWordText: '${headName}最多${maxLength}个字符',
39
39
  operationSuccessText: '操作成功',
40
40
  displayText: '显示',
41
- searchText: '搜索',
41
+ searchText: '按回车进行搜索',
42
42
  addCustomColumnText: '添加自定义列',
43
43
  resetText: '重置',
44
44
  saveText: '保存',
@@ -7,7 +7,7 @@ var locale = {
7
7
  defaultTitleText: '默认',
8
8
  noDefaultRemoveText: '不允许删除默认',
9
9
  autoPlaceholderText: '请${action}${label}',
10
- searchText: '搜索',
10
+ searchText: '查询',
11
11
  selectText: '选择',
12
12
  inputText: '输入',
13
13
  searchOptionText: '搜索选项',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.2.0-alpha.2",
3
+ "version": "1.2.0",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -22,7 +22,7 @@
22
22
  "@ag-grid-community/react": "29.2.0",
23
23
  "@ag-grid-community/styles": "29.2.0",
24
24
  "@dnd-kit/core": "^6.0.8",
25
- "@lemon-fe/hooks": "^1.2.0-alpha.1",
25
+ "@lemon-fe/hooks": "^1.2.0",
26
26
  "@lemon-fe/utils": "^1.1.0",
27
27
  "async-validator": "^4.2.5",
28
28
  "bignumber.js": ">=9.0.0",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "registry": "https://registry.npmjs.org"
64
64
  },
65
- "gitHead": "49675d62b0403af381b58a8a3da02255f2d16dbc"
65
+ "gitHead": "bc6eefb9acd1c267e15c7cf8132b4d866d3eb9ca"
66
66
  }