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

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 {};