@zgfe/business-lib 1.0.25-layers.3 → 1.0.25-userGroupFix.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.
Files changed (60) hide show
  1. package/es/addToPanel/index.js +33 -16
  2. package/es/assets/styles/resetAntd.less +7 -2
  3. package/es/attrConditions/components/stringList.js +1 -1
  4. package/es/attrConditions/components/valuesList.js +7 -5
  5. package/es/attrConditions/group.js +4 -4
  6. package/es/attrConditions/types.d.ts +1 -0
  7. package/es/attributeSelector/styles/index.less +31 -2
  8. package/es/attributeSelector/util.js +9 -1
  9. package/es/chart/demo/bar.js +3 -4
  10. package/es/chart/demo/data/data.d.ts +7 -0
  11. package/es/chart/demo/data/data.js +10 -0
  12. package/es/chart/demo/data/data3.d.ts +0 -2
  13. package/es/chart/demo/data/data3.js +15 -574
  14. package/es/chart/demo/map.js +1 -2
  15. package/es/chart/index.js +2 -2
  16. package/es/chart/util/chartOptionConfig.d.ts +1 -54
  17. package/es/chart/util/chartOptionConfig.js +13 -7
  18. package/es/chart/util/formatData.js +2 -1
  19. package/es/chart/util/formatOption.js +7 -23
  20. package/es/chart/util/mapUtil.d.ts +2 -2
  21. package/es/chart/util/mapUtil.js +59 -75
  22. package/es/eventSelector/index.js +2 -2
  23. package/es/eventSelector/listPanel.js +20 -5
  24. package/es/eventSelector/types.d.ts +1 -1
  25. package/es/layout/analysisLayout/demo/index.js +5 -1
  26. package/es/layout/analysisLayout/index.js +5 -5
  27. package/es/layout/analysisLayout/index.less +0 -6
  28. package/es/select/handle.js +47 -10
  29. package/es/select/index.js +44 -9
  30. package/es/select/overlay.d.ts +1 -1
  31. package/es/select/overlay.js +4 -5
  32. package/es/select/styles/handle.less +14 -1
  33. package/es/select/types.d.ts +6 -0
  34. package/es/targetConditionGroup/index.js +3 -1
  35. package/es/targetConditionGroup/types.d.ts +1 -0
  36. package/es/targetSelector/index.js +13 -0
  37. package/es/targetSelector/styles/index.less +1 -0
  38. package/es/userCondition/conditions/styles/eventCondition.less +1 -1
  39. package/es/userCondition/conditions/styles/tagsCondition.less +1 -1
  40. package/es/userCondition/conditions/tagsCondition.js +13 -26
  41. package/es/userCondition/conditions/textDesc.js +8 -29
  42. package/es/userCondition/demo/index.js +228 -5
  43. package/es/userCondition/types.d.ts +3 -21
  44. package/es/userCondition/util.d.ts +1 -23
  45. package/es/userCondition/util.js +5 -39
  46. package/es/userTagsSelector/cascaderOverlay.js +42 -132
  47. package/es/userTagsSelector/demo/index.js +5 -12
  48. package/es/userTagsSelector/groups/groupOption.js +1 -1
  49. package/es/userTagsSelector/groups/index.js +11 -18
  50. package/es/userTagsSelector/groups/styles/option.less +1 -6
  51. package/es/userTagsSelector/index.js +3 -17
  52. package/es/userTagsSelector/multipleCheckPanel/index.js +16 -7
  53. package/es/userTagsSelector/styles/cascaderOverlay.less +4 -9
  54. package/es/userTagsSelector/types.d.ts +10 -1
  55. package/es/userTagsSelector/util.d.ts +1 -1
  56. package/es/userTagsSelector/util.js +2 -6
  57. package/es/utils/ajax.js +5 -1
  58. package/package.json +3 -3
  59. package/es/userCondition/demo/mockData.d.ts +0 -82
  60. package/es/userCondition/demo/mockData.js +0 -543
