@king-design/intact 3.5.2 → 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/button/index.md +1 -0
- package/components/cascader/index.spec.ts +7 -6
- package/components/datepicker/basepicker.ts +26 -267
- package/components/datepicker/calendar.ts +8 -2
- package/components/datepicker/calendar.vdt +23 -6
- package/components/datepicker/dayjs.ts +8 -2
- package/components/datepicker/demos/multiple.md +1 -1
- package/components/datepicker/demos/yearMonth.md +1 -1
- package/components/datepicker/helpers.ts +10 -12
- package/components/datepicker/index.md +2 -2
- package/components/datepicker/index.spec.ts +619 -190
- package/components/datepicker/index.ts +22 -21
- package/components/datepicker/index.vdt +47 -42
- package/components/datepicker/shortcuts.ts +1 -1
- package/components/datepicker/styles.ts +112 -4
- package/components/datepicker/useConfirm.ts +82 -0
- package/components/datepicker/useDisabled.ts +31 -33
- package/components/datepicker/useFormats.ts +10 -4
- package/components/datepicker/useHighlight.ts +81 -0
- package/components/datepicker/useKeyboards.ts +2 -1
- package/components/datepicker/useMergeRange.ts +54 -0
- package/components/datepicker/useMonths.ts +6 -3
- package/components/datepicker/usePanel.ts +19 -19
- package/components/datepicker/useQuarters.ts +47 -0
- package/components/datepicker/useShowDate.ts +14 -3
- package/components/datepicker/useStatus.ts +34 -15
- package/components/datepicker/useValue.ts +41 -39
- package/components/datepicker/useValueBase.ts +309 -0
- package/components/datepicker/useWeeks.ts +58 -0
- package/components/datepicker/useYears.ts +7 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dialog/useFixBody.ts +7 -64
- 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/ellipsis/styles.ts +4 -0
- package/components/form/styles.ts +1 -0
- 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/index.spec.ts +3 -3
- package/components/scrollSelect/useMouseEvents.ts +24 -10
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +3 -1
- package/components/select/demos/creatable.md +13 -0
- package/components/select/index.md +1 -0
- package/components/select/index.spec.ts +225 -6
- package/components/select/option.ts +10 -1
- package/components/select/select.ts +3 -0
- package/components/select/styles.ts +3 -1
- package/components/select/useFilterable.ts +1 -1
- package/components/select/useInput.ts +7 -9
- package/components/select/useSearchable.ts +2 -2
- 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/demos/step.md +1 -1
- package/components/timepicker/index.spec.ts +145 -27
- package/components/timepicker/panelPicker.ts +10 -4
- package/components/timepicker/panelPicker.vdt +5 -3
- 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/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/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 -25
- package/es/components/datepicker/basepicker.js +22 -234
- package/es/components/datepicker/calendar.d.ts +36 -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 +2 -2
- package/es/components/datepicker/dayjs.js +6 -0
- package/es/components/datepicker/helpers.d.ts +8 -7
- package/es/components/datepicker/helpers.js +2 -3
- package/es/components/datepicker/index.d.ts +26 -19
- package/es/components/datepicker/index.js +21 -13
- package/es/components/datepicker/index.spec.js +1389 -633
- package/es/components/datepicker/index.vdt.js +43 -46
- package/es/components/datepicker/shortcuts.d.ts +1 -1
- package/es/components/datepicker/styles.d.ts +22 -0
- package/es/components/datepicker/styles.js +26 -4
- package/es/components/datepicker/useConfirm.d.ts +6 -0
- package/es/components/datepicker/useConfirm.js +65 -0
- package/es/components/datepicker/useDisabled.d.ts +7 -5
- package/es/components/datepicker/useDisabled.js +22 -27
- package/es/components/datepicker/useFormats.d.ts +2 -2
- package/es/components/datepicker/useFormats.js +9 -3
- 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 +5 -0
- package/es/components/datepicker/useMergeRange.js +45 -0
- 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/useQuarters.d.ts +15 -0
- package/es/components/datepicker/useQuarters.js +36 -0
- package/es/components/datepicker/useShowDate.js +10 -2
- package/es/components/datepicker/useStatus.d.ts +1 -1
- package/es/components/datepicker/useStatus.js +33 -16
- package/es/components/datepicker/useValue.d.ts +12 -6
- package/es/components/datepicker/useValue.js +49 -45
- package/es/components/datepicker/useValueBase.d.ts +28 -0
- package/es/components/datepicker/useValueBase.js +277 -0
- package/es/components/datepicker/useWeeks.d.ts +19 -0
- package/es/components/datepicker/useWeeks.js +48 -0
- package/es/components/datepicker/useYears.js +6 -3
- package/es/components/dialog/useFixBody.js +6 -58
- package/es/components/dropdown/dropdown.d.ts +1 -0
- package/es/components/dropdown/dropdown.js +7 -4
- package/es/components/ellipsis/styles.js +1 -1
- package/es/components/form/styles.js +1 -1
- 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/index.spec.js +4 -6
- package/es/components/scrollSelect/useMouseEvents.js +22 -9
- package/es/components/select/base.d.ts +1 -1
- package/es/components/select/base.js +3 -2
- package/es/components/select/base.vdt.js +5 -2
- package/es/components/select/index.spec.js +329 -82
- package/es/components/select/option.d.ts +1 -0
- package/es/components/select/option.js +10 -2
- package/es/components/select/select.d.ts +1 -0
- package/es/components/select/select.js +4 -2
- package/es/components/select/styles.d.ts +79 -0
- package/es/components/select/styles.js +1 -0
- package/es/components/select/useFilterable.js +2 -1
- package/es/components/select/useInput.d.ts +1 -1
- package/es/components/select/useInput.js +7 -4
- package/es/components/select/useSearchable.js +1 -0
- 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 +23 -17
- package/es/components/timepicker/panelPicker.js +7 -4
- package/es/components/timepicker/panelPicker.vdt.js +8 -4
- package/es/components/timepicker/selectPicker.d.ts +5 -4
- 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 +7 -4
- package/es/components/timepicker/useDisabled.js +13 -4
- package/es/components/timepicker/useFormats.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +14 -8
- package/es/components/timepicker/useValue.js +14 -15
- 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/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/datepicker/demos/multiple/react.js +2 -2
- 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/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/customText/index.d.ts +33 -0
- package/es/site/data/components/tour/demos/customText/index.js +55 -0
- package/es/site/data/components/tour/demos/customText/react.d.ts +33 -0
- package/es/site/data/components/tour/demos/customText/react.js +99 -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/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
|
@@ -7,84 +7,81 @@ 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';
|
|
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,
|
|
17
|
+
_classDatePickerObj,
|
|
16
18
|
_this = this;
|
|
17
19
|
$blocks || ($blocks = {});
|
|
18
20
|
$props || ($props = {});
|
|
19
21
|
var $this = this;
|
|
22
|
+
var k = this.config.k;
|
|
20
23
|
var _this$get = this.get(),
|
|
21
24
|
className = _this$get.className,
|
|
22
25
|
type = _this$get.type,
|
|
23
26
|
range = _this$get.range,
|
|
24
27
|
multiple = _this$get.multiple,
|
|
25
|
-
shortcuts = _this$get.shortcuts
|
|
28
|
+
shortcuts = _this$get.shortcuts,
|
|
29
|
+
size = _this$get.size;
|
|
26
30
|
var _this$value = this.value,
|
|
27
31
|
value = _this$value.value.value,
|
|
28
32
|
onChangeDate = _this$value.onChangeDate,
|
|
29
|
-
onConfirm = _this$value.onConfirm,
|
|
30
33
|
onChangeTime = _this$value.onChangeTime,
|
|
31
34
|
onChangeDateForRange = _this$value.onChangeDateForRange,
|
|
32
35
|
getTimeValue = _this$value.getTimeValue;
|
|
33
|
-
var
|
|
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
|
+
// 判断是否显示双面板
|
|
43
|
+
var showDualPanels = range && type !== 'datetime';
|
|
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[makeHighlightStyles(k, size, highlightWidth.value, highlightLeft.value)] = range, _classDatePickerObj[makeStyles(k)] = true, _classDatePickerObj);
|
|
35
46
|
var _this$disabled = this.disabled,
|
|
36
47
|
isDisabledTime = _this$disabled.isDisabledTime,
|
|
37
48
|
isDisabledConfirm = _this$disabled.isDisabledConfirm;
|
|
38
49
|
var _this$panel = this.panel,
|
|
39
|
-
startPanel = _this$panel.startPanel,
|
|
40
|
-
endPanel = _this$panel.endPanel,
|
|
41
|
-
getPanel = _this$panel.getPanel,
|
|
42
50
|
startRef = _this$panel.startRef,
|
|
43
51
|
endRef = _this$panel.endRef;
|
|
44
52
|
var generatePanel = function generatePanel(flag) {
|
|
45
|
-
|
|
46
|
-
var timeValue = getTimeValue(flag);
|
|
47
|
-
return _$ce(2, 'div', [function () {
|
|
48
|
-
if (type === 'datetime') {
|
|
49
|
-
var dateString = '0000-00-00';
|
|
50
|
-
var timeString = '00:00:00';
|
|
51
|
-
if (timeValue) {
|
|
52
|
-
var valueString = _this.formats.getShowString(timeValue).split(/\s+/);
|
|
53
|
-
dateString = valueString[0];
|
|
54
|
-
timeString = valueString[1];
|
|
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, {
|
|
53
|
+
return _$ce(2, 'div', [_$cc(DatepickerCalendar, {
|
|
71
54
|
'value': value,
|
|
72
55
|
'ev-change': onChangeDate,
|
|
73
56
|
'type': type === 'datetime' ? 'date' : type,
|
|
74
57
|
'flag': flag,
|
|
75
|
-
'ref': flag === PanelFlags.Start ? startRef : endRef
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
'
|
|
83
|
-
|
|
84
|
-
|
|
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"));
|
|
85
80
|
};
|
|
86
81
|
return _$su.call($this, {
|
|
87
|
-
'className': _$cn(
|
|
82
|
+
'className': _$cn(classDatePickerObj),
|
|
83
|
+
'onClick': handleInputClick,
|
|
84
|
+
'alwaysShowOnClick': true
|
|
88
85
|
}, function ($blocks) {
|
|
89
86
|
var _$blocks = {},
|
|
90
87
|
__$blocks = _$ex({}, $blocks);
|
|
@@ -98,7 +95,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
98
95
|
'title': label,
|
|
99
96
|
'ev-click': linkEvent($value, _this2.setByShortcut)
|
|
100
97
|
});
|
|
101
|
-
}), 0, _$cn(k + "-datepicker-shortcuts")) : undefined, _$ce(2, 'div', [_$ce(2, 'div', [generatePanel(PanelFlags.Start), _$ct('\n '),
|
|
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, {
|
|
102
99
|
'type': 'primary',
|
|
103
100
|
'size': 'small',
|
|
104
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;
|
|
@@ -5,7 +6,9 @@ declare const defaults: {
|
|
|
5
6
|
border: string;
|
|
6
7
|
item: {
|
|
7
8
|
gutter: string;
|
|
9
|
+
yearGutter: string;
|
|
8
10
|
height: string;
|
|
11
|
+
rangeGutter: string;
|
|
9
12
|
readonly hoverBgColor: string;
|
|
10
13
|
readonly exceedColor: string;
|
|
11
14
|
readonly todayBorder: string;
|
|
@@ -34,6 +37,17 @@ declare const defaults: {
|
|
|
34
37
|
footer: {
|
|
35
38
|
padding: string;
|
|
36
39
|
};
|
|
40
|
+
week: {
|
|
41
|
+
height: string;
|
|
42
|
+
width: string;
|
|
43
|
+
margin: string;
|
|
44
|
+
padding: string;
|
|
45
|
+
currentWeek: string;
|
|
46
|
+
};
|
|
47
|
+
calendarTime: {
|
|
48
|
+
height: string;
|
|
49
|
+
fontSize: string;
|
|
50
|
+
};
|
|
37
51
|
shortcuts: {
|
|
38
52
|
width: string;
|
|
39
53
|
padding: string;
|
|
@@ -46,6 +60,10 @@ declare const defaults: {
|
|
|
46
60
|
};
|
|
47
61
|
declare let datepicker: typeof defaults;
|
|
48
62
|
export { datepicker };
|
|
63
|
+
export declare const makeStyles: {
|
|
64
|
+
(k: string): string;
|
|
65
|
+
clearCache(): {};
|
|
66
|
+
};
|
|
49
67
|
export declare const makePanelStyles: {
|
|
50
68
|
(k: string): string;
|
|
51
69
|
clearCache(): {};
|
|
@@ -58,3 +76,7 @@ export declare const makeTimeStyles: {
|
|
|
58
76
|
(k: string): string;
|
|
59
77
|
clearCache(): {};
|
|
60
78
|
};
|
|
79
|
+
export declare const makeHighlightStyles: {
|
|
80
|
+
(k: string, size: Sizes, highlightWidth: number, highlightLeft: number): string;
|
|
81
|
+
clearCache(): {};
|
|
82
|
+
};
|
|
@@ -1,15 +1,18 @@
|
|
|
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",
|
|
9
10
|
border: "1px solid #e5e5e5",
|
|
10
11
|
item: {
|
|
11
12
|
gutter: "7px",
|
|
13
|
+
yearGutter: '36px',
|
|
12
14
|
height: "24px",
|
|
15
|
+
rangeGutter: "17px",
|
|
13
16
|
get hoverBgColor() {
|
|
14
17
|
return theme.color.bg;
|
|
15
18
|
},
|
|
@@ -52,6 +55,17 @@ var defaults = {
|
|
|
52
55
|
footer: {
|
|
53
56
|
padding: "8px 16px"
|
|
54
57
|
},
|
|
58
|
+
week: {
|
|
59
|
+
height: "20px",
|
|
60
|
+
width: "40px",
|
|
61
|
+
margin: "0 0 0 10px",
|
|
62
|
+
padding: "0 2px",
|
|
63
|
+
currentWeek: '#eee'
|
|
64
|
+
},
|
|
65
|
+
calendarTime: {
|
|
66
|
+
height: "44px",
|
|
67
|
+
fontSize: "14px"
|
|
68
|
+
},
|
|
55
69
|
shortcuts: {
|
|
56
70
|
width: '100px',
|
|
57
71
|
padding: '12px 0',
|
|
@@ -72,14 +86,22 @@ setDefault(function () {
|
|
|
72
86
|
makePanelStyles == null || makePanelStyles.clearCache();
|
|
73
87
|
makeCalendarStyles == null || makeCalendarStyles.clearCache();
|
|
74
88
|
makeTimeStyles == null || makeTimeStyles.clearCache();
|
|
89
|
+
makeHighlightStyles == null || makeHighlightStyles.clearCache();
|
|
75
90
|
});
|
|
76
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
|
+
});
|
|
77
95
|
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;}");
|
|
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;}");
|
|
79
97
|
});
|
|
80
98
|
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(
|
|
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;}}}");
|
|
82
100
|
});
|
|
83
101
|
export var makeTimeStyles = cache(function makeTimeStyles(k) {
|
|
84
|
-
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;}");
|
|
103
|
+
});
|
|
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, ";}}");
|
|
85
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
|
-
import { Dayjs, OpUnitType } from 'dayjs';
|
|
2
|
+
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
3
3
|
import type { useFormats } from './useFormats';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { StateValueItem } from './useValueBase';
|
|
5
|
+
import { Position } from './useHighlight';
|
|
6
|
+
export declare function useDisabled({ createDateByValueFormat }: ReturnType<typeof useFormats>, getHighlightPosition?: () => State<Position>): {
|
|
7
|
+
isDisabled: (value: Dayjs, type?: OpUnitType | QUnitType) => boolean;
|
|
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,11 +1,13 @@
|
|
|
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',
|
|
6
6
|
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
7
7
|
year: 'YYYY',
|
|
8
|
-
month: 'YYYY-MM'
|
|
8
|
+
month: 'YYYY-MM',
|
|
9
|
+
quarter: 'YYYY-[Q]Q',
|
|
10
|
+
week: 'YYYY-w[周]'
|
|
9
11
|
};
|
|
10
12
|
export function useFormats() {
|
|
11
13
|
var instance = useInstance();
|
|
@@ -23,8 +25,12 @@ export function useFormats() {
|
|
|
23
25
|
type = _instance$get2.type;
|
|
24
26
|
return showFormat || format || FORMATS[type];
|
|
25
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 根据日期字符串,按照格式创建日期对象
|
|
30
|
+
*/
|
|
26
31
|
function createDateByValueFormat(value) {
|
|
27
|
-
|
|
32
|
+
var format = isString(value) ? getValueFormat() : undefined;
|
|
33
|
+
return dayjs(value, format);
|
|
28
34
|
}
|
|
29
35
|
function createDateByShowFormat(value) {
|
|
30
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);
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { useInstance } from 'intact';
|
|
5
|
+
// TODO isMerge
|
|
6
|
+
export function useMergeRange(formats) {
|
|
7
|
+
var instance = useInstance();
|
|
8
|
+
function _mergeRanges(dayjsValue, getShowString) {
|
|
9
|
+
var _context, _context2;
|
|
10
|
+
var ranges = _sortInstanceProperty(_context = _mapInstanceProperty(_context2 = _filterInstanceProperty(dayjsValue).call(dayjsValue, Array.isArray)).call(_context2, function (range) {
|
|
11
|
+
return {
|
|
12
|
+
start: range[0],
|
|
13
|
+
end: range[1]
|
|
14
|
+
};
|
|
15
|
+
})).call(_context, function (a, b) {
|
|
16
|
+
return a.start.valueOf() - b.start.valueOf();
|
|
17
|
+
});
|
|
18
|
+
if (ranges.length === 0) return [];
|
|
19
|
+
// 合并有交集的时间范围
|
|
20
|
+
var mergedRange = ranges.reduce(function (acc, curr) {
|
|
21
|
+
if (!acc) return curr;
|
|
22
|
+
return {
|
|
23
|
+
start: acc.start,
|
|
24
|
+
end: curr.end.valueOf() > acc.end.valueOf() ? curr.end : acc.end
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
return [getShowString(mergedRange.start) + " ~ " + getShowString(mergedRange.end)];
|
|
28
|
+
}
|
|
29
|
+
function formatMultipleValues(dayjsValue, results) {
|
|
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
|
+
// }
|
|
40
|
+
return results;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
formatMultipleValues: formatMultipleValues
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -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 {
|