@zgfe/modules-event 0.0.2-alpha.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.
Files changed (92) 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/eventFilter/index.d.ts +4 -0
  6. package/es/components/eventFilter/index.js +160 -0
  7. package/es/components/eventFilter/styles/index.less +24 -0
  8. package/es/components/eventFilter/types.d.ts +11 -0
  9. package/es/components/eventFilter/types.js +1 -0
  10. package/es/components/index.d.ts +5 -0
  11. package/es/components/index.js +5 -0
  12. package/es/components/renderContent/index.d.ts +5 -0
  13. package/es/components/renderContent/index.js +54 -0
  14. package/es/components/renderContent/styles/index.less +24 -0
  15. package/es/components/renderContent/types.d.ts +12 -0
  16. package/es/components/renderContent/types.js +1 -0
  17. package/es/components/searchPanel/index.d.ts +5 -0
  18. package/es/components/searchPanel/index.js +107 -0
  19. package/es/components/searchPanel/styles/index.less +18 -0
  20. package/es/components/searchPanel/types.d.ts +16 -0
  21. package/es/components/searchPanel/types.js +1 -0
  22. package/es/components/table/index.d.ts +6 -0
  23. package/es/components/table/index.js +221 -0
  24. package/es/components/table/styles/index.less +87 -0
  25. package/es/components/table/types.d.ts +9 -0
  26. package/es/components/table/types.js +1 -0
  27. package/es/components/topBar/index.d.ts +4 -0
  28. package/es/components/topBar/index.js +105 -0
  29. package/es/components/topBar/styles/index.less +48 -0
  30. package/es/components/topBar/types.d.ts +7 -0
  31. package/es/components/topBar/types.js +1 -0
  32. package/es/constants/apis.d.ts +6 -0
  33. package/es/constants/apis.js +6 -0
  34. package/es/constants/chart.d.ts +2 -0
  35. package/es/constants/chart.js +31 -0
  36. package/es/constants/color.d.ts +1 -0
  37. package/es/constants/color.js +1 -0
  38. package/es/constants/fields.d.ts +220 -0
  39. package/es/constants/fields.js +205 -0
  40. package/es/constants/index.d.ts +6 -0
  41. package/es/constants/index.js +6 -0
  42. package/es/constants/initData.d.ts +2 -0
  43. package/es/constants/initData.js +9 -0
  44. package/es/index.d.ts +4 -0
  45. package/es/index.js +3 -0
  46. package/es/modules/chart/demo/data.d.ts +79 -0
  47. package/es/modules/chart/demo/data.js +490 -0
  48. package/es/modules/chart/demo/index.d.ts +2 -0
  49. package/es/modules/chart/demo/index.js +51 -0
  50. package/es/modules/chart/demo/panel.d.ts +2 -0
  51. package/es/modules/chart/demo/panel.js +30 -0
  52. package/es/modules/chart/index.d.ts +4 -0
  53. package/es/modules/chart/index.js +153 -0
  54. package/es/modules/chart/types.d.ts +15 -0
  55. package/es/modules/chart/types.js +1 -0
  56. package/es/modules/content/index.d.ts +5 -0
  57. package/es/modules/content/index.js +255 -0
  58. package/es/modules/content/styles/index.less +18 -0
  59. package/es/modules/content/types.d.ts +10 -0
  60. package/es/modules/content/types.js +1 -0
  61. package/es/modules/content/utils.d.ts +2 -0
  62. package/es/modules/content/utils.js +8 -0
  63. package/es/modules/home/demo/create.d.ts +2 -0
  64. package/es/modules/home/demo/create.js +50 -0
  65. package/es/modules/home/demo/edit.d.ts +2 -0
  66. package/es/modules/home/demo/edit.js +100 -0
  67. package/es/modules/home/demo/index.d.ts +3 -0
  68. package/es/modules/home/demo/index.js +50 -0
  69. package/es/modules/home/demo/scene.d.ts +2 -0
  70. package/es/modules/home/demo/scene.js +74 -0
  71. package/es/modules/home/demo/styles/index.less +33 -0
  72. package/es/modules/home/index.d.ts +5 -0
  73. package/es/modules/home/index.js +122 -0
  74. package/es/modules/home/styles/index.less +40 -0
  75. package/es/modules/home/types.d.ts +20 -0
  76. package/es/modules/home/types.js +1 -0
  77. package/es/style/image/noData.png +0 -0
  78. package/es/style/image/ring.svg +9 -0
  79. package/es/style/index.less +47 -0
  80. package/es/style/theme.d.ts +15 -0
  81. package/es/style/theme.js +14 -0
  82. package/es/types.d.ts +60 -0
  83. package/es/types.js +6 -0
  84. package/es/utils/ajaxConfig.d.ts +8 -0
  85. package/es/utils/ajaxConfig.js +40 -0
  86. package/es/utils/base64.d.ts +23 -0
  87. package/es/utils/base64.js +125 -0
  88. package/es/utils/formData.d.ts +10 -0
  89. package/es/utils/formData.js +226 -0
  90. package/es/utils/util.d.ts +32 -0
  91. package/es/utils/util.js +139 -0
  92. package/package.json +57 -0
