@zgfe/modules-attribution 1.0.1-alpha.0

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 (95) hide show
  1. package/README.md +35 -0
  2. package/es/components/common/index.d.ts +6 -0
  3. package/es/components/common/index.js +17 -0
  4. package/es/components/common/styles/index.less +27 -0
  5. package/es/components/index.d.ts +5 -0
  6. package/es/components/index.js +5 -0
  7. package/es/components/option/index.d.ts +5 -0
  8. package/es/components/option/index.js +134 -0
  9. package/es/components/option/styles/index.less +17 -0
  10. package/es/components/option/types.d.ts +8 -0
  11. package/es/components/option/types.js +1 -0
  12. package/es/components/searchTime/index.d.ts +5 -0
  13. package/es/components/searchTime/index.js +41 -0
  14. package/es/components/searchTime/styles/index.less +19 -0
  15. package/es/components/searchTime/types.d.ts +8 -0
  16. package/es/components/searchTime/types.js +1 -0
  17. package/es/components/tableList/index.d.ts +8 -0
  18. package/es/components/tableList/index.js +23 -0
  19. package/es/components/tableList/styles/index.less +7 -0
  20. package/es/components/title/index.d.ts +5 -0
  21. package/es/components/title/index.js +187 -0
  22. package/es/components/title/searchTitle.d.ts +7 -0
  23. package/es/components/title/searchTitle.js +47 -0
  24. package/es/components/title/styles/index.less +83 -0
  25. package/es/components/title/styles/search.less +27 -0
  26. package/es/components/title/types.d.ts +7 -0
  27. package/es/components/title/types.js +1 -0
  28. package/es/constants/apis.d.ts +10 -0
  29. package/es/constants/apis.js +10 -0
  30. package/es/constants/chart.d.ts +2 -0
  31. package/es/constants/chart.js +24 -0
  32. package/es/constants/color.d.ts +1 -0
  33. package/es/constants/color.js +1 -0
  34. package/es/constants/fields.d.ts +146 -0
  35. package/es/constants/fields.js +179 -0
  36. package/es/constants/index.d.ts +6 -0
  37. package/es/constants/index.js +6 -0
  38. package/es/constants/initData.d.ts +17 -0
  39. package/es/constants/initData.js +24 -0
  40. package/es/index.d.ts +3 -0
  41. package/es/index.js +2 -0
  42. package/es/modules/content/index.d.ts +5 -0
  43. package/es/modules/content/index.js +125 -0
  44. package/es/modules/content/styles/index.less +7 -0
  45. package/es/modules/content/types.d.ts +8 -0
  46. package/es/modules/content/types.js +1 -0
  47. package/es/modules/content/utils.d.ts +8 -0
  48. package/es/modules/content/utils.js +192 -0
  49. package/es/modules/home/demo/create.d.ts +2 -0
  50. package/es/modules/home/demo/create.js +53 -0
  51. package/es/modules/home/demo/edit.d.ts +2 -0
  52. package/es/modules/home/demo/edit.js +190 -0
  53. package/es/modules/home/demo/index.d.ts +3 -0
  54. package/es/modules/home/demo/index.js +51 -0
  55. package/es/modules/home/demo/scene.d.ts +2 -0
  56. package/es/modules/home/demo/scene.js +74 -0
  57. package/es/modules/home/demo/styles/index.less +33 -0
  58. package/es/modules/home/index.d.ts +5 -0
  59. package/es/modules/home/index.js +150 -0
  60. package/es/modules/home/styles/index.less +63 -0
  61. package/es/modules/home/types.d.ts +20 -0
  62. package/es/modules/home/types.js +1 -0
  63. package/es/modules/searchPanel/components/attributableEvents.d.ts +4 -0
  64. package/es/modules/searchPanel/components/attributableEvents.js +172 -0
  65. package/es/modules/searchPanel/components/globalAttribute.d.ts +8 -0
  66. package/es/modules/searchPanel/components/globalAttribute.js +58 -0
  67. package/es/modules/searchPanel/components/index.d.ts +4 -0
  68. package/es/modules/searchPanel/components/index.js +21 -0
  69. package/es/modules/searchPanel/components/targetEvent.d.ts +4 -0
  70. package/es/modules/searchPanel/components/targetEvent.js +149 -0
  71. package/es/modules/searchPanel/demo/index.d.ts +2 -0
  72. package/es/modules/searchPanel/demo/index.js +28 -0
  73. package/es/modules/searchPanel/index.d.ts +6 -0
  74. package/es/modules/searchPanel/index.js +316 -0
  75. package/es/modules/searchPanel/styles/index.less +202 -0
  76. package/es/modules/searchPanel/types.d.ts +31 -0
  77. package/es/modules/searchPanel/types.js +1 -0
  78. package/es/modules/searchPanel/utils.d.ts +5 -0
  79. package/es/modules/searchPanel/utils.js +139 -0
  80. package/es/style/image/noData.png +0 -0
  81. package/es/style/image/ring.svg +9 -0
  82. package/es/style/index.less +47 -0
  83. package/es/style/theme.d.ts +15 -0
  84. package/es/style/theme.js +14 -0
  85. package/es/types.d.ts +62 -0
  86. package/es/types.js +2 -0
  87. package/es/utils/ajaxConfig.d.ts +8 -0
  88. package/es/utils/ajaxConfig.js +40 -0
  89. package/es/utils/request.d.ts +3 -0
  90. package/es/utils/request.js +5 -0
  91. package/es/utils/transfer.d.ts +65 -0
  92. package/es/utils/transfer.js +173 -0
  93. package/es/utils/util.d.ts +32 -0
  94. package/es/utils/util.js +139 -0
  95. package/package.json +54 -0
