@semcore/notice-bubble 4.6.7 → 4.7.0

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 CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [4.7.0] - 2023-03-15
6
+
7
+ ### Added
8
+
9
+ - Properties to add icons to notices.
10
+ - `NoticeBubbleManager` method typings.
11
+ - Documentation examples.
12
+
13
+ ### Fixed
14
+
15
+ - Disappear animation of stacked notices.
16
+ - Warning notices were not removable.
17
+ - Default links color.
18
+
19
+ ### Changed
20
+
21
+ - Deprecated adding notices by `NoticeBubble` and `NoticeBubbleWarning` without `NoticeBubbleManager`.
22
+
23
+ ## [4.6.8] - 2023-03-13
24
+
25
+ ### Changed
26
+
27
+ - Version patch update due to children dependencies update (`@semcore/utils` [3.47.1 ~> 3.47.2], `@semcore/icon` [3.13.2 ~> 3.13.3], `@semcore/flex-box` [4.7.10 ~> 4.7.11], `@semcore/animation` [1.9.2 ~> 1.9.3]).
28
+
5
29
  ## [4.6.7] - 2023-03-13
6
30
 
7
31
  ### Fixed
@@ -53,28 +53,28 @@ var _i18nEnhance = _interopRequireDefault(require("@semcore/utils/lib/enhances/i
53
53
 
54
54
  var _useCssVariable = require("@semcore/utils/lib/useCssVariable");
55
55
 
56
- var _excluded = ["action", "forwardRef", "styles", "onMouseEnter", "onMouseLeave", "children", "getI18nText"],
57
- _excluded2 = ["action", "children", "styles", "forwardRef"];
56
+ var _excluded = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action"];
58
57
 
59
58
  /*__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
60
59
  var style = (
61
60
  /*__reshadow_css_start__*/
62
61
  _core.sstyled.insert(
63
62
  /*__inner_css_start__*/
64
- "@keyframes enter_1rhk1{0%{transform:translate(100%,0)}to{transform:translate(0,0)}}@keyframes exit_1rhk1{0%{opacity:1}to{opacity:0}}.___SInfo_1rhk1_gg_,.___SView_1rhk1_gg_,.___SWarning_1rhk1_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}.___SInfo_1rhk1_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SWarning_1rhk1_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SDismiss_1rhk1_gg_,.___SMessage_1rhk1_gg_{color:var(--intergalactic-text-primary-invert, #ffffff)}.___SMessage_1rhk1_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_1rhk1_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px)}@media (hover:hover){.___SDismiss_1rhk1_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SAction_1rhk1_gg_{margin-top:var(--intergalactic-spacing-2x, 8px)}.___SNoticeBubble_1rhk1_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_1rhk1_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}"
63
+ "@keyframes enter_1dph8{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_1dph8{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_1dph8_gg_,.___SContent_1dph8_gg_,.___SView_1dph8_gg_{grid-gap:var(--intergalactic-spacing-2x, 8px);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_1dph8_gg_,.___SView_1dph8_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_1dph8_gg_._type_info_1dph8_gg_,.___SView_1dph8_gg_._type_info_1dph8_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_1dph8_gg_._type_warning_1dph8_gg_,.___SView_1dph8_gg_._type_warning_1dph8_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_1dph8_gg_{flex-direction:column;flex:1}.___SMessage_1dph8_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_1dph8_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_1dph8_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SNoticeBubble_1dph8_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_1dph8_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SMessage_1dph8_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}"
65
64
  /*__inner_css_end__*/
66
- , "1rhk1_gg_")
65
+ , "1dph8_gg_")
67
66
  /*__reshadow_css_end__*/
68
67
  , {
69
- "__SInfo": "___SInfo_1rhk1_gg_",
70
- "__SWarning": "___SWarning_1rhk1_gg_",
71
- "__SView": "___SView_1rhk1_gg_",
72
- "__SMessage": "___SMessage_1rhk1_gg_",
73
- "__SDismiss": "___SDismiss_1rhk1_gg_",
74
- "__SAction": "___SAction_1rhk1_gg_",
75
- "__SNoticeBubble": "___SNoticeBubble_1rhk1_gg_",
76
- "@enter": "enter_1rhk1",
77
- "@exit": "exit_1rhk1"
68
+ "__SBubble": "___SBubble_1dph8_gg_",
69
+ "__SView": "___SView_1dph8_gg_",
70
+ "_type_info": "_type_info_1dph8_gg_",
71
+ "_type_warning": "_type_warning_1dph8_gg_",
72
+ "__SContent": "___SContent_1dph8_gg_",
73
+ "__SMessage": "___SMessage_1dph8_gg_",
74
+ "__SDismiss": "___SDismiss_1dph8_gg_",
75
+ "__SNoticeBubble": "___SNoticeBubble_1dph8_gg_",
76
+ "@enter": "enter_1dph8",
77
+ "@exit": "exit_1dph8"
78
78
  });
79
79
 
80
80
  var Notices = function Notices(props) {
@@ -93,12 +93,12 @@ var Notices = function Notices(props) {
93
93
  }, [durationStr]);
94
94
 
95
95
  return data.map(function (notice) {
96
- var _ref2;
96
+ var _ref2, _notice$visible;
97
97
 
98
98
  return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_animation.Animation, _ref2.cn("Animation", {
99
99
  "key": notice.uid,
100
100
  "initialAnimation": notice.initialAnimation,
101
- "visible": notice.visible === undefined ? true : notice.visible,
101
+ "visible": (_notice$visible = notice.visible) !== null && _notice$visible !== void 0 ? _notice$visible : true,
102
102
  "duration": duration,
103
103
  "keyframes": [styles['@enter'], styles['@exit']],
104
104
  "ref": ref
@@ -108,15 +108,6 @@ var Notices = function Notices(props) {
108
108
  }))));
109
109
  });
110
110
  };
111
- /**
112
- * ```js
113
- * import { NoticeBubble } from "@semcore/notice-bubble"
114
- * ```
115
- *
116
- * Container is a portal (React.Portal) in the body, inserted once into any part of the application
117
- * and subscribes to manager updates(NoticeBubbleManager)
118
- * */
119
-
120
111
 
121
112
  var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
122
113
  (0, _inherits2["default"])(NoticeBubbleContainerRoot, _Component);
@@ -191,15 +182,6 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
191
182
  }]);
192
183
  return NoticeBubbleContainerRoot;
193
184
  }(_core.Component);
194
- /**
195
- * ```js
196
- * import { NoticeBubble } from "@semcore/notice-bubble"
197
- * <NoticeBubble.Info/>
198
- * ```
199
- *
200
- * View component, the appearance of the notice
201
- * */
202
-
203
185
 
204
186
  (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
205
187
  (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "style", style);
@@ -272,20 +254,22 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
272
254
  value: function render() {
273
255
  var _ref4;
274
256
 
275
- var SInfo = _flexBox.Box;
257
+ var SBubble = _flexBox.Flex;
258
+ var SDismiss = 'div';
259
+ var SContent = _flexBox.Flex;
276
260
  var SMessage = 'div';
277
261
  var SAction = 'div';
278
- var SDismiss = 'div';
279
262
  var _this$props = this.props,
280
- actionNode = _this$props.action,
281
263
  forwardRef = _this$props.forwardRef,
282
264
  styles = _this$props.styles,
283
265
  onMouseEnter = _this$props.onMouseEnter,
284
266
  onMouseLeave = _this$props.onMouseLeave,
285
- children = _this$props.children,
286
267
  getI18nText = _this$props.getI18nText,
268
+ icon = _this$props.icon,
269
+ children = _this$props.children,
270
+ actionNode = _this$props.action,
287
271
  other = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
288
- return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInfo, _ref4.cn("SInfo", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
272
+ return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SBubble, _ref4.cn("SBubble", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
289
273
  "role": "alert"
290
274
  }, other), {}, {
291
275
  "ref": forwardRef,
@@ -295,7 +279,7 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
295
279
  "title": getI18nText('close'),
296
280
  "onClick": this.handlerClose,
297
281
  "aria-label": getI18nText('close')
298
- }), /*#__PURE__*/_react["default"].createElement(_m["default"], _ref4.cn("CloseIcon", {}))), /*#__PURE__*/_react["default"].createElement(SMessage, _ref4.cn("SMessage", {}), children), (0, _isNode["default"])(actionNode) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null);
282
+ }), /*#__PURE__*/_react["default"].createElement(_m["default"], _ref4.cn("CloseIcon", {}))), (0, _isNode["default"])(icon) ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, icon, /*#__PURE__*/_react["default"].createElement(SContent, _ref4.cn("SContent", {}), /*#__PURE__*/_react["default"].createElement(SMessage, _ref4.cn("SMessage", {}), children), (0, _isNode["default"])(actionNode) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null)) : /*#__PURE__*/_react["default"].createElement(SContent, _ref4.cn("SContent", {}), /*#__PURE__*/_react["default"].createElement(SMessage, _ref4.cn("SMessage", {}), children), (0, _isNode["default"])(actionNode) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null));
299
283
  }
