@semcore/notice-bubble 16.3.0 → 16.3.1
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 +1 -1
- package/lib/cjs/NoticeBubble.js +78 -17
- package/lib/cjs/NoticeBubble.js.map +1 -1
- package/lib/cjs/NoticeBubble.type.js.map +1 -1
- package/lib/cjs/NoticeBubbleManager.js +38 -12
- package/lib/cjs/NoticeBubbleManager.js.map +1 -1
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/es6/NoticeBubble.js +78 -16
- package/lib/es6/NoticeBubble.js.map +1 -1
- package/lib/es6/NoticeBubble.type.js.map +1 -1
- package/lib/es6/NoticeBubbleManager.js +38 -12
- package/lib/es6/NoticeBubbleManager.js.map +1 -1
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +83 -20
- package/lib/esm/NoticeBubbleManager.mjs +38 -12
- package/lib/esm/index.mjs +7 -3
- package/lib/types/NoticeBubble.d.ts +31 -2
- package/lib/types/NoticeBubble.type.d.ts +45 -6
- package/lib/types/NoticeBubbleManager.d.ts +4 -2
- package/lib/types/index.d.ts +1 -0
- package/package.json +6 -6
|
@@ -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","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","notices","infos","warnings","_unsubscribe","setState","forceUpdate","_inherits","_createClass","key","value","componentDidMount","asProps","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","SNoticeAriaLiveWrapper","_this$asProps","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","_objectSpread","uid","filter","_assignProps","_ref4","_ref5","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","forwardRef","props","outerRef","focusLock","other","_objectWithoutProperties","_excluded","innerRef","useRef","_extends","_React$useState","useState","_React$useState2","_slicedToArray","showContent","setShowContent","useEffect","setTimeout","Tag","tag","designToken","nodeToMount","_Component2","_this2","_len2","_key2","createRef","e","clearTimer","handleClose","timer","pause","resume","event","_this2$timer","_this2$ref$current","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","_this3","document","body","addEventListener","handleBodyMouseMove","noticeElement","focusableNodes","node","closeButtonRef","componentWillUnmount","removeEventListener","clear","_ref6","SBubble","SDismiss","SContent","SMessage","SAction","SIcon","_this$props","visible","initialAnimation","animationDuration","icon","children","action","handleMouseEnter","handleMouseLeave","handleKeydown","undefined","Addon","color","Fragment","_ViewInfo2","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 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 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<NoticeBubbleContainerProps, typeof NoticeBubbleContainerRoot.enhance, {}, typeof NoticeBubbleContainerRoot.defaultProps, State> {\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 tag={SView}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\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: NoticeBubbleViewItemProps & { 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 = props.tag;\n\n if (props.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={props.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...props} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={props.containerNode}>\n <Tag {...props} />\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 ?? true}\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\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot) as Intergalactic.Component<'div', NoticeBubbleContainerProps>;\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;AAEzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,I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AAC,gBAGHlJ,KAAA,CAAAwD,aAAA,CAACgF,QAAQ,EAAAH,KAAA,CAAA3E,EAAA,+BACP1D,KAAA,CAAAwD,aAAA,CAACiF,QAAQ,EAAAJ,KAAA,CAAA3E,EAAA,kBAAEuF,QAAmB,CAAC,EAC9B1J,MAAM,CAAC2J,MAAM,CAAC,gBAAGlJ,KAAA,CAAAwD,aAAA,CAACkF,OAAO,EAAAL,KAAA,CAAA3E,EAAA,iBAAEwF,MAAgB,CAAC,GAAG,IACxC,CAET,CACA,CAAC;IAEhB;EAAC;AAAA,EAhJoBjK,SAAS;AAAA,IAmJ1BqE,WAAW,0BAAAoG,UAAA;EAAA,SAAApG,YAAA;IAAA5C,eAAA,OAAA4C,WAAA;IAAA,OAAArC,UAAA,OAAAqC,WAAA,EAAA1C,SAAA;EAAA;EAAAc,SAAA,CAAA4B,WAAA,EAAAoG,UAAA;EAAA,OAAA/H,YAAA,CAAA2B,WAAA;AAAA,EAASC,QAAQ;AAAApC,eAAA,CAA5BmC,WAAW,kBACO;EACpBD,IAAI,EAAE,SAAS;EACfP,QAAQ,EAAE;AACZ,CAAC;AAGH,IAAM6G,qBAAqB,GAAG3K,eAAe,CAACuB,yBAAyB,CAA+D;AAEtI,eAAeoJ,qBAAqB","ignoreList":[]}
|
|
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","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","notices","infos","warnings","_unsubscribe","setState","forceUpdate","_inherits","_createClass","key","value","componentDidMount","asProps","addListener","handleChange","render","_ref","_ref3","SNoticeBubble","SNoticeAriaLiveWrapper","_this$asProps","Children","styles","disablePortal","getI18nText","ref","parentZIndexStacking","duration","containerNode","state","map","notice","_ref2","SView","type","ViewWarning","ViewInfo","createElement","PortalForNoticeItem","cn","_objectSpread","uid","filter","_assignProps","_ref4","_ref5","variable","fallback","v","Number","parseInt","prop","i18n","locale","FocusLock","forwardRef","props","outerRef","focusLock","other","_objectWithoutProperties","_excluded","innerRef","useRef","_extends","_React$useState","useState","_React$useState2","_slicedToArray","showContent","setShowContent","useEffect","setTimeout","Tag","tag","designToken","nodeToMount","_Component2","_this2","_len2","_key2","createRef","e","clearTimer","handleClose","timer","pause","resume","event","_this2$timer","_this2$ref$current","paused","rect","current","getBoundingClientRect","mouseInRect","clientX","left","right","clientY","top","bottom","_this3","document","body","addEventListener","handleBodyMouseMove","noticeElement","focusableNodes","node","closeButtonRef","componentWillUnmount","removeEventListener","clear","_ref6","SBubble","SDismiss","SContent","SMessage","SAction","SIcon","_this$props","visible","initialAnimation","animationDuration","icon","children","action","handleMouseEnter","handleMouseLeave","handleKeydown","undefined","Addon","color","Fragment","_ViewInfo2","NoticeBubbleView","_Component3","_this4","_len3","_key3","_notice","add","remove","componentDidUpdate","update","NoticeBubbleWarningView","_NoticeBubbleView2","NoticeBubbleContainer","Info","Warning","NoticeBubble","NoticeBubbleWarning"],"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 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 type { NodeByRef } from '@semcore/core/lib/utils/ref';\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 AddedNoticeMeta,\n NoticeBubbleContainerProps,\n NoticeBubbleProps,\n NoticeBubbleViewItemProps, NoticeBubbleWarningProps,\n} from './NoticeBubble.type';\nimport type { NoticeBubbleManager, 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<NoticeBubbleContainerProps, {}, State, typeof NoticeBubbleContainerRoot.enhance, typeof NoticeBubbleContainerRoot.defaultProps> {\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 tag={SView}\n containerNode={containerNode}\n animationDuration={duration}\n styles={styles}\n getI18nText={getI18nText}\n {...notice}\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: NoticeBubbleViewItemProps & { containerNode: NodeByRef; 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 = props.tag;\n\n if (props.type === 'info') {\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={props.containerNode}>\n <SNoticeAriaLiveWrapper aria-live='polite'>\n {showContent && <Tag {...props} />}\n </SNoticeAriaLiveWrapper>\n </Portal>\n </ZIndexStackingContextProvider>\n );\n }\n\n return (\n <ZIndexStackingContextProvider designToken='z-index-notice-bubble'>\n <Portal nodeToMount={props.containerNode}>\n <Tag {...props} />\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 ?? true}\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\nclass NoticeBubbleView extends Component<{ manager: NoticeBubbleManager } & (NoticeBubbleProps | NoticeBubbleWarningProps)> {\n static defaultProps = {\n duration: 5000,\n type: 'info',\n manager,\n };\n\n _notice: null | AddedNoticeMeta = null;\n\n componentDidMount() {\n this._notice = this.asProps.manager.add(this.asProps);\n }\n\n componentWillUnmount() {\n if (this._notice) {\n this._notice.remove();\n }\n }\n\n componentDidUpdate() {\n if (this._notice) {\n this._notice.update(this.asProps);\n }\n }\n\n render() {\n return null;\n }\n}\n\nclass NoticeBubbleWarningView extends NoticeBubbleView {\n static defaultProps = {\n duration: 5000,\n type: 'warning',\n manager,\n };\n}\n\nconst NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {\n Info: NoticeBubbleView,\n Warning: NoticeBubbleWarningView,\n}) as Intergalactic.Component<'div', NoticeBubbleContainerProps> & {\n Info: typeof NoticeBubbleView;\n Warning: typeof NoticeBubbleWarningView;\n};\n\nconst NoticeBubble = NoticeBubbleContainer.Info;\nconst NoticeBubbleWarning = NoticeBubbleContainer.Warning;\n\nexport { NoticeBubble, NoticeBubbleWarning };\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;AAEzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,OAAOC,IAAI,MAAM,8BAA8B;AAC/C,SAASC,cAAc,QAAQ,mDAAmD;AAClF,OAAOC,MAAM,MAAM,gCAAgC;AAEnD,SAASC,UAAU,QAAQ,6BAA6B;AACxD,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,YAAY,EAAEC,QAAQ,QAAQ,0CAA0C;AACjF,SAASC,kBAAkB,QAAQ,wCAAwC;AAC3E,SACEC,6BAA6B,EAC7BC,qBAAqB,QAChB,wCAAwC;AAC/C,OAAOC,SAAS,MAAM,uBAAuB;AAC7C,OAAOC,KAAK,MAAM,OAAO;AASzB,OAAOC,OAAO,MAAM,uBAAuB;AAAC;AAAA,IAAAC,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nB,IAAI,IAAI,CAACH,OAAO,EAAE;QAChB,IAAI,CAACA,OAAO,CAACI,MAAM,CAAC,IAAI,CAACrI,OAAO,CAAC;MACnC;IACF;EAAC;IAAAH,GAAA;IAAAC,KAAA,EAED,SAAAK,MAAMA,CAAA,EAAG;MACP,OAAO,IAAI;IACb;EAAC;AAAA,EA3B4BjD,SAAS;AAAAkC,eAAA,CAAlCwI,gBAAgB,kBACE;EACpB7G,QAAQ,EAAE,IAAI;EACdO,IAAI,EAAE,MAAM;EACZpD,OAAO,EAAPA;AACF,CAAC;AAAA,IAyBGoK,uBAAuB,0BAAAC,kBAAA;EAAA,SAAAD,wBAAA;IAAA3J,eAAA,OAAA2J,uBAAA;IAAA,OAAApJ,UAAA,OAAAoJ,uBAAA,EAAAzJ,SAAA;EAAA;EAAAc,SAAA,CAAA2I,uBAAA,EAAAC,kBAAA;EAAA,OAAA3I,YAAA,CAAA0I,uBAAA;AAAA,EAASV,gBAAgB;AAAAxI,eAAA,CAAhDkJ,uBAAuB,kBACL;EACpBvH,QAAQ,EAAE,IAAI;EACdO,IAAI,EAAE,SAAS;EACfpD,OAAO,EAAPA;AACF,CAAC;AAGH,IAAMsK,qBAAqB,GAAGvL,eAAe,CAACuB,yBAAyB,EAAE;EACvEiK,IAAI,EAAEb,gBAAgB;EACtBc,OAAO,EAAEJ;AACX,CAAC,CAGA;AAED,IAAMK,YAAY,GAAGH,qBAAqB,CAACC,IAAI;AAC/C,IAAMG,mBAAmB,GAAGJ,qBAAqB,CAACE,OAAO;AAEzD,SAASC,YAAY,EAAEC,mBAAmB;AAE1C,eAAeJ,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\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?:
|
|
1
|
+
{"version":3,"file":"NoticeBubble.type.js","names":[],"sources":["../../src/NoticeBubble.type.ts"],"sourcesContent":["import type { PortalProps, BoxProps } from '@semcore/base-components';\nimport type { UnknownProperties, Intergalactic } from '@semcore/core';\nimport type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';\nimport type { NodeByRef } from '@semcore/core/lib/utils/ref';\nimport type { RefObject } from 'react';\n\n/** @deprecated */\nexport interface INoticeBubbleContainerProps\n extends NoticeBubbleContainerProps,\n UnknownProperties {}\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 or element to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */\n containerNode?: NodeByRef | null;\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n /** Specifies the locale for i18n support */\n locale?: string;\n };\n\nexport type NoticeBubbleViewItemProps = NoticeBubbleProps & {\n containerNode?: NodeByRef;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\n/** @deprecated */\nexport interface INoticeBubbleProps extends NoticeBubbleProps, UnknownProperties {}\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/** @deprecated */\nexport interface INoticeBubbleInfoProps extends NoticeBubbleInfoProps, UnknownProperties {}\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\n/** @deprecated */\nexport interface INoticeBubbleWarningProps extends NoticeBubbleWarningProps, UnknownProperties {}\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => boolean;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n focus: () => void;\n};\n\n/** @deprecated */\nexport interface INoticeBubbleManager extends NoticeBubbleManagerClass, UnknownProperties {}\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Updates notice by uid.\n * @deprecated use replace instead.\n */\n update: (uid: number, props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;\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};\n\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\nexport declare const NoticeBubble: Intergalactic.Component<'div', NoticeBubbleInfoProps>;\n/**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\nexport declare const NoticeBubbleWarning: Intergalactic.Component<'div', NoticeBubbleWarningProps>;\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n> & {\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Info: typeof NoticeBubble;\n\n /**\n * @deprecated use `NoticeBubbleManager` instead.\n * */\n Warning: typeof NoticeBubbleWarning;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';
|
|
6
6
|
import EventEmitter from '@semcore/core/lib/utils/eventEmitter';
|
|
7
|
+
import { setFocus } from '@semcore/core/lib/utils/use/useFocusLock';
|
|
7
8
|
import React from 'react';
|
|
8
9
|
var EVENT_NAME = 'CHANGE';
|
|
9
10
|
var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
@@ -12,6 +13,7 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
12
13
|
_defineProperty(this, "items", []);
|
|
13
14
|
_defineProperty(this, "emitter", new EventEmitter());
|
|
14
15
|
_defineProperty(this, "counter", 0);
|
|
16
|
+
_defineProperty(this, "replaceTimer", null);
|
|
15
17
|
}
|
|
16
18
|
return _createClass(NoticeBubbleManager, [{
|
|
17
19
|
key: "addListener",
|
|
@@ -29,6 +31,13 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
29
31
|
var _this = this;
|
|
30
32
|
var uid = this.counter++;
|
|
31
33
|
var ref = /*#__PURE__*/React.createRef();
|
|
34
|
+
var focus = function focus() {
|
|
35
|
+
setTimeout(function () {
|
|
36
|
+
if (ref.current) {
|
|
37
|
+
setFocus(ref.current);
|
|
38
|
+
}
|
|
39
|
+
}, 0);
|
|
40
|
+
};
|
|
32
41
|
var item = _objectSpread(_objectSpread({
|
|
33
42
|
type: 'info',
|
|
34
43
|
uid: uid,
|
|
@@ -43,35 +52,52 @@ var NoticeBubbleManager = /*#__PURE__*/function () {
|
|
|
43
52
|
this.emit();
|
|
44
53
|
return {
|
|
45
54
|
uid: uid,
|
|
46
|
-
update: this.
|
|
55
|
+
update: this.update.bind(this, uid),
|
|
47
56
|
remove: this.remove.bind(this, uid),
|
|
48
|
-
ref: ref
|
|
57
|
+
ref: ref,
|
|
58
|
+
// todo Brauer Ilia: remove this property, because we added logic about autofocus in Notice
|
|
59
|
+
focus: focus
|
|
49
60
|
};
|
|
50
61
|
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "update",
|
|
64
|
+
value: function update(uid, props) {
|
|
65
|
+
var index = this.items.findIndex(function (item) {
|
|
66
|
+
return item.uid === uid;
|
|
67
|
+
});
|
|
68
|
+
if (index !== -1) {
|
|
69
|
+
this.items[index] = _objectSpread(_objectSpread({}, this.items[index]), props);
|
|
70
|
+
this.emit();
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
51
75
|
}, {
|
|
52
76
|
key: "replace",
|
|
53
77
|
value: function replace(uid, props) {
|
|
54
78
|
var _this2 = this;
|
|
79
|
+
if (this.replaceTimer) {
|
|
80
|
+
clearTimeout(this.replaceTimer);
|
|
81
|
+
}
|
|
55
82
|
this.remove(uid);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, 300);
|
|
60
|
-
});
|
|
83
|
+
this.replaceTimer = setTimeout(function () {
|
|
84
|
+
_this2.add(props);
|
|
85
|
+
}, 300);
|
|
61
86
|
}
|
|
62
87
|
}, {
|
|
63
88
|
key: "replaceLast",
|
|
64
89
|
value: function replaceLast(props) {
|
|
65
90
|
var _this3 = this;
|
|
91
|
+
if (this.replaceTimer) {
|
|
92
|
+
clearTimeout(this.replaceTimer);
|
|
93
|
+
}
|
|
66
94
|
var item = this.items[this.items.length - 1];
|
|
67
95
|
if (item !== null && item !== void 0 && item.visible) {
|
|
68
96
|
this.remove(this.counter - 1);
|
|
69
97
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, 300);
|
|
74
|
-
});
|
|
98
|
+
this.replaceTimer = setTimeout(function () {
|
|
99
|
+
_this3.add(props);
|
|
100
|
+
}, 300);
|
|
75
101
|
}
|
|
76
102
|
}, {
|
|
77
103
|
key: "remove",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoticeBubbleManager.js","names":["callAllEventHandlers","EventEmitter","React","EVENT_NAME","NoticeBubbleManager","_classCallCheck","_defineProperty","_createClass","key","value","addListener","fn","emitter","subscribe","emit","items","add","props","_this","uid","counter","ref","createRef","item","_objectSpread","type","visible","initialAnimation","undefined","forwardRef","onClose","remove","push","update","
|
|
1
|
+
{"version":3,"file":"NoticeBubbleManager.js","names":["callAllEventHandlers","EventEmitter","setFocus","React","EVENT_NAME","NoticeBubbleManager","_classCallCheck","_defineProperty","_createClass","key","value","addListener","fn","emitter","subscribe","emit","items","add","props","_this","uid","counter","ref","createRef","focus","setTimeout","current","item","_objectSpread","type","visible","initialAnimation","undefined","forwardRef","onClose","remove","push","update","bind","index","findIndex","replace","_this2","replaceTimer","clearTimeout","replaceLast","_this3","length","_this4","find","filter","noticeBubbleDefaultManager"],"sources":["../../src/NoticeBubbleManager.ts"],"sourcesContent":["import { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';\nimport EventEmitter from '@semcore/core/lib/utils/eventEmitter';\nimport { setFocus } from '@semcore/core/lib/utils/use/useFocusLock';\nimport type { RefObject } from 'react';\nimport React from 'react';\n\nimport type {\n NoticeBubbleManagerClass,\n NoticeBubbleInfoProps,\n NoticeBubbleWarningProps,\n AddedNoticeMeta,\n} from './NoticeBubble.type';\n\nconst EVENT_NAME = 'CHANGE';\n\nexport type NoticeItem = (NoticeBubbleInfoProps | NoticeBubbleWarningProps) & {\n uid: number;\n visible?: boolean;\n forwardRef: RefObject<HTMLElement>;\n onClose: () => void;\n};\n\nclass NoticeBubbleManager implements NoticeBubbleManagerClass {\n private items: NoticeItem[] = [];\n private emitter = new EventEmitter();\n private counter = 0;\n\n private replaceTimer: ReturnType<typeof setTimeout> | null = null;\n\n public addListener(fn: (items: NoticeItem[]) => void): () => void {\n return this.emitter.subscribe(EVENT_NAME, fn);\n }\n\n private emit() {\n this.emitter.emit(EVENT_NAME, this.items);\n }\n\n public add(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): AddedNoticeMeta {\n const uid = this.counter++;\n const ref = React.createRef<HTMLElement>();\n const focus = () => {\n setTimeout(() => {\n if (ref.current) {\n setFocus(ref.current);\n }\n }, 0);\n };\n const item = {\n type: 'info',\n uid,\n visible: props.initialAnimation ? true : undefined,\n forwardRef: ref,\n ...props,\n onClose: callAllEventHandlers(props.onClose, () => {\n this.remove(uid);\n }),\n } as const;\n this.items.push(item);\n this.emit();\n return {\n uid,\n update: this.update.bind(this, uid),\n remove: this.remove.bind(this, uid),\n ref,\n // todo Brauer Ilia: remove this property, because we added logic about autofocus in Notice\n focus,\n };\n }\n\n public update(uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): boolean {\n const index = this.items.findIndex((item) => item.uid === uid);\n if (index !== -1) {\n this.items[index] = {\n ...this.items[index],\n ...props,\n };\n this.emit();\n return true;\n }\n return false;\n }\n\n public replace(uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): void {\n if (this.replaceTimer) {\n clearTimeout(this.replaceTimer);\n }\n\n this.remove(uid);\n\n this.replaceTimer = setTimeout(() => {\n this.add(props);\n }, 300);\n }\n\n public replaceLast(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): void {\n if (this.replaceTimer) {\n clearTimeout(this.replaceTimer);\n }\n\n const item = this.items[this.items.length - 1];\n\n if (item?.visible) {\n this.remove(this.counter - 1);\n }\n\n this.replaceTimer = setTimeout(() => {\n this.add(props);\n }, 300);\n }\n\n public remove(uid: number): boolean {\n const item = this.items.find((item) => item.uid === uid);\n if (item) {\n item.visible = false;\n setTimeout(() => {\n this.items = this.items.filter((item) => item.uid !== uid);\n this.emit();\n }, 1000);\n this.emit();\n return true;\n }\n return false;\n }\n}\n\nconst noticeBubbleDefaultManager = new NoticeBubbleManager();\n\nexport { NoticeBubbleManager };\nexport default noticeBubbleDefaultManager;\n"],"mappings":";;;;AAAA,SAASA,oBAAoB,QAAQ,qCAAqC;AAC1E,OAAOC,YAAY,MAAM,sCAAsC;AAC/D,SAASC,QAAQ,QAAQ,0CAA0C;AAEnE,OAAOC,KAAK,MAAM,OAAO;AASzB,IAAMC,UAAU,GAAG,QAAQ;AAAC,IAStBC,mBAAmB;EAAA,SAAAA,oBAAA;IAAAC,eAAA,OAAAD,mBAAA;IAAAE,eAAA,gBACO,EAAE;IAAAA,eAAA,kBACd,IAAIN,YAAY,CAAC,CAAC;IAAAM,eAAA,kBAClB,CAAC;IAAAA,eAAA,uBAE0C,IAAI;EAAA;EAAA,OAAAC,YAAA,CAAAH,mBAAA;IAAAI,GAAA;IAAAC,KAAA,EAEjE,SAAOC,WAAWA,CAACC,EAAiC,EAAc;MAChE,OAAO,IAAI,CAACC,OAAO,CAACC,SAAS,CAACV,UAAU,EAAEQ,EAAE,CAAC;IAC/C;EAAC;IAAAH,GAAA;IAAAC,KAAA,EAED,SAAQK,IAAIA,CAAA,EAAG;MACb,IAAI,CAACF,OAAO,CAACE,IAAI,CAACX,UAAU,EAAE,IAAI,CAACY,KAAK,CAAC;IAC3C;EAAC;IAAAP,GAAA;IAAAC,KAAA,EAED,SAAOO,GAAGA,CAACC,KAAuD,EAAmB;MAAA,IAAAC,KAAA;MACnF,IAAMC,GAAG,GAAG,IAAI,CAACC,OAAO,EAAE;MAC1B,IAAMC,GAAG,gBAAGnB,KAAK,CAACoB,SAAS,CAAc,CAAC;MAC1C,IAAMC,KAAK,GAAG,SAARA,KAAKA,CAAA,EAAS;QAClBC,UAA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xD,IAAIO,IAAI,EAAE;QACRA,IAAI,CAACG,OAAO,GAAG,KAAK;QACpBL,UAAU,CAAC,YAAM;UACfuB,MAAI,CAAChC,KAAK,GAAGgC,MAAI,CAAChC,KAAK,CAACkC,MAAM,CAAC,UAACvB,IAAI;YAAA,OAAKA,IAAI,CAACP,GAAG,KAAKA,GAAG;UAAA,EAAC;UAC1D4B,MAAI,CAACjC,IAAI,CAAC,CAAC;QACb,CAAC,EAAE,IAAI,CAAC;QACR,IAAI,CAACA,IAAI,CAAC,CAAC;QACX,OAAO,IAAI;MACb;MACA,OAAO,KAAK;IACd;EAAC;AAAA;AAGH,IAAMoC,0BAA0B,GAAG,IAAI9C,mBAAmB,CAAC,CAAC;AAE5D,SAASA,mBAAmB;AAC5B,eAAe8C,0BAA0B","ignoreList":[]}
|
package/lib/es6/index.js
CHANGED
|
@@ -2,5 +2,6 @@ import { default as NoticeBubbleContainer } from './NoticeBubble';
|
|
|
2
2
|
import { default as noticeBubbleDefaultManager } from './NoticeBubbleManager';
|
|
3
3
|
export * from './NoticeBubble';
|
|
4
4
|
export * from './NoticeBubbleManager';
|
|
5
|
+
export default noticeBubbleDefaultManager;
|
|
5
6
|
export { NoticeBubbleContainer, noticeBubbleDefaultManager };
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/lib/es6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","NoticeBubbleContainer","noticeBubbleDefaultManager"],"sources":["../../src/index.ts"],"sourcesContent":["import { default as NoticeBubbleContainer } from './NoticeBubble';\nimport type {\n NoticeBubbleContainerProps,\n NoticeBubbleInfoProps,\n NoticeBubbleWarningProps,\n AddedNoticeMeta,\n} from './NoticeBubble.type';\nimport { default as noticeBubbleDefaultManager } from './NoticeBubbleManager';\n\nexport * from './NoticeBubble';\n\nexport * from './NoticeBubbleManager';\n\nexport { NoticeBubbleContainer, noticeBubbleDefaultManager };\n\nexport type {\n NoticeBubbleContainerProps,\n NoticeBubbleInfoProps,\n NoticeBubbleWarningProps,\n AddedNoticeMeta,\n};\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAAqB,QAAQ,gBAAgB;AAOjE,SAASD,OAAO,IAAIE,0BAA0B,QAAQ,uBAAuB;AAE7E,cAAc,gBAAgB;AAE9B,cAAc,uBAAuB;AAErC,SAASD,qBAAqB,EAAEC,0BAA0B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","NoticeBubbleContainer","noticeBubbleDefaultManager"],"sources":["../../src/index.ts"],"sourcesContent":["import { default as NoticeBubbleContainer } from './NoticeBubble';\nimport type {\n NoticeBubbleContainerProps,\n NoticeBubbleInfoProps,\n NoticeBubbleWarningProps,\n AddedNoticeMeta,\n} from './NoticeBubble.type';\nimport { default as noticeBubbleDefaultManager } from './NoticeBubbleManager';\n\nexport * from './NoticeBubble';\n\nexport * from './NoticeBubbleManager';\n\nexport default noticeBubbleDefaultManager;\nexport { NoticeBubbleContainer, noticeBubbleDefaultManager };\n\nexport type {\n NoticeBubbleContainerProps,\n NoticeBubbleInfoProps,\n NoticeBubbleWarningProps,\n AddedNoticeMeta,\n};\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAAqB,QAAQ,gBAAgB;AAOjE,SAASD,OAAO,IAAIE,0BAA0B,QAAQ,uBAAuB;AAE7E,cAAc,gBAAgB;AAE9B,cAAc,uBAAuB;AAErC,eAAeA,0BAA0B;AACzC,SAASD,qBAAqB,EAAEC,0BAA0B","ignoreList":[]}
|
package/lib/esm/NoticeBubble.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
7
7
|
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
8
8
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
import { sstyled, assignProps, Component
|
|
11
|
-
import { Box,
|
|
10
|
+
import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
|
|
11
|
+
import { Portal, Box, Animation, Flex } from "@semcore/base-components";
|
|
12
12
|
import Button from "@semcore/button";
|
|
13
13
|
import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
|
|
14
14
|
import fire from "@semcore/core/lib/utils/fire";
|
|
@@ -16,7 +16,7 @@ import { getFocusableIn } from "@semcore/core/lib/utils/focus-lock/getFocusableI
|
|
|
16
16
|
import isNode from "@semcore/core/lib/utils/isNode";
|
|
17
17
|
import { useForkRef } from "@semcore/core/lib/utils/ref";
|
|
18
18
|
import { contextThemeEnhance } from "@semcore/core/lib/utils/ThemeProvider";
|
|
19
|
-
import {
|
|
19
|
+
import { setFocus, useFocusLock } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
20
20
|
import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
21
21
|
import { ZIndexStackingContextProvider, zIndexStackingEnhance } from "@semcore/core/lib/utils/zIndexStacking";
|
|
22
22
|
import CloseIcon from "@semcore/icon/Close/m";
|
|
@@ -30,25 +30,25 @@ var style = (
|
|
|
30
30
|
/*__reshadow_css_start__*/
|
|
31
31
|
(sstyled.insert(
|
|
32
32
|
/*__inner_css_start__*/
|
|
33
|
-
"@keyframes
|
|
33
|
+
"@keyframes enter_e1i3p{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_e1i3p{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_e1i3p_gg_,.___SView_e1i3p_gg_{position:relative;margin-bottom:var(--intergalactic-spacing-3x, 12px);padding:var(--intergalactic-spacing-3x, 12px);padding-right:calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-1x, 4px));width:100%;border-radius:var(--intergalactic-popper-rounded, 6px);overflow:hidden;box-sizing:border-box;color:var(--intergalactic-text-primary-invert, rgba(254, 255, 255, 0.949));gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_e1i3p_gg_._type_info_e1i3p_gg_,.___SView_e1i3p_gg_._type_info_e1i3p_gg_{background:var(--intergalactic-bg-primary-invert, rgb(26, 30, 26))}.___SBubble_e1i3p_gg_._type_warning_e1i3p_gg_,.___SView_e1i3p_gg_._type_warning_e1i3p_gg_{background:var(--intergalactic-bg-primary-critical, rgb(247, 55, 64))}.___SContent_e1i3p_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_e1i3p_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_e1i3p_gg_{cursor:pointer;position:absolute;right:0;top:0;margin-top:var(--intergalactic-spacing-2x, 8px);margin-right:var(--intergalactic-spacing-2x, 8px);margin-bottom:var(--intergalactic-spacing-2x, 8px);flex-shrink:0;border:0;background:0 0}.___SDismiss_e1i3p_gg_.__use_e1i3p_gg_{padding:0 1px}.___SIcon_e1i3p_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_e1i3p_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_e1i3p_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_e1i3p_gg_.__disablePortal_e1i3p_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_e1i3p_gg_ a{color:var(--intergalactic-text-link-invert, rgb(136, 172, 253))}.___SNoticeAriaLiveWrapper_e1i3p_gg_{display:contents}",
|
|
34
34
|
/*__inner_css_end__*/
|
|
35
|
-
"
|
|
35
|
+
"e1i3p_gg_"
|
|
36
36
|
), /*__reshadow_css_end__*/
|
|
37
37
|
{
|
|
38
|
-
"__SContent": "
|
|
39
|
-
"__SMessage": "
|
|
40
|
-
"__SDismiss": "
|
|
41
|
-
"_use": "
|
|
42
|
-
"__SIcon": "
|
|
43
|
-
"__SNoticeBubble": "
|
|
44
|
-
"_disablePortal": "
|
|
45
|
-
"__SNoticeAriaLiveWrapper": "
|
|
46
|
-
"@enter": "
|
|
47
|
-
"@exit": "
|
|
48
|
-
"__SBubble": "
|
|
49
|
-
"__SView": "
|
|
50
|
-
"_type_info": "
|
|
51
|
-
"_type_warning": "
|
|
38
|
+
"__SContent": "___SContent_e1i3p_gg_",
|
|
39
|
+
"__SMessage": "___SMessage_e1i3p_gg_",
|
|
40
|
+
"__SDismiss": "___SDismiss_e1i3p_gg_",
|
|
41
|
+
"_use": "__use_e1i3p_gg_",
|
|
42
|
+
"__SIcon": "___SIcon_e1i3p_gg_",
|
|
43
|
+
"__SNoticeBubble": "___SNoticeBubble_e1i3p_gg_",
|
|
44
|
+
"_disablePortal": "__disablePortal_e1i3p_gg_",
|
|
45
|
+
"__SNoticeAriaLiveWrapper": "___SNoticeAriaLiveWrapper_e1i3p_gg_",
|
|
46
|
+
"@enter": "enter_e1i3p",
|
|
47
|
+
"@exit": "exit_e1i3p",
|
|
48
|
+
"__SBubble": "___SBubble_e1i3p_gg_",
|
|
49
|
+
"__SView": "___SView_e1i3p_gg_",
|
|
50
|
+
"_type_info": "_type_info_e1i3p_gg_",
|
|
51
|
+
"_type_warning": "_type_warning_e1i3p_gg_"
|
|
52
52
|
})
|
|
53
53
|
);
|
|
54
54
|
var NoticeBubbleContainerRoot = /* @__PURE__ */ (function(_Component) {
|
|
@@ -324,7 +324,70 @@ _defineProperty(ViewWarning, "defaultProps", {
|
|
|
324
324
|
type: "warning",
|
|
325
325
|
duration: 0
|
|
326
326
|
});
|
|
327
|
-
var
|
|
327
|
+
var NoticeBubbleView = /* @__PURE__ */ (function(_Component3) {
|
|
328
|
+
function NoticeBubbleView2() {
|
|
329
|
+
var _this4;
|
|
330
|
+
_classCallCheck(this, NoticeBubbleView2);
|
|
331
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
332
|
+
args[_key3] = arguments[_key3];
|
|
333
|
+
}
|
|
334
|
+
_this4 = _callSuper(this, NoticeBubbleView2, [].concat(args));
|
|
335
|
+
_defineProperty(_this4, "_notice", null);
|
|
336
|
+
return _this4;
|
|
337
|
+
}
|
|
338
|
+
_inherits(NoticeBubbleView2, _Component3);
|
|
339
|
+
return _createClass(NoticeBubbleView2, [{
|
|
340
|
+
key: "componentDidMount",
|
|
341
|
+
value: function componentDidMount() {
|
|
342
|
+
this._notice = this.asProps.manager.add(this.asProps);
|
|
343
|
+
}
|
|
344
|
+
}, {
|
|
345
|
+
key: "componentWillUnmount",
|
|
346
|
+
value: function componentWillUnmount() {
|
|
347
|
+
if (this._notice) {
|
|
348
|
+
this._notice.remove();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
key: "componentDidUpdate",
|
|
353
|
+
value: function componentDidUpdate() {
|
|
354
|
+
if (this._notice) {
|
|
355
|
+
this._notice.update(this.asProps);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}, {
|
|
359
|
+
key: "render",
|
|
360
|
+
value: function render() {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
}]);
|
|
364
|
+
})(Component);
|
|
365
|
+
_defineProperty(NoticeBubbleView, "defaultProps", {
|
|
366
|
+
duration: 5e3,
|
|
367
|
+
type: "info",
|
|
368
|
+
manager: noticeBubbleDefaultManager
|
|
369
|
+
});
|
|
370
|
+
var NoticeBubbleWarningView = /* @__PURE__ */ (function(_NoticeBubbleView2) {
|
|
371
|
+
function NoticeBubbleWarningView2() {
|
|
372
|
+
_classCallCheck(this, NoticeBubbleWarningView2);
|
|
373
|
+
return _callSuper(this, NoticeBubbleWarningView2, arguments);
|
|
374
|
+
}
|
|
375
|
+
_inherits(NoticeBubbleWarningView2, _NoticeBubbleView2);
|
|
376
|
+
return _createClass(NoticeBubbleWarningView2);
|
|
377
|
+
})(NoticeBubbleView);
|
|
378
|
+
_defineProperty(NoticeBubbleWarningView, "defaultProps", {
|
|
379
|
+
duration: 5e3,
|
|
380
|
+
type: "warning",
|
|
381
|
+
manager: noticeBubbleDefaultManager
|
|
382
|
+
});
|
|
383
|
+
var NoticeBubbleContainer = createComponent(NoticeBubbleContainerRoot, {
|
|
384
|
+
Info: NoticeBubbleView,
|
|
385
|
+
Warning: NoticeBubbleWarningView
|
|
386
|
+
});
|
|
387
|
+
var NoticeBubble = NoticeBubbleContainer.Info;
|
|
388
|
+
var NoticeBubbleWarning = NoticeBubbleContainer.Warning;
|
|
328
389
|
export {
|
|
390
|
+
NoticeBubble,
|
|
391
|
+
NoticeBubbleWarning,
|
|
329
392
|
NoticeBubbleContainer as default
|
|
330
393
|
};
|
|
@@ -4,6 +4,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
5
|
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
6
6
|
import EventEmitter from "@semcore/core/lib/utils/eventEmitter";
|
|
7
|
+
import { setFocus } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
7
8
|
import React from "react";
|
|
8
9
|
var EVENT_NAME = "CHANGE";
|
|
9
10
|
var NoticeBubbleManager = /* @__PURE__ */ (function() {
|
|
@@ -12,6 +13,7 @@ var NoticeBubbleManager = /* @__PURE__ */ (function() {
|
|
|
12
13
|
_defineProperty(this, "items", []);
|
|
13
14
|
_defineProperty(this, "emitter", new EventEmitter());
|
|
14
15
|
_defineProperty(this, "counter", 0);
|
|
16
|
+
_defineProperty(this, "replaceTimer", null);
|
|
15
17
|
}
|
|
16
18
|
return _createClass(NoticeBubbleManager2, [{
|
|
17
19
|
key: "addListener",
|
|
@@ -29,6 +31,13 @@ var NoticeBubbleManager = /* @__PURE__ */ (function() {
|
|
|
29
31
|
var _this = this;
|
|
30
32
|
var uid = this.counter++;
|
|
31
33
|
var ref = /* @__PURE__ */ React.createRef();
|
|
34
|
+
var focus = function focus2() {
|
|
35
|
+
setTimeout(function() {
|
|
36
|
+
if (ref.current) {
|
|
37
|
+
setFocus(ref.current);
|
|
38
|
+
}
|
|
39
|
+
}, 0);
|
|
40
|
+
};
|
|
32
41
|
var item = _objectSpread(_objectSpread({
|
|
33
42
|
type: "info",
|
|
34
43
|
uid,
|
|
@@ -43,35 +52,52 @@ var NoticeBubbleManager = /* @__PURE__ */ (function() {
|
|
|
43
52
|
this.emit();
|
|
44
53
|
return {
|
|
45
54
|
uid,
|
|
46
|
-
update: this.
|
|
55
|
+
update: this.update.bind(this, uid),
|
|
47
56
|
remove: this.remove.bind(this, uid),
|
|
48
|
-
ref
|
|
57
|
+
ref,
|
|
58
|
+
// todo Brauer Ilia: remove this property, because we added logic about autofocus in Notice
|
|
59
|
+
focus
|
|
49
60
|
};
|
|
50
61
|
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "update",
|
|
64
|
+
value: function update(uid, props) {
|
|
65
|
+
var index = this.items.findIndex(function(item) {
|
|
66
|
+
return item.uid === uid;
|
|
67
|
+
});
|
|
68
|
+
if (index !== -1) {
|
|
69
|
+
this.items[index] = _objectSpread(_objectSpread({}, this.items[index]), props);
|
|
70
|
+
this.emit();
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
51
75
|
}, {
|
|
52
76
|
key: "replace",
|
|
53
77
|
value: function replace(uid, props) {
|
|
54
78
|
var _this2 = this;
|
|
79
|
+
if (this.replaceTimer) {
|
|
80
|
+
clearTimeout(this.replaceTimer);
|
|
81
|
+
}
|
|
55
82
|
this.remove(uid);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}, 300);
|
|
60
|
-
});
|
|
83
|
+
this.replaceTimer = setTimeout(function() {
|
|
84
|
+
_this2.add(props);
|
|
85
|
+
}, 300);
|
|
61
86
|
}
|
|
62
87
|
}, {
|
|
63
88
|
key: "replaceLast",
|
|
64
89
|
value: function replaceLast(props) {
|
|
65
90
|
var _this3 = this;
|
|
91
|
+
if (this.replaceTimer) {
|
|
92
|
+
clearTimeout(this.replaceTimer);
|
|
93
|
+
}
|
|
66
94
|
var item = this.items[this.items.length - 1];
|
|
67
95
|
if (item !== null && item !== void 0 && item.visible) {
|
|
68
96
|
this.remove(this.counter - 1);
|
|
69
97
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, 300);
|
|
74
|
-
});
|
|
98
|
+
this.replaceTimer = setTimeout(function() {
|
|
99
|
+
_this3.add(props);
|
|
100
|
+
}, 300);
|
|
75
101
|
}
|
|
76
102
|
}, {
|
|
77
103
|
key: "remove",
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { default as default2 } from "./NoticeBubble.mjs";
|
|
2
|
-
import
|
|
1
|
+
import { NoticeBubble, default as default2, NoticeBubbleWarning } from "./NoticeBubble.mjs";
|
|
2
|
+
import noticeBubbleDefaultManager from "./NoticeBubbleManager.mjs";
|
|
3
|
+
import { NoticeBubbleManager } from "./NoticeBubbleManager.mjs";
|
|
3
4
|
export {
|
|
5
|
+
NoticeBubble,
|
|
4
6
|
default2 as NoticeBubbleContainer,
|
|
5
7
|
NoticeBubbleManager,
|
|
6
|
-
|
|
8
|
+
NoticeBubbleWarning,
|
|
9
|
+
noticeBubbleDefaultManager as default,
|
|
10
|
+
noticeBubbleDefaultManager
|
|
7
11
|
};
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
+
import { Component } from '@semcore/core';
|
|
1
2
|
import type { Intergalactic } from '@semcore/core';
|
|
2
|
-
import type { NoticeBubbleContainerProps } from './NoticeBubble.type';
|
|
3
|
-
|
|
3
|
+
import type { AddedNoticeMeta, NoticeBubbleContainerProps, NoticeBubbleProps, NoticeBubbleWarningProps } from './NoticeBubble.type';
|
|
4
|
+
import type { NoticeBubbleManager } from './NoticeBubbleManager';
|
|
5
|
+
declare class NoticeBubbleView extends Component<{
|
|
6
|
+
manager: NoticeBubbleManager;
|
|
7
|
+
} & (NoticeBubbleProps | NoticeBubbleWarningProps)> {
|
|
8
|
+
static defaultProps: {
|
|
9
|
+
duration: number;
|
|
10
|
+
type: string;
|
|
11
|
+
manager: NoticeBubbleManager;
|
|
12
|
+
};
|
|
13
|
+
_notice: null | AddedNoticeMeta;
|
|
14
|
+
componentDidMount(): void;
|
|
15
|
+
componentWillUnmount(): void;
|
|
16
|
+
componentDidUpdate(): void;
|
|
17
|
+
render(): null;
|
|
18
|
+
}
|
|
19
|
+
declare class NoticeBubbleWarningView extends NoticeBubbleView {
|
|
20
|
+
static defaultProps: {
|
|
21
|
+
duration: number;
|
|
22
|
+
type: string;
|
|
23
|
+
manager: NoticeBubbleManager;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
declare const NoticeBubbleContainer: Intergalactic.Component<"div", NoticeBubbleContainerProps> & {
|
|
27
|
+
Info: typeof NoticeBubbleView;
|
|
28
|
+
Warning: typeof NoticeBubbleWarningView;
|
|
29
|
+
};
|
|
30
|
+
declare const NoticeBubble: typeof NoticeBubbleView;
|
|
31
|
+
declare const NoticeBubbleWarning: typeof NoticeBubbleWarningView;
|
|
32
|
+
export { NoticeBubble, NoticeBubbleWarning };
|
|
4
33
|
export default NoticeBubbleContainer;
|