@semcore/notice-bubble 5.54.0 → 5.54.1

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