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