ls-pro-common 3.0.14 → 3.0.15
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.
- package/CHANGELOG.md +746 -0
- package/es/components/404.d.ts +3 -0
- package/es/components/404.jpg +0 -0
- package/es/components/404.js +9 -0
- package/es/components/AreaCascader.d.ts +4 -0
- package/es/components/AreaCascader.js +76 -0
- package/es/components/AreaCascaderPanel.d.ts +5 -0
- package/es/components/AreaCascaderPanel.js +230 -0
- package/es/components/DescritionCard.d.ts +11 -0
- package/es/components/DescritionCard.js +79 -0
- package/es/components/DtlLayout.d.ts +44 -0
- package/es/components/DtlLayout.js +116 -0
- package/es/components/GroupTip.d.ts +10 -0
- package/es/components/GroupTip.js +31 -0
- package/es/components/IconBack.d.ts +3 -0
- package/es/components/IconBack.js +20 -0
- package/es/components/IconBell.d.ts +3 -0
- package/es/components/IconBell.js +22 -0
- package/es/components/IconQuestion.d.ts +3 -0
- package/es/components/IconQuestion.js +26 -0
- package/es/components/IconSearch.d.ts +3 -0
- package/es/components/IconSearch.js +22 -0
- package/es/components/IconSelector.d.ts +14 -0
- package/es/components/IconSelector.js +222 -0
- package/es/components/IconText.d.ts +3 -0
- package/es/components/IconText.js +30 -0
- package/es/components/ImageSelector.d.ts +31 -0
- package/es/components/ImageSelector.js +437 -0
- package/es/components/InputMultiLine.d.ts +46 -0
- package/es/components/InputMultiLine.js +139 -0
- package/es/components/InputTable.d.ts +106 -0
- package/es/components/InputTable.js +473 -0
- package/es/components/Loading.d.ts +8 -0
- package/es/components/Loading.js +20 -0
- package/es/components/Permission.d.ts +6 -0
- package/es/components/Permission.js +13 -0
- package/es/components/antd-custom.less +356 -0
- package/es/components/common.less +474 -0
- package/es/hooks/useDtl/index.d.ts +47 -0
- package/es/hooks/useDtl/index.js +949 -0
- package/es/hooks/useGetState.d.ts +1 -0
- package/es/hooks/useGetState.js +17 -0
- package/es/hooks/usePermission/index.d.ts +15 -0
- package/es/hooks/usePermission/index.js +58 -0
- package/es/hooks/useSingle/index.d.ts +54 -0
- package/es/hooks/useSingle/index.js +662 -0
- package/es/http/index.d.ts +53 -0
- package/es/http/index.js +309 -0
- package/es/index.d.ts +32 -0
- package/es/index.js +26 -0
- package/es/service/BaseService.d.ts +24 -0
- package/es/service/BaseService.js +214 -0
- package/es/typing.d.ts +53 -0
- package/es/typing.js +1 -0
- package/es/utils/index.d.ts +258 -0
- package/es/utils/index.js +682 -0
- package/lib/components/404.d.ts +3 -0
- package/lib/components/404.jpg +0 -0
- package/lib/components/404.js +17 -0
- package/lib/components/AreaCascader.d.ts +4 -0
- package/lib/components/AreaCascader.js +85 -0
- package/lib/components/AreaCascaderPanel.d.ts +5 -0
- package/lib/components/AreaCascaderPanel.js +239 -0
- package/lib/components/DescritionCard.d.ts +11 -0
- package/lib/components/DescritionCard.js +88 -0
- package/lib/components/DtlLayout.d.ts +44 -0
- package/lib/components/DtlLayout.js +125 -0
- package/lib/components/GroupTip.d.ts +10 -0
- package/lib/components/GroupTip.js +39 -0
- package/lib/components/IconBack.d.ts +3 -0
- package/lib/components/IconBack.js +28 -0
- package/lib/components/IconBell.d.ts +3 -0
- package/lib/components/IconBell.js +30 -0
- package/lib/components/IconQuestion.d.ts +3 -0
- package/lib/components/IconQuestion.js +34 -0
- package/lib/components/IconSearch.d.ts +3 -0
- package/lib/components/IconSearch.js +30 -0
- package/lib/components/IconSelector.d.ts +14 -0
- package/lib/components/IconSelector.js +230 -0
- package/lib/components/IconText.d.ts +3 -0
- package/lib/components/IconText.js +38 -0
- package/lib/components/ImageSelector.d.ts +31 -0
- package/lib/components/ImageSelector.js +445 -0
- package/lib/components/InputMultiLine.d.ts +46 -0
- package/lib/components/InputMultiLine.js +148 -0
- package/lib/components/InputTable.d.ts +106 -0
- package/lib/components/InputTable.js +482 -0
- package/lib/components/Loading.d.ts +8 -0
- package/lib/components/Loading.js +28 -0
- package/lib/components/Permission.d.ts +6 -0
- package/lib/components/Permission.js +21 -0
- package/lib/components/antd-custom.less +356 -0
- package/lib/components/common.less +474 -0
- package/lib/hooks/useDtl/index.d.ts +47 -0
- package/lib/hooks/useDtl/index.js +957 -0
- package/lib/hooks/useGetState.d.ts +1 -0
- package/lib/hooks/useGetState.js +24 -0
- package/lib/hooks/usePermission/index.d.ts +15 -0
- package/lib/hooks/usePermission/index.js +65 -0
- package/lib/hooks/useSingle/index.d.ts +54 -0
- package/lib/hooks/useSingle/index.js +670 -0
- package/lib/http/index.d.ts +53 -0
- package/lib/http/index.js +323 -0
- package/lib/index.d.ts +32 -0
- package/lib/service/BaseService.d.ts +24 -0
- package/lib/service/BaseService.js +222 -0
- package/lib/typing.d.ts +53 -0
- package/lib/typing.js +5 -0
- package/lib/utils/index.d.ts +258 -0
- package/lib/utils/index.js +779 -0
- package/package.json +5 -13
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import "antd/es/modal/style";
|
|
2
|
+
import _Modal from "antd/es/modal";
|
|
3
|
+
import "antd/es/empty/style";
|
|
4
|
+
import _Empty from "antd/es/empty";
|
|
5
|
+
import "antd/es/card/style";
|
|
6
|
+
import _Card from "antd/es/card";
|
|
7
|
+
import "antd/es/button/style";
|
|
8
|
+
import _Button from "antd/es/button";
|
|
9
|
+
import "antd/es/upload/style";
|
|
10
|
+
import _Upload from "antd/es/upload";
|
|
11
|
+
import "antd/es/input/style";
|
|
12
|
+
import _Input from "antd/es/input";
|
|
13
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
14
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
15
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
16
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
17
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
18
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
19
|
+
var _excluded = ["type", "uploadable", "readonly", "allowClear", "title", "modalWidth", "name", "maxSize", "modalProps", "code", "isInput", "desc", "imageClass", "maxCount"];
|
|
20
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
21
|
+
import React from "react";
|
|
22
|
+
import { useMemo, useState, useEffect, useContext, useRef } from 'react';
|
|
23
|
+
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
24
|
+
import { PlusOutlined, UploadOutlined, SearchOutlined, CloseOutlined } from '@ant-design/icons';
|
|
25
|
+
import { httpGet } from '../http';
|
|
26
|
+
import { getCache, showError, showWarn, showSuccess } from '../utils';
|
|
27
|
+
var fileCenter = getCache('ossPath') || '/petrel/petrel-file-center-api/lesoon/oss/file/';
|
|
28
|
+
function ImageSelector(prop) {
|
|
29
|
+
var _rest$fieldProps3;
|
|
30
|
+
//@ts-ignore?
|
|
31
|
+
var _useContext = useContext(ProFormContext),
|
|
32
|
+
formRef = _useContext.formRef;
|
|
33
|
+
var _useState = useState(false),
|
|
34
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
35
|
+
visible = _useState2[0],
|
|
36
|
+
setVisible = _useState2[1];
|
|
37
|
+
var _useState3 = useState(''),
|
|
38
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
39
|
+
imgUrl = _useState4[0],
|
|
40
|
+
setImgUrl = _useState4[1];
|
|
41
|
+
var _useState5 = useState([]),
|
|
42
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
43
|
+
list = _useState6[0],
|
|
44
|
+
setList = _useState6[1];
|
|
45
|
+
var _useState7 = useState(''),
|
|
46
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
47
|
+
searchKey = _useState8[0],
|
|
48
|
+
setSearchKey = _useState8[1];
|
|
49
|
+
var _useState9 = useState(''),
|
|
50
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
51
|
+
nextMarker = _useState10[0],
|
|
52
|
+
setNextMarker = _useState10[1];
|
|
53
|
+
var inputRef = useRef();
|
|
54
|
+
var type = prop.type,
|
|
55
|
+
_prop$uploadable = prop.uploadable,
|
|
56
|
+
uploadable = _prop$uploadable === void 0 ? true : _prop$uploadable,
|
|
57
|
+
_prop$readonly = prop.readonly,
|
|
58
|
+
readonly = _prop$readonly === void 0 ? true : _prop$readonly,
|
|
59
|
+
_prop$allowClear = prop.allowClear,
|
|
60
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
61
|
+
_prop$title = prop.title,
|
|
62
|
+
title = _prop$title === void 0 ? "选择图标" : _prop$title,
|
|
63
|
+
_prop$modalWidth = prop.modalWidth,
|
|
64
|
+
modalWidth = _prop$modalWidth === void 0 ? '600px' : _prop$modalWidth,
|
|
65
|
+
name = prop.name,
|
|
66
|
+
_prop$maxSize = prop.maxSize,
|
|
67
|
+
maxSize = _prop$maxSize === void 0 ? 5 : _prop$maxSize,
|
|
68
|
+
modalProps = prop.modalProps,
|
|
69
|
+
_prop$code = prop.code,
|
|
70
|
+
code = _prop$code === void 0 ? 'RETAIL' : _prop$code,
|
|
71
|
+
_prop$isInput = prop.isInput,
|
|
72
|
+
isInput = _prop$isInput === void 0 ? true : _prop$isInput,
|
|
73
|
+
_prop$desc = prop.desc,
|
|
74
|
+
desc = _prop$desc === void 0 ? '支持 png | jpg | gif 格式图片' : _prop$desc,
|
|
75
|
+
_prop$imageClass = prop.imageClass,
|
|
76
|
+
imageClass = _prop$imageClass === void 0 ? '' : _prop$imageClass,
|
|
77
|
+
_prop$maxCount = prop.maxCount,
|
|
78
|
+
maxCount = _prop$maxCount === void 0 ? 1 : _prop$maxCount,
|
|
79
|
+
rest = _objectWithoutProperties(prop, _excluded);
|
|
80
|
+
// 上传地址
|
|
81
|
+
var uploadImgApi = useMemo(function () {
|
|
82
|
+
return fileCenter + 'upload/' + code + '?catalogName=' + type;
|
|
83
|
+
}, [code, type]);
|
|
84
|
+
// 分页加载列表地址
|
|
85
|
+
var pageImgApi = useMemo(function () {
|
|
86
|
+
return fileCenter + 'page/' + code;
|
|
87
|
+
}, [code]);
|
|
88
|
+
// 展示地址
|
|
89
|
+
var showImgApi = useMemo(function () {
|
|
90
|
+
return fileCenter + 'show/' + code;
|
|
91
|
+
}, [code]);
|
|
92
|
+
var _useState11 = useState([]),
|
|
93
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
94
|
+
selectedUrl = _useState12[0],
|
|
95
|
+
setSelectedUrl = _useState12[1];
|
|
96
|
+
var loadData = /*#__PURE__*/function () {
|
|
97
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(keys) {
|
|
98
|
+
var _result$data, _result$data2;
|
|
99
|
+
var url, param, result, rows;
|
|
100
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
101
|
+
while (1) switch (_context.prev = _context.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
url = pageImgApi;
|
|
104
|
+
param = {
|
|
105
|
+
prefix: type,
|
|
106
|
+
maxKeys: 16
|
|
107
|
+
};
|
|
108
|
+
if (keys) {
|
|
109
|
+
param.prefix = param.prefix + '/' + keys;
|
|
110
|
+
}
|
|
111
|
+
if (nextMarker) {
|
|
112
|
+
param.nextMarker = nextMarker;
|
|
113
|
+
}
|
|
114
|
+
_context.next = 6;
|
|
115
|
+
return httpGet(url, param, false);
|
|
116
|
+
case 6:
|
|
117
|
+
result = _context.sent;
|
|
118
|
+
rows = (((_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.objectList) || []).filter(function (o) {
|
|
119
|
+
return o.dir == false && (!nextMarker || !list.find(function (e) {
|
|
120
|
+
return e.path === o.path;
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
rows.forEach(function (row) {
|
|
124
|
+
row.url = showImgApi + '?fileName=' + row.path;
|
|
125
|
+
});
|
|
126
|
+
if (!nextMarker) {
|
|
127
|
+
setList(rows);
|
|
128
|
+
} else {
|
|
129
|
+
setList([].concat(_toConsumableArray(list), _toConsumableArray(rows)));
|
|
130
|
+
}
|
|
131
|
+
setNextMarker((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.nextMarker);
|
|
132
|
+
case 11:
|
|
133
|
+
case "end":
|
|
134
|
+
return _context.stop();
|
|
135
|
+
}
|
|
136
|
+
}, _callee);
|
|
137
|
+
}));
|
|
138
|
+
return function loadData(_x) {
|
|
139
|
+
return _ref.apply(this, arguments);
|
|
140
|
+
};
|
|
141
|
+
}();
|
|
142
|
+
useEffect(function () {
|
|
143
|
+
if (!visible) {
|
|
144
|
+
setNextMarker('');
|
|
145
|
+
setSearchKey('');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
loadData(searchKey);
|
|
149
|
+
}, [visible, searchKey]);
|
|
150
|
+
useEffect(function () {
|
|
151
|
+
var _formRef$current, _formRef$current$getF;
|
|
152
|
+
var val = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current)) || {};
|
|
153
|
+
var url = val === null || val === void 0 ? void 0 : val[name];
|
|
154
|
+
if (!url) {
|
|
155
|
+
var _formRef$current2, _formRef$current2$get;
|
|
156
|
+
url = formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2, name);
|
|
157
|
+
}
|
|
158
|
+
if (url) {
|
|
159
|
+
var urls = url.toString().split(',');
|
|
160
|
+
setImgUrl(urls[0]);
|
|
161
|
+
setSelectedUrl(urls);
|
|
162
|
+
}
|
|
163
|
+
}, []);
|
|
164
|
+
// 验证上传文件大小
|
|
165
|
+
var beforeUpload = function beforeUpload(file) {
|
|
166
|
+
var sizeLimit = file.size / 1024 / 1024 >= maxSize;
|
|
167
|
+
if (sizeLimit) {
|
|
168
|
+
showError("\u4E0A\u4F20\u7684\u6587\u4EF6\u4E0D\u80FD\u5927\u4E8E".concat(maxSize, "M"));
|
|
169
|
+
}
|
|
170
|
+
return !sizeLimit;
|
|
171
|
+
};
|
|
172
|
+
// 上传图片
|
|
173
|
+
var onUpload = function onUpload(info) {
|
|
174
|
+
var isDirect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
175
|
+
if (info.file.status === 'done') {
|
|
176
|
+
var _result$flag;
|
|
177
|
+
var result = info.file.response;
|
|
178
|
+
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
|
179
|
+
showSuccess(result.flag.retMsg);
|
|
180
|
+
// 直接上传
|
|
181
|
+
if (isDirect) {
|
|
182
|
+
var _result$rows$, _formRef$current3, _formRef$current3$get, _formRef$current4, _formRef$current4$set;
|
|
183
|
+
var img = showImgApi + '?fileName=' + (result === null || result === void 0 ? void 0 : (_result$rows$ = result.rows[0]) === null || _result$rows$ === void 0 ? void 0 : _result$rows$.newFileId);
|
|
184
|
+
setImgUrl(img);
|
|
185
|
+
var formVal = formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$get = _formRef$current3.getFieldsValue) === null || _formRef$current3$get === void 0 ? void 0 : _formRef$current3$get.call(_formRef$current3);
|
|
186
|
+
var val = _objectSpread({}, formVal);
|
|
187
|
+
//@ts-ignore
|
|
188
|
+
val[name] = img;
|
|
189
|
+
formRef === null || formRef === void 0 ? void 0 : (_formRef$current4 = formRef.current) === null || _formRef$current4 === void 0 ? void 0 : (_formRef$current4$set = _formRef$current4.setFieldsValue) === null || _formRef$current4$set === void 0 ? void 0 : _formRef$current4$set.call(_formRef$current4, val);
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
var _result$flag2;
|
|
193
|
+
showError((result === null || result === void 0 ? void 0 : (_result$flag2 = result.flag) === null || _result$flag2 === void 0 ? void 0 : _result$flag2.retMsg) || '上传图片失败,请联系管理员');
|
|
194
|
+
}
|
|
195
|
+
} else if (info.file.status === 'error') {
|
|
196
|
+
showError('上传数据失败,请联系管理员');
|
|
197
|
+
}
|
|
198
|
+
if (!isDirect && !info.fileList.filter(function (o) {
|
|
199
|
+
return o.status === 'uploading';
|
|
200
|
+
}).length) {
|
|
201
|
+
loadData(searchKey);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
var showSelect = function showSelect() {
|
|
205
|
+
var _rest$fieldProps;
|
|
206
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps = rest.fieldProps) === null || _rest$fieldProps === void 0 ? void 0 : _rest$fieldProps.disabled)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
setVisible(true);
|
|
210
|
+
};
|
|
211
|
+
useEffect(function () {
|
|
212
|
+
var _rest$fieldProps2;
|
|
213
|
+
if ((rest === null || rest === void 0 ? void 0 : rest.disabled) || (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps2 = rest.fieldProps) === null || _rest$fieldProps2 === void 0 ? void 0 : _rest$fieldProps2.disabled)) return;
|
|
214
|
+
try {
|
|
215
|
+
if (!inputRef.current) return;
|
|
216
|
+
var el = inputRef.current.input.parentNode;
|
|
217
|
+
if (!el) return;
|
|
218
|
+
if (imgUrl) {
|
|
219
|
+
el.classList.add('ant-input-has-value');
|
|
220
|
+
} else {
|
|
221
|
+
el.classList.remove('ant-input-has-value');
|
|
222
|
+
}
|
|
223
|
+
} catch (e) {}
|
|
224
|
+
}, [imgUrl]);
|
|
225
|
+
var toggleSelectImage = function toggleSelectImage(url) {
|
|
226
|
+
if (selectedUrl.includes(url)) {
|
|
227
|
+
setSelectedUrl(function (val) {
|
|
228
|
+
return val.filter(function (o) {
|
|
229
|
+
return o !== url;
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
} else if (selectedUrl.length < maxCount && maxCount > 1) {
|
|
233
|
+
setSelectedUrl([].concat(_toConsumableArray(selectedUrl), [url]));
|
|
234
|
+
} else if (maxCount === 1) {
|
|
235
|
+
setSelectedUrl([url]);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var confirmImage = function confirmImage() {
|
|
239
|
+
var _formRef$current5, _formRef$current5$get;
|
|
240
|
+
var formVal = formRef === null || formRef === void 0 ? void 0 : (_formRef$current5 = formRef.current) === null || _formRef$current5 === void 0 ? void 0 : (_formRef$current5$get = _formRef$current5.getFieldsValue) === null || _formRef$current5$get === void 0 ? void 0 : _formRef$current5$get.call(_formRef$current5);
|
|
241
|
+
var val = _objectSpread({}, formVal);
|
|
242
|
+
//@ts-ignore
|
|
243
|
+
val[name] = selectedUrl.join(',');
|
|
244
|
+
formRef.current.setFieldsValue(val);
|
|
245
|
+
setImgUrl(selectedUrl.join(','));
|
|
246
|
+
setVisible(false);
|
|
247
|
+
};
|
|
248
|
+
var clearValue = function clearValue(e) {
|
|
249
|
+
if (!e || !e.target.value) {
|
|
250
|
+
var _formRef$current6, _formRef$current6$get;
|
|
251
|
+
setImgUrl('');
|
|
252
|
+
var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current6 = formRef.current) === null || _formRef$current6 === void 0 ? void 0 : (_formRef$current6$get = _formRef$current6.getFieldsValue) === null || _formRef$current6$get === void 0 ? void 0 : _formRef$current6$get.call(_formRef$current6)) || {};
|
|
253
|
+
formValue[name] = '';
|
|
254
|
+
formRef.current.setFieldsValue(_objectSpread({}, formValue));
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
258
|
+
name: name
|
|
259
|
+
}, rest), isInput ? /*#__PURE__*/React.createElement(_Input, _extends({
|
|
260
|
+
addonAfter: imgUrl ? /*#__PURE__*/React.createElement("img", {
|
|
261
|
+
style: {
|
|
262
|
+
maxWidth: 22,
|
|
263
|
+
maxHeight: 22
|
|
264
|
+
},
|
|
265
|
+
src: (imgUrl || '').split(',')[0],
|
|
266
|
+
onClick: function onClick() {
|
|
267
|
+
return showSelect();
|
|
268
|
+
}
|
|
269
|
+
}) : /*#__PURE__*/React.createElement(PlusOutlined, {
|
|
270
|
+
onClick: function onClick() {
|
|
271
|
+
return showSelect();
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
}, rest.fieldProps, {
|
|
275
|
+
readOnly: readonly,
|
|
276
|
+
allowClear: allowClear,
|
|
277
|
+
ref: inputRef,
|
|
278
|
+
onChange: clearValue
|
|
279
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
280
|
+
className: "image-selector"
|
|
281
|
+
}, /*#__PURE__*/React.createElement(_Upload, {
|
|
282
|
+
beforeUpload: beforeUpload,
|
|
283
|
+
onChange: function onChange(info) {
|
|
284
|
+
return onUpload(info, true);
|
|
285
|
+
},
|
|
286
|
+
action: uploadImgApi,
|
|
287
|
+
showUploadList: false,
|
|
288
|
+
name: "file",
|
|
289
|
+
maxCount: 1,
|
|
290
|
+
multiple: false,
|
|
291
|
+
headers: {
|
|
292
|
+
token: localStorage.getItem('token') || ''
|
|
293
|
+
},
|
|
294
|
+
accept: ".png,.gif,.jpg,.jpeg,.bmp"
|
|
295
|
+
}, imgUrl ? /*#__PURE__*/React.createElement("div", {
|
|
296
|
+
className: "img-wrapper"
|
|
297
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
298
|
+
className: "img-preview ".concat(imageClass),
|
|
299
|
+
src: (imgUrl || '').split(',')[0]
|
|
300
|
+
}), (rest === null || rest === void 0 ? void 0 : rest.disabled) !== true && (rest === null || rest === void 0 ? void 0 : (_rest$fieldProps3 = rest.fieldProps) === null || _rest$fieldProps3 === void 0 ? void 0 : _rest$fieldProps3.disabled) !== true && /*#__PURE__*/React.createElement("div", {
|
|
301
|
+
className: "clear-btn"
|
|
302
|
+
}, /*#__PURE__*/React.createElement(CloseOutlined, {
|
|
303
|
+
title: "\u6E05\u7A7A",
|
|
304
|
+
onClick: function onClick(e) {
|
|
305
|
+
e.preventDefault();
|
|
306
|
+
e.stopPropagation();
|
|
307
|
+
clearValue(undefined);
|
|
308
|
+
}
|
|
309
|
+
}))) : /*#__PURE__*/React.createElement("img", {
|
|
310
|
+
className: "img-upload",
|
|
311
|
+
src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAABxLuKEAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAABB9SURBVHhe7ZyJV1THtsb5F1+Sm0Gj8SZOiVFUVBBFmhkZBGRukKmbbqbuZp5EJpFmUFEZFKPxOiT3Je8ac2OuCgLf21+dPs3p9oDNYDTxnrW+RfepOlW7frVr167TLsPguxaXlvBsfgn3/72I0R8X0XVvEc13F+G+AyXXd0DDSrq95Jfr9qJoAe7ZeXhm5+TvHFzyuWF2wad5dY9iuapzS+rc0ussam19p2u5n3q5r8vYZ4AM9YPFMVAcT6Oo8x/A1Z+AH38H5hd8IHyXAjO/sIRfni1g+ueXGHzwEi3fvUTNzQXYby7CdhMhaEnTzCLsMy9RPTOP6ul52H2yTb+UsgUlfndMvfCrenrOX6dKnq+aYTtaW5q056gqpSWtjqkda5PzFtByF7j0A3DnCfDrC8VEXWELi0t4IlBmf55Hy+0XqJmmsTSUxqwNjF0M50D1wWoD1WSfpgSalDmnnisRjB+K9KdL9T0lMKcE7JTe3pwP3uaB0UVA3eI9t38Bnr/k6hEwvz2bx/RPL9D+3XPU3qQBYpAMQilkAzQwCqT+rEiHwgHpwBwC3ilAKIdv0Lxn9CKtTFO1iPA0uzbXY4winAv3l+GEff94DoP3X6BuRgxRBtBTOMj1dO57TknzEG1QGgAjHIf6rA1YeZJ4R4CkTC9fXkraUnsTYKiG28DAQ+DxcwEz9mhOYoqsezFCA0ND1uItBvmA6FA4eEIgDJvEHjVAQlCDFiCsG/CsQcZ2/0B57kA2IAFz4cEi6mU30IzVZlG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D0y7ZX2uRQdrRfkWacyRF9KjCvcZZySEtAbVtM5gUNQnH0mmjulb04QPxv7M4p2lda1I1YmxKycWhFMYIxJDUlbxMv0GMM2GAjpHQyG/Bzc/seHEvClQKB3GsvobYRDL+MgXqcdom3SBwfDZz+XkzPtMLZplD5ptM2snGLMixS4YTysmVV4X0Wwx9MFzP64bHU6Nqv0PorvbmIyBUxE0ln12tCs0vuorRFJSM4WMCk5Vuw4svrrvvdJX0alosLpQpitpgGH42U3Man0vumTcIt6JzQw5EXYjclJFJRXq3cZ/BnU7IH3QRz7N9HJyC06h/sPHiLs8ePH6B0cQlquFXuikvCZUFvtbftfTVwpWw7GYV90EvJLqzDsHcXTp79r/xXTo0ePcKGvH1n5JTiacAa7ok/ji2Mp2GY4D/3VxLFRe06kISopB/nFZQJlRKA8xcLCggZmbm4OT578irv3/oHBSyNwuppQWFmLrFIn0vlCynAu+isoTcaUdc6JvDIn6ps6MDJ+BQ8f/eCHsrS0hP8HWEep3cNGCJsAAAAASUVORK5CYII="
|
|
312
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
313
|
+
className: "img-choose"
|
|
314
|
+
}, /*#__PURE__*/React.createElement("a", {
|
|
315
|
+
onClick: function onClick() {
|
|
316
|
+
return showSelect();
|
|
317
|
+
}
|
|
318
|
+
}, "\u9009\u62E9\u5DF2\u6709\u56FE\u7247")), /*#__PURE__*/React.createElement("div", {
|
|
319
|
+
className: "img-desc"
|
|
320
|
+
}, desc))), /*#__PURE__*/React.createElement(_Modal, _extends({
|
|
321
|
+
title: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null, title), /*#__PURE__*/React.createElement("span", {
|
|
322
|
+
style: {
|
|
323
|
+
display: 'inline-block',
|
|
324
|
+
width: 230,
|
|
325
|
+
marginLeft: 30
|
|
326
|
+
}
|
|
327
|
+
}, /*#__PURE__*/React.createElement(_Input, {
|
|
328
|
+
suffix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
329
|
+
placeholder: "\u8F93\u5165\u56FE\u7247\u540D\u67E5\u8BE2",
|
|
330
|
+
onPressEnter: function onPressEnter(e) {
|
|
331
|
+
setNextMarker('');
|
|
332
|
+
setTimeout(function () {
|
|
333
|
+
setSearchKey(e.target.value || '');
|
|
334
|
+
}, 1);
|
|
335
|
+
}
|
|
336
|
+
}))),
|
|
337
|
+
visible: visible,
|
|
338
|
+
width: modalWidth,
|
|
339
|
+
destroyOnClose: true,
|
|
340
|
+
onCancel: function onCancel() {
|
|
341
|
+
return setVisible(false);
|
|
342
|
+
},
|
|
343
|
+
className: "image-selector",
|
|
344
|
+
centered: true,
|
|
345
|
+
footer: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
346
|
+
style: {
|
|
347
|
+
display: 'inline-block',
|
|
348
|
+
marginRight: 8
|
|
349
|
+
}
|
|
350
|
+
}, /*#__PURE__*/React.createElement(_Upload, {
|
|
351
|
+
beforeUpload: beforeUpload,
|
|
352
|
+
onChange: function onChange(info) {
|
|
353
|
+
return onUpload(info, false);
|
|
354
|
+
},
|
|
355
|
+
action: uploadImgApi,
|
|
356
|
+
showUploadList: false,
|
|
357
|
+
name: "file",
|
|
358
|
+
maxCount: 20,
|
|
359
|
+
multiple: true,
|
|
360
|
+
headers: {
|
|
361
|
+
token: localStorage.getItem('token') || ''
|
|
362
|
+
},
|
|
363
|
+
accept: ".png,.gif,.jpg,.jpeg,.bmp"
|
|
364
|
+
}, /*#__PURE__*/React.createElement(_Button, {
|
|
365
|
+
icon: /*#__PURE__*/React.createElement(UploadOutlined, null)
|
|
366
|
+
}, "\u4E0A\u4F20\u65B0\u56FE"))), /*#__PURE__*/React.createElement(_Button, {
|
|
367
|
+
onClick: function onClick() {
|
|
368
|
+
return loadData(searchKey);
|
|
369
|
+
}
|
|
370
|
+
}, nextMarker ? '加载更多' : '刷新'), maxCount > 1 && /*#__PURE__*/React.createElement(_Button, {
|
|
371
|
+
onClick: confirmImage
|
|
372
|
+
}, "\u786E\u8BA4")),
|
|
373
|
+
getContainer: function getContainer() {
|
|
374
|
+
return document.body;
|
|
375
|
+
}
|
|
376
|
+
}, modalProps), /*#__PURE__*/React.createElement("div", {
|
|
377
|
+
style: {
|
|
378
|
+
minHeight: '120px',
|
|
379
|
+
display: 'flex',
|
|
380
|
+
marginLeft: 16,
|
|
381
|
+
gap: 16,
|
|
382
|
+
flexWrap: 'wrap'
|
|
383
|
+
}
|
|
384
|
+
}, list.map(function (o) {
|
|
385
|
+
return /*#__PURE__*/React.createElement(_Card, {
|
|
386
|
+
hoverable: true,
|
|
387
|
+
style: {
|
|
388
|
+
width: '125px',
|
|
389
|
+
height: '130px',
|
|
390
|
+
verticalAlign: 'middle',
|
|
391
|
+
background: selectedUrl.includes(o.url) ? '#efefef' : '#fff'
|
|
392
|
+
},
|
|
393
|
+
bodyStyle: {
|
|
394
|
+
padding: '15px 8px',
|
|
395
|
+
textAlign: 'center'
|
|
396
|
+
},
|
|
397
|
+
onDoubleClick: function onDoubleClick() {
|
|
398
|
+
if (!name) {
|
|
399
|
+
showWarn('选择图标组件未设置name属性');
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
var formVal = formRef.current.getFieldsValue();
|
|
403
|
+
var val = _objectSpread({}, formVal);
|
|
404
|
+
//@ts-ignore
|
|
405
|
+
val[name] = o.url;
|
|
406
|
+
formRef.current.setFieldsValue(val);
|
|
407
|
+
setImgUrl(o.url);
|
|
408
|
+
setSelectedUrl([o.url]);
|
|
409
|
+
setVisible(false);
|
|
410
|
+
},
|
|
411
|
+
onClick: function onClick() {
|
|
412
|
+
toggleSelectImage(o.url);
|
|
413
|
+
},
|
|
414
|
+
key: o.path
|
|
415
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
416
|
+
style: {
|
|
417
|
+
height: 80
|
|
418
|
+
}
|
|
419
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
420
|
+
title: o.name,
|
|
421
|
+
style: {
|
|
422
|
+
maxWidth: '80px',
|
|
423
|
+
maxHeight: '80px'
|
|
424
|
+
},
|
|
425
|
+
src: o.url
|
|
426
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
427
|
+
style: {
|
|
428
|
+
whiteSpace: 'nowrap',
|
|
429
|
+
textOverflow: 'ellipsis',
|
|
430
|
+
overflow: 'hidden'
|
|
431
|
+
}
|
|
432
|
+
}, o.name));
|
|
433
|
+
}), list.length === 0 && /*#__PURE__*/React.createElement(_Empty, {
|
|
434
|
+
image: _Empty.PRESENTED_IMAGE_SIMPLE
|
|
435
|
+
}))));
|
|
436
|
+
}
|
|
437
|
+
export default ImageSelector;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { InputProps } from 'antd';
|
|
3
|
+
import type { TextAreaProps } from 'antd/lib/input';
|
|
4
|
+
import type { ProFormItemProps } from 'ls-pro-form';
|
|
5
|
+
export declare type InputMultiLineProps = ProFormItemProps<InputProps> & {
|
|
6
|
+
/**@name 表单项name, 跟 form.item 的 name一致 */
|
|
7
|
+
name: string;
|
|
8
|
+
/**@name 表单值*/
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/**@name 弹框宽度,默认为400 */
|
|
11
|
+
popWidth?: string;
|
|
12
|
+
/**@name 弹框位置,默认为bottom */
|
|
13
|
+
placement?: string;
|
|
14
|
+
/**@name 多行文本框行数 */
|
|
15
|
+
rows?: number;
|
|
16
|
+
/** @name 最大输入行数 */
|
|
17
|
+
maxRows?: number;
|
|
18
|
+
getPopupContainer?: (triggerNode: any) => HTMLElement;
|
|
19
|
+
textAreaProps?: TextAreaProps;
|
|
20
|
+
};
|
|
21
|
+
declare const InputMultiLine: React.ForwardRefExoticComponent<{
|
|
22
|
+
fieldProps?: (import("ls-pro-form/lib/interface").FieldProps & InputProps) | undefined;
|
|
23
|
+
placeholder?: string | string[] | undefined;
|
|
24
|
+
secondary?: boolean | undefined;
|
|
25
|
+
allowClear?: boolean | undefined;
|
|
26
|
+
disabled?: boolean | undefined;
|
|
27
|
+
width?: number | "sm" | "md" | "xl" | "xs" | "lg" | undefined;
|
|
28
|
+
proFieldProps?: import("ls-pro-utils").ProFieldProps | undefined;
|
|
29
|
+
footerRender?: import("ls-pro-form").LightFilterFooterRender | undefined;
|
|
30
|
+
} & Omit<import("ls-pro-form/lib/components/FormItem").ProFormItemProps, "valueType"> & import("ls-pro-form/lib/interface").ExtendsProps & {
|
|
31
|
+
/**@name 表单项name, 跟 form.item 的 name一致 */
|
|
32
|
+
name: string;
|
|
33
|
+
/**@name 表单值*/
|
|
34
|
+
defaultValue?: string | undefined;
|
|
35
|
+
/**@name 弹框宽度,默认为400 */
|
|
36
|
+
popWidth?: string | undefined;
|
|
37
|
+
/**@name 弹框位置,默认为bottom */
|
|
38
|
+
placement?: string | undefined;
|
|
39
|
+
/**@name 多行文本框行数 */
|
|
40
|
+
rows?: number | undefined;
|
|
41
|
+
/** @name 最大输入行数 */
|
|
42
|
+
maxRows?: number | undefined;
|
|
43
|
+
getPopupContainer?: ((triggerNode: any) => HTMLElement) | undefined;
|
|
44
|
+
textAreaProps?: TextAreaProps | undefined;
|
|
45
|
+
} & React.RefAttributes<unknown>>;
|
|
46
|
+
export default InputMultiLine;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import "antd/es/popover/style";
|
|
2
|
+
import _Popover from "antd/es/popover";
|
|
3
|
+
import "antd/es/input/style";
|
|
4
|
+
import _Input from "antd/es/input";
|
|
5
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
6
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
9
|
+
var _excluded = ["name", "rows", "maxRows", "placement", "popWidth", "fieldProps", "defaultValue", "allowClear", "getPopupContainer", "textAreaProps"];
|
|
10
|
+
import React, { useRef, useState, useEffect, useContext, useMemo, useImperativeHandle } from 'react';
|
|
11
|
+
import { ProFormText, ProFormContext } from 'ls-pro-form';
|
|
12
|
+
import { UnorderedListOutlined } from '@ant-design/icons';
|
|
13
|
+
var InputMultiLine = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
14
|
+
//@ts-ignore
|
|
15
|
+
var _useContext = useContext(ProFormContext),
|
|
16
|
+
formRef = _useContext.formRef;
|
|
17
|
+
var _useState = useState(''),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
text = _useState2[0],
|
|
20
|
+
setText = _useState2[1];
|
|
21
|
+
var _useState3 = useState(''),
|
|
22
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
23
|
+
lineText = _useState4[0],
|
|
24
|
+
setLineText = _useState4[1];
|
|
25
|
+
var _useState5 = useState(false),
|
|
26
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
27
|
+
visible = _useState6[0],
|
|
28
|
+
setVisible = _useState6[1];
|
|
29
|
+
var inputRef = useRef();
|
|
30
|
+
useImperativeHandle(ref, function () {
|
|
31
|
+
return inputRef.current;
|
|
32
|
+
});
|
|
33
|
+
var name = prop.name,
|
|
34
|
+
_prop$rows = prop.rows,
|
|
35
|
+
rows = _prop$rows === void 0 ? 12 : _prop$rows,
|
|
36
|
+
_prop$maxRows = prop.maxRows,
|
|
37
|
+
maxRows = _prop$maxRows === void 0 ? 20 : _prop$maxRows,
|
|
38
|
+
_prop$placement = prop.placement,
|
|
39
|
+
placement = _prop$placement === void 0 ? 'bottom' : _prop$placement,
|
|
40
|
+
_prop$popWidth = prop.popWidth,
|
|
41
|
+
popWidth = _prop$popWidth === void 0 ? '400px' : _prop$popWidth,
|
|
42
|
+
fieldProps = prop.fieldProps,
|
|
43
|
+
defaultValue = prop.defaultValue,
|
|
44
|
+
_prop$allowClear = prop.allowClear,
|
|
45
|
+
allowClear = _prop$allowClear === void 0 ? true : _prop$allowClear,
|
|
46
|
+
_prop$getPopupContain = prop.getPopupContainer,
|
|
47
|
+
getPopupContainer = _prop$getPopupContain === void 0 ? function (triggerNode) {
|
|
48
|
+
return triggerNode.parentNode.parentNode.parentNode.parentNode;
|
|
49
|
+
} : _prop$getPopupContain,
|
|
50
|
+
textAreaProps = prop.textAreaProps,
|
|
51
|
+
rest = _objectWithoutProperties(prop, _excluded);
|
|
52
|
+
// 设置初始值
|
|
53
|
+
useEffect(function () {
|
|
54
|
+
if (defaultValue) {
|
|
55
|
+
setText(defaultValue);
|
|
56
|
+
} else if (name && (formRef === null || formRef === void 0 ? void 0 : formRef.current)) {
|
|
57
|
+
var _formRef$current, _formRef$current$getF;
|
|
58
|
+
var formValue = formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldValue) === null || _formRef$current$getF === void 0 ? void 0 : _formRef$current$getF.call(_formRef$current, name);
|
|
59
|
+
setText(formValue);
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
// 显示多行输入时,赋值给多行文本框
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
if (!visible) return;
|
|
65
|
+
var line = (text || '').split(',').join('\n');
|
|
66
|
+
setLineText(line);
|
|
67
|
+
}, [visible, text]);
|
|
68
|
+
// 输入框值变化时,赋值给表单项
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
var _formRef$current2, _formRef$current2$get, _formRef$current3, _formRef$current3$set;
|
|
71
|
+
var formValue = (formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2)) || {};
|
|
72
|
+
formValue[name] = text;
|
|
73
|
+
formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _objectSpread({}, formValue));
|
|
74
|
+
}, [text]);
|
|
75
|
+
var lineInput = function lineInput(e) {
|
|
76
|
+
var line = (e.target.value || '').split('\n').filter(function (o, i) {
|
|
77
|
+
return i <= (maxRows < 1 ? 1000 : maxRows);
|
|
78
|
+
}).join('\n');
|
|
79
|
+
var txt = line.split('\n').join(',');
|
|
80
|
+
setLineText(line);
|
|
81
|
+
setText(txt);
|
|
82
|
+
};
|
|
83
|
+
var textInput = function textInput(e) {
|
|
84
|
+
setText(e.target.value);
|
|
85
|
+
};
|
|
86
|
+
var clearValue = function clearValue(e) {
|
|
87
|
+
if (!e.target.value) {
|
|
88
|
+
setText('');
|
|
89
|
+
setLineText('');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var PopoverDom = useMemo(function () {
|
|
93
|
+
return /*#__PURE__*/React.createElement(_Popover, {
|
|
94
|
+
content: /*#__PURE__*/React.createElement("div", {
|
|
95
|
+
style: {
|
|
96
|
+
width: popWidth
|
|
97
|
+
}
|
|
98
|
+
}, /*#__PURE__*/React.createElement(_Input.TextArea, _extends({
|
|
99
|
+
placeholder: "\u8BF7\u8F93\u5165"
|
|
100
|
+
}, textAreaProps, {
|
|
101
|
+
rows: rows,
|
|
102
|
+
value: lineText,
|
|
103
|
+
onInput: lineInput,
|
|
104
|
+
onKeyPress: function onKeyPress(e) {
|
|
105
|
+
if (e.key === 'Enter') e.stopPropagation();
|
|
106
|
+
}
|
|
107
|
+
}))),
|
|
108
|
+
trigger: "click",
|
|
109
|
+
visible: rest.disabled || (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.disabled) ? false : visible,
|
|
110
|
+
onVisibleChange: setVisible,
|
|
111
|
+
getPopupContainer: getPopupContainer
|
|
112
|
+
}, /*#__PURE__*/React.createElement(UnorderedListOutlined, {
|
|
113
|
+
onClick: function onClick(e) {
|
|
114
|
+
setVisible(true);
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
}, [visible, popWidth, lineText, rest]);
|
|
118
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, rest.label && name ? /*#__PURE__*/React.createElement(ProFormText, _extends({
|
|
119
|
+
name: name
|
|
120
|
+
}, rest), /*#__PURE__*/React.createElement(_Input, _extends({
|
|
121
|
+
suffix: PopoverDom,
|
|
122
|
+
placeholder: "\u8BF7\u8F93\u5165"
|
|
123
|
+
}, fieldProps, {
|
|
124
|
+
onChange: clearValue,
|
|
125
|
+
onInput: textInput,
|
|
126
|
+
allowClear: allowClear,
|
|
127
|
+
ref: inputRef
|
|
128
|
+
}))) : /*#__PURE__*/React.createElement(_Input, _extends({
|
|
129
|
+
suffix: PopoverDom,
|
|
130
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
|
131
|
+
allowClear: allowClear
|
|
132
|
+
}, fieldProps, {
|
|
133
|
+
onChange: clearValue,
|
|
134
|
+
onInput: textInput,
|
|
135
|
+
value: text,
|
|
136
|
+
ref: inputRef
|
|
137
|
+
})));
|
|
138
|
+
});
|
|
139
|
+
export default InputMultiLine;
|