@lemon-fe/components 1.4.22-alpha.3 → 1.4.22-alpha.5

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.
@@ -282,5 +282,7 @@ export default function FieldModal(props) {
282
282
  handleAddExp(item);
283
283
  }
284
284
  }, /*#__PURE__*/React.createElement(Icons.Plus, null)));
285
- })))));
285
+ })))), /*#__PURE__*/React.createElement("div", {
286
+ className: prefix('column-panel-modal-bottomtooltip')
287
+ }, fieldModal.bottomTooltip));
286
288
  }
@@ -283,6 +283,12 @@
283
283
  opacity: 1;
284
284
  }
285
285
  }
286
+
287
+ &-bottomtooltip {
288
+ margin-top: 10px;
289
+ color: ~'var(--@{ant-prefix}-error-color-active)';
290
+ font-size: 14px;
291
+ }
286
292
  }
287
293
  }
288
294
 
@@ -40,6 +40,7 @@ var locale = {
40
40
  dataSourceSummaryDataText: 'Total value calculated based on the formula from the data source',
41
41
  addFieldText: 'Add Field',
42
42
  idTooltip: 'Custom column name is not allowed to be the same as the existing field, if the history has been set with the same name field, it does not support export',
43
+ bottomTooltip: 'Note: Formulas only support calculation on numerical columns',
43
44
  customColumnNameTextRequired: 'Please enter the custom column name'
44
45
  },
45
46
  maxWordText: '${headerName} can not exceed ${maxLength} words',
@@ -19,6 +19,7 @@ export interface DataGridLocale {
19
19
  dataSourceSummaryDataText: string;
20
20
  addFieldText: string;
21
21
  idTooltip: string;
22
+ bottomTooltip: string;
22
23
  customColumnNameTextRequired: string;
23
24
  };
24
25
  maxWordText: string;
@@ -37,6 +37,7 @@ var locale = {
37
37
  dataSourceSummaryDataText: 'Nguồn dữ liệu tính toán giá trị tổng cộng theo công thức tính toán',
38
38
  addFieldText: 'Thêm trường',
39
39
  idTooltip: 'Tên cột tùy chỉnh không được trùng với tên cột đã có, nếu cột đã có tên trùng đã được thiết lập thì không hỗ trợ xuất',
40
+ bottomTooltip: 'Lưu ý: Công thức chỉ hỗ trợ tính toán cho cột số liệu',
40
41
  customColumnNameTextRequired: 'Vui lòng nhập tên cột tùy chỉnh'
41
42
  },
