@zgfe/business-lib 1.1.49 → 1.1.50-title.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 (44) hide show
  1. package/es/addToPanel/components/styleList.js +1 -1
  2. package/es/addToPanel/demo/edit.js +0 -32
  3. package/es/addToPanel/demo/index.js +1 -32
  4. package/es/addToPanel/index.js +22 -15
  5. package/es/addToPanel/types.d.ts +3 -3
  6. package/es/constants/apis.d.ts +2 -0
  7. package/es/constants/apis.js +2 -0
  8. package/es/constants/common.d.ts +29 -0
  9. package/es/constants/common.js +38 -1
  10. package/es/index.d.ts +3 -1
  11. package/es/index.js +3 -1
  12. package/es/layout/optionTitle/components/btnMenu/api.d.ts +4 -0
  13. package/es/layout/optionTitle/components/btnMenu/api.js +7 -0
  14. package/es/layout/optionTitle/components/btnMenu/demo.d.ts +2 -0
  15. package/es/layout/optionTitle/components/btnMenu/demo.js +80 -0
  16. package/es/layout/optionTitle/components/btnMenu/index.d.ts +5 -0
  17. package/es/layout/optionTitle/components/btnMenu/index.js +48 -0
  18. package/es/layout/optionTitle/components/btnMenu/index.less +18 -0
  19. package/es/layout/optionTitle/components/title/demo.d.ts +2 -0
  20. package/es/layout/optionTitle/components/title/demo.js +50 -0
  21. package/es/layout/optionTitle/components/title/index.d.ts +5 -0
  22. package/es/layout/optionTitle/components/title/index.js +106 -0
  23. package/es/layout/optionTitle/components/title/index.less +42 -0
  24. package/es/layout/optionTitle/data.d.ts +3 -0
  25. package/es/layout/optionTitle/data.js +77 -0
  26. package/es/layout/optionTitle/demo/index.d.ts +2 -0
  27. package/es/layout/optionTitle/demo/index.js +84 -0
  28. package/es/layout/optionTitle/demo/index.less +12 -0
  29. package/es/layout/optionTitle/demo/layout.d.ts +3 -0
  30. package/es/layout/optionTitle/demo/layout.js +41 -0
  31. package/es/layout/optionTitle/demo/panelCreate.d.ts +2 -0
  32. package/es/layout/optionTitle/demo/panelCreate.js +82 -0
  33. package/es/layout/optionTitle/index.d.ts +6 -0
  34. package/es/layout/optionTitle/index.js +154 -0
  35. package/es/layout/optionTitle/layout.d.ts +5 -0
  36. package/es/layout/optionTitle/layout.js +38 -0
  37. package/es/layout/optionTitle/styles/index.less +19 -0
  38. package/es/layout/optionTitle/styles/layout.less +43 -0
  39. package/es/layout/optionTitle/styles/search.less +27 -0
  40. package/es/layout/optionTitle/types.d.ts +83 -0
  41. package/es/layout/optionTitle/types.js +15 -0
  42. package/es/layout/optionTitle/typesValue.d.ts +4 -0
  43. package/es/layout/optionTitle/typesValue.js +7 -0
  44. package/package.json +2 -2
