@zgfe/business-lib 1.0.3 → 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.
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { IconFontProps } from '@ant-design/icons/lib/components/IconFont';
3
3
  import '../assets/iconfont/iconfont.css';
4
- declare const IconFont: React.FC<IconFontProps>;
4
+ interface Props extends IconFontProps {
5
+ family?: string;
6
+ }
7
+ declare const IconFont: React.FC<Props>;
5
8
  export default IconFont;
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "type"];
1
+ var _excluded = ["className", "type", "family"];
2
2
 
3
3
  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; }
4
4
 
@@ -16,10 +16,11 @@ import '../assets/iconfont/iconfont.css';
16
16
  var IconFont = function IconFont(props) {
17
17
  var className = props.className,
18
18
  type = props.type,
19
+ family = props.family,
19
20
  rest = _objectWithoutProperties(props, _excluded);
20
21
 
21
22
  var iconClassName = useMemo(function () {
22
- return "bsicon ".concat(className, " bs").concat(type);
23
+ return "".concat(family, " ").concat(className, " bs").concat(type);
23
24
  }, [className, type]);
24
25
  return /*#__PURE__*/React.createElement("span", _objectSpread({
25
26
  className: iconClassName
@@ -27,6 +28,7 @@ var IconFont = function IconFont(props) {
27
28
  };
28
29
 
29
30
  IconFont.defaultProps = {
30
- className: ''
31
+ className: '',
32
+ family: 'bsicon'
31
33
  };
32
34
  export default IconFont;
@@ -1,11 +1,5 @@
1
1
  import React from 'react';
2
- import { AllConditionBasePropsI, BizUserConditionT } from '../types';
2
+ import { PropConditionType } from '../types';
3
3
  import './styles/propCondition.less';
4
- export interface PropConditionPropsI extends AllConditionBasePropsI<any> {
5
- isEvent?: boolean;
6
- label?: string | React.ReactDOM;
7
- eventId?: number;
8
- attrs: BizUserConditionT.AttrCondition[];
9
- }
10
- declare const PropCondition: React.FC<PropConditionPropsI>;
4
+ declare const PropCondition: React.FC<PropConditionType.PropsI>;
11
5
  export default PropCondition;
@@ -8,20 +8,29 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
8
8
 
9
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
10
 
11
- 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); }
12
-
13
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
12
 
15
13
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
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
+
17
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; }
18
22
 
19
- import React from 'react';
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';
20
28
  import { PlusOutlined } from '@ant-design/icons';
21
29
  import BizConditionItem from '../../attrConditions';
22
30
  import './styles/propCondition.less';
23
31
  import { useContext } from 'react';
24
32
  import { BizUserConditionContext, classPrefix } from '..';
33
+ import { transformNumberOperate } from '../util';
25
34
  var numAttrTypeMap = {
26
35
  1: 'cont-string',
27
36
  2: 'cont-num',
@@ -42,6 +51,40 @@ var PropCondition = function PropCondition(props) {
42
51
  attrs = props.attrs,
43
52
  dataId = props.dataId;
44
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
+
45
88
  function _onChange(data, i) {
46
89
  var attrName = data.attrName,
47
90
  attrId = data.attrId,
@@ -56,24 +99,33 @@ var PropCondition = function PropCondition(props) {
56
99
  attrName: attrName,
57
100
  attrId: attrId,
58
101
  category: category,
59
- operator: operation,
102
+ operator: transformNumberOperate(operation),
60
103
  params: values,
61
104
  attrType: numAttrTypeMap[type]
62
105
  };
63
- newAttrs[i] = newAttr;
106
+ Object.assign(newAttrs[i], newAttr);
64
107
  props.onChange(dataId, newAttrs);
65
108
  }
66
109
 
67
110
  function onAddAttr() {
68
- props.onChange(dataId, [].concat(_toConsumableArray(attrs), [{
111
+ var attr = {
69
112
  attrId: 0
113
+ };
114
+ setShowList([].concat(_toConsumableArray(showList), [{
115
+ id: Math.random(),
116
+ attr: attr
70
117
  }]));
118
+ props.onChange(dataId, [].concat(_toConsumableArray(attrs), [attr]));
71
119
  }
72
120
 
73
121
  function onRemoveAttr(i) {
74
122
  var newAttrs = _toConsumableArray(attrs);
75
123
 
124
+ var newList = _toConsumableArray(showList);
125
+
126
+ newList.splice(i, 1);
76
127
  newAttrs.splice(i, 1);
128
+ setShowList(newList);
77
129
  props.onChange(dataId, newAttrs);
78
130
  }
79
131
 
@@ -82,18 +134,19 @@ var PropCondition = function PropCondition(props) {
82
134
  return attrName === undefined ? 'eventProp' : 'envProp';
83
135
  }
84
136
 
85
- function renderAttr(attr, i) {
86
- var attrId = attr.attrId,
87
- attrName = attr.attrName,
88
- category = attr.category,
89
- operator = attr.operator,
90
- params = attr.params,
91
- attrType = attr.attrType;
92
- console.log(attrType);
137
+ function renderAttr(item, i) {
93
138
  var props = {};
94
-
95
- if ((attrName || attrId) && operator) {
96
- props.value = {
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 = {
97
150
  attrName: attrName,
98
151
  category: category || 'custom',
99
152
  operation: operator,
@@ -101,14 +154,12 @@ var PropCondition = function PropCondition(props) {
101
154
  propCategory: getPropCategory(attrName),
102
155
  type: attrNumTypeMap[attrType]
103
156
  };
104
- props.key = attrName || attrId;
105
- attrId && (props.value.attrId = attrId);
157
+ attrId && (props.defaultValue.attrId = attrId);
106
158
  }
107
159
 
108
- console.log(props);
109
160
  return /*#__PURE__*/React.createElement("div", {
110
161
  className: "".concat(classPrefix, "-prop-condition-attr"),
111
- key: attrName || attrId || Math.random()
162
+ key: id
112
163
  }, /*#__PURE__*/React.createElement("div", {
113
164
  className: "".concat(classPrefix, "-prop-condition-item-wrap")
114
165
  }, /*#__PURE__*/React.createElement(BizConditionItem, _objectSpread({
@@ -131,8 +182,8 @@ var PropCondition = function PropCondition(props) {
131
182
  className: "".concat(classPrefix, "-prop-condition-label")
132
183
  }, label) : null, /*#__PURE__*/React.createElement("div", {
133
184
  className: "".concat(classPrefix, "-prop-condition-attrs")
134
- }, attrs.map(function (attr, i) {
135
- return renderAttr(attr, i);
185
+ }, showList && showList.map(function (item, i) {
186
+ return renderAttr(item, i);
136
187
  })), attrs.length < eventAttrNum && isEvent ? /*#__PURE__*/React.createElement("div", {
137
188
  className: "".concat(classPrefix, "-prop-condition-add")
138
189
  }, /*#__PURE__*/React.createElement("div", {
@@ -38,51 +38,26 @@ export default (function () {
38
38
  }
39
39
 
40
40
  var defaultValue = [[{
41
- attrs: [{
42
- attrName: 'is_anonymous',
43
- category: 'fixed',
44
- operator: 'equal',
45
- params: ['Safari', 'Apple WebKit', 'Unknown', 'Mobile Safari', 'BlackBerry', 'Microsoft Edge Mobile'],
46
- attrType: 'cont-string'
47
- }]
48
- }, {
49
- eventId: 24143017,
41
+ eventId: 7086293,
50
42
  runTimes: {
51
43
  operator: '>=',
52
44
  values: ['1']
53
45
  },
54
46
  attrs: [{
55
- attrId: 30183430,
56
- operator: 'equal',
57
- params: ['Safari', 'Mobile Safari', 'BlackBerry', 'Unknown'],
47
+ attrId: 30183425,
48
+ operator: '=',
49
+ params: ['Apple WebKit', 'Unknown'],
58
50
  attrType: 'cont-string'
51
+ }, {
52
+ attrId: 5461057,
53
+ operator: '>',
54
+ params: ['123'],
55
+ attrType: 'cont-num'
59
56
  }],
60
57
  runPeriod: {
61
58
  operator: 'relative',
62
59
  values: ['30', '0']
63
60
  }
64
- }], [{
65
- eventId: '-3',
66
- runPeriod: {
67
- operator: 'relative',
68
- values: ['30', '0']
69
- },
70
- runTimes: {
71
- operator: '>=',
72
- values: ['1']
73
- },
74
- attrs: []
75
- }, {
76
- eventId: '-4',
77
- runPeriod: {
78
- operator: 'relative',
79
- values: ['30', '1']
80
- },
81
- runTimes: {
82
- operator: '>=',
83
- values: ['1']
84
- },
85
- attrs: []
86
61
  }]];
87
62
  return /*#__PURE__*/React.createElement(BizGlobalDataContext.Provider, {
88
63
  value: {
@@ -92,6 +67,7 @@ export default (function () {
92
67
  }
93
68
  }, /*#__PURE__*/React.createElement(BizUserCondition, {
94
69
  defaultValue: defaultValue,
95
- onChange: onChange
70
+ onChange: onChange,
71
+ eventAttrNum: 3
96
72
  }));
97
73
  });
@@ -50,11 +50,8 @@ var BizUserCondition = function BizUserCondition(props) {
50
50
  setValue = _useState6[1];
51
51
 
52
52
  useEffect(function () {
53
- if (props.defaultValue) {
54
- setValue(props.defaultValue);
55
- initShowList();
56
- }
57
- }, [props.defaultValue]);
53
+ initShowList();
54
+ }, []);
58
55
 
59
56
  function initShowList() {
60
57
  var showList = [];
@@ -1,3 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare type Unpacked<T, U extends keyof T> = Required<T> extends {
3
+ [key in U]: infer R;
4
+ } ? R : never;
1
5
  export interface RunPeriodI {
2
6
  operator: 'relative' | 'unlimited_time' | 'join_time' | 'absolute';
3
7
  values: string[];
@@ -22,7 +26,7 @@ export declare namespace BizUserConditionT {
22
26
  interface AttrCondition {
23
27
  attrId: number;
24
28
  attrName: string;
25
- operator: 'is not null' | 'is null' | 'not contains' | 'contains' | 'equal' | 'not equal' | 'begin with' | 'not begin with' | 'end with' | 'not end with';
29
+ operator: 'is not null' | 'is null' | 'not contains' | 'contains' | 'equal' | 'not equal' | 'begin with' | 'not begin with' | 'end with' | 'not end with' | Unpacked<RunTimesI, 'operator'>;
26
30
  params: string[];
27
31
  attrType: 'cont-string' | 'cont-num' | 'cont-date';
28
32
  category: 'fixed' | 'custom';
@@ -77,3 +81,16 @@ export declare namespace RunTimesConditionTypes {
77
81
  } ? U : never;
78
82
  }[];
79
83
  }
84
+ export declare namespace PropConditionType {
85
+ type ShowListI = {
86
+ attr: BizUserConditionT.AttrCondition;
87
+ id: number;
88
+ default?: BizUserConditionT.AttrCondition;
89
+ }[];
90
+ interface PropsI extends AllConditionBasePropsI<any> {
91
+ isEvent?: boolean;
92
+ label?: string | React.ReactDOM;
93
+ eventId?: number;
94
+ attrs: BizUserConditionT.AttrCondition[];
95
+ }
96
+ }
@@ -1,2 +1,3 @@
1
1
  import { BizUserConditionT } from './types';
2
2
  export declare function buildCondition(type: BizUserConditionT.ConditionType): BizUserConditionT.EventCondition | BizUserConditionT.AddCondition | BizUserConditionT.ActiveCondition | BizUserConditionT.PropCondition;
3
+ export declare function transformNumberOperate(key: string, output?: boolean): string;
@@ -51,4 +51,23 @@ export function buildCondition(type) {
51
51
  }]
52
52
  };
53
53
  }
54
+ }
55
+ export function transformNumberOperate(key) {
56
+ var output = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
57
+ var outputMap = {
58
+ gt: '>',
59
+ equal: '=',
60
+ lt: '<',
61
+ ge: '>=',
62
+ le: '<='
63
+ };
64
+ var inputMap = {
65
+ '>': 'gt',
66
+ '=': 'equal',
67
+ '<': 'lt',
68
+ '>=': 'ge',
69
+ '<=': 'le'
70
+ };
71
+ if (output) return outputMap[key] || key;
72
+ return inputMap[key] || key;
54
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -58,5 +58,5 @@
58
58
  "prettier": "^2.2.1",
59
59
  "yorkie": "^2.0.0"
60
60
  },
61
- "gitHead": "81e9003818182ca6aa3755ba71f55cf8964d7d09"
61
+ "gitHead": "d01bb3a8b365c50b8c99c2a63a6501d87fba27e9"
62
62
  }