@semcore/notice-bubble 4.0.13 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/cjs/NoticeBubble.js +16 -23
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/style/notice-bubble.shadow.css +18 -0
- package/lib/es6/NoticeBubble.js +16 -23
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/style/notice-bubble.shadow.css +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [4.1.1] - 2022-08-29
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/animation` [1.5.8 ~> 1.5.9]).
|
|
10
|
+
|
|
11
|
+
## [4.1.0] - 2022-08-24
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Animation styles moved to css file and now available for theming.
|
|
16
|
+
|
|
17
|
+
## [4.0.14] - 2022-08-23
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Added role and aria-live attribute for better accessibility.
|
|
22
|
+
|
|
5
23
|
## [4.0.13] - 2022-08-18
|
|
6
24
|
|
|
7
25
|
### Changed
|
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -67,30 +67,20 @@ var style = (
|
|
|
67
67
|
/*__reshadow_css_start__*/
|
|
68
68
|
_core.sstyled.insert(
|
|
69
69
|
/*__inner_css_start__*/
|
|
70
|
-
".
|
|
70
|
+
".___SInfo_4mbvd_gg_,.___SView_4mbvd_gg_,.___SWarning_4mbvd_gg_{position:relative;margin-bottom:12px;padding:12px 28px 12px 12px;width:100%;min-height:44px;border-radius:6px;overflow:hidden;box-sizing:border-box}.___SInfo_4mbvd_gg_{background:#191b23}.___SWarning_4mbvd_gg_{background:#ff4953}.___SMessage_4mbvd_gg_{font-size:14px;color:#fff;line-height:1.33}.___SDismiss_4mbvd_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:8px;color:#ffffff}.___SDismiss_4mbvd_gg_:hover{color:#e0e1e9}.___SAction_4mbvd_gg_{margin-top:8px}.___SNoticeBubble_4mbvd_gg_{width:300px;position:fixed;z-index:1010;right:12px;top:12px}@media (max-width:767px){.___SNoticeBubble_4mbvd_gg_{width:calc(100% - 24px)}}@-webkit-keyframes enter_4mbvd{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_4mbvd{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_4mbvd{0%{opacity:1}to{opacity:0}}@keyframes exit_4mbvd{0%{opacity:1}to{opacity:0}}"
|
|
71
71
|
/*__inner_css_end__*/
|
|
72
|
-
, "
|
|
72
|
+
, "4mbvd_gg_")
|
|
73
73
|
/*__reshadow_css_end__*/
|
|
74
74
|
, {
|
|
75
|
-
"__SInfo": "
|
|
76
|
-
"__SView": "
|
|
77
|
-
"__SWarning": "
|
|
78
|
-
"__SMessage": "
|
|
79
|
-
"__SDismiss": "
|
|
80
|
-
"__SAction": "
|
|
81
|
-
"__SNoticeBubble": "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/*__reshadow_css_start__*/
|
|
85
|
-
_core.sstyled.insert(
|
|
86
|
-
/*__inner_css_start__*/
|
|
87
|
-
"@-webkit-keyframes enter_5nq7f{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_5nq7f{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_5nq7f{0%{opacity:1}to{opacity:0}}@keyframes exit_5nq7f{0%{opacity:1}to{opacity:0}}"
|
|
88
|
-
/*__inner_css_end__*/
|
|
89
|
-
, "5nq7f_gg_")
|
|
90
|
-
/*__reshadow_css_end__*/
|
|
91
|
-
, {
|
|
92
|
-
"@enter": "enter_5nq7f",
|
|
93
|
-
"@exit": "exit_5nq7f"
|
|
75
|
+
"__SInfo": "___SInfo_4mbvd_gg_",
|
|
76
|
+
"__SView": "___SView_4mbvd_gg_",
|
|
77
|
+
"__SWarning": "___SWarning_4mbvd_gg_",
|
|
78
|
+
"__SMessage": "___SMessage_4mbvd_gg_",
|
|
79
|
+
"__SDismiss": "___SDismiss_4mbvd_gg_",
|
|
80
|
+
"__SAction": "___SAction_4mbvd_gg_",
|
|
81
|
+
"__SNoticeBubble": "___SNoticeBubble_4mbvd_gg_",
|
|
82
|
+
"@enter": "enter_4mbvd",
|
|
83
|
+
"@exit": "exit_4mbvd"
|
|
94
84
|
});
|
|
95
85
|
|
|
96
86
|
var Notices = function Notices(props) {
|
|
@@ -106,7 +96,7 @@ var Notices = function Notices(props) {
|
|
|
106
96
|
"key": notice.uid,
|
|
107
97
|
"visible": notice.visible === undefined ? true : notice.visible,
|
|
108
98
|
"duration": 250,
|
|
109
|
-
"keyframes": [
|
|
99
|
+
"keyframes": [styles['@enter'], styles['@exit']]
|
|
110
100
|
}), /*#__PURE__*/_react["default"].createElement(SView, _ref2.cn("SView", _objectSpread(_objectSpread({}, notice), {}, {
|
|
111
101
|
"styles": notice.styles || styles
|
|
112
102
|
}))));
|
|
@@ -176,7 +166,10 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
176
166
|
warnings = _this$state.warnings;
|
|
177
167
|
return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_portal["default"], _ref3.cn("Portal", {
|
|
178
168
|
"disablePortal": disablePortal
|
|
179
|
-
}), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, (0, _core.assignProps)({
|
|
169
|
+
}), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, (0, _core.assignProps)({
|
|
170
|
+
"role": "alert",
|
|
171
|
+
"aria-live": "assertive"
|
|
172
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {})), /*#__PURE__*/_react["default"].createElement(Notices, _ref3.cn("Notices", {
|
|
180
173
|
"styles": styles,
|
|
181
174
|
"data": warnings,
|
|
182
175
|
"tag": ViewWarning
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["animationNotice","sstyled","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","e","fire","clearTimer","timer","pause","resume","duration","Timer","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","callAllEventHandlers","handlerMouseEnter","handlerMouseLeave","isNode","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","createComponent","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,eAAe;AAAA;AAAGC,aAAA,OAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAAA;EAAA;AAAA,EAArB;;AAoBA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;EACzB,IAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;EAAA,kBAAqDD,KAArD,CAAgBE,IAAhB;EAAA,IAAgBA,IAAhB,4BAAuB,EAAvB;EAAA,iBAAqDF,KAArD,CAA2BG,GAA3B;EAAA,IAAgCC,KAAhC,2BAAwCC,QAAxC;EAEA,OAAOH,IAAI,CAACI,GAAL,CAAS,UAACC,MAAD,EAAY;IAAA;;IAC1B,eAAO,IAAAT,aAAA,EAAQG,MAAR,CAAP,eACE,gCAAC,oBAAD;MAAA,OACOM,MAAM,CAACC,GADd;MAAA,WAEWD,MAAM,CAACE,OAAP,KAAmBC,SAAnB,GAA+B,IAA/B,GAAsCH,MAAM,CAACE,OAFxD;MAAA,YAGY,GAHZ;MAAA,aAIa,CAACZ,eAAe,CAAC,QAAD,CAAhB,EAA4BA,eAAe,CAAC,OAAD,CAA3C;IAJb,iBAME,gCAAC,KAAD,oDAAWU,MAAX;MAAA,UAA2BA,MAAM,CAACN,MAAP,IAAiBA;IAA5C,IANF,CADF;EAUD,CAXM,CAAP;AAYD,CAfD;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;I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D,QAAX,CADF,EAEG,IAAAK,kBAAA,EAAOV,UAAP,iBAAqB,gCAAC,OAAD,2BAAUA,UAAV,CAArB,GAAuD,IAF1D,CADF;IAMD;;;EAlBuB1C,Q;;iCAApByB,W,kBACkB;EACpBb,IAAI,EAAE,SADc;EAEpBsB,QAAQ,EAAE;AAFU,C;;IAoBlBoB,gB;;;;;;;;;;;;;;;iGAOM,I;;;;;;WAEV,6BAAoB;MAClB,KAAKC,OAAL,GAAe,KAAKlC,OAAL,CAAaN,OAAb,CAAqByC,GAArB,CAAyB,KAAKnC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAKkC,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAKrC,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzB4B,gB,kBACkB;EACpBpB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlB4C,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBzB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAM6C,qBAAqB,GAAG,IAAAC,gBAAA,EAAgBvD,yBAAhB,EAA2C;EACvEwD,IAAI,EAAER,gBADiE;EAEvES,OAAO,EAAEJ;AAF8D,CAA3C,CAA9B;AAKA,IAAMK,YAAY,GAAGJ,qBAAqB,CAACE,IAA3C;;AACA,IAAMG,mBAAmB,GAAGL,qBAAqB,CAACG,OAAlD;;eAIeH,qB"}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["Notices","props","styles","data","tag","SView","ViewInfo","map","notice","sstyled","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","e","fire","clearTimer","timer","pause","resume","duration","Timer","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","callAllEventHandlers","handlerMouseEnter","handlerMouseLeave","isNode","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","createComponent","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box} role=\"alert\" aria-live=\"assertive\">\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;EACzB,IAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;EAAA,k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CAAaG,MAAb,CAAoB,KAAKrC,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzB4B,gB,kBACkB;EACpBpB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlB4C,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBzB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAM6C,qBAAqB,GAAG,IAAAC,gBAAA,EAAgBvD,yBAAhB,EAA2C;EACvEwD,IAAI,EAAER,gBADiE;EAEvES,OAAO,EAAEJ;AAF8D,CAA3C,CAA9B;AAKA,IAAMK,YAAY,GAAGJ,qBAAqB,CAACE,IAA3C;;AACA,IAAMG,mBAAmB,GAAGL,qBAAqB,CAACG,OAAlD;;eAIeH,qB"}
|
|
@@ -55,3 +55,21 @@ SNoticeBubble {
|
|
|
55
55
|
width: calc(100% - 24px);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
@keyframes enter {
|
|
60
|
+
from {
|
|
61
|
+
transform: translate(100%, 0);
|
|
62
|
+
}
|
|
63
|
+
to {
|
|
64
|
+
transform: translate(0, 0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes exit {
|
|
69
|
+
from {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
to {
|
|
73
|
+
opacity: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
package/lib/es6/NoticeBubble.js
CHANGED
|
@@ -36,30 +36,20 @@ var style = (
|
|
|
36
36
|
/*__reshadow_css_start__*/
|
|
37
37
|
_sstyled.insert(
|
|
38
38
|
/*__inner_css_start__*/
|
|
39
|
-
".
|
|
39
|
+
".___SInfo_4mbvd_gg_,.___SView_4mbvd_gg_,.___SWarning_4mbvd_gg_{position:relative;margin-bottom:12px;padding:12px 28px 12px 12px;width:100%;min-height:44px;border-radius:6px;overflow:hidden;box-sizing:border-box}.___SInfo_4mbvd_gg_{background:#191b23}.___SWarning_4mbvd_gg_{background:#ff4953}.___SMessage_4mbvd_gg_{font-size:14px;color:#fff;line-height:1.33}.___SDismiss_4mbvd_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:8px;color:#ffffff}.___SDismiss_4mbvd_gg_:hover{color:#e0e1e9}.___SAction_4mbvd_gg_{margin-top:8px}.___SNoticeBubble_4mbvd_gg_{width:300px;position:fixed;z-index:1010;right:12px;top:12px}@media (max-width:767px){.___SNoticeBubble_4mbvd_gg_{width:calc(100% - 24px)}}@-webkit-keyframes enter_4mbvd{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_4mbvd{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_4mbvd{0%{opacity:1}to{opacity:0}}@keyframes exit_4mbvd{0%{opacity:1}to{opacity:0}}"
|
|
40
40
|
/*__inner_css_end__*/
|
|
41
|
-
, "
|
|
41
|
+
, "4mbvd_gg_")
|
|
42
42
|
/*__reshadow_css_end__*/
|
|
43
43
|
, {
|
|
44
|
-
"__SInfo": "
|
|
45
|
-
"__SView": "
|
|
46
|
-
"__SWarning": "
|
|
47
|
-
"__SMessage": "
|
|
48
|
-
"__SDismiss": "
|
|
49
|
-
"__SAction": "
|
|
50
|
-
"__SNoticeBubble": "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/*__reshadow_css_start__*/
|
|
54
|
-
sstyled.insert(
|
|
55
|
-
/*__inner_css_start__*/
|
|
56
|
-
"@-webkit-keyframes enter_5nq7f{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_5nq7f{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_5nq7f{0%{opacity:1}to{opacity:0}}@keyframes exit_5nq7f{0%{opacity:1}to{opacity:0}}"
|
|
57
|
-
/*__inner_css_end__*/
|
|
58
|
-
, "5nq7f_gg_")
|
|
59
|
-
/*__reshadow_css_end__*/
|
|
60
|
-
, {
|
|
61
|
-
"@enter": "enter_5nq7f",
|
|
62
|
-
"@exit": "exit_5nq7f"
|
|
44
|
+
"__SInfo": "___SInfo_4mbvd_gg_",
|
|
45
|
+
"__SView": "___SView_4mbvd_gg_",
|
|
46
|
+
"__SWarning": "___SWarning_4mbvd_gg_",
|
|
47
|
+
"__SMessage": "___SMessage_4mbvd_gg_",
|
|
48
|
+
"__SDismiss": "___SDismiss_4mbvd_gg_",
|
|
49
|
+
"__SAction": "___SAction_4mbvd_gg_",
|
|
50
|
+
"__SNoticeBubble": "___SNoticeBubble_4mbvd_gg_",
|
|
51
|
+
"@enter": "enter_4mbvd",
|
|
52
|
+
"@exit": "exit_4mbvd"
|
|
63
53
|
});
|
|
64
54
|
|
|
65
55
|
var Notices = function Notices(props) {
|
|
@@ -75,7 +65,7 @@ var Notices = function Notices(props) {
|
|
|
75
65
|
"key": notice.uid,
|
|
76
66
|
"visible": notice.visible === undefined ? true : notice.visible,
|
|
77
67
|
"duration": 250,
|
|
78
|
-
"keyframes": [
|
|
68
|
+
"keyframes": [styles['@enter'], styles['@exit']]
|
|
79
69
|
}), /*#__PURE__*/React.createElement(SView, _ref2.cn("SView", _objectSpread(_objectSpread({}, notice), {}, {
|
|
80
70
|
"styles": notice.styles || styles
|
|
81
71
|
}))));
|
|
@@ -151,7 +141,10 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
151
141
|
warnings = _this$state.warnings;
|
|
152
142
|
return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(Portal, _ref3.cn("Portal", {
|
|
153
143
|
"disablePortal": disablePortal
|
|
154
|
-
}), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, _assignProps({
|
|
144
|
+
}), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, _assignProps({
|
|
145
|
+
"role": "alert",
|
|
146
|
+
"aria-live": "assertive"
|
|
147
|
+
}, _ref))), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})), /*#__PURE__*/React.createElement(Notices, _ref3.cn("Notices", {
|
|
155
148
|
"styles": styles,
|
|
156
149
|
"data": warnings,
|
|
157
150
|
"tag": ViewWarning
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","animationNotice","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","e","clearTimer","timer","pause","resume","duration","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","handlerMouseEnter","handlerMouseLeave","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,yBAAjB;AACA,OAAOC,MAAP,MAAmB,2BAAnB;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AACA,SAASC,KAAT,QAAsB,SAAtB;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,eAAe;AAAA;AAAGT,OAAO,OAAV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAAA;EAAA;AAAA,EAArB;;AAoBA,IAAMU,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;EACzB,IAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;EAAA,kBAAqDD,KAArD,CAAgBE,IAAhB;EAAA,IAAgBA,IAAhB,4BAAuB,EAAvB;EAAA,iBAAqDF,KAArD,CAA2BG,GAA3B;EAAA,IAAgCC,KAAhC,2BAAwCC,QAAxC;EAEA,OAAOH,IAAI,CAACI,GAAL,CAAS,UAACC,MAAD,EAAY;IAAA;;IAC1B,eAAOlB,OAAO,CAACY,MAAD,CAAd,eACE,oBAAC,SAAD;MAAA,OACOM,MAAM,CAACC,GADd;MAAA,WAEWD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AAOxB,IAAMwE,qBAAqB,GAAGvE,eAAe,CAACwB,yBAAD,EAA4B;EACvEgD,IAAI,EAAEP,gBADiE;EAEvEQ,OAAO,EAAEH;AAF8D,CAA5B,CAA7C;AAKA,IAAMI,YAAY,GAAGH,qBAAqB,CAACC,IAA3C;AACA,IAAMG,mBAAmB,GAAGJ,qBAAqB,CAACE,OAAlD;AAEA,SAASC,YAAT,EAAuBC,mBAAvB;AAEA,eAAeJ,qBAAf"}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","e","clearTimer","timer","pause","resume","duration","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","handlerMouseEnter","handlerMouseLeave","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box} role=\"alert\" aria-live=\"assertive\">\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,yBAAjB;AACA,OAAOC,MAAP,MAAmB,2BAAnB;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AACA,SAASC,KAAT,QAAsB,SAAtB;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;EACzB,IAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;EAAA,kBAAqDD,KAArD,CAAgBE,IAAhB;EAAA,IAAgBA,IAAhB,4BAAuB,EAAvB;EAAA,iBAAqDF,KAArD,CAA2BG,GAA3B;EAAA,IAAgCC,KAAhC,2BAAwCC,QAAxC;EAEA,OAAOH,IAAI,CAACI,GAAL,CAAS,UAACC,MAAD,EAAY;IAAA;;IAC1B,eAAOjB,OAAO,CAACW,MAAD,CAAd,eACE,oBAAC,SAAD;MAAA,OACOM,MAAM,CAACC,GADd;MAAA,WAEWD,MAAM,CAACE,OAAP,KAAmBC,SAAnB,GAA+B,IAA/B,GAAsCH,MAAM,CAACE,OAFxD;MAAA,YAGY,GAHZ;MAAA,aAIa,CAACR,MAAM,CAAC,QAAD,CAAP,EAAmBA,MAAM,CAAC,OAAD,CAAzB;IAJb,iBAME,oBAAC,KAAD,oDAA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BAAqB,CAACC,IAA3C;AACA,IAAMG,mBAAmB,GAAGJ,qBAAqB,CAACE,OAAlD;AAEA,SAASC,YAAT,EAAuBC,mBAAvB;AAEA,eAAeJ,qBAAf"}
|
|
@@ -55,3 +55,21 @@ SNoticeBubble {
|
|
|
55
55
|
width: calc(100% - 24px);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
@keyframes enter {
|
|
60
|
+
from {
|
|
61
|
+
transform: translate(100%, 0);
|
|
62
|
+
}
|
|
63
|
+
to {
|
|
64
|
+
transform: translate(0, 0);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes exit {
|
|
69
|
+
from {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
to {
|
|
73
|
+
opacity: 0;
|
|
74
|
+
}
|
|
75
|
+
}
|