@zgfe/business-lib 1.0.16 → 1.0.18
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/assets/styles/resetAntd.less +0 -9
- package/es/assets/theme.js +1 -1
- package/es/attrConditions/components/stringList.js +65 -43
- package/es/attrConditions/demo/index.js +7 -8
- package/es/select/handle.js +6 -6
- package/es/select/index.js +5 -25
- package/es/select/overlay.js +26 -1
- package/es/select/styles/handle.less +6 -0
- package/es/select/types.d.ts +1 -2
- package/package.json +2 -2
|
@@ -429,15 +429,6 @@
|
|
|
429
429
|
background-color: #94a6ce !important;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
|
|
433
|
-
.ant-btn-primary {
|
|
434
|
-
color: #fff !important;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
.ant-btn-ghost {
|
|
438
|
-
color: @text-color-secondary!important;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
432
|
.ant-form-item-explain-error {
|
|
442
433
|
color: @error-color!important;
|
|
443
434
|
}
|
package/es/assets/theme.js
CHANGED
|
@@ -6,7 +6,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
exports.theme = {
|
|
9
|
-
'primary-color': '
|
|
9
|
+
'primary-color': '#165dff',
|
|
10
10
|
'border-color-base': '#ECEDF0',
|
|
11
11
|
'background-color-base': '#fafafb',
|
|
12
12
|
'text-color': '#021429',
|
|
@@ -43,6 +43,16 @@ var StringList = function StringList(props) {
|
|
|
43
43
|
isFirst = _useState6[0],
|
|
44
44
|
setIsFirst = _useState6[1];
|
|
45
45
|
|
|
46
|
+
var _useState7 = useState(''),
|
|
47
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
+
searchValue = _useState8[0],
|
|
49
|
+
setSearchValue = _useState8[1];
|
|
50
|
+
|
|
51
|
+
var _useState9 = useState(0),
|
|
52
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
53
|
+
timer = _useState10[0],
|
|
54
|
+
setTimer = _useState10[1];
|
|
55
|
+
|
|
46
56
|
useEffect(function () {
|
|
47
57
|
if (props.value) {
|
|
48
58
|
var data = props.value.map(function (item) {
|
|
@@ -57,7 +67,7 @@ var StringList = function StringList(props) {
|
|
|
57
67
|
}
|
|
58
68
|
}, [props.value]);
|
|
59
69
|
useEffect(function () {
|
|
60
|
-
fetchValues(
|
|
70
|
+
fetchValues();
|
|
61
71
|
|
|
62
72
|
if (isFirst) {
|
|
63
73
|
setIsFirst(false);
|
|
@@ -71,55 +81,66 @@ var StringList = function StringList(props) {
|
|
|
71
81
|
onChange([]);
|
|
72
82
|
}
|
|
73
83
|
}, [props.operate]);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
fetchValues();
|
|
86
|
+
}, [searchValue]);
|
|
74
87
|
|
|
75
88
|
var fetchValues = /*#__PURE__*/function () {
|
|
76
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(
|
|
77
|
-
var
|
|
89
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
90
|
+
var fetch;
|
|
78
91
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
79
92
|
while (1) {
|
|
80
93
|
switch (_context.prev = _context.next) {
|
|
81
94
|
case 0:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
fetch = function fetch() {
|
|
96
|
+
var attrData = props.attr;
|
|
97
|
+
var requestData = {
|
|
98
|
+
app_id: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
|
|
99
|
+
platform: currentApp === null || currentApp === void 0 ? void 0 : currentApp.platform,
|
|
100
|
+
limit: 20,
|
|
101
|
+
attr: (attrData === null || attrData === void 0 ? void 0 : attrData.id) || 0,
|
|
102
|
+
dimension_sub: attrData === null || attrData === void 0 ? void 0 : attrData.dimensionSub,
|
|
103
|
+
v: searchValue || ''
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var transformRequest = function transformRequest(params) {
|
|
107
|
+
var arr = [];
|
|
108
|
+
|
|
109
|
+
for (var key in params) {
|
|
110
|
+
arr.push("".concat(key, "=").concat(encodeURIComponent(params[key])));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return arr.join('&');
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var formData = transformRequest(requestData);
|
|
117
|
+
request(Apis.esQuery, {
|
|
118
|
+
method: 'post',
|
|
119
|
+
data: formData,
|
|
120
|
+
headers: {
|
|
121
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
122
|
+
}
|
|
123
|
+
}).then(function (result) {
|
|
124
|
+
setOptions(function () {
|
|
125
|
+
return result && result.sources ? result.sources.map(function (item) {
|
|
126
|
+
return {
|
|
127
|
+
name: item,
|
|
128
|
+
value: item
|
|
129
|
+
};
|
|
130
|
+
}) : [];
|
|
131
|
+
});
|
|
132
|
+
}).catch(function (e) {
|
|
133
|
+
console.error(e);
|
|
134
|
+
setOptions([]);
|
|
135
|
+
});
|
|
99
136
|
};
|
|
100
137
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
headers: {
|
|
106
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
107
|
-
}
|
|
108
|
-
}).then(function (result) {
|
|
109
|
-
setOptions(function () {
|
|
110
|
-
return result && result.sources ? result.sources.map(function (item) {
|
|
111
|
-
return {
|
|
112
|
-
name: item,
|
|
113
|
-
value: item
|
|
114
|
-
};
|
|
115
|
-
}) : [];
|
|
116
|
-
});
|
|
117
|
-
}).catch(function (e) {
|
|
118
|
-
console.error(e);
|
|
119
|
-
setOptions([]);
|
|
120
|
-
});
|
|
138
|
+
if (timer) clearTimeout(timer);
|
|
139
|
+
setTimer(setTimeout(function () {
|
|
140
|
+
fetch();
|
|
141
|
+
}, 400));
|
|
121
142
|
|
|
122
|
-
case
|
|
143
|
+
case 3:
|
|
123
144
|
case "end":
|
|
124
145
|
return _context.stop();
|
|
125
146
|
}
|
|
@@ -127,7 +148,7 @@ var StringList = function StringList(props) {
|
|
|
127
148
|
}, _callee);
|
|
128
149
|
}));
|
|
129
150
|
|
|
130
|
-
return function fetchValues(
|
|
151
|
+
return function fetchValues() {
|
|
131
152
|
return _ref.apply(this, arguments);
|
|
132
153
|
};
|
|
133
154
|
}();
|
|
@@ -162,7 +183,8 @@ var StringList = function StringList(props) {
|
|
|
162
183
|
labelField: "name",
|
|
163
184
|
keyField: "value",
|
|
164
185
|
options: options,
|
|
165
|
-
onChange: onChange
|
|
186
|
+
onChange: onChange,
|
|
187
|
+
onSearch: setSearchValue
|
|
166
188
|
});
|
|
167
189
|
};
|
|
168
190
|
|
|
@@ -23,14 +23,13 @@ export default (function () {
|
|
|
23
23
|
|
|
24
24
|
var _useState = useState({
|
|
25
25
|
condition: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
category: 'fixed'
|
|
26
|
+
attrId: 30183426,
|
|
27
|
+
propCategory: 'eventProp',
|
|
28
|
+
type: 1,
|
|
29
|
+
operator: 'equal',
|
|
30
|
+
values: [],
|
|
31
|
+
dimensionSub: 'event_attr',
|
|
32
|
+
attrName: '公众号名称'
|
|
34
33
|
}
|
|
35
34
|
}),
|
|
36
35
|
_useState2 = _slicedToArray(_useState, 2),
|
package/es/select/handle.js
CHANGED
|
@@ -29,6 +29,7 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
29
29
|
|
|
30
30
|
var handleRef = useRef(null);
|
|
31
31
|
var inputRef = useRef(null);
|
|
32
|
+
var textRef = useRef();
|
|
32
33
|
|
|
33
34
|
var _useState3 = useState(''),
|
|
34
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
@@ -47,16 +48,12 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
setSearchValue('');
|
|
50
|
-
|
|
51
|
-
if (props.enableCreate && searchValue && !flag) {
|
|
52
|
-
if (props.onCreate) props.onCreate(searchValue);
|
|
53
|
-
}
|
|
54
51
|
},
|
|
55
52
|
width: handleRef.current.clientWidth
|
|
56
53
|
};
|
|
57
54
|
});
|
|
58
55
|
var searchInputWidth = useMemo(function () {
|
|
59
|
-
return
|
|
56
|
+
return textRef.current && searchValue ? textRef.current.offsetWidth : 3;
|
|
60
57
|
}, [searchValue]);
|
|
61
58
|
|
|
62
59
|
var onDelete = function onDelete(data) {
|
|
@@ -98,7 +95,10 @@ var SelectHandle = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
95
|
},
|
|
99
96
|
value: searchValue,
|
|
100
97
|
onChange: onSearch
|
|
101
|
-
})
|
|
98
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
99
|
+
className: "".concat(classPrefix, "-temp"),
|
|
100
|
+
ref: textRef
|
|
101
|
+
}, searchValue));
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
return /*#__PURE__*/React.createElement("div", {
|
package/es/select/index.js
CHANGED
|
@@ -132,28 +132,6 @@ var BizSelect = function BizSelect(props) {
|
|
|
132
132
|
if (props.onChange) props.onChange(data);
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
var onCreate = function onCreate(val) {
|
|
136
|
-
var _newItem;
|
|
137
|
-
|
|
138
|
-
var data = _.cloneDeep(current) || [];
|
|
139
|
-
var newItem = (_newItem = {}, _defineProperty(_newItem, keyField, val), _defineProperty(_newItem, labelField, val), _newItem);
|
|
140
|
-
var flag = false;
|
|
141
|
-
current === null || current === void 0 ? void 0 : current.forEach(function (item) {
|
|
142
|
-
if (item[labelField] === val) {
|
|
143
|
-
flag = true;
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
setSearchValue('');
|
|
148
|
-
|
|
149
|
-
if (!flag) {
|
|
150
|
-
newItem = getCheckedData(newItem);
|
|
151
|
-
data.push(newItem);
|
|
152
|
-
setCurrent(data);
|
|
153
|
-
if (props.onChange) props.onChange(data);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
135
|
var onChange = function onChange(option) {
|
|
158
136
|
setCurrent(option);
|
|
159
137
|
setSearchValue('');
|
|
@@ -166,6 +144,7 @@ var BizSelect = function BizSelect(props) {
|
|
|
166
144
|
};
|
|
167
145
|
|
|
168
146
|
var onVisibleChange = function onVisibleChange(flag) {
|
|
147
|
+
setSearchValue('');
|
|
169
148
|
setVisible(flag);
|
|
170
149
|
};
|
|
171
150
|
|
|
@@ -201,13 +180,14 @@ var BizSelect = function BizSelect(props) {
|
|
|
201
180
|
keyField: keyField,
|
|
202
181
|
disable: props.disable,
|
|
203
182
|
multiple: props.multiple,
|
|
204
|
-
enableCreate: props.enableCreate,
|
|
205
183
|
theme: props.theme,
|
|
206
184
|
size: props.size,
|
|
207
185
|
border: props.border,
|
|
208
186
|
onDelete: onDelete,
|
|
209
|
-
onSearch:
|
|
210
|
-
|
|
187
|
+
onSearch: function onSearch(v) {
|
|
188
|
+
setSearchValue(v);
|
|
189
|
+
if (props.onSearch) props.onSearch(v);
|
|
190
|
+
}
|
|
211
191
|
})));
|
|
212
192
|
};
|
|
213
193
|
|
package/es/select/overlay.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
1
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
4
|
|
|
3
5
|
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."); }
|
|
@@ -96,8 +98,20 @@ var SelectOverlay = function SelectOverlay(props) {
|
|
|
96
98
|
|
|
97
99
|
function getOptionDom(data, ids) {
|
|
98
100
|
var optionsDom = [];
|
|
99
|
-
|
|
101
|
+
|
|
102
|
+
var list = _.cloneDeep(data);
|
|
103
|
+
|
|
104
|
+
if (props.enableCreate && searchValue) {
|
|
105
|
+
var _list$push;
|
|
106
|
+
|
|
107
|
+
list.push((_list$push = {}, _defineProperty(_list$push, props.keyField, searchValue), _defineProperty(_list$push, props.labelField, searchValue), _defineProperty(_list$push, "isTemp", true), _list$push));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
var tempOption = null;
|
|
111
|
+
var useTemp = true;
|
|
112
|
+
list.forEach(function (option) {
|
|
100
113
|
if (searchValue && !new RegExp(searchValue, 'i').test(option[labelField])) return;
|
|
114
|
+
if (searchValue && searchValue === option[labelField] && !option.isTemp) useTemp = false;
|
|
101
115
|
var disabled = false;
|
|
102
116
|
disableItemList === null || disableItemList === void 0 ? void 0 : disableItemList.forEach(function (item) {
|
|
103
117
|
if (item[keyField] === option[keyField] && (!current || current && ids.indexOf(option[keyField]) < 0)) {
|
|
@@ -118,8 +132,19 @@ var SelectOverlay = function SelectOverlay(props) {
|
|
|
118
132
|
disabled: disabled,
|
|
119
133
|
key: option[keyField] || String(Math.random())
|
|
120
134
|
});
|
|
135
|
+
|
|
136
|
+
if (option.isTemp) {
|
|
137
|
+
tempOption = dom;
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
121
141
|
optionsDom.push(dom);
|
|
122
142
|
});
|
|
143
|
+
|
|
144
|
+
if (useTemp) {
|
|
145
|
+
optionsDom.push(tempOption);
|
|
146
|
+
}
|
|
147
|
+
|
|
123
148
|
return optionsDom;
|
|
124
149
|
}
|
|
125
150
|
|
package/es/select/types.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare namespace BizSelectTypes {
|
|
|
34
34
|
notFound?: string | ReactNode;
|
|
35
35
|
loading?: boolean;
|
|
36
36
|
onChange?: (val: Option) => void;
|
|
37
|
+
onSearch?: (val: string) => void;
|
|
37
38
|
}
|
|
38
39
|
interface OverlayProps {
|
|
39
40
|
option?: Option;
|
|
@@ -56,7 +57,6 @@ export interface HandlerTypes {
|
|
|
56
57
|
placeholder?: string;
|
|
57
58
|
value?: BizSelectTypes.Option | BizSelectTypes.Option[];
|
|
58
59
|
multiple?: boolean;
|
|
59
|
-
enableCreate?: boolean;
|
|
60
60
|
labelField?: string;
|
|
61
61
|
keyField?: string | number;
|
|
62
62
|
disable?: boolean;
|
|
@@ -65,5 +65,4 @@ export interface HandlerTypes {
|
|
|
65
65
|
border?: boolean;
|
|
66
66
|
onDelete?: (data: BizSelectTypes.Option) => void;
|
|
67
67
|
onSearch?: (val: string) => void;
|
|
68
|
-
onCreate?: (val: string) => void;
|
|
69
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"prettier": "^2.2.1",
|
|
60
60
|
"yorkie": "^2.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "572cbe41c1052ce19fa66b5c95b0e7738f2ceb6c"
|
|
63
63
|
}
|