@zgfe/business-lib 1.2.14 → 1.2.15-data.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.
- package/es/assets/styles/resetAntd.less +5 -3
- package/es/cycleTime/demo/hour.d.ts +3 -0
- package/es/cycleTime/demo/hour.js +83 -0
- package/es/cycleTime/index.d.ts +8 -1
- package/es/cycleTime/index.js +37 -14
- package/es/cycleTime/month.js +5 -2
- package/es/cycleTime/styles/index.less +2 -2
- package/es/cycleTime/styles/month.less +11 -0
- package/es/select/styles/handle.less +4 -0
- package/package.json +2 -2
|
@@ -194,9 +194,11 @@
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
&:
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
&:not(.ant-picker-disabled, .ant-picker-status-error) {
|
|
198
|
+
&:hover,
|
|
199
|
+
&.ant-picker-focused {
|
|
200
|
+
border-color: @primary-color!important;
|
|
201
|
+
}
|
|
200
202
|
}
|
|
201
203
|
|
|
202
204
|
.ant-picker-active-bar {
|
|
@@ -0,0 +1,83 @@
|
|
|
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 from 'react';
|
|
8
|
+
import { BizCycleTime } from '@zgfe/business-lib';
|
|
9
|
+
import { CycleTimeUnit } from '..';
|
|
10
|
+
import { Button, Form } from 'antd';
|
|
11
|
+
export default (function () {
|
|
12
|
+
var options = [{
|
|
13
|
+
label: '每小时',
|
|
14
|
+
value: CycleTimeUnit.hour
|
|
15
|
+
}, {
|
|
16
|
+
label: '每日',
|
|
17
|
+
value: CycleTimeUnit.day
|
|
18
|
+
}, {
|
|
19
|
+
label: '每周',
|
|
20
|
+
value: CycleTimeUnit.week
|
|
21
|
+
}, {
|
|
22
|
+
label: '每月',
|
|
23
|
+
value: CycleTimeUnit.month
|
|
24
|
+
}];
|
|
25
|
+
var customOptions = [].concat(options, [{
|
|
26
|
+
label: '指定时间',
|
|
27
|
+
value: CycleTimeUnit.custom
|
|
28
|
+
}]);
|
|
29
|
+
var _Form$useForm = Form.useForm(),
|
|
30
|
+
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
31
|
+
form = _Form$useForm2[0];
|
|
32
|
+
var onChange = function onChange(data) {
|
|
33
|
+
console.log('change:', data);
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "\u9ED8\u8BA4\u503C")), /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
36
|
+
value: {
|
|
37
|
+
unit: 3,
|
|
38
|
+
day: [1, 23, 4],
|
|
39
|
+
time: '12:00:00'
|
|
40
|
+
},
|
|
41
|
+
multiple: true,
|
|
42
|
+
showHour: true,
|
|
43
|
+
options: options,
|
|
44
|
+
onChange: onChange
|
|
45
|
+
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "\u65E0\u9ED8\u8BA4\u503C")), /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
46
|
+
multiple: true,
|
|
47
|
+
showHour: true,
|
|
48
|
+
options: options,
|
|
49
|
+
format: "HH",
|
|
50
|
+
onChange: onChange
|
|
51
|
+
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "\u6307\u5B9A\u65F6\u95F4")), /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
52
|
+
multiple: true,
|
|
53
|
+
showHour: true,
|
|
54
|
+
options: customOptions,
|
|
55
|
+
format: "HH",
|
|
56
|
+
onChange: onChange
|
|
57
|
+
}), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("b", null, "Form")), /*#__PURE__*/React.createElement(Form, {
|
|
58
|
+
form: form
|
|
59
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
60
|
+
label: "\u65E5\u671F",
|
|
61
|
+
name: "date",
|
|
62
|
+
rules: [{
|
|
63
|
+
validator: function validator(_, value) {
|
|
64
|
+
if (value.unit > 1 && !value.day.length) {
|
|
65
|
+
return Promise.reject('请选择日期');
|
|
66
|
+
}
|
|
67
|
+
if (value.unit > 0 && !value.time) {
|
|
68
|
+
return Promise.reject('请选择小时');
|
|
69
|
+
}
|
|
70
|
+
return Promise.resolve();
|
|
71
|
+
}
|
|
72
|
+
}]
|
|
73
|
+
}, /*#__PURE__*/React.createElement(BizCycleTime, {
|
|
74
|
+
multiple: true,
|
|
75
|
+
showHour: true,
|
|
76
|
+
options: options,
|
|
77
|
+
format: "HH",
|
|
78
|
+
onChange: onChange
|
|
79
|
+
})), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Button, {
|
|
80
|
+
type: "primary",
|
|
81
|
+
htmlType: "submit"
|
|
82
|
+
}, "\u786E\u5B9A"))));
|
|
83
|
+
});
|
package/es/cycleTime/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { BaseOption } from '../utils/type';
|
|
3
4
|
import './styles/index.less';
|
|
4
5
|
export declare enum CycleTimeUnit {
|
|
6
|
+
hour = 0,
|
|
5
7
|
day = 1,
|
|
6
8
|
week = 2,
|
|
7
|
-
month = 3
|
|
9
|
+
month = 3,
|
|
10
|
+
year = 4,
|
|
11
|
+
custom = 5
|
|
8
12
|
}
|
|
9
13
|
interface Value {
|
|
10
14
|
unit: CycleTimeUnit;
|
|
@@ -18,5 +22,8 @@ declare const BizCycleTime: React.FC<{
|
|
|
18
22
|
onChange?: (val: Value) => void;
|
|
19
23
|
size?: SizeType;
|
|
20
24
|
disable?: boolean;
|
|
25
|
+
showHour?: boolean;
|
|
26
|
+
format?: string;
|
|
27
|
+
options?: BaseOption<CycleTimeUnit>[];
|
|
21
28
|
}>;
|
|
22
29
|
export default BizCycleTime;
|
package/es/cycleTime/index.js
CHANGED
|
@@ -12,16 +12,21 @@ import MonthDay from './month';
|
|
|
12
12
|
import './styles/index.less';
|
|
13
13
|
export var CycleTimeUnit;
|
|
14
14
|
(function (CycleTimeUnit) {
|
|
15
|
+
CycleTimeUnit[CycleTimeUnit["hour"] = 0] = "hour";
|
|
15
16
|
CycleTimeUnit[CycleTimeUnit["day"] = 1] = "day";
|
|
16
17
|
CycleTimeUnit[CycleTimeUnit["week"] = 2] = "week";
|
|
17
18
|
CycleTimeUnit[CycleTimeUnit["month"] = 3] = "month";
|
|
19
|
+
CycleTimeUnit[CycleTimeUnit["year"] = 4] = "year";
|
|
20
|
+
CycleTimeUnit[CycleTimeUnit["custom"] = 5] = "custom";
|
|
18
21
|
})(CycleTimeUnit || (CycleTimeUnit = {}));
|
|
19
22
|
var BizCycleTime = function BizCycleTime(props) {
|
|
20
23
|
var multiple = props.multiple,
|
|
21
24
|
size = props.size,
|
|
22
|
-
disable = props.disable
|
|
25
|
+
disable = props.disable,
|
|
26
|
+
showHour = props.showHour,
|
|
27
|
+
options = props.options;
|
|
23
28
|
var classPrefix = 'biz-cycle-time';
|
|
24
|
-
var unitList = [{
|
|
29
|
+
var unitList = options || [{
|
|
25
30
|
label: '每日',
|
|
26
31
|
value: CycleTimeUnit.day
|
|
27
32
|
}, {
|
|
@@ -59,6 +64,9 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
59
64
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
60
65
|
initing = _useState10[0],
|
|
61
66
|
setIniting = _useState10[1];
|
|
67
|
+
var _useState11 = useState(props.format || 'hh:mm:ss'),
|
|
68
|
+
_useState12 = _slicedToArray(_useState11, 1),
|
|
69
|
+
format = _useState12[0];
|
|
62
70
|
useEffect(function () {
|
|
63
71
|
if (!props.value) {
|
|
64
72
|
setIniting(false);
|
|
@@ -71,6 +79,7 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
71
79
|
setUnit(item);
|
|
72
80
|
switch (item.value) {
|
|
73
81
|
case CycleTimeUnit.day:
|
|
82
|
+
case CycleTimeUnit.custom:
|
|
74
83
|
setTime(props.value.time);
|
|
75
84
|
break;
|
|
76
85
|
case CycleTimeUnit.week:
|
|
@@ -85,6 +94,7 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
85
94
|
} else {
|
|
86
95
|
setDay(valList[0]);
|
|
87
96
|
}
|
|
97
|
+
if (showHour) setTime(props.value.time);
|
|
88
98
|
break;
|
|
89
99
|
case CycleTimeUnit.month:
|
|
90
100
|
setDay(props.value.day.map(function (v) {
|
|
@@ -93,6 +103,7 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
93
103
|
value: v
|
|
94
104
|
};
|
|
95
105
|
}));
|
|
106
|
+
if (showHour) setTime(props.value.time);
|
|
96
107
|
break;
|
|
97
108
|
}
|
|
98
109
|
}
|
|
@@ -111,9 +122,12 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
111
122
|
}) : [day.value],
|
|
112
123
|
time: time
|
|
113
124
|
};
|
|
114
|
-
if (unit.value === CycleTimeUnit.
|
|
125
|
+
if (unit.value === CycleTimeUnit.hour) {
|
|
115
126
|
delete res.day;
|
|
116
|
-
|
|
127
|
+
delete res.time;
|
|
128
|
+
} else if (unit.value === CycleTimeUnit.day || unit.value === CycleTimeUnit.custom) {
|
|
129
|
+
delete res.day;
|
|
130
|
+
} else if (!showHour) {
|
|
117
131
|
delete res.time;
|
|
118
132
|
}
|
|
119
133
|
if (props.onChange) props.onChange(res);
|
|
@@ -135,18 +149,9 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
135
149
|
disable: disable,
|
|
136
150
|
onChange: function onChange(v) {
|
|
137
151
|
setDay([]);
|
|
138
|
-
setTime(undefined);
|
|
152
|
+
setTime(showHour && v.value !== CycleTimeUnit.custom ? '00' : undefined);
|
|
139
153
|
setUnit(v);
|
|
140
154
|
}
|
|
141
|
-
}), unit.value === CycleTimeUnit.day && /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
|
|
142
|
-
className: "".concat(classPrefix, "-hour"),
|
|
143
|
-
size: size,
|
|
144
|
-
placeholder: props.placeholder,
|
|
145
|
-
defaultValue: time ? moment(time, 'hh:mm:ss') : undefined,
|
|
146
|
-
onChange: function onChange(time) {
|
|
147
|
-
setTime(time === null || time === void 0 ? void 0 : time.format('hh:mm:ss'));
|
|
148
|
-
},
|
|
149
|
-
disabled: disable
|
|
150
155
|
}), unit.value === CycleTimeUnit.week && /*#__PURE__*/React.createElement(BizSelect, {
|
|
151
156
|
options: days,
|
|
152
157
|
labelField: "label",
|
|
@@ -166,6 +171,24 @@ var BizCycleTime = function BizCycleTime(props) {
|
|
|
166
171
|
defaultValue: day,
|
|
167
172
|
onChange: setDayList,
|
|
168
173
|
disable: disable
|
|
174
|
+
}), unit.value === CycleTimeUnit.day || unit.value && unit.value !== CycleTimeUnit.custom && showHour ? /*#__PURE__*/React.createElement(DatePicker.TimePicker, {
|
|
175
|
+
className: "".concat(classPrefix, "-hour"),
|
|
176
|
+
size: size,
|
|
177
|
+
placeholder: props.placeholder,
|
|
178
|
+
value: time ? moment(time, format) : undefined,
|
|
179
|
+
format: format,
|
|
180
|
+
onChange: function onChange(time) {
|
|
181
|
+
setTime(time === null || time === void 0 ? void 0 : time.format(format));
|
|
182
|
+
},
|
|
183
|
+
disabled: disable
|
|
184
|
+
}) : null, unit.value == CycleTimeUnit.custom && /*#__PURE__*/React.createElement(DatePicker, {
|
|
185
|
+
value: time ? moment(time, 'YYYY-MM-DD HH:mm:ss') : undefined,
|
|
186
|
+
showTime: true,
|
|
187
|
+
disabled: disable,
|
|
188
|
+
placeholder: props.placeholder,
|
|
189
|
+
onChange: function onChange(time) {
|
|
190
|
+
setTime(time === null || time === void 0 ? void 0 : time.format('YYYY-MM-DD HH:mm:ss'));
|
|
191
|
+
}
|
|
169
192
|
}));
|
|
170
193
|
};
|
|
171
194
|
BizCycleTime.defaultProps = {
|
package/es/cycleTime/month.js
CHANGED
|
@@ -5,10 +5,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { Dropdown, Tag } from 'antd';
|
|
8
|
-
import React, { useEffect, useState } from 'react';
|
|
8
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
9
9
|
import { IconFont } from '..';
|
|
10
10
|
import './styles/month.less';
|
|
11
11
|
import _ from 'lodash';
|
|
12
|
+
import { FormItemInputContext } from 'antd/es/form/context';
|
|
12
13
|
var MonthDay = function MonthDay(props) {
|
|
13
14
|
var classPrefix = 'biz-month-day';
|
|
14
15
|
var disable = props.disable;
|
|
@@ -20,6 +21,8 @@ var MonthDay = function MonthDay(props) {
|
|
|
20
21
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
21
22
|
visible = _useState4[0],
|
|
22
23
|
setVisible = _useState4[1];
|
|
24
|
+
var _useContext = useContext(FormItemInputContext),
|
|
25
|
+
status = _useContext.status;
|
|
23
26
|
var dayList = [];
|
|
24
27
|
for (var i = 1; i < 33; i++) {
|
|
25
28
|
dayList.push({
|
|
@@ -90,7 +93,7 @@ var MonthDay = function MonthDay(props) {
|
|
|
90
93
|
}, /*#__PURE__*/React.createElement("div", {
|
|
91
94
|
className: "".concat(classPrefix, "-wrapper")
|
|
92
95
|
}, /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
className: "".concat(classPrefix, "-handle ").concat(props.size, " ").concat(!chosenDayList.length ? "holder" : '', " ").concat(disable ? 'disable' : '')
|
|
96
|
+
className: "".concat(classPrefix, "-handle ").concat(props.size, " ").concat(!chosenDayList.length ? "holder" : '', " ").concat(disable ? 'disable' : '').concat(status ? " ".concat(classPrefix, "-status-").concat(status) : '')
|
|
94
97
|
}, /*#__PURE__*/React.createElement("div", {
|
|
95
98
|
className: "".concat(classPrefix, "-val")
|
|
96
99
|
}, chosenDayList.map(function (item) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@import '../../assets//styles/inner.less';
|
|
2
2
|
.biz-cycle-time {
|
|
3
|
-
display:
|
|
3
|
+
display: flex;
|
|
4
|
+
gap: 12px;
|
|
4
5
|
&-unit {
|
|
5
6
|
width: 129px;
|
|
6
7
|
}
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
&-day,
|
|
16
17
|
&-hour {
|
|
17
18
|
display: inline-block;
|
|
18
|
-
margin-right: @margin-xs;
|
|
19
19
|
}
|
|
20
20
|
&-hour {
|
|
21
21
|
width: 220px;
|
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
&-holder {
|
|
36
36
|
color: @input-placeholder-color;
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
&-status-error:not(.disable) {
|
|
40
|
+
border-color: @error-color;
|
|
41
|
+
&.biz-month-day-handle:hover {
|
|
42
|
+
border-color: @error-color;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
38
45
|
&-val {
|
|
39
46
|
flex: 1;
|
|
40
47
|
.ant-tag {
|
|
@@ -46,6 +53,10 @@
|
|
|
46
53
|
vertical-align: top;
|
|
47
54
|
&.ant-dropdown-open > .biz-month-day-handle {
|
|
48
55
|
.__default-focused();
|
|
56
|
+
&.biz-month-day-status-error:not(.disable) {
|
|
57
|
+
border-color: @error-color;
|
|
58
|
+
box-shadow: 0 0 0 4px rgba(#ff8170, 0.2) !important;
|
|
59
|
+
}
|
|
49
60
|
}
|
|
50
61
|
.biz-month-day-handle {
|
|
51
62
|
&.disable {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.15-data.0",
|
|
4
4
|
"module": "es/index.js",
|
|
5
5
|
"typings": "es/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react": "^16.12.0 || ^17.0.0",
|
|
56
56
|
"yorkie": "^2.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "39f628374430fd56999cfd30173fe6edabb16f86",
|
|
59
59
|
"gitHooks": {
|
|
60
60
|
"pre-commit": "lint-staged"
|
|
61
61
|
}
|