@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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 隐藏关闭按钮
|
|
3
|
+
order: 4
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
设置`closable`为`false`即可隐藏关闭按钮
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<Button ev-click={this.hideClosable}>隐藏关闭按钮</Button>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import {Notification} from 'kpc';
|
|
16
|
+
import {bind} from 'kpc';
|
|
17
|
+
|
|
18
|
+
export default class extends Component {
|
|
19
|
+
static template = template;
|
|
20
|
+
|
|
21
|
+
@bind
|
|
22
|
+
hideClosable() {
|
|
23
|
+
Notification.info({
|
|
24
|
+
title: '隐藏关闭按钮',
|
|
25
|
+
content: '这条通知隐藏了关闭按钮',
|
|
26
|
+
closable: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义图标
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
可以通过`icon`属性自定义通知图标,支持传入组件库支持的`Icon`类名(string)或自定义`VNode`。当指定了四种`type`之一时,会优先使用`type`对应的图标。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button, Icon} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button ev-click={this.showNotificationIcon}>
|
|
13
|
+
<Icon class="k-icon-notification-fill" />
|
|
14
|
+
</Button>
|
|
15
|
+
<Button ev-click={this.showTimeIcon}>
|
|
16
|
+
<Icon class="k-icon-time" />
|
|
17
|
+
</Button>
|
|
18
|
+
</ButtonGroup>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import {Notification} from 'kpc';
|
|
23
|
+
import {bind} from 'kpc';
|
|
24
|
+
|
|
25
|
+
export default class extends Component {
|
|
26
|
+
static template = template;
|
|
27
|
+
|
|
28
|
+
@bind
|
|
29
|
+
showNotificationIcon() {
|
|
30
|
+
Notification.notice({
|
|
31
|
+
title: '自定义图标',
|
|
32
|
+
content: 'hello, kc',
|
|
33
|
+
icon: 'k-icon-notification-fill'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@bind
|
|
38
|
+
showTimeIcon() {
|
|
39
|
+
Notification.notice({
|
|
40
|
+
title: '自定义图标',
|
|
41
|
+
content: 'hello, kc',
|
|
42
|
+
icon: 'k-icon-time'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 弹出位置
|
|
3
|
+
order: 2
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
通过`position`属性可以设置通知出现的位置,支持六个位置:`topRight`、`topLeft`、`bottomRight`、`bottomLeft`、`top`(顶部中间)、`bottom`(底部中间)。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button v-for={this.get('positions')}
|
|
13
|
+
ev-click={this.showNotification.bind(this, $value)}
|
|
14
|
+
>{$value}</Button>
|
|
15
|
+
</ButtonGroup>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {Notification} from 'kpc';
|
|
20
|
+
|
|
21
|
+
export default class extends Component {
|
|
22
|
+
static template = template;
|
|
23
|
+
|
|
24
|
+
static defaults() {
|
|
25
|
+
return {
|
|
26
|
+
positions: ['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'] as const
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
showNotification(position: 'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom') {
|
|
31
|
+
Notification.info({
|
|
32
|
+
title: '通知标题',
|
|
33
|
+
content: `通知出现在${position}位置`,
|
|
34
|
+
position
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 不同类型的通知
|
|
3
|
+
order: 1
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
可以使用`Notification`提供的静态方法,展示通知,包括:`info`, `error`, `warning`, `success`;也可以使用`notice`静态方法,通过设置`type`属性来使用这四种类型。
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {ButtonGroup, Button} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<ButtonGroup>
|
|
12
|
+
<Button v-for={this.get('types')}
|
|
13
|
+
ev-click={this.showNotification.bind(this, $value)}
|
|
14
|
+
>{$value}</Button>
|
|
15
|
+
</ButtonGroup>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {Notification} from 'kpc';
|
|
20
|
+
|
|
21
|
+
export default class extends Component {
|
|
22
|
+
static template = template;
|
|
23
|
+
|
|
24
|
+
static defaults() {
|
|
25
|
+
return {
|
|
26
|
+
types: ['info', 'error', 'warning', 'success'] as const
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
showNotification(type: 'info' | 'error' | 'warning' | 'success') {
|
|
31
|
+
Notification[type]({
|
|
32
|
+
title: type,
|
|
33
|
+
content: `这是一条${type}类型的通知`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 通知提醒
|
|
3
|
+
category: 组件
|
|
4
|
+
order: 13
|
|
5
|
+
sidebar: doc
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
> 如果你在Vue下全局安装@king-design,可以通过`this.$notification`引用到`Notification`组件,所以你可以这样调用它的
|
|
9
|
+
> 方法:`this.$notification.success({ title: 'Test', content: 'test' })`
|
|
10
|
+
|
|
11
|
+
# 属性
|
|
12
|
+
|
|
13
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
14
|
+
| --- | --- | --- | --- |
|
|
15
|
+
| title | 通知标题 | `string` | `VNode` | `undefined` |
|
|
16
|
+
| content | 通知内容 | `string` | `VNode` | `undefined` |
|
|
17
|
+
| duration | 通知展示多长时间后自动关闭,当传入`0`时,通知将会一直展示。单位ms | `number` | `4500` |
|
|
18
|
+
| type | 通知类型 | `"info"` | `"error"` | `"success"` | `"warning"` | `""` | `""` |
|
|
19
|
+
| closable | 是否显示关闭按钮 | `boolean` | `true` |
|
|
20
|
+
| icon | 自定义图标,可以传入组件库支持的Icon类名(string)或自定义VNode。当指定了四种type之一时,会优先使用type对应的图标 | `string` | `VNode` | `undefined` |
|
|
21
|
+
| position | 通知位置 | `"topRight"` | `"topLeft"` | `"bottomRight"` | `"bottomLeft"` | `"top"` | `"bottom"` | `"topRight"` |
|
|
22
|
+
| className | 自定义类名 | `string` | `undefined` |
|
|
23
|
+
| onClick | 点击通知的回调函数 | `(e: MouseEvent) => void` | `undefined` |
|
|
24
|
+
| onClose | 通知关闭的回调函数(主动关闭、延时到达关闭都会触发) | `() => void` | `undefined` |
|
|
25
|
+
|
|
26
|
+
> **VNode 使用说明:** `title` 、 `content` 和 `icon` 属性都支持传入 `VNode`,可以实现更丰富的内容展示。需要注意:将 VNode 作为属性传给 KingDesign 组件时,需要使用 `normalize` 方法处理 VNode。详细用法请参考文档中在[各框架中使用的注意事项](/docs/vue/)。
|
|
27
|
+
|
|
28
|
+
# 静态方法
|
|
29
|
+
|
|
30
|
+
| 方法名 | 说明 | 参数 | 返回值 |
|
|
31
|
+
| --- | --- | --- | --- |
|
|
32
|
+
| notice | 显示通知 | <code>(props: Partial<NotificationProps>) => number</code> | 通知的唯一 ID |
|
|
33
|
+
| info | 信息通知 | <code>(props: Partial<NotificationProps>) => number</code> | 通知的唯一 ID |
|
|
34
|
+
| error | 错误通知 | <code>(props: Partial<NotificationProps>) => number</code> | 通知的唯一 ID |
|
|
35
|
+
| success | 成功通知 | <code>(props: Partial<NotificationProps>) => number</code> | 通知的唯一 ID |
|
|
36
|
+
| warning | 警告通知 | <code>(props: Partial<NotificationProps>) => number</code> | 通知的唯一 ID |
|
|
37
|
+
| close | 关闭指定 ID 的通知 | <code>(id: number) => void</code> | - |
|
|
38
|
+
|
|
39
|
+
参数说明:
|
|
40
|
+
|
|
41
|
+
| 参数名 | 说明 | 类型 | 默认值 |
|
|
42
|
+
| --- | --- | --- | --- |
|
|
43
|
+
| props | 通知配置对象 | `Partial<NotificationProps>` | - |
|
|
44
|
+
| id | 通知的唯一 ID,由 `notice`、`info`、`error`、`success`、`warning` 方法返回 | `number` | - |
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import {VNode} from 'intact';
|
|
48
|
+
|
|
49
|
+
export interface NotificationProps {
|
|
50
|
+
title?: string | VNode
|
|
51
|
+
content?: string | VNode
|
|
52
|
+
duration?: number
|
|
53
|
+
type?: 'info' | 'error' | 'success' | 'warning' | ''
|
|
54
|
+
closable?: boolean
|
|
55
|
+
icon?: string | VNode
|
|
56
|
+
position?: 'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom'
|
|
57
|
+
className?: string
|
|
58
|
+
onClick?: (e: MouseEvent) => void
|
|
59
|
+
onClose?: () => void
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import TypesDemo from '~/components/notification/demos/types';
|
|
2
|
+
import EventDemo from '~/components/notification/demos/events';
|
|
3
|
+
import {mount, unmount, dispatchEvent, getElement, wait, nextFrame} from '../../test/utils';
|
|
4
|
+
import {Notification} from './';
|
|
5
|
+
import {createVNode as h} from 'intact';
|
|
6
|
+
|
|
7
|
+
describe('Notification', () => {
|
|
8
|
+
afterEach(() => {unmount()});
|
|
9
|
+
|
|
10
|
+
it('show basic notification', async () => {
|
|
11
|
+
Notification.notice({
|
|
12
|
+
title: 'Hello, Kingcloud Design!',
|
|
13
|
+
content: '这是一条基础用法的通知'
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await wait();
|
|
17
|
+
const notification = getElement('.k-notification')!;
|
|
18
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('show notifications with different types', async () => {
|
|
22
|
+
const [instance, element] = mount(TypesDemo);
|
|
23
|
+
|
|
24
|
+
const [info, error, warning, success] = element.querySelectorAll<HTMLElement>('.k-btn');
|
|
25
|
+
|
|
26
|
+
info.click();
|
|
27
|
+
await wait();
|
|
28
|
+
let notification = getElement('.k-notification')!;
|
|
29
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
30
|
+
|
|
31
|
+
error.click();
|
|
32
|
+
await wait();
|
|
33
|
+
expect(getElement('.k-notification')!.outerHTML).to.matchSnapshot();
|
|
34
|
+
|
|
35
|
+
warning.click();
|
|
36
|
+
await wait();
|
|
37
|
+
expect(getElement('.k-notification')!.outerHTML).to.matchSnapshot();
|
|
38
|
+
|
|
39
|
+
success.click();
|
|
40
|
+
await wait();
|
|
41
|
+
expect(getElement('.k-notification')!.outerHTML).to.matchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('set duration', async function() {
|
|
45
|
+
this.timeout(0);
|
|
46
|
+
|
|
47
|
+
Notification.info({
|
|
48
|
+
title: '测试标题',
|
|
49
|
+
content: '测试内容',
|
|
50
|
+
duration: 500
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await wait();
|
|
54
|
+
const notification = getElement('.k-notification')!;
|
|
55
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
56
|
+
|
|
57
|
+
// should not remove when mouseenter
|
|
58
|
+
dispatchEvent(notification, 'mouseenter');
|
|
59
|
+
await wait(1000);
|
|
60
|
+
let notification1 = getElement('.k-notification');
|
|
61
|
+
expect(notification1).eql(notification);
|
|
62
|
+
|
|
63
|
+
dispatchEvent(notification, 'mouseleave');
|
|
64
|
+
await wait(500);
|
|
65
|
+
notification1 = getElement('.k-notification');
|
|
66
|
+
expect(notification1).eql(notification);
|
|
67
|
+
|
|
68
|
+
await wait(700);
|
|
69
|
+
notification1 = getElement('.k-notification');
|
|
70
|
+
expect(notification1).not.eql(notification);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('set duration to 0 should not auto close', async function() {
|
|
74
|
+
this.timeout(0);
|
|
75
|
+
|
|
76
|
+
Notification.warning({
|
|
77
|
+
title: '不会自动关闭',
|
|
78
|
+
content: '这条通知不会自动关闭',
|
|
79
|
+
duration: 0
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await wait();
|
|
83
|
+
const notification = getElement('.k-notification')!;
|
|
84
|
+
|
|
85
|
+
// wait for a long time, should still exist
|
|
86
|
+
await wait(2000);
|
|
87
|
+
const notification1 = getElement('.k-notification');
|
|
88
|
+
expect(notification1).eql(notification);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('hide close button when closable is false', async () => {
|
|
92
|
+
Notification.info({
|
|
93
|
+
title: '隐藏关闭按钮',
|
|
94
|
+
content: '这条通知隐藏了关闭按钮',
|
|
95
|
+
closable: false
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
await wait();
|
|
99
|
+
const notification = getElement('.k-notification')!;
|
|
100
|
+
const closeButton = notification.querySelector('.k-notification-close');
|
|
101
|
+
expect(closeButton).to.be.null;
|
|
102
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should not show icon when type is empty string and icon is not provided', async () => {
|
|
106
|
+
Notification.notice({
|
|
107
|
+
title: '无类型通知',
|
|
108
|
+
content: '这条通知没有类型,不应该显示图标',
|
|
109
|
+
type: ''
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await wait();
|
|
113
|
+
const notification = getElement('.k-notification')!;
|
|
114
|
+
const icon = notification.querySelector('.k-notification-icon');
|
|
115
|
+
expect(icon).to.be.null;
|
|
116
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('show notification at different positions', async () => {
|
|
120
|
+
const positions: Array<'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom'> =
|
|
121
|
+
['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'];
|
|
122
|
+
|
|
123
|
+
for (const position of positions) {
|
|
124
|
+
Notification.info({
|
|
125
|
+
title: '位置测试',
|
|
126
|
+
content: `通知出现在${position}位置`,
|
|
127
|
+
position
|
|
128
|
+
});
|
|
129
|
+
await wait();
|
|
130
|
+
|
|
131
|
+
const containers = document.querySelectorAll(`.k-notifications`);
|
|
132
|
+
const container = containers[containers.length - 1] as HTMLElement;
|
|
133
|
+
expect(container).to.exist;
|
|
134
|
+
|
|
135
|
+
const notification = container?.querySelector(`.k-notification.k-position-${position}`);
|
|
136
|
+
expect(notification).to.exist;
|
|
137
|
+
expect(notification!.outerHTML).to.matchSnapshot();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should trigger onClose callback when notification auto closes', async function() {
|
|
142
|
+
this.timeout(0);
|
|
143
|
+
const onCloseSpy = sinon.spy();
|
|
144
|
+
|
|
145
|
+
Notification.info({
|
|
146
|
+
title: '自动关闭测试',
|
|
147
|
+
content: '这条通知会自动关闭',
|
|
148
|
+
onClose: onCloseSpy,
|
|
149
|
+
duration: 500
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
await wait();
|
|
153
|
+
const notification = getElement('.k-notification')!;
|
|
154
|
+
expect(notification).to.exist;
|
|
155
|
+
|
|
156
|
+
// 等待自动关闭
|
|
157
|
+
await wait(700);
|
|
158
|
+
|
|
159
|
+
expect(onCloseSpy.callCount).to.eql(1);
|
|
160
|
+
expect(onCloseSpy.calledOnce).to.be.true;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('test notification click and close event', async () => {
|
|
164
|
+
const [instance, element] = mount(EventDemo);
|
|
165
|
+
|
|
166
|
+
const [btn] = element.querySelectorAll<HTMLElement>('.k-btn');
|
|
167
|
+
|
|
168
|
+
btn.click();
|
|
169
|
+
await wait();
|
|
170
|
+
let notification = document.querySelector('.event-test')!;
|
|
171
|
+
dispatchEvent(notification, 'click');
|
|
172
|
+
await wait(500);
|
|
173
|
+
let message1 = document.querySelector('.k-info') as HTMLElement;
|
|
174
|
+
expect(message1.outerHTML).to.matchSnapshot();
|
|
175
|
+
await wait(500);
|
|
176
|
+
const closeButton = notification.querySelector<HTMLElement>('.k-notification-close')!;
|
|
177
|
+
closeButton.click();
|
|
178
|
+
await wait(500);
|
|
179
|
+
let message2 = document.querySelector('.k-warning') as HTMLElement;
|
|
180
|
+
expect(message2.outerHTML).to.matchSnapshot();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should support VNode as title and content', async () => {
|
|
184
|
+
Notification.info({
|
|
185
|
+
title: h('div', {class: 'custom-title'}, '自定义标题'),
|
|
186
|
+
content: h('div', {class: 'custom-content'}, [
|
|
187
|
+
h('span', {style: 'color: red;'}, '这是'),
|
|
188
|
+
'一段',
|
|
189
|
+
h('strong', null, '自定义内容')
|
|
190
|
+
]),
|
|
191
|
+
className: 'custom-notification'
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
await wait(100);
|
|
195
|
+
const notification = document.querySelector('.custom-notification') as HTMLElement;
|
|
196
|
+
expect(notification.outerHTML).to.matchSnapshot();
|
|
197
|
+
|
|
198
|
+
const titleContainer = notification.querySelector('.k-notification-title');
|
|
199
|
+
expect(titleContainer).to.exist;
|
|
200
|
+
const title = titleContainer!.querySelector('.custom-title');
|
|
201
|
+
expect(title).to.exist;
|
|
202
|
+
expect(title!.textContent).to.eql('自定义标题');
|
|
203
|
+
|
|
204
|
+
const contentContainer = notification.querySelector('.k-notification-body');
|
|
205
|
+
expect(contentContainer).to.exist;
|
|
206
|
+
const content = contentContainer!.querySelector('.custom-content');
|
|
207
|
+
expect(content).to.exist;
|
|
208
|
+
expect(content!.querySelector('span')).to.exist;
|
|
209
|
+
expect(content!.querySelector('strong')).to.exist;
|
|
210
|
+
});
|
|
211
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
VNode,
|
|
4
|
+
TypeDefs,
|
|
5
|
+
render,
|
|
6
|
+
createVNode as h,
|
|
7
|
+
Children,
|
|
8
|
+
Props,
|
|
9
|
+
} from 'intact';
|
|
10
|
+
import template from './notification.vdt';
|
|
11
|
+
import {Notifications} from './notifications';
|
|
12
|
+
import {useDelayClose} from '../../hooks/useDelayClose';
|
|
13
|
+
import {bind} from '../utils';
|
|
14
|
+
import { useConfigContext } from '../config';
|
|
15
|
+
|
|
16
|
+
export interface NotificationProps {
|
|
17
|
+
title?: Children,
|
|
18
|
+
content?: Children
|
|
19
|
+
duration?: number
|
|
20
|
+
type?: 'info' | 'error' | 'success' | 'warning' | ''
|
|
21
|
+
closable?: boolean
|
|
22
|
+
icon?: string | VNode
|
|
23
|
+
position?: 'topRight' | 'topLeft' | 'bottomRight' | 'bottomLeft' | 'top' | 'bottom'
|
|
24
|
+
className?: string
|
|
25
|
+
onClick?: (e: MouseEvent) => void
|
|
26
|
+
onClose?: () => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const typeDefs: Required<TypeDefs<NotificationProps>> = {
|
|
30
|
+
title: [String, VNode],
|
|
31
|
+
content: [String, VNode],
|
|
32
|
+
duration: Number,
|
|
33
|
+
type: ['info', 'error', 'success', 'warning', ''],
|
|
34
|
+
closable: Boolean,
|
|
35
|
+
icon: [String, VNode],
|
|
36
|
+
position: ['topRight', 'topLeft', 'bottomRight', 'bottomLeft', 'top', 'bottom'],
|
|
37
|
+
className: String,
|
|
38
|
+
onClick: Function,
|
|
39
|
+
onClose: Function,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let id = 0;
|
|
43
|
+
const defaults = (): Partial<NotificationProps> => ({
|
|
44
|
+
duration: 4500,
|
|
45
|
+
type: '',
|
|
46
|
+
closable: true,
|
|
47
|
+
position: 'topRight',
|
|
48
|
+
});
|
|
49
|
+
// 按位置维护多个容器实例
|
|
50
|
+
let notificationsMap: Map<string, Notifications> = new Map();
|
|
51
|
+
// 存储 notificationId -> { position, key } 的映射,用于通过 id 关闭通知
|
|
52
|
+
let notificationIdMap: Map<number, { position: string; key: number | string }> = new Map();
|
|
53
|
+
|
|
54
|
+
export class Notification extends Component<NotificationProps> {
|
|
55
|
+
static template = template;
|
|
56
|
+
static typeDefs = typeDefs;
|
|
57
|
+
static defaults = defaults;
|
|
58
|
+
static classNamePrefix: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 显示通知
|
|
62
|
+
* @param props 通知配置对象
|
|
63
|
+
* @returns 返回通知的唯一 ID,可用于调用 close 方法关闭通知
|
|
64
|
+
*/
|
|
65
|
+
static notice(props: Partial<NotificationProps>): number {
|
|
66
|
+
const notificationId = id++;
|
|
67
|
+
const key = notificationId;
|
|
68
|
+
const finalProps = {
|
|
69
|
+
...props,
|
|
70
|
+
key,
|
|
71
|
+
type: props.type ?? '',
|
|
72
|
+
duration: props.duration ?? 4500,
|
|
73
|
+
position: props.position || 'topRight',
|
|
74
|
+
} as Partial<Props<NotificationProps>>;
|
|
75
|
+
|
|
76
|
+
const position = finalProps.position!;
|
|
77
|
+
|
|
78
|
+
// 存储 notificationId 到 position 和 key 的映射
|
|
79
|
+
notificationIdMap.set(notificationId, { position, key });
|
|
80
|
+
|
|
81
|
+
// 如果该位置的容器不存在,创建并挂载
|
|
82
|
+
if (!notificationsMap.has(position)) {
|
|
83
|
+
const container = document.createElement('div');
|
|
84
|
+
document.body.append(container);
|
|
85
|
+
// @ts-ignore 类型实例化过深
|
|
86
|
+
render(h(Notifications, {
|
|
87
|
+
ref: (i: Notifications | null) => {
|
|
88
|
+
if (i) {
|
|
89
|
+
notificationsMap.set(position, i);
|
|
90
|
+
// 设置清理回调
|
|
91
|
+
i.__cleanup = () => {
|
|
92
|
+
notificationsMap.delete(position);
|
|
93
|
+
render(null, container);
|
|
94
|
+
container.remove();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
classNamePrefix: Notification.classNamePrefix,
|
|
99
|
+
position,
|
|
100
|
+
} as any), container);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// @ts-ignore 类型实例化过深
|
|
104
|
+
notificationsMap.get(position)!.notice(h(Notification, finalProps as any));
|
|
105
|
+
return notificationId;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 关闭指定 ID 的通知
|
|
110
|
+
* @param id 通知的唯一 ID,由 notice 方法返回
|
|
111
|
+
*/
|
|
112
|
+
static close(id: number) {
|
|
113
|
+
const notificationInfo = notificationIdMap.get(id);
|
|
114
|
+
if (!notificationInfo) {
|
|
115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
116
|
+
console.warn(`Notification with id ${id} does not exist.`);
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const { position, key } = notificationInfo;
|
|
122
|
+
const notifications = notificationsMap.get(position);
|
|
123
|
+
if (notifications) {
|
|
124
|
+
notifications.delete(key);
|
|
125
|
+
}
|
|
126
|
+
// 从映射中移除
|
|
127
|
+
notificationIdMap.delete(id);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static info(props: Partial<NotificationProps>): number {
|
|
131
|
+
return Notification.notice({...props, type: 'info'});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static error(props: Partial<NotificationProps>): number {
|
|
135
|
+
return Notification.notice({...props, type: 'error'});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static success(props: Partial<NotificationProps>): number {
|
|
139
|
+
return Notification.notice({...props, type: 'success'});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static warning(props: Partial<NotificationProps>): number {
|
|
143
|
+
return Notification.notice({...props, type: 'warning'});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private delayClose = useDelayClose(
|
|
147
|
+
this.close,
|
|
148
|
+
this.get('duration')!
|
|
149
|
+
);
|
|
150
|
+
private config = useConfigContext();
|
|
151
|
+
|
|
152
|
+
@bind
|
|
153
|
+
onClick(e: MouseEvent) {
|
|
154
|
+
const onClick = this.get('onClick');
|
|
155
|
+
if (onClick) {
|
|
156
|
+
onClick(e);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@bind
|
|
161
|
+
onCloseClick(e: MouseEvent) {
|
|
162
|
+
e.stopPropagation(); // 阻止事件冒泡,避免触发外层的 onClick
|
|
163
|
+
this.close();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@bind
|
|
167
|
+
close() {
|
|
168
|
+
const onClose = this.get('onClose');
|
|
169
|
+
if (onClose) {
|
|
170
|
+
onClose();
|
|
171
|
+
}
|
|
172
|
+
const position = this.get('position') || 'topRight';
|
|
173
|
+
const key = this.get('key')!;
|
|
174
|
+
|
|
175
|
+
// 从 notificationIdMap 中移除对应的映射
|
|
176
|
+
for (const [notificationId, info] of notificationIdMap.entries()) {
|
|
177
|
+
if (info.position === position && info.key === key) {
|
|
178
|
+
notificationIdMap.delete(notificationId);
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
notificationsMap.get(position)!.delete(key);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {Button} from '../button';
|
|
2
|
+
import {Icon} from '../icon';
|
|
3
|
+
import {getRestProps} from '../utils';
|
|
4
|
+
import {makeNotificationStyles} from './styles';
|
|
5
|
+
import {theme} from '../../styles/theme';
|
|
6
|
+
|
|
7
|
+
const {type, title, content, children, closable, icon, classNamePrefix, position, className} = this.get();
|
|
8
|
+
const { k } = this.config;
|
|
9
|
+
|
|
10
|
+
const classNameObj = {
|
|
11
|
+
[`${k}-notification`]: true,
|
|
12
|
+
[className]: className,
|
|
13
|
+
[`${k}-${type}`]: type && (type === 'info' || type === 'error' || type === 'success' || type === 'warning'),
|
|
14
|
+
[`${k}-position-${position || 'topRight'}`]: true,
|
|
15
|
+
[makeNotificationStyles(k)]: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const iconMap = {
|
|
19
|
+
info: `${k}-icon-information-fill`,
|
|
20
|
+
warning: `${k}-icon-warning-fill`,
|
|
21
|
+
success: `${k}-icon-success-fill`,
|
|
22
|
+
error: `${k}-icon-error-fill`,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// type 优先级大于 icon,如果 type 存在且是四种类型之一,使用 type 对应的 icon
|
|
26
|
+
// 否则如果 icon 有值,使用自定义 icon
|
|
27
|
+
const hasIcon = (type && iconMap[type]) || icon;
|
|
28
|
+
const iconName = type && iconMap[type] ? iconMap[type] : (typeof icon === 'string' ? icon : null);
|
|
29
|
+
const iconColor = type ? theme.color[type === 'error' ? 'danger' : type] : 'default';
|
|
30
|
+
|
|
31
|
+
<div {...getRestProps(this)}
|
|
32
|
+
class={classNameObj}
|
|
33
|
+
ev-mouseenter={this.delayClose.onMouseEnter}
|
|
34
|
+
ev-mouseleave={this.delayClose.onMouseLeave}
|
|
35
|
+
ev-click={this.onClick}
|
|
36
|
+
>
|
|
37
|
+
<div class={`${k}-notification-container`}>
|
|
38
|
+
<div class={{[`${k}-notification-wrapper`]: true, [`${k}-with-icon`]: hasIcon}}>
|
|
39
|
+
<div v-if={hasIcon && iconName} class={`${k}-notification-icon`}>
|
|
40
|
+
<Icon class={iconName} color={iconColor}/>
|
|
41
|
+
</div>
|
|
42
|
+
<div v-else-if={hasIcon && !iconName} class={`${k}-notification-icon`}>
|
|
43
|
+
{icon}
|
|
44
|
+
</div>
|
|
45
|
+
<div class={`${k}-notification-content`}>
|
|
46
|
+
<div v-if={title} class={`${k}-notification-title`}>{title}</div>
|
|
47
|
+
<div v-if={content || children} class={`${k}-notification-body`}>
|
|
48
|
+
{content || children}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
<Button
|
|
53
|
+
v-if={closable}
|
|
54
|
+
type="none"
|
|
55
|
+
icon
|
|
56
|
+
class={`${k}-notification-close`}
|
|
57
|
+
ev-click={this.onCloseClick}
|
|
58
|
+
>
|
|
59
|
+
<Icon class={`${k}-icon-close`} hoverable />
|
|
60
|
+
</Button>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|