@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
|
@@ -10,14 +10,18 @@ import {useValue} from './useValue';
|
|
|
10
10
|
import {useDisabled} from './useDisabled';
|
|
11
11
|
import {usePanel} from '../datepicker/usePanel';
|
|
12
12
|
import {State} from '../../hooks/useState';
|
|
13
|
-
import {PanelTypes} from '../datepicker/usePanel';
|
|
14
13
|
import {useStep} from './useStep';
|
|
15
14
|
import {
|
|
16
15
|
TimepickerProps,
|
|
17
16
|
TimepickerEvents,
|
|
18
17
|
TimepickerBlocks,
|
|
19
18
|
typeDefs,
|
|
19
|
+
NOW_START,
|
|
20
|
+
NOW_END,
|
|
20
21
|
} from './constants';
|
|
22
|
+
import { useConfirm } from './useConfirm';
|
|
23
|
+
import { StateValueItem } from '../datepicker/useValueBase';
|
|
24
|
+
import { useDefaultValue } from './useDefaultValue';
|
|
21
25
|
|
|
22
26
|
export class PanelPicker<
|
|
23
27
|
Multipe extends boolean = false,
|
|
@@ -31,10 +35,12 @@ export class PanelPicker<
|
|
|
31
35
|
static typeDefs = typeDefs;
|
|
32
36
|
|
|
33
37
|
public formats = useFormats();
|
|
34
|
-
public
|
|
35
|
-
public
|
|
36
|
-
public
|
|
38
|
+
public defaultValue = useDefaultValue();
|
|
39
|
+
public disabled = useDisabled(this.formats, this.defaultValue);
|
|
40
|
+
public panel = usePanel();
|
|
41
|
+
public value = useValue(this.formats, this.disabled, this.panel, this.defaultValue);
|
|
37
42
|
public step = useStep(this.disabled, this.formats);
|
|
43
|
+
public confirm = useConfirm(this.value, this.formats.getValueString, this.defaultValue);
|
|
38
44
|
|
|
39
45
|
protected getPlaceholder() {
|
|
40
46
|
const {placeholder, range} = this.get();
|
|
@@ -7,11 +7,11 @@ import {Button} from '../button';
|
|
|
7
7
|
import {PanelFlags} from '../datepicker/usePanel';
|
|
8
8
|
import {last} from '../datepicker/helpers';
|
|
9
9
|
import {ScrollSelect} from '../scrollSelect';
|
|
10
|
+
import { makeStyles as makeStylesInheritDatepicker } from '../datepicker/styles';
|
|
10
11
|
|
|
11
12
|
const {className, range, multiple, min, max} = this.get();
|
|
12
13
|
const {
|
|
13
14
|
value: {value},
|
|
14
|
-
onConfirm,
|
|
15
15
|
onChangeTime,
|
|
16
16
|
onChangeTimeByStep,
|
|
17
17
|
getTimeValue,
|
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
} = this.value;
|
|
20
20
|
const lastValue = last(value);
|
|
21
21
|
const { k } = this.config;
|
|
22
|
+
const { onConfirm } = this.confirm;
|
|
22
23
|
|
|
23
24
|
const classNameObj = {
|
|
24
25
|
[`${k}-time-content`]: true,
|
|
@@ -57,7 +58,7 @@ const generatePanel = flag => {
|
|
|
57
58
|
);
|
|
58
59
|
};
|
|
59
60
|
|
|
60
|
-
<t:super class={`${k}-timepicker`}>
|
|
61
|
+
<t:super class={`${k}-timepicker ${makeStylesInheritDatepicker(k)}`}>
|
|
61
62
|
<b:base-menu>
|
|
62
63
|
<DropdownMenu class={classNameObj}>
|
|
63
64
|
<div class={`${k}-datepicker-wrapper`}>
|
|
@@ -66,9 +67,6 @@ const generatePanel = flag => {
|
|
|
66
67
|
{range ? generatePanel(PanelFlags.End) : null}
|
|
67
68
|
</div>
|
|
68
69
|
<div class={`${k}-datepicker-footer`}>
|
|
69
|
-
<Button v-if={!range && !multiple && !max && !min} type="link" size="small"
|
|
70
|
-
ev-click={setMoment}
|
|
71
|
-
>{_$('此刻')}</Button>
|
|
72
70
|
<Button type="primary" size="small"
|
|
73
71
|
disabled={isDisabledConfirm()}
|
|
74
72
|
ev-click={onConfirm}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {useInstance, Component, TypeDefs} from 'intact';
|
|
2
|
+
import {useState, watchState, State} from '../../hooks/useState';
|
|
3
|
+
import type {useFormats} from './useFormats';
|
|
4
|
+
import type {useDisabled} from './useDisabled';
|
|
5
|
+
import {isEqualArray, last, bind} from '../utils';
|
|
6
|
+
import type { PanelPicker } from './panelPicker';
|
|
7
|
+
import { useValue } from './useValue';
|
|
8
|
+
import { StateValueRange, StateValue, DayjsValueRange, StateValueItem } from '../datepicker/useValueBase';
|
|
9
|
+
import type { useDefaultValue } from './useDefaultValue';
|
|
10
|
+
|
|
11
|
+
export function useConfirm(
|
|
12
|
+
value: ReturnType<typeof useValue>,
|
|
13
|
+
getValueString: ReturnType<typeof useFormats>['getValueString'],
|
|
14
|
+
defaultValue: ReturnType<typeof useDefaultValue>,
|
|
15
|
+
) {
|
|
16
|
+
const instance = useInstance() as PanelPicker;
|
|
17
|
+
|
|
18
|
+
function onConfirm() {
|
|
19
|
+
const { multiple } = instance.get();
|
|
20
|
+
// if we click confirm button directly, set the value to placeholder values
|
|
21
|
+
value.setValue(defaultValue.get(), false);
|
|
22
|
+
|
|
23
|
+
if (!multiple) {
|
|
24
|
+
instance.hide();
|
|
25
|
+
} else {
|
|
26
|
+
value.unique();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
value.updateValue();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { onConfirm }
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
2
|
+
import { StateValueItem } from '../datepicker/useValueBase';
|
|
3
|
+
import type { PanelPicker } from './panelPicker';
|
|
4
|
+
import { last } from '../datepicker/helpers';
|
|
5
|
+
import {NOW_START, NOW_END} from './constants';
|
|
6
|
+
import { isArray } from 'intact-shared';
|
|
7
|
+
|
|
8
|
+
export function useDefaultValue() {
|
|
9
|
+
const instance = useInstance() as PanelPicker;
|
|
10
|
+
|
|
11
|
+
function get(): StateValueItem {
|
|
12
|
+
const _value = instance.value.value.value;
|
|
13
|
+
const lastValue = last(_value);
|
|
14
|
+
const { range } = instance.get();
|
|
15
|
+
|
|
16
|
+
if (range) {
|
|
17
|
+
// consider the second last value to maintain consistency
|
|
18
|
+
const penulimate = getPenulimate(_value);
|
|
19
|
+
return Object.assign([NOW_START, NOW_END], penulimate, lastValue);
|
|
20
|
+
}
|
|
21
|
+
return lastValue || NOW_START;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return { get };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getPenulimate(value: unknown[]) {
|
|
28
|
+
if (!isArray(value)) return;
|
|
29
|
+
return value[value.length - 2];
|
|
30
|
+
}
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
1
2
|
import {useDisabled as useDisabledBase} from '../datepicker/useDisabled';
|
|
2
3
|
import type {useFormats} from './useFormats';
|
|
3
4
|
import {PanelFlags} from '../datepicker/usePanel';
|
|
5
|
+
import {isGT, isLT, last} from '../datepicker/helpers';
|
|
6
|
+
import type { PanelPicker } from './panelPicker';
|
|
7
|
+
import { StateValueItem } from '../datepicker/useValueBase';
|
|
8
|
+
import type { useDefaultValue } from './useDefaultValue';
|
|
4
9
|
|
|
5
|
-
export function useDisabled(
|
|
6
|
-
|
|
10
|
+
export function useDisabled(
|
|
11
|
+
formats: ReturnType<typeof useFormats>,
|
|
12
|
+
defaultValue: ReturnType<typeof useDefaultValue>,
|
|
13
|
+
) {
|
|
14
|
+
const instance = useInstance() as PanelPicker;
|
|
15
|
+
const {isDisabledTime, isDisabledConfirm: isDisabledConfirmBase, isDisabledValue, ...rest} = useDisabledBase(formats);
|
|
7
16
|
|
|
8
17
|
function isDisabledTimeByStep(value: string, flag: PanelFlags) {
|
|
9
|
-
return isDisabledTime(formats.createDateByValueFormat(value)
|
|
18
|
+
return isDisabledTime(formats.createDateByValueFormat(value));
|
|
10
19
|
}
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
function isDisabledConfirm(): boolean {
|
|
22
|
+
return isDisabledValue(defaultValue.get());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {isDisabledTime, isDisabledTimeByStep, isDisabledConfirm, isDisabledValue, ...rest};
|
|
13
26
|
}
|
|
@@ -2,7 +2,7 @@ import {useInstance, Component} from 'intact';
|
|
|
2
2
|
import dayjs, {Dayjs} from '../datepicker/dayjs';
|
|
3
3
|
import {isString} from 'intact-shared';
|
|
4
4
|
import type {TimepickerProps} from './';
|
|
5
|
-
import type {Value} from '../datepicker/
|
|
5
|
+
import type {Value} from '../datepicker/useValueBase';
|
|
6
6
|
import {YEAR_FORMAT, TIME_FORMAT, PREFIX} from './constants'
|
|
7
7
|
|
|
8
8
|
export function useFormats<T extends Component<TimepickerProps>>() {
|
|
@@ -2,23 +2,29 @@ import {useInstance} from 'intact';
|
|
|
2
2
|
import type {PanelPicker} from './panelPicker';
|
|
3
3
|
import type {useFormats} from './useFormats';
|
|
4
4
|
import {last} from '../utils';
|
|
5
|
-
import {
|
|
6
|
-
useValue as useValueBase,
|
|
7
|
-
StateValueItem,
|
|
8
|
-
DayjsValueItem
|
|
9
|
-
} from '../datepicker/basepicker';
|
|
5
|
+
import {useValueBase, StateValueItem, DayjsValueItem, DayjsValue, StateValueRange} from '../datepicker/useValueBase';
|
|
10
6
|
import type {useDisabled} from '../datepicker/useDisabled';
|
|
11
7
|
import type {usePanel} from '../datepicker/usePanel';
|
|
12
8
|
import {NOW_START, NOW_END} from './constants';
|
|
13
9
|
import {PanelFlags} from '../datepicker/usePanel';
|
|
10
|
+
import type Dayjs from 'dayjs';
|
|
11
|
+
import type { useDefaultValue } from './useDefaultValue';
|
|
14
12
|
|
|
15
13
|
export function useValue(
|
|
16
14
|
formats: ReturnType<typeof useFormats>,
|
|
17
15
|
disabled: ReturnType<typeof useDisabled>,
|
|
18
16
|
panel: ReturnType<typeof usePanel>,
|
|
17
|
+
defaultValue: ReturnType<typeof useDefaultValue>,
|
|
19
18
|
) {
|
|
20
19
|
const instance = useInstance() as PanelPicker;
|
|
21
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
value,
|
|
22
|
+
getDayjsValue,
|
|
23
|
+
setValue,
|
|
24
|
+
onChangeTime,
|
|
25
|
+
getTimeValue: getTimeValueBase,
|
|
26
|
+
...rest
|
|
27
|
+
} = useValueBase(
|
|
22
28
|
formats,
|
|
23
29
|
disabled,
|
|
24
30
|
panel,
|
|
@@ -28,7 +34,7 @@ export function useValue(
|
|
|
28
34
|
function(v: DayjsValueItem) {
|
|
29
35
|
// pop the last value when input
|
|
30
36
|
// because it is a placeholder date
|
|
31
|
-
value.value.pop();
|
|
37
|
+
// value.value.pop(); // no placeholder any more
|
|
32
38
|
setValue(v, true);
|
|
33
39
|
},
|
|
34
40
|
function() {
|
|
@@ -39,21 +45,18 @@ export function useValue(
|
|
|
39
45
|
}
|
|
40
46
|
);
|
|
41
47
|
|
|
42
|
-
setValue(getPlaceholderDates(), false);
|
|
43
|
-
|
|
44
|
-
instance.watch('value', value => {
|
|
45
|
-
const dayjsValue = getDayjsValue();
|
|
46
|
-
setValue(last(dayjsValue) || getPlaceholderDates(), false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
function getPlaceholderDates(): StateValueItem {
|
|
50
|
-
return instance.get('range') ? [NOW_START, NOW_END] : NOW_START;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
function onChangeTimeByStep(v: string, flag: PanelFlags) {
|
|
54
49
|
const date = formats.createDateByValueFormat(v);
|
|
55
50
|
onChangeTime(date, flag);
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
function getTimeValue(flag: PanelFlags): Dayjs.Dayjs | null | undefined {
|
|
54
|
+
const value = defaultValue.get();
|
|
55
|
+
if (instance.get('range')) {
|
|
56
|
+
return (value as StateValueRange)[flag];
|
|
57
|
+
}
|
|
58
|
+
return value as Dayjs.Dayjs;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {value, setValue, getDayjsValue, onChangeTime, onChangeTimeByStep, getTimeValue, ...rest};
|
|
59
62
|
}
|
|
Binary file
|
|
@@ -196,7 +196,7 @@ describe('Tour', () => {
|
|
|
196
196
|
const [instance, element] = mount(CustomTextDemo);
|
|
197
197
|
|
|
198
198
|
const buttons = element.querySelectorAll('.k-btn');
|
|
199
|
-
const startBtn = Array.from(buttons).find(btn => btn.textContent?.includes('
|
|
199
|
+
const startBtn = Array.from(buttons).find(btn => btn.textContent?.includes('开始自定义按钮引导')) as HTMLElement;
|
|
200
200
|
startBtn.click();
|
|
201
201
|
await wait(50);
|
|
202
202
|
|
|
Binary file
|
|
Binary file
|
|
@@ -160,7 +160,7 @@ describe('Cascader', function () {
|
|
|
160
160
|
}, _callee5);
|
|
161
161
|
})));
|
|
162
162
|
it('filter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
163
|
-
var _mount5, instance, element, input,
|
|
163
|
+
var _mount5, instance, element, input, dropdown1, _getElements2, _dropdown1, _dropdown2, _dropdown3;
|
|
164
164
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
165
165
|
while (1) switch (_context6.prev = _context6.next) {
|
|
166
166
|
case 0:
|
|
@@ -170,53 +170,52 @@ describe('Cascader', function () {
|
|
|
170
170
|
_context6.next = 5;
|
|
171
171
|
return wait();
|
|
172
172
|
case 5:
|
|
173
|
+
// FIXME: maybe we should show no-data layer
|
|
173
174
|
// should show layer when input empty string
|
|
174
|
-
input.value = ' ';
|
|
175
|
+
// input.value = ' ';
|
|
176
|
+
// dispatchEvent(input, 'input');
|
|
177
|
+
// await wait();
|
|
178
|
+
// const dropdown = getElement('.k-cascader-menu')!;
|
|
179
|
+
// expect(dropdown.innerHTML).to.matchSnapshot();
|
|
180
|
+
// expect(dropdown.innerText).to.eql('北京\n湖南');
|
|
181
|
+
input.value = '长沙';
|
|
175
182
|
dispatchEvent(input, 'input');
|
|
176
183
|
_context6.next = 9;
|
|
177
184
|
return wait();
|
|
178
185
|
case 9:
|
|
179
|
-
dropdown = getElement('.k-cascader-menu');
|
|
180
|
-
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
181
|
-
expect(dropdown.innerText).to.eql('北京\n湖南');
|
|
182
|
-
input.value = '长沙';
|
|
183
|
-
dispatchEvent(input, 'input');
|
|
184
|
-
_context6.next = 16;
|
|
185
|
-
return wait();
|
|
186
|
-
case 16:
|
|
187
186
|
dropdown1 = getElement('.k-cascader-filter');
|
|
188
187
|
expect(dropdown1.innerHTML).to.matchSnapshot();
|
|
189
188
|
expect(dropdown1.innerText).to.eql('湖南 / 长沙市 / 岳麓区');
|
|
190
189
|
// should show no-data layer
|
|
191
190
|
input.value = 'xxx';
|
|
192
191
|
dispatchEvent(input, 'input');
|
|
193
|
-
_context6.next =
|
|
192
|
+
_context6.next = 16;
|
|
194
193
|
return wait();
|
|
195
|
-
case
|
|
194
|
+
case 16:
|
|
196
195
|
expect(dropdown1.innerHTML).to.matchSnapshot();
|
|
197
196
|
expect(dropdown1.innerText).to.eql('无匹配数据');
|
|
198
197
|
input.value = '岳阳';
|
|
199
198
|
dispatchEvent(input, 'input');
|
|
200
|
-
_context6.next =
|
|
199
|
+
_context6.next = 22;
|
|
201
200
|
return wait();
|
|
202
|
-
case
|
|
201
|
+
case 22:
|
|
203
202
|
expect(dropdown1.innerHTML).to.matchSnapshot();
|
|
204
203
|
expect(dropdown1.childElementCount).to.eql(2);
|
|
205
204
|
dropdown1.querySelector('.k-dropdown-item').click();
|
|
206
|
-
_context6.next =
|
|
205
|
+
_context6.next = 27;
|
|
207
206
|
return wait();
|
|
208
|
-
case
|
|
207
|
+
case 27:
|
|
209
208
|
expect(instance.get('value')).to.eql(['hunan', 'yueyang', 'yueyanglou']);
|
|
210
209
|
// show again to test the position
|
|
211
210
|
input.click();
|
|
212
|
-
_context6.next =
|
|
211
|
+
_context6.next = 31;
|
|
213
212
|
return wait();
|
|
214
|
-
case
|
|
213
|
+
case 31:
|
|
215
214
|
_getElements2 = getElements('.k-cascader-menu'), _dropdown1 = _getElements2[0], _dropdown2 = _getElements2[1], _dropdown3 = _getElements2[2];
|
|
216
215
|
expect(_dropdown1.style.top).not.eql('0px');
|
|
217
216
|
expect(_dropdown2.style.top).not.eql('0px');
|
|
218
217
|
expect(_dropdown3.style.top).not.eql('0px');
|
|
219
|
-
case
|
|
218
|
+
case 35:
|
|
220
219
|
case "end":
|
|
221
220
|
return _context6.stop();
|
|
222
221
|
}
|
|
@@ -2,20 +2,12 @@
|
|
|
2
2
|
* The base hook for handling value of Datepicker and Timepicker
|
|
3
3
|
*/
|
|
4
4
|
import { TypeDefs } from 'intact';
|
|
5
|
-
import {
|
|
6
|
-
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
5
|
+
import { Dayjs } from './dayjs';
|
|
7
6
|
import type { useFormats } from './useFormats';
|
|
8
|
-
import
|
|
9
|
-
import { PanelFlags, usePanel } from './usePanel';
|
|
7
|
+
import { usePanel } from './usePanel';
|
|
10
8
|
import { BaseSelect, BaseSelectProps, BaseSelectEvents, BaseSelectBlocks } from '../select/base';
|
|
11
9
|
import type { Events } from '../types';
|
|
12
|
-
|
|
13
|
-
export type StateValueItem = Dayjs | StateValueRange;
|
|
14
|
-
export type StateValue = StateValueItem[];
|
|
15
|
-
export type StringValue = string | string[] | [string, string] | [string, string][];
|
|
16
|
-
export type DayjsValueRange = [Dayjs, Dayjs];
|
|
17
|
-
export type DayjsValueItem = Dayjs | DayjsValueRange;
|
|
18
|
-
export type DayjsValue = DayjsValueItem[];
|
|
10
|
+
import type { useValueBase, StateValueRange, Value } from './useValueBase';
|
|
19
11
|
export interface BasePickerProps<V extends Value = Value, Multipe extends boolean = boolean, Range extends boolean = boolean> extends BaseSelectProps<V | [V, V], Multipe> {
|
|
20
12
|
value?: Multipe extends true ? Range extends true ? [
|
|
21
13
|
V,
|
|
@@ -33,29 +25,16 @@ export interface BasePickerProps<V extends Value = Value, Multipe extends boolea
|
|
|
33
25
|
disabledDate?: (v: Dayjs) => boolean;
|
|
34
26
|
}
|
|
35
27
|
export interface BasePickerEvents extends BaseSelectEvents {
|
|
36
|
-
selecting: [StateValueRange];
|
|
37
|
-
togglePosition: [];
|
|
28
|
+
selecting: [StateValueRange, boolean];
|
|
38
29
|
}
|
|
39
30
|
export interface BasePickerBlocks<V extends Value = Value, R extends boolean = boolean> extends BaseSelectBlocks<R extends true ? [Value, Value] : Value> {
|
|
40
31
|
}
|
|
41
|
-
export type Value = string | Date | number | Dayjs;
|
|
42
32
|
export declare abstract class BasePicker<T extends BasePickerProps = BasePickerProps, E extends BasePickerEvents = BasePickerEvents, B extends BasePickerBlocks<any> = BasePickerBlocks<any>> extends BaseSelect<T, E, B> {
|
|
43
33
|
static typeDefs: Required<TypeDefs<BasePickerProps<Value, boolean, boolean>>>;
|
|
44
34
|
static defaults: () => Partial<BasePickerProps<any, boolean, boolean>>;
|
|
45
35
|
static events: Events<BasePickerEvents>;
|
|
46
|
-
abstract value: ReturnType<typeof
|
|
36
|
+
abstract value: ReturnType<typeof useValueBase>;
|
|
47
37
|
abstract formats: ReturnType<typeof useFormats>;
|
|
48
38
|
abstract panel: ReturnType<typeof usePanel>;
|
|
49
|
-
resetKeywords(
|
|
39
|
+
resetKeywords(silent?: boolean): void;
|
|
50
40
|
}
|
|
51
|
-
export declare function useValue({ createDateByValueFormat, createDateByShowFormat, getShowString, getValueString, }: ReturnType<typeof useFormats>, { isDisabled, minDate }: ReturnType<typeof useDisabled>, panel: ReturnType<typeof usePanel>, shouldUpdateValue: (v: StateValueItem) => boolean, updateValueOnInput: (v: DayjsValueItem) => void, getEqualType: () => OpUnitType | QUnitType, updateStateValue: (v: DayjsValue, value: State<StateValue>) => void): {
|
|
52
|
-
value: State<StateValue>;
|
|
53
|
-
format: () => string | string[];
|
|
54
|
-
onConfirm: () => void;
|
|
55
|
-
onChangeTime: (date: Dayjs, flag: PanelFlags) => void;
|
|
56
|
-
getTimeValue: (flag: PanelFlags) => Dayjs | null | undefined;
|
|
57
|
-
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
58
|
-
convertToDayjs: (v: BasePickerProps<Value>['value']) => DayjsValue;
|
|
59
|
-
getDayjsValue: () => DayjsValue;
|
|
60
|
-
setMoment: () => void;
|
|
61
|
-
};
|