@semcore/notice-bubble 4.0.5 → 4.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +75 -0
- package/lib/cjs/NoticeBubble.js +13 -13
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/NoticeBubble.js +13 -13
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/NoticeBubble.jsx +0 -259
- package/src/NoticeBubbleManager.js +0 -74
- package/src/index.d.ts +0 -83
- package/src/index.js +0 -9
- package/src/style/notice-bubble.shadow.css +0 -57
- package/src/utils.js +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [4.0.8] - 2022-07-22
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.34.0 ~> 3.35.0], `@semcore/icon` [2.29.0 ~> 2.29.1], `@semcore/flex-box` [4.5.6 ~> 4.5.7], `@semcore/animation` [1.5.4 ~> 1.5.5]).
|
|
10
|
+
|
|
11
|
+
## [4.0.7] - 2022-07-21
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Version patch update due to children dependencies update (`@semcore/icon` [2.28.0 ~> 2.29.0]).
|
|
16
|
+
|
|
17
|
+
## [4.0.6] - 2022-07-07
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Version patch update due to children dependencies update (`@semcore/utils` [3.33.0 ~> 3.34.0], `@semcore/icon` [2.27.0 ~> 2.28.0], `@semcore/flex-box` [4.5.5 ~> 4.5.6], `@semcore/animation` [1.5.3 ~> 1.5.4]).
|
|
22
|
+
|
|
5
23
|
## [4.0.5] - 2022-06-02
|
|
6
24
|
|
|
7
25
|
### Changed
|
package/README.md
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @semcore/notice-bubble
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/@semcore/notice-bubble)
|
|
4
|
+
[](https://www.npmjs.com/package/@semcore/notice-bubble)
|
|
5
|
+
[](https://github.com/semrush/intergalactic/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
> This component is part of the Intergalactic design system
|
|
8
|
+
|
|
9
|
+
### 📖 [Component documentation](https://developer.semrush.com/intergalactic/components/notice-bubble/)
|
|
10
|
+
|
|
11
|
+
### 🏠 [Design system](https://developer.semrush.com/intergalactic/)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @semcore/ui
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import NoticeBubbleManager, {
|
|
23
|
+
NoticeBubbleContainer,
|
|
24
|
+
NoticeBubble,
|
|
25
|
+
NoticeBubbleWarning,
|
|
26
|
+
} from '@semcore/ui/notice-bubble';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<details>
|
|
30
|
+
<summary>Alternative installation and use</summary>
|
|
31
|
+
|
|
32
|
+
**We do not recommend this usage path due to possible dependency and update issues.**
|
|
33
|
+
|
|
34
|
+
### Install
|
|
35
|
+
|
|
36
|
+
You can only install one package from the design system
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install @semcore/notice-bubble @semcore/core
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`@semcore/core` - _is the basic package by which we create our components, and it contains all of the common logic
|
|
43
|
+
of the components that is discussed below. There should only be one version of the package in the project._
|
|
44
|
+
|
|
45
|
+
### Usage
|
|
46
|
+
|
|
47
|
+
You can use the package the same way but without `/ui/` in the import path.
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
import NoticeBubbleManager, {
|
|
51
|
+
NoticeBubbleContainer,
|
|
52
|
+
NoticeBubble,
|
|
53
|
+
NoticeBubbleWarning,
|
|
54
|
+
} from '@semcore/notice-bubble';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
</details>
|
|
58
|
+
|
|
59
|
+
## 👤 Author
|
|
60
|
+
|
|
61
|
+
[UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
|
|
62
|
+
|
|
63
|
+
## 🤝 Contributing
|
|
64
|
+
|
|
65
|
+
Contributions, issues and feature requests are welcome!
|
|
66
|
+
|
|
67
|
+
Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
|
|
68
|
+
|
|
69
|
+
## Show your support
|
|
70
|
+
|
|
71
|
+
Give a ⭐️ if this project helped you!
|
|
72
|
+
|
|
73
|
+
## 📝 License
|
|
74
|
+
|
|
75
|
+
This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
|
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -67,30 +67,30 @@ var style = (
|
|
|
67
67
|
/*__reshadow_css_start__*/
|
|
68
68
|
_core.sstyled.insert(
|
|
69
69
|
/*__inner_css_start__*/
|
|
70
|
-
".
|
|
70
|
+
".___SInfo_nowff_gg_,.___SView_nowff_gg_,.___SWarning_nowff_gg_{position:relative;margin-bottom:12px;padding:12px 28px 12px 12px;width:100%;min-height:44px;border-radius:6px;overflow:hidden;box-sizing:border-box}.___SInfo_nowff_gg_{background:#191b23}.___SWarning_nowff_gg_{background:#ff4953}.___SMessage_nowff_gg_{font-size:14px;color:#fff;line-height:1.33}.___SDismiss_nowff_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:8px;color:#ffffff}.___SDismiss_nowff_gg_:hover{color:#e0e1e9}.___SAction_nowff_gg_{margin-top:8px}.___SNoticeBubble_nowff_gg_{width:300px;position:fixed;z-index:1010;right:12px;top:12px}@media (max-width:767px){.___SNoticeBubble_nowff_gg_{width:calc(100% - 24px)}}"
|
|
71
71
|
/*__inner_css_end__*/
|
|
72
|
-
, "
|
|
72
|
+
, "nowff_gg_")
|
|
73
73
|
/*__reshadow_css_end__*/
|
|
74
74
|
, {
|
|
75
|
-
"__SInfo": "
|
|
76
|
-
"__SView": "
|
|
77
|
-
"__SWarning": "
|
|
78
|
-
"__SMessage": "
|
|
79
|
-
"__SDismiss": "
|
|
80
|
-
"__SAction": "
|
|
81
|
-
"__SNoticeBubble": "
|
|
75
|
+
"__SInfo": "___SInfo_nowff_gg_",
|
|
76
|
+
"__SView": "___SView_nowff_gg_",
|
|
77
|
+
"__SWarning": "___SWarning_nowff_gg_",
|
|
78
|
+
"__SMessage": "___SMessage_nowff_gg_",
|
|
79
|
+
"__SDismiss": "___SDismiss_nowff_gg_",
|
|
80
|
+
"__SAction": "___SAction_nowff_gg_",
|
|
81
|
+
"__SNoticeBubble": "___SNoticeBubble_nowff_gg_"
|
|
82
82
|
});
|
|
83
83
|
var animationNotice = (
|
|
84
84
|
/*__reshadow_css_start__*/
|
|
85
85
|
_core.sstyled.insert(
|
|
86
86
|
/*__inner_css_start__*/
|
|
87
|
-
"@-webkit-keyframes
|
|
87
|
+
"@-webkit-keyframes enter_16lhx{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_16lhx{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_16lhx{0%{opacity:1}to{opacity:0}}@keyframes exit_16lhx{0%{opacity:1}to{opacity:0}}"
|
|
88
88
|
/*__inner_css_end__*/
|
|
89
|
-
, "
|
|
89
|
+
, "16lhx_gg_")
|
|
90
90
|
/*__reshadow_css_end__*/
|
|
91
91
|
, {
|
|
92
|
-
"@enter": "
|
|
93
|
-
"@exit": "
|
|
92
|
+
"@enter": "enter_16lhx",
|
|
93
|
+
"@exit": "exit_16lhx"
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
var Notices = function Notices(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/NoticeBubble.jsx"],"names":["animationNotice","sstyled","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","e","clearTimer","timer","pause","resume","duration","Timer","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,eAAe;AAAA;AAAGC,oBAAH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAArB;;AAoBA,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;AACzB,MAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;AAAA,oBAAqDD,KAArD,CAAgBE,IAAhB;AAAA,MAAgBA,IAAhB,4BAAuB,EAAvB;AAAA,mBAAqDF,KAArD,CAA2BG,GAA3B;AAAA,MAAgCC,KAAhC,2BAAwCC,QAAxC;AAEA,SAAOH,IAAI,CAACI,GAAL,CAAS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;;iCAAhCK,uB,kBACkB;AACpBvB,EAAAA,QAAQ,EAAE,IADU;AAEpBrB,EAAAA,IAAI,EAAE,SAFc;AAGpBG,EAAAA,OAAO,EAAPA;AAHoB,C;AAOxB,IAAM0C,qBAAqB,GAAG,sBAAgBnD,yBAAhB,EAA2C;AACvEoD,EAAAA,IAAI,EAAEP,gBADiE;AAEvEQ,EAAAA,OAAO,EAAEH;AAF8D,CAA3C,CAA9B;AAKA,IAAMI,YAAY,GAAGH,qBAAqB,CAACC,IAA3C;;AACA,IAAMG,mBAAmB,GAAGJ,qBAAqB,CAACE,OAAlD;;eAIeF,qB","sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"file":"NoticeBubble.js"}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["animationNotice","sstyled","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","manager","counter","addListener","handleChange","SNoticeBubble","Box","asProps","Children","disablePortal","state","ViewWarning","Component","style","e","fire","clearTimer","timer","pause","resume","duration","Timer","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","callAllEventHandlers","handlerMouseEnter","handlerMouseLeave","isNode","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","createComponent","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;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AAKnC,OAA9B,CAAf;IACD;;;WAED,gCAAuB;MACrB,IAAI,KAAKkC,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaE,MAAb;MACD;IACF;;;WAED,8BAAqB;MACnB,IAAI,KAAKF,OAAT,EAAkB;QAChB,KAAKA,OAAL,CAAaG,MAAb,CAAoB,KAAKrC,OAAzB;MACD;IACF;;;WAED,kBAAS;MACP,OAAO,IAAP;IACD;;;EA3B4BK,e;;iCAAzB4B,gB,kBACkB;EACpBpB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,MAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;;IA6BlB4C,uB;;;;;;;;;;;EAAgCL,gB;;iCAAhCK,uB,kBACkB;EACpBzB,QAAQ,EAAE,IADU;EAEpBtB,IAAI,EAAE,SAFc;EAGpBG,OAAO,EAAPA;AAHoB,C;AAOxB,IAAM6C,qBAAqB,GAAG,IAAAC,gBAAA,EAAgBvD,yBAAhB,EAA2C;EACvEwD,IAAI,EAAER,gBADiE;EAEvES,OAAO,EAAEJ;AAF8D,CAA3C,CAA9B;AAKA,IAAMK,YAAY,GAAGJ,qBAAqB,CAACE,IAA3C;;AACA,IAAMG,mBAAmB,GAAGL,qBAAqB,CAACG,OAAlD;;eAIeH,qB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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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AKR,IAAL;QACA,OAAO,IAAP;MACD;;MACD,OAAO,KAAP;IACD;;;;;;;eAIY,IAAId,mBAAJ,E"}
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["NoticeBubbleManager"],"sources":["../../src/index.js"],"sourcesContent":["import { default as NoticeBubbleContainer } from './NoticeBubble';\nexport * from './NoticeBubble';\n\nimport { default as NoticeBubbleManager } from './NoticeBubbleManager';\n\nexport * from './NoticeBubbleManager';\n\nexport default NoticeBubbleManager;\nexport { NoticeBubbleContainer };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAEA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;eAEeA,+B"}
|
package/lib/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["Timer","callback","delay","remaining","resume","clearTimeout","timerId","Date","now","start","setTimeout"],"sources":["../../src/utils.js"],"sourcesContent":["class Timer {\n constructor(callback, delay) {\n this.callback = callback;\n this.delay = delay;\n this.remaining = delay;\n this.resume();\n }\n\n pause() {\n clearTimeout(this.timerId);\n this.remaining -= Date.now() - this.start;\n }\n\n resume() {\n this.start = Date.now();\n clearTimeout(this.timerId);\n this.timerId = setTimeout(this.callback, this.remaining);\n }\n\n reset() {\n this.remaining = this.delay;\n this.resume();\n }\n\n clear() {\n clearTimeout(this.timerId);\n }\n}\n\nexport { Timer };\n"],"mappings":";;;;;;;;;;;;;IAAMA,K;EACJ,eAAYC,QAAZ,EAAsBC,KAAtB,EAA6B;IAAA;IAC3B,KAAKD,QAAL,GAAgBA,QAAhB;IACA,KAAKC,KAAL,GAAaA,KAAb;IACA,KAAKC,SAAL,GAAiBD,KAAjB;IACA,KAAKE,MAAL;EACD;;;;WAED,iBAAQ;MACNC,YAAY,CAAC,KAAKC,OAAN,CAAZ;MACA,KAAKH,SAAL,IAAkBI,IAAI,CAACC,GAAL,KAAa,KAAKC,KAApC;IACD;;;WAED,kBAAS;MACP,KAAKA,KAAL,GAAaF,IAAI,CAACC,GAAL,EAAb;MACAH,YAAY,CAAC,KAAKC,OAAN,CAAZ;MACA,KAAKA,OAAL,GAAeI,UAAU,CAAC,KAAKT,QAAN,EAAgB,KAAKE,SAArB,CAAzB;IACD;;;WAED,iBAAQ;MACN,KAAKA,SAAL,GAAiB,KAAKD,KAAtB;MACA,KAAKE,MAAL;IACD;;;WAED,iBAAQ;MACNC,YAAY,CAAC,KAAKC,OAAN,CAAZ;IACD"}
|
package/lib/es6/NoticeBubble.js
CHANGED
|
@@ -36,30 +36,30 @@ var style = (
|
|
|
36
36
|
/*__reshadow_css_start__*/
|
|
37
37
|
_sstyled.insert(
|
|
38
38
|
/*__inner_css_start__*/
|
|
39
|
-
".
|
|
39
|
+
".___SInfo_nowff_gg_,.___SView_nowff_gg_,.___SWarning_nowff_gg_{position:relative;margin-bottom:12px;padding:12px 28px 12px 12px;width:100%;min-height:44px;border-radius:6px;overflow:hidden;box-sizing:border-box}.___SInfo_nowff_gg_{background:#191b23}.___SWarning_nowff_gg_{background:#ff4953}.___SMessage_nowff_gg_{font-size:14px;color:#fff;line-height:1.33}.___SDismiss_nowff_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:8px;color:#ffffff}.___SDismiss_nowff_gg_:hover{color:#e0e1e9}.___SAction_nowff_gg_{margin-top:8px}.___SNoticeBubble_nowff_gg_{width:300px;position:fixed;z-index:1010;right:12px;top:12px}@media (max-width:767px){.___SNoticeBubble_nowff_gg_{width:calc(100% - 24px)}}"
|
|
40
40
|
/*__inner_css_end__*/
|
|
41
|
-
, "
|
|
41
|
+
, "nowff_gg_")
|
|
42
42
|
/*__reshadow_css_end__*/
|
|
43
43
|
, {
|
|
44
|
-
"__SInfo": "
|
|
45
|
-
"__SView": "
|
|
46
|
-
"__SWarning": "
|
|
47
|
-
"__SMessage": "
|
|
48
|
-
"__SDismiss": "
|
|
49
|
-
"__SAction": "
|
|
50
|
-
"__SNoticeBubble": "
|
|
44
|
+
"__SInfo": "___SInfo_nowff_gg_",
|
|
45
|
+
"__SView": "___SView_nowff_gg_",
|
|
46
|
+
"__SWarning": "___SWarning_nowff_gg_",
|
|
47
|
+
"__SMessage": "___SMessage_nowff_gg_",
|
|
48
|
+
"__SDismiss": "___SDismiss_nowff_gg_",
|
|
49
|
+
"__SAction": "___SAction_nowff_gg_",
|
|
50
|
+
"__SNoticeBubble": "___SNoticeBubble_nowff_gg_"
|
|
51
51
|
});
|
|
52
52
|
var animationNotice = (
|
|
53
53
|
/*__reshadow_css_start__*/
|
|
54
54
|
sstyled.insert(
|
|
55
55
|
/*__inner_css_start__*/
|
|
56
|
-
"@-webkit-keyframes
|
|
56
|
+
"@-webkit-keyframes enter_16lhx{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes enter_16lhx{0%{transform:translate(100%)}to{transform:translate(0)}}@-webkit-keyframes exit_16lhx{0%{opacity:1}to{opacity:0}}@keyframes exit_16lhx{0%{opacity:1}to{opacity:0}}"
|
|
57
57
|
/*__inner_css_end__*/
|
|
58
|
-
, "
|
|
58
|
+
, "16lhx_gg_")
|
|
59
59
|
/*__reshadow_css_end__*/
|
|
60
60
|
, {
|
|
61
|
-
"@enter": "
|
|
62
|
-
"@exit": "
|
|
61
|
+
"@enter": "enter_16lhx",
|
|
62
|
+
"@exit": "exit_16lhx"
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
var Notices = function Notices(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/NoticeBubble.jsx"],"names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","animationNotice","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","e","clearTimer","timer","pause","resume","duration","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","handlerMouseEnter","handlerMouseLeave","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,uBAApB;AACA,OAAOC,eAAP,IAA0BC,SAA1B,EAAqCC,OAArC,EAA8CC,IAA9C,QAA0D,eAA1D;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,GAAT,QAAoB,mBAApB;AACA,OAAOC,IAAP,MAAiB,yBAAjB;AACA,OAAOC,MAAP,MAAmB,2BAAnB;AACA,SAASC,oBAAT,QAAqC,gCAArC;AACA,OAAOC,SAAP,MAAsB,uBAAtB;AACA,SAASC,KAAT,QAAsB,SAAtB;;;;;;;;;;;;;;;;;;;;AAIA,IAAMC,eAAe;AAAA;AAAGT,OAAO,OAAV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAArB;;AAoBA,IAAMU,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;AACzB,MAAQC,MAAR,GAAqDD,KAArD,CAAQC,MAAR;AAAA,oBAAqDD,KAArD,CAAgBE,IAAhB;AAAA,MAAgBA,IAAhB,4BAAuB,EAAvB;AAAA,mBAAqDF,KAArD,CAA2BG,GAA3B;AAAA,MAAgCC,KAAhC,2BAAwCC,QAAxC;AAEA,SAAOH,IAAI,CAACI,GAAL,CAAS,UAACC,MAAD,EAAY;AAAA;;AAC1B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AE,MAFc;AAGpB/B,EAAAA,OAAO,EAAPA;AAHoB,C;;IA6BlBuE,uB;;;;;;;;;;;;EAAgCL,gB;;gBAAhCK,uB,kBACkB;AACpBtB,EAAAA,QAAQ,EAAE,IADU;AAEpBlB,EAAAA,IAAI,EAAE,SAFc;AAGpB/B,EAAAA,OAAO,EAAPA;AAHoB,C;;AAOxB,IAAMwE,qBAAqB,GAAGvE,eAAe,CAACwB,yBAAD,EAA4B;AACvEgD,EAAAA,IAAI,EAAEP,gBADiE;AAEvEQ,EAAAA,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","sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\n\nexport default NoticeBubbleContainer;\n"],"file":"NoticeBubble.js"}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["React","Portal","manager","createComponent","Component","sstyled","Root","Animation","Box","fire","isNode","callAllEventHandlers","CloseIcon","Timer","animationNotice","Notices","props","styles","data","tag","SView","ViewInfo","map","notice","uid","visible","undefined","NoticeBubbleContainerRoot","notices","warnings","_unsubscribe","info","filter","type","warning","setState","counter","addListener","handleChange","SNoticeBubble","asProps","Children","disablePortal","state","ViewWarning","style","e","clearTimer","timer","pause","resume","duration","handlerClose","clear","SInfo","SMessage","SAction","SDismiss","actionNode","action","forwardRef","onMouseEnter","onMouseLeave","children","other","handlerMouseEnter","handlerMouseLeave","SWarning","NoticeBubbleView","_notice","add","remove","update","NoticeBubbleWarningView","NoticeBubbleContainer","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"sources":["../../src/NoticeBubble.jsx"],"sourcesContent":["import React from 'react';\nimport Portal from '@semcore/portal';\nimport manager from './NoticeBubbleManager';\nimport createComponent, { Component, sstyled, Root } from '@semcore/core';\nimport { Animation } from '@semcore/animation';\nimport { Box } from '@semcore/flex-box';\nimport fire from '@semcore/utils/lib/fire';\nimport isNode from '@semcore/utils/lib/isNode';\nimport { callAllEventHandlers } from '@semcore/utils/lib/assignProps';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport { Timer } from './utils';\n\nimport style from './style/notice-bubble.shadow.css';\n\nconst animationNotice = sstyled.css`\n @keyframes enter {\n from {\n transform: translate(100%, 0);\n }\n to {\n transform: translate(0, 0);\n }\n }\n\n @keyframes exit {\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n }\n`;\n\nconst Notices = (props) => {\n const { styles, data = [], tag: SView = ViewInfo } = props;\n\n return data.map((notice) => {\n return sstyled(styles)(\n <Animation\n key={notice.uid}\n visible={notice.visible === undefined ? true : notice.visible}\n duration={250}\n keyframes={[animationNotice['@enter'], animationNotice['@exit']]}\n >\n <SView {...notice} styles={notice.styles || styles} />\n </Animation>,\n );\n });\n};\n\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * ```\n *\n * Container is a portal (React.Portal) in the body, inserted once into any part of the application\n * and subscribes to manager updates(NoticeBubbleManager)\n * */\n\nclass NoticeBubbleContainerRoot extends Component {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static defaultProps = {\n manager,\n };\n\n _unsubscribe = null;\n\n state = {\n notices: [],\n warnings: [],\n };\n\n constructor(props) {\n super(props);\n props.manager.counter = 0;\n this._unsubscribe = props.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices) => {\n const info = notices.filter((notice) => notice.type === 'info');\n const warning = notices.filter((notice) => notice.type === 'warning');\n\n this.setState({ notices: info, warnings: warning });\n };\n\n render() {\n const SNoticeBubble = Root;\n const { Children, styles, disablePortal } = this.asProps;\n const { notices, warnings } = this.state;\n\n return sstyled(styles)(\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble render={Box}>\n <Children />\n <Notices styles={styles} data={warnings} tag={ViewWarning} />\n <Notices styles={styles} data={notices} tag={ViewInfo} />\n </SNoticeBubble>\n </Portal>,\n );\n }\n}\n/**\n * ```js\n * import { NoticeBubble } from \"@semcore/notice-bubble\"\n * <NoticeBubble.Info/>\n * ```\n *\n * View component, the appearance of the notice\n * */\nclass ViewInfo extends Component {\n timer = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handlerClose, duration);\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handlerClose = (e) => {\n // because call not only click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handlerMouseEnter = () => {\n if (this.timer) {\n this.timer.pause();\n }\n };\n\n handlerMouseLeave = () => {\n if (this.timer) {\n this.timer.resume();\n }\n };\n\n render() {\n const SInfo = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const SDismiss = 'div';\n const {\n action: actionNode,\n forwardRef,\n styles,\n onMouseEnter,\n onMouseLeave,\n children,\n ...other\n } = this.props;\n\n return sstyled(styles)(\n <SInfo\n role=\"alert\"\n {...other}\n ref={forwardRef}\n onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}\n onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}\n >\n <SDismiss title=\"Close\" onClick={this.handlerClose} aria-label=\"Close alert\">\n <CloseIcon />\n </SDismiss>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SInfo>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n\n render() {\n const SWarning = Box;\n const SMessage = 'div';\n const SAction = 'div';\n const { action: actionNode, children, styles, forwardRef, ...other } = this.props;\n\n return sstyled(styles)(\n <SWarning ref={forwardRef} role=\"alert\" {...other}>\n <SMessage>{children}</SMessage>\n {isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}\n </SWarning>,\n );\n }\n}\n\nclass NoticeBubbleView extends Component {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n});\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\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E,OAAlD;AAEA,SAASC,YAAT,EAAuBC,mBAAvB;AAEA,eAAeJ,qBAAf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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,Q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,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"}
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","NoticeBubbleContainer","NoticeBubbleManager"],"sources":["../../src/index.js"],"sourcesContent":["import { default as NoticeBubbleContainer } from './NoticeBubble';\nexport * from './NoticeBubble';\n\nimport { default as NoticeBubbleManager } from './NoticeBubbleManager';\n\nexport * from './NoticeBubbleManager';\n\nexport default NoticeBubbleManager;\nexport { NoticeBubbleContainer };\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAApB,QAAiD,gBAAjD;AACA,cAAc,gBAAd;AAEA,SAASD,OAAO,IAAIE,mBAApB,QAA+C,uBAA/C;AAEA,cAAc,uBAAd;AAEA,eAAeA,mBAAf;AACA,SAASD,qBAAT"}
|
package/lib/es6/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["Timer","callback","delay","remaining","resume","clearTimeout","timerId","Date","now","start","setTimeout"],"sources":["../../src/utils.js"],"sourcesContent":["class Timer {\n constructor(callback, delay) {\n this.callback = callback;\n this.delay = delay;\n this.remaining = delay;\n this.resume();\n }\n\n pause() {\n clearTimeout(this.timerId);\n this.remaining -= Date.now() - this.start;\n }\n\n resume() {\n this.start = Date.now();\n clearTimeout(this.timerId);\n this.timerId = setTimeout(this.callback, this.remaining);\n }\n\n reset() {\n this.remaining = this.delay;\n this.resume();\n }\n\n clear() {\n clearTimeout(this.timerId);\n }\n}\n\nexport { Timer };\n"],"mappings":";;;IAAMA,K;EACJ,eAAYC,QAAZ,EAAsBC,KAAtB,EAA6B;IAAA;;IAC3B,KAAKD,QAAL,GAAgBA,QAAhB;IACA,KAAKC,KAAL,GAAaA,KAAb;IACA,KAAKC,SAAL,GAAiBD,KAAjB;IACA,KAAKE,MAAL;EACD;;;;WAED,iBAAQ;MACNC,YAAY,CAAC,KAAKC,OAAN,CAAZ;MACA,KAAKH,SAAL,IAAkBI,IAAI,CAACC,GAAL,KAAa,KAAKC,KAApC;IACD;;;WAED,kBAAS;MACP,KAAKA,KAAL,GAAaF,IAAI,CAACC,GAAL,EAAb;MACAH,YAAY,CAAC,KAAKC,OAAN,CAAZ;MACA,KAAKA,OAAL,GAAeI,UAAU,CAAC,KAAKT,QAAN,EAAgB,KAAKE,SAArB,CAAzB;IACD;;;WAED,iBAAQ;MACN,KAAKA,SAAL,GAAiB,KAAKD,KAAtB;MACA,KAAKE,MAAL;IACD;;;WAED,iBAAQ;MACNC,YAAY,CAAC,KAAKC,OAAN,CAAZ;IACD;;;;;;AAGH,SAASN,KAAT"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/notice-bubble",
|
|
3
3
|
"description": "SEMRush NoticeBubble Component",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.8",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
|
-
"author": "
|
|
8
|
+
"author": "UI-kit team <ui-kit-team@semrush.com>",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"scripts": {
|
package/src/NoticeBubble.jsx
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Portal from '@semcore/portal';
|
|
3
|
-
import manager from './NoticeBubbleManager';
|
|
4
|
-
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
5
|
-
import { Animation } from '@semcore/animation';
|
|
6
|
-
import { Box } from '@semcore/flex-box';
|
|
7
|
-
import fire from '@semcore/utils/lib/fire';
|
|
8
|
-
import isNode from '@semcore/utils/lib/isNode';
|
|
9
|
-
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
10
|
-
import CloseIcon from '@semcore/icon/Close/m';
|
|
11
|
-
import { Timer } from './utils';
|
|
12
|
-
|
|
13
|
-
import style from './style/notice-bubble.shadow.css';
|
|
14
|
-
|
|
15
|
-
const animationNotice = sstyled.css`
|
|
16
|
-
@keyframes enter {
|
|
17
|
-
from {
|
|
18
|
-
transform: translate(100%, 0);
|
|
19
|
-
}
|
|
20
|
-
to {
|
|
21
|
-
transform: translate(0, 0);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@keyframes exit {
|
|
26
|
-
from {
|
|
27
|
-
opacity: 1;
|
|
28
|
-
}
|
|
29
|
-
to {
|
|
30
|
-
opacity: 0;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const Notices = (props) => {
|
|
36
|
-
const { styles, data = [], tag: SView = ViewInfo } = props;
|
|
37
|
-
|
|
38
|
-
return data.map((notice) => {
|
|
39
|
-
return sstyled(styles)(
|
|
40
|
-
<Animation
|
|
41
|
-
key={notice.uid}
|
|
42
|
-
visible={notice.visible === undefined ? true : notice.visible}
|
|
43
|
-
duration={250}
|
|
44
|
-
keyframes={[animationNotice['@enter'], animationNotice['@exit']]}
|
|
45
|
-
>
|
|
46
|
-
<SView {...notice} styles={notice.styles || styles} />
|
|
47
|
-
</Animation>,
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* ```js
|
|
54
|
-
* import { NoticeBubble } from "@semcore/notice-bubble"
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* Container is a portal (React.Portal) in the body, inserted once into any part of the application
|
|
58
|
-
* and subscribes to manager updates(NoticeBubbleManager)
|
|
59
|
-
* */
|
|
60
|
-
|
|
61
|
-
class NoticeBubbleContainerRoot extends Component {
|
|
62
|
-
static displayName = 'NoticeBubbleContainer';
|
|
63
|
-
static style = style;
|
|
64
|
-
static defaultProps = {
|
|
65
|
-
manager,
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
_unsubscribe = null;
|
|
69
|
-
|
|
70
|
-
state = {
|
|
71
|
-
notices: [],
|
|
72
|
-
warnings: [],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
constructor(props) {
|
|
76
|
-
super(props);
|
|
77
|
-
props.manager.counter = 0;
|
|
78
|
-
this._unsubscribe = props.manager.addListener(this.handleChange);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
componentWillUnmount = () => {
|
|
82
|
-
if (this._unsubscribe) {
|
|
83
|
-
this._unsubscribe();
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
handleChange = (notices) => {
|
|
88
|
-
const info = notices.filter((notice) => notice.type === 'info');
|
|
89
|
-
const warning = notices.filter((notice) => notice.type === 'warning');
|
|
90
|
-
|
|
91
|
-
this.setState({ notices: info, warnings: warning });
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
render() {
|
|
95
|
-
const SNoticeBubble = Root;
|
|
96
|
-
const { Children, styles, disablePortal } = this.asProps;
|
|
97
|
-
const { notices, warnings } = this.state;
|
|
98
|
-
|
|
99
|
-
return sstyled(styles)(
|
|
100
|
-
<Portal disablePortal={disablePortal}>
|
|
101
|
-
<SNoticeBubble render={Box}>
|
|
102
|
-
<Children />
|
|
103
|
-
<Notices styles={styles} data={warnings} tag={ViewWarning} />
|
|
104
|
-
<Notices styles={styles} data={notices} tag={ViewInfo} />
|
|
105
|
-
</SNoticeBubble>
|
|
106
|
-
</Portal>,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* ```js
|
|
112
|
-
* import { NoticeBubble } from "@semcore/notice-bubble"
|
|
113
|
-
* <NoticeBubble.Info/>
|
|
114
|
-
* ```
|
|
115
|
-
*
|
|
116
|
-
* View component, the appearance of the notice
|
|
117
|
-
* */
|
|
118
|
-
class ViewInfo extends Component {
|
|
119
|
-
timer = null;
|
|
120
|
-
|
|
121
|
-
componentDidMount() {
|
|
122
|
-
const { duration } = this.props;
|
|
123
|
-
if (duration) {
|
|
124
|
-
this.timer = new Timer(this.handlerClose, duration);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
componentWillUnmount() {
|
|
129
|
-
this.clearTimer();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
clearTimer() {
|
|
133
|
-
if (this.timer) {
|
|
134
|
-
this.timer.clear();
|
|
135
|
-
this.timer = null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
handlerClose = (e) => {
|
|
140
|
-
// because call not only click
|
|
141
|
-
fire(this, 'onClose', e);
|
|
142
|
-
this.clearTimer();
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
handlerMouseEnter = () => {
|
|
146
|
-
if (this.timer) {
|
|
147
|
-
this.timer.pause();
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
handlerMouseLeave = () => {
|
|
152
|
-
if (this.timer) {
|
|
153
|
-
this.timer.resume();
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
render() {
|
|
158
|
-
const SInfo = Box;
|
|
159
|
-
const SMessage = 'div';
|
|
160
|
-
const SAction = 'div';
|
|
161
|
-
const SDismiss = 'div';
|
|
162
|
-
const {
|
|
163
|
-
action: actionNode,
|
|
164
|
-
forwardRef,
|
|
165
|
-
styles,
|
|
166
|
-
onMouseEnter,
|
|
167
|
-
onMouseLeave,
|
|
168
|
-
children,
|
|
169
|
-
...other
|
|
170
|
-
} = this.props;
|
|
171
|
-
|
|
172
|
-
return sstyled(styles)(
|
|
173
|
-
<SInfo
|
|
174
|
-
role="alert"
|
|
175
|
-
{...other}
|
|
176
|
-
ref={forwardRef}
|
|
177
|
-
onMouseEnter={callAllEventHandlers(onMouseEnter, this.handlerMouseEnter)}
|
|
178
|
-
onMouseLeave={callAllEventHandlers(onMouseLeave, this.handlerMouseLeave)}
|
|
179
|
-
>
|
|
180
|
-
<SDismiss title="Close" onClick={this.handlerClose} aria-label="Close alert">
|
|
181
|
-
<CloseIcon />
|
|
182
|
-
</SDismiss>
|
|
183
|
-
<SMessage>{children}</SMessage>
|
|
184
|
-
{isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}
|
|
185
|
-
</SInfo>,
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
class ViewWarning extends ViewInfo {
|
|
191
|
-
static defaultProps = {
|
|
192
|
-
type: 'warning',
|
|
193
|
-
duration: 0,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
render() {
|
|
197
|
-
const SWarning = Box;
|
|
198
|
-
const SMessage = 'div';
|
|
199
|
-
const SAction = 'div';
|
|
200
|
-
const { action: actionNode, children, styles, forwardRef, ...other } = this.props;
|
|
201
|
-
|
|
202
|
-
return sstyled(styles)(
|
|
203
|
-
<SWarning ref={forwardRef} role="alert" {...other}>
|
|
204
|
-
<SMessage>{children}</SMessage>
|
|
205
|
-
{isNode(actionNode) ? <SAction>{actionNode}</SAction> : null}
|
|
206
|
-
</SWarning>,
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
class NoticeBubbleView extends Component {
|
|
212
|
-
static defaultProps = {
|
|
213
|
-
duration: 5000,
|
|
214
|
-
type: 'info',
|
|
215
|
-
manager,
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
_notice = null;
|
|
219
|
-
|
|
220
|
-
componentDidMount() {
|
|
221
|
-
this._notice = this.asProps.manager.add(this.asProps);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
componentWillUnmount() {
|
|
225
|
-
if (this._notice) {
|
|
226
|
-
this._notice.remove();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
componentDidUpdate() {
|
|
231
|
-
if (this._notice) {
|
|
232
|
-
this._notice.update(this.asProps);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
render() {
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
class NoticeBubbleWarningView extends NoticeBubbleView {
|
|
242
|
-
static defaultProps = {
|
|
243
|
-
duration: 5000,
|
|
244
|
-
type: 'warning',
|
|
245
|
-
manager,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
const NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
|
|
250
|
-
Info: NoticeBubbleView,
|
|
251
|
-
Warning: NoticeBubbleWarningView,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const NoticeBubble = NoticeBubbleContainer.Info;
|
|
255
|
-
const NoticeBubbleWarning = NoticeBubbleContainer.Warning;
|
|
256
|
-
|
|
257
|
-
export { NoticeBubble, NoticeBubbleWarning };
|
|
258
|
-
|
|
259
|
-
export default NoticeBubbleContainer;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import EventEmitter from '@semcore/utils/lib/eventEmitter';
|
|
2
|
-
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
3
|
-
|
|
4
|
-
const EVENT_NAME = 'CHANGE';
|
|
5
|
-
|
|
6
|
-
class NoticeBubbleManager {
|
|
7
|
-
items = [];
|
|
8
|
-
emitter = null;
|
|
9
|
-
counter = 0;
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
this.emitter = new EventEmitter();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
addListener(fn) {
|
|
16
|
-
return this.emitter.subscribe(EVENT_NAME, fn);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
createItem(props) {
|
|
20
|
-
const manager = this;
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
type: 'info',
|
|
24
|
-
...props,
|
|
25
|
-
onClose: callAllEventHandlers(props.onClose, () => {
|
|
26
|
-
if (props.visible === undefined) {
|
|
27
|
-
manager.remove(props.uid);
|
|
28
|
-
}
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
emit() {
|
|
34
|
-
this.emitter.emit(EVENT_NAME, this.items);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
add(props) {
|
|
38
|
-
const uid = this.counter++;
|
|
39
|
-
const item = this.createItem({ uid, ...props });
|
|
40
|
-
this.items.push(item);
|
|
41
|
-
this.emit();
|
|
42
|
-
return {
|
|
43
|
-
uid,
|
|
44
|
-
update: this.update.bind(this, uid),
|
|
45
|
-
remove: this.remove.bind(this, uid),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
update(uid, props) {
|
|
50
|
-
const index = this.items.findIndex((item) => item.uid === uid);
|
|
51
|
-
if (index !== -1) {
|
|
52
|
-
this.items[index] = this.createItem({
|
|
53
|
-
...this.items[index],
|
|
54
|
-
...props,
|
|
55
|
-
});
|
|
56
|
-
this.emit();
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
remove(uid) {
|
|
63
|
-
const index = this.items.findIndex((item) => item.uid === uid);
|
|
64
|
-
if (index !== -1) {
|
|
65
|
-
this.items.splice(index, 1);
|
|
66
|
-
this.emit();
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { NoticeBubbleManager };
|
|
74
|
-
export default new NoticeBubbleManager();
|
package/src/index.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { IPortalProps } from '@semcore/portal';
|
|
2
|
-
import { CProps, ReturnEl } from '@semcore/core';
|
|
3
|
-
import { IBoxProps } from '@semcore/flex-box';
|
|
4
|
-
|
|
5
|
-
export interface INoticeBubbleContainerProps extends IBoxProps, IPortalProps {
|
|
6
|
-
/** Manager copy */
|
|
7
|
-
manager?: INoticeBubbleManager;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface INoticeBubbleInfoProps extends INoticeBubbleProps {
|
|
11
|
-
readonly type?: 'info';
|
|
12
|
-
/** Notice display duration
|
|
13
|
-
* @default 5000
|
|
14
|
-
*/
|
|
15
|
-
duration?: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface INoticeBubbleWarningProps extends INoticeBubbleProps {
|
|
19
|
-
readonly type?: 'warning';
|
|
20
|
-
/**
|
|
21
|
-
* Notice display duration
|
|
22
|
-
* @default 0
|
|
23
|
-
*/
|
|
24
|
-
duration?: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface INoticeBubbleProps extends IBoxProps {
|
|
28
|
-
/**
|
|
29
|
-
* Manager instance
|
|
30
|
-
* @default NoticeBubbleManager()
|
|
31
|
-
*/
|
|
32
|
-
manager?: INoticeBubbleManager;
|
|
33
|
-
/**
|
|
34
|
-
* Notice visibility
|
|
35
|
-
*/
|
|
36
|
-
visible?: boolean;
|
|
37
|
-
/** Adds controls (buttons, etc.) */
|
|
38
|
-
action?: React.ReactNode;
|
|
39
|
-
|
|
40
|
-
/** Triggered when the notice is closed */
|
|
41
|
-
onClose?: (e?: React.SyntheticEvent) => void;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface INoticeBubbleManager {
|
|
45
|
-
/**
|
|
46
|
-
* Adding a notice.
|
|
47
|
-
* Takes the props properties of NoticeBubble.
|
|
48
|
-
* Returns an object with the uid and the update, remove functions.
|
|
49
|
-
* */
|
|
50
|
-
add: (
|
|
51
|
-
props: object,
|
|
52
|
-
) => {
|
|
53
|
-
uid: string;
|
|
54
|
-
update: (props: object) => boolean;
|
|
55
|
-
remove: () => boolean;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Updates the notice by uid.
|
|
59
|
-
* Takes the uid-unique identifier and the props-properties of NoticeBubble.
|
|
60
|
-
* Returns a successful or unsuccessful update.
|
|
61
|
-
* */
|
|
62
|
-
update: (uid: string, props: object) => boolean;
|
|
63
|
-
/**
|
|
64
|
-
* Deletes the notice by uid.
|
|
65
|
-
* Takes an uid-unique identifier.
|
|
66
|
-
* Returns a successful or unsuccessful deletion.
|
|
67
|
-
* */
|
|
68
|
-
remove: (uid: string) => boolean;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
declare const NoticeBubble: <T>(props: INoticeBubbleInfoProps & T) => ReturnEl;
|
|
72
|
-
declare const NoticeBubbleWarning: <T>(props: INoticeBubbleWarningProps & T) => ReturnEl;
|
|
73
|
-
declare const NoticeBubbleContainer: (<T>(
|
|
74
|
-
props: CProps<INoticeBubbleContainerProps & T>,
|
|
75
|
-
) => ReturnEl) & {
|
|
76
|
-
Info: typeof NoticeBubble;
|
|
77
|
-
Warning: typeof NoticeBubbleWarning;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
declare const manager: INoticeBubbleManager;
|
|
81
|
-
|
|
82
|
-
export { NoticeBubbleContainer, NoticeBubble, NoticeBubbleWarning };
|
|
83
|
-
export default manager;
|
package/src/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as NoticeBubbleContainer } from './NoticeBubble';
|
|
2
|
-
export * from './NoticeBubble';
|
|
3
|
-
|
|
4
|
-
import { default as NoticeBubbleManager } from './NoticeBubbleManager';
|
|
5
|
-
|
|
6
|
-
export * from './NoticeBubbleManager';
|
|
7
|
-
|
|
8
|
-
export default NoticeBubbleManager;
|
|
9
|
-
export { NoticeBubbleContainer };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
@import '@semcore/utils/style/var.css';
|
|
2
|
-
|
|
3
|
-
SInfo,
|
|
4
|
-
SWarning,
|
|
5
|
-
SView {
|
|
6
|
-
position: relative;
|
|
7
|
-
margin-bottom: 12px;
|
|
8
|
-
padding: 12px 28px 12px 12px;
|
|
9
|
-
width: 100%;
|
|
10
|
-
min-height: 44px;
|
|
11
|
-
border-radius: var(--rounded-m);
|
|
12
|
-
overflow: hidden;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
SInfo {
|
|
17
|
-
background: var(--gray-800);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
SWarning {
|
|
21
|
-
background: var(--red-400);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
SMessage {
|
|
25
|
-
font-size: var(--fs-200);
|
|
26
|
-
color: #fff;
|
|
27
|
-
line-height: var(--lh-100);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
SDismiss {
|
|
31
|
-
cursor: pointer;
|
|
32
|
-
position: absolute;
|
|
33
|
-
right: 0;
|
|
34
|
-
top: 0;
|
|
35
|
-
padding: 8px;
|
|
36
|
-
color: var(--white);
|
|
37
|
-
|
|
38
|
-
&:hover {
|
|
39
|
-
color: var(--gray-100);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
SAction {
|
|
44
|
-
margin-top: 8px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
SNoticeBubble {
|
|
48
|
-
width: 300px;
|
|
49
|
-
position: fixed;
|
|
50
|
-
z-index: 1010;
|
|
51
|
-
right: 12px;
|
|
52
|
-
top: 12px;
|
|
53
|
-
|
|
54
|
-
@media (max-width: 767px) {
|
|
55
|
-
width: calc(100% - 24px);
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
class Timer {
|
|
2
|
-
constructor(callback, delay) {
|
|
3
|
-
this.callback = callback;
|
|
4
|
-
this.delay = delay;
|
|
5
|
-
this.remaining = delay;
|
|
6
|
-
this.resume();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
pause() {
|
|
10
|
-
clearTimeout(this.timerId);
|
|
11
|
-
this.remaining -= Date.now() - this.start;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
resume() {
|
|
15
|
-
this.start = Date.now();
|
|
16
|
-
clearTimeout(this.timerId);
|
|
17
|
-
this.timerId = setTimeout(this.callback, this.remaining);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
reset() {
|
|
21
|
-
this.remaining = this.delay;
|
|
22
|
-
this.resume();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
clear() {
|
|
26
|
-
clearTimeout(this.timerId);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Timer };
|