42
43
  validate: {
@@ -37,6 +37,7 @@ var locale = {
37
37
  dataSourceSummaryDataText: '数据源根据计算公式得出合计值',
38
38
  addFieldText: '添加字段',
39
39
  idTooltip: '自定义列名不允许和已有字段重复,如果历史已经设置的重名字段不支持导出',
40
+ bottomTooltip: '注:公式仅支持数值列计算',
40
41
  customColumnNameTextRequired: '请输入自定义列名'
41
42
  },
42
43
  validate: {
@@ -37,6 +37,7 @@ var locale = {
37
37
  dataSourceSummaryDataText: '數據源根據計算公式得出合計值',
38
38
  addFieldText: '添加字段',
39
39
  idTooltip: '自定義列名不允許與已有字段重複,如果歷史已經設置的重名字段不支持導出',
40
+ bottomTooltip: '註:公式僅支持數值列計算',
40
41
  customColumnNameTextRequired: '請輸入自定義列名'
41
42
  },
42
43
  validate: {
@@ -20,6 +20,14 @@ interface Props<KeyType> extends Omit<TreeProps, 'onSelect' | 'selectedKeys' | '
20
20
  * @description 是否在搜索时保留父节点
21
21
  */
22
22
  filterKeepParents?: boolean;
23
+ /**
24
+ * @description 是否在搜索时保留子孙节点
25
+ */
26
+ filterKeepDescendants?: boolean;
27
+ /**
28
+ * @description 是否高亮关键词
29
+ */
30
+ highlightKeywords?: boolean;
23
31
  }
24
32
  declare function SiderTreeTabs(props: {
25
33
  tabs: {
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["tabs", "children"],
2
- _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents"];
2
+ _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents", "filterKeepDescendants", "highlightKeywords"];
3
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  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."); }
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -74,6 +74,8 @@ export default function SiderTree(props) {
74
74
  footer = props.footer,
75
75
  heightProp = props.height,
76
76
  filterKeepParents = props.filterKeepParents,
77
+ filterKeepDescendants = props.filterKeepDescendants,
78
+ highlightKeywords = props.highlightKeywords,
77
79
  restProps = _objectWithoutProperties(props, _excluded2);
78
80
  var _useState = useState(''),
79
81
  _useState2 = _slicedToArray(_useState, 2),
@@ -87,47 +89,70 @@ export default function SiderTree(props) {
87
89
  _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 1),
88
90
  SiderTreeLocale = _useLocaleReceiver2[0];
89
91
  var tree = useMemo(function () {
90
- var list = mData;
91
- var items = new Set();
92
- var addedNodes = new Set();
93
92
  var shouldInclude = function shouldInclude(item) {
94
93
  return filterNode ? filterNode(keywords, item) : item.title.toString().toLowerCase().includes(keywords.toLowerCase());
95
94
  };
96
- if (keywords && !filterKeepParents) {
97
- list = list.filter(shouldInclude);
98
- }
99
- var map = new Map(list.map(function (item) {
100
- return [item.key, {
95
+ var matchedNodes = new Set();
96
+ var childrenIndex = new Map();
97
+ var nodesIndex = new Map();
98
+ var addedNodes = new Set();
99
+ var roots = [];
100
+ mData.forEach(function (item) {
101
+ var node = {
101
102
  key: item.key,
102
103
  parent: item.parent,
103
104
  icon: item.icon,
104
105
  data: item,
105
106
  title: item.title
106
- }];
107
- }));
108
- list.forEach(function (item) {
109
- if (keywords && !shouldInclude(item)) {
107
+ };
108
+ nodesIndex.set(item.key, node);
109
+ if (item.parent !== undefined) {
110
+ var children = childrenIndex.get(item.parent) || [];
111
+ children.push(node);
112
+ childrenIndex.set(item.parent, children);
113
+ }
114
+ if (!keywords || shouldInclude(item)) {
115
+ matchedNodes.add(node);
116
+ }
117
+ });
118
+ var collectAncestors = function collectAncestors(node) {
119
+ if (addedNodes.has(node.key)) {
110
120
  return;
111
121
  }
112
- var parent;
113
- var node = map.get(item.key);
114
- while (node) {
115
- if (addedNodes.has(node)) {
116
- return;
117
- }
118
- parent = node.parent !== undefined ? map.get(node.parent) : undefined;
119
- if (parent) {
120
- parent.children = parent.children || [];
121
- parent.children.push(node);
122
+ addedNodes.add(node.key);
123
+ if (node.parent !== undefined) {
124
+ var parentNode = nodesIndex.get(node.parent);
125
+ if (parentNode && (matchedNodes.has(parentNode) || filterKeepParents)) {
126
+ parentNode.children = parentNode.children || [];
127
+ parentNode.children.push(node);
128
+ collectAncestors(parentNode);
122
129
  } else {
123
- items.add(node);
130
+ roots.push(node);
124
131
  }
125
- addedNodes.add(node);
126
- node = parent;
132
+ } else {
133
+ roots.push(node);
134
+ }
135
+ };
136
+ var collectChildren = function collectChildren(node) {
137
+ var children = childrenIndex.get(node.key) || [];
138
+ node.children = node.children || [];
139
+ children.forEach(function (child) {
140
+ if (addedNodes.has(child.key)) {
141
+ return;
142
+ }
143
+ node.children.push(child);
144
+ addedNodes.add(child.key);
145
+ collectChildren(child);
146
+ });
147
+ };
148
+ _toConsumableArray(matchedNodes).forEach(function (item) {
149
+ collectAncestors(item);
150
+ if (filterKeepDescendants) {
151
+ collectChildren(item);
127
152
  }
128
153
  });
129
- return _toConsumableArray(items);
130
- }, [mData, keywords, filterKeepParents]);
154
+ return roots;
155
+ }, [mData, keywords, filterKeepParents, filterKeepDescendants]);
131
156
  var handleChange = useDebounce(function (value) {
132
157
  setKeywords(value);
133
158
  }, 300);
@@ -156,7 +181,8 @@ export default function SiderTree(props) {
156
181
  return /*#__PURE__*/React.createElement(TreeNodeTitle, {
157
182
  operation: operation,
158
183
  node: node.data,
159
- prefixCls: prefixCls
184
+ prefixCls: prefixCls,
185
+ highlightKeywords: highlightKeywords ? keywords : undefined
160
186
  });
161
187
  },
162
188
  onSelect: function onSelect(keys, info) {
@@ -4,6 +4,7 @@ interface Props<T> {
4
4
  node: TreeData<T>;
5
5
  prefixCls: string;
6
6
  operation?: OperationType<T>;
7
+ highlightKeywords?: string;
7
8
  }
8
9
  export default function TreeNodeTitle<T>(props: Props<T>): JSX.Element;
9
10
  export {};
@@ -8,10 +8,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  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; }
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
- import { Popover } from 'antd';
12
- import React, { useEffect, useRef, useState } from 'react';
11
+ import { Popover, Typography } from 'antd';
12
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { useLocaleReceiver } from "../locale-receiver";
14
14
  import classNames from 'classnames';
15
+ var Text = Typography.Text;
15
16
  export default function TreeNodeTitle(props) {
16
17
  var _operation$others;
17
18
  var item = props.node,
@@ -46,17 +47,31 @@ export default function TreeNodeTitle(props) {
46
47
  title = null;
47
48
  };
48
49
  }, []);
50
+ var title = useMemo(function () {
51
+ if (!props.highlightKeywords) {
52
+ return item.title;
53
+ }
54
+ var searchValue = props.highlightKeywords;
55
+ var strTitle = item.title.toString();
56
+ var index = strTitle.indexOf(searchValue);
57
+ if (index === -1) {
58
+ return strTitle;
59
+ }
60
+ return /*#__PURE__*/React.createElement("span", null, strTitle.slice(0, index), /*#__PURE__*/React.createElement(Text, {
61
+ type: "danger"
62
+ }, strTitle.substring(index, index + searchValue.length)), strTitle.slice(index + searchValue.length));
63
+ }, [item.title, props.highlightKeywords]);
49
64
  if (!operation) {
50
65
  return /*#__PURE__*/React.createElement("div", {
51
66
  className: "".concat(prefixCls, "-title-content")
52
- }, item.title);
67
+ }, title);
53
68
  }
54
69
  var others = (_operation$others = operation.others) === null || _operation$others === void 0 ? void 0 : _operation$others.call(operation, item);
55
70
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
56
71
  className: "".concat(prefixCls, "-title-content"),
57
72
  ref: trigger,
58
73
  title: item.title.toString()
59
- }, item.title), /*#__PURE__*/React.createElement("div", {
74
+ }, title), /*#__PURE__*/React.createElement("div", {
60
75
  className: "".concat(prefixCls, "-title-operators"),
61
76
  style: {
62
77
  display: visible || show ? 'block' : 'none'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.22-alpha.3",
3
+ "version": "1.4.22-alpha.5",
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": "8689b1f8504006653c00dbb88c37b62e455a8148"
61
+ "gitHead": "0c4dc48dacd31fd903bbcbad684f4da20b51b543"
62
62
  }