cloud-b2b 1.0.0 → 1.0.1
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/es/Card/Card.js +20 -0
- package/es/Card/package.json +6 -0
- package/es/Control/Control.js +402 -0
- package/es/Control/event.js +57 -0
- package/es/Control/package.json +6 -0
- package/es/Enhance/Dialogs.js +67 -0
- package/es/Enhance/Loading.js +151 -0
- package/es/Enhance/index.js +8 -0
- package/es/Enhance/package.json +6 -0
- package/es/Header/Header.js +194 -0
- package/es/Header/Header.less +94 -0
- package/es/Header/Vertical.js +129 -0
- package/es/Header/Vertical.less +60 -0
- package/es/Header/package.json +6 -0
- package/es/HomeHeader/Header.js +75 -0
- package/es/HomeHeader/Header.less +73 -0
- package/es/HomeHeader/package.json +6 -0
- package/es/ImageView/ImageView.js +117 -0
- package/es/ImageView/ImageView.less +14 -0
- package/es/ImageView/package.json +6 -0
- package/es/InpurCascader/InputCascader.js +135 -0
- package/es/InpurCascader/package.json +6 -0
- package/es/InputEditor/InputEditor.js +118 -0
- package/es/InputEditor/inputEditor.less +8 -0
- package/es/InputEditor/package.json +6 -0
- package/es/InputSearch/InputSearch.js +306 -0
- package/es/InputSearch/package.json +6 -0
- package/es/InputSelect/InputSelect.js +185 -0
- package/es/InputSelect/package.json +6 -0
- package/es/InputWriting/InputWriting.js +107 -0
- package/es/InputWriting/package.json +6 -0
- package/es/Layout/Layout.js +232 -0
- package/es/Layout/Layout.less +28 -0
- package/es/Layout/package.json +6 -0
- package/es/LayoutLink/LayoutLink.js +82 -0
- package/es/LayoutLink/LayoutLink.less +53 -0
- package/es/LayoutLink/package.json +6 -0
- package/es/Link/Link.js +108 -0
- package/es/Link/package.json +6 -0
- package/es/Loading/Loading.js +15 -0
- package/es/Loading/Loading.less +13 -0
- package/es/Loading/package.json +6 -0
- package/es/Loading2/Loading2.js +11 -0
- package/es/Loading2/Loading2.less +19 -0
- package/es/Loading2/package.json +6 -0
- package/es/ModalWithDrag/ModalWithDrag.js +34 -0
- package/es/ModalWithDrag/ModalWithDrag.less +6 -0
- package/es/ModalWithDrag/drag.js +133 -0
- package/es/ModalWithDrag/package.json +6 -0
- package/es/NumberInput/NumberInput.js +237 -0
- package/es/NumberInput/package.json +6 -0
- package/es/Search/Search.js +581 -0
- package/es/Search/Search.less +63 -0
- package/es/Search/package.json +6 -0
- package/es/Sidebar/Sidebar.js +165 -0
- package/es/Sidebar/Sidebar.less +77 -0
- package/es/Sidebar/package.json +6 -0
- package/es/Sidebar2/Sidebar.js +192 -0
- package/es/Sidebar2/Sidebar.less +153 -0
- package/es/Sidebar2/package.json +6 -0
- package/es/SuperForm/SuperForm.js +641 -0
- package/es/SuperForm/SuperForm.less +52 -0
- package/es/SuperForm/package.json +6 -0
- package/es/SuperIcon/SuperIcon.js +30 -0
- package/es/SuperIcon/package.json +6 -0
- package/es/SuperPagination/SuperPagination.js +126 -0
- package/es/SuperPagination/package.json +6 -0
- package/es/SuperToolbar/SuperToolbar.js +223 -0
- package/es/SuperToolbar/SuperToolbar.less +17 -0
- package/es/SuperToolbar/package.json +6 -0
- package/es/SuperUpload/SuperUpload.js +282 -0
- package/es/SuperUpload/SuperUpload.less +27 -0
- package/es/SuperUpload/package.json +6 -0
- package/es/Viewer/ImageViews.js +311 -0
- package/es/Viewer/Viewer.js +149 -0
- package/es/Viewer/Viewer.less +67 -0
- package/es/Viewer/imgView.less +59 -0
- package/es/Viewer/package.json +7 -0
- package/es/WingBlank/WingBlank.js +20 -0
- package/es/WingBlank/WingBlank.less +12 -0
- package/es/WingBlank/package.json +6 -0
- package/es/helper.js +118 -0
- package/es/history.js +5 -0
- package/es/index.js +24 -1
- package/es/variables.less +73 -73
- package/lib/Card/Card.js +38 -0
- package/lib/Card/package.json +6 -0
- package/lib/Control/Control.js +449 -0
- package/lib/Control/event.js +68 -0
- package/lib/Control/package.json +6 -0
- package/lib/Enhance/Dialogs.js +87 -0
- package/lib/Enhance/Loading.js +175 -0
- package/lib/Enhance/index.js +35 -0
- package/lib/Enhance/package.json +6 -0
- package/lib/Header/Header.js +215 -0
- package/lib/Header/Header.less +94 -0
- package/lib/Header/Vertical.js +150 -0
- package/lib/Header/Vertical.less +60 -0
- package/lib/Header/package.json +6 -0
- package/lib/HomeHeader/Header.js +95 -0
- package/lib/HomeHeader/Header.less +73 -0
- package/lib/HomeHeader/package.json +6 -0
- package/lib/ImageView/ImageView.js +134 -0
- package/lib/ImageView/ImageView.less +14 -0
- package/lib/ImageView/package.json +6 -0
- package/lib/InpurCascader/InputCascader.js +156 -0
- package/lib/InpurCascader/package.json +6 -0
- package/lib/InputEditor/InputEditor.js +136 -0
- package/lib/InputEditor/inputEditor.less +8 -0
- package/lib/InputEditor/package.json +6 -0
- package/lib/InputSearch/InputSearch.js +322 -0
- package/lib/InputSearch/package.json +6 -0
- package/lib/InputSelect/InputSelect.js +208 -0
- package/lib/InputSelect/package.json +6 -0
- package/lib/InputWriting/InputWriting.js +123 -0
- package/lib/InputWriting/package.json +6 -0
- package/lib/Layout/Layout.js +258 -0
- package/lib/Layout/Layout.less +28 -0
- package/lib/Layout/package.json +6 -0
- package/lib/LayoutLink/LayoutLink.js +114 -0
- package/lib/LayoutLink/LayoutLink.less +53 -0
- package/lib/LayoutLink/package.json +6 -0
- package/lib/Link/Link.js +130 -0
- package/lib/Link/package.json +6 -0
- package/lib/Loading/Loading.js +30 -0
- package/lib/Loading/Loading.less +13 -0
- package/lib/Loading/package.json +6 -0
- package/lib/Loading2/Loading2.js +26 -0
- package/lib/Loading2/Loading2.less +19 -0
- package/lib/Loading2/package.json +6 -0
- package/lib/ModalWithDrag/ModalWithDrag.js +53 -0
- package/lib/ModalWithDrag/ModalWithDrag.less +6 -0
- package/lib/ModalWithDrag/drag.js +147 -0
- package/lib/ModalWithDrag/package.json +6 -0
- package/lib/NumberInput/NumberInput.js +259 -0
- package/lib/NumberInput/package.json +6 -0
- package/lib/Search/Search.js +603 -0
- package/lib/Search/Search.less +63 -0
- package/lib/Search/package.json +6 -0
- package/lib/Sidebar/Sidebar.js +186 -0
- package/lib/Sidebar/Sidebar.less +77 -0
- package/lib/Sidebar/package.json +6 -0
- package/lib/Sidebar2/Sidebar.js +213 -0
- package/lib/Sidebar2/Sidebar.less +153 -0
- package/lib/Sidebar2/package.json +6 -0
- package/lib/SuperForm/SuperForm.js +657 -0
- package/lib/SuperForm/SuperForm.less +52 -0
- package/lib/SuperForm/package.json +6 -0
- package/lib/SuperIcon/SuperIcon.js +47 -0
- package/lib/SuperIcon/package.json +6 -0
- package/lib/SuperPagination/SuperPagination.js +145 -0
- package/lib/SuperPagination/package.json +6 -0
- package/lib/SuperToolbar/SuperToolbar.js +248 -0
- package/lib/SuperToolbar/SuperToolbar.less +17 -0
- package/lib/SuperToolbar/package.json +6 -0
- package/lib/SuperUpload/SuperUpload.js +324 -0
- package/lib/SuperUpload/SuperUpload.less +27 -0
- package/lib/SuperUpload/package.json +6 -0
- package/lib/Viewer/ImageViews.js +323 -0
- package/lib/Viewer/Viewer.js +167 -0
- package/lib/Viewer/Viewer.less +67 -0
- package/lib/Viewer/imgView.less +59 -0
- package/lib/Viewer/package.json +7 -0
- package/lib/WingBlank/WingBlank.js +37 -0
- package/lib/WingBlank/WingBlank.less +12 -0
- package/lib/WingBlank/package.json +6 -0
- package/lib/helper.js +147 -0
- package/lib/history.js +18 -0
- package/lib/index.js +208 -1
- package/lib/index.less +20 -1
- package/lib/variables.less +73 -73
- package/package.json +3 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
|
+
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
+
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
+
|
|
9
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports["default"] = void 0;
|
|
14
|
+
|
|
15
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
16
|
+
|
|
17
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
18
|
+
|
|
19
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
20
|
+
|
|
21
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
22
|
+
|
|
23
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
24
|
+
|
|
25
|
+
var _react = _interopRequireDefault(require("react"));
|
|
26
|
+
|
|
27
|
+
var _variables = _interopRequireDefault(require("../variables"));
|
|
28
|
+
|
|
29
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
30
|
+
|
|
31
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
32
|
+
|
|
33
|
+
var defaultMenus = ['head', // 标题
|
|
34
|
+
'bold', // 粗体
|
|
35
|
+
'fontSize', // 字号
|
|
36
|
+
'fontName', // 字体
|
|
37
|
+
'italic', // 斜体
|
|
38
|
+
'underline', // 下划线
|
|
39
|
+
'strikeThrough', // 删除线
|
|
40
|
+
'foreColor', // 文字颜色
|
|
41
|
+
'backColor', // 背景颜色
|
|
42
|
+
'link', // 插入链接
|
|
43
|
+
'list', // 列表
|
|
44
|
+
'justify', // 对齐方式
|
|
45
|
+
'quote', // 引用
|
|
46
|
+
'image', // 插入图片
|
|
47
|
+
'table', // 表格
|
|
48
|
+
'code' // 插入代码
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
var InputEditor = /*#__PURE__*/function (_React$Component) {
|
|
52
|
+
(0, _inherits2["default"])(InputEditor, _React$Component);
|
|
53
|
+
|
|
54
|
+
var _super = _createSuper(InputEditor);
|
|
55
|
+
|
|
56
|
+
function InputEditor() {
|
|
57
|
+
(0, _classCallCheck2["default"])(this, InputEditor);
|
|
58
|
+
return _super.apply(this, arguments);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
(0, _createClass2["default"])(InputEditor, [{
|
|
62
|
+
key: "componentDidMount",
|
|
63
|
+
value: function componentDidMount() {
|
|
64
|
+
var _this$props = this.props,
|
|
65
|
+
inputKey = _this$props.inputKey,
|
|
66
|
+
menus = _this$props.menus,
|
|
67
|
+
color = _this$props.color,
|
|
68
|
+
_this$props$showLinkI = _this$props.showLinkImg,
|
|
69
|
+
showLinkImg = _this$props$showLinkI === void 0 ? true : _this$props$showLinkI,
|
|
70
|
+
_this$props$uploadImg = _this$props.uploadImgShowBase64,
|
|
71
|
+
uploadImgShowBase64 = _this$props$uploadImg === void 0 ? true : _this$props$uploadImg,
|
|
72
|
+
onChange = _this$props.onChange,
|
|
73
|
+
value = _this$props.value,
|
|
74
|
+
readonly = _this$props.readonly;
|
|
75
|
+
|
|
76
|
+
if (!readonly) {
|
|
77
|
+
var elem = this.refs[inputKey];
|
|
78
|
+
this[inputKey] = new E(elem); //配置菜单
|
|
79
|
+
|
|
80
|
+
menus && (this[inputKey].customConfig.menus = menus); //配置颜色
|
|
81
|
+
|
|
82
|
+
color && (this[inputKey].customConfig.menus = color); //配置菜单
|
|
83
|
+
|
|
84
|
+
this[inputKey].customConfig.menus = defaultMenus;
|
|
85
|
+
|
|
86
|
+
if (menus) {
|
|
87
|
+
this[inputKey].customConfig.menus = menus;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this[inputKey].customConfig.uploadImgShowBase64 = uploadImgShowBase64; //是否可以上传图片
|
|
91
|
+
|
|
92
|
+
this[inputKey].customConfig.showLinkImg = showLinkImg; //隐藏网络图片
|
|
93
|
+
|
|
94
|
+
this[inputKey].customConfig.onchange = function (html) {
|
|
95
|
+
onChange && onChange(html);
|
|
96
|
+
}; //配置编辑区域的 z-index
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
this[inputKey].customConfig.zIndex = 0;
|
|
100
|
+
this[inputKey].create();
|
|
101
|
+
this[inputKey].txt.html(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "componentDidUpdate",
|
|
106
|
+
value: function componentDidUpdate() {
|
|
107
|
+
var _this$props2 = this.props,
|
|
108
|
+
inputKey = _this$props2.inputKey,
|
|
109
|
+
_this$props2$value = _this$props2.value,
|
|
110
|
+
value = _this$props2$value === void 0 ? '' : _this$props2$value,
|
|
111
|
+
readonly = _this$props2.readonly;
|
|
112
|
+
!readonly && !value && this[inputKey].txt.html(value); //支持清空操作
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "render",
|
|
116
|
+
value: function render() {
|
|
117
|
+
var _this$props3 = this.props,
|
|
118
|
+
inputKey = _this$props3.inputKey,
|
|
119
|
+
readonly = _this$props3.readonly,
|
|
120
|
+
value = _this$props3.value;
|
|
121
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
122
|
+
className: (0, _variables["default"])('InputEditor')
|
|
123
|
+
}, readonly ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
124
|
+
dangerouslySetInnerHTML: {
|
|
125
|
+
__html: "".concat(value)
|
|
126
|
+
}
|
|
127
|
+
}) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
128
|
+
ref: inputKey
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
}]);
|
|
132
|
+
return InputEditor;
|
|
133
|
+
}(_react["default"].Component);
|
|
134
|
+
|
|
135
|
+
var _default = InputEditor;
|
|
136
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs3/core-js-stable/reflect/construct");
|
|
4
|
+
|
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
6
|
+
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
+
|
|
9
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports["default"] = void 0;
|
|
14
|
+
|
|
15
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
16
|
+
|
|
17
|
+
var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
|
|
18
|
+
|
|
19
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
20
|
+
|
|
21
|
+
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
22
|
+
|
|
23
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
24
|
+
|
|
25
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
26
|
+
|
|
27
|
+
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
28
|
+
|
|
29
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
30
|
+
|
|
31
|
+
var _input = _interopRequireDefault(require("antd/lib/input"));
|
|
32
|
+
|
|
33
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/typeof"));
|
|
34
|
+
|
|
35
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
36
|
+
|
|
37
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
38
|
+
|
|
39
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized"));
|
|
40
|
+
|
|
41
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits"));
|
|
42
|
+
|
|
43
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn"));
|
|
44
|
+
|
|
45
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf"));
|
|
46
|
+
|
|
47
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
48
|
+
|
|
49
|
+
var _icon = _interopRequireDefault(require("antd/lib/icon"));
|
|
50
|
+
|
|
51
|
+
var _autoComplete = _interopRequireDefault(require("antd/lib/auto-complete"));
|
|
52
|
+
|
|
53
|
+
var _react = _interopRequireDefault(require("react"));
|
|
54
|
+
|
|
55
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
56
|
+
|
|
57
|
+
var _helper = require("../helper");
|
|
58
|
+
|
|
59
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
60
|
+
|
|
61
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
62
|
+
|
|
63
|
+
var SelectOption = _autoComplete["default"].Option; // 如果写在局部,每次渲染时生成的suffix引用值不同,会使antd的Input认为suffix动态变化了,从而导致Input报出警告 (antd的BUG)
|
|
64
|
+
|
|
65
|
+
var suffix = /*#__PURE__*/_react["default"].createElement(_icon["default"], {
|
|
66
|
+
type: "search",
|
|
67
|
+
style: {
|
|
68
|
+
color: 'black',
|
|
69
|
+
opacity: 0.25,
|
|
70
|
+
marginRight: -4
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
var OPTION_STYLE = {
|
|
75
|
+
"float": 'right',
|
|
76
|
+
marginLeft: '1rem',
|
|
77
|
+
color: '#aaa',
|
|
78
|
+
whiteSpace: 'pre-wrap'
|
|
79
|
+
};
|
|
80
|
+
var OPTION_STYLE2 = {
|
|
81
|
+
display: 'block',
|
|
82
|
+
color: '#aaa',
|
|
83
|
+
whiteSpace: 'pre-wrap'
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* filter: 为true表示下拉列表会依据输入的值进行前端过滤,默认为true; 如果不想过滤,则设为false
|
|
87
|
+
* remark: 为true表示options的option中含有remark字段,并需要用remark值进行过滤下拉,默认为false
|
|
88
|
+
* searchWhenClick: 每次点击时,触发onSearch事件,默认为false
|
|
89
|
+
* noSearchWhenTypo: 当输入时,不触发onSearch事件,默认为false
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
var PROPS = {
|
|
93
|
+
filter: _propTypes["default"].bool,
|
|
94
|
+
remark: _propTypes["default"].bool,
|
|
95
|
+
searchWhenClick: _propTypes["default"].bool,
|
|
96
|
+
noSearchWhenTypo: _propTypes["default"].bool,
|
|
97
|
+
options: _propTypes["default"].array,
|
|
98
|
+
value: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number, _propTypes["default"].object]),
|
|
99
|
+
inputRef: _propTypes["default"].func,
|
|
100
|
+
onChange: _propTypes["default"].func,
|
|
101
|
+
onBlur: _propTypes["default"].func,
|
|
102
|
+
onSelect: _propTypes["default"].func,
|
|
103
|
+
onSearch: _propTypes["default"].func
|
|
104
|
+
};
|
|
105
|
+
var PROPS_KEYS = (0, _keys["default"])(PROPS);
|
|
106
|
+
|
|
107
|
+
var InputSearch = /*#__PURE__*/function (_React$Component) {
|
|
108
|
+
(0, _inherits2["default"])(InputSearch, _React$Component);
|
|
109
|
+
|
|
110
|
+
var _super = _createSuper(InputSearch);
|
|
111
|
+
|
|
112
|
+
function InputSearch(_props) {
|
|
113
|
+
var _this;
|
|
114
|
+
|
|
115
|
+
(0, _classCallCheck2["default"])(this, InputSearch);
|
|
116
|
+
_this = _super.call(this, _props);
|
|
117
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSearch", function (value) {
|
|
118
|
+
_this.setState({
|
|
119
|
+
value: value
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
var _this$props = _this.props,
|
|
123
|
+
onSearch = _this$props.onSearch,
|
|
124
|
+
noSearchWhenTypo = _this$props.noSearchWhenTypo;
|
|
125
|
+
!noSearchWhenTypo && onSearch && onSearch(value);
|
|
126
|
+
});
|
|
127
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function () {
|
|
128
|
+
var _this$props2 = _this.props,
|
|
129
|
+
_this$props2$autoAdd = _this$props2.autoAdd,
|
|
130
|
+
autoAdd = _this$props2$autoAdd === void 0 ? false : _this$props2$autoAdd,
|
|
131
|
+
_this$props2$options = _this$props2.options,
|
|
132
|
+
options = _this$props2$options === void 0 ? [] : _this$props2$options,
|
|
133
|
+
onChange = _this$props2.onChange,
|
|
134
|
+
onBlur = _this$props2.onBlur;
|
|
135
|
+
|
|
136
|
+
if (_this.props.value !== _this.state.value) {
|
|
137
|
+
var index = (0, _findIndex["default"])(options).call(options, function (option) {
|
|
138
|
+
return option.title === _this.state.value;
|
|
139
|
+
});
|
|
140
|
+
var value = '';
|
|
141
|
+
|
|
142
|
+
if (index === -1) {
|
|
143
|
+
if (autoAdd && _this.state.value) {
|
|
144
|
+
if (typeof _this.state.value === 'string') {
|
|
145
|
+
value = {
|
|
146
|
+
value: -1,
|
|
147
|
+
title: _this.state.value
|
|
148
|
+
};
|
|
149
|
+
} else if ((0, _typeof2["default"])(_this.state.value) === 'object' && _this.state.value.title && _this.state.value.value) {
|
|
150
|
+
value = _this.state.value;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
value = options[index];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_this.setState({
|
|
158
|
+
value: value
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
onChange && onChange(value);
|
|
162
|
+
onBlur && onBlur(value);
|
|
163
|
+
} else {
|
|
164
|
+
onBlur && onBlur(_this.props.value);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSelect", function (value) {
|
|
168
|
+
var _this$props3 = _this.props,
|
|
169
|
+
onChange = _this$props3.onChange,
|
|
170
|
+
_this$props3$options = _this$props3.options,
|
|
171
|
+
options = _this$props3$options === void 0 ? [] : _this$props3$options;
|
|
172
|
+
var index = (0, _findIndex["default"])(options).call(options, function (option) {
|
|
173
|
+
return String(option.value) === value;
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
if (index > -1) {
|
|
177
|
+
_this.setState({
|
|
178
|
+
value: options[index]
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
onChange && onChange(options[index]);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onClick", function (e) {
|
|
185
|
+
var _this$props4 = _this.props,
|
|
186
|
+
_this$props4$options = _this$props4.options,
|
|
187
|
+
options = _this$props4$options === void 0 ? [] : _this$props4$options,
|
|
188
|
+
onSearch = _this$props4.onSearch,
|
|
189
|
+
searchWhenClick = _this$props4.searchWhenClick,
|
|
190
|
+
value = _this$props4.value;
|
|
191
|
+
|
|
192
|
+
if (onSearch && (!options.length || !value && searchWhenClick)) {
|
|
193
|
+
onSearch(e.target.value);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "makeValueValid", function (value) {
|
|
197
|
+
var _context;
|
|
198
|
+
|
|
199
|
+
return (0, _includes["default"])(_context = [NaN, undefined, null]).call(_context, value) ? '' : value;
|
|
200
|
+
});
|
|
201
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getValue", function () {
|
|
202
|
+
var value = _this.state.value;
|
|
203
|
+
return String(_this.makeValueValid((0, _typeof2["default"])(value) === 'object' ? value.value : value));
|
|
204
|
+
});
|
|
205
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isMatch", function (inputValue, option) {
|
|
206
|
+
var _context2;
|
|
207
|
+
|
|
208
|
+
return option.props.children && (0, _indexOf["default"])(_context2 = option.props.children).call(_context2, inputValue) !== -1;
|
|
209
|
+
});
|
|
210
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isMatchRemark", function (inputValue, option) {
|
|
211
|
+
var _option$props = option.props,
|
|
212
|
+
text = _option$props.text,
|
|
213
|
+
remark = _option$props.remark;
|
|
214
|
+
return (0, _indexOf["default"])(text).call(text, inputValue) > -1 || (0, _indexOf["default"])(remark).call(remark, inputValue) > -1;
|
|
215
|
+
});
|
|
216
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isValidValue", function (value) {
|
|
217
|
+
var _context3;
|
|
218
|
+
|
|
219
|
+
// value必须为对象,且有属性value的值不等''或undefined
|
|
220
|
+
return value && !(0, _includes["default"])(_context3 = ['', undefined]).call(_context3, value.value);
|
|
221
|
+
});
|
|
222
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getOptions", function () {
|
|
223
|
+
var value = _this.state.value;
|
|
224
|
+
var options = _this.props.options;
|
|
225
|
+
|
|
226
|
+
if (options && options.length) {
|
|
227
|
+
if (_this.isValidValue(value) && !(0, _find["default"])(options).call(options, function (option) {
|
|
228
|
+
return option.value === value.value;
|
|
229
|
+
})) {
|
|
230
|
+
return [value];
|
|
231
|
+
} else {
|
|
232
|
+
return options;
|
|
233
|
+
}
|
|
234
|
+
} else if (_this.isValidValue(value)) {
|
|
235
|
+
return [value];
|
|
236
|
+
} else {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getDataSource", function () {
|
|
241
|
+
var _context4;
|
|
242
|
+
|
|
243
|
+
return (0, _map["default"])(_context4 = _this.getOptions()).call(_context4, function (option) {
|
|
244
|
+
return {
|
|
245
|
+
value: String(option.value),
|
|
246
|
+
text: option.title
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getDataSourceRemark", function () {
|
|
251
|
+
var _context5;
|
|
252
|
+
|
|
253
|
+
return (0, _map["default"])(_context5 = _this.getOptions()).call(_context5, function (option, index) {
|
|
254
|
+
return /*#__PURE__*/_react["default"].createElement(SelectOption, {
|
|
255
|
+
key: index,
|
|
256
|
+
value: String(option.value),
|
|
257
|
+
text: option.title,
|
|
258
|
+
remark: option.remark || ''
|
|
259
|
+
}, /*#__PURE__*/_react["default"].createElement("span", null, option.title), /*#__PURE__*/_react["default"].createElement("span", {
|
|
260
|
+
style: OPTION_STYLE
|
|
261
|
+
}, option.remark || ''), /*#__PURE__*/_react["default"].createElement("span", {
|
|
262
|
+
style: OPTION_STYLE2
|
|
263
|
+
}, option.description || ''));
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getProps", function () {
|
|
267
|
+
var _this$props5 = _this.props,
|
|
268
|
+
inputRef = _this$props5.inputRef,
|
|
269
|
+
_this$props5$filter = (0, _filter["default"])(_this$props5),
|
|
270
|
+
filter = _this$props5$filter === void 0 ? true : _this$props5$filter;
|
|
271
|
+
|
|
272
|
+
var props = (0, _assign["default"])((0, _helper.getObjectExclude)(_this.props, PROPS_KEYS), {
|
|
273
|
+
value: _this.getValue(),
|
|
274
|
+
allowClear: true,
|
|
275
|
+
ref: inputRef,
|
|
276
|
+
onSearch: _this.onSearch,
|
|
277
|
+
onSelect: _this.onSelect,
|
|
278
|
+
onBlur: _this.onBlur
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
if (_this.props.remark) {
|
|
282
|
+
props.dataSource = _this.getDataSourceRemark();
|
|
283
|
+
props.filterOption = filter ? _this.isMatchRemark : false;
|
|
284
|
+
props.optionLabelProp = 'text';
|
|
285
|
+
} else {
|
|
286
|
+
props.dataSource = _this.getDataSource();
|
|
287
|
+
props.filterOption = filter ? _this.isMatch : false;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return props;
|
|
291
|
+
});
|
|
292
|
+
_this.state = {
|
|
293
|
+
value: _props.value
|
|
294
|
+
};
|
|
295
|
+
return _this;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
(0, _createClass2["default"])(InputSearch, [{
|
|
299
|
+
key: "componentWillReceiveProps",
|
|
300
|
+
value: function componentWillReceiveProps(props) {
|
|
301
|
+
if (props.value !== this.props.value) {
|
|
302
|
+
this.setState({
|
|
303
|
+
value: props.value
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}, {
|
|
308
|
+
key: "render",
|
|
309
|
+
value: function render() {
|
|
310
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
311
|
+
onClick: this.onClick
|
|
312
|
+
}, /*#__PURE__*/_react["default"].createElement(_autoComplete["default"], this.getProps(), /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
|
313
|
+
suffix: suffix
|
|
314
|
+
})));
|
|
315
|
+
}
|
|
316
|
+
}]);
|
|
317
|
+
return InputSearch;
|
|
318
|
+
}(_react["default"].Component);
|
|
319
|
+
|
|
320
|
+
(0, _defineProperty2["default"])(InputSearch, "propTypes", PROPS);
|
|
321
|
+
var _default = InputSearch;
|
|
322
|
+
exports["default"] = _default;
|