@zgfe/business-lib 1.1.40 → 1.1.41-attribution.2

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.
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,25 @@
1
+ import React, { useRef } from 'react';
2
+ import { BizAttrConditionGroup, DemoWrapper } from '@zgfe/business-lib';
3
+ import { Button } from 'antd';
4
+ export default (function () {
5
+ var groupRef = useRef(null);
6
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
7
+ needMeta: true
8
+ }, /*#__PURE__*/React.createElement("div", {
9
+ style: {
10
+ padding: '16px',
11
+ background: '#fff'
12
+ }
13
+ }, /*#__PURE__*/React.createElement(BizAttrConditionGroup, {
14
+ ref: groupRef,
15
+ enableDelete: true
16
+ }), /*#__PURE__*/React.createElement("div", {
17
+ style: {
18
+ marginTop: '16px'
19
+ }
20
+ }, /*#__PURE__*/React.createElement(Button, {
21
+ onClick: function onClick() {
22
+ groupRef.current.add();
23
+ }
24
+ }, "\u6DFB\u52A0\u6761\u4EF6"))));
25
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -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,4 @@
1
+ import React from 'react';
2
+ import { AttrConditionTypes } from '../attrConditions/types';
3
+ declare const _default: React.ForwardRefExoticComponent<AttrConditionTypes.GroupProp & React.RefAttributes<any>>;
4
+ export default _default;
@@ -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' : '')
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,5 @@
1
+ import React from 'react';
2
+ import { AttrConditionTypes } from '../attrConditions/types';
3
+ import './styles/index.less';
4
+ declare const BizAttrCondition: React.FC<AttrConditionTypes.ItemProp>;
5
+ export default BizAttrCondition;
@@ -0,0 +1,66 @@
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
+ }), /*#__PURE__*/React.createElement(BizOperateList, {
40
+ theme: theme,
41
+ attr: attr,
42
+ defaultValue: operate,
43
+ onChange: onChangeOperate
44
+ }), /*#__PURE__*/React.createElement(ValuesList, {
45
+ attr: attr,
46
+ operate: operate,
47
+ defaultValue: values,
48
+ onChange: onChangeValues,
49
+ theme: theme
50
+ }), enableDelete && /*#__PURE__*/React.createElement(IconFont, {
51
+ type: "qingchu",
52
+ className: "".concat(classPrefix, "-btn-del"),
53
+ onClick: onDelete
54
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Skeleton.Input, {
55
+ active: true
56
+ }), /*#__PURE__*/React.createElement(Skeleton.Input, {
57
+ active: true
58
+ }), /*#__PURE__*/React.createElement(Skeleton.Input, {
59
+ active: true
60
+ })));
61
+ };
62
+ BizAttrCondition.defaultProps = {
63
+ border: false,
64
+ theme: ''
65
+ };
66
+ export default BizAttrCondition;
@@ -0,0 +1,61 @@
1
+ @import '../../assets/styles/inner.less';
2
+ .biz-attr-condition {
3
+ &-btn-del {
4
+ color: #9aa1a9;
5
+ &:hover {
6
+ color: @error-color;
7
+ cursor: pointer;
8
+ }
9
+ }
10
+ .biz-attr-select-handle {
11
+ width: 184px;
12
+ padding: 0;
13
+ border: none;
14
+ }
15
+ .ant-space-item:nth-of-type(3) {
16
+ width: 184px;
17
+ }
18
+ &-group {
19
+ display: flex;
20
+ flex-direction: row;
21
+ &-container {
22
+ flex: 1;
23
+ }
24
+ &-handle {
25
+ position: relative;
26
+ width: 1px;
27
+ margin-right: 16px;
28
+ margin-left: 8px;
29
+ background: @border-color-base;
30
+ }
31
+ &-operate {
32
+ position: absolute;
33
+ top: 50%;
34
+ left: 50%;
35
+ width: 16px;
36
+ transform: translate(-50%, -50%);
37
+ }
38
+ &-operate-text {
39
+ width: 16px;
40
+ height: 16px;
41
+ font-size: 12px;
42
+ line-height: 16px;
43
+ text-align: center;
44
+
45
+ .__default-hover();
46
+
47
+ &:first-child {
48
+ border-radius: @border-radius-sx @border-radius-sx 0px 0px;
49
+ }
50
+
51
+ &:last-child {
52
+ border-radius: 0px 0px @border-radius-sx @border-radius-sx;
53
+ }
54
+
55
+ &.active {
56
+ color: #fff;
57
+ background: @primary-color;
58
+ }
59
+ }
60
+ }
61
+ }
@@ -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;
@@ -1,134 +1,27 @@
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 React, { useEffect, useImperativeHandle, useState } from 'react';
1
+ import React from 'react';
12
2
  import BizConditionItem from './index';
