@oceanbase/ui 0.4.5 → 0.4.7
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/dist/ui.min.css +1 -1
- package/dist/ui.min.js +1 -1
- package/es/Action/Group.d.ts +4 -3
- package/es/Action/Group.js +30 -16
- package/es/Action/Item.d.ts +1 -1
- package/es/Action/index.d.ts +2 -1
- package/es/Action/style/index.d.ts +9 -0
- package/es/Action/style/index.js +43 -0
- package/es/DateRanger/PickerPanel.d.ts +4 -6
- package/es/DateRanger/PickerPanel.js +42 -29
- package/es/DateRanger/Ranger.d.ts +4 -3
- package/es/DateRanger/Ranger.js +20 -26
- package/es/DateRanger/constant/index.d.ts +6 -2
- package/es/DateRanger/constant/index.js +44 -3
- package/es/DateRanger/index.d.ts +24 -1
- package/es/DateRanger/index.js +24 -23
- package/es/DateRanger/index.less +16 -1
- package/es/DateRanger/locale/en-US.js +7 -7
- package/es/DateRanger/typing.d.ts +4 -0
- package/es/Highlight/index.d.ts +1 -1
- package/es/ProCard/index.d.ts +5 -0
- package/es/ProCard/index.js +52 -0
- package/es/ProCard/style/index.d.ts +9 -0
- package/es/ProCard/style/index.js +40 -0
- package/es/TagSelect/style/index.d.ts +3 -2
- package/es/_util/genComponentStyleHook.js +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/locale/LocaleWrapper.js +4 -1
- package/lib/Action/Group.d.ts +4 -3
- package/lib/Action/Group.js +64 -46
- package/lib/Action/Item.d.ts +1 -1
- package/lib/Action/index.d.ts +2 -1
- package/lib/Action/style/index.d.ts +9 -0
- package/lib/Action/style/index.js +78 -0
- package/lib/DateRanger/PickerPanel.d.ts +4 -6
- package/lib/DateRanger/PickerPanel.js +67 -29
- package/lib/DateRanger/Ranger.d.ts +4 -3
- package/lib/DateRanger/Ranger.js +17 -17
- package/lib/DateRanger/constant/index.d.ts +6 -2
- package/lib/DateRanger/constant/index.js +55 -2
- package/lib/DateRanger/index.d.ts +24 -1
- package/lib/DateRanger/index.js +23 -20
- package/lib/DateRanger/index.less +16 -1
- package/lib/DateRanger/locale/en-US.js +7 -7
- package/lib/DateRanger/typing.d.ts +4 -0
- package/lib/Highlight/index.d.ts +1 -1
- package/lib/ProCard/index.d.ts +5 -0
- package/lib/ProCard/index.js +88 -0
- package/lib/ProCard/style/index.d.ts +9 -0
- package/lib/ProCard/style/index.js +92 -0
- package/lib/TagSelect/style/index.d.ts +3 -2
- package/lib/_util/genComponentStyleHook.js +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/locale/LocaleWrapper.js +3 -1
- package/package.json +9 -9
package/es/Action/Group.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import type { ButtonSize } from '@oceanbase/design/es/button';
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import type { ButtonSize } from '@oceanbase/design/es/button';
|
|
3
3
|
import type { BaseProps } from './Item';
|
|
4
4
|
export interface GroupProps {
|
|
5
|
+
prefixCls?: string;
|
|
5
6
|
size?: number;
|
|
6
7
|
dropDownPlacement?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
|
|
7
8
|
children: React.ReactElement<BaseProps> | React.ReactElement<BaseProps>[];
|
|
8
9
|
shouldVisible?: (key: string) => boolean;
|
|
9
10
|
shouldDisabled?: (key: string) => boolean;
|
|
10
11
|
enableLoading?: boolean;
|
|
11
|
-
/** 更多操作的自定义展示 */
|
|
12
12
|
moreText?: React.ReactNode;
|
|
13
|
+
moreType?: 'button' | 'link';
|
|
13
14
|
buttonSize?: ButtonSize;
|
|
14
15
|
}
|
|
15
|
-
declare const _default: ({ size, children, dropDownPlacement, shouldVisible, shouldDisabled, enableLoading, moreText, buttonSize, }: GroupProps) =>
|
|
16
|
+
declare const _default: ({ prefixCls: customizePrefixCls, size, children, dropDownPlacement, shouldVisible, shouldDisabled, enableLoading, moreText, moreType, buttonSize, }: GroupProps) => React.JSX.Element;
|
|
16
17
|
export default _default;
|
package/es/Action/Group.js
CHANGED
|
@@ -4,10 +4,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import
|
|
7
|
+
import React, { useContext } from 'react';
|
|
8
|
+
import { Button, Dropdown, Menu, Space, Tooltip, Typography, ConfigProvider } from '@oceanbase/design';
|
|
8
9
|
import { EllipsisOutlined, LoadingOutlined } from '@oceanbase/icons';
|
|
9
10
|
import { isBoolean, max, omit } from 'lodash';
|
|
10
|
-
import
|
|
11
|
+
import useStyle from "./style";
|
|
11
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
var getOrder = function getOrder(_ref) {
|
|
@@ -28,7 +29,8 @@ var getOrder = function getOrder(_ref) {
|
|
|
28
29
|
return order;
|
|
29
30
|
};
|
|
30
31
|
export default (function (_ref2) {
|
|
31
|
-
var
|
|
32
|
+
var customizePrefixCls = _ref2.prefixCls,
|
|
33
|
+
_ref2$size = _ref2.size,
|
|
32
34
|
size = _ref2$size === void 0 ? 3 : _ref2$size,
|
|
33
35
|
children = _ref2.children,
|
|
34
36
|
dropDownPlacement = _ref2.dropDownPlacement,
|
|
@@ -36,7 +38,13 @@ export default (function (_ref2) {
|
|
|
36
38
|
shouldDisabled = _ref2.shouldDisabled,
|
|
37
39
|
enableLoading = _ref2.enableLoading,
|
|
38
40
|
moreText = _ref2.moreText,
|
|
41
|
+
moreType = _ref2.moreType,
|
|
39
42
|
buttonSize = _ref2.buttonSize;
|
|
43
|
+
var _useContext = useContext(ConfigProvider.ConfigContext),
|
|
44
|
+
getPrefixCls = _useContext.getPrefixCls;
|
|
45
|
+
var prefixCls = getPrefixCls('action', customizePrefixCls);
|
|
46
|
+
var _useStyle = useStyle(prefixCls),
|
|
47
|
+
wrapSSR = _useStyle.wrapSSR;
|
|
40
48
|
var visibleActions = Array.isArray(children) ? children.filter(function (c) {
|
|
41
49
|
if (isBoolean(c.props.visible) && shouldVisible) return c.props.visible && shouldVisible(c.key);
|
|
42
50
|
if (isBoolean(c.props.visible)) return c.props.visible;else if (shouldVisible) return shouldVisible(c.key);
|
|
@@ -57,25 +65,33 @@ export default (function (_ref2) {
|
|
|
57
65
|
var ellipsisType = 'link';
|
|
58
66
|
|
|
59
67
|
// @ts-ignore
|
|
60
|
-
if (visibleActionsSort.
|
|
68
|
+
if (visibleActionsSort.some(function (action) {
|
|
61
69
|
return action.type.__DISPLAY_NAME === 'button';
|
|
62
70
|
})) {
|
|
63
|
-
ellipsisType = '
|
|
71
|
+
ellipsisType = 'button';
|
|
64
72
|
}
|
|
73
|
+
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
if (visibleActionsSort.some(function (action) {
|
|
76
|
+
return action.type.__DISPLAY_NAME === 'link';
|
|
77
|
+
})) {
|
|
78
|
+
ellipsisType = 'link';
|
|
79
|
+
}
|
|
80
|
+
ellipsisType = moreType !== null && moreType !== void 0 ? moreType : ellipsisType;
|
|
65
81
|
var getDefaultDisabled = function getDefaultDisabled(key) {
|
|
66
82
|
var _shouldDisabled;
|
|
67
83
|
return (_shouldDisabled = shouldDisabled === null || shouldDisabled === void 0 ? void 0 : shouldDisabled(key)) !== null && _shouldDisabled !== void 0 ? _shouldDisabled : false;
|
|
68
84
|
};
|
|
69
85
|
var moreDom;
|
|
70
|
-
if (ellipsisType === '
|
|
86
|
+
if (ellipsisType === 'button') {
|
|
71
87
|
moreDom = /*#__PURE__*/_jsx(Button, {
|
|
72
|
-
type: ellipsisType,
|
|
73
88
|
size: buttonSize,
|
|
74
|
-
|
|
89
|
+
icon: moreText ? undefined : /*#__PURE__*/_jsx(EllipsisOutlined, {
|
|
75
90
|
style: {
|
|
76
91
|
cursor: 'pointer'
|
|
77
92
|
}
|
|
78
|
-
})
|
|
93
|
+
}),
|
|
94
|
+
children: moreText
|
|
79
95
|
});
|
|
80
96
|
} else {
|
|
81
97
|
moreDom = /*#__PURE__*/_jsx(Typography.Link, {
|
|
@@ -86,8 +102,8 @@ export default (function (_ref2) {
|
|
|
86
102
|
})
|
|
87
103
|
});
|
|
88
104
|
}
|
|
89
|
-
return /*#__PURE__*/_jsxs(Space, {
|
|
90
|
-
size: 8,
|
|
105
|
+
return wrapSSR( /*#__PURE__*/_jsxs(Space, {
|
|
106
|
+
size: ellipsisType === 'button' ? 8 : 16,
|
|
91
107
|
children: [mainActions.map(function (action) {
|
|
92
108
|
return /*#__PURE__*/React.cloneElement(action, _objectSpread(_objectSpread({
|
|
93
109
|
// size should be covered by action props
|
|
@@ -100,6 +116,7 @@ export default (function (_ref2) {
|
|
|
100
116
|
}), ellipsisActions.length > 0 && /*#__PURE__*/_jsx(Dropdown, {
|
|
101
117
|
placement: dropDownPlacement,
|
|
102
118
|
overlay: /*#__PURE__*/_jsx(Menu, {
|
|
119
|
+
className: "".concat(prefixCls, "-more-menu"),
|
|
103
120
|
children: ellipsisActions.map(function (action, index) {
|
|
104
121
|
var _ref3;
|
|
105
122
|
var actionKey = action.key;
|
|
@@ -116,15 +133,12 @@ export default (function (_ref2) {
|
|
|
116
133
|
var _action$props$onClick, _action$props;
|
|
117
134
|
var domEvent = _ref4.domEvent;
|
|
118
135
|
(_action$props$onClick = (_action$props = action.props).onClick) === null || _action$props$onClick === void 0 || _action$props$onClick.call(_action$props, domEvent);
|
|
119
|
-
},
|
|
120
|
-
style: {
|
|
121
|
-
minWidth: 120
|
|
122
136
|
}
|
|
123
137
|
}, omit(action.props, 'disabled')), {}, {
|
|
124
138
|
disabled: actionDisabled,
|
|
125
139
|
children: /*#__PURE__*/_jsxs(Tooltip, {
|
|
126
140
|
title: action.props.tooltip,
|
|
127
|
-
children: [action.props.loading && /*#__PURE__*/_jsx(LoadingOutlined, {}),
|
|
141
|
+
children: [action.props.loading && /*#__PURE__*/_jsx(LoadingOutlined, {}), ' ', action.props.children || action]
|
|
128
142
|
})
|
|
129
143
|
}), (_ref3 = actionKey) !== null && _ref3 !== void 0 ? _ref3 : index.toString())
|
|
130
144
|
);
|
|
@@ -132,5 +146,5 @@ export default (function (_ref2) {
|
|
|
132
146
|
}),
|
|
133
147
|
children: moreDom
|
|
134
148
|
})]
|
|
135
|
-
});
|
|
149
|
+
}));
|
|
136
150
|
});
|
package/es/Action/Item.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface BaseProps extends ButtonProps {
|
|
|
6
6
|
/** 固定展示、不会被折叠 */
|
|
7
7
|
fixed?: boolean;
|
|
8
8
|
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void> | void;
|
|
9
|
-
children?: React.ReactElement | string;
|
|
9
|
+
children?: React.ReactElement | React.ReactNode | string;
|
|
10
10
|
enableLoading?: boolean;
|
|
11
11
|
tooltip?: string;
|
|
12
12
|
loading?: boolean;
|
package/es/Action/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ActionButton, ActionLink } from './Item';
|
|
2
3
|
export type { GroupProps as ActionGroupProps } from './Group';
|
|
3
4
|
declare const _default: {
|
|
4
|
-
Group: ({ size, children, dropDownPlacement, shouldVisible, shouldDisabled, enableLoading, moreText, buttonSize, }: import("./Group").GroupProps) => import("
|
|
5
|
+
Group: ({ prefixCls: customizePrefixCls, size, children, dropDownPlacement, shouldVisible, shouldDisabled, enableLoading, moreText, moreType, buttonSize, }: import("./Group").GroupProps) => import("react").JSX.Element;
|
|
5
6
|
Button: typeof ActionButton;
|
|
6
7
|
Link: typeof ActionLink;
|
|
7
8
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { GenerateStyle } from '@oceanbase/design/es/theme';
|
|
3
|
+
import type { OBToken } from '../../_util/genComponentStyleHook';
|
|
4
|
+
export declare const genActionStyle: GenerateStyle<OBToken>;
|
|
5
|
+
declare const _default: (prefixCls: string) => {
|
|
6
|
+
wrapSSR: (node: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>) => import("react").JSX.Element;
|
|
7
|
+
hashId: string;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
|
+
import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
|
|
6
|
+
export var genActionStyle = function genActionStyle(token) {
|
|
7
|
+
var componentCls = token.componentCls,
|
|
8
|
+
antCls = token.antCls;
|
|
9
|
+
var paddingVertical = (token.controlHeight - token.fontSize * token.lineHeight) / 2;
|
|
10
|
+
var paddingHorizontal = token.paddingSM;
|
|
11
|
+
var padding = "".concat(paddingVertical, "px ").concat(paddingHorizontal, "px");
|
|
12
|
+
var margin = "-".concat(paddingVertical, "px -").concat(paddingHorizontal, "px");
|
|
13
|
+
return _defineProperty({}, "".concat(componentCls, "-more-menu"), _defineProperty({
|
|
14
|
+
background: 'red'
|
|
15
|
+
}, "".concat(antCls, "-dropdown-menu-item"), _defineProperty(_defineProperty({}, "".concat(antCls, "-typography"), _defineProperty({
|
|
16
|
+
display: 'block',
|
|
17
|
+
margin: margin,
|
|
18
|
+
padding: "".concat(padding, " !important")
|
|
19
|
+
}, "&:not(".concat(antCls, "-typography-disabled)"), {
|
|
20
|
+
color: token.colorText
|
|
21
|
+
})), "".concat(antCls, "-btn"), _defineProperty(_defineProperty({
|
|
22
|
+
padding: padding,
|
|
23
|
+
margin: margin,
|
|
24
|
+
border: 'none',
|
|
25
|
+
display: 'block',
|
|
26
|
+
width: "calc(100% + ".concat(paddingHorizontal * 2, "px)"),
|
|
27
|
+
textAlign: 'left',
|
|
28
|
+
height: 'inherit',
|
|
29
|
+
background: 'transparent'
|
|
30
|
+
}, "&:not(:disabled):not(".concat(antCls, "-btn-disabled)"), _defineProperty({
|
|
31
|
+
color: token.colorText
|
|
32
|
+
}, "&:hover", {
|
|
33
|
+
background: 'transparent'
|
|
34
|
+
})), "".concat(antCls, "-wave"), {
|
|
35
|
+
display: 'none'
|
|
36
|
+
}))));
|
|
37
|
+
};
|
|
38
|
+
export default (function (prefixCls) {
|
|
39
|
+
var useStyle = genComponentStyleHook('Action', function (token) {
|
|
40
|
+
return [genActionStyle(token)];
|
|
41
|
+
});
|
|
42
|
+
return useStyle(prefixCls);
|
|
43
|
+
});
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Moment } from 'moment';
|
|
3
|
-
type RangeValue = [Moment, Moment] | [Dayjs, Dayjs];
|
|
1
|
+
import type { RangeValue } from './Ranger';
|
|
4
2
|
type ValidateTrigger = 'submit' | 'valueChange';
|
|
5
3
|
type MaybeArray<T> = T | T[];
|
|
6
|
-
type ErrorType = 'endDate' | 'startDate' | 'endTime' | 'startTime';
|
|
4
|
+
type ErrorType = 'endDate' | 'startDate' | 'endTime' | 'startTime' | 'all';
|
|
7
5
|
export type Rule = {
|
|
8
6
|
message: string;
|
|
9
|
-
|
|
7
|
+
validator: (value: [string, string] | []) => MaybeArray<ErrorType> | null | undefined;
|
|
10
8
|
};
|
|
11
9
|
export interface PickerPanelProps {
|
|
12
10
|
value?: RangeValue;
|
|
13
11
|
defaultValue?: RangeValue;
|
|
14
12
|
tip?: string;
|
|
15
|
-
|
|
13
|
+
required?: boolean;
|
|
16
14
|
rules?: Rule[];
|
|
17
15
|
validateTrigger?: ValidateTrigger;
|
|
18
16
|
onCancel: () => void;
|
|
@@ -20,21 +20,21 @@ import { noop } from 'lodash';
|
|
|
20
20
|
import moment from 'moment';
|
|
21
21
|
import dayjs from 'dayjs';
|
|
22
22
|
import { getPrefix } from "../_util";
|
|
23
|
+
import { DATE_TIME_MONTH_FORMAT, DATE_TIME_MONTH_FORMAT_CN } from "./constant";
|
|
23
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
25
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
|
+
var ALL_ERROR_TYPE_LIST = ['endDate', 'startDate', 'endTime', 'startTime'];
|
|
25
27
|
var prefix = getPrefix('ranger-picker-panel');
|
|
26
28
|
var prefixCls = 'ant-picker';
|
|
27
|
-
var DATE_FORMAT = 'YYYY-MM-DD';
|
|
28
29
|
var TIME_FORMAT = 'HH:mm:ss';
|
|
29
30
|
var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
30
|
-
var
|
|
31
|
-
defaultValue = _props$defaultValue === void 0 ? [] : _props$defaultValue,
|
|
31
|
+
var defaultValue = props.defaultValue,
|
|
32
32
|
isMoment = props.isMoment,
|
|
33
33
|
locale = props.locale,
|
|
34
34
|
tip = props.tip,
|
|
35
35
|
rules = props.rules,
|
|
36
|
-
_props$
|
|
37
|
-
|
|
36
|
+
_props$required = props.required,
|
|
37
|
+
required = _props$required === void 0 ? true : _props$required,
|
|
38
38
|
_props$onOk = props.onOk,
|
|
39
39
|
onOk = _props$onOk === void 0 ? noop : _props$onOk,
|
|
40
40
|
_props$onCancel = props.onCancel,
|
|
@@ -61,6 +61,10 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
61
61
|
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
62
62
|
activeIndex = _React$useState6[0],
|
|
63
63
|
setActiveIndex = _React$useState6[1];
|
|
64
|
+
var isEn = (locale === null || locale === void 0 ? void 0 : locale.antLocale) === 'en';
|
|
65
|
+
|
|
66
|
+
//
|
|
67
|
+
var DATE_FORMAT = isEn ? DATE_TIME_MONTH_FORMAT : DATE_TIME_MONTH_FORMAT_CN;
|
|
64
68
|
var getDateInstance = useCallback(function (v, format, strict) {
|
|
65
69
|
return isMoment ? moment(v, format, strict) : dayjs(v, format, strict);
|
|
66
70
|
}, [isMoment]);
|
|
@@ -247,6 +251,9 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
247
251
|
style: {
|
|
248
252
|
marginBottom: 8
|
|
249
253
|
},
|
|
254
|
+
rules: [{
|
|
255
|
+
required: true
|
|
256
|
+
}],
|
|
250
257
|
children: /*#__PURE__*/_jsx(Input, {
|
|
251
258
|
size: "middle",
|
|
252
259
|
onBlur: function onBlur(e) {
|
|
@@ -283,6 +290,9 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
283
290
|
},
|
|
284
291
|
validateStatus: errorTypeMap['startTime'],
|
|
285
292
|
initialValue: defaultS || defaultTime,
|
|
293
|
+
rules: [{
|
|
294
|
+
required: true
|
|
295
|
+
}],
|
|
286
296
|
children: /*#__PURE__*/_jsx(TimePicker, {
|
|
287
297
|
allowClear: false,
|
|
288
298
|
suffixIcon: null,
|
|
@@ -316,6 +326,9 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
316
326
|
marginBottom: 0
|
|
317
327
|
},
|
|
318
328
|
validateStatus: errorTypeMap['endDate'],
|
|
329
|
+
rules: [{
|
|
330
|
+
required: true
|
|
331
|
+
}],
|
|
319
332
|
children: /*#__PURE__*/_jsx(Input, {
|
|
320
333
|
onBlur: function onBlur(e) {
|
|
321
334
|
var v = validateInputDate(e);
|
|
@@ -351,6 +364,9 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
351
364
|
},
|
|
352
365
|
validateStatus: errorTypeMap['endTime'],
|
|
353
366
|
initialValue: defaultE || defaultTime,
|
|
367
|
+
rules: [{
|
|
368
|
+
required: true
|
|
369
|
+
}],
|
|
354
370
|
children: /*#__PURE__*/_jsx(TimePicker, {
|
|
355
371
|
allowClear: false,
|
|
356
372
|
suffixIcon: null,
|
|
@@ -448,30 +464,27 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
448
464
|
endTime = values.endTime;
|
|
449
465
|
var start = "".concat(startDate, " ").concat(startTime.format(TIME_FORMAT));
|
|
450
466
|
var end = "".concat(endDate, " ").concat(endTime.format(TIME_FORMAT));
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
// setErrorTypeList([]);
|
|
473
|
-
// onOk([start, end]);
|
|
474
|
-
// }
|
|
467
|
+
var errorList = [];
|
|
468
|
+
var message = '';
|
|
469
|
+
rules === null || rules === void 0 || rules.some(function (item) {
|
|
470
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.validator) === 'function') {
|
|
471
|
+
var errorType = item.validator([start, end]);
|
|
472
|
+
if (errorType) {
|
|
473
|
+
errorList = Array.isArray(errorType) ? errorType : [errorType];
|
|
474
|
+
message = item.message;
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return false;
|
|
479
|
+
});
|
|
480
|
+
if (errorList.length > 0) {
|
|
481
|
+
setErrorTypeList(errorList.includes('all') ? ALL_ERROR_TYPE_LIST : errorList);
|
|
482
|
+
setErrorMessage(message);
|
|
483
|
+
} else {
|
|
484
|
+
setErrorMessage('');
|
|
485
|
+
setErrorTypeList([]);
|
|
486
|
+
onOk([start, end]);
|
|
487
|
+
}
|
|
475
488
|
});
|
|
476
489
|
},
|
|
477
490
|
children: locale.confirm
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { TooltipProps } from '@oceanbase/design';
|
|
2
3
|
import type { RangePickerProps } from '@oceanbase/design/es/date-picker';
|
|
3
4
|
import type { Dayjs } from 'dayjs';
|
|
@@ -6,7 +7,7 @@ import type { RangeOption } from './typing';
|
|
|
6
7
|
import type { Rule } from './PickerPanel';
|
|
7
8
|
import './index.less';
|
|
8
9
|
export type RangeName = 'customize' | string;
|
|
9
|
-
export type RangeValue = [Moment, Moment] | [Dayjs, Dayjs];
|
|
10
|
+
export type RangeValue = [Moment, Moment] | [Dayjs, Dayjs] | [] | null;
|
|
10
11
|
export type RangeDateValue = {
|
|
11
12
|
name: RangeName;
|
|
12
13
|
range: RangeValue;
|
|
@@ -34,7 +35,7 @@ export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker
|
|
|
34
35
|
defaultValue?: RangeValue;
|
|
35
36
|
size?: 'small' | 'large' | 'middle';
|
|
36
37
|
tooltipProps?: TooltipProps;
|
|
37
|
-
locale
|
|
38
|
+
locale?: any;
|
|
38
39
|
}
|
|
39
|
-
declare const _default:
|
|
40
|
+
declare const _default: React.ForwardRefExoticComponent<DateRangerProps & React.RefAttributes<unknown>>;
|
|
40
41
|
export default _default;
|
package/es/DateRanger/Ranger.js
CHANGED
|
@@ -30,7 +30,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
30
30
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
31
|
var prefix = getPrefix('date-ranger');
|
|
32
32
|
var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
33
|
-
var _selects
|
|
33
|
+
var _selects$;
|
|
34
34
|
var _props$selects = props.selects,
|
|
35
35
|
selects = _props$selects === void 0 ? [NEAR_1_MINUTES, NEAR_30_MINUTES, NEAR_1_HOURS, NEAR_3_HOURS, NEAR_6_HOURS, TODAY, LAST_3_DAYS] : _props$selects,
|
|
36
36
|
value = props.value,
|
|
@@ -72,7 +72,8 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
72
72
|
rest = _objectWithoutProperties(props, _excluded);
|
|
73
73
|
var _theme$useToken = theme.useToken(),
|
|
74
74
|
token = _theme$useToken.token;
|
|
75
|
-
var isCn = locale.
|
|
75
|
+
var isCn = locale.antLocale === 'zh-cn';
|
|
76
|
+
var isEN = locale.antLocale === 'en';
|
|
76
77
|
|
|
77
78
|
// 是否为 moment 时间对象
|
|
78
79
|
var isMoment = moment.isMoment(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[0]) || moment.isMoment(defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue[1]) || moment.isMoment(value === null || value === void 0 ? void 0 : value[0]) || moment.isMoment(value === null || value === void 0 ? void 0 : value[1]) || isMomentProps;
|
|
@@ -193,29 +194,21 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
193
194
|
};
|
|
194
195
|
var getCustomizeLabel = function getCustomizeLabel() {
|
|
195
196
|
if (differenceYears > 0) {
|
|
196
|
-
return "\u8FD1 ".concat(differenceYears, " \u5E74");
|
|
197
|
+
return isEN ? "Nearly ".concat(differenceYears, " years") : "\u8FD1 ".concat(differenceYears, " \u5E74");
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
-
// if (differenceQuarters > 0) {
|
|
200
|
-
// return `近 ${differenceQuarters} 季度`;
|
|
201
|
-
// }
|
|
202
|
-
|
|
203
199
|
if (differenceMonths > 0) {
|
|
204
|
-
return "\u8FD1 ".concat(differenceMonths, " \u6708");
|
|
200
|
+
return isEN ? "Nearly ".concat(differenceMonths, " months") : "\u8FD1 ".concat(differenceMonths, " \u6708");
|
|
205
201
|
}
|
|
206
202
|
if (differenceWeeks > 0) {
|
|
207
|
-
return "\u8FD1 ".concat(differenceWeeks, " \u5468");
|
|
208
|
-
}
|
|
209
|
-
if (differenceDays > 0) {
|
|
210
|
-
return "\u8FD1 ".concat(differenceDays, " \u5929");
|
|
203
|
+
return isEN ? "Nearly ".concat(differenceWeeks, " weeks") : "\u8FD1 ".concat(differenceWeeks, " \u5468");
|
|
211
204
|
}
|
|
212
205
|
if (differenceHours > 0) {
|
|
213
|
-
return "\u8FD1 ".concat(differenceHours, " \u65F6");
|
|
206
|
+
return isEN ? "Nearly ".concat(differenceHours, " hours") : "\u8FD1 ".concat(differenceHours, " \u5C0F\u65F6");
|
|
214
207
|
}
|
|
215
208
|
if (differenceMinutes > 0) {
|
|
216
|
-
return "\u8FD1 ".concat(differenceMinutes, " \u5206");
|
|
209
|
+
return isEN ? "Nearly ".concat(differenceMinutes, " minutes") : "\u8FD1 ".concat(differenceMinutes, " \u5206");
|
|
217
210
|
}
|
|
218
|
-
return "\u8FD1 ".concat(differenceSeconds, " \u79D2");
|
|
211
|
+
return isEN ? "Nearly ".concat(differenceSeconds, " seconds") : "\u8FD1 ".concat(differenceSeconds, " \u79D2");
|
|
219
212
|
};
|
|
220
213
|
var setNow = function setNow() {
|
|
221
214
|
var selected = NEAR_TIME_LIST.find(function (item) {
|
|
@@ -234,12 +227,11 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
234
227
|
updateCurrentTime: setNow
|
|
235
228
|
};
|
|
236
229
|
});
|
|
237
|
-
var
|
|
238
|
-
return _item.name === rangeName;
|
|
239
|
-
})) === null || _selects$find2 === void 0 ? void 0 : _selects$find2.rangeLabel;
|
|
240
|
-
var label = rangeName === CUSTOMIZE ? getCustomizeLabel() : (_selects$find3 = selects.find(function (_item) {
|
|
230
|
+
var currentRange = selects.find(function (_item) {
|
|
241
231
|
return _item.name === rangeName;
|
|
242
|
-
})
|
|
232
|
+
});
|
|
233
|
+
var rangeLabel = rangeName === CUSTOMIZE ? getCustomizeRangeLabel() : currentRange === null || currentRange === void 0 ? void 0 : currentRange.rangeLabel;
|
|
234
|
+
var label = rangeName === CUSTOMIZE ? getCustomizeLabel() : isEN ? currentRange.enLabel || currentRange.label : currentRange.label;
|
|
243
235
|
var thisYear = new Date().getFullYear();
|
|
244
236
|
var isThisYear = (startTime === null || startTime === void 0 ? void 0 : startTime.year()) === thisYear && (endTime === null || endTime === void 0 ? void 0 : endTime.year()) === thisYear;
|
|
245
237
|
var rangeNameIndex = findIndex(selects, function (item) {
|
|
@@ -285,7 +277,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
285
277
|
margin: '0px 4px 0px 0px'
|
|
286
278
|
}
|
|
287
279
|
}), /*#__PURE__*/_jsx(InternalPickerPanel, {
|
|
288
|
-
defaultValue: innerValue
|
|
280
|
+
defaultValue: innerValue || []
|
|
289
281
|
// @ts-ignore
|
|
290
282
|
,
|
|
291
283
|
locale: locale,
|
|
@@ -341,7 +333,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
341
333
|
children: [hasTagInPicker && /*#__PURE__*/_jsx("span", {
|
|
342
334
|
className: "".concat(prefix, "-label"),
|
|
343
335
|
children: item.rangeLabel
|
|
344
|
-
}),
|
|
336
|
+
}), isEN ? item.enLabel || item.label : item.label]
|
|
345
337
|
})
|
|
346
338
|
};
|
|
347
339
|
})
|
|
@@ -363,10 +355,10 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
363
355
|
onClick: function onClick() {
|
|
364
356
|
setOpen(true);
|
|
365
357
|
},
|
|
366
|
-
children: /*#__PURE__*/_jsx(DatePicker.RangePicker, _objectSpread({
|
|
358
|
+
children: /*#__PURE__*/_jsx(DatePicker.RangePicker, _objectSpread(_objectSpread({
|
|
367
359
|
className: classNames("".concat(prefix, "-picker")),
|
|
368
360
|
style: {
|
|
369
|
-
pointerEvents: 'none',
|
|
361
|
+
// pointerEvents: 'none',
|
|
370
362
|
border: 0
|
|
371
363
|
},
|
|
372
364
|
format: function format(v) {
|
|
@@ -384,7 +376,9 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
384
376
|
size: size,
|
|
385
377
|
suffixIcon: null
|
|
386
378
|
// 透传 props 到 antd Ranger
|
|
387
|
-
}, omit(rest, 'value', 'onChange'))
|
|
379
|
+
}, omit(rest, 'value', 'onChange')), {}, {
|
|
380
|
+
open: false
|
|
381
|
+
}))
|
|
388
382
|
})]
|
|
389
383
|
}), /*#__PURE__*/_jsxs(Radio.Group, {
|
|
390
384
|
value: isPlay ? 'play' : '',
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { RangeOption } from '../typing';
|
|
2
2
|
export declare const CUSTOMIZE = "customize";
|
|
3
|
-
export declare const YEAR_DATE_TIME_SECOND_FORMAT = "
|
|
4
|
-
export declare const YEAR_DATE_TIME_FORMAT = "
|
|
3
|
+
export declare const YEAR_DATE_TIME_SECOND_FORMAT = "MM/DD/YYYY HH:mm:ss";
|
|
4
|
+
export declare const YEAR_DATE_TIME_FORMAT = "MM/DD/YYYY HH:mm";
|
|
5
5
|
export declare const DATE_TIME_SECOND_FORMAT = "MM/DD HH:mm:ss";
|
|
6
6
|
export declare const DATE_TIME_FORMAT = "MM/DD HH:mm";
|
|
7
|
+
export declare const DATE_TIME_MONTH_FORMAT = "MM/DD/YYYY";
|
|
7
8
|
export declare const YEAR_DATE_TIME_SECOND_FORMAT_CN = "YYYY-MM-DD HH:mm:ss";
|
|
8
9
|
export declare const YEAR_DATE_TIME_FORMAT_CN = "YYYY-MM-DD HH:mm";
|
|
10
|
+
export declare const DATE_TIME_MONTH_FORMAT_CN = "YYYY-MM-DD";
|
|
9
11
|
export declare const DATE_TIME_SECOND_FORMAT_CN = "MM-DD HH:mm:ss";
|
|
10
12
|
export declare const DATE_TIME_FORMAT_CN = "MM-DD HH:mm";
|
|
11
13
|
export declare const NEAR_1_MINUTES: RangeOption;
|
|
@@ -17,8 +19,10 @@ export declare const NEAR_1_HOURS: RangeOption;
|
|
|
17
19
|
export declare const NEAR_2_HOURS: RangeOption;
|
|
18
20
|
export declare const NEAR_3_HOURS: RangeOption;
|
|
19
21
|
export declare const NEAR_6_HOURS: RangeOption;
|
|
22
|
+
export declare const NEAR_12_HOURS: RangeOption;
|
|
20
23
|
export declare const TODAY: RangeOption;
|
|
21
24
|
export declare const YESTERDAY: RangeOption;
|
|
25
|
+
export declare const LAST_1_DAY: RangeOption;
|
|
22
26
|
export declare const LAST_3_DAYS: RangeOption;
|
|
23
27
|
export declare const THIS_WEEK: RangeOption;
|
|
24
28
|
export declare const LAST_WEEK: RangeOption;
|