@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,18 +1,11 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = exports.NoticeBubbleWarning = exports.NoticeBubble = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
+ exports.default = void 0;
9
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
15
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
16
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
10
  var _core = require("@semcore/core");
18
11
  var _baseComponents = require("@semcore/base-components");
@@ -31,386 +24,287 @@ var _react = _interopRequireDefault(require("react"));
31
24
  var _NoticeBubbleManager = _interopRequireDefault(require("./NoticeBubbleManager"));
32
25
  var _intergalacticDynamicLocales = require("./translations/__intergalactic-dynamic-locales");
33
26
  var _utils = require("./utils");
34
- var _excluded = ["focusLock"];
35
27
  /*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
36
- var style = (/*__reshadow_css_start__*/_core.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_"),
28
+ const style = (/*__reshadow_css_start__*/_core.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_"),
37
29
  /*__reshadow_css_end__*/
38
30
  {
39
- "__SContent": "___SContent_3nrqr_gg_",
40
- "__SMessage": "___SMessage_3nrqr_gg_",
41
- "__SDismiss": "___SDismiss_3nrqr_gg_",
42
- "_use": "__use_3nrqr_gg_",
43
- "__SIcon": "___SIcon_3nrqr_gg_",
44
- "__SNoticeBubble": "___SNoticeBubble_3nrqr_gg_",
45
- "_disablePortal": "__disablePortal_3nrqr_gg_",
46
- "__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_3nrqr_gg_",
47
- "@enter": "enter_3nrqr",
48
- "@exit": "exit_3nrqr",
49
- "__SBubble": "___SBubble_3nrqr_gg_",
50
- "__SView": "___SView_3nrqr_gg_",
51
- "_type_info": "_type_info_3nrqr_gg_",
52
- "_type_warning": "_type_warning_3nrqr_gg_"
31
+ "__SContent": "___SContent_htjmd_gg_",
32
+ "__SMessage": "___SMessage_htjmd_gg_",
33
+ "__SDismiss": "___SDismiss_htjmd_gg_",
34
+ "_use": "__use_htjmd_gg_",
35
+ "__SIcon": "___SIcon_htjmd_gg_",
36
+ "__SNoticeBubble": "___SNoticeBubble_htjmd_gg_",
37
+ "_disablePortal": "__disablePortal_htjmd_gg_",
38
+ "__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_htjmd_gg_",
39
+ "@enter": "enter_htjmd",
40
+ "@exit": "exit_htjmd",
41
+ "__SBubble": "___SBubble_htjmd_gg_",
42
+ "__SView": "___SView_htjmd_gg_",
43
+ "_type_info": "_type_info_htjmd_gg_",
44
+ "_type_warning": "_type_warning_htjmd_gg_"
53
45
  });
54
- var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
55
- function NoticeBubbleContainerRoot() {
56
- var _this;
57
- (0, _classCallCheck2["default"])(this, NoticeBubbleContainerRoot);
58
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
59
- args[_key] = arguments[_key];
60
- }
61
- _this = (0, _callSuper2["default"])(this, NoticeBubbleContainerRoot, [].concat(args));
62
- (0, _defineProperty2["default"])(_this, "_unsubscribe", null);
63
- (0, _defineProperty2["default"])(_this, "state", {
46
+ class NoticeBubbleContainerRoot extends _core.Component {
47
+ constructor(...args) {
48
+ super(...args);
49
+ (0, _defineProperty2.default)(this, "_unsubscribe", null);
50
+ (0, _defineProperty2.default)(this, "state", {
64
51
  notices: [],
65
52
  infos: [],
66
53
  warnings: []
67
54
  });
68
- (0, _defineProperty2["default"])(_this, "componentWillUnmount", function () {
69
- if (_this._unsubscribe) {
70
- _this._unsubscribe();
55
+ (0, _defineProperty2.default)(this, "componentWillUnmount", () => {
56
+ if (this._unsubscribe) {
57
+ this._unsubscribe();
71
58
  }
72
59
  });
73
- (0, _defineProperty2["default"])(_this, "handleChange", function (notices) {
74
- _this.setState({
75
- notices: notices
60
+ (0, _defineProperty2.default)(this, "handleChange", notices => {
61
+ this.setState({
62
+ notices
76
63
  });
77
- _this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
64
+ this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
78
65
  });
79
- return _this;
80
66
  }
81
- (0, _inherits2["default"])(NoticeBubbleContainerRoot, _Component);
82
- return (0, _createClass2["default"])(NoticeBubbleContainerRoot, [{
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,
91
- _ref3;
92
- var SNoticeBubble = _baseComponents.Box;
93
- var SNoticeAriaLiveWrapper = 'div';
94
- var _this$asProps = this.asProps,
95
- Children = _this$asProps.Children,
96
- styles = _this$asProps.styles,
97
- disablePortal = _this$asProps.disablePortal,
98
- getI18nText = _this$asProps.getI18nText,
99
- ref = _this$asProps.ref,
100
- parentZIndexStacking = _this$asProps.parentZIndexStacking,
101
- duration = _this$asProps.duration,
102
- containerNode = _this$asProps.containerNode;
103
- var notices = this.state.notices;
104
- if (containerNode) {
105
- return notices.map(function (notice) {
106
- var _ref2;
107
- var SView = notice.type === 'warning' ? ViewWarning : ViewInfo;
108
- return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(PortalForNoticeItem, _ref2.cn("PortalForNoticeItem", (0, _objectSpread2["default"])({
109
- "key": notice.uid,
110
- "tag": SView,
111
- "containerNode": containerNode,
112
- "animationDuration": duration,
113
- "styles": styles,
114
- "getI18nText": getI18nText
115
- }, notice)));
116
- });
117
- }
118
- var infos = notices.filter(function (notice) {
119
- return notice.type === 'info';
120
- });
121
- var warnings = notices.filter(function (notice) {
122
- return notice.type === 'warning';
67
+ componentDidMount() {
68
+ this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
69
+ }
70
+ render() {
71
+ var _ref = this.asProps,
72
+ _ref3;
73
+ const SNoticeBubble = _baseComponents.Box;
74
+ const SNoticeAriaLiveWrapper = 'div';
75
+ const {
76
+ Children,
77
+ styles,
78
+ disablePortal,
79
+ getI18nText,
80
+ ref,
81
+ parentZIndexStacking,
82
+ duration,
83
+ containerNode
84
+ } = this.asProps;
85
+ const {
86
+ notices
87
+ } = this.state;
88
+ if (containerNode) {
89
+ return notices.map(notice => {
90
+ var _ref2;
91
+ const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;
92
+ return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(PortalForNoticeItem, _ref2.cn("PortalForNoticeItem", {
93
+ "key": notice.uid,
94
+ "tag": SView,
95
+ "containerNode": containerNode,
96
+ "animationDuration": duration,
97
+ "styles": styles,
98
+ "getI18nText": getI18nText,
99
+ ...notice
100
+ }));
123
101
  });
124
- return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_zIndexStacking.ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
125
- "designToken": 'z-index-notice-bubble'
126
- }), /*#__PURE__*/_react["default"].createElement(_baseComponents.Portal, _ref3.cn("Portal", {
127
- "disablePortal": disablePortal
128
- }), /*#__PURE__*/_react["default"].createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
102
+ }
103
+ const infos = notices.filter(notice => notice.type === 'info');
104
+ const warnings = notices.filter(notice => notice.type === 'warning');
105
+ return _ref3 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_zIndexStacking.ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
106
+ "designToken": 'z-index-notice-bubble'
107
+ }), /*#__PURE__*/_react.default.createElement(_baseComponents.Portal, _ref3.cn("Portal", {
108
+ "disablePortal": disablePortal
109
+ }), /*#__PURE__*/_react.default.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", {
110
+ ...(0, _core.assignProps)({
129
111
  "ref": ref,
130
112
  "tag": 'section',
131
113
  "role": 'region',
132
114
  "aria-label": getI18nText('notification'),
133
115
  "zIndex": parentZIndexStacking
134
- }, _ref))), /*#__PURE__*/_react["default"].createElement(Children, _ref3.cn("Children", {})), warnings.map(function (notice) {
135
- var _ref4;
136
- var SView = ViewWarning;
137
- return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SView, _ref4.cn("SView", (0, _objectSpread2["default"])({
138
- "key": notice.uid,
139
- "animationDuration": duration,
140
- "styles": styles,
141
- "getI18nText": getI18nText
142
- }, notice)));
143
- }), /*#__PURE__*/_react["default"].createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
144
- "aria-live": 'polite'
145
- }), infos.map(function (notice) {
146
- var _ref5;
147
- var SView = ViewInfo;
148
- return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SView, _ref5.cn("SView", (0, _objectSpread2["default"])({
149
- "key": notice.uid,
150
- "animationDuration": duration,
151
- "styles": styles,
152
- "getI18nText": getI18nText
153
- }, notice)));
154
- })))));
155
- }
156
- }]);
157
- }(_core.Component);
158
- (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
159
- (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "style", style);
160
- (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "enhance", [(0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages), (0, _ThemeProvider.contextThemeEnhance)(), (0, _zIndexStacking.zIndexStackingEnhance)('z-index-notice-bubble'), (0, _useCssVariable.cssVariableEnhance)({
116
+ }, _ref)
117
+ }), /*#__PURE__*/_react.default.createElement(Children, _ref3.cn("Children", {})), warnings.map(notice => {
118
+ var _ref4;
119
+ const SView = ViewWarning;
120
+ return _ref4 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SView, _ref4.cn("SView", {
121
+ "key": notice.uid,
122
+ "animationDuration": duration,
123
+ "styles": styles,
124
+ "getI18nText": getI18nText,
125
+ ...notice
126
+ }));
127
+ }), /*#__PURE__*/_react.default.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
128
+ "aria-live": 'polite'
129
+ }), infos.map(notice => {
130
+ var _ref5;
131
+ const SView = ViewInfo;
132
+ return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SView, _ref5.cn("SView", {
133
+ "key": notice.uid,
134
+ "animationDuration": duration,
135
+ "styles": styles,
136
+ "getI18nText": getI18nText,
137
+ ...notice
138
+ }));
139
+ })))));
140
+ }
141
+ }
142
+ (0, _defineProperty2.default)(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
143
+ (0, _defineProperty2.default)(NoticeBubbleContainerRoot, "style", style);
144
+ (0, _defineProperty2.default)(NoticeBubbleContainerRoot, "enhance", [(0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages), (0, _ThemeProvider.contextThemeEnhance)(), (0, _zIndexStacking.zIndexStackingEnhance)('z-index-notice-bubble'), (0, _useCssVariable.cssVariableEnhance)({
161
145
  variable: '--intergalactic-duration-popper',
162
146
  fallback: 200,
163
- map: function map(v) {
164
- return Number.parseInt(v, 10);
165
- },
147
+ map: v => Number.parseInt(v, 10),
166
148
  prop: 'duration'
167
149
  })]);
168
- (0, _defineProperty2["default"])(NoticeBubbleContainerRoot, "defaultProps", {
169
- manager: _NoticeBubbleManager["default"],
150
+ (0, _defineProperty2.default)(NoticeBubbleContainerRoot, "defaultProps", {
151
+ manager: _NoticeBubbleManager.default,
170
152
  i18n: _intergalacticDynamicLocales.localizedMessages,
171
153
  locale: 'en'
172
154
  });
173
- var FocusLock = /*#__PURE__*/_react["default"].forwardRef(function (props, outerRef) {
174
- var focusLock = props.focusLock,
175
- other = (0, _objectWithoutProperties2["default"])(props, _excluded);
176
- var innerRef = _react["default"].useRef(null);
155
+ const FocusLock = /*#__PURE__*/_react.default.forwardRef((props, outerRef) => {
156
+ const {
157
+ focusLock,
158
+ ...other
159
+ } = props;
160
+ const innerRef = _react.default.useRef(null);
177
161
  (0, _useFocusLock.useFocusLock)(innerRef, false, 'auto', !focusLock, true);
178
- var ref = (0, _ref7.useForkRef)(outerRef, innerRef);
179
- return /*#__PURE__*/_react["default"].createElement(_baseComponents.Flex, (0, _extends2["default"])({
162
+ const ref = (0, _ref7.useForkRef)(outerRef, innerRef);
163
+ return /*#__PURE__*/_react.default.createElement(_baseComponents.Flex, (0, _extends2.default)({
180
164
  ref: ref
181
165
  }, other));
182
166
  });
183
- var PortalForNoticeItem = function PortalForNoticeItem(props) {
184
- var _React$useState = _react["default"].useState(false),
185
- _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
186
- showContent = _React$useState2[0],
187
- setShowContent = _React$useState2[1];
167
+ const PortalForNoticeItem = props => {
168
+ const [showContent, setShowContent] = _react.default.useState(false);
188
169
 
189
170
  // Show content for info notice in previously mounted node with aria-live polite
190
- _react["default"].useEffect(function () {
191
- setTimeout(function () {
171
+ _react.default.useEffect(() => {
172
+ setTimeout(() => {
192
173
  setShowContent(true);
193
174
  }, 200);
194
175
  }, []);
195
- var SNoticeAriaLiveWrapper = 'div';
196
- var Tag = props.tag;
176
+ const SNoticeAriaLiveWrapper = 'div';
177
+ const Tag = props.tag;
197
178
  if (props.type === 'info') {
198
- return /*#__PURE__*/_react["default"].createElement(_zIndexStacking.ZIndexStackingContextProvider, {
179
+ return /*#__PURE__*/_react.default.createElement(_zIndexStacking.ZIndexStackingContextProvider, {
199
180
  designToken: "z-index-notice-bubble"
200
- }, /*#__PURE__*/_react["default"].createElement(_baseComponents.Portal, {
181
+ }, /*#__PURE__*/_react.default.createElement(_baseComponents.Portal, {
201
182
  nodeToMount: props.containerNode
202
- }, /*#__PURE__*/_react["default"].createElement(SNoticeAriaLiveWrapper, {
183
+ }, /*#__PURE__*/_react.default.createElement(SNoticeAriaLiveWrapper, {
203
184
  "aria-live": "polite"
204
- }, showContent && /*#__PURE__*/_react["default"].createElement(Tag, props))));
185
+ }, showContent && /*#__PURE__*/_react.default.createElement(Tag, props))));
205
186
  }
206
- return /*#__PURE__*/_react["default"].createElement(_zIndexStacking.ZIndexStackingContextProvider, {
187
+ return /*#__PURE__*/_react.default.createElement(_zIndexStacking.ZIndexStackingContextProvider, {
207
188
  designToken: "z-index-notice-bubble"
208
- }, /*#__PURE__*/_react["default"].createElement(_baseComponents.Portal, {
189
+ }, /*#__PURE__*/_react.default.createElement(_baseComponents.Portal, {
209
190
  nodeToMount: props.containerNode
210
- }, /*#__PURE__*/_react["default"].createElement(Tag, props)));
191
+ }, /*#__PURE__*/_react.default.createElement(Tag, props)));
211
192
  };
212
- var ViewInfo = /*#__PURE__*/function (_Component2) {
213
- function ViewInfo() {
214
- var _this2;
215
- (0, _classCallCheck2["default"])(this, ViewInfo);
216
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
217
- args[_key2] = arguments[_key2];
218
- }
219
- _this2 = (0, _callSuper2["default"])(this, ViewInfo, [].concat(args));
220
- (0, _defineProperty2["default"])(_this2, "timer", null);
221
- (0, _defineProperty2["default"])(_this2, "ref", /*#__PURE__*/_react["default"].createRef());
222
- (0, _defineProperty2["default"])(_this2, "closeButtonRef", /*#__PURE__*/_react["default"].createRef());
223
- (0, _defineProperty2["default"])(_this2, "handleClose", function (e) {
193
+ class ViewInfo extends _core.Component {
194
+ constructor(...args) {
195
+ super(...args);
196
+ (0, _defineProperty2.default)(this, "timer", null);
197
+ (0, _defineProperty2.default)(this, "ref", /*#__PURE__*/_react.default.createRef());
198
+ (0, _defineProperty2.default)(this, "closeButtonRef", /*#__PURE__*/_react.default.createRef());
199
+ (0, _defineProperty2.default)(this, "handleClose", e => {
224
200
  // because it might be called not only from the close icon click
225
- (0, _fire["default"])(_this2, 'onClose', e);
226
- _this2.clearTimer();
201
+ (0, _fire.default)(this, 'onClose', e);
202
+ this.clearTimer();
227
203
  });
228
- (0, _defineProperty2["default"])(_this2, "handleKeydown", function (e) {
204
+ (0, _defineProperty2.default)(this, "handleKeydown", e => {
229
205
  if (e.key === 'Escape') {
230
- _this2.handleClose(e);
206
+ this.handleClose(e);
231
207
  }
232
208
  });
233
- (0, _defineProperty2["default"])(_this2, "handleMouseEnter", function () {
234
- if (!_this2.timer) return;
235
- _this2.timer.pause();
209
+ (0, _defineProperty2.default)(this, "handleMouseEnter", () => {
210
+ if (!this.timer) return;
211
+ this.timer.pause();
236
212
  });
237
- (0, _defineProperty2["default"])(_this2, "handleMouseLeave", function () {
238
- if (!_this2.timer) return;
239
- _this2.timer.resume();
213
+ (0, _defineProperty2.default)(this, "handleMouseLeave", () => {
214
+ if (!this.timer) return;
215
+ this.timer.resume();
240
216
  });
241
- (0, _defineProperty2["default"])(_this2, "handleBodyMouseMove", function (event) {
242
- var _this2$timer, _this2$ref$current;
243
- if (!((_this2$timer = _this2.timer) !== null && _this2$timer !== void 0 && _this2$timer.paused)) return;
244
- var rect = (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getBoundingClientRect();
217
+ (0, _defineProperty2.default)(this, "handleBodyMouseMove", event => {
218
+ if (!this.timer?.paused) return;
219
+ const rect = this.ref.current?.getBoundingClientRect();
245
220
  if (!rect) return;
246
- var mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
221
+ const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
247
222
  if (mouseInRect) return;
248
- _this2.timer.resume();
223
+ this.timer.resume();
249
224
  });
250
- return _this2;
251
225
  }
252
- (0, _inherits2["default"])(ViewInfo, _Component2);
253
- return (0, _createClass2["default"])(ViewInfo, [{
254
- key: "componentDidMount",
255
- value: function componentDidMount() {
256
- var _this3 = this;
257
- var duration = this.props.duration;
258
- if (duration) {
259
- this.timer = new _utils.Timer(this.handleClose, duration);
260
- document.body.addEventListener('mousemove', this.handleBodyMouseMove);
261
- }
262
- var noticeElement = this.ref.current;
263
- if (noticeElement) {
264
- var focusableNodes = (0, _getFocusableIn.getFocusableIn)(noticeElement).filter(function (node) {
265
- return node !== _this3.closeButtonRef.current;
266
- });
267
- if (focusableNodes.length > 0) {
268
- setTimeout(function () {
269
- return (0, _useFocusLock.setFocus)(noticeElement);
270
- }, 0);
271
- }
272
- }
226
+ componentDidMount() {
227
+ const {
228
+ duration
229
+ } = this.props;
230
+ if (duration) {
231
+ this.timer = new _utils.Timer(this.handleClose, duration);
232
+ document.body.addEventListener('mousemove', this.handleBodyMouseMove);
273
233
  }
274
- }, {
275
- key: "componentWillUnmount",
276
- value: function componentWillUnmount() {
277
- this.clearTimer();
278
- document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
279
- }
280
- }, {
281
- key: "clearTimer",
282
- value: function clearTimer() {
283
- if (this.timer) {
284
- this.timer.clear();
285
- this.timer = null;
234
+ const noticeElement = this.ref.current;
235
+ if (noticeElement) {
236
+ const focusableNodes = (0, _getFocusableIn.getFocusableIn)(noticeElement).filter(node => node !== this.closeButtonRef.current);
237
+ if (focusableNodes.length > 0) {
238
+ setTimeout(() => (0, _useFocusLock.setFocus)(noticeElement), 0);
286
239
  }
287
240
  }
288
- }, {
289
- key: "render",
290
- value: function render() {
291
- var _ref6;
292
- var SBubble = FocusLock;
293
- var SDismiss = _button["default"];
294
- var SContent = _baseComponents.Flex;
295
- var SMessage = 'div';
296
- var SAction = 'div';
297
- var SIcon = _baseComponents.Flex;
298
- var _this$props = this.props,
299
- styles = _this$props.styles,
300
- getI18nText = _this$props.getI18nText,
301
- visible = _this$props.visible,
302
- type = _this$props.type,
303
- initialAnimation = _this$props.initialAnimation,
304
- animationDuration = _this$props.animationDuration,
305
- icon = _this$props.icon,
306
- children = _this$props.children,
307
- action = _this$props.action,
308
- focusLock = _this$props.focusLock;
309
- return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_baseComponents.Animation, _ref6.cn("Animation", {
310
- "initialAnimation": initialAnimation,
311
- "visible": visible !== null && visible !== void 0 ? visible : true,
312
- "duration": animationDuration,
313
- "keyframes": [styles['@enter'], styles['@exit']]
314
- }), /*#__PURE__*/_react["default"].createElement(SBubble, _ref6.cn("SBubble", {
315
- "type": type,
316
- "ref": this.ref,
317
- "onMouseEnter": this.handleMouseEnter,
318
- "onMouseLeave": this.handleMouseLeave,
319
- "onKeyDown": this.handleKeydown,
320
- "role": type === 'warning' ? 'alert' : undefined,
321
- "focusLock": focusLock
322
- }), /*#__PURE__*/_react["default"].createElement(SDismiss, _ref6.cn("SDismiss", {
323
- "aria-haspopup": undefined,
324
- "type": 'button',
325
- "use": 'tertiary',
326
- "size": 'm',
327
- "theme": 'invert',
328
- "onClick": this.handleClose,
329
- "aria-label": getI18nText('close'),
330
- "active": false,
331
- "title": getI18nText('close'),
332
- "ref": this.closeButtonRef,
333
- "data-hide-focus-hover-popper": 'true'
334
- }), /*#__PURE__*/_react["default"].createElement(_button["default"].Addon, {
335
- tag: _m["default"],
336
- color: "icon-primary-invert"
337
- })), (0, _isNode["default"])(icon) ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(SIcon, _ref6.cn("SIcon", {}), icon), /*#__PURE__*/_react["default"].createElement(SContent, _ref6.cn("SContent", {}), /*#__PURE__*/_react["default"].createElement(SMessage, _ref6.cn("SMessage", {}), children), (0, _isNode["default"])(action) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref6.cn("SAction", {}), action) : null)) : /*#__PURE__*/_react["default"].createElement(SContent, _ref6.cn("SContent", {}), /*#__PURE__*/_react["default"].createElement(SMessage, _ref6.cn("SMessage", {}), children), (0, _isNode["default"])(action) ? /*#__PURE__*/_react["default"].createElement(SAction, _ref6.cn("SAction", {}), action) : null)));
338
- }
339
- }]);
340
- }(_core.Component);
341
- var ViewWarning = /*#__PURE__*/function (_ViewInfo2) {
342
- function ViewWarning() {
343
- (0, _classCallCheck2["default"])(this, ViewWarning);
344
- return (0, _callSuper2["default"])(this, ViewWarning, arguments);
345
241
  }
346
- (0, _inherits2["default"])(ViewWarning, _ViewInfo2);
347
- return (0, _createClass2["default"])(ViewWarning);
348
- }(ViewInfo);
349
- (0, _defineProperty2["default"])(ViewWarning, "defaultProps", {
350
- type: 'warning',
351
- duration: 0
352
- });
353
- var NoticeBubbleView = /*#__PURE__*/function (_Component3) {
354
- function NoticeBubbleView() {
355
- var _this4;
356
- (0, _classCallCheck2["default"])(this, NoticeBubbleView);
357
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
358
- args[_key3] = arguments[_key3];
359
- }
360
- _this4 = (0, _callSuper2["default"])(this, NoticeBubbleView, [].concat(args));
361
- (0, _defineProperty2["default"])(_this4, "_notice", null);
362
- return _this4;
242
+ componentWillUnmount() {
243
+ this.clearTimer();
244
+ document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
363
245
  }
364
- (0, _inherits2["default"])(NoticeBubbleView, _Component3);
365
- return (0, _createClass2["default"])(NoticeBubbleView, [{
366
- key: "componentDidMount",
367
- value: function componentDidMount() {
368
- this._notice = this.asProps.manager.add(this.asProps);
246
+ clearTimer() {
247
+ if (this.timer) {
248
+ this.timer.clear();
249
+ this.timer = null;
369
250
  }
370
- }, {
371
- key: "componentWillUnmount",
372
- value: function componentWillUnmount() {
373
- if (this._notice) {
374
- this._notice.remove();
375
- }
376
- }
377
- }, {
378
- key: "componentDidUpdate",
379
- value: function componentDidUpdate() {
380
- if (this._notice) {
381
- this._notice.update(this.asProps);
382
- }
383
- }
384
- }, {
385
- key: "render",
386
- value: function render() {
387
- return null;
388
- }
389
- }]);
390
- }(_core.Component);
391
- (0, _defineProperty2["default"])(NoticeBubbleView, "defaultProps", {
392
- duration: 5000,
393
- type: 'info',
394
- manager: _NoticeBubbleManager["default"]
395
- });
396
- var NoticeBubbleWarningView = /*#__PURE__*/function (_NoticeBubbleView2) {
397
- function NoticeBubbleWarningView() {
398
- (0, _classCallCheck2["default"])(this, NoticeBubbleWarningView);
399
- return (0, _callSuper2["default"])(this, NoticeBubbleWarningView, arguments);
400
251
  }
401
- (0, _inherits2["default"])(NoticeBubbleWarningView, _NoticeBubbleView2);
402
- return (0, _createClass2["default"])(NoticeBubbleWarningView);
403
- }(NoticeBubbleView);
404
- (0, _defineProperty2["default"])(NoticeBubbleWarningView, "defaultProps", {
405
- duration: 5000,
252
+ render() {
253
+ var _ref6;
254
+ const SBubble = FocusLock;
255
+ const SDismiss = _button.default;
256
+ const SContent = _baseComponents.Flex;
257
+ const SMessage = 'div';
258
+ const SAction = 'div';
259
+ const SIcon = _baseComponents.Flex;
260
+ const {
261
+ styles,
262
+ getI18nText,
263
+ visible,
264
+ type,
265
+ initialAnimation,
266
+ animationDuration,
267
+ icon,
268
+ children,
269
+ action,
270
+ focusLock
271
+ } = this.props;
272
+ return _ref6 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_baseComponents.Animation, _ref6.cn("Animation", {
273
+ "initialAnimation": initialAnimation,
274
+ "visible": visible ?? true,
275
+ "duration": animationDuration,
276
+ "keyframes": [styles['@enter'], styles['@exit']]
277
+ }), /*#__PURE__*/_react.default.createElement(SBubble, _ref6.cn("SBubble", {
278
+ "type": type,
279
+ "ref": this.ref,
280
+ "onMouseEnter": this.handleMouseEnter,
281
+ "onMouseLeave": this.handleMouseLeave,
282
+ "onKeyDown": this.handleKeydown,
283
+ "role": type === 'warning' ? 'alert' : undefined,
284
+ "focusLock": focusLock
285
+ }), /*#__PURE__*/_react.default.createElement(SDismiss, _ref6.cn("SDismiss", {
286
+ "aria-haspopup": undefined,
287
+ "type": 'button',
288
+ "use": 'tertiary',
289
+ "size": 'm',
290
+ "theme": 'invert',
291
+ "onClick": this.handleClose,
292
+ "aria-label": getI18nText('close'),
293
+ "active": false,
294
+ "title": getI18nText('close'),
295
+ "ref": this.closeButtonRef,
296
+ "data-hide-focus-hover-popper": 'true'
297
+ }), /*#__PURE__*/_react.default.createElement(_button.default.Addon, {
298
+ tag: _m.default,
299
+ color: "icon-primary-invert"
300
+ })), (0, _isNode.default)(icon) ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SIcon, _ref6.cn("SIcon", {}), icon), /*#__PURE__*/_react.default.createElement(SContent, _ref6.cn("SContent", {}), /*#__PURE__*/_react.default.createElement(SMessage, _ref6.cn("SMessage", {}), children), (0, _isNode.default)(action) ? /*#__PURE__*/_react.default.createElement(SAction, _ref6.cn("SAction", {}), action) : null)) : /*#__PURE__*/_react.default.createElement(SContent, _ref6.cn("SContent", {}), /*#__PURE__*/_react.default.createElement(SMessage, _ref6.cn("SMessage", {}), children), (0, _isNode.default)(action) ? /*#__PURE__*/_react.default.createElement(SAction, _ref6.cn("SAction", {}), action) : null)));
301
+ }
302
+ }
303
+ class ViewWarning extends ViewInfo {}
304
+ (0, _defineProperty2.default)(ViewWarning, "defaultProps", {
406
305
  type: 'warning',
407
- manager: _NoticeBubbleManager["default"]
408
- });
409
- var NoticeBubbleContainer = (0, _core.createComponent)(NoticeBubbleContainerRoot, {
410
- Info: NoticeBubbleView,
411
- Warning: NoticeBubbleWarningView
306
+ duration: 0
412
307
  });
413
- var NoticeBubble = exports.NoticeBubble = NoticeBubbleContainer.Info;
414
- var NoticeBubbleWarning = exports.NoticeBubbleWarning = NoticeBubbleContainer.Warning;
415
- var _default = exports["default"] = NoticeBubbleContainer;
308
+ const NoticeBubbleContainer = (0, _core.createComponent)(NoticeBubbleContainerRoot);
309
+ var _default = exports.default = NoticeBubbleContainer;
416
310
  //# sourceMappingURL=NoticeBubble.js.map