@king-design/intact 3.5.1 → 3.6.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/breadcrumb/demos/separator.md +4 -4
- package/components/breadcrumb/index.vdt +1 -1
- package/components/breadcrumb/styles.ts +3 -2
- package/components/button/index.md +1 -0
- package/components/datepicker/basepicker.ts +60 -13
- package/components/datepicker/calendar.ts +5 -1
- package/components/datepicker/calendar.vdt +20 -6
- package/components/datepicker/dayjs.ts +22 -2
- package/components/datepicker/demos/multiple.md +0 -5
- package/components/datepicker/demos/nowrap.md +35 -0
- package/components/datepicker/demos/yearMonth.md +8 -2
- package/components/datepicker/helpers.ts +5 -5
- package/components/datepicker/index.md +3 -2
- package/components/datepicker/index.spec.ts +107 -90
- package/components/datepicker/index.ts +23 -5
- package/components/datepicker/index.vdt +34 -35
- package/components/datepicker/styles.ts +102 -3
- package/components/datepicker/useDisabled.ts +3 -3
- package/components/datepicker/useFormats.ts +2 -0
- package/components/datepicker/useMergeRange.ts +54 -0
- package/components/datepicker/usePosition.ts +169 -0
- package/components/datepicker/useQuarters.ts +47 -0
- package/components/datepicker/useShowDate.ts +42 -11
- package/components/datepicker/useValue.ts +35 -4
- package/components/datepicker/useWeeks.ts +58 -0
- package/components/dialog/useFixBody.ts +7 -64
- package/components/ellipsis/styles.ts +4 -0
- package/components/form/styles.ts +1 -0
- package/components/scrollSelect/index.spec.ts +3 -3
- package/components/scrollSelect/useMouseEvents.ts +23 -10
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +13 -0
- package/components/select/index.md +1 -0
- package/components/select/index.spec.ts +180 -0
- package/components/select/option.ts +9 -1
- package/components/select/select.ts +2 -0
- package/components/select/useFilterable.ts +1 -1
- package/components/select/useInput.ts +4 -2
- package/components/select/useSearchable.ts +2 -2
- package/components/table/table.vdt +3 -3
- package/components/timepicker/demos/step.md +1 -1
- package/components/timepicker/panelPicker.vdt +5 -1
- package/components/timepicker/styles.ts +0 -1
- package/components/tour/demos/basic.md +73 -0
- package/components/tour/demos/beforeChange.md +109 -0
- package/components/tour/demos/closable.md +70 -0
- package/components/tour/demos/custom.md +98 -0
- package/components/tour/demos/customText.md +94 -0
- package/components/tour/demos/declarative.md +72 -0
- package/components/tour/demos/events.md +101 -0
- package/components/tour/demos/maskClosable.md +76 -0
- package/components/tour/demos/notarget.md +59 -0
- package/components/tour/index.md +48 -0
- package/components/tour/index.spec.ts +259 -0
- package/components/tour/index.ts +2 -0
- package/components/tour/step.ts +55 -0
- package/components/tour/step.vdt +75 -0
- package/components/tour/styles.ts +283 -0
- package/components/tour/tour.ts +107 -0
- package/components/tour/tour.vdt +83 -0
- package/components/tour/useArrow.ts +46 -0
- package/components/tour/useFixBody.ts +22 -0
- package/components/tour/useHighlight.ts +36 -0
- package/components/tour/useMaskClosable.ts +26 -0
- package/components/tour/useNavigation.ts +46 -0
- package/components/tour/usePosition.ts +91 -0
- package/components/tour/useSteps.ts +80 -0
- package/components/tree/useChecked.ts +6 -4
- package/components/treeSelect/index.spec.ts +13 -1
- package/components/virtualList/useVirtualRows.ts +1 -1
- package/es/components/breadcrumb/index.vdt.js +2 -1
- package/es/components/breadcrumb/styles.js +5 -3
- package/es/components/datepicker/basepicker.d.ts +4 -2
- package/es/components/datepicker/basepicker.js +46 -13
- package/es/components/datepicker/calendar.d.ts +34 -6
- package/es/components/datepicker/calendar.js +4 -0
- package/es/components/datepicker/calendar.vdt.js +21 -5
- package/es/components/datepicker/dayjs.d.ts +13 -2
- package/es/components/datepicker/dayjs.js +6 -0
- package/es/components/datepicker/helpers.d.ts +5 -5
- package/es/components/datepicker/index.d.ts +17 -2
- package/es/components/datepicker/index.js +23 -5
- package/es/components/datepicker/index.spec.js +356 -355
- package/es/components/datepicker/index.vdt.js +25 -29
- package/es/components/datepicker/styles.d.ts +17 -0
- package/es/components/datepicker/styles.js +29 -2
- package/es/components/datepicker/useDisabled.d.ts +2 -2
- package/es/components/datepicker/useDisabled.js +1 -1
- package/es/components/datepicker/useFormats.js +3 -1
- package/es/components/datepicker/useMergeRange.d.ts +5 -0
- package/es/components/datepicker/useMergeRange.js +50 -0
- package/es/components/datepicker/usePosition.d.ts +10 -0
- package/es/components/datepicker/usePosition.js +166 -0
- package/es/components/datepicker/useQuarters.d.ts +15 -0
- package/es/components/datepicker/useQuarters.js +36 -0
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +42 -9
- package/es/components/datepicker/useStatus.d.ts +1 -1
- package/es/components/datepicker/useValue.d.ts +1 -0
- package/es/components/datepicker/useValue.js +26 -2
- package/es/components/datepicker/useWeeks.d.ts +19 -0
- package/es/components/datepicker/useWeeks.js +48 -0
- package/es/components/dialog/useFixBody.js +6 -58
- package/es/components/ellipsis/styles.js +1 -1
- package/es/components/form/styles.js +1 -1
- package/es/components/scrollSelect/index.spec.js +4 -6
- package/es/components/scrollSelect/useMouseEvents.js +21 -9
- package/es/components/select/base.vdt.js +4 -2
- package/es/components/select/index.spec.js +269 -42
- package/es/components/select/option.d.ts +1 -0
- package/es/components/select/option.js +9 -2
- package/es/components/select/select.d.ts +1 -0
- package/es/components/select/select.js +2 -1
- package/es/components/select/useFilterable.js +2 -1
- package/es/components/select/useInput.js +5 -2
- package/es/components/select/useSearchable.js +1 -0
- package/es/components/table/table.vdt.js +4 -2
- package/es/components/timepicker/panelPicker.d.ts +2 -1
- package/es/components/timepicker/panelPicker.vdt.js +12 -4
- package/es/components/timepicker/selectPicker.d.ts +1 -1
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useDisabled.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +1 -0
- package/es/components/tour/index.d.ts +2 -0
- package/es/components/tour/index.js +2 -0
- package/es/components/tour/index.spec.d.ts +1 -0
- package/es/components/tour/index.spec.js +356 -0
- package/es/components/tour/step.d.ts +23 -0
- package/es/components/tour/step.js +46 -0
- package/es/components/tour/step.vdt.js +74 -0
- package/es/components/tour/styles.d.ts +7 -0
- package/es/components/tour/styles.js +84 -0
- package/es/components/tour/tour.d.ts +73 -0
- package/es/components/tour/tour.js +70 -0
- package/es/components/tour/tour.vdt.js +66 -0
- package/es/components/tour/useArrow.d.ts +4 -0
- package/es/components/tour/useArrow.js +40 -0
- package/es/components/tour/useFixBody.d.ts +4 -0
- package/es/components/tour/useFixBody.js +17 -0
- package/es/components/tour/useHighlight.d.ts +4 -0
- package/es/components/tour/useHighlight.js +31 -0
- package/es/components/tour/useMaskClosable.d.ts +1 -0
- package/es/components/tour/useMaskClosable.js +25 -0
- package/es/components/tour/useNavigation.d.ts +5 -0
- package/es/components/tour/useNavigation.js +103 -0
- package/es/components/tour/usePosition.d.ts +6 -0
- package/es/components/tour/usePosition.js +93 -0
- package/es/components/tour/useSteps.d.ts +6 -0
- package/es/components/tour/useSteps.js +68 -0
- package/es/components/tree/useChecked.js +6 -4
- package/es/components/treeSelect/index.spec.js +20 -5
- package/es/components/virtualList/useVirtualRows.js +1 -1
- package/es/hooks/useDocumentClick.js +3 -3
- package/es/hooks/useFixBody.d.ts +11 -0
- package/es/hooks/useFixBody.js +72 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/breadcrumb/demos/separator/react.js +7 -5
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/index.js +1 -2
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +0 -1
- package/es/site/data/components/datepicker/demos/multiple/react.js +2 -13
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/index.js +19 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +10 -0
- package/es/site/data/components/datepicker/demos/nowrap/react.js +49 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +3 -1
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +2 -0
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +21 -1
- package/es/site/data/components/select/demos/creatable/index.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/index.js +2 -1
- package/es/site/data/components/select/demos/creatable/react.d.ts +1 -0
- package/es/site/data/components/select/demos/creatable/react.js +31 -2
- package/es/site/data/components/select/demos/searchable/index.js +1 -1
- package/es/site/data/components/select/demos/searchable/react.js +1 -1
- package/es/site/data/components/tour/demos/basic/index.d.ts +17 -0
- package/es/site/data/components/tour/demos/basic/index.js +46 -0
- package/es/site/data/components/tour/demos/basic/react.d.ts +16 -0
- package/es/site/data/components/tour/demos/basic/react.js +82 -0
- package/es/site/data/components/tour/demos/beforeChange/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/beforeChange/index.js +69 -0
- package/es/site/data/components/tour/demos/beforeChange/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/beforeChange/react.js +129 -0
- package/es/site/data/components/tour/demos/closable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/closable/index.js +42 -0
- package/es/site/data/components/tour/demos/closable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/closable/react.js +85 -0
- package/es/site/data/components/tour/demos/custom/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/index.js +35 -0
- package/es/site/data/components/tour/demos/custom/react.d.ts +11 -0
- package/es/site/data/components/tour/demos/custom/react.js +108 -0
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/index.js +55 -0
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +33 -0
- package/es/site/data/components/tour/demos/customButtons/react.js +99 -0
- package/es/site/data/components/tour/demos/customText/index.d.ts +20 -0
- package/es/site/data/components/tour/demos/customText/index.js +54 -0
- package/es/site/data/components/tour/demos/customText/react.d.ts +19 -0
- package/es/site/data/components/tour/demos/customText/react.js +95 -0
- package/es/site/data/components/tour/demos/declarative/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/declarative/index.js +36 -0
- package/es/site/data/components/tour/demos/declarative/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/declarative/react.js +80 -0
- package/es/site/data/components/tour/demos/events/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/index.js +58 -0
- package/es/site/data/components/tour/demos/events/react.d.ts +18 -0
- package/es/site/data/components/tour/demos/events/react.js +101 -0
- package/es/site/data/components/tour/demos/maskClosable/index.d.ts +18 -0
- package/es/site/data/components/tour/demos/maskClosable/index.js +47 -0
- package/es/site/data/components/tour/demos/maskClosable/react.d.ts +17 -0
- package/es/site/data/components/tour/demos/maskClosable/react.js +95 -0
- package/es/site/data/components/tour/demos/notarget/index.d.ts +11 -0
- package/es/site/data/components/tour/demos/notarget/index.js +35 -0
- package/es/site/data/components/tour/demos/notarget/react.d.ts +10 -0
- package/es/site/data/components/tour/demos/notarget/react.js +61 -0
- package/es/site/data/components/tour/index.d.ts +57 -0
- package/es/site/data/components/tour/index.js +32 -0
- package/es/site/src/pages/resource/index.js +1 -1
- package/es/styles/fonts/iconfont.js +2 -1
- package/es/styles/global.js +2 -1
- package/hooks/useDocumentClick.ts +3 -3
- package/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +1 -1
- package/styles/fonts/iconfont.ts +2 -1
- package/styles/global.ts +2 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
TypeDefs,
|
|
4
|
+
VNode,
|
|
5
|
+
createRef,
|
|
6
|
+
onMounted,
|
|
7
|
+
onUpdated,
|
|
8
|
+
nextTick
|
|
9
|
+
} from "intact";
|
|
10
|
+
import template from "./tour.vdt";
|
|
11
|
+
import { useConfigContext } from '../config';
|
|
12
|
+
import { TourStepProps } from './step';
|
|
13
|
+
import type {Events} from '../types';
|
|
14
|
+
import { createContext } from '../context';
|
|
15
|
+
import { usePosition } from './usePosition';
|
|
16
|
+
import { Feedback } from '../position';
|
|
17
|
+
import { useSteps } from './useSteps';
|
|
18
|
+
import { useArrow } from './useArrow';
|
|
19
|
+
import { useHighlight } from './useHighlight';
|
|
20
|
+
import { useNavigation } from './useNavigation';
|
|
21
|
+
import { useFixBody } from './useFixBody';
|
|
22
|
+
import { useMaskClosable } from './useMaskClosable';
|
|
23
|
+
import {Theme, themes} from './styles';
|
|
24
|
+
|
|
25
|
+
export interface TourProps {
|
|
26
|
+
value?: number;
|
|
27
|
+
theme?: Theme
|
|
28
|
+
data?: TourStepProps[];
|
|
29
|
+
beforeChange?: (current: number) => boolean | Promise<boolean>;
|
|
30
|
+
maskClosable?: boolean;
|
|
31
|
+
closable?: boolean;
|
|
32
|
+
doneText?: string;
|
|
33
|
+
showArrow?: boolean;
|
|
34
|
+
visible?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TourEvents {
|
|
38
|
+
finish: [];
|
|
39
|
+
prev: [number];
|
|
40
|
+
next: [number];
|
|
41
|
+
positioned: [Feedback];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TourBlocks {
|
|
45
|
+
default: null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface TourContextValue {
|
|
49
|
+
value: number;
|
|
50
|
+
total: number;
|
|
51
|
+
doneText: string;
|
|
52
|
+
closable: boolean;
|
|
53
|
+
onPrev: () => void;
|
|
54
|
+
onNext: () => void;
|
|
55
|
+
onFinish: () => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const TourContext = createContext<TourContextValue>();
|
|
59
|
+
|
|
60
|
+
const typeDefs: Required<TypeDefs<TourProps>> = {
|
|
61
|
+
value: Number,
|
|
62
|
+
theme: themes,
|
|
63
|
+
data: Array,
|
|
64
|
+
beforeChange: Function,
|
|
65
|
+
maskClosable: Boolean,
|
|
66
|
+
closable: Boolean,
|
|
67
|
+
doneText: String,
|
|
68
|
+
showArrow: Boolean,
|
|
69
|
+
visible: Boolean,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const defaults = (): Partial<TourProps> => ({
|
|
73
|
+
value: 0,
|
|
74
|
+
theme: 'light',
|
|
75
|
+
data: [],
|
|
76
|
+
maskClosable: true,
|
|
77
|
+
closable: true,
|
|
78
|
+
doneText: '完成',
|
|
79
|
+
showArrow: true,
|
|
80
|
+
visible: true,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const events: Events<TourEvents> = {
|
|
84
|
+
finish: true,
|
|
85
|
+
prev: true,
|
|
86
|
+
next: true,
|
|
87
|
+
positioned: true,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export class Tour extends Component<TourProps, TourEvents, TourBlocks> {
|
|
91
|
+
static template = template;
|
|
92
|
+
static typeDefs = typeDefs;
|
|
93
|
+
static defaults = defaults;
|
|
94
|
+
static events = events;
|
|
95
|
+
|
|
96
|
+
public config = useConfigContext();
|
|
97
|
+
public tourRef = createRef<HTMLDivElement>();
|
|
98
|
+
|
|
99
|
+
public steps = useSteps();
|
|
100
|
+
public arrow = useArrow();
|
|
101
|
+
public highlight = useHighlight(this.steps.getTargetElement);
|
|
102
|
+
private position = usePosition(this.tourRef, this.steps.getTargetElement);
|
|
103
|
+
public navigation = useNavigation(this.steps.getTotalSteps);
|
|
104
|
+
private fixBody = useFixBody();
|
|
105
|
+
private useMaskClosable = useMaskClosable();
|
|
106
|
+
|
|
107
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {makeStyles} from './styles';
|
|
2
|
+
import {TourStep} from './step';
|
|
3
|
+
import {TourContext} from './tour';
|
|
4
|
+
import {getRestProps, stopPropagation} from '../utils';
|
|
5
|
+
import {mapChildren, isComponentVNode} from '../utils';
|
|
6
|
+
|
|
7
|
+
const { className, data, children, value, hoverable,
|
|
8
|
+
showArrow, theme, visible, maskClosable,
|
|
9
|
+
doneText, closable,
|
|
10
|
+
} = this.get();
|
|
11
|
+
const { k } = this.config;
|
|
12
|
+
|
|
13
|
+
const currentValue = value !== undefined ? value : 0;
|
|
14
|
+
const {arrowType, arrowRef} = this.arrow;
|
|
15
|
+
const {highlightRef} = this.highlight;
|
|
16
|
+
const {prev, next, finish} = this.navigation;
|
|
17
|
+
const {getTotalSteps} = this.steps;
|
|
18
|
+
|
|
19
|
+
const contextValue = {
|
|
20
|
+
value: value || 0,
|
|
21
|
+
total: getTotalSteps(),
|
|
22
|
+
doneText: doneText,
|
|
23
|
+
closable: closable,
|
|
24
|
+
onPrev: prev,
|
|
25
|
+
onNext: next,
|
|
26
|
+
onFinish: finish
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const classNameObj = {
|
|
30
|
+
[`${k}-tour`]: true,
|
|
31
|
+
[`${k}-${theme}`]: true,
|
|
32
|
+
[className]: className,
|
|
33
|
+
[makeStyles(k)]: true,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
<div class={classNameObj} {...getRestProps(this)} v-if={visible}>
|
|
37
|
+
<TourContext.Provider value={contextValue}>
|
|
38
|
+
{/* 高亮目标元素 */}
|
|
39
|
+
<div
|
|
40
|
+
class={{
|
|
41
|
+
[`${k}-tour-target-highlight`]: true,
|
|
42
|
+
[`${k}-hoverable`]: hoverable
|
|
43
|
+
}}
|
|
44
|
+
v-if={currentValue !== undefined}
|
|
45
|
+
ref={highlightRef}
|
|
46
|
+
></div>
|
|
47
|
+
|
|
48
|
+
{/* 步骤内容 */}
|
|
49
|
+
<div
|
|
50
|
+
class={`${k}-tour-step-wrapper`}
|
|
51
|
+
ref={this.tourRef}
|
|
52
|
+
ev-click={stopPropagation}
|
|
53
|
+
>
|
|
54
|
+
<template v-if={!children}>
|
|
55
|
+
<TourStep
|
|
56
|
+
v-for={data}
|
|
57
|
+
v-if={$key === currentValue}
|
|
58
|
+
key={$key}
|
|
59
|
+
{...$value}
|
|
60
|
+
/>
|
|
61
|
+
</template>
|
|
62
|
+
<template v-else>
|
|
63
|
+
{mapChildren(children, (vNode, index) => {
|
|
64
|
+
if (isComponentVNode(vNode, TourStep)) {
|
|
65
|
+
if (index === currentValue) {
|
|
66
|
+
return vNode;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
})}
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
{/* 箭头 */}
|
|
74
|
+
<i v-if={showArrow && arrowType.value}
|
|
75
|
+
class={{
|
|
76
|
+
[`${k}-tour-arrow`]: true,
|
|
77
|
+
[`${k}-${arrowType.value}`]: arrowType.value,
|
|
78
|
+
}}
|
|
79
|
+
ref={arrowRef}
|
|
80
|
+
></i>
|
|
81
|
+
</div>
|
|
82
|
+
</TourContext.Provider>
|
|
83
|
+
</div>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {useInstance, createRef, nextTick} from 'intact';
|
|
2
|
+
import { Tour } from './tour';
|
|
3
|
+
import {Feedback} from '../position';
|
|
4
|
+
import {useState} from '../../hooks/useState';
|
|
5
|
+
import {clamp} from '../utils';
|
|
6
|
+
|
|
7
|
+
export function useArrow() {
|
|
8
|
+
const instance = useInstance() as Tour;
|
|
9
|
+
const arrowType = useState<string | null>(null);
|
|
10
|
+
const arrowRef = createRef<HTMLElement>();
|
|
11
|
+
|
|
12
|
+
// 监听positioned事件
|
|
13
|
+
instance.on('positioned', (feedback: Feedback) => {
|
|
14
|
+
updateArrow(feedback);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// update arrow position and type
|
|
18
|
+
function updateArrow(feedback: Feedback) {
|
|
19
|
+
if (!instance.get('showArrow')) return;
|
|
20
|
+
|
|
21
|
+
arrowType.set(feedback[feedback.important]);
|
|
22
|
+
|
|
23
|
+
nextTick(() => {
|
|
24
|
+
if (instance.$unmounted) return;
|
|
25
|
+
|
|
26
|
+
const arrow = arrowRef.value!;
|
|
27
|
+
const {target, element} = feedback;
|
|
28
|
+
|
|
29
|
+
if (feedback.important === 'vertical') {
|
|
30
|
+
// vertical important, adjust horizontal position
|
|
31
|
+
const arrowWidth = arrow.offsetWidth;
|
|
32
|
+
let left = target.left - element.left + (target.width - arrowWidth) / 2;
|
|
33
|
+
left = clamp(left, 1, element.width - 1 - arrowWidth);
|
|
34
|
+
arrow.setAttribute('style', `left: ${left}px`);
|
|
35
|
+
} else {
|
|
36
|
+
// horizontal important, adjust vertical position
|
|
37
|
+
const arrowHeight = arrow.offsetHeight;
|
|
38
|
+
let top = target.top - element.top + target.height / 2 - arrowHeight / 2;
|
|
39
|
+
top = clamp(top, 1, element.height - 1 - arrowHeight);
|
|
40
|
+
arrow.setAttribute('style', `top: ${top}px`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {arrowType, arrowRef};
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {useInstance} from 'intact';
|
|
2
|
+
import type {Tour} from './tour';
|
|
3
|
+
import {useFixBody as useFixBodyHook} from '../../hooks/useFixBody';
|
|
4
|
+
|
|
5
|
+
export function useFixBody() {
|
|
6
|
+
const instance = useInstance() as Tour;
|
|
7
|
+
|
|
8
|
+
const fixBodyHook = useFixBodyHook();
|
|
9
|
+
|
|
10
|
+
instance.watch('visible', (visible) => {
|
|
11
|
+
if (visible) {
|
|
12
|
+
fixBodyHook.onOpen();
|
|
13
|
+
} else {
|
|
14
|
+
fixBodyHook.onClose();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
onOpen: fixBodyHook.onOpen,
|
|
20
|
+
onClosed: fixBodyHook.onClose
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {useInstance, createRef, nextTick} from 'intact';
|
|
2
|
+
import { Tour } from './tour';
|
|
3
|
+
|
|
4
|
+
export function useHighlight(getTargetElement: (index?: number) => HTMLElement | null,) {
|
|
5
|
+
const instance = useInstance() as Tour;
|
|
6
|
+
const highlightRef = createRef<HTMLElement>();
|
|
7
|
+
|
|
8
|
+
instance.on('$updated' as any, updateHighlight);
|
|
9
|
+
|
|
10
|
+
instance.watch('visible', (visible) => {
|
|
11
|
+
if (visible) {
|
|
12
|
+
nextTick(() => {
|
|
13
|
+
updateHighlight();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// update highlight element position and size
|
|
19
|
+
function updateHighlight() {
|
|
20
|
+
const highlightElem = highlightRef.value;
|
|
21
|
+
const targetElem = getTargetElement();
|
|
22
|
+
|
|
23
|
+
if (highlightElem && targetElem) {
|
|
24
|
+
const rect = targetElem.getBoundingClientRect();
|
|
25
|
+
const padding = 8;
|
|
26
|
+
|
|
27
|
+
highlightElem.style.width = `${rect.width + padding * 2}px`;
|
|
28
|
+
highlightElem.style.height = `${rect.height + padding * 2}px`;
|
|
29
|
+
highlightElem.style.position = 'fixed';
|
|
30
|
+
highlightElem.style.left = `${rect.left - padding}px`;
|
|
31
|
+
highlightElem.style.top = `${rect.top - padding}px`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {highlightRef, updateHighlight};
|
|
36
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useInstance } from "intact";
|
|
2
|
+
import { useDocumentClick } from "../../hooks/useDocumentClick";
|
|
3
|
+
import type {Tour} from './tour';
|
|
4
|
+
|
|
5
|
+
export function useMaskClosable() {
|
|
6
|
+
const tour = useInstance() as Tour;
|
|
7
|
+
const [addDocumentClick, removeDocumentClick] = useDocumentClick(tour.tourRef, (e) => {
|
|
8
|
+
const maskClosable = tour.get('maskClosable');
|
|
9
|
+
if (maskClosable) {
|
|
10
|
+
// 检查点击的是否是当前目标元素或其子元素
|
|
11
|
+
const targetElement = tour.steps.getTargetElement();
|
|
12
|
+
if (targetElement && (e.target === targetElement || targetElement.contains(e.target as Node))) {
|
|
13
|
+
return; // 点击的是目标元素,不关闭
|
|
14
|
+
}
|
|
15
|
+
tour.navigation.finish();
|
|
16
|
+
}
|
|
17
|
+
}, true);
|
|
18
|
+
|
|
19
|
+
tour.watch('visible', (visible: boolean | undefined) => {
|
|
20
|
+
if (visible) {
|
|
21
|
+
addDocumentClick();
|
|
22
|
+
} else {
|
|
23
|
+
removeDocumentClick();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {useInstance, createRef, nextTick} from 'intact';
|
|
2
|
+
import { Tour } from './tour';
|
|
3
|
+
|
|
4
|
+
export function useNavigation(getTotalSteps: () => number) {
|
|
5
|
+
const instance = useInstance() as Tour;
|
|
6
|
+
|
|
7
|
+
async function prev() {
|
|
8
|
+
const { value, beforeChange } = instance.get();
|
|
9
|
+
if (value === undefined || value <= 0) return;
|
|
10
|
+
|
|
11
|
+
if (beforeChange) {
|
|
12
|
+
const canChange = await beforeChange(value - 1);
|
|
13
|
+
if (canChange === false) return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
instance.set('value', value - 1);
|
|
17
|
+
instance.trigger('prev', value - 1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function next() {
|
|
21
|
+
const { value, beforeChange } = instance.get();
|
|
22
|
+
if (value === undefined) return;
|
|
23
|
+
|
|
24
|
+
const steps = getTotalSteps();
|
|
25
|
+
|
|
26
|
+
if (value >= steps - 1) {
|
|
27
|
+
finish();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (beforeChange) {
|
|
32
|
+
const canChange = await beforeChange(value + 1);
|
|
33
|
+
if (canChange === false) return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
instance.set('value', value + 1);
|
|
37
|
+
instance.trigger('next', value + 1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function finish() {
|
|
41
|
+
instance.trigger('finish');
|
|
42
|
+
instance.set('visible', false);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {prev, next, finish};
|
|
46
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useInstance, RefObject, onMounted, nextTick } from 'intact';
|
|
2
|
+
import type { Tour } from './tour';
|
|
3
|
+
import { Options as PositionOptions, position, Feedback } from '../position';
|
|
4
|
+
|
|
5
|
+
const CENTER_POSITION_OPTIONS: PositionOptions = {
|
|
6
|
+
my: 'center center',
|
|
7
|
+
at: 'center center',
|
|
8
|
+
collision: 'none'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function usePosition(
|
|
12
|
+
stepRef: RefObject<HTMLDivElement>,
|
|
13
|
+
getTargetElement: (index?: number) => HTMLElement | null
|
|
14
|
+
) {
|
|
15
|
+
const instance = useInstance() as Tour;
|
|
16
|
+
|
|
17
|
+
instance.watch('value', (value) => {
|
|
18
|
+
if (value !== undefined && value >= 0) {
|
|
19
|
+
nextTick(() => updatePosition());
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
instance.watch('visible', (visible) => {
|
|
24
|
+
if (visible) {
|
|
25
|
+
updatePosition();
|
|
26
|
+
}
|
|
27
|
+
}, {presented: true});
|
|
28
|
+
|
|
29
|
+
onMounted(() => {
|
|
30
|
+
updatePosition();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// get position options
|
|
34
|
+
function getPositionOptions(index?: number): PositionOptions {
|
|
35
|
+
const currentIndex = index !== undefined ? index : (instance.get('value') || 0);
|
|
36
|
+
let positionConfig: PositionOptions | string | undefined;
|
|
37
|
+
|
|
38
|
+
const { data } = instance.get();
|
|
39
|
+
if (data && data[currentIndex]) {
|
|
40
|
+
positionConfig = data[currentIndex].position;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!positionConfig && instance.steps.steps[currentIndex]) {
|
|
44
|
+
positionConfig = instance.steps.steps[currentIndex].props?.position;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!positionConfig) {
|
|
48
|
+
positionConfig = 'bottom';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof positionConfig === 'string') {
|
|
52
|
+
switch (positionConfig) {
|
|
53
|
+
case 'left':
|
|
54
|
+
return {my: 'right-20 center', at: 'left center', collision: 'flipfit'};
|
|
55
|
+
case 'bottom':
|
|
56
|
+
return {my: 'center top+20', at: 'center bottom', collision: 'flipfit'};
|
|
57
|
+
case 'right':
|
|
58
|
+
return {my: 'left+20 center', at: 'right center', collision: 'flipfit'};
|
|
59
|
+
case 'top':
|
|
60
|
+
default:
|
|
61
|
+
return {my: 'center bottom-20', at: 'center top', collision: 'flipfit'};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return positionConfig;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// update position
|
|
69
|
+
function updatePosition() {
|
|
70
|
+
const stepElement = stepRef.value;
|
|
71
|
+
if (!stepElement) return;
|
|
72
|
+
|
|
73
|
+
const targetElement = getTargetElement();
|
|
74
|
+
|
|
75
|
+
const positionOptions = targetElement ? getPositionOptions() : CENTER_POSITION_OPTIONS;
|
|
76
|
+
const ofElement = targetElement || window;
|
|
77
|
+
|
|
78
|
+
position(stepElement, {
|
|
79
|
+
...positionOptions,
|
|
80
|
+
of: ofElement,
|
|
81
|
+
using: (feedback, pos) => {
|
|
82
|
+
instance.trigger('positioned', feedback);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
getPositionOptions,
|
|
89
|
+
updatePosition
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useInstance, onMounted } from 'intact';
|
|
2
|
+
import type { Tour } from './tour';
|
|
3
|
+
import type { TourStepProps } from './step';
|
|
4
|
+
import { TourStep } from './step';
|
|
5
|
+
import { isComponentVNode } from '../utils';
|
|
6
|
+
|
|
7
|
+
export function useSteps() {
|
|
8
|
+
const instance = useInstance() as Tour;
|
|
9
|
+
const steps: any[] = [];
|
|
10
|
+
const targetElements = new Map<number, HTMLElement | null>();
|
|
11
|
+
|
|
12
|
+
instance.on('$receive:children' as any, collectSteps);
|
|
13
|
+
|
|
14
|
+
instance.watch('data', () => {
|
|
15
|
+
targetElements.clear();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 收集子组件步骤
|
|
20
|
+
*/
|
|
21
|
+
function collectSteps(children: any) {
|
|
22
|
+
steps.length = 0;
|
|
23
|
+
if (!children) return;
|
|
24
|
+
|
|
25
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
26
|
+
childrenArray.forEach(child => {
|
|
27
|
+
if (child && isComponentVNode(child, TourStep)) {
|
|
28
|
+
steps.push(child);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getTotalSteps(): number {
|
|
34
|
+
const { data, children } = instance.get();
|
|
35
|
+
if (children) {
|
|
36
|
+
return steps.length;
|
|
37
|
+
}
|
|
38
|
+
return (data || []).length;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// get current step target element
|
|
42
|
+
function getTargetElement(index?: number): HTMLElement | null {
|
|
43
|
+
const currentIndex = index !== undefined ? index : (instance.get('value') || 0);
|
|
44
|
+
if (targetElements.has(currentIndex)) {
|
|
45
|
+
return targetElements.get(currentIndex) || null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let target: string | HTMLElement | undefined;
|
|
49
|
+
|
|
50
|
+
// get target from data
|
|
51
|
+
const data = instance.get('data');
|
|
52
|
+
if (data && data[currentIndex]) {
|
|
53
|
+
target = data[currentIndex].target;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// get target from children
|
|
57
|
+
if (!target && steps[currentIndex]) {
|
|
58
|
+
target = steps[currentIndex].props?.target;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!target) return null;
|
|
62
|
+
|
|
63
|
+
let element: HTMLElement | null = null;
|
|
64
|
+
if (typeof target === 'string') {
|
|
65
|
+
element = document.querySelector(target);
|
|
66
|
+
} else {
|
|
67
|
+
element = target;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
targetElements.set(currentIndex, element);
|
|
71
|
+
return element;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
steps,
|
|
76
|
+
collectSteps,
|
|
77
|
+
getTotalSteps,
|
|
78
|
+
getTargetElement
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -56,10 +56,12 @@ export function useChecked(getNodes: () => Node<Key>[]) {
|
|
|
56
56
|
updateUpward(node);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
if (instance.get('checkbox')) {
|
|
60
|
+
const oldCheckedKeys = instance.get('checkedKeys');
|
|
61
|
+
const newCheckedKeys = Array.from(checkedKeys);
|
|
62
|
+
if (!isEqualArray(oldCheckedKeys, newCheckedKeys)) {
|
|
63
|
+
instance.set('checkedKeys', newCheckedKeys);
|
|
64
|
+
}
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -18,10 +18,22 @@ describe('TreeSelect', () => {
|
|
|
18
18
|
const dropdown = getElement('.k-tree-select-menu')!;
|
|
19
19
|
expect(dropdown.innerHTML).to.matchSnapshot();
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const texts = dropdown.querySelectorAll('.k-tree-text');
|
|
22
|
+
const text1 = texts[0] as HTMLElement;
|
|
23
|
+
const text111 = texts[2] as HTMLElement;
|
|
24
|
+
text1.click();
|
|
25
|
+
await wait();
|
|
22
26
|
expect(instance.get('value')).to.eql('1');
|
|
23
27
|
|
|
24
28
|
await wait(500);
|
|
29
|
+
|
|
30
|
+
element.click();
|
|
31
|
+
text111.click();
|
|
32
|
+
await wait();
|
|
33
|
+
expect(instance.get('value')).to.eql('1.1.1');
|
|
34
|
+
|
|
35
|
+
await wait(500);
|
|
36
|
+
|
|
25
37
|
expect(getElement('.k-tree-select-menu')).to.be.undefined;
|
|
26
38
|
});
|
|
27
39
|
|
|
@@ -76,7 +76,7 @@ export function useVirtualRows() {
|
|
|
76
76
|
const key = row.key!;
|
|
77
77
|
if (!rowsHeightMap.has(key)) {
|
|
78
78
|
const rowDom = findDomFromVNode(row, true) as HTMLElement;
|
|
79
|
-
const height = rowDom.offsetHeight;
|
|
79
|
+
const height = rowDom.offsetHeight || rowAvgHeight;
|
|
80
80
|
rowsHeightMap.set(key, height);
|
|
81
81
|
calculatedHeight += height;
|
|
82
82
|
}
|
|
@@ -6,7 +6,8 @@ import { BreadcrumbItem } from './item';
|
|
|
6
6
|
import { makeStyles } from './styles';
|
|
7
7
|
import { Icon } from '../icon';
|
|
8
8
|
var _$tmp0 = {
|
|
9
|
-
'className': 'k-icon-right'
|
|
9
|
+
'className': 'k-icon-right',
|
|
10
|
+
'size': 'small'
|
|
10
11
|
};
|
|
11
12
|
export default function ($props, $blocks, $__proto__) {
|
|
12
13
|
var _classNameObj;
|
|
@@ -4,7 +4,7 @@ import { theme, setDefault } from '../../styles/theme';
|
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import { cache } from '../utils';
|
|
6
6
|
var defaults = {
|
|
7
|
-
fontSize: '
|
|
7
|
+
fontSize: '12px',
|
|
8
8
|
get color() {
|
|
9
9
|
return theme.color.lightBlack;
|
|
10
10
|
},
|
|
@@ -13,7 +13,9 @@ var defaults = {
|
|
|
13
13
|
},
|
|
14
14
|
gap: '6px',
|
|
15
15
|
activeFontWeight: 'normal',
|
|
16
|
-
activeColor
|
|
16
|
+
get activeColor() {
|
|
17
|
+
return theme.color.title;
|
|
18
|
+
}
|
|
17
19
|
};
|
|
18
20
|
var breadcrumb;
|
|
19
21
|
setDefault(function () {
|
|
@@ -23,5 +25,5 @@ setDefault(function () {
|
|
|
23
25
|
makeStyles == null || makeStyles.clearCache();
|
|
24
26
|
});
|
|
25
27
|
export var makeStyles = cache(function makeStyles(k) {
|
|
26
|
-
return /*#__PURE__*/css("font-size:", breadcrumb.fontSize, ";display:flex;align-items:center;.", k, "-breadcrumb-item{&:last-of-type .", k, "-breadcrumb-link{font-weight:", breadcrumb.activeFontWeight, ";color:", breadcrumb.activeColor, ";}}.", k, "-breadcrumb-link,.", k, "-breadcrumb-link a{color:", breadcrumb.color, ";}a.", k, "-breadcrumb-link,.", k, "-breadcrumb-link a{cursor:pointer;&:hover{color:", breadcrumb.hoverColor, ";}}.", k, "-breadcrumb-separator{margin:0 ", breadcrumb.gap, ";}");
|
|
28
|
+
return /*#__PURE__*/css("font-size:", breadcrumb.fontSize, ";line-height:12px;display:flex;align-items:center;.", k, "-breadcrumb-item{&:last-of-type .", k, "-breadcrumb-link{font-weight:", breadcrumb.activeFontWeight, ";color:", breadcrumb.activeColor, ";}}.", k, "-breadcrumb-link,.", k, "-breadcrumb-link a{color:", breadcrumb.color, ";}a.", k, "-breadcrumb-link,.", k, "-breadcrumb-link a{cursor:pointer;&:hover{color:", breadcrumb.hoverColor, ";}}.", k, "-breadcrumb-separator{margin:0 ", breadcrumb.gap, ";}");
|
|
27
29
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { TypeDefs } from 'intact';
|
|
5
5
|
import { State } from '../../hooks/useState';
|
|
6
|
-
import { Dayjs, OpUnitType } from './dayjs';
|
|
6
|
+
import { Dayjs, OpUnitType, QUnitType } from './dayjs';
|
|
7
7
|
import type { useFormats } from './useFormats';
|
|
8
8
|
import type { useDisabled } from './useDisabled';
|
|
9
9
|
import { PanelFlags, usePanel } from './usePanel';
|
|
@@ -34,6 +34,7 @@ export interface BasePickerProps<V extends Value = Value, Multipe extends boolea
|
|
|
34
34
|
}
|
|
35
35
|
export interface BasePickerEvents extends BaseSelectEvents {
|
|
36
36
|
selecting: [StateValueRange];
|
|
37
|
+
togglePosition: [];
|
|
37
38
|
}
|
|
38
39
|
export interface BasePickerBlocks<V extends Value = Value, R extends boolean = boolean> extends BaseSelectBlocks<R extends true ? [Value, Value] : Value> {
|
|
39
40
|
}
|
|
@@ -47,7 +48,7 @@ export declare abstract class BasePicker<T extends BasePickerProps = BasePickerP
|
|
|
47
48
|
abstract panel: ReturnType<typeof usePanel>;
|
|
48
49
|
resetKeywords(keywords: State<string>): void;
|
|
49
50
|
}
|
|
50
|
-
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, updateStateValue: (v: DayjsValue, value: State<StateValue>) => void): {
|
|
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): {
|
|
51
52
|
value: State<StateValue>;
|
|
52
53
|
format: () => string | string[];
|
|
53
54
|
onConfirm: () => void;
|
|
@@ -56,4 +57,5 @@ export declare function useValue({ createDateByValueFormat, createDateByShowForm
|
|
|
56
57
|
setValue: (v: StateValueItem, fromInput: boolean) => void;
|
|
57
58
|
convertToDayjs: (v: BasePickerProps<Value>['value']) => DayjsValue;
|
|
58
59
|
getDayjsValue: () => DayjsValue;
|
|
60
|
+
setMoment: () => void;
|
|
59
61
|
};
|