@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
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import {TypeDefs, provide} from 'intact';
|
|
2
2
|
import template from './index.vdt';
|
|
3
|
-
import {BaseSelect, BaseSelectProps} from '../select/base';
|
|
4
3
|
import {DATEPICKER} from './constants';
|
|
5
4
|
import dayjs, {Dayjs} from './dayjs';
|
|
6
5
|
import {useValue} from './useValue';
|
|
7
6
|
import {isNullOrUndefined} from 'intact-shared'
|
|
8
7
|
import {_$} from '../../i18n';
|
|
9
8
|
import {bind} from '../utils';
|
|
10
|
-
import {State} from '../../hooks/useState';
|
|
11
9
|
import {useDisabled} from './useDisabled';
|
|
12
10
|
import {useFormats} from './useFormats';
|
|
13
11
|
import {usePanel} from './usePanel';
|
|
14
12
|
import {useFocusDate} from './useFocusDate';
|
|
15
13
|
import {useKeyboards} from './useKeyboards';
|
|
16
14
|
import {Shortcut} from './shortcuts';
|
|
15
|
+
import {useHighlight} from './useHighlight';
|
|
16
|
+
// import {useMergeRange} from './useMergeRange';
|
|
17
17
|
import {
|
|
18
18
|
BasePicker,
|
|
19
19
|
BasePickerProps,
|
|
20
20
|
BasePickerEvents,
|
|
21
21
|
BasePickerBlocks,
|
|
22
|
-
Value
|
|
23
22
|
} from './basepicker';
|
|
23
|
+
import {Value} from './useValueBase';
|
|
24
|
+
import { useConfirm } from './useConfirm';
|
|
24
25
|
|
|
25
26
|
export * as shortcuts from './shortcuts';
|
|
26
27
|
export { dayjs };
|
|
@@ -30,8 +31,9 @@ export interface DatepickerProps<
|
|
|
30
31
|
M extends boolean = boolean,
|
|
31
32
|
R extends boolean = boolean,
|
|
32
33
|
> extends BasePickerProps<V extends string ? V : V | string, M, R> {
|
|
33
|
-
type?: 'date' | 'datetime' | 'year' | 'month'
|
|
34
|
-
shortcuts?: Shortcut[]
|
|
34
|
+
type?: 'date' | 'datetime' | 'year' | 'month' | 'week' | 'quarter'
|
|
35
|
+
shortcuts?: Shortcut[],
|
|
36
|
+
// isMerge?: boolean
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export interface DatepickerEvents extends BasePickerEvents { }
|
|
@@ -43,13 +45,15 @@ export interface DatepickerBlocks<
|
|
|
43
45
|
|
|
44
46
|
const typeDefs: Required<TypeDefs<DatepickerProps>> = {
|
|
45
47
|
...BasePicker.typeDefs,
|
|
46
|
-
type: ['date', 'datetime', 'year', 'month'],
|
|
48
|
+
type: ['date', 'datetime', 'year', 'month', 'week', 'quarter'],
|
|
47
49
|
shortcuts: Array,
|
|
50
|
+
// isMerge: Boolean
|
|
48
51
|
};
|
|
49
52
|
|
|
50
53
|
const defaults = (): Partial<DatepickerProps> => ({
|
|
51
54
|
...BasePicker.defaults(),
|
|
52
55
|
type: 'date',
|
|
56
|
+
// isMerge: false
|
|
53
57
|
});
|
|
54
58
|
|
|
55
59
|
export class Datepicker<
|
|
@@ -62,11 +66,14 @@ export class Datepicker<
|
|
|
62
66
|
static defaults = defaults;
|
|
63
67
|
|
|
64
68
|
public formats = useFormats();
|
|
65
|
-
public disabled = useDisabled(this.formats);
|
|
69
|
+
public disabled = useDisabled(this.formats, () => this.highlight.position);
|
|
66
70
|
public panel = usePanel();
|
|
67
71
|
public focusDate = useFocusDate();
|
|
68
|
-
public value = useValue(this.formats, this.disabled, this.panel);
|
|
69
|
-
|
|
72
|
+
public value = useValue(this.formats, this.disabled, this.panel, () => this.highlight.position);
|
|
73
|
+
public highlight = useHighlight(this.value.value, this.formats.getShowString, this.input.keywords);
|
|
74
|
+
// public mergeRange = useMergeRange(this.formats);
|
|
75
|
+
private confirm = useConfirm(this.highlight, this.value, this.formats.getValueString);
|
|
76
|
+
|
|
70
77
|
init() {
|
|
71
78
|
super.init();
|
|
72
79
|
provide(DATEPICKER, this);
|
|
@@ -75,16 +82,19 @@ export class Datepicker<
|
|
|
75
82
|
|
|
76
83
|
protected getPlaceholder() {
|
|
77
84
|
const {placeholder, type, range} = this.get();
|
|
78
|
-
|
|
79
85
|
if (!isNullOrUndefined(placeholder)) return placeholder;
|
|
80
86
|
|
|
81
87
|
switch (type) {
|
|
82
88
|
case 'datetime':
|
|
83
89
|
return range ? _$('开始时间 ~ 结束时间') : _$('请选择日期和时间');
|
|
84
90
|
case 'year':
|
|
85
|
-
return _$('请选择年份');
|
|
91
|
+
return range ? _$('开始年份 ~ 结束年份') : _$('请选择年份');
|
|
86
92
|
case 'month':
|
|
87
|
-
return _$('请选择月份');
|
|
93
|
+
return range ? _$('开始月份 ~ 结束月份') : _$('请选择月份');
|
|
94
|
+
case 'week':
|
|
95
|
+
return range ? _$('开始周 ~ 结束周') : _$('请选择周');
|
|
96
|
+
case 'quarter':
|
|
97
|
+
return range ? _$('开始季度 ~ 结束季度') : _$('请选择季度');
|
|
88
98
|
default:
|
|
89
99
|
return range ? _$('开始日期 ~ 结束日期') : _$('请选择日期');
|
|
90
100
|
}
|
|
@@ -94,15 +104,6 @@ export class Datepicker<
|
|
|
94
104
|
return this.value.format();
|
|
95
105
|
}
|
|
96
106
|
|
|
97
|
-
@bind
|
|
98
|
-
protected clear(e: MouseEvent) {
|
|
99
|
-
super.clear(e);
|
|
100
|
-
if (this.get('type') === 'datetime') {
|
|
101
|
-
// reset the state to let user re-select
|
|
102
|
-
this.panel.reset();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
107
|
@bind
|
|
107
108
|
private setByShortcut(shortcut: Shortcut) {
|
|
108
109
|
const {setValue, convertToDayjs} = this.value;
|
|
@@ -5,75 +5,80 @@ import {DatepickerTime} from './time';
|
|
|
5
5
|
import {Icon} from '../icon';
|
|
6
6
|
import {Button} from '../button';
|
|
7
7
|
import {_$} from '../../i18n';
|
|
8
|
-
import {makePanelStyles} from './styles';
|
|
9
|
-
import {
|
|
8
|
+
import {makeStyles, makePanelStyles, makeHighlightStyles} from './styles';
|
|
9
|
+
import {PanelFlags} from './usePanel';
|
|
10
10
|
import {isFunction} from 'intact-shared';
|
|
11
11
|
import {Tabs, Tab} from '../tabs';
|
|
12
|
+
import {Position} from './useHighlight';
|
|
12
13
|
|
|
13
|
-
const {
|
|
14
|
+
const { k } = this.config;
|
|
15
|
+
const {className, type, range, multiple, shortcuts, size} = this.get();
|
|
14
16
|
const {
|
|
15
17
|
value: {value},
|
|
16
18
|
onChangeDate,
|
|
17
|
-
onConfirm,
|
|
19
|
+
/* onConfirm, */
|
|
18
20
|
onChangeTime,
|
|
19
21
|
onChangeDateForRange,
|
|
20
22
|
getTimeValue,
|
|
21
23
|
} = this.value;
|
|
22
|
-
const {
|
|
24
|
+
const { onConfirm } = this.confirm;
|
|
25
|
+
const { position, handleInputClick, highlightWidth, highlightLeft } = this.highlight;
|
|
26
|
+
// 判断是否显示双面板
|
|
27
|
+
const showDualPanels = range && type !== 'datetime';
|
|
28
|
+
|
|
23
29
|
const classNameObj = {
|
|
24
30
|
[`${k}-datepicker-content`]: true,
|
|
25
31
|
[className]: className,
|
|
26
32
|
[makePanelStyles(k)]: true,
|
|
27
33
|
};
|
|
28
|
-
|
|
34
|
+
const classDatePickerObj = {
|
|
35
|
+
[`${k}-datepicker`]: true,
|
|
36
|
+
[makeHighlightStyles(k, size, highlightWidth.value, highlightLeft.value)]: range,
|
|
37
|
+
[makeStyles(k)]: true,
|
|
38
|
+
}
|
|
29
39
|
const {isDisabledTime, isDisabledConfirm} = this.disabled;
|
|
30
|
-
const {
|
|
40
|
+
const {startRef, endRef} = this.panel;
|
|
31
41
|
const generatePanel = (flag) => {
|
|
32
|
-
const panel = getPanel(flag);
|
|
33
|
-
const timeValue = getTimeValue(flag);
|
|
34
42
|
return (
|
|
35
|
-
<div class={`${k}-datepicker-calendar-wrapper`}>
|
|
36
|
-
{(() => {
|
|
37
|
-
if (type === 'datetime') {
|
|
38
|
-
let dateString = '0000-00-00';
|
|
39
|
-
let timeString = '00:00:00';
|
|
40
|
-
if (timeValue) {
|
|
41
|
-
const valueString = this.formats.getShowString(timeValue).split(/\s+/);
|
|
42
|
-
dateString = valueString[0];
|
|
43
|
-
timeString = valueString[1];
|
|
44
|
-
}
|
|
45
|
-
return (
|
|
46
|
-
<Tabs type="card"
|
|
47
|
-
value={panel.value}
|
|
48
|
-
ev-$change:value={panel.set}
|
|
49
|
-
>
|
|
50
|
-
<Tab value={PanelTypes.Date}>{dateString}</Tab>
|
|
51
|
-
<Tab value={PanelTypes.Time} disabled={!timeValue} >{timeString}</Tab>
|
|
52
|
-
</Tabs>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
})()}
|
|
43
|
+
<div class={`${k}-datepicker-calendar-time-wrapper`}>
|
|
56
44
|
<DatepickerCalendar
|
|
57
|
-
v-if={panel.value === PanelTypes.Date}
|
|
58
45
|
value={value}
|
|
59
46
|
ev-change={onChangeDate}
|
|
60
47
|
type={type === 'datetime' ? 'date' : type}
|
|
61
48
|
flag={flag}
|
|
62
49
|
ref={flag === PanelFlags.Start ? startRef : endRef}
|
|
50
|
+
highlightPosition={position.value}
|
|
63
51
|
/>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
<div class={`${k}-datepicker-time-wrapper`} v-if={type === 'datetime'}>{
|
|
53
|
+
(() => {
|
|
54
|
+
let timeValue = getTimeValue(flag);
|
|
55
|
+
if (flag === PanelFlags.End && !timeValue) {
|
|
56
|
+
timeValue = getTimeValue(PanelFlags.Start);
|
|
57
|
+
}
|
|
58
|
+
let timeString = '00:00:00';
|
|
59
|
+
|
|
60
|
+
if (timeValue) {
|
|
61
|
+
const valueString = this.formats.getShowString(timeValue).split(/\s+/);
|
|
62
|
+
timeString = valueString[1];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <template>
|
|
66
|
+
<div class={`${k}-datepicker-time-time`}>{timeString}</div>
|
|
67
|
+
<DatepickerTime
|
|
68
|
+
value={timeValue}
|
|
69
|
+
ev-$change:value={v => onChangeTime(v, flag)}
|
|
70
|
+
format={this.formats.getValueFormat()}
|
|
71
|
+
flag={flag}
|
|
72
|
+
isDisabledTime={isDisabledTime}
|
|
73
|
+
/>
|
|
74
|
+
</template>
|
|
75
|
+
})()
|
|
76
|
+
}</div>
|
|
72
77
|
</div>
|
|
73
78
|
);
|
|
74
79
|
};
|
|
75
80
|
|
|
76
|
-
<t:super class={
|
|
81
|
+
<t:super class={classDatePickerObj} onClick={handleInputClick} alwaysShowOnClick={true}>
|
|
77
82
|
<b:base-menu>
|
|
78
83
|
<DropdownMenu class={classNameObj}>
|
|
79
84
|
<div class={`${k}-datepicker-shortcuts`} v-if={shortcuts && shortcuts.length}>
|
|
@@ -87,8 +92,8 @@ const generatePanel = (flag) => {
|
|
|
87
92
|
</div>
|
|
88
93
|
<div class={`${k}-datepicker-wrapper`}>
|
|
89
94
|
<div class={`${k}-datepicker-calendars`}>
|
|
90
|
-
{generatePanel(PanelFlags.Start)}
|
|
91
|
-
{
|
|
95
|
+
{generatePanel(!showDualPanels && position.value === Position.End ? PanelFlags.End : PanelFlags.Start)}
|
|
96
|
+
{showDualPanels ? generatePanel(PanelFlags.End) : null}
|
|
92
97
|
</div>
|
|
93
98
|
<div v-if={type === 'datetime'} class={`${k}-datepicker-footer`}>
|
|
94
99
|
<Button type="primary" size="small"
|
|
@@ -3,6 +3,7 @@ import {theme, setDefault} from '../../styles/theme';
|
|
|
3
3
|
import {deepDefaults, sizes, Sizes, getRight, getLeft, palette} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import { cache } from '../utils';
|
|
6
|
+
import { select } from '../select/styles';
|
|
6
7
|
|
|
7
8
|
const defaults = {
|
|
8
9
|
width: `300px`,
|
|
@@ -11,7 +12,9 @@ const defaults = {
|
|
|
11
12
|
|
|
12
13
|
item: {
|
|
13
14
|
gutter: `7px`,
|
|
15
|
+
yearGutter: '36px',
|
|
14
16
|
height: `24px`,
|
|
17
|
+
rangeGutter: `17px`,
|
|
15
18
|
get hoverBgColor() { return theme.color.bg },
|
|
16
19
|
get exceedColor() { return theme.color.disabled },
|
|
17
20
|
get todayBorder() { return `1px solid ${theme.color.border}` },
|
|
@@ -49,6 +52,19 @@ const defaults = {
|
|
|
49
52
|
padding: `8px 16px`,
|
|
50
53
|
},
|
|
51
54
|
|
|
55
|
+
week: {
|
|
56
|
+
height: `20px`,
|
|
57
|
+
width: `40px`,
|
|
58
|
+
margin: `0 0 0 10px`,
|
|
59
|
+
padding: `0 2px`,
|
|
60
|
+
currentWeek: '#eee'
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
calendarTime: {
|
|
64
|
+
height: `44px`,
|
|
65
|
+
fontSize: `14px`,
|
|
66
|
+
},
|
|
67
|
+
|
|
52
68
|
shortcuts: {
|
|
53
69
|
width: '100px',
|
|
54
70
|
padding: '12px 0',
|
|
@@ -57,7 +73,7 @@ const defaults = {
|
|
|
57
73
|
height: '32px',
|
|
58
74
|
padding: '0 16px',
|
|
59
75
|
}
|
|
60
|
-
}
|
|
76
|
+
},
|
|
61
77
|
};
|
|
62
78
|
|
|
63
79
|
let datepicker: typeof defaults;
|
|
@@ -66,10 +82,21 @@ setDefault(() => {
|
|
|
66
82
|
makePanelStyles?.clearCache();
|
|
67
83
|
makeCalendarStyles?.clearCache();
|
|
68
84
|
makeTimeStyles?.clearCache();
|
|
85
|
+
makeHighlightStyles?.clearCache();
|
|
69
86
|
});
|
|
70
87
|
|
|
71
88
|
export {datepicker};
|
|
72
89
|
|
|
90
|
+
export const makeStyles = cache((k: string) => {
|
|
91
|
+
return css`
|
|
92
|
+
&.${k}-dropdown-open {
|
|
93
|
+
.${k}-input-inner {
|
|
94
|
+
color: ${theme.color.placeholder};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
});
|
|
99
|
+
|
|
73
100
|
export const makePanelStyles = cache(function makePanelStyles(k: string) {
|
|
74
101
|
return css`
|
|
75
102
|
display: flex;
|
|
@@ -103,12 +130,26 @@ export const makePanelStyles = cache(function makePanelStyles(k: string) {
|
|
|
103
130
|
width: 50%;
|
|
104
131
|
}
|
|
105
132
|
}
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
.${k}-datepicker-calendar-time-wrapper {
|
|
136
|
+
display: flex;
|
|
137
|
+
.${k}-datepicker-time-time {
|
|
138
|
+
height: ${datepicker.calendarTime.height};
|
|
139
|
+
line-height: ${datepicker.calendarTime.height};
|
|
140
|
+
text-align: center;
|
|
141
|
+
font-size: ${datepicker.calendarTime.fontSize};
|
|
142
|
+
}
|
|
143
|
+
.${k}-datepicker-time-wrapper {
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
height: 320px;
|
|
146
|
+
}
|
|
106
147
|
}
|
|
107
148
|
.${k}-datepicker-footer {
|
|
108
149
|
border-top: ${datepicker.border};
|
|
109
150
|
padding: ${datepicker.footer.padding};
|
|
110
151
|
text-align: right;
|
|
111
|
-
}
|
|
152
|
+
}
|
|
112
153
|
`
|
|
113
154
|
});
|
|
114
155
|
|
|
@@ -207,8 +248,56 @@ export const makeCalendarStyles = cache(function makeCalendarStyles(k: string) {
|
|
|
207
248
|
grid-template-columns: repeat(7, 1fr);
|
|
208
249
|
}
|
|
209
250
|
.${k}-years {
|
|
251
|
+
.${k}-calendar-item {
|
|
252
|
+
height: 20px;
|
|
253
|
+
width: 40px;
|
|
254
|
+
|
|
255
|
+
&.${k}-in-range:after {
|
|
256
|
+
width: calc(100% + 14px);
|
|
257
|
+
left: calc(-${datepicker.item.yearGutter} / 2);
|
|
258
|
+
padding: 0 calc(${datepicker.item.yearGutter} / 2);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
display: grid;
|
|
262
|
+
justify-items: center;
|
|
263
|
+
grid-template-columns: repeat(3, 1fr);
|
|
264
|
+
gap: 0;
|
|
265
|
+
}
|
|
266
|
+
.${k}-weeks {
|
|
210
267
|
display: grid;
|
|
211
|
-
|
|
268
|
+
.week-row {
|
|
269
|
+
display: flex;
|
|
270
|
+
align-items: center;
|
|
271
|
+
width: ${datepicker.week.width};
|
|
272
|
+
margin: ${datepicker.week.margin};
|
|
273
|
+
|
|
274
|
+
.${k}-week-number {
|
|
275
|
+
padding: ${datepicker.week.padding};
|
|
276
|
+
cursor: pointer;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
.${k}-calendar-item {
|
|
280
|
+
height: ${datepicker.week.height};
|
|
281
|
+
&.${k}-today:not(:last-child) .${k}-value {
|
|
282
|
+
background: ${datepicker.week.currentWeek};
|
|
283
|
+
border: 0;
|
|
284
|
+
&:after {
|
|
285
|
+
content: '';
|
|
286
|
+
display: block;
|
|
287
|
+
position: absolute;
|
|
288
|
+
box-sizing: content-box;
|
|
289
|
+
background: ${datepicker.week.currentWeek};
|
|
290
|
+
width: 100%;
|
|
291
|
+
height: 100%;
|
|
292
|
+
left: 0;
|
|
293
|
+
padding: 0 ${datepicker.item.rangeGutter};
|
|
294
|
+
z-index: -1;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
&.${k}-today:last-child .${k}-value {
|
|
298
|
+
border: 0;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
212
301
|
}
|
|
213
302
|
`
|
|
214
303
|
});
|
|
@@ -221,7 +310,26 @@ export const makeTimeStyles = cache(function makeTimeStyles(k: string) {
|
|
|
221
310
|
position: relative;
|
|
222
311
|
.${k}-scroll-select {
|
|
223
312
|
flex: 1;
|
|
224
|
-
height:
|
|
313
|
+
height: 265px;
|
|
225
314
|
}
|
|
226
315
|
`;
|
|
227
316
|
});
|
|
317
|
+
|
|
318
|
+
export const makeHighlightStyles = cache(function makeHighlightStyles(k: string, size: Sizes, highlightWidth: number, highlightLeft: number) {
|
|
319
|
+
const paddingLeft = getLeft(select[size].padding);
|
|
320
|
+
return css`
|
|
321
|
+
&.${k}-dropdown-open {
|
|
322
|
+
&:before {
|
|
323
|
+
content: '';
|
|
324
|
+
display: block;
|
|
325
|
+
width: ${highlightWidth ? highlightWidth + 'px' : '50%'};
|
|
326
|
+
height: 1px;
|
|
327
|
+
position: absolute;
|
|
328
|
+
background-color: ${datepicker.item.active.bgColor};
|
|
329
|
+
left: calc(${paddingLeft} + ${highlightLeft}px);
|
|
330
|
+
bottom: 0;
|
|
331
|
+
transition: left ${theme.transition.middle};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
`;
|
|
335
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {useInstance, Component, TypeDefs} from 'intact';
|
|
2
|
+
import {useState, watchState, State} from '../../hooks/useState';
|
|
3
|
+
import dayjs, {Dayjs, OpUnitType, QUnitType} from './dayjs';
|
|
4
|
+
import {findValueIndex} from './helpers';
|
|
5
|
+
import type {useFormats} from './useFormats';
|
|
6
|
+
import type {useDisabled} from './useDisabled';
|
|
7
|
+
import {isEqualArray, last, bind} from '../utils';
|
|
8
|
+
import {PanelFlags, usePanel} from './usePanel';
|
|
9
|
+
import type {BasePicker, BasePickerProps} from './basepicker';
|
|
10
|
+
import type { Datepicker } from '.';
|
|
11
|
+
import { Position, useHighlight } from './useHighlight';
|
|
12
|
+
import { useValue } from './useValue';
|
|
13
|
+
import { StateValueRange, StateValue, DayjsValueRange } from './useValueBase';
|
|
14
|
+
|
|
15
|
+
export function useConfirm(
|
|
16
|
+
highlight: ReturnType<typeof useHighlight>,
|
|
17
|
+
value: ReturnType<typeof useValue>,
|
|
18
|
+
getValueString: ReturnType<typeof useFormats>['getValueString'],
|
|
19
|
+
) {
|
|
20
|
+
const instance = useInstance() as Datepicker;
|
|
21
|
+
let selectionState = [false, false];
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* can not use hide event to do it
|
|
25
|
+
* because value will be reset to dayjsValue on hide in useValue
|
|
26
|
+
*/
|
|
27
|
+
instance.on('$change:show', (show) => {
|
|
28
|
+
if (!show) {
|
|
29
|
+
reset();
|
|
30
|
+
if (instance.get('range') && hasWholeRangeValue()) {
|
|
31
|
+
// to fix the order
|
|
32
|
+
value.updateValue();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
instance.on('selecting', () => {
|
|
38
|
+
const { type } = instance.get();
|
|
39
|
+
if (type !== 'datetime') {
|
|
40
|
+
onConfirm();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function reset() {
|
|
45
|
+
selectionState = [false, false];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function onConfirm() {
|
|
49
|
+
const { multiple, range } = instance.get();
|
|
50
|
+
if (range) {
|
|
51
|
+
const position = highlight.position.value;
|
|
52
|
+
selectionState[position] = true;
|
|
53
|
+
|
|
54
|
+
if (selectionState.every(state => state)) {
|
|
55
|
+
if (!multiple) {
|
|
56
|
+
instance.hide();
|
|
57
|
+
} else {
|
|
58
|
+
// update value directly on multiple mode
|
|
59
|
+
reset();
|
|
60
|
+
value.unique();
|
|
61
|
+
value.updateValue();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
highlight.togglePosition();
|
|
66
|
+
} else {
|
|
67
|
+
if (!multiple) {
|
|
68
|
+
instance.hide();
|
|
69
|
+
} else {
|
|
70
|
+
value.unique();
|
|
71
|
+
}
|
|
72
|
+
value.updateValue();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function hasWholeRangeValue() {
|
|
77
|
+
const lastValue = last(value.value.value) as StateValueRange;
|
|
78
|
+
return lastValue && lastValue.length === 2;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { onConfirm }
|
|
82
|
+
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import {useInstance} from 'intact';
|
|
2
2
|
import {useState, State} from '../../hooks/useState';
|
|
3
|
-
import {Dayjs, OpUnitType} from 'dayjs';
|
|
3
|
+
import {Dayjs, OpUnitType, QUnitType} from './dayjs';
|
|
4
4
|
import type {Datepicker} from './index';
|
|
5
5
|
import {isNullOrUndefined} from 'intact-shared';
|
|
6
6
|
import {isGT, isLT, last} from './helpers';
|
|
7
7
|
import type {useFormats} from './useFormats';
|
|
8
|
-
import {PanelFlags
|
|
9
|
-
import {Value} from './
|
|
8
|
+
import {PanelFlags} from './usePanel';
|
|
9
|
+
import {Value, StateValueRange, StateValueItem} from './useValueBase';
|
|
10
|
+
import { Position } from './useHighlight';
|
|
10
11
|
|
|
11
|
-
export function useDisabled(
|
|
12
|
+
export function useDisabled(
|
|
13
|
+
{createDateByValueFormat}: ReturnType<typeof useFormats>,
|
|
14
|
+
getHighlightPosition?: () => State<Position>
|
|
15
|
+
) {
|
|
12
16
|
const instance = useInstance() as Datepicker;
|
|
13
17
|
const maxDate = useState<Dayjs | null>(null);
|
|
14
18
|
const minDate = useState<Dayjs | null>(null);
|
|
@@ -28,57 +32,51 @@ export function useDisabled({createDateByValueFormat}: ReturnType<typeof useForm
|
|
|
28
32
|
convertToDayjs(minDate, v);
|
|
29
33
|
});
|
|
30
34
|
|
|
31
|
-
function isDisabled(value: Dayjs, type: OpUnitType = 'date') {
|
|
35
|
+
function isDisabled(value: Dayjs, type: OpUnitType | QUnitType = 'date') {
|
|
32
36
|
const {disabledDate} = instance.get();
|
|
33
37
|
return isGT(value, maxDate.value, type) ||
|
|
34
38
|
isLT(value, minDate.value, type) ||
|
|
35
39
|
!!disabledDate && disabledDate(value);
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
function isDisabledTime(value: Dayjs
|
|
39
|
-
|
|
40
|
-
if (!instance.get('range')) return false;
|
|
41
|
-
|
|
42
|
-
// compare the start and the end datetime
|
|
43
|
-
const anotherDatetime = instance.value.getTimeValue(
|
|
44
|
-
flag === PanelFlags.Start ? PanelFlags.End : PanelFlags.Start
|
|
45
|
-
);
|
|
46
|
-
if (!anotherDatetime) return false;
|
|
47
|
-
if (flag === PanelFlags.Start) {
|
|
48
|
-
return value.isAfter(anotherDatetime, 'second');
|
|
49
|
-
} else {
|
|
50
|
-
return value.isBefore(anotherDatetime, 'second');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
42
|
+
function isDisabledTime(value: Dayjs): boolean {
|
|
43
|
+
return isDisabled(value, 'second');
|
|
54
44
|
}
|
|
55
45
|
|
|
56
46
|
function isDisabledConfirm(): boolean {
|
|
57
47
|
const lastValue = last(instance.value.value.value);
|
|
58
|
-
|
|
48
|
+
const {range, multiple} = instance.get();
|
|
49
|
+
if (!lastValue || instance.value.allValuesUpdatedInMultipleMode()) return true;
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
if (range && getHighlightPosition) {
|
|
52
|
+
const position = getHighlightPosition();
|
|
53
|
+
// if the position is not selected, it should be disabled
|
|
54
|
+
if (!(lastValue as StateValueRange)[position.value]) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
66
57
|
}
|
|
67
58
|
|
|
59
|
+
return isDisabledValue(lastValue);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isDisabledValue(value: StateValueItem): boolean {
|
|
63
|
+
const { range } = instance.get();
|
|
68
64
|
let start: Dayjs;
|
|
69
65
|
let end: Dayjs | undefined;
|
|
66
|
+
|
|
70
67
|
if (range) {
|
|
71
|
-
start = (
|
|
72
|
-
end = (
|
|
68
|
+
start = (value as [Dayjs, Dayjs])[0];
|
|
69
|
+
end = (value as [Dayjs, Dayjs])[1];
|
|
73
70
|
} else {
|
|
74
|
-
start =
|
|
71
|
+
start = value as Dayjs;
|
|
75
72
|
}
|
|
76
|
-
|
|
73
|
+
|
|
74
|
+
if (isDisabledTime(start) || end && isDisabledTime(end)) {
|
|
77
75
|
return true;
|
|
78
76
|
}
|
|
79
77
|
|
|
80
78
|
return false;
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
return {isDisabled, isDisabledTime, isDisabledConfirm, maxDate, minDate};
|
|
81
|
+
return {isDisabled, isDisabledTime, isDisabledConfirm, isDisabledValue, maxDate, minDate};
|
|
84
82
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {useInstance} from 'intact';
|
|
2
|
-
import dayjs, {Dayjs} from '
|
|
2
|
+
import dayjs, {Dayjs} from 'dayjs';
|
|
3
3
|
import {isString} from 'intact-shared';
|
|
4
4
|
import type {Datepicker} from './index';
|
|
5
|
-
import {Value} from './
|
|
5
|
+
import type {Value} from './useValueBase';
|
|
6
6
|
|
|
7
7
|
const FORMATS = {
|
|
8
8
|
date: 'YYYY-MM-DD',
|
|
9
9
|
datetime: 'YYYY-MM-DD HH:mm:ss',
|
|
10
10
|
year: 'YYYY',
|
|
11
11
|
month: 'YYYY-MM',
|
|
12
|
+
quarter: 'YYYY-[Q]Q',
|
|
13
|
+
week: 'YYYY-w[周]',
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export function useFormats() {
|
|
@@ -23,9 +25,13 @@ export function useFormats() {
|
|
|
23
25
|
const {format, showFormat, type} = instance.get();
|
|
24
26
|
return showFormat || format || FORMATS[type!];
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 根据日期字符串,按照格式创建日期对象
|
|
31
|
+
*/
|
|
27
32
|
function createDateByValueFormat(value: Value) {
|
|
28
|
-
|
|
33
|
+
const format = isString(value) ? getValueFormat() : undefined;
|
|
34
|
+
return dayjs(value, format);
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
function createDateByShowFormat(value: string) {
|