@semcore/notice-bubble 5.55.0-prerelease.0 → 5.55.0-prerelease.4
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/lib/cjs/NoticeBubble.js +217 -177
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubbleManager.js +56 -34
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.d.js +2 -0
- package/lib/cjs/index.d.js.map +1 -0
- package/lib/cjs/index.js +4 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/notice-bubble.shadow.css +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +5 -4
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils.js +9 -20
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/NoticeBubble.js +207 -170
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubbleManager.js +51 -31
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/lib/es6/index.d.js +2 -0
- package/lib/es6/index.d.js.map +1 -0
- package/lib/es6/index.js +2 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/notice-bubble.shadow.css +1 -1
- 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 +6 -18
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +215 -175
- package/lib/esm/NoticeBubbleManager.mjs +53 -33
- package/lib/esm/index.mjs +7 -3
- package/lib/esm/style/notice-bubble.shadow.css +1 -1
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
- package/lib/esm/utils.mjs +8 -20
- package/lib/types/index.d.ts +167 -7
- package/package.json +9 -9
- package/lib/cjs/NoticeBubble.type.js +0 -2
- package/lib/cjs/NoticeBubble.type.js.map +0 -1
- package/lib/es6/NoticeBubble.type.js +0 -2
- package/lib/es6/NoticeBubble.type.js.map +0 -1
- package/lib/types/NoticeBubble.d.ts +0 -4
- package/lib/types/NoticeBubble.type.d.ts +0 -91
- package/lib/types/NoticeBubbleManager.d.ts +0 -22
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +0 -58
- package/lib/types/utils.d.ts +0 -14
package/lib/esm/NoticeBubble.mjs
CHANGED
|
@@ -1,85 +1,118 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
-
import
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
8
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
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";
|
|
9
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
|
+
import { sstyled } from "@semcore/utils/lib/core/index";
|
|
11
|
+
import createComponent, { sstyled as sstyled$1, assignProps, Component } from "@semcore/core";
|
|
23
12
|
import React from "react";
|
|
13
|
+
import Portal from "@semcore/portal";
|
|
24
14
|
import noticeBubbleDefaultManager from "./NoticeBubbleManager.mjs";
|
|
25
|
-
import {
|
|
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";
|
|
26
21
|
import { Timer } from "./utils.mjs";
|
|
27
|
-
|
|
22
|
+
import { localizedMessages } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
23
|
+
import i18nEnhance from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
24
|
+
import { useCssVariable } from "@semcore/utils/lib/useCssVariable";
|
|
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"];
|
|
28
33
|
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
29
34
|
var style = (
|
|
30
35
|
/*__reshadow_css_start__*/
|
|
31
36
|
(sstyled.insert(
|
|
32
37
|
/*__inner_css_start__*/
|
|
33
|
-
"@keyframes
|
|
38
|
+
"@keyframes enter_7ow1n{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_7ow1n{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_7ow1n_gg_,.___SView_7ow1n_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_7ow1n_gg_._type_info_7ow1n_gg_,.___SView_7ow1n_gg_._type_info_7ow1n_gg_{background:var(--intergalactic-bg-primary-invert, rgb(26, 30, 26))}.___SBubble_7ow1n_gg_._type_warning_7ow1n_gg_,.___SView_7ow1n_gg_._type_warning_7ow1n_gg_{background:var(--intergalactic-bg-primary-critical, rgb(247, 55, 64))}.___SContent_7ow1n_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_7ow1n_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_7ow1n_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_7ow1n_gg_.__use_7ow1n_gg_{padding:0 1px}.___SIcon_7ow1n_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_7ow1n_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_7ow1n_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_7ow1n_gg_.__disablePortal_7ow1n_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_7ow1n_gg_ a{color:var(--intergalactic-text-link-invert, rgb(136, 172, 253))}.___SNoticeAriaLiveWrapper_7ow1n_gg_{display:contents}",
|
|
34
39
|
/*__inner_css_end__*/
|
|
35
|
-
"
|
|
40
|
+
"7ow1n_gg_"
|
|
36
41
|
), /*__reshadow_css_end__*/
|
|
37
42
|
{
|
|
38
|
-
"__SContent": "
|
|
39
|
-
"__SMessage": "
|
|
40
|
-
"__SDismiss": "
|
|
41
|
-
"_use": "
|
|
42
|
-
"__SIcon": "
|
|
43
|
-
"__SNoticeBubble": "
|
|
44
|
-
"_disablePortal": "
|
|
45
|
-
"__SNoticeAriaLiveWrapper": "
|
|
46
|
-
"@enter": "
|
|
47
|
-
"@exit": "
|
|
48
|
-
"__SBubble": "
|
|
49
|
-
"__SView": "
|
|
50
|
-
"_type_info": "
|
|
51
|
-
"_type_warning": "
|
|
43
|
+
"__SContent": "___SContent_7ow1n_gg_",
|
|
44
|
+
"__SMessage": "___SMessage_7ow1n_gg_",
|
|
45
|
+
"__SDismiss": "___SDismiss_7ow1n_gg_",
|
|
46
|
+
"_use": "__use_7ow1n_gg_",
|
|
47
|
+
"__SIcon": "___SIcon_7ow1n_gg_",
|
|
48
|
+
"__SNoticeBubble": "___SNoticeBubble_7ow1n_gg_",
|
|
49
|
+
"_disablePortal": "__disablePortal_7ow1n_gg_",
|
|
50
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_7ow1n_gg_",
|
|
51
|
+
"@enter": "enter_7ow1n",
|
|
52
|
+
"@exit": "exit_7ow1n",
|
|
53
|
+
"__SBubble": "___SBubble_7ow1n_gg_",
|
|
54
|
+
"__SView": "___SView_7ow1n_gg_",
|
|
55
|
+
"_type_info": "_type_info_7ow1n_gg_",
|
|
56
|
+
"_type_warning": "_type_warning_7ow1n_gg_"
|
|
52
57
|
})
|
|
53
58
|
);
|
|
54
|
-
var
|
|
59
|
+
var Notices = function Notices2(props) {
|
|
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);
|
|
55
84
|
function NoticeBubbleContainerRoot2() {
|
|
56
85
|
var _this;
|
|
57
86
|
_classCallCheck(this, NoticeBubbleContainerRoot2);
|
|
58
87
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
59
88
|
args[_key] = arguments[_key];
|
|
60
89
|
}
|
|
61
|
-
_this =
|
|
62
|
-
_defineProperty(_this, "_unsubscribe", null);
|
|
63
|
-
_defineProperty(_this, "state", {
|
|
90
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "_unsubscribe", null);
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
64
93
|
notices: [],
|
|
65
|
-
infos: [],
|
|
66
94
|
warnings: []
|
|
67
95
|
});
|
|
68
|
-
_defineProperty(_this, "componentWillUnmount", function() {
|
|
96
|
+
_defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function() {
|
|
69
97
|
if (_this._unsubscribe) {
|
|
70
98
|
_this._unsubscribe();
|
|
71
99
|
}
|
|
72
100
|
});
|
|
73
|
-
_defineProperty(_this, "handleChange", function(notices) {
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function(notices) {
|
|
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
|
+
});
|
|
74
108
|
_this.setState({
|
|
75
|
-
notices
|
|
109
|
+
notices: info,
|
|
110
|
+
warnings: warning
|
|
76
111
|
});
|
|
77
|
-
_this.forceUpdate();
|
|
78
112
|
});
|
|
79
113
|
return _this;
|
|
80
114
|
}
|
|
81
|
-
|
|
82
|
-
return _createClass(NoticeBubbleContainerRoot2, [{
|
|
115
|
+
_createClass(NoticeBubbleContainerRoot2, [{
|
|
83
116
|
key: "componentDidMount",
|
|
84
117
|
value: function componentDidMount() {
|
|
85
118
|
this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
|
|
@@ -90,29 +123,9 @@ var NoticeBubbleContainerRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
90
123
|
var _ref = this.asProps, _ref3;
|
|
91
124
|
var SNoticeBubble = Box;
|
|
92
125
|
var SNoticeAriaLiveWrapper = "div";
|
|
93
|
-
var _this$asProps = this.asProps, Children = _this$asProps.Children, styles = _this$asProps.styles, disablePortal = _this$asProps.disablePortal, getI18nText = _this$asProps.getI18nText, ref = _this$asProps.ref, parentZIndexStacking = _this$asProps.parentZIndexStacking
|
|
94
|
-
var
|
|
95
|
-
|
|
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", {
|
|
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 _this$state = this.state, notices = _this$state.notices, warnings = _this$state.warnings;
|
|
128
|
+
return _ref3 = sstyled$1(styles), /* @__PURE__ */ React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
|
|
116
129
|
"designToken": "z-index-notice-bubble"
|
|
117
130
|
}), /* @__PURE__ */ React.createElement(Portal, _ref3.cn("Portal", {
|
|
118
131
|
"disablePortal": disablePortal
|
|
@@ -122,40 +135,26 @@ var NoticeBubbleContainerRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
122
135
|
"role": "region",
|
|
123
136
|
"aria-label": getI18nText("notification"),
|
|
124
137
|
"zIndex": parentZIndexStacking
|
|
125
|
-
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {})),
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"styles": styles,
|
|
132
|
-
"getI18nText": getI18nText
|
|
133
|
-
}, notice)));
|
|
134
|
-
}), /* @__PURE__ */ React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
|
|
138
|
+
}, _ref))), /* @__PURE__ */ React.createElement(Children, _ref3.cn("Children", {})), /* @__PURE__ */ React.createElement(Notices, _ref3.cn("Notices", {
|
|
139
|
+
"styles": styles,
|
|
140
|
+
"data": warnings,
|
|
141
|
+
"tag": ViewWarning,
|
|
142
|
+
"getI18nText": getI18nText
|
|
143
|
+
})), /* @__PURE__ */ React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
|
|
135
144
|
"aria-live": "polite"
|
|
136
|
-
}),
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
"styles": styles,
|
|
143
|
-
"getI18nText": getI18nText
|
|
144
|
-
}, notice)));
|
|
145
|
-
})))));
|
|
145
|
+
}), /* @__PURE__ */ React.createElement(Notices, _ref3.cn("Notices", {
|
|
146
|
+
"styles": styles,
|
|
147
|
+
"data": notices,
|
|
148
|
+
"tag": ViewInfo,
|
|
149
|
+
"getI18nText": getI18nText
|
|
150
|
+
}))))));
|
|
146
151
|
}
|
|
147
152
|
}]);
|
|
148
|
-
|
|
153
|
+
return NoticeBubbleContainerRoot2;
|
|
154
|
+
}(Component);
|
|
149
155
|
_defineProperty(NoticeBubbleContainerRoot, "displayName", "NoticeBubbleContainer");
|
|
150
156
|
_defineProperty(NoticeBubbleContainerRoot, "style", style);
|
|
151
|
-
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance("z-index-notice-bubble")
|
|
152
|
-
variable: "--intergalactic-duration-popper",
|
|
153
|
-
fallback: 200,
|
|
154
|
-
map: function map(v) {
|
|
155
|
-
return Number.parseInt(v, 10);
|
|
156
|
-
},
|
|
157
|
-
prop: "duration"
|
|
158
|
-
})]);
|
|
157
|
+
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance("z-index-notice-bubble")]);
|
|
159
158
|
_defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
160
159
|
manager: noticeBubbleDefaultManager,
|
|
161
160
|
i18n: localizedMessages,
|
|
@@ -163,78 +162,54 @@ _defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
|
163
162
|
});
|
|
164
163
|
var FocusLock = /* @__PURE__ */ React.forwardRef(function(props, outerRef) {
|
|
165
164
|
var focusLock = props.focusLock, other = _objectWithoutProperties(props, _excluded);
|
|
166
|
-
var innerRef = React.useRef(
|
|
165
|
+
var innerRef = React.useRef();
|
|
167
166
|
useFocusLock(innerRef, false, "auto", !focusLock, true);
|
|
168
167
|
var ref = useForkRef(outerRef, innerRef);
|
|
169
168
|
return /* @__PURE__ */ React.createElement(Flex, _extends({
|
|
170
169
|
ref
|
|
171
170
|
}, other));
|
|
172
171
|
});
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
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) {
|
|
172
|
+
var ViewInfo = /* @__PURE__ */ function(_Component2) {
|
|
173
|
+
_inherits(ViewInfo2, _Component2);
|
|
174
|
+
var _super2 = _createSuper(ViewInfo2);
|
|
198
175
|
function ViewInfo2() {
|
|
199
176
|
var _this2;
|
|
200
177
|
_classCallCheck(this, ViewInfo2);
|
|
201
178
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
202
179
|
args[_key2] = arguments[_key2];
|
|
203
180
|
}
|
|
204
|
-
_this2 =
|
|
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);
|
|
181
|
+
_this2 = _super2.call.apply(_super2, [this].concat(args));
|
|
182
|
+
_defineProperty(_assertThisInitialized(_this2), "timer", null);
|
|
183
|
+
_defineProperty(_assertThisInitialized(_this2), "ref", /* @__PURE__ */ React.createRef());
|
|
184
|
+
_defineProperty(_assertThisInitialized(_this2), "closeButtonRef", /* @__PURE__ */ React.createRef());
|
|
185
|
+
_defineProperty(_assertThisInitialized(_this2), "handleClose", function(e) {
|
|
186
|
+
fire(_assertThisInitialized(_this2), "onClose", e);
|
|
210
187
|
_this2.clearTimer();
|
|
211
188
|
});
|
|
212
|
-
_defineProperty(_this2, "handleKeydown", function(e) {
|
|
189
|
+
_defineProperty(_assertThisInitialized(_this2), "handleKeydown", function(e) {
|
|
213
190
|
if (e.key === "Escape") {
|
|
214
191
|
_this2.handleClose(e);
|
|
215
192
|
}
|
|
216
193
|
});
|
|
217
|
-
_defineProperty(_this2, "handleMouseEnter", function() {
|
|
194
|
+
_defineProperty(_assertThisInitialized(_this2), "handleMouseEnter", function() {
|
|
218
195
|
if (!_this2.timer) return;
|
|
219
196
|
_this2.timer.pause();
|
|
220
197
|
});
|
|
221
|
-
_defineProperty(_this2, "handleMouseLeave", function() {
|
|
198
|
+
_defineProperty(_assertThisInitialized(_this2), "handleMouseLeave", function() {
|
|
222
199
|
if (!_this2.timer) return;
|
|
223
200
|
_this2.timer.resume();
|
|
224
201
|
});
|
|
225
|
-
_defineProperty(_this2, "handleBodyMouseMove", function(event) {
|
|
226
|
-
var _this2$timer
|
|
202
|
+
_defineProperty(_assertThisInitialized(_this2), "handleBodyMouseMove", function(event) {
|
|
203
|
+
var _this2$timer;
|
|
227
204
|
if (!((_this2$timer = _this2.timer) !== null && _this2$timer !== void 0 && _this2$timer.paused)) return;
|
|
228
|
-
var rect =
|
|
229
|
-
if (!rect) return;
|
|
205
|
+
var rect = _this2.ref.current.getBoundingClientRect();
|
|
230
206
|
var mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
231
207
|
if (mouseInRect) return;
|
|
232
208
|
_this2.timer.resume();
|
|
233
209
|
});
|
|
234
210
|
return _this2;
|
|
235
211
|
}
|
|
236
|
-
|
|
237
|
-
return _createClass(ViewInfo2, [{
|
|
212
|
+
_createClass(ViewInfo2, [{
|
|
238
213
|
key: "componentDidMount",
|
|
239
214
|
value: function componentDidMount() {
|
|
240
215
|
var _this3 = this;
|
|
@@ -272,59 +247,124 @@ var ViewInfo = /* @__PURE__ */ (function(_Component2) {
|
|
|
272
247
|
}, {
|
|
273
248
|
key: "render",
|
|
274
249
|
value: function render() {
|
|
275
|
-
var
|
|
250
|
+
var _ref4;
|
|
276
251
|
var SBubble = FocusLock;
|
|
277
|
-
var SDismiss =
|
|
252
|
+
var SDismiss = Hint.Trigger;
|
|
278
253
|
var SContent = Flex;
|
|
279
254
|
var SMessage = "div";
|
|
280
255
|
var SAction = "div";
|
|
281
256
|
var SIcon = Flex;
|
|
282
|
-
var _this$props = this.props,
|
|
283
|
-
return
|
|
284
|
-
"
|
|
285
|
-
"
|
|
286
|
-
"
|
|
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,
|
|
257
|
+
var _this$props = this.props, forwardRef = _this$props.forwardRef, styles = _this$props.styles, onMouseEnter = _this$props.onMouseEnter, onMouseLeave = _this$props.onMouseLeave, getI18nText = _this$props.getI18nText, icon = _this$props.icon, children = _this$props.children, actionNode = _this$props.action, type = _this$props.type, other = _objectWithoutProperties(_this$props, _excluded2);
|
|
258
|
+
return _ref4 = sstyled$1(styles), /* @__PURE__ */ React.createElement(SBubble, _ref4.cn("SBubble", _objectSpread(_objectSpread({}, other), {}, {
|
|
259
|
+
"ref": forkRef(forwardRef, this.ref),
|
|
260
|
+
"onMouseEnter": callAllEventHandlers(onMouseEnter, this.handleMouseEnter),
|
|
261
|
+
"onMouseLeave": callAllEventHandlers(onMouseLeave, this.handleMouseLeave),
|
|
293
262
|
"onKeyDown": this.handleKeydown,
|
|
294
|
-
"role": type === "warning" ? "alert" :
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
"
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
263
|
+
"role": type === "warning" ? "alert" : this.props.role
|
|
264
|
+
})), /* @__PURE__ */ React.createElement(
|
|
265
|
+
SDismiss,
|
|
266
|
+
_ref4.cn("SDismiss", {
|
|
267
|
+
"aria-haspopup": void 0,
|
|
268
|
+
"tag": Button,
|
|
269
|
+
"type": "button",
|
|
270
|
+
"use": "tertiary",
|
|
271
|
+
"size": "m",
|
|
272
|
+
"theme": "invert",
|
|
273
|
+
"onClick": this.handleClose,
|
|
274
|
+
"aria-label": getI18nText("close"),
|
|
275
|
+
"active": false,
|
|
276
|
+
"title": getI18nText("close"),
|
|
277
|
+
"ref": this.closeButtonRef
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ React.createElement(Button.Addon, {
|
|
280
|
+
tag: CloseIcon,
|
|
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));
|
|
312
284
|
}
|
|
313
285
|
}]);
|
|
314
|
-
|
|
315
|
-
|
|
286
|
+
return ViewInfo2;
|
|
287
|
+
}(Component);
|
|
288
|
+
var ViewWarning = /* @__PURE__ */ function(_ViewInfo) {
|
|
289
|
+
_inherits(ViewWarning2, _ViewInfo);
|
|
290
|
+
var _super3 = _createSuper(ViewWarning2);
|
|
316
291
|
function ViewWarning2() {
|
|
317
292
|
_classCallCheck(this, ViewWarning2);
|
|
318
|
-
return
|
|
293
|
+
return _super3.apply(this, arguments);
|
|
319
294
|
}
|
|
320
|
-
_inherits(ViewWarning2, _ViewInfo2);
|
|
321
295
|
return _createClass(ViewWarning2);
|
|
322
|
-
}
|
|
296
|
+
}(ViewInfo);
|
|
323
297
|
_defineProperty(ViewWarning, "defaultProps", {
|
|
324
298
|
type: "warning",
|
|
325
299
|
duration: 0
|
|
326
300
|
});
|
|
327
|
-
var
|
|
301
|
+
var NoticeBubbleView = /* @__PURE__ */ function(_Component3) {
|
|
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;
|
|
328
366
|
export {
|
|
367
|
+
NoticeBubble,
|
|
368
|
+
NoticeBubbleWarning,
|
|
329
369
|
NoticeBubbleContainer as default
|
|
330
370
|
};
|