@zgfe/business-lib 1.0.0-beta.4 → 1.0.1-beta.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 (248) 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 +32 -42
  4. package/es/analysisLayout/index.less +7 -5
  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 +167 -0
  15. package/es/attrConditions/components/valuesList.d.ts +10 -0
  16. package/es/attrConditions/components/valuesList.js +186 -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 +184 -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/{multipleSelector → attributeSelector}/demo/index.d.ts +1 -0
  32. package/es/attributeSelector/demo/{singleForm.js → index.js} +42 -44
  33. package/es/attributeSelector/index.d.ts +4 -109
  34. package/es/attributeSelector/index.js +85 -527
  35. package/es/attributeSelector/listPanel.d.ts +4 -0
  36. package/es/attributeSelector/listPanel.js +206 -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/bar.js +2 -1
  45. package/es/chart/demo/pie.js +1 -0
  46. package/es/chart/index.d.ts +2 -80
  47. package/es/chart/index.js +27 -24
  48. package/es/chart/styles/index.less +50 -0
  49. package/es/chart/types.d.ts +46 -0
  50. package/es/chart/{type.js → types.js} +0 -0
  51. package/es/chart/util/{chartConfig.d.ts → chartOptionConfig.d.ts} +4 -35
  52. package/es/chart/util/{chartConfig.js → chartOptionConfig.js} +46 -109
  53. package/es/chart/util/formatData.d.ts +3 -7
  54. package/es/chart/util/formatData.js +47 -26
  55. package/es/chart/util/formatOption.d.ts +2 -1
  56. package/es/chart/util/formatOption.js +22 -9
  57. package/es/chart/util/mapUtil.d.ts +3 -3
  58. package/es/chart/util/mapUtil.js +9 -19
  59. package/es/commonStyle/icon.less +130 -110
  60. package/es/commonStyle/select.less +1 -1
  61. package/es/commonStyle/theme.less +520 -470
  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 +9 -0
  76. package/es/dialog/components/itemNode.js +107 -0
  77. package/es/dialog/components/list.d.ts +3 -13
  78. package/es/dialog/components/list.js +8 -7
  79. package/es/dialog/components/selectToInput.d.ts +4 -41
  80. package/es/dialog/components/selectToInput.js +109 -54
  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 +60 -22
  90. package/es/dialog/demo/index2.js +14 -2
  91. package/es/dialog/index.d.ts +4 -65
  92. package/es/dialog/index.js +124 -108
  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 -25
  98. package/es/eventSelector/index.js +91 -338
  99. package/es/eventSelector/listPanel.d.ts +4 -0
  100. package/es/eventSelector/listPanel.js +195 -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 +12 -10
  107. package/es/index.js +7 -10
  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/searchInput/index.d.ts +8 -0
  115. package/es/searchInput/index.js +31 -0
  116. package/es/{attributeSelector/demo/multiForm.d.ts → select/demo/group.d.ts} +0 -0
  117. package/es/{globalAttributes/demo/index.js → select/demo/group.js} +49 -31
  118. package/es/select/demo/index.js +49 -21
  119. package/es/{attributeSelector/demo/single.d.ts → select/demo/multiple.d.ts} +0 -0
  120. package/es/{multipleSelector/demo/index.js → select/demo/multiple.js} +55 -12
  121. package/es/select/handle.d.ts +5 -0
  122. package/es/select/handle.js +119 -0
  123. package/es/select/index.d.ts +4 -41
  124. package/es/select/index.js +166 -121
  125. package/es/select/option.d.ts +4 -0
  126. package/es/select/option.js +59 -0
  127. package/es/select/overlay.d.ts +4 -0
  128. package/es/select/overlay.js +154 -0
  129. package/es/select/styles/handle.less +111 -0
  130. package/es/select/styles/index.less +99 -0
  131. package/es/select/types.d.ts +65 -0
  132. package/es/select/types.js +1 -0
  133. package/es/table/demo/data/table.js +1 -1
  134. package/es/table/demo/index.d.ts +1 -1
  135. package/es/table/demo/index.js +9 -8
  136. package/es/table/demo/index2.js +45 -3
  137. package/es/{attributeSelector/demo/singleForm.d.ts → table/demo/index3.d.ts} +0 -0
  138. package/es/table/demo/index3.js +218 -0
  139. package/es/table/index.d.ts +4 -30
  140. package/es/table/index.js +19 -17
  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 +3 -0
  149. package/es/targetConditionGroup/demo/group.js +127 -0
  150. package/es/targetConditionGroup/demo/index.js +41 -51
  151. package/es/targetConditionGroup/demo/styles/index.less +29 -0
  152. package/es/targetConditionGroup/index.d.ts +4 -51
  153. package/es/targetConditionGroup/index.js +187 -222
  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 -39
  162. package/es/targetSelector/index.js +102 -169
  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/{datePicker/demo/form.d.ts → userGroup/demo/group.d.ts} +0 -0
  171. package/es/{targetConditionGroup/demo/form.js → userGroup/demo/group.js} +68 -72
  172. package/es/userGroup/demo/index.d.ts +0 -1
  173. package/es/userGroup/demo/index.js +5 -62
  174. package/es/userGroup/index.d.ts +3 -77
  175. package/es/userGroup/index.js +58 -108
  176. package/es/userGroup/styles/index.less +20 -0
  177. package/es/userGroup/types.d.ts +15 -0
  178. package/es/userGroup/types.js +1 -0
  179. package/es/utils/ajax.js +5 -20
  180. package/es/utils/type.d.ts +42 -44
  181. package/es/utils/util.d.ts +1 -35
  182. package/es/utils/util.js +27 -57
  183. package/package.json +11 -4
  184. package/es/attributeSelector/demo/multi.js +0 -39
  185. package/es/attributeSelector/demo/multiForm.js +0 -64
  186. package/es/attributeSelector/demo/single.js +0 -43
  187. package/es/attributeSelector/group.d.ts +0 -31
  188. package/es/attributeSelector/group.js +0 -225
  189. package/es/attributeSelector/index.less +0 -172
  190. package/es/chart/index.less +0 -38
  191. package/es/chart/style/circle.svg +0 -4
  192. package/es/chart/type.d.ts +0 -22
  193. package/es/datePicker/data.d.ts +0 -9
  194. package/es/datePicker/data.js +0 -65
  195. package/es/datePicker/index.less +0 -364
  196. package/es/dialog/components/style/list.less +0 -59
  197. package/es/dialog/components/style/tab.less +0 -61
  198. package/es/dialog/style/index.less +0 -76
  199. package/es/eventSelector/demo/form.d.ts +0 -2
  200. package/es/eventSelector/demo/form.js +0 -89
  201. package/es/eventSelector/demo/nodata.d.ts +0 -2
  202. package/es/eventSelector/demo/nodata.js +0 -13
  203. package/es/eventSelector/index.less +0 -121
  204. package/es/eventSelector/type.d.ts +0 -41
  205. package/es/globalAttributes/demo/data/env.d.ts +0 -11
  206. package/es/globalAttributes/demo/data/env.js +0 -181
  207. package/es/globalAttributes/demo/data/event.d.ts +0 -237
  208. package/es/globalAttributes/demo/data/event.js +0 -3483
  209. package/es/globalAttributes/demo/data/user.d.ts +0 -22
  210. package/es/globalAttributes/demo/data/user.js +0 -218
  211. package/es/globalAttributes/index.d.ts +0 -46
  212. package/es/globalAttributes/index.js +0 -117
  213. package/es/multipleSelector/index.d.ts +0 -36
  214. package/es/multipleSelector/index.js +0 -103
  215. package/es/multipleSelector/index.less +0 -136
  216. package/es/table/demo/index.less +0 -8
  217. package/es/table/index.less +0 -139
  218. package/es/targetConditionGroup/components/conditionGroup.d.ts +0 -30
  219. package/es/targetConditionGroup/components/conditionGroup.js +0 -111
  220. package/es/targetConditionGroup/components/conditionItem.d.ts +0 -47
  221. package/es/targetConditionGroup/components/conditionItem.js +0 -259
  222. package/es/targetConditionGroup/components/style/group.less +0 -47
  223. package/es/targetConditionGroup/components/style/index.less +0 -16
  224. package/es/targetConditionGroup/demo/data/env.d.ts +0 -11
  225. package/es/targetConditionGroup/demo/data/env.js +0 -181
  226. package/es/targetConditionGroup/demo/data/event.d.ts +0 -237
  227. package/es/targetConditionGroup/demo/data/event.js +0 -3483
  228. package/es/targetConditionGroup/demo/data/user.d.ts +0 -22
  229. package/es/targetConditionGroup/demo/data/user.js +0 -218
  230. package/es/targetConditionGroup/demo/form.d.ts +0 -2
  231. package/es/targetConditionGroup/demo/item.d.ts +0 -2
  232. package/es/targetConditionGroup/demo/item.js +0 -5
  233. package/es/targetConditionGroup/index.less +0 -64
  234. package/es/targetConditionGroup/type.d.ts +0 -50
  235. package/es/targetSelector/components/BizCascadeBox.d.ts +0 -34
  236. package/es/targetSelector/components/BizCascadeBox.js +0 -213
  237. package/es/targetSelector/components/BizEventNameEditBox.d.ts +0 -20
  238. package/es/targetSelector/demo/form.d.ts +0 -2
  239. package/es/targetSelector/demo/form.js +0 -133
  240. package/es/targetSelector/demo/nodata.d.ts +0 -2
  241. package/es/targetSelector/demo/nodata.js +0 -13
  242. package/es/targetSelector/index.less +0 -28
  243. package/es/userGroup/demo/cluster.d.ts +0 -3
  244. package/es/userGroup/demo/cluster.js +0 -102
  245. package/es/userGroup/demo/index.less +0 -3
  246. package/es/userGroup/index.less +0 -2
  247. package/es/userGroup/userCluster.d.ts +0 -63
  248. package/es/userGroup/userCluster.js +0 -255
