@semcore/notice-bubble 5.52.0-prerelease.1 → 5.52.0-prerelease.12
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 +9 -3
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/esm/NoticeBubble.mjs +298 -0
- package/lib/esm/NoticeBubbleManager.mjs +91 -0
- package/lib/esm/index.mjs +11 -0
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +33 -0
- package/lib/esm/translations/de.json.mjs +9 -0
- package/lib/esm/translations/en.json.mjs +9 -0
- package/lib/esm/translations/es.json.mjs +9 -0
- package/lib/esm/translations/fr.json.mjs +9 -0
- package/lib/esm/translations/it.json.mjs +9 -0
- package/lib/esm/translations/ja.json.mjs +9 -0
- package/lib/esm/translations/ko.json.mjs +9 -0
- package/lib/esm/translations/nl.json.mjs +9 -0
- package/lib/esm/translations/pl.json.mjs +9 -0
- package/lib/esm/translations/pt.json.mjs +9 -0
- package/lib/esm/translations/sv.json.mjs +9 -0
- package/lib/esm/translations/tr.json.mjs +9 -0
- package/lib/esm/translations/vi.json.mjs +9 -0
- package/lib/esm/translations/zh.json.mjs +9 -0
- package/lib/esm/utils.mjs +31 -0
- package/lib/types/index.d.ts +1 -1
- package/package.json +15 -8
- package/vite.config.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [5.52.0] - 2025-
|
|
5
|
+
## [5.52.0] - 2025-03-14
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Build for ESM.
|
|
10
|
+
|
|
11
|
+
## [5.51.2] - 2025-03-11
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
8
14
|
|
|
9
|
-
-
|
|
15
|
+
- Types for correct display in documentation.
|
|
10
16
|
|
|
11
17
|
## [5.51.1] - 2025-02-05
|
|
12
18
|
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { PortalProps } from '@semcore/portal';\nimport { UnknownProperties, Intergalactic } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface INoticeBubbleContainerProps\n extends NoticeBubbleContainerProps,\n UnknownProperties {}\nexport type NoticeBubbleContainerProps = BoxProps &\n PortalProps & {\n /** Manager copy */\n manager?:
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { PortalProps } from '@semcore/portal';\nimport { UnknownProperties, Intergalactic } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface INoticeBubbleContainerProps\n extends NoticeBubbleContainerProps,\n UnknownProperties {}\nexport type NoticeBubbleContainerProps = BoxProps &\n PortalProps & {\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n locale?: string;\n };\n\n/** @deprecated */\nexport interface INoticeBubbleProps extends NoticeBubbleProps, UnknownProperties {}\nexport type NoticeBubbleProps = BoxProps & {\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?: NoticeBubbleManager;\n icon?: React.ReactElement;\n};\n/** @deprecated */\nexport interface INoticeBubbleInfoProps extends NoticeBubbleInfoProps, UnknownProperties {}\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\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\n/** @deprecated */\nexport interface INoticeBubbleWarningProps extends NoticeBubbleWarningProps, UnknownProperties {}\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n /**\n * Notice display duration.\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\n/** @deprecated */\nexport interface INoticeBubbleManager extends NoticeBubbleManagerClass, UnknownProperties {}\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => {\n uid: string;\n update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;\n remove: () => boolean;\n ref: React.RefObject<HTMLDivElement>;\n focus: () => void;\n };\n /**\n * Updates notice by uid.\n * */\n update: (\n uid: string,\n props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,\n ) => boolean;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: string) => boolean;\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};\nexport declare class NoticeBubbleManager implements NoticeBubbleManagerClass {\n /**\n * Creates and shows a notice.\n * */\n add(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): {\n uid: string;\n update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;\n remove: () => boolean;\n ref: React.RefObject<HTMLDivElement>;\n focus: () => void;\n };\n /**\n * Updates notice by uid.\n * */\n update(\n uid: string,\n props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,\n ): boolean;\n /**\n * Removes notice by uid.\n * */\n remove(uid: string): boolean;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n}\n\nexport declare const noticeBubbleDefaultManager: NoticeBubbleManager;\n\n/**\n * @deprecated Use `import { noticeBubbleDefaultManager } from ...` instead\n */\nexport default noticeBubbleDefaultManager;\n"],"mappings":""}
|
package/lib/es6/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { PortalProps } from '@semcore/portal';\nimport { UnknownProperties, Intergalactic } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface INoticeBubbleContainerProps\n extends NoticeBubbleContainerProps,\n UnknownProperties {}\nexport type NoticeBubbleContainerProps = BoxProps &\n PortalProps & {\n /** Manager copy */\n manager?:
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import { PortalProps } from '@semcore/portal';\nimport { UnknownProperties, Intergalactic } from '@semcore/core';\nimport { BoxProps } from '@semcore/flex-box';\n\n/** @deprecated */\nexport interface INoticeBubbleContainerProps\n extends NoticeBubbleContainerProps,\n UnknownProperties {}\nexport type NoticeBubbleContainerProps = BoxProps &\n PortalProps & {\n /** Manager copy */\n manager?: NoticeBubbleManagerClass;\n locale?: string;\n };\n\n/** @deprecated */\nexport interface INoticeBubbleProps extends NoticeBubbleProps, UnknownProperties {}\nexport type NoticeBubbleProps = BoxProps & {\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?: NoticeBubbleManager;\n icon?: React.ReactElement;\n};\n/** @deprecated */\nexport interface INoticeBubbleInfoProps extends NoticeBubbleInfoProps, UnknownProperties {}\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\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\n/** @deprecated */\nexport interface INoticeBubbleWarningProps extends NoticeBubbleWarningProps, UnknownProperties {}\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n /**\n * Notice display duration.\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\n/** @deprecated */\nexport interface INoticeBubbleManager extends NoticeBubbleManagerClass, UnknownProperties {}\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => {\n uid: string;\n update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;\n remove: () => boolean;\n ref: React.RefObject<HTMLDivElement>;\n focus: () => void;\n };\n /**\n * Updates notice by uid.\n * */\n update: (\n uid: string,\n props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,\n ) => boolean;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: string) => boolean;\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};\nexport declare class NoticeBubbleManager implements NoticeBubbleManagerClass {\n /**\n * Creates and shows a notice.\n * */\n add(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): {\n uid: string;\n update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;\n remove: () => boolean;\n ref: React.RefObject<HTMLDivElement>;\n focus: () => void;\n };\n /**\n * Updates notice by uid.\n * */\n update(\n uid: string,\n props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,\n ): boolean;\n /**\n * Removes notice by uid.\n * */\n remove(uid: string): boolean;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n}\n\nexport declare const noticeBubbleDefaultManager: NoticeBubbleManager;\n\n/**\n * @deprecated Use `import { noticeBubbleDefaultManager } from ...` instead\n */\nexport default noticeBubbleDefaultManager;\n"],"mappings":""}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import K from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import V from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
import v from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import h from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import u from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
+
import b from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import x from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import c from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
+
import d from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
|
+
import { sstyled as H } from "@semcore/utils/lib/core/index";
|
|
11
|
+
import X, { sstyled as N, assignProps as Y, Component as k } from "@semcore/core";
|
|
12
|
+
import r from "react";
|
|
13
|
+
import G from "@semcore/portal";
|
|
14
|
+
import P from "./NoticeBubbleManager.mjs";
|
|
15
|
+
import { Animation as J } from "@semcore/animation";
|
|
16
|
+
import { Box as O, Flex as I } from "@semcore/flex-box";
|
|
17
|
+
import Q from "@semcore/utils/lib/fire";
|
|
18
|
+
import C from "@semcore/utils/lib/isNode";
|
|
19
|
+
import { callAllEventHandlers as W } from "@semcore/utils/lib/assignProps";
|
|
20
|
+
import ee from "@semcore/icon/Close/m";
|
|
21
|
+
import { Timer as te } from "./utils.mjs";
|
|
22
|
+
import { localizedMessages as z } from "./translations/__intergalactic-dynamic-locales.mjs";
|
|
23
|
+
import ne from "@semcore/utils/lib/enhances/i18nEnhance";
|
|
24
|
+
import { useCssVariable as re } from "@semcore/utils/lib/useCssVariable";
|
|
25
|
+
import { contextThemeEnhance as ie } from "@semcore/utils/lib/ThemeProvider";
|
|
26
|
+
import A from "@semcore/button";
|
|
27
|
+
import { setFocus as ae, useFocusLock as oe } from "@semcore/utils/lib/use/useFocusLock";
|
|
28
|
+
import { Hint as se } from "@semcore/tooltip";
|
|
29
|
+
import { zIndexStackingEnhance as ce, ZIndexStackingContextProvider as le } from "@semcore/utils/lib/zIndexStacking";
|
|
30
|
+
import { forkRef as _e, useForkRef as ge } from "@semcore/utils/lib/ref";
|
|
31
|
+
import { getFocusableIn as ue } from "@semcore/utils/lib/focus-lock/getFocusableIn";
|
|
32
|
+
var pe = ["focusLock"], fe = ["forwardRef", "styles", "onMouseEnter", "onMouseLeave", "getI18nText", "icon", "children", "action", "type"], me = (
|
|
33
|
+
/*__reshadow_css_start__*/
|
|
34
|
+
(H.insert(
|
|
35
|
+
/*__inner_css_start__*/
|
|
36
|
+
"@keyframes enter_1qpfg{0%{transform:translate(100%,0);max-height:0;overflow:hidden}to{transform:translate(0,0);max-height:100vh;overflow:hidden}}@keyframes exit_1qpfg{0%{max-height:100vh;overflow:hidden;opacity:1}to{max-height:0;overflow:hidden;opacity:0}}.___SBubble_1qpfg_gg_,.___SView_1qpfg_gg_{position:relative;margin-bottom:var(--intergalactic-spacing-3x, 12px);padding:var(--intergalactic-spacing-3x, 12px);padding-right:calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-1x, 4px));width:100%;border-radius:var(--intergalactic-popper-rounded, 6px);overflow:hidden;box-sizing:border-box;color:var(--intergalactic-text-primary-invert, #ffffff);gap:var(--intergalactic-spacing-2x, 8px)}.___SBubble_1qpfg_gg_._type_info_1qpfg_gg_,.___SView_1qpfg_gg_._type_info_1qpfg_gg_{background:var(--intergalactic-bg-primary-invert, #191b23)}.___SBubble_1qpfg_gg_._type_warning_1qpfg_gg_,.___SView_1qpfg_gg_._type_warning_1qpfg_gg_{background:var(--intergalactic-bg-primary-critical, #ff4953)}.___SContent_1qpfg_gg_{flex-direction:column;gap:var(--intergalactic-spacing-2x, 8px);flex:1}.___SMessage_1qpfg_gg_{font-size:var(--intergalactic-fs-200, 14px);line-height:var(--intergalactic-lh-200, 142%)}.___SDismiss_1qpfg_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_1qpfg_gg_.__use_1qpfg_gg_{padding:0 1px}.___SIcon_1qpfg_gg_{justify-content:center;align-items:center;height:var(--intergalactic-spacing-5x, 20px)}.___SNoticeBubble_1qpfg_gg_{width:300px;position:fixed;right:var(--intergalactic-spacing-3x, 12px);top:var(--intergalactic-spacing-3x, 12px)}@media (max-width:767px){.___SNoticeBubble_1qpfg_gg_{width:calc(100% - var(--intergalactic-spacing-6x, 24px))}}.___SNoticeBubble_1qpfg_gg_.__disablePortal_1qpfg_gg_{position:sticky;margin-left:auto;height:0}.___SMessage_1qpfg_gg_ a{color:var(--intergalactic-text-link-invert, #8ecdff)}.___SNoticeAriaLiveWrapper_1qpfg_gg_{display:contents}",
|
|
37
|
+
"1qpfg_gg_"
|
|
38
|
+
), {
|
|
39
|
+
__SContent: "___SContent_1qpfg_gg_",
|
|
40
|
+
__SMessage: "___SMessage_1qpfg_gg_",
|
|
41
|
+
__SDismiss: "___SDismiss_1qpfg_gg_",
|
|
42
|
+
_use: "__use_1qpfg_gg_",
|
|
43
|
+
__SIcon: "___SIcon_1qpfg_gg_",
|
|
44
|
+
__SNoticeBubble: "___SNoticeBubble_1qpfg_gg_",
|
|
45
|
+
_disablePortal: "__disablePortal_1qpfg_gg_",
|
|
46
|
+
__SNoticeAriaLiveWrapper: "___SNoticeAriaLiveWrapper_1qpfg_gg_",
|
|
47
|
+
"@enter": "enter_1qpfg",
|
|
48
|
+
"@exit": "exit_1qpfg",
|
|
49
|
+
__SBubble: "___SBubble_1qpfg_gg_",
|
|
50
|
+
__SView: "___SView_1qpfg_gg_",
|
|
51
|
+
_type_info: "_type_info_1qpfg_gg_",
|
|
52
|
+
_type_warning: "_type_warning_1qpfg_gg_"
|
|
53
|
+
})
|
|
54
|
+
), D = function(l) {
|
|
55
|
+
var t = l.styles, e = l.data, n = e === void 0 ? [] : e, i = l.tag, a = i === void 0 ? L : i, o = r.useRef(), s = re("--intergalactic-duration-popper", "200", o), f = r.useMemo(function() {
|
|
56
|
+
return parseInt(s, 10);
|
|
57
|
+
}, [s]);
|
|
58
|
+
return n.map(function(_) {
|
|
59
|
+
var g, m;
|
|
60
|
+
return g = N(t), /* @__PURE__ */ r.createElement(J, g.cn("Animation", {
|
|
61
|
+
key: _.uid,
|
|
62
|
+
initialAnimation: _.initialAnimation,
|
|
63
|
+
visible: (m = _.visible) !== null && m !== void 0 ? m : !0,
|
|
64
|
+
duration: f,
|
|
65
|
+
keyframes: [t["@enter"], t["@exit"]],
|
|
66
|
+
ref: o
|
|
67
|
+
}), /* @__PURE__ */ r.createElement(a, g.cn("SView", d(d({}, _), {}, {
|
|
68
|
+
styles: _.styles || t,
|
|
69
|
+
getI18nText: l.getI18nText
|
|
70
|
+
}))));
|
|
71
|
+
});
|
|
72
|
+
}, y = /* @__PURE__ */ function(p) {
|
|
73
|
+
b(t, p);
|
|
74
|
+
var l = x(t);
|
|
75
|
+
function t() {
|
|
76
|
+
var e;
|
|
77
|
+
v(this, t);
|
|
78
|
+
for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
|
|
79
|
+
i[a] = arguments[a];
|
|
80
|
+
return e = l.call.apply(l, [this].concat(i)), c(u(e), "_unsubscribe", null), c(u(e), "state", {
|
|
81
|
+
notices: [],
|
|
82
|
+
warnings: []
|
|
83
|
+
}), c(u(e), "componentWillUnmount", function() {
|
|
84
|
+
e._unsubscribe && e._unsubscribe();
|
|
85
|
+
}), c(u(e), "handleChange", function(o) {
|
|
86
|
+
var s = o.filter(function(_) {
|
|
87
|
+
return _.type === "info";
|
|
88
|
+
}), f = o.filter(function(_) {
|
|
89
|
+
return _.type === "warning";
|
|
90
|
+
});
|
|
91
|
+
e.setState({
|
|
92
|
+
notices: s,
|
|
93
|
+
warnings: f
|
|
94
|
+
});
|
|
95
|
+
}), e;
|
|
96
|
+
}
|
|
97
|
+
return h(t, [{
|
|
98
|
+
key: "componentDidMount",
|
|
99
|
+
value: function() {
|
|
100
|
+
this._unsubscribe = this.asProps.manager.addListener(this.handleChange);
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "render",
|
|
104
|
+
value: function() {
|
|
105
|
+
var n = this.asProps, i, a = O, o = "div", s = this.asProps, f = s.Children, _ = s.styles, g = s.disablePortal, m = s.getI18nText, B = s.ref, M = s.parentZIndexStacking, S = this.state, w = S.notices, q = S.warnings;
|
|
106
|
+
return i = N(_), /* @__PURE__ */ r.createElement(le, i.cn("ZIndexStackingContextProvider", {
|
|
107
|
+
designToken: "z-index-notice-bubble"
|
|
108
|
+
}), /* @__PURE__ */ r.createElement(G, i.cn("Portal", {
|
|
109
|
+
disablePortal: g
|
|
110
|
+
}), /* @__PURE__ */ r.createElement(a, i.cn("SNoticeBubble", d({}, Y({
|
|
111
|
+
ref: B,
|
|
112
|
+
tag: "section",
|
|
113
|
+
role: "region",
|
|
114
|
+
"aria-label": m("notification"),
|
|
115
|
+
zIndex: M
|
|
116
|
+
}, n))), /* @__PURE__ */ r.createElement(f, i.cn("Children", {})), /* @__PURE__ */ r.createElement(D, i.cn("Notices", {
|
|
117
|
+
styles: _,
|
|
118
|
+
data: q,
|
|
119
|
+
tag: $,
|
|
120
|
+
getI18nText: m
|
|
121
|
+
})), /* @__PURE__ */ r.createElement(o, i.cn("SNoticeAriaLiveWrapper", {
|
|
122
|
+
"aria-live": "polite"
|
|
123
|
+
}), /* @__PURE__ */ r.createElement(D, i.cn("Notices", {
|
|
124
|
+
styles: _,
|
|
125
|
+
data: w,
|
|
126
|
+
tag: L,
|
|
127
|
+
getI18nText: m
|
|
128
|
+
}))))));
|
|
129
|
+
}
|
|
130
|
+
}]), t;
|
|
131
|
+
}(k);
|
|
132
|
+
c(y, "displayName", "NoticeBubbleContainer");
|
|
133
|
+
c(y, "style", me);
|
|
134
|
+
c(y, "enhance", [ne(z), ie(), ce("z-index-notice-bubble")]);
|
|
135
|
+
c(y, "defaultProps", {
|
|
136
|
+
manager: P,
|
|
137
|
+
i18n: z,
|
|
138
|
+
locale: "en"
|
|
139
|
+
});
|
|
140
|
+
var de = /* @__PURE__ */ r.forwardRef(function(p, l) {
|
|
141
|
+
var t = p.focusLock, e = V(p, pe), n = r.useRef();
|
|
142
|
+
oe(n, !1, "auto", !t, !0);
|
|
143
|
+
var i = ge(l, n);
|
|
144
|
+
return /* @__PURE__ */ r.createElement(I, K({
|
|
145
|
+
ref: i
|
|
146
|
+
}, e));
|
|
147
|
+
}), L = /* @__PURE__ */ function(p) {
|
|
148
|
+
b(t, p);
|
|
149
|
+
var l = x(t);
|
|
150
|
+
function t() {
|
|
151
|
+
var e;
|
|
152
|
+
v(this, t);
|
|
153
|
+
for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
|
|
154
|
+
i[a] = arguments[a];
|
|
155
|
+
return e = l.call.apply(l, [this].concat(i)), c(u(e), "timer", null), c(u(e), "ref", /* @__PURE__ */ r.createRef()), c(u(e), "closeButtonRef", /* @__PURE__ */ r.createRef()), c(u(e), "handleClose", function(o) {
|
|
156
|
+
Q(u(e), "onClose", o), e.clearTimer();
|
|
157
|
+
}), c(u(e), "handleKeydown", function(o) {
|
|
158
|
+
o.key === "Escape" && e.handleClose(o);
|
|
159
|
+
}), c(u(e), "handleMouseEnter", function() {
|
|
160
|
+
e.timer && e.timer.pause();
|
|
161
|
+
}), c(u(e), "handleMouseLeave", function() {
|
|
162
|
+
e.timer && e.timer.resume();
|
|
163
|
+
}), c(u(e), "handleBodyMouseMove", function(o) {
|
|
164
|
+
var s;
|
|
165
|
+
if ((s = e.timer) !== null && s !== void 0 && s.paused) {
|
|
166
|
+
var f = e.ref.current.getBoundingClientRect(), _ = o.clientX >= f.left && o.clientX <= f.right && o.clientY >= f.top && o.clientY <= f.bottom;
|
|
167
|
+
_ || e.timer.resume();
|
|
168
|
+
}
|
|
169
|
+
}), e;
|
|
170
|
+
}
|
|
171
|
+
return h(t, [{
|
|
172
|
+
key: "componentDidMount",
|
|
173
|
+
value: function() {
|
|
174
|
+
var n = this, i = this.props.duration;
|
|
175
|
+
i && (this.timer = new te(this.handleClose, i), document.body.addEventListener("mousemove", this.handleBodyMouseMove));
|
|
176
|
+
var a = this.ref.current;
|
|
177
|
+
if (a) {
|
|
178
|
+
var o = ue(a).filter(function(s) {
|
|
179
|
+
return s !== n.closeButtonRef.current;
|
|
180
|
+
});
|
|
181
|
+
o.length > 0 && setTimeout(function() {
|
|
182
|
+
return ae(a);
|
|
183
|
+
}, 0);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "componentWillUnmount",
|
|
188
|
+
value: function() {
|
|
189
|
+
this.clearTimer(), document.body.removeEventListener("mousemove", this.handleBodyMouseMove);
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "clearTimer",
|
|
193
|
+
value: function() {
|
|
194
|
+
this.timer && (this.timer.clear(), this.timer = null);
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "render",
|
|
198
|
+
value: function() {
|
|
199
|
+
var n, i = de, a = se.Trigger, o = I, s = "div", f = "div", _ = I, g = this.props, m = g.forwardRef, B = g.styles, M = g.onMouseEnter, S = g.onMouseLeave, w = g.getI18nText, q = g.icon, T = g.children, E = g.action, Z = g.type, j = V(g, fe);
|
|
200
|
+
return n = N(B), /* @__PURE__ */ r.createElement(i, n.cn("SBubble", d(d({}, j), {}, {
|
|
201
|
+
ref: _e(m, this.ref),
|
|
202
|
+
onMouseEnter: W(M, this.handleMouseEnter),
|
|
203
|
+
onMouseLeave: W(S, this.handleMouseLeave),
|
|
204
|
+
onKeyDown: this.handleKeydown,
|
|
205
|
+
role: Z === "warning" ? "alert" : this.props.role
|
|
206
|
+
})), /* @__PURE__ */ r.createElement(
|
|
207
|
+
a,
|
|
208
|
+
n.cn("SDismiss", {
|
|
209
|
+
"aria-haspopup": void 0,
|
|
210
|
+
tag: A,
|
|
211
|
+
type: "button",
|
|
212
|
+
use: "tertiary",
|
|
213
|
+
size: "m",
|
|
214
|
+
theme: "invert",
|
|
215
|
+
onClick: this.handleClose,
|
|
216
|
+
"aria-label": w("close"),
|
|
217
|
+
active: !1,
|
|
218
|
+
title: w("close"),
|
|
219
|
+
ref: this.closeButtonRef
|
|
220
|
+
}),
|
|
221
|
+
/* @__PURE__ */ r.createElement(A.Addon, {
|
|
222
|
+
tag: ee,
|
|
223
|
+
color: "icon-primary-invert"
|
|
224
|
+
})
|
|
225
|
+
), C(q) ? /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(_, n.cn("SIcon", {}), q), /* @__PURE__ */ r.createElement(o, n.cn("SContent", {}), /* @__PURE__ */ r.createElement(s, n.cn("SMessage", {}), T), C(E) ? /* @__PURE__ */ r.createElement(f, n.cn("SAction", {}), E) : null)) : /* @__PURE__ */ r.createElement(o, n.cn("SContent", {}), /* @__PURE__ */ r.createElement(s, n.cn("SMessage", {}), T), C(E) ? /* @__PURE__ */ r.createElement(f, n.cn("SAction", {}), E) : null));
|
|
226
|
+
}
|
|
227
|
+
}]), t;
|
|
228
|
+
}(k), $ = /* @__PURE__ */ function(p) {
|
|
229
|
+
b(t, p);
|
|
230
|
+
var l = x(t);
|
|
231
|
+
function t() {
|
|
232
|
+
return v(this, t), l.apply(this, arguments);
|
|
233
|
+
}
|
|
234
|
+
return h(t);
|
|
235
|
+
}(L);
|
|
236
|
+
c($, "defaultProps", {
|
|
237
|
+
type: "warning",
|
|
238
|
+
duration: 0
|
|
239
|
+
});
|
|
240
|
+
var R = /* @__PURE__ */ function(p) {
|
|
241
|
+
b(t, p);
|
|
242
|
+
var l = x(t);
|
|
243
|
+
function t() {
|
|
244
|
+
var e;
|
|
245
|
+
v(this, t);
|
|
246
|
+
for (var n = arguments.length, i = new Array(n), a = 0; a < n; a++)
|
|
247
|
+
i[a] = arguments[a];
|
|
248
|
+
return e = l.call.apply(l, [this].concat(i)), c(u(e), "_notice", null), e;
|
|
249
|
+
}
|
|
250
|
+
return h(t, [{
|
|
251
|
+
key: "componentDidMount",
|
|
252
|
+
value: function() {
|
|
253
|
+
this._notice = this.asProps.manager.add(this.asProps);
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "componentWillUnmount",
|
|
257
|
+
value: function() {
|
|
258
|
+
this._notice && this._notice.remove();
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "componentDidUpdate",
|
|
262
|
+
value: function() {
|
|
263
|
+
this._notice && this._notice.update(this.asProps);
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "render",
|
|
267
|
+
value: function() {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}]), t;
|
|
271
|
+
}(k);
|
|
272
|
+
c(R, "defaultProps", {
|
|
273
|
+
duration: 5e3,
|
|
274
|
+
type: "info",
|
|
275
|
+
manager: P
|
|
276
|
+
});
|
|
277
|
+
var F = /* @__PURE__ */ function(p) {
|
|
278
|
+
b(t, p);
|
|
279
|
+
var l = x(t);
|
|
280
|
+
function t() {
|
|
281
|
+
return v(this, t), l.apply(this, arguments);
|
|
282
|
+
}
|
|
283
|
+
return h(t);
|
|
284
|
+
}(R);
|
|
285
|
+
c(F, "defaultProps", {
|
|
286
|
+
duration: 5e3,
|
|
287
|
+
type: "warning",
|
|
288
|
+
manager: P
|
|
289
|
+
});
|
|
290
|
+
var U = X(y, {
|
|
291
|
+
Info: R,
|
|
292
|
+
Warning: F
|
|
293
|
+
}), Xe = U.Info, Ye = U.Warning;
|
|
294
|
+
export {
|
|
295
|
+
Xe as NoticeBubble,
|
|
296
|
+
Ye as NoticeBubbleWarning,
|
|
297
|
+
U as default
|
|
298
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import s from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import f from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import c from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import u from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
+
import l from "@semcore/utils/lib/eventEmitter";
|
|
6
|
+
import { callAllEventHandlers as h } from "@semcore/utils/lib/assignProps";
|
|
7
|
+
import { setFocus as d } from "@semcore/utils/lib/use/useFocusLock";
|
|
8
|
+
import v from "react";
|
|
9
|
+
var m = "CHANGE", p = /* @__PURE__ */ function() {
|
|
10
|
+
function a() {
|
|
11
|
+
f(this, a), u(this, "items", []), u(this, "emitter", null), u(this, "counter", 0), u(this, "replaceTimer", 0), this.emitter = new l();
|
|
12
|
+
}
|
|
13
|
+
return c(a, [{
|
|
14
|
+
key: "addListener",
|
|
15
|
+
value: function(e) {
|
|
16
|
+
return this.emitter.subscribe(m, e);
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
key: "createItem",
|
|
20
|
+
value: function(e) {
|
|
21
|
+
var t = this;
|
|
22
|
+
return s(s({
|
|
23
|
+
type: "info"
|
|
24
|
+
}, e), {}, {
|
|
25
|
+
onClose: h(e.onClose, function() {
|
|
26
|
+
t.remove(e.uid);
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "emit",
|
|
32
|
+
value: function() {
|
|
33
|
+
this.emitter.emit(m, this.items);
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "add",
|
|
37
|
+
value: function(e) {
|
|
38
|
+
var t = this.counter++, i = /* @__PURE__ */ v.createRef(), r = function() {
|
|
39
|
+
return setTimeout(function() {
|
|
40
|
+
return d(i.current);
|
|
41
|
+
}, 0);
|
|
42
|
+
}, o = this.createItem(s({
|
|
43
|
+
uid: t,
|
|
44
|
+
visible: e.initialAnimation ? !0 : void 0,
|
|
45
|
+
forwardRef: i
|
|
46
|
+
}, e));
|
|
47
|
+
return this.items.push(o), this.emit(), {
|
|
48
|
+
uid: t,
|
|
49
|
+
update: this.update.bind(this, t),
|
|
50
|
+
remove: this.remove.bind(this, t),
|
|
51
|
+
ref: i,
|
|
52
|
+
// todo Brauer Ilia: remove this property, because we added logic about autofocus in Notice
|
|
53
|
+
focus: r
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "update",
|
|
58
|
+
value: function(e, t) {
|
|
59
|
+
var i = this.items.findIndex(function(r) {
|
|
60
|
+
return r.uid === e;
|
|
61
|
+
});
|
|
62
|
+
return i !== -1 ? (this.items[i] = this.createItem(s(s({}, this.items[i]), t)), this.emit(), !0) : !1;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "replaceLast",
|
|
66
|
+
value: function(e) {
|
|
67
|
+
var t = this;
|
|
68
|
+
this.replaceTimer && clearTimeout(this.replaceTimer);
|
|
69
|
+
var i = this.items[this.items.length - 1];
|
|
70
|
+
i != null && i.visible && this.remove(this.counter - 1), this.replaceTimer = setTimeout(function() {
|
|
71
|
+
t.add(e);
|
|
72
|
+
}, 300);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "remove",
|
|
76
|
+
value: function(e) {
|
|
77
|
+
var t = this, i = this.items.find(function(r) {
|
|
78
|
+
return r.uid === e;
|
|
79
|
+
});
|
|
80
|
+
return i ? (i.visible = !1, setTimeout(function() {
|
|
81
|
+
t.items = t.items.filter(function(r) {
|
|
82
|
+
return r.uid !== e;
|
|
83
|
+
}), t.emit();
|
|
84
|
+
}, 1e3), this.emit(), !0) : !1;
|
|
85
|
+
}
|
|
86
|
+
}]), a;
|
|
87
|
+
}(), N = new p();
|
|
88
|
+
export {
|
|
89
|
+
p as NoticeBubbleManager,
|
|
90
|
+
N as default
|
|
91
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NoticeBubble as r, default as b, NoticeBubbleWarning as i } from "./NoticeBubble.mjs";
|
|
2
|
+
import o from "./NoticeBubbleManager.mjs";
|
|
3
|
+
import { NoticeBubbleManager as u } from "./NoticeBubbleManager.mjs";
|
|
4
|
+
export {
|
|
5
|
+
r as NoticeBubble,
|
|
6
|
+
b as NoticeBubbleContainer,
|
|
7
|
+
u as NoticeBubbleManager,
|
|
8
|
+
i as NoticeBubbleWarning,
|
|
9
|
+
o as default,
|
|
10
|
+
o as noticeBubbleDefaultManager
|
|
11
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import r from "./de.json.mjs";
|
|
2
|
+
import o from "./en.json.mjs";
|
|
3
|
+
import m from "./es.json.mjs";
|
|
4
|
+
import t from "./fr.json.mjs";
|
|
5
|
+
import i from "./it.json.mjs";
|
|
6
|
+
import p from "./ja.json.mjs";
|
|
7
|
+
import f from "./ko.json.mjs";
|
|
8
|
+
import e from "./nl.json.mjs";
|
|
9
|
+
import s from "./pt.json.mjs";
|
|
10
|
+
import a from "./tr.json.mjs";
|
|
11
|
+
import l from "./vi.json.mjs";
|
|
12
|
+
import v from "./zh.json.mjs";
|
|
13
|
+
import d from "./pl.json.mjs";
|
|
14
|
+
import n from "./sv.json.mjs";
|
|
15
|
+
var B = {
|
|
16
|
+
de: r,
|
|
17
|
+
en: o,
|
|
18
|
+
es: m,
|
|
19
|
+
fr: t,
|
|
20
|
+
it: i,
|
|
21
|
+
ja: p,
|
|
22
|
+
ko: f,
|
|
23
|
+
nl: e,
|
|
24
|
+
pt: s,
|
|
25
|
+
tr: a,
|
|
26
|
+
vi: l,
|
|
27
|
+
zh: v,
|
|
28
|
+
pl: d,
|
|
29
|
+
sv: n
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
B as localizedMessages
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import s from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import a from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
var n = /* @__PURE__ */ function() {
|
|
4
|
+
function t(e, i) {
|
|
5
|
+
s(this, t), this.callback = e, this.delay = i, this.remaining = i, this.paused = !1, this.resume();
|
|
6
|
+
}
|
|
7
|
+
return a(t, [{
|
|
8
|
+
key: "pause",
|
|
9
|
+
value: function() {
|
|
10
|
+
clearTimeout(this.timerId), this.remaining -= Date.now() - this.start, this.paused = !0;
|
|
11
|
+
}
|
|
12
|
+
}, {
|
|
13
|
+
key: "resume",
|
|
14
|
+
value: function() {
|
|
15
|
+
this.start = Date.now(), this.paused = !1, clearTimeout(this.timerId), this.timerId = setTimeout(this.callback, this.remaining);
|
|
16
|
+
}
|
|
17
|
+
}, {
|
|
18
|
+
key: "reset",
|
|
19
|
+
value: function() {
|
|
20
|
+
this.remaining = this.delay, this.resume();
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: "clear",
|
|
24
|
+
value: function() {
|
|
25
|
+
clearTimeout(this.timerId);
|
|
26
|
+
}
|
|
27
|
+
}]), t;
|
|
28
|
+
}();
|
|
29
|
+
export {
|
|
30
|
+
n as Timer
|
|
31
|
+
};
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/notice-bubble",
|
|
3
3
|
"description": "Semrush NoticeBubble Component",
|
|
4
|
-
"version": "5.52.0-prerelease.
|
|
4
|
+
"version": "5.52.0-prerelease.12",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
8
8
|
"author": "UI-kit team <ui-kit-team@semrush.com>",
|
|
9
9
|
"sideEffects": false,
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"exports": {
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"import": "./lib/esm/index.mjs",
|
|
14
|
+
"types": "./lib/types/index.d.ts"
|
|
15
|
+
},
|
|
11
16
|
"dependencies": {
|
|
12
|
-
"@semcore/
|
|
13
|
-
"@semcore/
|
|
14
|
-
"@semcore/
|
|
15
|
-
"@semcore/
|
|
16
|
-
"@semcore/
|
|
17
|
+
"@semcore/button": "5.42.0-prerelease.12",
|
|
18
|
+
"@semcore/utils": "4.48.0-prerelease.12",
|
|
19
|
+
"@semcore/icon": "4.61.0-prerelease.12",
|
|
20
|
+
"@semcore/portal": "3.41.0-prerelease.12",
|
|
21
|
+
"@semcore/flex-box": "5.41.0-prerelease.12",
|
|
22
|
+
"@semcore/animation": "2.41.0-prerelease.12",
|
|
23
|
+
"@semcore/tooltip": "6.49.0-prerelease.12"
|
|
17
24
|
},
|
|
18
25
|
"peerDependencies": {
|
|
19
|
-
"@semcore/core": "^2.39.0-prerelease.
|
|
26
|
+
"@semcore/core": "^2.39.0-prerelease.12",
|
|
20
27
|
"react": "16.8 - 18",
|
|
21
28
|
"react-dom": "16.8 - 18"
|
|
22
29
|
},
|
|
@@ -30,6 +37,6 @@
|
|
|
30
37
|
"@semcore/testing-utils": "1.0.0"
|
|
31
38
|
},
|
|
32
39
|
"scripts": {
|
|
33
|
-
"build": "pnpm semcore-builder --source=js"
|
|
40
|
+
"build": "pnpm semcore-builder --source=js && pnpm vite build"
|
|
34
41
|
}
|
|
35
42
|
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
import viteConfig from '../../commonVite.config';
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
viteConfig,
|
|
7
|
+
defineConfig({
|
|
8
|
+
build: {
|
|
9
|
+
lib: {
|
|
10
|
+
entry: './src/index.js',
|
|
11
|
+
},
|
|
12
|
+
rollupOptions: {
|
|
13
|
+
external: ['react', 'react-dom', 'react/jsx-runtime', /@babel\/runtime\/*/, /@semcore\/*/],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
);
|