@king-design/intact 3.5.1 → 3.6.0-beta.0
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/components/breadcrumb/demos/separator.md +4 -4
- package/components/breadcrumb/index.vdt +1 -1
- package/components/breadcrumb/styles.ts +3 -2
- package/components/button/index.md +1 -0
- package/components/datepicker/basepicker.ts +60 -13
- package/components/datepicker/calendar.ts +5 -1
- package/components/datepicker/calendar.vdt +20 -6
- package/components/datepicker/dayjs.ts +22 -2
- package/components/datepicker/demos/multiple.md +0 -5
- package/components/datepicker/demos/nowrap.md +35 -0
- package/components/datepicker/demos/yearMonth.md +8 -2
- package/components/datepicker/helpers.ts +5 -5
- package/components/datepicker/index.md +3 -2
- package/components/datepicker/index.spec.ts +107 -90
- package/components/datepicker/index.ts +23 -5
- package/components/datepicker/index.vdt +34 -35
- package/components/datepicker/styles.ts +102 -3
- package/components/datepicker/useDisabled.ts +3 -3
- package/components/datepicker/useFormats.ts +2 -0
- package/components/datepicker/useMergeRange.ts +54 -0
- package/components/datepicker/usePosition.ts +169 -0
- package/components/datepicker/useQuarters.ts +47 -0
- package/components/datepicker/useShowDate.ts +42 -11
- package/components/datepicker/useValue.ts +35 -4
- package/components/datepicker/useWeeks.ts +58 -0
- package/components/dialog/useFixBody.ts +7 -64
- package/components/ellipsis/styles.ts +4 -0
- package/components/form/styles.ts +1 -0
- package/components/scrollSelect/index.spec.ts +3 -3
- package/components/scrollSelect/useMouseEvents.ts +23 -10
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +13 -0
- package/components/select/index.md +1 -0
- package/components/select/index.spec.ts +180 -0
- package/components/select/option.ts +9 -1
- package/components/select/select.ts +2 -0
- package/components/select/useFilterable.ts +1 -1
- package/components/select/useInput.ts +4 -2
- package/components/select/useSearchable.ts +2 -2
- package/components/table/table.vdt +3 -3
- package/components/timepicker/demos/step.md +1 -1
- package/components/timepicker/panelPicker.vdt +5 -1
- package/components/timepicker/styles.ts +0 -1
- package/components/tour/demos/basic.md +73 -0
- package/components/tour/demos/beforeChange.md +109 -0
- package/components/tour/demos/closable.md +70 -0
- package/components/tour/demos/custom.md +98 -0
- package/components/tour/demos/customText.md +94 -0
- package/components/tour/demos/declarative.md +72 -0
- package/components/tour/demos/events.md +101 -0
- package/components/tour/demos/maskClosable.md +76 -0
- package/components/tour/demos/notarget.md +59 -0
- package/components/tour/index.md +48 -0
- package/components/tour/index.spec.ts +259 -0
- package/components/tour/index.ts +2 -0
- package/components/tour/step.ts +55 -0
- package/components/tour/step.vdt +75 -0
- package/components/tour/styles.ts +283 -0
- package/components/tour/tour.ts +107 -0
- package/components/tour/tour.vdt +83 -0
- package/components/tour/useArrow.ts +46 -0
- package/components/tour/useFixBody.ts +22 -0
- package/components/tour/useHighlight.ts +36 -0
- package/components/tour/useMaskClosable.ts +26 -0
- package/components/tour/useNavigation.ts +46 -0
- package/components/tour/usePosition.ts +91 -0
- package/components/tour/useSteps.ts +80 -0
- package/components/tree/useChecked.ts +6 -4
- package/components/treeSelect/index.spec.ts +13 -1
- package/components/virtualList/useVirtualRows.ts +1 -1
- package/es/components/breadcrumb/index.vdt.js +2 -1
- package/es/components/breadcrumb/styles.js +5 -3
- package/es/components/datepicker/basepicker.d.ts +4 -2
- package/es/components/datepicker/basepicker.js +46 -13
- package/es/components/datepicker/calendar.d.ts +34 -6
- package/es/components/datepicker/calendar.js +4 -0
- package/es/components/datepicker/calendar.vdt.js +21 -5
- package/es/components/datepicker/dayjs.d.ts +13 -2
- package/es/components/datepicker/dayjs.js +6 -0
- package/es/components/datepicker/helpers.d.ts +5 -5
- package/es/components/datepicker/index.d.ts +17 -2
- package/es/components/datepicker/index.js +23 -5
- package/es/components/datepicker/index.spec.js +356 -355
- package/es/components/datepicker/index.vdt.js +25 -29
- package/es/components/datepicker/styles.d.ts +17 -0
- package/es/components/datepicker/styles.js +29 -2
- package/es/components/datepicker/useDisabled.d.ts +2 -2
- package/es/components/datepicker/useDisabled.js +1 -1
- package/es/components/datepicker/useFormats.js +3 -1
- package/es/components/datepicker/useMergeRange.d.ts +5 -0
- package/es/components/datepicker/useMergeRange.js +50 -0
- package/es/components/datepicker/usePosition.d.ts +10 -0
- package/es/components/datepicker/usePosition.js +166 -0
- package/es/components/datepicker/useQuarters.d.ts +15 -0
- package/es/components/datepicker/useQuarters.js +36 -0
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +42 -9
- package/es/components/datepicker/useStatus.d.ts +1 -1
- package/es/components/datepicker/useValue.d.ts +1 -0
- package/es/components/datepicker/useValue.js +26 -2
- package/es/components/datepicker/useWeeks.d.ts +19 -0
- package/es/components/datepicker/useWeeks.js +48 -0
- package/es/components/dialog/useFixBody.js +6 -58
- package/es/components/ellipsis/styles.js +1 -1
- package/es/components/form/styles.js +1 -1
- package/es/components/scrollSelect/index.spec.js +4 -6
- package/es/components/scrollSelect/useMouseEvents.js +21 -9
- package/es/components/select/base.vdt.js +4 -2
- package/es/components/select/index.spec.js +269 -42
- package/es/components/select/option.d.ts +1 -0
- package/es/components/select/option.js +9 -2
- package/es/components/select/select.d.ts +1 -0
- package/es/components/select/select.js +2 -1
- package/es/components/select/useFilterable.js +2 -1
- package/es/components/select/useInput.js +5 -2
- package/es/components/select/useSearchable.js +1 -0
- package/es/components/table/table.vdt.js +4 -2
- package/es/components/timepicker/panelPicker.d.ts +2 -1
- package/es/components/timepicker/panelPicker.vdt.js +12 -4
- package/es/components/timepicker/selectPicker.d.ts +1 -1
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useDisabled.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +1 -0
- package/es/components/tour/index.d.ts +2 -0
- package/es/components/tour/index.js +2 -0
- package/es/components/tour/index.spec.d.ts +1 -0
- package/es/components/tour/index.spec.js +356 -0
- package/es/components/tour/step.d.ts +23 -0
- package/es/components/tour/step.js +46 -0
- package/es/components/tour/step.vdt.js +74 -0
- package/es/components/tour/styles.d.ts +7 -0
- package/es/components/tour/styles.js +84 -0
- package/es/components/tour/tour.d.ts +73 -0
- package/es/components/tour/tour.js +70 -0
- package/es/components/tour/tour.vdt.js +66 -0
- package/es/components/tour/useArrow.d.ts +4 -0
- package/es/components/tour/useArrow.js +40 -0
- package/es/components/tour/useFixBody.d.ts +4 -0
- package/es/components/tour/useFixBody.js +17 -0
- package/es/components/tour/useHighlight.d.ts +4 -0
- package/es/components/tour/useHighlight.js +31 -0
- package/es/components/tour/useMaskClosable.d.ts +1 -0
- package/es/components/tour/useMaskClosable.js +25 -0
- package/es/components/tour/useNavigation.d.ts +5 -0
- package/es/components/tour/useNavigation.js +103 -0
- package/es/components/tour/usePosition.d.ts +6 -0
- package/es/components/tour/usePosition.js +93 -0
- package/es/components/tour/useSteps.d.ts +6 -0
- package/es/components/tour/useSteps.js +68 -0
- package/es/components/tree/useChecked.js +6 -4
- package/es/components/treeSelect/index.spec.js +20 -5
- package/es/components/virtualList/useVirtualRows.js +1 -1
- package/es/hooks/useDocumentClick.js +3 -3
- package/es/hooks/useFixBody.d.ts +11 -0
- package/es/hooks/useFixBody.js +72 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/breadcrumb/demos/separator/react.js +7 -5
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/index.js +1 -2
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/react.js +2 -13
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/index.js +19 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.js +49 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +3 -1
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +21 -1
- package/es/site/data/components/select/demos/creatable/index.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/index.js +2 -1
- package/es/site/data/components/select/demos/creatable/react.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/react.js +31 -2
- package/es/site/data/components/select/demos/searchable/index.js +1 -1
- package/es/site/data/components/select/demos/searchable/react.js +1 -1
- package/es/site/data/components/tour/demos/basic/index.d.ts +17 -0
- package/es/site/data/components/tour/demos/basic/index.js +46 -0
- package/es/site/data/components/tour/demos/basic/react.d.ts +16 -0
- package/es/site/data/components/tour/demos/basic/react.js +82 -0
- package/es/site/data/components/tour/demos/beforeChange/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/beforeChange/index.js +69 -0
- package/es/site/data/components/tour/demos/beforeChange/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/beforeChange/react.js +129 -0
- package/es/site/data/components/tour/demos/closable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/closable/index.js +42 -0
- package/es/site/data/components/tour/demos/closable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/closable/react.js +85 -0
- package/es/site/data/components/tour/demos/custom/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/index.js +35 -0
- package/es/site/data/components/tour/demos/custom/react.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/react.js +108 -0
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/index.js +55 -0
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/react.js +99 -0
- package/es/site/data/components/tour/demos/customText/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/customText/index.js +54 -0
- package/es/site/data/components/tour/demos/customText/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/customText/react.js +95 -0
- package/es/site/data/components/tour/demos/declarative/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/declarative/index.js +36 -0
- package/es/site/data/components/tour/demos/declarative/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/declarative/react.js +80 -0
- package/es/site/data/components/tour/demos/events/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/index.js +58 -0
- package/es/site/data/components/tour/demos/events/react.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/react.js +101 -0
- package/es/site/data/components/tour/demos/maskClosable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/maskClosable/index.js +47 -0
- package/es/site/data/components/tour/demos/maskClosable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/maskClosable/react.js +95 -0
- package/es/site/data/components/tour/demos/notarget/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/notarget/index.js +35 -0
- package/es/site/data/components/tour/demos/notarget/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/notarget/react.js +61 -0
- package/es/site/data/components/tour/index.d.ts +57 -0
- package/es/site/data/components/tour/index.js +32 -0
- package/es/site/src/pages/resource/index.js +1 -1
- package/es/styles/fonts/iconfont.js +2 -1
- package/es/styles/global.js +2 -1
- package/hooks/useDocumentClick.ts +3 -3
- package/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +1 -1
- package/styles/fonts/iconfont.ts +2 -1
- package/styles/global.ts +2 -1
|
@@ -7,12 +7,13 @@ import { DatepickerTime } from './time';
|
|
|
7
7
|
import { Icon } from '../icon';
|
|
8
8
|
import { Button } from '../button';
|
|
9
9
|
import { _$ } from '../../i18n';
|
|
10
|
-
import { makePanelStyles } from './styles';
|
|
10
|
+
import { makePanelStyles, makeDatePickRangeStyles } from './styles';
|
|
11
11
|
import { PanelTypes, PanelFlags } from './usePanel';
|
|
12
12
|
import { isFunction } from 'intact-shared';
|
|
13
13
|
import { Tabs, Tab } from '../tabs';
|
|
14
14
|
export default function ($props, $blocks, $__proto__) {
|
|
15
15
|
var _classNameObj,
|
|
16
|
+
_classDatePickerObj,
|
|
16
17
|
_this = this;
|
|
17
18
|
$blocks || ($blocks = {});
|
|
18
19
|
$props || ($props = {});
|
|
@@ -30,8 +31,18 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
30
31
|
onChangeTime = _this$value.onChangeTime,
|
|
31
32
|
onChangeDateForRange = _this$value.onChangeDateForRange,
|
|
32
33
|
getTimeValue = _this$value.getTimeValue;
|
|
34
|
+
var _this$activePosition = this.activePosition,
|
|
35
|
+
position = _this$activePosition.position,
|
|
36
|
+
charLength = _this$activePosition.charLength,
|
|
37
|
+
startTextLength = _this$activePosition.startTextLength,
|
|
38
|
+
handleInputClick = _this$activePosition.handleInputClick;
|
|
33
39
|
var k = this.config.k;
|
|
40
|
+
var showPanel = range && position.value === 'end';
|
|
41
|
+
var positionDisplay = !multiple && range && (type === 'datetime' || type === 'date');
|
|
42
|
+
// 判断是否显示双面板
|
|
43
|
+
var showDualPanels = range && (type === 'date' || type === 'month' || type === 'year');
|
|
34
44
|
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-datepicker-content"] = true, _classNameObj[className] = className, _classNameObj[makePanelStyles(k)] = true, _classNameObj);
|
|
45
|
+
var classDatePickerObj = (_classDatePickerObj = {}, _classDatePickerObj[k + "-datepicker"] = true, _classDatePickerObj[makeDatePickRangeStyles(k, position.value, positionDisplay, charLength.value, startTextLength.value)] = true, _classDatePickerObj);
|
|
35
46
|
var _this$disabled = this.disabled,
|
|
36
47
|
isDisabledTime = _this$disabled.isDisabledTime,
|
|
37
48
|
isDisabledConfirm = _this$disabled.isDisabledConfirm;
|
|
@@ -44,36 +55,20 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
44
55
|
var generatePanel = function generatePanel(flag) {
|
|
45
56
|
var panel = getPanel(flag);
|
|
46
57
|
var timeValue = getTimeValue(flag);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return _$cc(Tabs, {
|
|
57
|
-
'type': 'card',
|
|
58
|
-
'value': panel.value,
|
|
59
|
-
'ev-$change:value': panel.set,
|
|
60
|
-
'children': [_$cc(Tab, {
|
|
61
|
-
'value': PanelTypes.Date,
|
|
62
|
-
'children': dateString
|
|
63
|
-
}), _$cc(Tab, {
|
|
64
|
-
'value': PanelTypes.Time,
|
|
65
|
-
'disabled': !timeValue,
|
|
66
|
-
'children': timeString
|
|
67
|
-
})]
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}(), panel.value === PanelTypes.Date ? _$cc(DatepickerCalendar, {
|
|
58
|
+
var dateString = '0000-00-00';
|
|
59
|
+
var timeString = '00:00:00';
|
|
60
|
+
if (type === 'datetime' && timeValue) {
|
|
61
|
+
var valueString = _this.formats.getShowString(timeValue).split(/\s+/);
|
|
62
|
+
dateString = valueString[0];
|
|
63
|
+
timeString = valueString[1];
|
|
64
|
+
}
|
|
65
|
+
return _$ce(2, 'div', [_$cc(DatepickerCalendar, {
|
|
71
66
|
'value': value,
|
|
72
67
|
'ev-change': onChangeDate,
|
|
73
68
|
'type': type === 'datetime' ? 'date' : type,
|
|
74
69
|
'flag': flag,
|
|
75
70
|
'ref': flag === PanelFlags.Start ? startRef : endRef
|
|
76
|
-
}, null, flag === PanelFlags.Start ? startRef : endRef)
|
|
71
|
+
}, null, flag === PanelFlags.Start ? startRef : endRef), type === 'datetime' ? _$ce(2, 'div', [_$ce(2, 'div', timeString, 0, _$cn(k + "-datepicker-time-time")), _$cc(DatepickerTime, {
|
|
77
72
|
'value': timeValue,
|
|
78
73
|
'ev-$change:value': function ev$changeValue(v) {
|
|
79
74
|
return onChangeTime(v, flag);
|
|
@@ -81,10 +76,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
81
76
|
'format': _this.formats.getValueFormat(),
|
|
82
77
|
'flag': flag,
|
|
83
78
|
'isDisabledTime': isDisabledTime
|
|
84
|
-
})], 0, _$cn(k + "-datepicker-calendar-wrapper"));
|
|
79
|
+
})], 4, _$cn(k + "-datepicker-time-wrapper")) : undefined], 0, _$cn(k + "-datepicker-calendar-time-wrapper"));
|
|
85
80
|
};
|
|
86
81
|
return _$su.call($this, {
|
|
87
|
-
'className': _$cn(
|
|
82
|
+
'className': _$cn(classDatePickerObj),
|
|
83
|
+
'onClick': handleInputClick
|
|
88
84
|
}, function ($blocks) {
|
|
89
85
|
var _$blocks = {},
|
|
90
86
|
__$blocks = _$ex({}, $blocks);
|
|
@@ -98,7 +94,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
98
94
|
'title': label,
|
|
99
95
|
'ev-click': linkEvent($value, _this2.setByShortcut)
|
|
100
96
|
});
|
|
101
|
-
}), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [generatePanel(PanelFlags.Start), _$ct('\n '),
|
|
97
|
+
}), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [showDualPanels ? generatePanel(PanelFlags.Start) : showPanel ? null : generatePanel(PanelFlags.Start), _$ct('\n '), showDualPanels ? generatePanel(PanelFlags.End) : showPanel ? generatePanel(PanelFlags.End) : null], 0, _$cn(k + "-datepicker-calendars")), type === 'datetime' ? _$ce(2, 'div', _$cc(Button, {
|
|
102
98
|
'type': 'primary',
|
|
103
99
|
'size': 'small',
|
|
104
100
|
'disabled': isDisabledConfirm(),
|
|
@@ -5,7 +5,9 @@ declare const defaults: {
|
|
|
5
5
|
border: string;
|
|
6
6
|
item: {
|
|
7
7
|
gutter: string;
|
|
8
|
+
yearGutter: string;
|
|
8
9
|
height: string;
|
|
10
|
+
rangeGutter: string;
|
|
9
11
|
readonly hoverBgColor: string;
|
|
10
12
|
readonly exceedColor: string;
|
|
11
13
|
readonly todayBorder: string;
|
|
@@ -34,6 +36,17 @@ declare const defaults: {
|
|
|
34
36
|
footer: {
|
|
35
37
|
padding: string;
|
|
36
38
|
};
|
|
39
|
+
week: {
|
|
40
|
+
height: string;
|
|
41
|
+
width: string;
|
|
42
|
+
margin: string;
|
|
43
|
+
padding: string;
|
|
44
|
+
currentWeek: string;
|
|
45
|
+
};
|
|
46
|
+
calendarTime: {
|
|
47
|
+
height: string;
|
|
48
|
+
fontSize: string;
|
|
49
|
+
};
|
|
37
50
|
shortcuts: {
|
|
38
51
|
width: string;
|
|
39
52
|
padding: string;
|
|
@@ -58,3 +71,7 @@ export declare const makeTimeStyles: {
|
|
|
58
71
|
(k: string): string;
|
|
59
72
|
clearCache(): {};
|
|
60
73
|
};
|
|
74
|
+
export declare const makeDatePickRangeStyles: {
|
|
75
|
+
(k: string, activePositionValue: string, display: boolean, charLength?: number | undefined, startTextLength?: number | undefined): string;
|
|
76
|
+
clearCache(): {};
|
|
77
|
+
};
|
|
@@ -9,7 +9,9 @@ var defaults = {
|
|
|
9
9
|
border: "1px solid #e5e5e5",
|
|
10
10
|
item: {
|
|
11
11
|
gutter: "7px",
|
|
12
|
+
yearGutter: '36px',
|
|
12
13
|
height: "24px",
|
|
14
|
+
rangeGutter: "17px",
|
|
13
15
|
get hoverBgColor() {
|
|
14
16
|
return theme.color.bg;
|
|
15
17
|
},
|
|
@@ -52,6 +54,17 @@ var defaults = {
|
|
|
52
54
|
footer: {
|
|
53
55
|
padding: "8px 16px"
|
|
54
56
|
},
|
|
57
|
+
week: {
|
|
58
|
+
height: "20px",
|
|
59
|
+
width: "40px",
|
|
60
|
+
margin: "0 0 0 10px",
|
|
61
|
+
padding: "0 2px",
|
|
62
|
+
currentWeek: '#eee'
|
|
63
|
+
},
|
|
64
|
+
calendarTime: {
|
|
65
|
+
height: "44px",
|
|
66
|
+
fontSize: "14px"
|
|
67
|
+
},
|
|
55
68
|
shortcuts: {
|
|
56
69
|
width: '100px',
|
|
57
70
|
padding: '12px 0',
|
|
@@ -75,11 +88,25 @@ setDefault(function () {
|
|
|
75
88
|
});
|
|
76
89
|
export { datepicker };
|
|
77
90
|
export var makePanelStyles = cache(function makePanelStyles(k) {
|
|
78
|
-
return /*#__PURE__*/css("display:flex;.", k, "-datepicker-shortcuts{width:", datepicker.shortcuts.width, ";padding:", datepicker.shortcuts.padding, ";border-right:", datepicker.border, ";}.", k, "-datepicker-shortcut{height:", datepicker.shortcuts.shortcut.height, ";line-height:", datepicker.shortcuts.shortcut.height, ";padding:", datepicker.shortcuts.shortcut.padding, ";cursor:pointer;&:hover{background:", datepicker.shortcuts.shortcut.hoverBgcolor, ";}}.", k, "-datepicker-calendars{display:flex;}.", k, "-datepicker-calendar-wrapper{&:nth-child(2){border-left:", datepicker.border, ";}.", k, "-tabs{border:none;.", k, "-tabs-wrapper{float:none;}.", k, "-tab{width:50%;}}}.", k, "-datepicker-footer{border-top:", datepicker.border, ";padding:", datepicker.footer.padding, ";text-align:right;}");
|
|
91
|
+
return /*#__PURE__*/css("display:flex;.", k, "-datepicker-shortcuts{width:", datepicker.shortcuts.width, ";padding:", datepicker.shortcuts.padding, ";border-right:", datepicker.border, ";}.", k, "-datepicker-shortcut{height:", datepicker.shortcuts.shortcut.height, ";line-height:", datepicker.shortcuts.shortcut.height, ";padding:", datepicker.shortcuts.shortcut.padding, ";cursor:pointer;&:hover{background:", datepicker.shortcuts.shortcut.hoverBgcolor, ";}}.", k, "-datepicker-calendars{display:flex;}.", k, "-datepicker-calendar-wrapper{&:nth-child(2){border-left:", datepicker.border, ";}.", k, "-tabs{border:none;.", k, "-tabs-wrapper{float:none;}.", k, "-tab{width:50%;}}}.", k, "-datepicker-calendar-time-wrapper{display:flex;.", k, "-datepicker-time-time{height:", datepicker.calendarTime.height, ";line-height:", datepicker.calendarTime.height, ";text-align:center;font-size:", datepicker.calendarTime.fontSize, ";}.", k, "-datepicker-time-wrapper{overflow:hidden;height:320px;}}.", k, "-datepicker-footer{border-top:", datepicker.border, ";padding:", datepicker.footer.padding, ";text-align:right;}");
|
|
79
92
|
});
|
|
80
93
|
export var makeCalendarStyles = cache(function makeCalendarStyles(k) {
|
|
81
|
-
return /*#__PURE__*/css("padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-datepicker-month{display:flex;padding:", datepicker.month.padding, ";}.", k, "-prev .", k, "-icon,.", k, "-next .", k, "-icon{margin:0 -5px!important;}.", k, "-month-values{flex:1;font-size:14px;text-align:center;cursor:pointer;overflow:hidden;position:relative;}.", k, "-month-value{margin:0 ", datepicker.month.valueGap, ";line-height:", theme.small.height, ";&:hover{color:", theme.color.primary, ";}},.", k, "-weekdays{display:flex;border-bottom:", datepicker.border, ";padding:", datepicker.weekday.padding, ";}.", k, "-weekday{flex:1;text-align:center;}.", k, "-calendar-item{text-align:center;margin:", datepicker.item.gutter, ";aspect-ratio:1;display:flex;align-items:center;cursor:pointer;position:relative;border-radius:", datepicker.item.borderRadius, ";.", k, "-value{border-radius:", datepicker.item.borderRadius, ";}&.", k, "-hover{background:", datepicker.item.hoverBgColor, ";}&.", k, "-exceed{color:", datepicker.item.exceedColor, ";}&.", k, "-today .", k, "-value{border:", datepicker.item.todayBorder, ";}&.", k, "-active{background:", datepicker.item.active.bgColor, ";color:", datepicker.item.active.color, ";&.", k, "-today .", k, "-value{border-color:", datepicker.item.active.todayBorderColor, ";}}&.", k, "-disabled{color:", datepicker.item.disabled.color, ";cursor:not-allowed;background:", datepicker.item.disabled.hoverBgColor, ";}&.", k, "-in-range:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.item.range.bgColor, ";width:100%;height:100%;left:-", datepicker.item.gutter, ";padding:0 ", datepicker.item.gutter, ";z-index:-1;}.", k, "-value{flex:1;display:flex;align-items:center;justify-content:center;height:100%;}}.", k, "-days{display:grid;grid-template-columns:repeat(7, 1fr);}.", k, "-years{display:grid;grid-template-columns:repeat(
|
|
94
|
+
return /*#__PURE__*/css("padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-datepicker-month{display:flex;padding:", datepicker.month.padding, ";}.", k, "-prev .", k, "-icon,.", k, "-next .", k, "-icon{margin:0 -5px!important;}.", k, "-month-values{flex:1;font-size:14px;text-align:center;cursor:pointer;overflow:hidden;position:relative;}.", k, "-month-value{margin:0 ", datepicker.month.valueGap, ";line-height:", theme.small.height, ";&:hover{color:", theme.color.primary, ";}},.", k, "-weekdays{display:flex;border-bottom:", datepicker.border, ";padding:", datepicker.weekday.padding, ";}.", k, "-weekday{flex:1;text-align:center;}.", k, "-calendar-item{text-align:center;margin:", datepicker.item.gutter, ";aspect-ratio:1;display:flex;align-items:center;cursor:pointer;position:relative;border-radius:", datepicker.item.borderRadius, ";.", k, "-value{border-radius:", datepicker.item.borderRadius, ";}&.", k, "-hover{background:", datepicker.item.hoverBgColor, ";}&.", k, "-exceed{color:", datepicker.item.exceedColor, ";}&.", k, "-today .", k, "-value{border:", datepicker.item.todayBorder, ";}&.", k, "-active{background:", datepicker.item.active.bgColor, ";color:", datepicker.item.active.color, ";&.", k, "-today .", k, "-value{border-color:", datepicker.item.active.todayBorderColor, ";}}&.", k, "-disabled{color:", datepicker.item.disabled.color, ";cursor:not-allowed;background:", datepicker.item.disabled.hoverBgColor, ";}&.", k, "-in-range:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.item.range.bgColor, ";width:100%;height:100%;left:-", datepicker.item.gutter, ";padding:0 ", datepicker.item.gutter, ";z-index:-1;}.", k, "-value{flex:1;display:flex;align-items:center;justify-content:center;height:100%;}}.", k, "-days{display:grid;grid-template-columns:repeat(7, 1fr);}.", k, "-years{display:grid;justify-items:center;grid-template-columns:repeat(3, 1fr);gap:0;.", k, "-calendar-item{height:20px;width:40px;&.", k, "-in-range:after{width:calc(100% + 14px);left:calc(-", datepicker.item.yearGutter, " / 2);padding:0 calc(", datepicker.item.yearGutter, " / 2);}}}.", k, "-weeks{display:grid;.week-row{display:flex;align-items:center;width:", datepicker.week.width, ";margin:", datepicker.week.margin, ";.", k, "-week-number{padding:", datepicker.week.padding, ";cursor:pointer;}}.", k, "-calendar-item{height:", datepicker.week.height, ";&.", k, "-today:not(:last-child) .", k, "-value{background:", datepicker.week.currentWeek, ";border:0;&:after{content:'';display:block;position:absolute;box-sizing:content-box;background:", datepicker.week.currentWeek, ";width:100%;height:100%;left:0;padding:0 ", datepicker.item.rangeGutter, ";z-index:-1;}}&.", k, "-today:last-child .", k, "-value{border:0;}}}");
|
|
82
95
|
});
|
|
83
96
|
export var makeTimeStyles = cache(function makeTimeStyles(k) {
|
|
84
97
|
return /*#__PURE__*/css("display:flex;padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-scroll-select{flex:1;height:305px;}");
|
|
98
|
+
});
|
|
99
|
+
export var makeDatePickRangeStyles = cache(function makeTimeStyles(k, activePositionValue, display, charLength, startTextLength) {
|
|
100
|
+
if (charLength === void 0) {
|
|
101
|
+
charLength = 10;
|
|
102
|
+
}
|
|
103
|
+
if (startTextLength === void 0) {
|
|
104
|
+
startTextLength = 10;
|
|
105
|
+
}
|
|
106
|
+
var displayType = display ? 'block' : 'none';
|
|
107
|
+
var charWidthPx = 8;
|
|
108
|
+
var highlightWidthPx = charLength * charWidthPx;
|
|
109
|
+
// 计算结束文本的起始位置 - 紧接着开始文本
|
|
110
|
+
var endTextStartPos = startTextLength * charWidthPx;
|
|
111
|
+
return /*#__PURE__*/css("&:hover:before,&:focus:before{content:'';display:", displayType, ";width:", highlightWidthPx, "px;height:1px;position:absolute;background-color:", datepicker.item.active.bgColor, ";left:", activePositionValue === 'start' ? '0' : endTextStartPos + 'px', ";bottom:0;}");
|
|
85
112
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { State } from '../../hooks/useState';
|
|
2
|
-
import { Dayjs, OpUnitType } from 'dayjs';
|
|
2
|
+
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
3
3
|
import type { useFormats } from './useFormats';
|
|
4
4
|
import { PanelFlags } from './usePanel';
|
|
5
5
|
export declare function useDisabled({ createDateByValueFormat }: ReturnType<typeof useFormats>): {
|
|
6
|
-
isDisabled: (value: Dayjs, type?: OpUnitType) => boolean;
|
|
6
|
+
isDisabled: (value: Dayjs, type?: OpUnitType | QUnitType) => boolean;
|
|
7
7
|
isDisabledTime: (value: Dayjs, flag: PanelFlags) => boolean;
|
|
8
8
|
isDisabledConfirm: () => boolean;
|
|
9
9
|
maxDate: State<Dayjs | null>;
|
|
@@ -48,7 +48,7 @@ export function useDisabled(_ref) {
|
|
|
48
48
|
if (!lastValue) return true;
|
|
49
49
|
var _instance$get2 = instance.get(),
|
|
50
50
|
range = _instance$get2.range;
|
|
51
|
-
if (range && lastValue.length
|
|
51
|
+
if (range && lastValue.length === 1) return false;
|
|
52
52
|
var _instance$panel = instance.panel,
|
|
53
53
|
startPanel = _instance$panel.startPanel,
|
|
54
54
|
endPanel = _instance$panel.endPanel;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
|
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
4
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
5
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
6
|
+
import { useInstance } from 'intact';
|
|
7
|
+
export function useMergeRange(formats) {
|
|
8
|
+
var instance = useInstance();
|
|
9
|
+
function _mergeRanges(dayjsValue, getShowString) {
|
|
10
|
+
var _context, _context2;
|
|
11
|
+
var ranges = _sortInstanceProperty(_context = _mapInstanceProperty(_context2 = _filterInstanceProperty(dayjsValue).call(dayjsValue, Array.isArray)).call(_context2, function (range) {
|
|
12
|
+
return {
|
|
13
|
+
start: range[0],
|
|
14
|
+
end: range[1]
|
|
15
|
+
};
|
|
16
|
+
})).call(_context, function (a, b) {
|
|
17
|
+
return a.start.valueOf() - b.start.valueOf();
|
|
18
|
+
});
|
|
19
|
+
if (ranges.length === 0) return [];
|
|
20
|
+
// 合并有交集的时间范围
|
|
21
|
+
var mergedRange = ranges.reduce(function (acc, curr) {
|
|
22
|
+
if (!acc) return curr;
|
|
23
|
+
return {
|
|
24
|
+
start: acc.start,
|
|
25
|
+
end: curr.end.valueOf() > acc.end.valueOf() ? curr.end : acc.end
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return [getShowString(mergedRange.start) + " ~ " + getShowString(mergedRange.end)];
|
|
29
|
+
}
|
|
30
|
+
function formatMultipleValues(dayjsValue, results) {
|
|
31
|
+
var _instance$get = instance.get(),
|
|
32
|
+
isMerge = _instance$get.isMerge,
|
|
33
|
+
nowrap = _instance$get.nowrap;
|
|
34
|
+
if (isMerge && nowrap) {
|
|
35
|
+
var mergedResults = _mergeRanges(dayjsValue, function (v) {
|
|
36
|
+
return v.format(formats.getShowFormat());
|
|
37
|
+
});
|
|
38
|
+
if (mergedResults.length > 0) {
|
|
39
|
+
var _context3, _context4;
|
|
40
|
+
return _concatInstanceProperty(_context3 = []).call(_context3, mergedResults, _mapInstanceProperty(_context4 = _sliceInstanceProperty(results).call(results, 1)).call(_context4, function (result, index) {
|
|
41
|
+
return result + "-" + index;
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return results;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
formatMultipleValues: formatMultipleValues
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function usePosition(): {
|
|
2
|
+
position: import("../../hooks/useState").State<"end" | "start">;
|
|
3
|
+
charLength: import("../../hooks/useState").State<number>;
|
|
4
|
+
startTextLength: import("../../hooks/useState").State<number>;
|
|
5
|
+
handleInputClick: (e: MouseEvent) => void;
|
|
6
|
+
resetPosition: (pos?: 'start' | 'end') => void;
|
|
7
|
+
togglePosition: () => void;
|
|
8
|
+
setupEventListeners: () => void;
|
|
9
|
+
resetToStart: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
2
|
+
import { useInstance } from 'intact';
|
|
3
|
+
import { useState } from '../../hooks/useState';
|
|
4
|
+
import { last } from '../utils';
|
|
5
|
+
export function usePosition() {
|
|
6
|
+
var instance = useInstance();
|
|
7
|
+
var position = useState('start');
|
|
8
|
+
// 根据类型获取默认字符长度
|
|
9
|
+
function getDefaultCharLength() {
|
|
10
|
+
var _instance$get = instance.get(),
|
|
11
|
+
type = _instance$get.type;
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'datetime':
|
|
14
|
+
return 16;
|
|
15
|
+
// "2025-07-10 00:00:00"
|
|
16
|
+
case 'date':
|
|
17
|
+
return 10;
|
|
18
|
+
// "2025-07-09"
|
|
19
|
+
default:
|
|
20
|
+
return 10;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
var charLength = useState(getDefaultCharLength()); // 当前活动部分的字符长度
|
|
24
|
+
var startTextLength = useState(getDefaultCharLength()); // 开始文本的长度,用于计算结束文本位置
|
|
25
|
+
// 监听类型变化,更新默认字符长度
|
|
26
|
+
instance.watch('type', function () {
|
|
27
|
+
var defaultLength = getDefaultCharLength();
|
|
28
|
+
charLength.set(defaultLength);
|
|
29
|
+
startTextLength.set(defaultLength);
|
|
30
|
+
});
|
|
31
|
+
function handleInputClick(e) {
|
|
32
|
+
var _context;
|
|
33
|
+
var _instance$get2 = instance.get(),
|
|
34
|
+
range = _instance$get2.range,
|
|
35
|
+
type = _instance$get2.type;
|
|
36
|
+
if (!range) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// 对于日期时间范围选择器,如果当前没有值或值不完整,总是设置为开始时间
|
|
40
|
+
if (type === 'datetime') {
|
|
41
|
+
var currentValue = instance.value.value.value;
|
|
42
|
+
var lastValue = last(currentValue);
|
|
43
|
+
// 如果没有值或者当前范围值不完整(只有开始时间没有结束时间),强制设置为开始时间
|
|
44
|
+
if (!lastValue || !Array.isArray(lastValue) || lastValue.length < 2 || !lastValue[1]) {
|
|
45
|
+
position.set('start');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// 获取事件目标元素
|
|
50
|
+
var target = e.currentTarget;
|
|
51
|
+
// 如果目标元素不是 .k-select-main,则查找父元素
|
|
52
|
+
if (!target.classList.contains(".k-select-main")) {
|
|
53
|
+
target = target.closest(".k-select-main");
|
|
54
|
+
if (!target) return;
|
|
55
|
+
}
|
|
56
|
+
var hiddenInput = target.querySelector('input[type="hidden"]');
|
|
57
|
+
var _target$getBoundingCl = target.getBoundingClientRect(),
|
|
58
|
+
totalVisualWidth = _target$getBoundingCl.width;
|
|
59
|
+
var midPoint;
|
|
60
|
+
if (hiddenInput && hiddenInput.value && _includesInstanceProperty(_context = hiddenInput.value).call(_context, ',')) {
|
|
61
|
+
// 分割字符串获取开始和结束日期的文本
|
|
62
|
+
var _hiddenInput$value$sp = hiddenInput.value.split(','),
|
|
63
|
+
startText = _hiddenInput$value$sp[0],
|
|
64
|
+
endText = _hiddenInput$value$sp[1];
|
|
65
|
+
// 确保两部分都存在,避免计算错误
|
|
66
|
+
if (startText && endText) {
|
|
67
|
+
var totalCharLength = startText.length + endText.length;
|
|
68
|
+
// 计算开始日期文本长度所占的比例
|
|
69
|
+
var startRatio = startText.length / totalCharLength;
|
|
70
|
+
// 估算每个字符的宽度(与样式中保持一致)
|
|
71
|
+
var charWidthPx = 8;
|
|
72
|
+
// 计算实际文本占用的宽度
|
|
73
|
+
var startTextWidth = startText.length * charWidthPx;
|
|
74
|
+
var endTextWidth = endText.length * charWidthPx;
|
|
75
|
+
var separatorWidth = 3 * charWidthPx; // " ~ " 大约3个字符宽度
|
|
76
|
+
var totalTextWidth = startTextWidth + separatorWidth + endTextWidth;
|
|
77
|
+
// 如果文本宽度超过input宽度,使用比例分割
|
|
78
|
+
if (totalTextWidth >= totalVisualWidth) {
|
|
79
|
+
midPoint = totalVisualWidth * startRatio;
|
|
80
|
+
} else {
|
|
81
|
+
// 如果文本宽度小于input宽度,使用实际文本宽度计算分割点
|
|
82
|
+
midPoint = startTextWidth + separatorWidth / 2;
|
|
83
|
+
}
|
|
84
|
+
// 更新开始文本长度状态,限制为默认长度以保证结束时间高亮位置正确
|
|
85
|
+
startTextLength.set(Math.min(startText.length, getDefaultCharLength()));
|
|
86
|
+
} else {
|
|
87
|
+
// 如果值格式不正确(例如 "2025-07-09,"),则退回使用几何中心点
|
|
88
|
+
var defaultLength = getDefaultCharLength();
|
|
89
|
+
charLength.set(defaultLength);
|
|
90
|
+
startTextLength.set(defaultLength);
|
|
91
|
+
midPoint = totalVisualWidth / 2;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
// 如果没有找到 hiddenInput 或其值不是范围,则退回原始的几何中心点
|
|
95
|
+
var _defaultLength = getDefaultCharLength();
|
|
96
|
+
charLength.set(_defaultLength);
|
|
97
|
+
startTextLength.set(_defaultLength);
|
|
98
|
+
midPoint = totalVisualWidth / 2;
|
|
99
|
+
}
|
|
100
|
+
// 计算相对于 target 的 offsetX
|
|
101
|
+
var rect = target.getBoundingClientRect();
|
|
102
|
+
var offsetX = e.clientX - rect.left;
|
|
103
|
+
// 根据点击位置判断是点击了左半边(开始)还是右半边(结束)
|
|
104
|
+
if (offsetX < midPoint) {
|
|
105
|
+
var _context2;
|
|
106
|
+
position.set('start');
|
|
107
|
+
// 更新为开始部分的字符长度,限制为默认长度
|
|
108
|
+
if (hiddenInput && hiddenInput.value && _includesInstanceProperty(_context2 = hiddenInput.value).call(_context2, ',')) {
|
|
109
|
+
var _hiddenInput$value$sp2 = hiddenInput.value.split(','),
|
|
110
|
+
_startText = _hiddenInput$value$sp2[0];
|
|
111
|
+
charLength.set(Math.min(_startText.length, getDefaultCharLength()));
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
var _context3;
|
|
115
|
+
position.set('end');
|
|
116
|
+
// 更新为结束部分的字符长度,限制为默认长度
|
|
117
|
+
if (hiddenInput && hiddenInput.value && _includesInstanceProperty(_context3 = hiddenInput.value).call(_context3, ',')) {
|
|
118
|
+
var _hiddenInput$value$sp3 = hiddenInput.value.split(','),
|
|
119
|
+
_endText = _hiddenInput$value$sp3[1];
|
|
120
|
+
charLength.set(Math.min(_endText.length, getDefaultCharLength()));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// 重置位置到指定值
|
|
125
|
+
function resetPosition(pos) {
|
|
126
|
+
if (pos === void 0) {
|
|
127
|
+
pos = 'start';
|
|
128
|
+
}
|
|
129
|
+
if (position.value === pos) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
position.set(pos);
|
|
133
|
+
}
|
|
134
|
+
// 切换位置
|
|
135
|
+
function togglePosition() {
|
|
136
|
+
var currentPosition = position.value;
|
|
137
|
+
if (currentPosition === 'start') {
|
|
138
|
+
position.set('end');
|
|
139
|
+
} else {
|
|
140
|
+
position.set('start');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// 在组件初始化时设置事件监听
|
|
144
|
+
function setupEventListeners() {
|
|
145
|
+
// instance.on('resetPosition', resetPosition);
|
|
146
|
+
instance.on('togglePosition', togglePosition);
|
|
147
|
+
}
|
|
148
|
+
function resetToStart() {
|
|
149
|
+
var _instance$get3 = instance.get(),
|
|
150
|
+
range = _instance$get3.range,
|
|
151
|
+
type = _instance$get3.type;
|
|
152
|
+
if (range && type === 'date') {
|
|
153
|
+
position.set('start');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
position: position,
|
|
158
|
+
charLength: charLength,
|
|
159
|
+
startTextLength: startTextLength,
|
|
160
|
+
handleInputClick: handleInputClick,
|
|
161
|
+
resetPosition: resetPosition,
|
|
162
|
+
togglePosition: togglePosition,
|
|
163
|
+
setupEventListeners: setupEventListeners,
|
|
164
|
+
resetToStart: resetToStart
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
2
|
+
import { State } from '../../hooks/useState';
|
|
3
|
+
import type { useStatus } from './useStatus';
|
|
4
|
+
export declare function useQuarters(showDate: State<Dayjs>, status: ReturnType<typeof useStatus>, focusDate: State<Dayjs | null>): {
|
|
5
|
+
getQuarters: (now: Dayjs) => {
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
isToday: boolean;
|
|
8
|
+
isDisabled: boolean;
|
|
9
|
+
isHover: boolean;
|
|
10
|
+
isInRange: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
value: dayjs.Dayjs;
|
|
13
|
+
}[];
|
|
14
|
+
onClick: (date: Dayjs) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { isEqual } from './helpers';
|
|
4
|
+
import { _$ } from '../../i18n';
|
|
5
|
+
export function useQuarters(showDate, status, focusDate) {
|
|
6
|
+
var instance = useInstance();
|
|
7
|
+
function getQuarters(now) {
|
|
8
|
+
var ret = [];
|
|
9
|
+
var year = showDate.value.year();
|
|
10
|
+
for (var i = 1; i <= 4; i++) {
|
|
11
|
+
var quarterStart = dayjs().year(year).quarter(i).startOf('quarter');
|
|
12
|
+
ret.push({
|
|
13
|
+
isActive: status.isActive(quarterStart, 'quarter'),
|
|
14
|
+
isToday: now.isSame(quarterStart, 'quarter'),
|
|
15
|
+
isDisabled: status.isDisabled(quarterStart),
|
|
16
|
+
isHover: isEqual(quarterStart, focusDate.value, 'quarter'),
|
|
17
|
+
isInRange: status.isInRange(quarterStart, 'quarter'),
|
|
18
|
+
label: _$("Q" + i),
|
|
19
|
+
value: quarterStart
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return ret;
|
|
23
|
+
}
|
|
24
|
+
function onClick(date) {
|
|
25
|
+
var quarterStart = date.startOf('quarter');
|
|
26
|
+
showDate.set(quarterStart);
|
|
27
|
+
var datepickerType = instance.datepicker.get('type');
|
|
28
|
+
if (datepickerType === 'quarter') {
|
|
29
|
+
instance.triggerChange(quarterStart);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
getQuarters: getQuarters,
|
|
34
|
+
onClick: onClick
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -5,7 +5,7 @@ export declare function useShowDate(panel: ReturnType<typeof usePanel>): {
|
|
|
5
5
|
date: import("../../hooks/useState").State<Dayjs>;
|
|
6
6
|
getDateLabel: () => {
|
|
7
7
|
value: string;
|
|
8
|
-
onClick(e: IgnoreClickEvent)
|
|
8
|
+
onClick: (e: IgnoreClickEvent) => void;
|
|
9
9
|
}[];
|
|
10
10
|
prevMonth: () => void;
|
|
11
11
|
nextMonth: () => void;
|
|
@@ -67,29 +67,62 @@ export function useShowDate(panel) {
|
|
|
67
67
|
case 'month':
|
|
68
68
|
return date.add(isEnd ? 1 : -1, 'year');
|
|
69
69
|
break;
|
|
70
|
+
case 'week':
|
|
71
|
+
return date.add(isEnd ? 1 : -1, 'week');
|
|
72
|
+
break;
|
|
73
|
+
case 'quarter':
|
|
74
|
+
return date.add(isEnd ? 1 : -1, 'quarter');
|
|
75
|
+
break;
|
|
70
76
|
default:
|
|
71
77
|
return date.add(isEnd ? 1 : -1, 'month');
|
|
72
78
|
break;
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
function getDateLabel() {
|
|
82
|
+
var year = showDate.value.get('year');
|
|
83
|
+
var month = showDate.value.get('month') + 1;
|
|
76
84
|
var map = {
|
|
77
|
-
MM: _$(
|
|
78
|
-
YYYY: _$("{n}\u5E74", {
|
|
79
|
-
n:
|
|
80
|
-
})
|
|
85
|
+
'MM': _$(month + "\u6708"),
|
|
86
|
+
'YYYY': _$("{n}\u5E74", {
|
|
87
|
+
n: year
|
|
88
|
+
}),
|
|
89
|
+
'YYYY MM': _$("{n}\u5E74{y}\u6708", {
|
|
90
|
+
n: year,
|
|
91
|
+
y: month
|
|
92
|
+
}) // 年月组合标签
|
|
81
93
|
};
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
94
|
+
var format;
|
|
95
|
+
switch (type) {
|
|
96
|
+
case 'week':
|
|
97
|
+
format = ['YYYY MM']; // week 类型显示年月组合
|
|
98
|
+
break;
|
|
99
|
+
case 'quarter':
|
|
100
|
+
format = ['YYYY']; // quarter 类型仅显示年
|
|
101
|
+
break;
|
|
102
|
+
default:
|
|
103
|
+
var yearMonthFormat = _$('yearMonthFormat');
|
|
104
|
+
if (yearMonthFormat === 'yearMonthFormat') {
|
|
105
|
+
yearMonthFormat = 'YYYY MM'; // 默认格式
|
|
106
|
+
}
|
|
107
|
+
format = yearMonthFormat.split(' '); // 其他类型按配置拆分
|
|
108
|
+
break;
|
|
85
109
|
}
|
|
86
|
-
|
|
110
|
+
// 根据 type 动态调整显示的格式
|
|
87
111
|
return _mapInstanceProperty(format).call(format, function (item) {
|
|
88
112
|
return {
|
|
89
113
|
value: map[item],
|
|
90
114
|
onClick: function onClick(e) {
|
|
91
115
|
e._ignore = true;
|
|
92
|
-
|
|
116
|
+
// 根据点击的项设置不同的 type
|
|
117
|
+
if (item === 'YYYY MM') {
|
|
118
|
+
instance.type.set('week'); // 点击年月组合,保持 week
|
|
119
|
+
} else if (item === 'YYYY') {
|
|
120
|
+
instance.type.set(type === 'quarter' ? 'quarter' : 'year'); // 根据当前 type 决定
|
|
121
|
+
} else if (item === 'MM') {
|
|
122
|
+
instance.type.set('month'); // 点击月,切换到 month
|
|
123
|
+
} else {
|
|
124
|
+
instance.type.set('date'); // 默认切换到 date
|
|
125
|
+
}
|
|
93
126
|
}
|
|
94
127
|
};
|
|
95
128
|
});
|
|
@@ -4,5 +4,5 @@ import type { DatepickerCalendarProps } from './calendar';
|
|
|
4
4
|
export declare function useStatus(focusDate: State<Dayjs | null>): {
|
|
5
5
|
isActive: (date: Dayjs, type: DatepickerCalendarProps['type']) => boolean;
|
|
6
6
|
isInRange: (date: Dayjs, type: DatepickerCalendarProps['type']) => boolean;
|
|
7
|
-
isDisabled: (value: Dayjs, type?:
|
|
7
|
+
isDisabled: (value: 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;
|
|
8
8
|
};
|
|
@@ -10,6 +10,7 @@ export declare function useValue(formats: ReturnType<typeof useFormats>, disable
|
|
|
10
10
|
getTimeValue: (flag: PanelFlags) => dayjs.Dayjs | null | undefined;
|
|
11
11
|
convertToDayjs: (v: import("./basepicker").Value | [import("./basepicker").Value, import("./basepicker").Value] | import("./basepicker").Value[] | [import("./basepicker").Value, import("./basepicker").Value][] | null | undefined) => DayjsValue;
|
|
12
12
|
getDayjsValue: () => DayjsValue;
|
|
13
|
+
setMoment: () => void;
|
|
13
14
|
value: import("../../hooks/useState").State<import("./basepicker").StateValue>;
|
|
14
15
|
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
15
16
|
onChangeDate: (v: Dayjs, flag: PanelFlags) => void;
|