add all frontend files

This commit is contained in:
2026-01-17 15:16:36 -05:00
parent ff16ae7858
commit e40287e4aa
25704 changed files with 1935289 additions and 0 deletions

9
node_modules/rc-notification/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2014-present yiminghe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

191
node_modules/rc-notification/README.md generated vendored Normal file
View File

@@ -0,0 +1,191 @@
# rc-notification
React Notification UI Component
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
[npm-image]: http://img.shields.io/npm/v/rc-notification.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-notification
[github-actions-image]: https://github.com/react-component/notification/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/notification/actions
[coveralls-image]: https://img.shields.io/coveralls/react-component/notification.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/react-component/notification?branch=master
[download-image]: https://img.shields.io/npm/dm/rc-notification.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-notification
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-notification
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-notification
## Install
[![rc-notification](https://nodei.co/npm/rc-notification.png)](https://npmjs.org/package/rc-notification)
## Usage
```js
import Notification from 'rc-notification';
Notification.newInstance({}, notification => {
notification.notice({
content: 'content'
});
});
```
## Compatibility
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
| --- | --- | --- | --- | --- |
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
## Example
http://localhost:8001
online example: https://notification-react-component.vercel.app
## API
### Notification.newInstance(props, (notification) => void) => void
props details:
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>prefixCls</td>
<td>String</td>
<td></td>
<td>prefix class name for notification container</td>
</tr>
<tr>
<td>style</td>
<td>Object</td>
<td>{'top': 65, left: '50%'}</td>
<td>additional style for notification container.</td>
</tr>
<tr>
<td>getContainer</td>
<td>getContainer(): HTMLElement</td>
<td></td>
<td>function returning html node which will act as notification container</td>
</tr>
<tr>
<td>maxCount</td>
<td>number</td>
<td></td>
<td>max notices show, drop first notice if exceed limit</td>
</tr>
</tbody>
</table>
### notification.notice(props)
props details:
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 100px;">name</th>
<th style="width: 50px;">type</th>
<th style="width: 50px;">default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>content</td>
<td>React.Element</td>
<td></td>
<td>content of notice</td>
</tr>
<tr>
<td>key</td>
<td>String</td>
<td></td>
<td>id of this notice</td>
</tr>
<tr>
<td>closable</td>
<td>Boolean</td>
<td></td>
<td>whether show close button</td>
</tr>
<tr>
<td>onClose</td>
<td>Function</td>
<td></td>
<td>called when notice close</td>
</tr>
<tr>
<td>duration</td>
<td>number</td>
<td>1.5</td>
<td>after duration of time, this notice will disappear.(seconds)</td>
</tr>
<tr>
<td>showProgress</td>
<td>boolean</td>
<td>false</td>
<td>show with progress bar for auto-closing notification</td>
</tr>
<tr>
<td>pauseOnHover</td>
<td>boolean</td>
<td>true</td>
<td>keep the timer running or not on hover</td>
</tr>
<tr>
<td>style</td>
<td>Object</td>
<td> { right: '50%' } </td>
<td>additional style for single notice node.</td>
</tr>
<tr>
<td>closeIcon</td>
<td>ReactNode</td>
<td></td>
<td>specific the close icon.</td>
</tr>
<tr>
<td>props</td>
<td>Object</td>
<td></td>
<td>An object that can contain <code>data-*</code>, <code>aria-*</code>, or <code>role</code> props, to be put on the notification <code>div</code>. This currently only allows <code>data-testid</code> instead of <code>data-*</code> in TypeScript. See https://github.com/microsoft/TypeScript/issues/28960.</td>
</tr>
</tbody>
</table>
### notification.removeNotice(key:string)
remove single notice with specified key
### notification.destroy()
destroy current notification
## Test Case
```
npm test
npm run chrome-test
```
## Coverage
```
npm run coverage
```
open coverage/ dir
## License
rc-notification is released under the MIT license.

170
node_modules/rc-notification/assets/index.css generated vendored Normal file
View File

@@ -0,0 +1,170 @@
.rc-notification {
position: fixed;
z-index: 1000;
display: flex;
max-height: 100vh;
padding: 10px;
align-items: flex-end;
width: 340px;
overflow-x: hidden;
overflow-y: auto;
height: 100vh;
box-sizing: border-box;
pointer-events: none;
flex-direction: column;
}
.rc-notification-top,
.rc-notification-topLeft,
.rc-notification-topRight {
top: 0;
}
.rc-notification-bottom,
.rc-notification-bottomRight,
.rc-notification-bottomLeft {
bottom: 0;
}
.rc-notification-bottomRight,
.rc-notification-topRight {
right: 0;
}
.rc-notification-notice {
position: relative;
display: block;
box-sizing: border-box;
line-height: 1.5;
width: 100%;
}
.rc-notification-notice-wrapper {
pointer-events: auto;
position: relative;
display: block;
box-sizing: border-box;
border-radius: 3px 3px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
margin: 0 0 16px;
border: 1px solid #999;
border: 0px solid rgba(0, 0, 0, 0);
background: #fff;
width: 300px;
}
.rc-notification-notice-content {
padding: 7px 20px 7px 10px;
}
.rc-notification-notice-closable .rc-notification-notice-content {
padding-right: 20px;
}
.rc-notification-notice-close {
position: absolute;
top: 3px;
right: 5px;
color: #000;
font-weight: 700;
font-size: 16px;
line-height: 1;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
outline: none;
cursor: pointer;
opacity: 0.2;
filter: alpha(opacity=20);
}
.rc-notification-notice-close-x:after {
content: '×';
}
.rc-notification-notice-close:hover {
text-decoration: none;
opacity: 1;
filter: alpha(opacity=100);
}
.rc-notification-notice-progress {
position: absolute;
left: 3px;
right: 3px;
border-radius: 1px;
overflow: hidden;
appearance: none;
-webkit-appearance: none;
display: block;
inline-size: 100%;
block-size: 2px;
border: 0;
}
.rc-notification-notice-progress,
.rc-notification-notice-progress::-webkit-progress-bar {
background-color: rgba(0, 0, 0, 0.04);
}
.rc-notification-notice-progress::-moz-progress-bar {
background-color: #31afff;
}
.rc-notification-notice-progress::-webkit-progress-value {
background-color: #31afff;
}
.rc-notification-fade {
overflow: hidden;
transition: all 0.3s;
}
.rc-notification-fade-appear-prepare {
pointer-events: none;
opacity: 0 !important;
}
.rc-notification-fade-appear-start {
transform: translateX(100%);
opacity: 0;
}
.rc-notification-fade-appear-active {
transform: translateX(0);
opacity: 1;
}
.rc-notification-stack > .rc-notification-notice-wrapper {
transition: all 0.3s;
position: absolute;
top: 12px;
opacity: 1;
}
.rc-notification-stack > .rc-notification-notice-wrapper:not(:nth-last-child(-n + 3)) {
opacity: 0;
right: 34px;
width: 252px;
overflow: hidden;
color: transparent;
pointer-events: none;
}
.rc-notification-stack > .rc-notification-notice-wrapper:nth-last-child(1) {
right: 10px;
}
.rc-notification-stack > .rc-notification-notice-wrapper:nth-last-child(2) {
right: 18px;
width: 284px;
color: transparent;
overflow: hidden;
}
.rc-notification-stack > .rc-notification-notice-wrapper:nth-last-child(3) {
right: 26px;
width: 268px;
color: transparent;
overflow: hidden;
}
.rc-notification-stack.rc-notification-stack-expanded > .rc-notification-notice-wrapper:not(:nth-last-child(-n + 1)) {
opacity: 1;
width: 300px;
right: 10px;
overflow: unset;
color: inherit;
pointer-events: auto;
}
.rc-notification-stack.rc-notification-stack-expanded > .rc-notification-notice-wrapper::after {
content: "";
position: absolute;
left: 0;
right: 0;
top: -16px;
width: 100%;
height: calc(100% + 32px);
background: transparent;
pointer-events: auto;
color: #000000;
}
.rc-notification-stack.rc-notification-bottomRight > .rc-notification-notice-wrapper {
top: unset;
bottom: 12px;
}

263
node_modules/rc-notification/assets/index.less generated vendored Normal file
View File

@@ -0,0 +1,263 @@
@notificationPrefixCls: rc-notification;
.@{notificationPrefixCls} {
// ====================== Notification ======================
position: fixed;
z-index: 1000;
display: flex;
max-height: 100vh;
padding: 10px;
align-items: flex-end;
width: 340px;
overflow-x: hidden;
overflow-y: auto;
height: 100vh;
box-sizing: border-box;
pointer-events: none;
flex-direction: column;
// Position
&-top,
&-topLeft,
&-topRight {
top: 0;
}
&-bottom,
&-bottomRight,
&-bottomLeft {
bottom: 0;
}
&-bottomRight,
&-topRight {
right: 0;
}
// ========================= Notice =========================
&-notice {
position: relative;
display: block;
box-sizing: border-box;
line-height: 1.5;
width: 100%;
&-wrapper {
pointer-events: auto;
position: relative;
display: block;
box-sizing: border-box;
border-radius: 3px 3px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
margin: 0 0 16px;
border: 1px solid #999;
border: 0px solid rgba(0, 0, 0, 0);
background: #fff;
width: 300px;
}
// Content
&-content {
padding: 7px 20px 7px 10px;
}
&-closable &-content {
padding-right: 20px;
}
&-close {
position: absolute;
top: 3px;
right: 5px;
color: #000;
font-weight: 700;
font-size: 16px;
line-height: 1;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
outline: none;
cursor: pointer;
opacity: 0.2;
filter: alpha(opacity=20);
&-x:after {
content: '×';
}
&:hover {
text-decoration: none;
opacity: 1;
filter: alpha(opacity=100);
}
}
// Progress
&-progress {
position: absolute;
left: 3px;
right: 3px;
border-radius: 1px;
overflow: hidden;
appearance: none;
-webkit-appearance: none;
display: block;
inline-size: 100%;
block-size: 2px;
border: 0;
&,
&::-webkit-progress-bar {
background-color: rgba(0, 0, 0, 0.04);
}
&::-moz-progress-bar {
background-color: #31afff;
}
&::-webkit-progress-value {
background-color: #31afff;
}
}
}
&-fade {
overflow: hidden;
transition: all 0.3s;
}
&-fade-appear-prepare {
pointer-events: none;
opacity: 0 !important;
}
&-fade-appear-start {
transform: translateX(100%);
opacity: 0;
}
&-fade-appear-active {
transform: translateX(0);
opacity: 1;
}
// .fade-effect() {
// animation-duration: 0.3s;
// animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
// animation-fill-mode: both;
// }
// &-fade-appear,
// &-fade-enter {
// opacity: 0;
// animation-play-state: paused;
// .fade-effect();
// }
// &-fade-leave {
// .fade-effect();
// animation-play-state: paused;
// }
// &-fade-appear&-fade-appear-active,
// &-fade-enter&-fade-enter-active {
// animation-name: rcNotificationFadeIn;
// animation-play-state: running;
// }
// &-fade-leave&-fade-leave-active {
// animation-name: rcDialogFadeOut;
// animation-play-state: running;
// }
// @keyframes rcNotificationFadeIn {
// 0% {
// opacity: 0;
// }
// 100% {
// opacity: 1;
// }
// }
// @keyframes rcDialogFadeOut {
// 0% {
// opacity: 1;
// }
// 100% {
// opacity: 0;
// }
// }
// ========================= Stack =========================
&-stack {
& > .@{notificationPrefixCls}-notice {
&-wrapper {
transition: all 0.3s;
position: absolute;
top: 12px;
opacity: 1;
&:not(:nth-last-child(-n + 3)) {
opacity: 0;
right: 34px;
width: 252px;
overflow: hidden;
color: transparent;
pointer-events: none;
}
&:nth-last-child(1) {
right: 10px;
}
&:nth-last-child(2) {
right: 18px;
width: 284px;
color: transparent;
overflow: hidden;
}
&:nth-last-child(3) {
right: 26px;
width: 268px;
color: transparent;
overflow: hidden;
}
}
}
&&-expanded {
& > .@{notificationPrefixCls}-notice {
&-wrapper {
&:not(:nth-last-child(-n + 1)) {
opacity: 1;
width: 300px;
right: 10px;
overflow: unset;
color: inherit;
pointer-events: auto;
}
&::after {
content: "";
position: absolute;
left: 0;
right: 0;
top: -16px;
width: 100%;
height: calc(100% + 32px);
background: transparent;
pointer-events: auto;
color: rgb(0,0,0);
}
}
}
}
&.@{notificationPrefixCls}-bottomRight {
& > .@{notificationPrefixCls}-notice-wrapper {
top: unset;
bottom: 12px;
}
}
}
}

15
node_modules/rc-notification/es/Notice.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import type { NoticeConfig } from './interface';
export interface NoticeProps extends Omit<NoticeConfig, 'onClose'> {
prefixCls: string;
className?: string;
style?: React.CSSProperties;
eventKey: React.Key;
onClick?: React.MouseEventHandler<HTMLDivElement>;
onNoticeClose?: (key: React.Key) => void;
hovering?: boolean;
}
declare const Notify: React.ForwardRefExoticComponent<NoticeProps & {
times?: number;
} & React.RefAttributes<HTMLDivElement>>;
export default Notify;

147
node_modules/rc-notification/es/Notice.js generated vendored Normal file
View File

@@ -0,0 +1,147 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _typeof from "@babel/runtime/helpers/esm/typeof";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import classNames from 'classnames';
import KeyCode from "rc-util/es/KeyCode";
import * as React from 'react';
import pickAttrs from "rc-util/es/pickAttrs";
var Notify = /*#__PURE__*/React.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
style = props.style,
className = props.className,
_props$duration = props.duration,
duration = _props$duration === void 0 ? 4.5 : _props$duration,
showProgress = props.showProgress,
_props$pauseOnHover = props.pauseOnHover,
pauseOnHover = _props$pauseOnHover === void 0 ? true : _props$pauseOnHover,
eventKey = props.eventKey,
content = props.content,
closable = props.closable,
_props$closeIcon = props.closeIcon,
closeIcon = _props$closeIcon === void 0 ? 'x' : _props$closeIcon,
divProps = props.props,
onClick = props.onClick,
onNoticeClose = props.onNoticeClose,
times = props.times,
forcedHovering = props.hovering;
var _React$useState = React.useState(false),
_React$useState2 = _slicedToArray(_React$useState, 2),
hovering = _React$useState2[0],
setHovering = _React$useState2[1];
var _React$useState3 = React.useState(0),
_React$useState4 = _slicedToArray(_React$useState3, 2),
percent = _React$useState4[0],
setPercent = _React$useState4[1];
var _React$useState5 = React.useState(0),
_React$useState6 = _slicedToArray(_React$useState5, 2),
spentTime = _React$useState6[0],
setSpentTime = _React$useState6[1];
var mergedHovering = forcedHovering || hovering;
var mergedShowProgress = duration > 0 && showProgress;
// ======================== Close =========================
var onInternalClose = function onInternalClose() {
onNoticeClose(eventKey);
};
var onCloseKeyDown = function onCloseKeyDown(e) {
if (e.key === 'Enter' || e.code === 'Enter' || e.keyCode === KeyCode.ENTER) {
onInternalClose();
}
};
// ======================== Effect ========================
React.useEffect(function () {
if (!mergedHovering && duration > 0) {
var start = Date.now() - spentTime;
var timeout = setTimeout(function () {
onInternalClose();
}, duration * 1000 - spentTime);
return function () {
if (pauseOnHover) {
clearTimeout(timeout);
}
setSpentTime(Date.now() - start);
};
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [duration, mergedHovering, times]);
React.useEffect(function () {
if (!mergedHovering && mergedShowProgress && (pauseOnHover || spentTime === 0)) {
var start = performance.now();
var animationFrame;
var calculate = function calculate() {
cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(function (timestamp) {
var runtime = timestamp + spentTime - start;
var progress = Math.min(runtime / (duration * 1000), 1);
setPercent(progress * 100);
if (progress < 1) {
calculate();
}
});
};
calculate();
return function () {
if (pauseOnHover) {
cancelAnimationFrame(animationFrame);
}
};
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [duration, spentTime, mergedHovering, mergedShowProgress, times]);
// ======================== Closable ========================
var closableObj = React.useMemo(function () {
if (_typeof(closable) === 'object' && closable !== null) {
return closable;
}
if (closable) {
return {
closeIcon: closeIcon
};
}
return {};
}, [closable, closeIcon]);
var ariaProps = pickAttrs(closableObj, true);
// ======================== Progress ========================
var validPercent = 100 - (!percent || percent < 0 ? 0 : percent > 100 ? 100 : percent);
// ======================== Render ========================
var noticePrefixCls = "".concat(prefixCls, "-notice");
return /*#__PURE__*/React.createElement("div", _extends({}, divProps, {
ref: ref,
className: classNames(noticePrefixCls, className, _defineProperty({}, "".concat(noticePrefixCls, "-closable"), closable)),
style: style,
onMouseEnter: function onMouseEnter(e) {
var _divProps$onMouseEnte;
setHovering(true);
divProps === null || divProps === void 0 || (_divProps$onMouseEnte = divProps.onMouseEnter) === null || _divProps$onMouseEnte === void 0 || _divProps$onMouseEnte.call(divProps, e);
},
onMouseLeave: function onMouseLeave(e) {
var _divProps$onMouseLeav;
setHovering(false);
divProps === null || divProps === void 0 || (_divProps$onMouseLeav = divProps.onMouseLeave) === null || _divProps$onMouseLeav === void 0 || _divProps$onMouseLeav.call(divProps, e);
},
onClick: onClick
}), /*#__PURE__*/React.createElement("div", {
className: "".concat(noticePrefixCls, "-content")
}, content), closable && /*#__PURE__*/React.createElement("a", _extends({
tabIndex: 0,
className: "".concat(noticePrefixCls, "-close"),
onKeyDown: onCloseKeyDown,
"aria-label": "Close"
}, ariaProps, {
onClick: function onClick(e) {
e.preventDefault();
e.stopPropagation();
onInternalClose();
}
}), closableObj.closeIcon), mergedShowProgress && /*#__PURE__*/React.createElement("progress", {
className: "".concat(noticePrefixCls, "-progress"),
max: "100",
value: validPercent
}, validPercent + '%'));
});
export default Notify;

17
node_modules/rc-notification/es/NoticeList.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { CSSProperties, FC } from 'react';
import React from 'react';
import type { CSSMotionProps } from 'rc-motion';
import type { OpenConfig, Placement, StackConfig } from './interface';
export interface NoticeListProps {
configList?: OpenConfig[];
placement?: Placement;
prefixCls?: string;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
stack?: StackConfig;
onAllNoticeRemoved?: (placement: Placement) => void;
onNoticeClose?: (key: React.Key) => void;
className?: string;
style?: CSSProperties;
}
declare const NoticeList: FC<NoticeListProps>;
export default NoticeList;

165
node_modules/rc-notification/es/NoticeList.js generated vendored Normal file
View File

@@ -0,0 +1,165 @@
import _extends from "@babel/runtime/helpers/esm/extends";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
var _excluded = ["className", "style", "classNames", "styles"];
import React, { useContext, useEffect, useRef, useState } from 'react';
import clsx from 'classnames';
import { CSSMotionList } from 'rc-motion';
import Notice from "./Notice";
import { NotificationContext } from "./NotificationProvider";
import useStack from "./hooks/useStack";
var NoticeList = function NoticeList(props) {
var configList = props.configList,
placement = props.placement,
prefixCls = props.prefixCls,
className = props.className,
style = props.style,
motion = props.motion,
onAllNoticeRemoved = props.onAllNoticeRemoved,
onNoticeClose = props.onNoticeClose,
stackConfig = props.stack;
var _useContext = useContext(NotificationContext),
ctxCls = _useContext.classNames;
var dictRef = useRef({});
var _useState = useState(null),
_useState2 = _slicedToArray(_useState, 2),
latestNotice = _useState2[0],
setLatestNotice = _useState2[1];
var _useState3 = useState([]),
_useState4 = _slicedToArray(_useState3, 2),
hoverKeys = _useState4[0],
setHoverKeys = _useState4[1];
var keys = configList.map(function (config) {
return {
config: config,
key: String(config.key)
};
});
var _useStack = useStack(stackConfig),
_useStack2 = _slicedToArray(_useStack, 2),
stack = _useStack2[0],
_useStack2$ = _useStack2[1],
offset = _useStack2$.offset,
threshold = _useStack2$.threshold,
gap = _useStack2$.gap;
var expanded = stack && (hoverKeys.length > 0 || keys.length <= threshold);
var placementMotion = typeof motion === 'function' ? motion(placement) : motion;
// Clean hover key
useEffect(function () {
if (stack && hoverKeys.length > 1) {
setHoverKeys(function (prev) {
return prev.filter(function (key) {
return keys.some(function (_ref) {
var dataKey = _ref.key;
return key === dataKey;
});
});
});
}
}, [hoverKeys, keys, stack]);
// Force update latest notice
useEffect(function () {
var _keys;
if (stack && dictRef.current[(_keys = keys[keys.length - 1]) === null || _keys === void 0 ? void 0 : _keys.key]) {
var _keys2;
setLatestNotice(dictRef.current[(_keys2 = keys[keys.length - 1]) === null || _keys2 === void 0 ? void 0 : _keys2.key]);
}
}, [keys, stack]);
return /*#__PURE__*/React.createElement(CSSMotionList, _extends({
key: placement,
className: clsx(prefixCls, "".concat(prefixCls, "-").concat(placement), ctxCls === null || ctxCls === void 0 ? void 0 : ctxCls.list, className, _defineProperty(_defineProperty({}, "".concat(prefixCls, "-stack"), !!stack), "".concat(prefixCls, "-stack-expanded"), expanded)),
style: style,
keys: keys,
motionAppear: true
}, placementMotion, {
onAllRemoved: function onAllRemoved() {
onAllNoticeRemoved(placement);
}
}), function (_ref2, nodeRef) {
var config = _ref2.config,
motionClassName = _ref2.className,
motionStyle = _ref2.style,
motionIndex = _ref2.index;
var _ref3 = config,
key = _ref3.key,
times = _ref3.times;
var strKey = String(key);
var _ref4 = config,
configClassName = _ref4.className,
configStyle = _ref4.style,
configClassNames = _ref4.classNames,
configStyles = _ref4.styles,
restConfig = _objectWithoutProperties(_ref4, _excluded);
var dataIndex = keys.findIndex(function (item) {
return item.key === strKey;
});
// If dataIndex is -1, that means this notice has been removed in data, but still in dom
// Should minus (motionIndex - 1) to get the correct index because keys.length is not the same as dom length
var stackStyle = {};
if (stack) {
var index = keys.length - 1 - (dataIndex > -1 ? dataIndex : motionIndex - 1);
var transformX = placement === 'top' || placement === 'bottom' ? '-50%' : '0';
if (index > 0) {
var _dictRef$current$strK, _dictRef$current$strK2, _dictRef$current$strK3;
stackStyle.height = expanded ? (_dictRef$current$strK = dictRef.current[strKey]) === null || _dictRef$current$strK === void 0 ? void 0 : _dictRef$current$strK.offsetHeight : latestNotice === null || latestNotice === void 0 ? void 0 : latestNotice.offsetHeight;
// Transform
var verticalOffset = 0;
for (var i = 0; i < index; i++) {
var _dictRef$current$keys;
verticalOffset += ((_dictRef$current$keys = dictRef.current[keys[keys.length - 1 - i].key]) === null || _dictRef$current$keys === void 0 ? void 0 : _dictRef$current$keys.offsetHeight) + gap;
}
var transformY = (expanded ? verticalOffset : index * offset) * (placement.startsWith('top') ? 1 : -1);
var scaleX = !expanded && latestNotice !== null && latestNotice !== void 0 && latestNotice.offsetWidth && (_dictRef$current$strK2 = dictRef.current[strKey]) !== null && _dictRef$current$strK2 !== void 0 && _dictRef$current$strK2.offsetWidth ? ((latestNotice === null || latestNotice === void 0 ? void 0 : latestNotice.offsetWidth) - offset * 2 * (index < 3 ? index : 3)) / ((_dictRef$current$strK3 = dictRef.current[strKey]) === null || _dictRef$current$strK3 === void 0 ? void 0 : _dictRef$current$strK3.offsetWidth) : 1;
stackStyle.transform = "translate3d(".concat(transformX, ", ").concat(transformY, "px, 0) scaleX(").concat(scaleX, ")");
} else {
stackStyle.transform = "translate3d(".concat(transformX, ", 0, 0)");
}
}
return /*#__PURE__*/React.createElement("div", {
ref: nodeRef,
className: clsx("".concat(prefixCls, "-notice-wrapper"), motionClassName, configClassNames === null || configClassNames === void 0 ? void 0 : configClassNames.wrapper),
style: _objectSpread(_objectSpread(_objectSpread({}, motionStyle), stackStyle), configStyles === null || configStyles === void 0 ? void 0 : configStyles.wrapper),
onMouseEnter: function onMouseEnter() {
return setHoverKeys(function (prev) {
return prev.includes(strKey) ? prev : [].concat(_toConsumableArray(prev), [strKey]);
});
},
onMouseLeave: function onMouseLeave() {
return setHoverKeys(function (prev) {
return prev.filter(function (k) {
return k !== strKey;
});
});
}
}, /*#__PURE__*/React.createElement(Notice, _extends({}, restConfig, {
ref: function ref(node) {
if (dataIndex > -1) {
dictRef.current[strKey] = node;
} else {
delete dictRef.current[strKey];
}
},
prefixCls: prefixCls,
classNames: configClassNames,
styles: configStyles,
className: clsx(configClassName, ctxCls === null || ctxCls === void 0 ? void 0 : ctxCls.notice),
style: configStyle,
times: times,
key: key,
eventKey: key,
onNoticeClose: onNoticeClose,
hovering: stack && hoverKeys.length > 0
})));
});
};
if (process.env.NODE_ENV !== 'production') {
NoticeList.displayName = 'NoticeList';
}
export default NoticeList;

View File

@@ -0,0 +1,14 @@
import type { FC } from 'react';
import React from 'react';
export interface NotificationContextProps {
classNames?: {
notice?: string;
list?: string;
};
}
export declare const NotificationContext: React.Context<NotificationContextProps>;
export interface NotificationProviderProps extends NotificationContextProps {
children: React.ReactNode;
}
declare const NotificationProvider: FC<NotificationProviderProps>;
export default NotificationProvider;

View File

@@ -0,0 +1,12 @@
import React from 'react';
export var NotificationContext = /*#__PURE__*/React.createContext({});
var NotificationProvider = function NotificationProvider(_ref) {
var children = _ref.children,
classNames = _ref.classNames;
return /*#__PURE__*/React.createElement(NotificationContext.Provider, {
value: {
classNames: classNames
}
}, children);
};
export default NotificationProvider;

25
node_modules/rc-notification/es/Notifications.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import type { ReactElement } from 'react';
import type { CSSMotionProps } from 'rc-motion';
import type { OpenConfig, Placement, StackConfig } from './interface';
export interface NotificationsProps {
prefixCls?: string;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
container?: HTMLElement | ShadowRoot;
maxCount?: number;
className?: (placement: Placement) => string;
style?: (placement: Placement) => React.CSSProperties;
onAllRemoved?: VoidFunction;
stack?: StackConfig;
renderNotifications?: (node: ReactElement, info: {
prefixCls: string;
key: React.Key;
}) => ReactElement;
}
export interface NotificationsRef {
open: (config: OpenConfig) => void;
close: (key: React.Key) => void;
destroy: () => void;
}
declare const Notifications: React.ForwardRefExoticComponent<NotificationsProps & React.RefAttributes<NotificationsRef>>;
export default Notifications;

148
node_modules/rc-notification/es/Notifications.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import { createPortal } from 'react-dom';
import NoticeList from "./NoticeList";
// ant-notification ant-notification-topRight
var Notifications = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-notification' : _props$prefixCls,
container = props.container,
motion = props.motion,
maxCount = props.maxCount,
className = props.className,
style = props.style,
onAllRemoved = props.onAllRemoved,
stack = props.stack,
renderNotifications = props.renderNotifications;
var _React$useState = React.useState([]),
_React$useState2 = _slicedToArray(_React$useState, 2),
configList = _React$useState2[0],
setConfigList = _React$useState2[1];
// ======================== Close =========================
var onNoticeClose = function onNoticeClose(key) {
var _config$onClose;
// Trigger close event
var config = configList.find(function (item) {
return item.key === key;
});
config === null || config === void 0 || (_config$onClose = config.onClose) === null || _config$onClose === void 0 || _config$onClose.call(config);
setConfigList(function (list) {
return list.filter(function (item) {
return item.key !== key;
});
});
};
// ========================= Refs =========================
React.useImperativeHandle(ref, function () {
return {
open: function open(config) {
setConfigList(function (list) {
var clone = _toConsumableArray(list);
// Replace if exist
var index = clone.findIndex(function (item) {
return item.key === config.key;
});
var innerConfig = _objectSpread({}, config);
if (index >= 0) {
var _list$index;
innerConfig.times = (((_list$index = list[index]) === null || _list$index === void 0 ? void 0 : _list$index.times) || 0) + 1;
clone[index] = innerConfig;
} else {
innerConfig.times = 0;
clone.push(innerConfig);
}
if (maxCount > 0 && clone.length > maxCount) {
clone = clone.slice(-maxCount);
}
return clone;
});
},
close: function close(key) {
onNoticeClose(key);
},
destroy: function destroy() {
setConfigList([]);
}
};
});
// ====================== Placements ======================
var _React$useState3 = React.useState({}),
_React$useState4 = _slicedToArray(_React$useState3, 2),
placements = _React$useState4[0],
setPlacements = _React$useState4[1];
React.useEffect(function () {
var nextPlacements = {};
configList.forEach(function (config) {
var _config$placement = config.placement,
placement = _config$placement === void 0 ? 'topRight' : _config$placement;
if (placement) {
nextPlacements[placement] = nextPlacements[placement] || [];
nextPlacements[placement].push(config);
}
});
// Fill exist placements to avoid empty list causing remove without motion
Object.keys(placements).forEach(function (placement) {
nextPlacements[placement] = nextPlacements[placement] || [];
});
setPlacements(nextPlacements);
}, [configList]);
// Clean up container if all notices fade out
var onAllNoticeRemoved = function onAllNoticeRemoved(placement) {
setPlacements(function (originPlacements) {
var clone = _objectSpread({}, originPlacements);
var list = clone[placement] || [];
if (!list.length) {
delete clone[placement];
}
return clone;
});
};
// Effect tell that placements is empty now
var emptyRef = React.useRef(false);
React.useEffect(function () {
if (Object.keys(placements).length > 0) {
emptyRef.current = true;
} else if (emptyRef.current) {
// Trigger only when from exist to empty
onAllRemoved === null || onAllRemoved === void 0 || onAllRemoved();
emptyRef.current = false;
}
}, [placements]);
// ======================== Render ========================
if (!container) {
return null;
}
var placementList = Object.keys(placements);
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, placementList.map(function (placement) {
var placementConfigList = placements[placement];
var list = /*#__PURE__*/React.createElement(NoticeList, {
key: placement,
configList: placementConfigList,
placement: placement,
prefixCls: prefixCls,
className: className === null || className === void 0 ? void 0 : className(placement),
style: style === null || style === void 0 ? void 0 : style(placement),
motion: motion,
onNoticeClose: onNoticeClose,
onAllNoticeRemoved: onAllNoticeRemoved,
stack: stack
});
return renderNotifications ? renderNotifications(list, {
prefixCls: prefixCls,
key: placement
}) : list;
})), container);
});
if (process.env.NODE_ENV !== 'production') {
Notifications.displayName = 'Notifications';
}
export default Notifications;

