@zgfe/business-lib 1.0.0-beta.6 → 1.0.3

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 (283) hide show
  1. package/es/analysisLayout/demo/index.js +4 -1
  2. package/es/analysisLayout/index.d.ts +1 -28
  3. package/es/analysisLayout/index.js +38 -48
  4. package/es/analysisLayout/index.less +1 -1
  5. package/es/assets/styles/chunks.less +143 -0
  6. package/es/assets/styles/inner.less +3 -0
  7. package/es/assets/styles/resetAntd.less +398 -0
  8. package/es/assets/styles/variable.less +21 -0
  9. package/es/assets/theme.d.ts +5 -0
  10. package/es/assets/theme.js +4 -0
  11. package/es/attrConditions/components/operateList.d.ts +8 -0
  12. package/es/attrConditions/components/operateList.js +83 -0
  13. package/es/attrConditions/components/stringList.d.ts +9 -0
  14. package/es/attrConditions/components/stringList.js +168 -0
  15. package/es/attrConditions/components/valuesList.d.ts +10 -0
  16. package/es/attrConditions/components/valuesList.js +188 -0
  17. package/es/{attributeSelector/demo/multi.d.ts → attrConditions/demo/group.d.ts} +0 -0
  18. package/es/attrConditions/demo/group.js +82 -0
  19. package/es/{globalAttributes → attrConditions}/demo/index.d.ts +0 -0
  20. package/es/{datePicker/demo/form.js → attrConditions/demo/index.js} +43 -23
  21. package/es/attrConditions/group.d.ts +5 -0
  22. package/es/attrConditions/group.js +183 -0
  23. package/es/attrConditions/index.d.ts +6 -0
  24. package/es/attrConditions/index.js +160 -0
  25. package/es/attrConditions/styles/group.less +49 -0
  26. package/es/attrConditions/styles/index.less +94 -0
  27. package/es/attrConditions/types.d.ts +63 -0
  28. package/es/attrConditions/types.js +19 -0
  29. package/es/attrConditions/utils/operates.d.ts +16 -0
  30. package/es/attrConditions/utils/operates.js +67 -0
  31. package/es/attributeSelector/demo/index.d.ts +3 -0
  32. package/es/attributeSelector/demo/{singleForm.js → index.js} +42 -44
  33. package/es/attributeSelector/index.d.ts +4 -111
  34. package/es/attributeSelector/index.js +88 -543
  35. package/es/attributeSelector/listPanel.d.ts +4 -0
  36. package/es/attributeSelector/listPanel.js +208 -0
  37. package/es/attributeSelector/option.d.ts +15 -0
  38. package/es/attributeSelector/option.js +53 -0
  39. package/es/attributeSelector/styles/index.less +100 -0
  40. package/es/attributeSelector/types.d.ts +79 -0
  41. package/es/attributeSelector/types.js +15 -0
  42. package/es/attributeSelector/util.d.ts +7 -0
  43. package/es/attributeSelector/util.js +69 -0
  44. package/es/chart/demo/pie.js +1 -0
  45. package/es/chart/index.d.ts +2 -96
  46. package/es/chart/index.js +28 -35
  47. package/es/chart/styles/index.less +50 -0
  48. package/es/chart/types.d.ts +46 -0
  49. package/es/chart/{type.js → types.js} +0 -0
  50. package/es/chart/util/{chartConfig.d.ts → chartOptionConfig.d.ts} +4 -35
  51. package/es/chart/util/{chartConfig.js → chartOptionConfig.js} +45 -111
  52. package/es/chart/util/formatData.d.ts +3 -7
  53. package/es/chart/util/formatData.js +47 -26
  54. package/es/chart/util/formatOption.d.ts +2 -1
  55. package/es/chart/util/formatOption.js +22 -9
  56. package/es/chart/util/mapUtil.d.ts +3 -3
  57. package/es/chart/util/mapUtil.js +9 -19
  58. package/es/commonStyle/icon.less +116 -112
  59. package/es/commonStyle/select.less +1 -1
  60. package/es/commonStyle/theme.less +520 -473
  61. package/es/components/iconFont.js +4 -2
  62. package/es/context/index.d.ts +16 -0
  63. package/es/context/index.js +3 -0
  64. package/es/datePicker/datePicker.d.ts +10 -0
  65. package/es/datePicker/datePicker.js +115 -0
  66. package/es/datePicker/demo/index.d.ts +1 -0
  67. package/es/datePicker/demo/index.js +9 -2
  68. package/es/datePicker/index.d.ts +4 -27
  69. package/es/datePicker/index.js +72 -148
  70. package/es/datePicker/styles/index.less +48 -0
  71. package/es/datePicker/types.d.ts +24 -0
  72. package/es/{eventSelector/type.js → datePicker/types.js} +0 -0
  73. package/es/datePicker/utils.d.ts +6 -0
  74. package/es/datePicker/utils.js +70 -0
  75. package/es/dialog/components/itemNode.d.ts +10 -0
  76. package/es/dialog/components/itemNode.js +109 -0
  77. package/es/dialog/components/list.d.ts +3 -13
  78. package/es/dialog/components/list.js +15 -12
  79. package/es/dialog/components/selectToInput.d.ts +4 -48
  80. package/es/dialog/components/selectToInput.js +74 -80
  81. package/es/dialog/components/styles/handle.less +39 -0
  82. package/es/dialog/components/styles/list.less +60 -0
  83. package/es/dialog/components/styles/tab.less +55 -0
  84. package/es/dialog/components/tab.d.ts +3 -7
  85. package/es/dialog/components/tab.js +57 -19
  86. package/es/dialog/data/{chart.d.ts → data.d.ts} +9 -0
  87. package/es/dialog/data/{chart.js → data.js} +11 -0
  88. package/es/dialog/demo/index.d.ts +23 -0
  89. package/es/dialog/demo/index.js +34 -3
  90. package/es/dialog/demo/index2.js +14 -2
  91. package/es/dialog/index.d.ts +4 -97
  92. package/es/dialog/index.js +54 -109
  93. package/es/dialog/styles/index.less +11 -0
  94. package/es/dialog/types.d.ts +77 -0
  95. package/es/{targetConditionGroup/type.js → dialog/types.js} +0 -0
  96. package/es/eventSelector/demo/index.js +26 -44
  97. package/es/eventSelector/index.d.ts +4 -30
  98. package/es/eventSelector/index.js +90 -416
  99. package/es/eventSelector/listPanel.d.ts +4 -0
  100. package/es/eventSelector/listPanel.js +197 -0
  101. package/es/eventSelector/option.d.ts +17 -0
  102. package/es/eventSelector/option.js +54 -0
  103. package/es/eventSelector/styles/index.less +77 -0
  104. package/es/eventSelector/types.d.ts +31 -0
  105. package/es/eventSelector/types.js +1 -0
  106. package/es/index.d.ts +14 -11
  107. package/es/index.js +9 -11
  108. package/es/{attributeSelector/data → mock}/env.d.ts +0 -0
  109. package/es/{attributeSelector/data → mock}/env.js +0 -0
  110. package/es/{attributeSelector/data → mock}/event.d.ts +0 -0
  111. package/es/{attributeSelector/data → mock}/event.js +0 -0
  112. package/es/{attributeSelector/data → mock}/user.d.ts +0 -0
  113. package/es/{attributeSelector/data → mock}/user.js +0 -0
  114. package/es/{multipleSelector → searchInput}/demo/index.d.ts +0 -0
  115. package/es/searchInput/demo/index.js +5 -0
  116. package/es/searchInput/index.d.ts +8 -0
  117. package/es/searchInput/index.js +31 -0
  118. package/es/{attributeSelector/demo/multiForm.d.ts → select/demo/group.d.ts} +0 -0
  119. package/es/{globalAttributes/demo/index.js → select/demo/group.js} +49 -31
  120. package/es/select/demo/index.js +49 -21
  121. package/es/{attributeSelector/demo/single.d.ts → select/demo/multiple.d.ts} +0 -0
  122. package/es/{multipleSelector/demo/index.js → select/demo/multiple.js} +55 -12
  123. package/es/select/handle.d.ts +5 -0
  124. package/es/select/handle.js +119 -0
  125. package/es/select/index.d.ts +4 -49
  126. package/es/select/index.js +168 -122
  127. package/es/select/option.d.ts +4 -0
  128. package/es/select/option.js +59 -0
  129. package/es/select/overlay.d.ts +4 -0
  130. package/es/select/overlay.js +154 -0
  131. package/es/select/styles/handle.less +111 -0
  132. package/es/select/styles/index.less +99 -0
  133. package/es/select/types.d.ts +65 -0
  134. package/es/select/types.js +1 -0
  135. package/es/table/demo/data/table.js +1 -1
  136. package/es/table/demo/index.d.ts +1 -1
  137. package/es/table/demo/index.js +9 -8
  138. package/es/table/demo/index3.js +9 -18
  139. package/es/table/index.d.ts +4 -30
  140. package/es/table/index.js +30 -26
  141. package/es/table/styles/index.less +5 -0
  142. package/es/table/type.d.ts +10 -0
  143. package/es/table/type.js +1 -0
  144. package/es/targetConditionGroup/components/targetDimension.d.ts +8 -0
  145. package/es/targetConditionGroup/components/targetDimension.js +153 -0
  146. package/es/targetConditionGroup/data/operates.d.ts +8 -24
  147. package/es/targetConditionGroup/data/operates.js +26 -69
  148. package/es/targetConditionGroup/demo/group.d.ts +1 -0
  149. package/es/targetConditionGroup/demo/group.js +108 -23
  150. package/es/targetConditionGroup/demo/index.js +34 -34
  151. package/es/targetConditionGroup/demo/styles/index.less +29 -0
  152. package/es/targetConditionGroup/index.d.ts +4 -57
  153. package/es/targetConditionGroup/index.js +177 -274
  154. package/es/targetConditionGroup/styles/index.less +25 -0
  155. package/es/targetConditionGroup/types.d.ts +32 -0
  156. package/es/targetConditionGroup/types.js +1 -0
  157. package/es/targetSelector/demo/index.d.ts +1 -0
  158. package/es/targetSelector/demo/index.js +29 -71
  159. package/es/targetSelector/editBox.d.ts +8 -0
  160. package/es/targetSelector/{components/BizEventNameEditBox.js → editBox.js} +49 -24
  161. package/es/targetSelector/index.d.ts +5 -55
  162. package/es/targetSelector/index.js +103 -214
  163. package/es/targetSelector/optionIcon.d.ts +9 -0
  164. package/es/targetSelector/optionIcon.js +24 -0
  165. package/es/targetSelector/optionMenu.d.ts +7 -0
  166. package/es/targetSelector/optionMenu.js +38 -0
  167. package/es/targetSelector/styles/index.less +88 -0
  168. package/es/targetSelector/types.d.ts +18 -0
  169. package/es/targetSelector/types.js +1 -0
  170. package/es/userCondition/conditionTypeList.d.ts +10 -0
  171. package/es/userCondition/conditionTypeList.js +43 -0
  172. package/es/userCondition/conditionWrap.d.ts +7 -0
  173. package/es/userCondition/conditionWrap.js +18 -0
  174. package/es/userCondition/conditions/eventCondition.d.ts +8 -0
  175. package/es/userCondition/conditions/eventCondition.js +104 -0
  176. package/es/userCondition/conditions/periodCondition.d.ts +11 -0
  177. package/es/userCondition/conditions/periodCondition.js +156 -0
  178. package/es/userCondition/conditions/propCondition.d.ts +11 -0
  179. package/es/userCondition/conditions/propCondition.js +147 -0
  180. package/es/userCondition/conditions/runTimesCondition.d.ts +9 -0
  181. package/es/userCondition/conditions/runTimesCondition.js +78 -0
  182. package/es/userCondition/conditions/styles/eventCondition.less +49 -0
  183. package/es/userCondition/conditions/styles/periodCondition.less +14 -0
  184. package/es/userCondition/conditions/styles/propCondition.less +36 -0
  185. package/es/userCondition/conditions/styles/runTimesCondition.less +16 -0
  186. package/es/{attributeSelector/demo/singleForm.d.ts → userCondition/demo/index.d.ts} +0 -0
  187. package/es/userCondition/demo/index.js +97 -0
  188. package/es/userCondition/index.d.ts +7 -0
  189. package/es/userCondition/index.js +146 -0
  190. package/es/userCondition/orConditions.d.ts +5 -0
  191. package/es/userCondition/orConditions.js +202 -0
  192. package/es/userCondition/relationLabel.d.ts +6 -0
  193. package/es/userCondition/relationLabel.js +12 -0
  194. package/es/userCondition/styles/conditionTypeList.less +31 -0
  195. package/es/userCondition/styles/conditionWrap.less +14 -0
  196. package/es/userCondition/styles/index.less +13 -0
  197. package/es/userCondition/styles/orConditions.less +16 -0
  198. package/es/userCondition/styles/relationLabel.less +18 -0
  199. package/es/userCondition/types.d.ts +79 -0
  200. package/es/userCondition/types.js +1 -0
  201. package/es/userCondition/util.d.ts +2 -0
  202. package/es/userCondition/util.js +54 -0
  203. package/es/{datePicker/demo/form.d.ts → userGroup/demo/group.d.ts} +0 -0
  204. package/es/{targetConditionGroup/demo/form.js → userGroup/demo/group.js} +68 -72
  205. package/es/userGroup/demo/index.d.ts +0 -1
  206. package/es/userGroup/demo/index.js +5 -62
  207. package/es/userGroup/index.d.ts +3 -77
  208. package/es/userGroup/index.js +60 -108
  209. package/es/userGroup/styles/index.less +20 -0
  210. package/es/userGroup/types.d.ts +15 -0
  211. package/es/userGroup/types.js +1 -0
  212. package/es/utils/ajax.js +5 -20
  213. package/es/utils/type.d.ts +42 -44
  214. package/es/utils/util.d.ts +1 -35
  215. package/es/utils/util.js +27 -57
  216. package/package.json +11 -4
  217. package/es/attributeSelector/demo/multi.js +0 -39
  218. package/es/attributeSelector/demo/multiForm.js +0 -64
  219. package/es/attributeSelector/demo/single.js +0 -43
  220. package/es/attributeSelector/group.d.ts +0 -31
  221. package/es/attributeSelector/group.js +0 -225
  222. package/es/attributeSelector/index.less +0 -172
  223. package/es/chart/index.less +0 -38
  224. package/es/chart/style/circle.svg +0 -4
  225. package/es/chart/type.d.ts +0 -22
  226. package/es/datePicker/data.d.ts +0 -9
  227. package/es/datePicker/data.js +0 -65
  228. package/es/datePicker/index.less +0 -364
  229. package/es/dialog/components/style/list.less +0 -59
  230. package/es/dialog/components/style/tab.less +0 -61
  231. package/es/dialog/style/index.less +0 -86
  232. package/es/eventSelector/demo/form.d.ts +0 -2
  233. package/es/eventSelector/demo/form.js +0 -89
  234. package/es/eventSelector/demo/nodata.d.ts +0 -2
  235. package/es/eventSelector/demo/nodata.js +0 -13
  236. package/es/eventSelector/index.less +0 -121
  237. package/es/eventSelector/type.d.ts +0 -41
  238. package/es/globalAttributes/demo/data/env.d.ts +0 -11
  239. package/es/globalAttributes/demo/data/env.js +0 -181
  240. package/es/globalAttributes/demo/data/event.d.ts +0 -237
  241. package/es/globalAttributes/demo/data/event.js +0 -3483
  242. package/es/globalAttributes/demo/data/user.d.ts +0 -22
  243. package/es/globalAttributes/demo/data/user.js +0 -218
  244. package/es/globalAttributes/index.d.ts +0 -47
  245. package/es/globalAttributes/index.js +0 -112
  246. package/es/multipleSelector/index.d.ts +0 -36
  247. package/es/multipleSelector/index.js +0 -131
  248. package/es/multipleSelector/index.less +0 -136
  249. package/es/table/demo/index.less +0 -8
  250. package/es/table/index.less +0 -139
  251. package/es/targetConditionGroup/components/conditionGroup.d.ts +0 -30
  252. package/es/targetConditionGroup/components/conditionGroup.js +0 -112
  253. package/es/targetConditionGroup/components/conditionItem.d.ts +0 -47
  254. package/es/targetConditionGroup/components/conditionItem.js +0 -232
  255. package/es/targetConditionGroup/components/style/group.less +0 -47
  256. package/es/targetConditionGroup/components/style/index.less +0 -16
  257. package/es/targetConditionGroup/demo/data/env.d.ts +0 -11
  258. package/es/targetConditionGroup/demo/data/env.js +0 -181
  259. package/es/targetConditionGroup/demo/data/event.d.ts +0 -237
  260. package/es/targetConditionGroup/demo/data/event.js +0 -3483
  261. package/es/targetConditionGroup/demo/data/user.d.ts +0 -22
  262. package/es/targetConditionGroup/demo/data/user.js +0 -218
  263. package/es/targetConditionGroup/demo/form.d.ts +0 -2
  264. package/es/targetConditionGroup/demo/item.d.ts +0 -2
  265. package/es/targetConditionGroup/demo/item.js +0 -5
  266. package/es/targetConditionGroup/group.d.ts +0 -56
  267. package/es/targetConditionGroup/group.js +0 -204
  268. package/es/targetConditionGroup/index.less +0 -76
  269. package/es/targetConditionGroup/type.d.ts +0 -95
  270. package/es/targetSelector/components/BizCascadeBox.d.ts +0 -34
  271. package/es/targetSelector/components/BizCascadeBox.js +0 -213
  272. package/es/targetSelector/components/BizEventNameEditBox.d.ts +0 -20
  273. package/es/targetSelector/demo/form.d.ts +0 -2
  274. package/es/targetSelector/demo/form.js +0 -133
  275. package/es/targetSelector/demo/nodata.d.ts +0 -2
  276. package/es/targetSelector/demo/nodata.js +0 -13
  277. package/es/targetSelector/index.less +0 -28
  278. package/es/userGroup/demo/cluster.d.ts +0 -3
  279. package/es/userGroup/demo/cluster.js +0 -102
  280. package/es/userGroup/demo/index.less +0 -3
  281. package/es/userGroup/index.less +0 -2
  282. package/es/userGroup/userCluster.d.ts +0 -63
  283. package/es/userGroup/userCluster.js +0 -255
