@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,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 禁用关闭图标
|
|
3
|
+
order: 7
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```vdt
|
|
7
|
+
import {Tour, Button, Switch} from 'kpc';
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<div class="example-container">
|
|
11
|
+
<Button id="closabelDemo">目标元素1</Button>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<Tour
|
|
15
|
+
v-model="currentStep"
|
|
16
|
+
visible={this.get('showTour')}
|
|
17
|
+
data={this.get('tourData')}
|
|
18
|
+
closable={this.get('closable')}
|
|
19
|
+
ev-finish={this.finishTour}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<div style="margin-top: 20px;">
|
|
23
|
+
<div style="margin-bottom: 10px;">
|
|
24
|
+
<Switch v-model="closable" />
|
|
25
|
+
<span style="margin-left: 10px;">关闭图标: {this.get('closable') ? '启用' : '禁用'}</span>
|
|
26
|
+
</div>
|
|
27
|
+
<Button ev-click={this.startTour}>
|
|
28
|
+
启动引导
|
|
29
|
+
</Button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import {bind} from 'kpc';
|
|
36
|
+
|
|
37
|
+
export default class extends Component {
|
|
38
|
+
static template = template;
|
|
39
|
+
static defaults() {
|
|
40
|
+
return {
|
|
41
|
+
currentStep: 0,
|
|
42
|
+
showTour: false,
|
|
43
|
+
closable: false,
|
|
44
|
+
tourData: [
|
|
45
|
+
{
|
|
46
|
+
target: '#closabelDemo',
|
|
47
|
+
title: '禁用关闭图标',
|
|
48
|
+
content: '当closable为true时,header区域关闭图标隐藏',
|
|
49
|
+
position: 'right'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@bind
|
|
56
|
+
startTour() {
|
|
57
|
+
this.set({
|
|
58
|
+
showTour: true,
|
|
59
|
+
currentStep: 0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@bind
|
|
64
|
+
finishTour() {
|
|
65
|
+
this.set({
|
|
66
|
+
showTour: false
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义内容
|
|
3
|
+
order: 2
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通过使用`TourStep`组件的block,可以自定义引导步骤的内容。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tour, TourStep, Button, Icon} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<div class="example-container">
|
|
13
|
+
<Button id="btn5">示例元素</Button>
|
|
14
|
+
</div>
|
|
15
|
+
<Tour
|
|
16
|
+
v-model="currentStep"
|
|
17
|
+
visible={this.get('showTour')}
|
|
18
|
+
ev-finish={this.close}
|
|
19
|
+
>
|
|
20
|
+
<TourStep
|
|
21
|
+
target="#btn5"
|
|
22
|
+
position="bottom"
|
|
23
|
+
>
|
|
24
|
+
<b:header>
|
|
25
|
+
<div style="display: flex; align-items: center">
|
|
26
|
+
<Icon class="ion-android-star" style="margin-right: 5px; color: #f0ad4e" />
|
|
27
|
+
<span class="custom-title">自定义标题</span>
|
|
28
|
+
<span style="margin-left: 8px; color: #999; font-size: 12px">带图标和样式</span>
|
|
29
|
+
</div>
|
|
30
|
+
</b:header>
|
|
31
|
+
<div class="custom-content">
|
|
32
|
+
<p>这是一个自定义的复杂内容,可以包含图片、链接等任何元素。</p>
|
|
33
|
+
<a href="javascript:;" style="color: #2d8cf0">了解更多</a>
|
|
34
|
+
</div>
|
|
35
|
+
<b:footer>
|
|
36
|
+
<div class="step-indicator">{this.get('currentStep') + 1} / 1</div>
|
|
37
|
+
<div class="custom-footer">
|
|
38
|
+
<Button size="small" type="danger" style="margin-right: 8px;" ev-click={this.close}>跳过</Button>
|
|
39
|
+
<Button size="small" type="primary" ev-click={this.close}>我知道了</Button>
|
|
40
|
+
</div>
|
|
41
|
+
</b:footer>
|
|
42
|
+
</TourStep>
|
|
43
|
+
</Tour>
|
|
44
|
+
<div style="margin-top: 20px;">
|
|
45
|
+
<Button ev-click={this.settour}>
|
|
46
|
+
启动自定义引导
|
|
47
|
+
</Button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import {bind} from 'kpc';
|
|
54
|
+
|
|
55
|
+
export default class extends Component {
|
|
56
|
+
static template = template;
|
|
57
|
+
static defaults() {
|
|
58
|
+
return {
|
|
59
|
+
currentStep: 0,
|
|
60
|
+
showTour: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@bind
|
|
65
|
+
settour() {
|
|
66
|
+
this.set({
|
|
67
|
+
showTour: true,
|
|
68
|
+
currentStep: 0
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@bind
|
|
73
|
+
close() {
|
|
74
|
+
this.set({
|
|
75
|
+
showTour: false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```styl
|
|
82
|
+
.custom-title
|
|
83
|
+
font-weight bold
|
|
84
|
+
color #2d8cf0
|
|
85
|
+
|
|
86
|
+
.custom-content
|
|
87
|
+
text-align center
|
|
88
|
+
padding 8px 0
|
|
89
|
+
|
|
90
|
+
.custom-footer
|
|
91
|
+
display flex
|
|
92
|
+
justify-content space-between
|
|
93
|
+
align-items center
|
|
94
|
+
width 100%
|
|
95
|
+
.k-btn
|
|
96
|
+
margin-right 8px
|
|
97
|
+
|
|
98
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义按钮文本
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
每个步骤可以单独设置按钮文本,实现更灵活的用户体验。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tour, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<div class="example-container">
|
|
13
|
+
<Button id="welcome-btn">欢迎页面</Button>
|
|
14
|
+
<Button id="feature-btn" style="margin-left: 20px;">功能介绍</Button>
|
|
15
|
+
<Button id="finish-btn" style="margin-left: 20px;">完成设置</Button>
|
|
16
|
+
</div>
|
|
17
|
+
<Tour
|
|
18
|
+
v-model="currentStep"
|
|
19
|
+
visible={this.get('showTour')}
|
|
20
|
+
data={this.get('tourData')}
|
|
21
|
+
doneText="完成"
|
|
22
|
+
ev-finish={this.close}
|
|
23
|
+
/>
|
|
24
|
+
<div style="margin-top: 20px;">
|
|
25
|
+
<Button type="primary" ev-click={this.startTour}>
|
|
26
|
+
开始自定义按钮引导
|
|
27
|
+
</Button>
|
|
28
|
+
<span style="margin-left: 10px;">
|
|
29
|
+
当前步骤: {this.get('currentStep') >= 0 ? this.get('currentStep') + 1 : '未启动'}
|
|
30
|
+
</span>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import {bind} from 'kpc';
|
|
37
|
+
|
|
38
|
+
export default class extends Component {
|
|
39
|
+
static template = template;
|
|
40
|
+
static defaults() {
|
|
41
|
+
return {
|
|
42
|
+
currentStep: 0,
|
|
43
|
+
showTour: false,
|
|
44
|
+
tourData: [
|
|
45
|
+
{
|
|
46
|
+
target: '#welcome-btn',
|
|
47
|
+
title: '欢迎使用!',
|
|
48
|
+
content: '欢迎来到我们的应用,让我们开始引导之旅吧!',
|
|
49
|
+
position: 'bottom',
|
|
50
|
+
nextText: '开始探索',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
target: '#feature-btn',
|
|
54
|
+
title: '功能介绍',
|
|
55
|
+
content: '这里是主要功能区域,您可以在这里进行各种操作。',
|
|
56
|
+
position: 'bottom',
|
|
57
|
+
nextText: '前进',
|
|
58
|
+
prevText: '回到开始',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
target: '#finish-btn',
|
|
62
|
+
title: '设置完成',
|
|
63
|
+
content: '恭喜!您已经完成了所有设置,现在可以开始使用了。',
|
|
64
|
+
position: 'top',
|
|
65
|
+
prevText: '返回上一步',
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@bind
|
|
72
|
+
startTour() {
|
|
73
|
+
this.set({
|
|
74
|
+
showTour: true,
|
|
75
|
+
currentStep: 0
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@bind
|
|
80
|
+
close() {
|
|
81
|
+
this.set({
|
|
82
|
+
showTour: false
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```styl
|
|
89
|
+
.example-container
|
|
90
|
+
padding: 20px
|
|
91
|
+
border: 1px dashed #ddd
|
|
92
|
+
border-radius: 4px
|
|
93
|
+
margin-bottom: 20px
|
|
94
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 声明式用法
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
使用`TourStep`子组件可以声明式地定义引导步骤,更加灵活。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tour, TourStep, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<div class="example-container">
|
|
13
|
+
<Button id="btn3">示例元素1</Button>
|
|
14
|
+
<Button id="btn4" style="margin-left: 20px;">示例元素2</Button>
|
|
15
|
+
</div>
|
|
16
|
+
<Tour
|
|
17
|
+
v-model="currentStep"
|
|
18
|
+
visible={this.get('showTour')}
|
|
19
|
+
ev-finish={this.close}
|
|
20
|
+
>
|
|
21
|
+
<TourStep
|
|
22
|
+
target="#btn3"
|
|
23
|
+
title="第一步"
|
|
24
|
+
content="这是使用子组件方式的第一步说明"
|
|
25
|
+
position="left"
|
|
26
|
+
/>
|
|
27
|
+
<TourStep
|
|
28
|
+
target="#btn4"
|
|
29
|
+
title="第二步"
|
|
30
|
+
position="top"
|
|
31
|
+
>这是使用子组件方式的第二步说明</TourStep>
|
|
32
|
+
</Tour>
|
|
33
|
+
<div style="margin-top: 20px;">
|
|
34
|
+
<Button ev-click={this.settour}>
|
|
35
|
+
启动引导
|
|
36
|
+
</Button>
|
|
37
|
+
<span style="margin-left: 10px;">
|
|
38
|
+
当前步骤: {this.get('currentStep') >= 0 ? this.get('currentStep') + 1 : '未启动'}
|
|
39
|
+
</span>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import {bind} from 'kpc';
|
|
46
|
+
|
|
47
|
+
export default class extends Component {
|
|
48
|
+
static template = template;
|
|
49
|
+
static defaults() {
|
|
50
|
+
return {
|
|
51
|
+
currentStep: 0,
|
|
52
|
+
showTour: false, // 默认不显示
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@bind
|
|
57
|
+
settour() {
|
|
58
|
+
// 重置步骤并显示Tour
|
|
59
|
+
this.set({
|
|
60
|
+
showTour: true,
|
|
61
|
+
currentStep: 0
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@bind
|
|
66
|
+
close() {
|
|
67
|
+
this.set({
|
|
68
|
+
showTour: false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 事件处理
|
|
3
|
+
order: 5
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```vdt
|
|
7
|
+
import {Tour, Button, Message} from 'kpc';
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<div class="example-container">
|
|
11
|
+
<Button id="event-btn1">第一步</Button>
|
|
12
|
+
<Button id="event-btn2" style="margin-left: 20px;">第二步</Button>
|
|
13
|
+
<Button id="event-btn3" style="margin-left: 20px;">第三步</Button>
|
|
14
|
+
</div>
|
|
15
|
+
<Tour
|
|
16
|
+
v-model="currentStep"
|
|
17
|
+
visible={this.get('showTour')}
|
|
18
|
+
data={this.get('tourData')}
|
|
19
|
+
ev-prev={this.handlePrev}
|
|
20
|
+
ev-next={this.handleNext}
|
|
21
|
+
ev-finish={this.handleFinish}
|
|
22
|
+
/>
|
|
23
|
+
<div style="margin-top: 20px;">
|
|
24
|
+
<Button ev-click={this.startTour}>
|
|
25
|
+
开始引导
|
|
26
|
+
</Button>
|
|
27
|
+
<span style="margin-left: 10px;">
|
|
28
|
+
当前步骤: {this.get('currentStep') >= 0 ? this.get('currentStep') + 1 : '未启动'}
|
|
29
|
+
</span>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import {bind} from 'kpc';
|
|
36
|
+
import {Message} from 'kpc';
|
|
37
|
+
|
|
38
|
+
export default class extends Component {
|
|
39
|
+
static template = template;
|
|
40
|
+
static defaults() {
|
|
41
|
+
return {
|
|
42
|
+
currentStep: 0,
|
|
43
|
+
showTour: false,
|
|
44
|
+
tourData: [
|
|
45
|
+
{
|
|
46
|
+
target: '#event-btn1',
|
|
47
|
+
title: '第一步',
|
|
48
|
+
content: '点击"下一步"按钮,将触发next事件',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: '#event-btn2',
|
|
52
|
+
title: '第二步',
|
|
53
|
+
content: '点击"上一步"按钮,将触发prev事件',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
target: '#event-btn3',
|
|
57
|
+
title: '第三步',
|
|
58
|
+
content: '点击"完成"按钮或关闭图标,将触发finish事件',
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@bind
|
|
65
|
+
startTour() {
|
|
66
|
+
this.set({
|
|
67
|
+
showTour: true,
|
|
68
|
+
currentStep: 0,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@bind
|
|
73
|
+
handlePrev(index: number) {
|
|
74
|
+
Message.success(`上一步事件触发: 当前步骤 ${index + 1}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@bind
|
|
78
|
+
handleNext(index: number) {
|
|
79
|
+
Message.success(`下一步事件触发: 当前步骤 ${index + 1}`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@bind
|
|
83
|
+
handleFinish() {
|
|
84
|
+
Message.success('引导结束事件触发');
|
|
85
|
+
this.set({
|
|
86
|
+
showTour: false
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```styl
|
|
94
|
+
.event-log
|
|
95
|
+
margin-top 5px
|
|
96
|
+
padding 10px
|
|
97
|
+
border 1px solid #eee
|
|
98
|
+
border-radius 4px
|
|
99
|
+
max-height 150px
|
|
100
|
+
overflow-y auto
|
|
101
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 遮罩层交互
|
|
3
|
+
order: 5
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```vdt
|
|
7
|
+
import {Tour, Button, Switch} from 'kpc';
|
|
8
|
+
|
|
9
|
+
<div>
|
|
10
|
+
<div class="example-container">
|
|
11
|
+
<Button id="maskDemo1">目标元素1</Button>
|
|
12
|
+
<Button id="maskDemo2" style="margin-left: 20px;">目标元素2</Button>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<Tour
|
|
16
|
+
v-model="currentStep"
|
|
17
|
+
visible={this.get('showTour')}
|
|
18
|
+
data={this.get('tourData')}
|
|
19
|
+
maskClosable={this.get('maskClosable')}
|
|
20
|
+
ev-finish={this.finishTour}
|
|
21
|
+
/>
|
|
22
|
+
<div style="margin-top: 20px;">
|
|
23
|
+
<div style="margin-bottom: 10px;">
|
|
24
|
+
<Switch v-model="maskClosable" />
|
|
25
|
+
<span style="margin-left: 10px;">点击遮罩关闭引导: {this.get('maskClosable') ? '启用' : '禁用'}</span>
|
|
26
|
+
</div>
|
|
27
|
+
<Button ev-click={this.startTour}>
|
|
28
|
+
启动引导
|
|
29
|
+
</Button>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import {bind} from 'kpc';
|
|
36
|
+
|
|
37
|
+
export default class extends Component {
|
|
38
|
+
static template = template;
|
|
39
|
+
static defaults() {
|
|
40
|
+
return {
|
|
41
|
+
currentStep: 0,
|
|
42
|
+
showTour: false,
|
|
43
|
+
maskClosable: true,
|
|
44
|
+
tourData: [
|
|
45
|
+
{
|
|
46
|
+
target: '#maskDemo1',
|
|
47
|
+
title: '遮罩层交互',
|
|
48
|
+
content: '当maskClosable为true时,点击遮罩层可关闭引导',
|
|
49
|
+
position: 'bottom'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
target: '#maskDemo2',
|
|
53
|
+
title: '禁用遮罩层关闭',
|
|
54
|
+
content: '当maskClosable为false时,点击遮罩层无反应,必须使用按钮进行操作',
|
|
55
|
+
position: 'right'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@bind
|
|
62
|
+
startTour() {
|
|
63
|
+
this.set({
|
|
64
|
+
showTour: true,
|
|
65
|
+
currentStep: 0
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@bind
|
|
70
|
+
finishTour() {
|
|
71
|
+
this.set({
|
|
72
|
+
showTour: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 无目标元素
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
当没有指定目标元素或目标元素不存在时,Tour会居中显示。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Tour, TourStep, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Tour
|
|
13
|
+
v-model="currentStep"
|
|
14
|
+
visible={this.get('showTour')}
|
|
15
|
+
ev-finish={this.close}
|
|
16
|
+
>
|
|
17
|
+
<TourStep title="无目标元素-第一步">
|
|
18
|
+
<span>当没有指定target属性或者目标元素不存在时,Tour会居中显示在屏幕中央。</span>
|
|
19
|
+
</TourStep>
|
|
20
|
+
<TourStep title="无目标元素-第二步">
|
|
21
|
+
<span>当没有指定target属性或者目标元素不存在时,所有步骤都会居中显示在屏幕中央。</span>
|
|
22
|
+
</TourStep>
|
|
23
|
+
</Tour>
|
|
24
|
+
<div style="margin-top: 20px;">
|
|
25
|
+
<Button ev-click={this.settour}>
|
|
26
|
+
启动无目标引导
|
|
27
|
+
</Button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import {bind} from 'kpc';
|
|
34
|
+
|
|
35
|
+
export default class extends Component {
|
|
36
|
+
static template = template;
|
|
37
|
+
static defaults() {
|
|
38
|
+
return {
|
|
39
|
+
currentStep: 0,
|
|
40
|
+
showTour: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@bind
|
|
45
|
+
settour() {
|
|
46
|
+
this.set({
|
|
47
|
+
showTour: true,
|
|
48
|
+
currentStep: 0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@bind
|
|
53
|
+
close() {
|
|
54
|
+
this.set({
|
|
55
|
+
showTour: false
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 引导式导航
|
|
3
|
+
category: 组件
|
|
4
|
+
order: 99
|
|
5
|
+
sidebar: doc
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# 属性
|
|
9
|
+
|
|
10
|
+
## Tour
|
|
11
|
+
|
|
12
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| value | 当前显示的步骤索引,从0开始,可通过`v-model`双向绑定 | `number` | `0` |
|
|
15
|
+
| visible | 是否展示引导组件 | `boolean` | `true` |
|
|
16
|
+
| data | 步骤数据数组,用于数据驱动方式 | `TourStepData[]` | `undefined` |
|
|
17
|
+
| beforeChange | 步骤切换前的回调函数,返回false可阻止切换 | `(current: number) => boolean \| Promise<boolean>` | `undefined` |
|
|
18
|
+
| maskClosable | 点击遮罩层是否可关闭 | `boolean` | `false` |
|
|
19
|
+
| closable | 是否展示关闭图标 | `boolean` | `true` |
|
|
20
|
+
| doneText | 完成按钮文本 | `string` | `"完成"` |
|
|
21
|
+
|
|
22
|
+
## TourStep
|
|
23
|
+
|
|
24
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
25
|
+
| --- | --- | --- | --- |
|
|
26
|
+
| target | 目标元素,可以是CSS选择器或DOM元素 | `string \| HTMLElement` | `undefined` |
|
|
27
|
+
| title | 步骤标题 | `string \| VNode` | `undefined` |
|
|
28
|
+
| content | 步骤内容 | `string \| VNode` | `undefined` |
|
|
29
|
+
| nextText | 下一步按钮文本 | `string` | `"下一步"` |
|
|
30
|
+
| prevText | 上一步按钮文本 | `string` | `"上一步"` |
|
|
31
|
+
| position | 弹出位置,可选值:`top`、`right`、`bottom`、`left` | `string` | `"bottom"` |
|
|
32
|
+
|
|
33
|
+
# 事件
|
|
34
|
+
|
|
35
|
+
| 事件名 | 说明 | 参数 |
|
|
36
|
+
| --- | --- | --- |
|
|
37
|
+
| prev | 点击上一步按钮时触发 | `(index: number)` |
|
|
38
|
+
| next | 点击下一步按钮时触发 | `(index: number)` |
|
|
39
|
+
| finish | 引导完成时触发 | - |
|
|
40
|
+
|
|
41
|
+
# 扩展点
|
|
42
|
+
|
|
43
|
+
## TourStep
|
|
44
|
+
|
|
45
|
+
| 名称 | 说明 |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| title | 自定义标题内容 |
|
|
48
|
+
| footer | 自定义底部内容 |
|