View File

@@ -0,0 +1,35 @@
import type { CSSMotionProps } from 'rc-motion';
import * as React from 'react';
import type { NotificationsProps } from '../Notifications';
import type { OpenConfig, Placement, StackConfig } from '../interface';
type OptionalConfig = Partial<OpenConfig>;
export interface NotificationConfig {
prefixCls?: string;
/** Customize container. It will repeat call which means you should return same container element. */
getContainer?: () => HTMLElement | ShadowRoot;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
closeIcon?: React.ReactNode;
closable?: boolean | ({
closeIcon?: React.ReactNode;
} & React.AriaAttributes);
maxCount?: number;
duration?: number;
showProgress?: boolean;
pauseOnHover?: boolean;
/** @private. Config for notification holder style. Safe to remove if refactor */
className?: (placement: Placement) => string;
/** @private. Config for notification holder style. Safe to remove if refactor */
style?: (placement: Placement) => React.CSSProperties;
/** @private Trigger when all the notification closed. */
onAllRemoved?: VoidFunction;
stack?: StackConfig;
/** @private Slot for style in Notifications */
renderNotifications?: NotificationsProps['renderNotifications'];
}
export interface NotificationAPI {
open: (config: OptionalConfig) => void;
close: (key: React.Key) => void;
destroy: () => void;
}
export default function useNotification(rootConfig?: NotificationConfig): [NotificationAPI, React.ReactElement];
export {};

