@semcore/notice-bubble 5.54.2-prerelease.0 → 5.55.0-prerelease.0
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.
- package/CHANGELOG.md +6 -0
- package/lib/cjs/NoticeBubble.js +177 -217
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubble.type.js +2 -0
- package/lib/cjs/NoticeBubble.type.js.map +1 -0
- package/lib/cjs/NoticeBubbleManager.js +34 -56
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.js +1 -4
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/notice-bubble.shadow.css +4 -4
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +4 -5
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils.js +20 -9
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/NoticeBubble.js +170 -207
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.type.js +2 -0
- package/lib/es6/NoticeBubble.type.js.map +1 -0
- package/lib/es6/NoticeBubbleManager.js +31 -51
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/lib/es6/index.js +1 -2
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/notice-bubble.shadow.css +4 -4
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils.js +18 -6
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +175 -215
- package/lib/esm/NoticeBubbleManager.mjs +33 -53
- package/lib/esm/index.mjs +3 -7
- package/lib/esm/style/notice-bubble.shadow.css +4 -4
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/esm/utils.mjs +20 -8
- package/lib/types/NoticeBubble.d.ts +4 -0
- package/lib/types/NoticeBubble.type.d.ts +91 -0
- package/lib/types/NoticeBubbleManager.d.ts +22 -0
- package/lib/types/index.d.ts +7 -167
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +58 -0
- package/lib/types/utils.d.ts +14 -0
- package/package.json +9 -9
- package/lib/cjs/index.d.js +0 -2
- package/lib/cjs/index.d.js.map +0 -1
- package/lib/es6/index.d.js +0 -2
- package/lib/es6/index.d.js.map +0 -1
package/lib/es6/NoticeBubble.js
CHANGED
|
@@ -1,118 +1,80 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
5
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
6
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import
|
|
7
|
+
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
6
8
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
import
|
|
10
|
-
import { sstyled as _sstyled } from "@semcore/utils/lib/core/index";
|
|
10
|
+
import { sstyled as _sstyled } from "@semcore/core";
|
|
11
11
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
|
-
var _excluded = ["focusLock"]
|
|
13
|
-
|
|
12
|
+
var _excluded = ["focusLock"];
|
|
13
|
+
import { Animation, Box, Flex, Portal } from '@semcore/base-components';
|
|
14
|
+
import Button from '@semcore/button';
|
|
15
|
+
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
16
|
+
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
17
|
+
import fire from '@semcore/core/lib/utils/fire';
|
|
18
|
+
import { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';
|
|
19
|
+
import isNode from '@semcore/core/lib/utils/isNode';
|
|
20
|
+
import { useForkRef } from '@semcore/core/lib/utils/ref';
|
|
21
|
+
import { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';
|
|
22
|
+
import { useFocusLock, setFocus } from '@semcore/core/lib/utils/use/useFocusLock';
|
|
23
|
+
import { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';
|
|
24
|
+
import { ZIndexStackingContextProvider, zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';
|
|
25
|
+
import CloseIcon from '@semcore/icon/Close/m';
|
|
14
26
|
import React from 'react';
|
|
15
|
-
import Portal from '@semcore/portal';
|
|
16
27
|
import manager from './NoticeBubbleManager';
|
|
17
|
-
import createComponent, { Component, sstyled, Root } from '@semcore/core';
|
|
18
|
-
import { Animation } from '@semcore/animation';
|
|
19
|
-
import { Flex, Box } from '@semcore/flex-box';
|
|
20
|
-
import fire from '@semcore/utils/lib/fire';
|
|
21
|
-
import isNode from '@semcore/utils/lib/isNode';
|
|
22
|
-
import { callAllEventHandlers } from '@semcore/utils/lib/assignProps';
|
|
23
|
-
import CloseIcon from '@semcore/icon/Close/m';
|
|
24
|
-
import { Timer } from './utils';
|
|
25
|
-
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
26
|
-
import i18nEnhance from '@semcore/utils/lib/enhances/i18nEnhance';
|
|
27
|
-
import { useCssVariable } from '@semcore/utils/lib/useCssVariable';
|
|
28
|
-
import { contextThemeEnhance } from '@semcore/utils/lib/ThemeProvider';
|
|
29
|
-
import Button from '@semcore/button';
|
|
30
|
-
import { useFocusLock } from '@semcore/utils/lib/use/useFocusLock';
|
|
31
|
-
import { Hint } from '@semcore/tooltip';
|
|
32
|
-
import { ZIndexStackingContextProvider, zIndexStackingEnhance } from '@semcore/utils/lib/zIndexStacking';
|
|
33
28
|
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
34
|
-
var style = (
|
|
29
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/"@keyframes enter_19cf4{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_19cf4{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_19cf4_gg_,.___SView_19cf4_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, rgba(254, 255, 255, 0.949));gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_19cf4_gg_._type_info_19cf4_gg_,.___SView_19cf4_gg_._type_info_19cf4_gg_{background:var(--intergalactic-bg-primary-invert, rgb(26, 30, 26))}.___SBubble_19cf4_gg_._type_warning_19cf4_gg_,.___SView_19cf4_gg_._type_warning_19cf4_gg_{background:var(--intergalactic-bg-primary-critical, rgb(247, 55, 64))}.___SContent_19cf4_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_19cf4_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_19cf4_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_19cf4_gg_.__use_19cf4_gg_{padding:0 1px}.___SIcon_19cf4_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_19cf4_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_19cf4_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_19cf4_gg_.__disablePortal_19cf4_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_19cf4_gg_ a{color:var(--intergalactic-text-link-invert, rgb(135, 171, 255))}@supports (color:color(display-p3 0 0 0%)){.___SMessage_19cf4_gg_ a{color:var(--intergalactic-text-link-invert, rgb(135, 171, 255))}@media (color-gamut:p3){.___SMessage_19cf4_gg_ a{color:var(--intergalactic-text-link-invert, color(display-p3 0.55796 0.66814 0.97583))}}}.___SNoticeAriaLiveWrapper_19cf4_gg_{display:contents}", /*__inner_css_end__*/"19cf4_gg_"),
|
|
35
30
|
/*__reshadow_css_end__*/
|
|
36
31
|
{
|
|
37
|
-
"__SContent": "
|
|
38
|
-
"__SMessage": "
|
|
39
|
-
"__SDismiss": "
|
|
40
|
-
"_use": "
|
|
41
|
-
"__SIcon": "
|
|
42
|
-
"__SNoticeBubble": "
|
|
43
|
-
"_disablePortal": "
|
|
44
|
-
"__SNoticeAriaLiveWrapper": "
|
|
45
|
-
"@enter": "
|
|
46
|
-
"@exit": "
|
|
47
|
-
"__SBubble": "
|
|
48
|
-
"__SView": "
|
|
49
|
-
"_type_info": "
|
|
50
|
-
"_type_warning": "
|
|
32
|
+
"__SContent": "___SContent_19cf4_gg_",
|
|
33
|
+
"__SMessage": "___SMessage_19cf4_gg_",
|
|
34
|
+
"__SDismiss": "___SDismiss_19cf4_gg_",
|
|
35
|
+
"_use": "__use_19cf4_gg_",
|
|
36
|
+
"__SIcon": "___SIcon_19cf4_gg_",
|
|
37
|
+
"__SNoticeBubble": "___SNoticeBubble_19cf4_gg_",
|
|
38
|
+
"_disablePortal": "__disablePortal_19cf4_gg_",
|
|
39
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_19cf4_gg_",
|
|
40
|
+
"@enter": "enter_19cf4",
|
|
41
|
+
"@exit": "exit_19cf4",
|
|
42
|
+
"__SBubble": "___SBubble_19cf4_gg_",
|
|
43
|
+
"__SView": "___SView_19cf4_gg_",
|
|
44
|
+
"_type_info": "_type_info_19cf4_gg_",
|
|
45
|
+
"_type_warning": "_type_warning_19cf4_gg_"
|
|
51
46
|
});
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import { setFocus } from '@semcore/utils/lib/use/useFocusLock';
|
|
55
|
-
var Notices = function Notices(props) {
|
|
56
|
-
var styles = props.styles,
|
|
57
|
-
_props$data = props.data,
|
|
58
|
-
data = _props$data === void 0 ? [] : _props$data,
|
|
59
|
-
_props$tag = props.tag,
|
|
60
|
-
SView = _props$tag === void 0 ? ViewInfo : _props$tag;
|
|
61
|
-
var ref = React.useRef();
|
|
62
|
-
var durationStr = useCssVariable('--intergalactic-duration-popper', '200', ref);
|
|
63
|
-
var duration = React.useMemo(function () {
|
|
64
|
-
return parseInt(durationStr, 10);
|
|
65
|
-
}, [durationStr]);
|
|
66
|
-
return data.map(function (notice) {
|
|
67
|
-
var _ref2, _notice$visible;
|
|
68
|
-
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(Animation, _ref2.cn("Animation", {
|
|
69
|
-
"key": notice.uid,
|
|
70
|
-
"initialAnimation": notice.initialAnimation,
|
|
71
|
-
"visible": (_notice$visible = notice.visible) !== null && _notice$visible !== void 0 ? _notice$visible : true,
|
|
72
|
-
"duration": duration,
|
|
73
|
-
"keyframes": [styles['@enter'], styles['@exit']],
|
|
74
|
-
"ref": ref
|
|
75
|
-
}), /*#__PURE__*/React.createElement(SView, _ref2.cn("SView", _objectSpread(_objectSpread({}, notice), {}, {
|
|
76
|
-
"styles": notice.styles || styles,
|
|
77
|
-
"getI18nText": props.getI18nText
|
|
78
|
-
}))));
|
|
79
|
-
});
|
|
80
|
-
};
|
|
47
|
+
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
48
|
+
import { Timer } from './utils';
|
|
81
49
|
var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
82
|
-
_inherits(NoticeBubbleContainerRoot, _Component);
|
|
83
|
-
var _super = _createSuper(NoticeBubbleContainerRoot);
|
|
84
50
|
function NoticeBubbleContainerRoot() {
|
|
85
51
|
var _this;
|
|
86
52
|
_classCallCheck(this, NoticeBubbleContainerRoot);
|
|
87
53
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
88
54
|
args[_key] = arguments[_key];
|
|
89
55
|
}
|
|
90
|
-
_this =
|
|
91
|
-
_defineProperty(
|
|
92
|
-
_defineProperty(
|
|
56
|
+
_this = _callSuper(this, NoticeBubbleContainerRoot, [].concat(args));
|
|
57
|
+
_defineProperty(_this, "_unsubscribe", null);
|
|
58
|
+
_defineProperty(_this, "state", {
|
|
93
59
|
notices: [],
|
|
60
|
+
infos: [],
|
|
94
61
|
warnings: []
|
|
95
62
|
});
|
|
96
|
-
_defineProperty(
|
|
63
|
+
_defineProperty(_this, "componentWillUnmount", function () {
|
|
97
64
|
if (_this._unsubscribe) {
|
|
98
65
|
_this._unsubscribe();
|
|
99
66
|
}
|
|
100
67
|
});
|
|
101
|
-
_defineProperty(
|
|
102
|
-
var info = notices.filter(function (notice) {
|
|
103
|
-
return notice.type === 'info';
|
|
104
|
-
});
|
|
105
|
-
var warning = notices.filter(function (notice) {
|
|
106
|
-
return notice.type === 'warning';
|
|
107
|
-
});
|
|
68
|
+
_defineProperty(_this, "handleChange", function (notices) {
|
|
108
69
|
_this.setState({
|
|
109
|
-
notices:
|
|
110
|
-
warnings: warning
|
|
70
|
+
notices: notices
|
|
111
71
|
});
|
|
72
|
+
_this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
|
|
112
73
|
});
|
|
113
74
|
return _this;
|
|
114
75
|
}
|
|
115
|
-
|
|
76
|
+
_inherits(NoticeBubbleContainerRoot, _Component);
|
|
77
|
+
return _createClass(NoticeBubbleContainerRoot, [{
|
|
116
78
|
key: "componentDidMount",
|
|
117
79
|
value: function componentDidMount() {
|
|
118
80
|
this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
|
|
@@ -130,10 +92,30 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
130
92
|
disablePortal = _this$asProps.disablePortal,
|
|
131
93
|
getI18nText = _this$asProps.getI18nText,
|
|
132
94
|
ref = _this$asProps.ref,
|
|
133
|
-
parentZIndexStacking = _this$asProps.parentZIndexStacking
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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';
|
|
118
|
+
});
|
|
137
119
|
return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
|
|
138
120
|
"designToken": 'z-index-notice-bubble'
|
|
139
121
|
}), /*#__PURE__*/React.createElement(Portal, _ref3.cn("Portal", {
|
|
@@ -144,26 +126,40 @@ var NoticeBubbleContainerRoot = /*#__PURE__*/function (_Component) {
|
|
|
144
126
|
"role": 'region',
|
|
145
127
|
"aria-label": getI18nText('notification'),
|
|
146
128
|
"zIndex": parentZIndexStacking
|
|
147
|
-
}, _ref))), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
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", {
|
|
153
139
|
"aria-live": 'polite'
|
|
154
|
-
}),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
|
|
159
|
-
|
|
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
|
+
})))));
|
|
160
150
|
}
|
|
161
151
|
}]);
|
|
162
|
-
return NoticeBubbleContainerRoot;
|
|
163
152
|
}(Component);
|
|
164
153
|
_defineProperty(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
|
|
165
154
|
_defineProperty(NoticeBubbleContainerRoot, "style", style);
|
|
166
|
-
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance('z-index-notice-bubble')
|
|
155
|
+
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance('z-index-notice-bubble'), cssVariableEnhance({
|
|
156
|
+
variable: '--intergalactic-duration-popper',
|
|
157
|
+
fallback: 200,
|
|
158
|
+
map: function map(v) {
|
|
159
|
+
return Number.parseInt(v, 10);
|
|
160
|
+
},
|
|
161
|
+
prop: 'duration'
|
|
162
|
+
})]);
|
|
167
163
|
_defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
168
164
|
manager: manager,
|
|
169
165
|
i18n: localizedMessages,
|
|
@@ -172,55 +168,84 @@ _defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
|
172
168
|
var FocusLock = /*#__PURE__*/React.forwardRef(function (props, outerRef) {
|
|
173
169
|
var focusLock = props.focusLock,
|
|
174
170
|
other = _objectWithoutProperties(props, _excluded);
|
|
175
|
-
var innerRef = React.useRef();
|
|
171
|
+
var innerRef = React.useRef(null);
|
|
176
172
|
useFocusLock(innerRef, false, 'auto', !focusLock, true);
|
|
177
173
|
var ref = useForkRef(outerRef, innerRef);
|
|
178
174
|
return /*#__PURE__*/React.createElement(Flex, _extends({
|
|
179
175
|
ref: ref
|
|
180
176
|
}, other));
|
|
181
177
|
});
|
|
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];
|
|
183
|
+
|
|
184
|
+
// Show content for info notice in previously mounted node with aria-live polite
|
|
185
|
+
React.useEffect(function () {
|
|
186
|
+
setTimeout(function () {
|
|
187
|
+
setShowContent(true);
|
|
188
|
+
}, 200);
|
|
189
|
+
}, []);
|
|
190
|
+
var SNoticeAriaLiveWrapper = 'div';
|
|
191
|
+
var Tag = props.tag;
|
|
192
|
+
if (props.type === 'info') {
|
|
193
|
+
return /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, {
|
|
194
|
+
designToken: "z-index-notice-bubble"
|
|
195
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
196
|
+
nodeToMount: props.containerNode
|
|
197
|
+
}, /*#__PURE__*/React.createElement(SNoticeAriaLiveWrapper, {
|
|
198
|
+
"aria-live": "polite"
|
|
199
|
+
}, showContent && /*#__PURE__*/React.createElement(Tag, props))));
|
|
200
|
+
}
|
|
201
|
+
return /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, {
|
|
202
|
+
designToken: "z-index-notice-bubble"
|
|
203
|
+
}, /*#__PURE__*/React.createElement(Portal, {
|
|
204
|
+
nodeToMount: props.containerNode
|
|
205
|
+
}, /*#__PURE__*/React.createElement(Tag, props)));
|
|
206
|
+
};
|
|
182
207
|
var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
183
|
-
_inherits(ViewInfo, _Component2);
|
|
184
|
-
var _super2 = _createSuper(ViewInfo);
|
|
185
208
|
function ViewInfo() {
|
|
186
209
|
var _this2;
|
|
187
210
|
_classCallCheck(this, ViewInfo);
|
|
188
211
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
189
212
|
args[_key2] = arguments[_key2];
|
|
190
213
|
}
|
|
191
|
-
_this2 =
|
|
192
|
-
_defineProperty(
|
|
193
|
-
_defineProperty(
|
|
194
|
-
_defineProperty(
|
|
195
|
-
_defineProperty(
|
|
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) {
|
|
196
219
|
// because it might be called not only from the close icon click
|
|
197
|
-
fire(
|
|
220
|
+
fire(_this2, 'onClose', e);
|
|
198
221
|
_this2.clearTimer();
|
|
199
222
|
});
|
|
200
|
-
_defineProperty(
|
|
223
|
+
_defineProperty(_this2, "handleKeydown", function (e) {
|
|
201
224
|
if (e.key === 'Escape') {
|
|
202
225
|
_this2.handleClose(e);
|
|
203
226
|
}
|
|
204
227
|
});
|
|
205
|
-
_defineProperty(
|
|
228
|
+
_defineProperty(_this2, "handleMouseEnter", function () {
|
|
206
229
|
if (!_this2.timer) return;
|
|
207
230
|
_this2.timer.pause();
|
|
208
231
|
});
|
|
209
|
-
_defineProperty(
|
|
232
|
+
_defineProperty(_this2, "handleMouseLeave", function () {
|
|
210
233
|
if (!_this2.timer) return;
|
|
211
234
|
_this2.timer.resume();
|
|
212
235
|
});
|
|
213
|
-
_defineProperty(
|
|
214
|
-
var _this2$timer;
|
|
236
|
+
_defineProperty(_this2, "handleBodyMouseMove", function (event) {
|
|
237
|
+
var _this2$timer, _this2$ref$current;
|
|
215
238
|
if (!((_this2$timer = _this2.timer) !== null && _this2$timer !== void 0 && _this2$timer.paused)) return;
|
|
216
|
-
var rect = _this2.ref.current.getBoundingClientRect();
|
|
239
|
+
var rect = (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getBoundingClientRect();
|
|
240
|
+
if (!rect) return;
|
|
217
241
|
var mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
218
242
|
if (mouseInRect) return;
|
|
219
243
|
_this2.timer.resume();
|
|
220
244
|
});
|
|
221
245
|
return _this2;
|
|
222
246
|
}
|
|
223
|
-
|
|
247
|
+
_inherits(ViewInfo, _Component2);
|
|
248
|
+
return _createClass(ViewInfo, [{
|
|
224
249
|
key: "componentDidMount",
|
|
225
250
|
value: function componentDidMount() {
|
|
226
251
|
var _this3 = this;
|
|
@@ -258,35 +283,39 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
|
258
283
|
}, {
|
|
259
284
|
key: "render",
|
|
260
285
|
value: function render() {
|
|
261
|
-
var
|
|
286
|
+
var _ref6;
|
|
262
287
|
var SBubble = FocusLock;
|
|
263
|
-
var SDismiss =
|
|
288
|
+
var SDismiss = Button;
|
|
264
289
|
var SContent = Flex;
|
|
265
290
|
var SMessage = 'div';
|
|
266
291
|
var SAction = 'div';
|
|
267
292
|
var SIcon = Flex;
|
|
268
293
|
var _this$props = this.props,
|
|
269
|
-
forwardRef = _this$props.forwardRef,
|
|
270
294
|
styles = _this$props.styles,
|
|
271
|
-
onMouseEnter = _this$props.onMouseEnter,
|
|
272
|
-
onMouseLeave = _this$props.onMouseLeave,
|
|
273
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,
|
|
274
300
|
icon = _this$props.icon,
|
|
275
301
|
children = _this$props.children,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
"
|
|
281
|
-
"
|
|
282
|
-
"
|
|
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,
|
|
283
314
|
"onKeyDown": this.handleKeydown,
|
|
284
|
-
"role": type === 'warning' ? 'alert' :
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
, _ref4.cn("SDismiss", {
|
|
315
|
+
"role": type === 'warning' ? 'alert' : undefined,
|
|
316
|
+
"focusLock": focusLock
|
|
317
|
+
}), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
|
|
288
318
|
"aria-haspopup": undefined,
|
|
289
|
-
"tag": Button,
|
|
290
319
|
"type": 'button',
|
|
291
320
|
"use": 'tertiary',
|
|
292
321
|
"size": 'm',
|
|
@@ -295,93 +324,27 @@ var ViewInfo = /*#__PURE__*/function (_Component2) {
|
|
|
295
324
|
"aria-label": getI18nText('close'),
|
|
296
325
|
"active": false,
|
|
297
326
|
"title": getI18nText('close'),
|
|
298
|
-
"ref": this.closeButtonRef
|
|
327
|
+
"ref": this.closeButtonRef,
|
|
328
|
+
"data-hide-focus-hover-popper": 'true'
|
|
299
329
|
}), /*#__PURE__*/React.createElement(Button.Addon, {
|
|
300
330
|
tag: CloseIcon,
|
|
301
331
|
color: "icon-primary-invert"
|
|
302
|
-
})), isNode(icon) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SIcon,
|
|
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)));
|
|
303
333
|
}
|
|
304
334
|
}]);
|
|
305
|
-
return ViewInfo;
|
|
306
335
|
}(Component);
|
|
307
|
-
var ViewWarning = /*#__PURE__*/function (
|
|
308
|
-
_inherits(ViewWarning, _ViewInfo);
|
|
309
|
-
var _super3 = _createSuper(ViewWarning);
|
|
336
|
+
var ViewWarning = /*#__PURE__*/function (_ViewInfo2) {
|
|
310
337
|
function ViewWarning() {
|
|
311
338
|
_classCallCheck(this, ViewWarning);
|
|
312
|
-
return
|
|
339
|
+
return _callSuper(this, ViewWarning, arguments);
|
|
313
340
|
}
|
|
341
|
+
_inherits(ViewWarning, _ViewInfo2);
|
|
314
342
|
return _createClass(ViewWarning);
|
|
315
343
|
}(ViewInfo);
|
|
316
344
|
_defineProperty(ViewWarning, "defaultProps", {
|
|
317
345
|
type: 'warning',
|
|
318
346
|
duration: 0
|
|
319
347
|
});
|
|
320
|
-
var
|
|
321
|
-
_inherits(NoticeBubbleView, _Component3);
|
|
322
|
-
var _super4 = _createSuper(NoticeBubbleView);
|
|
323
|
-
function NoticeBubbleView() {
|
|
324
|
-
var _this4;
|
|
325
|
-
_classCallCheck(this, NoticeBubbleView);
|
|
326
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
327
|
-
args[_key3] = arguments[_key3];
|
|
328
|
-
}
|
|
329
|
-
_this4 = _super4.call.apply(_super4, [this].concat(args));
|
|
330
|
-
_defineProperty(_assertThisInitialized(_this4), "_notice", null);
|
|
331
|
-
return _this4;
|
|
332
|
-
}
|
|
333
|
-
_createClass(NoticeBubbleView, [{
|
|
334
|
-
key: "componentDidMount",
|
|
335
|
-
value: function componentDidMount() {
|
|
336
|
-
this._notice = this.asProps.manager.add(this.asProps);
|
|
337
|
-
}
|
|
338
|
-
}, {
|
|
339
|
-
key: "componentWillUnmount",
|
|
340
|
-
value: function componentWillUnmount() {
|
|
341
|
-
if (this._notice) {
|
|
342
|
-
this._notice.remove();
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}, {
|
|
346
|
-
key: "componentDidUpdate",
|
|
347
|
-
value: function componentDidUpdate() {
|
|
348
|
-
if (this._notice) {
|
|
349
|
-
this._notice.update(this.asProps);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}, {
|
|
353
|
-
key: "render",
|
|
354
|
-
value: function render() {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
}]);
|
|
358
|
-
return NoticeBubbleView;
|
|
359
|
-
}(Component);
|
|
360
|
-
_defineProperty(NoticeBubbleView, "defaultProps", {
|
|
361
|
-
duration: 5000,
|
|
362
|
-
type: 'info',
|
|
363
|
-
manager: manager
|
|
364
|
-
});
|
|
365
|
-
var NoticeBubbleWarningView = /*#__PURE__*/function (_NoticeBubbleView) {
|
|
366
|
-
_inherits(NoticeBubbleWarningView, _NoticeBubbleView);
|
|
367
|
-
var _super5 = _createSuper(NoticeBubbleWarningView);
|
|
368
|
-
function NoticeBubbleWarningView() {
|
|
369
|
-
_classCallCheck(this, NoticeBubbleWarningView);
|
|
370
|
-
return _super5.apply(this, arguments);
|
|
371
|
-
}
|
|
372
|
-
return _createClass(NoticeBubbleWarningView);
|
|
373
|
-
}(NoticeBubbleView);
|
|
374
|
-
_defineProperty(NoticeBubbleWarningView, "defaultProps", {
|
|
375
|
-
duration: 5000,
|
|
376
|
-
type: 'warning',
|
|
377
|
-
manager: manager
|
|
378
|
-
});
|
|
379
|
-
var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
|
|
380
|
-
Info: NoticeBubbleView,
|
|
381
|
-
Warning: NoticeBubbleWarningView
|
|
382
|
-
});
|
|
383
|
-
var NoticeBubble = NoticeBubbleContainer.Info;
|
|
384
|
-
var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
|
|
385
|
-
export { NoticeBubble, NoticeBubbleWarning };
|
|
348
|
+
var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot);
|
|
386
349
|
export default NoticeBubbleContainer;
|
|
387
350
|
//# sourceMappingURL=NoticeBubble.js.map
|