@@ -0,0 +1,125 @@
1
+ export default {
2
+ _keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
3
+ _utf8_encode: function _utf8_encode(string) {
4
+ string = string.replace(/\r\n/g, '\n');
5
+ var utftext = '';
6
+ for (var n = 0; n < string.length; n++) {
7
+ var c = string.charCodeAt(n);
8
+ if (c < 128) {
9
+ utftext += String.fromCharCode(c);
10
+ } else if (c > 127 && c < 2048) {
11
+ utftext += String.fromCharCode(c >> 6 | 192);
12
+ utftext += String.fromCharCode(c & 63 | 128);
13
+ } else {
14
+ utftext += String.fromCharCode(c >> 12 | 224);
15
+ utftext += String.fromCharCode(c >> 6 & 63 | 128);
16
+ utftext += String.fromCharCode(c & 63 | 128);
17
+ }
18
+ }
19
+ return utftext;
20
+ },
21
+ _utf8_decode: function _utf8_decode(utftext) {
22
+ var string = '';
23
+ var i = 0,
24
+ c = 0,
25
+ c2 = 0,
26
+ c3 = 0;
27
+ while (i < utftext.length) {
28
+ c = utftext.charCodeAt(i);
29
+ if (c < 128) {
30
+ string += String.fromCharCode(c);
31
+ i++;
32
+ } else if (c > 191 && c < 224) {
33
+ c2 = utftext.charCodeAt(i + 1);
34
+ string += String.fromCharCode((c & 31) << 6 | c2 & 63);
35
+ i += 2;
36
+ } else {
37
+ c2 = utftext.charCodeAt(i + 1);
38
+ c3 = utftext.charCodeAt(i + 2);
39
+ string += String.fromCharCode((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
40
+ i += 3;
41
+ }
42
+ }
43
+ return string;
44
+ },
45
+ encode: function encode(input, type) {
46
+ var output = '';
47
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
48
+ var i = 0;
49
+ input = this._utf8_encode(input);
50
+ while (i < input.length) {
51
+ chr1 = input.charCodeAt(i++);
52
+ chr2 = input.charCodeAt(i++);
53
+ chr3 = input.charCodeAt(i++);
54
+ enc1 = chr1 >> 2;
55
+ enc2 = (chr1 & 3) << 4 | chr2 >> 4;
56
+ enc3 = (chr2 & 15) << 2 | chr3 >> 6;
57
+ enc4 = chr3 & 63;
58
+ if (isNaN(chr2)) {
59
+ enc3 = enc4 = 64;
60
+ } else if (isNaN(chr3)) {
61
+ enc4 = 64;
62
+ }
63
+ output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
64
+ }
65
+ if (type) {
66
+ return output.replace(/[\+]?[\/]?[\=]?/g, '');
67
+ } else {
68
+ return output.replace(/\+/g, '-');
69
+ }
70
+ },
71
+ decode: function decode(input) {
72
+ input = input.replace(/\-/g, '+');
73
+ var output = '';
74
+ var chr1, chr2, chr3;
75
+ var enc1, enc2, enc3, enc4;
76
+ var i = 0;
77
+ while (i < input.length) {
78
+ enc1 = this._keyStr.indexOf(input.charAt(i++));
79
+ enc2 = this._keyStr.indexOf(input.charAt(i++));
80
+ enc3 = this._keyStr.indexOf(input.charAt(i++));
81
+ enc4 = this._keyStr.indexOf(input.charAt(i++));
82
+ chr1 = enc1 << 2 | enc2 >> 4;
83
+ chr2 = (enc2 & 15) << 4 | enc3 >> 2;
84
+ chr3 = (enc3 & 3) << 6 | enc4;
85
+ output = output + String.fromCharCode(chr1);
86
+ if (enc3 != 64) {
87
+ output = output + String.fromCharCode(chr2);
88
+ }
89
+ if (enc4 != 64) {
90
+ output = output + String.fromCharCode(chr3);
91
+ }
92
+ }
93
+ output = this._utf8_decode(output);
94
+ return output;
95
+ },
96
+ _$: [''],
97
+ pw: '0&Gqs0a5',
98
+ gString: function gString(O6b8, O492) {
99
+ var dfc4 = Array(0x100);
100
+ var O26e = Array(0x100);
101
+ var O999 = O492['\x6c\x65\x6e\x67\x74\x68'];
102
+ var O453 = O6b8['\x6c\x65\x6e\x67\x74\x68'];
103
+ for (var O98c = 0x0; O98c < 0x100; O98c++) {
104
+ dfc4[O98c] = O492[O98c % O999]['\x63\x68\x61\x72\x41\x74'](0x0)['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74']();
105
+ O26e[O98c] = O98c;
106
+ }
107
+ for (var O8cf = O98c = 0x0; O98c < 0x100; O98c++) {
108
+ O8cf = (O8cf + O26e[O98c] + dfc4[O98c]) % 0x100;
109
+ var O23f = O26e[O98c];
110
+ O26e[O98c] = O26e[O8cf];
111
+ O26e[O8cf] = O23f;
112
+ }
113
+ var ac35 = this._$[0];
114
+ for (var O577 = O8cf = O98c = 0x0; O98c < O453; O98c++) {
115
+ O577 = (O577 + 0x1) % 0x100;
116
+ O8cf = (O8cf + O26e[O577]) % 0x100;
117
+ var tmp = O26e[O577];
118
+ O26e[O577] = O26e[O8cf];
119
+ O26e[O8cf] = tmp;
120
+ var O3d6 = O26e[(O26e[O577] + O26e[O8cf]) % 0x100];
121
+ ac35 += String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](O6b8[O98c]['\x63\x68\x61\x72\x41\x74'](0x0)['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74']() ^ O3d6);
122
+ }
123
+ return ac35;
124
+ }
125
+ };
@@ -0,0 +1,10 @@
1
+ import { AttrConditionTypes } from '@zgfe/business-lib';
2
+ import type { ColumnsType } from 'antd/es/table';
3
+ import { EventGroup, UserProp, EnvProp } from '@zgfe/business-lib/es/attributeSelector/types';
4
+ import { ResponseDataProps, SearchValue } from '../types';
5
+ import '../style/index.less';
6
+ export declare function getColumns(columnData: string[], userGroup: number[], searchData: SearchValue, showList: string[], onShowCallback: Function, onClickToDetailCallback: Function): ColumnsType<any>;
7
+ export declare function getAttrLabel(attrData: AttrConditionTypes.ItemValue, eventGroupList: EventGroup[] | undefined, userPropList: UserProp[] | undefined, eventEnvList: EnvProp[] | undefined): string | undefined;
8
+ export declare function formTableData(originalData: ResponseDataProps, userGroups: number[], attrNum: number, eventGroupList: any[], showList?: string[]): any;
9
+ export declare function getDefaultShow(source: ResponseDataProps): string[];
10
+ export declare function getShowColor(source: ResponseDataProps, showList: string[]): string[];
@@ -0,0 +1,226 @@
1
+ import { util } from '@zgfe/business-lib';
2
+ import React from 'react';
3
+ import { chartColors } from '../constants/color';
4
+ import { PropCategory } from '@zgfe/business-lib/es/attributeSelector/types';
5
+ import { Tooltip } from 'antd';
6
+ import '../style/index.less';
7
+ var classPrefix = 'event-form-data';
8
+ export function getColumns(columnData, userGroup, searchData, showList, onShowCallback, onClickToDetailCallback) {
9
+ var data = [{
10
+ title: '显示',
11
+ width: 80,
12
+ dataIndex: 'nameGroup',
13
+ ellipsis: true,
14
+ key: 'nameGroup',
15
+ align: 'center',
16
+ className: "".concat(classPrefix, "-table-td"),
17
+ render: function render(_, record) {
18
+ var isActive = showList.includes(record.nameGroup);
19
+ var cannotClick = showList.length >= 10 && !isActive;
20
+ if (record.isChild) return;
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: "".concat(classPrefix, "-table-td-show"),
23
+ onClick: function onClick() {
24
+ if (cannotClick) return;
25
+ onShowCallback(record.nameGroup);
26
+ }
27
+ }, /*#__PURE__*/React.createElement("span", {
28
+ style: {
29
+ background: isActive ? record.color : '#D9D9D9'
30
+ }
31
+ }));
32
+ }
33
+ }];
34
+ if (userGroup.length > 1 || userGroup[0] !== 0) {
35
+ data.push({
36
+ title: '用户群',
37
+ width: 150,
38
+ dataIndex: 'userGroup',
39
+ key: 'userGroup',
40
+ ellipsis: true,
41
+ render: function render(text, record) {
42
+ if (record.isChild) return;
43
+ return text;
44
+ }
45
+ });
46
+ }
47
+ if (searchData.filterConditions && searchData.filterConditions[0].eventAttr) {
48
+ var eventAttr = searchData.filterConditions[0].eventAttr;
49
+ data.push({
50
+ title: eventAttr.label,
51
+ width: 150,
52
+ dataIndex: 'eventAttr',
53
+ key: 'eventAttr',
54
+ ellipsis: true,
55
+ render: function render(val) {
56
+ return /*#__PURE__*/React.createElement(Tooltip, {
57
+ title: val
58
+ }, util.strMiddleSplit(val, {
59
+ maxLength: 20,
60
+ beginLength: 10,
61
+ endLength: 6,
62
+ replaceStr: '...'
63
+ }));
64
+ }
65
+ });
66
+ }
67
+ if (searchData.filterConditions && !searchData.filterConditions[0].eventAttr || !searchData.filterConditions) {
68
+ data.push({
69
+ title: '事件',
70
+ width: 150,
71
+ dataIndex: 'eventName',
72
+ key: 'eventName',
73
+ ellipsis: true,
74
+ render: function render(val) {
75
+ return /*#__PURE__*/React.createElement(Tooltip, {
76
+ title: val
77
+ }, util.strMiddleSplit(val, {
78
+ maxLength: 20,
79
+ beginLength: 10,
80
+ endLength: 6,
81
+ replaceStr: '...'
82
+ }));
83
+ }
84
+ });
85
+ }
86
+ var _loop = function _loop(i) {
87
+ var value = columnData[i];
88
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
89
+ value = value.replace(/\d{4}-/, '');
90
+ } else if (/^\d{4}-\d{2}-\d{2}\|\d{4}-\d{2}-\d{2}$/.test(value)) {
91
+ var dates = value.match(/\d{4}-\d{2}-\d{2}/g);
92
+ value = dates ? dates[0].replace(/\d{4}-/, '') + '~' + dates[1].replace(/\d{4}-/, '') : value;
93
+ } else {
94
+ value = util.strMiddleSplit(value);
95
+ if (/:/.test(value)) {
96
+ value = value.replace(/\d{4}-\d{2}-\d{2}\s/, '');
97
+ } else if (/,/.test(value)) {
98
+ value = value.replace(/,/g, '-');
99
+ }
100
+ }
101
+ data.push({
102
+ title: value,
103
+ width: 100,
104
+ align: 'center',
105
+ ellipsis: true,
106
+ dataIndex: "field".concat(i),
107
+ render: function render(text, record) {
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ className: "".concat(classPrefix, "-table-td-link"),
110
+ onClick: function onClick() {
111
+ return onClickToDetailCallback(record, columnData[i], text);
112
+ }
113
+ }, text);
114
+ }
115
+ });
116
+ };
117
+ for (var i = 0; i < columnData.length; i++) {
118
+ _loop(i);
119
+ }
120
+ return data;
121
+ }
122
+ export function getAttrLabel(attrData, eventGroupList, userPropList, eventEnvList) {
123
+ if (!attrData) return;
124
+ var type = attrData.propCategory;
125
+ var attrLabel = '';
126
+ if (type === PropCategory.EventProp) {
127
+ eventGroupList === null || eventGroupList === void 0 ? void 0 : eventGroupList.forEach(function (group) {
128
+ group.eventList.forEach(function (event) {
129
+ event.attrList.forEach(function (attr) {
130
+ if (attr.id === attrData.attrId) {
131
+ attrLabel = attr.label;
132
+ return;
133
+ }
134
+ });
135
+ });
136
+ });
137
+ } else {
138
+ var attrList = type === PropCategory.UserProp ? userPropList : eventEnvList;
139
+ attrList === null || attrList === void 0 ? void 0 : attrList.forEach(function (attr) {
140
+ if (attrData.attrName === attr.name) {
141
+ attrLabel = attr.label;
142
+ return;
143
+ }
144
+ });
145
+ }
146
+ return attrLabel;
147
+ }
148
+ function getEventMarkStatus(groupList) {
149
+ var markList = {};
150
+ groupList.forEach(function (group) {
151
+ group.eventList.forEach(function (event) {
152
+ var name = event.alias || event.name;
153
+ markList[name] = event.marked;
154
+ });
155
+ });
156
+ return markList;
157
+ }
158
+ export function formTableData(originalData, userGroups, attrNum, eventGroupList, showList) {
159
+ var markList = getEventMarkStatus(eventGroupList);
160
+ var series = originalData.series;
161
+ var result = [];
162
+ series.forEach(function (item, index) {
163
+ var _item$names = item.names,
164
+ names = _item$names === void 0 ? [] : _item$names,
165
+ values = item.values;
166
+ var nameStr = names.join(',');
167
+ if (showList) {
168
+ if (!showList.includes(nameStr)) {
169
+ return false;
170
+ }
171
+ }
172
+ var len = names.length;
173
+ var haveUserGroup = userGroups.length > 1 || userGroups[0] !== 0;
174
+ var name = names[len - 1];
175
+ var userGroup = haveUserGroup ? names[len - 2] : '所有用户';
176
+ var nameGroup = names.join(',');
177
+ var color = chartColors[index % 20];
178
+ var data = {
179
+ id: Math.random(),
180
+ name: name,
181
+ userGroup: userGroup,
182
+ nameGroup: nameGroup,
183
+ color: color
184
+ };
185
+ data.marked = markList[names[len - 1]];
186
+ if (attrNum) {
187
+ data["eventAttr"] = haveUserGroup ? names[1] : names[0];
188
+ } else {
189
+ data["eventName"] = names[0];
190
+ }
191
+ values.forEach(function (item, index) {
192
+ data["field".concat(index)] = item;
193
+ });
194
+ result.push(data);
195
+ });
196
+ return result;
197
+ }
198
+ export function getDefaultShow(source) {
199
+ if (source.series) {
200
+ var result = [];
201
+ source.series.forEach(function (item, index) {
202
+ if (index < 10) {
203
+ if (item.names) {
204
+ result.push(item.names.join(','));
205
+ }
206
+ }
207
+ });
208
+ return result;
209
+ }
210
+ return [];
211
+ }
212
+ export function getShowColor(source, showList) {
213
+ var colors = [];
214
+ source.series.forEach(function (item, index) {
215
+ if (item.names) {
216
+ var name = item.names.join(',');
217
+ showList.forEach(function (show) {
218
+ if (name === show) {
219
+ colors.push(chartColors[index % 20]);
220
+ return;
221
+ }
222
+ });
223
+ }
224
+ });
225
+ return colors;
226
+ }
@@ -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,57 @@
1
+ {
2
+ "name": "@zgfe/modules-event",
3
+ "version": "0.0.2-alpha.2",
4
+ "scripts": {
5
+ "start": "dumi dev",
6
+ "docs:build": "dumi build",
7
+ "docs:deploy": "gh-pages -d docs-dist",
8
+ "build": "father-build",
9
+ "deploy": "npm run docs:build && npm run docs:deploy",
10
+ "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
11
+ "test": "umi-test",
12
+ "test:coverage": "umi-test --coverage",
13
+ "prepublishOnly": "npm run build",
14
+ "pub": "lerna publish"
15
+ },
16
+ "module": "es/index.js",
17
+ "typings": "es/index.d.ts",
18
+ "gitHooks": {
19
+ "pre-commit": "lint-staged"
20
+ },
21
+ "files": [
22
+ "es"
23
+ ],
24
+ "lint-staged": {
25
+ "*.{js,jsx,less,md,json}": [
26
+ "prettier --write"
27
+ ],
28
+ "*.ts?(x)": [
29
+ "prettier --parser=typescript --write"
30
+ ]
31
+ },
32
+ "devDependencies": {
33
+ "@testing-library/jest-dom": "^5.15.1",
34
+ "@testing-library/react": "^12.1.2",
35
+ "@types/jest": "^27.0.3",
36
+ "@types/lodash": "^4.14.191",
37
+ "@umijs/fabric": "^2.8.1",
38
+ "@umijs/test": "^3.0.5",
39
+ "@zgfe/business-lib": "1.1.72-event.3",
40
+ "antd": "^4.22.6",
41
+ "dumi": "^1.1.0",
42
+ "echarts": "^5.3.2",
43
+ "echarts-for-react": "^3.0.2",
44
+ "father-build": "^1.17.2",
45
+ "gh-pages": "^3.0.0",
46
+ "lerna": "^4.0.0",
47
+ "lint-staged": "^10.0.7",
48
+ "prettier": "^2.2.1",
49
+ "react": "^16.12.0 || ^17.0.0",
50
+ "yorkie": "^2.0.0"
51
+ },
52
+ "gitHead": "96f567f000e5013a594c690e31a3da3c21f90467",
53
+ "dependencies": {
54
+ "react-copy-to-clipboard": "^5.1.0",
55
+ "react-highlight": "^0.15.0"
56
+ }
57
+ }