@semcore/notice-bubble 4.6.1 → 4.6.3
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 +8 -0
- package/lib/cjs/NoticeBubble.js +24 -36
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubbleManager.js +5 -7
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.js +1 -6
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/NoticeBubble.js +13 -22
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubbleManager.js +1 -5
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [4.6.3] - 2023-02-24
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Version patch update due to children dependencies update (`@semcore/icon` [3.12.0 ~> 3.13.0]).
|
|
10
|
+
|
|
11
|
+
## [4.6.2] - 2023-02-22
|
|
12
|
+
|
|
5
13
|
## [4.6.1] - 2023-02-21
|
|
6
14
|
|
|
7
15
|
### Changed
|
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
@@ -19,12 +19,12 @@ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
19
19
|
|
|
20
20
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
22
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
25
23
|
|
|
26
24
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
25
|
|
|
26
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
27
|
+
|
|
28
28
|
var _core = _interopRequireWildcard(require("@semcore/core"));
|
|
29
29
|
|
|
30
30
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -56,37 +56,25 @@ var _useCssVariable = require("@semcore/utils/lib/useCssVariable");
|
|
|
56
56
|
var _excluded = ["action", "forwardRef", "styles", "onMouseEnter", "onMouseLeave", "children", "getI18nText"],
|
|
57
57
|
_excluded2 = ["action", "children", "styles", "forwardRef"];
|
|
58
58
|
|
|
59
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
60
|
-
|
|
61
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
|
-
|
|
63
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
64
|
-
|
|
65
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
66
|
-
|
|
67
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
68
|
-
|
|
69
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
70
|
-
|
|
71
59
|
/*__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
72
60
|
var style = (
|
|
73
61
|
/*__reshadow_css_start__*/
|
|
74
62
|
_core.sstyled.insert(
|
|
75
63
|
/*__inner_css_start__*/
|
|
76
|
-
"@keyframes
|
|
64
|
+
"@keyframes enter_wfsei{0%{transform:translate(100%,0)}to{transform:translate(0,0)}}@keyframes exit_wfsei{0%{opacity:1}to{opacity:0}}.___SInfo_wfsei_gg_,.___SView_wfsei_gg_,.___SWarning_wfsei_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_wfsei_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SWarning_wfsei_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SDismiss_wfsei_gg_,.___SMessage_wfsei_gg_{color:var(--intergalactic-text-primary-invert, #ffffff)}.___SMessage_wfsei_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_wfsei_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px)}@media (hover:hover){.___SDismiss_wfsei_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SAction_wfsei_gg_{margin-top:var(--intergalactic-spacing-2x, 8px)}.___SNoticeBubble_wfsei_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_wfsei_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}"
|
|
77
65
|
/*__inner_css_end__*/
|
|
78
|
-
, "
|
|
66
|
+
, "wfsei_gg_")
|
|
79
67
|
/*__reshadow_css_end__*/
|
|
80
68
|
, {
|
|
81
|
-
"__SInfo": "
|
|
82
|
-
"__SWarning": "
|
|
83
|
-
"__SView": "
|
|
84
|
-
"__SMessage": "
|
|
85
|
-
"__SDismiss": "
|
|
86
|
-
"__SAction": "
|
|
87
|
-
"__SNoticeBubble": "
|
|
88
|
-
"@enter": "
|
|
89
|
-
"@exit": "
|
|
69
|
+
"__SInfo": "___SInfo_wfsei_gg_",
|
|
70
|
+
"__SWarning": "___SWarning_wfsei_gg_",
|
|
71
|
+
"__SView": "___SView_wfsei_gg_",
|
|
72
|
+
"__SMessage": "___SMessage_wfsei_gg_",
|
|
73
|
+
"__SDismiss": "___SDismiss_wfsei_gg_",
|
|
74
|
+
"__SAction": "___SAction_wfsei_gg_",
|
|
75
|
+
"__SNoticeBubble": "___SNoticeBubble_wfsei_gg_",
|
|
76
|
+
"@enter": "enter_wfsei",
|
|
77
|
+
"@exit": "exit_wfsei"
|
|
90
78
|
});
|
|
91
79
|
|
|
92
80
|
var Notices = function Notices(props) {
|
|
@@ -114,7 +102,7 @@ var Notices = function Notices(props) {
|
|
|
114
102
|
"duration": duration,
|
|
115
103
|
"keyframes": [styles['@enter'], styles['@exit']],
|
|
116
104
|
"ref": ref
|
|
117
|
-
}), /*#__PURE__*/_react["default"].createElement(SView, _ref2.cn("SView",
|
|
105
|
+
}), /*#__PURE__*/_react["default"].createElement(SView, _ref2.cn("SView", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, notice), {}, {
|
|
118
106
|
"styles": notice.styles || styles,
|
|
119
107
|
"getI18nText": props.getI18nText
|
|
120
108
|
}))));
|
|
@@ -133,7 +121,7 @@ var Notices = function Notices(props) {
|
|
|
133
121
|
var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
134
122
|
(0, _inherits2["default"])(NoticeBubbleContainerRoot, _Component);
|
|
135
123
|
|
|
136
|
-
var _super =
|
|
124
|
+
var _super = (0, _createSuper2["default"])(NoticeBubbleContainerRoot);
|
|
137
125
|
|
|
138
126
|
function NoticeBubbleContainerRoot(props) {
|
|
139
127
|
var _this;
|
|
@@ -185,7 +173,7 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
185
173
|
warnings = _this$state.warnings;
|
|
186
174
|
return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_portal["default"], _ref3.cn("Portal", {
|
|
187
175
|
"disablePortal": disablePortal
|
|
188
|
-
}), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble",
|
|
176
|
+
}), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
189
177
|
"role": "alert",
|
|
190
178
|
"aria-live": "assertive"
|
|
191
179
|
}, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {})), /*#__PURE__*/_react["default"].createElement(Notices, _ref3.cn("Notices", {
|
|
@@ -225,7 +213,7 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
225
213
|
var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
226
214
|
(0, _inherits2["default"])(ViewInfo, _Component2);
|
|
227
215
|
|
|
228
|
-
var _super2 =
|
|
216
|
+
var _super2 = (0, _createSuper2["default"])(ViewInfo);
|
|
229
217
|
|
|
230
218
|
function ViewInfo() {
|
|
231
219
|
var _this2;
|
|
@@ -297,7 +285,7 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
|
297
285
|
children = _this$props.children,
|
|
298
286
|
getI18nText = _this$props.getI18nText,
|
|
299
287
|
other = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
|
|
300
|
-
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInfo, _ref4.cn("SInfo",
|
|
288
|
+
return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SInfo, _ref4.cn("SInfo", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
301
289
|
"role": "alert"
|
|
302
290
|
}, other), {}, {
|
|
303
291
|
"ref": forwardRef,
|
|
@@ -316,7 +304,7 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
|
316
304
|
var ViewWarning = /*#__PURE__*/function (_ViewInfo) {
|
|
317
305
|
(0, _inherits2["default"])(ViewWarning, _ViewInfo);
|
|
318
306
|
|
|
319
|
-
var _super3 =
|
|
307
|
+
var _super3 = (0, _createSuper2["default"])(ViewWarning);
|
|
320
308
|
|
|
321
309
|
function ViewWarning() {
|
|
322
310
|
(0, _classCallCheck2["default"])(this, ViewWarning);
|
|
@@ -337,7 +325,7 @@ var ViewWarning = /*#__PURE__*/function (_ViewInfo) {
|
|
|
337
325
|
styles = _this$props2.styles,
|
|
338
326
|
forwardRef = _this$props2.forwardRef,
|
|
339
327
|
other = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded2);
|
|
340
|
-
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SWarning, _ref5.cn("SWarning",
|
|
328
|
+
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SWarning, _ref5.cn("SWarning", (0, _objectSpread2["default"])({
|
|
341
329
|
"ref": forwardRef,
|
|
342
330
|
"role": "alert"
|
|
343
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);
|
|
@@ -354,7 +342,7 @@ var ViewWarning = /*#__PURE__*/function (_ViewInfo) {
|
|
|
354
342
|
var NoticeBubbleView = /*#__PURE__*/function (_Component3) {
|
|
355
343
|
(0, _inherits2["default"])(NoticeBubbleView, _Component3);
|
|
356
344
|
|
|
357
|
-
var _super4 =
|
|
345
|
+
var _super4 = (0, _createSuper2["default"])(NoticeBubbleView);
|
|
358
346
|
|
|
359
347
|
function NoticeBubbleView() {
|
|
360
348
|
var _this3;
|
|
@@ -407,7 +395,7 @@ var NoticeBubbleView = /*#__PURE__*/function (_Component3) {
|
|
|
407
395
|
var NoticeBubbleWarningView = /*#__PURE__*/function (_NoticeBubbleView) {
|
|
408
396
|
(0, _inherits2["default"])(NoticeBubbleWarningView, _NoticeBubbleView);
|
|
409
397
|
|
|
410
|
-
var _super5 =
|
|
398
|
+
var _super5 = (0, _createSuper2["default"])(NoticeBubbleWarningView);
|
|
411
399
|
|
|
412
400
|
function NoticeBubbleWarningView() {
|
|
413
401
|
(0, _classCallCheck2["default"])(this, NoticeBubbleWarningView);
|
|
@@ -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,QAAQ,GAAGJ,iBAAA,CAAMK,OAAN,CAAc;IAAA,OAAMC,QAAQ,CAACJ,WAAD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;;;;;;;;;;;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","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":";;;;;;;;;;;;;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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"}
|
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.NoticeBubbleManager = void 0;
|
|
9
9
|
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -17,10 +19,6 @@ var _eventEmitter = _interopRequireDefault(require("@semcore/utils/lib/eventEmit
|
|
|
17
19
|
|
|
18
20
|
var _assignProps = require("@semcore/utils/lib/assignProps");
|
|
19
21
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
24
22
|
var EVENT_NAME = 'CHANGE';
|
|
25
23
|
|
|
26
24
|
var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
@@ -41,7 +39,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
41
39
|
key: "createItem",
|
|
42
40
|
value: function createItem(props) {
|
|
43
41
|
var manager = this;
|
|
44
|
-
return
|
|
42
|
+
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
45
43
|
type: 'info'
|
|
46
44
|
}, props), {}, {
|
|
47
45
|
onClose: (0, _assignProps.callAllEventHandlers)(props.onClose, function () {
|
|
@@ -60,7 +58,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
60
58
|
key: "add",
|
|
61
59
|
value: function add(props) {
|
|
62
60
|
var uid = this.counter++;
|
|
63
|
-
var item = this.createItem(
|
|
61
|
+
var item = this.createItem((0, _objectSpread2["default"])({
|
|
64
62
|
uid: uid
|
|
65
63
|
}, props));
|
|
66
64
|
this.items.push(item);
|
|
@@ -79,7 +77,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
79
77
|
});
|
|
80
78
|
|
|
81
79
|
if (index !== -1) {
|
|
82
|
-
this.items[index] = this.createItem(
|
|
80
|
+
this.items[index] = this.createItem((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, this.items[index]), props));
|
|
83
81
|
this.emit();
|
|
84
82
|
return true;
|
|
85
83
|
}
|
|
@@ -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":"
|
|
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,KA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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -43,11 +43,6 @@ Object.keys(_NoticeBubbleManager).forEach(function (key) {
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
48
|
-
|
|
49
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
50
|
-
|
|
51
46
|
var _default = _NoticeBubbleManager["default"];
|
|
52
47
|
exports["default"] = _default;
|
|
53
48
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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/es6/NoticeBubble.js
CHANGED
|
@@ -3,22 +3,13 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
11
|
var _excluded = ["action", "forwardRef", "styles", "onMouseEnter", "onMouseLeave", "children", "getI18nText"],
|
|
12
12
|
_excluded2 = ["action", "children", "styles", "forwardRef"];
|
|
13
|
-
|
|
14
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
-
|
|
16
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
|
|
22
13
|
import React from 'react';
|
|
23
14
|
import Portal from '@semcore/portal';
|
|
24
15
|
import manager from './NoticeBubbleManager';
|
|
@@ -39,20 +30,20 @@ var style = (
|
|
|
39
30
|
/*__reshadow_css_start__*/
|
|
40
31
|
_sstyled.insert(
|
|
41
32
|
/*__inner_css_start__*/
|
|
42
|
-
"@keyframes
|
|
33
|
+
"@keyframes enter_wfsei{0%{transform:translate(100%,0)}to{transform:translate(0,0)}}@keyframes exit_wfsei{0%{opacity:1}to{opacity:0}}.___SInfo_wfsei_gg_,.___SView_wfsei_gg_,.___SWarning_wfsei_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_wfsei_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SWarning_wfsei_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SDismiss_wfsei_gg_,.___SMessage_wfsei_gg_{color:var(--intergalactic-text-primary-invert, #ffffff)}.___SMessage_wfsei_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-100, 133%)}.___SDismiss_wfsei_gg_{cursor:pointer;position:absolute;right:0;top:0;padding:var(--intergalactic-spacing-2x, 8px)}@media (hover:hover){.___SDismiss_wfsei_gg_:hover{color:var(--intergalactic-control-primary-invert-active, #e0e1e9)}}.___SAction_wfsei_gg_{margin-top:var(--intergalactic-spacing-2x, 8px)}.___SNoticeBubble_wfsei_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_wfsei_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}"
|
|
43
34
|
/*__inner_css_end__*/
|
|
44
|
-
, "
|
|
35
|
+
, "wfsei_gg_")
|
|
45
36
|
/*__reshadow_css_end__*/
|
|
46
37
|
, {
|
|
47
|
-
"__SInfo": "
|
|
48
|
-
"__SWarning": "
|
|
49
|
-
"__SView": "
|
|
50
|
-
"__SMessage": "
|
|
51
|
-
"__SDismiss": "
|
|
52
|
-
"__SAction": "
|
|
53
|
-
"__SNoticeBubble": "
|
|
54
|
-
"@enter": "
|
|
55
|
-
"@exit": "
|
|
38
|
+
"__SInfo": "___SInfo_wfsei_gg_",
|
|
39
|
+
"__SWarning": "___SWarning_wfsei_gg_",
|
|
40
|
+
"__SView": "___SView_wfsei_gg_",
|
|
41
|
+
"__SMessage": "___SMessage_wfsei_gg_",
|
|
42
|
+
"__SDismiss": "___SDismiss_wfsei_gg_",
|
|
43
|
+
"__SAction": "___SAction_wfsei_gg_",
|
|
44
|
+
"__SNoticeBubble": "___SNoticeBubble_wfsei_gg_",
|
|
45
|
+
"@enter": "enter_wfsei",
|
|
46
|
+
"@exit": "exit_wfsei"
|
|
56
47
|
});
|
|
57
48
|
|
|
58
49
|
var Notices = function Notices(props) {
|
|
@@ -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,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,oB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K,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","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,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;AACA,SAASC,iBAAT,QAAkC,gDAAlC;AACA,OAAOC,WAAP,MAAwB,yCAAxB;AACA,SAASC,cAAT,QAA+B,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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,11 +1,7 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
|
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
5
|
import EventEmitter from '@semcore/utils/lib/eventEmitter';
|
|
10
6
|
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
11
7
|
var EVENT_NAME = 'CHANGE';
|
|
@@ -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":"
|
|
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,EAA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