300
284
  }]);
301
285
  return ViewInfo;
@@ -311,27 +295,7 @@ var ViewWarning = /*#__PURE__*/function (_ViewInfo) {
311
295
  return _super3.apply(this, arguments);
312
296
  }
313
297
 
314
- (0, _createClass2["default"])(ViewWarning, [{
315
- key: "render",
316
- value: function render() {
317
- var _ref5;
318
-
319
- var SWarning = _flexBox.Box;
320
- var SMessage = 'div';
321
- var SAction = 'div';
322
- var _this$props2 = this.props,
323
- actionNode = _this$props2.action,
324
- children = _this$props2.children,
325
- styles = _this$props2.styles,
326
- forwardRef = _this$props2.forwardRef,
327
- other = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded2);
328
- return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SWarning, _ref5.cn("SWarning", (0, _objectSpread2["default"])({
329
- "ref": forwardRef,
330
- "role": "alert"
331
- }, other)), /*#__PURE__*/_react["default"].createElement(SMessage, _ref5.cn("SMessage", {}), children), (0, _isNode["default"])(actionNode) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref5.cn("SAction", {}), actionNode) : null);
332
- }
333
- }]);
334
- return ViewWarning;
298
+ return (0, _createClass2["default"])(ViewWarning);
335
299
  }(ViewInfo);
336
300
 
337
301
  (0, _defineProperty2["default"])(ViewWarning, "defaultProps", {
@@ -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","undefined","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","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';\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 === undefined ? true : notice.visible}\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\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 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/**\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 getI18nText,\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\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\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;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,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,GAAGC,iBAAA,CAAMC,MAAN,EAAZ;;EACA,IAAMC,WAAW,GAAG,IAAAC,8BAAA,EAAe,iCAAf,EAAkD,KAAlD,EAAyDJ,GAAzD,CAApB;;EACA,IAAMK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;EACpBb,IAAI,EAAE,SADc;EAEpBjB,QAAQ,EAAE;AAFU,C;;IAoBlB8D,gB;;;;;;;;;;;;;;;iGAOM,I;;;;;;WAEV,6BAAoB;MAClB,KAAKC,OAAL,GAAe,KAAKrC,OAAL,CAAaN,OAAb,CAAqB4C,GAArB,CAAyB,KAAKtC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAKqC,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAKxC,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzB+B,gB,kBACkB;EACpB9D,QAAQ,EAAE,IADU;EAEpBiB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlB+C,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBnE,QAAQ,EAAE,IADU;EAEpBiB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAMgD,qBAAqB,GAAG,IAAAC,gBAAA,EAAgB1D,yBAAhB,EAA2C;EACvE2D,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","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;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;EACzB,IAAQC,MAAR,GAAqDD,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;;;;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"}
@@ -43,9 +43,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
43
43
  type: 'info'
44
44
  }, props), {}, {
45
45
  onClose: (0, _assignProps.callAllEventHandlers)(props.onClose, function () {
46
- if (props.visible === undefined) {
47
- manager.remove(props.uid);
48
- }
46
+ manager.remove(props.uid);
49
47
  })
50
48
  });
51
49
  }