@@ -13,39 +13,67 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import React, { useState } from 'react';
14
14
  import { BizSelect } from '@zgfe/business-lib';
15
15
  import { Button } from 'antd';
16
- var options = [{
17
- label: 'test',
18
- value: 'test'
16
+ var stringOperate = [{
17
+ name: '是',
18
+ value: 'equal'
19
19
  }, {
20
- label: 'test2',
21
- value: 'test2'
20
+ name: '包含',
21
+ value: 'contains'
22
22
  }, {
23
- label: 'test3',
24
- value: 'test3',
25
- disabled: true
23
+ name: '不是',
24
+ value: 'not equal'
25
+ }, {
26
+ name: '不包含',
27
+ value: 'not contains'
28
+ }, {
29
+ name: '开头是',
30
+ value: 'begin with'
31
+ }, {
32
+ name: '结尾是',
33
+ value: 'end with'
34
+ }, {
35
+ name: '开头不是',
36
+ value: 'not begin with'
37
+ }, {
38
+ name: '结尾不是',
39
+ value: 'not end with'
40
+ }, {
41
+ name: '是空值',
42
+ value: 'is null'
43
+ }, {
44
+ name: '不是空值',
45
+ value: 'is not null'
46
+ }];
47
+ var disabledList = [{
48
+ value: 'not equal'
49
+ }, {
50
+ value: 'not begin with'
26
51
  }];
27
52
  export default (function () {
28
- var _useState = useState('test2'),
53
+ var _useState = useState({
54
+ name: '不是',
55
+ value: 'not equal'
56
+ }),
29
57
  _useState2 = _slicedToArray(_useState, 2),
30
58
  data = _useState2[0],
31
59
  setData = _useState2[1];
32
60
 
33
- var handleChange = function handleChange(value) {
34
- console.log('select >>', value);
61
+ var onChange = function onChange(value) {
35
62
  setData(function () {
36
63
  return value;
37
64
  });
38
65
  };
39
66
 
40
67
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizSelect, {
41
- options: options,
42
- value: data,
43
- onChange: handleChange
44
- }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Button, {
45
- onClick: function onClick() {
46
- setData(function () {
47
- return null;
48
- });
49
- }
50
- }, "clear"));
68
+ options: stringOperate,
69
+ defaultValue: data,
70
+ labelField: "name",
71
+ keyField: "value",
72
+ enableSearch: true,
73
+ theme: "secondary",
74
+ popupContainer: true,
75
+ onChange: onChange,
76
+ disableItemList: disabledList,
77
+ dropdownExtra: /*#__PURE__*/React.createElement(Button, null, "+ \u6DFB\u52A0")
78
+ }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u9009\u62E9\u7684\u503C\u662F\uFF1A", JSON.stringify(data)));
51
79
  });
