@oceanbase/ui 1.0.0-alpha.17 → 1.0.0-alpha.18
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.js +1 -1
- package/es/DateRanger/EditableDateTimeInput.d.ts +6 -1
- package/es/DateRanger/EditableDateTimeInput.js +21 -11
- package/es/DateRanger/Ranger.d.ts +4 -1
- package/es/DateRanger/Ranger.js +25 -9
- package/es/DateRanger/hooks/index.d.ts +1 -1
- package/es/DateRanger/hooks/useSegmentedInput.d.ts +8 -16
- package/es/DateRanger/hooks/useSegmentedInput.js +228 -351
- package/es/DateRanger/style/index.js +12 -4
- package/es/Highlight/index.d.ts +1 -1
- package/lib/DateRanger/EditableDateTimeInput.d.ts +6 -1
- package/lib/DateRanger/EditableDateTimeInput.js +17 -10
- package/lib/DateRanger/Ranger.d.ts +4 -1
- package/lib/DateRanger/Ranger.js +23 -7
- package/lib/DateRanger/hooks/index.d.ts +1 -1
- package/lib/DateRanger/hooks/useSegmentedInput.d.ts +8 -16
- package/lib/DateRanger/hooks/useSegmentedInput.js +158 -298
- package/lib/DateRanger/style/index.js +14 -1
- package/lib/Highlight/index.d.ts +1 -1
- package/package.json +3 -3
|
@@ -13,6 +13,11 @@ export interface EditableDateTimeInputProps {
|
|
|
13
13
|
prefixCls?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
onClick?: () => void;
|
|
16
|
+
open?: boolean;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
export interface EditableDateTimeInputRef {
|
|
19
|
+
hasPastedValue: boolean;
|
|
20
|
+
confirmPastedValue: () => void;
|
|
21
|
+
}
|
|
22
|
+
declare const EditableDateTimeInput: React.ForwardRefExoticComponent<EditableDateTimeInputProps & React.RefAttributes<EditableDateTimeInputRef>>;
|
|
18
23
|
export default EditableDateTimeInput;
|
|
@@ -3,12 +3,12 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
3
3
|
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; }
|
|
4
4
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
5
5
|
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); }
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
6
|
+
import React, { useMemo, useImperativeHandle, forwardRef } from 'react';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { Input } from '@oceanbase/design';
|
|
9
9
|
import { useSegmentedInput } from "./hooks/useSegmentedInput";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
var EditableDateTimeInput = function
|
|
11
|
+
var EditableDateTimeInput = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
12
|
var value = props.value,
|
|
13
13
|
onChange = props.onChange,
|
|
14
14
|
formatProp = props.format,
|
|
@@ -25,7 +25,9 @@ var EditableDateTimeInput = function EditableDateTimeInput(props) {
|
|
|
25
25
|
prefixCls = _props$prefixCls === void 0 ? 'ant-picker' : _props$prefixCls,
|
|
26
26
|
_props$disabled = props.disabled,
|
|
27
27
|
disabled = _props$disabled === void 0 ? false : _props$disabled,
|
|
28
|
-
onClick = props.onClick
|
|
28
|
+
onClick = props.onClick,
|
|
29
|
+
_props$open = props.open,
|
|
30
|
+
open = _props$open === void 0 ? false : _props$open;
|
|
29
31
|
|
|
30
32
|
// 根据配置生成格式,优先使用外部传入的 format
|
|
31
33
|
var format = useMemo(function () {
|
|
@@ -70,16 +72,26 @@ var EditableDateTimeInput = function EditableDateTimeInput(props) {
|
|
|
70
72
|
baseFormat: baseFormat,
|
|
71
73
|
isMoment: isMoment,
|
|
72
74
|
isCn: isCn,
|
|
73
|
-
onClick: onClick
|
|
75
|
+
onClick: onClick,
|
|
76
|
+
open: open
|
|
74
77
|
}),
|
|
75
78
|
inputRef = _useSegmentedInput.inputRef,
|
|
76
79
|
isEditing = _useSegmentedInput.isEditing,
|
|
77
80
|
displayValue = _useSegmentedInput.displayValue,
|
|
78
81
|
handleClick = _useSegmentedInput.handleClick,
|
|
79
82
|
handleDoubleClick = _useSegmentedInput.handleDoubleClick,
|
|
80
|
-
handleKeyDown = _useSegmentedInput.handleKeyDown,
|
|
81
83
|
handleBlur = _useSegmentedInput.handleBlur,
|
|
82
|
-
|
|
84
|
+
handleKeyDown = _useSegmentedInput.handleKeyDown,
|
|
85
|
+
hasPastedValue = _useSegmentedInput.hasPastedValue,
|
|
86
|
+
confirmPastedValue = _useSegmentedInput.confirmPastedValue;
|
|
87
|
+
|
|
88
|
+
// 暴露方法给父组件
|
|
89
|
+
useImperativeHandle(ref, function () {
|
|
90
|
+
return {
|
|
91
|
+
hasPastedValue: hasPastedValue,
|
|
92
|
+
confirmPastedValue: confirmPastedValue
|
|
93
|
+
};
|
|
94
|
+
});
|
|
83
95
|
return /*#__PURE__*/_jsx("div", {
|
|
84
96
|
className: classNames("".concat(prefixCls, "-range-editable"), className, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-range-editable-focused"), isEditing), "".concat(prefixCls, "-range-editable-disabled"), disabled)),
|
|
85
97
|
children: /*#__PURE__*/_jsx(Input, {
|
|
@@ -91,12 +103,10 @@ var EditableDateTimeInput = function EditableDateTimeInput(props) {
|
|
|
91
103
|
variant: "borderless",
|
|
92
104
|
onClick: handleClick,
|
|
93
105
|
onDoubleClick: handleDoubleClick,
|
|
94
|
-
onKeyDown: handleKeyDown
|
|
95
|
-
// onFocus={handleFocus}
|
|
96
|
-
,
|
|
97
106
|
onBlur: handleBlur,
|
|
98
|
-
|
|
107
|
+
onKeyDown: handleKeyDown
|
|
99
108
|
})
|
|
100
109
|
});
|
|
101
|
-
};
|
|
110
|
+
});
|
|
111
|
+
EditableDateTimeInput.displayName = 'EditableDateTimeInput';
|
|
102
112
|
export default EditableDateTimeInput;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import type { TooltipProps } from '@oceanbase/design';
|
|
3
3
|
import type { RangePickerProps } from '@oceanbase/design/es/date-picker';
|
|
4
4
|
import type { Dayjs } from 'dayjs';
|
|
5
|
+
import 'dayjs/locale/zh-cn';
|
|
5
6
|
import type { Moment } from 'moment';
|
|
6
7
|
import type { RangeOption } from './typing';
|
|
7
8
|
import type { Rule } from './PickerPanel';
|
|
@@ -12,7 +13,7 @@ export type RangeDateValue = {
|
|
|
12
13
|
name: RangeName;
|
|
13
14
|
range: RangeValue;
|
|
14
15
|
};
|
|
15
|
-
export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker' | 'value' | 'defaultValue'> {
|
|
16
|
+
export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker' | 'value' | 'defaultValue' | 'variant'> {
|
|
16
17
|
selects?: RangeOption[];
|
|
17
18
|
defaultQuickValue?: string;
|
|
18
19
|
hasRewind?: boolean;
|
|
@@ -37,6 +38,8 @@ export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker
|
|
|
37
38
|
value?: RangeValue;
|
|
38
39
|
defaultValue?: RangeValue;
|
|
39
40
|
size?: 'small' | 'large' | 'middle';
|
|
41
|
+
/** 边框变体,默认实线,可配置为 dashed 虚线 */
|
|
42
|
+
variant?: 'dashed';
|
|
40
43
|
tooltipProps?: TooltipProps;
|
|
41
44
|
autoAdjustOverflow?: boolean;
|
|
42
45
|
overlayClassName?: string;
|
package/es/DateRanger/Ranger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "history", "onChange", "disabledDate", "locale", "size", "stickRangeName", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
|
|
2
|
+
var _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "history", "onChange", "disabledDate", "locale", "size", "stickRangeName", "variant", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
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; }
|
|
@@ -22,6 +22,7 @@ import React, { useContext, useEffect, useRef, useState, useImperativeHandle, us
|
|
|
22
22
|
import { Button, ConfigProvider, Divider, Dropdown, Flex, Menu, Radio, Space, Tooltip, message, theme } from '@oceanbase/design';
|
|
23
23
|
import { LeftOutlined, RightOutlined, ZoomOutOutlined, SyncOutlined, ArrowLeftOutlined, CopyOutlined, DeleteOutlined } from '@oceanbase/icons';
|
|
24
24
|
import dayjs from 'dayjs';
|
|
25
|
+
import 'dayjs/locale/zh-cn';
|
|
25
26
|
import { findIndex, isEqual as _isEqual, isNil, noop, omit } from 'lodash';
|
|
26
27
|
import moment from 'moment';
|
|
27
28
|
import classNames from 'classnames';
|
|
@@ -80,6 +81,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
80
81
|
size = props.size,
|
|
81
82
|
_props$stickRangeName = props.stickRangeName,
|
|
82
83
|
stickRangeName = _props$stickRangeName === void 0 ? false : _props$stickRangeName,
|
|
84
|
+
variant = props.variant,
|
|
83
85
|
tooltipProps = props.tooltipProps,
|
|
84
86
|
isMomentProps = props.isMoment,
|
|
85
87
|
rules = props.rules,
|
|
@@ -133,6 +135,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
133
135
|
var rangeRef = useRef(null);
|
|
134
136
|
var popRef = useRef(null);
|
|
135
137
|
var labelRef = useRef(null);
|
|
138
|
+
var editableInputRef = useRef(null);
|
|
136
139
|
|
|
137
140
|
// 没有 selects 时,回退到普通 RangePicker, 当前时间选项为自定义时,应该显示 RangePicker
|
|
138
141
|
var _useState13 = useState(rangeName !== CUSTOMIZE),
|
|
@@ -317,7 +320,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
317
320
|
return diffMs > differenceMs;
|
|
318
321
|
}) : selects[rangeNameIndex + 1];
|
|
319
322
|
return wrapSSR( /*#__PURE__*/_jsxs(Space, {
|
|
320
|
-
className: classNames(rest.className, _defineProperty(_defineProperty(_defineProperty({}, prefix, true), "".concat(prefix, "-show-range"), true), "".concat(prefix, "-back-radio-focused"), backRadioFocused)),
|
|
323
|
+
className: classNames(rest.className, _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, prefix, true), "".concat(prefix, "-show-range"), true), "".concat(prefix, "-dashed"), variant === 'dashed'), "".concat(prefix, "-back-radio-focused"), backRadioFocused)),
|
|
321
324
|
style: rest.style,
|
|
322
325
|
children: [/*#__PURE__*/_jsxs(Space, {
|
|
323
326
|
size: 0,
|
|
@@ -452,12 +455,22 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
452
455
|
rules: rules,
|
|
453
456
|
hideSecond: hideSecond,
|
|
454
457
|
onOk: function onOk(vList) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
var _editableInputRef$cur;
|
|
459
|
+
// 如果有粘贴值,优先使用粘贴值
|
|
460
|
+
if ((_editableInputRef$cur = editableInputRef.current) !== null && _editableInputRef$cur !== void 0 && _editableInputRef$cur.hasPastedValue) {
|
|
461
|
+
editableInputRef.current.confirmPastedValue();
|
|
462
|
+
setIsPlay(false);
|
|
463
|
+
handleNameChange(CUSTOMIZE);
|
|
464
|
+
closeTooltip();
|
|
465
|
+
} else {
|
|
466
|
+
// 否则使用面板中的值
|
|
467
|
+
setIsPlay(false);
|
|
468
|
+
handleNameChange(CUSTOMIZE);
|
|
469
|
+
rangeChange(vList.map(function (v) {
|
|
470
|
+
return isMoment ? moment(v) : dayjs(v);
|
|
471
|
+
}));
|
|
472
|
+
closeTooltip();
|
|
473
|
+
}
|
|
461
474
|
},
|
|
462
475
|
onCancel: function onCancel() {
|
|
463
476
|
closeTooltip();
|
|
@@ -521,6 +534,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
521
534
|
ref: rangeRef,
|
|
522
535
|
className: "".concat(prefix, "-editable-wrapper"),
|
|
523
536
|
children: /*#__PURE__*/_jsx(EditableDateTimeInput, _objectSpread({
|
|
537
|
+
ref: editableInputRef,
|
|
524
538
|
prefixCls: prefixCls,
|
|
525
539
|
value: innerValue,
|
|
526
540
|
onChange: function onChange(newValue) {
|
|
@@ -530,11 +544,13 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
530
544
|
hideSecond: hideSecond,
|
|
531
545
|
isMoment: isMoment,
|
|
532
546
|
isCn: isCn,
|
|
547
|
+
format: (rest === null || rest === void 0 ? void 0 : rest.format) || YEAR_DATE_TIME_SECOND_FORMAT_CN,
|
|
548
|
+
open: open,
|
|
533
549
|
onClick: function onClick() {
|
|
534
550
|
setOpen(true);
|
|
535
551
|
setTooltipOpen(true);
|
|
536
552
|
}
|
|
537
|
-
}, omit(rest, 'value', 'onChange', 'style', 'className', 'onClick', '
|
|
553
|
+
}, omit(rest, 'value', 'onChange', 'style', 'className', 'onClick', 'disabled', 'format')))
|
|
538
554
|
})]
|
|
539
555
|
}), /*#__PURE__*/_jsxs(Radio.Group, {
|
|
540
556
|
value: isPlay ? 'play' : '',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useSegmentedInput } from './useSegmentedInput';
|
|
2
|
-
export type {
|
|
2
|
+
export type { UseSegmentedInputOptions, UseSegmentedInputReturn } from './useSegmentedInput';
|
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { Dayjs } from 'dayjs';
|
|
3
3
|
import type { Moment } from 'moment';
|
|
4
|
+
import 'dayjs/locale/en';
|
|
5
|
+
import 'dayjs/locale/zh-cn';
|
|
4
6
|
import type { InputRef } from '@oceanbase/design';
|
|
5
|
-
export type SegmentType = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
|
|
6
|
-
export type RangeType = 'start' | 'end';
|
|
7
|
-
export interface Segment {
|
|
8
|
-
type: SegmentType;
|
|
9
|
-
range: RangeType;
|
|
10
|
-
start: number;
|
|
11
|
-
end: number;
|
|
12
|
-
value: string;
|
|
13
|
-
min: number;
|
|
14
|
-
max: number;
|
|
15
|
-
padLength: number;
|
|
16
|
-
}
|
|
17
7
|
export interface UseSegmentedInputOptions {
|
|
18
8
|
value?: [Dayjs | Moment | null, Dayjs | Moment | null];
|
|
19
9
|
onChange?: (value: [Dayjs | Moment, Dayjs | Moment]) => void;
|
|
@@ -22,18 +12,20 @@ export interface UseSegmentedInputOptions {
|
|
|
22
12
|
isMoment?: boolean;
|
|
23
13
|
isCn?: boolean;
|
|
24
14
|
onClick?: () => void;
|
|
15
|
+
locale?: string;
|
|
16
|
+
open?: boolean;
|
|
25
17
|
}
|
|
26
18
|
export interface UseSegmentedInputReturn {
|
|
27
19
|
inputRef: React.RefObject<InputRef>;
|
|
28
20
|
isEditing: boolean;
|
|
29
21
|
displayValue: string;
|
|
30
|
-
currentSegment: Segment | null;
|
|
31
|
-
allSegments: Segment[];
|
|
32
22
|
handleClick: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
33
23
|
handleDoubleClick: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
34
|
-
handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
35
24
|
handleBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
36
|
-
|
|
25
|
+
handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
26
|
+
confirmPastedValue: () => void;
|
|
27
|
+
hasPastedValue: boolean;
|
|
28
|
+
getPastedValue: () => [Dayjs | Moment, Dayjs | Moment] | null;
|
|
37
29
|
}
|
|
38
30
|
export declare const useSegmentedInput: (options: UseSegmentedInputOptions) => UseSegmentedInputReturn;
|
|
39
31
|
export default useSegmentedInput;
|