Skip to content

Commit

Permalink
feat: message.config supports closable
Browse files Browse the repository at this point in the history
  • Loading branch information
yinkaihui committed Apr 26, 2024
1 parent 8236aba commit 4740d8c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ export type ConfigProps = {
getContainer?: () => HTMLElement;
duration?: number;
rtl?: boolean;
closable?: boolean;
};

let maxCount;
let prefixCls;
let duration;
let container;
let rtl;
let closable;

export interface MessageType {
(): void;
Expand Down Expand Up @@ -138,6 +140,9 @@ class Message extends BaseNotification {
if (typeof options.rtl === 'boolean') {
rtl = options.rtl;
}
if (typeof options.closable === 'boolean') {
closable = options.closable;
}
if (options.getContainer && options.getContainer() !== container) {
container = options.getContainer();
Object.values(messageInstance).forEach(({ instance }) => instance?.clear());
Expand Down Expand Up @@ -174,10 +179,12 @@ class Message extends BaseNotification {
transitionTimeout: _transitionTimeout,
prefixCls: _prefixCls,
rtl: _rtl,
closable: _closable,
} = this.props;
const { notices, position } = this.state;
const mergedPrefixCls = _prefixCls || prefixCls;
const mergedRtl = !isUndefined(_rtl) ? _rtl : rtl;
const mergeClosable = !isUndefined(_closable) ? _closable : closable;
const prefixClsMessage = mergedPrefixCls ? `${mergedPrefixCls}-message` : 'arco-message';
const transitionTimeout = {
enter: isNumber(_transitionTimeout?.enter) ? _transitionTimeout?.enter : 100,
Expand Down Expand Up @@ -212,6 +219,7 @@ class Message extends BaseNotification {
onClose={this.remove}
noticeType="message"
rtl={mergedRtl}
{...(isUndefined(mergeClosable) ? {} : { closable: mergeClosable })}
/>
</CSSTransition>
))}
Expand Down

0 comments on commit 4740d8c

Please sign in to comment.