@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/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["Timer","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["Timer","constructor","callback","delay","_defineProperty2","default","remaining","paused","resume","pause","timerId","clearTimeout","Date","now","start","window","setTimeout","reset","clear","exports"],"sources":["../../src/utils.ts"],"sourcesContent":["class Timer {\n private readonly delay: number;\n private readonly callback: Function;\n\n private remaining: number;\n private timerId: number | null = null;\n private start: number = 0;\n\n public paused: boolean;\n\n constructor(callback: Function, delay: number) {\n this.callback = callback;\n this.delay = delay;\n\n this.remaining = delay;\n this.paused = false;\n this.resume();\n }\n\n pause() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.remaining -= Date.now() - this.start;\n this.paused = true;\n }\n\n resume() {\n this.start = Date.now();\n this.paused = false;\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n this.timerId = window.setTimeout(this.callback, this.remaining);\n }\n\n reset() {\n this.remaining = this.delay;\n this.resume();\n }\n\n clear() {\n if (this.timerId) {\n clearTimeout(this.timerId);\n }\n }\n}\n\nexport { Timer };\n"],"mappings":";;;;;;;;AAAA,MAAMA,KAAK,CAAC;EAUVC,WAAWA,CAACC,QAAkB,EAAEC,KAAa,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,mBALd,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA,iBACb,CAAC;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAKvB,IAAI,CAACH,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAElB,IAAI,CAACG,SAAS,GAAGH,KAAK;IACtB,IAAI,CAACI,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,IAAI,CAACC,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;IACA,IAAI,CAACJ,SAAS,IAAIM,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACC,KAAK;IACzC,IAAI,CAACP,MAAM,GAAG,IAAI;EACpB;EAEAC,MAAMA,CAAA,EAAG;IACP,IAAI,CAACM,KAAK,GAAGF,IAAI,CAACC,GAAG,CAAC,CAAC;IACvB,IAAI,CAACN,MAAM,GAAG,KAAK;IACnB,IAAI,IAAI,CAACG,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;IACA,IAAI,CAACA,OAAO,GAAGK,MAAM,CAACC,UAAU,CAAC,IAAI,CAACd,QAAQ,EAAE,IAAI,CAACI,SAAS,CAAC;EACjE;EAEAW,KAAKA,CAAA,EAAG;IACN,IAAI,CAACX,SAAS,GAAG,IAAI,CAACH,KAAK;IAC3B,IAAI,CAACK,MAAM,CAAC,CAAC;EACf;EAEAU,KAAKA,CAAA,EAAG;IACN,IAAI,IAAI,CAACR,OAAO,EAAE;MAChBC,YAAY,CAAC,IAAI,CAACD,OAAO,CAAC;IAC5B;EACF;AACF;AAACS,OAAA,CAAAnB,KAAA,GAAAA,KAAA","ignoreList":[]}
|
package/lib/es6/NoticeBubble.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
5
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
6
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
7
|
-
import _callSuper from "@babel/runtime/helpers/callSuper";
|
|
8
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
9
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
3
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
11
4
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
12
|
-
var _excluded = ["focusLock"];
|
|
13
5
|
import { Animation, Box, Flex, Portal } from '@semcore/base-components';
|
|
14
6
|
import Button from '@semcore/button';
|
|
15
7
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
@@ -26,169 +18,158 @@ import CloseIcon from '@semcore/icon/Close/m';
|
|
|
26
18
|
import React from 'react';
|
|
27
19
|
import manager from './NoticeBubbleManager';
|
|
28
20
|
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
29
|
-
|
|
21
|
+
const style = (/*__reshadow_css_start__*/_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_"),
|
|
30
22
|
/*__reshadow_css_end__*/
|
|
31
23
|
{
|
|
32
|
-
"__SContent": "
|
|
33
|
-
"__SMessage": "
|
|
34
|
-
"__SDismiss": "
|
|
35
|
-
"_use": "
|
|
36
|
-
"__SIcon": "
|
|
37
|
-
"__SNoticeBubble": "
|
|
38
|
-
"_disablePortal": "
|
|
39
|
-
"__SNoticeAriaLiveWrapper": "
|
|
40
|
-
"@enter": "
|
|
41
|
-
"@exit": "
|
|
42
|
-
"__SBubble": "
|
|
43
|
-
"__SView": "
|
|
44
|
-
"_type_info": "
|
|
45
|
-
"_type_warning": "
|
|
24
|
+
"__SContent": "___SContent_htjmd_gg_",
|
|
25
|
+
"__SMessage": "___SMessage_htjmd_gg_",
|
|
26
|
+
"__SDismiss": "___SDismiss_htjmd_gg_",
|
|
27
|
+
"_use": "__use_htjmd_gg_",
|
|
28
|
+
"__SIcon": "___SIcon_htjmd_gg_",
|
|
29
|
+
"__SNoticeBubble": "___SNoticeBubble_htjmd_gg_",
|
|
30
|
+
"_disablePortal": "__disablePortal_htjmd_gg_",
|
|
31
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_htjmd_gg_",
|
|
32
|
+
"@enter": "enter_htjmd",
|
|
33
|
+
"@exit": "exit_htjmd",
|
|
34
|
+
"__SBubble": "___SBubble_htjmd_gg_",
|
|
35
|
+
"__SView": "___SView_htjmd_gg_",
|
|
36
|
+
"_type_info": "_type_info_htjmd_gg_",
|
|
37
|
+
"_type_warning": "_type_warning_htjmd_gg_"
|
|
46
38
|
});
|
|
47
39
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
48
40
|
import { Timer } from './utils';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
args[_key] = arguments[_key];
|
|
55
|
-
}
|
|
56
|
-
_this = _callSuper(this, NoticeBubbleContainerRoot, [].concat(args));
|
|
57
|
-
_defineProperty(_this, "_unsubscribe", null);
|
|
58
|
-
_defineProperty(_this, "state", {
|
|
41
|
+
class NoticeBubbleContainerRoot extends Component {
|
|
42
|
+
constructor(...args) {
|
|
43
|
+
super(...args);
|
|
44
|
+
_defineProperty(this, "_unsubscribe", null);
|
|
45
|
+
_defineProperty(this, "state", {
|
|
59
46
|
notices: [],
|
|
60
47
|
infos: [],
|
|
61
48
|
warnings: []
|
|
62
49
|
});
|
|
63
|
-
_defineProperty(
|
|
64
|
-
if (
|
|
65
|
-
|
|
50
|
+
_defineProperty(this, "componentWillUnmount", () => {
|
|
51
|
+
if (this._unsubscribe) {
|
|
52
|
+
this._unsubscribe();
|
|
66
53
|
}
|
|
67
54
|
});
|
|
68
|
-
_defineProperty(
|
|
69
|
-
|
|
70
|
-
notices
|
|
55
|
+
_defineProperty(this, "handleChange", notices => {
|
|
56
|
+
this.setState({
|
|
57
|
+
notices
|
|
71
58
|
});
|
|
72
|
-
|
|
59
|
+
this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different
|
|
73
60
|
});
|
|
74
|
-
return _this;
|
|
75
61
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
}, 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';
|
|
62
|
+
componentDidMount() {
|
|
63
|
+
this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
var _ref = this.asProps,
|
|
67
|
+
_ref3;
|
|
68
|
+
const SNoticeBubble = Box;
|
|
69
|
+
const SNoticeAriaLiveWrapper = 'div';
|
|
70
|
+
const {
|
|
71
|
+
Children,
|
|
72
|
+
styles,
|
|
73
|
+
disablePortal,
|
|
74
|
+
getI18nText,
|
|
75
|
+
ref,
|
|
76
|
+
parentZIndexStacking,
|
|
77
|
+
duration,
|
|
78
|
+
containerNode
|
|
79
|
+
} = this.asProps;
|
|
80
|
+
const {
|
|
81
|
+
notices
|
|
82
|
+
} = this.state;
|
|
83
|
+
if (containerNode) {
|
|
84
|
+
return notices.map(notice => {
|
|
85
|
+
var _ref2;
|
|
86
|
+
const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;
|
|
87
|
+
return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(PortalForNoticeItem, _ref2.cn("PortalForNoticeItem", {
|
|
88
|
+
"key": notice.uid,
|
|
89
|
+
"tag": SView,
|
|
90
|
+
"containerNode": containerNode,
|
|
91
|
+
"animationDuration": duration,
|
|
92
|
+
"styles": styles,
|
|
93
|
+
"getI18nText": getI18nText,
|
|
94
|
+
...notice
|
|
95
|
+
}));
|
|
118
96
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
97
|
+
}
|
|
98
|
+
const infos = notices.filter(notice => notice.type === 'info');
|
|
99
|
+
const warnings = notices.filter(notice => notice.type === 'warning');
|
|
100
|
+
return _ref3 = sstyled(styles), /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, _ref3.cn("ZIndexStackingContextProvider", {
|
|
101
|
+
"designToken": 'z-index-notice-bubble'
|
|
102
|
+
}), /*#__PURE__*/React.createElement(Portal, _ref3.cn("Portal", {
|
|
103
|
+
"disablePortal": disablePortal
|
|
104
|
+
}), /*#__PURE__*/React.createElement(SNoticeBubble, _ref3.cn("SNoticeBubble", {
|
|
105
|
+
..._assignProps({
|
|
124
106
|
"ref": ref,
|
|
125
107
|
"tag": 'section',
|
|
126
108
|
"role": 'region',
|
|
127
109
|
"aria-label": getI18nText('notification'),
|
|
128
110
|
"zIndex": parentZIndexStacking
|
|
129
|
-
}, _ref)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
111
|
+
}, _ref)
|
|
112
|
+
}), /*#__PURE__*/React.createElement(Children, _ref3.cn("Children", {})), warnings.map(notice => {
|
|
113
|
+
var _ref4;
|
|
114
|
+
const SView = ViewWarning;
|
|
115
|
+
return _ref4 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref4.cn("SView", {
|
|
116
|
+
"key": notice.uid,
|
|
117
|
+
"animationDuration": duration,
|
|
118
|
+
"styles": styles,
|
|
119
|
+
"getI18nText": getI18nText,
|
|
120
|
+
...notice
|
|
121
|
+
}));
|
|
122
|
+
}), /*#__PURE__*/React.createElement(SNoticeAriaLiveWrapper, _ref3.cn("SNoticeAriaLiveWrapper", {
|
|
123
|
+
"aria-live": 'polite'
|
|
124
|
+
}), infos.map(notice => {
|
|
125
|
+
var _ref5;
|
|
126
|
+
const SView = ViewInfo;
|
|
127
|
+
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SView, _ref5.cn("SView", {
|
|
128
|
+
"key": notice.uid,
|
|
129
|
+
"animationDuration": duration,
|
|
130
|
+
"styles": styles,
|
|
131
|
+
"getI18nText": getI18nText,
|
|
132
|
+
...notice
|
|
133
|
+
}));
|
|
134
|
+
})))));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
153
137
|
_defineProperty(NoticeBubbleContainerRoot, "displayName", 'NoticeBubbleContainer');
|
|
154
138
|
_defineProperty(NoticeBubbleContainerRoot, "style", style);
|
|
155
139
|
_defineProperty(NoticeBubbleContainerRoot, "enhance", [i18nEnhance(localizedMessages), contextThemeEnhance(), zIndexStackingEnhance('z-index-notice-bubble'), cssVariableEnhance({
|
|
156
140
|
variable: '--intergalactic-duration-popper',
|
|
157
141
|
fallback: 200,
|
|
158
|
-
map:
|
|
159
|
-
return Number.parseInt(v, 10);
|
|
160
|
-
},
|
|
142
|
+
map: v => Number.parseInt(v, 10),
|
|
161
143
|
prop: 'duration'
|
|
162
144
|
})]);
|
|
163
145
|
_defineProperty(NoticeBubbleContainerRoot, "defaultProps", {
|
|
164
|
-
manager
|
|
146
|
+
manager,
|
|
165
147
|
i18n: localizedMessages,
|
|
166
148
|
locale: 'en'
|
|
167
149
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
150
|
+
const FocusLock = /*#__PURE__*/React.forwardRef((props, outerRef) => {
|
|
151
|
+
const {
|
|
152
|
+
focusLock,
|
|
153
|
+
...other
|
|
154
|
+
} = props;
|
|
155
|
+
const innerRef = React.useRef(null);
|
|
172
156
|
useFocusLock(innerRef, false, 'auto', !focusLock, true);
|
|
173
|
-
|
|
157
|
+
const ref = useForkRef(outerRef, innerRef);
|
|
174
158
|
return /*#__PURE__*/React.createElement(Flex, _extends({
|
|
175
159
|
ref: ref
|
|
176
160
|
}, other));
|
|
177
161
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
181
|
-
showContent = _React$useState2[0],
|
|
182
|
-
setShowContent = _React$useState2[1];
|
|
162
|
+
const PortalForNoticeItem = props => {
|
|
163
|
+
const [showContent, setShowContent] = React.useState(false);
|
|
183
164
|
|
|
184
165
|
// Show content for info notice in previously mounted node with aria-live polite
|
|
185
|
-
React.useEffect(
|
|
186
|
-
setTimeout(
|
|
166
|
+
React.useEffect(() => {
|
|
167
|
+
setTimeout(() => {
|
|
187
168
|
setShowContent(true);
|
|
188
169
|
}, 200);
|
|
189
170
|
}, []);
|
|
190
|
-
|
|
191
|
-
|
|
171
|
+
const SNoticeAriaLiveWrapper = 'div';
|
|
172
|
+
const Tag = props.tag;
|
|
192
173
|
if (props.type === 'info') {
|
|
193
174
|
return /*#__PURE__*/React.createElement(ZIndexStackingContextProvider, {
|
|
194
175
|
designToken: "z-index-notice-bubble"
|
|
@@ -204,209 +185,121 @@ var PortalForNoticeItem = function PortalForNoticeItem(props) {
|
|
|
204
185
|
nodeToMount: props.containerNode
|
|
205
186
|
}, /*#__PURE__*/React.createElement(Tag, props)));
|
|
206
187
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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) {
|
|
188
|
+
class ViewInfo extends Component {
|
|
189
|
+
constructor(...args) {
|
|
190
|
+
super(...args);
|
|
191
|
+
_defineProperty(this, "timer", null);
|
|
192
|
+
_defineProperty(this, "ref", /*#__PURE__*/React.createRef());
|
|
193
|
+
_defineProperty(this, "closeButtonRef", /*#__PURE__*/React.createRef());
|
|
194
|
+
_defineProperty(this, "handleClose", e => {
|
|
219
195
|
// because it might be called not only from the close icon click
|
|
220
|
-
fire(
|
|
221
|
-
|
|
196
|
+
fire(this, 'onClose', e);
|
|
197
|
+
this.clearTimer();
|
|
222
198
|
});
|
|
223
|
-
_defineProperty(
|
|
199
|
+
_defineProperty(this, "handleKeydown", e => {
|
|
224
200
|
if (e.key === 'Escape') {
|
|
225
|
-
|
|
201
|
+
this.handleClose(e);
|
|
226
202
|
}
|
|
227
203
|
});
|
|
228
|
-
_defineProperty(
|
|
229
|
-
if (!
|
|
230
|
-
|
|
204
|
+
_defineProperty(this, "handleMouseEnter", () => {
|
|
205
|
+
if (!this.timer) return;
|
|
206
|
+
this.timer.pause();
|
|
231
207
|
});
|
|
232
|
-
_defineProperty(
|
|
233
|
-
if (!
|
|
234
|
-
|
|
208
|
+
_defineProperty(this, "handleMouseLeave", () => {
|
|
209
|
+
if (!this.timer) return;
|
|
210
|
+
this.timer.resume();
|
|
235
211
|
});
|
|
236
|
-
_defineProperty(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var rect = (_this2$ref$current = _this2.ref.current) === null || _this2$ref$current === void 0 ? void 0 : _this2$ref$current.getBoundingClientRect();
|
|
212
|
+
_defineProperty(this, "handleBodyMouseMove", event => {
|
|
213
|
+
if (!this.timer?.paused) return;
|
|
214
|
+
const rect = this.ref.current?.getBoundingClientRect();
|
|
240
215
|
if (!rect) return;
|
|
241
|
-
|
|
216
|
+
const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
242
217
|
if (mouseInRect) return;
|
|
243
|
-
|
|
218
|
+
this.timer.resume();
|
|
244
219
|
});
|
|
245
|
-
return _this2;
|
|
246
220
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.timer = new Timer(this.handleClose, duration);
|
|
255
|
-
document.body.addEventListener('mousemove', this.handleBodyMouseMove);
|
|
256
|
-
}
|
|
257
|
-
var noticeElement = this.ref.current;
|
|
258
|
-
if (noticeElement) {
|
|
259
|
-
var focusableNodes = getFocusableIn(noticeElement).filter(function (node) {
|
|
260
|
-
return node !== _this3.closeButtonRef.current;
|
|
261
|
-
});
|
|
262
|
-
if (focusableNodes.length > 0) {
|
|
263
|
-
setTimeout(function () {
|
|
264
|
-
return setFocus(noticeElement);
|
|
265
|
-
}, 0);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}, {
|
|
270
|
-
key: "componentWillUnmount",
|
|
271
|
-
value: function componentWillUnmount() {
|
|
272
|
-
this.clearTimer();
|
|
273
|
-
document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
|
|
221
|
+
componentDidMount() {
|
|
222
|
+
const {
|
|
223
|
+
duration
|
|
224
|
+
} = this.props;
|
|
225
|
+
if (duration) {
|
|
226
|
+
this.timer = new Timer(this.handleClose, duration);
|
|
227
|
+
document.body.addEventListener('mousemove', this.handleBodyMouseMove);
|
|
274
228
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
this.timer = null;
|
|
229
|
+
const noticeElement = this.ref.current;
|
|
230
|
+
if (noticeElement) {
|
|
231
|
+
const focusableNodes = getFocusableIn(noticeElement).filter(node => node !== this.closeButtonRef.current);
|
|
232
|
+
if (focusableNodes.length > 0) {
|
|
233
|
+
setTimeout(() => setFocus(noticeElement), 0);
|
|
281
234
|
}
|
|
282
235
|
}
|
|
283
|
-
}, {
|
|
284
|
-
key: "render",
|
|
285
|
-
value: function render() {
|
|
286
|
-
var _ref6;
|
|
287
|
-
var SBubble = FocusLock;
|
|
288
|
-
var SDismiss = Button;
|
|
289
|
-
var SContent = Flex;
|
|
290
|
-
var SMessage = 'div';
|
|
291
|
-
var SAction = 'div';
|
|
292
|
-
var SIcon = Flex;
|
|
293
|
-
var _this$props = this.props,
|
|
294
|
-
styles = _this$props.styles,
|
|
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,
|
|
300
|
-
icon = _this$props.icon,
|
|
301
|
-
children = _this$props.children,
|
|
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,
|
|
314
|
-
"onKeyDown": this.handleKeydown,
|
|
315
|
-
"role": type === 'warning' ? 'alert' : undefined,
|
|
316
|
-
"focusLock": focusLock
|
|
317
|
-
}), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
|
|
318
|
-
"aria-haspopup": undefined,
|
|
319
|
-
"type": 'button',
|
|
320
|
-
"use": 'tertiary',
|
|
321
|
-
"size": 'm',
|
|
322
|
-
"theme": 'invert',
|
|
323
|
-
"onClick": this.handleClose,
|
|
324
|
-
"aria-label": getI18nText('close'),
|
|
325
|
-
"active": false,
|
|
326
|
-
"title": getI18nText('close'),
|
|
327
|
-
"ref": this.closeButtonRef,
|
|
328
|
-
"data-hide-focus-hover-popper": 'true'
|
|
329
|
-
}), /*#__PURE__*/React.createElement(Button.Addon, {
|
|
330
|
-
tag: CloseIcon,
|
|
331
|
-
color: "icon-primary-invert"
|
|
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)));
|
|
333
|
-
}
|
|
334
|
-
}]);
|
|
335
|
-
}(Component);
|
|
336
|
-
var ViewWarning = /*#__PURE__*/function (_ViewInfo2) {
|
|
337
|
-
function ViewWarning() {
|
|
338
|
-
_classCallCheck(this, ViewWarning);
|
|
339
|
-
return _callSuper(this, ViewWarning, arguments);
|
|
340
236
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
_defineProperty(ViewWarning, "defaultProps", {
|
|
345
|
-
type: 'warning',
|
|
346
|
-
duration: 0
|
|
347
|
-
});
|
|
348
|
-
var NoticeBubbleView = /*#__PURE__*/function (_Component3) {
|
|
349
|
-
function NoticeBubbleView() {
|
|
350
|
-
var _this4;
|
|
351
|
-
_classCallCheck(this, NoticeBubbleView);
|
|
352
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
353
|
-
args[_key3] = arguments[_key3];
|
|
354
|
-
}
|
|
355
|
-
_this4 = _callSuper(this, NoticeBubbleView, [].concat(args));
|
|
356
|
-
_defineProperty(_this4, "_notice", null);
|
|
357
|
-
return _this4;
|
|
237
|
+
componentWillUnmount() {
|
|
238
|
+
this.clearTimer();
|
|
239
|
+
document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
|
|
358
240
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this._notice = this.asProps.manager.add(this.asProps);
|
|
241
|
+
clearTimer() {
|
|
242
|
+
if (this.timer) {
|
|
243
|
+
this.timer.clear();
|
|
244
|
+
this.timer = null;
|
|
364
245
|
}
|
|
365
|
-
}, {
|
|
366
|
-
key: "componentWillUnmount",
|
|
367
|
-
value: function componentWillUnmount() {
|
|
368
|
-
if (this._notice) {
|
|
369
|
-
this._notice.remove();
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}, {
|
|
373
|
-
key: "componentDidUpdate",
|
|
374
|
-
value: function componentDidUpdate() {
|
|
375
|
-
if (this._notice) {
|
|
376
|
-
this._notice.update(this.asProps);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}, {
|
|
380
|
-
key: "render",
|
|
381
|
-
value: function render() {
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
}]);
|
|
385
|
-
}(Component);
|
|
386
|
-
_defineProperty(NoticeBubbleView, "defaultProps", {
|
|
387
|
-
duration: 5000,
|
|
388
|
-
type: 'info',
|
|
389
|
-
manager: manager
|
|
390
|
-
});
|
|
391
|
-
var NoticeBubbleWarningView = /*#__PURE__*/function (_NoticeBubbleView2) {
|
|
392
|
-
function NoticeBubbleWarningView() {
|
|
393
|
-
_classCallCheck(this, NoticeBubbleWarningView);
|
|
394
|
-
return _callSuper(this, NoticeBubbleWarningView, arguments);
|
|
395
246
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
247
|
+
render() {
|
|
248
|
+
var _ref6;
|
|
249
|
+
const SBubble = FocusLock;
|
|
250
|
+
const SDismiss = Button;
|
|
251
|
+
const SContent = Flex;
|
|
252
|
+
const SMessage = 'div';
|
|
253
|
+
const SAction = 'div';
|
|
254
|
+
const SIcon = Flex;
|
|
255
|
+
const {
|
|
256
|
+
styles,
|
|
257
|
+
getI18nText,
|
|
258
|
+
visible,
|
|
259
|
+
type,
|
|
260
|
+
initialAnimation,
|
|
261
|
+
animationDuration,
|
|
262
|
+
icon,
|
|
263
|
+
children,
|
|
264
|
+
action,
|
|
265
|
+
focusLock
|
|
266
|
+
} = this.props;
|
|
267
|
+
return _ref6 = sstyled(styles), /*#__PURE__*/React.createElement(Animation, _ref6.cn("Animation", {
|
|
268
|
+
"initialAnimation": initialAnimation,
|
|
269
|
+
"visible": visible ?? true,
|
|
270
|
+
"duration": animationDuration,
|
|
271
|
+
"keyframes": [styles['@enter'], styles['@exit']]
|
|
272
|
+
}), /*#__PURE__*/React.createElement(SBubble, _ref6.cn("SBubble", {
|
|
273
|
+
"type": type,
|
|
274
|
+
"ref": this.ref,
|
|
275
|
+
"onMouseEnter": this.handleMouseEnter,
|
|
276
|
+
"onMouseLeave": this.handleMouseLeave,
|
|
277
|
+
"onKeyDown": this.handleKeydown,
|
|
278
|
+
"role": type === 'warning' ? 'alert' : undefined,
|
|
279
|
+
"focusLock": focusLock
|
|
280
|
+
}), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
|
|
281
|
+
"aria-haspopup": undefined,
|
|
282
|
+
"type": 'button',
|
|
283
|
+
"use": 'tertiary',
|
|
284
|
+
"size": 'm',
|
|
285
|
+
"theme": 'invert',
|
|
286
|
+
"onClick": this.handleClose,
|
|
287
|
+
"aria-label": getI18nText('close'),
|
|
288
|
+
"active": false,
|
|
289
|
+
"title": getI18nText('close'),
|
|
290
|
+
"ref": this.closeButtonRef,
|
|
291
|
+
"data-hide-focus-hover-popper": 'true'
|
|
292
|
+
}), /*#__PURE__*/React.createElement(Button.Addon, {
|
|
293
|
+
tag: CloseIcon,
|
|
294
|
+
color: "icon-primary-invert"
|
|
295
|
+
})), 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)));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
class ViewWarning extends ViewInfo {}
|
|
299
|
+
_defineProperty(ViewWarning, "defaultProps", {
|
|
401
300
|
type: 'warning',
|
|
402
|
-
|
|
403
|
-
});
|
|
404
|
-
var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
|
|
405
|
-
Info: NoticeBubbleView,
|
|
406
|
-
Warning: NoticeBubbleWarningView
|
|
301
|
+
duration: 0
|
|
407
302
|
});
|
|
408
|
-
|
|
409
|
-
var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
|
|
410
|
-
export { NoticeBubble, NoticeBubbleWarning };
|
|
303
|
+
const NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot);
|
|
411
304
|
export default NoticeBubbleContainer;
|
|
412
305
|
//# sourceMappingURL=NoticeBubble.js.map
|