@@ -0,0 +1,106 @@
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 = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { Input, message } from 'antd';
8
+ import React, { useImperativeHandle, useRef, useState } from 'react';
9
+ import './index.less';
10
+ import { IconFont } from '../../../..';
11
+ var BizEditText = /*#__PURE__*/React.forwardRef(function (props, ref) {
12
+ var classPrefix = 'biz-edit-text';
13
+ var inputRef = useRef(null);
14
+ var _useState = useState(props.value),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ curTitle = _useState2[0],
17
+ setCurTitle = _useState2[1];
18
+ var _useState3 = useState(props.value),
19
+ _useState4 = _slicedToArray(_useState3, 2),
20
+ prevTitle = _useState4[0],
21
+ setPrevTitle = _useState4[1];
22
+ var _useState5 = useState(!props.value && props.canEdit),
23
+ _useState6 = _slicedToArray(_useState5, 2),
24
+ isEdit = _useState6[0],
25
+ setIsEdit = _useState6[1];
26
+ var _useState7 = useState(''),
27
+ _useState8 = _slicedToArray(_useState7, 2),
28
+ errorText = _useState8[0],
29
+ setErrorText = _useState8[1];
30
+ useImperativeHandle(ref, function () {
31
+ return {
32
+ setEdit: function setEdit() {
33
+ setIsEdit(true);
34
+ inputRef.current.focus();
35
+ }
36
+ };
37
+ });
38
+ var onBlur = function onBlur(e) {
39
+ var value = e.target.value.trim();
40
+ if (props.required && !value) {
41
+ inputRef.current.focus();
42
+ setErrorText("".concat(props.name || '名称', "\u4E0D\u80FD\u4E3A\u7A7A"));
43
+ props.onChange && props.onChange(value);
44
+ return;
45
+ }
46
+ if (value === prevTitle) {
47
+ setIsEdit(false);
48
+ return;
49
+ }
50
+ if (props.onService) {
51
+ props.onService(value, changeService);
52
+ } else {
53
+ setIsEdit(false);
54
+ props.onChange && props.onChange(value);
55
+ }
56
+ };
57
+ var changeService = function changeService(error, msg) {
58
+ if (error) {
59
+ if (!msg) {
60
+ setCurTitle(prevTitle);
61
+ } else {
62
+ setErrorText(msg);
63
+ }
64
+ } else {
65
+ setIsEdit(false);
66
+ setPrevTitle(curTitle);
67
+ message.success("".concat(props.name || '', "\u7F16\u8F91\u6210\u529F"));
68
+ }
69
+ };
70
+ var onChange = function onChange(e) {
71
+ setErrorText('');
72
+ setCurTitle(e.target.value.trim());
73
+ };
74
+ return /*#__PURE__*/React.createElement("div", {
75
+ className: classPrefix
76
+ }, isEdit || props.isInput ? /*#__PURE__*/React.createElement("div", {
77
+ className: "".concat(classPrefix, "-input")
78
+ }, /*#__PURE__*/React.createElement(Input, {
79
+ ref: inputRef,
80
+ className: "".concat(classPrefix, "-input-content"),
81
+ status: errorText && 'error',
82
+ value: curTitle,
83
+ required: props.required,
84
+ disabled: !props.canEdit,
85
+ autoFocus: !curTitle,
86
+ max: props.max,
87
+ placeholder: "\u8BF7\u8F93\u5165".concat(props.name || ''),
88
+ onBlur: onBlur,
89
+ onChange: onChange
90
+ }), errorText ? /*#__PURE__*/React.createElement("span", {
91
+ className: "".concat(classPrefix, "-error-tip")
92
+ }, errorText) : null) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
93
+ className: "".concat(classPrefix, "-content")
94
+ }, props.value), props.canEdit ? /*#__PURE__*/React.createElement(IconFont, {
95
+ className: "".concat(classPrefix, "-icon"),
96
+ type: "bianji1",
97
+ onClick: function onClick() {
98
+ setIsEdit(true);
99
+ }
100
+ }) : null));
101
+ });
102
+ BizEditText.defaultProps = {
103
+ required: true,
104
+ canEdit: true
105
+ };
106
+ export default BizEditText;
@@ -0,0 +1,42 @@
1
+ @import '~@zgfe/business-lib/es/assets/styles/inner.less';
2
+ .biz-edit-text {
3
+ display: flex;
4
+ align-items: center;
5
+ &-input {
6
+ position: relative;
7
+ width: 350px;
8
+ height: 100%;
9
+ .ant-input {
10
+ background-color: #fff !important;
11
+ border-color: #fff;
12
+ &:not(.ant-input-status-error):hover {
13
+ border-color: @primary-color!important;
14
+ }
15
+ &:not(.ant-input-status-error):focus {
16
+ border-color: @primary-color!important;
17
+ }
18
+ }
19
+ }
20
+ &-error-tip {
21
+ position: absolute;
22
+ top: 100%;
23
+ left: 0;
24
+ color: @error-color;
25
+ line-height: 1.2;
26
+ }
27
+
28
+ &-content {
29
+ display: inline-block;
30
+ max-width: 330px;
31
+ height: @height-sm;
32
+ color: @text-color;
33
+ font-size: 16px;
34
+ line-height: @height-sm;
35
+ .__default-overflow();
36
+ }
37
+ &-icon {
38
+ margin-left: @margin-xs;
39
+ color: @primary-color;
40
+ cursor: pointer;
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ import { BizOptionTitleProps } from './types';
2
+ export declare const panelBtn: (callback: Function, disabled?: boolean) => BizOptionTitleProps.BtnItem[];
3
+ export declare const panelCreateBtn: (callback: Function, disabled?: boolean) => BizOptionTitleProps.BtnItem[];
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { IconFont } from '../..';
3
+ import { classPrefix } from '.';
4
+ export var panelBtn = function panelBtn(callback, disabled) {
5
+ return [{
6
+ key: '11',
7
+ label: /*#__PURE__*/React.createElement("a", {
8
+ className: "".concat(classPrefix, "-btn-more")
9
+ }, /*#__PURE__*/React.createElement(IconFont, {
10
+ type: "gengduocaozuo1"
11
+ })),
12
+ itemType: 'dropdown',
13
+ type: 'default',
14
+ children: [{
15
+ key: '110',
16
+ label: '编辑名称',
17
+ icon: /*#__PURE__*/React.createElement(IconFont, {
18
+ type: "bianji"
19
+ }),
20
+ onClick: function onClick() {
21
+ callback('edit');
22
+ }
23
+ }, {
24
+ key: '111',
25
+ label: '删除指标',
26
+ icon: /*#__PURE__*/React.createElement(IconFont, {
27
+ type: "shanchu"
28
+ }),
29
+ onClick: function onClick() {
30
+ callback('delete');
31
+ }
32
+ }]
33
+ }, {
34
+ key: '12',
35
+ label: '',
36
+ itemType: 'divider'
37
+ }, {
38
+ key: '1',
39
+ label: '取消',
40
+ type: 'text',
41
+ onClick: function onClick() {
42
+ callback('cancel');
43
+ }
44
+ }, {
45
+ key: '2',
46
+ label: '保存',
47
+ disabled: disabled,
48
+ onClick: function onClick() {
49
+ callback('save');
50
+ }
51
+ }, {
52
+ key: '3',
53
+ label: '另存为',
54
+ disabled: disabled,
55
+ onClick: function onClick() {
56
+ callback('saveAs');
57
+ }
58
+ }];
59
+ };
60
+ export var panelCreateBtn = function panelCreateBtn(callback, disabled) {
61
+ return [{
62
+ key: '1',
63
+ label: '取消',
64
+ type: 'text',
65
+ onClick: function onClick() {
66
+ console.log('取消');
67
+ callback('cancel');
68
+ }
69
+ }, {
70
+ key: '2',
71
+ label: '保存',
72
+ disabled: disabled,
73
+ onClick: function onClick() {
74
+ callback('save');
75
+ }
76
+ }];
77
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,84 @@
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 = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useContext, useEffect, useState } from 'react';
8
+ import { DemoWrapper, BizTargetFromPanel, BizTargetFromPanelContext } from '@zgfe/business-lib';
9
+ import { Button, Spin } from 'antd';
10
+ var params = {
11
+ app_id: 4,
12
+ module: 'insight',
13
+ targets: [{
14
+ type: 'event',
15
+ alias: '事件概览',
16
+ eventId: -100,
17
+ eventName: '事件概览',
18
+ eventGroupId: 0,
19
+ analysisDimension: {
20
+ analysisIndex: 'number'
21
+ }
22
+ }],
23
+ userGroup: [0],
24
+ time: {
25
+ unit: 'week',
26
+ relative: [8, 1],
27
+ begin: '2023-02-13',
28
+ end: '2023-04-14'
29
+ },
30
+ chartType: 'line'
31
+ };
32
+ var InsightContent = function InsightContent() {
33
+ var _useContext = useContext(BizTargetFromPanelContext),
34
+ handleSearch = _useContext.handleSearch;
35
+ var _useState = useState(false),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ searching = _useState2[0],
38
+ setSearching = _useState2[1];
39
+ useEffect(function () {
40
+ handleSearch && handleSearch(searching);
41
+ }, [searching]);
42
+ var onClick = function onClick() {
43
+ setSearching(true);
44
+ setTimeout(function () {
45
+ setSearching(false);
46
+ }, 2000);
47
+ };
48
+ return /*#__PURE__*/React.createElement(Spin, {
49
+ spinning: searching
50
+ }, /*#__PURE__*/React.createElement("div", {
51
+ style: {
52
+ display: 'flex',
53
+ justifyContent: 'center',
54
+ padding: 20
55
+ }
56
+ }, /*#__PURE__*/React.createElement(Button, {
57
+ onClick: onClick
58
+ }, "searching")));
59
+ };
60
+ export default (function () {
61
+ var afterEditTarget = function afterEditTarget(type, data) {
62
+ console.log(type, data);
63
+ };
64
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
65
+ needMeta: true,
66
+ defaultApp: 292
67
+ }, /*#__PURE__*/React.createElement("div", {
68
+ style: {
69
+ background: '#FAFAFB',
70
+ padding: '24px',
71
+ height: '300px'
72
+ }
73
+ }, /*#__PURE__*/React.createElement(BizTargetFromPanel, {
74
+ value: {
75
+ panelId: 55,
76
+ target: {
77
+ id: 282,
78
+ name: '洞察',
79
+ params: params
80
+ }
81
+ },
82
+ afterEditTarget: afterEditTarget
83
+ }, /*#__PURE__*/React.createElement(InsightContent, null))));
84
+ });
@@ -0,0 +1,12 @@
1
+ .ml-20 {
2
+ margin-left: 20px;
3
+ }
4
+
5
+ .green {
6
+ background: #4ac288;
7
+ border-color: #4ac288;
8
+ &:hover {
9
+ background: #3ad48a;
10
+ border-color: #3ad48a;
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ import './index.less';
2
+ declare const _default: () => JSX.Element;
3
+ export default _default;
@@ -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 = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) 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 { BizOptionLayout } from '@zgfe/business-lib';
9
+ import './index.less';
10
+ export default (function () {
11
+ var _useState = useState('报告1'),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ title = _useState2[0],
14
+ setTitle = _useState2[1];
15
+ var options = [{
16
+ key: '1',
17
+ label: '保存',
18
+ className: 'green',
19
+ onClick: function onClick() {
20
+ return _onClick('cancel');
21
+ }
22
+ }, {
23
+ key: '2',
24
+ label: '删除',
25
+ onClick: function onClick() {
26
+ return _onClick('save');
27
+ }
28
+ }];
29
+ var _onClick = function _onClick(type) {
30
+ console.log(type);
31
+ };
32
+ var onChange = function onChange(value) {
33
+ setTitle(value || '');
34
+ };
35
+ return /*#__PURE__*/React.createElement(BizOptionLayout, {
36
+ name: "\u62A5\u544A\u540D\u79F0",
37
+ value: title,
38
+ options: options,
39
+ onChange: onChange
40
+ });
41
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,82 @@
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 = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useContext, useEffect, useState } from 'react';
8
+ import { DemoWrapper, BizTargetFromPanel, BizTargetFromPanelContext } from '@zgfe/business-lib';
9
+ import { Button, Spin } from 'antd';
10
+ var params = {
11
+ app_id: 4,
12
+ module: 'insight',
13
+ targets: [{
14
+ type: 'event',
15
+ alias: '事件概览',
16
+ eventId: -100,
17
+ eventName: '事件概览',
18
+ eventGroupId: 0,
19
+ analysisDimension: {
20
+ analysisIndex: 'number'
21
+ }
22
+ }],
23
+ userGroup: [0],
24
+ time: {
25
+ unit: 'week',
26
+ relative: [8, 1],
27
+ begin: '2023-02-13',
28
+ end: '2023-04-14'
29
+ },
30
+ chartType: 'line'
31
+ };
32
+ var InsightContent = function InsightContent() {
33
+ var _useContext = useContext(BizTargetFromPanelContext),
34
+ handleSearch = _useContext.handleSearch;
35
+ var _useState = useState(false),
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ searching = _useState2[0],
38
+ setSearching = _useState2[1];
39
+ useEffect(function () {
40
+ handleSearch && handleSearch(searching);
41
+ }, [searching]);
42
+ var onClick = function onClick() {
43
+ setSearching(true);
44
+ setTimeout(function () {
45
+ setSearching(false);
46
+ }, 2000);
47
+ };
48
+ return /*#__PURE__*/React.createElement(Spin, {
49
+ spinning: searching
50
+ }, /*#__PURE__*/React.createElement("div", {
51
+ style: {
52
+ display: 'flex',
53
+ justifyContent: 'center',
54
+ padding: 20
55
+ }
56
+ }, /*#__PURE__*/React.createElement(Button, {
57
+ onClick: onClick
58
+ }, "searching")));
59
+ };
60
+ export default (function () {
61
+ var afterEditTarget = function afterEditTarget(type, data) {
62
+ console.log(type, data);
63
+ };
64
+ return /*#__PURE__*/React.createElement(DemoWrapper, {
65
+ needMeta: true,
66
+ defaultApp: 292
67
+ }, /*#__PURE__*/React.createElement("div", {
68
+ style: {
69
+ background: '#FAFAFB',
70
+ padding: '24px',
71
+ height: '300px'
72
+ }
73
+ }, /*#__PURE__*/React.createElement(BizTargetFromPanel, {
74
+ value: {
75
+ panelId: 55,
76
+ target: {
77
+ params: params
78
+ }
79
+ },
80
+ afterEditTarget: afterEditTarget
81
+ }, /*#__PURE__*/React.createElement(InsightContent, null))));
82
+ });
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { BizOptionTitleProps } from './types';
3
+ import './styles/index.less';
4
+ export declare const classPrefix = "biz-layout-panel";
5
+ declare const BizTargetFromPanel: React.FC<BizOptionTitleProps.Props>;
6
+ export default BizTargetFromPanel;
@@ -0,0 +1,154 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ 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."); }
7
+ 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); }
8
+ 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; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { useEffect, useRef, useState } from 'react';
12
+ import BizOptionLayout from './layout';
13
+ import { BizOptionTitleProps, BizTargetFromPanelContext } from './types';
14
+ import BizAddToPanel from '../../addToPanel';
15
+ import { panelBtn, panelCreateBtn } from './data';
16
+ import './styles/index.less';
17
+ import { ajax } from '../../utils';
18
+ import Apis from '../../constants/apis';
19
+ import { Spin, message } from 'antd';
20
+ export var classPrefix = 'biz-layout-panel';
21
+ var BizTargetFromPanel = function BizTargetFromPanel(props) {
22
+ var _props$value$target$p;
23
+ var _useState = useState([]),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ options = _useState2[0],
26
+ setOptions = _useState2[1];
27
+ var _useState3 = useState(props.value.target.name || '洞察'),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ title = _useState4[0],
30
+ setTitle = _useState4[1];
31
+ var _useState5 = useState(false),
32
+ _useState6 = _slicedToArray(_useState5, 2),
33
+ showDialog = _useState6[0],
34
+ setShowDialog = _useState6[1];
35
+ var _useState7 = useState(BizOptionTitleProps.OptionTypes.SAVE),
36
+ _useState8 = _slicedToArray(_useState7, 2),
37
+ saveType = _useState8[0],
38
+ setSaveType = _useState8[1];
39
+ var _useState9 = useState(false),
40
+ _useState10 = _slicedToArray(_useState9, 2),
41
+ loading = _useState10[0],
42
+ setLoading = _useState10[1];
43
+ var titleRef = useRef(null);
44
+ useEffect(function () {
45
+ setOptions(props.value.target.id ? panelBtn(onClick) : panelCreateBtn(onClick));
46
+ }, []);
47
+ var onClick = function onClick(type) {
48
+ if (type === BizOptionTitleProps.OptionTypes.CANCEL) {
49
+ var param = props.value.target.id ? {
50
+ panelId: props.value.panelId,
51
+ elementId: props.value.target.id,
52
+ name: title
53
+ } : null;
54
+ props.afterEditTarget && props.afterEditTarget(type, param);
55
+ } else if (type === BizOptionTitleProps.OptionTypes.EDIT) {
56
+ titleRef.current.setEdit();
57
+ } else if (type === BizOptionTitleProps.OptionTypes.DELETE) {
58
+ onDelete();
59
+ } else {
60
+ setShowDialog(true);
61
+ setSaveType(type);
62
+ }
63
+ };
64
+ var onDelete = function onDelete() {
65
+ setLoading(true);
66
+ ajax(Apis.delPanelElement, {
67
+ method: 'post',
68
+ data: {
69
+ panel_id: props.value.panelId,
70
+ element_id: props.value.target.id
71
+ }
72
+ }).then(function (res) {
73
+ if (!res) return;
74
+ if (res.flag === 101) {
75
+ message.success('删除成功');
76
+ props.afterEditTarget && props.afterEditTarget(BizOptionTitleProps.OptionTypes.DELETE);
77
+ } else {
78
+ message.error('删除失败');
79
+ }
80
+ }).finally(function () {
81
+ setLoading(false);
82
+ });
83
+ };
84
+ var onService = function onService(value, callback) {
85
+ setTitle(value);
86
+ setBtnOptions(!value);
87
+ if (!value) return;
88
+ setLoading(true);
89
+ ajax(Apis.updateElementName, {
90
+ method: 'post',
91
+ data: {
92
+ panel_id: props.value.panelId,
93
+ element_id: props.value.target.id,
94
+ name: value
95
+ }
96
+ }).then(function (res) {
97
+ if (!res) return;
98
+ callback(res.flag !== 101);
99
+ }).finally(function () {
100
+ callback(true, '');
101
+ setLoading(false);
102
+ });
103
+ };
104
+ var onCancel = function onCancel() {
105
+ setShowDialog(false);
106
+ };
107
+ var onPanelSave = function onPanelSave(data) {
108
+ setShowDialog(false);
109
+ props.afterEditTarget && props.afterEditTarget(BizOptionTitleProps.OptionTypes.PANEL, data);
110
+ };
111
+ var setBtnOptions = function setBtnOptions(disabled) {
112
+ setOptions(function (option) {
113
+ if (!option.length) return [];
114
+ option[option.length - 1].disabled = disabled;
115
+ if (props.value.target.id) {
116
+ option[option.length - 2].disabled = disabled;
117
+ }
118
+ return _toConsumableArray(option);
119
+ });
120
+ };
121
+ return /*#__PURE__*/React.createElement(BizTargetFromPanelContext.Provider, {
122
+ value: {
123
+ handleSearch: setBtnOptions
124
+ }
125
+ }, /*#__PURE__*/React.createElement(Spin, {
126
+ spinning: loading
127
+ }, /*#__PURE__*/React.createElement(BizOptionLayout, {
128
+ ref: titleRef,
129
+ value: title,
130
+ options: options,
131
+ isInput: true,
132
+ onService: onService,
133
+ onChange: setTitle,
134
+ onBack: function onBack() {
135
+ return onClick(BizOptionTitleProps.OptionTypes.CANCEL);
136
+ }
137
+ }, props.children, showDialog && /*#__PURE__*/React.createElement(BizAddToPanel, {
138
+ defaultValue: {
139
+ panel: {
140
+ id: props.value.panelId
141
+ },
142
+ name: saveType === BizOptionTitleProps.OptionTypes.SAVE_AS ? title + '(1)' : title,
143
+ chartType: ((_props$value$target$p = props.value.target.params) === null || _props$value$target$p === void 0 ? void 0 : _props$value$target$p.chartType) || 'line',
144
+ showList: 'fix'
145
+ },
146
+ type: props.value.target.id && saveType === BizOptionTitleProps.OptionTypes.SAVE ? BizOptionTitleProps.OptionTypes.EDIT : BizOptionTitleProps.OptionTypes.CREATE,
147
+ params: props.value.target.params,
148
+ elementId: props.value.target.id,
149
+ showList: props.value.target.showList,
150
+ onCancel: onCancel,
151
+ onOk: onPanelSave
152
+ }))));
153
+ };
154
+ export default BizTargetFromPanel;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { BizOptionTitleProps } from './types';
3
+ import './styles/layout.less';
4
+ declare const BizOptionLayout: React.ForwardRefExoticComponent<BizOptionTitleProps.LayoutProps & React.RefAttributes<any>>;
5
+ export default BizOptionLayout;