@zgfe/business-lib 1.0.1-beta.0 → 1.0.5

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 (61) hide show
  1. package/es/analysisLayout/index.js +11 -9
  2. package/es/attrConditions/components/stringList.js +1 -0
  3. package/es/attrConditions/components/valuesList.js +4 -2
  4. package/es/attrConditions/group.js +1 -2
  5. package/es/attributeSelector/index.js +6 -4
  6. package/es/attributeSelector/listPanel.js +11 -9
  7. package/es/chart/index.js +12 -10
  8. package/es/components/iconFont.d.ts +4 -1
  9. package/es/components/iconFont.js +8 -4
  10. package/es/dialog/components/itemNode.d.ts +1 -0
  11. package/es/dialog/components/itemNode.js +15 -13
  12. package/es/dialog/components/list.js +7 -5
  13. package/es/dialog/components/selectToInput.js +8 -6
  14. package/es/dialog/index.js +14 -11
  15. package/es/dialog/types.d.ts +1 -1
  16. package/es/eventSelector/listPanel.js +4 -2
  17. package/es/index.d.ts +3 -1
  18. package/es/index.js +3 -1
  19. package/es/searchInput/demo/index.d.ts +2 -0
  20. package/es/searchInput/demo/index.js +5 -0
  21. package/es/select/handle.d.ts +2 -2
  22. package/es/select/handle.js +8 -8
  23. package/es/select/index.js +6 -4
  24. package/es/table/index.js +12 -10
  25. package/es/targetConditionGroup/index.js +5 -2
  26. package/es/targetSelector/index.js +6 -4
  27. package/es/userCondition/conditionTypeList.d.ts +10 -0
  28. package/es/userCondition/conditionTypeList.js +43 -0
  29. package/es/userCondition/conditionWrap.d.ts +7 -0
  30. package/es/userCondition/conditionWrap.js +18 -0
  31. package/es/userCondition/conditions/eventCondition.d.ts +8 -0
  32. package/es/userCondition/conditions/eventCondition.js +104 -0
  33. package/es/userCondition/conditions/periodCondition.d.ts +11 -0
  34. package/es/userCondition/conditions/periodCondition.js +156 -0
  35. package/es/userCondition/conditions/propCondition.d.ts +5 -0
  36. package/es/userCondition/conditions/propCondition.js +198 -0
  37. package/es/userCondition/conditions/runTimesCondition.d.ts +9 -0
  38. package/es/userCondition/conditions/runTimesCondition.js +78 -0
  39. package/es/userCondition/conditions/styles/eventCondition.less +49 -0
  40. package/es/userCondition/conditions/styles/periodCondition.less +14 -0
  41. package/es/userCondition/conditions/styles/propCondition.less +36 -0
  42. package/es/userCondition/conditions/styles/runTimesCondition.less +16 -0
  43. package/es/userCondition/demo/index.d.ts +2 -0
  44. package/es/userCondition/demo/index.js +73 -0
  45. package/es/userCondition/index.d.ts +7 -0
  46. package/es/userCondition/index.js +143 -0
  47. package/es/userCondition/orConditions.d.ts +5 -0
  48. package/es/userCondition/orConditions.js +202 -0
  49. package/es/userCondition/relationLabel.d.ts +6 -0
  50. package/es/userCondition/relationLabel.js +12 -0
  51. package/es/userCondition/styles/conditionTypeList.less +31 -0
  52. package/es/userCondition/styles/conditionWrap.less +14 -0
  53. package/es/userCondition/styles/index.less +13 -0
  54. package/es/userCondition/styles/orConditions.less +16 -0
  55. package/es/userCondition/styles/relationLabel.less +18 -0
  56. package/es/userCondition/types.d.ts +96 -0
  57. package/es/userCondition/types.js +1 -0
  58. package/es/userCondition/util.d.ts +3 -0
  59. package/es/userCondition/util.js +73 -0
  60. package/es/userGroup/index.js +6 -4
  61. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import './styles/conditionTypeList.less';
