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