@@ -11,25 +11,68 @@ 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 React, { useState } from 'react';
14
- import { BizMultipleSelector } from '@zgfe/business-lib';
15
- var options = ['CHROME48', 'FIREFOX37', 'CHROME21', 'Firefox', 'FIREFOX_MOBILE', 'BOT', 'FIREFOX9', 'MOBILE_SAFARI', 'MOBILE_SAFARI2', 'MOBILE_SAFARI4'];
14
+ import { BizSelect } from '@zgfe/business-lib';
15
+ var stringOperate = [{
16
+ name: '是',
17
+ value: 'equal'
18
+ }, {
19
+ name: '包含',
20
+ value: 'contains'
21
+ }, {
22
+ name: '不是',
23
+ value: 'not equal'
24
+ }, {
25
+ name: '不包含',
26
+ value: 'not contains'
27
+ }, {
28
+ name: '开头是',
29
+ value: 'begin with'
30
+ }, {
31
+ name: '结尾是',
32
+ value: 'end with'
33
+ }, {
34
+ name: '开头不是',
35
+ value: 'not begin with'
36
+ }, {
37
+ name: '结尾不是',
38
+ value: 'not end with'
39
+ }, {
40
+ name: '是空值',
41
+ value: 'is null'
42
+ }, {
43
+ name: '不是空值',
44
+ value: 'is not null'
45
+ }];
46
+ var disabledList = [{
47
+ name: '不包含',
48
+ value: 'not contains'
49
+ }, {
50
+ name: '开头不是',
51
+ value: 'not begin with'
52
+ }];
16
53
  export default (function () {
17
- var _useState = useState(['CHROME48']),
54
+ var _useState = useState(),
18
55
  _useState2 = _slicedToArray(_useState, 2),
19
- condition = _useState2[0],
20
- setCondition = _useState2[1];
56
+ data = _useState2[0],
57
+ setData = _useState2[1];
21
58
 
22
- var handleChange = function handleChange(data) {
23
- setCondition(data);
59
+ var onChange = function onChange(value) {
60
+ setData(function () {
61
+ return value;
62
+ });
24
63
  };
25
64
 
26
65
  return /*#__PURE__*/React.createElement("div", {
27
66
  style: {
28
67
  width: '400px'
29
68
  }
30
- }, /*#__PURE__*/React.createElement(BizMultipleSelector, {
31
- options: options,
32
- defaultValue: condition,
33
- onChange: handleChange
34
- }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u9009\u62E9\u7684\u6761\u4EF6\u503C\u662F\uFF1A", JSON.stringify(condition)));
69
+ }, /*#__PURE__*/React.createElement(BizSelect, {
70
+ options: stringOperate,
71
+ labelField: "name",
72
+ keyField: "value",
73
+ onChange: onChange,
74
+ disableItemList: disabledList,
75
+ multiple: true,
76
+ enableCreate: true
77
+ }), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, "\u5F53\u524D\u9009\u62E9\u7684\u503C\u662F\uFF1A", JSON.stringify(data)));
35
78
  });
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './styles/handle.less';
3
+ import { HandlerTypes } from './types';
4
+ declare const SelectHandle: React.ForwardRefExoticComponent<HandlerTypes & React.RefAttributes<any>>;
5
+ export default SelectHandle;
@@ -0,0 +1,119 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { Input, Tag, Tooltip } from 'antd';
14
+ import React, { useImperativeHandle, useMemo, useRef, useState } from 'react';
15
+ import IconFont from '../components/iconFont';
16
+ import './styles/handle.less';
17
+ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
18
+ var placeholder = props.placeholder,
19
+ labelField = props.labelField,
20
+ keyField = props.keyField,
21
+ _props$border = props.border,
22
+ border = _props$border === void 0 ? true : _props$border;
23
+ var classPrefix = 'biz-select-handle';
24
+
25
+ var _useState = useState(false),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ focus = _useState2[0],
28
+ setFocus = _useState2[1];
29
+
30
+ var handleRef = useRef(null);
31
+ var inputRef = useRef(null);
32
+
33
+ var _useState3 = useState(''),
34
+ _useState4 = _slicedToArray(_useState3, 2),
35
+ searchValue = _useState4[0],
36
+ setSearchValue = _useState4[1];
37
+
38
+ useImperativeHandle(ref, function () {
39
+ return {
40
+ create: function create(flag) {
41
+ if (props.disable) return;
42
+ setFocus(flag);
43
+ if (!props.multiple) return;
44
+
45
+ if (flag) {
46
+ inputRef.current.focus();
47
+ }
48
+
49
+ setSearchValue('');
50
+
51
+ if (props.enableCreate && searchValue && !flag) {
52
+ if (props.onCreate) props.onCreate(searchValue);
53
+ }
54
+ },
55
+ width: handleRef.current.clientWidth
56
+ };
57
+ });
58
+ var searchInputWidth = useMemo(function () {
59
+ return searchValue.length * 14 || 3;
60
+ }, [searchValue]);
61
+
62
+ var onDelete = function onDelete(data) {
63
+ if (props.onDelete) props.onDelete(data);
64
+ };
65
+
66
+ var onSearch = function onSearch(e) {
67
+ var value = e.target.value;
68
+ setSearchValue(value);
69
+ if (props.onSearch) props.onSearch(value);
70
+ };
71
+
72
+ if (props.multiple) {
73
+ return /*#__PURE__*/React.createElement("div", {
74
+ ref: handleRef,
75
+ className: "".concat(classPrefix, "-input ").concat(classPrefix, "-input-multiple\n ").concat(props.theme ? props.theme : '', " ").concat(props.disable ? 'disable' : '', " \n ").concat(focus ? 'active' : '', " ").concat(border ? '' : 'borderless', " ").concat(props.size ? props.size : '')
76
+ }, props.value && props.value.length > 0 ? props.value.map(function (item, index) {
77
+ return /*#__PURE__*/React.createElement(Tooltip, {
78
+ title: item[labelField],
79
+ key: item[keyField] || index,
80
+ overlayClassName: "".concat(classPrefix, "-tooltip"),
81
+ color: "#fff"
82
+ }, /*#__PURE__*/React.createElement(Tag, {
83
+ closable: true,
84
+ className: "".concat(classPrefix, "-tag"),
85
+ onClose: function onClose() {
86
+ onDelete(item);
87
+ }
88
+ }, item[labelField]));
89
+ }) : !focus ? /*#__PURE__*/React.createElement("span", {
90
+ className: "".concat(classPrefix, "-holder")
91
+ }, placeholder || '请选择') : '', /*#__PURE__*/React.createElement(Input, {
92
+ ref: inputRef,
93
+ autoFocus: focus,
94
+ disabled: props.disable,
95
+ className: "".concat(classPrefix, "-search"),
96
+ style: {
97
+ width: "".concat(searchInputWidth, "px")
98
+ },
99
+ value: searchValue,
100
+ onChange: onSearch
101
+ }));
102
+ }
103
+
104
+ return /*#__PURE__*/React.createElement("div", {
105
+ ref: handleRef,
106
+ className: "".concat(classPrefix, "-input ").concat(classPrefix, "-single-input ").concat(props.theme ? props.theme : '', "\n ").concat(props.disable ? 'disable' : '', " ").concat(focus ? 'active' : '', " \n ").concat(border ? '' : 'borderless', " ").concat(props.size ? props.size : ''),
107
+ title: props.label || props.value && props.value[labelField]
108
+ }, props.label || props.value && props.value[labelField] || /*#__PURE__*/React.createElement("span", {
109
+ className: "".concat(classPrefix, "-holder")
110
+ }, placeholder || '请选择'), /*#__PURE__*/React.createElement(IconFont, {
111
+ className: "".concat(classPrefix, "-expand-icon"),
112
+ type: 'icon-xiangxia'
113
+ }));
114
+ });
115
+ SelectHandle.defaultProps = {
116
+ labelField: 'label',
117
+ keyField: 'id'
118
+ };
119
+ export default SelectHandle;
@@ -1,51 +1,6 @@
1
1
  import React from 'react';