@@ -0,0 +1,173 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ import moment from 'moment';
5
+ import util from './util';
6
+ export function transferEventSearchData(params) {
7
+ var userPropList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
8
+ var eventGroupList = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
9
+ var eventEnvList = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
10
+ var result = {
11
+ userGroup: params.user_group.split(','),
12
+ targets: [],
13
+ chartType: params.chartType
14
+ };
15
+ var timeData = params.time;
16
+ if (util.isString(timeData)) {
17
+ timeData = JSON.parse(timeData);
18
+ }
19
+ var time = timeData.dimension_date.split(',');
20
+ var unit = time[0];
21
+ var begin = timeData.begin_date;
22
+ var end = timeData.end_date;
23
+ if (time.includes('total') || begin.indexOf('-') < 0) {
24
+ result.time = {
25
+ unit: unit,
26
+ relative: [begin, end],
27
+ begin: moment().subtract(begin, unit).format('YYYY-MM-DD'),
28
+ end: moment().subtract(end, 'days').format('YYYY-MM-DD')
29
+ };
30
+ } else {
31
+ result.time = {
32
+ unit: unit,
33
+ begin: begin,
34
+ end: end
35
+ };
36
+ }
37
+ if (params.platform) {
38
+ var envData;
39
+ eventEnvList.forEach(function (env) {
40
+ if (env.name === 'platform') {
41
+ envData = env;
42
+ }
43
+ });
44
+ if (envData) {
45
+ var platforms = ['android', 'ios', 'js'];
46
+ result.globalFilters = {
47
+ relation: 'and',
48
+ conditions: [{
49
+ attrId: envData.id,
50
+ attrName: 'platform',
51
+ dimensionSub: 'platform',
52
+ label: envData.label,
53
+ category: envData.category,
54
+ type: envData.type,
55
+ operator: 'equal',
56
+ propCategory: 'envProp',
57
+ values: [platforms[params.platform - 1]]
58
+ }]
59
+ };
60
+ }
61
+ }
62
+ if (params.dimension_sub && params.event) {
63
+ var data = transferDimension(userPropList, eventGroupList, eventEnvList, params.dimension_sub, params.event, params.event_attr, params.user_attr);
64
+ if (data) {
65
+ result.globalDimensions = [data];
66
+ }
67
+ }
68
+ var targets = {
69
+ type: params.module,
70
+ alias: '',
71
+ eventGroupId: params.event_group_id || 0,
72
+ eventId: params.event || -100,
73
+ analysisDimension: {
74
+ analysisIndex: params.analysis_index,
75
+ analysisAttr: params.event_attr
76
+ }
77
+ };
78
+ if (params.filter_condition) {
79
+ var conditions = [];
80
+ var filterCondition = params.filter_condition;
81
+ if (util.isString(filterCondition)) {
82
+ filterCondition = JSON.parse(filterCondition);
83
+ }
84
+ var _filterCondition = filterCondition,
85
+ eventCondition = _filterCondition.eventCondition,
86
+ userCondition = _filterCondition.userCondition;
87
+ if (eventCondition && eventCondition.eventSingleConditions) {
88
+ eventCondition.eventSingleConditions.forEach(function (e) {
89
+ if (e.happenTime && e.happenTime.params.length) {
90
+ if (e.happenTime.params[0] === 'relative') {
91
+ result.time.relative = [e.happenTime.params[1], e.happenTime.params[2]];
92
+ }
93
+ }
94
+ if (e.eventName) {
95
+ targets.eventName = e.eventName;
96
+ }
97
+ if (e.attrConditions) {
98
+ conditions = conditions.concat(transferCondition(e.attrConditions));
99
+ }
100
+ if (e.environmentConditions) {
101
+ conditions = conditions.concat(transferCondition(e.environmentConditions));
102
+ }
103
+ });
104
+ }
105
+ if (userCondition && userCondition.userSingleConditions) {
106
+ conditions = conditions.concat(transferCondition(userCondition.userSingleConditions));
107
+ }
108
+ targets.filters = {
109
+ conditions: conditions,
110
+ relation: 'and'
111
+ };
112
+ }
113
+ result.targets = [targets];
114
+ return result;
115
+ }
116
+ function transferDimension(userPropList, eventGroupList, eventEnvList, dimensionSub, eventId, eventAttr, userAttr) {
117
+ var data;
118
+ if (eventAttr) {
119
+ eventGroupList.forEach(function (group) {
120
+ group.eventList.forEach(function (event) {
121
+ if (event.id === eventId) {
122
+ event.attrList.forEach(function (attr) {
123
+ if (attr.label === eventAttr && !data) {
124
+ data = {
125
+ attrId: attr.id,
126
+ attrName: attr.label,
127
+ propCategory: 'eventProp',
128
+ type: attr.type
129
+ };
130
+ }
131
+ });
132
+ }
133
+ });
134
+ });
135
+ } else if (userAttr) {
136
+ userPropList.forEach(function (user) {
137
+ if (user.name === userAttr) {
138
+ data = _objectSpread({
139
+ attrId: user.id,
140
+ attrName: user.name
141
+ }, user);
142
+ }
143
+ });
144
+ } else {
145
+ eventEnvList.forEach(function (env) {
146
+ if (env.name === dimensionSub) {
147
+ data = _objectSpread({
148
+ attrId: env.id,
149
+ attrName: env.name
150
+ }, env);
151
+ }
152
+ });
153
+ }
154
+ return data;
155
+ }
156
+ function transferCondition(conditions) {
157
+ var result = [];
158
+ conditions.forEach(function (attr) {
159
+ result.push({
160
+ subtype: attr.subtype,
161
+ attrId: attr.attrId,
162
+ attrName: attr.name,
163
+ label: attr.text,
164
+ type: attr.type,
165
+ propCategory: attr.isEventProp ? 'eventProp' : attr.isUserProp ? 'userProp' : 'envProp',
166
+ category: attr.category,
167
+ dimensionSub: attr.category,
168
+ operator: attr.operator,
169
+ values: attr.params
170
+ });
171
+ });
172
+ return result;
173
+ }
@@ -0,0 +1,32 @@
1
+ declare let util: {
2
+ dayTime: number;
3
+ type(obj: any): string;
4
+ isObject(obj: any): boolean;
5
+ isArray(obj: any): boolean;
6
+ isString(obj: any): boolean;
7
+ isNumber(obj: any): boolean;
8
+ isDate(obj: any): boolean;
9
+ isFunction(obj: any): boolean;
10
+ isEqual(a?: {}, b?: {}): boolean;
11
+ equal(a: any, b: any): boolean;
12
+ random(min: number, max: number): number;
13
+ guid(): string;
14
+ mergeObject(defaults: {
15
+ [x: string]: any;
16
+ }, option: {
17
+ [x: string]: any;
18
+ }): {
19
+ [x: string]: any;
20
+ };
21
+ toThousands(num: number): string;
22
+ toDoubleNumber(num: number): string;
23
+ dateFormat(date?: any, formatter?: string): string;
24
+ timeFormat(date: any, formatter: string | undefined, autoShort: any): string | undefined;
25
+ strMiddleSplit(str: string, config?: {
26
+ maxLength: number;
27
+ beginLength: number;
28
+ endLength: number;
29
+ replaceStr: string;
30
+ }): string;
31
+ };
32
+ export default util;
@@ -0,0 +1,139 @@
1
+ var util = {
2
+ dayTime: 24 * 60 * 60 * 1000,
3
+ type: function type(obj) {
4
+ return Object.prototype.toString.call(obj);
5
+ },
6
+ isObject: function isObject(obj) {
7
+ return this.type(obj) === '[object Object]';
8
+ },
9
+ isArray: function isArray(obj) {
10
+ return this.type(obj) === '[object Array]';
11
+ },
12
+ isString: function isString(obj) {
13
+ return this.type(obj) === '[object String]';
14
+ },
15
+ isNumber: function isNumber(obj) {
16
+ return this.type(obj) === '[object Number]';
17
+ },
18
+ isDate: function isDate(obj) {
19
+ return this.type(obj) === '[object Date]';
20
+ },
21
+ isFunction: function isFunction(obj) {
22
+ return this.type(obj) === '[object Function]';
23
+ },
24
+ isEqual: function isEqual() {
25
+ var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26
+ var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27
+ return JSON.stringify(a) === JSON.stringify(b);
28
+ },
29
+ equal: function equal(a, b) {
30
+ return JSON.stringify(a) === JSON.stringify(b);
31
+ },
32
+ random: function random(min, max) {
33
+ return Math.round(Math.random() * (max - min)) + min;
34
+ },
35
+ guid: function guid() {
36
+ function s4() {
37
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
38
+ }
39
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
40
+ },
41
+ mergeObject: function mergeObject(defaults, option) {
42
+ defaults = defaults || {};
43
+ option = option || {};
44
+ for (var prop in defaults) {
45
+ if (this.isObject(defaults[prop])) {
46
+ option[prop] = option[prop] ? option[prop] : {};
47
+ this.mergeObject(defaults[prop], option[prop]);
48
+ } else if (this.isArray(defaults[prop])) {
49
+ if (!option[prop] || !option[prop].length) {
50
+ option[prop] = defaults[prop];
51
+ } else {
52
+ var i = 0;
53
+ var optLenght = option[prop].length;
54
+ var defaultLength = defaults[prop].length;
55
+ for (i; i < optLenght && i < defaultLength; i++) {
56
+ option[prop][i] = this.mergeObject(defaults[prop][i], option[prop][i]);
57
+ }
58
+ }
59
+ } else {
60
+ option[prop] = option[prop] === null || option[prop] === undefined ? defaults[prop] : option[prop];
61
+ }
62
+ }
63
+ return option;
64
+ },
65
+ toThousands: function toThousands(num) {
66
+ var source = String(num).split('.');
67
+ source[0] = source[0].replace(new RegExp('(\\d)(?=(\\d{3})+$)', 'ig'), '$1,');
68
+ return source.join('.');
69
+ },
70
+ toDoubleNumber: function toDoubleNumber(num) {
71
+ var num2 = num.toString();
72
+ return num > 9 ? num2 : '0' + num2;
73
+ },
74
+ dateFormat: function dateFormat() {
75
+ var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
76
+ var formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-mm-dd';
77
+ return formatter.replace('yyyy', date.getFullYear()).replace('mm', this.toDoubleNumber(date.getMonth() + 1)).replace('dd', this.toDoubleNumber(date.getDate()));
78
+ },
79
+ timeFormat: function timeFormat() {
80
+ var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
81
+ var formatter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'hh:mm:ss';
82
+ var autoShort = arguments.length > 2 ? arguments[2] : undefined;
83
+ if (this.isDate(date)) {
84
+ return formatter.replace('hh', this.toDoubleNumber(date.getHours())).replace('mm', this.toDoubleNumber(date.getMinutes())).replace('ss', this.toDoubleNumber(date.getSeconds()));
85
+ } else if (this.isNumber(date)) {
86
+ var s = parseInt(date / 1000 + '');
87
+ var m = parseInt(s / 60 + '');
88
+ var h = parseInt(m / 60 + '');
89
+ s = s - m * 60;
90
+ m = m - h * 60;
91
+ if (!h && autoShort) {
92
+ formatter = formatter.replace(/hh\S*?mm/, 'mm');
93
+ if (!m) {
94
+ formatter = formatter.replace(/mm\S*?ss/, 'ss');
95
+ return formatter.replace('ss', s + '');
96
+ }
97
+ }
98
+ return formatter.replace('hh', this.toDoubleNumber(h)).replace('mm', this.toDoubleNumber(m)).replace('ss', this.toDoubleNumber(s));
99
+ }
100
+ },
101
+ strMiddleSplit: function strMiddleSplit(str) {
102
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
103
+ maxLength: 20,
104
+ beginLength: 8,
105
+ endLength: 8,
106
+ replaceStr: '...'
107
+ };
108
+ str += '';
109
+ var reg = {
110
+ fullCharReg: /[^\x00-\xff]/,
111
+ fullCharsReg: /[^\x00-\xff]/g,
112
+ anyChars: /[\S\s]{1}/g
113
+ };
114
+ var fullCharLength = (str.match(reg.fullCharsReg) || []).length;
115
+ var fullLength = str.length + fullCharLength;
116
+ var beginArr = [];
117
+ var beginLength = 0;
118
+ var endArr = [];
119
+ var endLength = 0;
120
+ if (fullLength > config.maxLength) {
121
+ var strArr = str.match(reg.anyChars) || [];
122
+ strArr.forEach(function (char) {
123
+ if (beginLength >= config.beginLength) return;
124
+ var len = reg.fullCharReg.test(char) ? 2 : 1;
125
+ beginLength += len;
126
+ beginArr.push(char);
127
+ });
128
+ strArr.reverse().forEach(function (char) {
129
+ if (endLength >= config.endLength) return;
130
+ var len = reg.fullCharReg.test(char) ? 2 : 1;
131
+ endLength += len;
132
+ endArr.push(char);
133
+ });
134
+ return beginArr.join('') + config.replaceStr + endArr.reverse().join('');
135
+ }
136
+ return str;
137
+ }
138
+ };
139
+ export default util;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@zgfe/modules-attribution",
3
+ "version": "1.0.1-alpha.0",
4
+ "module": "es/index.js",
5
+ "typings": "es/index.d.ts",
6
+ "files": [
7
+ "es"
8
+ ],
9
+ "scripts": {
10
+ "build": "father-build",
11
+ "deploy": "npm run docs:build && npm run docs:deploy",
12
+ "docs:build": "dumi build",
13
+ "docs:deploy": "gh-pages -d docs-dist",
14
+ "prepublishOnly": "npm run build",
15
+ "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
16
+ "pub": "lerna publish",
17
+ "start": "dumi dev",
18
+ "test": "umi-test",
19
+ "test:coverage": "umi-test --coverage"
20
+ },
21
+ "lint-staged": {
22
+ "*.{js,jsx,less,md,json}": [
23
+ "prettier --write"
24
+ ],
25
+ "*.ts?(x)": [
26
+ "prettier --parser=typescript --write"
27
+ ]
28
+ },
29
+ "dependencies": {
30
+ "caniuse-lite": "^1.0.30001491",
31
+ "nanoid": "^4.0.2"
32
+ },
33
+ "devDependencies": {
34
+ "@testing-library/jest-dom": "^5.15.1",
35
+ "@testing-library/react": "^12.1.2",
36
+ "@types/jest": "^27.0.3",
37
+ "@types/lodash": "^4.14.191",
38
+ "@umijs/fabric": "^2.8.1",
39
+ "@umijs/test": "^3.0.5",
40
+ "@zgfe/business-lib": "1.1.41-attribution.2",
41
+ "antd": "^4.22.6",
42
+ "dumi": "^1.1.0",
43
+ "echarts": "^5.3.2",
44
+ "echarts-for-react": "^3.0.2",
45
+ "father-build": "^1.17.2",
46
+ "gh-pages": "^3.0.0",
47
+ "lerna": "^4.0.0",
48
+ "lint-staged": "^10.0.7",
49
+ "prettier": "^2.2.1",
50
+ "react": "^16.12.0 || ^17.0.0",
51
+ "yorkie": "^2.0.0"
52
+ },
53
+ "gitHead": "de967bd9bb00ff055a992f8b2f21e656554b239c"
54
+ }