@semcore/notice-bubble 4.7.5 → 4.7.7
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 +12 -0
- package/lib/cjs/NoticeBubble.js +19 -15
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.js +18 -15
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [4.7.7] - 2023-03-28
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.49.0 ~> 3.49.1], `@semcore/icon` [3.14.4 ~> 3.14.5], `@semcore/flex-box` [4.7.16 ~> 4.7.17], `@semcore/animation` [1.9.8 ~> 1.9.9]).
|
|
10
|
+
|
|
11
|
+
## [4.7.6] - 2023-03-24
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Fixed local themes in notice bubbles.
|
|
16
|
+
|
|
5
17
|
## [4.7.5] - 2023-03-24
|
|
6
18
|
|
|
7
19
|
### Changed
|
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -53,6 +53,8 @@ var _i18nEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/i
|
|
|
53
53
|
|
|
54
54
|
var _useCssVariable = require("@semcore/utils/lib/useCssVariable");
|
|
55
55
|
|
|
56
|
+
var _ThemeProvider = require("@semcore/utils/lib/ThemeProvider");
|
|
57
|
+
|
|
56
58
|
var _excluded = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action"];
|
|
57
59
|
|
|
58
60
|
/*__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
@@ -60,21 +62,21 @@ var style = (
|
|
|
60
62
|
/*__reshadow_css_start__*/
|
|
61
63
|
_core.sstyled.insert(
|
|
62
64
|
/*__inner_css_start__*/
|
|
63
|
-
"@keyframes
|
|
65
|
+
"@keyframes enter_700nr{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_700nr{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_700nr_gg_,.___SContent_700nr_gg_,.___SView_700nr_gg_{grid-gap:var(--intergalactic-spacing-2x, 8px);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_700nr_gg_,.___SView_700nr_gg_{position:relative;margin-bottom:var(--intergalactic-spacing-3x, 12px);padding:var(--intergalactic-spacing-3x, 12px) calc(var(--intergalactic-spacing-6x, 24px) + var(--intergalactic-spacing-1x, 4px)) var(--intergalactic-spacing-3x, 12px) var(--intergalactic-spacing-3x, 12px);width:100%;border-radius:var(--intergalactic-popper-rounded, 6px);overflow:hidden;box-sizing:border-box;color:var(--intergalactic-text-primary-invert, #ffffff)}.___SBubble_700nr_gg_._type_info_700nr_gg_,.___SView_700nr_gg_._type_info_700nr_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_700nr_gg_._type_warning_700nr_gg_,.___SView_700nr_gg_._type_warning_700nr_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_700nr_gg_{flex-direction:column;flex:1}.___SMessage_700nr_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_700nr_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary-invert, #ffffff)}@media (hover:hover){.___SDismiss_700nr_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SNoticeBubble_700nr_gg_{width:300px;position:fixed;z-index:var(--intergalactic-z-index-notice-bubble, 999);right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_700nr_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SMessage_700nr_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}"
|
|
64
66
|
/*__inner_css_end__*/
|
|
65
|
-
, "
|
|
67
|
+
, "700nr_gg_")
|
|
66
68
|
/*__reshadow_css_end__*/
|
|
67
69
|
, {
|
|
68
|
-
"__SBubble": "
|
|
69
|
-
"__SView": "
|
|
70
|
-
"_type_info": "
|
|
71
|
-
"_type_warning": "
|
|
72
|
-
"__SContent": "
|
|
73
|
-
"__SMessage": "
|
|
74
|
-
"__SDismiss": "
|
|
75
|
-
"__SNoticeBubble": "
|
|
76
|
-
"@enter": "
|
|
77
|
-
"@exit": "
|
|
70
|
+
"__SBubble": "___SBubble_700nr_gg_",
|
|
71
|
+
"__SView": "___SView_700nr_gg_",
|
|
72
|
+
"_type_info": "_type_info_700nr_gg_",
|
|
73
|
+
"_type_warning": "_type_warning_700nr_gg_",
|
|
74
|
+
"__SContent": "___SContent_700nr_gg_",
|
|
75
|
+
"__SMessage": "___SMessage_700nr_gg_",
|
|
76
|
+
"__SDismiss": "___SDismiss_700nr_gg_",
|
|
77
|
+
"__SNoticeBubble": "___SNoticeBubble_700nr_gg_",
|
|
78
|
+
"@enter": "enter_700nr",
|
|
79
|
+
"@exit": "exit_700nr"
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
var Notices = function Notices(props) {
|
|
@@ -158,7 +160,8 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
158
160
|
Children = _this$asProps.Children,
|
|
159
161
|
styles = _this$asProps.styles,
|
|
160
162
|
disablePortal = _this$asProps.disablePortal,
|
|
161
|
-
getI18nText = _this$asProps.getI18nText
|
|
163
|
+
getI18nText = _this$asProps.getI18nText,
|
|
164
|
+
ref = _this$asProps.ref;
|
|
162
165
|
var _this$state = this.state,
|
|
163
166
|
notices = _this$state.notices,
|
|
164
167
|
warnings = _this$state.warnings;
|
|
@@ -166,7 +169,8 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
166
169
|
"disablePortal": disablePortal
|
|
167
170
|
}), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
168
171
|
"role": "alert",
|
|
169
|
-
"aria-live": "assertive"
|
|
172
|
+
"aria-live": "assertive",
|
|
173
|
+
"ref": ref
|
|
170
174
|
}, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {})), /*#__PURE__*/_react["default"].createElement(Notices, _ref3.cn("Notices", {
|
|
171
175
|
"styles": styles,
|
|
172
176
|
"data": warnings,
|
|
@@ -185,7 +189,7 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
185
189
|
|
|
186
190
|
(0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
|
|
187
191
|
(0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "style", style);
|
|
188
|
-
(0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "enhance", [(0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages)]);
|
|
192
|
+
(0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "enhance", [(0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages), (0, _ThemeProvider.contextThemeEnhance)()]);
|
|
189
193
|
(0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "defaultProps", {
|
|
190
194
|
manager: _NoticeBubbleManager["default"],
|
|
191
195
|
i18n: _intergalacticDynamicLocales.localizedMessages,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["Notices","props","styles","data","tag","SView","ViewInfo","ref","React","useRef","durationStr","useCssVariable","duration","useMemo","parseInt","map","notice","sstyled","uid","initialAnimation","visible","getI18nText","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","i18nEnhance","localizedMessages","i18n","locale","e","fire","clearTimer","timer","pause","resume","Timer","handlerClose","clear","SBubble","Flex","SDismiss","SContent","SMessage","SAction","forwardRef","onMouseEnter","onMouseLeave","icon","children","actionNode","action","other","callAllEventHandlers","handlerMouseEnter","handlerMouseLeave","isNode","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 { Flex, 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';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { useCssVariable } from '@semcore/utils/lib/useCssVariable';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n const ref = React.useRef();\n const durationStr = useCssVariable('--intergalactic-duration-popper', '200', ref);\n const duration = React.useMemo(() => parseInt(durationStr, 10), [durationStr]);\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n initialAnimation={notice.initialAnimation}\n visible={notice.visible ?? true}\n duration={duration}\n keyframes={[styles['@enter'], styles['@exit']]}\n ref={ref}\n >\n <SView {...notice} styles={notice.styles || styles} getI18nText={props.getI18nText} />\n </Animation>,\n );\n });\n};\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [i18nEnhance(localizedMessages)];\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\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, getI18nText } = 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} getI18nText={getI18nText} />\n <Notices styles={styles} data={notices} tag={ViewInfo} getI18nText={getI18nText} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\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 SBubble = Flex;\n const SDismiss = 'div';\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const {\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n getI18nText,\n icon,\n children,\n action: actionNode,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SBubble\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\n <CloseIcon />\n </SDismiss>\n {isNode(icon) ? (\n <>\n {icon}\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n </>\n ) : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n )}\n </SBubble>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\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;;A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;;;;EAAoBnC,Q;;iCAApBmC,W,kBACkB;EACpBb,IAAI,EAAE,SADc;EAEpBhB,QAAQ,EAAE;AAFU,C;;IAMlB+D,gB;;;;;;;;;;;;;;;iGAOM,I;;;;;;WAEV,6BAAoB;MAClB,KAAKC,OAAL,GAAe,KAAKvC,OAAL,CAAaN,OAAb,CAAqB8C,GAArB,CAAyB,KAAKxC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAKuC,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAK1C,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzBiC,gB,kBACkB;EACpB/D,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlBiD,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBpE,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAMkD,qBAAqB,GAAG,IAAAC,gBAAA,EAAgB5D,yBAAhB,EAA2C;EACvE6D,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","ref","React","useRef","durationStr","useCssVariable","duration","useMemo","parseInt","map","notice","sstyled","uid","initialAnimation","visible","getI18nText","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","i18nEnhance","localizedMessages","contextThemeEnhance","i18n","locale","e","fire","clearTimer","timer","pause","resume","Timer","handlerClose","clear","SBubble","Flex","SDismiss","SContent","SMessage","SAction","forwardRef","onMouseEnter","onMouseLeave","icon","children","actionNode","action","other","callAllEventHandlers","handlerMouseEnter","handlerMouseLeave","isNode","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 { Flex, 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';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { useCssVariable } from '@semcore/utils/lib/useCssVariable';\nimport { contextThemeEnhance } from '@semcore/utils/lib/ThemeProvider';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n const ref = React.useRef();\n const durationStr = useCssVariable('--intergalactic-duration-popper', '200', ref);\n const duration = React.useMemo(() => parseInt(durationStr, 10), [durationStr]);\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n initialAnimation={notice.initialAnimation}\n visible={notice.visible ?? true}\n duration={duration}\n keyframes={[styles['@enter'], styles['@exit']]}\n ref={ref}\n >\n <SView {...notice} styles={notice.styles || styles} getI18nText={props.getI18nText} />\n </Animation>,\n );\n });\n};\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [i18nEnhance(localizedMessages), contextThemeEnhance()];\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\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, getI18nText, ref } = 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\" ref={ref}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} getI18nText={getI18nText} />\n <Notices styles={styles} data={notices} tag={ViewInfo} getI18nText={getI18nText} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\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 SBubble = Flex;\n const SDismiss = 'div';\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const {\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n getI18nText,\n icon,\n children,\n action: actionNode,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SBubble\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\n <CloseIcon />\n </SDismiss>\n {isNode(icon) ? (\n <>\n {icon}\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n </>\n ) : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n )}\n </SBubble>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\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;;AACA;;AAC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UA,UAAV,CAArB,GAAuD,IAF1D,CAvBJ,CADF;IA+BD;;;EAxFoB3B,e;;IA2FjBD,W;;;;;;;;;;;EAAoBnC,Q;;iCAApBmC,W,kBACkB;EACpBb,IAAI,EAAE,SADc;EAEpBhB,QAAQ,EAAE;AAFU,C;;IAMlBgE,gB;;;;;;;;;;;;;;;iGAOM,I;;;;;;WAEV,6BAAoB;MAClB,KAAKC,OAAL,GAAe,KAAKxC,OAAL,CAAaN,OAAb,CAAqB+C,GAArB,CAAyB,KAAKzC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAKwC,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAK3C,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzBkC,gB,kBACkB;EACpBhE,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlBkD,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBrE,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAMmD,qBAAqB,GAAG,IAAAC,gBAAA,EAAgB7D,yBAAhB,EAA2C;EACvE8D,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"}
|
package/lib/es6/NoticeBubble.js
CHANGED
|
@@ -23,27 +23,28 @@ import { Timer } from './utils';
|
|
|
23
23
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
24
24
|
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
25
25
|
import { useCssVariable } from '@semcore/utils/lib/useCssVariable';
|
|
26
|
+
import { contextThemeEnhance } from '@semcore/utils/lib/ThemeProvider';
|
|
26
27
|
|
|
27
28
|
/*__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
28
29
|
var style = (
|
|
29
30
|
/*__reshadow_css_start__*/
|
|
30
31
|
_sstyled.insert(
|
|
31
32
|
/*__inner_css_start__*/
|
|
32
|
-
"@keyframes
|
|
33
|
+
"@keyframes enter_700nr{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_700nr{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_700nr_gg_,.___SContent_700nr_gg_,.___SView_700nr_gg_{grid-gap:var(--intergalactic-spacing-2x, 8px);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_700nr_gg_,.___SView_700nr_gg_{position:relative;margin-bottom:var(--intergalactic-spacing-3x, 12px);padding:var(--intergalactic-spacing-3x, 12px) calc(var(--intergalactic-spacing-6x, 24px) + var(--intergalactic-spacing-1x, 4px)) var(--intergalactic-spacing-3x, 12px) var(--intergalactic-spacing-3x, 12px);width:100%;border-radius:var(--intergalactic-popper-rounded, 6px);overflow:hidden;box-sizing:border-box;color:var(--intergalactic-text-primary-invert, #ffffff)}.___SBubble_700nr_gg_._type_info_700nr_gg_,.___SView_700nr_gg_._type_info_700nr_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_700nr_gg_._type_warning_700nr_gg_,.___SView_700nr_gg_._type_warning_700nr_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_700nr_gg_{flex-direction:column;flex:1}.___SMessage_700nr_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_700nr_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px);color:var(--intergalactic-text-primary-invert, #ffffff)}@media (hover:hover){.___SDismiss_700nr_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SNoticeBubble_700nr_gg_{width:300px;position:fixed;z-index:var(--intergalactic-z-index-notice-bubble, 999);right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_700nr_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SMessage_700nr_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}"
|
|
33
34
|
/*__inner_css_end__*/
|
|
34
|
-
, "
|
|
35
|
+
, "700nr_gg_")
|
|
35
36
|
/*__reshadow_css_end__*/
|
|
36
37
|
, {
|
|
37
|
-
"__SBubble": "
|
|
38
|
-
"__SView": "
|
|
39
|
-
"_type_info": "
|
|
40
|
-
"_type_warning": "
|
|
41
|
-
"__SContent": "
|
|
42
|
-
"__SMessage": "
|
|
43
|
-
"__SDismiss": "
|
|
44
|
-
"__SNoticeBubble": "
|
|
45
|
-
"@enter": "
|
|
46
|
-
"@exit": "
|
|
38
|
+
"__SBubble": "___SBubble_700nr_gg_",
|
|
39
|
+
"__SView": "___SView_700nr_gg_",
|
|
40
|
+
"_type_info": "_type_info_700nr_gg_",
|
|
41
|
+
"_type_warning": "_type_warning_700nr_gg_",
|
|
42
|
+
"__SContent": "___SContent_700nr_gg_",
|
|
43
|
+
"__SMessage": "___SMessage_700nr_gg_",
|
|
44
|
+
"__SDismiss": "___SDismiss_700nr_gg_",
|
|
45
|
+
"__SNoticeBubble": "___SNoticeBubble_700nr_gg_",
|
|
46
|
+
"@enter": "enter_700nr",
|
|
47
|
+
"@exit": "exit_700nr"
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
var Notices = function Notices(props) {
|
|
@@ -129,7 +130,8 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
129
130
|
Children = _this$asProps.Children,
|
|
130
131
|
styles = _this$asProps.styles,
|
|
131
132
|
disablePortal = _this$asProps.disablePortal,
|
|
132
|
-
getI18nText = _this$asProps.getI18nText
|
|
133
|
+
getI18nText = _this$asProps.getI18nText,
|
|
134
|
+
ref = _this$asProps.ref;
|
|
133
135
|
var _this$state = this.state,
|
|
134
136
|
notices = _this$state.notices,
|
|
135
137
|
warnings = _this$state.warnings;
|
|
@@ -137,7 +139,8 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
137
139
|
"disablePortal": disablePortal
|
|
138
140
|
}), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, _assignProps({
|
|
139
141
|
"role": "alert",
|
|
140
|
-
"aria-live": "assertive"
|
|
142
|
+
"aria-live": "assertive",
|
|
143
|
+
"ref": ref
|
|
141
144
|
}, _ref))), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})), /*#__PURE__*/React.createElement(Notices, _ref3.cn("Notices", {
|
|
142
145
|
"styles": styles,
|
|
143
146
|
"data": warnings,
|
|
@@ -159,7 +162,7 @@ _defineProperty(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer
|
|
|
159
162
|
|
|
160
163
|
_defineProperty(NoticeBubbleContainerRoot, "style", style);
|
|
161
164
|
|
|
162
|
-
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages)]);
|
|
165
|
+
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance()]);
|
|
163
166
|
|
|
164
167
|
_defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
165
168
|
manager: manager,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","Flex","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","localizedMessages","i18nEnhance","useCssVariable","Notices","props","styles","data","tag","SView","ViewInfo","ref","useRef","durationStr","duration","useMemo","parseInt","map","notice","uid","initialAnimation","visible","getI18nText","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","i18n","locale","e","clearTimer","timer","pause","resume","handlerClose","clear","SBubble","SDismiss","SContent","SMessage","SAction","forwardRef","onMouseEnter","onMouseLeave","icon","children","actionNode","action","other","handlerMouseEnter","handlerMouseLeave","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 { Flex, 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';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { useCssVariable } from '@semcore/utils/lib/useCssVariable';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n const ref = React.useRef();\n const durationStr = useCssVariable('--intergalactic-duration-popper', '200', ref);\n const duration = React.useMemo(() => parseInt(durationStr, 10), [durationStr]);\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n initialAnimation={notice.initialAnimation}\n visible={notice.visible ?? true}\n duration={duration}\n keyframes={[styles['@enter'], styles['@exit']]}\n ref={ref}\n >\n <SView {...notice} styles={notice.styles || styles} getI18nText={props.getI18nText} />\n </Animation>,\n );\n });\n};\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [i18nEnhance(localizedMessages)];\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\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, getI18nText } = 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} getI18nText={getI18nText} />\n <Notices styles={styles} data={notices} tag={ViewInfo} getI18nText={getI18nText} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\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 SBubble = Flex;\n const SDismiss = 'div';\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const {\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n getI18nText,\n icon,\n children,\n action: actionNode,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SBubble\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\n <CloseIcon />\n </SDismiss>\n {isNode(icon) ? (\n <>\n {icon}\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n </>\n ) : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n )}\n </SBubble>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\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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AAI,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","Flex","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","localizedMessages","i18nEnhance","useCssVariable","contextThemeEnhance","Notices","props","styles","data","tag","SView","ViewInfo","ref","useRef","durationStr","duration","useMemo","parseInt","map","notice","uid","initialAnimation","visible","getI18nText","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","i18n","locale","e","clearTimer","timer","pause","resume","handlerClose","clear","SBubble","SDismiss","SContent","SMessage","SAction","forwardRef","onMouseEnter","onMouseLeave","icon","children","actionNode","action","other","handlerMouseEnter","handlerMouseLeave","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 { Flex, 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';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';\nimport { useCssVariable } from '@semcore/utils/lib/useCssVariable';\nimport { contextThemeEnhance } from '@semcore/utils/lib/ThemeProvider';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n const ref = React.useRef();\n const durationStr = useCssVariable('--intergalactic-duration-popper', '200', ref);\n const duration = React.useMemo(() => parseInt(durationStr, 10), [durationStr]);\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n initialAnimation={notice.initialAnimation}\n visible={notice.visible ?? true}\n duration={duration}\n keyframes={[styles['@enter'], styles['@exit']]}\n ref={ref}\n >\n <SView {...notice} styles={notice.styles || styles} getI18nText={props.getI18nText} />\n </Animation>,\n );\n });\n};\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [i18nEnhance(localizedMessages), contextThemeEnhance()];\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\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, getI18nText, ref } = 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\" ref={ref}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} getI18nText={getI18nText} />\n <Notices styles={styles} data={notices} tag={ViewInfo} getI18nText={getI18nText} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\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 SBubble = Flex;\n const SDismiss = 'div';\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const {\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n getI18nText,\n icon,\n children,\n action: actionNode,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SBubble\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\n <CloseIcon />\n </SDismiss>\n {isNode(icon) ? (\n <>\n {icon}\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n </>\n ) : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SContent>\n )}\n </SBubble>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\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,IAAT,EAAeC,GAAf,QAA0B,mBAA1B;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;AACA,SAASC,iBAAT,QAAkC,gDAAlC;AACA,OAAOC,WAAP,MAAwB,yCAAxB;AACA,SAASC,cAAT,QAA+B,mCAA/B;AACA,SAASC,mBAAT,QAAoC,kCAApC;;;;;;;;;;;;;;;;;;;;;;;;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;EACA,IAAMC,GAAG,GAAG1B,KAAK,CAAC2B,M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