@semcore/notice-bubble 16.2.1 → 17.0.0-prerelease.18

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