View File

@@ -0,0 +1,150 @@
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["getContainer", "motion", "prefixCls", "maxCount", "className", "style", "onAllRemoved", "stack", "renderNotifications"];
import * as React from 'react';
import Notifications from "../Notifications";
import { useEvent } from 'rc-util';
var defaultGetContainer = function defaultGetContainer() {
return document.body;
};
var uniqueKey = 0;
function mergeConfig() {
var clone = {};
for (var _len = arguments.length, objList = new Array(_len), _key = 0; _key < _len; _key++) {
objList[_key] = arguments[_key];
}
objList.forEach(function (obj) {
if (obj) {
Object.keys(obj).forEach(function (key) {
var val = obj[key];
if (val !== undefined) {
clone[key] = val;
}
});
}
});
return clone;
}
export default function useNotification() {
var rootConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _rootConfig$getContai = rootConfig.getContainer,
getContainer = _rootConfig$getContai === void 0 ? defaultGetContainer : _rootConfig$getContai,
motion = rootConfig.motion,
prefixCls = rootConfig.prefixCls,
maxCount = rootConfig.maxCount,
className = rootConfig.className,
style = rootConfig.style,
onAllRemoved = rootConfig.onAllRemoved,
stack = rootConfig.stack,
renderNotifications = rootConfig.renderNotifications,
shareConfig = _objectWithoutProperties(rootConfig, _excluded);
var _React$useState = React.useState(),
_React$useState2 = _slicedToArray(_React$useState, 2),
container = _React$useState2[0],
setContainer = _React$useState2[1];
var notificationsRef = React.useRef();
var contextHolder = /*#__PURE__*/React.createElement(Notifications, {
container: container,
ref: notificationsRef,
prefixCls: prefixCls,
motion: motion,
maxCount: maxCount,
className: className,
style: style,
onAllRemoved: onAllRemoved,
stack: stack,
renderNotifications: renderNotifications
});
var _React$useState3 = React.useState([]),
_React$useState4 = _slicedToArray(_React$useState3, 2),
taskQueue = _React$useState4[0],
setTaskQueue = _React$useState4[1];
var open = useEvent(function (config) {
var mergedConfig = mergeConfig(shareConfig, config);
if (mergedConfig.key === null || mergedConfig.key === undefined) {
mergedConfig.key = "rc-notification-".concat(uniqueKey);
uniqueKey += 1;
}
setTaskQueue(function (queue) {
return [].concat(_toConsumableArray(queue), [{
type: 'open',
config: mergedConfig
}]);
});
});
// ========================= Refs =========================
var api = React.useMemo(function () {
return {
open: open,
close: function close(key) {
setTaskQueue(function (queue) {
return [].concat(_toConsumableArray(queue), [{
type: 'close',
key: key
}]);
});
},
destroy: function destroy() {
setTaskQueue(function (queue) {
return [].concat(_toConsumableArray(queue), [{
type: 'destroy'
}]);
});
}
};
}, []);
// ======================= Container ======================
// React 18 should all in effect that we will check container in each render
// Which means getContainer should be stable.
React.useEffect(function () {
setContainer(getContainer());
});
// ======================== Effect ========================
React.useEffect(function () {
// Flush task when node ready
if (notificationsRef.current && taskQueue.length) {
taskQueue.forEach(function (task) {
switch (task.type) {
case 'open':
notificationsRef.current.open(task.config);
break;
case 'close':
notificationsRef.current.close(task.key);
break;
case 'destroy':
notificationsRef.current.destroy();
break;
}
});
// https://github.com/ant-design/ant-design/issues/52590
// React `startTransition` will run once `useEffect` but many times `setState`,
// So `setTaskQueue` with filtered array will cause infinite loop.
// We cache the first match queue instead.
var oriTaskQueue;
var tgtTaskQueue;
// React 17 will mix order of effect & setState in async
// - open: setState[0]
// - effect[0]
// - open: setState[1]
// - effect setState([]) * here will clean up [0, 1] in React 17
setTaskQueue(function (oriQueue) {
if (oriTaskQueue !== oriQueue || !tgtTaskQueue) {
oriTaskQueue = oriQueue;
tgtTaskQueue = oriQueue.filter(function (task) {
return !taskQueue.includes(task);
});
}
return tgtTaskQueue;
});
}
}, [taskQueue]);
// ======================== Return ========================
return [api, contextHolder];
}

