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