@zgfe/business-lib 1.1.51 → 1.1.52
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/addToPanel/components/styleList.js +1 -1
- package/es/addToPanel/index.js +4 -0
- package/es/addToPanel/styles/style.less +6 -0
- package/es/addToScene/index.js +6 -14
- package/es/addToScene/types.d.ts +1 -1
- package/es/assets/iconfont/demo_index.html +233 -49
- package/es/assets/iconfont/iconfont.css +43 -11
- package/es/assets/iconfont/iconfont.js +7 -7
- package/es/assets/iconfont/iconfont.json +70 -14
- package/es/assets/iconfont/iconfont.ttf +0 -0
- package/es/assets/iconfont/iconfont.woff +0 -0
- package/es/assets/iconfont/iconfont.woff2 +0 -0
- package/es/attrCondition/demo/ajaxConfig.d.ts +8 -0
- package/es/attrCondition/demo/ajaxConfig.js +40 -0
- package/es/attrCondition/demo/group.d.ts +2 -0
- package/es/attrCondition/demo/group.js +29 -0
- package/es/attrCondition/demo/index.d.ts +2 -0
- package/es/attrCondition/demo/index.js +16 -0
- package/es/attrCondition/group.d.ts +4 -0
- package/es/attrCondition/group.js +59 -0
- package/es/attrCondition/index.d.ts +5 -0
- package/es/attrCondition/index.js +67 -0
- package/es/attrCondition/styles/index.less +74 -0
- package/es/attrCondition/useAttrCondition.d.ts +13 -0
- package/es/attrCondition/useAttrCondition.js +91 -0
- package/es/attrCondition/useConditionGroup.d.ts +10 -0
- package/es/attrCondition/useConditionGroup.js +127 -0
- package/es/attrConditions/components/operateList.js +7 -2
- package/es/attrConditions/components/stringList.js +7 -3
- package/es/attrConditions/components/valuesList.js +13 -7
- package/es/attrConditions/group.js +11 -118
- package/es/attrConditions/index.js +13 -79
- package/es/attrConditions/styles/index.less +0 -2
- package/es/attributeSelector/demo/index.js +4 -2
- package/es/attributeSelector/listPanel.js +2 -1
- package/es/constants/apis.js +2 -2
- package/es/datePicker/datePicker.d.ts +1 -0
- package/es/datePicker/datePicker.js +12 -3
- package/es/datePicker/demo/day.js +14 -2
- package/es/datePicker/index.js +18 -7
- package/es/datePicker/types.d.ts +1 -0
- package/es/demoWrapper/content.js +15 -15
- package/es/demoWrapper/head.js +4 -4
- package/es/demoWrapper/index.js +3 -2
- package/es/eventSelector/demo/index.js +2 -1
- package/es/eventSelector/index.js +2 -1
- package/es/eventSelector/listPanel.js +10 -3
- package/es/eventSelector/option.d.ts +1 -0
- package/es/eventSelector/option.js +4 -2
- package/es/eventSelector/styles/index.less +6 -0
- package/es/eventSelector/types.d.ts +2 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -1
- package/es/layout/optionTitle/index.js +2 -0
- package/es/select/option.js +1 -1
- package/es/utils/ajax.js +1 -3
- package/package.json +2 -2
|
@@ -5,6 +5,76 @@
|
|
|
5
5
|
"css_prefix_text": "",
|
|
6
6
|
"description": "诸葛业务平台",
|
|
7
7
|
"glyphs": [
|
|
8
|
+
{
|
|
9
|
+
"icon_id": "36023911",
|
|
10
|
+
"name": "归因",
|
|
11
|
+
"font_class": "guiyin",
|
|
12
|
+
"unicode": "e764",
|
|
13
|
+
"unicode_decimal": 59236
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"icon_id": "36017810",
|
|
17
|
+
"name": "筛选",
|
|
18
|
+
"font_class": "shaixuan",
|
|
19
|
+
"unicode": "e76e",
|
|
20
|
+
"unicode_decimal": 59246
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"icon_id": "36017811",
|
|
24
|
+
"name": "清除",
|
|
25
|
+
"font_class": "qingchu",
|
|
26
|
+
"unicode": "e759",
|
|
27
|
+
"unicode_decimal": 59225
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"icon_id": "35960341",
|
|
31
|
+
"name": "数据去重",
|
|
32
|
+
"font_class": "shujuquzhong",
|
|
33
|
+
"unicode": "e761",
|
|
34
|
+
"unicode_decimal": 59233
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"icon_id": "35960342",
|
|
38
|
+
"name": "替换缺失值",
|
|
39
|
+
"font_class": "tihuanqueshizhi",
|
|
40
|
+
"unicode": "e762",
|
|
41
|
+
"unicode_decimal": 59234
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"icon_id": "35892782",
|
|
45
|
+
"name": "播放",
|
|
46
|
+
"font_class": "bofang",
|
|
47
|
+
"unicode": "e75b",
|
|
48
|
+
"unicode_decimal": 59227
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"icon_id": "35892783",
|
|
52
|
+
"name": "方向上",
|
|
53
|
+
"font_class": "fangxiangshang",
|
|
54
|
+
"unicode": "e75c",
|
|
55
|
+
"unicode_decimal": 59228
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"icon_id": "35892784",
|
|
59
|
+
"name": "暂停",
|
|
60
|
+
"font_class": "zanting",
|
|
61
|
+
"unicode": "e75e",
|
|
62
|
+
"unicode_decimal": 59230
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"icon_id": "35892785",
|
|
66
|
+
"name": "音量",
|
|
67
|
+
"font_class": "yinliang",
|
|
68
|
+
"unicode": "e75f",
|
|
69
|
+
"unicode_decimal": 59231
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"icon_id": "35892786",
|
|
73
|
+
"name": "方向下",
|
|
74
|
+
"font_class": "fangxiangxia",
|
|
75
|
+
"unicode": "e760",
|
|
76
|
+
"unicode_decimal": 59232
|
|
77
|
+
},
|
|
8
78
|
{
|
|
9
79
|
"icon_id": "34970302",
|
|
10
80
|
"name": "用户",
|
|
@@ -642,13 +712,6 @@
|
|
|
642
712
|
"unicode": "e757",
|
|
643
713
|
"unicode_decimal": 59223
|
|
644
714
|
},
|
|
645
|
-
{
|
|
646
|
-
"icon_id": "28442442",
|
|
647
|
-
"name": "清除",
|
|
648
|
-
"font_class": "qingchu",
|
|
649
|
-
"unicode": "e759",
|
|
650
|
-
"unicode_decimal": 59225
|
|
651
|
-
},
|
|
652
715
|
{
|
|
653
716
|
"icon_id": "28442453",
|
|
654
717
|
"name": "向下",
|
|
@@ -656,13 +719,6 @@
|
|
|
656
719
|
"unicode": "e76d",
|
|
657
720
|
"unicode_decimal": 59245
|
|
658
721
|
},
|
|
659
|
-
{
|
|
660
|
-
"icon_id": "28444857",
|
|
661
|
-
"name": "筛选",
|
|
662
|
-
"font_class": "shaixuan",
|
|
663
|
-
"unicode": "e76e",
|
|
664
|
-
"unicode_decimal": 59246
|
|
665
|
-
},
|
|
666
722
|
{
|
|
667
723
|
"icon_id": "28447646",
|
|
668
724
|
"name": "添加",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
function setOptionWapper(url, options) {
|
|
3
|
+
var reqOption = _.cloneDeep(options);
|
|
4
|
+
if (/^\/v1|\.jsp$/.test(url)) {
|
|
5
|
+
if (reqOption.headers && reqOption.headers['Content-Type'] === 'application/x-www-form-urlencoded') {
|
|
6
|
+
return reqOption;
|
|
7
|
+
}
|
|
8
|
+
reqOption.headers = {
|
|
9
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
10
|
+
};
|
|
11
|
+
var transformRequest = function transformRequest(param) {
|
|
12
|
+
var arr = [];
|
|
13
|
+
for (var key in param) {
|
|
14
|
+
arr.push("".concat(key, "=").concat(encodeURIComponent(param[key])));
|
|
15
|
+
}
|
|
16
|
+
return arr.join('&');
|
|
17
|
+
};
|
|
18
|
+
reqOption.data = transformRequest(options.data);
|
|
19
|
+
}
|
|
20
|
+
return reqOption;
|
|
21
|
+
}
|
|
22
|
+
export var requestConfig = {
|
|
23
|
+
request: {
|
|
24
|
+
optionsWrapper: function optionsWrapper(url, options) {
|
|
25
|
+
var newUrl = url;
|
|
26
|
+
var reqOption = options;
|
|
27
|
+
var ajaxUrlReg = '/analysis/api/common/proxy';
|
|
28
|
+
if (/^\/v1|\.jsp$/.test(url)) {
|
|
29
|
+
if (ajaxUrlReg && !url.includes(ajaxUrlReg)) {
|
|
30
|
+
newUrl = ajaxUrlReg + url;
|
|
31
|
+
reqOption = setOptionWapper(url, options);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
url: newUrl,
|
|
36
|
+
options: reqOption
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import { BizAttrConditionGroup, DemoWrapper, setGlobalConfig } from '@zgfe/business-lib';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import { requestConfig } from './ajaxConfig';
|
|
5
|
+
export default (function () {
|
|
6
|
+
var groupRef = useRef(null);
|
|
7
|
+
useEffect(function () {
|
|
8
|
+
setGlobalConfig(requestConfig);
|
|
9
|
+
}, []);
|
|
10
|
+
return /*#__PURE__*/React.createElement(DemoWrapper, {
|
|
11
|
+
needMeta: true
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
style: {
|
|
14
|
+
padding: '16px',
|
|
15
|
+
background: '#fff'
|
|
16
|
+
}
|
|
17
|
+
}, /*#__PURE__*/React.createElement(BizAttrConditionGroup, {
|
|
18
|
+
ref: groupRef,
|
|
19
|
+
enableDelete: true
|
|
20
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
style: {
|
|
22
|
+
marginTop: '16px'
|
|
23
|
+
}
|
|
24
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
groupRef.current.add();
|
|
27
|
+
}
|
|
28
|
+
}, "\u6DFB\u52A0\u6761\u4EF6"))));
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BizAttrCondition, DemoWrapper } from '@zgfe/business-lib';
|
|
3
|
+
export default (function () {
|
|
4
|
+
return /*#__PURE__*/React.createElement(DemoWrapper, {
|
|
5
|
+
needMeta: true
|
|
6
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
7
|
+
style: {
|
|
8
|
+
padding: '16px',
|
|
9
|
+
background: '#fff'
|
|
10
|
+
}
|
|
11
|
+
}, /*#__PURE__*/React.createElement(BizAttrCondition, {
|
|
12
|
+
onChange: function onChange(condition) {
|
|
13
|
+
console.log(condition);
|
|
14
|
+
}
|
|
15
|
+
})));
|
|
16
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import useConditionGroup from './useConditionGroup';
|
|
3
|
+
import { Skeleton, Space } from 'antd';
|
|
4
|
+
import BizAttrCondition from '.';
|
|
5
|
+
var BizAttrConditionGroup = function BizAttrConditionGroup(props, ref) {
|
|
6
|
+
var eventIdList = props.eventIdList,
|
|
7
|
+
enableDelete = props.enableDelete,
|
|
8
|
+
enableEventProp = props.enableEventProp,
|
|
9
|
+
enableUserProp = props.enableUserProp,
|
|
10
|
+
enableEnvProp = props.enableEnvProp,
|
|
11
|
+
disableItemList = props.disableItemList;
|
|
12
|
+
var _useConditionGroup = useConditionGroup(props, ref),
|
|
13
|
+
loading = _useConditionGroup.loading,
|
|
14
|
+
conditions = _useConditionGroup.conditions,
|
|
15
|
+
_onChange = _useConditionGroup.onChange,
|
|
16
|
+
onClickRelation = _useConditionGroup.onClickRelation,
|
|
17
|
+
_onDelete = _useConditionGroup.onDelete,
|
|
18
|
+
relation = _useConditionGroup.relation;
|
|
19
|
+
var classPrefix = 'biz-attr-condition-group';
|
|
20
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: classPrefix
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Skeleton, {
|
|
23
|
+
loading: loading,
|
|
24
|
+
active: true,
|
|
25
|
+
paragraph: {
|
|
26
|
+
rows: 2
|
|
27
|
+
}
|
|
28
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "".concat(classPrefix, "-handle")
|
|
30
|
+
}, conditions.length > 1 && /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "".concat(classPrefix, "-operate"),
|
|
32
|
+
onClick: onClickRelation
|
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "".concat(classPrefix, "-operate-text ").concat(relation === 'and' || props.onlyAnd ? 'active' : '', " ").concat(props.onlyAnd ? 'only-and' : '')
|
|
35
|
+
}, "\u4E14"), !props.onlyAnd && /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "".concat(classPrefix, "-operate-text ").concat(relation === 'or' ? 'active' : '')
|
|
37
|
+
}, "\u6216"))), /*#__PURE__*/React.createElement(Space, {
|
|
38
|
+
className: "".concat(classPrefix, "-container"),
|
|
39
|
+
direction: "vertical"
|
|
40
|
+
}, conditions.map(function (item, index) {
|
|
41
|
+
return /*#__PURE__*/React.createElement(BizAttrCondition, {
|
|
42
|
+
key: item.key,
|
|
43
|
+
value: item.data,
|
|
44
|
+
eventIdList: eventIdList,
|
|
45
|
+
enableDelete: enableDelete,
|
|
46
|
+
enableEventProp: enableEventProp,
|
|
47
|
+
enableUserProp: enableUserProp,
|
|
48
|
+
enableEnvProp: enableEnvProp,
|
|
49
|
+
disableItemList: disableItemList,
|
|
50
|
+
onChange: function onChange(data) {
|
|
51
|
+
return _onChange(data, index);
|
|
52
|
+
},
|
|
53
|
+
onDelete: function onDelete() {
|
|
54
|
+
return _onDelete(index);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}))));
|
|
58
|
+
};
|
|
59
|
+
export default /*#__PURE__*/React.forwardRef(BizAttrConditionGroup);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Skeleton, Space } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import BizAttributeSelector from '../attributeSelector';
|
|
4
|
+
import BizOperateList from '../attrConditions/components/operateList';
|
|
5
|
+
import ValuesList from '../attrConditions/components/valuesList';
|
|
6
|
+
import useAttrCondition from './useAttrCondition';
|
|
7
|
+
import './styles/index.less';
|
|
8
|
+
import IconFont from '../icon/iconFont';
|
|
9
|
+
var classPrefix = 'biz-attr-condition';
|
|
10
|
+
var BizAttrCondition = function BizAttrCondition(props) {
|
|
11
|
+
var eventIdList = props.eventIdList,
|
|
12
|
+
enableDelete = props.enableDelete,
|
|
13
|
+
enableEventProp = props.enableEventProp,
|
|
14
|
+
enableUserProp = props.enableUserProp,
|
|
15
|
+
enableEnvProp = props.enableEnvProp,
|
|
16
|
+
disableItemList = props.disableItemList,
|
|
17
|
+
theme = props.theme;
|
|
18
|
+
var _useAttrCondition = useAttrCondition(props),
|
|
19
|
+
loading = _useAttrCondition.loading,
|
|
20
|
+
attr = _useAttrCondition.attr,
|
|
21
|
+
operate = _useAttrCondition.operate,
|
|
22
|
+
values = _useAttrCondition.values,
|
|
23
|
+
onChangeAttr = _useAttrCondition.onChangeAttr,
|
|
24
|
+
onChangeOperate = _useAttrCondition.onChangeOperate,
|
|
25
|
+
onChangeValues = _useAttrCondition.onChangeValues,
|
|
26
|
+
onDelete = _useAttrCondition.onDelete;
|
|
27
|
+
return /*#__PURE__*/React.createElement(Space, {
|
|
28
|
+
className: classPrefix
|
|
29
|
+
}, !loading ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BizAttributeSelector, {
|
|
30
|
+
value: attr,
|
|
31
|
+
eventIdList: eventIdList,
|
|
32
|
+
enableEventProp: enableEventProp,
|
|
33
|
+
enableUserProp: enableUserProp,
|
|
34
|
+
enableEnvProp: enableEnvProp,
|
|
35
|
+
disableItemList: disableItemList,
|
|
36
|
+
onChange: onChangeAttr,
|
|
37
|
+
theme: theme,
|
|
38
|
+
destroyPopupOnHide: props.destroyPopupOnHide,
|
|
39
|
+
placeholder: "\u8BF7\u9009\u62E9\u5C5E\u6027"
|
|
40
|
+
}), /*#__PURE__*/React.createElement(BizOperateList, {
|
|
41
|
+
theme: theme,
|
|
42
|
+
attr: attr,
|
|
43
|
+
defaultValue: operate,
|
|
44
|
+
onChange: onChangeOperate
|
|
45
|
+
}), /*#__PURE__*/React.createElement(ValuesList, {
|
|
46
|
+
attr: attr,
|
|
47
|
+
operate: operate,
|
|
48
|
+
defaultValue: values,
|
|
49
|
+
onChange: onChangeValues,
|
|
50
|
+
theme: theme
|
|
51
|
+
}), enableDelete && /*#__PURE__*/React.createElement(IconFont, {
|
|
52
|
+
type: "qingchu",
|
|
53
|
+
className: "".concat(classPrefix, "-btn-del"),
|
|
54
|
+
onClick: onDelete
|
|
55
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
56
|
+
active: true
|
|
57
|
+
}), /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
58
|
+
active: true
|
|
59
|
+
}), /*#__PURE__*/React.createElement(Skeleton.Input, {
|
|
60
|
+
active: true
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
63
|
+
BizAttrCondition.defaultProps = {
|
|
64
|
+
border: false,
|
|
65
|
+
theme: ''
|
|
66
|
+
};
|
|
67
|
+
export default BizAttrCondition;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
@import '../../assets/styles/inner.less';
|
|
2
|
+
.biz-attr-condition {
|
|
3
|
+
gap: 16px !important;
|
|
4
|
+
width: 100%;
|
|
5
|
+
&-btn-del {
|
|
6
|
+
color: #9aa1a9;
|
|
7
|
+
font-size: 20px !important;
|
|
8
|
+
&:hover {
|
|
9
|
+
color: @error-color;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
.biz-attr-select-handle {
|
|
14
|
+
width: 184px;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: none;
|
|
17
|
+
}
|
|
18
|
+
.ant-space-item:nth-of-type(3) {
|
|
19
|
+
min-width: 184px;
|
|
20
|
+
max-width: calc(100% - 320px);
|
|
21
|
+
}
|
|
22
|
+
&-group {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: row;
|
|
25
|
+
.ant-space-item:nth-of-type(3) {
|
|
26
|
+
min-width: 184px;
|
|
27
|
+
max-width: calc(100% - 380px);
|
|
28
|
+
}
|
|
29
|
+
&-container {
|
|
30
|
+
flex: 1;
|
|
31
|
+
gap: 12px !important;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
&-handle {
|
|
35
|
+
position: relative;
|
|
36
|
+
width: 1px;
|
|
37
|
+
margin-right: 16px;
|
|
38
|
+
margin-left: 8px;
|
|
39
|
+
background: @border-color-base;
|
|
40
|
+
}
|
|
41
|
+
&-operate {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 50%;
|
|
44
|
+
left: 50%;
|
|
45
|
+
width: 16px;
|
|
46
|
+
transform: translate(-50%, -50%);
|
|
47
|
+
}
|
|
48
|
+
&-operate-text {
|
|
49
|
+
width: 16px;
|
|
50
|
+
height: 16px;
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
line-height: 16px;
|
|
53
|
+
text-align: center;
|
|
54
|
+
|
|
55
|
+
.__default-hover();
|
|
56
|
+
|
|
57
|
+
&:first-child {
|
|
58
|
+
border-radius: @border-radius-sx @border-radius-sx 0px 0px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&:last-child {
|
|
62
|
+
border-radius: 0px 0px @border-radius-sx @border-radius-sx;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.active {
|
|
66
|
+
color: #fff;
|
|
67
|
+
background: @primary-color;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
&-operate-text.only-and {
|
|
71
|
+
border-radius: 2px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AttrConditionTypes } from '../attrConditions/types';
|
|
2
|
+
import { AttributeSelect } from '../attributeSelector/types';
|
|
3
|
+
declare const useAttrCondition: (props: AttrConditionTypes.ItemProp) => {
|
|
4
|
+
attr: AttributeSelect.Value | undefined;
|
|
5
|
+
operate: import("../attrConditions/types").OperateTypes | undefined;
|
|
6
|
+
values: string[] | undefined;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
onDelete: () => void;
|
|
9
|
+
onChangeAttr: (attrData: AttributeSelect.Value) => void;
|
|
10
|
+
onChangeOperate: (data: any) => void;
|
|
11
|
+
onChangeValues: (data: any) => void;
|
|
12
|
+
};
|
|
13
|
+
export default useAttrCondition;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
8
|
+
import { PropCategory } from '../attributeSelector/types';
|
|
9
|
+
import { getCondition } from '../attrConditions';
|
|
10
|
+
var useAttrCondition = function useAttrCondition(props) {
|
|
11
|
+
var _props$defaultValue, _props$value, _props$defaultValue2, _props$value2;
|
|
12
|
+
var _useState = useState(),
|
|
13
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
14
|
+
attr = _useState2[0],
|
|
15
|
+
setAttr = _useState2[1];
|
|
16
|
+
var _useState3 = useState(((_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.operator) || ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.operator)),
|
|
17
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
18
|
+
operate = _useState4[0],
|
|
19
|
+
setOperate = _useState4[1];
|
|
20
|
+
var _useState5 = useState(((_props$defaultValue2 = props.defaultValue) === null || _props$defaultValue2 === void 0 ? void 0 : _props$defaultValue2.values) || ((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.values)),
|
|
21
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
22
|
+
values = _useState6[0],
|
|
23
|
+
setValues = _useState6[1];
|
|
24
|
+
var _useState7 = useState(true),
|
|
25
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
26
|
+
loading = _useState8[0],
|
|
27
|
+
setLoading = _useState8[1];
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
var data = props.defaultValue || props.value;
|
|
30
|
+
if (data) {
|
|
31
|
+
var attrData;
|
|
32
|
+
if (data.propCategory === PropCategory.EventProp) {
|
|
33
|
+
if (data.attrId) {
|
|
34
|
+
attrData = {
|
|
35
|
+
id: data.attrId,
|
|
36
|
+
propCategory: data.propCategory,
|
|
37
|
+
type: data.type,
|
|
38
|
+
key: data.attrId,
|
|
39
|
+
label: data.label,
|
|
40
|
+
dimensionSub: data.dimensionSub || 'event_attr'
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
} else if (data.propCategory === PropCategory.UserProp || data.propCategory === PropCategory.EnvProp) {
|
|
44
|
+
if (data.attrName) {
|
|
45
|
+
var aId = data.attrId || 0;
|
|
46
|
+
attrData = {
|
|
47
|
+
id: aId,
|
|
48
|
+
name: data.attrName,
|
|
49
|
+
propCategory: data.propCategory,
|
|
50
|
+
type: data.type,
|
|
51
|
+
category: data.category,
|
|
52
|
+
key: "".concat(data.propCategory, "-").concat(data.dimensionSub || data.attrName, "-").concat(aId),
|
|
53
|
+
subtype: data.subtype,
|
|
54
|
+
dimensionSub: data.dimensionSub || data.attrName
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setAttr(attrData);
|
|
59
|
+
}
|
|
60
|
+
setLoading(false);
|
|
61
|
+
}, []);
|
|
62
|
+
var onDelete = function onDelete() {
|
|
63
|
+
if (props.onDelete) props.onDelete();
|
|
64
|
+
};
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
if (props.onChange) {
|
|
67
|
+
if (!attr) return;
|
|
68
|
+
props.onChange(getCondition(attr, operate, values));
|
|
69
|
+
}
|
|
70
|
+
}, [attr, operate, values]);
|
|
71
|
+
var onChangeAttr = function onChangeAttr(attrData) {
|
|
72
|
+
setAttr(attrData);
|
|
73
|
+
};
|
|
74
|
+
var onChangeOperate = function onChangeOperate(data) {
|
|
75
|
+
setOperate(data);
|
|
76
|
+
};
|
|
77
|
+
var onChangeValues = function onChangeValues(data) {
|
|
78
|
+
setValues(data);
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
attr: attr,
|
|
82
|
+
operate: operate,
|
|
83
|
+
values: values,
|
|
84
|
+
loading: loading,
|
|
85
|
+
onDelete: onDelete,
|
|
86
|
+
onChangeAttr: onChangeAttr,
|
|
87
|
+
onChangeOperate: onChangeOperate,
|
|
88
|
+
onChangeValues: onChangeValues
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export default useAttrCondition;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AttrConditionTypes } from '../attrConditions/types';
|
|
2
|
+
declare const useConditionGroup: (props: AttrConditionTypes.GroupProp, ref: React.ForwardedRef<any>) => {
|
|
3
|
+
relation: "and" | "or";
|
|
4
|
+
conditions: AttrConditionTypes.GroupAddKey[];
|
|
5
|
+
loading: boolean;
|
|
6
|
+
onClickRelation: (e: any) => void;
|
|
7
|
+
onChange: (data: AttrConditionTypes.ItemValue, index: number) => void;
|
|
8
|
+
onDelete: (index: number) => void;
|
|
9
|
+
};
|
|
10
|
+
export default useConditionGroup;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import { useState, useEffect, useImperativeHandle } from 'react';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
var useConditionGroup = function useConditionGroup(props, ref) {
|
|
14
|
+
var onConditionsCount = props.onConditionsCount;
|
|
15
|
+
var _useState = useState('and'),
|
|
16
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
17
|
+
relation = _useState2[0],
|
|
18
|
+
setRelation = _useState2[1];
|
|
19
|
+
var _useState3 = useState([]),
|
|
20
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
21
|
+
conditions = _useState4[0],
|
|
22
|
+
setConditions = _useState4[1];
|
|
23
|
+
var _useState5 = useState(true),
|
|
24
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
25
|
+
loading = _useState6[0],
|
|
26
|
+
setLoading = _useState6[1];
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
var data = props.defaultValue || props.value;
|
|
29
|
+
if (data) {
|
|
30
|
+
if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
|
|
31
|
+
if (data.conditions) {
|
|
32
|
+
setConditions(function () {
|
|
33
|
+
return addKeyToGroup(data.conditions);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
setLoading(false);
|
|
38
|
+
}, []);
|
|
39
|
+
useImperativeHandle(ref, function () {
|
|
40
|
+
return {
|
|
41
|
+
add: function add() {
|
|
42
|
+
onConditionsCount && onConditionsCount(conditions.length + 1);
|
|
43
|
+
setConditions(function (conditions) {
|
|
44
|
+
conditions.push({
|
|
45
|
+
key: Math.random()
|
|
46
|
+
});
|
|
47
|
+
return _toConsumableArray(conditions);
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
setValue: function setValue(data) {
|
|
51
|
+
if (data) {
|
|
52
|
+
if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
|
|
53
|
+
if (data.conditions) {
|
|
54
|
+
setConditions(function () {
|
|
55
|
+
return addKeyToGroup(data.conditions);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
setRelation('and');
|
|
60
|
+
setConditions([]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
var addKeyToGroup = function addKeyToGroup(data) {
|
|
66
|
+
return data.map(function (item) {
|
|
67
|
+
return {
|
|
68
|
+
key: Math.random(),
|
|
69
|
+
data: item
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var removeKeyToGroup = function removeKeyToGroup(data) {
|
|
74
|
+
var group = [];
|
|
75
|
+
data.forEach(function (item) {
|
|
76
|
+
if (item.data) group.push(item.data);
|
|
77
|
+
});
|
|
78
|
+
return group;
|
|
79
|
+
};
|
|
80
|
+
var onClickRelation = function onClickRelation(e) {
|
|
81
|
+
e.stopPropagation();
|
|
82
|
+
var data = e.target.innerText === '且' ? 'and' : 'or';
|
|
83
|
+
setRelation(data);
|
|
84
|
+
if (props.onChange) {
|
|
85
|
+
var group = removeKeyToGroup(conditions);
|
|
86
|
+
props.onChange({
|
|
87
|
+
relation: data,
|
|
88
|
+
conditions: group
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var onChange = function onChange(data, index) {
|
|
93
|
+
var conditionArr = _.cloneDeep(conditions);
|
|
94
|
+
conditionArr[index].data = data;
|
|
95
|
+
setConditions(conditionArr);
|
|
96
|
+
onConditionsCount && onConditionsCount(conditionArr.length);
|
|
97
|
+
if (props.onChange) {
|
|
98
|
+
var group = removeKeyToGroup(conditionArr);
|
|
99
|
+
props.onChange({
|
|
100
|
+
relation: relation,
|
|
101
|
+
conditions: group
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var onDelete = function onDelete(index) {
|
|
106
|
+
var conditionArr = _.cloneDeep(conditions);
|
|
107
|
+
conditionArr.splice(index, 1);
|
|
108
|
+
setConditions(conditionArr);
|
|
109
|
+
onConditionsCount && onConditionsCount(conditionArr.length);
|
|
110
|
+
if (props.onChange) {
|
|
111
|
+
var group = removeKeyToGroup(conditionArr);
|
|
112
|
+
props.onChange({
|
|
113
|
+
relation: relation,
|
|
114
|
+
conditions: group
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
relation: relation,
|
|
120
|
+
conditions: conditions,
|
|
121
|
+
loading: loading,
|
|
122
|
+
onClickRelation: onClickRelation,
|
|
123
|
+
onChange: onChange,
|
|
124
|
+
onDelete: onDelete
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export default useConditionGroup;
|