5
node_modules/rc-notification/es/hooks/useStack.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import type { StackConfig } from '../interface';
type StackParams = Exclude<StackConfig, boolean>;
type UseStack = (config?: StackConfig) => [boolean, StackParams];
declare const useStack: UseStack;
export default useStack;

19
node_modules/rc-notification/es/hooks/useStack.js generated vendored Normal file
View File

@@ -0,0 +1,19 @@
import _typeof from "@babel/runtime/helpers/esm/typeof";
var DEFAULT_OFFSET = 8;
var DEFAULT_THRESHOLD = 3;
var DEFAULT_GAP = 16;
var useStack = function useStack(config) {
var result = {
offset: DEFAULT_OFFSET,
threshold: DEFAULT_THRESHOLD,
gap: DEFAULT_GAP
};
if (config && _typeof(config) === 'object') {
var _config$offset, _config$threshold, _config$gap;
result.offset = (_config$offset = config.offset) !== null && _config$offset !== void 0 ? _config$offset : DEFAULT_OFFSET;
result.threshold = (_config$threshold = config.threshold) !== null && _config$threshold !== void 0 ? _config$threshold : DEFAULT_THRESHOLD;
result.gap = (_config$gap = config.gap) !== null && _config$gap !== void 0 ? _config$gap : DEFAULT_GAP;
}
return [!!config, result];
};
export default useStack;

