1 line
17 KiB
JSON
1 line
17 KiB
JSON
{"ast":null,"code":"import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport NoticeList from \"./NoticeList\";\n// ant-notification ant-notification-topRight\nvar Notifications = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? 'rc-notification' : _props$prefixCls,\n container = props.container,\n motion = props.motion,\n maxCount = props.maxCount,\n className = props.className,\n style = props.style,\n onAllRemoved = props.onAllRemoved,\n stack = props.stack,\n renderNotifications = props.renderNotifications;\n var _React$useState = React.useState([]),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n configList = _React$useState2[0],\n setConfigList = _React$useState2[1];\n\n // ======================== Close =========================\n var onNoticeClose = function onNoticeClose(key) {\n var _config$onClose;\n // Trigger close event\n var config = configList.find(function (item) {\n return item.key === key;\n });\n config === null || config === void 0 || (_config$onClose = config.onClose) === null || _config$onClose === void 0 || _config$onClose.call(config);\n setConfigList(function (list) {\n return list.filter(function (item) {\n return item.key !== key;\n });\n });\n };\n\n // ========================= Refs =========================\n React.useImperativeHandle(ref, function () {\n return {\n open: function open(config) {\n setConfigList(function (list) {\n var clone = _toConsumableArray(list);\n\n // Replace if exist\n var index = clone.findIndex(function (item) {\n return item.key === config.key;\n });\n var innerConfig = _objectSpread({}, config);\n if (index >= 0) {\n var _list$index;\n innerConfig.times = (((_list$index = list[index]) === null || _list$index === void 0 ? void 0 : _list$index.times) || 0) + 1;\n clone[index] = innerConfig;\n } else {\n innerConfig.times = 0;\n clone.push(innerConfig);\n }\n if (maxCount > 0 && clone.length > maxCount) {\n clone = clone.slice(-maxCount);\n }\n return clone;\n });\n },\n close: function close(key) {\n onNoticeClose(key);\n },\n destroy: function destroy() {\n setConfigList([]);\n }\n };\n });\n\n // ====================== Placements ======================\n var _React$useState3 = React.useState({}),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n placements = _React$useState4[0],\n setPlacements = _React$useState4[1];\n React.useEffect(function () {\n var nextPlacements = {};\n configList.forEach(function (config) {\n var _config$placement = config.placement,\n placement = _config$placement === void 0 ? 'topRight' : _config$placement;\n if (placement) {\n nextPlacements[placement] = nextPlacements[placement] || [];\n nextPlacements[placement].push(config);\n }\n });\n\n // Fill exist placements to avoid empty list causing remove without motion\n Object.keys(placements).forEach(function (placement) {\n nextPlacements[placement] = nextPlacements[placement] || [];\n });\n setPlacements(nextPlacements);\n }, [configList]);\n\n // Clean up container if all notices fade out\n var onAllNoticeRemoved = function onAllNoticeRemoved(placement) {\n setPlacements(function (originPlacements) {\n var clone = _objectSpread({}, originPlacements);\n var list = clone[placement] || [];\n if (!list.length) {\n delete clone[placement];\n }\n return clone;\n });\n };\n\n // Effect tell that placements is empty now\n var emptyRef = React.useRef(false);\n React.useEffect(function () {\n if (Object.keys(placements).length > 0) {\n emptyRef.current = true;\n } else if (emptyRef.current) {\n // Trigger only when from exist to empty\n onAllRemoved === null || onAllRemoved === void 0 || onAllRemoved();\n emptyRef.current = false;\n }\n }, [placements]);\n // ======================== Render ========================\n if (!container) {\n return null;\n }\n var placementList = Object.keys(placements);\n return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, placementList.map(function (placement) {\n var placementConfigList = placements[placement];\n var list = /*#__PURE__*/React.createElement(NoticeList, {\n key: placement,\n configList: placementConfigList,\n placement: placement,\n prefixCls: prefixCls,\n className: className === null || className === void 0 ? void 0 : className(placement),\n style: style === null || style === void 0 ? void 0 : style(placement),\n motion: motion,\n onNoticeClose: onNoticeClose,\n onAllNoticeRemoved: onAllNoticeRemoved,\n stack: stack\n });\n return renderNotifications ? renderNotifications(list, {\n prefixCls: prefixCls,\n key: placement\n }) : list;\n })), container);\n});\nif (process.env.NODE_ENV !== 'production') {\n Notifications.displayName = 'Notifications';\n}\nexport default Notifications;","map":{"version":3,"names":["_objectSpread","_toConsumableArray","_slicedToArray","React","createPortal","NoticeList","Notifications","forwardRef","props","ref","_props$prefixCls","prefixCls","container","motion","maxCount","className","style","onAllRemoved","stack","renderNotifications","_React$useState","useState","_React$useState2","configList","setConfigList","onNoticeClose","key","_config$onClose","config","find","item","onClose","call","list","filter","useImperativeHandle","open","clone","index","findIndex","innerConfig","_list$index","times","push","length","slice","close","destroy","_React$useState3","_React$useState4","placements","setPlacements","useEffect","nextPlacements","forEach","_config$placement","placement","Object","keys","onAllNoticeRemoved","originPlacements","emptyRef","useRef","current","placementList","createElement","Fragment","map","placementConfigList","process","env","NODE_ENV","displayName"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-notification/es/Notifications.js"],"sourcesContent":["import _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport NoticeList from \"./NoticeList\";\n// ant-notification ant-notification-topRight\nvar Notifications = /*#__PURE__*/React.forwardRef(function (props, ref) {\n var _props$prefixCls = props.prefixCls,\n prefixCls = _props$prefixCls === void 0 ? 'rc-notification' : _props$prefixCls,\n container = props.container,\n motion = props.motion,\n maxCount = props.maxCount,\n className = props.className,\n style = props.style,\n onAllRemoved = props.onAllRemoved,\n stack = props.stack,\n renderNotifications = props.renderNotifications;\n var _React$useState = React.useState([]),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n configList = _React$useState2[0],\n setConfigList = _React$useState2[1];\n\n // ======================== Close =========================\n var onNoticeClose = function onNoticeClose(key) {\n var _config$onClose;\n // Trigger close event\n var config = configList.find(function (item) {\n return item.key === key;\n });\n config === null || config === void 0 || (_config$onClose = config.onClose) === null || _config$onClose === void 0 || _config$onClose.call(config);\n setConfigList(function (list) {\n return list.filter(function (item) {\n return item.key !== key;\n });\n });\n };\n\n // ========================= Refs =========================\n React.useImperativeHandle(ref, function () {\n return {\n open: function open(config) {\n setConfigList(function (list) {\n var clone = _toConsumableArray(list);\n\n // Replace if exist\n var index = clone.findIndex(function (item) {\n return item.key === config.key;\n });\n var innerConfig = _objectSpread({}, config);\n if (index >= 0) {\n var _list$index;\n innerConfig.times = (((_list$index = list[index]) === null || _list$index === void 0 ? void 0 : _list$index.times) || 0) + 1;\n clone[index] = innerConfig;\n } else {\n innerConfig.times = 0;\n clone.push(innerConfig);\n }\n if (maxCount > 0 && clone.length > maxCount) {\n clone = clone.slice(-maxCount);\n }\n return clone;\n });\n },\n close: function close(key) {\n onNoticeClose(key);\n },\n destroy: function destroy() {\n setConfigList([]);\n }\n };\n });\n\n // ====================== Placements ======================\n var _React$useState3 = React.useState({}),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n placements = _React$useState4[0],\n setPlacements = _React$useState4[1];\n React.useEffect(function () {\n var nextPlacements = {};\n configList.forEach(function (config) {\n var _config$placement = config.placement,\n placement = _config$placement === void 0 ? 'topRight' : _config$placement;\n if (placement) {\n nextPlacements[placement] = nextPlacements[placement] || [];\n nextPlacements[placement].push(config);\n }\n });\n\n // Fill exist placements to avoid empty list causing remove without motion\n Object.keys(placements).forEach(function (placement) {\n nextPlacements[placement] = nextPlacements[placement] || [];\n });\n setPlacements(nextPlacements);\n }, [configList]);\n\n // Clean up container if all notices fade out\n var onAllNoticeRemoved = function onAllNoticeRemoved(placement) {\n setPlacements(function (originPlacements) {\n var clone = _objectSpread({}, originPlacements);\n var list = clone[placement] || [];\n if (!list.length) {\n delete clone[placement];\n }\n return clone;\n });\n };\n\n // Effect tell that placements is empty now\n var emptyRef = React.useRef(false);\n React.useEffect(function () {\n if (Object.keys(placements).length > 0) {\n emptyRef.current = true;\n } else if (emptyRef.current) {\n // Trigger only when from exist to empty\n onAllRemoved === null || onAllRemoved === void 0 || onAllRemoved();\n emptyRef.current = false;\n }\n }, [placements]);\n // ======================== Render ========================\n if (!container) {\n return null;\n }\n var placementList = Object.keys(placements);\n return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement(React.Fragment, null, placementList.map(function (placement) {\n var placementConfigList = placements[placement];\n var list = /*#__PURE__*/React.createElement(NoticeList, {\n key: placement,\n configList: placementConfigList,\n placement: placement,\n prefixCls: prefixCls,\n className: className === null || className === void 0 ? void 0 : className(placement),\n style: style === null || style === void 0 ? void 0 : style(placement),\n motion: motion,\n onNoticeClose: onNoticeClose,\n onAllNoticeRemoved: onAllNoticeRemoved,\n stack: stack\n });\n return renderNotifications ? renderNotifications(list, {\n prefixCls: prefixCls,\n key: placement\n }) : list;\n })), container);\n});\nif (process.env.NODE_ENV !== 'production') {\n Notifications.displayName = 'Notifications';\n}\nexport default Notifications;"],"mappings":"AAAA,OAAOA,aAAa,MAAM,0CAA0C;AACpE,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,YAAY,QAAQ,WAAW;AACxC,OAAOC,UAAU,MAAM,cAAc;AACrC;AACA,IAAIC,aAAa,GAAG,aAAaH,KAAK,CAACI,UAAU,CAAC,UAAUC,KAAK,EAAEC,GAAG,EAAE;EACtE,IAAIC,gBAAgB,GAAGF,KAAK,CAACG,SAAS;IACpCA,SAAS,GAAGD,gBAAgB,KAAK,KAAK,CAAC,GAAG,iBAAiB,GAAGA,gBAAgB;IAC9EE,SAAS,GAAGJ,KAAK,CAACI,SAAS;IAC3BC,MAAM,GAAGL,KAAK,CAACK,MAAM;IACrBC,QAAQ,GAAGN,KAAK,CAACM,QAAQ;IACzBC,SAAS,GAAGP,KAAK,CAACO,SAAS;IAC3BC,KAAK,GAAGR,KAAK,CAACQ,KAAK;IACnBC,YAAY,GAAGT,KAAK,CAACS,YAAY;IACjCC,KAAK,GAAGV,KAAK,CAACU,KAAK;IACnBC,mBAAmB,GAAGX,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