3
+ import { BizUserConditionT } from './types';
4
+ export interface ConditionTypeListPropsI {
5
+ onAdd: (type: BizUserConditionT.ConditionType) => void;
6
+ label?: string | React.ReactDOM;
7
+ show?: boolean;
8
+ }
9
+ declare const ConditionTypeList: React.FC<ConditionTypeListPropsI>;
10
+ export default ConditionTypeList;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Space } from 'antd';
3
+ import { PlusOutlined } from '@ant-design/icons';
4
+ import './styles/conditionTypeList.less';
5
+
6
+ var ConditionTypeList = function ConditionTypeList(props) {
7
+ var onAdd = props.onAdd,
8
+ label = props.label,
9
+ show = props.show;
10
+ if (!show) return null;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: "biz-user-condition-type-list"
13
+ }, label ? /*#__PURE__*/React.createElement("div", {
14
+ className: "biz-user-condition-type-label"
15
+ }, label) : null, /*#__PURE__*/React.createElement("ul", {
16
+ className: "biz-user-condition-type-container"
17
+ }, /*#__PURE__*/React.createElement("li", {
18
+ className: "condition-type",
19
+ onClick: function onClick() {
20
+ return onAdd('event');
21
+ }
22
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u505A\u8FC7\uFF08\u6CA1\u505A\u8FC7\uFF09\u2026"))), /*#__PURE__*/React.createElement("li", {
23
+ className: "condition-type",
24
+ onClick: function onClick() {
25
+ return onAdd('add');
26
+ }
27
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u65B0\u589E\u4E8E"))), /*#__PURE__*/React.createElement("li", {
28
+ className: "condition-type",
29
+ onClick: function onClick() {
30
+ return onAdd('active');
31
+ }
32
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u6D3B\u8DC3\u4E8E"))), /*#__PURE__*/React.createElement("li", {
33
+ className: "condition-type",
34
+ onClick: function onClick() {
35
+ return onAdd('prop');
36
+ }
37
+ }, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(PlusOutlined, null), /*#__PURE__*/React.createElement("span", null, "\u7528\u6237\u5C5E\u6027\u6EE1\u8DB3")))));
38
+ };
39
+
40
+ ConditionTypeList.defaultProps = {
41
+ show: true
42
+ };
43
+ export default ConditionTypeList;
@@ -0,0 +1,7 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import './styles/conditionWrap.less';
3
+ export interface ConditionWrapPropsI {
4
+ onDelte: () => void;
5
+ }
6
+ declare const ConditionWrap: React.FC<PropsWithChildren<ConditionWrapPropsI>>;
7
+ export default ConditionWrap;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { CloseOutlined } from '@ant-design/icons';
3
+ import './styles/conditionWrap.less';
4
+
5
+ var ConditionWrap = function ConditionWrap(props) {
6
+ return /*#__PURE__*/React.createElement("div", {
7
+ className: "biz-user-condition-item-wrap"
8
+ }, /*#__PURE__*/React.createElement("div", {
9
+ className: "biz-user-condition-item"
10
+ }, props.children), /*#__PURE__*/React.createElement("div", {
11
+ className: "biz-user-condition-item-delete",
12
+ onClick: function onClick() {
13
+ return props.onDelte();
14
+ }
15
+ }, /*#__PURE__*/React.createElement(CloseOutlined, null)));
16
+ };
17
+
18
+ export default ConditionWrap;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, BizUserConditionT } from '../types';
3
+ import './styles/eventCondition.less';
4
+ export interface EventConditionPropsI extends AllConditionBasePropsI<any> {
5
+ condition: BizUserConditionT.EventCondition;
6
+ }
7
+ declare const EventCondition: React.FC<EventConditionPropsI>;
8
+ export default EventCondition;
@@ -0,0 +1,104 @@
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
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ import React from 'react';
8
+ import { RightOutlined } from '@ant-design/icons';
9
+ import BizEventSelector from '../../eventSelector';
10
+ import RunTimesCondition from './runTimesCondition';
11
+ import PeriodCondition from './periodCondition';
12
+ import PropCondition from './propCondition';
13
+ import './styles/eventCondition.less';
14
+ import { classPrefix } from '..';
15
+
16
+ var EventCondition = function EventCondition(props) {
17
+ var condition = props.condition,
18
+ dataId = props.dataId;
19
+
20
+ function onChange(data) {
21
+ props.onChange(dataId, data);
22
+ }
23
+
24
+ function onEventChange(data) {
25
+ var event = data.event;
26
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
27
+ eventId: event.id
28
+ }));
29
+ }
30
+
31
+ function onRunTimesChange(newRunTimes) {
32
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
33
+ runTimes: newRunTimes
34
+ }));
35
+ }
36
+
37
+ function onPeriodChange(_dataId, newPeriod) {
38
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
39
+ runPeriod: newPeriod
40
+ }));
41
+ }
42
+
43
+ function onAttrChange(_dataId, newAttrs) {
44
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
45
+ attrs: newAttrs
46
+ }));
47
+ }
48
+
49
+ function onAddAttr() {
50
+ onChange(_objectSpread(_objectSpread({}, condition), {}, {
51
+ attrs: [{
52
+ attrId: 0,
53
+ attrName: ''
54
+ }]
55
+ }));
56
+ }
57
+
58
+ return /*#__PURE__*/React.createElement("div", {
59
+ className: "".concat(classPrefix, "-event-condition")
60
+ }, /*#__PURE__*/React.createElement("div", {
61
+ className: "".concat(classPrefix, "-event-condition-left")
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: "".concat(classPrefix, "-event-condition-label")
64
+ }, /*#__PURE__*/React.createElement("span", null, "\u505A\u8FC7")), /*#__PURE__*/React.createElement("div", {
65
+ className: "".concat(classPrefix, "-event")
66
+ }, /*#__PURE__*/React.createElement(BizEventSelector, {
67
+ showAllEvent: false,
68
+ defaultValue: {
69
+ event: {
70
+ id: condition.eventId
71
+ }
72
+ },
73
+ onChange: onEventChange
74
+ })), /*#__PURE__*/React.createElement("div", {
75
+ className: "".concat(classPrefix, "-event-condition-expand-attr"),
76
+ onClick: onAddAttr
77
+ }, /*#__PURE__*/React.createElement(RightOutlined, null))), /*#__PURE__*/React.createElement("div", {
78
+ className: "".concat(classPrefix, "-event-condition-right")
79
+ }, condition.attrs.length && condition.eventId ? /*#__PURE__*/React.createElement("div", {
80
+ className: "".concat(classPrefix, "-event-condition-attrs")
81
+ }, /*#__PURE__*/React.createElement(PropCondition, {
82
+ isEvent: true,
83
+ dataId: dataId,
84
+ attrs: condition.attrs,
85
+ onChange: onAttrChange,
86
+ eventId: condition.eventId
87
+ })) : null, /*#__PURE__*/React.createElement("div", {
88
+ className: "".concat(classPrefix, "-event-condition-times-period-wrap")
89
+ }, /*#__PURE__*/React.createElement("div", {
90
+ className: "".concat(classPrefix, "-event-condition-runtimes")
91
+ }, /*#__PURE__*/React.createElement(RunTimesCondition, {
92
+ onChange: onRunTimesChange,
93
+ runTimes: condition.runTimes
94
+ })), /*#__PURE__*/React.createElement("div", {
95
+ className: "".concat(classPrefix, "-event-condition-period")
96
+ }, /*#__PURE__*/React.createElement(PeriodCondition, {
97
+ dataId: dataId,
98
+ runPeriod: condition.runPeriod,
99
+ onChange: onPeriodChange,
100
+ isEvent: true
101
+ })))));
102
+ };
103
+
104
+ export default EventCondition;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { AllConditionBasePropsI, RunPeriodI } from '../types';
3
+ import './styles/periodCondition.less';
4
+ export interface PeriodConditionPropsI extends AllConditionBasePropsI<RunPeriodI> {
5
+ label?: string | React.ReactDOM;
6
+ isEvent?: boolean;
7
+ runPeriod: RunPeriodI;
8
+ isRealTime?: boolean;
9
+ }
10
+ declare const PeriodCondition: React.FC<PeriodConditionPropsI>;
11
+ export default PeriodCondition;
@@ -0,0 +1,156 @@
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
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ import React from 'react';
8
+ import BizSelect from '../../select';
9
+ import { Input, DatePicker, Checkbox } from 'antd';
10
+ import moment from 'moment';
11
+ import './styles/periodCondition.less';
12
+ import { classPrefix } from '..';
13
+ var RangePicker = DatePicker.RangePicker;
14
+ var operatorMap = {
15
+ relative: '最近',
16
+ absolute: '固定时段',
17
+ unlimited_time: '任意时间',
18
+ join_time: '新增后'
19
+ };
20
+
21
+ var PeriodCondition = function PeriodCondition(props) {
22
+ var dataId = props.dataId,
23
+ label = props.label,
24
+ isEvent = props.isEvent,
25
+ runPeriod = props.runPeriod;
26
+ var options = [{
27
+ text: '最近',
28
+ value: 'relative'
29
+ }, {
30
+ text: '固定时段',
31
+ value: 'absolute'
32
+ }];
33
+
34
+ if (isEvent) {
35
+ options = options.concat([{
36
+ text: '任意时间',
37
+ value: 'unlimited_time'
38
+ }, {
39
+ text: '新增后',
40
+ value: 'join_time'
41
+ }]);
42
+ }
43
+
44
+ function onChange(data) {
45
+ props.onChange(dataId, data);
46
+ }
47
+
48
+ function onOperatorChange(option) {
49
+ var newData = {
50
+ operator: option.value
51
+ };
52
+
53
+ if (newData.operator === 'absolute') {
54
+ var endDate = moment().format('YYYY-MM-DD');
55
+ var startDate = moment().subtract(7, 'days').format('YYYY-MM-DD');
56
+ newData.values = [startDate, endDate];
57
+ }
58
+
59
+ if (newData.operator === 'relative') {
60
+ newData.values = ['30', '0'];
61
+ }
62
+
63
+ if (newData.operator === 'join_time') {
64
+ newData.values = ['3', '0'];
65
+ }
66
+
67
+ onChange(newData);
68
+ }
69
+
70
+ function onDateChange(newData) {
71
+ if (runPeriod.operator === 'absolute') {
72
+ var dateRange = newData;
73
+ var newValues = dateRange.map(function (date) {
74
+ return date.format('YYYY-MM-DD');
75
+ });
76
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
77
+ values: newValues
78
+ }));
79
+ } else if (runPeriod.operator === 'relative' || runPeriod.operator === 'join_time') {
80
+ var newValue = newData.target.value;
81
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
82
+ values: [newValue, runPeriod.values[1]]
83
+ }));
84
+ }
85
+ }
86
+
87
+ function onChangeToday(e) {
88
+ var newValues = [runPeriod.values[0], '0'];
89
+
90
+ if (e.target.checked) {
91
+ newValues[1] = '1';
92
+ console.log(newValues);
93
+ }
94
+
95
+ onChange(_objectSpread(_objectSpread({}, runPeriod), {}, {
96
+ values: newValues
97
+ }));
98
+ }
99
+
100
+ function renderValues() {
101
+ var operator = runPeriod.operator,
102
+ values = runPeriod.values;
103
+
104
+ if (operator === 'relative' || operator === 'join_time') {
105
+ return /*#__PURE__*/React.createElement(Input, {
106
+ size: "large",
107
+ value: values[0],
108
+ onChange: onDateChange,
109
+ style: {
110
+ width: 58
111
+ }
112
+ });
113
+ }
114
+
115
+ if (operator === 'absolute') {
116
+ return /*#__PURE__*/React.createElement(RangePicker, {
117
+ defaultValue: [moment(values[0]), moment(values[1])],
118
+ onChange: onDateChange,
119
+ allowClear: false
120
+ });
121
+ }
122
+ }
123
+
124
+ return /*#__PURE__*/React.createElement("div", {
125
+ className: "".concat(classPrefix, "-period-condition")
126
+ }, label ? /*#__PURE__*/React.createElement("div", {
127
+ className: "".concat(classPrefix, "-period-condition-label")
128
+ }, label) : null, /*#__PURE__*/React.createElement("div", {
129
+ className: "".concat(classPrefix, "-period-condition-operator")
130
+ }, /*#__PURE__*/React.createElement(BizSelect, {
131
+ overlayWidth: 129,
132
+ options: options,
133
+ labelField: "text",
134
+ keyField: "value",
135
+ value: {
136
+ value: runPeriod.operator,
137
+ text: operatorMap[runPeriod.operator]
138
+ },
139
+ onChange: onOperatorChange
140
+ })), /*#__PURE__*/React.createElement("div", {
141
+ className: "".concat(classPrefix, "-period-condition-values")
142
+ }, renderValues()), /*#__PURE__*/React.createElement("div", {
143
+ className: "".concat(classPrefix, "-period-condition-unit")
144
+ }, "\u5929"), props.isRealTime && runPeriod.operator === 'relative' ? /*#__PURE__*/React.createElement("div", {
145
+ className: "".concat(classPrefix, "-period-condition-today")
146
+ }, /*#__PURE__*/React.createElement(Checkbox, {
147
+ checked: runPeriod.values[1] === '1',
148
+ onChange: onChangeToday
149
+ }, "\u4E0D\u5305\u542B\u4ECA\u5929")) : null);
150
+ };
151
+
152
+ PeriodCondition.defaultProps = {
153
+ isEvent: false,
154
+ isRealTime: false
155
+ };
156
+ export default PeriodCondition;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { PropConditionType } from '../types';
3
+ import './styles/propCondition.less';
4
+ declare const PropCondition: React.FC<PropConditionType.PropsI>;
5
+ export default PropCondition;
@@ -0,0 +1,198 @@
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
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ 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."); }
10
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+
15
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+
17
+ 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."); }
18
+
19
+ 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); }
20
+
21
+ 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; }
22
+
23
+ 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; }
24
+
25
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
+
27
+ import React, { useEffect, useState } from 'react';
28
+ import { PlusOutlined } from '@ant-design/icons';
29
+ import BizConditionItem from '../../attrConditions';
30
+ import './styles/propCondition.less';
31
+ import { useContext } from 'react';
32
+ import { BizUserConditionContext, classPrefix } from '..';
33
+ import { transformNumberOperate } from '../util';
34
+ var numAttrTypeMap = {
35
+ 1: 'cont-string',
36
+ 2: 'cont-num',
37
+ 3: 'cont-date'
38
+ };
39
+ var attrNumTypeMap = {
40
+ 'cont-string': 1,
41
+ 'cont-num': 2,
42
+ 'cont-date': 3
43
+ };
44
+
45
+ var PropCondition = function PropCondition(props) {
46
+ var _useContext = useContext(BizUserConditionContext),
47
+ eventAttrNum = _useContext.eventAttrNum;
48
+
49
+ var isEvent = props.isEvent,
50
+ label = props.label,
51
+ attrs = props.attrs,
52
+ dataId = props.dataId;
53
+
54
+ var _useState = useState([]),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ showList = _useState2[0],
57
+ setShowList = _useState2[1];
58
+
59
+ JSON.stringify(showList);
60
+ useEffect(function () {
61
+ buildDefault();
62
+ }, []);
63
+
64
+ function buildDefault() {
65
+ var list = [];
66
+ attrs.forEach(function (attr) {
67
+ var attrId = attr.attrId,
68
+ attrName = attr.attrName,
69
+ operator = attr.operator;
70
+
71
+ if ((attrName || attrId) && operator) {
72
+ attr.operator = transformNumberOperate(operator, false);
73
+ list.push({
74
+ attr: attr,
75
+ default: attr,
76
+ id: Math.random()
77
+ });
78
+ } else {
79
+ list.push({
80
+ attr: attr,
81
+ id: Math.random()
82
+ });
83
+ }
84
+ });
85
+ setShowList(list);
86
+ }
87
+
88
+ function _onChange(data, i) {
89
+ var attrName = data.attrName,
90
+ attrId = data.attrId,
91
+ category = data.category,
92
+ type = data.type,
93
+ operation = data.operation,
94
+ values = data.values;
95
+
96
+ var newAttrs = _toConsumableArray(attrs);
97
+
98
+ var newAttr = {
99
+ attrName: attrName,
100
+ attrId: attrId,
101
+ category: category,
102
+ operator: transformNumberOperate(operation),
103
+ params: values,
104
+ attrType: numAttrTypeMap[type]
105
+ };
106
+ Object.assign(newAttrs[i], newAttr);
107
+ props.onChange(dataId, newAttrs);
108
+ }
109
+
110
+ function onAddAttr() {
111
+ var attr = {
112
+ attrId: 0
113
+ };
114
+ setShowList([].concat(_toConsumableArray(showList), [{
115
+ id: Math.random(),
116
+ attr: attr
117
+ }]));
118
+ props.onChange(dataId, [].concat(_toConsumableArray(attrs), [attr]));
119
+ }
120
+
121
+ function onRemoveAttr(i) {
122
+ var newAttrs = _toConsumableArray(attrs);
123
+
124
+ var newList = _toConsumableArray(showList);
125
+
126
+ newList.splice(i, 1);
127
+ newAttrs.splice(i, 1);
128
+ setShowList(newList);
129
+ props.onChange(dataId, newAttrs);
130
+ }
131
+
132
+ function getPropCategory(attrName) {
133
+ if (!isEvent) return 'userProp';
134
+ return attrName === undefined ? 'eventProp' : 'envProp';
135
+ }
136
+
137
+ function renderAttr(item, i) {
138
+ var props = {};
139
+ var id = item.id;
140
+
141
+ if (item.default) {
142
+ var _item$default = item.default,
143
+ attrId = _item$default.attrId,
144
+ attrName = _item$default.attrName,
145
+ category = _item$default.category,
146
+ operator = _item$default.operator,
147
+ params = _item$default.params,
148
+ attrType = _item$default.attrType;
149
+ props.defaultValue = {
150
+ attrName: attrName,
151
+ category: category || 'custom',
152
+ operation: operator,
153
+ values: params || [],
154
+ propCategory: getPropCategory(attrName),
155
+ type: attrNumTypeMap[attrType]
156
+ };
157
+ attrId && (props.defaultValue.attrId = attrId);
158
+ }
159
+
160
+ return /*#__PURE__*/React.createElement("div", {
161
+ className: "".concat(classPrefix, "-prop-condition-attr"),
162
+ key: id
163
+ }, /*#__PURE__*/React.createElement("div", {
164
+ className: "".concat(classPrefix, "-prop-condition-item-wrap")
165
+ }, /*#__PURE__*/React.createElement(BizConditionItem, _objectSpread({
166
+ onChange: function onChange(data) {
167
+ return _onChange(data, i);
168
+ },
169
+ enableUserProp: !isEvent,
170
+ enableEnvProp: isEvent,
171
+ enableEventProp: isEvent,
172
+ onDelete: function onDelete() {
173
+ return onRemoveAttr(i);
174
+ },
175
+ enableDelete: isEvent
176
+ }, props))));
177
+ }
178
+
179
+ return /*#__PURE__*/React.createElement("div", {
180
+ className: "".concat(classPrefix, "-prop-condition")
181
+ }, label ? /*#__PURE__*/React.createElement("div", {
182
+ className: "".concat(classPrefix, "-prop-condition-label")
183
+ }, label) : null, /*#__PURE__*/React.createElement("div", {
184
+ className: "".concat(classPrefix, "-prop-condition-attrs")
185
+ }, showList && showList.map(function (item, i) {
186
+ return renderAttr(item, i);
187
+ })), attrs.length < eventAttrNum && isEvent ? /*#__PURE__*/React.createElement("div", {
188
+ className: "".concat(classPrefix, "-prop-condition-add")
189
+ }, /*#__PURE__*/React.createElement("div", {
190
+ className: "".concat(classPrefix, "-prop-add-btn"),
191
+ onClick: onAddAttr
192
+ }, /*#__PURE__*/React.createElement(PlusOutlined, null))) : null);
193
+ };
194
+
195
+ PropCondition.defaultProps = {
196
+ isEvent: false
197
+ };
198
+ export default PropCondition;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { RunTimesI } from '../types';
3
+ import './styles/runTimesCondition.less';
4
+ export interface RunTimesConditionPropsI {
5
+ runTimes: RunTimesI;
6
+ onChange: (data: RunTimesI) => void;
7
+ }
8
+ declare const RunTimesCondition: React.FC<RunTimesConditionPropsI>;
9
+ export default RunTimesCondition;
@@ -0,0 +1,78 @@
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
+
3
+ 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; }
4
+
5
+ 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; }
6
+
7
+ import React from 'react';
8
+ import { Input, Tooltip, Space } from 'antd';
9
+ import { InfoCircleOutlined } from '@ant-design/icons';
10
+ import BizSelect from '../../select';
11
+ import './styles/runTimesCondition.less';
12
+ import { classPrefix } from '..';
13
+ var options = [{
14
+ value: '>',
15
+ text: '>'
16
+ }, {
17
+ value: '=',
18
+ text: '='
19
+ }, {
20
+ value: '<',
21
+ text: '<'
22
+ }, {
23
+ value: '>=',
24
+ text: '>='
25
+ }, {
26
+ value: '<=',
27
+ text: '<='
28
+ }, {
29
+ value: 'not equal',
30
+ text: '≠'
31
+ }];
32
+
33
+ var RunTimesCondition = function RunTimesCondition(props) {
34
+ var runTimes = props.runTimes,
35
+ onChange = props.onChange;
36
+
37
+ function onOperatorChange(data) {
38
+ onChange(_objectSpread(_objectSpread({}, runTimes), {}, {
39
+ operator: data.value
40
+ }));
41
+ }
42
+
43
+ function onValueChange(e) {
44
+ var value = e.target.value;
45
+ onChange(_objectSpread(_objectSpread({}, runTimes), {}, {
46
+ values: [value]
47
+ }));
48
+ }
49
+
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ className: "".concat(classPrefix, "-runtimes-condition")
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ className: "".concat(classPrefix, "-runtimes-condition-operator")
54
+ }, /*#__PURE__*/React.createElement(BizSelect, {
55
+ options: options,
56
+ labelField: "text",
57
+ keyField: "value",
58
+ value: {
59
+ value: runTimes.operator,
60
+ text: runTimes.operator === 'not equal' ? '≠' : runTimes.operator
61
+ },
62
+ onChange: onOperatorChange
63
+ })), /*#__PURE__*/React.createElement("div", {
64
+ className: "".concat(classPrefix, "-runtimes-condition-value")
65
+ }, /*#__PURE__*/React.createElement(Input, {
66
+ size: "large",
67
+ value: runTimes.values[0],
68
+ onChange: onValueChange
69
+ })), /*#__PURE__*/React.createElement("div", {
70
+ className: "".concat(classPrefix, "-runtimes-condition-unit")
71
+ }, /*#__PURE__*/React.createElement(Space, null, "\u6B21", /*#__PURE__*/React.createElement(Tooltip, {
72
+ title: "\u89E6\u53D1\u6B21\u6570\u4E3A0\u7B49\u540C\u4E8E\u6CA1\u6709\u89E6\u53D1"
73
+ }, /*#__PURE__*/React.createElement("span", {
74
+ className: "".concat(classPrefix, "-runtimes-tip")
75
+ }, /*#__PURE__*/React.createElement(InfoCircleOutlined, null))))));
76
+ };
77
+
78
+ export default RunTimesCondition;