@semcore/notice-bubble 16.0.0-prerelease.2 → 16.0.0-prerelease.20

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.
@@ -1,295 +1,367 @@
1
- import X from "@babel/runtime/helpers/esm/extends";
2
- import z from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- import v from "@babel/runtime/helpers/esm/classCallCheck";
4
- import h from "@babel/runtime/helpers/esm/createClass";
5
- import g from "@babel/runtime/helpers/esm/assertThisInitialized";
6
- import x from "@babel/runtime/helpers/esm/inherits";
7
- import b from "@babel/runtime/helpers/esm/createSuper";
8
- import s from "@babel/runtime/helpers/esm/defineProperty";
9
- import d from "@babel/runtime/helpers/esm/objectSpread2";
10
- import { sstyled as M, createComponent as Y, assignProps as H, Component as P } from "@semcore/core";
11
- import n from "react";
12
- import q from "@semcore/portal";
13
- import L from "./NoticeBubbleManager.mjs";
14
- import { Animation as G } from "@semcore/animation";
15
- import { Box as J, Flex as k } from "@semcore/flex-box";
16
- import O from "@semcore/core/lib/utils/fire";
17
- import N from "@semcore/core/lib/utils/isNode";
18
- import { callAllEventHandlers as A } from "@semcore/core/lib/utils/assignProps";
19
- import Q from "@semcore/icon/Close/m";
20
- import { Timer as ee } from "./utils.mjs";
21
- import { localizedMessages as F } from "./translations/__intergalactic-dynamic-locales.mjs";
22
- import te from "@semcore/core/lib/utils/enhances/i18nEnhance";
23
- import { useCssVariable as ie } from "@semcore/core/lib/utils/useCssVariable";
24
- import { contextThemeEnhance as ne } from "@semcore/core/lib/utils/ThemeProvider";
25
- import D from "@semcore/button";
26
- import { setFocus as re, useFocusLock as ae } from "@semcore/core/lib/utils/use/useFocusLock";
27
- import { zIndexStackingEnhance as oe, ZIndexStackingContextProvider as ce } from "@semcore/core/lib/utils/zIndexStacking";
28
- import { forkRef as se, useForkRef as le } from "@semcore/core/lib/utils/ref";
29
- import { getFocusableIn as _e } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
30
- var ue = ["focusLock"], ge = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action", "type"], me = (
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
- (M.insert(
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
- __SContent: "___SContent_1i85x_gg_",
38
- __SMessage: "___SMessage_1i85x_gg_",
39
- __SDismiss: "___SDismiss_1i85x_gg_",
40
- _use: "__use_1i85x_gg_",
41
- __SIcon: "___SIcon_1i85x_gg_",
42
- __SNoticeBubble: "___SNoticeBubble_1i85x_gg_",
43
- _disablePortal: "__disablePortal_1i85x_gg_",
44
- __SNoticeAriaLiveWrapper: "___SNoticeAriaLiveWrapper_1i85x_gg_",
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
- ), V = function(l) {
53
- var t = l.styles, e = l.data, i = e === void 0 ? [] : e, r = l.tag, a = r === void 0 ? R : r, o = n.useRef(), c = ie("--intergalactic-duration-popper", "200", o), p = n.useMemo(function() {
54
- return parseInt(c, 10);
55
- }, [c]);
56
- return i.map(function(_) {
57
- var u, f;
58
- return u = M(t), /* @__PURE__ */ n.createElement(G, u.cn("Animation", {
59
- key: _.uid,
60
- initialAnimation: _.initialAnimation,
61
- visible: (f = _.visible) !== null && f !== void 0 ? f : !0,
62
- duration: p,
63
- keyframes: [t["@enter"], t["@exit"]],
64
- ref: o
65
- }), /* @__PURE__ */ n.createElement(a, u.cn("SView", d(d({}, _), {}, {
66
- styles: _.styles || t,
67
- getI18nText: l.getI18nText
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
- }, y = /* @__PURE__ */ function(m) {
71
- x(t, m);
72
- var l = b(t);
73
- function t() {
74
- var e;
75
- v(this, t);
76
- for (var i = arguments.length, r = new Array(i), a = 0; a < i; a++)
77
- r[a] = arguments[a];
78
- return e = l.call.apply(l, [this].concat(r)), s(g(e), "_unsubscribe", null), s(g(e), "state", {
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
- }), s(g(e), "componentWillUnmount", function() {
82
- e._unsubscribe && e._unsubscribe();
83
- }), s(g(e), "handleChange", function(o) {
84
- var c = o.filter(function(_) {
85
- return _.type === "info";
86
- }), p = o.filter(function(_) {
87
- return _.type === "warning";
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
- e.setState({
90
- notices: c,
91
- warnings: p
103
+ var warning = notices.filter(function(notice) {
104
+ return notice.type === "warning";
92
105
  });
93
- }), e;
106
+ _this.setState({
107
+ notices: info,
108
+ warnings: warning
109
+ });
110
+ });
111
+ return _this;
94
112
  }
95
- return h(t, [{
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 i = this.asProps, r, a = J, o = "div", c = this.asProps, p = c.Children, _ = c.styles, u = c.disablePortal, f = c.getI18nText, C = c.ref, I = c.parentZIndexStacking, S = this.state, w = S.notices, E = S.warnings;
104
- return r = M(_), /* @__PURE__ */ n.createElement(ce, r.cn("ZIndexStackingContextProvider", {
105
- designToken: "z-index-notice-bubble"
106
- }), /* @__PURE__ */ n.createElement(q, r.cn("Portal", {
107
- disablePortal: u
108
- }), /* @__PURE__ */ n.createElement(a, r.cn("SNoticeBubble", d({}, H({
109
- ref: C,
110
- tag: "section",
111
- role: "region",
112
- "aria-label": f("notification"),
113
- zIndex: I
114
- }, i))), /* @__PURE__ */ n.createElement(p, r.cn("Children", {})), /* @__PURE__ */ n.createElement(V, r.cn("Notices", {
115
- styles: _,
116
- data: E,
117
- tag: U,
118
- getI18nText: f
119
- })), /* @__PURE__ */ n.createElement(o, r.cn("SNoticeAriaLiveWrapper", {
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__ */ n.createElement(V, r.cn("Notices", {
122
- styles: _,
123
- data: w,
124
- tag: R,
125
- getI18nText: f
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
- }]), t;
129
- }(P);
130
- s(y, "displayName", "NoticeBubbleContainer");
131
- s(y, "style", me);
132
- s(y, "enhance", [te(F), ne(), oe("z-index-notice-bubble")]);
133
- s(y, "defaultProps", {
134
- manager: L,
135
- i18n: F,
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 pe = /* @__PURE__ */ n.forwardRef(function(m, l) {
139
- var t = m.focusLock, e = z(m, ue), i = n.useRef();
140
- ae(i, !1, "auto", !t, !0);
141
- var r = le(l, i);
142
- return /* @__PURE__ */ n.createElement(k, X({
143
- ref: r
144
- }, e));
145
- }), R = /* @__PURE__ */ function(m) {
146
- x(t, m);
147
- var l = b(t);
148
- function t() {
149
- var e;
150
- v(this, t);
151
- for (var i = arguments.length, r = new Array(i), a = 0; a < i; a++)
152
- r[a] = arguments[a];
153
- return e = l.call.apply(l, [this].concat(r)), s(g(e), "timer", null), s(g(e), "ref", /* @__PURE__ */ n.createRef()), s(g(e), "closeButtonRef", /* @__PURE__ */ n.createRef()), s(g(e), "handleClose", function(o) {
154
- O(g(e), "onClose", o), e.clearTimer();
155
- }), s(g(e), "handleKeydown", function(o) {
156
- o.key === "Escape" && e.handleClose(o);
157
- }), s(g(e), "handleMouseEnter", function() {
158
- e.timer && e.timer.pause();
159
- }), s(g(e), "handleMouseLeave", function() {
160
- e.timer && e.timer.resume();
161
- }), s(g(e), "handleBodyMouseMove", function(o) {
162
- var c;
163
- if ((c = e.timer) !== null && c !== void 0 && c.paused) {
164
- var p = e.ref.current.getBoundingClientRect(), _ = o.clientX >= p.left && o.clientX <= p.right && o.clientY >= p.top && o.clientY <= p.bottom;
165
- _ || e.timer.resume();
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
- }), e;
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
- return h(t, [{
210
+ _createClass(ViewInfo2, [{
170
211
  key: "componentDidMount",
171
- value: function() {
172
- var i = this, r = this.props.duration;
173
- r && (this.timer = new ee(this.handleClose, r), document.body.addEventListener("mousemove", this.handleBodyMouseMove));
174
- var a = this.ref.current;
175
- if (a) {
176
- var o = _e(a).filter(function(c) {
177
- return c !== i.closeButtonRef.current;
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
- o.length > 0 && setTimeout(function() {
180
- return re(a);
181
- }, 0);
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(), document.body.removeEventListener("mousemove", this.handleBodyMouseMove);
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
- this.timer && (this.timer.clear(), this.timer = null);
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 i, r = pe, a = D, o = k, c = "div", p = "div", _ = k, u = this.props, f = u.forwardRef, C = u.styles, I = u.onMouseEnter, S = u.onMouseLeave, w = u.getI18nText, E = u.icon, W = u.children, B = u.action, j = u.type, K = z(u, ge);
198
- return i = M(C), /* @__PURE__ */ n.createElement(r, i.cn("SBubble", d(d({}, K), {}, {
199
- ref: se(f, this.ref),
200
- onMouseEnter: A(I, this.handleMouseEnter),
201
- onMouseLeave: A(S, this.handleMouseLeave),
202
- onKeyDown: this.handleKeydown,
203
- role: j === "warning" ? "alert" : this.props.role
204
- })), /* @__PURE__ */ n.createElement(
205
- a,
206
- i.cn("SDismiss", {
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": w("close"),
214
- active: !1,
215
- title: w("close"),
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__ */ n.createElement(D.Addon, {
219
- tag: Q,
276
+ /* @__PURE__ */ React.createElement(Button.Addon, {
277
+ tag: CloseIcon,
220
278
  color: "icon-primary-invert"
221
279
  })
222
- ), N(E) ? /* @__PURE__ */ n.createElement(n.Fragment, null, /* @__PURE__ */ n.createElement(_, i.cn("SIcon", {}), E), /* @__PURE__ */ n.createElement(o, i.cn("SContent", {}), /* @__PURE__ */ n.createElement(c, i.cn("SMessage", {}), W), N(B) ? /* @__PURE__ */ n.createElement(p, i.cn("SAction", {}), B) : null)) : /* @__PURE__ */ n.createElement(o, i.cn("SContent", {}), /* @__PURE__ */ n.createElement(c, i.cn("SMessage", {}), W), N(B) ? /* @__PURE__ */ n.createElement(p, i.cn("SAction", {}), B) : null));
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
- }]), t;
225
- }(P), U = /* @__PURE__ */ function(m) {
226
- x(t, m);
227
- var l = b(t);
228
- function t() {
229
- return v(this, t), l.apply(this, arguments);
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 h(t);
232
- }(R);
233
- s(U, "defaultProps", {
292
+ return _createClass(ViewWarning2);
293
+ }(ViewInfo);
294
+ _defineProperty(ViewWarning, "defaultProps", {
234
295
  type: "warning",
235
296
  duration: 0
236
297
  });
237
- var T = /* @__PURE__ */ function(m) {
238
- x(t, m);
239
- var l = b(t);
240
- function t() {
241
- var e;
242
- v(this, t);
243
- for (var i = arguments.length, r = new Array(i), a = 0; a < i; a++)
244
- r[a] = arguments[a];
245
- return e = l.call.apply(l, [this].concat(r)), s(g(e), "_notice", null), e;
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
- return h(t, [{
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
- this._notice && this._notice.remove();
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
- this._notice && this._notice.update(this.asProps);
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
- }]), t;
268
- }(P);
269
- s(T, "defaultProps", {
335
+ }]);
336
+ return NoticeBubbleView2;
337
+ }(Component);
338
+ _defineProperty(NoticeBubbleView, "defaultProps", {
270
339
  duration: 5e3,
271
340
  type: "info",
272
- manager: L
341
+ manager: noticeBubbleDefaultManager
273
342
  });
274
- var $ = /* @__PURE__ */ function(m) {
275
- x(t, m);
276
- var l = b(t);
277
- function t() {
278
- return v(this, t), l.apply(this, arguments);
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 h(t);
281
- }(T);
282
- s($, "defaultProps", {
350
+ return _createClass(NoticeBubbleWarningView2);
351
+ }(NoticeBubbleView);
352
+ _defineProperty(NoticeBubbleWarningView, "defaultProps", {
283
353
  duration: 5e3,
284
354
  type: "warning",
285
- manager: L
355
+ manager: noticeBubbleDefaultManager
356
+ });
357
+ var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
358
+ Info: NoticeBubbleView,
359
+ Warning: NoticeBubbleWarningView
286
360
  });
287
- var Z = Y(y, {
288
- Info: T,
289
- Warning: $
290
- }), je = Z.Info, Ke = Z.Warning;
361
+ var NoticeBubble = NoticeBubbleContainer.Info;
362
+ var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
291
363
  export {
292
- je as NoticeBubble,
293
- Ke as NoticeBubbleWarning,
294
- Z as default
364
+ NoticeBubble,
365
+ NoticeBubbleWarning,
366
+ NoticeBubbleContainer as default
295
367
  };