13
3
  import './styles/group.less';
14
- import _ from 'lodash';
15
4
  import { Skeleton } from 'antd';
5
+ import useConditionGroup from '../attrCondition/useConditionGroup';
16
6
  var BizConditionGroup = function BizConditionGroup(props, ref) {
17
7
  var eventIdList = props.eventIdList,
18
8
  enableDelete = props.enableDelete,
19
9
  enableEventProp = props.enableEventProp,
20
10
  enableUserProp = props.enableUserProp,
21
11
  enableEnvProp = props.enableEnvProp,
22
- disableItemList = props.disableItemList,
23
- onConditionsCount = props.onConditionsCount;
24
- var _useState = useState('and'),
25
- _useState2 = _slicedToArray(_useState, 2),
26
- relation = _useState2[0],
27
- setRelation = _useState2[1];
28
- var _useState3 = useState([]),
29
- _useState4 = _slicedToArray(_useState3, 2),
30
- conditions = _useState4[0],
31
- setConditions = _useState4[1];
32
- var _useState5 = useState(true),
33
- _useState6 = _slicedToArray(_useState5, 2),
34
- ready = _useState6[0],
35
- setReady = _useState6[1];
12
+ disableItemList = props.disableItemList;
13
+ var _useConditionGroup = useConditionGroup(props, ref),
14
+ loading = _useConditionGroup.loading,
15
+ conditions = _useConditionGroup.conditions,
16
+ _onChange = _useConditionGroup.onChange,
17
+ onClickRelation = _useConditionGroup.onClickRelation,
18
+ _onDelete = _useConditionGroup.onDelete,
19
+ relation = _useConditionGroup.relation;
36
20
  var classPrefix = 'biz-condition';
37
- useEffect(function () {
38
- var data = props.defaultValue || props.value;
39
- if (data) {
40
- if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
41
- if (data.conditions) {
42
- setConditions(function () {
43
- return addKeyToGroup(data.conditions);
44
- });
45
- }
46
- }
47
- setReady(false);
48
- }, []);
49
- useImperativeHandle(ref, function () {
50
- return {
51
- add: function add() {
52
- onConditionsCount && onConditionsCount(conditions.length + 1);
53
- setConditions(function (conditions) {
54
- conditions.push({
55
- key: Math.random()
56
- });
57
- return _toConsumableArray(conditions);
58
- });
59
- },
60
- setValue: function setValue(data) {
61
- if (data) {
62
- if (data.relation) setRelation(props.onlyAnd ? 'and' : data.relation);
63
- if (data.conditions) {
64
- setConditions(function () {
65
- return addKeyToGroup(data.conditions);
66
- });
67
- }
68
- } else {
69
- setRelation('and');
70
- setConditions([]);
71
- }
72
- }
73
- };
74
- });
75
- var addKeyToGroup = function addKeyToGroup(data) {
76
- return data.map(function (item) {
77
- return {
78
- key: Math.random(),
79
- data: item
80
- };
81
- });
82
- };
83
- var removeKeyToGroup = function removeKeyToGroup(data) {
84
- var group = [];
85
- data.forEach(function (item) {
86
- if (item.data) group.push(item.data);
87
- });
88
- return group;
89
- };
90
- var onClickRelation = function onClickRelation(e) {
91
- e.stopPropagation();
92
- var data = e.target.innerText === '且' ? 'and' : 'or';
93
- setRelation(data);
94
- if (props.onChange) {
95
- var group = removeKeyToGroup(conditions);
96
- props.onChange({
97
- relation: data,
98
- conditions: group
99
- });
100
- }
101
- };
102
- var _onChange = function onChange(data, index) {
103
- var conditionArr = _.cloneDeep(conditions);
104
- conditionArr[index].data = data;
105
- setConditions(conditionArr);
106
- onConditionsCount && onConditionsCount(conditionArr.length);
107
- if (props.onChange) {
108
- var group = removeKeyToGroup(conditionArr);
109
- props.onChange({
110
- relation: relation,
111
- conditions: group
112
- });
113
- }
114
- };
115
- var _onDelete = function onDelete(index) {
116
- var conditionArr = _.cloneDeep(conditions);
117
- conditionArr.splice(index, 1);
118
- setConditions(conditionArr);
119
- onConditionsCount && onConditionsCount(conditionArr.length);
120
- if (props.onChange) {
121
- var group = removeKeyToGroup(conditionArr);
122
- props.onChange({
123
- relation: relation,
124
- conditions: group
125
- });
126
- }
127
- };
128
21
  return /*#__PURE__*/React.createElement("div", {
129
22
  className: classPrefix
130
23
  }, /*#__PURE__*/React.createElement(Skeleton, {
131
- loading: ready,
24
+ loading: loading,
132
25
  active: true,
133
26
  paragraph: {
134
27
  rows: 2
@@ -1,16 +1,11 @@
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 React, { useEffect, useState } from 'react';
1
+ import React from 'react';
8
2
  import BizAttributeSelector from '../attributeSelector';
9
3
  import { PropCategory } from '../attributeSelector/types';
10
4
  import './styles/index.less';
11
5
  import BizOperateList from './components/operateList';
12
6
  import ValuesList from './components/valuesList';
13
7
  import { Skeleton } from 'antd';
8
+ import useAttrCondition from '../attrCondition/useAttrCondition';
14
9
  export var classPrefix = 'biz-condition-item';
15
10
  export function getCondition(attr, operate, values) {
16
11
  if (!attr) return;
@@ -35,9 +30,7 @@ export function getCondition(attr, operate, values) {
35
30
  return responseData;
36
31
  }
37
32
  var BizConditionItem = function BizConditionItem(props) {
38
- var _props$defaultValue, _props$value, _props$defaultValue2, _props$value2;
39
- var defaultValue = props.defaultValue,
40
- eventIdList = props.eventIdList,
33
+ var eventIdList = props.eventIdList,
41
34
  enableDelete = props.enableDelete,
42
35
  enableEventProp = props.enableEventProp,
43
36
  enableUserProp = props.enableUserProp,
@@ -45,78 +38,19 @@ var BizConditionItem = function BizConditionItem(props) {
45
38
  disableItemList = props.disableItemList,
46
39
  border = props.border,
47
40
  theme = props.theme;
48
- var _useState = useState(),
49
- _useState2 = _slicedToArray(_useState, 2),
50
- attr = _useState2[0],
51
- setAttr = _useState2[1];
52
- 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)),
53
- _useState4 = _slicedToArray(_useState3, 2),
54
- operate = _useState4[0],
55
- setOperate = _useState4[1];
56
- 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)),
57
- _useState6 = _slicedToArray(_useState5, 2),
58
- values = _useState6[0],
59
- setValues = _useState6[1];
60
- var _useState7 = useState(true),
61
- _useState8 = _slicedToArray(_useState7, 2),
62
- ready = _useState8[0],
63
- setReady = _useState8[1];
64
- useEffect(function () {
65
- var data = defaultValue || props.value;
66
- if (data) {
67
- var attrData;
68
- if (data.propCategory === PropCategory.EventProp) {
69
- if (data.attrId) {
70
- attrData = {
71
- id: data.attrId,
72
- propCategory: data.propCategory,
73
- type: data.type,
74
- key: data.attrId,
75
- label: data.label,
76
- dimensionSub: data.dimensionSub || 'event_attr'
77
- };
78
- }
79
- } else if (data.propCategory === PropCategory.UserProp || data.propCategory === PropCategory.EnvProp) {
80
- if (data.attrName) {
81
- var aId = data.attrId || 0;
82
- attrData = {
83
- id: aId,
84
- name: data.attrName,
85
- propCategory: data.propCategory,
86
- type: data.type,
87
- category: data.category,
88
- key: "".concat(data.propCategory, "-").concat(data.dimensionSub || data.attrName, "-").concat(aId),
89
- subtype: data.subtype,
90
- dimensionSub: data.dimensionSub || data.attrName
91
- };
92
- }
93
- }
94
- setAttr(attrData);
95
- }
96
- setReady(false);
97
- }, []);
98
- var onDelete = function onDelete() {
99
- if (props.onDelete) props.onDelete();
100
- };
101
- useEffect(function () {
102
- if (props.onChange) {
103
- if (!attr) return;
104
- props.onChange(getCondition(attr, operate, values));
105
- }
106
- }, [attr, operate, values]);
107
- var onChangeAttr = function onChangeAttr(attrData) {
108
- setAttr(attrData);
109
- };
110
- var onChangeOperate = function onChangeOperate(data) {
111
- setOperate(data);
112
- };
113
- var onChangeValues = function onChangeValues(data) {
114
- setValues(data);
115
- };
41
+ var _useAttrCondition = useAttrCondition(props),
42
+ loading = _useAttrCondition.loading,
43
+ attr = _useAttrCondition.attr,
44
+ operate = _useAttrCondition.operate,
45
+ values = _useAttrCondition.values,
46
+ onChangeAttr = _useAttrCondition.onChangeAttr,
47
+ onChangeOperate = _useAttrCondition.onChangeOperate,
48
+ onChangeValues = _useAttrCondition.onChangeValues,
49
+ onDelete = _useAttrCondition.onDelete;
116
50
  return /*#__PURE__*/React.createElement("div", {
117
51
  className: [classPrefix, border ? 'border' : ''].join(' ')
118
52
  }, /*#__PURE__*/React.createElement(Skeleton, {
119
- loading: ready,
53
+ loading: loading,
120
54
  active: true,
121
55
  paragraph: {
122
56
  rows: 2
@@ -113,7 +113,8 @@ var AttrListPanel = function AttrListPanel(props) {
113
113
  var showList = function () {
114
114
  var list = [];
115
115
  optionList.map(function (group) {
116
- if (!group.children.length) return;
116
+ var _group$children;
117
+ if (!((_group$children = group.children) === null || _group$children === void 0 ? void 0 : _group$children.length)) return;
117
118
  var head = /*#__PURE__*/React.createElement(Option, {
118
119
  group: group,
119
120
  key: group.key
package/es/index.d.ts CHANGED
@@ -30,7 +30,9 @@ import BizDetailLayout from './layout/detail';
30
30
  import BizLoginForm from './loginForm';
31
31
  import DemoWrapper from './demoWrapper';
32
32
  import SocketClient from './socket';
33
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, ColorIcon, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
33
+ import BizAttrCondition from './attrCondition';
34
+ import BizAttrConditionGroup from './attrCondition/group';
35
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, ColorIcon, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizAttrCondition, BizAttrConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
34
36
  export type { UserGroupTypes } from './userGroup/types';
35
37
  export type { BizSelectTypes } from './select/types';
36
38
  export type { AttributeSelect } from './attributeSelector/types';
package/es/index.js CHANGED
@@ -29,4 +29,6 @@ import BizDetailLayout from './layout/detail';
29
29
  import BizLoginForm from './loginForm';
30
30
  import DemoWrapper from './demoWrapper';
31
31
  import SocketClient from './socket';
32
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, ColorIcon, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
32
+ import BizAttrCondition from './attrCondition';
33
+ import BizAttrConditionGroup from './attrCondition/group';
34
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizDetailLayout, BizUserGroup, IconFont, ColorIcon, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizAttrCondition, BizAttrConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.1.40",
3
+ "version": "1.1.41-attribution.2",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -59,5 +59,5 @@
59
59
  "react": "^16.12.0 || ^17.0.0",
60
60
  "yorkie": "^2.0.0"
61
61
  },
62
- "gitHead": "591e8c635d8c93a6c17c88a38f8d3b89b433841f"
62
+ "gitHead": "33fd28c8387c8185dd349bbd0e2eb7b473523a60"
63
63
  }