6
node_modules/rc-notification/es/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import useNotification from './hooks/useNotification';
import Notice from './Notice';
import type { NotificationAPI, NotificationConfig } from './hooks/useNotification';
import NotificationProvider from './NotificationProvider';
export { useNotification, Notice, NotificationProvider };
export type { NotificationAPI, NotificationConfig };

4
node_modules/rc-notification/es/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import useNotification from "./hooks/useNotification";
import Notice from "./Notice";
import NotificationProvider from "./NotificationProvider";
export { useNotification, Notice, NotificationProvider };

52
node_modules/rc-notification/es/interface.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import type React from 'react';
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
type NoticeSemanticProps = 'wrapper';
export interface NoticeConfig {
content?: React.ReactNode;
duration?: number | null;
showProgress?: boolean;
pauseOnHover?: boolean;
closeIcon?: React.ReactNode;
closable?: boolean | ({
closeIcon?: React.ReactNode;
} & React.AriaAttributes);
className?: string;
style?: React.CSSProperties;
classNames?: {
[key in NoticeSemanticProps]?: string;
};
styles?: {
[key in NoticeSemanticProps]?: React.CSSProperties;
};
/** @private Internal usage. Do not override in your code */
props?: React.HTMLAttributes<HTMLDivElement> & Record<string, any>;
onClose?: VoidFunction;
onClick?: React.MouseEventHandler<HTMLDivElement>;
}
export interface OpenConfig extends NoticeConfig {
key: React.Key;
placement?: Placement;
content?: React.ReactNode;
duration?: number | null;
}
export type InnerOpenConfig = OpenConfig & {
times?: number;
};
export type Placements = Partial<Record<Placement, OpenConfig[]>>;
export type StackConfig = boolean | {
/**
* When number is greater than threshold, notifications will be stacked together.
* @default 3
*/
threshold?: number;
/**
* Offset when notifications are stacked together.
* @default 8
*/
offset?: number;
/**
* Spacing between each notification when expanded.
*/
gap?: number;
};
export {};

1
node_modules/rc-notification/es/interface.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

15
node_modules/rc-notification/lib/Notice.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import * as React from 'react';
import type { NoticeConfig } from './interface';
export interface NoticeProps extends Omit<NoticeConfig, 'onClose'> {
prefixCls: string;
className?: string;
style?: React.CSSProperties;
eventKey: React.Key;
onClick?: React.MouseEventHandler<HTMLDivElement>;
onNoticeClose?: (key: React.Key) => void;
hovering?: boolean;
}
declare const Notify: React.ForwardRefExoticComponent<NoticeProps & {
times?: number;
} & React.RefAttributes<HTMLDivElement>>;
export default Notify;

157
node_modules/rc-notification/lib/Notice.js generated vendored Normal file
View File

