@zgfe/business-lib 1.0.21-cdp.3 → 1.0.21-cdp.6

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.
@@ -28,6 +28,7 @@
28
28
  padding: @padding-xss;
29
29
  border: 1px solid @border-color-base;
30
30
  border-radius: @border-radius-small;
31
+ cursor: pointer;
31
32
  }
32
33
 
33
34
  // 下拉组件展开panel样式
@@ -44,6 +45,7 @@
44
45
  padding: 0 @padding-sm;
45
46
  line-height: @option-height;
46
47
  border-radius: @border-radius-normal;
48
+ cursor: pointer;
47
49
  .__default-overflow();
48
50
 
49
51
  &:not(.disabled, .active):hover {
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { BizCycleTime } from '@zgfe/business-lib';
3
+ export default (function () {
4
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizCycleTime, null));
5
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: () => JSX.Element;
2
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { BizCycleTime } from '@zgfe/business-lib';
3
+ export default (function () {
4
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(BizCycleTime, {
5
+ multiple: true
6
+ }));
7
+ });
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import './styles/index.less';
3
+ declare enum Unit {
4
+ day = "day",
5
+ week = "week",
6
+ month = "month"
7
+ }
8
+ interface Value {
9
+ unit: Unit;
10
+ day?: number[];
11
+ time?: string;
12
+ }
13
+ declare const BizCycleTime: React.FC<{
14
+ multiple?: boolean;
15
+ onChange?: (val: Value) => void;
16
+ }>;
17
+ export default BizCycleTime;
@@ -0,0 +1,122 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ 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."); }
4
+
5
+ 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); }
6
+
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
+
9
+ 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; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { DatePicker } from 'antd';
14
+ import React, { useEffect, useState } from 'react';
15
+ import { BizSelect } from '..';
16
+ import MonthDay from './month';
17
+ import './styles/index.less';
18
+ var Unit;
19
+
20
+ (function (Unit) {
21
+ Unit["day"] = "day";
22
+ Unit["week"] = "week";
23
+ Unit["month"] = "month";
24
+ })(Unit || (Unit = {}));
25
+
26
+ var BizCycleTime = function BizCycleTime(props) {
27
+ var multiple = props.multiple;
28
+ var classPrefix = 'biz-cycle-time';
29
+ var unitList = [{
30
+ label: '每日',
31
+ value: Unit.day
32
+ }, {
33
+ label: '每周',
34
+ value: Unit.week
35
+ }, {
36
+ label: '每月',
37
+ value: Unit.month
38
+ }];
39
+ var days = [];
40
+
41
+ var _useState = useState(unitList[0]),
42
+ _useState2 = _slicedToArray(_useState, 2),
43
+ unit = _useState2[0],
44
+ setUnit = _useState2[1];
45
+
46
+ var _useState3 = useState([]),
47
+ _useState4 = _slicedToArray(_useState3, 2),
48
+ day = _useState4[0],
49
+ setDay = _useState4[1];
50
+
51
+ var _useState5 = useState(),
52
+ _useState6 = _slicedToArray(_useState5, 2),
53
+ dayList = _useState6[0],
54
+ setDayList = _useState6[1];
55
+
56
+ var _useState7 = useState(),
57
+ _useState8 = _slicedToArray(_useState7, 2),
58
+ time = _useState8[0],
59
+ setTime = _useState8[1];
60
+
61
+ useEffect(function () {
62
+ var res = {
63
+ unit: unit.value,
64
+ day: unit.value === Unit.month ? dayList === null || dayList === void 0 ? void 0 : dayList.map(function (item) {
65
+ return item.value;
66
+ }) : multiple ? day.map(function (item) {
67
+ return item.value;
68
+ }) : [day.value],
69
+ time: time
70
+ };
71
+
72
+ if (unit.value === Unit.day) {
73
+ delete res.day;
74
+ } else {
75
+ delete res.time;
76
+ }
77
+
78
+ if (props.onChange) props.onChange(res);
79
+ }, [unit, day, dayList, time]);
80
+ var nums = ['一', '二', '三', '四', '五', '六', '日'];
81
+
82
+ for (var i = 1; i < 8; i++) {
83
+ days.push({
84
+ label: "\u661F\u671F".concat(nums[i - 1]),
85
+ value: i
86
+ });
87
+ }
88
+
89
+ return /*#__PURE__*/React.createElement("span", {
90
+ className: classPrefix
91
+ }, /*#__PURE__*/React.createElement(BizSelect, {
92
+ options: unitList,
93
+ labelField: "label",
94
+ keyField: "value",
95
+ className: "".concat(classPrefix, "-unit"),
96
+ defaultValue: unit,
97
+ onChange: function onChange(v) {
98
+ setUnit(v);
99
+ }
100
+ }), unit.value === Unit.day && /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
101
+ className: "".concat(classPrefix, "-hour"),
102
+ onChange: function onChange(time) {
103
+ setTime(time === null || time === void 0 ? void 0 : time.format('hh:mm:ss'));
104
+ }
105
+ }), unit.value === Unit.week && /*#__PURE__*/React.createElement(BizSelect, {
106
+ options: days,
107
+ labelField: "label",
108
+ keyField: "value",
109
+ multiple: multiple,
110
+ className: "".concat(classPrefix, "-day"),
111
+ onChange: function onChange(v) {
112
+ setDay(v);
113
+ }
114
+ }), unit.value === Unit.month && /*#__PURE__*/React.createElement(MonthDay, {
115
+ onChange: setDayList
116
+ }));
117
+ };
118
+
119
+ BizCycleTime.defaultProps = {
120
+ multiple: false
121
+ };
122
+ export default BizCycleTime;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import './styles/month.less';
3
+ import { BaseOption } from '../utils/type';
4
+ declare const MonthDay: React.FC<{
5
+ size?: 'large' | 'normal' | 'small';
6
+ className?: string;
7
+ onChange?: (days: BaseOption<number>[]) => void;
8
+ }>;
9
+ export default MonthDay;
@@ -0,0 +1,100 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ 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."); }
4
+
5
+ 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); }
6
+
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
+
9
+ 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; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { Dropdown, Tag } from 'antd';
14
+ import React, { useEffect, useState } from 'react';
15
+ import { IconFont } from '..';
16
+ import './styles/month.less';
17
+ import _ from 'lodash';
18
+
19
+ var MonthDay = function MonthDay(props) {
20
+ var classPrefix = 'biz-month-day';
21
+
22
+ var _useState = useState([]),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ chosenDayList = _useState2[0],
25
+ setChosenDayList = _useState2[1];
26
+
27
+ var _useState3 = useState(false),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ visible = _useState4[0],
30
+ setVisible = _useState4[1];
31
+
32
+ useEffect(function () {
33
+ if (props.onChange) props.onChange(chosenDayList);
34
+ }, [chosenDayList]);
35
+
36
+ function onClickMonthDay(day) {
37
+ setChosenDayList(function (list) {
38
+ var res = _.cloneDeep(list);
39
+
40
+ var daySelected = false;
41
+ res.forEach(function (item, i) {
42
+ if (day === item.value) {
43
+ res.splice(i, 1);
44
+ daySelected = true;
45
+ }
46
+ });
47
+ if (!daySelected) res.push({
48
+ label: String(day === 32 ? '月末' : day),
49
+ value: day
50
+ });
51
+ return res;
52
+ });
53
+ }
54
+
55
+ var dayList = [];
56
+
57
+ for (var i = 1; i < 33; i++) {
58
+ dayList.push({
59
+ label: String(i === 32 ? '月末' : i),
60
+ value: i
61
+ });
62
+ }
63
+
64
+ return /*#__PURE__*/React.createElement(Dropdown, {
65
+ overlay: /*#__PURE__*/React.createElement("div", {
66
+ className: "".concat(classPrefix, "-overlay")
67
+ }, dayList.map(function (item) {
68
+ return /*#__PURE__*/React.createElement("span", {
69
+ key: item.value,
70
+ className: "".concat(classPrefix, "-day ").concat(chosenDayList.map(function (v) {
71
+ return v.value;
72
+ }).indexOf(item.value) > -1 ? 'active' : '', " ").concat(item.value === 32 ? 'lastday' : ''),
73
+ onClick: function onClick() {
74
+ onClickMonthDay(item.value);
75
+ }
76
+ }, item.label);
77
+ })),
78
+ visible: visible,
79
+ onVisibleChange: setVisible,
80
+ trigger: ['click']
81
+ }, /*#__PURE__*/React.createElement("div", {
82
+ className: "".concat(classPrefix, "-wrapper")
83
+ }, /*#__PURE__*/React.createElement("div", {
84
+ className: "".concat(classPrefix, "-handle ").concat(props.size)
85
+ }, /*#__PURE__*/React.createElement("div", {
86
+ className: "".concat(classPrefix, "-val")
87
+ }, chosenDayList.map(function (item) {
88
+ return /*#__PURE__*/React.createElement(Tag, {
89
+ closable: true,
90
+ key: item.value
91
+ }, item.label);
92
+ })), /*#__PURE__*/React.createElement(IconFont, {
93
+ type: "xiangxia"
94
+ }))));
95
+ };
96
+
97
+ MonthDay.defaultProps = {
98
+ size: 'normal'
99
+ };
100
+ export default MonthDay;
@@ -0,0 +1,24 @@
1
+ @import '../../assets//styles/inner.less';
2
+ .biz-cycle-time {
3
+ display: inline-block;
4
+ &-unit {
5
+ width: 129px;
6
+ }
7
+ &-day {
8
+ width: 210px;
9
+ vertical-align: top;
10
+ &.multi {
11
+ width: 470px;
12
+ }
13
+ }
14
+ &-unit,
15
+ &-day,
16
+ &-hour {
17
+ display: inline-block;
18
+ margin-right: @margin-xs;
19
+ }
20
+ &-hour {
21
+ width: 220px;
22
+ vertical-align: top;
23
+ }
24
+ }
@@ -0,0 +1,58 @@
1
+ @import '../../assets//styles/inner.less';
2
+ .biz-month-day {
3
+ &-handle {
4
+ .__select-handle();
5
+ display: flex;
6
+ flex-direction: row;
7
+ width: 280px;
8
+ &:hover,
9
+ &:active {
10
+ .__default-focused();
11
+ }
12
+ &.large {
13
+ min-height: @height-lg;
14
+ }
15
+ &.normal {
16
+ min-height: @height-base;
17
+ }
18
+ &.small {
19
+ min-height: @height-sm;
20
+ }
21
+ .bsicon {
22
+ flex: none;
23
+ }
24
+ }
25
+ &-val {
26
+ flex: 1;
27
+ .ant-tag {
28
+ margin-bottom: @margin-xss;
29
+ }
30
+ }
31
+ &-wrapper {
32
+ display: inline-block;
33
+ vertical-align: top;
34
+ &.ant-dropdown-open > .biz-month-day-handle {
35
+ .__default-focused();
36
+ }
37
+ }
38
+ &-overlay {
39
+ .__select-panel();
40
+ width: 280px;
41
+ padding: @padding-xss @padding-md;
42
+ word-break: break-all;
43
+ }
44
+ &-day {
45
+ .__select-option();
46
+ display: inline-block;
47
+ width: 30px;
48
+ height: 30px;
49
+ margin: 0 @margin-xss + 1 @margin-xss 0;
50
+ padding: 0;
51
+ line-height: 30px;
52
+ text-align: center;
53
+ border-radius: 100%;
54
+ &.lastday {
55
+ .__default-hover();
56
+ }
57
+ }
58
+ }
package/es/index.d.ts CHANGED
@@ -23,7 +23,8 @@ import BizUserTagsSelect from './userTagsSelector';
23
23
  import BizAddToScene from './addToScene';
