@zgfe/business-lib 1.0.8 → 1.0.11

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 (80) hide show
  1. package/es/addToPanel/components/addPanel.d.ts +7 -0
  2. package/es/addToPanel/components/addPanel.js +101 -0
  3. package/es/addToPanel/components/radioGroup.d.ts +7 -0
  4. package/es/addToPanel/components/radioGroup.js +29 -0
  5. package/es/addToPanel/components/styleList.d.ts +5 -0
  6. package/es/{dialog/components/tab.js → addToPanel/components/styleList.js} +9 -6
  7. package/es/{dialog/demo/index2.d.ts → addToPanel/demo/edit.d.ts} +0 -0
  8. package/es/{dialog/components/list.js → addToPanel/demo/edit.js} +63 -44
  9. package/es/{dialog/demo/index3.d.ts → addToPanel/demo/index.d.ts} +0 -0
  10. package/es/addToPanel/demo/index.js +78 -0
  11. package/es/addToPanel/index.d.ts +6 -0
  12. package/es/addToPanel/index.js +253 -0
  13. package/es/addToPanel/styles/addPanel.less +25 -0
  14. package/es/addToPanel/styles/index.less +6 -0
  15. package/es/{dialog/components/styles/tab.less → addToPanel/styles/style.less} +7 -2
  16. package/es/addToPanel/types.d.ts +56 -0
  17. package/es/addToPanel/types.js +1 -0
  18. package/es/addToScene/addGroup.d.ts +11 -0
  19. package/es/addToScene/addGroup.js +34 -0
  20. package/es/addToScene/demo/index.d.ts +2 -0
  21. package/es/addToScene/demo/index.js +34 -0
  22. package/es/addToScene/index.d.ts +6 -0
  23. package/es/addToScene/index.js +192 -0
  24. package/es/addToScene/styles/index.less +23 -0
  25. package/es/addToScene/types.d.ts +29 -0
  26. package/es/addToScene/types.js +1 -0
  27. package/es/analysisLayout/demo/index.d.ts +1 -0
  28. package/es/analysisLayout/demo/index.js +7 -1
  29. package/es/analysisLayout/index.d.ts +1 -0
  30. package/es/analysisLayout/index.js +2 -1
  31. package/es/analysisLayout/index.less +3 -2
  32. package/es/assets/styles/chunks.less +19 -3
  33. package/es/assets/styles/resetAntd.less +61 -20
  34. package/es/assets/styles/variable.less +8 -1
  35. package/es/assets/theme.d.ts +3 -0
  36. package/es/assets/theme.js +4 -1
  37. package/es/attrConditions/components/stringList.js +4 -3
  38. package/es/attributeSelector/demo/index.js +1 -1
  39. package/es/attributeSelector/index.js +12 -2
  40. package/es/attributeSelector/styles/index.less +2 -1
  41. package/es/chart/demo/index.js +36 -4
  42. package/es/chart/index.d.ts +1 -1
  43. package/es/chart/index.js +16 -5
  44. package/es/config.d.ts +15 -0
  45. package/es/config.js +8 -0
  46. package/es/constants/apis.d.ts +8 -0
  47. package/es/constants/apis.js +8 -0
  48. package/es/datePicker/styles/index.less +4 -0
  49. package/es/dialog/demo/index.d.ts +0 -29
  50. package/es/dialog/demo/index.js +6 -130
  51. package/es/dialog/index.d.ts +1 -2
  52. package/es/dialog/index.js +15 -183
  53. package/es/dialog/types.d.ts +2 -74
  54. package/es/eventSelector/listPanel.js +8 -0
  55. package/es/eventSelector/styles/index.less +11 -5
  56. package/es/index.d.ts +4 -1
  57. package/es/index.js +4 -1
  58. package/es/select/index.js +4 -2
  59. package/es/select/overlay.js +3 -1
  60. package/es/select/styles/handle.less +2 -0
  61. package/es/select/styles/index.less +0 -3
  62. package/es/select/types.d.ts +2 -0
  63. package/es/targetSelector/styles/index.less +3 -1
  64. package/es/userGroup/demo/index.js +4 -1
  65. package/es/userGroup/index.js +1 -1
  66. package/es/utils/ajax.d.ts +33 -7
  67. package/es/utils/ajax.js +212 -111
  68. package/package.json +4 -3
  69. package/es/dialog/components/itemNode.d.ts +0 -10
  70. package/es/dialog/components/itemNode.js +0 -109
  71. package/es/dialog/components/list.d.ts +0 -5
  72. package/es/dialog/components/selectToInput.d.ts +0 -6
  73. package/es/dialog/components/selectToInput.js +0 -175
  74. package/es/dialog/components/styles/handle.less +0 -39
  75. package/es/dialog/components/styles/list.less +0 -60
  76. package/es/dialog/components/tab.d.ts +0 -5
  77. package/es/dialog/data/data.d.ts +0 -20
  78. package/es/dialog/data/data.js +0 -73
  79. package/es/dialog/demo/index2.js +0 -109
  80. package/es/dialog/demo/index3.js +0 -61
