@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
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # modules-attribution
2
+
3
+ 洞察分析
4
+
5
+ ## Getting Started
6
+
7
+ Install dependencies,
8
+
9
+ ```bash
10
+ $ npm i
11
+ ```
12
+
13
+ Start the dev server,
14
+
15
+ ```bash
16
+ $ npm start
17
+ ```
18
+
19
+ Build documentation,
20
+
21
+ ```bash
22
+ $ npm run docs:build
23
+ ```
24
+
25
+ Run test,
26
+
27
+ ```bash
28
+ $ npm test
29
+ ```
30
+
31
+ Build library via `father-build`,
32
+
33
+ ```bash
34
+ $ npm run build
35
+ ```
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ export declare const MiSpin: React.FC;
4
+ export declare const MiNone: React.FC<{
5
+ label?: string;
6
+ }>;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ var classPrefix = 'mi-common';
4
+ export var MiSpin = function MiSpin() {
5
+ return /*#__PURE__*/React.createElement("div", {
6
+ className: "".concat(classPrefix, "-loading-icon")
7
+ });
8
+ };
9
+ export var MiNone = function MiNone(props) {
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: "".concat(classPrefix, "-none-container")
12
+ }, /*#__PURE__*/React.createElement("div", {
13
+ className: "".concat(classPrefix, "-none")
14
+ }), /*#__PURE__*/React.createElement("span", {
15
+ className: "".concat(classPrefix, "-none-text")
16
+ }, " ", props.label));
17
+ };
@@ -0,0 +1,27 @@
1
+ @import '~@zgfe/business-lib/es/assets/styles/inner.less';
2
+
3
+ .mi-common {
4
+ &-loading-icon {
5
+ z-index: 1000;
6
+ display: inline-block;
7
+ width: 40px;
8
+ height: 40px;
9
+ background: url('../../../style/image/ring.svg') no-repeat;
10
+ background-size: contain;
11
+ }
12
+
13
+ &-none-text {
14
+ color: @text-color;
15
+ font-size: 16px;
16
+ }
17
+
18
+ &-none {
19
+ width: 348px;
20
+ height: 132px;
21
+ background: url('../../../style/image/noData.png') no-repeat;
22
+ }
23
+
24
+ &-none-container {
25
+ text-align: center;
26
+ }
27
+ }
@@ -0,0 +1,5 @@
1
+ import OptionGroup from './option';
2
+ import TableList from './tableList';
3
+ import SearchTime from './searchTime';
4
+ import { MiNone, MiSpin } from './common';
5
+ export { OptionGroup, TableList, SearchTime, MiNone, MiSpin };
@@ -0,0 +1,5 @@
1
+ import OptionGroup from './option';
2
+ import TableList from './tableList';
3
+ import SearchTime from './searchTime';
4
+ import { MiNone, MiSpin } from './common';
5
+ export { OptionGroup, TableList, SearchTime, MiNone, MiSpin };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ import { OptionGroupProps } from './types';
4
+ declare const OptionGroup: React.ForwardRefExoticComponent<OptionGroupProps & React.RefAttributes<any>>;
5
+ export default OptionGroup;
@@ -0,0 +1,134 @@
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ 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."); }
6
+ 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); }
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
+ 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; }
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ import { BizGlobalDataContext, IconFont, BizAddToScene, BizAddToPanel } from '@zgfe/business-lib';
11
+ import { Button } from 'antd';
12
+ import React, { useContext, useImperativeHandle, useState } from 'react';
13
+ import { chartTypes } from '../../constants';
14
+ import './styles/index.less';
15
+ import { AttributableContext } from '../../types';
16
+ var classPrefix = 'option-group';
17
+ var OptionGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
18
+ var searchData = props.searchData;
19
+ var _useState = useState(false),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ showPanelDialog = _useState2[0],
22
+ setShowPanelDialog = _useState2[1];
23
+ var _useState3 = useState(false),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ showSceneDialog = _useState4[0],
26
+ setShowSceneDialog = _useState4[1];
27
+ var _useState5 = useState(),
28
+ _useState6 = _slicedToArray(_useState5, 2),
29
+ panelValue = _useState6[0],
30
+ setPanelValue = _useState6[1];
31
+ var _useState7 = useState(),
32
+ _useState8 = _slicedToArray(_useState7, 2),
33
+ panelType = _useState8[0],
34
+ setPanelType = _useState8[1];
35
+ var _useContext = useContext(BizGlobalDataContext),
36
+ currentApp = _useContext.currentApp;
37
+ var _useContext2 = useContext(AttributableContext),
38
+ panelId = _useContext2.panelId,
39
+ panelName = _useContext2.panelName,
40
+ elementId = _useContext2.elementId,
41
+ searching = _useContext2.searching,
42
+ enableAddScene = _useContext2.enableAddScene,
43
+ afterEditTarget = _useContext2.afterEditTarget;
44
+ useImperativeHandle(ref, function () {
45
+ return {
46
+ saveAsPanel: function saveAsPanel() {
47
+ var item = {
48
+ panel: {
49
+ id: panelId
50
+ },
51
+ name: panelName ? panelName + '(1)' : '归因分析'
52
+ };
53
+ setPanelValue(item);
54
+ setShowPanelDialog(true);
55
+ },
56
+ savePanel: function savePanel() {
57
+ var item = {
58
+ panel: {
59
+ id: panelId
60
+ },
61
+ name: panelName
62
+ };
63
+ setPanelValue(item);
64
+ setShowPanelDialog(true);
65
+ setPanelType('edit');
66
+ }
67
+ };
68
+ });
69
+ var _onOk = function onOk(type, val) {
70
+ if (type === 'panel') {
71
+ setPanelType(undefined);
72
+ setShowPanelDialog(false);
73
+ } else {
74
+ setShowSceneDialog(false);
75
+ }
76
+ if (afterEditTarget) afterEditTarget(type, val);
77
+ };
78
+ var _onCancel = function onCancel(type) {
79
+ if (type === 'panel') {
80
+ setShowPanelDialog(false);
81
+ setPanelType(undefined);
82
+ } else {
83
+ setShowSceneDialog(false);
84
+ }
85
+ };
86
+ return /*#__PURE__*/React.createElement("div", {
87
+ className: classPrefix
88
+ }, !panelId && enableAddScene && /*#__PURE__*/React.createElement(Button, {
89
+ disabled: searching,
90
+ icon: /*#__PURE__*/React.createElement(IconFont, {
91
+ className: "".concat(classPrefix, "-icon"),
92
+ type: "tianjia2"
93
+ }),
94
+ onClick: function onClick() {
95
+ return setShowSceneDialog(true);
96
+ }
97
+ }, "\u6DFB\u52A0\u5230\u5E38\u7528\u573A\u666F"), !panelId && /*#__PURE__*/React.createElement(Button, {
98
+ disabled: searching,
99
+ icon: /*#__PURE__*/React.createElement(IconFont, {
100
+ className: "".concat(classPrefix, "-icon"),
101
+ type: "tianjia2"
102
+ }),
103
+ onClick: function onClick() {
104
+ return setShowPanelDialog(true);
105
+ }
106
+ }, "\u6DFB\u52A0\u5230\u770B\u677F"), showSceneDialog && /*#__PURE__*/React.createElement(BizAddToScene, {
107
+ params: _objectSpread({
108
+ app_id: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
109
+ module: 'attribution'
110
+ }, searchData),
111
+ onCancel: function onCancel() {
112
+ return _onCancel('scene');
113
+ },
114
+ onOk: function onOk(data) {
115
+ return _onOk('scene', data);
116
+ }
117
+ }), showPanelDialog && /*#__PURE__*/React.createElement(BizAddToPanel, {
118
+ defaultValue: panelValue,
119
+ params: _objectSpread({
120
+ app_id: currentApp === null || currentApp === void 0 ? void 0 : currentApp.appId,
121
+ module: 'attribution'
122
+ }, searchData),
123
+ type: panelType,
124
+ styleOptions: chartTypes,
125
+ elementId: elementId,
126
+ onCancel: function onCancel() {
127
+ return _onCancel('panel');
128
+ },
129
+ onOk: function onOk(data) {
130
+ return _onOk('panel', data);
131
+ }
132
+ }));
133
+ });
134
+ export default OptionGroup;
@@ -0,0 +1,17 @@
1
+ @import '~@zgfe/business-lib/es/assets/styles/variable.less';
2
+
3
+ .option-group {
4
+ display: flex;
5
+ &-icon.bsicon {
6
+ margin-right: @margin-xss;
7
+ font-size: 18px;
8
+ }
9
+ .ant-btn {
10
+ display: flex;
11
+ align-items: center;
12
+ padding: 0 12px;
13
+ &:not(:first-child) {
14
+ margin-left: 16px;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ export interface OptionGroupProps {
2
+ value?: any;
3
+ title?: string;
4
+ searchData: any;
5
+ result?: any;
6
+ enableSelectChart?: boolean;
7
+ onClickGenerateReport?: (value: any) => void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ import { SearchPanelProps } from './types';
4
+ declare const SearchTime: React.FC<SearchPanelProps>;
5
+ export default SearchTime;
@@ -0,0 +1,41 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = 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; }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { BizDatePicker } from '@zgfe/business-lib';
8
+ import React, { useContext, useState } from 'react';
9
+ import { getInitDate } from '../../constants';
10
+ import { AttributableContext } from '../../types';
11
+ import './styles/index.less';
12
+ var classPrefix = 'search-panel';
13
+ var SearchTime = function SearchTime(props) {
14
+ var _useContext = useContext(AttributableContext),
15
+ includeToday = _useContext.includeToday;
16
+ console.log('当前时间段', getInitDate(includeToday));
17
+ var _useState = useState(props.time || getInitDate(includeToday)),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ time = _useState2[0],
20
+ setTime = _useState2[1];
21
+ var _useState3 = useState(0),
22
+ _useState4 = _slicedToArray(_useState3, 2),
23
+ timer = _useState4[0],
24
+ setTimer = _useState4[1];
25
+ var onChangeTime = function onChangeTime(val) {
26
+ if (timer) clearTimeout(timer);
27
+ setTimer(setTimeout(function () {
28
+ setTime(val);
29
+ props.onChange({
30
+ time: val
31
+ });
32
+ }, 10));
33
+ };
34
+ return /*#__PURE__*/React.createElement("div", {
35
+ className: classPrefix
36
+ }, /*#__PURE__*/React.createElement(BizDatePicker, {
37
+ defaultValue: time,
38
+ onChange: onChangeTime
39
+ }));
40
+ };
41
+ export default SearchTime;
@@ -0,0 +1,19 @@
1
+ @import '~@zgfe/business-lib/es/assets/styles/variable.less';
2
+
3
+ .search-panel {
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: space-between;
7
+ .biz-date-picker-wrap {
8
+ > :nth-child(1) {
9
+ display: none;
10
+ }
11
+ }
12
+ &-search-right {
13
+ display: flex;
14
+ }
15
+
16
+ &-select {
17
+ width: 112px;
18
+ }
19
+ }
@@ -0,0 +1,8 @@
1
+ import { DatePickerTypes } from '@zgfe/business-lib/es/datePicker/types';
2
+ export interface SearchPanelProps {
3
+ enableSelectChart?: boolean;
4
+ time?: DatePickerTypes.Value;
5
+ onChange: (data: {
6
+ time: any;
7
+ }) => void;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ import { TableDataHandleProps } from '../../types';
4
+ declare const TableList: React.FC<{
5
+ total: number;
6
+ tableDataList: TableDataHandleProps;
7
+ }>;
8
+ export default TableList;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Table } from 'antd';
3
+ import './styles/index.less';
4
+ var TableList = function TableList(props) {
5
+ var classPrefix = 'table-list';
6
+ var tableDataList = props.tableDataList,
7
+ total = props.total;
8
+ return /*#__PURE__*/React.createElement("div", {
9
+ className: classPrefix
10
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Table, {
11
+ dataSource: tableDataList.dataSource,
12
+ columns: tableDataList.columns,
13
+ rowKey: "key",
14
+ pagination: {
15
+ showTotal: function showTotal(total) {
16
+ return "\u5171 ".concat(total, " \u6761");
17
+ },
18
+ showQuickJumper: true,
19
+ showSizeChanger: total > 10
20
+ }
21
+ })));
22
+ };
23
+ export default TableList;
@@ -0,0 +1,7 @@
1
+ .table-list {
2
+ margin-top: 25px;
3
+ &-empty-tips {
4
+ margin-top: 150px;
5
+ text-align: center;
6
+ }
7
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ import { TitleProps } from './types';
4
+ declare const EditTitle: React.FC<TitleProps>;
5
+ export default EditTitle;
@@ -0,0 +1,187 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = 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; }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { Input, Menu, Dropdown, Button, message } from 'antd';
8
+ import React, { useContext, useRef, useState } from 'react';
9
+ import { ajax, IconFont } from '@zgfe/business-lib';
10
+ import './styles/index.less';
11
+ import Apis from '../../constants/apis';
12
+ import { AttributableContext } from '../../types';
13
+ var classPrefix = 'attribution-title';
14
+ var EditTitle = function EditTitle(props) {
15
+ var title = props.title,
16
+ type = props.type,
17
+ onSave = props.onSave,
18
+ onSaveAs = props.onSaveAs;
19
+ var _useState = useState(title),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ curTitle = _useState2[0],
22
+ setCurTitle = _useState2[1];
23
+ var _useState3 = useState(title),
24
+ _useState4 = _slicedToArray(_useState3, 2),
25
+ prevTitle = _useState4[0],
26
+ setPrevTitle = _useState4[1];
27
+ var _useContext = useContext(AttributableContext),
28
+ panelId = _useContext.panelId,
29
+ elementId = _useContext.elementId,
30
+ panelName = _useContext.panelName,
31
+ changeLoading = _useContext.changeLoading,
32
+ afterEditTarget = _useContext.afterEditTarget,
33
+ searching = _useContext.searching;
34
+ var inputRef = useRef(null);
35
+ var menu = /*#__PURE__*/React.createElement(Menu, {
36
+ items: [{
37
+ key: '1',
38
+ label: '编辑名称',
39
+ icon: /*#__PURE__*/React.createElement(IconFont, {
40
+ type: "bianji"
41
+ }),
42
+ onClick: function onClick() {
43
+ inputRef.current.focus({
44
+ cursor: 'end'
45
+ });
46
+ }
47
+ }, {
48
+ key: '2',
49
+ label: '删除指标',
50
+ icon: /*#__PURE__*/React.createElement(IconFont, {
51
+ type: "shanchu"
52
+ }),
53
+ onClick: function onClick() {
54
+ return onDelete();
55
+ }
56
+ }]
57
+ });
58
+ var onDelete = function onDelete() {
59
+ changeLoading(true);
60
+ ajax(Apis.delPanelElement, {
61
+ method: 'post',
62
+ data: {
63
+ panel_id: panelId,
64
+ element_id: elementId
65
+ }
66
+ }).then(function (res) {
67
+ changeLoading(false);
68
+ if (res.flag === 101) {
69
+ message.success('删除成功');
70
+ callback('delete');
71
+ } else {
72
+ message.error('删除失败');
73
+ }
74
+ }).catch(function () {
75
+ changeLoading(false);
76
+ });
77
+ };
78
+ var onBlur = function onBlur(e) {
79
+ var value = e.target.value.trim();
80
+ if (value === prevTitle || !value) return;
81
+ changeLoading(true);
82
+ ajax(Apis.updateElementName, {
83
+ method: 'post',
84
+ data: {
85
+ panel_id: panelId,
86
+ element_id: elementId,
87
+ name: value
88
+ }
89
+ }).then(function (res) {
90
+ changeLoading(false);
91
+ if (res.flag === 101) {
92
+ message.success('编辑成功');
93
+ setPrevTitle(value);
94
+ if (props.onEditTitle) props.onEditTitle(value);
95
+ } else {
96
+ message.error('编辑失败');
97
+ setCurTitle(prevTitle);
98
+ }
99
+ }).catch(function () {
100
+ changeLoading(false);
101
+ setCurTitle(prevTitle);
102
+ });
103
+ };
104
+ var onChange = function onChange(e) {
105
+ setCurTitle(e.target.value.trim());
106
+ };
107
+ var callback = function callback(type) {
108
+ var param = elementId ? {
109
+ panelId: panelId,
110
+ elementId: elementId,
111
+ name: panelName
112
+ } : null;
113
+ afterEditTarget && afterEditTarget(type, param);
114
+ };
115
+ return /*#__PURE__*/React.createElement("div", {
116
+ className: classPrefix
117
+ }, /*#__PURE__*/React.createElement("div", {
118
+ className: "".concat(classPrefix, "-input-box")
119
+ }, /*#__PURE__*/React.createElement("a", {
120
+ className: "btn-back",
121
+ onClick: function onClick() {
122
+ return callback('cancel');
123
+ }
124
+ }, /*#__PURE__*/React.createElement(IconFont, {
125
+ type: "fanhuiicon"
126
+ }), "\u8FD4\u56DE"), /*#__PURE__*/React.createElement("div", {
127
+ className: "".concat(classPrefix, "-input-box-container")
128
+ }, /*#__PURE__*/React.createElement(Input, {
129
+ ref: inputRef,
130
+ className: "".concat(classPrefix, "-input-box-content"),
131
+ status: !curTitle ? 'error' : '',
132
+ value: curTitle,
133
+ onBlur: onBlur,
134
+ onChange: onChange
135
+ }), !curTitle ? /*#__PURE__*/React.createElement("span", {
136
+ className: "".concat(classPrefix, "-error-tip")
137
+ }, "\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A") : null)), type === 'edit' ? /*#__PURE__*/React.createElement("div", {
138
+ className: "".concat(classPrefix, "-option")
139
+ }, /*#__PURE__*/React.createElement(Dropdown, {
140
+ overlayClassName: "".concat(classPrefix, "-dropdown"),
141
+ dropdownRender: function dropdownRender() {
142
+ return menu;
143
+ },
144
+ trigger: ['click']
145
+ }, /*#__PURE__*/React.createElement("a", {
146
+ className: "".concat(classPrefix, "-pop-btn")
147
+ }, /*#__PURE__*/React.createElement(IconFont, {
148
+ className: "biz-pop-icon",
149
+ type: "gengduocaozuo1"
150
+ }))), /*#__PURE__*/React.createElement("div", {
151
+ className: "attribution-divider"
152
+ }), /*#__PURE__*/React.createElement(Button, {
153
+ className: "attribution-btn",
154
+ type: "text",
155
+ onClick: function onClick() {
156
+ return callback('cancel');
157
+ }
158
+ }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
159
+ className: "attribution-btn",
160
+ disabled: searching || !curTitle,
161
+ type: "primary",
162
+ onClick: onSave
163
+ }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement(Button, {
164
+ className: "attribution-btn",
165
+ disabled: searching,
166
+ type: "primary",
167
+ onClick: onSaveAs
168
+ }, "\u53E6\u5B58\u4E3A")) : /*#__PURE__*/React.createElement("div", {
169
+ className: "".concat(classPrefix, "-title-btn")
170
+ }, /*#__PURE__*/React.createElement(Button, {
171
+ className: "attribution-btn",
172
+ type: "text",
173
+ onClick: function onClick() {
174
+ return callback('cancel');
175
+ }
176
+ }, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
177
+ className: "attribution-btn",
178
+ disabled: searching || !curTitle,
179
+ type: "primary",
180
+ onClick: onSaveAs
181
+ }, "\u4FDD\u5B58")));
182
+ };
183
+ EditTitle.defaultProps = {
184
+ title: '归因分析',
185
+ type: 'edit'
186
+ };
187
+ export default EditTitle;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import './styles/search.less';
3
+ declare const SearchTitle: React.FC<{
4
+ title: string;
5
+ onChange: (searchTxt: string) => void;
6
+ }>;
7
+ export default SearchTitle;
@@ -0,0 +1,47 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = 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; }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useState } from 'react';
8
+ import { SearchOutlined } from '@ant-design/icons';
9
+ import './styles/search.less';
10
+ import { BizSearchInput } from '@zgfe/business-lib';
11
+ var classPrefix = 'search-title';
12
+ var SearchTitle = function SearchTitle(props) {
13
+ var _useState = useState(false),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ isSearch = _useState2[0],
16
+ setIsSearch = _useState2[1];
17
+ var _useState3 = useState(0),
18
+ _useState4 = _slicedToArray(_useState3, 2),
19
+ timer = _useState4[0],
20
+ setTimer = _useState4[1];
21
+ var onSearch = function onSearch(value) {
22
+ if (timer) clearTimeout(timer);
23
+ setTimer(setTimeout(function () {
24
+ props.onChange(value);
25
+ }, 500));
26
+ };
27
+ var onBlur = function onBlur(value) {
28
+ if (!value) {
29
+ setIsSearch(false);
30
+ }
31
+ };
32
+ return /*#__PURE__*/React.createElement("div", {
33
+ className: classPrefix
34
+ }, /*#__PURE__*/React.createElement("span", {
35
+ className: "".concat(classPrefix, "-title")
36
+ }, props.title), isSearch ? /*#__PURE__*/React.createElement(BizSearchInput, {
37
+ className: "".concat(classPrefix, "-input"),
38
+ onChange: onSearch,
39
+ onBlur: onBlur
40
+ }) : /*#__PURE__*/React.createElement(SearchOutlined, {
41
+ className: "".concat(classPrefix, "-icon"),
42
+ onClick: function onClick() {
43
+ return setIsSearch(true);
44
+ }
45
+ }));
46
+ };
47
+ export default SearchTitle;