24
24
  import BizAddToPanel from './addToPanel';
25
25
  import setGlobalConfig from './config';
26
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
26
+ import BizCycleTime from './cycleTime';
27
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, };
27
28
  export type { UserGroupTypes } from './userGroup/types';
28
29
  export type { BizSelectTypes } from './select/types';
29
30
  export type { AttributeSelect } from './attributeSelector/types';
package/es/index.js CHANGED
@@ -22,4 +22,5 @@ import BizUserTagsSelect from './userTagsSelector';
22
22
  import BizAddToScene from './addToScene';
23
23
  import BizAddToPanel from './addToPanel';
24
24
  import setGlobalConfig from './config';
25
- export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
25
+ import BizCycleTime from './cycleTime';
26
+ export { BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizAnalysisLayout, BizUserGroup, IconFont, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetCondition, BizDatePicker, BizConditionItem, BizConditionGroup, BizUserCondition, BizAddToScene, BizAddToPanel, BizCycleTime, ajax, util, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig };
@@ -87,16 +87,9 @@ var BizSelect = function BizSelect(props) {
87
87
  };
88
88
  }, []);
89
89
  useEffect(function () {
90
- if (!props.value) {
91
- setCurrent(undefined);
92
- return;
93
- }
94
-
90
+ if (!props.value) return;
95
91
  setCurrent(getValue(props.value));
96
92
  }, [props.value]);
97
- useEffect(function () {
98
- setCurrent(undefined);
99
- }, [props.options]);
100
93
 
101
94
  var getValue = function getValue(data) {
102
95
  if (props.multiple) {
@@ -5,6 +5,10 @@ export interface Event {
5
5
  label?: string | number;
6
6
  [prop: string]: any;
7
7
  }
8
+ export interface BaseOption<T> {
9
+ label: string;
10
+ value: T;
11
+ }
8
12
  export interface EventType {
9
13
  aliasName?: string;
10
14
  option?: string | number | Event;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgfe/business-lib",
3
- "version": "1.0.21-cdp.3",
3
+ "version": "1.0.21-cdp.6",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -58,5 +58,5 @@
58
58
  "react": "^16.12.0 || ^17.0.0",
59
59
  "yorkie": "^2.0.0"
60
60
  },
61
- "gitHead": "503dca03dfb6cf5a5392b67a5399a8df132bc0fa"
61
+ "gitHead": "678ee4c35972fecb35fe80d13259a69e651f8b6d"
62
62
  }