@zgfe/business-lib 1.0.14 → 1.0.15-user.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/assets/styles/chunks.less +3 -4
- package/es/assets/styles/resetAntd.less +36 -1
- package/es/attrConditions/components/operateList.d.ts +1 -0
- package/es/attrConditions/components/operateList.js +2 -2
- package/es/attrConditions/components/stringList.d.ts +1 -0
- package/es/attrConditions/components/stringList.js +2 -2
- package/es/attrConditions/components/valuesList.d.ts +1 -0
- package/es/attrConditions/components/valuesList.js +5 -4
- package/es/attrConditions/demo/index.js +7 -8
- package/es/attrConditions/index.js +14 -4
- package/es/attrConditions/styles/index.less +3 -2
- package/es/attrConditions/types.d.ts +3 -0
- package/es/attrConditions/utils/operates.js +2 -2
- package/es/attributeSelector/index.js +8 -4
- package/es/attributeSelector/listPanel.js +32 -19
- package/es/attributeSelector/styles/index.less +3 -3
- package/es/attributeSelector/types.d.ts +7 -0
- package/es/attributeSelector/types.js +8 -1
- package/es/attributeSelector/util.js +3 -2
- package/es/eventSelector/demo/index.js +11 -2
- package/es/eventSelector/index.js +40 -7
- package/es/eventSelector/listPanel.js +37 -22
- package/es/eventSelector/styles/index.less +5 -3
- package/es/eventSelector/types.d.ts +7 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/mock/event.js +214 -0
- package/es/select/demo/children.d.ts +2 -0
- package/es/select/demo/children.js +81 -0
- package/es/select/demo/index.js +10 -4
- package/es/select/demo/multiple.js +10 -3
- package/es/select/handle.js +4 -2
- package/es/select/index.d.ts +2 -2
- package/es/select/index.js +14 -7
- package/es/select/overlay.js +1 -1
- package/es/select/styles/handle.less +22 -13
- package/es/select/types.d.ts +3 -1
- package/es/userCondition/conditionTypeList.js +14 -3
- package/es/userCondition/conditionWrap.js +4 -2
- package/es/userCondition/conditions/constants.d.ts +21 -0
- package/es/userCondition/conditions/constants.js +21 -0
- package/es/userCondition/conditions/eventCondition.js +13 -4
- package/es/userCondition/conditions/periodCondition.js +20 -10
- package/es/userCondition/conditions/propCondition.js +28 -8
- package/es/userCondition/conditions/runTimesCondition.js +2 -2
- package/es/userCondition/conditions/styles/eventCondition.less +7 -5
- package/es/userCondition/conditions/styles/propCondition.less +3 -3
- package/es/userCondition/conditions/styles/tagsCondition.less +18 -0
- package/es/userCondition/conditions/styles/textDesc.less +17 -0
- package/es/userCondition/conditions/tagsCondition.d.ts +9 -0
- package/es/userCondition/conditions/tagsCondition.js +107 -0
- package/es/userCondition/conditions/textDesc.d.ts +9 -0
- package/es/userCondition/conditions/textDesc.js +197 -0
- package/es/userCondition/demo/index.js +200 -31
- package/es/userCondition/index.d.ts +1 -1
- package/es/userCondition/index.js +31 -10
- package/es/userCondition/orConditions.js +64 -17
- package/es/userCondition/relationLabel.js +6 -1
- package/es/userCondition/styles/conditionTypeList.less +1 -1
- package/es/userCondition/styles/conditionWrap.less +3 -0
- package/es/userCondition/styles/index.less +19 -0
- package/es/userCondition/styles/orConditions.less +13 -0
- package/es/userCondition/types.d.ts +21 -2
- package/es/userCondition/util.d.ts +5 -1
- package/es/userCondition/util.js +42 -0
- package/es/userTagsSelector/cascaderOverlay.d.ts +5 -0
- package/es/userTagsSelector/cascaderOverlay.js +114 -0
- package/es/userTagsSelector/components/search/index.d.ts +8 -0
- package/es/userTagsSelector/components/search/index.js +16 -0
- package/es/userTagsSelector/components/search/index.less +6 -0
- package/es/userTagsSelector/context.d.ts +3 -0
- package/es/userTagsSelector/context.js +2 -0
- package/es/userTagsSelector/demo/index.d.ts +2 -0
- package/es/userTagsSelector/demo/index.js +48 -0
- package/es/userTagsSelector/groups/groupOption.d.ts +5 -0
- package/es/userTagsSelector/groups/groupOption.js +42 -0
- package/es/userTagsSelector/groups/index.d.ts +4 -0
- package/es/userTagsSelector/groups/index.js +86 -0
- package/es/userTagsSelector/groups/styles/index.less +0 -0
- package/es/userTagsSelector/groups/styles/option.less +50 -0
- package/es/userTagsSelector/index.d.ts +6 -0
- package/es/userTagsSelector/index.js +110 -0
- package/es/userTagsSelector/multipleCheckPanel/checkOption.d.ts +5 -0
- package/es/userTagsSelector/multipleCheckPanel/checkOption.js +45 -0
- package/es/userTagsSelector/multipleCheckPanel/index.d.ts +4 -0
- package/es/userTagsSelector/multipleCheckPanel/index.js +80 -0
- package/es/userTagsSelector/multipleCheckPanel/styles/index.less +0 -0
- package/es/userTagsSelector/multipleCheckPanel/styles/option.less +39 -0
- package/es/userTagsSelector/styles/cascaderOverlay.less +27 -0
- package/es/userTagsSelector/styles/index.less +10 -0
- package/es/userTagsSelector/types.d.ts +67 -0
- package/es/userTagsSelector/types.js +1 -0
- package/es/userTagsSelector/util.d.ts +4 -0
- package/es/userTagsSelector/util.js +38 -0
- package/es/utils/type.d.ts +2 -2
- package/package.json +4 -2
|
@@ -29,13 +29,18 @@ import { buildCondition } from './util';
|
|
|
29
29
|
import ConditionWrap from './conditionWrap';
|
|
30
30
|
import PropCondition from './conditions/propCondition';
|
|
31
31
|
import EventCondition from './conditions/eventCondition';
|
|
32
|
+
import TagsCondition from './conditions/tagsCondition';
|
|
32
33
|
import { classPrefix } from '.';
|
|
34
|
+
import Text from './conditions/textDesc';
|
|
33
35
|
|
|
34
36
|
var OrConditions = function OrConditions(props) {
|
|
35
37
|
var _useContext = useContext(BizUserConditionContext),
|
|
36
|
-
orConditionNum = _useContext.orConditionNum
|
|
38
|
+
orConditionNum = _useContext.orConditionNum,
|
|
39
|
+
textMode = _useContext.textMode,
|
|
40
|
+
openTagCondition = _useContext.openTagCondition;
|
|
37
41
|
|
|
38
|
-
var orConditions = props.orConditions
|
|
42
|
+
var orConditions = props.orConditions,
|
|
43
|
+
showAndDesc = props.showAndDesc;
|
|
39
44
|
|
|
40
45
|
var _useState = useState([]),
|
|
41
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -117,6 +122,31 @@ var OrConditions = function OrConditions(props) {
|
|
|
117
122
|
props.onChange(newValue);
|
|
118
123
|
}
|
|
119
124
|
|
|
125
|
+
function onChangeTags(id, newTags) {
|
|
126
|
+
changeData('tag', id, newTags);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function changeData(type, id, newData) {
|
|
130
|
+
var newValue = [];
|
|
131
|
+
showList.forEach(function (data) {
|
|
132
|
+
if (id === data.id) {
|
|
133
|
+
if (type === 'period') {
|
|
134
|
+
data.condition.runPeriod = newData;
|
|
135
|
+
} else if (type === 'attr') {
|
|
136
|
+
data.condition.attrs = newData;
|
|
137
|
+
} else if (type === 'event') {
|
|
138
|
+
data.condition = newData;
|
|
139
|
+
} else if (type === 'tag') {
|
|
140
|
+
data.condition.labels = newData;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
newValue.push(data.condition);
|
|
145
|
+
});
|
|
146
|
+
setShowList(_toConsumableArray(showList));
|
|
147
|
+
props.onChange(newValue);
|
|
148
|
+
}
|
|
149
|
+
|
|
120
150
|
function onDelete(id) {
|
|
121
151
|
var index = showList.findIndex(function (item) {
|
|
122
152
|
return item.id === id;
|
|
@@ -133,30 +163,49 @@ var OrConditions = function OrConditions(props) {
|
|
|
133
163
|
props.onChange(newValue);
|
|
134
164
|
}
|
|
135
165
|
|
|
136
|
-
|
|
166
|
+
if (textMode) {
|
|
167
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, textMode && showAndDesc ? /*#__PURE__*/React.createElement("span", {
|
|
168
|
+
className: "".concat(classPrefix, "-and-desc")
|
|
169
|
+
}, "\u4E14") : null, /*#__PURE__*/React.createElement("span", null, "("), showList.map(function (item, i) {
|
|
170
|
+
return renderCondition(item, i);
|
|
171
|
+
}), /*#__PURE__*/React.createElement("span", null, ")"));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function renderCondition(data, i) {
|
|
137
175
|
var condition = data.condition,
|
|
138
176
|
id = data.id;
|
|
139
177
|
var conditionDom = null;
|
|
140
178
|
|
|
141
|
-
if (
|
|
179
|
+
if (textMode) {
|
|
180
|
+
return /*#__PURE__*/React.createElement(Text, {
|
|
181
|
+
showOrDesc: i > 0,
|
|
182
|
+
key: i,
|
|
183
|
+
condition: condition
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (condition.labels) {
|
|
188
|
+
if (!openTagCondition) return null;
|
|
189
|
+
conditionDom = /*#__PURE__*/React.createElement(TagsCondition, {
|
|
190
|
+
labels: condition.labels,
|
|
191
|
+
dataId: id,
|
|
192
|
+
onChange: onChangeTags
|
|
193
|
+
});
|
|
194
|
+
} else if (condition.eventId === undefined) {
|
|
142
195
|
conditionDom = /*#__PURE__*/React.createElement(PropCondition, {
|
|
143
196
|
label: "\u5C5E\u6027",
|
|
144
197
|
attrs: condition.attrs,
|
|
145
198
|
dataId: id,
|
|
146
199
|
onChange: onChangeAttrs
|
|
147
200
|
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (condition.eventId === '-3') {
|
|
201
|
+
} else if (condition.eventId === '-3') {
|
|
151
202
|
conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
|
|
152
203
|
label: "\u65B0\u589E\u4E8E",
|
|
153
204
|
dataId: id,
|
|
154
205
|
onChange: onChangeRunPeriod,
|
|
155
206
|
runPeriod: condition.runPeriod
|
|
156
207
|
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (condition.eventId === '-4') {
|
|
208
|
+
} else if (condition.eventId === '-4') {
|
|
160
209
|
conditionDom = /*#__PURE__*/React.createElement(PeriodCondition, {
|
|
161
210
|
label: "\u6D3B\u8DC3\u4E8E",
|
|
162
211
|
isRealTime: true,
|
|
@@ -164,9 +213,7 @@ var OrConditions = function OrConditions(props) {
|
|
|
164
213
|
onChange: onChangeRunPeriod,
|
|
165
214
|
runPeriod: condition.runPeriod
|
|
166
215
|
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (util.isNumber(condition.eventId)) {
|
|
216
|
+
} else if (util.isNumber(condition.eventId)) {
|
|
170
217
|
conditionDom = /*#__PURE__*/React.createElement(EventCondition, {
|
|
171
218
|
dataId: id,
|
|
172
219
|
onChange: onChangeEvent,
|
|
@@ -183,15 +230,15 @@ var OrConditions = function OrConditions(props) {
|
|
|
183
230
|
}
|
|
184
231
|
|
|
185
232
|
return /*#__PURE__*/React.createElement("div", {
|
|
186
|
-
className: "".concat(classPrefix, "-or")
|
|
233
|
+
className: ["".concat(classPrefix, "-or"),, textMode ? 'text-mode' : ''].join(' ')
|
|
187
234
|
}, /*#__PURE__*/React.createElement("div", {
|
|
188
|
-
className: "".concat(classPrefix, "-or-content")
|
|
235
|
+
className: ["".concat(classPrefix, "-or-content")].join(' ')
|
|
189
236
|
}, /*#__PURE__*/React.createElement(RelationLabel, {
|
|
190
237
|
show: showList.length >= 2
|
|
191
238
|
}, "\u6216"), /*#__PURE__*/React.createElement("div", {
|
|
192
239
|
className: "".concat(classPrefix, "-conditions")
|
|
193
|
-
}, showList.map(function (item) {
|
|
194
|
-
return renderCondition(item);
|
|
240
|
+
}, showList.map(function (item, i) {
|
|
241
|
+
return renderCondition(item, i);
|
|
195
242
|
}))), /*#__PURE__*/React.createElement(ConditionTypeList, {
|
|
196
243
|
label: "\u6216",
|
|
197
244
|
onAdd: onAdd,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { BizUserConditionContext } from '.';
|
|
2
3
|
import './styles/relationLabel.less';
|
|
3
4
|
|
|
4
5
|
var RelationLabel = function RelationLabel(props) {
|
|
6
|
+
var _useContext = useContext(BizUserConditionContext),
|
|
7
|
+
textMode = _useContext.textMode;
|
|
8
|
+
|
|
9
|
+
if (textMode) return null;
|
|
5
10
|
return /*#__PURE__*/React.createElement("div", {
|
|
6
11
|
className: "biz-user-condition-relation"
|
|
7
12
|
}, props.show ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
@import '../../assets/styles/variable.less';
|
|
2
2
|
.biz-user-condition {
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-width: 0;
|
|
3
5
|
&-conditions-content {
|
|
4
6
|
display: flex;
|
|
5
7
|
.biz-user-condition-and-conditions-wrap {
|
|
6
8
|
flex: 1;
|
|
7
9
|
margin-bottom: @margin-md;
|
|
10
|
+
&.text-mode {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
min-width: 0;
|
|
14
|
+
margin-bottom: 0;
|
|
15
|
+
border: none;
|
|
16
|
+
.biz-user-condition-and-desc {
|
|
17
|
+
margin: 0 @margin-xs;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
8
20
|
}
|
|
9
21
|
.biz-user-condition-and-conditions-empty {
|
|
10
22
|
margin-bottom: 0;
|
|
11
23
|
}
|
|
24
|
+
.biz-select-handle-input-multiple {
|
|
25
|
+
min-height: 40px;
|
|
26
|
+
padding: calc(@margin-xs - 2px) @margin-xs calc(@margin-xs - 2px) @margin-sm;
|
|
27
|
+
.biz-select-handle-holder {
|
|
28
|
+
line-height: 28px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
12
31
|
}
|
|
13
32
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
@import '../../assets/styles/variable.less';
|
|
2
2
|
.biz-user-condition-or {
|
|
3
3
|
margin-bottom: @margin-md;
|
|
4
|
+
&.text-mode {
|
|
5
|
+
display: flex;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
// align-items: center;
|
|
8
|
+
margin-bottom: 0;
|
|
9
|
+
.biz-user-condition-or-content {
|
|
10
|
+
margin-bottom: 0;
|
|
11
|
+
border: none;
|
|
12
|
+
.biz-user-condition-conditions {
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
&-content {
|
|
5
18
|
display: flex;
|
|
6
19
|
width: 100%;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { TagI } from './../userTagsSelector/types';
|
|
2
3
|
export declare type Unpacked<T, U extends keyof T> = Required<T> extends {
|
|
3
4
|
[key in U]: infer R;
|
|
4
5
|
} ? R : never;
|
|
@@ -15,13 +16,21 @@ export interface AllConditionBasePropsI<T> {
|
|
|
15
16
|
onChange: (dataId: number, newData: T) => void;
|
|
16
17
|
}
|
|
17
18
|
export declare namespace BizUserConditionT {
|
|
18
|
-
type ConditionType = 'add' | 'active' | 'event' | 'prop';
|
|
19
|
+
type ConditionType = 'add' | 'active' | 'event' | 'prop' | 'tag';
|
|
19
20
|
interface PropsI {
|
|
20
21
|
defaultValue: BizUserConditionT.Conditions;
|
|
21
22
|
onChange: (value: any[]) => void;
|
|
22
23
|
andConditionNum?: number;
|
|
23
24
|
orConditionNum?: number;
|
|
24
25
|
eventAttrNum?: number;
|
|
26
|
+
textMode?: boolean;
|
|
27
|
+
openTagCondition?: boolean;
|
|
28
|
+
userTagsData?: UserTagsDataI[];
|
|
29
|
+
isRealTime?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface UserTagsDataI {
|
|
32
|
+
labelGroup: string;
|
|
33
|
+
children: TagI[];
|
|
25
34
|
}
|
|
26
35
|
interface AttrCondition {
|
|
27
36
|
attrId: number;
|
|
@@ -50,11 +59,20 @@ export declare namespace BizUserConditionT {
|
|
|
50
59
|
runPeriod: RunPeriodI;
|
|
51
60
|
runTimes: RunTimesI;
|
|
52
61
|
}
|
|
62
|
+
interface Labels {
|
|
63
|
+
operator: 'not equal' | 'equal';
|
|
64
|
+
values: number[];
|
|
65
|
+
}
|
|
66
|
+
interface TagsCondition {
|
|
67
|
+
attrs: [];
|
|
68
|
+
labels: Labels;
|
|
69
|
+
eventId: undefined;
|
|
70
|
+
}
|
|
53
71
|
interface PropCondition {
|
|
54
72
|
attrs: AttrCondition[];
|
|
55
73
|
eventId: undefined;
|
|
56
74
|
}
|
|
57
|
-
type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition;
|
|
75
|
+
type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition;
|
|
58
76
|
type Conditions = Condition[][];
|
|
59
77
|
interface ShowItemI {
|
|
60
78
|
id: number;
|
|
@@ -66,6 +84,7 @@ export declare namespace OrConditionsT {
|
|
|
66
84
|
interface PropI {
|
|
67
85
|
onChange: (value: any[]) => void;
|
|
68
86
|
orConditions: BizUserConditionT.Conditions[number];
|
|
87
|
+
showAndDesc: boolean;
|
|
69
88
|
}
|
|
70
89
|
interface ShowItemI {
|
|
71
90
|
id: number;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GlobalContextProps } from '../context';
|
|
2
|
+
import type { BizUserConditionT, Unpacked } from './types';
|
|
2
3
|
export declare function buildCondition(type: BizUserConditionT.ConditionType): BizUserConditionT.EventCondition | BizUserConditionT.AddCondition | BizUserConditionT.ActiveCondition | BizUserConditionT.PropCondition;
|
|
3
4
|
export declare function transformNumberOperate(key: string, output?: boolean): string;
|
|
5
|
+
export declare function findEvent(eventId: number, eventGroupList: Unpacked<GlobalContextProps, 'eventGroupList'>): import("../attributeSelector/types").AnalysisEvent | null;
|
|
6
|
+
export declare function findPropAndEnv(name: string, list: Unpacked<GlobalContextProps, 'userPropList' | 'eventEnvList'>): import("../attributeSelector/types").UserProp | import("../attributeSelector/types").EnvProp | null;
|
|
7
|
+
export declare function findTagFactory(data: BizUserConditionT.UserTagsDataI[]): (id: number) => import("../userTagsSelector/types").TagI | null;
|
package/es/userCondition/util.js
CHANGED
|
@@ -50,6 +50,16 @@ export function buildCondition(type) {
|
|
|
50
50
|
attrId: 0
|
|
51
51
|
}]
|
|
52
52
|
};
|
|
53
|
+
|
|
54
|
+
case 'tag':
|
|
55
|
+
return {
|
|
56
|
+
attrs: [],
|
|
57
|
+
labels: {
|
|
58
|
+
operator: 'equal',
|
|
59
|
+
values: []
|
|
60
|
+
},
|
|
61
|
+
eventId: undefined
|
|
62
|
+
};
|
|
53
63
|
}
|
|
54
64
|
}
|
|
55
65
|
export function transformNumberOperate(key) {
|
|
@@ -70,4 +80,36 @@ export function transformNumberOperate(key) {
|
|
|
70
80
|
};
|
|
71
81
|
if (output) return outputMap[key] || key;
|
|
72
82
|
return inputMap[key] || key;
|
|
83
|
+
}
|
|
84
|
+
export function findEvent(eventId, eventGroupList) {
|
|
85
|
+
for (var i = 0; i < eventGroupList.length; i++) {
|
|
86
|
+
var eventList = eventGroupList[i].eventList;
|
|
87
|
+
|
|
88
|
+
for (var j = 0; j < eventList.length; j++) {
|
|
89
|
+
if (eventList[j].id === eventId) return eventList[j];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
export function findPropAndEnv(name, list) {
|
|
96
|
+
for (var i = 0; i < list.length; i++) {
|
|
97
|
+
if (list[i].name === name) return list[i];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
export function findTagFactory(data) {
|
|
103
|
+
return function (id) {
|
|
104
|
+
var i = -1;
|
|
105
|
+
var j = data.findIndex(function (item) {
|
|
106
|
+
i = item.children.findIndex(function (tag) {
|
|
107
|
+
return tag.labelId === id;
|
|
108
|
+
});
|
|
109
|
+
if (i < 0) return false;
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
if (j < 0) return null;
|
|
113
|
+
return data[j].children[i];
|
|
114
|
+
};
|
|
73
115
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
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."); }
|
|
4
|
+
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
|
|
11
|
+
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."); }
|
|
12
|
+
|
|
13
|
+
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); }
|
|
14
|
+
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
18
|
+
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
|
+
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import { useState } from 'react';
|
|
23
|
+
import { classPrefix } from '.';
|
|
24
|
+
import './styles/cascaderOverlay.less';
|
|
25
|
+
import Groups from './groups/index';
|
|
26
|
+
import MultipleCheckPanel from './multipleCheckPanel';
|
|
27
|
+
import { getFieldFactory } from './util';
|
|
28
|
+
import _ from 'lodash';
|
|
29
|
+
|
|
30
|
+
var CascaderOverlay = function CascaderOverlay(props) {
|
|
31
|
+
var data = props.data,
|
|
32
|
+
currentValue = props.currentValue,
|
|
33
|
+
labelFields = props.labelFields,
|
|
34
|
+
keyFields = props.keyFields,
|
|
35
|
+
valueFields = props.valueFields,
|
|
36
|
+
childFields = props.childFields;
|
|
37
|
+
|
|
38
|
+
var _useState = useState(function () {
|
|
39
|
+
var initPath = [];
|
|
40
|
+
var curr = data[0];
|
|
41
|
+
var getChildField = getFieldFactory(childFields);
|
|
42
|
+
|
|
43
|
+
while (curr) {
|
|
44
|
+
initPath.push(curr);
|
|
45
|
+
curr = curr[getChildField()];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
initPath.pop();
|
|
49
|
+
return initPath;
|
|
50
|
+
}),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
currentPath = _useState2[0],
|
|
53
|
+
setCurrentPath = _useState2[1];
|
|
54
|
+
|
|
55
|
+
function onActive(data, level) {
|
|
56
|
+
var currIndex = level;
|
|
57
|
+
var getChildField = getFieldFactory(childFields.slice(currIndex).length ? childFields.slice(currIndex) : childFields.slice(-1));
|
|
58
|
+
var curr = data;
|
|
59
|
+
var newPath = currentPath.slice();
|
|
60
|
+
|
|
61
|
+
while (curr) {
|
|
62
|
+
newPath[currIndex] = curr;
|
|
63
|
+
curr = curr[getChildField()];
|
|
64
|
+
currIndex++;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
newPath.pop();
|
|
68
|
+
setCurrentPath(newPath);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function onCheck(data) {
|
|
72
|
+
var getVabelField = getFieldFactory(valueFields);
|
|
73
|
+
var newValue = currentPath.map(function (item) {
|
|
74
|
+
return item[getVabelField()];
|
|
75
|
+
}).concat(data);
|
|
76
|
+
props.onChange([].concat(_toConsumableArray(currentValue), [newValue]));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function onUncheck(data) {
|
|
80
|
+
var index = currentValue.findIndex(function (item) {
|
|
81
|
+
return _.isEqual(item.slice().pop(), data);
|
|
82
|
+
});
|
|
83
|
+
var newValues = currentValue.slice();
|
|
84
|
+
newValues.splice(index, 1);
|
|
85
|
+
props.onChange(newValues);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
89
|
+
className: "".concat(classPrefix, "-overlay")
|
|
90
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
91
|
+
className: "".concat(classPrefix, "-overlay-groups")
|
|
92
|
+
}, /*#__PURE__*/React.createElement(Groups, {
|
|
93
|
+
currentValue: currentValue,
|
|
94
|
+
valueField: valueFields[0],
|
|
95
|
+
keyField: keyFields[0],
|
|
96
|
+
childField: childFields[0],
|
|
97
|
+
labelField: labelFields[0],
|
|
98
|
+
data: data,
|
|
99
|
+
onActive: onActive,
|
|
100
|
+
level: 0
|
|
101
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: "".concat(classPrefix, "-overlay-selections")
|
|
103
|
+
}, /*#__PURE__*/React.createElement(MultipleCheckPanel, {
|
|
104
|
+
valueField: valueFields[1],
|
|
105
|
+
onCheck: onCheck,
|
|
106
|
+
onUncheck: onUncheck,
|
|
107
|
+
currentValue: currentValue,
|
|
108
|
+
level: 1,
|
|
109
|
+
labelField: labelFields[1],
|
|
110
|
+
data: currentPath[0][childFields[0]]
|
|
111
|
+
})));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default CascaderOverlay;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BizSearchInput from '../../../searchInput';
|
|
3
|
+
import './index.less';
|
|
4
|
+
import { classPrefix } from '../..';
|
|
5
|
+
|
|
6
|
+
var Search = function Search(props) {
|
|
7
|
+
if (!props.show) return null;
|
|
8
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
9
|
+
className: "".concat(classPrefix, "-drop-panel-search")
|
|
10
|
+
}, /*#__PURE__*/React.createElement(BizSearchInput, {
|
|
11
|
+
placeholder: props.placeholder,
|
|
12
|
+
onChange: props.onChange
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default Search;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BizUserTagsSelect } from '@zgfe/business-lib';
|
|
3
|
+
var data = [{
|
|
4
|
+
labelGroup: '基本标签',
|
|
5
|
+
children: []
|
|
6
|
+
}, {
|
|
7
|
+
labelGroup: '行为标签',
|
|
8
|
+
children: []
|
|
9
|
+
}, {
|
|
10
|
+
labelGroup: '活跃标签',
|
|
11
|
+
children: []
|
|
12
|
+
}, {
|
|
13
|
+
labelGroup: '预测标签',
|
|
14
|
+
children: []
|
|
15
|
+
}, {
|
|
16
|
+
labelGroup: '其它标签',
|
|
17
|
+
children: []
|
|
18
|
+
}];
|
|
19
|
+
var defaultValue = [];
|
|
20
|
+
data.forEach(function (item) {
|
|
21
|
+
item.children = Array(100 * Math.random() >> 0).fill(1).map(function (_child, _index) {
|
|
22
|
+
var id = Math.random();
|
|
23
|
+
var tag = {
|
|
24
|
+
id: id,
|
|
25
|
+
labelName: '标签' + id
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (id < 0.6 && defaultValue.length < 20) {
|
|
29
|
+
defaultValue.push([item.labelGroup, tag]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return tag;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
export default (function () {
|
|
36
|
+
function onChange(data) {
|
|
37
|
+
console.log(data);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return /*#__PURE__*/React.createElement(BizUserTagsSelect, {
|
|
41
|
+
childFields: ['children'],
|
|
42
|
+
data: data,
|
|
43
|
+
keyFields: ['labelGroup', 'id'],
|
|
44
|
+
labelFields: ['labelGroup', 'labelName'],
|
|
45
|
+
valueFields: ['labelGroup', 'labelId'],
|
|
46
|
+
onChange: onChange
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UserTagsSelectorTypes } from '../types';
|
|
3
|
+
import './styles/option.less';
|
|
4
|
+
declare const GroupOption: React.ForwardRefExoticComponent<UserTagsSelectorTypes.GroupOption & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export default GroupOption;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { Badge } from 'antd';
|
|
3
|
+
import { classPrefix } from '..';
|
|
4
|
+
import theme from '../../assets/theme';
|
|
5
|
+
import './styles/option.less';
|
|
6
|
+
import { util } from '../../utils';
|
|
7
|
+
var GroupOption = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
|
+
var label = props.label,
|
|
9
|
+
count = props.count,
|
|
10
|
+
actived = props.actived,
|
|
11
|
+
checked = props.checked,
|
|
12
|
+
_onClick = props.onClick,
|
|
13
|
+
value = props.value,
|
|
14
|
+
highlightText = props.highlightText;
|
|
15
|
+
|
|
16
|
+
function renderLabel() {
|
|
17
|
+
if (!highlightText || !highlightText.trim()) return label;
|
|
18
|
+
var dom = util.setHighLight(label, highlightText, function (text) {
|
|
19
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
20
|
+
style: {
|
|
21
|
+
color: theme['primary-color']
|
|
22
|
+
}
|
|
23
|
+
}, text);
|
|
24
|
+
});
|
|
25
|
+
return dom;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
onClick: function onClick() {
|
|
30
|
+
return _onClick(value);
|
|
31
|
+
},
|
|
32
|
+
className: ["".concat(classPrefix, "-group-option"), actived ? 'active' : '', checked ? 'checked' : ''].join(' '),
|
|
33
|
+
ref: ref
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "".concat(classPrefix, "-group-option-label")
|
|
36
|
+
}, renderLabel()), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "".concat(classPrefix, "-group-option-count")
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
|
39
|
+
count: count
|
|
40
|
+
})));
|
|
41
|
+
});
|
|
42
|
+
export default GroupOption;
|