From ad3522df9049f73168a3025e35a8cb53c591ed1d Mon Sep 17 00:00:00 2001
From: 07akioni <07akioni2@gmail.com>
Date: Sun, 27 Feb 2022 21:55:54 +0800
Subject: [PATCH] feat(useMessage): supports `'default'` `type`
---
CHANGELOG.en-US.md | 3 +-
CHANGELOG.zh-CN.md | 3 +-
src/message/demos/enUS/index.demo-entry.md | 40 ++++++++++++----------
src/message/demos/zhCN/index.demo-entry.md | 40 ++++++++++++----------
src/message/src/Message.tsx | 31 ++++++++---------
src/message/src/MessageProvider.tsx | 4 +++
src/message/src/styles/index.cssr.ts | 3 +-
src/message/src/types.ts | 8 ++++-
src/message/styles/light.ts | 7 ++++
9 files changed, 83 insertions(+), 56 deletions(-)
diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md
index 9e149506bd8..47ac5b213a0 100644
--- a/CHANGELOG.en-US.md
+++ b/CHANGELOG.en-US.md
@@ -11,7 +11,8 @@
### Feats
- `n-collapse` add `RTL` support.
-- `n-message` adds `show-icon` prop, closes [#2495](https://github.com/TuSimple/naive-ui/issues/2495).
+- `useMessage` adds `showIcon` prop, closes [#2495](https://github.com/TuSimple/naive-ui/issues/2495).
+- `useMessage` supports `'default'` `type`.
## 2.25.5 (2022-02-24)
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index a15649affda..60ab2ce759d 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -11,7 +11,8 @@
### Feats
- `n-collapse` 添加 `RTL` 支持
-- `n-message` 新增 `show-icon` 属性,关闭 [#2495](https://github.com/TuSimple/naive-ui/issues/2495)
+- `useMessage` 新增 `showIcon` 属性,关闭 [#2495](https://github.com/TuSimple/naive-ui/issues/2495)
+- `useMessage` 支持 `'default'` 的 `type`
## 2.25.5 (2022-02-24)
diff --git a/src/message/demos/enUS/index.demo-entry.md b/src/message/demos/enUS/index.demo-entry.md
index 76d1e4506c0..f8bedcffc0e 100644
--- a/src/message/demos/enUS/index.demo-entry.md
+++ b/src/message/demos/enUS/index.demo-entry.md
@@ -70,14 +70,15 @@ no-icon.vue
#### MessageProvider Injection Methods
-| Name | Type | Description |
-| --- | --- | --- |
-| destroyAll | `() => void` | Destroy all popup messages. |
-| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use error type message. |
-| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use info type message. |
-| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use loading type message. |
-| success | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use success type message. |
-| warning | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use warning type message. |
+| Name | Type | Description | Version |
+| --- | --- | --- | --- |
+| destroyAll | `() => void` | Destroy all popup messages. | |
+| create | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use error type message. | NEXT_VERSION |
+| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use error type message. | |
+| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use info type message. | |
+| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use loading type message. | |
+| success | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use success type message. | |
+| warning | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | Use warning type message. | |
#### MessageOption Properties
@@ -88,6 +89,8 @@ no-icon.vue
| icon | `() => VNodeChild` | Message icon. | |
| keepAliveOnHover | `boolean` | Messages whether to destroy while hover. | |
| render | `MessageRenderMessage` | Render function of the entire message. | 2.24.0 |
+| showIcon | `boolean` | Whether to show icon. | NEXT_VERSION |
+| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading' \| 'default'` | Message type. | `'default'` NEXT_VERSION |
| onAfterLeave | `() => void` | Callback after message disappeared. | |
| onClose | `() => void` | Callback when close icon is clicked. | |
| onLeave | `() => void` | Callback when message start to disappear. | |
@@ -106,16 +109,17 @@ type MessageRenderMessage = (props: {
#### MessageReactive Properties
-| Name | Type | Description |
-| --- | --- | --- |
-| closable | `boolean` | Whether to show close icon. |
-| content | `string \| (() => VNodeChild)` | Message content. |
-| destroy | `() => void` | Message destroy method. |
-| icon | `() => VNodeChild` | Message icon. |
-| keepAliveOnHover | `boolean` | Messages whether to destroy while hover |
-| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading'` | Message type. |
-| onAfterLeave | `() => void` | Callback after message disappeared. |
-| onLeave | `() => void` | Callback when message start to disappear. |
+| Name | Type | Description | Version |
+| --- | --- | --- | --- |
+| closable | `boolean` | Whether to show close icon. | |
+| content | `string \| (() => VNodeChild)` | Message content. | |
+| destroy | `() => void` | Message destroy method. | |
+| icon | `() => VNodeChild` | Message icon. | |
+| keepAliveOnHover | `boolean` | Messages whether to destroy while hover | |
+| showIcon | `boolean` | Whether to show icon. | NEXT_VERSION |
+| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading' \| 'default'` | Message type. | `'default'` NEXT_VERSION |
+| onAfterLeave | `() => void` | Callback after message disappeared. | |
+| onLeave | `() => void` | Callback when message start to disappear. | |
#### MessageReactive Methods
diff --git a/src/message/demos/zhCN/index.demo-entry.md b/src/message/demos/zhCN/index.demo-entry.md
index 969edcea7b6..caaf678a0b3 100644
--- a/src/message/demos/zhCN/index.demo-entry.md
+++ b/src/message/demos/zhCN/index.demo-entry.md
@@ -70,14 +70,15 @@ no-icon.vue
#### MessageProvider Injection Methods
-| 名称 | 类型 | 说明 |
-| --- | --- | --- |
-| destroyAll | `() => void` | 销毁所有弹出的信息 |
-| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 error 类型的信息 |
-| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 info 类型的信息 |
-| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 loading 类型的信息 |
-| success | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 success 类型的信息 |
-| warning | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 warning 类型的信息 |
+| 名称 | 类型 | 说明 | 版本 |
+| --- | --- | --- | --- |
+| destroyAll | `() => void` | 销毁所有弹出的信息 | |
+| create | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 error 类型的信息 | NEXT_VERSION |
+| error | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 error 类型的信息 | |
+| info | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 info 类型的信息 | |
+| loading | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 loading 类型的信息 | |
+| success | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 success 类型的信息 | |
+| warning | `(content: string \| (() => VNodeChild), option?: MessageOption) => MessageReactive` | 调用 warning 类型的信息 | |
#### MessageOption Properties
@@ -88,6 +89,8 @@ no-icon.vue
| icon | `() => VNodeChild` | 信息图标 | |
| keepAliveOnHover | `boolean` | Hover 到信息上是否不销毁 | |
| render | `MessageRenderMessage` | 消息的渲染函数 | 2.24.0 |
+| showIcon | `boolean` | 是否展示图标 | NEXT_VERSION |
+| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading' \| 'default'` | 信息类型 | `'default'` NEXT_VERSION |
| onAfterLeave | `() => void` | 信息消失动画结束的回调 | |
| onClose | `() => void` | 点击关闭图标的回调 | |
| onLeave | `() => void` | 信息开始消失的回调 | |
@@ -106,16 +109,17 @@ type MessageRenderMessage = (props: {
#### MessageReactive Properties
-| 名称 | 类型 | 说明 |
-| --- | --- | --- |
-| closable | `boolean` | 是否显示 close 图标 |
-| content | `string \| (() => VNodeChild)` | 信息内容 |
-| destroy | `() => void` | 销毁信息的方法 |
-| icon | `() => VNodeChild` | 信息图标 |
-| keepAliveOnHover | `boolean` | Hover 到信息上是否不销毁 |
-| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading'` | 信息类型 |
-| onAfterLeave | `() => void` | 信息消失动画结束的回调 |
-| onLeave | `() => void` | 信息开始消失的回调 |
+| 名称 | 类型 | 说明 | 版本 |
+| --- | --- | --- | --- |
+| closable | `boolean` | 是否显示 close 图标 | |
+| content | `string \| (() => VNodeChild)` | 信息内容 | |
+| destroy | `() => void` | 销毁信息的方法 | |
+| icon | `() => VNodeChild` | 信息图标 | |
+| keepAliveOnHover | `boolean` | Hover 到信息上是否不销毁 | |
+| showIcon | `boolean` | 是否展示图标 | NEXT_VERSION |
+| type | `'info' \| 'success' \| 'warning' \| 'error' \| 'loading' \| 'default'` | 信息类型 | `'default'` NEXT_VERSION |
+| onAfterLeave | `() => void` | 信息消失动画结束的回调 | |
+| onLeave | `() => void` | 信息开始消失的回调 | |
#### MessageReactive Methods
diff --git a/src/message/src/Message.tsx b/src/message/src/Message.tsx
index db9cf454b0a..97e5efc7ca0 100644
--- a/src/message/src/Message.tsx
+++ b/src/message/src/Message.tsx
@@ -31,7 +31,8 @@ const iconMap = {
info: