@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 +1 @@
1
- {"version":3,"file":"utils.js","names":["Timer","exports","callback","delay","_classCallCheck2","_defineProperty2","remaining","paused","resume","_createClass2","key","value","pause","timerId","clearTimeout","Date","now","start","window","setTimeout","reset","clear"],"sources":["../../src/utils.ts"],"sourcesContent":["class Timer {\n private readonly delay: number;\n private readonly callback: Function;\n\n private remaining: number;\n private timerId: number | null = null;\n private start: number = 0;\n\n public paused: boolean;\n\n constructor(callback: Function, delay: number) {\n this.callback = callback;\n this.delay = delay;\n\n this.remaining = delay;\n this.paused = false;\n this.resume();\n }\n\n pause() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.remaining -= Date.now() - this.start;\n this.paused = true;\n }\n\n resume() {\n this.start = Date.now();\n this.paused = false;\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.timerId = window.setTimeout(this.callback, this.remaining);\n }\n\n reset() {\n this.remaining = this.delay;\n this.resume();\n }\n\n clear() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n }\n}\n\nexport { Timer };\n"],"mappings":";;;;;;;;;;IAAMA,KAAK,GAAAC,OAAA,CAAAD,KAAA;EAUT,SAAAA,MAAYE,QAAkB,EAAEC,KAAa,EAAE;IAAA,IAAAC,gBAAA,mBAAAJ,KAAA;IAAA,IAAAK,gBAAA;IAAA,IAAAA,gBAAA;IAAA,IAAAA,gBAAA;IAAA,IAAAA,gBAAA,8BALd,IAAI;IAAA,IAAAA,gBAAA,4BACb,CAAC;IAAA,IAAAA,gBAAA;IAKvB,IAAI,CAACH,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAElB,IAAI,CAACG,SAAS,GAAGH,KAAK;IACtB,IAAI,CAACI,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAAC,WAAAC,aAAA,aAAAT,KAAA;IAAAU,GAAA;IAAAC,KAAA,EAED,SAAAC,KAAKA,CAAA,EAAG;MACN,IAAI,IAAI,CAACC,OAAO,EAAE;QAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;MAC5B;MACA,IAAI,CAACP,SAAS,IAAIS,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACC,KAAK;MACzC,IAAI,CAACV,MAAM,GAAG,IAAI;IACpB;EAAC;IAAAG,GAAA;IAAAC,KAAA,EAED,SAAAH,MAAMA,CAAA,EAAG;MACP,IAAI,CAACS,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAC,CAAC;MACvB,IAAI,CAACT,MAAM,GAAG,KAAK;MACnB,IAAI,IAAI,CAACM,OAAO,EAAE;QAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;MAC5B;MACA,IAAI,CAACA,OAAO,GAAGK,MAAM,CAACC,UAAU,CAAC,IAAI,CAACjB,QAAQ,EAAE,IAAI,CAACI,SAAS,CAAC;IACjE;EAAC;IAAAI,GAAA;IAAAC,KAAA,EAED,SAAAS,KAAKA,CAAA,EAAG;MACN,IAAI,CAACd,SAAS,GAAG,IAAI,CAACH,KAAK;MAC3B,IAAI,CAACK,MAAM,CAAC,CAAC;IACf;EAAC;IAAAE,GAAA;IAAAC,KAAA,EAED,SAAAU,KAAKA,CAAA,EAAG;MACN,IAAI,IAAI,CAACR,OAAO,EAAE;QAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;MAC5B;IACF;EAAC;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["Timer","constructor","callback","delay","_defineProperty2","default","remaining","paused","resume","pause","timerId","clearTimeout","Date","now","start","window","setTimeout","reset","clear","exports"],"sources":["../../src/utils.ts"],"sourcesContent":["class Timer {\n private readonly delay: number;\n private readonly callback: Function;\n\n private remaining: number;\n private timerId: number | null = null;\n private start: number = 0;\n\n public paused: boolean;\n\n constructor(callback: Function, delay: number) {\n this.callback = callback;\n this.delay = delay;\n\n this.remaining = delay;\n this.paused = false;\n this.resume();\n }\n\n pause() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.remaining -= Date.now() - this.start;\n this.paused = true;\n }\n\n resume() {\n this.start = Date.now();\n this.paused = false;\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.timerId = window.setTimeout(this.callback, this.remaining);\n }\n\n reset() {\n this.remaining = this.delay;\n this.resume();\n }\n\n clear() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n }\n}\n\nexport { Timer };\n"],"mappings":";;;;;;;;AAAA,MAAMA,KAAK,CAAC;EAUVC,WAAWA,CAACC,QAAkB,EAAEC,KAAa,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,mBALd,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,iBACb,CAAC;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAKvB,IAAI,CAACH,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAElB,IAAI,CAACG,SAAS,GAAGH,KAAK;IACtB,IAAI,CAACI,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,IAAI,CAACC,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;IACA,IAAI,CAACJ,SAAS,IAAIM,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACC,KAAK;IACzC,IAAI,CAACP,MAAM,GAAG,IAAI;EACpB;EAEAC,MAAMA,CAAA,EAAG;IACP,IAAI,CAACM,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAC,CAAC;IACvB,IAAI,CAACN,MAAM,GAAG,KAAK;IACnB,IAAI,IAAI,CAACG,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;IACA,IAAI,CAACA,OAAO,GAAGK,MAAM,CAACC,UAAU,CAAC,IAAI,CAACd,QAAQ,EAAE,IAAI,CAACI,SAAS,CAAC;EACjE;EAEAW,KAAKA,CAAA,EAAG;IACN,IAAI,CAACX,SAAS,GAAG,IAAI,CAACH,KAAK;IAC3B,IAAI,CAACK,MAAM,CAAC,CAAC;EACf;EAEAU,KAAKA,CAAA,EAAG;IACN,IAAI,IAAI,CAACR,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;EACF;AACF;AAACS,OAAA,CAAAnB,KAAA,GAAAA,KAAA","ignoreList":[]}
@@ -1,15 +1,7 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _extends from "@babel/runtime/helpers/extends";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
5
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
6
- import _createClass from "@babel/runtime/helpers/createClass";
7
- import _callSuper from "@babel/runtime/helpers/callSuper";
8
- import _inherits from "@babel/runtime/helpers/inherits";
9
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
3
  import { sstyled as _sstyled } from "@semcore/core";
11
4
  import { assignProps as _assignProps } from "@semcore/core";
12
- var _excluded = ["focusLock"];
13
5
  import { Animation, Box, Flex, Portal } from '@semcore/base-components';
14
6
  import Button from '@semcore/button';
15
7
  import { createComponent, Component, sstyled, Root } from '@semcore/core';
@@ -26,169 +18,158 @@ import CloseIcon from '@semcore/icon/Close/m';
26
18
  import React from 'react';
27
19
  import manager from './NoticeBubbleManager';
28
20
  /*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
29
- var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@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}", /*__inner_css_end__*/"3nrqr_gg_"),
21
+ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@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}", /*__inner_css_end__*/"htjmd_gg_"),
30
22
  /*__reshadow_css_end__*/
31
23
  {
32
- "__SContent": "___SContent_3nrqr_gg_",
33
- "__SMessage": "___SMessage_3nrqr_gg_",
34
- "__SDismiss": "___SDismiss_3nrqr_gg_",
35
- "_use": "__use_3nrqr_gg_",
36
- "__SIcon": "___SIcon_3nrqr_gg_",
37
- "__SNoticeBubble": "___SNoticeBubble_3nrqr_gg_",
38
- "_disablePortal": "__disablePortal_3nrqr_gg_",
39
- "__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_3nrqr_gg_",
40
- "@enter": "enter_3nrqr",
41
- "@exit": "exit_3nrqr",
42
- "__SBubble": "___SBubble_3nrqr_gg_",
43
- "__SView": "___SView_3nrqr_gg_",
44
- "_type_info": "_type_info_3nrqr_gg_",
45
- "_type_warning": "_type_warning_3nrqr_gg_"
24
+ "__SContent": "___SContent_htjmd_gg_",
25
+ "__SMessage": "___SMessage_htjmd_gg_",
26
+ "__SDismiss": "___SDismiss_htjmd_gg_",
27
+ "_use": "__use_htjmd_gg_",
28
+ "__SIcon": "___SIcon_htjmd_gg_",
29
+ "__SNoticeBubble": "___SNoticeBubble_htjmd_gg_",
30
+ "_disablePortal": "__disablePortal_htjmd_gg_",
31
+ "__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_htjmd_gg_",
32
+ "@enter": "enter_htjmd",
33
+ "@exit": "exit_htjmd",
34
+ "__SBubble": "___SBubble_htjmd_gg_",
35
+ "__SView": "___SView_htjmd_gg_",
36
+ "_type_info": "_type_info_htjmd_gg_",
37
+ "_type_warning": "_type_warning_htjmd_gg_"
46
38
  });
47
39
  import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
48
40
  import { Timer } from './utils';
49
- var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
50
- function NoticeBubbleContainerRoot() {
51
- var _this;
52
- _classCallCheck(this, NoticeBubbleContainerRoot);
53
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
- args[_key] = arguments[_key];
55
- }
56
- _this = _callSuper(this, NoticeBubbleContainerRoot, [].concat(args));
57
- _defineProperty(_this, "_unsubscribe", null);
58
- _defineProperty(_this, "state", {
41
+ class NoticeBubbleContainerRoot extends Component {
42
+ constructor(...args) {
43
+ super(...args);
44
+ _defineProperty(this, "_unsubscribe", null);
45
+ _defineProperty(this, "state", {
59
46
  notices: [],
60
47
  infos: [],
61
48
  warnings: []
62
49
  });
63
- _defineProperty(_this, "componentWillUnmount", function () {
64
- if (_this._unsubscribe) {
65
- _this._unsubscribe();
50
+ _defineProperty(this, "componentWillUnmount", () => {
51
+ if (this._unsubscribe) {
52
+ this._unsubscribe();
66
53
  }
67
54
  });
68
- _defineProperty(_this, "handleChange", function (notices) {
69
- _this.setState({
70
- notices: notices
55
+ _defineProperty(this, "handleChange", notices => {
56
+ this.setState({
57
+ notices
71
58
  });
72
- _this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
59
+ this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
73
60
  });
74
- return _this;
75
61
  }
76
- _inherits(NoticeBubbleContainerRoot, _Component);
77
- return _createClass(NoticeBubbleContainerRoot, [{
78
- key: "componentDidMount",
79
- value: function componentDidMount() {
80
- this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
81
- }
82
- }, {
83
- key: "render",
84
- value: function render() {
85
- var _ref = this.asProps,
86
- _ref3;
87
- var SNoticeBubble = Box;
88
- var SNoticeAriaLiveWrapper = 'div';
89
- var _this$asProps = this.asProps,
90
- Children = _this$asProps.Children,
91
- styles = _this$asProps.styles,
92
- disablePortal = _this$asProps.disablePortal,
93
- getI18nText = _this$asProps.getI18nText,
94
- ref = _this$asProps.ref,
95
- parentZIndexStacking = _this$asProps.parentZIndexStacking,
96
- duration = _this$asProps.duration,
97
- containerNode = _this$asProps.containerNode;
98
- var notices = this.state.notices;
99
- if (containerNode) {
100
- return notices.map(function (notice) {
101
- var _ref2;
102
- var SView = notice.type === 'warning' ? ViewWarning : ViewInfo;
103
- return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(PortalForNoticeItem, _ref2.cn("PortalForNoticeItem", _objectSpread({
104
- "key": notice.uid,
105
- "tag": SView,
106
- "containerNode": containerNode,
107
- "animationDuration": duration,
108
- "styles": styles,
109
- "getI18nText": getI18nText
110
- }, notice)));
111
- });
112
- }
113
- var infos = notices.filter(function (notice) {
114
- return notice.type === 'info';
115
- });
116
- var warnings = notices.filter(function (notice) {
117
- return notice.type === 'warning';
62
+ componentDidMount() {
63
+ this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
64
+ }
65
+ render() {
66
+ var _ref = this.asProps,
67
+ _ref3;
68
+ const SNoticeBubble = Box;
69
+ const SNoticeAriaLiveWrapper = 'div';
70
+ const {
71
+ Children,
72
+ styles,
73
+ disablePortal,
74
+ getI18nText,
75
+ ref,
76
+ parentZIndexStacking,
77
+ duration,
78
+ containerNode
79
+ } = this.asProps;
80
+ const {
81
+ notices
82
+ } = this.state;
83
+ if (containerNode) {
84
+ return notices.map(notice => {
85
+ var _ref2;
86
+ const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;
87
+ return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(PortalForNoticeItem, _ref2.cn("PortalForNoticeItem", {
88
+ "key": notice.uid,
89
+ "tag": SView,
90
+ "containerNode": containerNode,
91
+ "animationDuration": duration,
92
+ "styles": styles,
93
+ "getI18nText": getI18nText,
94
+ ...notice
95
+ }));
118
96
  });
119
- return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
120
- "designToken": 'z-index-notice-bubble'
121
- }), /*#__PURE__*/React.createElement(Portal, _ref3.cn("Portal", {
122
- "disablePortal": disablePortal
123
- }), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", _objectSpread({}, _assignProps({
97
+ }
98
+ const infos = notices.filter(notice => notice.type === 'info');
99
+ const warnings = notices.filter(notice => notice.type === 'warning');
100
+ return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
101
+ "designToken": 'z-index-notice-bubble'
102
+ }), /*#__PURE__*/React.createElement(Portal, _ref3.cn("Portal", {
103
+ "disablePortal": disablePortal
104
+ }), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", {
105
+ ..._assignProps({
124
106
  "ref": ref,
125
107
  "tag": 'section',
126
108
  "role": 'region',
127
109
  "aria-label": getI18nText('notification'),
128
110
  "zIndex": parentZIndexStacking
129
- }, _ref))), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})), warnings.map(function (notice) {
130
- var _ref4;
131
- var SView = ViewWarning;
132
- return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref4.cn("SView", _objectSpread({
133
- "key": notice.uid,
134
- "animationDuration": duration,
135
- "styles": styles,
136
- "getI18nText": getI18nText
137
- }, notice)));
138
- }), /*#__PURE__*/React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
139
- "aria-live": 'polite'
140
- }), infos.map(function (notice) {
141
- var _ref5;
142
- var SView = ViewInfo;
143
- return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref5.cn("SView", _objectSpread({
144
- "key": notice.uid,
145
- "animationDuration": duration,
146
- "styles": styles,
147
- "getI18nText": getI18nText
148
- }, notice)));
149
- })))));
150
- }
151
- }]);
152
- }(Component);
111
+ }, _ref)
112
+ }), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})), warnings.map(notice => {
113
+ var _ref4;
114
+ const SView = ViewWarning;
115
+ return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref4.cn("SView", {
116
+ "key": notice.uid,
117
+ "animationDuration": duration,
118
+ "styles": styles,
119
+ "getI18nText": getI18nText,
120
+ ...notice
121
+ }));
122
+ }), /*#__PURE__*/React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
123
+ "aria-live": 'polite'
124
+ }), infos.map(notice => {
125
+ var _ref5;
126
+ const SView = ViewInfo;
127
+ return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref5.cn("SView", {
128
+ "key": notice.uid,
129
+ "animationDuration": duration,
130
+ "styles": styles,
131
+ "getI18nText": getI18nText,
132
+ ...notice
133
+ }));
134
+ })))));
135
+ }
136
+ }
153
137
  _defineProperty(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
154
138
  _defineProperty(NoticeBubbleContainerRoot, "style", style);
155
139
  _defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance('z-index-notice-bubble'), cssVariableEnhance({
156
140
  variable: '--intergalactic-duration-popper',
157
141
  fallback: 200,
158
- map: function map(v) {
159
- return Number.parseInt(v, 10);
160
- },
142
+ map: v => Number.parseInt(v, 10),
161
143
  prop: 'duration'
162
144
  })]);
163
145
  _defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
164
- manager: manager,
146
+ manager,
165
147
  i18n: localizedMessages,
166
148
  locale: 'en'
167
149
  });
168
- var FocusLock = /*#__PURE__*/React.forwardRef(function (props, outerRef) {
169
- var focusLock = props.focusLock,
170
- other = _objectWithoutProperties(props, _excluded);
171
- var innerRef = React.useRef(null);
150
+ const FocusLock = /*#__PURE__*/React.forwardRef((props, outerRef) => {
151
+ const {
152
+ focusLock,
153
+ ...other
154
+ } = props;
155
+ const innerRef = React.useRef(null);
172
156
  useFocusLock(innerRef, false, 'auto', !focusLock, true);
173
- var ref = useForkRef(outerRef, innerRef);
157
+ const ref = useForkRef(outerRef, innerRef);
174
158
  return /*#__PURE__*/React.createElement(Flex, _extends({
175
159
  ref: ref
176
160
  }, other));
177
161
  });
178
- var PortalForNoticeItem = function PortalForNoticeItem(props) {
179
- var _React$useState = React.useState(false),
180
- _React$useState2 = _slicedToArray(_React$useState, 2),
181
- showContent = _React$useState2[0],
182
- setShowContent = _React$useState2[1];
162
+ const PortalForNoticeItem = props => {
163
+ const [showContent, setShowContent] = React.useState(false);
183
164
 
184
165
  // Show content for info notice in previously mounted node with aria-live polite
185
- React.useEffect(function () {
186
- setTimeout(function () {
166
+ React.useEffect(() => {
167
+ setTimeout(() => {
187
168
  setShowContent(true);
188
169
  }, 200);
189
170
  }, []);
190
- var SNoticeAriaLiveWrapper = 'div';
191
- var Tag = props.tag;
171
+ const SNoticeAriaLiveWrapper = 'div';
172
+ const Tag = props.tag;
192
173
  if (props.type === 'info') {
193
174
  return /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, {
194
175
  designToken: "z-index-notice-bubble"
@@ -204,209 +185,121 @@ var PortalForNoticeItem = function PortalForNoticeItem(props) {
204
185
  nodeToMount: props.containerNode
205
186
  }, /*#__PURE__*/React.createElement(Tag, props)));
206
187
  };
207
- var ViewInfo = /*#__PURE__*/function (_Component2) {
208
- function ViewInfo() {
209
- var _this2;
210
- _classCallCheck(this, ViewInfo);
211
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
212
- args[_key2] = arguments[_key2];
213
- }
214
- _this2 = _callSuper(this, ViewInfo, [].concat(args));
215
- _defineProperty(_this2, "timer", null);
216
- _defineProperty(_this2, "ref", /*#__PURE__*/React.createRef());
217
- _defineProperty(_this2, "closeButtonRef", /*#__PURE__*/React.createRef());
218
- _defineProperty(_this2, "handleClose", function (e) {
188
+ class ViewInfo extends Component {
189
+ constructor(...args) {
190
+ super(...args);
191
+ _defineProperty(this, "timer", null);
192
+ _defineProperty(this, "ref", /*#__PURE__*/React.createRef());
193
+ _defineProperty(this, "closeButtonRef", /*#__PURE__*/React.createRef());
194
+ _defineProperty(this, "handleClose", e => {
219
195
  // because it might be called not only from the close icon click
220
- fire(_this2, 'onClose', e);
221
- _this2.clearTimer();
196
+ fire(this, 'onClose', e);
197
+ this.clearTimer();
222
198
  });
223
- _defineProperty(_this2, "handleKeydown", function (e) {
199
+ _defineProperty(this, "handleKeydown", e => {
224
200
  if (e.key === 'Escape') {
225
- _this2.handleClose(e);
201
+ this.handleClose(e);
226
202
  }
227
203
  });
228
- _defineProperty(_this2, "handleMouseEnter", function () {
229
- if (!_this2.timer) return;
230
- _this2.timer.pause();
204
+ _defineProperty(this, "handleMouseEnter", () => {
205
+ if (!this.timer) return;
206
+ this.timer.pause();
231
207
  });
232
- _defineProperty(_this2, "handleMouseLeave", function () {
233
- if (!_this2.timer) return;
234
- _this2.timer.resume();
208
+ _defineProperty(this, "handleMouseLeave", () => {
209
+ if (!this.timer) return;
210
+ this.timer.resume();
235
211
  });
236
- _defineProperty(_this2, "handleBodyMouseMove", function (event) {
237
- var _this2$timer, _this2$ref$current;
238
- if (!((_this2$timer = _this2.timer) !== null && _this2$timer !== void 0 && _this2$timer.paused)) return;
239
- var rect = (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getBoundingClientRect();
212
+ _defineProperty(this, "handleBodyMouseMove", event => {
213
+ if (!this.timer?.paused) return;
214
+ const rect = this.ref.current?.getBoundingClientRect();
240
215
  if (!rect) return;
241
- var mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
216
+ const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
242
217
  if (mouseInRect) return;
243
- _this2.timer.resume();
218
+ this.timer.resume();
244
219
  });
245
- return _this2;
246
220
  }
247
- _inherits(ViewInfo, _Component2);
248
- return _createClass(ViewInfo, [{
249
- key: "componentDidMount",
250
- value: function componentDidMount() {
251
- var _this3 = this;
252
- var duration = this.props.duration;
253
- if (duration) {
254
- this.timer = new Timer(this.handleClose, duration);
255
- document.body.addEventListener('mousemove', this.handleBodyMouseMove);
256
- }
257
- var noticeElement = this.ref.current;
258
- if (noticeElement) {
259
- var focusableNodes = getFocusableIn(noticeElement).filter(function (node) {
260
- return node !== _this3.closeButtonRef.current;
261
- });
262
- if (focusableNodes.length > 0) {
263
- setTimeout(function () {
264
- return setFocus(noticeElement);
265
- }, 0);
266
- }
267
- }
268
- }
269
- }, {
270
- key: "componentWillUnmount",
271
- value: function componentWillUnmount() {
272
- this.clearTimer();
273
- document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
221
+ componentDidMount() {
222
+ const {
223
+ duration
224
+ } = this.props;
225
+ if (duration) {
226
+ this.timer = new Timer(this.handleClose, duration);
227
+ document.body.addEventListener('mousemove', this.handleBodyMouseMove);
274
228
  }
275
- }, {
276
- key: "clearTimer",
277
- value: function clearTimer() {
278
- if (this.timer) {
279
- this.timer.clear();
280
- this.timer = null;
229
+ const noticeElement = this.ref.current;
230
+ if (noticeElement) {
231
+ const focusableNodes = getFocusableIn(noticeElement).filter(node => node !== this.closeButtonRef.current);
232
+ if (focusableNodes.length > 0) {
233
+ setTimeout(() => setFocus(noticeElement), 0);
281
234
  }
282
235
  }
283
- }, {
284
- key: "render",
285
- value: function render() {
286
- var _ref6;
287
- var SBubble = FocusLock;
288
- var SDismiss = Button;
289
- var SContent = Flex;
290
- var SMessage = 'div';
291
- var SAction = 'div';
292
- var SIcon = Flex;
293
- var _this$props = this.props,
294
- styles = _this$props.styles,
295
- getI18nText = _this$props.getI18nText,
296
- visible = _this$props.visible,
297
- type = _this$props.type,
298
- initialAnimation = _this$props.initialAnimation,
299
- animationDuration = _this$props.animationDuration,
300
- icon = _this$props.icon,
301
- children = _this$props.children,
302
- action = _this$props.action,
303
- focusLock = _this$props.focusLock;
304
- return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(Animation, _ref6.cn("Animation", {
305
- "initialAnimation": initialAnimation,
306
- "visible": visible !== null && visible !== void 0 ? visible : true,
307
- "duration": animationDuration,
308
- "keyframes": [styles['@enter'], styles['@exit']]
309
- }), /*#__PURE__*/React.createElement(SBubble, _ref6.cn("SBubble", {
310
- "type": type,
311
- "ref": this.ref,
312
- "onMouseEnter": this.handleMouseEnter,
313
- "onMouseLeave": this.handleMouseLeave,
314
- "onKeyDown": this.handleKeydown,
315
- "role": type === 'warning' ? 'alert' : undefined,
316
- "focusLock": focusLock
317
- }), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
318
- "aria-haspopup": undefined,
319
- "type": 'button',
320
- "use": 'tertiary',
321
- "size": 'm',
322
- "theme": 'invert',
323
- "onClick": this.handleClose,
324
- "aria-label": getI18nText('close'),
325
- "active": false,
326
- "title": getI18nText('close'),
327
- "ref": this.closeButtonRef,
328
- "data-hide-focus-hover-popper": 'true'
329
- }), /*#__PURE__*/React.createElement(Button.Addon, {
330
- tag: CloseIcon,
331
- color: "icon-primary-invert"
332
- })), 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)));
333
- }
334
- }]);
335
- }(Component);
336
- var ViewWarning = /*#__PURE__*/function (_ViewInfo2) {
337
- function ViewWarning() {
338
- _classCallCheck(this, ViewWarning);
339
- return _callSuper(this, ViewWarning, arguments);
340
236
  }
341
- _inherits(ViewWarning, _ViewInfo2);
342
- return _createClass(ViewWarning);
343
- }(ViewInfo);
344
- _defineProperty(ViewWarning, "defaultProps", {
345
- type: 'warning',
346
- duration: 0
347
- });
348
- var NoticeBubbleView = /*#__PURE__*/function (_Component3) {
349
- function NoticeBubbleView() {
350
- var _this4;
351
- _classCallCheck(this, NoticeBubbleView);
352
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
353
- args[_key3] = arguments[_key3];
354
- }
355
- _this4 = _callSuper(this, NoticeBubbleView, [].concat(args));
356
- _defineProperty(_this4, "_notice", null);
357
- return _this4;
237
+ componentWillUnmount() {
238
+ this.clearTimer();
239
+ document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
358
240
  }
359
- _inherits(NoticeBubbleView, _Component3);
360
- return _createClass(NoticeBubbleView, [{
361
- key: "componentDidMount",
362
- value: function componentDidMount() {
363
- this._notice = this.asProps.manager.add(this.asProps);
241
+ clearTimer() {
242
+ if (this.timer) {
243
+ this.timer.clear();
244
+ this.timer = null;
364
245
  }
365
- }, {
366
- key: "componentWillUnmount",
367
- value: function componentWillUnmount() {
368
- if (this._notice) {
369
- this._notice.remove();
370
- }
371
- }
372
- }, {
373
- key: "componentDidUpdate",
374
- value: function componentDidUpdate() {
375
- if (this._notice) {
376
- this._notice.update(this.asProps);
377
- }
378
- }
379
- }, {
380
- key: "render",
381
- value: function render() {
382
- return null;
383
- }
384
- }]);
385
- }(Component);
386
- _defineProperty(NoticeBubbleView, "defaultProps", {
387
- duration: 5000,
388
- type: 'info',
389
- manager: manager
390
- });
391
- var NoticeBubbleWarningView = /*#__PURE__*/function (_NoticeBubbleView2) {
392
- function NoticeBubbleWarningView() {
393
- _classCallCheck(this, NoticeBubbleWarningView);
394
- return _callSuper(this, NoticeBubbleWarningView, arguments);
395
246
  }
396
- _inherits(NoticeBubbleWarningView, _NoticeBubbleView2);
397
- return _createClass(NoticeBubbleWarningView);
398
- }(NoticeBubbleView);
399
- _defineProperty(NoticeBubbleWarningView, "defaultProps", {
400
- duration: 5000,
247
+ render() {
248
+ var _ref6;
249
+ const SBubble = FocusLock;
250
+ const SDismiss = Button;
251
+ const SContent = Flex;
252
+ const SMessage = 'div';
253
+ const SAction = 'div';
254
+ const SIcon = Flex;
255
+ const {
256
+ styles,
257
+ getI18nText,
258
+ visible,
259
+ type,
260
+ initialAnimation,
261
+ animationDuration,
262
+ icon,
263
+ children,
264
+ action,
265
+ focusLock
266
+ } = this.props;
267
+ return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(Animation, _ref6.cn("Animation", {
268
+ "initialAnimation": initialAnimation,
269
+ "visible": visible ?? true,
270
+ "duration": animationDuration,
271
+ "keyframes": [styles['@enter'], styles['@exit']]
272
+ }), /*#__PURE__*/React.createElement(SBubble, _ref6.cn("SBubble", {
273
+ "type": type,
274
+ "ref": this.ref,
275
+ "onMouseEnter": this.handleMouseEnter,
276
+ "onMouseLeave": this.handleMouseLeave,
277
+ "onKeyDown": this.handleKeydown,
278
+ "role": type === 'warning' ? 'alert' : undefined,
279
+ "focusLock": focusLock
280
+ }), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
281
+ "aria-haspopup": undefined,
282
+ "type": 'button',
283
+ "use": 'tertiary',
284
+ "size": 'm',
285
+ "theme": 'invert',
286
+ "onClick": this.handleClose,
287
+ "aria-label": getI18nText('close'),
288
+ "active": false,
289
+ "title": getI18nText('close'),
290
+ "ref": this.closeButtonRef,
291
+ "data-hide-focus-hover-popper": 'true'
292
+ }), /*#__PURE__*/React.createElement(Button.Addon, {
293
+ tag: CloseIcon,
294
+ color: "icon-primary-invert"
295
+ })), 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)));
296
+ }
297
+ }
298
+ class ViewWarning extends ViewInfo {}
299
+ _defineProperty(ViewWarning, "defaultProps", {
401
300
  type: 'warning',
402
- manager: manager
403
- });
404
- var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
405
- Info: NoticeBubbleView,
406
- Warning: NoticeBubbleWarningView
301
+ duration: 0
407
302
  });
408
- var NoticeBubble = NoticeBubbleContainer.Info;
409
- var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
410
- export { NoticeBubble, NoticeBubbleWarning };
303
+ const NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot);
411
304
  export default NoticeBubbleContainer;
412
305
  //# sourceMappingURL=NoticeBubble.js.map