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