package/es/utils/ajax.js CHANGED
@@ -1,124 +1,225 @@
1
- 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; }
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
2
 
3
- 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; }
3
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
 
5
- 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; }
5
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
6
 
7
- import axios from 'axios';
8
- var history = {
9
- option: [{
10
- resolve: null,
11
- reject: null
12
- }]
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+
9
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
+
11
+ import { extend } from 'umi-request';
12
+ import { notification } from 'antd';
13
+ import { globalConfig } from '../config';
14
+ var ResponseStatus;
15
+
16
+ (function (ResponseStatus) {
17
+ ResponseStatus[ResponseStatus["success"] = 200] = "success";
18
+ ResponseStatus[ResponseStatus["exists"] = 201] = "exists";
19
+ ResponseStatus[ResponseStatus["fail"] = 500] = "fail";
20
+ ResponseStatus[ResponseStatus["sysNotInit"] = 501] = "sysNotInit";
21
+ ResponseStatus[ResponseStatus["sysInited"] = 502] = "sysInited";
22
+ ResponseStatus[ResponseStatus["notLoggin"] = 503] = "notLoggin";
23
+ ResponseStatus[ResponseStatus["paramError"] = 504] = "paramError";
24
+ ResponseStatus[ResponseStatus["success2"] = 106000] = "success2";
25
+ ResponseStatus[ResponseStatus["fail2"] = 106001] = "fail2";
26
+ ResponseStatus[ResponseStatus["paramError2"] = 106002] = "paramError2";
27
+ ResponseStatus[ResponseStatus["paramError3"] = 106003] = "paramError3";
28
+ })(ResponseStatus || (ResponseStatus = {}));
29
+
30
+ export var ApiResult = /*#__PURE__*/_createClass(function ApiResult(code, data, message) {
31
+ _classCallCheck(this, ApiResult);
32
+
33
+ this.code = void 0;
34
+ this.data = void 0;
35
+ this.msg = void 0;
36
+ this.code = code;
37
+ this.data = data;
38
+ this.msg = message;
39
+ });
40
+ var codeMessage = {
41
+ 200: '服务器成功返回请求的数据。',
42
+ 201: '新建或修改数据成功。',
43
+ 202: '一个请求已经进入后台排队(异步任务)。',
44
+ 204: '删除数据成功。',
45
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
46
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
47
+ 403: '用户得到授权,但是访问是被禁止的。',
48
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
49
+ 406: '请求的格式不可得。',
50
+ 410: '请求的资源被永久删除,且不会再得到的。',
51
+ 422: '当创建一个对象时,发生一个验证错误。',
52
+ 500: '服务器发生错误,请检查服务器。',
53
+ 502: '网关错误。',
54
+ 503: '服务不可用,服务器暂时过载或维护。',
55
+ 504: '网关超时。'
13
56
  };
14
- var timer = {
15
- url: {
16
- id: 0,
17
- cancel: null,
18
- reject: function reject() {}
57
+
58
+ var errorHandler = function errorHandler(error) {
59
+ var response = error.response;
60
+
61
+ if (response && response.status) {
62
+ var errorText = codeMessage[response.status] || response.statusText;
63
+ var status = response.status,
64
+ url = response.url;
65
+ notification.error({
66
+ message: "\u8BF7\u6C42\u9519\u8BEF ".concat(status, ": ").concat(url),
67
+ description: errorText
68
+ });
69
+ } else if (!response) {
70
+ notification.error({
71
+ description: '您的网络发生异常,无法连接服务器',
72
+ message: '网络异常'
73
+ });
19
74
  }
20
- };
21
- var CancelToken = axios.CancelToken;
22
-
23
- var _request = function _request(ajax) {
24
- return function () {
25
- var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
26
- url: '',
27
- responseOnce: false,
28
- unique: false,
29
- delay: 0
30
- };
31
- return new Promise(function (resolve, reject) {
32
- var key = JSON.stringify(option);
33
- var timerKey = option.url + '_' + (Object.prototype.toString.call(option.unique) === '[object String]' ? option.unique : '');
34
-
35
- if (option.unique && timer[timerKey]) {
36
- clearTimeout(timer[timerKey].id);
37
-
38
- if (timer[timerKey].cancel) {
39
- timer[timerKey].cancel();
40
- } else {
41
- var cancel = new Error('cancel: before request');
42
- cancel.__CANCEL__ = true;
43
- timer[timerKey].reject(cancel);
44
- }
45
75
 
46
- delete timer[timerKey];
47
- if (history[key]) delete history[key];
48
- }
76
+ return response;
77
+ };
49
78
 
50
- if (!history[key]) {
51
- history[key] = [{
52
- resolve: resolve,
53
- reject: reject
54
- }];
79
+ function responseErrorHandler(url, apiResult) {
80
+ if (/\.jsp/.test(url)) {
81
+ return apiResult;
82
+ }
55
83
 
56
- var request = function request() {
57
- ajax(option).then(function (res) {
58
- history[key].forEach(function (item) {
59
- item.resolve(res);
60
- });
61
- }).catch(function (err) {
62
- history[key].forEach(function (item) {
63
- item.reject(err);
64
- });
65
- }).finally(function () {
66
- delete timer[timerKey];
67
- delete history[key];
68
- });
69
- };
70
-
71
- if (option.unique) {
72
- timer[timerKey] = {
73
- id: 0,
74
- option: option,
75
- cancel: null,
76
- reject: reject
77
- };
78
- timer[timerKey].id = setTimeout(function () {
79
- option.cancelToken = new CancelToken(function (c) {
80
- if (timer[timerKey]) {
81
- timer[timerKey].cancel = c;
82
- }
83
- });
84
- request();
85
- }, option.delay || 0);
86
- } else {
87
- request();
88
- }
89
- } else if (option.responseOnce) {
90
- var _cancel = new Error('cancel: before request');
91
-
92
- _cancel.__CANCEL__ = true;
93
- reject(_cancel);
94
- } else {
95
- history[key].push({
96
- resolve: resolve,
97
- reject: reject
98
- });
99
- }
84
+ if (!apiResult.code) {
85
+ notification.error({
86
+ message: "\u63A5\u53E3\u54CD\u5E94\u7ED3\u6784\u5F02\u5E38"
100
87
  });
101
- };
102
- };
88
+ throw new Error('接口响应结构异常,缺少code');
89
+ }
90
+
91
+ var flag = false;
92
+ var message = '接口请求失败';
93
+
94
+ switch (apiResult.code) {
95
+ case ResponseStatus.sysNotInit:
96
+ message = '系统未初始化';
97
+ break;
98
+
99
+ case ResponseStatus.sysInited:
100
+ message = '系统已初始化';
101
+ break;
102
+
103
+ case ResponseStatus.notLoggin:
104
+ message = '账户未登录或登录已失效';
105
+ break;
106
+
107
+ case ResponseStatus.paramError:
108
+ message = '请求参数错误';
109
+ break;
103
110
 
104
- var _ajax = function _ajax(option) {
105
- var optionData = _objectSpread({
106
- method: 'post',
107
- url: '',
108
- data: null,
109
- withCredentials: true
110
- }, option);
111
-
112
- return new Promise(function (resolve, reject) {
113
- axios(optionData).then(function (res) {
114
- resolve(res.data);
115
- }).catch(function (error) {
116
- if (axios.isCancel(error)) return;
117
- reject(error);
111
+ case ResponseStatus.paramError2:
112
+ message = '请求参数缺失';
113
+ break;
114
+
115
+ case ResponseStatus.paramError3:
116
+ message = '请求参数校验异常';
117
+ break;
118
+
119
+ case ResponseStatus.exists:
120
+ message = '数据已存在';
121
+ break;
122
+
123
+ case ResponseStatus.success:
124
+ flag = true;
125
+ break;
126
+
127
+ case ResponseStatus.success2:
128
+ flag = true;
129
+ break;
130
+
131
+ case ResponseStatus.fail:
132
+ message = apiResult.msg || '接口发生未知错误';
133
+ break;
134
+
135
+ case ResponseStatus.fail2:
136
+ message = apiResult.msg || '接口发生未知错误';
137
+ break;
138
+
139
+ default:
140
+ throw new Error("\u65E0\u6CD5\u8BC6\u522B\u7684\u8BF7\u6C42\u54CD\u5E94\u7801: ".concat(apiResult.code));
141
+ }
142
+
143
+ if (!flag) {
144
+ message = apiResult.msg || message;
145
+ notification.error({
146
+ message: "\u8BF7\u6C42\u9519\u8BEF",
147
+ description: message
118
148
  });
119
- });
120
- };
149
+ throw new Error(message);
150
+ }
151
+
152
+ return apiResult;
153
+ }
154
+
155
+ var req = extend({
156
+ errorHandler: errorHandler,
157
+ credentials: 'include'
158
+ });
121
159
 
122
- var ajax = _request(_ajax);
160
+ function request(_x, _x2) {
161
+ return _request.apply(this, arguments);
162
+ }
163
+
164
+ function _request() {
165
+ _request = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(url, options) {
166
+ var _globalConfig$request, _globalConfig$request2, err, option, list, optionsWrapper, responseWrapper, params, res;
167
+
168
+ return regeneratorRuntime.wrap(function _callee$(_context) {
169
+ while (1) {
170
+ switch (_context.prev = _context.next) {
171
+ case 0:
172
+ _context.prev = 0;
173
+
174
+ if (!/{{\S*}}/.test(url)) {
175
+ _context.next = 8;
176
+ break;
177
+ }
178
+
179
+ if (!(!options || !options.params)) {
180
+ _context.next = 5;
181
+ break;
182
+ }
183
+
184
+ err = new Error("\u5E26\u53C2URL(".concat(url, ")\u8BF7\u6C42\u4E2D\uFF0C\u7F3A\u5C11params\u53C2\u6570"));
185
+ throw err;
186
+
187
+ case 5:
188
+ option = options;
189
+ list = url.match(/{{\S*?}}/g) || [];
190
+ list.forEach(function (param) {
191
+ var key = param.replace(/[{|}]/g, '');
192
+ url = url.replace(param, option.params[key]);
193
+ delete option.params[key];
194
+ });
195
+
196
+ case 8:
197
+ optionsWrapper = (options === null || options === void 0 ? void 0 : options.optionsWrapper) || ((_globalConfig$request = globalConfig.request) === null || _globalConfig$request === void 0 ? void 0 : _globalConfig$request.optionsWrapper);
198
+ responseWrapper = (options === null || options === void 0 ? void 0 : options.responseWrapper) || ((_globalConfig$request2 = globalConfig.request) === null || _globalConfig$request2 === void 0 ? void 0 : _globalConfig$request2.responseWrapper);
199
+ params = optionsWrapper ? optionsWrapper(url, options) : {
200
+ url: url,
201
+ options: options
202
+ };
203
+ _context.next = 13;
204
+ return req(params.url, params.options);
205
+
206
+ case 13:
207
+ res = _context.sent;
208
+ return _context.abrupt("return", responseWrapper ? responseWrapper(url, responseErrorHandler(url, res)) : responseErrorHandler(url, res));
209
+
210
+ case 17:
211
+ _context.prev = 17;
212
+ _context.t0 = _context["catch"](0);
213
+ return _context.abrupt("return", null);
214
+
215
+ case 20:
216
+ case "end":
217
+ return _context.stop();
218
+ }
219
+ }
220
+ }, _callee, null, [[0, 17]]);
221
+ }));
222
+ return _request.apply(this, arguments);
223
+ }
123
224
 
124
- export default ajax;
225
+ export default request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -36,7 +36,8 @@
36
36
  "echarts": "^5.3.2",
37
37
  "echarts-for-react": "^3.0.2",
38
38
  "lerna": "^4.0.0",
39
- "react-infinite-scroll-component": "^6.1.0"
39
+ "react-infinite-scroll-component": "^6.1.0",
40
+ "umi-request": "^1.4.0"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "@types/lodash": "^4.14.182",
@@ -58,5 +59,5 @@
58
59
  "prettier": "^2.2.1",
59
60
  "yorkie": "^2.0.0"
60
61
  },
61
- "gitHead": "6964ab872826830d166d54905639a53303c2f04e"
62
+ "gitHead": "7b78a43e36641ad5c7a3bea015f4b0d5fd0e0fc4"
62
63
  }
@@ -1,10 +0,0 @@
1
- import { FormItemProps } from 'antd';
2
- import React from 'react';
3
- import { DialogTypes } from '../types';
4
- declare const ItemNode: React.FC<{
5
- value?: any;
6
- field: DialogTypes.FieldProps & FormItemProps;
7
- fieldNames?: DialogTypes.FieldOption;
8
- onChange?: (value: any) => void;
9
- }>;
10
- export default ItemNode;
@@ -1,109 +0,0 @@
1
- import { Input, Radio, Space } from 'antd';
2
- import React from 'react';
3
- import { classPrefix } from '..';
4
- import IconFont from '../../icon/iconFont';
5
- import BizSelect from '../../select';
6
- import BizList from './list';
7
- import BizSelectToInput from './selectToInput';
8
- import BizTab from './tab';
9
-
10
- var ItemNode = function ItemNode(props) {
11
- var _props$field = props.field,
12
- type = _props$field.type,
13
- label = _props$field.label,
14
- options = _props$field.options,
15
- placeholder = _props$field.placeholder,
16
- extendName = _props$field.extendName,
17
- direction = _props$field.direction,
18
- multiple = _props$field.multiple,
19
- enableSearch = _props$field.enableSearch,
20
- selectType = _props$field.selectType,
21
- overlayWidth = _props$field.overlayWidth,
22
- extra = _props$field.extra,
23
- fieldNames = props.fieldNames;
24
-
25
- var onChange = function onChange(data) {
26
- if (props.onChange) props.onChange(data);
27
- if (props.field.onChange) props.field.onChange(data);
28
- };
29
-
30
- if (type === 'input') {
31
- return /*#__PURE__*/React.createElement(Input, {
32
- defaultValue: props.value,
33
- className: "".concat(classPrefix, "-input"),
34
- placeholder: placeholder || "\u8BF7\u8F93\u5165".concat(label),
35
- autoComplete: "off",
36
- allowClear: {
37
- clearIcon: /*#__PURE__*/React.createElement(IconFont, {
38
- className: "biz-icon",
39
- type: 'qingchu'
40
- })
41
- },
42
- onChange: onChange
43
- });
44
- } else if (type === 'password') {
45
- return /*#__PURE__*/React.createElement(Input.Password, {
46
- className: "".concat(classPrefix, "-input"),
47
- defaultValue: props.value,
48
- placeholder: placeholder || "\u8BF7\u8F93\u5165".concat(label),
49
- onChange: onChange
50
- });
51
- } else if (type === 'select') {
52
- return /*#__PURE__*/React.createElement(BizSelect, {
53
- className: "".concat(classPrefix, "-select"),
54
- options: options || [],
55
- defaultValue: props.value,
56
- keyField: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value,
57
- labelField: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label,
58
- multiple: multiple,
59
- enableSearch: enableSearch,
60
- type: selectType,
61
- overlayWidth: overlayWidth,
62
- extra: extra,
63
- onChange: onChange
64
- });
65
- } else if (type === 'selectToInput') {
66
- return /*#__PURE__*/React.createElement(BizSelectToInput, {
67
- value: props.value,
68
- options: options || [],
69
- keyField: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value,
70
- labelField: fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label,
71
- onChange: onChange,
72
- extendName: extendName
73
- });
74
- } else if (type === 'tab') {
75
- return /*#__PURE__*/React.createElement(BizTab, {
76
- value: props.value,
77
- options: options,
78
- onChange: onChange
79
- });
80
- } else if (type === 'radio') {
81
- return /*#__PURE__*/React.createElement(Radio.Group, {
82
- onChange: onChange,
83
- defaultValue: props.value
84
- }, /*#__PURE__*/React.createElement(Space, {
85
- direction: direction || 'horizontal'
86
- }, options && options.map(function (item) {
87
- return /*#__PURE__*/React.createElement(Radio, {
88
- key: item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value],
89
- value: item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value]
90
- }, item[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label]);
91
- })));
92
- } else if (type === 'list') {
93
- return /*#__PURE__*/React.createElement(BizList, {
94
- value: props.value,
95
- options: options && options.length > 0 ? options : undefined,
96
- onChange: onChange
97
- });
98
- }
99
-
100
- return /*#__PURE__*/React.createElement("div", null, "\u6682\u65E0\u76F8\u5173\u7EC4\u4EF6");
101
- };
102
-
103
- ItemNode.defaultProps = {
104
- fieldNames: {
105
- label: 'label',
106
- value: 'value'
107
- }
108
- };
109
- export default ItemNode;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { ListProps } from '../types';
3
- import './styles/list.less';
4
- declare const BizList: React.FC<ListProps>;
5
- export default BizList;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { BizSelectTypes } from '../../select/types';
3
- import './styles/handle.less';
4
- import { SelectInputProps } from '../types';
5
- declare const BizSelectToInput: React.FC<BizSelectTypes.Props & SelectInputProps>;
6
- export default BizSelectToInput;
@@ -1,175 +0,0 @@
1
- var _excluded = ["options", "name", "extendName", "value", "keyField", "labelField"];
2
-
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
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
- 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."); }
12
-
13
- 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); }
14
-
15
- 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; }
16
-
17
- 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; }
18
-
19
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
- 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; }
22
-
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
-
25
- import React, { useEffect, useState } from 'react';
26
- import { BizSelect } from '../..';
27
- import IconFont from '../../icon/iconFont';
28
- import { Input, Radio, Space, Tooltip } from 'antd';
29
- import './styles/handle.less';
30
- import { inputOptions } from '../data/data';
31
-
32
- var BizSelectToInput = function BizSelectToInput(props) {
33
- var options = props.options,
34
- name = props.name,
35
- extendName = props.extendName,
36
- value = props.value,
37
- keyField = props.keyField,
38
- labelField = props.labelField,
39
- res = _objectWithoutProperties(props, _excluded);
40
-
41
- var _useState = useState(true),
42
- _useState2 = _slicedToArray(_useState, 2),
43
- isSelect = _useState2[0],
44
- setIsSelect = _useState2[1];
45
-
46
- var _useState3 = useState(true),
47
- _useState4 = _slicedToArray(_useState3, 2),
48
- isFirst = _useState4[0],
49
- setIsFirst = _useState4[1];
50
-
51
- var _useState5 = useState(props.value),
52
- _useState6 = _slicedToArray(_useState5, 2),
53
- selectValue = _useState6[0],
54
- setSelectValue = _useState6[1];
55
-
56
- var _useState7 = useState(3),
57
- _useState8 = _slicedToArray(_useState7, 2),
58
- radioData = _useState8[0],
59
- setRadioData = _useState8[1];
60
-
61
- var _useState9 = useState(''),
62
- _useState10 = _slicedToArray(_useState9, 2),
63
- inputData = _useState10[0],
64
- setInputData = _useState10[1];
65
-
66
- var classPrefix = 'biz-select-input';
67
- useEffect(function () {
68
- if (isFirst) {
69
- setIsFirst(false);
70
- return;
71
- }
72
-
73
- if (props.onChange) props.onChange(isSelect ? selectValue : undefined);
74
- }, [isSelect]);
75
- useEffect(function () {
76
- if (isFirst) return;
77
- var data = null;
78
-
79
- if (inputData) {
80
- if (extendName) {
81
- var _data;
82
-
83
- data = (_data = {}, _defineProperty(_data, keyField, 0), _defineProperty(_data, labelField, inputData), _defineProperty(_data, extendName, radioData), _data);
84
- } else {
85
- var _data2;
86
-
87
- data = (_data2 = {}, _defineProperty(_data2, keyField, 0), _defineProperty(_data2, labelField, inputData), _data2);
88
- }
89
- }
90
-
91
- if (props.onChange) props.onChange(data);
92
- }, [radioData, inputData]);
93
-
94
- var onChange = function onChange(data) {
95
- setSelectValue(data);
96
- if (props.onChange) props.onChange(data);
97
- };
98
-
99
- var onChangeRadio = function onChangeRadio(e) {
100
- setRadioData(function () {
101
- return e.target.value;
102
- });
103
- };
104
-
105
- var onAdd = function onAdd() {
106
- setIsSelect(false);
107
- };
108
-
109
- var onBlur = function onBlur(e) {
110
- setInputData(function () {
111
- return e.target.value;
112
- });
113
- };
114
-
115
- var addNode = /*#__PURE__*/React.createElement("div", {
116
- className: "".concat(classPrefix, "-add"),
117
- onClick: onAdd
118
- }, /*#__PURE__*/React.createElement(IconFont, {
119
- className: "".concat(classPrefix, "-add"),
120
- type: 'tianjia1'
121
- }), " \u6DFB\u52A0", name);
122
- return /*#__PURE__*/React.createElement("div", {
123
- className: classPrefix
124
- }, isSelect ? /*#__PURE__*/React.createElement(BizSelect, _objectSpread(_objectSpread({}, res), {}, {
125
- className: "".concat(classPrefix, "-select"),
126
- options: props.options,
127
- defaultValue: selectValue,
128
- keyField: keyField,
129
- labelField: labelField,
130
- enableSearch: true,
131
- dropdownExtra: addNode,
132
- onChange: onChange
133
- })) : /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
134
- className: "".concat(classPrefix, "-input-row")
135
- }, /*#__PURE__*/React.createElement(Input, {
136
- className: "".concat(classPrefix, "-input"),
137
- placeholder: "\u6DFB\u52A0".concat(name),
138
- autoFocus: !isSelect,
139
- allowClear: {
140
- clearIcon: /*#__PURE__*/React.createElement(IconFont, {
141
- type: 'qingchu'
142
- })
143
- },
144
- onBlur: onBlur
145
- }), /*#__PURE__*/React.createElement(Tooltip, {
146
- title: "\u8FD4\u56DE\u9009\u62E9\u770B\u677F\u5217\u8868"
147
- }, /*#__PURE__*/React.createElement(IconFont, {
148
- className: "".concat(classPrefix, "-switch"),
149
- type: "shurukuang_fanhui",
150
- onClick: function onClick() {
151
- return setIsSelect(true);
152
- }
153
- }))), extendName && /*#__PURE__*/React.createElement("div", {
154
- className: "".concat(classPrefix, "-radio")
155
- }, /*#__PURE__*/React.createElement(Radio.Group, {
156
- value: radioData,
157
- onChange: onChangeRadio
158
- }, /*#__PURE__*/React.createElement(Space, {
159
- direction: "horizontal"
160
- }, inputOptions.map(function (item) {
161
- return /*#__PURE__*/React.createElement(Radio, {
162
- key: item.value,
163
- value: item.value
164
- }, item.title ? /*#__PURE__*/React.createElement(Tooltip, {
165
- title: item.title
166
- }, item.label) : item.label);
167
- }))))));
168
- };
169
-
170
- BizSelectToInput.defaultProps = {
171
- keyField: 'value',
172
- labelField: 'label',
173
- name: ''
174
- };
175
- export default BizSelectToInput;