@chaoswise/ui 2.3.0 → 2.3.1
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/lib/Button/index.js +0 -8
- package/lib/CWCascader/index.js +56 -1
- package/lib/CWCascader/index.less +22 -0
- package/lib/CWCascader/rc-cascader/Cascader.js +45 -21
- package/lib/CWCascader/rc-cascader/OptionList/Column.js +115 -48
- package/lib/CWCascader/rc-cascader/OptionList/index.js +11 -5
- package/lib/CWCascader/rc-cascader/OptionList/useKeyboard.js +64 -68
- package/lib/CWCascader/rc-cascader/hooks/useDisplayValues.js +45 -16
- package/lib/CWCascader/rc-cascader/hooks/useEntities.js +0 -8
- package/lib/CWCascader/rc-cascader/utils/treeUtil.js +45 -1
- package/lib/CWRangePicker/DropdownMenu/index.js +1 -1
- package/lib/CWRangePicker/DropdownMenu/index.less +11 -7
- package/lib/CWRangePicker/index.js +24 -28
- package/lib/CWSelect/index.less +1 -1
- package/lib/Cascader/index.less +20 -2
- package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.js +46 -0
- package/lib/DropdownDatePicker/DropdownMenu/MoreTimeList/index.less +14 -0
- package/lib/DropdownDatePicker/DropdownMenu/index.js +126 -0
- package/lib/DropdownDatePicker/DropdownMenu/index.less +68 -0
- package/lib/DropdownDatePicker/assets/Calendar2.js +15 -0
- package/lib/DropdownDatePicker/assets/live.js +19 -0
- package/lib/DropdownDatePicker/assets/more.js +23 -0
- package/lib/DropdownDatePicker/index.js +281 -0
- package/lib/DropdownDatePicker/index.less +34 -0
- package/lib/DropdownDatePicker/locale/en_US.js +20 -0
- package/lib/DropdownDatePicker/locale/index.js +12 -0
- package/lib/DropdownDatePicker/locale/zh_CN.js +20 -0
- package/lib/DropdownDatePicker/utils/index.js +247 -0
- package/lib/InputNumber/index.js +15 -11
- package/lib/ModuleFederation/ErrorBoundary/index.js +54 -0
- package/lib/ModuleFederation/index.js +10 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/RemoteComponent.js +185 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/attach-script.js +42 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/index.js +1 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/load-module.js +44 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/loading-script.js +35 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/suspend.js +28 -0
- package/lib/ModuleFederation/react-dynamic-remote-component/utils.js +7 -0
- package/lib/QuickTransfer/locale/index.js +1 -4
- package/lib/QuickTransfer/locale/zh_CN.js +0 -8
- package/package.json +3 -2
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
import _Dropdown from "@chaoswise/ui/lib/Antd/Dropdown";
|
|
3
|
+
import _Icon from "@chaoswise/ui/lib/Antd/Icon";
|
|
4
|
+
import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
|
|
5
|
+
var _excluded = ["timeDomain", "number", "unit", "value", "isRecently"];
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
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); }
|
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
+
import React from "react";
|
|
14
|
+
import classnames from "classnames";
|
|
15
|
+
import { getLocale } from "../locale";
|
|
16
|
+
import Calendar2Svg from "../assets/Calendar2";
|
|
17
|
+
import LiveSvg from "../assets/live";
|
|
18
|
+
import MoreSvg from "../assets/more";
|
|
19
|
+
import MoreTimeList from "./MoreTimeList";
|
|
20
|
+
import { funcValueChangeArrayValue, getCorrectValue } from "../utils";
|
|
21
|
+
import _ from "lodash";
|
|
22
|
+
import "./index.less";
|
|
23
|
+
var DropdownMenu = function DropdownMenu(props) {
|
|
24
|
+
var dataSource = props.dataSource,
|
|
25
|
+
regroupDataSource = props.regroupDataSource,
|
|
26
|
+
setIsCalendar = props.setIsCalendar,
|
|
27
|
+
recordDateValue = props.recordDateValue,
|
|
28
|
+
setRecordDateValue = props.setRecordDateValue,
|
|
29
|
+
_value = props.value,
|
|
30
|
+
onChange = props.onChange,
|
|
31
|
+
menuOption = props.menuOption,
|
|
32
|
+
setIsFocus = props.setIsFocus;
|
|
33
|
+
var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
|
|
34
|
+
_ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
|
|
35
|
+
locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
|
|
36
|
+
var localeObj = getLocale(locale);
|
|
37
|
+
var _menuOption$showCalen = menuOption.showCalendar,
|
|
38
|
+
showCalendar = _menuOption$showCalen === void 0 ? true : _menuOption$showCalen,
|
|
39
|
+
_menuOption$showDefau = menuOption.showDefaultCount,
|
|
40
|
+
showDefaultCount = _menuOption$showDefau === void 0 ? 8 : _menuOption$showDefau,
|
|
41
|
+
_menuOption$moreItemD = menuOption.moreItemDropdownPosition,
|
|
42
|
+
moreItemDropdownPosition = _menuOption$moreItemD === void 0 ? "left" : _menuOption$moreItemD;
|
|
43
|
+
// 点击Menu.Item中切换选项列表
|
|
44
|
+
var onClickItem = function onClickItem(item) {
|
|
45
|
+
var timeDomain = recordDateValue.timeDomain,
|
|
46
|
+
number = recordDateValue.number,
|
|
47
|
+
unit = recordDateValue.unit,
|
|
48
|
+
value = recordDateValue.value,
|
|
49
|
+
isRecently = recordDateValue.isRecently,
|
|
50
|
+
rest = _objectWithoutProperties(recordDateValue, _excluded);
|
|
51
|
+
setIsFocus(false);
|
|
52
|
+
var values = item.value;
|
|
53
|
+
if (item.key !== recordDateValue.key) {
|
|
54
|
+
var returnValue = _objectSpread(_objectSpread({}, item), {}, {
|
|
55
|
+
value: funcValueChangeArrayValue(values)
|
|
56
|
+
});
|
|
57
|
+
returnValue = getCorrectValue(returnValue, item.key);
|
|
58
|
+
onChange(returnValue);
|
|
59
|
+
if (!_value) {
|
|
60
|
+
setRecordDateValue(returnValue);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// 点击切换为日历
|
|
65
|
+
var onClickSelectCalendar = function onClickSelectCalendar(e) {
|
|
66
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
67
|
+
setIsCalendar(true);
|
|
68
|
+
};
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: classnames("cw-dropdown-date-picker-dropdown-menu-wrapper")
|
|
71
|
+
}, dataSource === null || dataSource === void 0 ? void 0 : dataSource.slice(0, showDefaultCount).map(function (item) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: classnames("cw-dropdown-date-picker-dropdown-menu-_item", {
|
|
74
|
+
"cw-dropdown-date-picker-dropdown-menu-item-selected": (recordDateValue === null || recordDateValue === void 0 ? void 0 : recordDateValue.key) === item.key
|
|
75
|
+
}),
|
|
76
|
+
key: item.key,
|
|
77
|
+
onClick: function onClick() {
|
|
78
|
+
return onClickItem(item);
|
|
79
|
+
}
|
|
80
|
+
}, item.icon ? item.icon : /*#__PURE__*/React.createElement(LiveSvg, null), /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
style: {
|
|
82
|
+
marginLeft: "4px"
|
|
83
|
+
}
|
|
84
|
+
}, item.render ? item.render(item) : item.title));
|
|
85
|
+
}), (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) > showDefaultCount && /*#__PURE__*/React.createElement(_Dropdown, {
|
|
86
|
+
overlay: /*#__PURE__*/React.createElement(MoreTimeList, {
|
|
87
|
+
regroupDataSource: regroupDataSource,
|
|
88
|
+
recordDateValue: recordDateValue,
|
|
89
|
+
onClickItem: onClickItem
|
|
90
|
+
}),
|
|
91
|
+
overlayClassName: classnames("cw-dropdown-date-picker-dropdown-menu-more-wrapper", {
|
|
92
|
+
"cw-dropdown-date-picker-dropdown-menu-more-wrapper-left": moreItemDropdownPosition === "left"
|
|
93
|
+
}),
|
|
94
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
95
|
+
return triggerNode;
|
|
96
|
+
}
|
|
97
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
className: classnames("cw-dropdown-date-picker-dropdown-menu-_item", "cw-dropdown-date-picker-dropdown-menu-item-more")
|
|
99
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
style: {
|
|
101
|
+
display: "flex",
|
|
102
|
+
alignItems: "center"
|
|
103
|
+
}
|
|
104
|
+
}, /*#__PURE__*/React.createElement(MoreSvg, {
|
|
105
|
+
className: "cw-range-picker-prefix-icon"
|
|
106
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
107
|
+
style: {
|
|
108
|
+
marginLeft: "4px"
|
|
109
|
+
}
|
|
110
|
+
}, localeObj.more)), /*#__PURE__*/React.createElement(_Icon, {
|
|
111
|
+
type: "right"
|
|
112
|
+
}))), showCalendar && /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: classnames("cw-dropdown-date-picker-dropdown-menu-_item"),
|
|
114
|
+
key: "unique-calendar",
|
|
115
|
+
onClick: onClickSelectCalendar
|
|
116
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
className: "cw-range-picker-menu-item-calendar"
|
|
118
|
+
}, /*#__PURE__*/React.createElement(Calendar2Svg, {
|
|
119
|
+
className: "cw-range-picker-prefix-icon"
|
|
120
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
121
|
+
style: {
|
|
122
|
+
marginLeft: "4px"
|
|
123
|
+
}
|
|
124
|
+
}, localeObj["select-calendar"])));
|
|
125
|
+
};
|
|
126
|
+
export default DropdownMenu;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
@dropdown-prefix-cls: ~'@{ant-prefix}-dropdown';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
.cw-dropdown-date-picker-dropdown-menu-wrapper {
|
|
5
|
+
width: 360px;
|
|
6
|
+
padding: @dropdown-edge-child-vertical-padding 0;
|
|
7
|
+
text-align: left;
|
|
8
|
+
list-style-type: none;
|
|
9
|
+
box-shadow: @box-shadow-base;
|
|
10
|
+
background-color: @component-background;
|
|
11
|
+
border-radius: @border-radius-base;
|
|
12
|
+
outline: none;
|
|
13
|
+
background-clip: padding-box;
|
|
14
|
+
-webkit-transform: translate3d(0, 0, 0);
|
|
15
|
+
position: relative;
|
|
16
|
+
|
|
17
|
+
.cw-dropdown-date-picker-dropdown-menu-_item {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
padding: @dropdown-vertical-padding @control-padding-horizontal;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
transition: all 0.3s;
|
|
26
|
+
color: @text-color;
|
|
27
|
+
font-weight: normal;
|
|
28
|
+
font-size: @dropdown-font-size;
|
|
29
|
+
line-height: @dropdown-line-height;
|
|
30
|
+
|
|
31
|
+
.cw-range-picker-menu-item-calendar {
|
|
32
|
+
width: 14px;
|
|
33
|
+
height: 14px;
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.cw-dropdown-date-picker-dropdown-menu-item-selected {
|
|
40
|
+
background-color: @select-selected-enable-bg;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: @select-selected-enable-bg;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.cw-dropdown-date-picker-dropdown-menu-item-more {
|
|
49
|
+
position: relative;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
overflow: visible;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
.cw-dropdown-date-picker-dropdown-menu-more-wrapper {
|
|
57
|
+
width: 384px;
|
|
58
|
+
bottom: -30px !important;
|
|
59
|
+
top: auto !important;
|
|
60
|
+
left: calc(100% + 2px) !important;
|
|
61
|
+
box-shadow: @box-shadow-base;
|
|
62
|
+
|
|
63
|
+
&.cw-dropdown-date-picker-dropdown-menu-more-wrapper-left {
|
|
64
|
+
right: calc(100% + 2px) !important;
|
|
65
|
+
left: auto !important;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var SvgCalendar = function SvgCalendar(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
width: 12,
|
|
6
|
+
height: 12,
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
9
|
+
d: "M11.031 1.516H8.734V.64a.11.11 0 0 0-.109-.11h-.766a.11.11 0 0 0-.109.11v.875h-3.5V.64a.11.11 0 0 0-.11-.11h-.765a.11.11 0 0 0-.11.11v.875H.97a.437.437 0 0 0-.438.437v9.078c0 .242.196.438.438.438H11.03a.437.437 0 0 0 .438-.438V1.953a.437.437 0 0 0-.438-.437Zm-.547 8.968H1.516V5.29h8.968v5.195ZM1.516 4.36V2.5h1.75v.656c0 .06.049.11.109.11h.766c.06 0 .109-.05.109-.11V2.5h3.5v.656c0 .06.05.11.11.11h.765c.06 0 .11-.05.11-.11V2.5h1.75v1.86h-8.97Z",
|
|
10
|
+
fillOpacity: 0.45,
|
|
11
|
+
fill: "currentColor",
|
|
12
|
+
fillRule: "evenodd"
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
export default SvgCalendar;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var SvgLive = function SvgLive(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
width: 14,
|
|
6
|
+
height: 14,
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
8
|
+
}, props), /*#__PURE__*/React.createElement("g", {
|
|
9
|
+
fill: "none",
|
|
10
|
+
fillRule: "evenodd"
|
|
11
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
12
|
+
d: "M0 0h14v14H0z"
|
|
13
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
14
|
+
d: "M6.937.564a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13Zm1.189 2.507-4.37 3.973c-.151.138-.037.364.186.364h1.736c.156 0 .276.12.25.25l-.618 3.217c-.04.21.266.338.438.183l4.37-3.973c.152-.139.037-.364-.186-.364H8.196c-.157 0-.276-.12-.25-.251l.617-3.217c.041-.21-.265-.338-.437-.182Z",
|
|
15
|
+
fill: "#52c41a",
|
|
16
|
+
fillRule: "nonzero"
|
|
17
|
+
})));
|
|
18
|
+
};
|
|
19
|
+
export default SvgLive;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/*
|
|
3
|
+
* @Author: andrew.qiao andrew.qiao@cloudwise.com
|
|
4
|
+
* @Date: 2022-09-13 17:59:38
|
|
5
|
+
* @LastEditors: andrew.qiao andrew.qiao@cloudwise.com
|
|
6
|
+
* @LastEditTime: 2022-10-25 14:46:23
|
|
7
|
+
* @FilePath: /change_01/aops_web_commons/packages/ui/components/CWRangePicker/assets/more.js
|
|
8
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
9
|
+
*/
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
var SvgMore = function SvgMore(props) {
|
|
12
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
13
|
+
width: 14,
|
|
14
|
+
height: 14,
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
16
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
17
|
+
d: "M7 .875a6.125 6.125 0 1 1 0 12.25A6.125 6.125 0 0 1 7 .876Zm0 1.04a5.087 5.087 0 1 0 .002 10.173A5.087 5.087 0 0 0 7 1.914ZM7 6.22a.766.766 0 1 1 0 1.531.766.766 0 0 1 0-1.531Zm3.828 0a.766.766 0 1 1 0 1.531.766.766 0 0 1 0-1.531Zm-8.039.102a.766.766 0 1 1 .766 1.326.766.766 0 0 1-.766-1.326Z",
|
|
18
|
+
fillOpacity: 0.45,
|
|
19
|
+
fill: "currentColor",
|
|
20
|
+
fillRule: "evenodd"
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
export default SvgMore;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import _Dropdown from "@chaoswise/ui/lib/Antd/Dropdown";
|
|
2
|
+
import "@chaoswise/ui/lib/Input/index.less";
|
|
3
|
+
import _Input from "@chaoswise/ui/lib/Input";
|
|
4
|
+
import "@chaoswise/ui/lib/DatePicker/index.less";
|
|
5
|
+
import _DatePicker from "@chaoswise/ui/lib/DatePicker";
|
|
6
|
+
import "@chaoswise/ui/lib/RangePicker/index.less";
|
|
7
|
+
import _RangePicker from "@chaoswise/ui/lib/RangePicker";
|
|
8
|
+
import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
|
|
9
|
+
var _excluded = ["inputPrefixIcon", "className"];
|
|
10
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
+
import React, { forwardRef, useState, useEffect, useMemo, useRef } from "react";
|
|
20
|
+
import PropTypes from "prop-types";
|
|
21
|
+
import classnames from "classnames";
|
|
22
|
+
import DropDownMenu from "./DropdownMenu";
|
|
23
|
+
import LiveSvg from "./assets/live";
|
|
24
|
+
import { regroupDataSourceFn, echoInputValue } from "./utils";
|
|
25
|
+
import moment from "moment";
|
|
26
|
+
import "./index.less";
|
|
27
|
+
var DropdownDatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
28
|
+
var defaultValue = props.defaultValue,
|
|
29
|
+
value = props.value,
|
|
30
|
+
_props$dataSource = props.dataSource,
|
|
31
|
+
dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
|
|
32
|
+
classNameWrapper = props.classNameWrapper,
|
|
33
|
+
_props$onChange = props.onChange,
|
|
34
|
+
_onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
|
|
35
|
+
_props$inputOption = props.inputOption,
|
|
36
|
+
inputOption = _props$inputOption === void 0 ? {} : _props$inputOption,
|
|
37
|
+
_props$menuOption = props.menuOption,
|
|
38
|
+
menuOption = _props$menuOption === void 0 ? {} : _props$menuOption,
|
|
39
|
+
_props$format = props.format,
|
|
40
|
+
format = _props$format === void 0 ? "YYYY/MM/DD HH:mm:ss" : _props$format,
|
|
41
|
+
recordDateValueRender = props.recordDateValueRender;
|
|
42
|
+
var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
|
|
43
|
+
_ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
|
|
44
|
+
locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
|
|
45
|
+
var _menuOption$showCalen = menuOption.showCalendar,
|
|
46
|
+
showCalendar = _menuOption$showCalen === void 0 ? true : _menuOption$showCalen,
|
|
47
|
+
_menuOption$isRangePi = menuOption.isRangePickerCalendar,
|
|
48
|
+
isRangePickerCalendar = _menuOption$isRangePi === void 0 ? true : _menuOption$isRangePi,
|
|
49
|
+
_menuOption$exceedSho = menuOption.exceedShowInMore,
|
|
50
|
+
exceedShowInMore = _menuOption$exceedSho === void 0 ? false : _menuOption$exceedSho,
|
|
51
|
+
_menuOption$showDefau = menuOption.showDefaultCount,
|
|
52
|
+
showDefaultCount = _menuOption$showDefau === void 0 ? 8 : _menuOption$showDefau,
|
|
53
|
+
dropdownClassName = menuOption.dropdownClassName,
|
|
54
|
+
_getPopupContainer = menuOption.getPopupContainer,
|
|
55
|
+
getPopupContainerCalendar = menuOption.getPopupContainerCalendar,
|
|
56
|
+
dropdownCalendarClassName = menuOption.dropdownCalendarClassName,
|
|
57
|
+
open = menuOption.open;
|
|
58
|
+
var inputPrefixIcon = inputOption.inputPrefixIcon,
|
|
59
|
+
inputWrapperClassName = inputOption.className,
|
|
60
|
+
_inputOption = _objectWithoutProperties(inputOption, _excluded);
|
|
61
|
+
// 输入框是否获取焦点
|
|
62
|
+
var _useState = useState(false),
|
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
64
|
+
isFocus = _useState2[0],
|
|
65
|
+
setIsFocus = _useState2[1];
|
|
66
|
+
// 输入框回填内容
|
|
67
|
+
var _useState3 = useState(""),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
inputValue = _useState4[0],
|
|
70
|
+
setInputValue = _useState4[1];
|
|
71
|
+
// 记录切换之后的时间项
|
|
72
|
+
var _useState5 = useState({}),
|
|
73
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
74
|
+
recordDateValue = _useState6[0],
|
|
75
|
+
setRecordDateValue = _useState6[1];
|
|
76
|
+
// 是否切换到日历选择
|
|
77
|
+
var _useState7 = useState(false),
|
|
78
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
79
|
+
isCalendar = _useState8[0],
|
|
80
|
+
setIsCalendar = _useState8[1];
|
|
81
|
+
// 特殊时间选择器外壳容器
|
|
82
|
+
var calendarRef = useRef(null);
|
|
83
|
+
// 初始时记录当前时间项
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
if (value) {
|
|
86
|
+
setRecordDateValue(value);
|
|
87
|
+
} else if (defaultValue) {
|
|
88
|
+
setRecordDateValue(defaultValue);
|
|
89
|
+
}
|
|
90
|
+
}, [defaultValue, value]);
|
|
91
|
+
// 输入框回显
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
setInputValue(echoInputValue(recordDateValue, locale, format, recordDateValueRender));
|
|
94
|
+
}, [recordDateValue, locale, format, isFocus, recordDateValueRender]);
|
|
95
|
+
|
|
96
|
+
// 点击空白处日历切换
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
document.addEventListener("click", clickBody);
|
|
99
|
+
return function () {
|
|
100
|
+
document.removeEventListener("click", clickBody);
|
|
101
|
+
};
|
|
102
|
+
}, []);
|
|
103
|
+
// 重组数据源
|
|
104
|
+
var regroupDataSource = useMemo(function () {
|
|
105
|
+
if (exceedShowInMore) {
|
|
106
|
+
return regroupDataSourceFn(dataSource);
|
|
107
|
+
}
|
|
108
|
+
return regroupDataSourceFn(dataSource.slice(showDefaultCount));
|
|
109
|
+
}, [dataSource, exceedShowInMore, showDefaultCount]);
|
|
110
|
+
// 日历模式下点击body
|
|
111
|
+
var clickBody = function clickBody(e) {
|
|
112
|
+
var targetCalendar = calendarRef.current.querySelector(".cw-dropdown-date-picker-calendar-wrapper");
|
|
113
|
+
var targetInput = calendarRef.current.querySelector(".cw-dropdown-date-picker-box-wrapper");
|
|
114
|
+
if (targetCalendar) {
|
|
115
|
+
if (!targetCalendar.contains(e.target)) {
|
|
116
|
+
setIsCalendar(false);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (targetInput) {
|
|
120
|
+
if (!targetInput.contains(e.target)) {
|
|
121
|
+
setIsFocus(false);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
// 输入框前缀图标,
|
|
126
|
+
var inputPrefix = /*#__PURE__*/React.createElement("div", {
|
|
127
|
+
className: classnames("cw-dropdown-date-picker-prefix-wrapper"),
|
|
128
|
+
onClick: function onClick() {
|
|
129
|
+
setIsFocus(false);
|
|
130
|
+
}
|
|
131
|
+
}, inputPrefixIcon ? inputPrefixIcon : /*#__PURE__*/React.createElement(LiveSvg, {
|
|
132
|
+
className: classnames("cw-dropdown-date-picker-prefix-icon")
|
|
133
|
+
}));
|
|
134
|
+
// 输入框获取焦点
|
|
135
|
+
var onInputFocus = function onInputFocus(e) {
|
|
136
|
+
setIsFocus(true);
|
|
137
|
+
};
|
|
138
|
+
var dropdownMenuProps = {
|
|
139
|
+
onChange: _onChange,
|
|
140
|
+
recordDateValue: recordDateValue,
|
|
141
|
+
setRecordDateValue: setRecordDateValue,
|
|
142
|
+
value: value,
|
|
143
|
+
dataSource: dataSource,
|
|
144
|
+
regroupDataSource: regroupDataSource,
|
|
145
|
+
setIsCalendar: setIsCalendar,
|
|
146
|
+
menuOption: menuOption,
|
|
147
|
+
setIsFocus: setIsFocus,
|
|
148
|
+
format: format
|
|
149
|
+
};
|
|
150
|
+
var renderInputDom = isCalendar && showCalendar ? isRangePickerCalendar ? /*#__PURE__*/React.createElement(_RangePicker, {
|
|
151
|
+
open: isCalendar,
|
|
152
|
+
className: classnames("cw-dropdown-date-picker-calendar-wrapper"),
|
|
153
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
154
|
+
return getPopupContainerCalendar ? getPopupContainerCalendar(triggerNode) : triggerNode.parentNode;
|
|
155
|
+
},
|
|
156
|
+
style: {
|
|
157
|
+
width: 0,
|
|
158
|
+
height: 0,
|
|
159
|
+
padding: 0,
|
|
160
|
+
border: 0,
|
|
161
|
+
overflow: "hidden"
|
|
162
|
+
},
|
|
163
|
+
dropdownClassName: classnames(dropdownCalendarClassName),
|
|
164
|
+
format: format,
|
|
165
|
+
onChange: function onChange(_value, mode) {
|
|
166
|
+
setIsCalendar(false);
|
|
167
|
+
setIsFocus(false);
|
|
168
|
+
if (_value) {
|
|
169
|
+
_onChange({
|
|
170
|
+
value: _value
|
|
171
|
+
});
|
|
172
|
+
if (!value) {
|
|
173
|
+
setRecordDateValue({
|
|
174
|
+
value: _value
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
defaultTimeOption: {
|
|
180
|
+
startTimeOption: moment("00:00:00", "HH:mm:ss"),
|
|
181
|
+
endTimeOption: moment("23:59:59", "HH:mm:ss")
|
|
182
|
+
},
|
|
183
|
+
showTime: {
|
|
184
|
+
hideDisabledOptions: true
|
|
185
|
+
}
|
|
186
|
+
}) : /*#__PURE__*/React.createElement(_DatePicker, {
|
|
187
|
+
open: isCalendar,
|
|
188
|
+
className: classnames("cw-dropdown-date-picker-calendar-wrapper"),
|
|
189
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
190
|
+
return getPopupContainerCalendar ? getPopupContainerCalendar(triggerNode) : triggerNode.parentNode;
|
|
191
|
+
},
|
|
192
|
+
style: {
|
|
193
|
+
width: 0,
|
|
194
|
+
height: 0,
|
|
195
|
+
padding: 0,
|
|
196
|
+
border: 0,
|
|
197
|
+
overflow: "hidden"
|
|
198
|
+
},
|
|
199
|
+
dropdownClassName: classnames(dropdownCalendarClassName),
|
|
200
|
+
format: format,
|
|
201
|
+
onChange: function onChange(_value, mode) {
|
|
202
|
+
setIsCalendar(false);
|
|
203
|
+
setIsFocus(false);
|
|
204
|
+
if (_value) {
|
|
205
|
+
_onChange({
|
|
206
|
+
value: [_value]
|
|
207
|
+
});
|
|
208
|
+
if (!value) {
|
|
209
|
+
setRecordDateValue({
|
|
210
|
+
value: [_value]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
inputReadOnly: true
|
|
216
|
+
}) : null;
|
|
217
|
+
var _renderInputDom = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Input, _extends({
|
|
218
|
+
prefix: inputPrefix
|
|
219
|
+
}, _inputOption, {
|
|
220
|
+
className: classnames("cw-dropdown-date-picker-input-wrapper", inputWrapperClassName),
|
|
221
|
+
onFocus: onInputFocus,
|
|
222
|
+
value: inputValue,
|
|
223
|
+
readonly: "readOnly"
|
|
224
|
+
})), renderInputDom);
|
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
226
|
+
className: classnames("cw-dropdown-date-picker-wrapper", classNameWrapper),
|
|
227
|
+
ref: calendarRef
|
|
228
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
229
|
+
className: "cw-dropdown-date-picker-box-wrapper"
|
|
230
|
+
}, _renderInputDom, /*#__PURE__*/React.createElement(_Dropdown, {
|
|
231
|
+
overlay: /*#__PURE__*/React.createElement(DropDownMenu, dropdownMenuProps),
|
|
232
|
+
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
233
|
+
return _getPopupContainer ? _getPopupContainer(triggerNode) : triggerNode;
|
|
234
|
+
},
|
|
235
|
+
visible: open !== undefined ? open && !isCalendar : isFocus && !isCalendar,
|
|
236
|
+
overlayClassName: classnames("cw-dropdown-date-picker-dropdown", dropdownClassName)
|
|
237
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
238
|
+
className: "cw-dropdown-date-picker-position-dom",
|
|
239
|
+
style: {
|
|
240
|
+
position: "relative"
|
|
241
|
+
}
|
|
242
|
+
}))));
|
|
243
|
+
});
|
|
244
|
+
DropdownDatePicker.defaultProps = {
|
|
245
|
+
format: "YYYY/MM/DD HH:mm:ss"
|
|
246
|
+
};
|
|
247
|
+
DropdownDatePicker.propTypes = {
|
|
248
|
+
/**
|
|
249
|
+
* 默认value
|
|
250
|
+
*/
|
|
251
|
+
defaultValue: PropTypes.object,
|
|
252
|
+
/**
|
|
253
|
+
* 受控value
|
|
254
|
+
*/
|
|
255
|
+
value: PropTypes.object,
|
|
256
|
+
/**
|
|
257
|
+
* 时间数据源
|
|
258
|
+
*/
|
|
259
|
+
dataSource: PropTypes.array,
|
|
260
|
+
/**
|
|
261
|
+
* 时间变化的回调onChange({value,isRecently?timeDomain?number?unit?})
|
|
262
|
+
*/
|
|
263
|
+
onChange: PropTypes.func,
|
|
264
|
+
/**
|
|
265
|
+
* 时间选择器控件下拉菜单配置项,详情参考demo中案例注释
|
|
266
|
+
*/
|
|
267
|
+
menuOption: PropTypes.object,
|
|
268
|
+
/**
|
|
269
|
+
* 时间选择器控件外层容器新增外层容器类名
|
|
270
|
+
*/
|
|
271
|
+
classNameWrapper: PropTypes.string,
|
|
272
|
+
/**
|
|
273
|
+
* 非最近日期format展示格式
|
|
274
|
+
*/
|
|
275
|
+
format: PropTypes.string,
|
|
276
|
+
/**
|
|
277
|
+
* 输入框配置项
|
|
278
|
+
*/
|
|
279
|
+
inputOption: PropTypes.object
|
|
280
|
+
};
|
|
281
|
+
export default DropdownDatePicker;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.cw-dropdown-date-picker-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
.cw-dropdown-date-picker-box-wrapper{
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
}
|
|
8
|
+
.cw-dropdown-date-picker-input-wrapper {
|
|
9
|
+
width: 360px;
|
|
10
|
+
.@{ant-prefix}-input{
|
|
11
|
+
outline: none;
|
|
12
|
+
}
|
|
13
|
+
.@{ant-prefix}-input:not(:first-child) {
|
|
14
|
+
padding-left: 29px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 前缀尾缀图标共同样式
|
|
18
|
+
.cw-dropdown-date-picker-prefix-wrapper,
|
|
19
|
+
.cw-dropdown-date-picker-suffix-wrapper {
|
|
20
|
+
width: 16px;
|
|
21
|
+
height: 16px;
|
|
22
|
+
display: flex;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
26
|
+
.cw-dropdown-date-picker-prefix-icon{
|
|
27
|
+
color: @menu-dark-arrow-color;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cw-dropdown-date-picker-calendar-wrapper {
|
|
32
|
+
width: 360px;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
s: "Second",
|
|
3
|
+
m: "Minute",
|
|
4
|
+
h: "Hour",
|
|
5
|
+
d: "Day",
|
|
6
|
+
mo: "Month",
|
|
7
|
+
y: "Year",
|
|
8
|
+
more: "More",
|
|
9
|
+
"select-calendar": "Select From Calendar",
|
|
10
|
+
recently: "recently",
|
|
11
|
+
relative: "relative",
|
|
12
|
+
absolute: "absolute",
|
|
13
|
+
unixTimestamp: "Unix",
|
|
14
|
+
other: "other",
|
|
15
|
+
history: 'History',
|
|
16
|
+
clear: 'Clear',
|
|
17
|
+
"enter manually": "You can manually enter a query statement in the following format",
|
|
18
|
+
"fit-the-input-format": "Fit the input format",
|
|
19
|
+
"does-not-match-the-input-format": "Does not match the input format"
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
s: "秒",
|
|
3
|
+
m: "分钟",
|
|
4
|
+
h: "小时",
|
|
5
|
+
d: "天",
|
|
6
|
+
mo: "个月",
|
|
7
|
+
y: "年",
|
|
8
|
+
more: "更多",
|
|
9
|
+
"select-calendar": "日历选择",
|
|
10
|
+
recently: "最近",
|
|
11
|
+
relative: "相对",
|
|
12
|
+
absolute: "绝对",
|
|
13
|
+
unixTimestamp: "Unix",
|
|
14
|
+
other: "其他",
|
|
15
|
+
history: '历史记录',
|
|
16
|
+
clear: '清空',
|
|
17
|
+
"enter manually": "可根据以下类型,按查询语句格式手动输入",
|
|
18
|
+
"fit-the-input-format": "符合输入格式",
|
|
19
|
+
"does-not-match-the-input-format": "不符合输入格式,请重新输入"
|
|
20
|
+
};
|