@@ -0,0 +1,157 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof3 = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _classnames = _interopRequireDefault(require("classnames"));
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
var React = _interopRequireWildcard(require("react"));
var _pickAttrs = _interopRequireDefault(require("rc-util/lib/pickAttrs"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var Notify = /*#__PURE__*/React.forwardRef(function (props, ref) {
var prefixCls = props.prefixCls,
style = props.style,
className = props.className,
_props$duration = props.duration,
duration = _props$duration === void 0 ? 4.5 : _props$duration,
showProgress = props.showProgress,
_props$pauseOnHover = props.pauseOnHover,
pauseOnHover = _props$pauseOnHover === void 0 ? true : _props$pauseOnHover,
eventKey = props.eventKey,
content = props.content,
closable = props.closable,
_props$closeIcon = props.closeIcon,
closeIcon = _props$closeIcon === void 0 ? 'x' : _props$closeIcon,
divProps = props.props,
onClick = props.onClick,
onNoticeClose = props.onNoticeClose,
times = props.times,
forcedHovering = props.hovering;
var _React$useState = React.useState(false),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
hovering = _React$useState2[0],
setHovering = _React$useState2[1];
var _React$useState3 = React.useState(0),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
percent = _React$useState4[0],
setPercent = _React$useState4[1];
var _React$useState5 = React.useState(0),
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
spentTime = _React$useState6[0],
setSpentTime = _React$useState6[1];
var mergedHovering = forcedHovering || hovering;
var mergedShowProgress = duration > 0 && showProgress;
// ======================== Close =========================
var onInternalClose = function onInternalClose() {
onNoticeClose(eventKey);
};
var onCloseKeyDown = function onCloseKeyDown(e) {
if (e.key === 'Enter' || e.code === 'Enter' || e.keyCode === _KeyCode.default.ENTER) {
onInternalClose();
}
};
// ======================== Effect ========================
React.useEffect(function () {
if (!mergedHovering && duration > 0) {
var start = Date.now() - spentTime;
var timeout = setTimeout(function () {
onInternalClose();
}, duration * 1000 - spentTime);
return function () {
if (pauseOnHover) {
clearTimeout(timeout);
}
setSpentTime(Date.now() - start);
};
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [duration, mergedHovering, times]);
React.useEffect(function () {
if (!mergedHovering && mergedShowProgress && (pauseOnHover || spentTime === 0)) {
var start = performance.now();
var animationFrame;
var calculate = function calculate() {
cancelAnimationFrame(animationFrame);
animationFrame = requestAnimationFrame(function (timestamp) {
var runtime = timestamp + spentTime - start;
var progress = Math.min(runtime / (duration * 1000), 1);
setPercent(progress * 100);
if (progress < 1) {
calculate();
}
});
};
calculate();
return function () {
if (pauseOnHover) {
cancelAnimationFrame(animationFrame);
}
};
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [duration, spentTime, mergedHovering, mergedShowProgress, times]);
// ======================== Closable ========================
var closableObj = React.useMemo(function () {
if ((0, _typeof2.default)(closable) === 'object' && closable !== null) {
return closable;
}
if (closable) {
return {
closeIcon: closeIcon
};
}
return {};
}, [closable, closeIcon]);
var ariaProps = (0, _pickAttrs.default)(closableObj, true);
// ======================== Progress ========================
var validPercent = 100 - (!percent || percent < 0 ? 0 : percent > 100 ? 100 : percent);
// ======================== Render ========================
var noticePrefixCls = "".concat(prefixCls, "-notice");
return /*#__PURE__*/React.createElement("div", (0, _extends2.default)({}, divProps, {
ref: ref,
className: (0, _classnames.default)(noticePrefixCls, className, (0, _defineProperty2.default)({}, "".concat(noticePrefixCls, "-closable"), closable)),
style: style,
onMouseEnter: function onMouseEnter(e) {
var _divProps$onMouseEnte;
setHovering(true);
divProps === null || divProps === void 0 || (_divProps$onMouseEnte = divProps.onMouseEnter) === null || _divProps$onMouseEnte === void 0 || _divProps$onMouseEnte.call(divProps, e);
},
onMouseLeave: function onMouseLeave(e) {
var _divProps$onMouseLeav;
setHovering(false);
divProps === null || divProps === void 0 || (_divProps$onMouseLeav = divProps.onMouseLeave) === null || _divProps$onMouseLeav === void 0 || _divProps$onMouseLeav.call(divProps, e);
},
onClick: onClick
}), /*#__PURE__*/React.createElement("div", {
className: "".concat(noticePrefixCls, "-content")
}, content), closable && /*#__PURE__*/React.createElement("a", (0, _extends2.default)({
tabIndex: 0,
className: "".concat(noticePrefixCls, "-close"),
onKeyDown: onCloseKeyDown,
"aria-label": "Close"
}, ariaProps, {
onClick: function onClick(e) {
e.preventDefault();
e.stopPropagation();
onInternalClose();
}
}), closableObj.closeIcon), mergedShowProgress && /*#__PURE__*/React.createElement("progress", {
className: "".concat(noticePrefixCls, "-progress"),
max: "100",
value: validPercent
}, validPercent + '%'));
});
var _default = exports.default = Notify;

17
node_modules/rc-notification/lib/NoticeList.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import type { CSSProperties, FC } from 'react';
import React from 'react';
import type { CSSMotionProps } from 'rc-motion';
import type { OpenConfig, Placement, StackConfig } from './interface';
export interface NoticeListProps {
configList?: OpenConfig[];
placement?: Placement;
prefixCls?: string;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
stack?: StackConfig;
onAllNoticeRemoved?: (placement: Placement) => void;
onNoticeClose?: (key: React.Key) => void;
className?: string;
style?: CSSProperties;
}
declare const NoticeList: FC<NoticeListProps>;
export default NoticeList;

175
node_modules/rc-notification/lib/NoticeList.js generated vendored Normal file
View File

@@ -0,0 +1,175 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _rcMotion = require("rc-motion");
var _Notice = _interopRequireDefault(require("./Notice"));
var _NotificationProvider = require("./NotificationProvider");
var _useStack3 = _interopRequireDefault(require("./hooks/useStack"));
var _excluded = ["className", "style", "classNames", "styles"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var NoticeList = function NoticeList(props) {
var configList = props.configList,
placement = props.placement,
prefixCls = props.prefixCls,
className = props.className,
style = props.style,
motion = props.motion,
onAllNoticeRemoved = props.onAllNoticeRemoved,
onNoticeClose = props.onNoticeClose,
stackConfig = props.stack;
var _useContext = (0, _react.useContext)(_NotificationProvider.NotificationContext),
ctxCls = _useContext.classNames;
var dictRef = (0, _react.useRef)({});
var _useState = (0, _react.useState)(null),
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
latestNotice = _useState2[0],
setLatestNotice = _useState2[1];
var _useState3 = (0, _react.useState)([]),
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
hoverKeys = _useState4[0],
setHoverKeys = _useState4[1];
var keys = configList.map(function (config) {
return {
config: config,
key: String(config.key)
};
});
var _useStack = (0, _useStack3.default)(stackConfig),
_useStack2 = (0, _slicedToArray2.default)(_useStack, 2),
stack = _useStack2[0],
_useStack2$ = _useStack2[1],
offset = _useStack2$.offset,
threshold = _useStack2$.threshold,
gap = _useStack2$.gap;
var expanded = stack && (hoverKeys.length > 0 || keys.length <= threshold);
var placementMotion = typeof motion === 'function' ? motion(placement) : motion;
// Clean hover key
(0, _react.useEffect)(function () {
if (stack && hoverKeys.length > 1) {
setHoverKeys(function (prev) {
return prev.filter(function (key) {
return keys.some(function (_ref) {
var dataKey = _ref.key;
return key === dataKey;
});
});
});
}
}, [hoverKeys, keys, stack]);
// Force update latest notice
(0, _react.useEffect)(function () {
var _keys;
if (stack && dictRef.current[(_keys = keys[keys.length - 1]) === null || _keys === void 0 ? void 0 : _keys.key]) {
var _keys2;
setLatestNotice(dictRef.current[(_keys2 = keys[keys.length - 1]) === null || _keys2 === void 0 ? void 0 : _keys2.key]);
}
}, [keys, stack]);
return /*#__PURE__*/_react.default.createElement(_rcMotion.CSSMotionList, (0, _extends2.default)({
key: placement,
className: (0, _classnames.default)(prefixCls, "".concat(prefixCls, "-").concat(placement), ctxCls === null || ctxCls === void 0 ? void 0 : ctxCls.list, className, (0, _defineProperty2.default)((0, _defineProperty2.default)({}, "".concat(prefixCls, "-stack"), !!stack), "".concat(prefixCls, "-stack-expanded"), expanded)),
style: style,
keys: keys,
motionAppear: true
}, placementMotion, {
onAllRemoved: function onAllRemoved() {
onAllNoticeRemoved(placement);
}
}), function (_ref2, nodeRef) {
var config = _ref2.config,
motionClassName = _ref2.className,
motionStyle = _ref2.style,
motionIndex = _ref2.index;
var _ref3 = config,
key = _ref3.key,
times = _ref3.times;
var strKey = String(key);
var _ref4 = config,
configClassName = _ref4.className,
configStyle = _ref4.style,
configClassNames = _ref4.classNames,
configStyles = _ref4.styles,
restConfig = (0, _objectWithoutProperties2.default)(_ref4, _excluded);
var dataIndex = keys.findIndex(function (item) {
return item.key === strKey;
});
// If dataIndex is -1, that means this notice has been removed in data, but still in dom
// Should minus (motionIndex - 1) to get the correct index because keys.length is not the same as dom length
var stackStyle = {};
if (stack) {
var index = keys.length - 1 - (dataIndex > -1 ? dataIndex : motionIndex - 1);
var transformX = placement === 'top' || placement === 'bottom' ? '-50%' : '0';
if (index > 0) {
var _dictRef$current$strK, _dictRef$current$strK2, _dictRef$current$strK3;
stackStyle.height = expanded ? (_dictRef$current$strK = dictRef.current[strKey]) === null || _dictRef$current$strK === void 0 ? void 0 : _dictRef$current$strK.offsetHeight : latestNotice === null || latestNotice === void 0 ? void 0 : latestNotice.offsetHeight;
// Transform
var verticalOffset = 0;
for (var i = 0; i < index; i++) {
var _dictRef$current$keys;
verticalOffset += ((_dictRef$current$keys = dictRef.current[keys[keys.length - 1 - i].key]) === null || _dictRef$current$keys === void 0 ? void 0 : _dictRef$current$keys.offsetHeight) + gap;
}
var transformY = (expanded ? verticalOffset : index * offset) * (placement.startsWith('top') ? 1 : -1);
var scaleX = !expanded && latestNotice !== null && latestNotice !== void 0 && latestNotice.offsetWidth && (_dictRef$current$strK2 = dictRef.current[strKey]) !== null && _dictRef$current$strK2 !== void 0 && _dictRef$current$strK2.offsetWidth ? ((latestNotice === null || latestNotice === void 0 ? void 0 : latestNotice.offsetWidth) - offset * 2 * (index < 3 ? index : 3)) / ((_dictRef$current$strK3 = dictRef.current[strKey]) === null || _dictRef$current$strK3 === void 0 ? void 0 : _dictRef$current$strK3.offsetWidth) : 1;
stackStyle.transform = "translate3d(".concat(transformX, ", ").concat(transformY, "px, 0) scaleX(").concat(scaleX, ")");
} else {
stackStyle.transform = "translate3d(".concat(transformX, ", 0, 0)");
}
}
return /*#__PURE__*/_react.default.createElement("div", {
ref: nodeRef,
className: (0, _classnames.default)("".concat(prefixCls, "-notice-wrapper"), motionClassName, configClassNames === null || configClassNames === void 0 ? void 0 : configClassNames.wrapper),
style: (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, motionStyle), stackStyle), configStyles === null || configStyles === void 0 ? void 0 : configStyles.wrapper),
onMouseEnter: function onMouseEnter() {
return setHoverKeys(function (prev) {
return prev.includes(strKey) ? prev : [].concat((0, _toConsumableArray2.default)(prev), [strKey]);
});
},
onMouseLeave: function onMouseLeave() {
return setHoverKeys(function (prev) {
return prev.filter(function (k) {
return k !== strKey;
});
});
}
}, /*#__PURE__*/_react.default.createElement(_Notice.default, (0, _extends2.default)({}, restConfig, {
ref: function ref(node) {
if (dataIndex > -1) {
dictRef.current[strKey] = node;
} else {
delete dictRef.current[strKey];
}
},
prefixCls: prefixCls,
classNames: configClassNames,
styles: configStyles,
className: (0, _classnames.default)(configClassName, ctxCls === null || ctxCls === void 0 ? void 0 : ctxCls.notice),
style: configStyle,
times: times,
key: key,
eventKey: key,
onNoticeClose: onNoticeClose,
hovering: stack && hoverKeys.length > 0
})));
});
};
if (process.env.NODE_ENV !== 'production') {
NoticeList.displayName = 'NoticeList';
}
var _default = exports.default = NoticeList;

View File

@@ -0,0 +1,14 @@
import type { FC } from 'react';
import React from 'react';
export interface NotificationContextProps {
classNames?: {
notice?: string;
list?: string;
};
}
export declare const NotificationContext: React.Context<NotificationContextProps>;
export interface NotificationProviderProps extends NotificationContextProps {
children: React.ReactNode;
}
declare const NotificationProvider: FC<NotificationProviderProps>;
export default NotificationProvider;

View File

@@ -0,0 +1,19 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.NotificationContext = void 0;
var _react = _interopRequireDefault(require("react"));
var NotificationContext = exports.NotificationContext = /*#__PURE__*/_react.default.createContext({});
var NotificationProvider = function NotificationProvider(_ref) {
var children = _ref.children,
classNames = _ref.classNames;
return /*#__PURE__*/_react.default.createElement(NotificationContext.Provider, {
value: {
classNames: classNames
}
}, children);
};
var _default = exports.default = NotificationProvider;

25
node_modules/rc-notification/lib/Notifications.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import * as React from 'react';
import type { ReactElement } from 'react';
import type { CSSMotionProps } from 'rc-motion';
import type { OpenConfig, Placement, StackConfig } from './interface';
export interface NotificationsProps {
prefixCls?: string;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
container?: HTMLElement | ShadowRoot;
maxCount?: number;
className?: (placement: Placement) => string;
style?: (placement: Placement) => React.CSSProperties;
onAllRemoved?: VoidFunction;
stack?: StackConfig;
renderNotifications?: (node: ReactElement, info: {
prefixCls: string;
key: React.Key;
}) => ReactElement;
}
export interface NotificationsRef {
open: (config: OpenConfig) => void;
close: (key: React.Key) => void;
destroy: () => void;
}
declare const Notifications: React.ForwardRefExoticComponent<NotificationsProps & React.RefAttributes<NotificationsRef>>;
export default Notifications;

158
node_modules/rc-notification/lib/Notifications.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _reactDom = require("react-dom");
var _NoticeList = _interopRequireDefault(require("./NoticeList"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
// ant-notification ant-notification-topRight
var Notifications = /*#__PURE__*/React.forwardRef(function (props, ref) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? 'rc-notification' : _props$prefixCls,
container = props.container,
motion = props.motion,
maxCount = props.maxCount,
className = props.className,
style = props.style,
onAllRemoved = props.onAllRemoved,
stack = props.stack,
renderNotifications = props.renderNotifications;
var _React$useState = React.useState([]),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
configList = _React$useState2[0],
setConfigList = _React$useState2[1];
// ======================== Close =========================
var onNoticeClose = function onNoticeClose(key) {
var _config$onClose;
// Trigger close event
var config = configList.find(function (item) {
return item.key === key;
});
config === null || config === void 0 || (_config$onClose = config.onClose) === null || _config$onClose === void 0 || _config$onClose.call(config);
setConfigList(function (list) {
return list.filter(function (item) {
return item.key !== key;
});
});
};
// ========================= Refs =========================
React.useImperativeHandle(ref, function () {
return {
open: function open(config) {
setConfigList(function (list) {
var clone = (0, _toConsumableArray2.default)(list);
// Replace if exist
var index = clone.findIndex(function (item) {
return item.key === config.key;
});
var innerConfig = (0, _objectSpread2.default)({}, config);
if (index >= 0) {
var _list$index;
innerConfig.times = (((_list$index = list[index]) === null || _list$index === void 0 ? void 0 : _list$index.times) || 0) + 1;
clone[index] = innerConfig;
} else {
innerConfig.times = 0;
clone.push(innerConfig);
}
if (maxCount > 0 && clone.length > maxCount) {
clone = clone.slice(-maxCount);
}
return clone;
});
},
close: function close(key) {
onNoticeClose(key);
},
destroy: function destroy() {
setConfigList([]);
}
};
});
// ====================== Placements ======================
var _React$useState3 = React.useState({}),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
placements = _React$useState4[0],
setPlacements = _React$useState4[1];
React.useEffect(function () {
var nextPlacements = {};
configList.forEach(function (config) {
var _config$placement = config.placement,
placement = _config$placement === void 0 ? 'topRight' : _config$placement;
if (placement) {
nextPlacements[placement] = nextPlacements[placement] || [];
nextPlacements[placement].push(config);
}
});
// Fill exist placements to avoid empty list causing remove without motion
Object.keys(placements).forEach(function (placement) {
nextPlacements[placement] = nextPlacements[placement] || [];
});
setPlacements(nextPlacements);
}, [configList]);
// Clean up container if all notices fade out
var onAllNoticeRemoved = function onAllNoticeRemoved(placement) {
setPlacements(function (originPlacements) {
var clone = (0, _objectSpread2.default)({}, originPlacements);
var list = clone[placement] || [];
if (!list.length) {
delete clone[placement];
}
return clone;
});
};
// Effect tell that placements is empty now
var emptyRef = React.useRef(false);
React.useEffect(function () {
if (Object.keys(placements).length > 0) {
emptyRef.current = true;
} else if (emptyRef.current) {
// Trigger only when from exist to empty
onAllRemoved === null || onAllRemoved === void 0 || onAllRemoved();
emptyRef.current = false;
}
}, [placements]);
// ======================== Render ========================
if (!container) {
return null;
}
var placementList = Object.keys(placements);
return /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/React.createElement(React.Fragment, null, placementList.map(function (placement) {
var placementConfigList = placements[placement];
var list = /*#__PURE__*/React.createElement(_NoticeList.default, {
key: placement,
configList: placementConfigList,
placement: placement,
prefixCls: prefixCls,
className: className === null || className === void 0 ? void 0 : className(placement),
style: style === null || style === void 0 ? void 0 : style(placement),
motion: motion,
onNoticeClose: onNoticeClose,
onAllNoticeRemoved: onAllNoticeRemoved,
stack: stack
});
return renderNotifications ? renderNotifications(list, {
prefixCls: prefixCls,
key: placement
}) : list;
})), container);
});
if (process.env.NODE_ENV !== 'production') {
Notifications.displayName = 'Notifications';
}
var _default = exports.default = Notifications;

View File

@@ -0,0 +1,35 @@
import type { CSSMotionProps } from 'rc-motion';
import * as React from 'react';
import type { NotificationsProps } from '../Notifications';
import type { OpenConfig, Placement, StackConfig } from '../interface';
type OptionalConfig = Partial<OpenConfig>;
export interface NotificationConfig {
prefixCls?: string;
/** Customize container. It will repeat call which means you should return same container element. */
getContainer?: () => HTMLElement | ShadowRoot;
motion?: CSSMotionProps | ((placement: Placement) => CSSMotionProps);
closeIcon?: React.ReactNode;
closable?: boolean | ({
closeIcon?: React.ReactNode;
} & React.AriaAttributes);
maxCount?: number;
duration?: number;
showProgress?: boolean;
pauseOnHover?: boolean;
/** @private. Config for notification holder style. Safe to remove if refactor */
className?: (placement: Placement) => string;
/** @private. Config for notification holder style. Safe to remove if refactor */
style?: (placement: Placement) => React.CSSProperties;
/** @private Trigger when all the notification closed. */
onAllRemoved?: VoidFunction;
stack?: StackConfig;
/** @private Slot for style in Notifications */
renderNotifications?: NotificationsProps['renderNotifications'];
}
export interface NotificationAPI {
open: (config: OptionalConfig) => void;
close: (key: React.Key) => void;
destroy: () => void;
}
export default function useNotification(rootConfig?: NotificationConfig): [NotificationAPI, React.ReactElement];
export {};

View File

@@ -0,0 +1,160 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNotification;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var React = _interopRequireWildcard(require("react"));
var _Notifications = _interopRequireDefault(require("../Notifications"));
var _rcUtil = require("rc-util");
var _excluded = ["getContainer", "motion", "prefixCls", "maxCount", "className", "style", "onAllRemoved", "stack", "renderNotifications"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var defaultGetContainer = function defaultGetContainer() {
return document.body;
};
var uniqueKey = 0;
function mergeConfig() {
var clone = {};
for (var _len = arguments.length, objList = new Array(_len), _key = 0; _key < _len; _key++) {
objList[_key] = arguments[_key];
}
objList.forEach(function (obj) {
if (obj) {
Object.keys(obj).forEach(function (key) {
var val = obj[key];
if (val !== undefined) {
clone[key] = val;
}
});
}
});
return clone;
}
function useNotification() {
var rootConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _rootConfig$getContai = rootConfig.getContainer,
getContainer = _rootConfig$getContai === void 0 ? defaultGetContainer : _rootConfig$getContai,
motion = rootConfig.motion,
prefixCls = rootConfig.prefixCls,
maxCount = rootConfig.maxCount,
className = rootConfig.className,
style = rootConfig.style,
onAllRemoved = rootConfig.onAllRemoved,
stack = rootConfig.stack,
renderNotifications = rootConfig.renderNotifications,
shareConfig = (0, _objectWithoutProperties2.default)(rootConfig, _excluded);
var _React$useState = React.useState(),
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
container = _React$useState2[0],
setContainer = _React$useState2[1];
var notificationsRef = React.useRef();
var contextHolder = /*#__PURE__*/React.createElement(_Notifications.default, {
container: container,
ref: notificationsRef,
prefixCls: prefixCls,
motion: motion,
maxCount: maxCount,
className: className,
style: style,
onAllRemoved: onAllRemoved,
stack: stack,
renderNotifications: renderNotifications
});
var _React$useState3 = React.useState([]),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
taskQueue = _React$useState4[0],
setTaskQueue = _React$useState4[1];
var open = (0, _rcUtil.useEvent)(function (config) {
var mergedConfig = mergeConfig(shareConfig, config);
if (mergedConfig.key === null || mergedConfig.key === undefined) {
mergedConfig.key = "rc-notification-".concat(uniqueKey);
uniqueKey += 1;
}
setTaskQueue(function (queue) {
return [].concat((0, _toConsumableArray2.default)(queue), [{
type: 'open',
config: mergedConfig
}]);
});
});
// ========================= Refs =========================
var api = React.useMemo(function () {
return {
open: open,
close: function close(key) {
setTaskQueue(function (queue) {
return [].concat((0, _toConsumableArray2.default)(queue), [{
type: 'close',
key: key
}]);
});
},
destroy: function destroy() {
setTaskQueue(function (queue) {
return [].concat((0, _toConsumableArray2.default)(queue), [{
type: 'destroy'
}]);
});
}
};
}, []);
// ======================= Container ======================
// React 18 should all in effect that we will check container in each render
// Which means getContainer should be stable.
React.useEffect(function () {
setContainer(getContainer());
});
// ======================== Effect ========================
React.useEffect(function () {
// Flush task when node ready
if (notificationsRef.current && taskQueue.length) {
taskQueue.forEach(function (task) {
switch (task.type) {
case 'open':
notificationsRef.current.open(task.config);
break;
case 'close':
notificationsRef.current.close(task.key);
break;
case 'destroy':
notificationsRef.current.destroy();
break;
}
});
// https://github.com/ant-design/ant-design/issues/52590
// React `startTransition` will run once `useEffect` but many times `setState`,
// So `setTaskQueue` with filtered array will cause infinite loop.
// We cache the first match queue instead.
var oriTaskQueue;
var tgtTaskQueue;
// React 17 will mix order of effect & setState in async
// - open: setState[0]
// - effect[0]
// - open: setState[1]
// - effect setState([]) * here will clean up [0, 1] in React 17
setTaskQueue(function (oriQueue) {
if (oriTaskQueue !== oriQueue || !tgtTaskQueue) {
oriTaskQueue = oriQueue;
tgtTaskQueue = oriQueue.filter(function (task) {
return !taskQueue.includes(task);
});
}
return tgtTaskQueue;
});
}
}, [taskQueue]);
// ======================== Return ========================
return [api, contextHolder];
}

5
node_modules/rc-notification/lib/hooks/useStack.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import type { StackConfig } from '../interface';
type StackParams = Exclude<StackConfig, boolean>;
type UseStack = (config?: StackConfig) => [boolean, StackParams];
declare const useStack: UseStack;
export default useStack;

26
node_modules/rc-notification/lib/hooks/useStack.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var DEFAULT_OFFSET = 8;
var DEFAULT_THRESHOLD = 3;
var DEFAULT_GAP = 16;
var useStack = function useStack(config) {
var result = {
offset: DEFAULT_OFFSET,
threshold: DEFAULT_THRESHOLD,
gap: DEFAULT_GAP
};
if (config && (0, _typeof2.default)(config) === 'object') {
var _config$offset, _config$threshold, _config$gap;
result.offset = (_config$offset = config.offset) !== null && _config$offset !== void 0 ? _config$offset : DEFAULT_OFFSET;
result.threshold = (_config$threshold = config.threshold) !== null && _config$threshold !== void 0 ? _config$threshold : DEFAULT_THRESHOLD;
result.gap = (_config$gap = config.gap) !== null && _config$gap !== void 0 ? _config$gap : DEFAULT_GAP;
}
return [!!config, result];
};
var _default = exports.default = useStack;

6
node_modules/rc-notification/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import useNotification from './hooks/useNotification';
import Notice from './Notice';
import type { NotificationAPI, NotificationConfig } from './hooks/useNotification';
import NotificationProvider from './NotificationProvider';
export { useNotification, Notice, NotificationProvider };
export type { NotificationAPI, NotificationConfig };

27
node_modules/rc-notification/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Notice", {
enumerable: true,
get: function get() {
return _Notice.default;
}
});
Object.defineProperty(exports, "NotificationProvider", {
enumerable: true,
get: function get() {
return _NotificationProvider.default;
}
});
Object.defineProperty(exports, "useNotification", {
enumerable: true,
get: function get() {
return _useNotification.default;
}
});
var _useNotification = _interopRequireDefault(require("./hooks/useNotification"));
var _Notice = _interopRequireDefault(require("./Notice"));
var _NotificationProvider = _interopRequireDefault(require("./NotificationProvider"));

52
node_modules/rc-notification/lib/interface.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import type React from 'react';
export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight';
type NoticeSemanticProps = 'wrapper';
export interface NoticeConfig {
content?: React.ReactNode;
duration?: number | null;
showProgress?: boolean;
pauseOnHover?: boolean;
closeIcon?: React.ReactNode;
closable?: boolean | ({
closeIcon?: React.ReactNode;
} & React.AriaAttributes);
className?: string;
style?: React.CSSProperties;
classNames?: {
[key in NoticeSemanticProps]?: string;
};
styles?: {
[key in NoticeSemanticProps]?: React.CSSProperties;
};
/** @private Internal usage. Do not override in your code */
props?: React.HTMLAttributes<HTMLDivElement> & Record<string, any>;
onClose?: VoidFunction;
onClick?: React.MouseEventHandler<HTMLDivElement>;
}
export interface OpenConfig extends NoticeConfig {
key: React.Key;
placement?: Placement;
content?: React.ReactNode;
duration?: number | null;
}
export type InnerOpenConfig = OpenConfig & {
times?: number;
};
export type Placements = Partial<Record<Placement, OpenConfig[]>>;
export type StackConfig = boolean | {
/**
* When number is greater than threshold, notifications will be stacked together.
* @default 3
*/
threshold?: number;
/**
* Offset when notifications are stacked together.
* @default 8
*/
offset?: number;
/**
* Spacing between each notification when expanded.
*/
gap?: number;
};
export {};

5
node_modules/rc-notification/lib/interface.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});

92
node_modules/rc-notification/package.json generated vendored Normal file
View File

@@ -0,0 +1,92 @@
{
"name": "rc-notification",
"version": "5.6.4",
"description": "notification ui component for react",
"engines": {
"node": ">=8.x"
},
"keywords": [
"react",
"react-component",
"react-notification",
"notification"
],
"homepage": "http://github.com/react-component/notification",
"maintainers": [
"yiminghe@gmail.com",
"skyking_H@hotmail.com",
"hust2012jiangkai@gmail.com"
],
"files": [
"assets/*.css",
"assets/*.less",
"es",
"lib"
],
"repository": {
"type": "git",
"url": "git@github.com:react-component/notification.git"
},
"bugs": {
"url": "http://github.com/react-component/notification/issues"
},
"license": "MIT",
"main": "lib/index",
"module": "es/index",
"typings": "es/index.d.ts",
"scripts": {
"start": "dumi dev",
"build": "dumi build",
"docs:deploy": "gh-pages -d .doc",
"compile": "father build && lessc assets/index.less assets/index.css",
"prepublishOnly": "npm run compile && np --yolo --no-publish --branch antd-5.x",
"lint": "eslint src/ docs/examples/ --ext .tsx,.ts,.jsx,.js",
"test": "vitest --watch=false",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
"now-build": "npm run build",
"prepare": "husky install"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
},
"devDependencies": {
"@rc-component/father-plugin": "^1.0.2",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^15.0.7",
"@types/classnames": "^2.2.10",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/testing-library__jest-dom": "^6.0.0",
"@umijs/fabric": "^2.0.0",
"@vitest/coverage-v8": "^0.34.2",
"cross-env": "^7.0.0",
"dumi": "^2.1.0",
"eslint": "^7.8.1",
"father": "^4.0.0",
"gh-pages": "^3.1.0",
"husky": "^8.0.3",
"jsdom": "^24.0.0",
"less": "^4.2.0",
"lint-staged": "^14.0.1",
"np": "^10.0.5",
"prettier": "^3.0.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^5.4.5",
"vitest": "^0.34.2"
},
"dependencies": {
"@babel/runtime": "^7.10.1",
"classnames": "2.x",
"rc-motion": "^2.9.0",
"rc-util": "^5.20.1"
},
"lint-staged": {
"**/*.{js,jsx,tsx,ts,md,json}": [
"prettier --write",
"git add"
]
}
}