2
- import { SelectProps } from 'antd/lib/select';
3
- import './index.less';
4
- interface fieldNamesProps {
5
- label: string;
6
- value: string;
7
- }
8
- interface BizSelectProps {
9
- /**
10
- * @description 自定义节点
11
- * @default { label: 'label', value: 'value' }
12
- */
13
- fieldNames?: fieldNamesProps;
14
- /**
15
- * @description 默认值
16
- * @default -
17
- */
18
- defaultValue?: string | number;
19
- /**
20
- * @description 下拉名称
21
- * @default '''
22
- */
23
- name?: string;
24
- /**
25
- * @description 创建option回调
26
- * @default false
27
- */
28
- createOption?: () => void;
29
- /**
30
- * @description 是否搜索option
31
- * @default false
32
- */
33
- search?: boolean;
34
- /**
35
- * @description 是否有创建option
36
- * @default false
37
- */
38
- create?: boolean;
39
- /**
40
- * @description 文本框类
41
- * @default small
42
- */
43
- dropdownSize?: string;
44
- /**
45
- * @description 弹窗样式
46
- * @default false
47
- */
48
- isDialog?: boolean;
49
- }
50
- declare const BizSelect: React.FC<BizSelectProps & SelectProps>;
2
+ import './styles/index.less';
3
+ import { BizSelectTypes } from './types';
4
+ export declare const classPrefix = "biz-select";
5
+ declare const BizSelect: React.FC<BizSelectTypes.Props>;
51
6
  export default BizSelect;
