@zgfe/business-lib 1.2.52 → 1.2.53
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/iconfont/demo_index.html +3 -3
- package/es/assets/iconfont/iconfont.css +3 -3
- package/es/assets/iconfont/iconfont.ttf +0 -0
- package/es/assets/iconfont/iconfont.woff +0 -0
- package/es/assets/iconfont/iconfont.woff2 +0 -0
- package/es/datePicker/demo/index.js +3 -1
- package/es/datePickerV2/context.d.ts +13 -0
- package/es/datePickerV2/context.js +3 -0
- package/es/datePickerV2/datePicker.d.ts +7 -0
- package/es/datePickerV2/datePicker.js +149 -0
- package/es/datePickerV2/demo/customType.d.ts +4 -0
- package/es/datePickerV2/demo/customType.js +38 -0
- package/es/datePickerV2/demo/day.d.ts +4 -0
- package/es/datePickerV2/demo/day.js +47 -0
- package/es/datePickerV2/demo/index.d.ts +4 -0
- package/es/datePickerV2/demo/index.js +67 -0
- package/es/datePickerV2/index.d.ts +6 -0
- package/es/datePickerV2/index.js +243 -0
- package/es/datePickerV2/popoverContent.d.ts +13 -0
- package/es/datePickerV2/popoverContent.js +53 -0
- package/es/datePickerV2/shortcut.d.ts +7 -0
- package/es/datePickerV2/shortcut.js +120 -0
- package/es/datePickerV2/styles/index.less +184 -0
- package/es/datePickerV2/types.d.ts +38 -0
- package/es/datePickerV2/types.js +12 -0
- package/es/datePickerV2/utils.d.ts +30 -0
- package/es/datePickerV2/utils.js +139 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePickerTypes } from './types';
|
|
3
|
+
interface PopoverContent {
|
|
4
|
+
setDateRange?: any;
|
|
5
|
+
setOpen?: any;
|
|
6
|
+
timeRangeOpen?: number;
|
|
7
|
+
selectRange?: number;
|
|
8
|
+
currentType?: DatePickerTypes.Unit;
|
|
9
|
+
relative?: any[];
|
|
10
|
+
selectRangeUnit?: 'days' | 'weeks' | 'months' | 'quarter';
|
|
11
|
+
}
|
|
12
|
+
declare const _default: (props: PopoverContent) => React.JSX.Element;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { Button, Tabs } from 'antd';
|
|
8
|
+
import React, { useRef } from 'react';
|
|
9
|
+
import PickerShortcut from './shortcut';
|
|
10
|
+
import BizDate from './datePicker';
|
|
11
|
+
import { classPrefix } from '.';
|
|
12
|
+
import { DatePickerTypes } from './types';
|
|
13
|
+
export default (function (props) {
|
|
14
|
+
var selectRange = props.selectRange,
|
|
15
|
+
setDateRange = props.setDateRange,
|
|
16
|
+
setOpen = props.setOpen,
|
|
17
|
+
currentType = props.currentType,
|
|
18
|
+
relative = props.relative,
|
|
19
|
+
selectRangeUnit = props.selectRangeUnit;
|
|
20
|
+
var ref = useRef();
|
|
21
|
+
return /*#__PURE__*/React.createElement(Tabs, {
|
|
22
|
+
defaultActiveKey: relative ? '1' : '2'
|
|
23
|
+
}, currentType != DatePickerTypes.Unit.custom && /*#__PURE__*/React.createElement(Tabs.TabPane, {
|
|
24
|
+
tab: "\u6700\u8FD1",
|
|
25
|
+
key: "1"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(PickerShortcut, {
|
|
27
|
+
selectRange: selectRange,
|
|
28
|
+
selectRangeUnit: selectRangeUnit
|
|
29
|
+
})), /*#__PURE__*/React.createElement(Tabs.TabPane, {
|
|
30
|
+
tab: "\u81EA\u5B9A\u4E49",
|
|
31
|
+
key: "2"
|
|
32
|
+
}, /*#__PURE__*/React.createElement(BizDate, _objectSpread({
|
|
33
|
+
ref: ref
|
|
34
|
+
}, props)), /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "".concat(classPrefix, "-popoverContent-btns")
|
|
36
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
return setOpen(false);
|
|
39
|
+
}
|
|
40
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(Button, {
|
|
41
|
+
type: "primary",
|
|
42
|
+
onClick: function onClick() {
|
|
43
|
+
if (ref.current) {
|
|
44
|
+
var _ref$current;
|
|
45
|
+
var dateValue = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getDateValue();
|
|
46
|
+
if (dateValue === null || dateValue === void 0 ? void 0 : dateValue.begin) {
|
|
47
|
+
setDateRange(dateValue);
|
|
48
|
+
}
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, "\u786E\u5B9A"))));
|
|
53
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
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 { DatePickerTypes } from './types';
|
|
9
|
+
import { classPrefix } from '.';
|
|
10
|
+
import DatePickerContext from './context';
|
|
11
|
+
import { DateOptionMap, getDateRange, getTypeList } from './utils';
|
|
12
|
+
import { Button, InputNumber } from 'antd';
|
|
13
|
+
import BizGlobalDataContext from '../context';
|
|
14
|
+
import moment from 'moment';
|
|
15
|
+
var PickerShortcut = function PickerShortcut(_ref) {
|
|
16
|
+
var selectRange = _ref.selectRange,
|
|
17
|
+
selectRangeUnit = _ref.selectRangeUnit,
|
|
18
|
+
timeRangeOpen = _ref.timeRangeOpen;
|
|
19
|
+
var _useContext = useContext(DatePickerContext),
|
|
20
|
+
currentType = _useContext.currentType,
|
|
21
|
+
includeToday = _useContext.includeToday,
|
|
22
|
+
relative = _useContext.relative,
|
|
23
|
+
setDateRange = _useContext.setDateRange,
|
|
24
|
+
setRelative = _useContext.setRelative,
|
|
25
|
+
setOpen = _useContext.setOpen;
|
|
26
|
+
var _useContext2 = useContext(BizGlobalDataContext),
|
|
27
|
+
envs = _useContext2.envs;
|
|
28
|
+
var list = getTypeList(currentType, includeToday);
|
|
29
|
+
var _useState = useState(),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
active = _useState2[0],
|
|
32
|
+
setActive = _useState2[1];
|
|
33
|
+
var _useState3 = useState(active),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
numbers = _useState4[0],
|
|
36
|
+
setNumbers = _useState4[1];
|
|
37
|
+
var _useState5 = useState(false),
|
|
38
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
+
isError = _useState6[0],
|
|
40
|
+
setIsError = _useState6[1];
|
|
41
|
+
useEffect(function () {
|
|
42
|
+
list = getTypeList(currentType, includeToday);
|
|
43
|
+
if (relative) {
|
|
44
|
+
setActive(relative[0]);
|
|
45
|
+
setNumbers(relative[0]);
|
|
46
|
+
}
|
|
47
|
+
}, [currentType, includeToday]);
|
|
48
|
+
function getMax() {
|
|
49
|
+
var _timeRangeOpen = timeRangeOpen || 12;
|
|
50
|
+
if (envs === null || envs === void 0 ? void 0 : envs.timeRangeOpen) {
|
|
51
|
+
_timeRangeOpen = typeof (envs === null || envs === void 0 ? void 0 : envs.timeRangeOpen) === 'boolean' ? (envs === null || envs === void 0 ? void 0 : envs.timeRangeOpen) ? 200 : 12 : envs === null || envs === void 0 ? void 0 : envs.timeRangeOpen;
|
|
52
|
+
}
|
|
53
|
+
_timeRangeOpen = moment.duration(_timeRangeOpen, 'months').asDays();
|
|
54
|
+
var selectRangeCount = moment.duration(selectRange, selectRangeUnit).asDays();
|
|
55
|
+
var count = selectRange ? _timeRangeOpen > selectRangeCount ? selectRangeCount : _timeRangeOpen : _timeRangeOpen;
|
|
56
|
+
var max = moment.duration(count, 'days').asDays();
|
|
57
|
+
var duration = moment.duration(count, 'days');
|
|
58
|
+
switch (currentType) {
|
|
59
|
+
case 'week':
|
|
60
|
+
max = Math.round(duration.asWeeks());
|
|
61
|
+
break;
|
|
62
|
+
case 'month':
|
|
63
|
+
max = Math.round(duration.asMonths());
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return max;
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "".concat(classPrefix, "-shortcut")
|
|
72
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "".concat(classPrefix, "-list")
|
|
74
|
+
}, list.map(function (item, index) {
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
key: index,
|
|
77
|
+
className: "".concat(classPrefix, "-item ").concat(active === item.count ? 'active' : ''),
|
|
78
|
+
onClick: function onClick() {
|
|
79
|
+
setActive(item.count);
|
|
80
|
+
if (setRelative) setRelative([item.count, includeToday ? 0 : 1]);
|
|
81
|
+
setDateRange === null || setDateRange === void 0 ? void 0 : setDateRange(getDateRange(currentType, item.count, includeToday));
|
|
82
|
+
setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
|
|
83
|
+
}
|
|
84
|
+
}, item.value);
|
|
85
|
+
})), ![DatePickerTypes.Unit.hour, DatePickerTypes.Unit.quarter].includes(currentType) && /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: "".concat(classPrefix, "-list-relative")
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
className: "".concat(classPrefix, "-list-relative-content")
|
|
89
|
+
}, /*#__PURE__*/React.createElement("span", null, "\u8FD1"), /*#__PURE__*/React.createElement(InputNumber, {
|
|
90
|
+
className: isError ? "".concat(classPrefix, "-input-error") : '',
|
|
91
|
+
min: 1,
|
|
92
|
+
max: getMax(),
|
|
93
|
+
controls: false,
|
|
94
|
+
style: {
|
|
95
|
+
width: '58px'
|
|
96
|
+
},
|
|
97
|
+
value: numbers,
|
|
98
|
+
onChange: function onChange(value) {
|
|
99
|
+
return setNumbers(value);
|
|
100
|
+
},
|
|
101
|
+
onBlur: function onBlur() {
|
|
102
|
+
if (numbers) {
|
|
103
|
+
setIsError(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}), /*#__PURE__*/React.createElement("span", null, Reflect.get(DateOptionMap, currentType))), /*#__PURE__*/React.createElement(Button, {
|
|
107
|
+
type: "primary",
|
|
108
|
+
onClick: function onClick() {
|
|
109
|
+
if (!numbers) {
|
|
110
|
+
setIsError(true);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
var date = getDateRange(currentType, numbers, includeToday);
|
|
114
|
+
setDateRange === null || setDateRange === void 0 ? void 0 : setDateRange(date);
|
|
115
|
+
setRelative === null || setRelative === void 0 ? void 0 : setRelative([numbers, includeToday ? 0 : 1]);
|
|
116
|
+
setOpen === null || setOpen === void 0 ? void 0 : setOpen(false);
|
|
117
|
+
}
|
|
118
|
+
}, "\u786E\u8BA4")));
|
|
119
|
+
};
|
|
120
|
+
export default PickerShortcut;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
@import '../../assets/styles/inner.less';
|
|
2
|
+
|
|
3
|
+
.biz-date-picker-old-wrap {
|
|
4
|
+
display: flex;
|
|
5
|
+
|
|
6
|
+
&-type {
|
|
7
|
+
width: 88px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&-shortcut {
|
|
11
|
+
display: flex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&-list {
|
|
15
|
+
display: flex;
|
|
16
|
+
// margin: 0 16px 0 0;
|
|
17
|
+
|
|
18
|
+
&-relative {
|
|
19
|
+
display: flex;
|
|
20
|
+
gap: 24px;
|
|
21
|
+
align-items: center;
|
|
22
|
+
margin-left: 16px;
|
|
23
|
+
|
|
24
|
+
&-content {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
span {
|
|
28
|
+
margin: 0 8px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.ant-input-number {
|
|
32
|
+
background-color: #fff !important;
|
|
33
|
+
border: 1px solid var(---, #ecedf0);
|
|
34
|
+
border-radius: 4px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.biz-select-handle {
|
|
41
|
+
margin-right: 8px;
|
|
42
|
+
padding: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-item {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
width: 58px;
|
|
50
|
+
height: @height-base;
|
|
51
|
+
color: @text-color-secondary;
|
|
52
|
+
border: 1px solid @border-color-base;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
|
|
55
|
+
&:first-child {
|
|
56
|
+
border-radius: @border-radius-small 0px 0px @border-radius-small;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:last-child {
|
|
60
|
+
border-radius: 0px @border-radius-small @border-radius-small 0px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
.__default-hover();
|
|
65
|
+
border-color: @border-color-base;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&.active {
|
|
69
|
+
color: @primary-color;
|
|
70
|
+
background: @primary-color-hover;
|
|
71
|
+
border: 1px solid @primary-color;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&-input {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
gap: 4px;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: space-between;
|
|
81
|
+
width: 262px;
|
|
82
|
+
padding: 0px 12px;
|
|
83
|
+
font-size: 14px;
|
|
84
|
+
background: #fff;
|
|
85
|
+
border: 1px solid var(---, #ecedf0);
|
|
86
|
+
border-radius: 4px;
|
|
87
|
+
|
|
88
|
+
&-label {
|
|
89
|
+
display: flex;
|
|
90
|
+
gap: 4px;
|
|
91
|
+
align-items: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&:hover {
|
|
95
|
+
// color: #165dff;
|
|
96
|
+
border-color: @primary-color;
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&:focus {
|
|
101
|
+
border-color: @primary-color;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&:active {
|
|
105
|
+
border-color: @primary-color;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&-active {
|
|
109
|
+
border-color: @primary-color;
|
|
110
|
+
box-shadow: 0 0 0 4px #f0f7ff;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&-popover {
|
|
114
|
+
padding-top: 0 !important;
|
|
115
|
+
.ant-popover-arrow {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ant-popover-inner-content {
|
|
120
|
+
padding: 0 16px 16px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.ant-picker-dropdown {
|
|
124
|
+
padding-top: 0;
|
|
125
|
+
|
|
126
|
+
.ant-picker-range-arrow {
|
|
127
|
+
display: none;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ant-tabs-top > .ant-tabs-nav::before {
|
|
132
|
+
border-bottom: 1px solid #fafafb;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ant-tabs-tab {
|
|
136
|
+
padding: 12px 0 !important;
|
|
137
|
+
font-size: 14px !important;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.ant-popover-inner {
|
|
141
|
+
background: #fff;
|
|
142
|
+
border-radius: 8px;
|
|
143
|
+
box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&-error {
|
|
148
|
+
position: relative;
|
|
149
|
+
border: 1px solid var(--io-Error-E-, #fb5547) !important;
|
|
150
|
+
|
|
151
|
+
&::after {
|
|
152
|
+
position: absolute;
|
|
153
|
+
width: 67px;
|
|
154
|
+
color: red;
|
|
155
|
+
font-size: 12px;
|
|
156
|
+
content: '请输入内容';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&-panel {
|
|
162
|
+
& div:last-of-type {
|
|
163
|
+
position: relative !important;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.ant-picker-panel-container {
|
|
167
|
+
background: #fff;
|
|
168
|
+
border: 1px solid var(--io-n-02, #fafafb);
|
|
169
|
+
border-radius: 10px;
|
|
170
|
+
box-shadow: none;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.ant-picker-panel-container .ant-picker-panel-focused {
|
|
174
|
+
border-color: var(--io-n-02, #fafafb);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&-popoverContent-btns {
|
|
179
|
+
display: flex;
|
|
180
|
+
gap: 16px;
|
|
181
|
+
justify-content: flex-end;
|
|
182
|
+
padding-top: 16px;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare namespace DatePickerTypes {
|
|
2
|
+
enum Unit {
|
|
3
|
+
'hour' = "hour",
|
|
4
|
+
'day' = "day",
|
|
5
|
+
'week' = "week",
|
|
6
|
+
'month' = "month",
|
|
7
|
+
'quarter' = "quarter",
|
|
8
|
+
'custom' = "custom"
|
|
9
|
+
}
|
|
10
|
+
interface Range {
|
|
11
|
+
begin?: string;
|
|
12
|
+
end?: string;
|
|
13
|
+
}
|
|
14
|
+
interface Value extends Range {
|
|
15
|
+
unit: Unit;
|
|
16
|
+
relative?: [number, number];
|
|
17
|
+
}
|
|
18
|
+
interface Props {
|
|
19
|
+
defaultValue?: Value;
|
|
20
|
+
value?: Value;
|
|
21
|
+
includeToday?: boolean;
|
|
22
|
+
selectRange?: number;
|
|
23
|
+
timeRangeOpen?: number;
|
|
24
|
+
selectRangeUnit?: 'days' | 'weeks' | 'months' | 'quarter';
|
|
25
|
+
onChange?: (data: Value) => void;
|
|
26
|
+
onOpenChange?: (data: boolean) => void;
|
|
27
|
+
dateTypeList?: Unit[];
|
|
28
|
+
}
|
|
29
|
+
interface Option {
|
|
30
|
+
label: string;
|
|
31
|
+
value: Unit;
|
|
32
|
+
children: ListOption[];
|
|
33
|
+
}
|
|
34
|
+
interface ListOption {
|
|
35
|
+
count: number;
|
|
36
|
+
value: string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var DatePickerTypes;
|
|
2
|
+
(function (DatePickerTypes) {
|
|
3
|
+
var Unit;
|
|
4
|
+
(function (Unit) {
|
|
5
|
+
Unit["hour"] = "hour";
|
|
6
|
+
Unit["day"] = "day";
|
|
7
|
+
Unit["week"] = "week";
|
|
8
|
+
Unit["month"] = "month";
|
|
9
|
+
Unit["quarter"] = "quarter";
|
|
10
|
+
Unit["custom"] = "custom";
|
|
11
|
+
})(Unit = DatePickerTypes.Unit || (DatePickerTypes.Unit = {}));
|
|
12
|
+
})(DatePickerTypes || (DatePickerTypes = {}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { DatePickerTypes } from './types';
|
|
3
|
+
export declare const getDateRange: (type: DatePickerTypes.Unit, count: number, includeToday: boolean) => {
|
|
4
|
+
begin: string;
|
|
5
|
+
end: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const isTodayInRange: (_startDate: moment.Moment, _endDate: moment.Moment) => boolean;
|
|
8
|
+
export declare const getTypeList: (currentType: DatePickerTypes.Unit, includeToday: boolean) => DatePickerTypes.ListOption[];
|
|
9
|
+
export declare const DateOptionMap: {
|
|
10
|
+
day: string;
|
|
11
|
+
week: string;
|
|
12
|
+
month: string;
|
|
13
|
+
quarter: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const DateMaxMap: {
|
|
16
|
+
day: number;
|
|
17
|
+
week: number;
|
|
18
|
+
month: number;
|
|
19
|
+
quarter: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const DateSingleMap: {
|
|
22
|
+
day: number;
|
|
23
|
+
days: number;
|
|
24
|
+
week: number;
|
|
25
|
+
weeks: number;
|
|
26
|
+
month: number;
|
|
27
|
+
months: number;
|
|
28
|
+
quarter: number;
|
|
29
|
+
quarters: number;
|
|
30
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { DatePickerTypes } from './types';
|
|
3
|
+
function getAbsoluteDate(unit, count, maxDate) {
|
|
4
|
+
var res = {};
|
|
5
|
+
switch (unit) {
|
|
6
|
+
case DatePickerTypes.Unit.hour:
|
|
7
|
+
res.endDate = res.startDate = moment().subtract(count, 'days').toDate();
|
|
8
|
+
break;
|
|
9
|
+
case DatePickerTypes.Unit.day:
|
|
10
|
+
res.startDate = moment().subtract(count, 'days').toDate();
|
|
11
|
+
count == 1 ? res.endDate = moment().subtract(count, 'days').toDate() : res.endDate = maxDate;
|
|
12
|
+
break;
|
|
13
|
+
case DatePickerTypes.Unit.week:
|
|
14
|
+
res.endDate = maxDate;
|
|
15
|
+
res.startDate = moment(maxDate).subtract(count, 'weeks').toDate();
|
|
16
|
+
break;
|
|
17
|
+
case DatePickerTypes.Unit.month:
|
|
18
|
+
res.endDate = maxDate;
|
|
19
|
+
res.startDate = moment(maxDate).subtract(count, 'months').add(1, 'days').toDate();
|
|
20
|
+
break;
|
|
21
|
+
case DatePickerTypes.Unit.quarter:
|
|
22
|
+
res.endDate = maxDate;
|
|
23
|
+
res.startDate = moment(maxDate).subtract(count, 'quarters').add(1, 'days').toDate();
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
export var getDateRange = function getDateRange(type, count, includeToday) {
|
|
29
|
+
var maxDate = moment().subtract(includeToday || count == 0 ? 0 : 1, 'days').toDate();
|
|
30
|
+
var res = getAbsoluteDate(type, count, maxDate);
|
|
31
|
+
return {
|
|
32
|
+
begin: moment(res.startDate).format('YYYY-MM-DD'),
|
|
33
|
+
end: moment(res.endDate).format('YYYY-MM-DD')
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export var isTodayInRange = function isTodayInRange(_startDate, _endDate) {
|
|
37
|
+
var startDate = _startDate.format('x');
|
|
38
|
+
var endDate = moment(_endDate).add(1, 'days').format('x');
|
|
39
|
+
var dateToCheck = moment(new Date()).format('x');
|
|
40
|
+
return dateToCheck >= startDate && dateToCheck <= endDate;
|
|
41
|
+
};
|
|
42
|
+
export var getTypeList = function getTypeList(currentType, includeToday) {
|
|
43
|
+
var _shortcuts$find;
|
|
44
|
+
var shortcuts = [{
|
|
45
|
+
label: '按小时',
|
|
46
|
+
value: DatePickerTypes.Unit.hour,
|
|
47
|
+
children: [{
|
|
48
|
+
value: '昨天',
|
|
49
|
+
count: 1
|
|
50
|
+
}, {
|
|
51
|
+
value: '前天',
|
|
52
|
+
count: 2
|
|
53
|
+
}]
|
|
54
|
+
}, {
|
|
55
|
+
label: '按天',
|
|
56
|
+
value: DatePickerTypes.Unit.day,
|
|
57
|
+
children: [{
|
|
58
|
+
value: '7天',
|
|
59
|
+
count: 7
|
|
60
|
+
}, {
|
|
61
|
+
value: '14天',
|
|
62
|
+
count: 14
|
|
63
|
+
}, {
|
|
64
|
+
value: '30天',
|
|
65
|
+
count: 30
|
|
66
|
+
}]
|
|
67
|
+
}, {
|
|
68
|
+
label: '按周',
|
|
69
|
+
value: DatePickerTypes.Unit.week,
|
|
70
|
+
children: [{
|
|
71
|
+
value: '4周',
|
|
72
|
+
count: 4
|
|
73
|
+
}, {
|
|
74
|
+
value: '8周',
|
|
75
|
+
count: 8
|
|
76
|
+
}, {
|
|
77
|
+
value: '12周',
|
|
78
|
+
count: 12
|
|
79
|
+
}]
|
|
80
|
+
}, {
|
|
81
|
+
label: '按月',
|
|
82
|
+
value: DatePickerTypes.Unit.month,
|
|
83
|
+
children: [{
|
|
84
|
+
value: '1个月',
|
|
85
|
+
count: 1
|
|
86
|
+
}, {
|
|
87
|
+
value: '2个月',
|
|
88
|
+
count: 2
|
|
89
|
+
}, {
|
|
90
|
+
value: '3个月',
|
|
91
|
+
count: 3
|
|
92
|
+
}]
|
|
93
|
+
}, {
|
|
94
|
+
label: '按季度',
|
|
95
|
+
value: DatePickerTypes.Unit.quarter,
|
|
96
|
+
children: [{
|
|
97
|
+
value: '1季度',
|
|
98
|
+
count: 1
|
|
99
|
+
}, {
|
|
100
|
+
value: '2季度',
|
|
101
|
+
count: 2
|
|
102
|
+
}, {
|
|
103
|
+
value: '4季度',
|
|
104
|
+
count: 4
|
|
105
|
+
}]
|
|
106
|
+
}];
|
|
107
|
+
var list = (((_shortcuts$find = shortcuts.find(function (item) {
|
|
108
|
+
return item.value === currentType;
|
|
109
|
+
})) === null || _shortcuts$find === void 0 ? void 0 : _shortcuts$find.children) || []).filter(function (item) {
|
|
110
|
+
if (currentType === 'day') {
|
|
111
|
+
if (!includeToday && (item.count === 0 || item.count === 1)) return false;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
return list;
|
|
117
|
+
};
|
|
118
|
+
export var DateOptionMap = {
|
|
119
|
+
day: '天',
|
|
120
|
+
week: '周',
|
|
121
|
+
month: '个月',
|
|
122
|
+
quarter: '个季度'
|
|
123
|
+
};
|
|
124
|
+
export var DateMaxMap = {
|
|
125
|
+
day: 365,
|
|
126
|
+
week: 52,
|
|
127
|
+
month: 12,
|
|
128
|
+
quarter: 4
|
|
129
|
+
};
|
|
130
|
+
export var DateSingleMap = {
|
|
131
|
+
day: 1,
|
|
132
|
+
days: 1,
|
|
133
|
+
week: 7,
|
|
134
|
+
weeks: 7,
|
|
135
|
+
month: 30,
|
|
136
|
+
months: 30,
|
|
137
|
+
quarter: 91,
|
|
138
|
+
quarters: 91
|
|
139
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -48,7 +48,8 @@ import useChanged from './hooks/useChanged';
|
|
|
48
48
|
import useSubject from './hooks/useSubject';
|
|
49
49
|
import BizPlatformSelector from './platformSelector';
|
|
50
50
|
import DataSetGroup from './dataSetGroup';
|
|
51
|
-
|
|
51
|
+
import BizDatePickerV2 from './datePickerV2';
|
|
52
|
+
export { BizTargetDimension, BizTargetFromPanel, BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizLayout, BizAnalysisLayout, BizDetailLayout, BizUserGroup, BizUserGroupHeader, IconFont, ColorIcon, BizFormulaTarget, BizAUMFormulaTarget, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetFromPanelContext, BizTargetCondition, BizDatePicker, BizQuickDatePicker, BizLoading, BizConditionItem, BizConditionGroup, BizAttrCondition, BizAttrConditionGroup, BizUserCondition, BizProductCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, base64, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, chartColors, useBizStore, useChanged, useSubject, DataSetGroup, BizDatePickerV2, BizPlatformSelector, };
|
|
52
53
|
export type { UserGroupTypes } from './userGroup/types';
|
|
53
54
|
export type { BizProductConditionT } from './productCondition/types';
|
|
54
55
|
export type { BizSelectTypes } from './select/types';
|
package/es/index.js
CHANGED
|
@@ -47,4 +47,5 @@ import useChanged from './hooks/useChanged';
|
|
|
47
47
|
import useSubject from './hooks/useSubject';
|
|
48
48
|
import BizPlatformSelector from './platformSelector';
|
|
49
49
|
import DataSetGroup from './dataSetGroup';
|
|
50
|
-
|
|
50
|
+
import BizDatePickerV2 from './datePickerV2';
|
|
51
|
+
export { BizTargetDimension, BizTargetFromPanel, BizSearchInput, BizSelect, BizDialog, BizChart, BizTable, BizLayout, BizAnalysisLayout, BizDetailLayout, BizUserGroup, BizUserGroupHeader, IconFont, ColorIcon, BizFormulaTarget, BizAUMFormulaTarget, BizTargetSelector, BizEventSelector, BizAttributeSelector, BizGlobalDataContext, BizTargetFromPanelContext, BizTargetCondition, BizDatePicker, BizQuickDatePicker, BizLoading, BizConditionItem, BizConditionGroup, BizAttrCondition, BizAttrConditionGroup, BizUserCondition, BizProductCondition, BizAddToScene, BizAddToPanel, BizCycleTime, BizDnd, BizLoginForm, DemoWrapper, SocketClient, ajax, util, base64, theme, convertAttributeData, BizUserTagsSelect, setGlobalConfig, chartColors, useBizStore, useChanged, useSubject, DataSetGroup, BizDatePickerV2, BizPlatformSelector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.53",
|
|
4
4
|
"module": "es/index.js",
|
|
5
5
|
"typings": "es/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/lodash": "^4.14.182",
|
|
46
46
|
"@umijs/fabric": "^2.8.1",
|
|
47
47
|
"@umijs/test": "^3.0.5",
|
|
48
|
-
"antd": "
|
|
48
|
+
"antd": "4.24.16",
|
|
49
49
|
"dumi": "^1.1.0",
|
|
50
50
|
"father-build": "^1.17.2",
|
|
51
51
|
"gh-pages": "^3.0.0",
|
|
@@ -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": "ba9a9d18dfdcab3ac09e1b55b17d549a04b29045",
|
|
59
59
|
"gitHooks": {
|
|
60
60
|
"pre-commit": "lint-staged"
|
|
61
61
|
}
|