@@ -38,8 +38,9 @@ export var formatChartData = function formatChartData(data, showAll, showList, r
38
38
  if (reverseXAxis) {
39
39
  x_axis.push(name);
40
40
  sData.push({
41
- name: name,
41
+ name: data.x_axis[0],
42
42
  value: seriesItem.values[0],
43
+ label: name,
43
44
  itemStyle: {
44
45
  normal: {
45
46
  color: colorData[sData.length]
@@ -16,11 +16,7 @@ var tooltipFormatterDefault = function tooltipFormatterDefault(params) {
16
16
  }
17
17
 
18
18
  var htmlArray = [];
19
-
20
- if (params.length > 1) {
21
- htmlArray.push("<div class=\"biz-chart-tooltip-title\">".concat(xLabel, "</div>"));
22
- }
23
-
19
+ htmlArray.push("<div class=\"biz-chart-tooltip-title\">".concat(xLabel, "</div>"));
24
20
  params.forEach(function (item) {
25
21
  var lineLabel = item.value;
26
22
 
@@ -30,7 +26,7 @@ var tooltipFormatterDefault = function tooltipFormatterDefault(params) {
30
26
  lineLabel = util.toThousands(lineLabel);
31
27
  }
32
28
 
33
- var name = (params.length > 1 ? item.seriesName : item.name).trim();
29
+ var name = (params.length > 1 ? item.seriesName : item.data && item.data.label ? item.data.label : item.name).trim();
34
30
  htmlArray.push("<div class=\"biz-chart-tooltip-item\">\n <span class=\"biz-chart-tooltip-content\">\n <span class=\"biz-tooltip-marker\" style=\"background:".concat(item.color, "\"></span>").concat(name, "\n </span> \n <span class=\"biz-chart-tooltip-value\">").concat(lineLabel, "</span>\n </div>"));
35
31
  });
36
32
  return htmlArray.join('');
@@ -68,28 +64,16 @@ var mapTooltipFormatter = function mapTooltipFormatter(params) {
68
64
  var data = params.data;
69
65
 
70
66
  if (data.childrenOptions && data.childrenOptions.length) {
71
- var series = [];
67
+ var htmlArray = [];
68
+ htmlArray.push("<div class=\"biz-chart-tooltip-title\">".concat(params.name, "</div>"));
72
69
  var childrenOptions = data.childrenOptions;
73
70
  childrenOptions.forEach(function (option) {
74
- var label = option.name || option.names.join(',');
75
- var value = option.value || option.values;
76
-
77
- if (util.isArray(value)) {
78
- value = value[value.length - 1];
79
- }
80
-
81
- series.push("<div class=\"biz-chart-tooltip-item\"><span class=\"biz-chart-tooltip-content\">".concat(label, ": </span><span class=\"biz-chart-tooltip-value\" style=\"color:#66ccff;\">").concat(util.toThousands(value), "</span></div>"));
71
+ htmlArray.push("<div class=\"biz-chart-tooltip-item\">\n <span class=\"biz-chart-tooltip-content\">\n ".concat(option.name, "\n </span> \n <span class=\"biz-chart-tooltip-value\">").concat(util.toThousands(option.value), "</span>\n </div>"));
82
72
  });
83
- return "".concat(series.join('<br/>'));
84
- }
85
-
86
- var dataValue = data.value || data.values;
87
-
88
- if (util.isArray(dataValue)) {
89
- dataValue = dataValue[dataValue.length - 1];
73
+ return htmlArray.join('');
90
74
  }
91
75
 
92
- return "<div class=\"biz-chart-tooltip-item\"><span class=\"biz-chart-tooltip-content\">".concat(data.name || data.names.join(','), ": </span><span style=\"color:#66ccff;\">").concat(util.toThousands(dataValue), "</span></div>");
76
+ return "<div class=\"biz-chart-tooltip-item\"><span class=\"biz-chart-tooltip-content\">".concat(data.name, ": </span><span>").concat(util.toThousands(data.value), "</span></div>");
93
77
  };
94
78
 
95
79
  var legendFormatterDefault = function legendFormatterDefault(label) {
@@ -1,6 +1,6 @@
1
1
  import { ChartTypes, ItemDataProps } from '../types';
2
- declare const citySeries: (data: ChartTypes.Value, haveUserGroup: boolean) => ItemDataProps[];
3
- declare const provinceSeries: (data: ChartTypes.Value, haveUserGroup?: boolean | undefined) => any;
2
+ declare const citySeries: (data: ChartTypes.Value) => ItemDataProps[];
3
+ declare const provinceSeries: (data: ChartTypes.Value) => any;
4
4
  declare const maxMinValue: (series: ItemDataProps) => {
5
5
  max: number;
6
6
  min: number;
@@ -10,8 +10,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
10
10
 
11
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
12
 
13
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
14
-
15
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
14
 
17
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -22,13 +20,13 @@ import util from '../../utils/util';
22
20
  import cityGeoCoord from './data/cityGeoCoord';
23
21
  import provinceGeoCoord from './data/provinceGeoCoord';
24
22
 
25
- var citySeries = function citySeries(data, haveUserGroup) {
23
+ var citySeries = function citySeries(data) {
26
24
  var backGroundMapSeries = {
27
25
  type: 'map',
28
26
  map: 'china',
29
27
  showLegendSymbol: false,
30
- top: 20,
31
- bottom: 20,
28
+ top: 0,
29
+ bottom: 0,
32
30
  data: []
33
31
  };
34
32
  var scatterSeries = {
@@ -39,33 +37,29 @@ var citySeries = function citySeries(data, haveUserGroup) {
39
37
  data: []
40
38
  };
41
39
  var provinceMapData = {};
42
- data.x_axis.forEach(function (xItem, i) {
40
+ var mapStore = formatMapData(data, 'city');
41
+ mapStore.x_axis.forEach(function (xItem) {
43
42
  scatterSeries.name = xItem;
44
- data.series.forEach(function (cityItem) {
45
- var cityName = cityItem.names[cityItem.names.length - 1];
46
- cityName = cityName.replace(/(市|省|自治区)$/, '');
43
+ mapStore.series.forEach(function (cityItem) {
44
+ var cityName = cityItem.name;
47
45
  var cityCoordObj = cityGeoCoord[cityName];
48
-
49
- if (cityCoordObj) {
50
- var cityValue = cityItem.values[i];
51
- var scatterItem = {
52
- name: cityCoordObj.name,
53
- isCity: true,
54
- value: [cityCoordObj.log, cityCoordObj.lat, cityValue],
55
- childrenOptions: cityItem.userGroupCompareData
56
- };
57
- scatterSeries.data.push(scatterItem);
58
- var provinceObj = cityCoordObj.province;
59
- var provinceName = provinceObj ? provinceObj.name.replace(/(省|市)$/, '') : '';
60
- var currentMapData = provinceMapData[provinceName];
61
- var currentMapOptions = currentMapData ? currentMapData.childrenOptions : [];
62
- provinceMapData[provinceName] = {
63
- name: provinceName,
64
- isProvince: true,
65
- value: currentMapData ? currentMapData.value + cityValue : cityValue,
66
- childrenOptions: currentMapOptions.concat(haveUserGroup ? cityItem.userGroupCompareData : [cityItem])
67
- };
68
- }
46
+ var cityValue = cityItem.value;
47
+ var scatterItem = {
48
+ name: cityItem.name,
49
+ isCity: true,
50
+ value: [cityCoordObj.log, cityCoordObj.lat, cityValue],
51
+ childrenOptions: cityItem.childrenOptions
52
+ };
53
+ scatterSeries.data.push(scatterItem);
54
+ var provinceObj = cityCoordObj.province;
55
+ var provinceName = provinceObj ? provinceObj.name.replace(/(省|市)$/, '') : '';
56
+ var currentMapData = provinceMapData[provinceName];
57
+ var currentMapOptions = currentMapData ? currentMapData.childrenOptions : [];
58
+ provinceMapData[provinceName] = {
59
+ name: provinceName,
60
+ value: currentMapData ? currentMapData.value + cityValue : cityValue,
61
+ childrenOptions: currentMapOptions.concat([cityItem])
62
+ };
69
63
  });
70
64
  });
71
65
 
@@ -81,17 +75,17 @@ var citySeries = function citySeries(data, haveUserGroup) {
81
75
  return [scatterSeries, backGroundMapSeries];
82
76
  };
83
77
 
84
- var provinceSeries = function provinceSeries(data, haveUserGroup) {
78
+ var provinceSeries = function provinceSeries(data) {
85
79
  var series = [];
86
- var mapStore = formatData(data, haveUserGroup);
87
- mapStore.x_axis.forEach(function (xItem, i) {
80
+ var mapStore = formatMapData(data, 'province');
81
+ mapStore.x_axis.forEach(function (xItem) {
88
82
  var item = {
89
83
  name: xItem,
90
84
  type: 'map',
91
85
  map: 'china',
92
86
  roam: false,
93
- top: 20,
94
- bottom: 20,
87
+ top: 0,
88
+ bottom: 0,
95
89
  label: {
96
90
  show: true,
97
91
  color: '#565656'
@@ -100,21 +94,7 @@ var provinceSeries = function provinceSeries(data, haveUserGroup) {
100
94
  data: []
101
95
  };
102
96
  mapStore.series.forEach(function (provinceItem) {
103
- var name = provinceItem.name || provinceItem.names;
104
- var provinceName = _typeof(name) === 'object' ? name[name.length - 1] : name;
105
- provinceName = provinceName.replace(/(市|省|自治区)$/, '');
106
- var provinceCoordObj = provinceGeoCoord[provinceName];
107
- name = _typeof(name) === 'object' ? name.join('-') : name;
108
- name = name.replace(/(市|省|自治区)$/, '');
109
-
110
- if (provinceCoordObj) {
111
- item.data.push({
112
- name: name,
113
- isProvince: true,
114
- value: provinceItem.values[i],
115
- childrenOptions: provinceItem.userGroupCompareData
116
- });
117
- }
97
+ item.data.push(provinceItem);
118
98
  });
119
99
  series.push(item);
120
100
  });
@@ -150,36 +130,40 @@ var maxMinValue = function maxMinValue(series) {
150
130
  };
151
131
  };
152
132
 
153
- var formatData = function formatData(seriesData, haveUserGroup) {
154
- if (haveUserGroup) {
155
- var store = {
156
- x_axis: seriesData.x_axis,
157
- series: []
133
+ var formatMapData = function formatMapData(seriesData, type) {
134
+ var store = {
135
+ x_axis: seriesData.x_axis,
136
+ series: []
137
+ };
138
+ var areaObjMap = {};
139
+ seriesData.series.forEach(function (item) {
140
+ var areaName = item.names[0].replace(/(市|省|自治区)$/, '');
141
+ var targetName = item.names.slice(1).join(',');
142
+ var targeItem = {
143
+ name: targetName || areaName,
144
+ value: item.values[0]
158
145
  };
159
- var areaObjMap = {};
160
- seriesData.series.forEach(function (item) {
161
- var areaName = item.names[item.names.length - 1];
162
-
163
- if (!areaObjMap[areaName]) {
164
- areaObjMap[areaName] = {
165
- names: [areaName],
166
- values: item.values,
167
- userGroupCompareData: [item]
168
- };
169
- } else {
170
- areaObjMap[areaName].values = [areaObjMap[areaName].values[0] + item.values[0]];
171
- areaObjMap[areaName].userGroupCompareData.push(item);
172
- }
173
- });
174
146
 
175
- for (var area in areaObjMap) {
176
- store.series.push(areaObjMap[area]);
147
+ if (!areaObjMap[areaName]) {
148
+ areaObjMap[areaName] = {
149
+ name: areaName,
150
+ value: item.values[0],
151
+ childrenOptions: [targeItem]
152
+ };
153
+ } else {
154
+ areaObjMap[areaName].value += item.values[0];
155
+ areaObjMap[areaName].childrenOptions.push(targeItem);
177
156
  }
157
+ });
158
+ var areaMap = type === 'province' ? provinceGeoCoord : cityGeoCoord;
178
159
 
179
- return store;
180
- } else {
181
- return seriesData;
160
+ for (var area in areaObjMap) {
161
+ if (areaMap[area]) {
162
+ store.series.push(areaObjMap[area]);
163
+ }
182
164
  }
165
+
166
+ return store;
183
167
  };
184
168
 
185
169
  export { provinceSeries, citySeries, maxMinValue };
@@ -111,8 +111,8 @@ var BizEventSelector = function BizEventSelector(props) {
111
111
  return label;
112
112
  };
113
113
 
114
- var onChange = function onChange(value) {
115
- if (!defaultSelectAble) {
114
+ var onChange = function onChange(value, isOverview) {
115
+ if (!defaultSelectAble && !isOverview) {
116
116
  setVisible(false);
117
117
  }
118
118
 
@@ -72,14 +72,21 @@ var EventListPanel = function EventListPanel(props) {
72
72
  eventList: function () {
73
73
  var list = [];
74
74
  var listObj = {};
75
+ var markList = [];
75
76
  eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
76
77
  group.eventList.forEach(function (item) {
77
78
  if (!listObj[item.id]) {
78
- list.push(item);
79
+ if (item.marked) {
80
+ markList.push(item);
81
+ } else {
82
+ list.push(item);
83
+ }
84
+
79
85
  listObj[item.id] = 1;
80
86
  }
81
87
  });
82
88
  });
89
+ list = [].concat(markList, _toConsumableArray(list));
83
90
  return list;
84
91
  }(),
85
92
  name: '所有分组'
@@ -107,19 +114,27 @@ var EventListPanel = function EventListPanel(props) {
107
114
  function onClickEvent(e) {
108
115
  var resVal = _.cloneDeep(currentValue) || {};
109
116
  resVal.event = e;
117
+
118
+ if (e.id === -100) {
119
+ resVal.group = currentGroup;
120
+ }
121
+
110
122
  setCurrentValue(resVal);
111
123
  if (props.onChange) props.onChange(resVal);
112
124
  }
113
125
 
114
126
  function onClickGroup(g) {
127
+ var _currentValue$event;
128
+
115
129
  setCurrentGroup(g);
130
+ var isOverview = (currentValue === null || currentValue === void 0 ? void 0 : (_currentValue$event = currentValue.event) === null || _currentValue$event === void 0 ? void 0 : _currentValue$event.id) === -100;
116
131
 
117
- if (defaultSelectAble) {
132
+ if (defaultSelectAble || isOverview) {
118
133
  var resVal = _.cloneDeep(currentValue) || {};
119
134
  resVal.group = g;
120
135
  resVal.event = searchEventList[0];
121
136
  setCurrentValue(resVal);
122
- if (props.onChange) props.onChange(resVal);
137
+ if (props.onChange) props.onChange(resVal, isOverview);
123
138
  }
124
139
  }
125
140
 
@@ -202,13 +217,13 @@ var InfiniteScrollList = function InfiniteScrollList(_ref) {
202
217
  scrollableTarget: "scrollableDiv",
203
218
  key: Math.random()
204
219
  }, showList.map(function (e) {
205
- var _currentValue$event;
220
+ var _currentValue$event2;
206
221
 
207
222
  if (e.eventHidden === ShowStatus.hidden) return null;
208
223
  return /*#__PURE__*/React.createElement(EventListOption, {
209
224
  label: e.alias || e.name,
210
225
  key: "".concat(currentGroup === null || currentGroup === void 0 ? void 0 : currentGroup.id, "-").concat(e.id),
211
- checked: (currentValue === null || currentValue === void 0 ? void 0 : (_currentValue$event = currentValue.event) === null || _currentValue$event === void 0 ? void 0 : _currentValue$event.id) === e.id,
226
+ checked: (currentValue === null || currentValue === void 0 ? void 0 : (_currentValue$event2 = currentValue.event) === null || _currentValue$event2 === void 0 ? void 0 : _currentValue$event2.id) === e.id,
212
227
  highlight: {
213
228
  enable: true,
214
229
  text: searchValue
@@ -34,6 +34,6 @@ export declare namespace EventSelectTypes {
34
34
  value?: Value;
35
35
  showOverview?: boolean;
36
36
  defaultSelectAble?: boolean;
37
- onChange?: (value: Value) => void;
37
+ onChange?: (value: Value, isOverview?: boolean) => void;
38
38
  }
39
39
  }
@@ -17,7 +17,11 @@ var Footer = function Footer() {
17
17
  };
18
18
 
19
19
  var RightContent = function RightContent() {
20
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "right"));
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ style: {
22
+ height: '600px'
23
+ }
24
+ }, /*#__PURE__*/React.createElement("h1", null, "right"));
21
25
  };
22
26
 
23
27
  var onCollapse = function onCollapse(flag) {
@@ -111,7 +111,8 @@ var BizAnalysisLayout = function BizAnalysisLayout(props) {
111
111
  onClick: onCollapse
112
112
  }, /*#__PURE__*/React.createElement(IconFont, {
113
113
  className: "biz-layout-pickup-icon",
114
- type: 'zhedie'
114
+ type: 'zhedie',
115
+ size: 24
115
116
  }))) : /*#__PURE__*/React.createElement(Tooltip, {
116
117
  title: "\u5C55\u5F00\u7B5B\u9009\u9762\u677F",
117
118
  placement: "right",
@@ -120,7 +121,8 @@ var BizAnalysisLayout = function BizAnalysisLayout(props) {
120
121
  }, /*#__PURE__*/React.createElement(IconFont, {
121
122
  className: "biz-layout-open",
122
123
  onClick: onCollapse,
123
- type: "zhankai"
124
+ type: "zhankai",
125
+ size: 24
124
126
  })), /*#__PURE__*/React.createElement("div", {
125
127
  className: "biz-layout-handler",
126
128
  style: {
@@ -132,9 +134,7 @@ var BizAnalysisLayout = function BizAnalysisLayout(props) {
132
134
  style: {
133
135
  width: "calc(100% - ".concat(width + 6, "px)")
134
136
  }
135
- }, /*#__PURE__*/React.createElement("div", {
136
- className: "biz-right-content"
137
- }, children)));
137
+ }, children));
138
138
  };
139
139
 
140
140
  BizAnalysisLayout.defaultProps = {
@@ -69,12 +69,6 @@
69
69
  padding: @padding-lg;
70
70
  overflow: auto;
71
71
  background-color: #fff;
72
-
73
- .biz-right-content {
74
- min-width: 600px;
75
- height: 100%;
76
- min-height: 600px;
77
- }
78
72
  }
79
73
  }
80
74
 
@@ -11,15 +11,18 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import { Input, Tag, Tooltip } from 'antd';
14
- import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
14
+ import { FormItemInputContext } from 'antd/es/form/context';
15
+ import React, { useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
15
16
  import IconFont from '../icon/iconFont';
16
17
  import './styles/handle.less';
17
18
  var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
19
+ var _props$value;
20
+
18
21
  var placeholder = props.placeholder,
19
22
  labelField = props.labelField,
20
23
  keyField = props.keyField,
21
- _props$border = props.border,
22
- border = _props$border === void 0 ? true : _props$border;
24
+ border = props.border,
25
+ showSelectIcon = props.showSelectIcon;
23
26
  var classPrefix = 'biz-select-handle';
24
27
 
25
28
  var _useState = useState(false),
@@ -36,22 +39,38 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
36
39
  searchValue = _useState4[0],
37
40
  setSearchValue = _useState4[1];
38
41
 
42
+ var _useContext = useContext(FormItemInputContext),
43
+ contextStatus = _useContext.status;
44
+
45
+ var mergedStatus = props.status || contextStatus;
39
46
  useImperativeHandle(ref, function () {
40
47
  return {
41
- create: function create(flag) {
48
+ create: function create(flag, overlayClicked) {
42
49
  if (props.disable) return;
43
50
  setFocus(flag);
44
51
  if (!props.multiple) return;
45
52
 
46
53
  if (flag) {
47
54
  inputRef.current.focus();
55
+ } else {
56
+ if (overlayClicked) {
57
+ setSearchValue('');
58
+ } else {
59
+ if (searchValue && props.onCreate) {
60
+ props.onCreate(searchValue);
61
+ setSearchValue('');
62
+ }
63
+ }
48
64
  }
49
-
50
- setSearchValue('');
51
65
  },
52
66
  width: handleRef.current.clientWidth
53
67
  };
54
68
  });
69
+ useEffect(function () {
70
+ if (focus) {
71
+ props.onVisible && props.onVisible();
72
+ }
73
+ }, [focus]);
55
74
  var searchInputWidth = useMemo(function () {
56
75
  return textRef.current && searchValue ? textRef.current.offsetWidth : 3;
57
76
  }, [searchValue]);
@@ -66,6 +85,19 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
66
85
  if (props.onSearch) props.onSearch(value);
67
86
  };
68
87
 
88
+ var onKeyDown = function onKeyDown(e) {
89
+ if (e.keyCode === 13 && props.multiple) {
90
+ var value = e.target.value.trim();
91
+
92
+ if (value && props.onCreate) {
93
+ props.onCreate(value);
94
+ }
95
+
96
+ setFocus(false);
97
+ setSearchValue('');
98
+ }
99
+ };
100
+
69
101
  if (props.multiple) {
70
102
  return /*#__PURE__*/React.createElement("div", {
71
103
  ref: handleRef,
@@ -96,7 +128,8 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
96
128
  width: "".concat(searchInputWidth, "px")
97
129
  },
98
130
  value: searchValue,
99
- onChange: onSearch
131
+ onChange: onSearch,
132
+ onKeyDown: onKeyDown
100
133
  }), /*#__PURE__*/React.createElement("span", {
101
134
  className: "".concat(classPrefix, "-temp"),
102
135
  ref: textRef
@@ -105,11 +138,13 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
105
138
 
106
139
  return /*#__PURE__*/React.createElement("div", {
107
140
  ref: handleRef,
108
- className: "".concat(classPrefix, "-input ").concat(props.theme ? props.theme : '', "\n ").concat(props.disable ? 'disable' : '', " ").concat(focus ? 'active' : '', " \n ").concat(border ? '' : 'borderless', " ").concat(props.size ? props.size : 'middle'),
141
+ className: "".concat(classPrefix, "-input ").concat(props.theme ? props.theme : '', "\n ").concat(props.disable ? 'disable' : '', " ").concat(focus ? 'active' : '', " \n ").concat(mergedStatus ? "".concat(classPrefix, "-status-").concat(mergedStatus) : '', "\n ").concat(border ? '' : 'borderless', " ").concat(props.size ? props.size : 'middle'),
109
142
  title: props.label || props.value && props.value[labelField]
110
143
  }, /*#__PURE__*/React.createElement("span", {
111
144
  className: "".concat(classPrefix, "-content")
112
- }, props.label || props.value && props.value[labelField] || /*#__PURE__*/React.createElement("span", {
145
+ }, showSelectIcon && ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.icon) && /*#__PURE__*/React.createElement("span", {
146
+ className: "".concat(classPrefix, "-icon")
147
+ }, props.value.icon), props.label || props.value && props.value[labelField] || /*#__PURE__*/React.createElement("span", {
113
148
  className: "".concat(classPrefix, "-holder")
114
149
  }, placeholder || '请选择')), /*#__PURE__*/React.createElement(IconFont, {
115
150
  className: "".concat(classPrefix, "-expand-icon"),
@@ -118,6 +153,8 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
118
153
  });
119
154
  SelectHandle.defaultProps = {
120
155
  labelField: 'label',
121
- keyField: 'id'
156
+ keyField: 'id',
157
+ border: true,
158
+ showSelectIcon: true
122
159
  };
123
160
  export default SelectHandle;
@@ -31,6 +31,8 @@ import _ from 'lodash';
31
31
  export var classPrefix = 'biz-select';
32
32
 
33
33
  var BizSelect = function BizSelect(props) {
34
+ var _boxRef$current3;
35
+
34
36
  var overlayWidth = props.overlayWidth,
35
37
  minDropdownWidth = props.minDropdownWidth,
36
38
  labelField = props.labelField,
@@ -53,6 +55,7 @@ var BizSelect = function BizSelect(props) {
53
55
  setVisible = _useState6[1];
54
56
 
55
57
  var selectRef = useRef(null);
58
+ var overlayRef = useRef(null);
56
59
  var boxRef = useRef(null);
57
60
  var selectId = Math.random().toString();
58
61
 
@@ -62,21 +65,18 @@ var BizSelect = function BizSelect(props) {
62
65
  setWidth = _useState8[1];
63
66
 
64
67
  useEffect(function () {
65
- var _boxRef$current;
66
-
67
- setWidth((boxRef === null || boxRef === void 0 ? void 0 : (_boxRef$current = boxRef.current) === null || _boxRef$current === void 0 ? void 0 : _boxRef$current.width) || 200);
68
-
69
68
  if (props.defaultValue) {
70
69
  setCurrent(getValue(props.defaultValue));
71
70
  }
72
71
 
73
72
  var handleClick = function handleClick(e) {
74
- var _selectRef$current, _boxRef$current2;
73
+ var _selectRef$current, _overlayRef$current, _boxRef$current;
75
74
 
76
75
  var clicked = (_selectRef$current = selectRef.current) === null || _selectRef$current === void 0 ? void 0 : _selectRef$current.contains(e.target);
77
- (_boxRef$current2 = boxRef.current) === null || _boxRef$current2 === void 0 ? void 0 : _boxRef$current2.create(clicked);
76
+ var overlayClicked = (_overlayRef$current = overlayRef.current) === null || _overlayRef$current === void 0 ? void 0 : _overlayRef$current.contains(e.target);
77
+ (_boxRef$current = boxRef.current) === null || _boxRef$current === void 0 ? void 0 : _boxRef$current.create(clicked, overlayClicked);
78
78
 
79
- if (!clicked && !props.enableCreate) {
79
+ if (!clicked && !props.enableCreate || overlayClicked) {
80
80
  setSearchValue('');
81
81
  }
82
82
  };
@@ -86,6 +86,11 @@ var BizSelect = function BizSelect(props) {
86
86
  window.removeEventListener('click', handleClick);
87
87
  };
88
88
  }, []);
89
+ useEffect(function () {
90
+ var _boxRef$current2;
91
+
92
+ setWidth((boxRef === null || boxRef === void 0 ? void 0 : (_boxRef$current2 = boxRef.current) === null || _boxRef$current2 === void 0 ? void 0 : _boxRef$current2.width) || 200);
93
+ }, [boxRef === null || boxRef === void 0 ? void 0 : (_boxRef$current3 = boxRef.current) === null || _boxRef$current3 === void 0 ? void 0 : _boxRef$current3.width]);
89
94
  useEffect(function () {
90
95
  if (!props.value) return;
91
96
  setCurrent(getValue(props.value));
@@ -149,13 +154,39 @@ var BizSelect = function BizSelect(props) {
149
154
  props.onVisibleChange && props.onVisibleChange(flag);
150
155
  };
151
156
 
157
+ var onCreate = function onCreate(val) {
158
+ var _data;
159
+
160
+ if (current) {
161
+ var flag = true;
162
+ current.forEach(function (item) {
163
+ if (item[labelField] === val) {
164
+ flag = false;
165
+ }
166
+ });
167
+ if (!flag) return;
168
+ }
169
+
170
+ var data = (_data = {}, _defineProperty(_data, keyField, val), _defineProperty(_data, labelField, val), _data);
171
+ var originData = current || [];
172
+ originData.push(data);
173
+ setCurrent(originData);
174
+ setSearchValue('');
175
+ if (props.onChange) props.onChange(originData);
176
+ };
177
+
178
+ var onVisible = function onVisible() {
179
+ setVisible(true);
180
+ };
181
+
152
182
  return /*#__PURE__*/React.createElement(Dropdown, {
153
183
  overlay: /*#__PURE__*/React.createElement(SelectOverlay, _objectSpread(_objectSpread({}, res), {}, {
154
184
  value: current,
155
185
  labelField: labelField,
156
186
  keyField: keyField,
157
187
  searchValue: searchValue,
158
- onChange: onChange
188
+ onChange: onChange,
189
+ ref: overlayRef
159
190
  })),
160
191
  disabled: props.disable,
161
192
  destroyPopupOnHide: props.destroyPopupOnHide,
@@ -184,11 +215,15 @@ var BizSelect = function BizSelect(props) {
184
215
  theme: props.theme,
185
216
  size: props.size || 'middle',
186
217
  border: props.border,
218
+ showSelectIcon: props.showSelectIcon,
219
+ status: props.status,
187
220
  onDelete: onDelete,
188
221
  onSearch: function onSearch(v) {
189
222
  setSearchValue(v);
190
223
  if (props.onSearch) props.onSearch(v);
191
- }
224
+ },
225
+ onCreate: onCreate,
226
+ onVisible: onVisible
192
227
  })));
193
228
  };
194
229
 
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { BizSelectTypes } from './types';
3
- declare const SelectOverlay: React.FC<BizSelectTypes.Props>;
3
+ declare const SelectOverlay: React.ForwardRefExoticComponent<BizSelectTypes.Props & React.RefAttributes<any>>;
4
4
  export default SelectOverlay;