@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/lib/Action/Group.js
CHANGED
|
@@ -32,10 +32,11 @@ __export(Group_exports, {
|
|
|
32
32
|
default: () => Group_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Group_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
35
36
|
var import_design = require("@oceanbase/design");
|
|
36
37
|
var import_icons = require("@oceanbase/icons");
|
|
37
38
|
var import_lodash = require("lodash");
|
|
38
|
-
var
|
|
39
|
+
var import_style = __toESM(require("./style"));
|
|
39
40
|
var getOrder = ({ type, fixed }) => {
|
|
40
41
|
const ORDER_SET = { primary: 3, fixed: 2, default: 0 };
|
|
41
42
|
let order = ORDER_SET.default;
|
|
@@ -48,6 +49,7 @@ var getOrder = ({ type, fixed }) => {
|
|
|
48
49
|
return order;
|
|
49
50
|
};
|
|
50
51
|
var Group_default = ({
|
|
52
|
+
prefixCls: customizePrefixCls,
|
|
51
53
|
size = 3,
|
|
52
54
|
children,
|
|
53
55
|
dropDownPlacement,
|
|
@@ -55,8 +57,12 @@ var Group_default = ({
|
|
|
55
57
|
shouldDisabled,
|
|
56
58
|
enableLoading,
|
|
57
59
|
moreText,
|
|
60
|
+
moreType,
|
|
58
61
|
buttonSize
|
|
59
62
|
}) => {
|
|
63
|
+
const { getPrefixCls } = (0, import_react.useContext)(import_design.ConfigProvider.ConfigContext);
|
|
64
|
+
const prefixCls = getPrefixCls("action", customizePrefixCls);
|
|
65
|
+
const { wrapSSR } = (0, import_style.default)(prefixCls);
|
|
60
66
|
const visibleActions = Array.isArray(children) ? children.filter((c) => {
|
|
61
67
|
if ((0, import_lodash.isBoolean)(c.props.visible) && shouldVisible)
|
|
62
68
|
return c.props.visible && shouldVisible(c.key);
|
|
@@ -79,56 +85,68 @@ var Group_default = ({
|
|
|
79
85
|
const mainActions = visibleActionsSort.slice(0, realSize);
|
|
80
86
|
const ellipsisActions = visibleActionsSort.slice(realSize);
|
|
81
87
|
let ellipsisType = "link";
|
|
82
|
-
if (visibleActionsSort.
|
|
83
|
-
ellipsisType = "
|
|
88
|
+
if (visibleActionsSort.some((action) => action.type.__DISPLAY_NAME === "button")) {
|
|
89
|
+
ellipsisType = "button";
|
|
90
|
+
}
|
|
91
|
+
if (visibleActionsSort.some((action) => action.type.__DISPLAY_NAME === "link")) {
|
|
92
|
+
ellipsisType = "link";
|
|
84
93
|
}
|
|
94
|
+
ellipsisType = moreType ?? ellipsisType;
|
|
85
95
|
const getDefaultDisabled = (key) => (shouldDisabled == null ? void 0 : shouldDisabled(key)) ?? false;
|
|
86
96
|
let moreDom;
|
|
87
|
-
if (ellipsisType === "
|
|
88
|
-
moreDom = /* @__PURE__ */ import_react.default.createElement(
|
|
97
|
+
if (ellipsisType === "button") {
|
|
98
|
+
moreDom = /* @__PURE__ */ import_react.default.createElement(
|
|
99
|
+
import_design.Button,
|
|
100
|
+
{
|
|
101
|
+
size: buttonSize,
|
|
102
|
+
icon: moreText ? void 0 : /* @__PURE__ */ import_react.default.createElement(import_icons.EllipsisOutlined, { style: { cursor: "pointer" } })
|
|
103
|
+
},
|
|
104
|
+
moreText
|
|
105
|
+
);
|
|
89
106
|
} else {
|
|
90
107
|
moreDom = /* @__PURE__ */ import_react.default.createElement(import_design.Typography.Link, null, moreText ?? /* @__PURE__ */ import_react.default.createElement(import_icons.EllipsisOutlined, { style: { cursor: "pointer" } }));
|
|
91
108
|
}
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
return wrapSSR(
|
|
110
|
+
/* @__PURE__ */ import_react.default.createElement(import_design.Space, { size: ellipsisType === "button" ? 8 : 16 }, mainActions.map((action) => {
|
|
111
|
+
return import_react.default.cloneElement(action, {
|
|
112
|
+
// size should be covered by action props
|
|
113
|
+
size: buttonSize,
|
|
114
|
+
...action.props,
|
|
115
|
+
key: action.key,
|
|
116
|
+
enableLoading,
|
|
117
|
+
disabled: (0, import_lodash.isBoolean)(action.props.disabled) ? action.props.disabled : getDefaultDisabled(action.key)
|
|
118
|
+
});
|
|
119
|
+
}), ellipsisActions.length > 0 && /* @__PURE__ */ import_react.default.createElement(
|
|
120
|
+
import_design.Dropdown,
|
|
121
|
+
{
|
|
122
|
+
placement: dropDownPlacement,
|
|
123
|
+
overlay: /* @__PURE__ */ import_react.default.createElement(import_design.Menu, { className: `${prefixCls}-more-menu` }, ellipsisActions.map((action, index) => {
|
|
124
|
+
const actionKey = action.key;
|
|
125
|
+
let disabled = false;
|
|
126
|
+
if ((0, import_lodash.isBoolean)(action.props.disabled))
|
|
127
|
+
disabled = action.props.disabled;
|
|
128
|
+
else if (shouldDisabled)
|
|
129
|
+
disabled = shouldDisabled(action.key);
|
|
130
|
+
const actionDisabled = action.props.loading || ((0, import_lodash.isBoolean)(action.props.disabled) ? action.props.disabled : getDefaultDisabled(action.key));
|
|
131
|
+
return (
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
134
|
+
import_design.Menu.Item,
|
|
135
|
+
{
|
|
136
|
+
key: actionKey ?? index.toString(),
|
|
137
|
+
onClick: ({ domEvent }) => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
(_b = (_a = action.props).onClick) == null ? void 0 : _b.call(_a, domEvent);
|
|
140
|
+
},
|
|
141
|
+
...(0, import_lodash.omit)(action.props, "disabled"),
|
|
142
|
+
disabled: actionDisabled
|
|
122
143
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
moreDom
|
|
133
|
-
));
|
|
144
|
+
/* @__PURE__ */ import_react.default.createElement(import_design.Tooltip, { title: action.props.tooltip }, action.props.loading && /* @__PURE__ */ import_react.default.createElement(import_icons.LoadingOutlined, null), " ", action.props.children || action)
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
}))
|
|
148
|
+
},
|
|
149
|
+
moreDom
|
|
150
|
+
))
|
|
151
|
+
);
|
|
134
152
|
};
|
package/lib/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/lib/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,78 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/Action/style/index.ts
|
|
20
|
+
var style_exports = {};
|
|
21
|
+
__export(style_exports, {
|
|
22
|
+
default: () => style_default,
|
|
23
|
+
genActionStyle: () => genActionStyle
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(style_exports);
|
|
26
|
+
var import_genComponentStyleHook = require("../../_util/genComponentStyleHook");
|
|
27
|
+
var genActionStyle = (token) => {
|
|
28
|
+
const { componentCls, antCls } = token;
|
|
29
|
+
const paddingVertical = (token.controlHeight - token.fontSize * token.lineHeight) / 2;
|
|
30
|
+
const paddingHorizontal = token.paddingSM;
|
|
31
|
+
const padding = `${paddingVertical}px ${paddingHorizontal}px`;
|
|
32
|
+
const margin = `-${paddingVertical}px -${paddingHorizontal}px`;
|
|
33
|
+
return {
|
|
34
|
+
[`${componentCls}-more-menu`]: {
|
|
35
|
+
background: "red",
|
|
36
|
+
[`${antCls}-dropdown-menu-item`]: {
|
|
37
|
+
[`${antCls}-typography`]: {
|
|
38
|
+
display: "block",
|
|
39
|
+
margin,
|
|
40
|
+
padding: `${padding} !important`,
|
|
41
|
+
[`&:not(${antCls}-typography-disabled)`]: {
|
|
42
|
+
color: token.colorText
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
[`${antCls}-btn`]: {
|
|
46
|
+
padding,
|
|
47
|
+
margin,
|
|
48
|
+
border: "none",
|
|
49
|
+
display: "block",
|
|
50
|
+
width: `calc(100% + ${paddingHorizontal * 2}px)`,
|
|
51
|
+
textAlign: "left",
|
|
52
|
+
height: "inherit",
|
|
53
|
+
background: "transparent",
|
|
54
|
+
[`&:not(:disabled):not(${antCls}-btn-disabled)`]: {
|
|
55
|
+
color: token.colorText,
|
|
56
|
+
[`&:hover`]: {
|
|
57
|
+
background: "transparent"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
// remove button click animation
|
|
61
|
+
[`${antCls}-wave`]: {
|
|
62
|
+
display: "none"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var style_default = (prefixCls) => {
|
|
70
|
+
const useStyle = (0, import_genComponentStyleHook.genComponentStyleHook)("Action", (token) => {
|
|
71
|
+
return [genActionStyle(token)];
|
|
72
|
+
});
|
|
73
|
+
return useStyle(prefixCls);
|
|
74
|
+
};
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
genActionStyle
|
|
78
|
+
});
|
|
@@ -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;
|
|
@@ -44,18 +44,19 @@ var import_lodash = require("lodash");
|
|
|
44
44
|
var import_moment2 = __toESM(require("moment"));
|
|
45
45
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
46
46
|
var import_util = require("../_util");
|
|
47
|
+
var import_constant = require("./constant");
|
|
48
|
+
var ALL_ERROR_TYPE_LIST = ["endDate", "startDate", "endTime", "startTime"];
|
|
47
49
|
var prefix = (0, import_util.getPrefix)("ranger-picker-panel");
|
|
48
50
|
var prefixCls = "ant-picker";
|
|
49
|
-
var DATE_FORMAT = "YYYY-MM-DD";
|
|
50
51
|
var TIME_FORMAT = "HH:mm:ss";
|
|
51
52
|
var InternalPickerPanel = (props) => {
|
|
52
53
|
const {
|
|
53
|
-
defaultValue
|
|
54
|
+
defaultValue,
|
|
54
55
|
isMoment,
|
|
55
56
|
locale,
|
|
56
57
|
tip,
|
|
57
58
|
rules,
|
|
58
|
-
|
|
59
|
+
required = true,
|
|
59
60
|
onOk = import_lodash.noop,
|
|
60
61
|
onCancel = import_lodash.noop,
|
|
61
62
|
disabledDate
|
|
@@ -66,6 +67,8 @@ var InternalPickerPanel = (props) => {
|
|
|
66
67
|
const [calendarValue, setCalendarValue] = import_react.default.useState(defaultValue);
|
|
67
68
|
const [internalHoverValues, setInternalHoverValues] = import_react.default.useState(null);
|
|
68
69
|
const [activeIndex, setActiveIndex] = import_react.default.useState(0);
|
|
70
|
+
const isEn = (locale == null ? void 0 : locale.antLocale) === "en";
|
|
71
|
+
const DATE_FORMAT = isEn ? import_constant.DATE_TIME_MONTH_FORMAT : import_constant.DATE_TIME_MONTH_FORMAT_CN;
|
|
69
72
|
const getDateInstance = (0, import_react.useCallback)(
|
|
70
73
|
(v, format, strict) => {
|
|
71
74
|
return isMoment ? (0, import_moment2.default)(v, format, strict) : (0, import_dayjs2.default)(v, format, strict);
|
|
@@ -210,7 +213,8 @@ var InternalPickerPanel = (props) => {
|
|
|
210
213
|
name: "startDate",
|
|
211
214
|
label: locale.startDate,
|
|
212
215
|
validateStatus: errorTypeMap["startDate"],
|
|
213
|
-
style: { marginBottom: 8 }
|
|
216
|
+
style: { marginBottom: 8 },
|
|
217
|
+
rules: [{ required: true }]
|
|
214
218
|
},
|
|
215
219
|
/* @__PURE__ */ import_react.default.createElement(
|
|
216
220
|
import_design.Input,
|
|
@@ -242,7 +246,8 @@ var InternalPickerPanel = (props) => {
|
|
|
242
246
|
label: locale.startTime,
|
|
243
247
|
style: { marginBottom: 8 },
|
|
244
248
|
validateStatus: errorTypeMap["startTime"],
|
|
245
|
-
initialValue: defaultS || defaultTime
|
|
249
|
+
initialValue: defaultS || defaultTime,
|
|
250
|
+
rules: [{ required: true }]
|
|
246
251
|
},
|
|
247
252
|
/* @__PURE__ */ import_react.default.createElement(
|
|
248
253
|
import_design.TimePicker,
|
|
@@ -272,7 +277,8 @@ var InternalPickerPanel = (props) => {
|
|
|
272
277
|
name: "endDate",
|
|
273
278
|
label: locale.endDate,
|
|
274
279
|
style: { marginBottom: 0 },
|
|
275
|
-
validateStatus: errorTypeMap["endDate"]
|
|
280
|
+
validateStatus: errorTypeMap["endDate"],
|
|
281
|
+
rules: [{ required: true }]
|
|
276
282
|
},
|
|
277
283
|
/* @__PURE__ */ import_react.default.createElement(
|
|
278
284
|
import_design.Input,
|
|
@@ -303,7 +309,8 @@ var InternalPickerPanel = (props) => {
|
|
|
303
309
|
label: locale.endTime,
|
|
304
310
|
style: { marginBottom: 0 },
|
|
305
311
|
validateStatus: errorTypeMap["endTime"],
|
|
306
|
-
initialValue: defaultE || defaultTime
|
|
312
|
+
initialValue: defaultE || defaultTime,
|
|
313
|
+
rules: [{ required: true }]
|
|
307
314
|
},
|
|
308
315
|
/* @__PURE__ */ import_react.default.createElement(
|
|
309
316
|
import_design.TimePicker,
|
|
@@ -366,30 +373,61 @@ var InternalPickerPanel = (props) => {
|
|
|
366
373
|
}
|
|
367
374
|
)
|
|
368
375
|
)
|
|
369
|
-
), /* @__PURE__ */ import_react.default.createElement(import_design.Divider, { style: { margin: "8px 0" } }), tip && !errorMessage && /* @__PURE__ */ import_react.default.createElement(import_design.Alert, { message: tip, type: "info", style: { marginBottom: 8 }, showIcon: true }), errorMessage && /* @__PURE__ */ import_react.default.createElement(import_design.Alert, { message: errorMessage, type: "error", style: { marginBottom: 8 }, showIcon: true }), /* @__PURE__ */ import_react.default.createElement(
|
|
370
|
-
import_design.
|
|
371
|
-
{
|
|
372
|
-
size: "small",
|
|
373
|
-
onClick: () => {
|
|
374
|
-
onCancel();
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
locale.cancel
|
|
378
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
379
|
-
import_design.Button,
|
|
376
|
+
), /* @__PURE__ */ import_react.default.createElement(import_design.Divider, { style: { margin: "8px 0" } }), tip && !errorMessage && /* @__PURE__ */ import_react.default.createElement(import_design.Alert, { message: tip, type: "info", style: { marginBottom: 8 }, showIcon: true }), errorMessage && /* @__PURE__ */ import_react.default.createElement(import_design.Alert, { message: errorMessage, type: "error", style: { marginBottom: 8 }, showIcon: true }), /* @__PURE__ */ import_react.default.createElement(
|
|
377
|
+
import_design.Space,
|
|
380
378
|
{
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const { startDate, startTime, endDate, endTime } = values;
|
|
386
|
-
const start = `${startDate} ${startTime.format(TIME_FORMAT)}`;
|
|
387
|
-
const end = `${endDate} ${endTime.format(TIME_FORMAT)}`;
|
|
388
|
-
onOk([start, end]);
|
|
389
|
-
});
|
|
379
|
+
style: {
|
|
380
|
+
width: "100%",
|
|
381
|
+
justifyContent: "flex-end",
|
|
382
|
+
padding: "0 12px 4px 0"
|
|
390
383
|
}
|
|
391
384
|
},
|
|
392
|
-
|
|
393
|
-
|
|
385
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
386
|
+
import_design.Button,
|
|
387
|
+
{
|
|
388
|
+
size: "small",
|
|
389
|
+
onClick: () => {
|
|
390
|
+
onCancel();
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
locale.cancel
|
|
394
|
+
),
|
|
395
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
396
|
+
import_design.Button,
|
|
397
|
+
{
|
|
398
|
+
size: "small",
|
|
399
|
+
type: "primary",
|
|
400
|
+
onClick: () => {
|
|
401
|
+
form.validateFields().then((values) => {
|
|
402
|
+
const { startDate, startTime, endDate, endTime } = values;
|
|
403
|
+
const start = `${startDate} ${startTime.format(TIME_FORMAT)}`;
|
|
404
|
+
const end = `${endDate} ${endTime.format(TIME_FORMAT)}`;
|
|
405
|
+
let errorList = [];
|
|
406
|
+
let message = "";
|
|
407
|
+
rules == null ? void 0 : rules.some((item) => {
|
|
408
|
+
if (typeof (item == null ? void 0 : item.validator) === "function") {
|
|
409
|
+
const errorType = item.validator([start, end]);
|
|
410
|
+
if (errorType) {
|
|
411
|
+
errorList = Array.isArray(errorType) ? errorType : [errorType];
|
|
412
|
+
message = item.message;
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return false;
|
|
417
|
+
});
|
|
418
|
+
if (errorList.length > 0) {
|
|
419
|
+
setErrorTypeList(errorList.includes("all") ? ALL_ERROR_TYPE_LIST : errorList);
|
|
420
|
+
setErrorMessage(message);
|
|
421
|
+
} else {
|
|
422
|
+
setErrorMessage("");
|
|
423
|
+
setErrorTypeList([]);
|
|
424
|
+
onOk([start, end]);
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
},
|
|
429
|
+
locale.confirm
|
|
430
|
+
)
|
|
431
|
+
));
|
|
394
432
|
};
|
|
395
433
|
var PickerPanel_default = InternalPickerPanel;
|
|
@@ -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/lib/DateRanger/Ranger.js
CHANGED
|
@@ -47,7 +47,7 @@ var import_zh_CN = __toESM(require("./locale/zh-CN"));
|
|
|
47
47
|
var import_index = require("./index.less");
|
|
48
48
|
var prefix = (0, import_util.getPrefix)("date-ranger");
|
|
49
49
|
var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
50
|
-
var _a
|
|
50
|
+
var _a;
|
|
51
51
|
const {
|
|
52
52
|
selects = [
|
|
53
53
|
import_constant.NEAR_1_MINUTES,
|
|
@@ -85,7 +85,8 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
85
85
|
...rest
|
|
86
86
|
} = props;
|
|
87
87
|
const { token } = import_design.theme.useToken();
|
|
88
|
-
const isCn = locale.
|
|
88
|
+
const isCn = locale.antLocale === "zh-cn";
|
|
89
|
+
const isEN = locale.antLocale === "en";
|
|
89
90
|
const isMoment = import_moment.default.isMoment(defaultValue == null ? void 0 : defaultValue[0]) || import_moment.default.isMoment(defaultValue == null ? void 0 : defaultValue[1]) || import_moment.default.isMoment(value == null ? void 0 : value[0]) || import_moment.default.isMoment(value == null ? void 0 : value[1]) || isMomentProps;
|
|
90
91
|
const defaultRangeName = value || defaultValue ? import_constant.CUSTOMIZE : defaultQuickValue ?? ((_a = selects == null ? void 0 : selects[0]) == null ? void 0 : _a.name);
|
|
91
92
|
const [rangeName, setRangeName] = (0, import_react.useState)(defaultRangeName);
|
|
@@ -183,24 +184,21 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
183
184
|
};
|
|
184
185
|
const getCustomizeLabel = () => {
|
|
185
186
|
if (differenceYears > 0) {
|
|
186
|
-
return `近 ${differenceYears} 年`;
|
|
187
|
+
return isEN ? `Nearly ${differenceYears} years` : `近 ${differenceYears} 年`;
|
|
187
188
|
}
|
|
188
189
|
if (differenceMonths > 0) {
|
|
189
|
-
return `近 ${differenceMonths} 月`;
|
|
190
|
+
return isEN ? `Nearly ${differenceMonths} months` : `近 ${differenceMonths} 月`;
|
|
190
191
|
}
|
|
191
192
|
if (differenceWeeks > 0) {
|
|
192
|
-
return `近 ${differenceWeeks} 周`;
|
|
193
|
-
}
|
|
194
|
-
if (differenceDays > 0) {
|
|
195
|
-
return `近 ${differenceDays} 天`;
|
|
193
|
+
return isEN ? `Nearly ${differenceWeeks} weeks` : `近 ${differenceWeeks} 周`;
|
|
196
194
|
}
|
|
197
195
|
if (differenceHours > 0) {
|
|
198
|
-
return `近 ${differenceHours}
|
|
196
|
+
return isEN ? `Nearly ${differenceHours} hours` : `近 ${differenceHours} 小时`;
|
|
199
197
|
}
|
|
200
198
|
if (differenceMinutes > 0) {
|
|
201
|
-
return `近 ${differenceMinutes} 分`;
|
|
199
|
+
return isEN ? `Nearly ${differenceMinutes} minutes` : `近 ${differenceMinutes} 分`;
|
|
202
200
|
}
|
|
203
|
-
return `近 ${differenceSeconds} 秒`;
|
|
201
|
+
return isEN ? `Nearly ${differenceSeconds} seconds` : `近 ${differenceSeconds} 秒`;
|
|
204
202
|
};
|
|
205
203
|
const setNow = () => {
|
|
206
204
|
const selected = import_constant.NEAR_TIME_LIST.find((item) => item.name === rangeName);
|
|
@@ -215,8 +213,9 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
215
213
|
(0, import_react.useImperativeHandle)(ref, () => ({
|
|
216
214
|
updateCurrentTime: setNow
|
|
217
215
|
}));
|
|
218
|
-
const
|
|
219
|
-
const
|
|
216
|
+
const currentRange = selects.find((_item) => _item.name === rangeName);
|
|
217
|
+
const rangeLabel = rangeName === import_constant.CUSTOMIZE ? getCustomizeRangeLabel() : currentRange == null ? void 0 : currentRange.rangeLabel;
|
|
218
|
+
const label = rangeName === import_constant.CUSTOMIZE ? getCustomizeLabel() : isEN ? currentRange.enLabel || currentRange.label : currentRange.label;
|
|
220
219
|
const thisYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
221
220
|
const isThisYear = (startTime == null ? void 0 : startTime.year()) === thisYear && (endTime == null ? void 0 : endTime.year()) === thisYear;
|
|
222
221
|
const rangeNameIndex = (0, import_lodash.findIndex)(selects, (item) => item.name === rangeName);
|
|
@@ -258,7 +257,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
258
257
|
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}-dropdown-picker` }, originNode, /* @__PURE__ */ import_react.default.createElement(import_design.Divider, { type: "vertical", style: { height: "auto", margin: "0px 4px 0px 0px" } }), /* @__PURE__ */ import_react.default.createElement(
|
|
259
258
|
import_PickerPanel.default,
|
|
260
259
|
{
|
|
261
|
-
defaultValue: innerValue,
|
|
260
|
+
defaultValue: innerValue || [],
|
|
262
261
|
locale,
|
|
263
262
|
disabledDate: pastOnly ? disabledFuture : disabledDate,
|
|
264
263
|
tip,
|
|
@@ -301,7 +300,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
301
300
|
}).map((item) => {
|
|
302
301
|
return {
|
|
303
302
|
key: item.name,
|
|
304
|
-
label: /* @__PURE__ */ import_react.default.createElement(import_design.Space, { size: 8, style: { minWidth: 100 } }, hasTagInPicker && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefix}-label` }, item.rangeLabel),
|
|
303
|
+
label: /* @__PURE__ */ import_react.default.createElement(import_design.Space, { size: 8, style: { minWidth: 100 } }, hasTagInPicker && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefix}-label` }, item.rangeLabel), isEN ? item.enLabel || item.label : item.label)
|
|
305
304
|
};
|
|
306
305
|
})
|
|
307
306
|
}
|
|
@@ -329,7 +328,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
329
328
|
{
|
|
330
329
|
className: (0, import_classnames.default)(`${prefix}-picker`),
|
|
331
330
|
style: {
|
|
332
|
-
pointerEvents:
|
|
331
|
+
// pointerEvents: 'none',
|
|
333
332
|
border: 0
|
|
334
333
|
},
|
|
335
334
|
format: (v) => {
|
|
@@ -345,7 +344,8 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
345
344
|
allowClear: false,
|
|
346
345
|
size,
|
|
347
346
|
suffixIcon: null,
|
|
348
|
-
...(0, import_lodash.omit)(rest, "value", "onChange")
|
|
347
|
+
...(0, import_lodash.omit)(rest, "value", "onChange"),
|
|
348
|
+
open: false
|
|
349
349
|
}
|
|
350
350
|
)
|
|
351
351
|
)
|
|
@@ -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;
|