@semcore/notice-bubble 5.54.0 → 5.54.1-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/NoticeBubble.js +18 -16
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.js +18 -16
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +304 -232
- package/lib/esm/NoticeBubbleManager.mjs +89 -58
- package/lib/esm/index.mjs +9 -9
- package/lib/esm/style/notice-bubble.shadow.css +107 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +30 -30
- package/lib/esm/translations/de.json.mjs +8 -6
- package/lib/esm/translations/en.json.mjs +8 -6
- package/lib/esm/translations/es.json.mjs +8 -6
- package/lib/esm/translations/fr.json.mjs +8 -6
- package/lib/esm/translations/it.json.mjs +8 -6
- package/lib/esm/translations/ja.json.mjs +8 -6
- package/lib/esm/translations/ko.json.mjs +8 -6
- package/lib/esm/translations/nl.json.mjs +8 -6
- package/lib/esm/translations/pl.json.mjs +8 -6
- package/lib/esm/translations/pt.json.mjs +8 -6
- package/lib/esm/translations/sv.json.mjs +8 -6
- package/lib/esm/translations/tr.json.mjs +8 -6
- package/lib/esm/translations/vi.json.mjs +8 -6
- package/lib/esm/translations/zh.json.mjs +8 -6
- package/lib/esm/utils.mjs +27 -15
- package/package.json +9 -9
package/lib/esm/NoticeBubble.mjs
CHANGED
|
@@ -1,298 +1,370 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { sstyled
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { Animation
|
|
16
|
-
import { Box
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { callAllEventHandlers
|
|
20
|
-
import
|
|
21
|
-
import { Timer
|
|
22
|
-
import { localizedMessages
|
|
23
|
-
import
|
|
24
|
-
import { useCssVariable
|
|
25
|
-
import { contextThemeEnhance
|
|
26
|
-
import
|
|
27
|
-
import { setFocus
|
|
28
|
-
import { Hint
|
|
29
|
-
import { zIndexStackingEnhance
|
|
30
|
-
import { forkRef
|
|
31
|
-
import { getFocusableIn
|
|
32
|
-
var
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
11
|
+
import createComponent, { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import Portal from "@semcore/portal";
|
|
14
|
+
import noticeBubbleDefaultManager from "./NoticeBubbleManager.mjs";
|
|
15
|
+
import { Animation } from "@semcore/animation";
|
|
16
|
+
import { Box, Flex } from "@semcore/flex-box";
|
|
17
|
+
import fire from "@semcore/utils/lib/fire";
|
|
18
|
+
import isNode from "@semcore/utils/lib/isNode";
|
|
19
|
+
import { callAllEventHandlers } from "@semcore/utils/lib/assignProps";
|
|
20
|
+
import CloseIcon from "@semcore/icon/Close/m";
|
|
21
|
+
import { Timer } from "./utils.mjs";
|
|
22
|
+
import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
23
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
24
|
+
import { useCssVariable } from "@semcore/utils/lib/useCssVariable";
|
|
25
|
+
import { contextThemeEnhance } from "@semcore/utils/lib/ThemeProvider";
|
|
26
|
+
import Button from "@semcore/button";
|
|
27
|
+
import { setFocus, useFocusLock } from "@semcore/utils/lib/use/useFocusLock";
|
|
28
|
+
import { Hint } from "@semcore/tooltip";
|
|
29
|
+
import { zIndexStackingEnhance, ZIndexStackingContextProvider } from "@semcore/utils/lib/zIndexStacking";
|
|
30
|
+
import { forkRef, useForkRef } from "@semcore/utils/lib/ref";
|
|
31
|
+
import { getFocusableIn } from "@semcore/utils/lib/focus-lock/getFocusableIn";
|
|
32
|
+
var _excluded = ["focusLock"], _excluded2 = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action", "type"];
|
|
33
|
+
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
34
|
+
var style = (
|
|
33
35
|
/*__reshadow_css_start__*/
|
|
34
|
-
(
|
|
36
|
+
(sstyled.insert(
|
|
35
37
|
/*__inner_css_start__*/
|
|
36
|
-
"@keyframes
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
"@keyframes enter_zggka{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_zggka{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_zggka_gg_,.___SView_zggka_gg_{position:relative;margin-bottom:var(--intergalactic-spacing-3x, 12px);padding:var(--intergalactic-spacing-3x, 12px);padding-right:calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-1x, 4px));width:100%;border-radius:var(--intergalactic-popper-rounded, 6px);overflow:hidden;box-sizing:border-box;color:var(--intergalactic-text-primary-invert, #ffffff);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_zggka_gg_._type_info_zggka_gg_,.___SView_zggka_gg_._type_info_zggka_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_zggka_gg_._type_warning_zggka_gg_,.___SView_zggka_gg_._type_warning_zggka_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_zggka_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_zggka_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_zggka_gg_{cursor:pointer;position:absolute;right:0;top:0;margin-top:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px);margin-bottom:var(--intergalactic-spacing-2x, 8px);flex-shrink:0;border:0;background:0 0}.___SDismiss_zggka_gg_.__use_zggka_gg_{padding:0 1px}.___SIcon_zggka_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_zggka_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_zggka_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_zggka_gg_.__disablePortal_zggka_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_zggka_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}.___SNoticeAriaLiveWrapper_zggka_gg_{display:contents}",
|
|
39
|
+
/*__inner_css_end__*/
|
|
40
|
+
"zggka_gg_"
|
|
41
|
+
), /*__reshadow_css_end__*/
|
|
42
|
+
{
|
|
43
|
+
"__SContent": "___SContent_zggka_gg_",
|
|
44
|
+
"__SMessage": "___SMessage_zggka_gg_",
|
|
45
|
+
"__SDismiss": "___SDismiss_zggka_gg_",
|
|
46
|
+
"_use": "__use_zggka_gg_",
|
|
47
|
+
"__SIcon": "___SIcon_zggka_gg_",
|
|
48
|
+
"__SNoticeBubble": "___SNoticeBubble_zggka_gg_",
|
|
49
|
+
"_disablePortal": "__disablePortal_zggka_gg_",
|
|
50
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_zggka_gg_",
|
|
51
|
+
"@enter": "enter_zggka",
|
|
52
|
+
"@exit": "exit_zggka",
|
|
53
|
+
"__SBubble": "___SBubble_zggka_gg_",
|
|
54
|
+
"__SView": "___SView_zggka_gg_",
|
|
55
|
+
"_type_info": "_type_info_zggka_gg_",
|
|
56
|
+
"_type_warning": "_type_warning_zggka_gg_"
|
|
53
57
|
})
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
);
|
|
59
|
+
var Notices = function Notices2(props) {
|
|
60
|
+
var styles = props.styles, _props$data = props.data, data = _props$data === void 0 ? [] : _props$data, _props$tag = props.tag, SView = _props$tag === void 0 ? ViewInfo : _props$tag;
|
|
61
|
+
var ref = React.useRef();
|
|
62
|
+
var durationStr = useCssVariable("--intergalactic-duration-popper", "200", ref);
|
|
63
|
+
var duration = React.useMemo(function() {
|
|
64
|
+
return parseInt(durationStr, 10);
|
|
65
|
+
}, [durationStr]);
|
|
66
|
+
return data.map(function(notice) {
|
|
67
|
+
var _ref2, _notice$visible;
|
|
68
|
+
return _ref2 = sstyled$1(styles), /* @__PURE__ */ React.createElement(Animation, _ref2.cn("Animation", {
|
|
69
|
+
"key": notice.uid,
|
|
70
|
+
"initialAnimation": notice.initialAnimation,
|
|
71
|
+
"visible": (_notice$visible = notice.visible) !== null && _notice$visible !== void 0 ? _notice$visible : true,
|
|
72
|
+
"duration": duration,
|
|
73
|
+
"keyframes": [styles["@enter"], styles["@exit"]],
|
|
74
|
+
"ref": ref
|
|
75
|
+
}), /* @__PURE__ */ React.createElement(SView, _ref2.cn("SView", _objectSpread(_objectSpread({}, notice), {}, {
|
|
76
|
+
"styles": notice.styles || styles,
|
|
77
|
+
"getI18nText": props.getI18nText
|
|
70
78
|
}))));
|
|
71
79
|
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
};
|
|
81
|
+
var NoticeBubbleContainerRoot = /* @__PURE__ */ function(_Component) {
|
|
82
|
+
_inherits(NoticeBubbleContainerRoot2, _Component);
|
|
83
|
+
var _super = _createSuper(NoticeBubbleContainerRoot2);
|
|
84
|
+
function NoticeBubbleContainerRoot2() {
|
|
85
|
+
var _this;
|
|
86
|
+
_classCallCheck(this, NoticeBubbleContainerRoot2);
|
|
87
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
88
|
+
args[_key] = arguments[_key];
|
|
89
|
+
}
|
|
90
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "_unsubscribe", null);
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
81
93
|
notices: [],
|
|
82
94
|
warnings: []
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
});
|
|
96
|
+
_defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function() {
|
|
97
|
+
if (_this._unsubscribe) {
|
|
98
|
+
_this._unsubscribe();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function(notices) {
|
|
102
|
+
var info = notices.filter(function(notice) {
|
|
103
|
+
return notice.type === "info";
|
|
90
104
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
warnings: p
|
|
105
|
+
var warning = notices.filter(function(notice) {
|
|
106
|
+
return notice.type === "warning";
|
|
94
107
|
});
|
|
95
|
-
|
|
108
|
+
_this.setState({
|
|
109
|
+
notices: info,
|
|
110
|
+
warnings: warning
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return _this;
|
|
96
114
|
}
|
|
97
|
-
|
|
115
|
+
_createClass(NoticeBubbleContainerRoot2, [{
|
|
98
116
|
key: "componentDidMount",
|
|
99
|
-
value: function() {
|
|
117
|
+
value: function componentDidMount() {
|
|
100
118
|
this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
|
|
101
119
|
}
|
|
102
120
|
}, {
|
|
103
121
|
key: "render",
|
|
104
|
-
value: function() {
|
|
105
|
-
var
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
value: function render() {
|
|
123
|
+
var _ref = this.asProps, _ref3;
|
|
124
|
+
var SNoticeBubble = Box;
|
|
125
|
+
var SNoticeAriaLiveWrapper = "div";
|
|
126
|
+
var _this$asProps = this.asProps, Children = _this$asProps.Children, styles = _this$asProps.styles, disablePortal = _this$asProps.disablePortal, getI18nText = _this$asProps.getI18nText, ref = _this$asProps.ref, parentZIndexStacking = _this$asProps.parentZIndexStacking;
|
|
127
|
+
var _this$state = this.state, notices = _this$state.notices, warnings = _this$state.warnings;
|
|
128
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
|
|
129
|
+
"designToken": "z-index-notice-bubble"
|
|
130
|
+
}), /* @__PURE__ */ React.createElement(Portal, _ref3.cn("Portal", {
|
|
131
|
+
"disablePortal": disablePortal
|
|
132
|
+
}), /* @__PURE__ */ React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, assignProps({
|
|
133
|
+
"ref": ref,
|
|
134
|
+
"tag": "section",
|
|
135
|
+
"role": "region",
|
|
136
|
+
"aria-label": getI18nText("notification"),
|
|
137
|
+
"zIndex": parentZIndexStacking
|
|
138
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {})), /* @__PURE__ */ React.createElement(Notices, _ref3.cn("Notices", {
|
|
139
|
+
"styles": styles,
|
|
140
|
+
"data": warnings,
|
|
141
|
+
"tag": ViewWarning,
|
|
142
|
+
"getI18nText": getI18nText
|
|
143
|
+
})), /* @__PURE__ */ React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
|
|
122
144
|
"aria-live": "polite"
|
|
123
|
-
}), /* @__PURE__ */
|
|
124
|
-
styles:
|
|
125
|
-
data:
|
|
126
|
-
tag:
|
|
127
|
-
getI18nText:
|
|
145
|
+
}), /* @__PURE__ */ React.createElement(Notices, _ref3.cn("Notices", {
|
|
146
|
+
"styles": styles,
|
|
147
|
+
"data": notices,
|
|
148
|
+
"tag": ViewInfo,
|
|
149
|
+
"getI18nText": getI18nText
|
|
128
150
|
}))))));
|
|
129
151
|
}
|
|
130
|
-
}])
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
152
|
+
}]);
|
|
153
|
+
return NoticeBubbleContainerRoot2;
|
|
154
|
+
}(Component);
|
|
155
|
+
_defineProperty(NoticeBubbleContainerRoot, "displayName", "NoticeBubbleContainer");
|
|
156
|
+
_defineProperty(NoticeBubbleContainerRoot, "style", style);
|
|
157
|
+
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance("z-index-notice-bubble")]);
|
|
158
|
+
_defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
159
|
+
manager: noticeBubbleDefaultManager,
|
|
160
|
+
i18n: localizedMessages,
|
|
138
161
|
locale: "en"
|
|
139
162
|
});
|
|
140
|
-
var
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
var FocusLock = /* @__PURE__ */ React.forwardRef(function(props, outerRef) {
|
|
164
|
+
var focusLock = props.focusLock, other = _objectWithoutProperties(props, _excluded);
|
|
165
|
+
var innerRef = React.useRef();
|
|
166
|
+
useFocusLock(innerRef, false, "auto", !focusLock, true);
|
|
167
|
+
var ref = useForkRef(outerRef, innerRef);
|
|
168
|
+
return /* @__PURE__ */ React.createElement(Flex, _extends({
|
|
169
|
+
ref
|
|
170
|
+
}, other));
|
|
171
|
+
});
|
|
172
|
+
var ViewInfo = /* @__PURE__ */ function(_Component2) {
|
|
173
|
+
_inherits(ViewInfo2, _Component2);
|
|
174
|
+
var _super2 = _createSuper(ViewInfo2);
|
|
175
|
+
function ViewInfo2() {
|
|
176
|
+
var _this2;
|
|
177
|
+
_classCallCheck(this, ViewInfo2);
|
|
178
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
179
|
+
args[_key2] = arguments[_key2];
|
|
180
|
+
}
|
|
181
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
182
|
+
_defineProperty(_assertThisInitialized(_this2), "timer", null);
|
|
183
|
+
_defineProperty(_assertThisInitialized(_this2), "ref", /* @__PURE__ */ React.createRef());
|
|
184
|
+
_defineProperty(_assertThisInitialized(_this2), "closeButtonRef", /* @__PURE__ */ React.createRef());
|
|
185
|
+
_defineProperty(_assertThisInitialized(_this2), "handleClose", function(e) {
|
|
186
|
+
fire(_assertThisInitialized(_this2), "onClose", e);
|
|
187
|
+
_this2.clearTimer();
|
|
188
|
+
});
|
|
189
|
+
_defineProperty(_assertThisInitialized(_this2), "handleKeydown", function(e) {
|
|
190
|
+
if (e.key === "Escape") {
|
|
191
|
+
_this2.handleClose(e);
|
|
168
192
|
}
|
|
169
|
-
})
|
|
193
|
+
});
|
|
194
|
+
_defineProperty(_assertThisInitialized(_this2), "handleMouseEnter", function() {
|
|
195
|
+
if (!_this2.timer) return;
|
|
196
|
+
_this2.timer.pause();
|
|
197
|
+
});
|
|
198
|
+
_defineProperty(_assertThisInitialized(_this2), "handleMouseLeave", function() {
|
|
199
|
+
if (!_this2.timer) return;
|
|
200
|
+
_this2.timer.resume();
|
|
201
|
+
});
|
|
202
|
+
_defineProperty(_assertThisInitialized(_this2), "handleBodyMouseMove", function(event) {
|
|
203
|
+
var _this2$timer;
|
|
204
|
+
if (!((_this2$timer = _this2.timer) !== null && _this2$timer !== void 0 && _this2$timer.paused)) return;
|
|
205
|
+
var rect = _this2.ref.current.getBoundingClientRect();
|
|
206
|
+
var mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
207
|
+
if (mouseInRect) return;
|
|
208
|
+
_this2.timer.resume();
|
|
209
|
+
});
|
|
210
|
+
return _this2;
|
|
170
211
|
}
|
|
171
|
-
|
|
212
|
+
_createClass(ViewInfo2, [{
|
|
172
213
|
key: "componentDidMount",
|
|
173
|
-
value: function() {
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
214
|
+
value: function componentDidMount() {
|
|
215
|
+
var _this3 = this;
|
|
216
|
+
var duration = this.props.duration;
|
|
217
|
+
if (duration) {
|
|
218
|
+
this.timer = new Timer(this.handleClose, duration);
|
|
219
|
+
document.body.addEventListener("mousemove", this.handleBodyMouseMove);
|
|
220
|
+
}
|
|
221
|
+
var noticeElement = this.ref.current;
|
|
222
|
+
if (noticeElement) {
|
|
223
|
+
var focusableNodes = getFocusableIn(noticeElement).filter(function(node) {
|
|
224
|
+
return node !== _this3.closeButtonRef.current;
|
|
180
225
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
226
|
+
if (focusableNodes.length > 0) {
|
|
227
|
+
setTimeout(function() {
|
|
228
|
+
return setFocus(noticeElement);
|
|
229
|
+
}, 0);
|
|
230
|
+
}
|
|
184
231
|
}
|
|
185
232
|
}
|
|
186
233
|
}, {
|
|
187
234
|
key: "componentWillUnmount",
|
|
188
|
-
value: function() {
|
|
189
|
-
this.clearTimer()
|
|
235
|
+
value: function componentWillUnmount() {
|
|
236
|
+
this.clearTimer();
|
|
237
|
+
document.body.removeEventListener("mousemove", this.handleBodyMouseMove);
|
|
190
238
|
}
|
|
191
239
|
}, {
|
|
192
240
|
key: "clearTimer",
|
|
193
|
-
value: function() {
|
|
194
|
-
|
|
241
|
+
value: function clearTimer() {
|
|
242
|
+
if (this.timer) {
|
|
243
|
+
this.timer.clear();
|
|
244
|
+
this.timer = null;
|
|
245
|
+
}
|
|
195
246
|
}
|
|
196
247
|
}, {
|
|
197
248
|
key: "render",
|
|
198
|
-
value: function() {
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
249
|
+
value: function render() {
|
|
250
|
+
var _ref4;
|
|
251
|
+
var SBubble = FocusLock;
|
|
252
|
+
var SDismiss = Hint.Trigger;
|
|
253
|
+
var SContent = Flex;
|
|
254
|
+
var SMessage = "div";
|
|
255
|
+
var SAction = "div";
|
|
256
|
+
var SIcon = Flex;
|
|
257
|
+
var _this$props = this.props, forwardRef = _this$props.forwardRef, styles = _this$props.styles, onMouseEnter = _this$props.onMouseEnter, onMouseLeave = _this$props.onMouseLeave, getI18nText = _this$props.getI18nText, icon = _this$props.icon, children = _this$props.children, actionNode = _this$props.action, type = _this$props.type, other = _objectWithoutProperties(_this$props, _excluded2);
|
|
258
|
+
return _ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBubble, _ref4.cn("SBubble", _objectSpread(_objectSpread({}, other), {}, {
|
|
259
|
+
"ref": forkRef(forwardRef, this.ref),
|
|
260
|
+
"onMouseEnter": callAllEventHandlers(onMouseEnter, this.handleMouseEnter),
|
|
261
|
+
"onMouseLeave": callAllEventHandlers(onMouseLeave, this.handleMouseLeave),
|
|
262
|
+
"onKeyDown": this.handleKeydown,
|
|
263
|
+
"role": type === "warning" ? "alert" : this.props.role
|
|
264
|
+
})), /* @__PURE__ */ React.createElement(
|
|
265
|
+
SDismiss,
|
|
266
|
+
_ref4.cn("SDismiss", {
|
|
209
267
|
"aria-haspopup": void 0,
|
|
210
|
-
tag:
|
|
211
|
-
type: "button",
|
|
212
|
-
use: "tertiary",
|
|
213
|
-
size: "m",
|
|
214
|
-
theme: "invert",
|
|
215
|
-
onClick: this.handleClose,
|
|
216
|
-
"aria-label":
|
|
217
|
-
active:
|
|
218
|
-
title:
|
|
219
|
-
ref: this.closeButtonRef
|
|
268
|
+
"tag": Button,
|
|
269
|
+
"type": "button",
|
|
270
|
+
"use": "tertiary",
|
|
271
|
+
"size": "m",
|
|
272
|
+
"theme": "invert",
|
|
273
|
+
"onClick": this.handleClose,
|
|
274
|
+
"aria-label": getI18nText("close"),
|
|
275
|
+
"active": false,
|
|
276
|
+
"title": getI18nText("close"),
|
|
277
|
+
"ref": this.closeButtonRef
|
|
220
278
|
}),
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
tag:
|
|
279
|
+
/* @__PURE__ */ React.createElement(Button.Addon, {
|
|
280
|
+
tag: CloseIcon,
|
|
223
281
|
color: "icon-primary-invert"
|
|
224
282
|
})
|
|
225
|
-
),
|
|
283
|
+
), isNode(icon) ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SIcon, _ref4.cn("SIcon", {}), icon), /* @__PURE__ */ React.createElement(SContent, _ref4.cn("SContent", {}), /* @__PURE__ */ React.createElement(SMessage, _ref4.cn("SMessage", {}), children), isNode(actionNode) ? /* @__PURE__ */ React.createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null)) : /* @__PURE__ */ React.createElement(SContent, _ref4.cn("SContent", {}), /* @__PURE__ */ React.createElement(SMessage, _ref4.cn("SMessage", {}), children), isNode(actionNode) ? /* @__PURE__ */ React.createElement(SAction, _ref4.cn("SAction", {}), actionNode) : null));
|
|
226
284
|
}
|
|
227
|
-
}])
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
285
|
+
}]);
|
|
286
|
+
return ViewInfo2;
|
|
287
|
+
}(Component);
|
|
288
|
+
var ViewWarning = /* @__PURE__ */ function(_ViewInfo) {
|
|
289
|
+
_inherits(ViewWarning2, _ViewInfo);
|
|
290
|
+
var _super3 = _createSuper(ViewWarning2);
|
|
291
|
+
function ViewWarning2() {
|
|
292
|
+
_classCallCheck(this, ViewWarning2);
|
|
293
|
+
return _super3.apply(this, arguments);
|
|
233
294
|
}
|
|
234
|
-
return
|
|
235
|
-
}(
|
|
236
|
-
|
|
295
|
+
return _createClass(ViewWarning2);
|
|
296
|
+
}(ViewInfo);
|
|
297
|
+
_defineProperty(ViewWarning, "defaultProps", {
|
|
237
298
|
type: "warning",
|
|
238
299
|
duration: 0
|
|
239
300
|
});
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
var
|
|
243
|
-
function
|
|
244
|
-
var
|
|
245
|
-
|
|
246
|
-
for (var
|
|
247
|
-
|
|
248
|
-
|
|
301
|
+
var NoticeBubbleView = /* @__PURE__ */ function(_Component3) {
|
|
302
|
+
_inherits(NoticeBubbleView2, _Component3);
|
|
303
|
+
var _super4 = _createSuper(NoticeBubbleView2);
|
|
304
|
+
function NoticeBubbleView2() {
|
|
305
|
+
var _this4;
|
|
306
|
+
_classCallCheck(this, NoticeBubbleView2);
|
|
307
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
308
|
+
args[_key3] = arguments[_key3];
|
|
309
|
+
}
|
|
310
|
+
_this4 = _super4.call.apply(_super4, [this].concat(args));
|
|
311
|
+
_defineProperty(_assertThisInitialized(_this4), "_notice", null);
|
|
312
|
+
return _this4;
|
|
249
313
|
}
|
|
250
|
-
|
|
314
|
+
_createClass(NoticeBubbleView2, [{
|
|
251
315
|
key: "componentDidMount",
|
|
252
|
-
value: function() {
|
|
316
|
+
value: function componentDidMount() {
|
|
253
317
|
this._notice = this.asProps.manager.add(this.asProps);
|
|
254
318
|
}
|
|
255
319
|
}, {
|
|
256
320
|
key: "componentWillUnmount",
|
|
257
|
-
value: function() {
|
|
258
|
-
|
|
321
|
+
value: function componentWillUnmount() {
|
|
322
|
+
if (this._notice) {
|
|
323
|
+
this._notice.remove();
|
|
324
|
+
}
|
|
259
325
|
}
|
|
260
326
|
}, {
|
|
261
327
|
key: "componentDidUpdate",
|
|
262
|
-
value: function() {
|
|
263
|
-
|
|
328
|
+
value: function componentDidUpdate() {
|
|
329
|
+
if (this._notice) {
|
|
330
|
+
this._notice.update(this.asProps);
|
|
331
|
+
}
|
|
264
332
|
}
|
|
265
333
|
}, {
|
|
266
334
|
key: "render",
|
|
267
|
-
value: function() {
|
|
335
|
+
value: function render() {
|
|
268
336
|
return null;
|
|
269
337
|
}
|
|
270
|
-
}])
|
|
271
|
-
|
|
272
|
-
|
|
338
|
+
}]);
|
|
339
|
+
return NoticeBubbleView2;
|
|
340
|
+
}(Component);
|
|
341
|
+
_defineProperty(NoticeBubbleView, "defaultProps", {
|
|
273
342
|
duration: 5e3,
|
|
274
343
|
type: "info",
|
|
275
|
-
manager:
|
|
344
|
+
manager: noticeBubbleDefaultManager
|
|
276
345
|
});
|
|
277
|
-
var
|
|
278
|
-
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
|
|
346
|
+
var NoticeBubbleWarningView = /* @__PURE__ */ function(_NoticeBubbleView) {
|
|
347
|
+
_inherits(NoticeBubbleWarningView2, _NoticeBubbleView);
|
|
348
|
+
var _super5 = _createSuper(NoticeBubbleWarningView2);
|
|
349
|
+
function NoticeBubbleWarningView2() {
|
|
350
|
+
_classCallCheck(this, NoticeBubbleWarningView2);
|
|
351
|
+
return _super5.apply(this, arguments);
|
|
282
352
|
}
|
|
283
|
-
return
|
|
284
|
-
}(
|
|
285
|
-
|
|
353
|
+
return _createClass(NoticeBubbleWarningView2);
|
|
354
|
+
}(NoticeBubbleView);
|
|
355
|
+
_defineProperty(NoticeBubbleWarningView, "defaultProps", {
|
|
286
356
|
duration: 5e3,
|
|
287
357
|
type: "warning",
|
|
288
|
-
manager:
|
|
358
|
+
manager: noticeBubbleDefaultManager
|
|
359
|
+
});
|
|
360
|
+
var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
|
|
361
|
+
Info: NoticeBubbleView,
|
|
362
|
+
Warning: NoticeBubbleWarningView
|
|
289
363
|
});
|
|
290
|
-
var
|
|
291
|
-
|
|
292
|
-
Warning: U
|
|
293
|
-
}), Ye = Z.Info, qe = Z.Warning;
|
|
364
|
+
var NoticeBubble = NoticeBubbleContainer.Info;
|
|
365
|
+
var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
|
|
294
366
|
export {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
367
|
+
NoticeBubble,
|
|
368
|
+
NoticeBubbleWarning,
|
|
369
|
+
NoticeBubbleContainer as default
|
|
298
370
|
};
|