@semcore/notice-bubble 5.53.0-prerelease.2 → 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.
@@ -1,298 +1,364 @@
1
- import H from "@babel/runtime/helpers/esm/extends";
2
- import z from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- import d from "@babel/runtime/helpers/esm/classCallCheck";
4
- import h from "@babel/runtime/helpers/esm/createClass";
5
- import u from "@babel/runtime/helpers/esm/assertThisInitialized";
6
- import b from "@babel/runtime/helpers/esm/inherits";
7
- import x from "@babel/runtime/helpers/esm/createSuper";
8
- import c from "@babel/runtime/helpers/esm/defineProperty";
9
- import v from "@babel/runtime/helpers/esm/objectSpread2";
10
- import { sstyled as X } from "@semcore/utils/lib/core/index";
11
- import Y, { sstyled as k, assignProps as q, Component as P } from "@semcore/core";
12
- import r from "react";
13
- import G from "@semcore/portal";
14
- import L from "./NoticeBubbleManager.mjs";
15
- import { Animation as J } from "@semcore/animation";
16
- import { Box as O, Flex as N } from "@semcore/flex-box";
17
- import Q from "@semcore/utils/lib/fire";
18
- import I from "@semcore/utils/lib/isNode";
19
- import { callAllEventHandlers as A } from "@semcore/utils/lib/assignProps";
20
- import ee from "@semcore/icon/Close/m";
21
- import { Timer as te } from "./utils.mjs";
22
- import { localizedMessages as $ } from "./translations/__intergalactic-dynamic-locales.mjs";
23
- import ne from "@semcore/utils/lib/enhances/i18nEnhance";
24
- import { useCssVariable as re } from "@semcore/utils/lib/useCssVariable";
25
- import { contextThemeEnhance as ie } from "@semcore/utils/lib/ThemeProvider";
26
- import D from "@semcore/button";
27
- import { setFocus as ae, useFocusLock as oe } from "@semcore/utils/lib/use/useFocusLock";
28
- import { Hint as se } from "@semcore/tooltip";
29
- import { zIndexStackingEnhance as ce, ZIndexStackingContextProvider as ge } from "@semcore/utils/lib/zIndexStacking";
30
- import { forkRef as le, useForkRef as _e } from "@semcore/utils/lib/ref";
31
- import { getFocusableIn as ue } from "@semcore/utils/lib/focus-lock/getFocusableIn";
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
- (X.insert(
33
+ (sstyled.insert(
35
34
  /*__inner_css_start__*/
36
- "@keyframes enter_1gvsg{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_1gvsg{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_1gvsg_gg_,.___SView_1gvsg_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_1gvsg_gg_._type_info_1gvsg_gg_,.___SView_1gvsg_gg_._type_info_1gvsg_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_1gvsg_gg_._type_warning_1gvsg_gg_,.___SView_1gvsg_gg_._type_warning_1gvsg_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_1gvsg_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_1gvsg_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_1gvsg_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_1gvsg_gg_.__use_1gvsg_gg_{padding:0 1px}.___SIcon_1gvsg_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_1gvsg_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_1gvsg_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_1gvsg_gg_.__disablePortal_1gvsg_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_1gvsg_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}.___SNoticeAriaLiveWrapper_1gvsg_gg_{display:contents}",
37
- "1gvsg_gg_"
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: "___SContent_1gvsg_gg_",
40
- __SMessage: "___SMessage_1gvsg_gg_",
41
- __SDismiss: "___SDismiss_1gvsg_gg_",
42
- _use: "__use_1gvsg_gg_",
43
- __SIcon: "___SIcon_1gvsg_gg_",
44
- __SNoticeBubble: "___SNoticeBubble_1gvsg_gg_",
45
- _disablePortal: "__disablePortal_1gvsg_gg_",
46
- __SNoticeAriaLiveWrapper: "___SNoticeAriaLiveWrapper_1gvsg_gg_",
47
- "@enter": "enter_1gvsg",
48
- "@exit": "exit_1gvsg",
49
- __SBubble: "___SBubble_1gvsg_gg_",
50
- __SView: "___SView_1gvsg_gg_",
51
- _type_info: "_type_info_1gvsg_gg_",
52
- _type_warning: "_type_warning_1gvsg_gg_"
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
- ), V = function(g) {
55
- var t = g.styles, e = g.data, n = e === void 0 ? [] : e, i = g.tag, a = i === void 0 ? R : i, o = r.useRef(), s = re("--intergalactic-duration-popper", "200", o), p = r.useMemo(function() {
56
- return parseInt(s, 10);
57
- }, [s]);
58
- return n.map(function(l) {
59
- var _, f;
60
- return _ = k(t), /* @__PURE__ */ r.createElement(J, _.cn("Animation", {
61
- key: l.uid,
62
- initialAnimation: l.initialAnimation,
63
- visible: (f = l.visible) !== null && f !== void 0 ? f : !0,
64
- duration: p,
65
- keyframes: [t["@enter"], t["@exit"]],
66
- ref: o
67
- }), /* @__PURE__ */ r.createElement(a, _.cn("SView", v(v({}, l), {}, {
68
- styles: l.styles || t,
69
- getI18nText: g.getI18nText
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
- }, y = /* @__PURE__ */ function(m) {
73
- b(t, m);
74
- var g = x(t);
75
- function t() {
76
- var e;
77
- d(this, t);
78
- for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
79
- i[a] = arguments[a];
80
- return e = g.call.apply(g, [this].concat(i)), c(u(e), "_unsubscribe", null), c(u(e), "state", {
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
- }), c(u(e), "componentWillUnmount", function() {
84
- e._unsubscribe && e._unsubscribe();
85
- }), c(u(e), "handleChange", function(o) {
86
- var s = o.filter(function(l) {
87
- return l.type === "info";
88
- }), p = o.filter(function(l) {
89
- return l.type === "warning";
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
- e.setState({
92
- notices: s,
93
- warnings: p
100
+ var warning = notices.filter(function(notice) {
101
+ return notice.type === "warning";
94
102
  });
95
- }), e;
103
+ _this.setState({
104
+ notices: info,
105
+ warnings: warning
106
+ });
107
+ });
108
+ return _this;
96
109
  }
97
- return h(t, [{
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 n = this.asProps, i, a = O, o = "div", s = this.asProps, p = s.Children, l = s.styles, _ = s.disablePortal, f = s.getI18nText, M = s.ref, C = s.parentZIndexStacking, S = this.state, w = S.notices, E = S.warnings;
106
- return i = k(l), /* @__PURE__ */ r.createElement(ge, i.cn("ZIndexStackingContextProvider", {
107
- designToken: "z-index-notice-bubble"
108
- }), /* @__PURE__ */ r.createElement(G, i.cn("Portal", {
109
- disablePortal: _
110
- }), /* @__PURE__ */ r.createElement(a, i.cn("SNoticeBubble", v({}, q({
111
- ref: M,
112
- tag: "section",
113
- role: "region",
114
- "aria-label": f("notification"),
115
- zIndex: C
116
- }, n))), /* @__PURE__ */ r.createElement(p, i.cn("Children", {})), /* @__PURE__ */ r.createElement(V, i.cn("Notices", {
117
- styles: l,
118
- data: E,
119
- tag: F,
120
- getI18nText: f
121
- })), /* @__PURE__ */ r.createElement(o, i.cn("SNoticeAriaLiveWrapper", {
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__ */ r.createElement(V, i.cn("Notices", {
124
- styles: l,
125
- data: w,
126
- tag: R,
127
- getI18nText: f
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
- }]), t;
131
- }(P);
132
- c(y, "displayName", "NoticeBubbleContainer");
133
- c(y, "style", fe);
134
- c(y, "enhance", [ne($), ie(), ce("z-index-notice-bubble")]);
135
- c(y, "defaultProps", {
136
- manager: L,
137
- i18n: $,
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 ve = /* @__PURE__ */ r.forwardRef(function(m, g) {
141
- var t = m.focusLock, e = z(m, me), n = r.useRef();
142
- oe(n, !1, "auto", !t, !0);
143
- var i = _e(g, n);
144
- return /* @__PURE__ */ r.createElement(N, H({
145
- ref: i
146
- }, e));
147
- }), R = /* @__PURE__ */ function(m) {
148
- b(t, m);
149
- var g = x(t);
150
- function t() {
151
- var e;
152
- d(this, t);
153
- for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
154
- i[a] = arguments[a];
155
- return e = g.call.apply(g, [this].concat(i)), c(u(e), "timer", null), c(u(e), "ref", /* @__PURE__ */ r.createRef()), c(u(e), "closeButtonRef", /* @__PURE__ */ r.createRef()), c(u(e), "handleClose", function(o) {
156
- Q(u(e), "onClose", o), e.clearTimer();
157
- }), c(u(e), "handleKeydown", function(o) {
158
- o.key === "Escape" && e.handleClose(o);
159
- }), c(u(e), "handleMouseEnter", function() {
160
- e.timer && e.timer.pause();
161
- }), c(u(e), "handleMouseLeave", function() {
162
- e.timer && e.timer.resume();
163
- }), c(u(e), "handleBodyMouseMove", function(o) {
164
- var s;
165
- if ((s = e.timer) !== null && s !== void 0 && s.paused) {
166
- var p = e.ref.current.getBoundingClientRect(), l = o.clientX >= p.left && o.clientX <= p.right && o.clientY >= p.top && o.clientY <= p.bottom;
167
- l || e.timer.resume();
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
- }), e;
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
- return h(t, [{
207
+ _createClass(ViewInfo2, [{
172
208
  key: "componentDidMount",
173
- value: function() {
174
- var n = this, i = this.props.duration;
175
- i && (this.timer = new te(this.handleClose, i), document.body.addEventListener("mousemove", this.handleBodyMouseMove));
176
- var a = this.ref.current;
177
- if (a) {
178
- var o = ue(a).filter(function(s) {
179
- return s !== n.closeButtonRef.current;
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
- o.length > 0 && setTimeout(function() {
182
- return ae(a);
183
- }, 0);
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(), document.body.removeEventListener("mousemove", this.handleBodyMouseMove);
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
- this.timer && (this.timer.clear(), this.timer = null);
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 n, i = ve, a = se.Trigger, o = N, s = "div", p = "div", l = N, _ = this.props, f = _.forwardRef, M = _.styles, C = _.onMouseEnter, S = _.onMouseLeave, w = _.getI18nText, E = _.icon, W = _.children, B = _.action, j = _.type, K = z(_, pe);
200
- return n = k(M), /* @__PURE__ */ r.createElement(i, n.cn("SBubble", v(v({}, K), {}, {
201
- ref: le(f, this.ref),
202
- onMouseEnter: A(C, this.handleMouseEnter),
203
- onMouseLeave: A(S, this.handleMouseLeave),
204
- onKeyDown: this.handleKeydown,
205
- role: j === "warning" ? "alert" : this.props.role
206
- })), /* @__PURE__ */ r.createElement(
207
- a,
208
- n.cn("SDismiss", {
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
- tag: D,
211
- type: "button",
212
- use: "tertiary",
213
- size: "m",
214
- theme: "invert",
215
- onClick: this.handleClose,
216
- "aria-label": w("close"),
217
- active: !1,
218
- title: w("close"),
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__ */ r.createElement(D.Addon, {
222
- tag: ee,
273
+ /* @__PURE__ */ React.createElement(Button.Addon, {
274
+ tag: CloseIcon,
223
275
  color: "icon-primary-invert"
224
276
  })
225
- ), I(E) ? /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(l, n.cn("SIcon", {}), E), /* @__PURE__ */ r.createElement(o, n.cn("SContent", {}), /* @__PURE__ */ r.createElement(s, n.cn("SMessage", {}), W), I(B) ? /* @__PURE__ */ r.createElement(p, n.cn("SAction", {}), B) : null)) : /* @__PURE__ */ r.createElement(o, n.cn("SContent", {}), /* @__PURE__ */ r.createElement(s, n.cn("SMessage", {}), W), I(B) ? /* @__PURE__ */ r.createElement(p, n.cn("SAction", {}), B) : null));
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
- }]), t;
228
- }(P), F = /* @__PURE__ */ function(m) {
229
- b(t, m);
230
- var g = x(t);
231
- function t() {
232
- return d(this, t), g.apply(this, arguments);
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 h(t);
235
- }(R);
236
- c(F, "defaultProps", {
289
+ return _createClass(ViewWarning2);
290
+ }(ViewInfo);
291
+ _defineProperty(ViewWarning, "defaultProps", {
237
292
  type: "warning",
238
293
  duration: 0
239
294
  });
240
- var T = /* @__PURE__ */ function(m) {
241
- b(t, m);
242
- var g = x(t);
243
- function t() {
244
- var e;
245
- d(this, t);
246
- for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
247
- i[a] = arguments[a];
248
- return e = g.call.apply(g, [this].concat(i)), c(u(e), "_notice", null), e;
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
- return h(t, [{
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
- this._notice && this._notice.remove();
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
- this._notice && this._notice.update(this.asProps);
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
- }]), t;
271
- }(P);
272
- c(T, "defaultProps", {
332
+ }]);
333
+ return NoticeBubbleView2;
334
+ }(Component);
335
+ _defineProperty(NoticeBubbleView, "defaultProps", {
273
336
  duration: 5e3,
274
337
  type: "info",
275
- manager: L
338
+ manager: noticeBubbleDefaultManager
276
339
  });
277
- var U = /* @__PURE__ */ function(m) {
278
- b(t, m);
279
- var g = x(t);
280
- function t() {
281
- return d(this, t), g.apply(this, arguments);
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 h(t);
284
- }(T);
285
- c(U, "defaultProps", {
347
+ return _createClass(NoticeBubbleWarningView2);
348
+ }(NoticeBubbleView);
349
+ _defineProperty(NoticeBubbleWarningView, "defaultProps", {
286
350
  duration: 5e3,
287
351
  type: "warning",
288
- manager: L
352
+ manager: noticeBubbleDefaultManager
353
+ });
354
+ var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
355
+ Info: NoticeBubbleView,
356
+ Warning: NoticeBubbleWarningView
289
357
  });
290
- var Z = Y(y, {
291
- Info: T,
292
- Warning: U
293
- }), Ye = Z.Info, qe = Z.Warning;
358
+ var NoticeBubble = NoticeBubbleContainer.Info;
359
+ var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
294
360
  export {
295
- Ye as NoticeBubble,
296
- qe as NoticeBubbleWarning,
297
- Z as default
361
+ NoticeBubble,
362
+ NoticeBubbleWarning,
363
+ NoticeBubbleContainer as default
298
364
  };