@semcore/notice-bubble 16.2.1 → 17.0.0-prerelease.17
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/README.md +4 -4
- package/lib/cjs/NoticeBubble.js +222 -328
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubble.type.js.map +1 -1
- package/lib/cjs/NoticeBubbleManager.js +67 -117
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.js +7 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/cjs/utils.js +32 -43
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/NoticeBubble.js +207 -314
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.type.js.map +1 -1
- package/lib/es6/NoticeBubbleManager.js +60 -111
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/lib/es6/index.js +0 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/utils.js +24 -36
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +209 -293
- package/lib/esm/NoticeBubbleManager.mjs +60 -111
- package/lib/esm/index.mjs +3 -7
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/esm/utils.mjs +24 -36
- package/lib/types/NoticeBubble.d.ts +2 -31
- package/lib/types/NoticeBubble.type.d.ts +6 -45
- package/lib/types/NoticeBubbleManager.d.ts +2 -4
- package/lib/types/index.d.ts +0 -1
- package/package.json +8 -10
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
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
|
-
|
|
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": "
|
|
40
|
-
"__SMessage": "
|
|
41
|
-
"__SDismiss": "
|
|
42
|
-
"_use": "
|
|
43
|
-
"__SIcon": "
|
|
44
|
-
"__SNoticeBubble": "
|
|
45
|
-
"_disablePortal": "
|
|
46
|
-
"__SNoticeAriaLiveWrapper": "
|
|
47
|
-
"@enter": "
|
|
48
|
-
"@exit": "
|
|
49
|
-
"__SBubble": "
|
|
50
|
-
"__SView": "
|
|
51
|
-
"_type_info": "
|
|
52
|
-
"_type_warning": "
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(0,
|
|
58
|
-
|
|
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
|
|
69
|
-
if (
|
|
70
|
-
|
|
55
|
+
(0, _defineProperty2.default)(this, "componentWillUnmount", () => {
|
|
56
|
+
if (this._unsubscribe) {
|
|
57
|
+
this._unsubscribe();
|
|
71
58
|
}
|
|
72
59
|
});
|
|
73
|
-
(0, _defineProperty2
|
|
74
|
-
|
|
75
|
-
notices
|
|
60
|
+
(0, _defineProperty2.default)(this, "handleChange", notices => {
|
|
61
|
+
this.setState({
|
|
62
|
+
notices
|
|
76
63
|
});
|
|
77
|
-
|
|
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
|
-
(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
(0, _defineProperty2
|
|
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:
|
|
164
|
-
return Number.parseInt(v, 10);
|
|
165
|
-
},
|
|
147
|
+
map: v => Number.parseInt(v, 10),
|
|
166
148
|
prop: 'duration'
|
|
167
149
|
})]);
|
|
168
|
-
(0, _defineProperty2
|
|
169
|
-
manager: _NoticeBubbleManager
|
|
150
|
+
(0, _defineProperty2.default)(NoticeBubbleContainerRoot, "defaultProps", {
|
|
151
|
+
manager: _NoticeBubbleManager.default,
|
|
170
152
|
i18n: _intergalacticDynamicLocales.localizedMessages,
|
|
171
153
|
locale: 'en'
|
|
172
154
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
179
|
-
return /*#__PURE__*/_react
|
|
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
|
-
|
|
184
|
-
|
|
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
|
|
191
|
-
setTimeout(
|
|
171
|
+
_react.default.useEffect(() => {
|
|
172
|
+
setTimeout(() => {
|
|
192
173
|
setShowContent(true);
|
|
193
174
|
}, 200);
|
|
194
175
|
}, []);
|
|
195
|
-
|
|
196
|
-
|
|
176
|
+
const SNoticeAriaLiveWrapper = 'div';
|
|
177
|
+
const Tag = props.tag;
|
|
197
178
|
if (props.type === 'info') {
|
|
198
|
-
return /*#__PURE__*/_react
|
|
179
|
+
return /*#__PURE__*/_react.default.createElement(_zIndexStacking.ZIndexStackingContextProvider, {
|
|
199
180
|
designToken: "z-index-notice-bubble"
|
|
200
|
-
}, /*#__PURE__*/_react
|
|
181
|
+
}, /*#__PURE__*/_react.default.createElement(_baseComponents.Portal, {
|
|
201
182
|
nodeToMount: props.containerNode
|
|
202
|
-
}, /*#__PURE__*/_react
|
|
183
|
+
}, /*#__PURE__*/_react.default.createElement(SNoticeAriaLiveWrapper, {
|
|
203
184
|
"aria-live": "polite"
|
|
204
|
-
}, showContent && /*#__PURE__*/_react
|
|
185
|
+
}, showContent && /*#__PURE__*/_react.default.createElement(Tag, props))));
|
|
205
186
|
}
|
|
206
|
-
return /*#__PURE__*/_react
|
|
187
|
+
return /*#__PURE__*/_react.default.createElement(_zIndexStacking.ZIndexStackingContextProvider, {
|
|
207
188
|
designToken: "z-index-notice-bubble"
|
|
208
|
-
}, /*#__PURE__*/_react
|
|
189
|
+
}, /*#__PURE__*/_react.default.createElement(_baseComponents.Portal, {
|
|
209
190
|
nodeToMount: props.containerNode
|
|
210
|
-
}, /*#__PURE__*/_react
|
|
191
|
+
}, /*#__PURE__*/_react.default.createElement(Tag, props)));
|
|
211
192
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
(0,
|
|
216
|
-
|
|
217
|
-
|
|
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
|
|
226
|
-
|
|
201
|
+
(0, _fire.default)(this, 'onClose', e);
|
|
202
|
+
this.clearTimer();
|
|
227
203
|
});
|
|
228
|
-
(0, _defineProperty2
|
|
204
|
+
(0, _defineProperty2.default)(this, "handleKeydown", e => {
|
|
229
205
|
if (e.key === 'Escape') {
|
|
230
|
-
|
|
206
|
+
this.handleClose(e);
|
|
231
207
|
}
|
|
232
208
|
});
|
|
233
|
-
(0, _defineProperty2
|
|
234
|
-
if (!
|
|
235
|
-
|
|
209
|
+
(0, _defineProperty2.default)(this, "handleMouseEnter", () => {
|
|
210
|
+
if (!this.timer) return;
|
|
211
|
+
this.timer.pause();
|
|
236
212
|
});
|
|
237
|
-
(0, _defineProperty2
|
|
238
|
-
if (!
|
|
239
|
-
|
|
213
|
+
(0, _defineProperty2.default)(this, "handleMouseLeave", () => {
|
|
214
|
+
if (!this.timer) return;
|
|
215
|
+
this.timer.resume();
|
|
240
216
|
});
|
|
241
|
-
(0, _defineProperty2
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
|
|
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
|
-
|
|
223
|
+
this.timer.resume();
|
|
249
224
|
});
|
|
250
|
-
return _this2;
|
|
251
225
|
}
|
|
252
|
-
(
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
(
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
-
(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
408
|
-
});
|
|
409
|
-
var NoticeBubbleContainer = (0, _core.createComponent)(NoticeBubbleContainerRoot, {
|
|
410
|
-
Info: NoticeBubbleView,
|
|
411
|
-
Warning: NoticeBubbleWarningView
|
|
306
|
+
duration: 0
|
|
412
307
|
});
|
|
413
|
-
|
|
414
|
-
var
|
|
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
|