@semcore/notice-bubble 17.2.0 → 17.2.1-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 +8 -0
- package/lib/cjs/NoticeBubble.js +41 -27
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubble.type.js.map +1 -1
- package/lib/cjs/utils.js +1 -0
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/NoticeBubble.js +42 -28
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.type.js.map +1 -1
- package/lib/es6/utils.js +1 -0
- package/lib/es6/utils.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +43 -29
- package/lib/esm/utils.mjs +1 -0
- package/lib/types/NoticeBubble.type.d.ts +2 -0
- package/package.json +7 -7
- package/vitest.config.mts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
+
## [17.2.1] - 2026-06-25
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Bubble disappeared on a timer when interacting with it via the
|
|
10
|
+
keyboard.
|
|
11
|
+
- Incorrect processing of oklch values.
|
|
12
|
+
|
|
5
13
|
## [17.2.0] - 2026-06-05
|
|
6
14
|
|
|
7
15
|
### Added
|
package/lib/cjs/NoticeBubble.js
CHANGED
|
@@ -12,7 +12,6 @@ var _baseComponents = require("@semcore/base-components");
|
|
|
12
12
|
var _button = _interopRequireDefault(require("@semcore/button"));
|
|
13
13
|
var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/i18nEnhance"));
|
|
14
14
|
var _fire = _interopRequireDefault(require("@semcore/core/lib/utils/fire"));
|
|
15
|
-
var _getFocusableIn = require("@semcore/core/lib/utils/focus-lock/getFocusableIn");
|
|
16
15
|
var _isNode = _interopRequireDefault(require("@semcore/core/lib/utils/isNode"));
|
|
17
16
|
var _ref7 = require("@semcore/core/lib/utils/ref");
|
|
18
17
|
var _ThemeProvider = require("@semcore/core/lib/utils/ThemeProvider");
|
|
@@ -25,23 +24,23 @@ var _NoticeBubbleManager = _interopRequireDefault(require("./NoticeBubbleManager
|
|
|
25
24
|
var _intergalacticDynamicLocales = require("./translations/__intergalactic-dynamic-locales");
|
|
26
25
|
var _utils = require("./utils");
|
|
27
26
|
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
28
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
27
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBubble_1y8gb_gg_,.___SView_1y8gb_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,oklch(.999 .001 180/.949));gap:var(--intergalactic-spacing-2x,8px)}.___SBubble_1y8gb_gg_._type_info_1y8gb_gg_,.___SView_1y8gb_gg_._type_info_1y8gb_gg_{background:var(--intergalactic-bg-primary-invert,oklch(.23 .01 140))}.___SBubble_1y8gb_gg_._type_warning_1y8gb_gg_,.___SView_1y8gb_gg_._type_warning_1y8gb_gg_{background:var(--intergalactic-bg-primary-critical,oklch(.64 .226 24.5))}.___SContent_1y8gb_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x,8px);flex:1}.___SMessage_1y8gb_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%)}.___SDismiss_1y8gb_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:#0000}.___SDismiss_1y8gb_gg_.__use_1y8gb_gg_{padding:0 1px}.___SIcon_1y8gb_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x,20px)}.___SNoticeBubble_1y8gb_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x,12px);top:var(--intergalactic-spacing-3x,12px)}@media (max-width:767px){.___SNoticeBubble_1y8gb_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_1y8gb_gg_.__disablePortal_1y8gb_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_1y8gb_gg_ a{color:var(--intergalactic-text-link-invert,oklch(.75 .125 265.3))}.___SNoticeAriaLiveWrapper_1y8gb_gg_{display:contents}@keyframes enter_1y8gb{0%{transform:translate(100%);max-height:0;overflow:hidden}to{transform:translate(0);max-height:100vh;overflow:hidden}}@keyframes exit_1y8gb{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}", /*__inner_css_end__*/"1y8gb_gg_"),
|
|
29
28
|
/*__reshadow_css_end__*/
|
|
30
29
|
{
|
|
31
|
-
"__SContent": "
|
|
32
|
-
"__SMessage": "
|
|
33
|
-
"__SDismiss": "
|
|
34
|
-
"_use": "
|
|
35
|
-
"__SIcon": "
|
|
36
|
-
"__SNoticeBubble": "
|
|
37
|
-
"_disablePortal": "
|
|
38
|
-
"__SNoticeAriaLiveWrapper": "
|
|
39
|
-
"@enter": "
|
|
40
|
-
"@exit": "
|
|
41
|
-
"__SBubble": "
|
|
42
|
-
"__SView": "
|
|
43
|
-
"_type_info": "
|
|
44
|
-
"_type_warning": "
|
|
30
|
+
"__SContent": "___SContent_1y8gb_gg_",
|
|
31
|
+
"__SMessage": "___SMessage_1y8gb_gg_",
|
|
32
|
+
"__SDismiss": "___SDismiss_1y8gb_gg_",
|
|
33
|
+
"_use": "__use_1y8gb_gg_",
|
|
34
|
+
"__SIcon": "___SIcon_1y8gb_gg_",
|
|
35
|
+
"__SNoticeBubble": "___SNoticeBubble_1y8gb_gg_",
|
|
36
|
+
"_disablePortal": "__disablePortal_1y8gb_gg_",
|
|
37
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_1y8gb_gg_",
|
|
38
|
+
"@enter": "enter_1y8gb",
|
|
39
|
+
"@exit": "exit_1y8gb",
|
|
40
|
+
"__SBubble": "___SBubble_1y8gb_gg_",
|
|
41
|
+
"__SView": "___SView_1y8gb_gg_",
|
|
42
|
+
"_type_info": "_type_info_1y8gb_gg_",
|
|
43
|
+
"_type_warning": "_type_warning_1y8gb_gg_"
|
|
45
44
|
});
|
|
46
45
|
class NoticeBubbleContainerRoot extends _core.Component {
|
|
47
46
|
constructor(...args) {
|
|
@@ -199,6 +198,7 @@ class ViewInfo extends _core.Component {
|
|
|
199
198
|
(0, _defineProperty2.default)(this, "timer", null);
|
|
200
199
|
(0, _defineProperty2.default)(this, "ref", /*#__PURE__*/_react.default.createRef());
|
|
201
200
|
(0, _defineProperty2.default)(this, "closeButtonRef", /*#__PURE__*/_react.default.createRef());
|
|
201
|
+
(0, _defineProperty2.default)(this, "triggerButtonComponent", null);
|
|
202
202
|
(0, _defineProperty2.default)(this, "handleClose", e => {
|
|
203
203
|
// because it might be called not only from the close icon click
|
|
204
204
|
(0, _fire.default)(this, 'onClose', e);
|
|
@@ -209,16 +209,24 @@ class ViewInfo extends _core.Component {
|
|
|
209
209
|
this.handleClose(e);
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
|
+
(0, _defineProperty2.default)(this, "handleFocus", () => {
|
|
213
|
+
this.timer?.pause();
|
|
214
|
+
});
|
|
215
|
+
(0, _defineProperty2.default)(this, "handleBlur", () => {
|
|
216
|
+
this.timer?.resume();
|
|
217
|
+
});
|
|
218
|
+
(0, _defineProperty2.default)(this, "handleClick", () => {
|
|
219
|
+
this.timer?.pause();
|
|
220
|
+
});
|
|
212
221
|
(0, _defineProperty2.default)(this, "handleMouseEnter", () => {
|
|
213
|
-
|
|
214
|
-
this.timer.pause();
|
|
222
|
+
this.timer?.pause();
|
|
215
223
|
});
|
|
216
224
|
(0, _defineProperty2.default)(this, "handleMouseLeave", () => {
|
|
217
|
-
if (!this.timer) return;
|
|
225
|
+
if (!this.timer || this.isFocusInBubble()) return;
|
|
218
226
|
this.timer.resume();
|
|
219
227
|
});
|
|
220
228
|
(0, _defineProperty2.default)(this, "handleBodyMouseMove", event => {
|
|
221
|
-
if (!this.timer?.paused) return;
|
|
229
|
+
if (!this.timer?.paused || this.isFocusInBubble()) return;
|
|
222
230
|
const rect = this.ref.current?.getBoundingClientRect();
|
|
223
231
|
if (!rect) return;
|
|
224
232
|
const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
@@ -234,18 +242,20 @@ class ViewInfo extends _core.Component {
|
|
|
234
242
|
this.timer = new _utils.Timer(this.handleClose, duration);
|
|
235
243
|
document.body.addEventListener('mousemove', this.handleBodyMouseMove);
|
|
236
244
|
}
|
|
237
|
-
|
|
238
|
-
if (noticeElement) {
|
|
239
|
-
const focusableNodes = (0, _getFocusableIn.getFocusableIn)(noticeElement).filter(node => node !== this.closeButtonRef.current);
|
|
240
|
-
if (focusableNodes.length > 0) {
|
|
241
|
-
setTimeout(() => (0, _useFocusLock.setFocus)(noticeElement), 0);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
245
|
+
this.triggerButtonComponent = document.activeElement;
|
|
244
246
|
}
|
|
245
247
|
componentWillUnmount() {
|
|
248
|
+
const triggerElement = this.triggerButtonComponent;
|
|
249
|
+
if (this.ref.current && (0, _useFocusLock.isFocusInside)(this.ref.current) && triggerElement instanceof HTMLElement) {
|
|
250
|
+
setTimeout(() => (0, _useFocusLock.setFocus)(triggerElement), 0);
|
|
251
|
+
}
|
|
246
252
|
this.clearTimer();
|
|
247
253
|
document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
|
|
248
254
|
}
|
|
255
|
+
isFocusInBubble() {
|
|
256
|
+
const noticeElement = this.ref.current;
|
|
257
|
+
return noticeElement ? (0, _useFocusLock.isFocusInside)(noticeElement) : false;
|
|
258
|
+
}
|
|
249
259
|
clearTimer() {
|
|
250
260
|
if (this.timer) {
|
|
251
261
|
this.timer.clear();
|
|
@@ -278,11 +288,15 @@ class ViewInfo extends _core.Component {
|
|
|
278
288
|
"duration": animationDuration,
|
|
279
289
|
"keyframes": [styles['@enter'], styles['@exit']]
|
|
280
290
|
}), /*#__PURE__*/_react.default.createElement(SBubble, _ref6.cn("SBubble", {
|
|
291
|
+
"render": _baseComponents.Flex,
|
|
281
292
|
"type": type,
|
|
282
293
|
"ref": this.ref,
|
|
283
294
|
"onMouseEnter": this.handleMouseEnter,
|
|
284
295
|
"onMouseLeave": this.handleMouseLeave,
|
|
296
|
+
"onFocus": this.handleFocus,
|
|
297
|
+
"onBlur": this.handleBlur,
|
|
285
298
|
"onKeyDown": this.handleKeydown,
|
|
299
|
+
"onClick": this.handleClick,
|
|
286
300
|
"role": type === 'warning' ? 'alert' : undefined,
|
|
287
301
|
"focusLock": focusLock
|
|
288
302
|
}), /*#__PURE__*/_react.default.createElement(SDismiss, _ref6.cn("SDismiss", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["_core","require","_baseComponents","_button","_interopRequireDefault","_i18nEnhance","_fire","_getFocusableIn","_isNode","_ref7","_ThemeProvider","_useFocusLock","_useCssVariable","_zIndexStacking","_m","_react","_NoticeBubbleManager","_intergalacticDynamicLocales","_utils","style","sstyled","insert","NoticeBubbleContainerRoot","Component","constructor","args","_defineProperty2","default","notices","infos","warnings","_unsubscribe","setState","forceUpdate","componentDidMount","asProps","manager","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","Box","SNoticeAriaLiveWrapper","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","uid","filter","ZIndexStackingContextProvider","Portal","assignProps","_ref4","_ref5","i18nEnhance","localizedMessages","contextThemeEnhance","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","React","forwardRef","props","outerRef","focusLock","other","innerRef","useRef","useFocusLock","useForkRef","Flex","_extends2","showContent","setShowContent","useState","useEffect","setTimeout","tag","Tag","otherProps","designToken","nodeToMount","createRef","e","fire","clearTimer","key","handleClose","timer","pause","resume","event","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","Timer","document","body","addEventListener","handleBodyMouseMove","noticeElement","focusableNodes","getFocusableIn","node","closeButtonRef","length","setFocus","componentWillUnmount","removeEventListener","clear","_ref6","SBubble","SDismiss","Button","SContent","SMessage","SAction","SIcon","visible","initialAnimation","animationDuration","icon","children","action","Animation","handleMouseEnter","handleMouseLeave","handleKeydown","undefined","Addon","CloseIcon","color","isNode","Fragment","NoticeBubbleContainer","createComponent","_default","exports"],"sources":["../../src/NoticeBubble.tsx"],"sourcesContent":["import { Animation, Box, Flex, Portal } from '@semcore/base-components';\nimport Button from '@semcore/button';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport type { Intergalactic } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport fire from '@semcore/core/lib/utils/fire';\nimport { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';\nimport isNode from '@semcore/core/lib/utils/isNode';\nimport { useForkRef } from '@semcore/core/lib/utils/ref';\nimport { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';\nimport { useFocusLock, setFocus } from '@semcore/core/lib/utils/use/useFocusLock';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport {\n ZIndexStackingContextProvider,\n zIndexStackingEnhance,\n} from '@semcore/core/lib/utils/zIndexStacking';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport React from 'react';\n\nimport type {\n NoticeBubbleContainerDefaultProps,\n NoticeBubbleContainerProps,\n NoticeBubbleViewItemProps,\n} from './NoticeBubble.type';\nimport type { NoticeItem } from './NoticeBubbleManager';\nimport manager from './NoticeBubbleManager';\nimport style from './style/notice-bubble.shadow.css';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport { Timer } from './utils';\n\ntype State = {\n notices: NoticeItem[];\n infos: NoticeItem[];\n warnings: NoticeItem[];\n};\n\nclass NoticeBubbleContainerRoot extends Component<\n NoticeBubbleContainerProps,\n typeof NoticeBubbleContainerRoot.enhance,\n {},\n WithI18nEnhanceProps,\n State,\n NoticeBubbleContainerDefaultProps\n> {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [\n i18nEnhance(localizedMessages),\n contextThemeEnhance(),\n zIndexStackingEnhance('z-index-notice-bubble'),\n cssVariableEnhance<'duration', number, number>({\n variable: '--intergalactic-duration-popper',\n fallback: 200,\n map: (v: string) => Number.parseInt(v, 10),\n prop: 'duration',\n }),\n ] as const;\n\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\n } as const;\n\n _unsubscribe: (() => void) | null = null;\n\n state: State = {\n notices: [],\n infos: [],\n warnings: [],\n };\n\n componentDidMount() {\n this._unsubscribe = this.asProps.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices: NoticeItem[]) => {\n this.setState({ notices });\n this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different\n };\n\n render() {\n const SNoticeBubble = Root;\n const SNoticeAriaLiveWrapper = 'div';\n const { Children, styles, disablePortal, getI18nText, ref, parentZIndexStacking, duration, containerNode } =\n this.asProps;\n const { notices } = this.state;\n\n if (containerNode) {\n return notices.map((notice) => {\n const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;\n\n return sstyled(styles)(\n <PortalForNoticeItem\n key={notice.uid}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n tag={SView}\n />,\n );\n });\n }\n\n const infos = notices.filter((notice) => notice.type === 'info');\n const warnings = notices.filter((notice) => notice.type === 'warning');\n\n return sstyled(styles)(\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble\n render={Box}\n ref={ref}\n tag='section'\n role='region'\n aria-label={getI18nText('notification')}\n zIndex={parentZIndexStacking}\n >\n <Children />\n {warnings.map((notice) => {\n const SView = ViewWarning;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {infos.map((notice) => {\n const SView = ViewInfo;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n </SNoticeAriaLiveWrapper>\n </SNoticeBubble>\n </Portal>\n </ZIndexStackingContextProvider>,\n );\n }\n}\n\nconst FocusLock = React.forwardRef((props: any, outerRef: React.ForwardedRef<HTMLDivElement>) => {\n const { focusLock, ...other } = props;\n const innerRef = React.useRef<HTMLDivElement | null>(null);\n useFocusLock(innerRef, false, 'auto', !focusLock, true);\n const ref = useForkRef(outerRef, innerRef);\n\n return <Flex ref={ref} {...other} />;\n});\n\nconst PortalForNoticeItem = (props: Intergalactic.InternalTypings.EfficientOmit<NoticeBubbleViewItemProps, 'tag'> & { containerNode: HTMLElement; tag: typeof ViewInfo }) => {\n const [showContent, setShowContent] = React.useState(false);\n\n // Show content for info notice in previously mounted node with aria-live polite\n React.useEffect(() => {\n setTimeout(() => {\n setShowContent(true);\n }, 200);\n }, []);\n\n const SNoticeAriaLiveWrapper = 'div';\n const { tag: Tag, ...otherProps } = props;\n\n if (otherProps.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...otherProps} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <Tag {...otherProps} />\n </Portal>\n </ZIndexStackingContextProvider>\n );\n};\n\nclass ViewInfo extends Component<NoticeBubbleViewItemProps> {\n timer: Timer | null = null;\n ref = React.createRef<HTMLDivElement>();\n closeButtonRef = React.createRef<HTMLButtonElement>();\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handleClose, duration);\n document.body.addEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n const noticeElement = this.ref.current;\n\n if (noticeElement) {\n const focusableNodes = getFocusableIn(noticeElement).filter(\n (node) => node !== this.closeButtonRef.current,\n );\n\n if (focusableNodes.length > 0) {\n setTimeout(() => setFocus(noticeElement), 0);\n }\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n document.body.removeEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handleClose = (e: React.SyntheticEvent) => {\n // because it might be called not only from the close icon click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handleKeydown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.handleClose(e);\n }\n };\n\n handleMouseEnter = () => {\n if (!this.timer) return;\n this.timer.pause();\n };\n\n handleMouseLeave = () => {\n if (!this.timer) return;\n this.timer.resume();\n };\n\n handleBodyMouseMove = (event: MouseEvent) => {\n if (!this.timer?.paused) return;\n const rect = this.ref.current?.getBoundingClientRect();\n if (!rect) return;\n const mouseInRect =\n event.clientX >= rect.left &&\n event.clientX <= rect.right &&\n event.clientY >= rect.top &&\n event.clientY <= rect.bottom;\n if (mouseInRect) return;\n this.timer.resume();\n };\n\n render() {\n const SBubble = FocusLock;\n const SDismiss = Button;\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const SIcon = Flex;\n const {\n styles,\n getI18nText,\n visible,\n type,\n initialAnimation,\n animationDuration,\n icon,\n children,\n action,\n focusLock,\n } = this.props;\n\n return sstyled(styles)(\n <Animation\n initialAnimation={initialAnimation}\n visible={visible}\n duration={animationDuration}\n // @ts-ignore\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SBubble\n type={type}\n ref={this.ref}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onKeyDown={this.handleKeydown}\n role={type === 'warning' ? 'alert' : undefined}\n focusLock={focusLock}\n >\n <SDismiss\n aria-haspopup={undefined}\n type='button'\n use='tertiary'\n size='m'\n theme='invert'\n onClick={this.handleClose}\n aria-label={getI18nText('close')}\n active={false}\n title={getI18nText('close')}\n ref={this.closeButtonRef}\n data-hide-focus-hover-popper='true'\n >\n <Button.Addon tag={CloseIcon} color='icon-primary-invert' />\n </SDismiss>\n\n {isNode(icon)\n ? (\n <>\n <SIcon>{icon}</SIcon>\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n </>\n )\n : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n )}\n </SBubble>\n </Animation>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n}\n\n/**\n * NoticeBubble\n *\n * {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-api/|API} | {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-code/|Examples}\n */\nconst NoticeBubbleContainer = createComponent<\n Intergalactic.Component<'div', NoticeBubbleContainerProps>,\n typeof Notic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,EAAA,kBAAE4F,QAAmB,CAAC,EAC9B,IAAAU,eAAM,EAACT,MAAM,CAAC,gBAAG7I,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACwF,OAAO,EAAAN,KAAA,CAAAhF,EAAA,iBAAE6F,MAAgB,CAAC,GAAG,IACxC,CACV,CAAC,gBAGH7I,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACsF,QAAQ,EAAAJ,KAAA,CAAAhF,EAAA,+BACPhD,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACuF,QAAQ,EAAAL,KAAA,CAAAhF,EAAA,kBAAE4F,QAAmB,CAAC,EAC9B,IAAAU,eAAM,EAACT,MAAM,CAAC,gBAAG7I,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACwF,OAAO,EAAAN,KAAA,CAAAhF,EAAA,iBAAE6F,MAAgB,CAAC,GAAG,IACxC,CAET,CACA,CAAC;EAEhB;AACF;AAEA,MAAMjG,WAAW,SAASC,QAAQ,CAAC;;AAOnC;AACA;AACA;AACA;AACA;AAJA,IAAAlC,gBAAA,CAAAC,OAAA,EAPMgC,WAAW,kBACO;EACpBD,IAAI,EAAE,SAAS;EACfP,QAAQ,EAAE;AACZ,CAAC;AAQH,MAAMoH,qBAAqB,GAAG,IAAAC,qBAAe,EAG3ClJ,yBAAyB,CAAC;AAAC,IAAAmJ,QAAA,GAAAC,OAAA,CAAA/I,OAAA,GAEd4I,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["_core","require","_baseComponents","_button","_interopRequireDefault","_i18nEnhance","_fire","_isNode","_ref7","_ThemeProvider","_useFocusLock","_useCssVariable","_zIndexStacking","_m","_react","_NoticeBubbleManager","_intergalacticDynamicLocales","_utils","style","sstyled","insert","NoticeBubbleContainerRoot","Component","constructor","args","_defineProperty2","default","notices","infos","warnings","_unsubscribe","setState","forceUpdate","componentDidMount","asProps","manager","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","Box","SNoticeAriaLiveWrapper","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","uid","filter","ZIndexStackingContextProvider","Portal","assignProps","_ref4","_ref5","i18nEnhance","localizedMessages","contextThemeEnhance","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","React","forwardRef","props","outerRef","focusLock","other","innerRef","useRef","useFocusLock","useForkRef","Flex","_extends2","showContent","setShowContent","useState","useEffect","setTimeout","tag","Tag","otherProps","designToken","nodeToMount","createRef","e","fire","clearTimer","key","handleClose","timer","pause","resume","isFocusInBubble","event","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","Timer","document","body","addEventListener","handleBodyMouseMove","triggerButtonComponent","activeElement","componentWillUnmount","triggerElement","isFocusInside","HTMLElement","setFocus","removeEventListener","noticeElement","clear","_ref6","SBubble","SDismiss","Button","SContent","SMessage","SAction","SIcon","visible","initialAnimation","animationDuration","icon","children","action","Animation","handleMouseEnter","handleMouseLeave","handleFocus","handleBlur","handleKeydown","handleClick","undefined","closeButtonRef","Addon","CloseIcon","color","isNode","Fragment","NoticeBubbleContainer","createComponent","_default","exports"],"sources":["../../src/NoticeBubble.tsx"],"sourcesContent":["import { Animation, Box, Flex, Portal, ScreenReaderOnly } from '@semcore/base-components';\nimport Button from '@semcore/button';\nimport { createComponent, Component, sstyled, Root, lastInteraction } from '@semcore/core';\nimport type { Intergalactic } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport fire from '@semcore/core/lib/utils/fire';\nimport { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';\nimport isNode from '@semcore/core/lib/utils/isNode';\nimport { useForkRef } from '@semcore/core/lib/utils/ref';\nimport { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';\nimport { setFocus, isFocusInside, useFocusLock } from '@semcore/core/lib/utils/use/useFocusLock';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport {\n ZIndexStackingContextProvider,\n zIndexStackingEnhance,\n} from '@semcore/core/lib/utils/zIndexStacking';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport React from 'react';\n\nimport type {\n NoticeBubbleContainerDefaultProps,\n NoticeBubbleContainerProps,\n NoticeBubbleViewItemProps,\n} from './NoticeBubble.type';\nimport type { NoticeItem } from './NoticeBubbleManager';\nimport manager from './NoticeBubbleManager';\nimport style from './style/notice-bubble.shadow.css';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport { Timer } from './utils';\n\ntype State = {\n notices: NoticeItem[];\n infos: NoticeItem[];\n warnings: NoticeItem[];\n};\n\nclass NoticeBubbleContainerRoot extends Component<\n NoticeBubbleContainerProps,\n typeof NoticeBubbleContainerRoot.enhance,\n {},\n WithI18nEnhanceProps,\n State,\n NoticeBubbleContainerDefaultProps\n> {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [\n i18nEnhance(localizedMessages),\n contextThemeEnhance(),\n zIndexStackingEnhance('z-index-notice-bubble'),\n cssVariableEnhance<'duration', number, number>({\n variable: '--intergalactic-duration-popper',\n fallback: 200,\n map: (v: string) => Number.parseInt(v, 10),\n prop: 'duration',\n }),\n ] as const;\n\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\n } as const;\n\n _unsubscribe: (() => void) | null = null;\n\n state: State = {\n notices: [],\n infos: [],\n warnings: [],\n };\n\n componentDidMount() {\n this._unsubscribe = this.asProps.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices: NoticeItem[]) => {\n this.setState({ notices });\n this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different\n };\n\n render() {\n const SNoticeBubble = Root;\n const SNoticeAriaLiveWrapper = 'div';\n const { Children, styles, disablePortal, getI18nText, ref, parentZIndexStacking, duration, containerNode } =\n this.asProps;\n const { notices } = this.state;\n\n if (containerNode) {\n return notices.map((notice) => {\n const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;\n\n return sstyled(styles)(\n <PortalForNoticeItem\n key={notice.uid}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n tag={SView}\n />,\n );\n });\n }\n\n const infos = notices.filter((notice) => notice.type === 'info');\n const warnings = notices.filter((notice) => notice.type === 'warning');\n\n return sstyled(styles)(\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble\n render={Box}\n ref={ref}\n tag='section'\n role='region'\n aria-label={getI18nText('notification')}\n zIndex={parentZIndexStacking}\n >\n <Children />\n {warnings.map((notice) => {\n const SView = ViewWarning;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {infos.map((notice) => {\n const SView = ViewInfo;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n </SNoticeAriaLiveWrapper>\n </SNoticeBubble>\n </Portal>\n </ZIndexStackingContextProvider>,\n );\n }\n}\n\nconst FocusLock = React.forwardRef((props: any, outerRef: React.ForwardedRef<HTMLDivElement>) => {\n const { focusLock, ...other } = props;\n const innerRef = React.useRef<HTMLDivElement | null>(null);\n useFocusLock(innerRef, false, 'auto', !focusLock, true);\n const ref = useForkRef(outerRef, innerRef);\n\n return <Flex ref={ref} {...other} />;\n});\n\nconst PortalForNoticeItem = (props: Intergalactic.InternalTypings.EfficientOmit<NoticeBubbleViewItemProps, 'tag'> & { containerNode: HTMLElement; tag: typeof ViewInfo }) => {\n const [showContent, setShowContent] = React.useState(false);\n\n // Show content for info notice in previously mounted node with aria-live polite\n React.useEffect(() => {\n setTimeout(() => {\n setShowContent(true);\n }, 200);\n }, []);\n\n const SNoticeAriaLiveWrapper = 'div';\n const { tag: Tag, ...otherProps } = props;\n\n if (otherProps.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...otherProps} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <Tag {...otherProps} />\n </Portal>\n </ZIndexStackingContextProvider>\n );\n};\n\nclass ViewInfo extends Component<NoticeBubbleViewItemProps> {\n timer: Timer | null = null;\n ref = React.createRef<HTMLDivElement>();\n closeButtonRef = React.createRef<HTMLButtonElement>();\n triggerButtonComponent: Element | null = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handleClose, duration);\n document.body.addEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n this.triggerButtonComponent = document.activeElement;\n }\n\n componentWillUnmount() {\n const triggerElement = this.triggerButtonComponent;\n if (this.ref.current && isFocusInside(this.ref.current) && triggerElement instanceof HTMLElement) {\n setTimeout(() => setFocus(triggerElement), 0);\n }\n\n this.clearTimer();\n document.body.removeEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n isFocusInBubble() {\n const noticeElement = this.ref.current;\n\n return noticeElement ? isFocusInside(noticeElement) : false;\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handleClose = (e: React.SyntheticEvent) => {\n // because it might be called not only from the close icon click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handleKeydown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.handleClose(e);\n }\n };\n\n handleFocus = () => {\n this.timer?.pause();\n };\n\n handleBlur = () => {\n this.timer?.resume();\n };\n\n handleClick = () => {\n this.timer?.pause();\n };\n\n handleMouseEnter = () => {\n this.timer?.pause();\n };\n\n handleMouseLeave = () => {\n if (!this.timer || this.isFocusInBubble()) return;\n this.timer.resume();\n };\n\n handleBodyMouseMove = (event: MouseEvent) => {\n if (!this.timer?.paused || this.isFocusInBubble()) return;\n const rect = this.ref.current?.getBoundingClientRect();\n if (!rect) return;\n const mouseInRect =\n event.clientX >= rect.left &&\n event.clientX <= rect.right &&\n event.clientY >= rect.top &&\n event.clientY <= rect.bottom;\n if (mouseInRect) return;\n this.timer.resume();\n };\n\n render() {\n const SBubble = FocusLock;\n const SDismiss = Button;\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const SIcon = Flex;\n const {\n styles,\n getI18nText,\n visible,\n type,\n initialAnimation,\n animationDuration,\n icon,\n children,\n action,\n focusLock,\n } = this.props;\n\n return sstyled(styles)(\n <Animation\n initialAnimation={initialAnimation}\n visible={visible}\n duration={animationDuration}\n // @ts-ignore\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SBubble\n render={Flex}\n type={type}\n ref={this.ref}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeydown}\n onClick={this.handleClick}\n role={type === 'warning' ? 'alert' : undefined}\n focusLock={focusLock}\n >\n <SDismiss\n aria-haspopup={undefined}\n type='button'\n use='tertiary'\n size='m'\n theme='invert'\n onClick={this.handleClose}\n aria-label={getI18nText('close')}\n active={false}\n title={getI18nText('close')}\n ref={this.closeButtonRef}\n data-hide-focus-hover-popper='true'\n >\n <Button.Addon tag={CloseIcon} color='icon-primary-invert' />\n </SDismiss>\n\n {isNode(icon)\n ? (\n <>\n <SIcon>{icon}</SIcon>\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n </>\n )\n : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n )}\n </SBubble>\n </Animation>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n}\n\n/**\n * NoticeBubble\n *\n * {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-api/|API} | {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-code/|Examples}\n */\nconst NoticeBubbleContainer = createComponent<\n Intergalactic.Component<'div', NoticeBubbleContainerProps>,\n typeof NoticeBubbleContainerRoot\n>(NoticeBubbleContainerRoot);\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AAIA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,KAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,OAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,cAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,eAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAIA,IAAAY,EAAA,GAAAT,sBAAA,CAAAH,OAAA;AACA,IAAAa,MAAA,GAAAV,sBAAA,CAAAH,OAAA;AAQA,IAAAc,oBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAEA,IAAAe,4BAAA,GAAAf,OAAA;AACA,IAAAgB,MAAA,GAAAhB,OAAA;AAAgC;AAAA,MAAAiB,KAAA,8BAAAlB,KAAA,CAAAmB,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;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AC,gBAGH9I,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACuF,QAAQ,EAAAJ,KAAA,CAAAjF,EAAA,+BACPhD,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACwF,QAAQ,EAAAL,KAAA,CAAAjF,EAAA,kBAAE6F,QAAmB,CAAC,EAC9B,IAAAc,eAAM,EAACb,MAAM,CAAC,gBAAG9I,MAAA,CAAAY,OAAA,CAAAkC,aAAA,CAACyF,OAAO,EAAAN,KAAA,CAAAjF,EAAA,iBAAE8F,MAAgB,CAAC,GAAG,IACxC,CAET,CACA,CAAC;EAEhB;AACF;AAEA,MAAMlG,WAAW,SAASC,QAAQ,CAAC;;AAOnC;AACA;AACA;AACA;AACA;AAJA,IAAAlC,gBAAA,CAAAC,OAAA,EAPMgC,WAAW,kBACO;EACpBD,IAAI,EAAE,SAAS;EACfP,QAAQ,EAAE;AACZ,CAAC;AAQH,MAAMyH,qBAAqB,GAAG,IAAAC,qBAAe,EAG3CvJ,yBAAyB,CAAC;AAAC,IAAAwJ,QAAA,GAAAC,OAAA,CAAApJ,OAAA,GAEdiJ,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.type.js","names":[],"sources":["../../src/NoticeBubble.type.ts"],"sourcesContent":["import type { PortalProps, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';\nimport type { RefObject } from 'react';\n\nimport type { NoticeBubbleManager, NoticeItem } from './NoticeBubbleManager';\nimport type { LocalizedMessages } from './translations/__intergalactic-dynamic-locales';\n\n/**\n * @deprecated. Pass noticeBubbleContainer property from window.sm2.getNoticeBubbleContainer()\n */\nexport type NoticeBubbleContainerPortalProps = PortalProps;\n\nexport type NoticeBubbleContainerProps = BoxProps &\n NoticeBubbleContainerPortalProps & {\n /** Ref to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */\n containerNode?: HTMLElement | null;\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n /** Specifies the locale for i18n support */\n locale?: string;\n };\n\nexport type NoticeBubbleContainerDefaultProps = {\n manager: NoticeBubbleManagerClass;\n i18n: LocalizedMessages;\n locale: 'en';\n};\n\nexport type NoticeBubbleViewItemProps = NoticeBubbleProps & {\n containerNode?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /** Add change listener */\n addListener: (fn: (items: NoticeItem[]) => void) => (() => void);\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.type.js","names":[],"sources":["../../src/NoticeBubble.type.ts"],"sourcesContent":["import type { PortalProps, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';\nimport type { RefObject } from 'react';\n\nimport type { NoticeBubbleManager, NoticeItem } from './NoticeBubbleManager';\nimport type { LocalizedMessages } from './translations/__intergalactic-dynamic-locales';\n\n/**\n * @deprecated. Pass noticeBubbleContainer property from window.sm2.getNoticeBubbleContainer()\n */\nexport type NoticeBubbleContainerPortalProps = PortalProps;\n\nexport type NoticeBubbleContainerProps = BoxProps &\n NoticeBubbleContainerPortalProps & {\n /** Ref to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */\n containerNode?: HTMLElement | null;\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n /** Specifies the locale for i18n support */\n locale?: string;\n };\n\nexport type NoticeBubbleContainerDefaultProps = {\n manager: NoticeBubbleManagerClass;\n i18n: LocalizedMessages;\n locale: 'en';\n};\n\nexport type NoticeBubbleViewItemProps = NoticeBubbleProps & {\n containerNode?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n *\n * @deprecated\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /** Add change listener */\n addListener: (fn: (items: NoticeItem[]) => void) => (() => void);\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
|
package/lib/cjs/utils.js
CHANGED
package/lib/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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.paused) return;\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,CAACF,MAAM,EAAE;IACjB,IAAI,IAAI,CAACG,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
|
@@ -7,34 +7,33 @@ import Button from '@semcore/button';
|
|
|
7
7
|
import { createComponent, Component, sstyled, Root } from '@semcore/core';
|
|
8
8
|
import i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';
|
|
9
9
|
import fire from '@semcore/core/lib/utils/fire';
|
|
10
|
-
import { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';
|
|
11
10
|
import isNode from '@semcore/core/lib/utils/isNode';
|
|
12
11
|
import { useForkRef } from '@semcore/core/lib/utils/ref';
|
|
13
12
|
import { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';
|
|
14
|
-
import {
|
|
13
|
+
import { setFocus, isFocusInside, useFocusLock } from '@semcore/core/lib/utils/use/useFocusLock';
|
|
15
14
|
import { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';
|
|
16
15
|
import { ZIndexStackingContextProvider, zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';
|
|
17
16
|
import CloseIcon from '@semcore/icon/Close/m';
|
|
18
17
|
import React from 'react';
|
|
19
18
|
import manager from './NoticeBubbleManager';
|
|
20
19
|
/*!__reshadow-styles__:"./style/notice-bubble.shadow.css"*/
|
|
21
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
20
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SBubble_1y8gb_gg_,.___SView_1y8gb_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,oklch(.999 .001 180/.949));gap:var(--intergalactic-spacing-2x,8px)}.___SBubble_1y8gb_gg_._type_info_1y8gb_gg_,.___SView_1y8gb_gg_._type_info_1y8gb_gg_{background:var(--intergalactic-bg-primary-invert,oklch(.23 .01 140))}.___SBubble_1y8gb_gg_._type_warning_1y8gb_gg_,.___SView_1y8gb_gg_._type_warning_1y8gb_gg_{background:var(--intergalactic-bg-primary-critical,oklch(.64 .226 24.5))}.___SContent_1y8gb_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x,8px);flex:1}.___SMessage_1y8gb_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%)}.___SDismiss_1y8gb_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:#0000}.___SDismiss_1y8gb_gg_.__use_1y8gb_gg_{padding:0 1px}.___SIcon_1y8gb_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x,20px)}.___SNoticeBubble_1y8gb_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x,12px);top:var(--intergalactic-spacing-3x,12px)}@media (max-width:767px){.___SNoticeBubble_1y8gb_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_1y8gb_gg_.__disablePortal_1y8gb_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_1y8gb_gg_ a{color:var(--intergalactic-text-link-invert,oklch(.75 .125 265.3))}.___SNoticeAriaLiveWrapper_1y8gb_gg_{display:contents}@keyframes enter_1y8gb{0%{transform:translate(100%);max-height:0;overflow:hidden}to{transform:translate(0);max-height:100vh;overflow:hidden}}@keyframes exit_1y8gb{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}", /*__inner_css_end__*/"1y8gb_gg_"),
|
|
22
21
|
/*__reshadow_css_end__*/
|
|
23
22
|
{
|
|
24
|
-
"__SContent": "
|
|
25
|
-
"__SMessage": "
|
|
26
|
-
"__SDismiss": "
|
|
27
|
-
"_use": "
|
|
28
|
-
"__SIcon": "
|
|
29
|
-
"__SNoticeBubble": "
|
|
30
|
-
"_disablePortal": "
|
|
31
|
-
"__SNoticeAriaLiveWrapper": "
|
|
32
|
-
"@enter": "
|
|
33
|
-
"@exit": "
|
|
34
|
-
"__SBubble": "
|
|
35
|
-
"__SView": "
|
|
36
|
-
"_type_info": "
|
|
37
|
-
"_type_warning": "
|
|
23
|
+
"__SContent": "___SContent_1y8gb_gg_",
|
|
24
|
+
"__SMessage": "___SMessage_1y8gb_gg_",
|
|
25
|
+
"__SDismiss": "___SDismiss_1y8gb_gg_",
|
|
26
|
+
"_use": "__use_1y8gb_gg_",
|
|
27
|
+
"__SIcon": "___SIcon_1y8gb_gg_",
|
|
28
|
+
"__SNoticeBubble": "___SNoticeBubble_1y8gb_gg_",
|
|
29
|
+
"_disablePortal": "__disablePortal_1y8gb_gg_",
|
|
30
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_1y8gb_gg_",
|
|
31
|
+
"@enter": "enter_1y8gb",
|
|
32
|
+
"@exit": "exit_1y8gb",
|
|
33
|
+
"__SBubble": "___SBubble_1y8gb_gg_",
|
|
34
|
+
"__SView": "___SView_1y8gb_gg_",
|
|
35
|
+
"_type_info": "_type_info_1y8gb_gg_",
|
|
36
|
+
"_type_warning": "_type_warning_1y8gb_gg_"
|
|
38
37
|
});
|
|
39
38
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
40
39
|
import { Timer } from './utils';
|
|
@@ -194,6 +193,7 @@ class ViewInfo extends Component {
|
|
|
194
193
|
_defineProperty(this, "timer", null);
|
|
195
194
|
_defineProperty(this, "ref", /*#__PURE__*/React.createRef());
|
|
196
195
|
_defineProperty(this, "closeButtonRef", /*#__PURE__*/React.createRef());
|
|
196
|
+
_defineProperty(this, "triggerButtonComponent", null);
|
|
197
197
|
_defineProperty(this, "handleClose", e => {
|
|
198
198
|
// because it might be called not only from the close icon click
|
|
199
199
|
fire(this, 'onClose', e);
|
|
@@ -204,16 +204,24 @@ class ViewInfo extends Component {
|
|
|
204
204
|
this.handleClose(e);
|
|
205
205
|
}
|
|
206
206
|
});
|
|
207
|
+
_defineProperty(this, "handleFocus", () => {
|
|
208
|
+
this.timer?.pause();
|
|
209
|
+
});
|
|
210
|
+
_defineProperty(this, "handleBlur", () => {
|
|
211
|
+
this.timer?.resume();
|
|
212
|
+
});
|
|
213
|
+
_defineProperty(this, "handleClick", () => {
|
|
214
|
+
this.timer?.pause();
|
|
215
|
+
});
|
|
207
216
|
_defineProperty(this, "handleMouseEnter", () => {
|
|
208
|
-
|
|
209
|
-
this.timer.pause();
|
|
217
|
+
this.timer?.pause();
|
|
210
218
|
});
|
|
211
219
|
_defineProperty(this, "handleMouseLeave", () => {
|
|
212
|
-
if (!this.timer) return;
|
|
220
|
+
if (!this.timer || this.isFocusInBubble()) return;
|
|
213
221
|
this.timer.resume();
|
|
214
222
|
});
|
|
215
223
|
_defineProperty(this, "handleBodyMouseMove", event => {
|
|
216
|
-
if (!this.timer?.paused) return;
|
|
224
|
+
if (!this.timer?.paused || this.isFocusInBubble()) return;
|
|
217
225
|
const rect = this.ref.current?.getBoundingClientRect();
|
|
218
226
|
if (!rect) return;
|
|
219
227
|
const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
@@ -229,18 +237,20 @@ class ViewInfo extends Component {
|
|
|
229
237
|
this.timer = new Timer(this.handleClose, duration);
|
|
230
238
|
document.body.addEventListener('mousemove', this.handleBodyMouseMove);
|
|
231
239
|
}
|
|
232
|
-
|
|
233
|
-
if (noticeElement) {
|
|
234
|
-
const focusableNodes = getFocusableIn(noticeElement).filter(node => node !== this.closeButtonRef.current);
|
|
235
|
-
if (focusableNodes.length > 0) {
|
|
236
|
-
setTimeout(() => setFocus(noticeElement), 0);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
240
|
+
this.triggerButtonComponent = document.activeElement;
|
|
239
241
|
}
|
|
240
242
|
componentWillUnmount() {
|
|
243
|
+
const triggerElement = this.triggerButtonComponent;
|
|
244
|
+
if (this.ref.current && isFocusInside(this.ref.current) && triggerElement instanceof HTMLElement) {
|
|
245
|
+
setTimeout(() => setFocus(triggerElement), 0);
|
|
246
|
+
}
|
|
241
247
|
this.clearTimer();
|
|
242
248
|
document.body.removeEventListener('mousemove', this.handleBodyMouseMove);
|
|
243
249
|
}
|
|
250
|
+
isFocusInBubble() {
|
|
251
|
+
const noticeElement = this.ref.current;
|
|
252
|
+
return noticeElement ? isFocusInside(noticeElement) : false;
|
|
253
|
+
}
|
|
244
254
|
clearTimer() {
|
|
245
255
|
if (this.timer) {
|
|
246
256
|
this.timer.clear();
|
|
@@ -273,11 +283,15 @@ class ViewInfo extends Component {
|
|
|
273
283
|
"duration": animationDuration,
|
|
274
284
|
"keyframes": [styles['@enter'], styles['@exit']]
|
|
275
285
|
}), /*#__PURE__*/React.createElement(SBubble, _ref6.cn("SBubble", {
|
|
286
|
+
"render": Flex,
|
|
276
287
|
"type": type,
|
|
277
288
|
"ref": this.ref,
|
|
278
289
|
"onMouseEnter": this.handleMouseEnter,
|
|
279
290
|
"onMouseLeave": this.handleMouseLeave,
|
|
291
|
+
"onFocus": this.handleFocus,
|
|
292
|
+
"onBlur": this.handleBlur,
|
|
280
293
|
"onKeyDown": this.handleKeydown,
|
|
294
|
+
"onClick": this.handleClick,
|
|
281
295
|
"role": type === 'warning' ? 'alert' : undefined,
|
|
282
296
|
"focusLock": focusLock
|
|
283
297
|
}), /*#__PURE__*/React.createElement(SDismiss, _ref6.cn("SDismiss", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.js","names":["Animation","Box","Flex","Portal","Button","createComponent","Component","sstyled","Root","i18nEnhance","fire","getFocusableIn","isNode","useForkRef","contextThemeEnhance","useFocusLock","setFocus","cssVariableEnhance","ZIndexStackingContextProvider","zIndexStackingEnhance","CloseIcon","React","manager","style","_sstyled","insert","localizedMessages","Timer","NoticeBubbleContainerRoot","constructor","args","_defineProperty","notices","infos","warnings","_unsubscribe","setState","forceUpdate","componentDidMount","asProps","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","SNoticeAriaLiveWrapper","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","uid","filter","_assignProps","_ref4","_ref5","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","forwardRef","props","outerRef","focusLock","other","innerRef","useRef","_extends","showContent","setShowContent","useState","useEffect","setTimeout","tag","Tag","otherProps","designToken","nodeToMount","createRef","e","clearTimer","key","handleClose","timer","pause","resume","event","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","document","body","addEventListener","handleBodyMouseMove","noticeElement","focusableNodes","node","closeButtonRef","length","componentWillUnmount","removeEventListener","clear","_ref6","SBubble","SDismiss","SContent","SMessage","SAction","SIcon","visible","initialAnimation","animationDuration","icon","children","action","handleMouseEnter","handleMouseLeave","handleKeydown","undefined","Addon","color","Fragment","NoticeBubbleContainer"],"sources":["../../src/NoticeBubble.tsx"],"sourcesContent":["import { Animation, Box, Flex, Portal } from '@semcore/base-components';\nimport Button from '@semcore/button';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport type { Intergalactic } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport fire from '@semcore/core/lib/utils/fire';\nimport { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';\nimport isNode from '@semcore/core/lib/utils/isNode';\nimport { useForkRef } from '@semcore/core/lib/utils/ref';\nimport { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';\nimport { useFocusLock, setFocus } from '@semcore/core/lib/utils/use/useFocusLock';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport {\n ZIndexStackingContextProvider,\n zIndexStackingEnhance,\n} from '@semcore/core/lib/utils/zIndexStacking';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport React from 'react';\n\nimport type {\n NoticeBubbleContainerDefaultProps,\n NoticeBubbleContainerProps,\n NoticeBubbleViewItemProps,\n} from './NoticeBubble.type';\nimport type { NoticeItem } from './NoticeBubbleManager';\nimport manager from './NoticeBubbleManager';\nimport style from './style/notice-bubble.shadow.css';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport { Timer } from './utils';\n\ntype State = {\n notices: NoticeItem[];\n infos: NoticeItem[];\n warnings: NoticeItem[];\n};\n\nclass NoticeBubbleContainerRoot extends Component<\n NoticeBubbleContainerProps,\n typeof NoticeBubbleContainerRoot.enhance,\n {},\n WithI18nEnhanceProps,\n State,\n NoticeBubbleContainerDefaultProps\n> {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [\n i18nEnhance(localizedMessages),\n contextThemeEnhance(),\n zIndexStackingEnhance('z-index-notice-bubble'),\n cssVariableEnhance<'duration', number, number>({\n variable: '--intergalactic-duration-popper',\n fallback: 200,\n map: (v: string) => Number.parseInt(v, 10),\n prop: 'duration',\n }),\n ] as const;\n\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\n } as const;\n\n _unsubscribe: (() => void) | null = null;\n\n state: State = {\n notices: [],\n infos: [],\n warnings: [],\n };\n\n componentDidMount() {\n this._unsubscribe = this.asProps.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices: NoticeItem[]) => {\n this.setState({ notices });\n this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different\n };\n\n render() {\n const SNoticeBubble = Root;\n const SNoticeAriaLiveWrapper = 'div';\n const { Children, styles, disablePortal, getI18nText, ref, parentZIndexStacking, duration, containerNode } =\n this.asProps;\n const { notices } = this.state;\n\n if (containerNode) {\n return notices.map((notice) => {\n const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;\n\n return sstyled(styles)(\n <PortalForNoticeItem\n key={notice.uid}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n tag={SView}\n />,\n );\n });\n }\n\n const infos = notices.filter((notice) => notice.type === 'info');\n const warnings = notices.filter((notice) => notice.type === 'warning');\n\n return sstyled(styles)(\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble\n render={Box}\n ref={ref}\n tag='section'\n role='region'\n aria-label={getI18nText('notification')}\n zIndex={parentZIndexStacking}\n >\n <Children />\n {warnings.map((notice) => {\n const SView = ViewWarning;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {infos.map((notice) => {\n const SView = ViewInfo;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n </SNoticeAriaLiveWrapper>\n </SNoticeBubble>\n </Portal>\n </ZIndexStackingContextProvider>,\n );\n }\n}\n\nconst FocusLock = React.forwardRef((props: any, outerRef: React.ForwardedRef<HTMLDivElement>) => {\n const { focusLock, ...other } = props;\n const innerRef = React.useRef<HTMLDivElement | null>(null);\n useFocusLock(innerRef, false, 'auto', !focusLock, true);\n const ref = useForkRef(outerRef, innerRef);\n\n return <Flex ref={ref} {...other} />;\n});\n\nconst PortalForNoticeItem = (props: Intergalactic.InternalTypings.EfficientOmit<NoticeBubbleViewItemProps, 'tag'> & { containerNode: HTMLElement; tag: typeof ViewInfo }) => {\n const [showContent, setShowContent] = React.useState(false);\n\n // Show content for info notice in previously mounted node with aria-live polite\n React.useEffect(() => {\n setTimeout(() => {\n setShowContent(true);\n }, 200);\n }, []);\n\n const SNoticeAriaLiveWrapper = 'div';\n const { tag: Tag, ...otherProps } = props;\n\n if (otherProps.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...otherProps} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <Tag {...otherProps} />\n </Portal>\n </ZIndexStackingContextProvider>\n );\n};\n\nclass ViewInfo extends Component<NoticeBubbleViewItemProps> {\n timer: Timer | null = null;\n ref = React.createRef<HTMLDivElement>();\n closeButtonRef = React.createRef<HTMLButtonElement>();\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handleClose, duration);\n document.body.addEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n const noticeElement = this.ref.current;\n\n if (noticeElement) {\n const focusableNodes = getFocusableIn(noticeElement).filter(\n (node) => node !== this.closeButtonRef.current,\n );\n\n if (focusableNodes.length > 0) {\n setTimeout(() => setFocus(noticeElement), 0);\n }\n }\n }\n\n componentWillUnmount() {\n this.clearTimer();\n document.body.removeEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handleClose = (e: React.SyntheticEvent) => {\n // because it might be called not only from the close icon click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handleKeydown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.handleClose(e);\n }\n };\n\n handleMouseEnter = () => {\n if (!this.timer) return;\n this.timer.pause();\n };\n\n handleMouseLeave = () => {\n if (!this.timer) return;\n this.timer.resume();\n };\n\n handleBodyMouseMove = (event: MouseEvent) => {\n if (!this.timer?.paused) return;\n const rect = this.ref.current?.getBoundingClientRect();\n if (!rect) return;\n const mouseInRect =\n event.clientX >= rect.left &&\n event.clientX <= rect.right &&\n event.clientY >= rect.top &&\n event.clientY <= rect.bottom;\n if (mouseInRect) return;\n this.timer.resume();\n };\n\n render() {\n const SBubble = FocusLock;\n const SDismiss = Button;\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const SIcon = Flex;\n const {\n styles,\n getI18nText,\n visible,\n type,\n initialAnimation,\n animationDuration,\n icon,\n children,\n action,\n focusLock,\n } = this.props;\n\n return sstyled(styles)(\n <Animation\n initialAnimation={initialAnimation}\n visible={visible}\n duration={animationDuration}\n // @ts-ignore\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SBubble\n type={type}\n ref={this.ref}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onKeyDown={this.handleKeydown}\n role={type === 'warning' ? 'alert' : undefined}\n focusLock={focusLock}\n >\n <SDismiss\n aria-haspopup={undefined}\n type='button'\n use='tertiary'\n size='m'\n theme='invert'\n onClick={this.handleClose}\n aria-label={getI18nText('close')}\n active={false}\n title={getI18nText('close')}\n ref={this.closeButtonRef}\n data-hide-focus-hover-popper='true'\n >\n <Button.Addon tag={CloseIcon} color='icon-primary-invert' />\n </SDismiss>\n\n {isNode(icon)\n ? (\n <>\n <SIcon>{icon}</SIcon>\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n </>\n )\n : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n )}\n </SBubble>\n </Animation>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n}\n\n/**\n * NoticeBubble\n *\n * {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-api/|API} | {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-code/|Examples}\n */\nconst NoticeBubbleContainer = createComponent<\n Intergalactic.Component<'div', NoticeBubbleContainerProps>,\n typeof NoticeBubbleContainerRoot\n>(NoticeBubbleContainerRoot);\n\nexport default NoticeBubbleContainer;\n"],"mappings":";;;;AAAA,SAASA,SAAS,EAAEC,GAAG,EAAEC,IAAI,EAAEC,MAAM,QAAQ,0BAA0B;AACvE,OAAOC,MAAM,MAAM,iBAAiB;AACpC,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AAGzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,IAAI,MAAM,8BAA8B;AAC/C,SAASC,cAAc,QAAQ,mDAAmD;AAClF,OAAOC,MAAM,MAAM,gCAAgC;AACnD,SAASC,UAAU,QAAQ,6BAA6B;AACxD,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,YAAY,EAAEC,QAAQ,QAAQ,0CAA0C;AACjF,SAASC,kBAAkB,QAAQ,wCAAw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CACV,CAAC,gBAGHzH,KAAA,CAAA0C,aAAA,CAACsE,QAAQ,EAAAH,KAAA,CAAAjE,EAAA,+BACP5C,KAAA,CAAA0C,aAAA,CAACuE,QAAQ,EAAAJ,KAAA,CAAAjE,EAAA,kBAAE4E,QAAmB,CAAC,EAC9BjI,MAAM,CAACkI,MAAM,CAAC,gBAAGzH,KAAA,CAAA0C,aAAA,CAACwE,OAAO,EAAAL,KAAA,CAAAjE,EAAA,iBAAE6E,MAAgB,CAAC,GAAG,IACxC,CAET,CACA,CAAC;EAEhB;AACF;AAEA,MAAMjF,WAAW,SAASC,QAAQ,CAAC;;AAOnC;AACA;AACA;AACA;AACA;AAJA/B,eAAA,CAPM8B,WAAW,kBACO;EACpBD,IAAI,EAAE,SAAS;EACfP,QAAQ,EAAE;AACZ,CAAC;AAQH,MAAMiG,qBAAqB,GAAGjJ,eAAe,CAG3CuB,yBAAyB,CAAC;AAE5B,eAAe0H,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.js","names":["Animation","Box","Flex","Portal","Button","createComponent","Component","sstyled","Root","i18nEnhance","fire","isNode","useForkRef","contextThemeEnhance","setFocus","isFocusInside","useFocusLock","cssVariableEnhance","ZIndexStackingContextProvider","zIndexStackingEnhance","CloseIcon","React","manager","style","_sstyled","insert","localizedMessages","Timer","NoticeBubbleContainerRoot","constructor","args","_defineProperty","notices","infos","warnings","_unsubscribe","setState","forceUpdate","componentDidMount","asProps","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","SNoticeAriaLiveWrapper","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","uid","filter","_assignProps","_ref4","_ref5","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","forwardRef","props","outerRef","focusLock","other","innerRef","useRef","_extends","showContent","setShowContent","useState","useEffect","setTimeout","tag","Tag","otherProps","designToken","nodeToMount","createRef","e","clearTimer","key","handleClose","timer","pause","resume","isFocusInBubble","event","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","document","body","addEventListener","handleBodyMouseMove","triggerButtonComponent","activeElement","componentWillUnmount","triggerElement","HTMLElement","removeEventListener","noticeElement","clear","_ref6","SBubble","SDismiss","SContent","SMessage","SAction","SIcon","visible","initialAnimation","animationDuration","icon","children","action","handleMouseEnter","handleMouseLeave","handleFocus","handleBlur","handleKeydown","handleClick","undefined","closeButtonRef","Addon","color","Fragment","NoticeBubbleContainer"],"sources":["../../src/NoticeBubble.tsx"],"sourcesContent":["import { Animation, Box, Flex, Portal, ScreenReaderOnly } from '@semcore/base-components';\nimport Button from '@semcore/button';\nimport { createComponent, Component, sstyled, Root, lastInteraction } from '@semcore/core';\nimport type { Intergalactic } from '@semcore/core';\nimport type { WithI18nEnhanceProps } from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport i18nEnhance from '@semcore/core/lib/utils/enhances/i18nEnhance';\nimport fire from '@semcore/core/lib/utils/fire';\nimport { getFocusableIn } from '@semcore/core/lib/utils/focus-lock/getFocusableIn';\nimport isNode from '@semcore/core/lib/utils/isNode';\nimport { useForkRef } from '@semcore/core/lib/utils/ref';\nimport { contextThemeEnhance } from '@semcore/core/lib/utils/ThemeProvider';\nimport { setFocus, isFocusInside, useFocusLock } from '@semcore/core/lib/utils/use/useFocusLock';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport {\n ZIndexStackingContextProvider,\n zIndexStackingEnhance,\n} from '@semcore/core/lib/utils/zIndexStacking';\nimport CloseIcon from '@semcore/icon/Close/m';\nimport React from 'react';\n\nimport type {\n NoticeBubbleContainerDefaultProps,\n NoticeBubbleContainerProps,\n NoticeBubbleViewItemProps,\n} from './NoticeBubble.type';\nimport type { NoticeItem } from './NoticeBubbleManager';\nimport manager from './NoticeBubbleManager';\nimport style from './style/notice-bubble.shadow.css';\nimport { localizedMessages } from './translations/__intergalactic-dynamic-locales';\nimport { Timer } from './utils';\n\ntype State = {\n notices: NoticeItem[];\n infos: NoticeItem[];\n warnings: NoticeItem[];\n};\n\nclass NoticeBubbleContainerRoot extends Component<\n NoticeBubbleContainerProps,\n typeof NoticeBubbleContainerRoot.enhance,\n {},\n WithI18nEnhanceProps,\n State,\n NoticeBubbleContainerDefaultProps\n> {\n static displayName = 'NoticeBubbleContainer';\n static style = style;\n static enhance = [\n i18nEnhance(localizedMessages),\n contextThemeEnhance(),\n zIndexStackingEnhance('z-index-notice-bubble'),\n cssVariableEnhance<'duration', number, number>({\n variable: '--intergalactic-duration-popper',\n fallback: 200,\n map: (v: string) => Number.parseInt(v, 10),\n prop: 'duration',\n }),\n ] as const;\n\n static defaultProps = {\n manager,\n i18n: localizedMessages,\n locale: 'en',\n } as const;\n\n _unsubscribe: (() => void) | null = null;\n\n state: State = {\n notices: [],\n infos: [],\n warnings: [],\n };\n\n componentDidMount() {\n this._unsubscribe = this.asProps.manager.addListener(this.handleChange);\n }\n\n componentWillUnmount = () => {\n if (this._unsubscribe) {\n this._unsubscribe();\n }\n };\n\n handleChange = (notices: NoticeItem[]) => {\n this.setState({ notices });\n this.forceUpdate(); // need this, because somehow this component doesn't rerender event if the notices are different\n };\n\n render() {\n const SNoticeBubble = Root;\n const SNoticeAriaLiveWrapper = 'div';\n const { Children, styles, disablePortal, getI18nText, ref, parentZIndexStacking, duration, containerNode } =\n this.asProps;\n const { notices } = this.state;\n\n if (containerNode) {\n return notices.map((notice) => {\n const SView = notice.type === 'warning' ? ViewWarning : ViewInfo;\n\n return sstyled(styles)(\n <PortalForNoticeItem\n key={notice.uid}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n tag={SView}\n />,\n );\n });\n }\n\n const infos = notices.filter((notice) => notice.type === 'info');\n const warnings = notices.filter((notice) => notice.type === 'warning');\n\n return sstyled(styles)(\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal disablePortal={disablePortal}>\n <SNoticeBubble\n render={Box}\n ref={ref}\n tag='section'\n role='region'\n aria-label={getI18nText('notification')}\n zIndex={parentZIndexStacking}\n >\n <Children />\n {warnings.map((notice) => {\n const SView = ViewWarning;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {infos.map((notice) => {\n const SView = ViewInfo;\n return sstyled(styles)(\n <SView\n key={notice.uid}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\n />,\n );\n })}\n </SNoticeAriaLiveWrapper>\n </SNoticeBubble>\n </Portal>\n </ZIndexStackingContextProvider>,\n );\n }\n}\n\nconst FocusLock = React.forwardRef((props: any, outerRef: React.ForwardedRef<HTMLDivElement>) => {\n const { focusLock, ...other } = props;\n const innerRef = React.useRef<HTMLDivElement | null>(null);\n useFocusLock(innerRef, false, 'auto', !focusLock, true);\n const ref = useForkRef(outerRef, innerRef);\n\n return <Flex ref={ref} {...other} />;\n});\n\nconst PortalForNoticeItem = (props: Intergalactic.InternalTypings.EfficientOmit<NoticeBubbleViewItemProps, 'tag'> & { containerNode: HTMLElement; tag: typeof ViewInfo }) => {\n const [showContent, setShowContent] = React.useState(false);\n\n // Show content for info notice in previously mounted node with aria-live polite\n React.useEffect(() => {\n setTimeout(() => {\n setShowContent(true);\n }, 200);\n }, []);\n\n const SNoticeAriaLiveWrapper = 'div';\n const { tag: Tag, ...otherProps } = props;\n\n if (otherProps.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...otherProps} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={otherProps.containerNode}>\n <Tag {...otherProps} />\n </Portal>\n </ZIndexStackingContextProvider>\n );\n};\n\nclass ViewInfo extends Component<NoticeBubbleViewItemProps> {\n timer: Timer | null = null;\n ref = React.createRef<HTMLDivElement>();\n closeButtonRef = React.createRef<HTMLButtonElement>();\n triggerButtonComponent: Element | null = null;\n\n componentDidMount() {\n const { duration } = this.props;\n if (duration) {\n this.timer = new Timer(this.handleClose, duration);\n document.body.addEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n this.triggerButtonComponent = document.activeElement;\n }\n\n componentWillUnmount() {\n const triggerElement = this.triggerButtonComponent;\n if (this.ref.current && isFocusInside(this.ref.current) && triggerElement instanceof HTMLElement) {\n setTimeout(() => setFocus(triggerElement), 0);\n }\n\n this.clearTimer();\n document.body.removeEventListener('mousemove', this.handleBodyMouseMove);\n }\n\n isFocusInBubble() {\n const noticeElement = this.ref.current;\n\n return noticeElement ? isFocusInside(noticeElement) : false;\n }\n\n clearTimer() {\n if (this.timer) {\n this.timer.clear();\n this.timer = null;\n }\n }\n\n handleClose = (e: React.SyntheticEvent) => {\n // because it might be called not only from the close icon click\n fire(this, 'onClose', e);\n this.clearTimer();\n };\n\n handleKeydown = (e: React.KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.handleClose(e);\n }\n };\n\n handleFocus = () => {\n this.timer?.pause();\n };\n\n handleBlur = () => {\n this.timer?.resume();\n };\n\n handleClick = () => {\n this.timer?.pause();\n };\n\n handleMouseEnter = () => {\n this.timer?.pause();\n };\n\n handleMouseLeave = () => {\n if (!this.timer || this.isFocusInBubble()) return;\n this.timer.resume();\n };\n\n handleBodyMouseMove = (event: MouseEvent) => {\n if (!this.timer?.paused || this.isFocusInBubble()) return;\n const rect = this.ref.current?.getBoundingClientRect();\n if (!rect) return;\n const mouseInRect =\n event.clientX >= rect.left &&\n event.clientX <= rect.right &&\n event.clientY >= rect.top &&\n event.clientY <= rect.bottom;\n if (mouseInRect) return;\n this.timer.resume();\n };\n\n render() {\n const SBubble = FocusLock;\n const SDismiss = Button;\n const SContent = Flex;\n const SMessage = 'div';\n const SAction = 'div';\n const SIcon = Flex;\n const {\n styles,\n getI18nText,\n visible,\n type,\n initialAnimation,\n animationDuration,\n icon,\n children,\n action,\n focusLock,\n } = this.props;\n\n return sstyled(styles)(\n <Animation\n initialAnimation={initialAnimation}\n visible={visible}\n duration={animationDuration}\n // @ts-ignore\n keyframes={[styles['@enter'], styles['@exit']]}\n >\n <SBubble\n render={Flex}\n type={type}\n ref={this.ref}\n onMouseEnter={this.handleMouseEnter}\n onMouseLeave={this.handleMouseLeave}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeydown}\n onClick={this.handleClick}\n role={type === 'warning' ? 'alert' : undefined}\n focusLock={focusLock}\n >\n <SDismiss\n aria-haspopup={undefined}\n type='button'\n use='tertiary'\n size='m'\n theme='invert'\n onClick={this.handleClose}\n aria-label={getI18nText('close')}\n active={false}\n title={getI18nText('close')}\n ref={this.closeButtonRef}\n data-hide-focus-hover-popper='true'\n >\n <Button.Addon tag={CloseIcon} color='icon-primary-invert' />\n </SDismiss>\n\n {isNode(icon)\n ? (\n <>\n <SIcon>{icon}</SIcon>\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n </>\n )\n : (\n <SContent>\n <SMessage>{children}</SMessage>\n {isNode(action) ? <SAction>{action}</SAction> : null}\n </SContent>\n )}\n </SBubble>\n </Animation>,\n );\n }\n}\n\nclass ViewWarning extends ViewInfo {\n static defaultProps = {\n type: 'warning',\n duration: 0,\n };\n}\n\n/**\n * NoticeBubble\n *\n * {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-api/|API} | {@link https://developer.semrush.com/intergalactic/components/notice-bubble/notice-bubble-code/|Examples}\n */\nconst NoticeBubbleContainer = createComponent<\n Intergalactic.Component<'div', NoticeBubbleContainerProps>,\n typeof NoticeBubbleContainerRoot\n>(NoticeBubbleContainer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CAAC,EAC9BnI,MAAM,CAACoI,MAAM,CAAC,gBAAG1H,KAAA,CAAA0C,aAAA,CAACyE,OAAO,EAAAL,KAAA,CAAAlE,EAAA,iBAAE8E,MAAgB,CAAC,GAAG,IACxC,CAET,CACA,CAAC;EAEhB;AACF;AAEA,MAAMlF,WAAW,SAASC,QAAQ,CAAC;;AAOnC;AACA;AACA;AACA;AACA;AAJA/B,eAAA,CAPM8B,WAAW,kBACO;EACpBD,IAAI,EAAE,SAAS;EACfP,QAAQ,EAAE;AACZ,CAAC;AAQH,MAAMsG,qBAAqB,GAAGtJ,eAAe,CAG3CuB,yBAAyB,CAAC;AAE5B,eAAe+H,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubble.type.js","names":[],"sources":["../../src/NoticeBubble.type.ts"],"sourcesContent":["import type { PortalProps, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';\nimport type { RefObject } from 'react';\n\nimport type { NoticeBubbleManager, NoticeItem } from './NoticeBubbleManager';\nimport type { LocalizedMessages } from './translations/__intergalactic-dynamic-locales';\n\n/**\n * @deprecated. Pass noticeBubbleContainer property from window.sm2.getNoticeBubbleContainer()\n */\nexport type NoticeBubbleContainerPortalProps = PortalProps;\n\nexport type NoticeBubbleContainerProps = BoxProps &\n NoticeBubbleContainerPortalProps & {\n /** Ref to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */\n containerNode?: HTMLElement | null;\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n /** Specifies the locale for i18n support */\n locale?: string;\n };\n\nexport type NoticeBubbleContainerDefaultProps = {\n manager: NoticeBubbleManagerClass;\n i18n: LocalizedMessages;\n locale: 'en';\n};\n\nexport type NoticeBubbleViewItemProps = NoticeBubbleProps & {\n containerNode?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /** Add change listener */\n addListener: (fn: (items: NoticeItem[]) => void) => (() => void);\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"NoticeBubble.type.js","names":[],"sources":["../../src/NoticeBubble.type.ts"],"sourcesContent":["import type { PortalProps, BoxProps } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';\nimport type { RefObject } from 'react';\n\nimport type { NoticeBubbleManager, NoticeItem } from './NoticeBubbleManager';\nimport type { LocalizedMessages } from './translations/__intergalactic-dynamic-locales';\n\n/**\n * @deprecated. Pass noticeBubbleContainer property from window.sm2.getNoticeBubbleContainer()\n */\nexport type NoticeBubbleContainerPortalProps = PortalProps;\n\nexport type NoticeBubbleContainerProps = BoxProps &\n NoticeBubbleContainerPortalProps & {\n /** Ref to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */\n containerNode?: HTMLElement | null;\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n /** Specifies the locale for i18n support */\n locale?: string;\n };\n\nexport type NoticeBubbleContainerDefaultProps = {\n manager: NoticeBubbleManagerClass;\n i18n: LocalizedMessages;\n locale: 'en';\n};\n\nexport type NoticeBubbleViewItemProps = NoticeBubbleProps & {\n containerNode?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n *\n * @deprecated\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /** Add change listener */\n addListener: (fn: (items: NoticeItem[]) => void) => (() => void);\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/utils.js
CHANGED
package/lib/es6/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["Timer","constructor","callback","delay","_defineProperty","remaining","paused","resume","pause","timerId","clearTimeout","Date","now","start","window","setTimeout","reset","clear"],"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;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,kBALd,IAAI;IAAAA,eAAA,gBACb,CAAC;IAAAA,eAAA;IAKvB,IAAI,CAACF,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,KAAK,GAAGA,KAAK;IAElB,IAAI,CAACE,SAAS,GAAGF,KAAK;IACtB,IAAI,CAACG,MAAM,GAAG,KAAK;IACnB,IAAI,CAACC,MAAM,CAAC,CAAC;EACf;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.js","names":["Timer","constructor","callback","delay","_defineProperty","remaining","paused","resume","pause","timerId","clearTimeout","Date","now","start","window","setTimeout","reset","clear"],"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.paused) return;\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 }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AC,IAAI,CAACD,OAAO,CAAC;IAC5B;EACF;AACF;AAEA,SAAST,KAAK","ignoreList":[]}
|
package/lib/esm/NoticeBubble.mjs
CHANGED
|
@@ -5,11 +5,10 @@ import { Box, Portal, Flex, Animation } from "@semcore/base-components";
|
|
|
5
5
|
import Button from "@semcore/button";
|
|
6
6
|
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
7
7
|
import fire from "@semcore/core/lib/utils/fire";
|
|
8
|
-
import { getFocusableIn } from "@semcore/core/lib/utils/focus-lock/getFocusableIn";
|
|
9
8
|
import isNode from "@semcore/core/lib/utils/isNode";
|
|
10
9
|
import { useForkRef } from "@semcore/core/lib/utils/ref";
|
|
11
10
|
import { contextThemeEnhance } from "@semcore/core/lib/utils/ThemeProvider";
|
|
12
|
-
import { useFocusLock, setFocus } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
11
|
+
import { useFocusLock, isFocusInside, setFocus } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
13
12
|
import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
14
13
|
import { ZIndexStackingContextProvider, zIndexStackingEnhance } from "@semcore/core/lib/utils/zIndexStacking";
|
|
15
14
|
import CloseIcon from "@semcore/icon/Close/m";
|
|
@@ -22,25 +21,25 @@ const style = (
|
|
|
22
21
|
/*__reshadow_css_start__*/
|
|
23
22
|
(sstyled.insert(
|
|
24
23
|
/*__inner_css_start__*/
|
|
25
|
-
".
|
|
24
|
+
".___SBubble_1y8gb_gg_,.___SView_1y8gb_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,oklch(.999 .001 180/.949));gap:var(--intergalactic-spacing-2x,8px)}.___SBubble_1y8gb_gg_._type_info_1y8gb_gg_,.___SView_1y8gb_gg_._type_info_1y8gb_gg_{background:var(--intergalactic-bg-primary-invert,oklch(.23 .01 140))}.___SBubble_1y8gb_gg_._type_warning_1y8gb_gg_,.___SView_1y8gb_gg_._type_warning_1y8gb_gg_{background:var(--intergalactic-bg-primary-critical,oklch(.64 .226 24.5))}.___SContent_1y8gb_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x,8px);flex:1}.___SMessage_1y8gb_gg_{font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%)}.___SDismiss_1y8gb_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:#0000}.___SDismiss_1y8gb_gg_.__use_1y8gb_gg_{padding:0 1px}.___SIcon_1y8gb_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x,20px)}.___SNoticeBubble_1y8gb_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x,12px);top:var(--intergalactic-spacing-3x,12px)}@media (max-width:767px){.___SNoticeBubble_1y8gb_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_1y8gb_gg_.__disablePortal_1y8gb_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_1y8gb_gg_ a{color:var(--intergalactic-text-link-invert,oklch(.75 .125 265.3))}.___SNoticeAriaLiveWrapper_1y8gb_gg_{display:contents}@keyframes enter_1y8gb{0%{transform:translate(100%);max-height:0;overflow:hidden}to{transform:translate(0);max-height:100vh;overflow:hidden}}@keyframes exit_1y8gb{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}",
|
|
26
25
|
/*__inner_css_end__*/
|
|
27
|
-
"
|
|
26
|
+
"1y8gb_gg_"
|
|
28
27
|
), /*__reshadow_css_end__*/
|
|
29
28
|
{
|
|
30
|
-
"__SContent": "
|
|
31
|
-
"__SMessage": "
|
|
32
|
-
"__SDismiss": "
|
|
33
|
-
"_use": "
|
|
34
|
-
"__SIcon": "
|
|
35
|
-
"__SNoticeBubble": "
|
|
36
|
-
"_disablePortal": "
|
|
37
|
-
"__SNoticeAriaLiveWrapper": "
|
|
38
|
-
"@enter": "
|
|
39
|
-
"@exit": "
|
|
40
|
-
"__SBubble": "
|
|
41
|
-
"__SView": "
|
|
42
|
-
"_type_info": "
|
|
43
|
-
"_type_warning": "
|
|
29
|
+
"__SContent": "___SContent_1y8gb_gg_",
|
|
30
|
+
"__SMessage": "___SMessage_1y8gb_gg_",
|
|
31
|
+
"__SDismiss": "___SDismiss_1y8gb_gg_",
|
|
32
|
+
"_use": "__use_1y8gb_gg_",
|
|
33
|
+
"__SIcon": "___SIcon_1y8gb_gg_",
|
|
34
|
+
"__SNoticeBubble": "___SNoticeBubble_1y8gb_gg_",
|
|
35
|
+
"_disablePortal": "__disablePortal_1y8gb_gg_",
|
|
36
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_1y8gb_gg_",
|
|
37
|
+
"@enter": "enter_1y8gb",
|
|
38
|
+
"@exit": "exit_1y8gb",
|
|
39
|
+
"__SBubble": "___SBubble_1y8gb_gg_",
|
|
40
|
+
"__SView": "___SView_1y8gb_gg_",
|
|
41
|
+
"_type_info": "_type_info_1y8gb_gg_",
|
|
42
|
+
"_type_warning": "_type_warning_1y8gb_gg_"
|
|
44
43
|
})
|
|
45
44
|
);
|
|
46
45
|
class NoticeBubbleContainerRoot extends Component {
|
|
@@ -196,6 +195,7 @@ class ViewInfo extends Component {
|
|
|
196
195
|
_defineProperty(this, "timer", null);
|
|
197
196
|
_defineProperty(this, "ref", /* @__PURE__ */ React.createRef());
|
|
198
197
|
_defineProperty(this, "closeButtonRef", /* @__PURE__ */ React.createRef());
|
|
198
|
+
_defineProperty(this, "triggerButtonComponent", null);
|
|
199
199
|
_defineProperty(this, "handleClose", (e) => {
|
|
200
200
|
fire(this, "onClose", e);
|
|
201
201
|
this.clearTimer();
|
|
@@ -205,16 +205,24 @@ class ViewInfo extends Component {
|
|
|
205
205
|
this.handleClose(e);
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
|
+
_defineProperty(this, "handleFocus", () => {
|
|
209
|
+
this.timer?.pause();
|
|
210
|
+
});
|
|
211
|
+
_defineProperty(this, "handleBlur", () => {
|
|
212
|
+
this.timer?.resume();
|
|
213
|
+
});
|
|
214
|
+
_defineProperty(this, "handleClick", () => {
|
|
215
|
+
this.timer?.pause();
|
|
216
|
+
});
|
|
208
217
|
_defineProperty(this, "handleMouseEnter", () => {
|
|
209
|
-
|
|
210
|
-
this.timer.pause();
|
|
218
|
+
this.timer?.pause();
|
|
211
219
|
});
|
|
212
220
|
_defineProperty(this, "handleMouseLeave", () => {
|
|
213
|
-
if (!this.timer) return;
|
|
221
|
+
if (!this.timer || this.isFocusInBubble()) return;
|
|
214
222
|
this.timer.resume();
|
|
215
223
|
});
|
|
216
224
|
_defineProperty(this, "handleBodyMouseMove", (event) => {
|
|
217
|
-
if (!this.timer?.paused) return;
|
|
225
|
+
if (!this.timer?.paused || this.isFocusInBubble()) return;
|
|
218
226
|
const rect = this.ref.current?.getBoundingClientRect();
|
|
219
227
|
if (!rect) return;
|
|
220
228
|
const mouseInRect = event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
|
|
@@ -230,18 +238,20 @@ class ViewInfo extends Component {
|
|
|
230
238
|
this.timer = new Timer(this.handleClose, duration);
|
|
231
239
|
document.body.addEventListener("mousemove", this.handleBodyMouseMove);
|
|
232
240
|
}
|
|
233
|
-
|
|
234
|
-
if (noticeElement) {
|
|
235
|
-
const focusableNodes = getFocusableIn(noticeElement).filter((node) => node !== this.closeButtonRef.current);
|
|
236
|
-
if (focusableNodes.length > 0) {
|
|
237
|
-
setTimeout(() => setFocus(noticeElement), 0);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
241
|
+
this.triggerButtonComponent = document.activeElement;
|
|
240
242
|
}
|
|
241
243
|
componentWillUnmount() {
|
|
244
|
+
const triggerElement = this.triggerButtonComponent;
|
|
245
|
+
if (this.ref.current && isFocusInside(this.ref.current) && triggerElement instanceof HTMLElement) {
|
|
246
|
+
setTimeout(() => setFocus(triggerElement), 0);
|
|
247
|
+
}
|
|
242
248
|
this.clearTimer();
|
|
243
249
|
document.body.removeEventListener("mousemove", this.handleBodyMouseMove);
|
|
244
250
|
}
|
|
251
|
+
isFocusInBubble() {
|
|
252
|
+
const noticeElement = this.ref.current;
|
|
253
|
+
return noticeElement ? isFocusInside(noticeElement) : false;
|
|
254
|
+
}
|
|
245
255
|
clearTimer() {
|
|
246
256
|
if (this.timer) {
|
|
247
257
|
this.timer.clear();
|
|
@@ -274,11 +284,15 @@ class ViewInfo extends Component {
|
|
|
274
284
|
"duration": animationDuration,
|
|
275
285
|
"keyframes": [styles["@enter"], styles["@exit"]]
|
|
276
286
|
}), /* @__PURE__ */ React.createElement(SBubble, _ref6.cn("SBubble", {
|
|
287
|
+
"render": Flex,
|
|
277
288
|
"type": type,
|
|
278
289
|
"ref": this.ref,
|
|
279
290
|
"onMouseEnter": this.handleMouseEnter,
|
|
280
291
|
"onMouseLeave": this.handleMouseLeave,
|
|
292
|
+
"onFocus": this.handleFocus,
|
|
293
|
+
"onBlur": this.handleBlur,
|
|
281
294
|
"onKeyDown": this.handleKeydown,
|
|
295
|
+
"onClick": this.handleClick,
|
|
282
296
|
"role": type === "warning" ? "alert" : void 0,
|
|
283
297
|
"focusLock": focusLock
|
|
284
298
|
}), /* @__PURE__ */ React.createElement(SDismiss, _ref6.cn("SDismiss", {
|
package/lib/esm/utils.mjs
CHANGED
|
@@ -44,6 +44,8 @@ export type NoticeBubbleProps = BoxProps & {
|
|
|
44
44
|
* If enabled, browser focus will be locked in the notice
|
|
45
45
|
* until it's closed. After close focus should return to the element
|
|
46
46
|
* where it was placed before notice appear.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated
|
|
47
49
|
*/
|
|
48
50
|
focusLock?: boolean;
|
|
49
51
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/notice-bubble",
|
|
3
3
|
"description": "Semrush NoticeBubble Component",
|
|
4
|
-
"version": "17.2.0",
|
|
4
|
+
"version": "17.2.1-prerelease.0",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"require": "./lib/cjs/index.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/button": "^17.2.0"
|
|
17
|
+
"@semcore/button": "^17.2.1-prerelease.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@semcore/base-components": "^17.2.
|
|
21
|
-
"@semcore/icon": "^17.2.
|
|
20
|
+
"@semcore/base-components": "^17.2.1",
|
|
21
|
+
"@semcore/icon": "^17.2.1"
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"directory": "semcore/notice-bubble"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@semcore/core": "17.2.0",
|
|
30
|
-
"@semcore/base-components": "17.2.0",
|
|
29
|
+
"@semcore/core": "17.2.1-prerelease.0",
|
|
30
|
+
"@semcore/base-components": "17.2.1-prerelease.0",
|
|
31
31
|
"@semcore/testing-utils": "1.0.0",
|
|
32
|
-
"@semcore/icon": "17.2.0"
|
|
32
|
+
"@semcore/icon": "17.2.1-prerelease.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pnpm semcore-builder && pnpm vite build"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve as resolvePath } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
|
|
5
|
+
import { vitestPlugins, vitestResolve } from '../../vitest.config.mts';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: vitestPlugins,
|
|
9
|
+
resolve: vitestResolve,
|
|
10
|
+
test: {
|
|
11
|
+
include: [
|
|
12
|
+
'__tests__/**/*.test.tsx',
|
|
13
|
+
],
|
|
14
|
+
environment: 'jsdom',
|
|
15
|
+
setupFiles: [resolvePath(__dirname, '../../tools/testing-utils/setupTests')],
|
|
16
|
+
},
|
|
17
|
+
});
|