@king-design/react 3.6.0-beta.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/__snapshots__/React Demos.md +117 -61
- package/components/cascader/index.spec.js +18 -19
- package/components/copy/index.spec.js +14 -31
- package/components/datepicker/basepicker.d.ts +6 -27
- package/components/datepicker/basepicker.js +23 -268
- package/components/datepicker/calendar.d.ts +4 -2
- package/components/datepicker/dayjs.d.ts +2 -13
- package/components/datepicker/helpers.d.ts +3 -2
- package/components/datepicker/helpers.js +2 -3
- package/components/datepicker/index.d.ts +21 -29
- package/components/datepicker/index.js +22 -32
- package/components/datepicker/index.spec.js +1277 -484
- package/components/datepicker/index.vdt.js +39 -38
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/styles.d.ts +7 -2
- package/components/datepicker/styles.js +10 -15
- package/components/datepicker/useConfirm.d.ts +6 -0
- package/components/datepicker/useConfirm.js +65 -0
- package/components/datepicker/useDisabled.d.ts +5 -3
- package/components/datepicker/useDisabled.js +22 -27
- package/components/datepicker/useFormats.d.ts +2 -2
- package/components/datepicker/useFormats.js +6 -2
- package/components/datepicker/useHighlight.d.ts +14 -0
- package/components/datepicker/useHighlight.js +60 -0
- package/components/datepicker/useKeyboards.js +2 -1
- package/components/datepicker/useMergeRange.d.ts +1 -1
- package/components/datepicker/useMergeRange.js +11 -16
- package/components/datepicker/useMonths.js +5 -3
- package/components/datepicker/usePanel.d.ts +1 -10
- package/components/datepicker/usePanel.js +19 -32
- package/components/datepicker/useShowDate.d.ts +1 -1
- package/components/datepicker/useShowDate.js +15 -40
- package/components/datepicker/useStatus.js +33 -16
- package/components/datepicker/useValue.d.ts +11 -6
- package/components/datepicker/useValue.js +49 -69
- package/components/datepicker/useValueBase.d.ts +28 -0
- package/components/datepicker/useValueBase.js +280 -0
- package/components/datepicker/useYears.js +6 -3
- package/components/dropdown/dropdown.d.ts +1 -0
- package/components/dropdown/dropdown.js +7 -4
- package/components/form/form.d.ts +1 -0
- package/components/form/form.js +7 -0
- package/components/form/index.spec.js +10 -8
- package/components/input/index.d.ts +2 -0
- package/components/input/index.js +6 -0
- package/components/input/index.spec.js +45 -0
- package/components/input/index.vdt.js +4 -3
- package/components/input/useAutoWidth.d.ts +2 -0
- package/components/input/useAutoWidth.js +19 -1
- package/components/menu/index.spec.js +28 -0
- package/components/menu/styles.js +2 -2
- package/components/scrollSelect/useMouseEvents.js +5 -4
- package/components/select/base.d.ts +1 -1
- package/components/select/base.js +3 -2
- package/components/select/base.vdt.js +4 -3
- package/components/select/index.spec.js +346 -218
- package/components/select/menu.js +1 -1
- package/components/select/option.js +2 -1
- package/components/select/select.js +2 -1
- package/components/select/styles.d.ts +79 -0
- package/components/select/styles.js +1 -0
- package/components/select/useCard.d.ts +4 -3
- package/components/select/useCard.js +15 -4
- package/components/select/useInput.d.ts +1 -1
- package/components/select/useInput.js +4 -4
- package/components/spinner/index.spec.js +82 -44
- package/components/spinner/useValue.js +2 -1
- package/components/table/index.spec.js +84 -6
- package/components/table/useStickyHeader.js +1 -1
- package/components/timepicker/index.spec.js +298 -128
- package/components/timepicker/panelPicker.d.ts +21 -16
- package/components/timepicker/panelPicker.js +7 -4
- package/components/timepicker/panelPicker.vdt.js +5 -9
- package/components/timepicker/selectPicker.d.ts +4 -3
- package/components/timepicker/styles.js +1 -1
- package/components/timepicker/useConfirm.d.ts +6 -0
- package/components/timepicker/useConfirm.js +19 -0
- package/components/timepicker/useDefaultValue.d.ts +4 -0
- package/components/timepicker/useDefaultValue.js +27 -0
- package/components/timepicker/useDisabled.d.ts +6 -3
- package/components/timepicker/useDisabled.js +13 -4
- package/components/timepicker/useFormats.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +13 -8
- package/components/timepicker/useValue.js +14 -15
- package/components/tour/index.spec.js +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/yarn-error.log +528 -0
- package/components/datepicker/usePosition.d.ts +0 -10
- package/components/datepicker/usePosition.js +0 -166
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { TypeDefs } from 'intact-react';
|
|
2
2
|
import dayjs from './dayjs';
|
|
3
|
-
import { State } from '../../hooks/useState';
|
|
4
3
|
import { Shortcut } from './shortcuts';
|
|
5
|
-
import { BasePicker, BasePickerProps, BasePickerEvents, BasePickerBlocks
|
|
4
|
+
import { BasePicker, BasePickerProps, BasePickerEvents, BasePickerBlocks } from './basepicker';
|
|
5
|
+
import { Value } from './useValueBase';
|
|
6
6
|
export * as shortcuts from './shortcuts';
|
|
7
7
|
export { dayjs };
|
|
8
8
|
export interface DatepickerProps<V extends Value = Value, M extends boolean = boolean, R extends boolean = boolean> extends BasePickerProps<V extends string ? V : V | string, M, R> {
|
|
9
9
|
type?: 'date' | 'datetime' | 'year' | 'month' | 'week' | 'quarter';
|
|
10
10
|
shortcuts?: Shortcut[];
|
|
11
|
-
isMerge?: boolean;
|
|
12
11
|
}
|
|
13
12
|
export interface DatepickerEvents extends BasePickerEvents {
|
|
14
13
|
}
|
|
@@ -28,52 +27,45 @@ export declare class Datepicker<V extends Value = Value, M extends boolean = fal
|
|
|
28
27
|
};
|
|
29
28
|
disabled: {
|
|
30
29
|
isDisabled: (value: dayjs.Dayjs, type?: "h" | "s" | "y" | "date" | "month" | "week" | "millisecond" | "second" | "minute" | "hour" | "day" | "year" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years" | "dates" | "d" | "D" | "M" | "m" | "ms" | "weeks" | "w" | "quarter" | "quarters" | "Q") => boolean;
|
|
31
|
-
isDisabledTime: (value: dayjs.Dayjs
|
|
30
|
+
isDisabledTime: (value: dayjs.Dayjs) => boolean;
|
|
32
31
|
isDisabledConfirm: () => boolean;
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
isDisabledValue: (value: import("./useValueBase").StateValueItem) => boolean;
|
|
33
|
+
maxDate: import("../../hooks/useState").State<dayjs.Dayjs | null>;
|
|
34
|
+
minDate: import("../../hooks/useState").State<dayjs.Dayjs | null>;
|
|
35
35
|
};
|
|
36
36
|
panel: {
|
|
37
|
-
startPanel: State<import("./usePanel").PanelTypes>;
|
|
38
|
-
endPanel: State<import("./usePanel").PanelTypes>;
|
|
39
|
-
changePanel: (type: import("./usePanel").PanelTypes, flag?: import("./usePanel").PanelFlags) => void;
|
|
40
|
-
getPanel: (flag: import("./usePanel").PanelFlags) => State<import("./usePanel").PanelTypes>;
|
|
41
|
-
reset: () => void;
|
|
42
37
|
startRef: import('intact-react').RefObject<import("./calendar").DatepickerCalendar>;
|
|
43
38
|
endRef: import('intact-react').RefObject<import("./calendar").DatepickerCalendar>;
|
|
44
39
|
};
|
|
45
40
|
focusDate: {
|
|
46
|
-
focusDate: State<dayjs.Dayjs | null>;
|
|
41
|
+
focusDate: import("../../hooks/useState").State<dayjs.Dayjs | null>;
|
|
47
42
|
reset: () => void;
|
|
48
43
|
};
|
|
49
44
|
value: {
|
|
50
45
|
format: () => string | string[];
|
|
51
|
-
|
|
46
|
+
formatSingleValue: (value: import("./useValueBase").StateValueItem) => string;
|
|
52
47
|
onChangeTime: (date: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => void;
|
|
53
48
|
getTimeValue: (flag: import("./usePanel").PanelFlags) => dayjs.Dayjs | null | undefined;
|
|
54
|
-
convertToDayjs: (v: Value | [Value, Value] | Value[] | [Value, Value][] | null | undefined) => import("./
|
|
55
|
-
|
|
49
|
+
convertToDayjs: (v: Value | [Value, Value] | Value[] | [Value, Value][] | null | undefined) => import("./useValueBase").DayjsValue;
|
|
50
|
+
unique: () => void;
|
|
56
51
|
setMoment: () => void;
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
updateValue: () => void;
|
|
53
|
+
value: import("../../hooks/useState").State<import("./useValueBase").StateValue>;
|
|
54
|
+
setValue: (v: import("./useValueBase").StateValueItem, fromInput: boolean) => void;
|
|
59
55
|
onChangeDate: (v: dayjs.Dayjs, flag: import("./usePanel").PanelFlags) => void;
|
|
56
|
+
getDayjsValue: () => import("./useValueBase").DayjsValue;
|
|
57
|
+
allValuesUpdatedInMultipleMode: () => boolean | undefined;
|
|
60
58
|
};
|
|
61
|
-
|
|
62
|
-
position: State<"
|
|
63
|
-
|
|
64
|
-
startTextLength: State<number>;
|
|
65
|
-
handleInputClick: (e: MouseEvent) => void;
|
|
66
|
-
resetPosition: (pos?: "end" | "start") => void;
|
|
59
|
+
highlight: {
|
|
60
|
+
position: import("../../hooks/useState").State<import("./useHighlight").Position>;
|
|
61
|
+
handleInputClick: () => void;
|
|
67
62
|
togglePosition: () => void;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
};
|
|
71
|
-
mergeRange: {
|
|
72
|
-
formatMultipleValues: (dayjsValue: import("./basepicker").DayjsValue, results: string[]) => string[];
|
|
63
|
+
highlightWidth: import("../../hooks/useState").State<number>;
|
|
64
|
+
highlightLeft: import("../../hooks/useState").State<number>;
|
|
73
65
|
};
|
|
66
|
+
private confirm;
|
|
74
67
|
init(): void;
|
|
75
68
|
protected getPlaceholder(): string | number | boolean | import("misstime/dist/utils/types").VNode<any> | import('intact-react').Children[];
|
|
76
69
|
protected getLabel(): string | string[];
|
|
77
|
-
protected clear(e: MouseEvent): void;
|
|
78
70
|
private setByShortcut;
|
|
79
71
|
}
|
|
@@ -15,21 +15,22 @@ import { useFormats } from './useFormats';
|
|
|
15
15
|
import { usePanel } from './usePanel';
|
|
16
16
|
import { useFocusDate } from './useFocusDate';
|
|
17
17
|
import { useKeyboards } from './useKeyboards';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
18
|
+
import { useHighlight } from './useHighlight';
|
|
19
|
+
// import {useMergeRange} from './useMergeRange';
|
|
20
20
|
import { BasePicker } from './basepicker';
|
|
21
|
+
import { useConfirm } from './useConfirm';
|
|
21
22
|
import * as _shortcuts from './shortcuts';
|
|
22
23
|
export { _shortcuts as shortcuts };
|
|
23
24
|
export { dayjs };
|
|
24
25
|
var typeDefs = _extends({}, BasePicker.typeDefs, {
|
|
25
26
|
type: ['date', 'datetime', 'year', 'month', 'week', 'quarter'],
|
|
26
|
-
shortcuts: Array
|
|
27
|
-
isMerge: Boolean
|
|
27
|
+
shortcuts: Array
|
|
28
|
+
// isMerge: Boolean
|
|
28
29
|
});
|
|
29
30
|
var defaults = function defaults() {
|
|
30
31
|
return _extends({}, BasePicker.defaults(), {
|
|
31
|
-
type: 'date'
|
|
32
|
-
isMerge: false
|
|
32
|
+
type: 'date'
|
|
33
|
+
// isMerge: false
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
@@ -42,12 +43,17 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
42
43
|
}
|
|
43
44
|
_this = _BasePicker.call.apply(_BasePicker, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
44
45
|
_this.formats = useFormats();
|
|
45
|
-
_this.disabled = useDisabled(_this.formats)
|
|
46
|
+
_this.disabled = useDisabled(_this.formats, function () {
|
|
47
|
+
return _this.highlight.position;
|
|
48
|
+
});
|
|
46
49
|
_this.panel = usePanel();
|
|
47
50
|
_this.focusDate = useFocusDate();
|
|
48
|
-
_this.value = useValue(_this.formats, _this.disabled, _this.panel)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
_this.value = useValue(_this.formats, _this.disabled, _this.panel, function () {
|
|
52
|
+
return _this.highlight.position;
|
|
53
|
+
});
|
|
54
|
+
_this.highlight = useHighlight(_this.value.value, _this.formats.getShowString, _this.input.keywords);
|
|
55
|
+
// public mergeRange = useMergeRange(this.formats);
|
|
56
|
+
_this.confirm = useConfirm(_this.highlight, _this.value, _this.formats.getValueString);
|
|
51
57
|
return _this;
|
|
52
58
|
}
|
|
53
59
|
var _proto = Datepicker.prototype;
|
|
@@ -55,7 +61,6 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
55
61
|
_BasePicker.prototype.init.call(this);
|
|
56
62
|
provide(DATEPICKER, this);
|
|
57
63
|
useKeyboards(this.panel.startRef, this.focusDate.focusDate);
|
|
58
|
-
this.activePosition.setupEventListeners();
|
|
59
64
|
};
|
|
60
65
|
_proto.getPlaceholder = function getPlaceholder() {
|
|
61
66
|
var _this$get = this.get(),
|
|
@@ -67,40 +72,26 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
67
72
|
case 'datetime':
|
|
68
73
|
return range ? _$('开始时间 ~ 结束时间') : _$('请选择日期和时间');
|
|
69
74
|
case 'year':
|
|
70
|
-
return _$('请选择年份');
|
|
75
|
+
return range ? _$('开始年份 ~ 结束年份') : _$('请选择年份');
|
|
71
76
|
case 'month':
|
|
72
|
-
return _$('请选择月份');
|
|
77
|
+
return range ? _$('开始月份 ~ 结束月份') : _$('请选择月份');
|
|
73
78
|
case 'week':
|
|
74
|
-
return _$('请选择周');
|
|
79
|
+
return range ? _$('开始周 ~ 结束周') : _$('请选择周');
|
|
75
80
|
case 'quarter':
|
|
76
|
-
return _$('请选择季度');
|
|
81
|
+
return range ? _$('开始季度 ~ 结束季度') : _$('请选择季度');
|
|
77
82
|
default:
|
|
78
83
|
return range ? _$('开始日期 ~ 结束日期') : _$('请选择日期');
|
|
79
84
|
}
|
|
80
85
|
};
|
|
81
86
|
_proto.getLabel = function getLabel() {
|
|
82
|
-
var _this$get2 = this.get(),
|
|
83
|
-
multiple = _this$get2.multiple;
|
|
84
|
-
if (multiple) {
|
|
85
|
-
var results = this.value.format();
|
|
86
|
-
var dayjsValue = this.value.getDayjsValue();
|
|
87
|
-
return this.mergeRange.formatMultipleValues(dayjsValue, results);
|
|
88
|
-
}
|
|
89
87
|
return this.value.format();
|
|
90
88
|
};
|
|
91
|
-
_proto.clear = function clear(e) {
|
|
92
|
-
_BasePicker.prototype.clear.call(this, e);
|
|
93
|
-
if (this.get('type') === 'datetime') {
|
|
94
|
-
// reset the state to let user re-select
|
|
95
|
-
this.panel.reset();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
89
|
_proto.setByShortcut = function setByShortcut(shortcut) {
|
|
99
90
|
var _this$value = this.value,
|
|
100
91
|
setValue = _this$value.setValue,
|
|
101
92
|
convertToDayjs = _this$value.convertToDayjs;
|
|
102
|
-
var _this$
|
|
103
|
-
multiple = _this$
|
|
93
|
+
var _this$get2 = this.get(),
|
|
94
|
+
multiple = _this$get2.multiple;
|
|
104
95
|
setValue(convertToDayjs(shortcut.value())[0], true);
|
|
105
96
|
if (!multiple) {
|
|
106
97
|
this.hide();
|
|
@@ -111,5 +102,4 @@ export var Datepicker = /*#__PURE__*/function (_BasePicker) {
|
|
|
111
102
|
Datepicker.template = template;
|
|
112
103
|
Datepicker.typeDefs = typeDefs;
|
|
113
104
|
Datepicker.defaults = defaults;
|
|
114
|
-
__decorate([bind], Datepicker.prototype, "clear", null);
|
|
115
105
|
__decorate([bind], Datepicker.prototype, "setByShortcut", null);
|