@@ -1,133 +0,0 @@
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 { Button, Form } from 'antd';
14
- import React, { useState } from 'react';
15
- import { BizTargetSelector, BizEventSelector } from '@zgfe/business-lib';
16
- var cascadeOptions = [{
17
- value: 1,
18
- label: '整体',
19
- children: [{
20
- value: 'xihu',
21
- label: 'West Lake'
22
- }, {
23
- value: 'xiasha',
24
- label: 'Xia Sha'
25
- }]
26
- }, {
27
- value: 2,
28
- label: '分组',
29
- children: [{
30
- value: 'xihu2',
31
- label: 'West Lake2'
32
- }, {
33
- value: 'xiasha2',
34
- label: 'Xia Sha2j'
35
- }, {
36
- value: 'xihu21',
37
- label: 'West Lake2h'
38
- }, {
39
- value: 'xiasha21',
40
- label: 'Xia Sha2'
41
- }, {
42
- value: 'xihu22',
43
- label: 'West Lake2m'
44
- }, {
45
- value: 'xiasha22',
46
- label: 'Xia Sha2n'
47
- }, {
48
- value: 'xihu27',
49
- label: 'West Lake2b'
50
- }, {
51
- value: 'xiasha82',
52
- label: 'Xia Sha2v'
53
- }, {
54
- value: 'xihu23',
55
- label: 'West Lake2c'
56
- }, {
57
- value: 'xiasha23',
58
- label: 'Xia Sha2z'
59
- }, {
60
- value: 'xihu24',
61
- label: 'West Lake22x'
62
- }, {
63
- value: 'xiasha24',
64
- label: 'Xia Sha2a'
65
- }]
66
- }];
67
-
68
- var EventDemo = function EventDemo() {
69
- var _Form$useForm = Form.useForm(),
70
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
71
- form = _Form$useForm2[0];
72
-
73
- var _useState = useState(''),
74
- _useState2 = _slicedToArray(_useState, 2),
75
- formData = _useState2[0],
76
- setFormData = _useState2[1];
77
-
78
- var onFinish = function onFinish(values) {
79
- setFormData(JSON.stringify(values));
80
- };
81
-
82
- var onFinishFailed = function onFinishFailed(errorInfo) {
83
- console.log('Failed:', errorInfo);
84
- };
85
-
86
- var handleAdd = function handleAdd(data) {
87
- console.log('add', data);
88
- };
89
-
90
- var handleDelete = function handleDelete(data) {
91
- console.log('delete', data);
92
- };
93
-
94
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form, {
95
- form: form,
96
- onFinish: onFinish,
97
- onFinishFailed: onFinishFailed,
98
- initialValues: {
99
- target: {
100
- aliasName: '别名',
101
- option: 'xiasha2'
102
- }
103
- }
104
- }, /*#__PURE__*/React.createElement(Form.Item, {
105
- label: "\u6307\u6807",
106
- name: "target"
107
- }, /*#__PURE__*/React.createElement(BizTargetSelector, {
108
- onAdd: handleAdd,
109
- onDelete: handleDelete
110
- }, /*#__PURE__*/React.createElement(BizEventSelector, {
111
- responseType: 'object',
112
- fieldNames: {
113
- label: 'label',
114
- value: 'value',
115
- groupLabel: 'label',
116
- groupValue: 'value',
117
- children: 'children'
118
- },
119
- options: cascadeOptions
120
- }))), /*#__PURE__*/React.createElement(Form.Item, {
121
- wrapperCol: {
122
- offset: 8,
123
- span: 16
124
- }
125
- }, /*#__PURE__*/React.createElement(Button, {
126
- type: "primary",
127
- htmlType: "submit"
128
- }, "Submit"))), /*#__PURE__*/React.createElement("p", null, formData));
129
- };
130
-
131
- export default (function () {
132
- return /*#__PURE__*/React.createElement(EventDemo, null);
133
- });
@@ -1,2 +0,0 @@
1
- declare const _default: () => JSX.Element;
2
- export default _default;
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { BizTargetSelector, BizEventSelector } from '@zgfe/business-lib';
3
- var optionGroup = [];
4
-
5
- var EventDemo = function EventDemo() {
6
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizTargetSelector, null, /*#__PURE__*/React.createElement(BizEventSelector, {
7
- options: optionGroup
8
- })));
9
- };
10
-
11
- export default (function () {
12
- return /*#__PURE__*/React.createElement(EventDemo, null);
13
- });
@@ -1,28 +0,0 @@
1
- @import '../commonStyle/icon.less';
2
- @import '../commonStyle/select.less';
3
-
4
- .biz-placeholder {
5
- color: #9797af;
6
- }
7
-
8
- .biz-menu-item-edit {
9
- width: 100%;
10
- height: 100%;
11
- .ant-dropdown-menu-item-icon {
12
- margin-right: 15px;
13
- font-size: @iconSize;
14
- }
15
- }
16
- .biz-target-container {
17
- .biz-select-cotainer {
18
- margin-bottom: 0;
19
- padding: 0;
20
- border: none;
21
- }
22
- .ant-form {
23
- flex: 1;
24
- .ant-form-item {
25
- margin-bottom: 0;
26
- }
27
- }
28
- }
@@ -1,3 +0,0 @@
1
- import './index.less';
2
- declare const _default: () => JSX.Element;
3
- export default _default;
@@ -1,102 +0,0 @@
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 React, { useState } from 'react';
14
- import { BizUserCluster } from '@zgfe/business-lib';
15
- import './index.less';
16
- import { Button, Form } from 'antd';
17
- var groupOptions = [{
18
- id: 1,
19
- name: '用户群1'
20
- }, {
21
- id: 2,
22
- name: '用户群2'
23
- }, {
24
- id: 3,
25
- name: '用户群3'
26
- }];
27
- var groupOptions2 = [{
28
- id: 1,
29
- name: '用户群1'
30
- }, {
31
- id: 2,
32
- name: '用户群2'
33
- }, {
34
- id: 3,
35
- name: '用户群3'
36
- }];
37
-
38
- var UserClusterDemo = function UserClusterDemo() {
39
- var _Form$useForm = Form.useForm(),
40
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
41
- form = _Form$useForm2[0];
42
-
43
- var _useState = useState(),
44
- _useState2 = _slicedToArray(_useState, 2),
45
- userCluster = _useState2[0],
46
- setUserCluster = _useState2[1];
47
-
48
- var onFinish = function onFinish(values) {
49
- setUserCluster(JSON.stringify(values));
50
- };
51
-
52
- var onFinishFailed = function onFinishFailed(errorInfo) {
53
- console.log('Failed:', errorInfo);
54
- };
55
-
56
- var handleChange = function handleChange(selectedGroups, actualGroups) {
57
- console.log(selectedGroups, actualGroups);
58
- };
59
-
60
- return /*#__PURE__*/React.createElement("div", {
61
- className: "biz-user-group-demo"
62
- }, /*#__PURE__*/React.createElement(Form, {
63
- form: form,
64
- onFinish: onFinish,
65
- onFinishFailed: onFinishFailed,
66
- initialValues: {
67
- cluster: [1, 2],
68
- cluster2: [{
69
- id: 3
70
- }, {
71
- id: 4
72
- }]
73
- }
74
- }, /*#__PURE__*/React.createElement(Form.Item, {
75
- label: "\u7528\u6237\u7FA4",
76
- name: "cluster"
77
- }, /*#__PURE__*/React.createElement(BizUserCluster, {
78
- options: groupOptions,
79
- maxUserGroup: 6,
80
- onChange: handleChange
81
- })), /*#__PURE__*/React.createElement(Form.Item, {
82
- label: "\u7528\u6237\u7FA42",
83
- name: "cluster2"
84
- }, /*#__PURE__*/React.createElement(BizUserCluster, {
85
- options: groupOptions2,
86
- responseType: 'object',
87
- maxUserGroup: 2,
88
- onChange: handleChange
89
- })), /*#__PURE__*/React.createElement(Form.Item, {
90
- wrapperCol: {
91
- offset: 8,
92
- span: 16
93
- }
94
- }, /*#__PURE__*/React.createElement(Button, {
95
- type: "primary",
96
- htmlType: "submit"
97
- }, "Submit"))), /*#__PURE__*/React.createElement("p", null, "\u5DF2\u9009\u7528\u6237\u7FA4\u4FE1\u606F\uFF1A", userCluster));
98
- };
99
-
100
- export default (function () {
101
- return /*#__PURE__*/React.createElement(UserClusterDemo, null);
102
- });
@@ -1,3 +0,0 @@
1
- .biz-user-group-demo {
2
- width: 500px;
3
- }
@@ -1,2 +0,0 @@
1
- @import '../commonStyle/icon.less';
2
- @import '../commonStyle/select.less';
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- interface UserClusterProps {
3
- /**
4
- * @description 若组件是表单选项,value就是form的initialValues,也是组件的默认选项
5
- * @description.zh-CN
6
- * @default []
7
- */
8
- value?: Array<ValueType>;
9
- /**
10
- * @description 默认值
11
- * @default []
12
- */
13
- defaultValue?: Array<ValueType>;
14
- /**
15
- * @description 返回数据类型
16
- * @description.zh-CN id | object
17
- * @default id
18
- */
19
- responseType?: string;
20
- /**
21
- * @description 自定义节点 label、value 的字段
22
- * @description.zh-CN
23
- * @default -
24
- */
25
- fieldNames?: {
26
- label: string;
27
- value: string;
28
- };
29
- /**
30
- * @description 数据化配置选项内容
31
- * @description.zh-CN
32
- * @default { label: 'name', value: 'id' }
33
- */
34
- options: Option[];
35
- /**
36
- * @description 选中 option 时,调用此函数
37
- * @description.zh-CN
38
- * @default -
39
- */
40
- onChange: (valueObject: Option[] | (string | number)[], value: Option[] | (string | number)[]) => void;
41
- /**
42
- * @description 最多个数
43
- * @description.zh-CN
44
- * @default 3
45
- */
46
- maxUserGroup?: number;
47
- /**
48
- * @description 选择框默认文本
49
- * @description.zh-CN
50
- * @default 请选择
51
- */
52
- placeholder?: string;
53
- }
54
- interface Option {
55
- key?: string | number;
56
- disabled?: boolean | null;
57
- [prop: string]: any;
58
- }
59
- interface ValueType {
60
- [prop: string]: any;
61
- }
62
- declare const BizUserCluster: React.FC<UserClusterProps>;
63
- export default BizUserCluster;
@@ -1,255 +0,0 @@
1
- var _excluded = ["key", "disabled"];
2
-
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
- 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."); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
12
-
13
- 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; }
14
-
15
- 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
-
17
- 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; }
18
-
19
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
-
21
- 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); }
22
-
23
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
24
-
25
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
26
-
27
- 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."); }
28
-
29
- 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); }
30
-
31
- 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; }
32
-
33
- 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; }
34
-
35
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
-
37
- import { BizUserGroup } from '..';
38
- import IconFont from '../components/iconFont';
39
- import React, { useEffect, useState } from 'react';
40
-
41
- var BizUserCluster = function BizUserCluster(props) {
42
- var _props$defaultValue = props.defaultValue,
43
- defaultValue = _props$defaultValue === void 0 ? [] : _props$defaultValue,
44
- _props$value = props.value,
45
- value = _props$value === void 0 ? [] : _props$value,
46
- _props$responseType = props.responseType,
47
- responseType = _props$responseType === void 0 ? 'id' : _props$responseType,
48
- _props$fieldNames = props.fieldNames,
49
- fieldNames = _props$fieldNames === void 0 ? {
50
- label: 'name',
51
- value: 'id'
52
- } : _props$fieldNames,
53
- options = props.options,
54
- handleChange = props.onChange,
55
- _props$maxUserGroup = props.maxUserGroup,
56
- maxUserGroup = _props$maxUserGroup === void 0 ? 3 : _props$maxUserGroup,
57
- _props$placeholder = props.placeholder,
58
- placeholder = _props$placeholder === void 0 ? '请选择' : _props$placeholder;
59
-
60
- var _useState = useState([]),
61
- _useState2 = _slicedToArray(_useState, 2),
62
- userGroups = _useState2[0],
63
- setUserGroups = _useState2[1];
64
-
65
- var _useState3 = useState(options),
66
- _useState4 = _slicedToArray(_useState3, 2),
67
- userOptions = _useState4[0],
68
- setUserOptions = _useState4[1];
69
-
70
- var _useState5 = useState([]),
71
- _useState6 = _slicedToArray(_useState5, 2),
72
- selectIds = _useState6[0],
73
- setSelectIds = _useState6[1];
74
-
75
- var _useState7 = useState(false),
76
- _useState8 = _slicedToArray(_useState7, 2),
77
- isChange = _useState8[0],
78
- setIsChange = _useState8[1]; // 获取唯一key值
79
-
80
-
81
- var getUniqueKey = function getUniqueKey() {
82
- return Math.random().toString();
83
- }; // 初始化添加key
84
-
85
-
86
- useEffect(function () {
87
- var inValue = defaultValue.length ? defaultValue : value;
88
- var groups = [];
89
- var ids = [];
90
-
91
- var _iterator = _createForOfIteratorHelper(inValue),
92
- _step;
93
-
94
- try {
95
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
96
- var _value = _step.value;
97
- var vid = _typeof(_value) === 'object' ? _value[fieldNames.value] : _value;
98
- ids.push(vid);
99
-
100
- var _iterator2 = _createForOfIteratorHelper(options),
101
- _step2;
102
-
103
- try {
104
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
105
- var option = _step2.value;
106
-
107
- if (vid == option[fieldNames.value]) {
108
- var _key = getUniqueKey();
109
-
110
- groups.push(_objectSpread({
111
- key: _key
112
- }, option));
113
- break;
114
- }
115
- }
116
- } catch (err) {
117
- _iterator2.e(err);
118
- } finally {
119
- _iterator2.f();
120
- }
121
- }
122
- } catch (err) {
123
- _iterator.e(err);
124
- } finally {
125
- _iterator.f();
126
- }
127
-
128
- if (!defaultValue.length && !value.length) {
129
- var key = getUniqueKey();
130
- groups = [{
131
- key: key
132
- }];
133
- }
134
-
135
- setSelectIds(ids);
136
- setUserGroups(groups);
137
- }, []); // 数据响应
138
-
139
- useEffect(function () {
140
- if (!isChange) {
141
- return;
142
- } // 去掉bizGroupsKey
143
-
144
-
145
- var actualGroups = []; // 已选择的id数组
146
-
147
- var selectedGroups = [];
148
-
149
- var _iterator3 = _createForOfIteratorHelper(userGroups),
150
- _step3;
151
-
152
- try {
153
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
154
- var group = _step3.value;
155
-
156
- var key = group.key,
157
- disabled = group.disabled,
158
- res = _objectWithoutProperties(group, _excluded);
159
-
160
- var keys = Object.keys(res);
161
-
162
- if (keys.length > 0) {
163
- actualGroups.push(res);
164
- selectedGroups.push(group[fieldNames.value]);
165
- }
166
- }
167
- } catch (err) {
168
- _iterator3.e(err);
169
- } finally {
170
- _iterator3.f();
171
- }
172
-
173
- setSelectIds(function () {
174
- return [].concat(selectedGroups);
175
- });
176
-
177
- if (responseType === 'id') {
178
- handleChange(selectedGroups, actualGroups);
179
- } else {
180
- handleChange(actualGroups, selectedGroups);
181
- }
182
- }, [userGroups]); // 用户群更改操作
183
-
184
- var _onChange = function _onChange(option, value, index) {
185
- var changeGroups = _toConsumableArray(userGroups);
186
-
187
- var data = {};
188
-
189
- if (_typeof(option) === 'object') {
190
- data = _objectSpread({}, option);
191
- }
192
-
193
- if (_typeof(value) === 'object') {
194
- data = _objectSpread({}, value);
195
- }
196
-
197
- changeGroups[index] = _objectSpread(_objectSpread({}, changeGroups[index]), data);
198
- setUserGroups(function () {
199
- return _toConsumableArray(changeGroups);
200
- });
201
- setIsChange(true);
202
- }; // 添加用户群
203
-
204
-
205
- var addUserGroup = function addUserGroup() {
206
- var key = getUniqueKey();
207
- setUserGroups(function (groups) {
208
- return [].concat(_toConsumableArray(groups), [{
209
- key: key
210
- }]);
211
- });
212
- setIsChange(false);
213
- }; // 删除用户群
214
-
215
-
216
- var _onDelete = function _onDelete(index) {
217
- setUserGroups(function (groups) {
218
- groups.splice(index, 1);
219
- return _toConsumableArray(groups);
220
- });
221
- setIsChange(true);
222
- };
223
-
224
- return /*#__PURE__*/React.createElement("div", {
225
- className: "biz-user-cluster-container"
226
- }, userGroups.map(function (item, index) {
227
- return /*#__PURE__*/React.createElement("div", {
228
- className: "biz-user-cluster-item",
229
- key: item.key
230
- }, /*#__PURE__*/React.createElement(BizUserGroup, {
231
- defaultValue: item ? item[fieldNames.value] : null,
232
- options: options,
233
- fieldNames: fieldNames,
234
- onDelete: function onDelete() {
235
- return _onDelete(index);
236
- },
237
- onChange: _onChange,
238
- showDeleteIcon: userGroups.length > 1,
239
- placeholder: placeholder,
240
- disabled: selectIds,
241
- index: index,
242
- responseType: 'object'
243
- }));
244
- }), userGroups.length < maxUserGroup && /*#__PURE__*/React.createElement("div", {
245
- className: "biz-icon-add",
246
- onClick: addUserGroup
247
- }, /*#__PURE__*/React.createElement(IconFont, {
248
- className: "biz-icon",
249
- type: 'icon-tianjia1'
250
- }), /*#__PURE__*/React.createElement("span", {
251
- className: "biz-icon-text"
252
- }, "\u6DFB\u52A0\u7528\u6237\u7FA4")));
253
- };
254
-
255
- export default BizUserCluster;