@zgfe/business-lib 1.0.18 → 1.0.19

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.
Files changed (104) hide show
  1. package/es/addToPanel/index.js +1 -0
  2. package/es/addToScene/index.js +1 -0
  3. package/es/assets/styles/chunks.less +3 -4
  4. package/es/assets/styles/resetAntd.less +47 -11
  5. package/es/attrConditions/components/operateList.d.ts +1 -0
  6. package/es/attrConditions/components/operateList.js +2 -2
  7. package/es/attrConditions/components/stringList.d.ts +1 -0
  8. package/es/attrConditions/components/stringList.js +2 -2
  9. package/es/attrConditions/components/valuesList.d.ts +1 -1
  10. package/es/attrConditions/components/valuesList.js +11 -12
  11. package/es/attrConditions/demo/group.js +13 -1
  12. package/es/attrConditions/group.js +14 -0
  13. package/es/attrConditions/index.js +16 -5
  14. package/es/attrConditions/styles/index.less +39 -5
  15. package/es/attrConditions/types.d.ts +4 -0
  16. package/es/attrConditions/utils/operates.js +2 -2
  17. package/es/attributeSelector/index.js +8 -4
  18. package/es/attributeSelector/listPanel.js +32 -19
  19. package/es/attributeSelector/styles/index.less +3 -3
  20. package/es/attributeSelector/types.d.ts +7 -0
  21. package/es/attributeSelector/types.js +8 -1
  22. package/es/attributeSelector/util.js +3 -2
  23. package/es/eventSelector/index.js +10 -4
  24. package/es/eventSelector/listPanel.js +18 -23
  25. package/es/eventSelector/styles/index.less +5 -5
  26. package/es/eventSelector/types.d.ts +4 -0
  27. package/es/index.d.ts +2 -1
  28. package/es/index.js +2 -1
  29. package/es/mock/event.js +214 -0
  30. package/es/select/demo/children.d.ts +2 -0
  31. package/es/select/demo/children.js +81 -0
  32. package/es/select/demo/customLabel.d.ts +2 -0
  33. package/es/select/demo/customLabel.js +23 -0
  34. package/es/select/demo/index.js +10 -4
  35. package/es/select/demo/multiple.js +10 -3
  36. package/es/select/handle.js +4 -2
  37. package/es/select/index.d.ts +2 -2
  38. package/es/select/index.js +7 -5
  39. package/es/select/option.js +8 -2
  40. package/es/select/overlay.js +5 -3
  41. package/es/select/styles/handle.less +23 -13
  42. package/es/select/types.d.ts +5 -1
  43. package/es/userCondition/conditionTypeList.js +29 -6
  44. package/es/userCondition/conditionWrap.js +4 -2
  45. package/es/userCondition/conditions/constants.d.ts +24 -0
  46. package/es/userCondition/conditions/constants.js +41 -0
  47. package/es/userCondition/conditions/eventCondition.js +13 -4
  48. package/es/userCondition/conditions/periodCondition.js +21 -10
  49. package/es/userCondition/conditions/propCondition.js +25 -6
  50. package/es/userCondition/conditions/runTimesCondition.js +2 -2
  51. package/es/userCondition/conditions/styles/eventCondition.less +9 -7
  52. package/es/userCondition/conditions/styles/periodCondition.less +12 -0
  53. package/es/userCondition/conditions/styles/propCondition.less +11 -3
  54. package/es/userCondition/conditions/styles/runTimesCondition.less +3 -0
  55. package/es/userCondition/conditions/styles/tagsCondition.less +20 -0
  56. package/es/userCondition/conditions/styles/textDesc.less +17 -0
  57. package/es/userCondition/conditions/tagsCondition.d.ts +9 -0
  58. package/es/userCondition/conditions/tagsCondition.js +107 -0
  59. package/es/userCondition/conditions/textDesc.d.ts +9 -0
  60. package/es/userCondition/conditions/textDesc.js +241 -0
  61. package/es/userCondition/demo/index.js +259 -31
  62. package/es/userCondition/index.d.ts +1 -1
  63. package/es/userCondition/index.js +52 -10
  64. package/es/userCondition/orConditions.js +69 -28
  65. package/es/userCondition/relationLabel.js +6 -1
  66. package/es/userCondition/styles/conditionTypeList.less +1 -1
  67. package/es/userCondition/styles/conditionWrap.less +3 -0
  68. package/es/userCondition/styles/index.less +21 -1
  69. package/es/userCondition/styles/orConditions.less +20 -2
  70. package/es/userCondition/styles/relationLabel.less +5 -4
  71. package/es/userCondition/types.d.ts +28 -2
  72. package/es/userCondition/util.d.ts +5 -1
  73. package/es/userCondition/util.js +42 -0
  74. package/es/userTagsSelector/cascaderOverlay.d.ts +5 -0
  75. package/es/userTagsSelector/cascaderOverlay.js +114 -0
  76. package/es/userTagsSelector/components/search/index.d.ts +8 -0
  77. package/es/userTagsSelector/components/search/index.js +16 -0
  78. package/es/userTagsSelector/components/search/index.less +6 -0
  79. package/es/userTagsSelector/context.d.ts +3 -0
  80. package/es/userTagsSelector/context.js +2 -0
  81. package/es/userTagsSelector/demo/index.d.ts +2 -0
  82. package/es/userTagsSelector/demo/index.js +48 -0
  83. package/es/userTagsSelector/groups/groupOption.d.ts +5 -0
  84. package/es/userTagsSelector/groups/groupOption.js +42 -0
  85. package/es/userTagsSelector/groups/index.d.ts +4 -0
  86. package/es/userTagsSelector/groups/index.js +86 -0
  87. package/es/userTagsSelector/groups/styles/index.less +0 -0
  88. package/es/userTagsSelector/groups/styles/option.less +50 -0
  89. package/es/userTagsSelector/index.d.ts +6 -0
  90. package/es/userTagsSelector/index.js +110 -0
  91. package/es/userTagsSelector/multipleCheckPanel/checkOption.d.ts +5 -0
  92. package/es/userTagsSelector/multipleCheckPanel/checkOption.js +45 -0
  93. package/es/userTagsSelector/multipleCheckPanel/index.d.ts +4 -0
  94. package/es/userTagsSelector/multipleCheckPanel/index.js +80 -0
  95. package/es/userTagsSelector/multipleCheckPanel/styles/index.less +0 -0
  96. package/es/userTagsSelector/multipleCheckPanel/styles/option.less +40 -0
  97. package/es/userTagsSelector/styles/cascaderOverlay.less +27 -0
  98. package/es/userTagsSelector/styles/index.less +10 -0
  99. package/es/userTagsSelector/types.d.ts +67 -0
  100. package/es/userTagsSelector/types.js +1 -0
  101. package/es/userTagsSelector/util.d.ts +4 -0
  102. package/es/userTagsSelector/util.js +38 -0
  103. package/es/utils/type.d.ts +2 -2
  104. package/package.json +6 -7
