123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.prepareNotificationToken = exports.prepareComponentToken = exports.genNoticeStyle = exports.default = void 0;
- var _cssinjs = require("@ant-design/cssinjs");
- var _useZIndex = require("../../_util/hooks/useZIndex");
- var _style = require("../../style");
- var _internal = require("../../theme/internal");
- var _placement = _interopRequireDefault(require("./placement"));
- var _stack = _interopRequireDefault(require("./stack"));
- const genNoticeStyle = token => {
- const {
- iconCls,
- componentCls,
- // .ant-notification
- boxShadow,
- fontSizeLG,
- notificationMarginBottom,
- borderRadiusLG,
- colorSuccess,
- colorInfo,
- colorWarning,
- colorError,
- colorTextHeading,
- notificationBg,
- notificationPadding,
- notificationMarginEdge,
- notificationProgressBg,
- notificationProgressHeight,
- fontSize,
- lineHeight,
- width,
- notificationIconSize,
- colorText
- } = token;
- const noticeCls = `${componentCls}-notice`;
- return {
- position: 'relative',
- marginBottom: notificationMarginBottom,
- marginInlineStart: 'auto',
- background: notificationBg,
- borderRadius: borderRadiusLG,
- boxShadow,
- [noticeCls]: {
- padding: notificationPadding,
- width,
- maxWidth: `calc(100vw - ${(0, _cssinjs.unit)(token.calc(notificationMarginEdge).mul(2).equal())})`,
- overflow: 'hidden',
- lineHeight,
- wordWrap: 'break-word'
- },
- [`${noticeCls}-message`]: {
- color: colorTextHeading,
- fontSize: fontSizeLG,
- lineHeight: token.lineHeightLG
- },
- [`${noticeCls}-description`]: {
- fontSize,
- color: colorText,
- marginTop: token.marginXS
- },
- [`${noticeCls}-closable ${noticeCls}-message`]: {
- paddingInlineEnd: token.paddingLG
- },
- [`${noticeCls}-with-icon ${noticeCls}-message`]: {
- marginInlineStart: token.calc(token.marginSM).add(notificationIconSize).equal(),
- fontSize: fontSizeLG
- },
- [`${noticeCls}-with-icon ${noticeCls}-description`]: {
- marginInlineStart: token.calc(token.marginSM).add(notificationIconSize).equal(),
- fontSize
- },
- // Icon & color style in different selector level
- // https://github.com/ant-design/ant-design/issues/16503
- // https://github.com/ant-design/ant-design/issues/15512
- [`${noticeCls}-icon`]: {
- position: 'absolute',
- fontSize: notificationIconSize,
- lineHeight: 1,
- // icon-font
- [`&-success${iconCls}`]: {
- color: colorSuccess
- },
- [`&-info${iconCls}`]: {
- color: colorInfo
- },
- [`&-warning${iconCls}`]: {
- color: colorWarning
- },
- [`&-error${iconCls}`]: {
- color: colorError
- }
- },
- [`${noticeCls}-close`]: Object.assign({
- position: 'absolute',
- top: token.notificationPaddingVertical,
- insetInlineEnd: token.notificationPaddingHorizontal,
- color: token.colorIcon,
- outline: 'none',
- width: token.notificationCloseButtonSize,
- height: token.notificationCloseButtonSize,
- borderRadius: token.borderRadiusSM,
- transition: `background-color ${token.motionDurationMid}, color ${token.motionDurationMid}`,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- background: 'none',
- border: 'none',
- '&:hover': {
- color: token.colorIconHover,
- backgroundColor: token.colorBgTextHover
- },
- '&:active': {
- backgroundColor: token.colorBgTextActive
- }
- }, (0, _style.genFocusStyle)(token)),
- [`${noticeCls}-progress`]: {
- position: 'absolute',
- display: 'block',
- appearance: 'none',
- inlineSize: `calc(100% - ${(0, _cssinjs.unit)(borderRadiusLG)} * 2)`,
- left: {
- _skip_check_: true,
- value: borderRadiusLG
- },
- right: {
- _skip_check_: true,
- value: borderRadiusLG
- },
- bottom: 0,
- blockSize: notificationProgressHeight,
- border: 0,
- '&, &::-webkit-progress-bar': {
- borderRadius: borderRadiusLG,
- backgroundColor: `rgba(0, 0, 0, 0.04)`
- },
- '&::-moz-progress-bar': {
- background: notificationProgressBg
- },
- '&::-webkit-progress-value': {
- borderRadius: borderRadiusLG,
- background: notificationProgressBg
- }
- },
- [`${noticeCls}-actions`]: {
- float: 'right',
- marginTop: token.marginSM
- }
- };
- };
- exports.genNoticeStyle = genNoticeStyle;
- const genNotificationStyle = token => {
- const {
- componentCls,
- // .ant-notification
- notificationMarginBottom,
- notificationMarginEdge,
- motionDurationMid,
- motionEaseInOut
- } = token;
- const noticeCls = `${componentCls}-notice`;
- const fadeOut = new _cssinjs.Keyframes('antNotificationFadeOut', {
- '0%': {
- maxHeight: token.animationMaxHeight,
- marginBottom: notificationMarginBottom
- },
- '100%': {
- maxHeight: 0,
- marginBottom: 0,
- paddingTop: 0,
- paddingBottom: 0,
- opacity: 0
- }
- });
- return [
- // ============================ Holder ============================
- {
- [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
- position: 'fixed',
- zIndex: token.zIndexPopup,
- marginRight: {
- value: notificationMarginEdge,
- _skip_check_: true
- },
- [`${componentCls}-hook-holder`]: {
- position: 'relative'
- },
- // animation
- [`${componentCls}-fade-appear-prepare`]: {
- opacity: '0 !important'
- },
- [`${componentCls}-fade-enter, ${componentCls}-fade-appear`]: {
- animationDuration: token.motionDurationMid,
- animationTimingFunction: motionEaseInOut,
- animationFillMode: 'both',
- opacity: 0,
- animationPlayState: 'paused'
- },
- [`${componentCls}-fade-leave`]: {
- animationTimingFunction: motionEaseInOut,
- animationFillMode: 'both',
- animationDuration: motionDurationMid,
- animationPlayState: 'paused'
- },
- [`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]: {
- animationPlayState: 'running'
- },
- [`${componentCls}-fade-leave${componentCls}-fade-leave-active`]: {
- animationName: fadeOut,
- animationPlayState: 'running'
- },
- // RTL
- '&-rtl': {
- direction: 'rtl',
- [`${noticeCls}-actions`]: {
- float: 'left'
- }
- }
- })
- },
- // ============================ Notice ============================
- {
- [componentCls]: {
- [`${noticeCls}-wrapper`]: Object.assign({}, genNoticeStyle(token))
- }
- }];
- };
- // ============================== Export ==============================
- const prepareComponentToken = token => ({
- zIndexPopup: token.zIndexPopupBase + _useZIndex.CONTAINER_MAX_OFFSET + 50,
- width: 384
- });
- exports.prepareComponentToken = prepareComponentToken;
- const prepareNotificationToken = token => {
- const notificationPaddingVertical = token.paddingMD;
- const notificationPaddingHorizontal = token.paddingLG;
- const notificationToken = (0, _internal.mergeToken)(token, {
- notificationBg: token.colorBgElevated,
- notificationPaddingVertical,
- notificationPaddingHorizontal,
- notificationIconSize: token.calc(token.fontSizeLG).mul(token.lineHeightLG).equal(),
- notificationCloseButtonSize: token.calc(token.controlHeightLG).mul(0.55).equal(),
- notificationMarginBottom: token.margin,
- notificationPadding: `${(0, _cssinjs.unit)(token.paddingMD)} ${(0, _cssinjs.unit)(token.paddingContentHorizontalLG)}`,
- notificationMarginEdge: token.marginLG,
- animationMaxHeight: 150,
- notificationStackLayer: 3,
- notificationProgressHeight: 2,
- notificationProgressBg: `linear-gradient(90deg, ${token.colorPrimaryBorderHover}, ${token.colorPrimary})`
- });
- return notificationToken;
- };
- exports.prepareNotificationToken = prepareNotificationToken;
- var _default = exports.default = (0, _internal.genStyleHooks)('Notification', token => {
- const notificationToken = prepareNotificationToken(token);
- return [genNotificationStyle(notificationToken), (0, _placement.default)(notificationToken), (0, _stack.default)(notificationToken)];
- }, prepareComponentToken);
|