@king-design/intact 3.6.0-beta.0 → 3.6.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/.DS_Store +0 -0
- package/components/cascader/index.spec.ts +7 -6
- package/components/datepicker/basepicker.ts +26 -314
- package/components/datepicker/calendar.ts +3 -1
- package/components/datepicker/calendar.vdt +5 -2
- package/components/datepicker/dayjs.ts +2 -16
- package/components/datepicker/demos/multiple.md +5 -0
- package/components/datepicker/demos/yearMonth.md +2 -8
- package/components/datepicker/helpers.ts +5 -7
- package/components/datepicker/index.md +1 -2
- package/components/datepicker/index.spec.ts +551 -139
- package/components/datepicker/index.ts +16 -33
- package/components/datepicker/index.vdt +41 -35
- package/components/datepicker/shortcuts.ts +1 -1
- package/components/datepicker/styles.ts +27 -18
- package/components/datepicker/useConfirm.ts +82 -0
- package/components/datepicker/useDisabled.ts +29 -31
- package/components/datepicker/useFormats.ts +8 -4
- package/components/datepicker/useHighlight.ts +81 -0
- package/components/datepicker/useKeyboards.ts +2 -1
- package/components/datepicker/useMergeRange.ts +12 -12
- package/components/datepicker/useMonths.ts +6 -3
- package/components/datepicker/usePanel.ts +19 -19
- package/components/datepicker/useShowDate.ts +21 -41
- package/components/datepicker/useStatus.ts +34 -15
- package/components/datepicker/useValue.ts +43 -72
- package/components/datepicker/useValueBase.ts +309 -0
- package/components/datepicker/useWeeks.ts +1 -1
- package/components/datepicker/useYears.ts +7 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dropdown/dropdown.ts +5 -4
- package/components/dropdown/index.md +1 -0
- package/components/dropdown/item.ts +1 -1
- package/components/dropdown/useKeyboard.ts +0 -1
- package/components/input/index.spec.ts +42 -0
- package/components/input/index.ts +8 -0
- package/components/input/index.vdt +3 -4
- package/components/input/useAutoWidth.ts +19 -1
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/scrollSelect/useMouseEvents.ts +5 -4
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +2 -2
- package/components/select/index.md +1 -1
- package/components/select/index.spec.ts +107 -34
- package/components/select/option.ts +2 -1
- package/components/select/select.ts +1 -0
- package/components/select/styles.ts +3 -1
- package/components/select/useInput.ts +5 -9
- package/components/table/.DS_Store +0 -0
- package/components/table/index.spec.ts +69 -1
- package/components/table/useStickyHeader.ts +1 -1
- package/components/timepicker/index.spec.ts +145 -27
- package/components/timepicker/panelPicker.ts +10 -4
- package/components/timepicker/panelPicker.vdt +3 -5
- package/components/timepicker/styles.ts +1 -0
- package/components/timepicker/useConfirm.ts +33 -0
- package/components/timepicker/useDefaultValue.ts +30 -0
- package/components/timepicker/useDisabled.ts +17 -4
- package/components/timepicker/useFormats.ts +1 -1
- package/components/timepicker/useValue.ts +22 -19
- package/components/tour/.DS_Store +0 -0
- package/components/tour/index.spec.ts +1 -1
- package/components/virtualList/.DS_Store +0 -0
- package/components/virtualList/demos/.DS_Store +0 -0
- package/es/components/cascader/index.spec.js +18 -19
- package/es/components/datepicker/basepicker.d.ts +6 -27
- package/es/components/datepicker/basepicker.js +23 -268
- package/es/components/datepicker/calendar.d.ts +4 -2
- package/es/components/datepicker/dayjs.d.ts +2 -13
- package/es/components/datepicker/helpers.d.ts +3 -2
- package/es/components/datepicker/helpers.js +2 -3
- package/es/components/datepicker/index.d.ts +21 -29
- package/es/components/datepicker/index.js +22 -32
- package/es/components/datepicker/index.spec.js +1333 -578
- package/es/components/datepicker/index.vdt.js +39 -38
- package/es/components/datepicker/shortcuts.d.ts +1 -1
- package/es/components/datepicker/styles.d.ts +7 -2
- package/es/components/datepicker/styles.js +10 -15
- package/es/components/datepicker/useConfirm.d.ts +6 -0
- package/es/components/datepicker/useConfirm.js +65 -0
- package/es/components/datepicker/useDisabled.d.ts +5 -3
- package/es/components/datepicker/useDisabled.js +22 -27
- package/es/components/datepicker/useFormats.d.ts +2 -2
- package/es/components/datepicker/useFormats.js +6 -2
- package/es/components/datepicker/useHighlight.d.ts +14 -0
- package/es/components/datepicker/useHighlight.js +60 -0
- package/es/components/datepicker/useKeyboards.js +2 -1
- package/es/components/datepicker/useMergeRange.d.ts +1 -1
- package/es/components/datepicker/useMergeRange.js +11 -16
- package/es/components/datepicker/useMonths.js +5 -3
- package/es/components/datepicker/usePanel.d.ts +1 -10
- package/es/components/datepicker/usePanel.js +19 -32
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +15 -40
- package/es/components/datepicker/useStatus.js +33 -16
- package/es/components/datepicker/useValue.d.ts +11 -6
- package/es/components/datepicker/useValue.js +49 -69
- package/es/components/datepicker/useValueBase.d.ts +28 -0
- package/es/components/datepicker/useValueBase.js +277 -0
- package/es/components/datepicker/useYears.js +6 -3
- package/es/components/dropdown/dropdown.d.ts +1 -0
- package/es/components/dropdown/dropdown.js +7 -4
- package/es/components/input/index.d.ts +2 -0
- package/es/components/input/index.js +6 -0
- package/es/components/input/index.spec.js +45 -0
- package/es/components/input/index.vdt.js +4 -3
- package/es/components/input/useAutoWidth.d.ts +2 -0
- package/es/components/input/useAutoWidth.js +19 -1
- package/es/components/scrollSelect/useMouseEvents.js +5 -4
- package/es/components/select/base.d.ts +1 -1
- package/es/components/select/base.js +3 -2
- package/es/components/select/base.vdt.js +4 -3
- package/es/components/select/index.spec.js +158 -84
- package/es/components/select/option.js +2 -1
- package/es/components/select/select.js +2 -1
- package/es/components/select/styles.d.ts +79 -0
- package/es/components/select/styles.js +1 -0
- package/es/components/select/useInput.d.ts +1 -1
- package/es/components/select/useInput.js +4 -4
- package/es/components/table/index.spec.js +84 -6
- package/es/components/table/useStickyHeader.js +1 -1
- package/es/components/timepicker/index.spec.js +298 -128
- package/es/components/timepicker/panelPicker.d.ts +21 -16
- package/es/components/timepicker/panelPicker.js +7 -4
- package/es/components/timepicker/panelPicker.vdt.js +5 -9
- package/es/components/timepicker/selectPicker.d.ts +4 -3
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useConfirm.d.ts +6 -0
- package/es/components/timepicker/useConfirm.js +19 -0
- package/es/components/timepicker/useDefaultValue.d.ts +4 -0
- package/es/components/timepicker/useDefaultValue.js +27 -0
- package/es/components/timepicker/useDisabled.d.ts +6 -3
- package/es/components/timepicker/useDisabled.js +13 -4
- package/es/components/timepicker/useFormats.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +13 -8
- package/es/components/timepicker/useValue.js +14 -15
- package/es/components/tour/index.spec.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/index.js +2 -1
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/react.js +13 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +1 -3
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +1 -21
- package/es/site/data/components/select/demos/creatable/react.js +2 -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/customText/index.d.ts +19 -6
- package/es/site/data/components/tour/demos/customText/index.js +18 -17
- package/es/site/data/components/tour/demos/customText/react.d.ts +20 -6
- package/es/site/data/components/tour/demos/customText/react.js +31 -27
- package/index.ts +2 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
- package/components/datepicker/demos/nowrap.md +0 -35
- package/components/datepicker/usePosition.ts +0 -169
- package/es/components/datepicker/usePosition.d.ts +0 -10
- package/es/components/datepicker/usePosition.js +0 -166
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/index.js +0 -19
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/react.js +0 -49
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/index.js +0 -55
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/react.js +0 -99
|
@@ -7,10 +7,11 @@ import { DatepickerTime } from './time';
|
|
|
7
7
|
import { Icon } from '../icon';
|
|
8
8
|
import { Button } from '../button';
|
|
9
9
|
import { _$ } from '../../i18n';
|
|
10
|
-
import { makePanelStyles,
|
|
11
|
-
import {
|
|
10
|
+
import { makeStyles, makePanelStyles, makeHighlightStyles } from './styles';
|
|
11
|
+
import { PanelFlags } from './usePanel';
|
|
12
12
|
import { isFunction } from 'intact-shared';
|
|
13
13
|
import { Tabs, Tab } from '../tabs';
|
|
14
|
+
import { Position } from './useHighlight';
|
|
14
15
|
export default function ($props, $blocks, $__proto__) {
|
|
15
16
|
var _classNameObj,
|
|
16
17
|
_classDatePickerObj,
|
|
@@ -18,69 +19,69 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
18
19
|
$blocks || ($blocks = {});
|
|
19
20
|
$props || ($props = {});
|
|
20
21
|
var $this = this;
|
|
22
|
+
var k = this.config.k;
|
|
21
23
|
var _this$get = this.get(),
|
|
22
24
|
className = _this$get.className,
|
|
23
25
|
type = _this$get.type,
|
|
24
26
|
range = _this$get.range,
|
|
25
27
|
multiple = _this$get.multiple,
|
|
26
|
-
shortcuts = _this$get.shortcuts
|
|
28
|
+
shortcuts = _this$get.shortcuts,
|
|
29
|
+
size = _this$get.size;
|
|
27
30
|
var _this$value = this.value,
|
|
28
31
|
value = _this$value.value.value,
|
|
29
32
|
onChangeDate = _this$value.onChangeDate,
|
|
30
|
-
onConfirm = _this$value.onConfirm,
|
|
31
33
|
onChangeTime = _this$value.onChangeTime,
|
|
32
34
|
onChangeDateForRange = _this$value.onChangeDateForRange,
|
|
33
35
|
getTimeValue = _this$value.getTimeValue;
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var showPanel = range && position.value === 'end';
|
|
41
|
-
var positionDisplay = !multiple && range && (type === 'datetime' || type === 'date');
|
|
36
|
+
var onConfirm = this.confirm.onConfirm;
|
|
37
|
+
var _this$highlight = this.highlight,
|
|
38
|
+
position = _this$highlight.position,
|
|
39
|
+
handleInputClick = _this$highlight.handleInputClick,
|
|
40
|
+
highlightWidth = _this$highlight.highlightWidth,
|
|
41
|
+
highlightLeft = _this$highlight.highlightLeft;
|
|
42
42
|
// 判断是否显示双面板
|
|
43
|
-
var showDualPanels = range &&
|
|
43
|
+
var showDualPanels = range && type !== 'datetime';
|
|
44
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[
|
|
45
|
+
var classDatePickerObj = (_classDatePickerObj = {}, _classDatePickerObj[k + "-datepicker"] = true, _classDatePickerObj[makeHighlightStyles(k, size, highlightWidth.value, highlightLeft.value)] = range, _classDatePickerObj[makeStyles(k)] = true, _classDatePickerObj);
|
|
46
46
|
var _this$disabled = this.disabled,
|
|
47
47
|
isDisabledTime = _this$disabled.isDisabledTime,
|
|
48
48
|
isDisabledConfirm = _this$disabled.isDisabledConfirm;
|
|
49
49
|
var _this$panel = this.panel,
|
|
50
|
-
startPanel = _this$panel.startPanel,
|
|
51
|
-
endPanel = _this$panel.endPanel,
|
|
52
|
-
getPanel = _this$panel.getPanel,
|
|
53
50
|
startRef = _this$panel.startRef,
|
|
54
51
|
endRef = _this$panel.endRef;
|
|
55
52
|
var generatePanel = function generatePanel(flag) {
|
|
56
|
-
var panel = getPanel(flag);
|
|
57
|
-
var timeValue = getTimeValue(flag);
|
|
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
53
|
return _$ce(2, 'div', [_$cc(DatepickerCalendar, {
|
|
66
54
|
'value': value,
|
|
67
55
|
'ev-change': onChangeDate,
|
|
68
56
|
'type': type === 'datetime' ? 'date' : type,
|
|
69
57
|
'flag': flag,
|
|
70
|
-
'ref': flag === PanelFlags.Start ? startRef : endRef
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
'
|
|
78
|
-
|
|
79
|
-
|
|
58
|
+
'ref': flag === PanelFlags.Start ? startRef : endRef,
|
|
59
|
+
'highlightPosition': position.value
|
|
60
|
+
}, null, flag === PanelFlags.Start ? startRef : endRef), type === 'datetime' ? _$ce(2, 'div', function () {
|
|
61
|
+
var timeValue = getTimeValue(flag);
|
|
62
|
+
if (flag === PanelFlags.End && !timeValue) {
|
|
63
|
+
timeValue = getTimeValue(PanelFlags.Start);
|
|
64
|
+
}
|
|
65
|
+
var timeString = '00:00:00';
|
|
66
|
+
if (timeValue) {
|
|
67
|
+
var valueString = _this.formats.getShowString(timeValue).split(/\s+/);
|
|
68
|
+
timeString = valueString[1];
|
|
69
|
+
}
|
|
70
|
+
return [_$ce(2, 'div', timeString, 0, _$cn(k + "-datepicker-time-time")), _$cc(DatepickerTime, {
|
|
71
|
+
'value': timeValue,
|
|
72
|
+
'ev-$change:value': function ev$changeValue(v) {
|
|
73
|
+
return onChangeTime(v, flag);
|
|
74
|
+
},
|
|
75
|
+
'format': _this.formats.getValueFormat(),
|
|
76
|
+
'flag': flag,
|
|
77
|
+
'isDisabledTime': isDisabledTime
|
|
78
|
+
})];
|
|
79
|
+
}(), 0, _$cn(k + "-datepicker-time-wrapper")) : undefined], 0, _$cn(k + "-datepicker-calendar-time-wrapper"));
|
|
80
80
|
};
|
|
81
81
|
return _$su.call($this, {
|
|
82
82
|
'className': _$cn(classDatePickerObj),
|
|
83
|
-
'onClick': handleInputClick
|
|
83
|
+
'onClick': handleInputClick,
|
|
84
|
+
'alwaysShowOnClick': true
|
|
84
85
|
}, function ($blocks) {
|
|
85
86
|
var _$blocks = {},
|
|
86
87
|
__$blocks = _$ex({}, $blocks);
|
|
@@ -94,7 +95,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
94
95
|
'title': label,
|
|
95
96
|
'ev-click': linkEvent($value, _this2.setByShortcut)
|
|
96
97
|
});
|
|
97
|
-
}), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [showDualPanels
|
|
98
|
+
}), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [generatePanel(!showDualPanels && position.value === Position.End ? PanelFlags.End : PanelFlags.Start), _$ct('\n '), showDualPanels ? generatePanel(PanelFlags.End) : null], 0, _$cn(k + "-datepicker-calendars")), type === 'datetime' ? _$ce(2, 'div', _$cc(Button, {
|
|
98
99
|
'type': 'primary',
|
|
99
100
|
'size': 'small',
|
|
100
101
|
'disabled': isDisabledConfirm(),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Sizes } from '../../styles/utils';
|
|
1
2
|
import '../../styles/global';
|
|
2
3
|
declare const defaults: {
|
|
3
4
|
width: string;
|
|
@@ -59,6 +60,10 @@ declare const defaults: {
|
|
|
59
60
|
};
|
|
60
61
|
declare let datepicker: typeof defaults;
|
|
61
62
|
export { datepicker };
|
|
63
|
+
export declare const makeStyles: {
|
|
64
|
+
(k: string): string;
|
|
65
|
+
clearCache(): {};
|
|
66
|
+
};
|
|
62
67
|
export declare const makePanelStyles: {
|
|
63
68
|
(k: string): string;
|
|
64
69
|
clearCache(): {};
|
|
@@ -71,7 +76,7 @@ export declare const makeTimeStyles: {
|
|
|
71
76
|
(k: string): string;
|
|
72
77
|
clearCache(): {};
|
|
73
78
|
};
|
|
74
|
-
export declare const
|
|
75
|
-
(k: string,
|
|
79
|
+
export declare const makeHighlightStyles: {
|
|
80
|
+
(k: string, size: Sizes, highlightWidth: number, highlightLeft: number): string;
|
|
76
81
|
clearCache(): {};
|
|
77
82
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { css } from '@emotion/css';
|
|
2
2
|
import { theme, setDefault } from '../../styles/theme';
|
|
3
|
-
import { deepDefaults, palette } from '../../styles/utils';
|
|
3
|
+
import { deepDefaults, getLeft, palette } from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import { cache } from '../utils';
|
|
6
|
+
import { select } from '../select/styles';
|
|
6
7
|
var defaults = {
|
|
7
8
|
width: "300px",
|
|
8
9
|
padding: "16px 16px 4px",
|
|
@@ -85,8 +86,12 @@ setDefault(function () {
|
|
|
85
86
|
makePanelStyles == null || makePanelStyles.clearCache();
|
|
86
87
|
makeCalendarStyles == null || makeCalendarStyles.clearCache();
|
|
87
88
|
makeTimeStyles == null || makeTimeStyles.clearCache();
|
|
89
|
+
makeHighlightStyles == null || makeHighlightStyles.clearCache();
|
|
88
90
|
});
|
|
89
91
|
export { datepicker };
|
|
92
|
+
export var makeStyles = cache(function (k) {
|
|
93
|
+
return /*#__PURE__*/css("&.", k, "-dropdown-open{.", k, "-input-inner{color:", theme.color.placeholder, ";}}");
|
|
94
|
+
});
|
|
90
95
|
export var makePanelStyles = cache(function makePanelStyles(k) {
|
|
91
96
|
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;}");
|
|
92
97
|
});
|
|
@@ -94,19 +99,9 @@ export var makeCalendarStyles = cache(function makeCalendarStyles(k) {
|
|
|
94
99
|
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;}}}");
|
|
95
100
|
});
|
|
96
101
|
export var makeTimeStyles = cache(function makeTimeStyles(k) {
|
|
97
|
-
return /*#__PURE__*/css("display:flex;padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-scroll-select{flex:1;height:
|
|
102
|
+
return /*#__PURE__*/css("display:flex;padding:", datepicker.padding, ";width:", datepicker.width, ";position:relative;.", k, "-scroll-select{flex:1;height:265px;}");
|
|
98
103
|
});
|
|
99
|
-
export var
|
|
100
|
-
|
|
101
|
-
|
|
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;}");
|
|
104
|
+
export var makeHighlightStyles = cache(function makeHighlightStyles(k, size, highlightWidth, highlightLeft) {
|
|
105
|
+
var paddingLeft = getLeft(select[size].padding);
|
|
106
|
+
return /*#__PURE__*/css("&.", k, "-dropdown-open{&:before{content:'';display:block;width:", highlightWidth ? highlightWidth + 'px' : '50%', ";height:1px;position:absolute;background-color:", datepicker.item.active.bgColor, ";left:calc(", paddingLeft, " + ", highlightLeft, "px);bottom:0;transition:left ", theme.transition.middle, ";}}");
|
|
112
107
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { useFormats } from './useFormats';
|
|
2
|
+
import { useHighlight } from './useHighlight';
|
|
3
|
+
import { useValue } from './useValue';
|
|
4
|
+
export declare function useConfirm(highlight: ReturnType<typeof useHighlight>, value: ReturnType<typeof useValue>, getValueString: ReturnType<typeof useFormats>['getValueString']): {
|
|
5
|
+
onConfirm: () => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
2
|
+
import { last } from '../utils';
|
|
3
|
+
export function useConfirm(highlight, value, getValueString) {
|
|
4
|
+
var instance = useInstance();
|
|
5
|
+
var selectionState = [false, false];
|
|
6
|
+
/**
|
|
7
|
+
* can not use hide event to do it
|
|
8
|
+
* because value will be reset to dayjsValue on hide in useValue
|
|
9
|
+
*/
|
|
10
|
+
instance.on('$change:show', function (show) {
|
|
11
|
+
if (!show) {
|
|
12
|
+
reset();
|
|
13
|
+
if (instance.get('range') && hasWholeRangeValue()) {
|
|
14
|
+
// to fix the order
|
|
15
|
+
value.updateValue();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
instance.on('selecting', function () {
|
|
20
|
+
var _instance$get = instance.get(),
|
|
21
|
+
type = _instance$get.type;
|
|
22
|
+
if (type !== 'datetime') {
|
|
23
|
+
onConfirm();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
function reset() {
|
|
27
|
+
selectionState = [false, false];
|
|
28
|
+
}
|
|
29
|
+
function onConfirm() {
|
|
30
|
+
var _instance$get2 = instance.get(),
|
|
31
|
+
multiple = _instance$get2.multiple,
|
|
32
|
+
range = _instance$get2.range;
|
|
33
|
+
if (range) {
|
|
34
|
+
var position = highlight.position.value;
|
|
35
|
+
selectionState[position] = true;
|
|
36
|
+
if (selectionState.every(function (state) {
|
|
37
|
+
return state;
|
|
38
|
+
})) {
|
|
39
|
+
if (!multiple) {
|
|
40
|
+
instance.hide();
|
|
41
|
+
} else {
|
|
42
|
+
// update value directly on multiple mode
|
|
43
|
+
reset();
|
|
44
|
+
value.unique();
|
|
45
|
+
value.updateValue();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
highlight.togglePosition();
|
|
49
|
+
} else {
|
|
50
|
+
if (!multiple) {
|
|
51
|
+
instance.hide();
|
|
52
|
+
} else {
|
|
53
|
+
value.unique();
|
|
54
|
+
}
|
|
55
|
+
value.updateValue();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function hasWholeRangeValue() {
|
|
59
|
+
var lastValue = last(value.value.value);
|
|
60
|
+
return lastValue && lastValue.length === 2;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
onConfirm: onConfirm
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { State } from '../../hooks/useState';
|
|
2
2
|
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
3
3
|
import type { useFormats } from './useFormats';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { StateValueItem } from './useValueBase';
|
|
5
|
+
import { Position } from './useHighlight';
|
|
6
|
+
export declare function useDisabled({ createDateByValueFormat }: ReturnType<typeof useFormats>, getHighlightPosition?: () => State<Position>): {
|
|
6
7
|
isDisabled: (value: Dayjs, type?: OpUnitType | QUnitType) => boolean;
|
|
7
|
-
isDisabledTime: (value: Dayjs
|
|
8
|
+
isDisabledTime: (value: Dayjs) => boolean;
|
|
8
9
|
isDisabledConfirm: () => boolean;
|
|
10
|
+
isDisabledValue: (value: StateValueItem) => boolean;
|
|
9
11
|
maxDate: State<Dayjs | null>;
|
|
10
12
|
minDate: State<Dayjs | null>;
|
|
11
13
|
};
|
|
@@ -2,8 +2,7 @@ import { useInstance } from 'intact';
|
|
|
2
2
|
import { useState } from '../../hooks/useState';
|
|
3
3
|
import { isNullOrUndefined } from 'intact-shared';
|
|
4
4
|
import { isGT, isLT, last } from './helpers';
|
|
5
|
-
|
|
6
|
-
export function useDisabled(_ref) {
|
|
5
|
+
export function useDisabled(_ref, getHighlightPosition) {
|
|
7
6
|
var createDateByValueFormat = _ref.createDateByValueFormat;
|
|
8
7
|
var instance = useInstance();
|
|
9
8
|
var maxDate = useState(null);
|
|
@@ -29,41 +28,36 @@ export function useDisabled(_ref) {
|
|
|
29
28
|
disabledDate = _instance$get.disabledDate;
|
|
30
29
|
return isGT(value, maxDate.value, type) || isLT(value, minDate.value, type) || !!disabledDate && disabledDate(value);
|
|
31
30
|
}
|
|
32
|
-
function isDisabledTime(value
|
|
33
|
-
|
|
34
|
-
if (!instance.get('range')) return false;
|
|
35
|
-
// compare the start and the end datetime
|
|
36
|
-
var anotherDatetime = instance.value.getTimeValue(flag === PanelFlags.Start ? PanelFlags.End : PanelFlags.Start);
|
|
37
|
-
if (!anotherDatetime) return false;
|
|
38
|
-
if (flag === PanelFlags.Start) {
|
|
39
|
-
return value.isAfter(anotherDatetime, 'second');
|
|
40
|
-
} else {
|
|
41
|
-
return value.isBefore(anotherDatetime, 'second');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
31
|
+
function isDisabledTime(value) {
|
|
32
|
+
return isDisabled(value, 'second');
|
|
45
33
|
}
|
|
46
34
|
function isDisabledConfirm() {
|
|
47
35
|
var lastValue = last(instance.value.value.value);
|
|
48
|
-
if (!lastValue) return true;
|
|
49
36
|
var _instance$get2 = instance.get(),
|
|
50
|
-
range = _instance$get2.range
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
range = _instance$get2.range,
|
|
38
|
+
multiple = _instance$get2.multiple;
|
|
39
|
+
if (!lastValue || instance.value.allValuesUpdatedInMultipleMode()) return true;
|
|
40
|
+
if (range && getHighlightPosition) {
|
|
41
|
+
var position = getHighlightPosition();
|
|
42
|
+
// if the position is not selected, it should be disabled
|
|
43
|
+
if (!lastValue[position.value]) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
57
46
|
}
|
|
47
|
+
return isDisabledValue(lastValue);
|
|
48
|
+
}
|
|
49
|
+
function isDisabledValue(value) {
|
|
50
|
+
var _instance$get3 = instance.get(),
|
|
51
|
+
range = _instance$get3.range;
|
|
58
52
|
var start;
|
|
59
53
|
var end;
|
|
60
54
|
if (range) {
|
|
61
|
-
start =
|
|
62
|
-
end =
|
|
55
|
+
start = value[0];
|
|
56
|
+
end = value[1];
|
|
63
57
|
} else {
|
|
64
|
-
start =
|
|
58
|
+
start = value;
|
|
65
59
|
}
|
|
66
|
-
if (isDisabledTime(start
|
|
60
|
+
if (isDisabledTime(start) || end && isDisabledTime(end)) {
|
|
67
61
|
return true;
|
|
68
62
|
}
|
|
69
63
|
return false;
|
|
@@ -72,6 +66,7 @@ export function useDisabled(_ref) {
|
|
|
72
66
|
isDisabled: isDisabled,
|
|
73
67
|
isDisabledTime: isDisabledTime,
|
|
74
68
|
isDisabledConfirm: isDisabledConfirm,
|
|
69
|
+
isDisabledValue: isDisabledValue,
|
|
75
70
|
maxDate: maxDate,
|
|
76
71
|
minDate: minDate
|
|
77
72
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import dayjs, { Dayjs } from '
|
|
2
|
-
import { Value } from './
|
|
1
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
2
|
+
import type { Value } from './useValueBase';
|
|
3
3
|
export declare function useFormats(): {
|
|
4
4
|
getValueFormat: () => string;
|
|
5
5
|
getShowFormat: () => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useInstance } from 'intact';
|
|
2
|
-
import dayjs from '
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
3
|
import { isString } from 'intact-shared';
|
|
4
4
|
var FORMATS = {
|
|
5
5
|
date: 'YYYY-MM-DD',
|
|
@@ -25,8 +25,12 @@ export function useFormats() {
|
|
|
25
25
|
type = _instance$get2.type;
|
|
26
26
|
return showFormat || format || FORMATS[type];
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 根据日期字符串,按照格式创建日期对象
|
|
30
|
+
*/
|
|
28
31
|
function createDateByValueFormat(value) {
|
|
29
|
-
|
|
32
|
+
var format = isString(value) ? getValueFormat() : undefined;
|
|
33
|
+
return dayjs(value, format);
|
|
30
34
|
}
|
|
31
35
|
function createDateByShowFormat(value) {
|
|
32
36
|
return dayjs(value, getShowFormat(), true); // strict parsing
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { State } from '../../hooks/useState';
|
|
2
|
+
import { StateValue } from './useValueBase';
|
|
3
|
+
import { Dayjs } from 'dayjs';
|
|
4
|
+
export declare enum Position {
|
|
5
|
+
Start = 0,
|
|
6
|
+
End = 1
|
|
7
|
+
}
|
|
8
|
+
export declare function useHighlight(value: State<StateValue>, getShowString: (value: Dayjs) => string, keywords: State<string>): {
|
|
9
|
+
position: State<Position>;
|
|
10
|
+
handleInputClick: () => void;
|
|
11
|
+
togglePosition: () => void;
|
|
12
|
+
highlightWidth: State<number>;
|
|
13
|
+
highlightLeft: State<number>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useInstance, onMounted } from 'intact';
|
|
2
|
+
import { useState, watchState } from '../../hooks/useState';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
export var Position;
|
|
5
|
+
(function (Position) {
|
|
6
|
+
Position[Position["Start"] = 0] = "Start";
|
|
7
|
+
Position[Position["End"] = 1] = "End";
|
|
8
|
+
})(Position || (Position = {}));
|
|
9
|
+
var DELIMITER_WIDTH = 14;
|
|
10
|
+
var fakeDate = dayjs();
|
|
11
|
+
export function useHighlight(value, getShowString, keywords) {
|
|
12
|
+
var instance = useInstance();
|
|
13
|
+
var position = useState(Position.Start);
|
|
14
|
+
var highlightWidth = useState(0);
|
|
15
|
+
var highlightLeft = useState(0);
|
|
16
|
+
/**
|
|
17
|
+
* calculate the real width by rendering the showString to fake div
|
|
18
|
+
*/
|
|
19
|
+
onMounted(function () {
|
|
20
|
+
var showString = getShowString(fakeDate);
|
|
21
|
+
instance.input.inputRef.value.getStringWidth(showString).then(function (width) {
|
|
22
|
+
highlightWidth.set(width);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* change the left of style on position changed
|
|
27
|
+
*/
|
|
28
|
+
watchState(position, function (position) {
|
|
29
|
+
highlightLeft.set(position === Position.Start ? 0 : highlightWidth.value + DELIMITER_WIDTH);
|
|
30
|
+
});
|
|
31
|
+
// if value is cleared reset the position to start
|
|
32
|
+
instance.watch('value', function (v) {
|
|
33
|
+
if (!v || Array.isArray(v) && !v.length) {
|
|
34
|
+
position.set(Position.Start);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function handleInputClick() {
|
|
38
|
+
var _instance$get = instance.get(),
|
|
39
|
+
range = _instance$get.range,
|
|
40
|
+
type = _instance$get.type;
|
|
41
|
+
if (!range) return;
|
|
42
|
+
var cursorPosition = instance.input.inputRef.value.getSelectionStart();
|
|
43
|
+
var showString = getShowString(fakeDate);
|
|
44
|
+
if (!cursorPosition || cursorPosition <= showString.length + 1 /* one whitespace */) {
|
|
45
|
+
position.set(Position.Start);
|
|
46
|
+
} else {
|
|
47
|
+
position.set(Position.End);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function togglePosition() {
|
|
51
|
+
position.set(position.value === Position.Start ? Position.End : Position.Start);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
position: position,
|
|
55
|
+
handleInputClick: handleInputClick,
|
|
56
|
+
togglePosition: togglePosition,
|
|
57
|
+
highlightWidth: highlightWidth,
|
|
58
|
+
highlightLeft: highlightLeft
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -72,7 +72,8 @@ export function useKeyboards(panelRef, focusDate) {
|
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
var _focusDate = focusDate.value;
|
|
75
|
-
|
|
75
|
+
var unit = type === 'date' ? 'day' : type;
|
|
76
|
+
_focusDate = _focusDate.add(offset, unit);
|
|
76
77
|
focusDate.set(_focusDate);
|
|
77
78
|
// change panel show date
|
|
78
79
|
calendar.showDate.date.set(_focusDate);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DayjsValue } from './
|
|
1
|
+
import { DayjsValue } from './useValueBase';
|
|
2
2
|
import type { useFormats } from './useFormats';
|
|
3
3
|
export declare function useMergeRange(formats: ReturnType<typeof useFormats>): {
|
|
4
4
|
formatMultipleValues: (dayjsValue: DayjsValue, results: string[]) => string[];
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
|
|
2
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
3
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
4
|
import { useInstance } from 'intact';
|
|
5
|
+
// TODO isMerge
|
|
7
6
|
export function useMergeRange(formats) {
|
|
8
7
|
var instance = useInstance();
|
|
9
8
|
function _mergeRanges(dayjsValue, getShowString) {
|
|
@@ -28,20 +27,16 @@ export function useMergeRange(formats) {
|
|
|
28
27
|
return [getShowString(mergedRange.start) + " ~ " + getShowString(mergedRange.end)];
|
|
29
28
|
}
|
|
30
29
|
function formatMultipleValues(dayjsValue, results) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return result + "-" + index;
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
30
|
+
// const {isMerge, nowrap} = instance.get();
|
|
31
|
+
// if (isMerge && nowrap) {
|
|
32
|
+
// const mergedResults = _mergeRanges(dayjsValue, (v: Dayjs) => v.format(formats.getShowFormat()));
|
|
33
|
+
// if (mergedResults.length > 0) {
|
|
34
|
+
// return [
|
|
35
|
+
// ...mergedResults,
|
|
36
|
+
// ...results.slice(1).map((result, index) => `${result}-${index}`)
|
|
37
|
+
// ];
|
|
38
|
+
// }
|
|
39
|
+
// }
|
|
45
40
|
return results;
|
|
46
41
|
}
|
|
47
42
|
return {
|
|
@@ -26,10 +26,12 @@ export function useMonths(showDate, status, focusDate) {
|
|
|
26
26
|
function onClick(date) {
|
|
27
27
|
showDate.set(date);
|
|
28
28
|
var datepickerType = instance.datepicker.get('type');
|
|
29
|
-
if (datepickerType
|
|
30
|
-
instance.type.set('date');
|
|
31
|
-
} else {
|
|
29
|
+
if (datepickerType === 'month' || datepickerType === 'year') {
|
|
32
30
|
instance.triggerChange(date);
|
|
31
|
+
} else if (datepickerType === 'week') {
|
|
32
|
+
instance.type.set('week');
|
|
33
|
+
} else {
|
|
34
|
+
instance.type.set('date');
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
return {
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { DatepickerCalendar } from './calendar';
|
|
2
|
-
export declare enum PanelTypes {
|
|
3
|
-
Date = 0,
|
|
4
|
-
Time = 1
|
|
5
|
-
}
|
|
6
2
|
export declare enum PanelFlags {
|
|
7
3
|
Start = 0,
|
|
8
4
|
End = 1
|
|
9
5
|
}
|
|
10
|
-
export declare function usePanel(
|
|
11
|
-
startPanel: import("../../hooks/useState").State<PanelTypes>;
|
|
12
|
-
endPanel: import("../../hooks/useState").State<PanelTypes>;
|
|
13
|
-
changePanel: (type: PanelTypes, flag?: PanelFlags) => void;
|
|
14
|
-
getPanel: (flag: PanelFlags) => import("../../hooks/useState").State<PanelTypes>;
|
|
15
|
-
reset: () => void;
|
|
6
|
+
export declare function usePanel(): {
|
|
16
7
|
startRef: import("intact").RefObject<DatepickerCalendar>;
|
|
17
8
|
endRef: import("intact").RefObject<DatepickerCalendar>;
|
|
18
9
|
};
|