@king-design/intact 3.6.2-beta.1 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/.DS_Store +0 -0
- package/components/anchor/constants.ts +3 -0
- package/components/anchor/demos/basic.md +34 -0
- package/components/anchor/demos/container.md +76 -0
- package/components/anchor/demos/events.md +100 -0
- package/components/anchor/demos/horizontal.md +33 -0
- package/components/anchor/demos/nested.md +132 -0
- package/components/anchor/index.md +38 -0
- package/components/anchor/index.spec.ts +171 -0
- package/components/anchor/index.ts +159 -0
- package/components/anchor/index.vdt +24 -0
- package/components/anchor/link.ts +44 -0
- package/components/anchor/link.vdt +49 -0
- package/components/anchor/styles.ts +50 -0
- package/components/anchor/useScroll.ts +221 -0
- package/components/config/demos/basic.md +11 -3
- package/components/descriptions/.DS_Store +0 -0
- package/components/dialog/base.vdt +3 -1
- package/components/drawer/demos/resizable.md +67 -0
- package/components/drawer/index.md +1 -0
- package/components/drawer/index.spec.ts +43 -0
- package/components/drawer/index.ts +14 -0
- package/components/drawer/index.vdt +20 -3
- package/components/drawer/styles.ts +44 -0
- package/components/drawer/useDrawerResizable.ts +190 -0
- package/components/icon/demos/color.md +1 -1
- package/components/icon/demos/icons.md +18 -0
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/components/menu/demos/collapse.md +2 -2
- package/components/menu/demos/showCollapseArrow.md +3 -3
- package/components/menu/demos/size.md +4 -4
- package/components/menu/styles.ts +7 -3
- package/components/notification/demos/basic.md +27 -0
- package/components/notification/demos/close.md +52 -0
- package/components/notification/demos/duration.md +43 -0
- package/components/notification/demos/events.md +39 -0
- package/components/notification/demos/hideClose.md +30 -0
- package/components/notification/demos/icon.md +47 -0
- package/components/notification/demos/position.md +39 -0
- package/components/notification/demos/types.md +38 -0
- package/components/notification/index.md +62 -0
- package/components/notification/index.spec.ts +211 -0
- package/components/notification/index.ts +2 -0
- package/components/notification/notification.ts +185 -0
- package/components/notification/notification.vdt +62 -0
- package/components/notification/notifications.ts +46 -0
- package/components/notification/notifications.vdt +16 -0
- package/components/notification/styles.ts +179 -0
- package/components/select/styles.ts +2 -0
- package/components/table/.DS_Store +0 -0
- package/components/table/demos/hidden.md +8 -2
- package/components/table/demos/sort.md +4 -4
- package/components/table/styles.ts +6 -2
- package/components/tabs/useActiveBar.ts +3 -3
- package/components/tag/base.ts +4 -0
- package/components/tag/demos/border.md +1 -1
- package/components/tag/demos/color.md +40 -0
- package/components/tag/demos/draggable.md +1 -1
- package/components/tag/demos/tags.md +1 -1
- package/components/tag/index.md +1 -0
- package/components/tag/index.spec.ts +8 -0
- package/components/tag/index.vdt +6 -4
- package/components/tag/styles.ts +23 -0
- package/components/tag/useColor.ts +79 -0
- package/components/timepicker/index.spec.ts +16 -5
- package/components/timepicker/useDefaultValue.ts +16 -7
- package/components/timepicker/useStep.ts +3 -2
- package/components/tour/.DS_Store +0 -0
- package/components/transfer/demos/customFilter.md +1 -1
- package/components/transfer/demos/customList.md +1 -1
- package/components/transfer/demos/getData.md +1 -1
- package/components/transfer/demos/leftChecked.md +1 -1
- package/components/transfer/demos/pagination.md +63 -0
- package/components/transfer/demos/table.md +248 -0
- package/components/transfer/demos/tree.md +1 -1
- package/components/transfer/index.md +2 -0
- package/components/transfer/index.spec.ts +147 -0
- package/components/transfer/index.ts +7 -0
- package/components/transfer/index.vdt +30 -4
- package/components/transfer/styles.ts +11 -1
- package/components/transfer/useCheck.ts +5 -5
- package/components/transfer/usePagination.ts +92 -0
- package/components/virtualList/.DS_Store +0 -0
- package/components/virtualList/demos/.DS_Store +0 -0
- package/dist/fonts/iconfont.eot +0 -0
- package/dist/fonts/iconfont.svg +235 -0
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/iconfont.woff2 +0 -0
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/fonts/ionicons.woff2 +0 -0
- package/dist/i18n/en-US.js +1411 -0
- package/dist/i18n/en-US.js.map +1 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/i18n/index.js +283 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.min.js +1 -0
- package/dist/kpc.js +50764 -0
- package/dist/kpc.js.map +1 -0
- package/dist/kpc.min.js +1 -0
- package/dist/kpc.react.js +58380 -0
- package/dist/kpc.react.js.map +1 -0
- package/dist/kpc.react.min.js +1 -0
- package/dist/kpc.tmp.js.map +1 -0
- package/dist/kpc.vue-legacy.js +58272 -0
- package/dist/kpc.vue-legacy.js.map +1 -0
- package/dist/kpc.vue-legacy.min.js +1 -0
- package/dist/kpc.vue.js +58128 -0
- package/dist/kpc.vue.js.map +1 -0
- package/dist/kpc.vue.min.js +1 -0
- package/es/components/anchor/constants.d.ts +2 -0
- package/es/components/anchor/constants.js +2 -0
- package/es/components/anchor/index.d.ts +41 -0
- package/es/components/anchor/index.js +141 -0
- package/es/components/anchor/index.spec.d.ts +1 -0
- package/es/components/anchor/index.spec.js +230 -0
- package/es/components/anchor/index.vdt.js +31 -0
- package/es/components/anchor/link.d.ts +16 -0
- package/es/components/anchor/link.js +52 -0
- package/es/components/anchor/link.vdt.js +49 -0
- package/es/components/anchor/styles.d.ts +5 -0
- package/es/components/anchor/styles.js +30 -0
- package/es/components/anchor/useScroll.d.ts +7 -0
- package/es/components/anchor/useScroll.js +218 -0
- package/es/components/dialog/base.vdt.js +1 -1
- package/es/components/drawer/index.d.ts +3 -0
- package/es/components/drawer/index.js +22 -3
- package/es/components/drawer/index.spec.js +83 -0
- package/es/components/drawer/index.vdt.js +23 -3
- package/es/components/drawer/styles.js +1 -1
- package/es/components/drawer/useDrawerResizable.d.ts +10 -0
- package/es/components/drawer/useDrawerResizable.js +162 -0
- package/es/components/menu/styles.d.ts +1 -0
- package/es/components/menu/styles.js +4 -1
- package/es/components/notification/index.d.ts +1 -0
- package/es/components/notification/index.js +1 -0
- package/es/components/notification/index.spec.d.ts +1 -0
- package/es/components/notification/index.spec.js +317 -0
- package/es/components/notification/notification.d.ts +39 -0
- package/es/components/notification/notification.js +183 -0
- package/es/components/notification/notification.vdt.js +56 -0
- package/es/components/notification/notifications.d.ts +16 -0
- package/es/components/notification/notifications.js +51 -0
- package/es/components/notification/notifications.vdt.js +24 -0
- package/es/components/notification/styles.d.ts +9 -0
- package/es/components/notification/styles.js +110 -0
- package/es/components/select/styles.js +1 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/tabs/useActiveBar.js +7 -3
- package/es/components/tag/base.d.ts +2 -0
- package/es/components/tag/base.js +3 -0
- package/es/components/tag/index.spec.js +17 -0
- package/es/components/tag/index.vdt.js +12 -5
- package/es/components/tag/styles.d.ts +9 -0
- package/es/components/tag/styles.js +14 -1
- package/es/components/tag/useColor.d.ts +7 -0
- package/es/components/tag/useColor.js +71 -0
- package/es/components/timepicker/index.spec.js +70 -42
- package/es/components/timepicker/useDefaultValue.js +12 -7
- package/es/components/timepicker/useStep.js +4 -2
- package/es/components/transfer/index.d.ts +13 -0
- package/es/components/transfer/index.js +6 -2
- package/es/components/transfer/index.spec.js +197 -0
- package/es/components/transfer/index.vdt.js +28 -5
- package/es/components/transfer/styles.js +4 -1
- package/es/components/transfer/useCheck.js +2 -1
- package/es/components/transfer/usePagination.d.ts +12 -0
- package/es/components/transfer/usePagination.js +79 -0
- package/es/index.d.ts +4 -2
- package/es/index.js +4 -2
- package/es/site/data/components/anchor/demos/basic/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/index.js +18 -0
- package/es/site/data/components/anchor/demos/basic/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/basic/react.js +46 -0
- package/es/site/data/components/anchor/demos/container/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/index.js +19 -0
- package/es/site/data/components/anchor/demos/container/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/container/react.js +52 -0
- package/es/site/data/components/anchor/demos/events/index.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/index.js +36 -0
- package/es/site/data/components/anchor/demos/events/react.d.ts +17 -0
- package/es/site/data/components/anchor/demos/events/react.js +88 -0
- package/es/site/data/components/anchor/demos/horizontal/index.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/index.js +18 -0
- package/es/site/data/components/anchor/demos/horizontal/react.d.ts +11 -0
- package/es/site/data/components/anchor/demos/horizontal/react.js +46 -0
- package/es/site/data/components/anchor/demos/nested/index.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/index.js +19 -0
- package/es/site/data/components/anchor/demos/nested/react.d.ts +12 -0
- package/es/site/data/components/anchor/demos/nested/react.js +100 -0
- package/es/site/data/components/anchor/index.d.ts +57 -0
- package/es/site/data/components/anchor/index.js +32 -0
- package/es/site/data/components/config/demos/basic/index.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/index.js +8 -1
- package/es/site/data/components/config/demos/basic/react.d.ts +1 -0
- package/es/site/data/components/config/demos/basic/react.js +15 -3
- package/es/site/data/components/drawer/demos/resizable/index.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/index.js +26 -0
- package/es/site/data/components/drawer/demos/resizable/react.d.ts +15 -0
- package/es/site/data/components/drawer/demos/resizable/react.js +63 -0
- package/es/site/data/components/icon/demos/icons/index.js +1 -1
- package/es/site/data/components/menu/demos/collapse/index.d.ts +6 -1
- package/es/site/data/components/menu/demos/collapse/react.d.ts +6 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/index.d.ts +8 -1
- package/es/site/data/components/menu/demos/showCollapseArrow/react.d.ts +8 -1
- package/es/site/data/components/menu/demos/size/index.d.ts +7 -2
- package/es/site/data/components/menu/demos/size/react.d.ts +7 -2
- package/es/site/data/components/notification/demos/basic/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/basic/index.js +21 -0
- package/es/site/data/components/notification/demos/basic/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/basic/react.js +24 -0
- package/es/site/data/components/notification/demos/close/index.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/index.js +38 -0
- package/es/site/data/components/notification/demos/close/react.d.ts +13 -0
- package/es/site/data/components/notification/demos/close/react.js +52 -0
- package/es/site/data/components/notification/demos/duration/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/duration/index.js +33 -0
- package/es/site/data/components/notification/demos/duration/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/duration/react.js +38 -0
- package/es/site/data/components/notification/demos/events/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/events/index.js +31 -0
- package/es/site/data/components/notification/demos/events/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/events/react.js +34 -0
- package/es/site/data/components/notification/demos/hideClose/index.d.ts +6 -0
- package/es/site/data/components/notification/demos/hideClose/index.js +25 -0
- package/es/site/data/components/notification/demos/hideClose/react.d.ts +5 -0
- package/es/site/data/components/notification/demos/hideClose/react.js +28 -0
- package/es/site/data/components/notification/demos/icon/index.d.ts +7 -0
- package/es/site/data/components/notification/demos/icon/index.js +33 -0
- package/es/site/data/components/notification/demos/icon/react.d.ts +6 -0
- package/es/site/data/components/notification/demos/icon/react.js +42 -0
- package/es/site/data/components/notification/demos/position/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/position/index.js +27 -0
- package/es/site/data/components/notification/demos/position/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/position/react.js +40 -0
- package/es/site/data/components/notification/demos/types/index.d.ts +9 -0
- package/es/site/data/components/notification/demos/types/index.js +26 -0
- package/es/site/data/components/notification/demos/types/react.d.ts +8 -0
- package/es/site/data/components/notification/demos/types/react.js +39 -0
- package/es/site/data/components/notification/index.d.ts +57 -0
- package/es/site/data/components/notification/index.js +32 -0
- package/es/site/data/components/table/demos/hidden/react.js +21 -3
- package/es/site/data/components/tag/demos/color/index.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/index.js +19 -0
- package/es/site/data/components/tag/demos/color/react.d.ts +10 -0
- package/es/site/data/components/tag/demos/color/react.js +34 -0
- package/es/site/data/components/transfer/demos/pagination/index.d.ts +19 -0
- package/es/site/data/components/transfer/demos/pagination/index.js +42 -0
- package/es/site/data/components/transfer/demos/pagination/react.d.ts +20 -0
- package/es/site/data/components/transfer/demos/pagination/react.js +65 -0
- package/es/site/data/components/transfer/demos/table/index.d.ts +33 -0
- package/es/site/data/components/transfer/demos/table/index.js +132 -0
- package/es/site/data/components/transfer/demos/table/react.d.ts +35 -0
- package/es/site/data/components/transfer/demos/table/react.js +246 -0
- package/es/site/src/router/index.js +4 -33
- package/es/styles/fonts/iconfont.eot +0 -0
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/fonts/iconfont.svg +38 -0
- package/es/styles/fonts/iconfont.ttf +0 -0
- package/es/styles/fonts/iconfont.woff +0 -0
- package/es/styles/fonts/iconfont.woff2 +0 -0
- package/es/styles/theme.d.ts +8 -0
- package/es/styles/theme.js +5 -1
- package/index.ts +4 -2
- package/package.json +2 -2
- package/styles/.DS_Store +0 -0
- package/styles/fonts/demo_index.html +443 -6
- package/styles/fonts/iconfont.css +82 -6
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.json +133 -0
- package/styles/fonts/iconfont.svg +38 -0
- package/styles/fonts/iconfont.ts +76 -0
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.ts +4 -0
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 基本用法
|
|
3
|
+
order: 0
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Anchor` 的基本用法。使用 `Anchor` 包裹多个 `AnchorLink`,每个 `AnchorLink` 的 `href` 对应页面中元素的 `id`。可以通过`Anchor`的`offset`属性,设置锚点的滚动偏移量。`AnchorLink`的`disabled`属性对应其`Tab`是否禁用。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Anchor, AnchorLink} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="anchor-demo">
|
|
12
|
+
<Anchor v-model="activeAnchor" offset={76}>
|
|
13
|
+
<AnchorLink href="components-anchor-demos-basic" title="基础用法" />
|
|
14
|
+
<AnchorLink href="components-anchor-demos-horizontal" title="水平排列" />
|
|
15
|
+
<AnchorLink href="components-anchor-demos-container" title="自定义滚动容器" disabled={true} />
|
|
16
|
+
</Anchor>
|
|
17
|
+
</div>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
interface Props {
|
|
22
|
+
activeAnchor?: string
|
|
23
|
+
}
|
|
24
|
+
export default class extends Component<Props> {
|
|
25
|
+
static template = template;
|
|
26
|
+
|
|
27
|
+
static defaults() {
|
|
28
|
+
return {
|
|
29
|
+
activeAnchor: '',
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义滚动容器
|
|
3
|
+
order: 2
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
使用 `container` 属性可以指定滚动容器,适用于内容在特定容器内滚动的情况。默认滚动容器为`window`。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Anchor, AnchorLink} from 'kpc';
|
|
10
|
+
import {createVNode as h} from 'intact';
|
|
11
|
+
|
|
12
|
+
<div class="anchor-demo">
|
|
13
|
+
<Anchor value={this.get('activeAnchor')} container="#scroll-container1">
|
|
14
|
+
<AnchorLink href="basic-info-card" title="基础信息" />
|
|
15
|
+
<AnchorLink href="config-info-card" title="配置信息" />
|
|
16
|
+
<AnchorLink href="other-info-card" title="其他信息" />
|
|
17
|
+
</Anchor>
|
|
18
|
+
|
|
19
|
+
<div id="scroll-container1" class="scroll-container1">
|
|
20
|
+
<div id="basic-info-card" class="section basic-info">
|
|
21
|
+
<h2>基础信息</h2>
|
|
22
|
+
<p>这是基础信息</p>
|
|
23
|
+
</div>
|
|
24
|
+
<div id="config-info-card" class="section config-info">
|
|
25
|
+
<h2>配置信息</h2>
|
|
26
|
+
<p>这是配置信息</p>
|
|
27
|
+
</div>
|
|
28
|
+
<div id="other-info-card" class="section other-info">
|
|
29
|
+
<h2>其他信息</h2>
|
|
30
|
+
<p>这是其他信息</p>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```styl
|
|
37
|
+
.anchor-demo
|
|
38
|
+
display flex
|
|
39
|
+
align-items flex-start
|
|
40
|
+
gap 20px
|
|
41
|
+
|
|
42
|
+
.scroll-container1
|
|
43
|
+
position relative
|
|
44
|
+
flex 1
|
|
45
|
+
height 300px
|
|
46
|
+
overflow-y auto
|
|
47
|
+
.section
|
|
48
|
+
padding 20px
|
|
49
|
+
height 300px
|
|
50
|
+
&.basic-info
|
|
51
|
+
background #dad4f4
|
|
52
|
+
&.config-info
|
|
53
|
+
background #ecdbeb
|
|
54
|
+
&.other-info
|
|
55
|
+
background #d3fdfa
|
|
56
|
+
h2
|
|
57
|
+
margin-top 0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import {bind} from 'kpc';
|
|
62
|
+
|
|
63
|
+
interface Props {
|
|
64
|
+
activeAnchor?: string
|
|
65
|
+
}
|
|
66
|
+
export default class extends Component<Props> {
|
|
67
|
+
static template = template;
|
|
68
|
+
|
|
69
|
+
static defaults() {
|
|
70
|
+
return {
|
|
71
|
+
activeAnchor: 'config-info-card',
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义事件回调
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Anchor` 组件提供了 `click` 和 `change` 事件。`click` 事件在点击锚点链接时触发,`change` 事件在锚点值改变时触发(点击锚点链接或者滑动容器至目标锚点都会触发`change`事件)。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Anchor, AnchorLink, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="anchor-demo">
|
|
12
|
+
<Anchor
|
|
13
|
+
v-model="activeAnchor"
|
|
14
|
+
vertical={false}
|
|
15
|
+
container="#scroll-container2"
|
|
16
|
+
ev-click={this.handleAnchorClick}
|
|
17
|
+
ev-change={this.handleAnchorChange}
|
|
18
|
+
>
|
|
19
|
+
<AnchorLink href="section_one" title="section1" />
|
|
20
|
+
<AnchorLink href="section_two" title="section2" />
|
|
21
|
+
<AnchorLink href="section_three" title="section3" />
|
|
22
|
+
</Anchor>
|
|
23
|
+
<div id="scroll-container2" class="scroll-container2">
|
|
24
|
+
<div id="section_one" class="section section1">
|
|
25
|
+
<h2>Section1</h2>
|
|
26
|
+
</div>
|
|
27
|
+
<div id="section_two" class="section section2">
|
|
28
|
+
<h2>Section2</h2>
|
|
29
|
+
</div>
|
|
30
|
+
<div id="section_three" class="section section3">
|
|
31
|
+
<h2>Section3</h2>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
<div v-if={this.get('logs').length} class="logs-container">
|
|
35
|
+
{this.get('logs').map((log, index) => <div key={index}>{log}</div>)}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```styl
|
|
41
|
+
.anchor-demo
|
|
42
|
+
display flex
|
|
43
|
+
flex-direction column
|
|
44
|
+
gap 20px
|
|
45
|
+
|
|
46
|
+
.scroll-container2
|
|
47
|
+
position relative
|
|
48
|
+
height 300px
|
|
49
|
+
overflow-y auto
|
|
50
|
+
|
|
51
|
+
.section
|
|
52
|
+
padding 20px
|
|
53
|
+
height 300px
|
|
54
|
+
&.section1
|
|
55
|
+
background #dad4f4
|
|
56
|
+
&.section2
|
|
57
|
+
background #ecdbeb
|
|
58
|
+
&.section3
|
|
59
|
+
background #d3fdfa
|
|
60
|
+
h2
|
|
61
|
+
margin-top 0
|
|
62
|
+
.logs-container
|
|
63
|
+
border 1px solid #ddd
|
|
64
|
+
border-radius 4px
|
|
65
|
+
max-height 100px
|
|
66
|
+
overflow-y auto
|
|
67
|
+
padding 8px
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import {bind, AnchorLinkProps} from 'kpc';
|
|
72
|
+
|
|
73
|
+
interface Props {
|
|
74
|
+
activeAnchor?: string
|
|
75
|
+
logs: string[]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default class extends Component<Props> {
|
|
79
|
+
static template = template;
|
|
80
|
+
|
|
81
|
+
static defaults() {
|
|
82
|
+
return {
|
|
83
|
+
activeAnchor: 'section_one',
|
|
84
|
+
logs: [],
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@bind
|
|
89
|
+
handleAnchorClick(e: MouseEvent, link: AnchorLinkProps) {
|
|
90
|
+
const logs = this.get('logs') || [];
|
|
91
|
+
this.set('logs', [...logs, `点击了锚点: title: ${link.title} href: ${link.href}`]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@bind
|
|
95
|
+
handleAnchorChange(href: string) {
|
|
96
|
+
const logs = this.get('logs') || [];
|
|
97
|
+
this.set('logs', [...logs, `锚点改变为: ${href}`])
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 水平排列
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`Tabs`默认垂直排列,可以设置`vertical`为`false`,实现`Tabs`水平排列。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Anchor, AnchorLink} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="anchor-demo">
|
|
12
|
+
<Anchor v-model="activeAnchor" offset={76} vertical={false}>
|
|
13
|
+
<AnchorLink href="components-anchor-demos-basic" title="基础用法" />
|
|
14
|
+
<AnchorLink href="components-anchor-demos-horizontal" title="水平排列" />
|
|
15
|
+
<AnchorLink href="components-anchor-demos-container" title="自定义滚动容器" />
|
|
16
|
+
</Anchor>
|
|
17
|
+
</div>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
interface Props {
|
|
22
|
+
activeAnchor?: string
|
|
23
|
+
}
|
|
24
|
+
export default class extends Component<Props> {
|
|
25
|
+
static template = template;
|
|
26
|
+
|
|
27
|
+
static defaults() {
|
|
28
|
+
return {
|
|
29
|
+
activeAnchor: '',
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 嵌套锚点
|
|
3
|
+
order: 4
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`AnchorLink` 支持嵌套子 `AnchorLink`,嵌套的锚点会自动缩进,形成清晰的层级关系。(横向 `Anchor`,不支持嵌套)
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Anchor, AnchorLink} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div class="anchor-demo">
|
|
12
|
+
<div id="scroll-container3" class="scroll-container3">
|
|
13
|
+
<div id="section1" class="section section1">
|
|
14
|
+
<h2>Part1</h2>
|
|
15
|
+
<p>这是Part1的内容</p>
|
|
16
|
+
<div id="section1-1" class="subsection">
|
|
17
|
+
<h3>Part1.1</h3>
|
|
18
|
+
<p>这是Part1.1</p>
|
|
19
|
+
</div>
|
|
20
|
+
<div id="section1-2" class="subsection">
|
|
21
|
+
<h3>Part1.2</h3>
|
|
22
|
+
<p>这是Part1.2的内容</p>
|
|
23
|
+
<div id="section1-2-1" class="subsubsection">
|
|
24
|
+
<h4>Part1.2.1</h4>
|
|
25
|
+
<p>这是Part1.2.1的内容</p>
|
|
26
|
+
</div>
|
|
27
|
+
<div id="section1-2-2" class="subsubsection">
|
|
28
|
+
<h4>Part1.2.2</h4>
|
|
29
|
+
<p>这是Part1.2.2的内容</p>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div id="section1-3" class="subsection">
|
|
33
|
+
<h3>Part1.3</h3>
|
|
34
|
+
<p>这是Part1.3的内容</p>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<div id="section2" class="section section2">
|
|
38
|
+
<h2>Part2</h2>
|
|
39
|
+
<p>这是Part2的内容</p>
|
|
40
|
+
<div id="section2-1" class="subsection">
|
|
41
|
+
<h3>Part2.1</h3>
|
|
42
|
+
<p>这是Part2.1的内容</p>
|
|
43
|
+
</div>
|
|
44
|
+
<div id="section2-2" class="subsection">
|
|
45
|
+
<h3>Part2.2</h3>
|
|
46
|
+
<p>这是Part2.2的内容</p>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div id="section3" class="section section3">
|
|
50
|
+
<h2>Part3</h2>
|
|
51
|
+
<p>这是Part3的内容</p>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<Anchor v-model="activeAnchor" container="#scroll-container3">
|
|
55
|
+
<AnchorLink href="section1" title="Part1">
|
|
56
|
+
<AnchorLink href="section1-1" title="Part1.1" />
|
|
57
|
+
<AnchorLink href="section1-2" title="Part1.2">
|
|
58
|
+
<AnchorLink href="section1-2-1" title="Part1.2.1" />
|
|
59
|
+
<AnchorLink href="section1-2-2" title="Part1.2.2" />
|
|
60
|
+
</AnchorLink>
|
|
61
|
+
<AnchorLink href="section1-3" title="Part1.3" />
|
|
62
|
+
</AnchorLink>
|
|
63
|
+
<AnchorLink href="section2" title="Part2">
|
|
64
|
+
<AnchorLink href="section2-1" title="Part2.1" />
|
|
65
|
+
<AnchorLink href="section2-2" title="Part2.2" />
|
|
66
|
+
</AnchorLink>
|
|
67
|
+
<AnchorLink href="section3" title="Part3" />
|
|
68
|
+
</Anchor>
|
|
69
|
+
</div>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```styl
|
|
73
|
+
.anchor-demo
|
|
74
|
+
display flex
|
|
75
|
+
align-items flex-start
|
|
76
|
+
gap 20px
|
|
77
|
+
|
|
78
|
+
.scroll-container3
|
|
79
|
+
flex 1
|
|
80
|
+
height 350px
|
|
81
|
+
overflow-y auto
|
|
82
|
+
|
|
83
|
+
.section
|
|
84
|
+
margin-bottom 40px
|
|
85
|
+
padding 20px
|
|
86
|
+
&.section1
|
|
87
|
+
background #f0f4ff
|
|
88
|
+
&.section2
|
|
89
|
+
background #fff0f4
|
|
90
|
+
&.section3
|
|
91
|
+
background #f4fff0
|
|
92
|
+
|
|
93
|
+
h2
|
|
94
|
+
margin-top 0
|
|
95
|
+
color #333
|
|
96
|
+
|
|
97
|
+
.subsection
|
|
98
|
+
margin 20px 0
|
|
99
|
+
padding 15px
|
|
100
|
+
background rgba(255, 255, 255, 0.6)
|
|
101
|
+
border-radius 4px
|
|
102
|
+
|
|
103
|
+
h3
|
|
104
|
+
margin-top 0
|
|
105
|
+
color #555
|
|
106
|
+
|
|
107
|
+
.subsubsection
|
|
108
|
+
margin 15px 0
|
|
109
|
+
padding 10px
|
|
110
|
+
background rgba(255, 255, 255, 0.8)
|
|
111
|
+
border-radius 4px
|
|
112
|
+
|
|
113
|
+
h4
|
|
114
|
+
margin-top 0
|
|
115
|
+
color #666
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
interface Props {
|
|
120
|
+
activeAnchor?: string
|
|
121
|
+
}
|
|
122
|
+
export default class extends Component<Props> {
|
|
123
|
+
static template = template;
|
|
124
|
+
|
|
125
|
+
static defaults() {
|
|
126
|
+
return {
|
|
127
|
+
activeAnchor: 'section1',
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 锚点
|
|
3
|
+
category: 组件
|
|
4
|
+
order: 91
|
|
5
|
+
sidebar: doc
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# 属性
|
|
9
|
+
|
|
10
|
+
## Anchor
|
|
11
|
+
|
|
12
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
13
|
+
| --- | --- | --- | --- |
|
|
14
|
+
| value | 当前激活的锚点ID,使用`v-model`进行双向绑定 | `string` | `undefined` |
|
|
15
|
+
| offset | 滚动偏移量,用于调整滚动位置(如 header 高度) | `number` | `0` |
|
|
16
|
+
| container | 滚动容器,可以是CSS选择器字符串或HTMLElement对象 | `string \| HTMLElement` | `window` |
|
|
17
|
+
| threshold | 激活阈值,提前多少像素激活锚点 | `number` | `50` |
|
|
18
|
+
| vertical | 是否垂直排列 | `boolean` | `true` |
|
|
19
|
+
| size | 放置锚点链接的`Tabs`尺寸 | `"large" \| "default" \| "small" \| "mini"` | `"default"` |
|
|
20
|
+
| duration | 点击锚点链接或设置value触发的容器滚动的持续时间,单位为毫秒 | `number` | `700` |
|
|
21
|
+
|
|
22
|
+
## AnchorLink
|
|
23
|
+
|
|
24
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
25
|
+
| --- | --- | --- | --- |
|
|
26
|
+
| href | 锚点ID(对应页面元素的id),不需要包含`#` | `string` | `undefined` |
|
|
27
|
+
| title | 显示文本 | `string` | `VNode` | `undefined` |
|
|
28
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
29
|
+
|
|
30
|
+
# 事件
|
|
31
|
+
|
|
32
|
+
## Anchor
|
|
33
|
+
|
|
34
|
+
| 事件名 | 说明 | 参数 |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| change | 锚点改变时触发 | `(href: string) => void` |
|
|
37
|
+
| click | 点击锚点时触发 | `(e: MouseEvent, props: AnchorLinkProps) => void` |
|
|
38
|
+
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import BasicDemo from '~/components/anchor/demos/basic';
|
|
2
|
+
import NestedDemo from '~/components/anchor/demos/nested';
|
|
3
|
+
import {mount, unmount, wait, dispatchEvent} from '../../test/utils';
|
|
4
|
+
import {Anchor, AnchorLink} from './';
|
|
5
|
+
import {Component} from 'intact';
|
|
6
|
+
|
|
7
|
+
// 基础 Demo
|
|
8
|
+
class BaseAnchorDemo extends Component {
|
|
9
|
+
static template = `
|
|
10
|
+
const {Anchor, AnchorLink} = this;
|
|
11
|
+
<div style="display: flex; gap: 20px; align-items: flex-start;">
|
|
12
|
+
<div id="scroll-container-test" style="flex: 1; height: 300px; overflow-y: auto;">
|
|
13
|
+
<div id="section1" style="height: 300px; padding: 20px;">Section 1</div>
|
|
14
|
+
<div id="section2" style="height: 300px; padding: 20px;">Section 2</div>
|
|
15
|
+
<div id="section3" style="height: 300px; padding: 20px;">Section 3</div>
|
|
16
|
+
</div>
|
|
17
|
+
<Anchor v-model="value" container="#scroll-container-test" {...this.getAnchorProps()}>
|
|
18
|
+
<AnchorLink href="section1" title="Section 1" />
|
|
19
|
+
<AnchorLink href="section2" title="Section 2" />
|
|
20
|
+
<AnchorLink href="section3" title="Section 3" />
|
|
21
|
+
</Anchor>
|
|
22
|
+
</div>
|
|
23
|
+
`;
|
|
24
|
+
Anchor = Anchor;
|
|
25
|
+
AnchorLink = AnchorLink;
|
|
26
|
+
|
|
27
|
+
getAnchorProps() {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static defaults() {
|
|
32
|
+
return {
|
|
33
|
+
value: 'section1'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('Anchor', () => {
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
unmount();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should render basic anchor correctly', async () => {
|
|
44
|
+
const [instance, element] = mount(BasicDemo);
|
|
45
|
+
|
|
46
|
+
await wait(200);
|
|
47
|
+
const anchor = element.querySelector('.k-anchor') as HTMLElement;
|
|
48
|
+
expect(anchor).to.exist;
|
|
49
|
+
expect(anchor.outerHTML).to.matchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should scroll to target position when clicking anchor link', async function() {
|
|
53
|
+
this.timeout(0);
|
|
54
|
+
|
|
55
|
+
class Demo extends BaseAnchorDemo {}
|
|
56
|
+
|
|
57
|
+
const [instance, element] = mount(Demo);
|
|
58
|
+
await wait(300);
|
|
59
|
+
|
|
60
|
+
const container = document.querySelector('#scroll-container-test') as HTMLElement;
|
|
61
|
+
const anchor = element.querySelector('.k-anchor') as HTMLElement;
|
|
62
|
+
const secondLink = anchor.querySelectorAll('.k-tab')[1] as HTMLElement;
|
|
63
|
+
const section2 = document.getElementById('section2')!;
|
|
64
|
+
|
|
65
|
+
// 先滚动到顶部
|
|
66
|
+
container.scrollTop = 0;
|
|
67
|
+
await wait(100);
|
|
68
|
+
|
|
69
|
+
const initialScrollTop = container.scrollTop;
|
|
70
|
+
|
|
71
|
+
// 点击第二个锚点链接
|
|
72
|
+
secondLink.click();
|
|
73
|
+
|
|
74
|
+
// 等待滚动动画完成
|
|
75
|
+
await wait(800);
|
|
76
|
+
|
|
77
|
+
// 检查容器是否滚动
|
|
78
|
+
const finalScrollTop = container.scrollTop;
|
|
79
|
+
expect(finalScrollTop).to.be.greaterThan(initialScrollTop);
|
|
80
|
+
|
|
81
|
+
// 检查 section2 是否在视口内或接近视口顶部
|
|
82
|
+
const rect = section2.getBoundingClientRect();
|
|
83
|
+
const containerRect = container.getBoundingClientRect();
|
|
84
|
+
expect(rect.top).to.be.lessThan(containerRect.bottom);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should update value when scrolling', async function() {
|
|
88
|
+
this.timeout(0);
|
|
89
|
+
|
|
90
|
+
class Demo extends BaseAnchorDemo {}
|
|
91
|
+
|
|
92
|
+
const [instance, element] = mount(Demo);
|
|
93
|
+
await wait(300);
|
|
94
|
+
|
|
95
|
+
const container = document.querySelector('#scroll-container-test') as HTMLElement;
|
|
96
|
+
|
|
97
|
+
const targetScrollTop = 300;
|
|
98
|
+
container.scrollTop = targetScrollTop;
|
|
99
|
+
|
|
100
|
+
dispatchEvent(container, 'scroll');
|
|
101
|
+
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
102
|
+
await wait(100);
|
|
103
|
+
|
|
104
|
+
expect(instance.get('value')).to.eql('section2');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should trigger change event', async function() {
|
|
108
|
+
this.timeout(0);
|
|
109
|
+
|
|
110
|
+
class Demo extends BaseAnchorDemo {
|
|
111
|
+
onChange = sinon.spy();
|
|
112
|
+
|
|
113
|
+
getAnchorProps() {
|
|
114
|
+
return {
|
|
115
|
+
'ev-change': this.onChange
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const [instance, element] = mount(Demo);
|
|
121
|
+
await wait(300);
|
|
122
|
+
|
|
123
|
+
const anchor = element.querySelector('.k-anchor') as HTMLElement;
|
|
124
|
+
const secondLink = anchor.querySelectorAll('.k-tab')[1] as HTMLElement;
|
|
125
|
+
|
|
126
|
+
secondLink.click();
|
|
127
|
+
await wait(300);
|
|
128
|
+
|
|
129
|
+
expect(instance.onChange.calledOnce).to.be.true;
|
|
130
|
+
expect(instance.onChange.calledWith('section2')).to.be.true;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should render nested anchor links correctly', async () => {
|
|
134
|
+
const [instance, element] = mount(NestedDemo);
|
|
135
|
+
|
|
136
|
+
await wait(200);
|
|
137
|
+
const anchor = element.querySelector('.k-anchor') as HTMLElement;
|
|
138
|
+
expect(anchor).to.exist;
|
|
139
|
+
|
|
140
|
+
const nestedLinks = anchor.querySelectorAll('.k-anchor-link-nested');
|
|
141
|
+
expect(nestedLinks.length).to.be.greaterThan(0);
|
|
142
|
+
expect(anchor.outerHTML).to.matchSnapshot();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should support disabled anchor link', async () => {
|
|
146
|
+
class Demo extends BaseAnchorDemo {
|
|
147
|
+
static template = `
|
|
148
|
+
const {Anchor, AnchorLink} = this;
|
|
149
|
+
<div style="display: flex; gap: 20px; align-items: flex-start;">
|
|
150
|
+
<div id="scroll-container-test" style="flex: 1; height: 300px; overflow-y: auto;">
|
|
151
|
+
<div id="section1" style="height: 300px; padding: 20px;">Section 1</div>
|
|
152
|
+
<div id="section2" style="height: 300px; padding: 20px;">Section 2</div>
|
|
153
|
+
</div>
|
|
154
|
+
<Anchor v-model="value" container="#scroll-container-test">
|
|
155
|
+
<AnchorLink href="section1" title="Section 1" />
|
|
156
|
+
<AnchorLink href="section2" title="Section 2" disabled={true} />
|
|
157
|
+
</Anchor>
|
|
158
|
+
</div>
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const [instance, element] = mount(Demo);
|
|
163
|
+
await wait(200);
|
|
164
|
+
|
|
165
|
+
const anchor = element.querySelector('.k-anchor') as HTMLElement;
|
|
166
|
+
const disabledLink = anchor.querySelectorAll('.k-tab')[1] as HTMLElement;
|
|
167
|
+
|
|
168
|
+
expect(disabledLink.className).to.include('k-disabled');
|
|
169
|
+
expect(anchor.outerHTML).to.matchSnapshot();
|
|
170
|
+
});
|
|
171
|
+
});
|