@oceanbase/ui 1.0.0-alpha.16 → 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
|
@@ -4,6 +4,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
4
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
5
|
import { genComponentStyleHook } from "../../_util/genComponentStyleHook";
|
|
6
6
|
export var genDateRangerStyle = function genDateRangerStyle(token) {
|
|
7
|
+
var _ref;
|
|
7
8
|
var componentCls = token.componentCls,
|
|
8
9
|
antCls = token.antCls,
|
|
9
10
|
colorBgContainer = token.colorBgContainer,
|
|
@@ -12,7 +13,7 @@ export var genDateRangerStyle = function genDateRangerStyle(token) {
|
|
|
12
13
|
colorTextSecondary = token.colorTextSecondary,
|
|
13
14
|
colorFillSecondary = token.colorFillSecondary,
|
|
14
15
|
colorFill = token.colorFill;
|
|
15
|
-
return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(
|
|
16
|
+
return _ref = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, "".concat(componentCls), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
16
17
|
cursor: 'pointer'
|
|
17
18
|
}, "".concat(componentCls, "-wrapper"), _defineProperty(_defineProperty({
|
|
18
19
|
backgroundColor: colorBgContainer,
|
|
@@ -99,7 +100,14 @@ export var genDateRangerStyle = function genDateRangerStyle(token) {
|
|
|
99
100
|
width: 52,
|
|
100
101
|
borderRadius: token.borderRadiusSM,
|
|
101
102
|
textAlign: 'center'
|
|
102
|
-
}), "".concat(componentCls, "-
|
|
103
|
+
}), "".concat(componentCls, "-dashed"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-wrapper"), {
|
|
104
|
+
borderStyle: 'dashed'
|
|
105
|
+
}), "".concat(componentCls, "-playback-control"), _defineProperty({}, "".concat(antCls, "-radio-button-wrapper"), {
|
|
106
|
+
borderStyle: 'dashed',
|
|
107
|
+
'&::before': {
|
|
108
|
+
borderStyle: 'dashed'
|
|
109
|
+
}
|
|
110
|
+
}))), "".concat(componentCls, "-back-radio-focused"), _defineProperty(_defineProperty({}, "".concat(componentCls, "-wrapper"), {
|
|
103
111
|
borderRightColor: token.gray7
|
|
104
112
|
}), "".concat(componentCls, "-playback-control"), _defineProperty({}, "".concat(antCls, "-radio-button-wrapper:first-child"), _defineProperty({}, "+ ".concat(antCls, "-radio-button-wrapper::before"), {
|
|
105
113
|
backgroundColor: token.gray7
|
|
@@ -127,8 +135,8 @@ export var genDateRangerStyle = function genDateRangerStyle(token) {
|
|
|
127
135
|
cursor: 'not-allowed',
|
|
128
136
|
opacity: 0.6
|
|
129
137
|
}
|
|
130
|
-
}), "".concat(componentCls, "-range-editable-input"), {
|
|
131
|
-
width:
|
|
138
|
+
}), _defineProperty(_ref, "".concat(componentCls, "-range-editable-input"), {
|
|
139
|
+
width: 310,
|
|
132
140
|
cursor: 'text',
|
|
133
141
|
caretColor: 'transparent',
|
|
134
142
|
'&:focus, &:focus-within': _defineProperty({}, "".concat(antCls, "-input"), {
|
package/es/Highlight/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const THEME_DARK = "dark";
|
|
|
28
28
|
export declare const THEME_LIGHT = "light";
|
|
29
29
|
declare const ThemeTypes: ["dark", "light"];
|
|
30
30
|
export type ThemeType = (typeof ThemeTypes)[number];
|
|
31
|
-
declare const supportedLanguages: ("
|
|
31
|
+
declare const supportedLanguages: ("css" | "json" | "jsx" | "tsx" | "ruby" | "javascript" | "typescript" | "groovy" | "java" | "python" | "bash" | "cpp" | "http" | "markdown" | "nginx" | "sql" | "xml" | "dockerfile" | "go" | "yaml" | "solidity")[];
|
|
32
32
|
export type LanguageType = (typeof supportedLanguages)[number] | 'html';
|
|
33
33
|
export interface HighlightProps extends LocaleWrapperProps {
|
|
34
34
|
/**
|
|
@@ -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;
|
|
@@ -12,7 +12,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
const EditableDateTimeInput = props => {
|
|
15
|
+
const EditableDateTimeInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
16
16
|
const {
|
|
17
17
|
value,
|
|
18
18
|
onChange,
|
|
@@ -24,7 +24,8 @@ const EditableDateTimeInput = props => {
|
|
|
24
24
|
className,
|
|
25
25
|
prefixCls = 'ant-picker',
|
|
26
26
|
disabled = false,
|
|
27
|
-
onClick
|
|
27
|
+
onClick,
|
|
28
|
+
open = false
|
|
28
29
|
} = props;
|
|
29
30
|
|
|
30
31
|
// 根据配置生成格式,优先使用外部传入的 format
|
|
@@ -70,9 +71,10 @@ const EditableDateTimeInput = props => {
|
|
|
70
71
|
displayValue,
|
|
71
72
|
handleClick,
|
|
72
73
|
handleDoubleClick,
|
|
73
|
-
handleKeyDown,
|
|
74
74
|
handleBlur,
|
|
75
|
-
|
|
75
|
+
handleKeyDown,
|
|
76
|
+
hasPastedValue,
|
|
77
|
+
confirmPastedValue
|
|
76
78
|
} = (0, _useSegmentedInput.useSegmentedInput)({
|
|
77
79
|
value,
|
|
78
80
|
onChange,
|
|
@@ -80,8 +82,15 @@ const EditableDateTimeInput = props => {
|
|
|
80
82
|
baseFormat,
|
|
81
83
|
isMoment,
|
|
82
84
|
isCn,
|
|
83
|
-
onClick
|
|
85
|
+
onClick,
|
|
86
|
+
open
|
|
84
87
|
});
|
|
88
|
+
|
|
89
|
+
// 暴露方法给父组件
|
|
90
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
91
|
+
hasPastedValue,
|
|
92
|
+
confirmPastedValue
|
|
93
|
+
}));
|
|
85
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
86
95
|
className: (0, _classnames.default)(`${prefixCls}-range-editable`, className, {
|
|
87
96
|
[`${prefixCls}-range-editable-focused`]: isEditing,
|
|
@@ -96,12 +105,10 @@ const EditableDateTimeInput = props => {
|
|
|
96
105
|
variant: "borderless",
|
|
97
106
|
onClick: handleClick,
|
|
98
107
|
onDoubleClick: handleDoubleClick,
|
|
99
|
-
onKeyDown: handleKeyDown
|
|
100
|
-
// onFocus={handleFocus}
|
|
101
|
-
,
|
|
102
108
|
onBlur: handleBlur,
|
|
103
|
-
|
|
109
|
+
onKeyDown: handleKeyDown
|
|
104
110
|
})
|
|
105
111
|
});
|
|
106
|
-
};
|
|
112
|
+
});
|
|
113
|
+
EditableDateTimeInput.displayName = 'EditableDateTimeInput';
|
|
107
114
|
var _default = exports.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/lib/DateRanger/Ranger.js
CHANGED
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _design = require("@oceanbase/design");
|
|
9
9
|
var _icons = require("@oceanbase/icons");
|
|
10
10
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
|
+
require("dayjs/locale/zh-cn");
|
|
11
12
|
var _lodash = require("lodash");
|
|
12
13
|
var _moment = _interopRequireDefault(require("moment"));
|
|
13
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
@@ -56,6 +57,7 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
56
57
|
size,
|
|
57
58
|
//固定 rangeName
|
|
58
59
|
stickRangeName = false,
|
|
60
|
+
variant,
|
|
59
61
|
tooltipProps,
|
|
60
62
|
isMoment: isMomentProps,
|
|
61
63
|
rules,
|
|
@@ -90,6 +92,7 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
90
92
|
const rangeRef = (0, _react.useRef)(null);
|
|
91
93
|
const popRef = (0, _react.useRef)(null);
|
|
92
94
|
const labelRef = (0, _react.useRef)(null);
|
|
95
|
+
const editableInputRef = (0, _react.useRef)(null);
|
|
93
96
|
|
|
94
97
|
// 没有 selects 时,回退到普通 RangePicker, 当前时间选项为自定义时,应该显示 RangePicker
|
|
95
98
|
const [isPlay, setIsPlay] = (0, _react.useState)(rangeName !== _constant.CUSTOMIZE);
|
|
@@ -258,6 +261,7 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
258
261
|
className: (0, _classnames.default)(rest.className, {
|
|
259
262
|
[prefix]: true,
|
|
260
263
|
[`${prefix}-show-range`]: true,
|
|
264
|
+
[`${prefix}-dashed`]: variant === 'dashed',
|
|
261
265
|
[`${prefix}-back-radio-focused`]: backRadioFocused
|
|
262
266
|
}),
|
|
263
267
|
style: rest.style,
|
|
@@ -393,12 +397,21 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
393
397
|
rules: rules,
|
|
394
398
|
hideSecond: hideSecond,
|
|
395
399
|
onOk: vList => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
400
|
+
// 如果有粘贴值,优先使用粘贴值
|
|
401
|
+
if (editableInputRef.current?.hasPastedValue) {
|
|
402
|
+
editableInputRef.current.confirmPastedValue();
|
|
403
|
+
setIsPlay(false);
|
|
404
|
+
handleNameChange(_constant.CUSTOMIZE);
|
|
405
|
+
closeTooltip();
|
|
406
|
+
} else {
|
|
407
|
+
// 否则使用面板中的值
|
|
408
|
+
setIsPlay(false);
|
|
409
|
+
handleNameChange(_constant.CUSTOMIZE);
|
|
410
|
+
rangeChange(vList.map(v => {
|
|
411
|
+
return isMoment ? (0, _moment.default)(v) : (0, _dayjs.default)(v);
|
|
412
|
+
}));
|
|
413
|
+
closeTooltip();
|
|
414
|
+
}
|
|
402
415
|
},
|
|
403
416
|
onCancel: () => {
|
|
404
417
|
closeTooltip();
|
|
@@ -461,6 +474,7 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
461
474
|
ref: rangeRef,
|
|
462
475
|
className: `${prefix}-editable-wrapper`,
|
|
463
476
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditableDateTimeInput.default, {
|
|
477
|
+
ref: editableInputRef,
|
|
464
478
|
prefixCls: prefixCls,
|
|
465
479
|
value: innerValue,
|
|
466
480
|
onChange: newValue => {
|
|
@@ -470,11 +484,13 @@ const Ranger = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
470
484
|
hideSecond: hideSecond,
|
|
471
485
|
isMoment: isMoment,
|
|
472
486
|
isCn: isCn,
|
|
487
|
+
format: rest?.format || _constant.YEAR_DATE_TIME_SECOND_FORMAT_CN,
|
|
488
|
+
open: open,
|
|
473
489
|
onClick: () => {
|
|
474
490
|
setOpen(true);
|
|
475
491
|
setTooltipOpen(true);
|
|
476
492
|
},
|
|
477
|
-
...(0, _lodash.omit)(rest, 'value', 'onChange', 'style', 'className', 'onClick', '
|
|
493
|
+
...(0, _lodash.omit)(rest, 'value', 'onChange', 'style', 'className', 'onClick', 'disabled', 'format')
|
|
478
494
|
})
|
|
479
495
|
})]
|
|
480
496
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_design.Radio.Group, {
|
|
@@ -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;
|