@@ -59,7 +57,8 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
59
57
  value: function add(props) {
60
58
  var uid = this.counter++;
61
59
  var item = this.createItem((0, _objectSpread2["default"])({
62
- uid: uid
60
+ uid: uid,
61
+ visible: props.initialAnimation ? true : undefined
63
62
  }, props));
64
63
  this.items.push(item);
65
64
  this.emit();
@@ -87,12 +86,25 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
87
86
  }, {
88
87
  key: "remove",
89
88
  value: function remove(uid) {
89
+ var _this = this;
90
+
90
91
  var index = this.items.findIndex(function (item) {
91
92
  return item.uid === uid;
92
93
  });
93
94
 
94
95
  if (index !== -1) {
95
- this.items.splice(index, 1);
96
+ this.items[index].visible = false;
97
+ setTimeout(function () {
98
+ var index = _this.items.findIndex(function (item) {
99
+ return item.uid === uid;
100
+ });
101
+
102
+ if (index !== -1) {
103
+ _this.items.splice(index, 1);
104
+
105
+ _this.emit();
106
+ }
107
+ }, 1000);
96
108
  this.emit();
97
109
  return true;
98
110
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NoticeBubbleManager.js","names":["EVENT_NAME","NoticeBubbleManager","emitter","EventEmitter","fn","subscribe","props","manager","type","onClose","callAllEventHandlers","visible","undefined","remove","uid","emit","items","counter","item","createItem","push","update","bind","index","findIndex","splice"],"sources":["../../src/NoticeBubbleManager.js"],"sourcesContent":["import EventEmitter from '@semcore/utils/lib/eventEmitter';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\n\nconst EVENT_NAME = 'CHANGE';\n\nclass NoticeBubbleManager {\n items = [];\n emitter = null;\n counter = 0;\n\n constructor() {\n this.emitter = new EventEmitter();\n }\n\n addListener(fn) {\n return this.emitter.subscribe(EVENT_NAME, fn);\n }\n\n createItem(props) {\n const manager = this;\n\n return {\n type: 'info',\n ...props,\n onClose: callAllEventHandlers(props.onClose, () => {\n if (props.visible === undefined) {\n manager.remove(props.uid);\n }\n }),\n };\n }\n\n emit() {\n this.emitter.emit(EVENT_NAME, this.items);\n }\n\n add(props) {\n const uid = this.counter++;\n const item = this.createItem({ uid, ...props });\n this.items.push(item);\n this.emit();\n return {\n uid,\n update: this.update.bind(this, uid),\n remove: this.remove.bind(this, uid),\n };\n }\n\n update(uid, props) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index] = this.createItem({\n ...this.items[index],\n ...props,\n });\n this.emit();\n return true;\n }\n return false;\n }\n\n remove(uid) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items.splice(index, 1);\n this.emit();\n return true;\n }\n return false;\n }\n}\n\nexport { NoticeBubbleManager };\nexport default new NoticeBubbleManager();\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,UAAU,GAAG,QAAnB;;IAEMC,mB;EAKJ,+BAAc;IAAA;IAAA,gDAJN,EAIM;IAAA,kDAHJ,IAGI;IAAA,kDAFJ,CAEI;IACZ,KAAKC,OAAL,GAAe,IAAIC,wBAAJ,EAAf;EACD;;;;WAED,qBAAYC,EAAZ,EAAgB;MACd,OAAO,KAAKF,OAAL,CAAaG,SAAb,CAAuBL,UAAvB,EAAmCI,EAAnC,CAAP;IACD;;;WAED,oBAAWE,KAAX,EAAkB;MAChB,IAAMC,OAAO,GAAG,IAAhB;MAEA;QACEC,IAAI,EAAE;MADR,GAEKF,KAFL;QAGEG,OAAO,EAAE,IAAAC,iCAAA,EAAqBJ,KAAK,CAACG,OAA3B,EAAoC,YAAM;UACjD,IAAIH,KAAK,CAACK,OAAN,KAAkBC,SAAtB,EAAiC;YAC/BL,OAAO,CAACM,MAAR,CAAeP,KAAK,CAACQ,GAArB;UACD;QACF,CAJQ;MAHX;IASD;;;WAED,gBAAO;MACL,KAAKZ,OAAL,CAAaa,IAAb,CAAkBf,UAAlB,EAA8B,KAAKgB,KAAnC;IACD;;;WAED,aAAIV,KAAJ,EAAW;MACT,IAAMQ,GAAG,GAAG,KAAKG,OAAL,EAAZ;MACA,IAAMC,IAAI,GAAG,KAAKC,UAAL;QAAkBL,GAAG,EAAHA;MAAlB,GAA0BR,KAA1B,EAAb;MACA,KAAKU,KAAL,CAAWI,IAAX,CAAgBF,IAAhB;MACA,KAAKH,IAAL;MACA,OAAO;QACLD,GAAG,EAAHA,GADK;QAELO,MAAM,EAAE,KAAKA,MAAL,CAAYC,IAAZ,CAAiB,IAAjB,EAAuBR,GAAvB,CAFH;QAGLD,MAAM,EAAE,KAAKA,MAAL,CAAYS,IAAZ,CAAiB,IAAjB,EAAuBR,GAAvB;MAHH,CAAP;IAKD;;;WAED,gBAAOA,GAAP,EAAYR,KAAZ,EAAmB;MACjB,IAAMiB,KAAK,GAAG,KAAKP,KAAL,CAAWQ,SAAX,CAAqB,UAACN,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIS,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKP,KAAL,CAAWO,KAAX,IAAoB,KAAKJ,UAAL,mEACf,KAAKH,KAAL,CAAWO,KAAX,CADe,GAEfjB,KAFe,EAApB;QAIA,KAAKS,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;WAED,gBAAOD,GAAP,EAAY;MACV,IAAMS,KAAK,GAAG,KAAKP,KAAL,CAAWQ,SAAX,CAAqB,UAACN,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIS,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKP,KAAL,CAAWS,MAAX,CAAkBF,KAAlB,EAAyB,CAAzB;QACA,KAAKR,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;;;;;eAIY,IAAId,mBAAJ,E"}
1
+ {"version":3,"file":"NoticeBubbleManager.js","names":["EVENT_NAME","NoticeBubbleManager","emitter","EventEmitter","fn","subscribe","props","manager","type","onClose","callAllEventHandlers","remove","uid","emit","items","counter","item","createItem","visible","initialAnimation","undefined","push","update","bind","index","findIndex","setTimeout","splice"],"sources":["../../src/NoticeBubbleManager.js"],"sourcesContent":["import EventEmitter from '@semcore/utils/lib/eventEmitter';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\n\nconst EVENT_NAME = 'CHANGE';\n\nclass NoticeBubbleManager {\n items = [];\n emitter = null;\n counter = 0;\n\n constructor() {\n this.emitter = new EventEmitter();\n }\n\n addListener(fn) {\n return this.emitter.subscribe(EVENT_NAME, fn);\n }\n\n createItem(props) {\n const manager = this;\n\n return {\n type: 'info',\n ...props,\n onClose: callAllEventHandlers(props.onClose, () => {\n manager.remove(props.uid);\n }),\n };\n }\n\n emit() {\n this.emitter.emit(EVENT_NAME, this.items);\n }\n\n add(props) {\n const uid = this.counter++;\n const item = this.createItem({\n uid,\n visible: props.initialAnimation ? true : undefined,\n ...props,\n });\n this.items.push(item);\n this.emit();\n return {\n uid,\n update: this.update.bind(this, uid),\n remove: this.remove.bind(this, uid),\n };\n }\n\n update(uid, props) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index] = this.createItem({\n ...this.items[index],\n ...props,\n });\n this.emit();\n return true;\n }\n return false;\n }\n\n remove(uid) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index].visible = false;\n setTimeout(() => {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items.splice(index, 1);\n this.emit();\n }\n }, 1000);\n this.emit();\n return true;\n }\n return false;\n }\n}\n\nexport { NoticeBubbleManager };\nexport default new NoticeBubbleManager();\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,UAAU,GAAG,QAAnB;;IAEMC,mB;EAKJ,+BAAc;IAAA;IAAA,gDAJN,EAIM;IAAA,kDAHJ,IAGI;IAAA,kDAFJ,CAEI;IACZ,KAAKC,OAAL,GAAe,IAAIC,wBAAJ,EAAf;EACD;;;;WAED,qBAAYC,EAAZ,EAAgB;MACd,OAAO,KAAKF,OAAL,CAAaG,SAAb,CAAuBL,UAAvB,EAAmCI,EAAnC,CAAP;IACD;;;WAED,oBAAWE,KAAX,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AAOD,GAAP,EAAY;MAAA;;MACV,IAAMY,KAAK,GAAG,KAAKV,KAAL,CAAWW,SAAX,CAAqB,UAACT,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIY,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKV,KAAL,CAAWU,KAAX,EAAkBN,OAAlB,GAA4B,KAA5B;QACAQ,UAAU,CAAC,YAAM;UACf,IAAMF,KAAK,GAAG,KAAI,CAACV,KAAL,CAAWW,SAAX,CAAqB,UAACT,IAAD;YAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;UAAA,CAArB,CAAd;;UACA,IAAIY,KAAK,KAAK,CAAC,CAAf,EAAkB;YAChB,KAAI,CAACV,KAAL,CAAWa,MAAX,CAAkBH,KAAlB,EAAyB,CAAzB;;YACA,KAAI,CAACX,IAAL;UACD;QACF,CANS,EAMP,IANO,CAAV;QAOA,KAAKA,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;;;;;eAIY,IAAIZ,mBAAJ,E"}
@@ -6,6 +6,13 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
6
6
 
7
7
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
8
8
 
9
+ /**
10
+ * @deprecated use `NoticeBubbleManager` instead.
11
+ * */
12
+
13
+ /**
14
+ * @deprecated use `NoticeBubbleManager` instead.
15
+ * */
9
16
  var NoticeBubbleManager = /*#__PURE__*/(0, _createClass2["default"])(function NoticeBubbleManager() {
10
17
  (0, _classCallCheck2["default"])(this, NoticeBubbleManager);
11
18
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.js","names":["NoticeBubbleManager"],"sources":["../../src/index.d.ts"],"sourcesContent":["import { IPortalProps } from '@semcore/portal';\nimport { CProps, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\n\nexport interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {\n /** Manager copy */\n manager?: INoticeBubbleManager;\n locale?: string;\n}\n\nexport interface INoticeBubbleInfoProps extends INoticeBubbleProps {\n readonly type?: 'info';\n /** Notice display duration\n * @default 5000\n */\n duration?: number;\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleWarningProps extends INoticeBubbleProps {\n readonly type?: 'warning';\n /**\n * Notice display duration\n * @default 0\n */\n duration?: number;\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleProps extends IBoxProps {\n /**\n * Manager instance\n * @default NoticeBubbleManager()\n */\n manager?: INoticeBubbleManager;\n /**\n * Notice visibility\n */\n visible?: boolean;\n /** Adds controls (buttons, etc.) */\n action?: React.ReactNode;\n\n /** Triggered when the notice is closed */\n onClose?: (e?: React.SyntheticEvent) => void;\n}\n\nexport interface INoticeBubbleManager {\n /**\n * Adding a notice.\n * Takes the props properties of NoticeBubble.\n * Returns an object with the uid and the update, remove functions.\n * */\n add: (props: object) => {\n uid: string;\n update: (props: object) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates the notice by uid.\n * Takes the uid-unique identifier and the props-properties of NoticeBubble.\n * Returns a successful or unsuccessful update.\n * */\n update: (uid: string, props: object) => boolean;\n /**\n * Deletes the notice by uid.\n * Takes an uid-unique identifier.\n * Returns a successful or unsuccessful deletion.\n * */\n remove: (uid: string) => boolean;\n}\n\ndeclare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;\ndeclare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;\ndeclare const NoticeBubbleContainer: (<T>(\n props: CProps<INoticeBubbleContainerProps & T>,\n) => ReturnEl) & {\n Info: typeof NoticeBubble;\n Warning: typeof NoticeBubbleWarning;\n};\ndeclare class NoticeBubbleManager implements INoticeBubbleManager {\n /**\n * Adding a notice.\n * Takes the props properties of NoticeBubble.\n * Returns an object with the uid and the update, remove functions.\n * */\n add(props: object): {\n uid: string;\n update: (props: object) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates the notice by uid.\n * Takes the uid-unique identifier and the props-properties of NoticeBubble.\n * Returns a successful or unsuccessful update.\n * */\n update(uid: string, props: object): boolean;\n /**\n * Deletes the notice by uid.\n * Takes an uid-unique identifier.\n * Returns a successful or unsuccessful deletion.\n * */\n remove(uid: string): boolean;\n}\n\nexport { NoticeBubbleContainer, NoticeBubble, NoticeBubbleWarning, NoticeBubbleManager };\nexport default NoticeBubbleManager;\n"],"mappings":";;;;;;;;IAqFcA,mB"}
1
+ {"version":3,"file":"index.d.js","names":["NoticeBubbleManager"],"sources":["../../src/index.d.ts"],"sourcesContent":["import { IPortalProps } from '@semcore/portal';\nimport { CProps, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\n\nexport interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {\n /** Manager copy */\n manager?: INoticeBubbleManager;\n locale?: string;\n}\n\nexport interface INoticeBubbleProps extends IBoxProps {\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children: React.ReactNode;\n}\nexport interface INoticeBubbleInfoProps extends INoticeBubbleProps {\n readonly type?: 'info';\n /**\n * Notice display duration.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleWarningProps extends INoticeBubbleProps {\n readonly type?: 'warning';\n /**\n * Notice display duration.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleManager {\n /**\n * Creates and shows a notice.\n * */\n add: (props: INoticeBubbleInfoProps | INoticeBubbleWarningProps) => {\n uid: string;\n update: (\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates notice by uid.\n * */\n update: (\n uid: string,\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: string) => boolean;\n}\n\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\ndeclare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\ndeclare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;\ndeclare const NoticeBubbleContainer: (<T>(\n props: CProps<INoticeBubbleContainerProps & T>,\n) => ReturnEl) & {\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Info: typeof NoticeBubble;\n\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Warning: typeof NoticeBubbleWarning;\n};\ndeclare class NoticeBubbleManager implements INoticeBubbleManager {\n /**\n * Creates and shows a notice.\n * */\n add(props: INoticeBubbleInfoProps | INoticeBubbleWarningProps): {\n uid: string;\n update: (\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates notice by uid.\n * */\n update(\n uid: string,\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ): boolean;\n /**\n * Removes notice by uid.\n * */\n remove(uid: string): boolean;\n}\n\nexport { NoticeBubbleContainer, NoticeBubble, NoticeBubbleWarning, NoticeBubbleManager };\nexport default NoticeBubbleManager;\n"],"mappings":";;;;;;;;AA8EA;AACA;AACA;;AAEA;AACA;AACA;IAecA,mB"}
@@ -1,5 +1,4 @@
1
- SInfo,
2
- SWarning,
1
+ SBubble,
3
2
  SView {
4
3
  position: relative;
5
4
  margin-bottom: var(--intergalactic-spacing-3x, 12px);
@@ -10,19 +9,25 @@ SView {
10
9
  border-radius: var(--intergalactic-popper-rounded, 6px);
11
10
  overflow: hidden;
12
11
  box-sizing: border-box;
13
- }
12
+ color: var(--intergalactic-text-primary-invert, #ffffff);
13
+ gap: var(--intergalactic-spacing-2x, 8px);
14
14
 
15
- SInfo {
16
- background: var(--intergalactic-bg-primary-invert, #191b23);
15
+ &[type='info'] {
16
+ background: var(--intergalactic-bg-primary-invert, #191b23);
17
+ }
18
+ &[type='warning'] {
19
+ background: var(--intergalactic-bg-primary-critical, #ff4953);
20
+ }
17
21
  }
18
22
 
19
- SWarning {
20
- background: var(--intergalactic-bg-primary-critical, #ff4953);
23
+ SContent {
24
+ flex-direction: column;
25
+ gap: var(--intergalactic-spacing-2x, 8px);
26
+ flex: 1;
21
27
  }
22
28
 
23
29
  SMessage {
24
30
  font-size: var(--intergalactic-fs-200, 14px);
25
- color: var(--intergalactic-text-primary-invert, #ffffff);
26
31
  line-height: var(--intergalactic-lh-100, 133%);
27
32
  }
28
33
 
@@ -39,10 +44,6 @@ SDismiss {
39
44
  }
40
45
  }
41
46
 
42
- SAction {
43
- margin-top: var(--intergalactic-spacing-2x, 8px);
44
- }
45
-
46
47
  SNoticeBubble {
47
48
  width: 300px;
48
49
  position: fixed;
@@ -55,20 +56,32 @@ SNoticeBubble {
55
56
  }
56
57
  }
57
58
 
59
+ SMessage a {
60
+ color: var(--intergalactic-text-link-invert, #8ecdff);
61
+ }
62
+
58
63
  @keyframes enter {
59
64
  from {
60
65
  transform: translate(100%, 0);
66
+ max-height: 0;
67
+ overflow: hidden;
61
68
  }
62
69
  to {
63
70
  transform: translate(0, 0);
71
+ max-height: 100vh;
72
+ overflow: hidden;
64
73
  }
65
74
  }
66
75
 
67
76
  @keyframes exit {
68
77
  from {
78
+ max-height: 100vh;
79
+ overflow: hidden;
69
80
  opacity: 1;
70
81
  }
71
82
  to {
83
+ max-height: 0;
84
+ overflow: hidden;
72
85
  opacity: 0;
73
86
  }
74
87
  }
@@ -8,14 +8,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  import _objectSpread from "@babel/runtime/helpers/objectSpread2";
9
9
  import { sstyled as _sstyled } from "@semcore/core";
10
10
  import { assignProps as _assignProps } from "@semcore/core";
11
- var _excluded = ["action", "forwardRef", "styles", "onMouseEnter", "onMouseLeave", "children", "getI18nText"],
12
- _excluded2 = ["action", "children", "styles", "forwardRef"];
11
+ var _excluded = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action"];
13
12
  import React from 'react';
14
13
  import Portal from '@semcore/portal';
15
14
  import manager from './NoticeBubbleManager';
16
15
  import createComponent, { Component, sstyled, Root } from '@semcore/core';
17
16
  import { Animation } from '@semcore/animation';
18
- import { Box } from '@semcore/flex-box';
17
+ import { Flex, Box } from '@semcore/flex-box';
19
18
  import fire from '@semcore/utils/lib/fire';
20
19
  import isNode from '@semcore/utils/lib/isNode';
21
20
  import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
@@ -30,20 +29,21 @@ var style = (
30
29
  /*__reshadow_css_start__*/
31
30
  _sstyled.insert(
32
31
  /*__inner_css_start__*/
33
- "@keyframes enter_1rhk1{0%{transform:translate(100%,0)}to{transform:translate(0,0)}}@keyframes exit_1rhk1{0%{opacity:1}to{opacity:0}}.___SInfo_1rhk1_gg_,.___SView_1rhk1_gg_,.___SWarning_1rhk1_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}.___SInfo_1rhk1_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SWarning_1rhk1_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SDismiss_1rhk1_gg_,.___SMessage_1rhk1_gg_{color:var(--intergalactic-text-primary-invert, #ffffff)}.___SMessage_1rhk1_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_1rhk1_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px)}@media (hover:hover){.___SDismiss_1rhk1_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SAction_1rhk1_gg_{margin-top:var(--intergalactic-spacing-2x, 8px)}.___SNoticeBubble_1rhk1_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_1rhk1_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}"
32
+ "@keyframes enter_1dph8{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_1dph8{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_1dph8_gg_,.___SContent_1dph8_gg_,.___SView_1dph8_gg_{grid-gap:var(--intergalactic-spacing-2x, 8px);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_1dph8_gg_,.___SView_1dph8_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_1dph8_gg_._type_info_1dph8_gg_,.___SView_1dph8_gg_._type_info_1dph8_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_1dph8_gg_._type_warning_1dph8_gg_,.___SView_1dph8_gg_._type_warning_1dph8_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_1dph8_gg_{flex-direction:column;flex:1}.___SMessage_1dph8_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_1dph8_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_1dph8_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SNoticeBubble_1dph8_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_1dph8_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SMessage_1dph8_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}"
34
33
  /*__inner_css_end__*/
35
- , "1rhk1_gg_")
34
+ , "1dph8_gg_")
36
35
  /*__reshadow_css_end__*/
37
36
  , {
38
- "__SInfo": "___SInfo_1rhk1_gg_",
39
- "__SWarning": "___SWarning_1rhk1_gg_",
40
- "__SView": "___SView_1rhk1_gg_",
41
- "__SMessage": "___SMessage_1rhk1_gg_",
42
- "__SDismiss": "___SDismiss_1rhk1_gg_",
43
- "__SAction": "___SAction_1rhk1_gg_",
44
- "__SNoticeBubble": "___SNoticeBubble_1rhk1_gg_",
45
- "@enter": "enter_1rhk1",
46
- "@exit": "exit_1rhk1"
37
+ "__SBubble": "___SBubble_1dph8_gg_",
38
+ "__SView": "___SView_1dph8_gg_",
39
+ "_type_info": "_type_info_1dph8_gg_",
40
+ "_type_warning": "_type_warning_1dph8_gg_",
41
+ "__SContent": "___SContent_1dph8_gg_",
42
+ "__SMessage": "___SMessage_1dph8_gg_",
43
+ "__SDismiss": "___SDismiss_1dph8_gg_",
44
+ "__SNoticeBubble": "___SNoticeBubble_1dph8_gg_",
45
+ "@enter": "enter_1dph8",
46
+ "@exit": "exit_1dph8"
47
47
  });
48
48
 
49
49
  var Notices = function Notices(props) {
@@ -58,12 +58,12 @@ var Notices = function Notices(props) {
58
58
  return parseInt(durationStr, 10);
59
59
  }, [durationStr]);
60
60
  return data.map(function (notice) {
61
- var _ref2;
61
+ var _ref2, _notice$visible;
62
62
 
63
63
  return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(Animation, _ref2.cn("Animation", {
64
64
  "key": notice.uid,
65
65
  "initialAnimation": notice.initialAnimation,
66
- "visible": notice.visible === undefined ? true : notice.visible,
66
+ "visible": (_notice$visible = notice.visible) !== null && _notice$visible !== void 0 ? _notice$visible : true,
67
67
  "duration": duration,
68
68
  "keyframes": [styles['@enter'], styles['@exit']],
69
69
  "ref": ref
@@ -73,15 +73,6 @@ var Notices = function Notices(props) {
73
73
  }))));
74
74
  });
75
75
  };
76
- /**
77
- * ```js
78
- * import { NoticeBubble } from "@semcore/notice-bubble"
79
- * ```
80
- *
81
- * Container is a portal (React.Portal) in the body, inserted once into any part of the application
82
- * and subscribes to manager updates(NoticeBubbleManager)
83
- * */
84
-
85
76
 
86
77
  var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
87
78
  _inherits(NoticeBubbleContainerRoot, _Component);
@@ -163,15 +154,6 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
163
154
 
164
155
  return NoticeBubbleContainerRoot;
165
156
  }(Component);
166
- /**
167
- * ```js
168
- * import { NoticeBubble } from "@semcore/notice-bubble"
169
- * <NoticeBubble.Info/>
170
- * ```
171
- *
172
- * View component, the appearance of the notice
173
- * */
174
-
175
157
 
176
158
  _defineProperty(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
177
159
 
@@ -252,22 +234,24 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
252
234
  value: function render() {
253
235
  var _ref4;
254
236
 
255
- var SInfo = Box;
237
+ var SBubble = Flex;
238
+ var SDismiss = 'div';
239
+ var SContent = Flex;
256
240
  var SMessage = 'div';
257
241
  var SAction = 'div';
258
- var SDismiss = 'div';
259
242
 
260
243
  var _this$props = this.props,
261
- actionNode = _this$props.action,
262
244
  forwardRef = _this$props.forwardRef,
263
245
  styles = _this$props.styles,
264
246
  onMouseEnter = _this$props.onMouseEnter,
265
247
  onMouseLeave = _this$props.onMouseLeave,
266
- children = _this$props.children,
267
248
  getI18nText = _this$props.getI18nText,
249
+ icon = _this$props.icon,
250
+ children = _this$props.children,
251
+ actionNode = _this$props.action,
268
252
  other = _objectWithoutProperties(_this$props, _excluded);
269
253
 
270
- return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SInfo, _ref4.cn("SInfo", _objectSpread(_objectSpread({
254
+ return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SBubble, _ref4.cn("SBubble", _objectSpread(_objectSpread({
271
255
  "role": "alert"
272
256
  }, other), {}, {
273
257
  "ref": forwardRef,
@@ -277,7 +261,7 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
277
261
  "title": getI18nText('close'),
278
262
  "onClick": this.handlerClose,
279
263
  "aria-label": getI18nText('close')
280
- }), /*#__PURE__*/React.createElement(CloseIcon, _ref4.cn("CloseIcon", {}))), /*#__PURE__*/React.createElement(SMessage, _ref4.cn("SMessage", {}), children), isNode(actionNode) ? /*#__PURE__*/React.createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null);
264
+ }), /*#__PURE__*/React.createElement(CloseIcon, _ref4.cn("CloseIcon", {}))), isNode(icon) ? /*#__PURE__*/React.createElement(React.Fragment, null, icon, /*#__PURE__*/React.createElement(SContent, _ref4.cn("SContent", {}), /*#__PURE__*/React.createElement(SMessage, _ref4.cn("SMessage", {}), children), isNode(actionNode) ? /*#__PURE__*/React.createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null)) : /*#__PURE__*/React.createElement(SContent, _ref4.cn("SContent", {}), /*#__PURE__*/React.createElement(SMessage, _ref4.cn("SMessage", {}), children), isNode(actionNode) ? /*#__PURE__*/React.createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null));
281
265
  }
282
266
  }]);
283
267
 
@@ -295,30 +279,7 @@ var ViewWarning = /*#__PURE__*/function (_ViewInfo) {
295
279
  return _super3.apply(this, arguments);
296
280
  }
297
281
 
298
- _createClass(ViewWarning, [{
299
- key: "render",
300
- value: function render() {
301
- var _ref5;
302
-
303
- var SWarning = Box;
304
- var SMessage = 'div';
305
- var SAction = 'div';
306
-
307
- var _this$props2 = this.props,
308
- actionNode = _this$props2.action,
309
- children = _this$props2.children,
310
- styles = _this$props2.styles,
311
- forwardRef = _this$props2.forwardRef,
312
- other = _objectWithoutProperties(_this$props2, _excluded2);
313
-
314
- return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SWarning, _ref5.cn("SWarning", _objectSpread({
315
- "ref": forwardRef,
316
- "role": "alert"
317
- }, other)), /*#__PURE__*/React.createElement(SMessage, _ref5.cn("SMessage", {}), children), isNode(actionNode) ? /*#__PURE__*/React.createElement(SAction, _ref5.cn("SAction", {}), actionNode) : null);
318
- }
319
- }]);
320
-
321
- return ViewWarning;
282
+ return _createClass(ViewWarning);
322
283
  }(ViewInfo);
323
284
 
324
285
  _defineProperty(ViewWarning, "defaultProps", {
@@ -1 +1 @@
1
- {"version":3,"file":"NoticeBubble.js","names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","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","undefined","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","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';\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 === undefined ? true : notice.visible}\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\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 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/**\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 getI18nText,\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\n title={getI18nText('close')}\n onClick={this.handlerClose}\n aria-label={getI18nText('close')}\n >\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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;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;;EA3B4B9C,S;;gBAAzB2E,gB,kBACkB;EACpBpD,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,MAFc;EAGpBzC,OAAO,EAAPA;AAHoB,C;;IA6BlBkF,uB;;;;;;;;;;;;EAAgCL,gB;;gBAAhCK,uB,kBACkB;EACpBzD,QAAQ,EAAE,IADU;EAEpBgB,IAAI,EAAE,SAFc;EAGpBzC,OAAO,EAAPA;AAHoB,C;;AAOxB,IAAMmF,qBAAqB,GAAGlF,eAAe,CAACkC,yBAAD,EAA4B;EACvEiD,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","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,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;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,OAAO,GAAG,SAAVA,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D,gB;;;;;;;;;;;;;;;;+DAOM,I;;;;;;;WAEV,6BAAoB;MAClB,KAAKC,OAAL,GAAe,KAAK/B,OAAL,CAAahD,OAAb,CAAqBgF,GAArB,CAAyB,KAAKhC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAK+B,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAKlC,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;;EA3B4B9C,S;;gBAAzB4E,gB,kBACkB;EACpBpD,QAAQ,EAAE,IADU;EAEpBe,IAAI,EAAE,MAFc;EAGpBzC,OAAO,EAAPA;AAHoB,C;;IA6BlBmF,uB;;;;;;;;;;;;EAAgCL,gB;;gBAAhCK,uB,kBACkB;EACpBzD,QAAQ,EAAE,IADU;EAEpBe,IAAI,EAAE,SAFc;EAGpBzC,OAAO,EAAPA;AAHoB,C;;AAOxB,IAAMoF,qBAAqB,GAAGnF,eAAe,CAACkC,yBAAD,EAA4B;EACvEkD,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"}
@@ -32,9 +32,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
32
32
  type: 'info'
33
33
  }, props), {}, {
34
34
  onClose: callAllEventHandlers(props.onClose, function () {
35
- if (props.visible === undefined) {
36
- manager.remove(props.uid);
37
- }
35
+ manager.remove(props.uid);
38
36
  })
39
37
  });
40
38
  }
@@ -48,7 +46,8 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
48
46
  value: function add(props) {
49
47
  var uid = this.counter++;
50
48
  var item = this.createItem(_objectSpread({
51
- uid: uid
49
+ uid: uid,
50
+ visible: props.initialAnimation ? true : undefined
52
51
  }, props));
53
52
  this.items.push(item);
54
53
  this.emit();
@@ -76,12 +75,25 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
76
75
  }, {
77
76
  key: "remove",
78
77
  value: function remove(uid) {
78
+ var _this = this;
79
+
79
80
  var index = this.items.findIndex(function (item) {
80
81
  return item.uid === uid;
81
82
  });
82
83
 
83
84
  if (index !== -1) {
84
- this.items.splice(index, 1);
85
+ this.items[index].visible = false;
86
+ setTimeout(function () {
87
+ var index = _this.items.findIndex(function (item) {
88
+ return item.uid === uid;
89
+ });
90
+
91
+ if (index !== -1) {
92
+ _this.items.splice(index, 1);
93
+
94
+ _this.emit();
95
+ }
96
+ }, 1000);
85
97
  this.emit();
86
98
  return true;
87
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NoticeBubbleManager.js","names":["EventEmitter","callAllEventHandlers","EVENT_NAME","NoticeBubbleManager","emitter","fn","subscribe","props","manager","type","onClose","visible","undefined","remove","uid","emit","items","counter","item","createItem","push","update","bind","index","findIndex","splice"],"sources":["../../src/NoticeBubbleManager.js"],"sourcesContent":["import EventEmitter from '@semcore/utils/lib/eventEmitter';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\n\nconst EVENT_NAME = 'CHANGE';\n\nclass NoticeBubbleManager {\n items = [];\n emitter = null;\n counter = 0;\n\n constructor() {\n this.emitter = new EventEmitter();\n }\n\n addListener(fn) {\n return this.emitter.subscribe(EVENT_NAME, fn);\n }\n\n createItem(props) {\n const manager = this;\n\n return {\n type: 'info',\n ...props,\n onClose: callAllEventHandlers(props.onClose, () => {\n if (props.visible === undefined) {\n manager.remove(props.uid);\n }\n }),\n };\n }\n\n emit() {\n this.emitter.emit(EVENT_NAME, this.items);\n }\n\n add(props) {\n const uid = this.counter++;\n const item = this.createItem({ uid, ...props });\n this.items.push(item);\n this.emit();\n return {\n uid,\n update: this.update.bind(this, uid),\n remove: this.remove.bind(this, uid),\n };\n }\n\n update(uid, props) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index] = this.createItem({\n ...this.items[index],\n ...props,\n });\n this.emit();\n return true;\n }\n return false;\n }\n\n remove(uid) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items.splice(index, 1);\n this.emit();\n return true;\n }\n return false;\n }\n}\n\nexport { NoticeBubbleManager };\nexport default new NoticeBubbleManager();\n"],"mappings":";;;;AAAA,OAAOA,YAAP,MAAyB,iCAAzB;AACA,SAASC,oBAAT,QAAqC,gCAArC;AAEA,IAAMC,UAAU,GAAG,QAAnB;;IAEMC,mB;EAKJ,+BAAc;IAAA;;IAAA,+BAJN,EAIM;;IAAA,iCAHJ,IAGI;;IAAA,iCAFJ,CAEI;;IACZ,KAAKC,OAAL,GAAe,IAAIJ,YAAJ,EAAf;EACD;;;;WAED,qBAAYK,EAAZ,EAAgB;MACd,OAAO,KAAKD,OAAL,CAAaE,SAAb,CAAuBJ,UAAvB,EAAmCG,EAAnC,CAAP;IACD;;;WAED,oBAAWE,KAAX,EAAkB;MAChB,IAAMC,OAAO,GAAG,IAAhB;MAEA;QACEC,IAAI,EAAE;MADR,GAEKF,KAFL;QAGEG,OAAO,EAAET,oBAAoB,CAACM,KAAK,CAACG,OAAP,EAAgB,YAAM;UACjD,IAAIH,KAAK,CAACI,OAAN,KAAkBC,SAAtB,EAAiC;YAC/BJ,OAAO,CAACK,MAAR,CAAeN,KAAK,CAACO,GAArB;UACD;QACF,CAJ4B;MAH/B;IASD;;;WAED,gBAAO;MACL,KAAKV,OAAL,CAAaW,IAAb,CAAkBb,UAAlB,EAA8B,KAAKc,KAAnC;IACD;;;WAED,aAAIT,KAAJ,EAAW;MACT,IAAMO,GAAG,GAAG,KAAKG,OAAL,EAAZ;MACA,IAAMC,IAAI,GAAG,KAAKC,UAAL;QAAkBL,GAAG,EAAHA;MAAlB,GAA0BP,KAA1B,EAAb;MACA,KAAKS,KAAL,CAAWI,IAAX,CAAgBF,IAAhB;MACA,KAAKH,IAAL;MACA,OAAO;QACLD,GAAG,EAAHA,GADK;QAELO,MAAM,EAAE,KAAKA,MAAL,CAAYC,IAAZ,CAAiB,IAAjB,EAAuBR,GAAvB,CAFH;QAGLD,MAAM,EAAE,KAAKA,MAAL,CAAYS,IAAZ,CAAiB,IAAjB,EAAuBR,GAAvB;MAHH,CAAP;IAKD;;;WAED,gBAAOA,GAAP,EAAYP,KAAZ,EAAmB;MACjB,IAAMgB,KAAK,GAAG,KAAKP,KAAL,CAAWQ,SAAX,CAAqB,UAACN,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIS,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKP,KAAL,CAAWO,KAAX,IAAoB,KAAKJ,UAAL,iCACf,KAAKH,KAAL,CAAWO,KAAX,CADe,GAEfhB,KAFe,EAApB;QAIA,KAAKQ,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;WAED,gBAAOD,GAAP,EAAY;MACV,IAAMS,KAAK,GAAG,KAAKP,KAAL,CAAWQ,SAAX,CAAqB,UAACN,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIS,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKP,KAAL,CAAWS,MAAX,CAAkBF,KAAlB,EAAyB,CAAzB;QACA,KAAKR,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;;;;AAGH,SAASZ,mBAAT;AACA,eAAe,IAAIA,mBAAJ,EAAf"}
1
+ {"version":3,"file":"NoticeBubbleManager.js","names":["EventEmitter","callAllEventHandlers","EVENT_NAME","NoticeBubbleManager","emitter","fn","subscribe","props","manager","type","onClose","remove","uid","emit","items","counter","item","createItem","visible","initialAnimation","undefined","push","update","bind","index","findIndex","setTimeout","splice"],"sources":["../../src/NoticeBubbleManager.js"],"sourcesContent":["import EventEmitter from '@semcore/utils/lib/eventEmitter';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\n\nconst EVENT_NAME = 'CHANGE';\n\nclass NoticeBubbleManager {\n items = [];\n emitter = null;\n counter = 0;\n\n constructor() {\n this.emitter = new EventEmitter();\n }\n\n addListener(fn) {\n return this.emitter.subscribe(EVENT_NAME, fn);\n }\n\n createItem(props) {\n const manager = this;\n\n return {\n type: 'info',\n ...props,\n onClose: callAllEventHandlers(props.onClose, () => {\n manager.remove(props.uid);\n }),\n };\n }\n\n emit() {\n this.emitter.emit(EVENT_NAME, this.items);\n }\n\n add(props) {\n const uid = this.counter++;\n const item = this.createItem({\n uid,\n visible: props.initialAnimation ? true : undefined,\n ...props,\n });\n this.items.push(item);\n this.emit();\n return {\n uid,\n update: this.update.bind(this, uid),\n remove: this.remove.bind(this, uid),\n };\n }\n\n update(uid, props) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index] = this.createItem({\n ...this.items[index],\n ...props,\n });\n this.emit();\n return true;\n }\n return false;\n }\n\n remove(uid) {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index].visible = false;\n setTimeout(() => {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items.splice(index, 1);\n this.emit();\n }\n }, 1000);\n this.emit();\n return true;\n }\n return false;\n }\n}\n\nexport { NoticeBubbleManager };\nexport default new NoticeBubbleManager();\n"],"mappings":";;;;AAAA,OAAOA,YAAP,MAAyB,iCAAzB;AACA,SAASC,oBAAT,QAAqC,gCAArC;AAEA,IAAMC,UAAU,GAAG,QAAnB;;IAEMC,mB;EAKJ,+BAAc;IAAA;;IAAA,+BAJN,EAIM;;IAAA,iCAHJ,IAGI;;IAAA,iCAFJ,CAEI;;IACZ,KAAKC,OAAL,GA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X,IAAoB,KAAKP,UAAL,iCACf,KAAKH,KAAL,CAAWU,KAAX,CADe,GAEfjB,KAFe,EAApB;QAIA,KAAKM,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;WAED,gBAAOD,GAAP,EAAY;MAAA;;MACV,IAAMY,KAAK,GAAG,KAAKV,KAAL,CAAWW,SAAX,CAAqB,UAACT,IAAD;QAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;MAAA,CAArB,CAAd;;MACA,IAAIY,KAAK,KAAK,CAAC,CAAf,EAAkB;QAChB,KAAKV,KAAL,CAAWU,KAAX,EAAkBN,OAAlB,GAA4B,KAA5B;QACAQ,UAAU,CAAC,YAAM;UACf,IAAMF,KAAK,GAAG,KAAI,CAACV,KAAL,CAAWW,SAAX,CAAqB,UAACT,IAAD;YAAA,OAAUA,IAAI,CAACJ,GAAL,KAAaA,GAAvB;UAAA,CAArB,CAAd;;UACA,IAAIY,KAAK,KAAK,CAAC,CAAf,EAAkB;YAChB,KAAI,CAACV,KAAL,CAAWa,MAAX,CAAkBH,KAAlB,EAAyB,CAAzB;;YACA,KAAI,CAACX,IAAL;UACD;QACF,CANS,EAMP,IANO,CAAV;QAOA,KAAKA,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;;;;AAGH,SAASV,mBAAT;AACA,eAAe,IAAIA,mBAAJ,EAAf"}
@@ -1,6 +1,13 @@
1
1
  import _createClass from "@babel/runtime/helpers/createClass";
2
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
3
 
4
+ /**
5
+ * @deprecated use `NoticeBubbleManager` instead.
6
+ * */
7
+
8
+ /**
9
+ * @deprecated use `NoticeBubbleManager` instead.
10
+ * */
4
11
  var NoticeBubbleManager = /*#__PURE__*/_createClass(function NoticeBubbleManager() {
5
12
  _classCallCheck(this, NoticeBubbleManager);
6
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.js","names":["NoticeBubbleManager"],"sources":["../../src/index.d.ts"],"sourcesContent":["import { IPortalProps } from '@semcore/portal';\nimport { CProps, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\n\nexport interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {\n /** Manager copy */\n manager?: INoticeBubbleManager;\n locale?: string;\n}\n\nexport interface INoticeBubbleInfoProps extends INoticeBubbleProps {\n readonly type?: 'info';\n /** Notice display duration\n * @default 5000\n */\n duration?: number;\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleWarningProps extends INoticeBubbleProps {\n readonly type?: 'warning';\n /**\n * Notice display duration\n * @default 0\n */\n duration?: number;\n /** Enables animation on first rendering\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleProps extends IBoxProps {\n /**\n * Manager instance\n * @default NoticeBubbleManager()\n */\n manager?: INoticeBubbleManager;\n /**\n * Notice visibility\n */\n visible?: boolean;\n /** Adds controls (buttons, etc.) */\n action?: React.ReactNode;\n\n /** Triggered when the notice is closed */\n onClose?: (e?: React.SyntheticEvent) => void;\n}\n\nexport interface INoticeBubbleManager {\n /**\n * Adding a notice.\n * Takes the props properties of NoticeBubble.\n * Returns an object with the uid and the update, remove functions.\n * */\n add: (props: object) => {\n uid: string;\n update: (props: object) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates the notice by uid.\n * Takes the uid-unique identifier and the props-properties of NoticeBubble.\n * Returns a successful or unsuccessful update.\n * */\n update: (uid: string, props: object) => boolean;\n /**\n * Deletes the notice by uid.\n * Takes an uid-unique identifier.\n * Returns a successful or unsuccessful deletion.\n * */\n remove: (uid: string) => boolean;\n}\n\ndeclare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;\ndeclare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;\ndeclare const NoticeBubbleContainer: (<T>(\n props: CProps<INoticeBubbleContainerProps & T>,\n) => ReturnEl) & {\n Info: typeof NoticeBubble;\n Warning: typeof NoticeBubbleWarning;\n};\ndeclare class NoticeBubbleManager implements INoticeBubbleManager {\n /**\n * Adding a notice.\n * Takes the props properties of NoticeBubble.\n * Returns an object with the uid and the update, remove functions.\n * */\n add(props: object): {\n uid: string;\n update: (props: object) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates the notice by uid.\n * Takes the uid-unique identifier and the props-properties of NoticeBubble.\n * Returns a successful or unsuccessful update.\n * */\n update(uid: string, props: object): boolean;\n /**\n * Deletes the notice by uid.\n * Takes an uid-unique identifier.\n * Returns a successful or unsuccessful deletion.\n * */\n remove(uid: string): boolean;\n}\n\nexport { NoticeBubbleContainer, NoticeBubble, NoticeBubbleWarning, NoticeBubbleManager };\nexport default NoticeBubbleManager;\n"],"mappings":";;;IAqFcA,mB"}
1
+ {"version":3,"file":"index.d.js","names":["NoticeBubbleManager"],"sources":["../../src/index.d.ts"],"sourcesContent":["import { IPortalProps } from '@semcore/portal';\nimport { CProps, ReturnEl } from '@semcore/core';\nimport { IBoxProps } from '@semcore/flex-box';\n\nexport interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {\n /** Manager copy */\n manager?: INoticeBubbleManager;\n locale?: string;\n}\n\nexport interface INoticeBubbleProps extends IBoxProps {\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children: React.ReactNode;\n}\nexport interface INoticeBubbleInfoProps extends INoticeBubbleProps {\n readonly type?: 'info';\n /**\n * Notice display duration.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleWarningProps extends INoticeBubbleProps {\n readonly type?: 'warning';\n /**\n * Notice display duration.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n}\n\nexport interface INoticeBubbleManager {\n /**\n * Creates and shows a notice.\n * */\n add: (props: INoticeBubbleInfoProps | INoticeBubbleWarningProps) => {\n uid: string;\n update: (\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates notice by uid.\n * */\n update: (\n uid: string,\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: string) => boolean;\n}\n\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\ndeclare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\ndeclare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;\ndeclare const NoticeBubbleContainer: (<T>(\n props: CProps<INoticeBubbleContainerProps & T>,\n) => ReturnEl) & {\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Info: typeof NoticeBubble;\n\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Warning: typeof NoticeBubbleWarning;\n};\ndeclare class NoticeBubbleManager implements INoticeBubbleManager {\n /**\n * Creates and shows a notice.\n * */\n add(props: INoticeBubbleInfoProps | INoticeBubbleWarningProps): {\n uid: string;\n update: (\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ) => boolean;\n remove: () => boolean;\n };\n /**\n * Updates notice by uid.\n * */\n update(\n uid: string,\n props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,\n ): boolean;\n /**\n * Removes notice by uid.\n * */\n remove(uid: string): boolean;\n}\n\nexport { NoticeBubbleContainer, NoticeBubble, NoticeBubbleWarning, NoticeBubbleManager };\nexport default NoticeBubbleManager;\n"],"mappings":";;;AA8EA;AACA;AACA;;AAEA;AACA;AACA;IAecA,mB"}
@@ -1,5 +1,4 @@
1
- SInfo,
2
- SWarning,
1
+ SBubble,
3
2
  SView {
4
3
  position: relative;
5
4
  margin-bottom: var(--intergalactic-spacing-3x, 12px);
@@ -10,19 +9,25 @@ SView {
10
9
  border-radius: var(--intergalactic-popper-rounded, 6px);
11
10
  overflow: hidden;
12
11
  box-sizing: border-box;
13
- }
12
+ color: var(--intergalactic-text-primary-invert, #ffffff);
13
+ gap: var(--intergalactic-spacing-2x, 8px);
14
14
 
15
- SInfo {
16
- background: var(--intergalactic-bg-primary-invert, #191b23);
15
+ &[type='info'] {
16
+ background: var(--intergalactic-bg-primary-invert, #191b23);
17
+ }
18
+ &[type='warning'] {
19
+ background: var(--intergalactic-bg-primary-critical, #ff4953);
20
+ }
17
21
  }
18
22
 
19
- SWarning {
20
- background: var(--intergalactic-bg-primary-critical, #ff4953);
23
+ SContent {
24
+ flex-direction: column;
25
+ gap: var(--intergalactic-spacing-2x, 8px);
26
+ flex: 1;
21
27
  }
22
28
 
23
29
  SMessage {
24
30
  font-size: var(--intergalactic-fs-200, 14px);
25
- color: var(--intergalactic-text-primary-invert, #ffffff);
26
31
  line-height: var(--intergalactic-lh-100, 133%);
27
32
  }
28
33
 
@@ -39,10 +44,6 @@ SDismiss {
39
44
  }
40
45
  }
41
46
 
42
- SAction {
43
- margin-top: var(--intergalactic-spacing-2x, 8px);
44
- }
45
-
46
47
  SNoticeBubble {
47
48
  width: 300px;
48
49
  position: fixed;
@@ -55,20 +56,32 @@ SNoticeBubble {
55
56
  }
56
57
  }
57
58
 
59
+ SMessage a {
60
+ color: var(--intergalactic-text-link-invert, #8ecdff);
61
+ }
62
+
58
63
  @keyframes enter {
59
64
  from {
60
65
  transform: translate(100%, 0);
66
+ max-height: 0;
67
+ overflow: hidden;
61
68
  }
62
69
  to {
63
70
  transform: translate(0, 0);
71
+ max-height: 100vh;
72
+ overflow: hidden;
64
73
  }
65
74
  }
66
75
 
67
76
  @keyframes exit {
68
77
  from {
78
+ max-height: 100vh;
79
+ overflow: hidden;
69
80
  opacity: 1;
70
81
  }
71
82
  to {
83
+ max-height: 0;
84
+ overflow: hidden;
72
85
  opacity: 0;
73
86
  }
74
87
  }
@@ -8,13 +8,32 @@ export interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {
8
8
  locale?: string;
9
9
  }
10
10
 
11
+ export interface INoticeBubbleProps extends IBoxProps {
12
+ /**
13
+ * Notice visibility.
14
+ */
15
+ visible?: boolean;
16
+ /**
17
+ * Control under the notice children.
18
+ * */
19
+ action?: React.ReactNode;
20
+ /**
21
+ * Callback triggered by "Close" icon click.
22
+ * */
23
+ onClose?: (e?: React.SyntheticEvent) => void;
24
+ /**
25
+ * Notice content.
26
+ * */
27
+ children: React.ReactNode;
28
+ }
11
29
  export interface INoticeBubbleInfoProps extends INoticeBubbleProps {
12
30
  readonly type?: 'info';
13
- /** Notice display duration
14
- * @default 5000
31
+ /**
32
+ * Notice display duration.
15
33
  */
16
34
  duration?: number;
17
- /** Enables animation on first rendering
35
+ /**
36
+ * Enables animation on first rendering.
18
37
  * @default false
19
38
  */
20
39
  initialAnimation?: boolean;
@@ -23,87 +42,81 @@ export interface INoticeBubbleInfoProps extends INoticeBubbleProps {
23
42
  export interface INoticeBubbleWarningProps extends INoticeBubbleProps {
24
43
  readonly type?: 'warning';
25
44
  /**
26
- * Notice display duration
27
- * @default 0
45
+ * Notice display duration.
28
46
  */
29
47
  duration?: number;
30
- /** Enables animation on first rendering
48
+ /**
49
+ * Enables animation on first rendering.
31
50
  * @default false
32
51
  */
33
52
  initialAnimation?: boolean;
34
53
  }
35
54
 
36
- export interface INoticeBubbleProps extends IBoxProps {
37
- /**
38
- * Manager instance
39
- * @default NoticeBubbleManager()
40
- */
41
- manager?: INoticeBubbleManager;
42
- /**
43
- * Notice visibility
44
- */
45
- visible?: boolean;
46
- /** Adds controls (buttons, etc.) */
47
- action?: React.ReactNode;
48
-
49
- /** Triggered when the notice is closed */
50
- onClose?: (e?: React.SyntheticEvent) => void;
51
- }
52
-
53
55
  export interface INoticeBubbleManager {
54
56
  /**
55
- * Adding a notice.
56
- * Takes the props properties of NoticeBubble.
57
- * Returns an object with the uid and the update, remove functions.
57
+ * Creates and shows a notice.
58
58
  * */
59
- add: (props: object) => {
59
+ add: (props: INoticeBubbleInfoProps | INoticeBubbleWarningProps) => {
60
60
  uid: string;
61
- update: (props: object) => boolean;
61
+ update: (
62
+ props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,
63
+ ) => boolean;
62
64
  remove: () => boolean;
63
65
  };
64
66
  /**
65
- * Updates the notice by uid.
66
- * Takes the uid-unique identifier and the props-properties of NoticeBubble.
67
- * Returns a successful or unsuccessful update.
67
+ * Updates notice by uid.
68
68
  * */
69
- update: (uid: string, props: object) => boolean;
69
+ update: (
70
+ uid: string,
71
+ props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,
72
+ ) => boolean;
70
73
  /**
71
- * Deletes the notice by uid.
72
- * Takes an uid-unique identifier.
73
- * Returns a successful or unsuccessful deletion.
74
+ * Removes notice by uid.
74
75
  * */
75
76
  remove: (uid: string) => boolean;
76
77
  }
77
78
 
79
+ /**
80
+ * @deprecated use `NoticeBubbleManager` instead.
81
+ * */
78
82
  declare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;
83
+ /**
84
+ * @deprecated use `NoticeBubbleManager` instead.
85
+ * */
79
86
  declare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;
80
87
  declare const NoticeBubbleContainer: (<T>(
81
88
  props: CProps<INoticeBubbleContainerProps & T>,
82
89
  ) => ReturnEl) & {
90
+ /**
91
+ * @deprecated use `NoticeBubbleManager` instead.
92
+ * */
83
93
  Info: typeof NoticeBubble;
94
+
95
+ /**
96
+ * @deprecated use `NoticeBubbleManager` instead.
97
+ * */
84
98
  Warning: typeof NoticeBubbleWarning;
85
99
  };
86
100
  declare class NoticeBubbleManager implements INoticeBubbleManager {
87
101
  /**
88
- * Adding a notice.
89
- * Takes the props properties of NoticeBubble.
90
- * Returns an object with the uid and the update, remove functions.
102
+ * Creates and shows a notice.
91
103
  * */
92
- add(props: object): {
104
+ add(props: INoticeBubbleInfoProps | INoticeBubbleWarningProps): {
93
105
  uid: string;
94
- update: (props: object) => boolean;
106
+ update: (
107
+ props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,
108
+ ) => boolean;
95
109
  remove: () => boolean;
96
110
  };
97
111
  /**
98
- * Updates the notice by uid.
99
- * Takes the uid-unique identifier and the props-properties of NoticeBubble.
100
- * Returns a successful or unsuccessful update.
112
+ * Updates notice by uid.
101
113
  * */
102
- update(uid: string, props: object): boolean;
114
+ update(
115
+ uid: string,
116
+ props: Partial<INoticeBubbleInfoProps> | Partial<INoticeBubbleWarningProps>,
117
+ ): boolean;
103
118
  /**
104
- * Deletes the notice by uid.
105
- * Takes an uid-unique identifier.
106
- * Returns a successful or unsuccessful deletion.
119
+ * Removes notice by uid.
107
120
  * */
108
121
  remove(uid: string): boolean;
109
122
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/notice-bubble",
3
3
  "description": "Semrush NoticeBubble Component",
4
- "version": "4.6.7",
4
+ "version": "4.7.0",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",