@@ -1,4 +1,4 @@
1
- var _excluded = ["value", "defaultValue", "isDialog", "placeholder", "fieldNames", "dropdownSize", "size", "createOption", "search", "create", "options", "name", "bordered", "className", "onChange"];
1
+ var _excluded = ["overlayWidth", "labelField", "keyField"];
2
2
 
3
3
  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; }
4
4
 
@@ -22,145 +22,191 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
22
22
 
23
23
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
24
 
25
- import { Input, Select } from 'antd';
26
- import React, { useEffect, useState } from 'react';
27
- import IconFont from '../components/iconFont';
28
- import { util } from '../utils';
29
- import './index.less';
30
- var Option = Select.Option;
25
+ import { Dropdown } from 'antd';
26
+ import React, { useEffect, useRef, useState } from 'react';
27
+ import SelectHandle from './handle';
28
+ import SelectOverlay from './overlay';
29
+ import './styles/index.less';
30
+ import _ from 'lodash';
31
+ export var classPrefix = 'biz-select';
31
32
 
32
33
  var BizSelect = function BizSelect(props) {
33
- var value = props.value,
34
- defaultValue = props.defaultValue,
35
- _props$isDialog = props.isDialog,
36
- isDialog = _props$isDialog === void 0 ? false : _props$isDialog,
37
- _props$placeholder = props.placeholder,
38
- placeholder = _props$placeholder === void 0 ? '请选择' : _props$placeholder,
39
- _props$fieldNames = props.fieldNames,
40
- fieldNames = _props$fieldNames === void 0 ? {
41
- label: 'label',
42
- value: 'value'
43
- } : _props$fieldNames,
44
- dropdownSize = props.dropdownSize,
45
- _props$size = props.size,
46
- size = _props$size === void 0 ? 'small' : _props$size,
47
- createOption = props.createOption,
48
- _props$search = props.search,
49
- search = _props$search === void 0 ? false : _props$search,
50
- _props$create = props.create,
51
- create = _props$create === void 0 ? false : _props$create,
52
- options = props.options,
53
- _props$name = props.name,
54
- name = _props$name === void 0 ? '' : _props$name,
55
- _props$bordered = props.bordered,
56
- bordered = _props$bordered === void 0 ? true : _props$bordered,
57
- className = props.className,
58
- _onChange = props.onChange,
34
+ var overlayWidth = props.overlayWidth,
35
+ labelField = props.labelField,
36
+ keyField = props.keyField,
59
37
  res = _objectWithoutProperties(props, _excluded);
60
38
 
61
- var _useState = useState(''),
39
+ var _useState = useState(),
62
40
  _useState2 = _slicedToArray(_useState, 2),
63
- searchValue = _useState2[0],
64
- setSearchValue = _useState2[1];
41
+ current = _useState2[0],
42
+ setCurrent = _useState2[1];
65
43
 
66
- var _useState3 = useState(options || []),
44
+ var _useState3 = useState(''),
67
45
  _useState4 = _slicedToArray(_useState3, 2),
68
- originalOption = _useState4[0],
69
- setOriginalOption = _useState4[1];
46
+ searchValue = _useState4[0],
47
+ setSearchValue = _useState4[1];
70
48
 
71
- var _useState5 = useState(options || []),
49
+ var _useState5 = useState(false),
72
50
  _useState6 = _slicedToArray(_useState5, 2),
73
- currentOption = _useState6[0],
74
- setCurrentOption = _useState6[1];
51
+ visible = _useState6[0],
52
+ setVisible = _useState6[1];
75
53
 
76
- var _useState7 = useState(),
54
+ var selectRef = useRef(null);
55
+ var boxRef = useRef(null);
56
+ var selectId = Math.random().toString();
57
+
58
+ var _useState7 = useState(200),
77
59
  _useState8 = _slicedToArray(_useState7, 2),
78
- selectValue = _useState8[0],
79
- setSelectValue = _useState8[1];
60
+ width = _useState8[0],
61
+ setWidth = _useState8[1];
80
62
 
81
63
  useEffect(function () {
82
- var data = defaultValue || value;
64
+ setWidth(boxRef.current.width || 200);
83
65
 
84
- if (data !== selectValue) {
85
- setSelectValue(function () {
86
- return data;
87
- });
66
+ if (props.defaultValue) {
67
+ setCurrent(getValue(props.defaultValue));
88
68
  }
89
- }, [defaultValue, value]);
90
- return /*#__PURE__*/React.createElement(Select, _objectSpread(_objectSpread({
91
- className: "".concat(size, " ").concat(className),
92
- value: selectValue,
93
- dropdownClassName: "biz-single-select-dropdown ".concat(dropdownSize ? dropdownSize : ''),
94
- placeholder: placeholder || "\u8BF7\u9009\u62E9".concat(name || '')
95
- }, res), {}, {
96
- bordered: bordered,
97
- suffixIcon: /*#__PURE__*/React.createElement(IconFont, {
98
- className: "biz-icon1",
99
- type: 'icon-xiangxia'
100
- }),
101
- dropdownRender: function dropdownRender(menu) {
102
- return /*#__PURE__*/React.createElement(React.Fragment, null, search && /*#__PURE__*/React.createElement(Input, {
103
- className: "biz-search-box",
104
- prefix: /*#__PURE__*/React.createElement(IconFont, {
105
- className: "biz-icon biz-input-icon",
106
- type: 'icon-sousuo'
107
- }),
108
- allowClear: {
109
- clearIcon: /*#__PURE__*/React.createElement(IconFont, {
110
- className: "biz-icon",
111
- type: 'icon-qingchu'
112
- })
113
- },
114
- value: searchValue,
115
- placeholder: "\u641C\u7D22".concat(name),
116
- onChange: function onChange(e) {
117
- var value = e.target.value;
118
- setSearchValue(function () {
119
- return value;
120
- });
121
- var reg = new RegExp(value);
122
- setCurrentOption(function () {
123
- return originalOption.filter(function (item) {
124
- return reg.test(item[fieldNames.label] || item);
125
- });
126
- });
127
- }
128
- }), create && /*#__PURE__*/React.createElement("div", {
129
- className: "biz-icon-add mb-12",
130
- onClick: function onClick() {
131
- return createOption && createOption();
132
- }
133
- }, /*#__PURE__*/React.createElement(IconFont, {
134
- className: "biz-icon",
135
- type: 'icon-tianjia1'
136
- }), /*#__PURE__*/React.createElement("span", {
137
- className: "biz-icon-text"
138
- }, "\u6DFB\u52A0".concat(name))), menu);
139
- },
140
- onChange: function onChange(value, option) {
141
- setSelectValue(function () {
142
- return value;
69
+
70
+ var handleClick = function handleClick(e) {
71
+ var clicked = selectRef.current.contains(e.target);
72
+ boxRef.current.create(clicked);
73
+
74
+ if (!clicked && !props.enableCreate) {
75
+ setSearchValue('');
76
+ }
77
+ };
78
+
79
+ window.addEventListener('click', handleClick);
80
+ return function () {
81
+ window.removeEventListener('click', handleClick);
82
+ };
83
+ }, []);
84
+ useEffect(function () {
85
+ if (!props.value) return;
86
+ setCurrent(getValue(props.value));
87
+ }, [props.value]);
88
+
89
+ var getValue = function getValue(data) {
90
+ if (props.multiple) {
91
+ var result = [];
92
+ data.forEach(function (item) {
93
+ result === null || result === void 0 ? void 0 : result.push(getCheckedData(item));
143
94
  });
144
- _onChange && _onChange(value, option.data);
95
+ return result;
96
+ } else {
97
+ return getCheckedData(data);
145
98
  }
146
- }), currentOption.map(function (item) {
147
- return /*#__PURE__*/React.createElement(Option, {
148
- value: item[fieldNames.value] || item,
149
- key: item[fieldNames.value] || item,
150
- disabled: item.disabled,
151
- data: item
152
- }, item.icon && /*#__PURE__*/React.createElement(IconFont, {
153
- style: {
154
- marginRight: '7px',
155
- fontSize: '16px'
156
- },
157
- type: item.icon
158
- }), /*#__PURE__*/React.createElement("span", {
159
- dangerouslySetInnerHTML: {
160
- __html: util.setHighLight(item[fieldNames.label] || item, searchValue)
99
+ };
100
+
101
+ var getCheckedData = function getCheckedData(data) {
102
+ var result = data;
103
+ props.options.forEach(function (option) {
104
+ if (props.type === 'group') {
105
+ option.children.forEach(function (child) {
106
+ if (data[keyField] === child[keyField]) {
107
+ result = child;
108
+ }
109
+ });
110
+ } else if (data[keyField] === option[keyField]) {
111
+ result = option;
161
112
  }
162
- }));
163
- }));
113
+ });
114
+ return result;
115
+ };
116
+
117
+ var onDelete = function onDelete(option) {
118
+ var data = _.cloneDeep(current);
119
+
120
+ data.forEach(function (item, index) {
121
+ if (item[keyField] === option[keyField]) {
122
+ data.splice(index, 1);
123
+ return;
124
+ }
125
+ });
126
+ setCurrent(data);
127
+ if (props.onChange) props.onChange(data);
128
+ };
129
+
130
+ var onCreate = function onCreate(val) {
131
+ var _newItem;
132
+
133
+ var data = _.cloneDeep(current) || [];
134
+ var newItem = (_newItem = {}, _defineProperty(_newItem, keyField, val), _defineProperty(_newItem, labelField, val), _newItem);
135
+ var flag = false;
136
+ current === null || current === void 0 ? void 0 : current.forEach(function (item) {
137
+ if (item[labelField] === val) {
138
+ flag = true;
139
+ return;
140
+ }
141
+ });
142
+ setSearchValue('');
143
+
144
+ if (!flag) {
145
+ newItem = getCheckedData(newItem);
146
+ data.push(newItem);
147
+ setCurrent(data);
148
+ if (props.onChange) props.onChange(data);
149
+ }
150
+ };
151
+
152
+ var onChange = function onChange(option) {
153
+ setCurrent(option);
154
+ setSearchValue('');
155
+
156
+ if (!props.multiple) {
157
+ setVisible(false);
158
+ }
159
+
160
+ if (props.onChange) props.onChange(option);
161
+ };
162
+
163
+ var onVisibleChange = function onVisibleChange(flag) {
164
+ setVisible(flag);
165
+ };
166
+
167
+ return /*#__PURE__*/React.createElement(Dropdown, {
168
+ overlay: /*#__PURE__*/React.createElement(SelectOverlay, _objectSpread(_objectSpread({}, res), {}, {
169
+ value: current,
170
+ labelField: labelField,
171
+ keyField: keyField,
172
+ searchValue: searchValue,
173
+ onChange: onChange
174
+ })),
175
+ disabled: props.disable,
176
+ destroyPopupOnHide: true,
177
+ overlayStyle: {
178
+ minWidth: 0,
179
+ width: overlayWidth || width
180
+ },
181
+ trigger: ['click'],
182
+ getPopupContainer: props.popupContainer || props.multiple ? function () {
183
+ return document.getElementById(selectId);
184
+ } : undefined,
185
+ visible: visible,
186
+ onVisibleChange: onVisibleChange
187
+ }, /*#__PURE__*/React.createElement("div", {
188
+ className: "".concat(classPrefix, "-handle ").concat(props.className ? props.className : ''),
189
+ ref: selectRef,
190
+ id: selectId
191
+ }, /*#__PURE__*/React.createElement(SelectHandle, {
192
+ ref: boxRef,
193
+ value: current,
194
+ labelField: labelField,
195
+ keyField: keyField,
196
+ disable: props.disable,
197
+ multiple: props.multiple,
198
+ enableCreate: props.enableCreate,
199
+ theme: props.theme,
200
+ size: props.size,
201
+ border: props.border,
202
+ onDelete: onDelete,
203
+ onSearch: setSearchValue,
204
+ onCreate: onCreate
205
+ })));
164
206
  };
165
207
 
208
+ BizSelect.defaultProps = {
209
+ labelField: 'label',
210
+ keyField: 'id'
211
+ };
166
212
  export default BizSelect;