@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,73 @@
|
|
|
1
|
+
import { Component, TypeDefs } from "intact";
|
|
2
|
+
import { TourStepProps } from './step';
|
|
3
|
+
import type { Events } from '../types';
|
|
4
|
+
import { Feedback } from '../position';
|
|
5
|
+
import { Theme } from './styles';
|
|
6
|
+
export interface TourProps {
|
|
7
|
+
value?: number;
|
|
8
|
+
theme?: Theme;
|
|
9
|
+
data?: TourStepProps[];
|
|
10
|
+
beforeChange?: (current: number) => boolean | Promise<boolean>;
|
|
11
|
+
maskClosable?: boolean;
|
|
12
|
+
closable?: boolean;
|
|
13
|
+
doneText?: string;
|
|
14
|
+
showArrow?: boolean;
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TourEvents {
|
|
18
|
+
finish: [];
|
|
19
|
+
prev: [number];
|
|
20
|
+
next: [number];
|
|
21
|
+
positioned: [Feedback];
|
|
22
|
+
}
|
|
23
|
+
export interface TourBlocks {
|
|
24
|
+
default: null;
|
|
25
|
+
}
|
|
26
|
+
export interface TourContextValue {
|
|
27
|
+
value: number;
|
|
28
|
+
total: number;
|
|
29
|
+
doneText: string;
|
|
30
|
+
closable: boolean;
|
|
31
|
+
onPrev: () => void;
|
|
32
|
+
onNext: () => void;
|
|
33
|
+
onFinish: () => void;
|
|
34
|
+
}
|
|
35
|
+
export declare const TourContext: {
|
|
36
|
+
Provider: import("intact").ComponentConstructor<Component<import("../context").ProviderProps<TourContextValue>, {}, {}, {}>>;
|
|
37
|
+
Consumer: import("intact").ComponentConstructor<Component<import("../context").ConsumerProps<TourContextValue>, {}, {}, {}>>;
|
|
38
|
+
useContext: () => import("intact").RefObject<TourContextValue | undefined>;
|
|
39
|
+
};
|
|
40
|
+
export declare class Tour extends Component<TourProps, TourEvents, TourBlocks> {
|
|
41
|
+
static template: string | import("intact").Template<any>;
|
|
42
|
+
static typeDefs: Required<TypeDefs<TourProps>>;
|
|
43
|
+
static defaults: () => Partial<TourProps>;
|
|
44
|
+
static events: Events<TourEvents>;
|
|
45
|
+
config: {
|
|
46
|
+
cls: (name: string) => string;
|
|
47
|
+
readonly k: string;
|
|
48
|
+
readonly disableWave: boolean;
|
|
49
|
+
};
|
|
50
|
+
tourRef: import("intact").RefObject<HTMLDivElement>;
|
|
51
|
+
steps: {
|
|
52
|
+
steps: any[];
|
|
53
|
+
collectSteps: (children: any) => void;
|
|
54
|
+
getTotalSteps: () => number;
|
|
55
|
+
getTargetElement: (index?: number | undefined) => HTMLElement | null;
|
|
56
|
+
};
|
|
57
|
+
arrow: {
|
|
58
|
+
arrowType: import("../../hooks/useState").State<string | null>;
|
|
59
|
+
arrowRef: import("intact").RefObject<HTMLElement>;
|
|
60
|
+
};
|
|
61
|
+
highlight: {
|
|
62
|
+
highlightRef: import("intact").RefObject<HTMLElement>;
|
|
63
|
+
updateHighlight: () => void;
|
|
64
|
+
};
|
|
65
|
+
private position;
|
|
66
|
+
navigation: {
|
|
67
|
+
prev: () => Promise<void>;
|
|
68
|
+
next: () => Promise<void>;
|
|
69
|
+
finish: () => void;
|
|
70
|
+
};
|
|
71
|
+
private fixBody;
|
|
72
|
+
private useMaskClosable;
|
|
73
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
+
import { Component, createRef } from "intact";
|
|
4
|
+
import template from "./tour.vdt";
|
|
5
|
+
import { useConfigContext } from '../config';
|
|
6
|
+
import { createContext } from '../context';
|
|
7
|
+
import { usePosition } from './usePosition';
|
|
8
|
+
import { useSteps } from './useSteps';
|
|
9
|
+
import { useArrow } from './useArrow';
|
|
10
|
+
import { useHighlight } from './useHighlight';
|
|
11
|
+
import { useNavigation } from './useNavigation';
|
|
12
|
+
import { useFixBody } from './useFixBody';
|
|
13
|
+
import { useMaskClosable } from './useMaskClosable';
|
|
14
|
+
import { themes } from './styles';
|
|
15
|
+
export var TourContext = createContext();
|
|
16
|
+
var typeDefs = {
|
|
17
|
+
value: Number,
|
|
18
|
+
theme: themes,
|
|
19
|
+
data: Array,
|
|
20
|
+
beforeChange: Function,
|
|
21
|
+
maskClosable: Boolean,
|
|
22
|
+
closable: Boolean,
|
|
23
|
+
doneText: String,
|
|
24
|
+
showArrow: Boolean,
|
|
25
|
+
visible: Boolean
|
|
26
|
+
};
|
|
27
|
+
var defaults = function defaults() {
|
|
28
|
+
return {
|
|
29
|
+
value: 0,
|
|
30
|
+
theme: 'light',
|
|
31
|
+
data: [],
|
|
32
|
+
maskClosable: true,
|
|
33
|
+
closable: true,
|
|
34
|
+
doneText: '完成',
|
|
35
|
+
showArrow: true,
|
|
36
|
+
visible: true
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
var events = {
|
|
40
|
+
finish: true,
|
|
41
|
+
prev: true,
|
|
42
|
+
next: true,
|
|
43
|
+
positioned: true
|
|
44
|
+
};
|
|
45
|
+
export var Tour = /*#__PURE__*/function (_Component) {
|
|
46
|
+
_inheritsLoose(Tour, _Component);
|
|
47
|
+
function Tour() {
|
|
48
|
+
var _context;
|
|
49
|
+
var _this;
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
54
|
+
_this.config = useConfigContext();
|
|
55
|
+
_this.tourRef = createRef();
|
|
56
|
+
_this.steps = useSteps();
|
|
57
|
+
_this.arrow = useArrow();
|
|
58
|
+
_this.highlight = useHighlight(_this.steps.getTargetElement);
|
|
59
|
+
_this.position = usePosition(_this.tourRef, _this.steps.getTargetElement);
|
|
60
|
+
_this.navigation = useNavigation(_this.steps.getTotalSteps);
|
|
61
|
+
_this.fixBody = useFixBody();
|
|
62
|
+
_this.useMaskClosable = useMaskClosable();
|
|
63
|
+
return _this;
|
|
64
|
+
}
|
|
65
|
+
return Tour;
|
|
66
|
+
}(Component);
|
|
67
|
+
Tour.template = template;
|
|
68
|
+
Tour.typeDefs = typeDefs;
|
|
69
|
+
Tour.defaults = defaults;
|
|
70
|
+
Tour.events = events;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { createVNode as _$cv, className as _$cn, createUnknownComponentVNode as _$cc, createElementVNode as _$ce, map as _$ma } from 'intact';
|
|
3
|
+
import { makeStyles } from './styles';
|
|
4
|
+
import { TourStep } from './step';
|
|
5
|
+
import { TourContext } from './tour';
|
|
6
|
+
import { getRestProps, stopPropagation } from '../utils';
|
|
7
|
+
import { mapChildren, isComponentVNode } from '../utils';
|
|
8
|
+
export default function ($props, $blocks, $__proto__) {
|
|
9
|
+
var _classNameObj, _$cn2, _$cn3;
|
|
10
|
+
$blocks || ($blocks = {});
|
|
11
|
+
$props || ($props = {});
|
|
12
|
+
var $this = this;
|
|
13
|
+
var _this$get = this.get(),
|
|
14
|
+
className = _this$get.className,
|
|
15
|
+
data = _this$get.data,
|
|
16
|
+
children = _this$get.children,
|
|
17
|
+
value = _this$get.value,
|
|
18
|
+
hoverable = _this$get.hoverable,
|
|
19
|
+
showArrow = _this$get.showArrow,
|
|
20
|
+
theme = _this$get.theme,
|
|
21
|
+
visible = _this$get.visible,
|
|
22
|
+
maskClosable = _this$get.maskClosable,
|
|
23
|
+
doneText = _this$get.doneText,
|
|
24
|
+
closable = _this$get.closable;
|
|
25
|
+
var k = this.config.k;
|
|
26
|
+
var currentValue = value !== undefined ? value : 0;
|
|
27
|
+
var _this$arrow = this.arrow,
|
|
28
|
+
arrowType = _this$arrow.arrowType,
|
|
29
|
+
arrowRef = _this$arrow.arrowRef;
|
|
30
|
+
var highlightRef = this.highlight.highlightRef;
|
|
31
|
+
var _this$navigation = this.navigation,
|
|
32
|
+
prev = _this$navigation.prev,
|
|
33
|
+
next = _this$navigation.next,
|
|
34
|
+
finish = _this$navigation.finish;
|
|
35
|
+
var getTotalSteps = this.steps.getTotalSteps;
|
|
36
|
+
var contextValue = {
|
|
37
|
+
value: value || 0,
|
|
38
|
+
total: getTotalSteps(),
|
|
39
|
+
doneText: doneText,
|
|
40
|
+
closable: closable,
|
|
41
|
+
onPrev: prev,
|
|
42
|
+
onNext: next,
|
|
43
|
+
onFinish: finish
|
|
44
|
+
};
|
|
45
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-tour"] = true, _classNameObj[k + "-" + theme] = true, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
46
|
+
return visible ? _$cv('div', _extends({
|
|
47
|
+
'className': _$cn(classNameObj)
|
|
48
|
+
}, getRestProps(this)), _$cc(TourContext.Provider, {
|
|
49
|
+
'value': contextValue,
|
|
50
|
+
'children': [null, currentValue !== undefined ? _$ce(2, 'div', null, 1, _$cn((_$cn2 = {}, _$cn2[k + "-tour-target-highlight"] = true, _$cn2[k + "-hoverable"] = hoverable, _$cn2)), null, null, highlightRef) : undefined, null, _$ce(2, 'div', [!children ? _$ma(data, function ($value, $key) {
|
|
51
|
+
return $key === currentValue ? _$cc(TourStep, _extends({
|
|
52
|
+
'key': $key
|
|
53
|
+
}, $value), $key) : undefined;
|
|
54
|
+
}, $this) : mapChildren(children, function (vNode, index) {
|
|
55
|
+
if (isComponentVNode(vNode, TourStep)) {
|
|
56
|
+
if (index === currentValue) {
|
|
57
|
+
return vNode;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}), null, showArrow && arrowType.value ? _$ce(2, 'i', null, 1, _$cn((_$cn3 = {}, _$cn3[k + "-tour-arrow"] = true, _$cn3[k + "-" + arrowType.value] = arrowType.value, _$cn3)), null, null, arrowRef) : undefined], 0, _$cn(k + "-tour-step-wrapper"), {
|
|
62
|
+
'ev-click': stopPropagation
|
|
63
|
+
}, null, this.tourRef)]
|
|
64
|
+
})) : undefined;
|
|
65
|
+
}
|
|
66
|
+
;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useInstance, createRef, nextTick } from 'intact';
|
|
2
|
+
import { useState } from '../../hooks/useState';
|
|
3
|
+
import { clamp } from '../utils';
|
|
4
|
+
export function useArrow() {
|
|
5
|
+
var instance = useInstance();
|
|
6
|
+
var arrowType = useState(null);
|
|
7
|
+
var arrowRef = createRef();
|
|
8
|
+
// 监听positioned事件
|
|
9
|
+
instance.on('positioned', function (feedback) {
|
|
10
|
+
updateArrow(feedback);
|
|
11
|
+
});
|
|
12
|
+
// update arrow position and type
|
|
13
|
+
function updateArrow(feedback) {
|
|
14
|
+
if (!instance.get('showArrow')) return;
|
|
15
|
+
arrowType.set(feedback[feedback.important]);
|
|
16
|
+
nextTick(function () {
|
|
17
|
+
if (instance.$unmounted) return;
|
|
18
|
+
var arrow = arrowRef.value;
|
|
19
|
+
var target = feedback.target,
|
|
20
|
+
element = feedback.element;
|
|
21
|
+
if (feedback.important === 'vertical') {
|
|
22
|
+
// vertical important, adjust horizontal position
|
|
23
|
+
var arrowWidth = arrow.offsetWidth;
|
|
24
|
+
var left = target.left - element.left + (target.width - arrowWidth) / 2;
|
|
25
|
+
left = clamp(left, 1, element.width - 1 - arrowWidth);
|
|
26
|
+
arrow.setAttribute('style', "left: " + left + "px");
|
|
27
|
+
} else {
|
|
28
|
+
// horizontal important, adjust vertical position
|
|
29
|
+
var arrowHeight = arrow.offsetHeight;
|
|
30
|
+
var top = target.top - element.top + target.height / 2 - arrowHeight / 2;
|
|
31
|
+
top = clamp(top, 1, element.height - 1 - arrowHeight);
|
|
32
|
+
arrow.setAttribute('style', "top: " + top + "px");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
arrowType: arrowType,
|
|
38
|
+
arrowRef: arrowRef
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useInstance } from 'intact';
|
|
2
|
+
import { useFixBody as useFixBodyHook } from '../../hooks/useFixBody';
|
|
3
|
+
export function useFixBody() {
|
|
4
|
+
var instance = useInstance();
|
|
5
|
+
var fixBodyHook = useFixBodyHook();
|
|
6
|
+
instance.watch('visible', function (visible) {
|
|
7
|
+
if (visible) {
|
|
8
|
+
fixBodyHook.onOpen();
|
|
9
|
+
} else {
|
|
10
|
+
fixBodyHook.onClose();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
onOpen: fixBodyHook.onOpen,
|
|
15
|
+
onClosed: fixBodyHook.onClose
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useInstance, createRef, nextTick } from 'intact';
|
|
2
|
+
export function useHighlight(getTargetElement) {
|
|
3
|
+
var instance = useInstance();
|
|
4
|
+
var highlightRef = createRef();
|
|
5
|
+
instance.on('$updated', updateHighlight);
|
|
6
|
+
instance.watch('visible', function (visible) {
|
|
7
|
+
if (visible) {
|
|
8
|
+
nextTick(function () {
|
|
9
|
+
updateHighlight();
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
// update highlight element position and size
|
|
14
|
+
function updateHighlight() {
|
|
15
|
+
var highlightElem = highlightRef.value;
|
|
16
|
+
var targetElem = getTargetElement();
|
|
17
|
+
if (highlightElem && targetElem) {
|
|
18
|
+
var rect = targetElem.getBoundingClientRect();
|
|
19
|
+
var padding = 8;
|
|
20
|
+
highlightElem.style.width = rect.width + padding * 2 + "px";
|
|
21
|
+
highlightElem.style.height = rect.height + padding * 2 + "px";
|
|
22
|
+
highlightElem.style.position = 'fixed';
|
|
23
|
+
highlightElem.style.left = rect.left - padding + "px";
|
|
24
|
+
highlightElem.style.top = rect.top - padding + "px";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
highlightRef: highlightRef,
|
|
29
|
+
updateHighlight: updateHighlight
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMaskClosable(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useInstance } from "intact";
|
|
2
|
+
import { useDocumentClick } from "../../hooks/useDocumentClick";
|
|
3
|
+
export function useMaskClosable() {
|
|
4
|
+
var tour = useInstance();
|
|
5
|
+
var _useDocumentClick = useDocumentClick(tour.tourRef, function (e) {
|
|
6
|
+
var maskClosable = tour.get('maskClosable');
|
|
7
|
+
if (maskClosable) {
|
|
8
|
+
// 检查点击的是否是当前目标元素或其子元素
|
|
9
|
+
var targetElement = tour.steps.getTargetElement();
|
|
10
|
+
if (targetElement && (e.target === targetElement || targetElement.contains(e.target))) {
|
|
11
|
+
return; // 点击的是目标元素,不关闭
|
|
12
|
+
}
|
|
13
|
+
tour.navigation.finish();
|
|
14
|
+
}
|
|
15
|
+
}, true),
|
|
16
|
+
addDocumentClick = _useDocumentClick[0],
|
|
17
|
+
removeDocumentClick = _useDocumentClick[1];
|
|
18
|
+
tour.watch('visible', function (visible) {
|
|
19
|
+
if (visible) {
|
|
20
|
+
addDocumentClick();
|
|
21
|
+
} else {
|
|
22
|
+
removeDocumentClick();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
|
+
import { useInstance } from 'intact';
|
|
4
|
+
export function useNavigation(getTotalSteps) {
|
|
5
|
+
var instance = useInstance();
|
|
6
|
+
function prev() {
|
|
7
|
+
return _prev.apply(this, arguments);
|
|
8
|
+
}
|
|
9
|
+
function _prev() {
|
|
10
|
+
_prev = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
11
|
+
var _instance$get, value, beforeChange, canChange;
|
|
12
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
13
|
+
while (1) switch (_context.prev = _context.next) {
|
|
14
|
+
case 0:
|
|
15
|
+
_instance$get = instance.get(), value = _instance$get.value, beforeChange = _instance$get.beforeChange;
|
|
16
|
+
if (!(value === undefined || value <= 0)) {
|
|
17
|
+
_context.next = 3;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return _context.abrupt("return");
|
|
21
|
+
case 3:
|
|
22
|
+
if (!beforeChange) {
|
|
23
|
+
_context.next = 9;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
_context.next = 6;
|
|
27
|
+
return beforeChange(value - 1);
|
|
28
|
+
case 6:
|
|
29
|
+
canChange = _context.sent;
|
|
30
|
+
if (!(canChange === false)) {
|
|
31
|
+
_context.next = 9;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
return _context.abrupt("return");
|
|
35
|
+
case 9:
|
|
36
|
+
instance.set('value', value - 1);
|
|
37
|
+
instance.trigger('prev', value - 1);
|
|
38
|
+
case 11:
|
|
39
|
+
case "end":
|
|
40
|
+
return _context.stop();
|
|
41
|
+
}
|
|
42
|
+
}, _callee);
|
|
43
|
+
}));
|
|
44
|
+
return _prev.apply(this, arguments);
|
|
45
|
+
}
|
|
46
|
+
function next() {
|
|
47
|
+
return _next.apply(this, arguments);
|
|
48
|
+
}
|
|
49
|
+
function _next() {
|
|
50
|
+
_next = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
51
|
+
var _instance$get2, value, beforeChange, steps, canChange;
|
|
52
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
53
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
_instance$get2 = instance.get(), value = _instance$get2.value, beforeChange = _instance$get2.beforeChange;
|
|
56
|
+
if (!(value === undefined)) {
|
|
57
|
+
_context2.next = 3;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
return _context2.abrupt("return");
|
|
61
|
+
case 3:
|
|
62
|
+
steps = getTotalSteps();
|
|
63
|
+
if (!(value >= steps - 1)) {
|
|
64
|
+
_context2.next = 7;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
finish();
|
|
68
|
+
return _context2.abrupt("return");
|
|
69
|
+
case 7:
|
|
70
|
+
if (!beforeChange) {
|
|
71
|
+
_context2.next = 13;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context2.next = 10;
|
|
75
|
+
return beforeChange(value + 1);
|
|
76
|
+
case 10:
|
|
77
|
+
canChange = _context2.sent;
|
|
78
|
+
if (!(canChange === false)) {
|
|
79
|
+
_context2.next = 13;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
return _context2.abrupt("return");
|
|
83
|
+
case 13:
|
|
84
|
+
instance.set('value', value + 1);
|
|
85
|
+
instance.trigger('next', value + 1);
|
|
86
|
+
case 15:
|
|
87
|
+
case "end":
|
|
88
|
+
return _context2.stop();
|
|
89
|
+
}
|
|
90
|
+
}, _callee2);
|
|
91
|
+
}));
|
|
92
|
+
return _next.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
function finish() {
|
|
95
|
+
instance.trigger('finish');
|
|
96
|
+
instance.set('visible', false);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
prev: prev,
|
|
100
|
+
next: next,
|
|
101
|
+
finish: finish
|
|
102
|
+
};
|
|
103
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RefObject } from 'intact';
|
|
2
|
+
import { Options as PositionOptions } from '../position';
|
|
3
|
+
export declare function usePosition(stepRef: RefObject<HTMLDivElement>, getTargetElement: (index?: number) => HTMLElement | null): {
|
|
4
|
+
getPositionOptions: (index?: number) => PositionOptions;
|
|
5
|
+
updatePosition: () => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import { useInstance, onMounted, nextTick } from 'intact';
|
|
3
|
+
import { position } from '../position';
|
|
4
|
+
var CENTER_POSITION_OPTIONS = {
|
|
5
|
+
my: 'center center',
|
|
6
|
+
at: 'center center',
|
|
7
|
+
collision: 'none'
|
|
8
|
+
};
|
|
9
|
+
export function usePosition(stepRef, getTargetElement) {
|
|
10
|
+
var instance = useInstance();
|
|
11
|
+
instance.watch('value', function (value) {
|
|
12
|
+
if (value !== undefined && value >= 0) {
|
|
13
|
+
nextTick(function () {
|
|
14
|
+
return updatePosition();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
instance.watch('visible', function (visible) {
|
|
19
|
+
if (visible) {
|
|
20
|
+
updatePosition();
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
presented: true
|
|
24
|
+
});
|
|
25
|
+
onMounted(function () {
|
|
26
|
+
updatePosition();
|
|
27
|
+
});
|
|
28
|
+
// get position options
|
|
29
|
+
function getPositionOptions(index) {
|
|
30
|
+
var currentIndex = index !== undefined ? index : instance.get('value') || 0;
|
|
31
|
+
var positionConfig;
|
|
32
|
+
var _instance$get = instance.get(),
|
|
33
|
+
data = _instance$get.data;
|
|
34
|
+
if (data && data[currentIndex]) {
|
|
35
|
+
positionConfig = data[currentIndex].position;
|
|
36
|
+
}
|
|
37
|
+
if (!positionConfig && instance.steps.steps[currentIndex]) {
|
|
38
|
+
var _instance$steps$steps;
|
|
39
|
+
positionConfig = (_instance$steps$steps = instance.steps.steps[currentIndex].props) == null ? void 0 : _instance$steps$steps.position;
|
|
40
|
+
}
|
|
41
|
+
if (!positionConfig) {
|
|
42
|
+
positionConfig = 'bottom';
|
|
43
|
+
}
|
|
44
|
+
if (typeof positionConfig === 'string') {
|
|
45
|
+
switch (positionConfig) {
|
|
46
|
+
case 'left':
|
|
47
|
+
return {
|
|
48
|
+
my: 'right-20 center',
|
|
49
|
+
at: 'left center',
|
|
50
|
+
collision: 'flipfit'
|
|
51
|
+
};
|
|
52
|
+
case 'bottom':
|
|
53
|
+
return {
|
|
54
|
+
my: 'center top+20',
|
|
55
|
+
at: 'center bottom',
|
|
56
|
+
collision: 'flipfit'
|
|
57
|
+
};
|
|
58
|
+
case 'right':
|
|
59
|
+
return {
|
|
60
|
+
my: 'left+20 center',
|
|
61
|
+
at: 'right center',
|
|
62
|
+
collision: 'flipfit'
|
|
63
|
+
};
|
|
64
|
+
case 'top':
|
|
65
|
+
default:
|
|
66
|
+
return {
|
|
67
|
+
my: 'center bottom-20',
|
|
68
|
+
at: 'center top',
|
|
69
|
+
collision: 'flipfit'
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return positionConfig;
|
|
74
|
+
}
|
|
75
|
+
// update position
|
|
76
|
+
function updatePosition() {
|
|
77
|
+
var stepElement = stepRef.value;
|
|
78
|
+
if (!stepElement) return;
|
|
79
|
+
var targetElement = getTargetElement();
|
|
80
|
+
var positionOptions = targetElement ? getPositionOptions() : CENTER_POSITION_OPTIONS;
|
|
81
|
+
var ofElement = targetElement || window;
|
|
82
|
+
position(stepElement, _extends({}, positionOptions, {
|
|
83
|
+
of: ofElement,
|
|
84
|
+
using: function using(feedback, pos) {
|
|
85
|
+
instance.trigger('positioned', feedback);
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
getPositionOptions: getPositionOptions,
|
|
91
|
+
updatePosition: updatePosition
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _Map from "@babel/runtime-corejs3/core-js/map";
|
|
2
|
+
import { useInstance } from 'intact';
|
|
3
|
+
import { TourStep } from './step';
|
|
4
|
+
import { isComponentVNode } from '../utils';
|
|
5
|
+
export function useSteps() {
|
|
6
|
+
var instance = useInstance();
|
|
7
|
+
var steps = [];
|
|
8
|
+
var targetElements = new _Map();
|
|
9
|
+
instance.on('$receive:children', collectSteps);
|
|
10
|
+
instance.watch('data', function () {
|
|
11
|
+
targetElements.clear();
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* 收集子组件步骤
|
|
15
|
+
*/
|
|
16
|
+
function collectSteps(children) {
|
|
17
|
+
steps.length = 0;
|
|
18
|
+
if (!children) return;
|
|
19
|
+
var childrenArray = Array.isArray(children) ? children : [children];
|
|
20
|
+
childrenArray.forEach(function (child) {
|
|
21
|
+
if (child && isComponentVNode(child, TourStep)) {
|
|
22
|
+
steps.push(child);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function getTotalSteps() {
|
|
27
|
+
var _instance$get = instance.get(),
|
|
28
|
+
data = _instance$get.data,
|
|
29
|
+
children = _instance$get.children;
|
|
30
|
+
if (children) {
|
|
31
|
+
return steps.length;
|
|
32
|
+
}
|
|
33
|
+
return (data || []).length;
|
|
34
|
+
}
|
|
35
|
+
// get current step target element
|
|
36
|
+
function getTargetElement(index) {
|
|
37
|
+
var currentIndex = index !== undefined ? index : instance.get('value') || 0;
|
|
38
|
+
if (targetElements.has(currentIndex)) {
|
|
39
|
+
return targetElements.get(currentIndex) || null;
|
|
40
|
+
}
|
|
41
|
+
var target;
|
|
42
|
+
// get target from data
|
|
43
|
+
var data = instance.get('data');
|
|
44
|
+
if (data && data[currentIndex]) {
|
|
45
|
+
target = data[currentIndex].target;
|
|
46
|
+
}
|
|
47
|
+
// get target from children
|
|
48
|
+
if (!target && steps[currentIndex]) {
|
|
49
|
+
var _steps$currentIndex$p;
|
|
50
|
+
target = (_steps$currentIndex$p = steps[currentIndex].props) == null ? void 0 : _steps$currentIndex$p.target;
|
|
51
|
+
}
|
|
52
|
+
if (!target) return null;
|
|
53
|
+
var element = null;
|
|
54
|
+
if (typeof target === 'string') {
|
|
55
|
+
element = document.querySelector(target);
|
|
56
|
+
} else {
|
|
57
|
+
element = target;
|
|
58
|
+
}
|
|
59
|
+
targetElements.set(currentIndex, element);
|
|
60
|
+
return element;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
steps: steps,
|
|
64
|
+
collectSteps: collectSteps,
|
|
65
|
+
getTotalSteps: getTotalSteps,
|
|
66
|
+
getTargetElement: getTargetElement
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -46,10 +46,12 @@ export function useChecked(getNodes) {
|
|
|
46
46
|
needRecheckNodes.forEach(function (node) {
|
|
47
47
|
updateUpward(node);
|
|
48
48
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (instance.get('checkbox')) {
|
|
50
|
+
var oldCheckedKeys = instance.get('checkedKeys');
|
|
51
|
+
var newCheckedKeys = _Array$from(checkedKeys);
|
|
52
|
+
if (!isEqualArray(oldCheckedKeys, newCheckedKeys)) {
|
|
53
|
+
instance.set('checkedKeys', newCheckedKeys);
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
function updateCheckedKeys(node) {
|