@@ -1,13 +1,31 @@
1
1
  @import '../../assets/styles/variable.less';
2
2
  .biz-user-condition-or {
3
- margin-bottom: @margin-md;
3
+ &:not(:last-child) {
4
+ margin-bottom: @margin-lg;
5
+ }
6
+ &.text-mode {
7
+ display: flex;
8
+ min-width: 0;
9
+ // align-items: center;
10
+ margin-bottom: 0;
11
+ .biz-user-condition-or-content {
12
+ margin-bottom: 0;
13
+ border: none;
14
+ .biz-user-condition-conditions {
15
+ padding: 0;
16
+ }
17
+ }
18
+ }
4
19
  &-content {
5
20
  display: flex;
6
21
  width: 100%;
7
- margin-bottom: @margin-md;
22
+
8
23
  background: #ffffff;
9
24
  border: 1px solid @border-color-base;
10
25
  border-radius: @border-radius-small;
26
+ &:not(:last-child) {
27
+ margin-bottom: @margin-md;
28
+ }
11
29
  .biz-user-condition-conditions {
12
30
  flex: 1;
13
31
  padding: @padding-xs @padding-md 0 0;
@@ -1,9 +1,9 @@
1
- @import '../../commonStyle/variable.less';
1
+ @import '../../assets/styles/inner.less';
2
2
  .biz-user-condition-relation {
3
3
  position: relative;
4
4
  width: 2px;
5
- margin-right: 30px;
6
- background-color: @hoverBgColor;
5
+ margin-right: @margin-lg;
6
+ background-color: @border-color-split;
7
7
  &-label {
8
8
  position: absolute;
9
9
  top: 50%;
@@ -12,7 +12,8 @@
12
12
  height: 24px;
13
13
  line-height: 24px;
14
14
  text-align: center;
15
- background-color: @hoverBgColor;
15
+ background-color: @border-color-split;
16
+ border-radius: @border-radius-small;
16
17
  transform: translate(-50%, -50%);
17
18
  }
18
19
  }
@@ -1,4 +1,6 @@
1
1
  /// <reference types="react" />
2
+ import { UserProp } from '../attributeSelector/types';
3
+ import { TagI } from './../userTagsSelector/types';
2
4
  export declare type Unpacked<T, U extends keyof T> = Required<T> extends {
3
5
  [key in U]: infer R;
4
6
  } ? R : never;
@@ -15,13 +17,21 @@ export interface AllConditionBasePropsI<T> {
15
17
  onChange: (dataId: number, newData: T) => void;
16
18
  }
17
19
  export declare namespace BizUserConditionT {
18
- type ConditionType = 'add' | 'active' | 'event' | 'prop';
20
+ type ConditionType = 'add' | 'active' | 'event' | 'prop' | 'tag';
19
21
  interface PropsI {
20
22
  defaultValue: BizUserConditionT.Conditions;
21
23
  onChange: (value: any[]) => void;
22
24
  andConditionNum?: number;
23
25
  orConditionNum?: number;
24
26
  eventAttrNum?: number;
27
+ textMode?: boolean;
28
+ openTagCondition?: boolean;
29
+ userTagsData?: UserTagsDataI[];
30
+ isRealTime?: boolean;
31
+ }
32
+ interface UserTagsDataI {
33
+ labelGroup: string;
34
+ children: TagI[];
25
35
  }
26
36
  interface AttrCondition {
27
37
  attrId: number;
@@ -50,22 +60,38 @@ export declare namespace BizUserConditionT {
50
60
  runPeriod: RunPeriodI;
51
61
  runTimes: RunTimesI;
52
62
  }
63
+ interface Labels {
64
+ operator: 'not equal' | 'equal';
65
+ values: number[];
66
+ }
67
+ interface TagsCondition {
68
+ attrs: [];
69
+ labels: Labels;
70
+ eventId: undefined;
71
+ }
53
72
  interface PropCondition {
54
73
  attrs: AttrCondition[];
55
74
  eventId: undefined;
56
75
  }
57
- type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition;
76
+ type Condition = EventCondition | AddCondition | ActiveCondition | PropCondition | TagsCondition;
58
77
  type Conditions = Condition[][];
59
78
  interface ShowItemI {
60
79
  id: number;
61
80
  orConditions: Conditions[number];
62
81
  }
63
82
  type ShowListT = ShowItemI[];
83
+ type GlobalContext = Pick<BizUserConditionT.PropsI, 'orConditionNum' | 'eventAttrNum' | 'openTagCondition' | 'userTagsData' | 'textMode' | 'isRealTime'> & {
84
+ envNameList: string[];
85
+ userPropsMap: {
86
+ [key: string]: UserProp;
87
+ };
88
+ };
64
89
  }
65
90
  export declare namespace OrConditionsT {
66
91
  interface PropI {
67
92
  onChange: (value: any[]) => void;
68
93
  orConditions: BizUserConditionT.Conditions[number];
94
+ showAndDesc: boolean;
69
95
  }
70
96
  interface ShowItemI {
71
97
  id: number;
@@ -1,3 +1,7 @@
1
- import { BizUserConditionT } from './types';
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;
@@ -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,5 @@
1
+ import React from 'react';
2
+ import './styles/cascaderOverlay.less';
3
+ import { UserTagsSelectorTypes } from './types';
4
+ declare const CascaderOverlay: React.FC<UserTagsSelectorTypes.CascaderOverlayProps>;
5
+ export default CascaderOverlay;
@@ -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,8 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ declare const Search: React.FC<{
4
+ show: boolean;
5
+ onChange: (val: string) => void;
6
+ placeholder?: string;
7
+ }>;
8
+ export default Search;
@@ -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,6 @@
1
+ @import '../../../assets/styles/variable.less';
2
+ .biz-user-tags-selector {
3
+ &-drop-panel-search {
4
+ margin-bottom: @margin-xs;
5
+ }
6
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { UserTagsSelectorTypes } from './types';
3
+ export declare const UserTagsSelectContext: import("react").Context<Partial<UserTagsSelectorTypes.Props>>;
@@ -0,0 +1,2 @@
1
+ import { createContext } from 'react';
2
+ export var UserTagsSelectContext = /*#__PURE__*/createContext({});
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -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 + id + id + 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.js';
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;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { UserTagsSelectorTypes } from '../types';
3
+ declare const Groups: React.FC<UserTagsSelectorTypes.Groups>;
4
+ export default Groups;
@@ -0,0 +1,86 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ 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."); }
4
+
5
+ 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); }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import React, { useMemo } from 'react';
14
+ import VirtualList from 'rc-virtual-list';
15
+ import { classPrefix } from '../';
16
+ import GroupOption from './groupOption';
17
+ import Search from '../components/search/index';
18
+ import { useState } from 'react';
19
+ import { filterFactory, isCheckedFactory } from '../util';
20
+
21
+ var Groups = function Groups(props) {
22
+ var data = props.data,
23
+ labelField = props.labelField,
24
+ childField = props.childField,
25
+ keyField = props.keyField,
26
+ valueField = props.valueField,
27
+ searchable = props.searchable,
28
+ level = props.level,
29
+ currentValue = props.currentValue;
30
+
31
+ var _useState = useState(''),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ searchValue = _useState2[0],
34
+ setSearchValue = _useState2[1];
35
+
36
+ var _useState3 = useState(data[0][valueField]),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ active = _useState4[0],
39
+ setActive = _useState4[1];
40
+
41
+ function _onClick(i) {
42
+ setActive(data[i][valueField]);
43
+ props.onActive(data[i], level);
44
+ }
45
+
46
+ function onSearch(val) {
47
+ setSearchValue(val);
48
+ }
49
+
50
+ var searchFilter = useMemo(function () {
51
+ return filterFactory(labelField, searchValue);
52
+ }, [labelField, searchValue]);
53
+ var isChecked = useMemo(function () {
54
+ return isCheckedFactory(currentValue, level);
55
+ }, [currentValue, level]);
56
+ if (!data.length) return /*#__PURE__*/React.createElement("span", null, "\u6682\u65E0\u6570\u636E");
57
+ return /*#__PURE__*/React.createElement("div", {
58
+ className: "".concat(classPrefix, "-groups-panel")
59
+ }, /*#__PURE__*/React.createElement(Search, {
60
+ show: searchable,
61
+ onChange: onSearch
62
+ }), /*#__PURE__*/React.createElement(VirtualList, {
63
+ data: searchable ? data.filter(searchFilter) : data,
64
+ height: 408,
65
+ itemKey: keyField
66
+ }, function (item, index) {
67
+ return /*#__PURE__*/React.createElement(GroupOption, {
68
+ onClick: function onClick() {
69
+ return _onClick(index);
70
+ },
71
+ actived: item[valueField] === active,
72
+ checked: isChecked(item[valueField]),
73
+ count: item[childField].length,
74
+ label: item[labelField],
75
+ value: item[valueField],
76
+ highlightText: searchValue
77
+ });
78
+ }));
79
+ };
80
+
81
+ Groups.defaultProps = {
82
+ data: [],
83
+ childField: 'children',
84
+ searchable: false
85
+ };
86
+ export default Groups;
File without changes
@@ -0,0 +1,50 @@
1
+ @import '../../../assets/styles/inner.less';
2
+ .biz-user-tags-selector {
3
+ &-group-option {
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: space-between;
7
+ height: 48px;
8
+ padding: 0 16px;
9
+ border-radius: @border-radius-normal;
10
+
11
+ cursor: pointer;
12
+ &-label {
13
+ .__default-overflow();
14
+ margin-right: @margin-xs;
15
+ }
16
+ &-count {
17
+ .ant-badge-count {
18
+ color: @text-color;
19
+ background: none;
20
+ }
21
+ }
22
+ &.checked {
23
+ color: @primary-color;
24
+ .biz-user-tags-selector-group-option-count {
25
+ .ant-badge-count {
26
+ color: @primary-color;
27
+ }
28
+ }
29
+ }
30
+ &:hover {
31
+ .__default-hover();
32
+ .biz-user-tags-selector-group-option-count {
33
+ .ant-badge-count {
34
+ color: #fff;
35
+ background: @primary-color;
36
+ }
37
+ }
38
+ }
39
+ &.active {
40
+ color: #fff;
41
+ background: @primary-color;
42
+ .biz-user-tags-selector-group-option-count {
43
+ .ant-badge-count {
44
+ color: #fff;
45
+ background: @primary-color;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ import { UserTagsSelectorTypes } from './types';
4
+ export declare const classPrefix = "biz-user-tags-selector";
5
+ declare const UserTagsSelect: React.FC<UserTagsSelectorTypes.Props>;
6
+ export default UserTagsSelect;