@king-design/intact 3.5.2 → 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/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 +146 -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/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/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 +235 -62
- 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/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/hooks/useFixBody.d.ts +11 -0
- package/es/hooks/useFixBody.js +72 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +3 -2
- package/es/site/data/components/datepicker/demos/multiple/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/hooks/useFixBody.ts +87 -0
- package/index.ts +3 -2
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Hooks = {
|
|
2
|
+
onStart?: (scrollBarWidth: number | undefined) => void;
|
|
3
|
+
onEnd?: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function useFixBody(): {
|
|
6
|
+
onOpen: () => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
readonly isFixed: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function setHooks(h: Hooks | null): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _Set from "@babel/runtime-corejs3/core-js/set";
|
|
2
|
+
import { useInstance, onBeforeUnmount } from 'intact';
|
|
3
|
+
import { scrollbarWidth } from '../components/position';
|
|
4
|
+
var instances = new _Set();
|
|
5
|
+
var originalStyle = null;
|
|
6
|
+
var hooks = null;
|
|
7
|
+
export function useFixBody() {
|
|
8
|
+
var instance = useInstance();
|
|
9
|
+
var fixedBody = false;
|
|
10
|
+
onBeforeUnmount(function () {
|
|
11
|
+
if (fixedBody) {
|
|
12
|
+
onClosed(instance);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function onOpen() {
|
|
16
|
+
if (!fixedBody) {
|
|
17
|
+
fixedBody = true;
|
|
18
|
+
onOpened(instance);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function onClose() {
|
|
22
|
+
if (fixedBody) {
|
|
23
|
+
fixedBody = false;
|
|
24
|
+
onClosed(instance);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
onOpen: onOpen,
|
|
29
|
+
onClose: onClose,
|
|
30
|
+
get isFixed() {
|
|
31
|
+
return fixedBody;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function setHooks(h) {
|
|
36
|
+
hooks = h;
|
|
37
|
+
}
|
|
38
|
+
function onOpened(instance) {
|
|
39
|
+
var body = document.body;
|
|
40
|
+
if (instances.size === 0) {
|
|
41
|
+
var bodyStyle = body.style;
|
|
42
|
+
originalStyle = body.getAttribute('style');
|
|
43
|
+
bodyStyle.overflow = 'hidden';
|
|
44
|
+
var scrollBarWidth = shouldFixBody();
|
|
45
|
+
if (scrollBarWidth) {
|
|
46
|
+
bodyStyle.paddingRight = scrollBarWidth + "px";
|
|
47
|
+
}
|
|
48
|
+
if (hooks && hooks.onStart) {
|
|
49
|
+
hooks.onStart(scrollBarWidth);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
instances.add(instance);
|
|
53
|
+
}
|
|
54
|
+
function onClosed(instance) {
|
|
55
|
+
var body = document.body;
|
|
56
|
+
instances.delete(instance);
|
|
57
|
+
if (instances.size === 0) {
|
|
58
|
+
if (originalStyle) {
|
|
59
|
+
body.setAttribute('style', originalStyle);
|
|
60
|
+
} else {
|
|
61
|
+
body.removeAttribute('style');
|
|
62
|
+
}
|
|
63
|
+
if (hooks && hooks.onEnd) {
|
|
64
|
+
hooks.onEnd();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function shouldFixBody() {
|
|
69
|
+
if (document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight)) {
|
|
70
|
+
return scrollbarWidth();
|
|
71
|
+
}
|
|
72
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v3.
|
|
2
|
+
* @king-design v3.6.0-beta.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Kingsoft Cloud
|
|
5
5
|
* Released under the MIT License
|
|
@@ -58,6 +58,7 @@ export * from './components/timeline';
|
|
|
58
58
|
export * from './components/timepicker';
|
|
59
59
|
export * from './components/tip';
|
|
60
60
|
export * from './components/tooltip';
|
|
61
|
+
export * from './components/tour';
|
|
61
62
|
export * from './components/transfer';
|
|
62
63
|
export * from './components/tree';
|
|
63
64
|
export * from './components/treeSelect';
|
|
@@ -65,4 +66,4 @@ export * from './components/upload';
|
|
|
65
66
|
export * from './components/view';
|
|
66
67
|
export * from './components/virtualList';
|
|
67
68
|
export * from './components/wave';
|
|
68
|
-
export declare const version = "3.
|
|
69
|
+
export declare const version = "3.6.0-beta.0";
|