@semcore/notice-bubble 5.55.0-prerelease.5 → 5.55.0-prerelease.7

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.
Files changed (40) hide show
  1. package/lib/cjs/NoticeBubble.js +217 -177
  2. package/lib/cjs/NoticeBubble.js.map +1 -1
  3. package/lib/cjs/NoticeBubbleManager.js +56 -34
  4. package/lib/cjs/NoticeBubbleManager.js.map +1 -1
  5. package/lib/cjs/index.d.js +2 -0
  6. package/lib/cjs/index.d.js.map +1 -0
  7. package/lib/cjs/index.js +4 -1
  8. package/lib/cjs/index.js.map +1 -1
  9. package/lib/cjs/translations/__intergalactic-dynamic-locales.js +5 -4
  10. package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
  11. package/lib/cjs/utils.js +9 -20
  12. package/lib/cjs/utils.js.map +1 -1
  13. package/lib/es6/NoticeBubble.js +207 -170
  14. package/lib/es6/NoticeBubble.js.map +1 -1
  15. package/lib/es6/NoticeBubbleManager.js +51 -31
  16. package/lib/es6/NoticeBubbleManager.js.map +1 -1
  17. package/lib/es6/index.d.js +2 -0
  18. package/lib/es6/index.d.js.map +1 -0
  19. package/lib/es6/index.js +2 -1
  20. package/lib/es6/index.js.map +1 -1
  21. package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
  22. package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
  23. package/lib/es6/utils.js +6 -18
  24. package/lib/es6/utils.js.map +1 -1
  25. package/lib/esm/NoticeBubble.mjs +215 -175
  26. package/lib/esm/NoticeBubbleManager.mjs +53 -33
  27. package/lib/esm/index.mjs +7 -3
  28. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
  29. package/lib/esm/utils.mjs +8 -20
  30. package/lib/types/index.d.ts +167 -7
  31. package/package.json +9 -9
  32. package/lib/cjs/NoticeBubble.type.js +0 -2
  33. package/lib/cjs/NoticeBubble.type.js.map +0 -1
  34. package/lib/es6/NoticeBubble.type.js +0 -2
  35. package/lib/es6/NoticeBubble.type.js.map +0 -1
  36. package/lib/types/NoticeBubble.d.ts +0 -4
  37. package/lib/types/NoticeBubble.type.d.ts +0 -91
  38. package/lib/types/NoticeBubbleManager.d.ts +0 -22
  39. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +0 -58
  40. package/lib/types/utils.d.ts +0 -14
@@ -2,22 +2,37 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
6
- import EventEmitter from "@semcore/core/lib/utils/eventEmitter";
5
+ import EventEmitter from "@semcore/utils/lib/eventEmitter";
6
+ import { callAllEventHandlers } from "@semcore/utils/lib/assignProps";
7
+ import { setFocus } from "@semcore/utils/lib/use/useFocusLock";
7
8
  import React from "react";
8
9
  var EVENT_NAME = "CHANGE";
9
- var NoticeBubbleManager = /* @__PURE__ */ (function() {
10
+ var NoticeBubbleManager = /* @__PURE__ */ function() {
10
11
  function NoticeBubbleManager2() {
11
12
  _classCallCheck(this, NoticeBubbleManager2);
12
13
  _defineProperty(this, "items", []);
13
- _defineProperty(this, "emitter", new EventEmitter());
14
+ _defineProperty(this, "emitter", null);
14
15
  _defineProperty(this, "counter", 0);
16
+ _defineProperty(this, "replaceTimer", 0);
17
+ this.emitter = new EventEmitter();
15
18
  }
16
- return _createClass(NoticeBubbleManager2, [{
19
+ _createClass(NoticeBubbleManager2, [{
17
20
  key: "addListener",
18
21
  value: function addListener(fn) {
19
22
  return this.emitter.subscribe(EVENT_NAME, fn);
20
23
  }
24
+ }, {
25
+ key: "createItem",
26
+ value: function createItem(props) {
27
+ var manager = this;
28
+ return _objectSpread(_objectSpread({
29
+ type: "info"
30
+ }, props), {}, {
31
+ onClose: callAllEventHandlers(props.onClose, function() {
32
+ manager.remove(props.uid);
33
+ })
34
+ });
35
+ }
21
36
  }, {
22
37
  key: "emit",
23
38
  value: function emit() {
@@ -26,67 +41,71 @@ var NoticeBubbleManager = /* @__PURE__ */ (function() {
26
41
  }, {
27
42
  key: "add",
28
43
  value: function add(props) {
29
- var _this = this;
30
44
  var uid = this.counter++;
31
45
  var ref = /* @__PURE__ */ React.createRef();
32
- var item = _objectSpread(_objectSpread({
33
- type: "info",
46
+ var focus = function focus2() {
47
+ return setTimeout(function() {
48
+ return setFocus(ref.current);
49
+ }, 0);
50
+ };
51
+ var item = this.createItem(_objectSpread({
34
52
  uid,
35
53
  visible: props.initialAnimation ? true : void 0,
36
54
  forwardRef: ref
37
- }, props), {}, {
38
- onClose: callAllEventHandlers(props.onClose, function() {
39
- _this.remove(uid);
40
- })
41
- });
55
+ }, props));
42
56
  this.items.push(item);
43
57
  this.emit();
44
58
  return {
45
59
  uid,
46
- update: this.replace.bind(this, uid),
60
+ update: this.update.bind(this, uid),
47
61
  remove: this.remove.bind(this, uid),
48
- ref
62
+ ref,
63
+ // todo Brauer Ilia: remove this property, because we added logic about autofocus in Notice
64
+ focus
49
65
  };
50
66
  }
51
67
  }, {
52
- key: "replace",
53
- value: function replace(uid, props) {
54
- var _this2 = this;
55
- this.remove(uid);
56
- return new Promise(function(resolve) {
57
- setTimeout(function() {
58
- resolve(_this2.add(props));
59
- }, 300);
68
+ key: "update",
69
+ value: function update(uid, props) {
70
+ var index = this.items.findIndex(function(item) {
71
+ return item.uid === uid;
60
72
  });
73
+ if (index !== -1) {
74
+ this.items[index] = this.createItem(_objectSpread(_objectSpread({}, this.items[index]), props));
75
+ this.emit();
76
+ return true;
77
+ }
78
+ return false;
61
79
  }
62
80
  }, {
63
81
  key: "replaceLast",
64
82
  value: function replaceLast(props) {
65
- var _this3 = this;
83
+ var _this = this;
84
+ if (this.replaceTimer) {
85
+ clearTimeout(this.replaceTimer);
86
+ }
66
87
  var item = this.items[this.items.length - 1];
67
88
  if (item !== null && item !== void 0 && item.visible) {
68
89
  this.remove(this.counter - 1);
69
90
  }
70
- return new Promise(function(resolve) {
71
- setTimeout(function() {
72
- resolve(_this3.add(props));
73
- }, 300);
74
- });
91
+ this.replaceTimer = setTimeout(function() {
92
+ _this.add(props);
93
+ }, 300);
75
94
  }
76
95
  }, {
77
96
  key: "remove",
78
97
  value: function remove(uid) {
79
- var _this4 = this;
98
+ var _this2 = this;
80
99
  var item = this.items.find(function(item2) {
81
100
  return item2.uid === uid;
82
101
  });
83
102
  if (item) {
84
103
  item.visible = false;
85
104
  setTimeout(function() {
86
- _this4.items = _this4.items.filter(function(item2) {
105
+ _this2.items = _this2.items.filter(function(item2) {
87
106
  return item2.uid !== uid;
88
107
  });
89
- _this4.emit();
108
+ _this2.emit();
90
109
  }, 1e3);
91
110
  this.emit();
92
111
  return true;
@@ -94,7 +113,8 @@ var NoticeBubbleManager = /* @__PURE__ */ (function() {
94
113
  return false;
95
114
  }
96
115
  }]);
97
- })();
116
+ return NoticeBubbleManager2;
117
+ }();
98
118
  var noticeBubbleDefaultManager = new NoticeBubbleManager();
99
119
  export {
100
120
  NoticeBubbleManager,
package/lib/esm/index.mjs CHANGED
@@ -1,7 +1,11 @@
1
- import { default as default2 } from "./NoticeBubble.mjs";
2
- import { NoticeBubbleManager, default as default3 } from "./NoticeBubbleManager.mjs";
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
- default3 as noticeBubbleDefaultManager
8
+ NoticeBubbleWarning,
9
+ noticeBubbleDefaultManager as default,
10
+ noticeBubbleDefaultManager
7
11
  };
@@ -6,12 +6,12 @@ import it from "./it.json.mjs";
6
6
  import ja from "./ja.json.mjs";
7
7
  import ko from "./ko.json.mjs";
8
8
  import nl from "./nl.json.mjs";
9
- import pl from "./pl.json.mjs";
10
9
  import pt from "./pt.json.mjs";
11
- import sv from "./sv.json.mjs";
12
10
  import tr from "./tr.json.mjs";
13
11
  import vi from "./vi.json.mjs";
14
12
  import zh from "./zh.json.mjs";
13
+ import pl from "./pl.json.mjs";
14
+ import sv from "./sv.json.mjs";
15
15
  var localizedMessages = {
16
16
  de,
17
17
  en,
package/lib/esm/utils.mjs CHANGED
@@ -1,27 +1,18 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- var Timer = /* @__PURE__ */ (function() {
3
+ var Timer = /* @__PURE__ */ function() {
5
4
  function Timer2(callback, delay) {
6
5
  _classCallCheck(this, Timer2);
7
- _defineProperty(this, "delay", void 0);
8
- _defineProperty(this, "callback", void 0);
9
- _defineProperty(this, "remaining", void 0);
10
- _defineProperty(this, "timerId", null);
11
- _defineProperty(this, "start", 0);
12
- _defineProperty(this, "paused", void 0);
13
6
  this.callback = callback;
14
7
  this.delay = delay;
15
8
  this.remaining = delay;
16
9
  this.paused = false;
17
10
  this.resume();
18
11
  }
19
- return _createClass(Timer2, [{
12
+ _createClass(Timer2, [{
20
13
  key: "pause",
21
14
  value: function pause() {
22
- if (this.timerId) {
23
- clearTimeout(this.timerId);
24
- }
15
+ clearTimeout(this.timerId);
25
16
  this.remaining -= Date.now() - this.start;
26
17
  this.paused = true;
27
18
  }
@@ -30,10 +21,8 @@ var Timer = /* @__PURE__ */ (function() {
30
21
  value: function resume() {
31
22
  this.start = Date.now();
32
23
  this.paused = false;
33
- if (this.timerId) {
34
- clearTimeout(this.timerId);
35
- }
36
- this.timerId = window.setTimeout(this.callback, this.remaining);
24
+ clearTimeout(this.timerId);
25
+ this.timerId = setTimeout(this.callback, this.remaining);
37
26
  }
38
27
  }, {
39
28
  key: "reset",
@@ -44,12 +33,11 @@ var Timer = /* @__PURE__ */ (function() {
44
33
  }, {
45
34
  key: "clear",
46
35
  value: function clear() {
47
- if (this.timerId) {
48
- clearTimeout(this.timerId);
49
- }
36
+ clearTimeout(this.timerId);
50
37
  }
51
38
  }]);
52
- })();
39
+ return Timer2;
40
+ }();
53
41
  export {
54
42
  Timer
55
43
  };
@@ -1,7 +1,167 @@
1
- import { default as NoticeBubbleContainer } from './NoticeBubble';
2
- import type { NoticeBubbleContainerProps, NoticeBubbleInfoProps, NoticeBubbleWarningProps, AddedNoticeMeta } from './NoticeBubble.type';
3
- import { default as noticeBubbleDefaultManager } from './NoticeBubbleManager';
4
- export * from './NoticeBubble';
5
- export * from './NoticeBubbleManager';
6
- export { NoticeBubbleContainer, noticeBubbleDefaultManager };
7
- export type { NoticeBubbleContainerProps, NoticeBubbleInfoProps, NoticeBubbleWarningProps, AddedNoticeMeta, };
1
+ import { PortalProps } from '@semcore/portal';
2
+ import { UnknownProperties, Intergalactic } from '@semcore/core';
3
+ import { BoxProps } from '@semcore/flex-box';
4
+
5
+ /** @deprecated */
6
+ export interface INoticeBubbleContainerProps
7
+ extends NoticeBubbleContainerProps,
8
+ UnknownProperties {}
9
+ export type NoticeBubbleContainerProps = BoxProps &
10
+ PortalProps & {
11
+ /** Manager copy */
12
+ manager?: NoticeBubbleManagerClass;
13
+ locale?: string;
14
+ };
15
+
16
+ /** @deprecated */
17
+ export interface INoticeBubbleProps extends NoticeBubbleProps, UnknownProperties {}
18
+ export type NoticeBubbleProps = BoxProps & {
19
+ /**
20
+ * Notice visibility.
21
+ */
22
+ visible?: boolean;
23
+ /**
24
+ * Control under the notice children.
25
+ * */
26
+ action?: React.ReactNode;
27
+ /**
28
+ * Callback triggered by "Close" icon click.
29
+ * */
30
+ onClose?: (e?: React.SyntheticEvent) => void;
31
+ /**
32
+ * Notice content.
33
+ * */
34
+ children?: React.ReactNode;
35
+ manager?: NoticeBubbleManager;
36
+ icon?: React.ReactElement;
37
+ };
38
+ /** @deprecated */
39
+ export interface INoticeBubbleInfoProps extends NoticeBubbleInfoProps, UnknownProperties {}
40
+ export type NoticeBubbleInfoProps = NoticeBubbleProps & {
41
+ readonly type?: 'info';
42
+ /**
43
+ * Notice display duration. Set to 0 to disable auto-close.
44
+ */
45
+ duration?: number;
46
+ /**
47
+ * Enables animation on first rendering.
48
+ * @default false
49
+ */
50
+ initialAnimation?: boolean;
51
+ /**
52
+ * Use it for complex notices with important controls.
53
+ * If enabled, browser focus will be locked in the notice
54
+ * until it's closed. After close focus should return to the element
55
+ * where it was placed before notice appear.
56
+ */
57
+ focusLock?: boolean;
58
+ };
59
+
60
+ /** @deprecated */
61
+ export interface INoticeBubbleWarningProps extends NoticeBubbleWarningProps, UnknownProperties {}
62
+ export type NoticeBubbleWarningProps = NoticeBubbleProps & {
63
+ readonly type?: 'warning';
64
+ /**
65
+ * Notice display duration.
66
+ */
67
+ duration?: number;
68
+ /**
69
+ * Enables animation on first rendering.
70
+ * @default false
71
+ */
72
+ initialAnimation?: boolean;
73
+ /**
74
+ * Use it for complex notices with important controls.
75
+ * If enabled, browser focus will be locked in the notice
76
+ * until it's closed. After close focus should return to the element
77
+ * where it was placed before notice appear.
78
+ */
79
+ focusLock?: boolean;
80
+ };
81
+
82
+ /** @deprecated */
83
+ export interface INoticeBubbleManager extends NoticeBubbleManagerClass, UnknownProperties {}
84
+ export type NoticeBubbleManagerClass = {
85
+ /**
86
+ * Creates and shows a notice.
87
+ * */
88
+ add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => {
89
+ uid: string;
90
+ update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;
91
+ remove: () => boolean;
92
+ ref: React.RefObject<HTMLDivElement>;
93
+ focus: () => void;
94
+ };
95
+ /**
96
+ * Updates notice by uid.
97
+ * */
98
+ update: (
99
+ uid: string,
100
+ props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,
101
+ ) => boolean;
102
+ /**
103
+ * Removes notice by uid.
104
+ * */
105
+ remove: (uid: string) => boolean;
106
+ /**
107
+ * Replace last notice (if it is existing)
108
+ */
109
+ replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;
110
+ };
111
+
112
+ /**
113
+ * @deprecated use `NoticeBubbleManager` instead.
114
+ * */
115
+ export declare const NoticeBubble: Intergalactic.Component<'div', NoticeBubbleInfoProps>;
116
+ /**
117
+ * @deprecated use `NoticeBubbleManager` instead.
118
+ * */
119
+ export declare const NoticeBubbleWarning: Intergalactic.Component<'div', NoticeBubbleWarningProps>;
120
+ export declare const NoticeBubbleContainer: Intergalactic.Component<
121
+ 'div',
122
+ NoticeBubbleContainerProps
123
+ > & {
124
+ /**
125
+ * @deprecated use `NoticeBubbleManager` instead.
126
+ * */
127
+ Info: typeof NoticeBubble;
128
+
129
+ /**
130
+ * @deprecated use `NoticeBubbleManager` instead.
131
+ * */
132
+ Warning: typeof NoticeBubbleWarning;
133
+ };
134
+ export declare class NoticeBubbleManager implements NoticeBubbleManagerClass {
135
+ /**
136
+ * Creates and shows a notice.
137
+ * */
138
+ add(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): {
139
+ uid: string;
140
+ update: (props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>) => boolean;
141
+ remove: () => boolean;
142
+ ref: React.RefObject<HTMLDivElement>;
143
+ focus: () => void;
144
+ };
145
+ /**
146
+ * Updates notice by uid.
147
+ * */
148
+ update(
149
+ uid: string,
150
+ props: Partial<NoticeBubbleInfoProps> | Partial<NoticeBubbleWarningProps>,
151
+ ): boolean;
152
+ /**
153
+ * Removes notice by uid.
154
+ * */
155
+ remove(uid: string): boolean;
156
+ /**
157
+ * Replace last notice (if it is existing)
158
+ */
159
+ replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;
160
+ }
161
+
162
+ export declare const noticeBubbleDefaultManager: NoticeBubbleManager;
163
+
164
+ /**
165
+ * @deprecated Use `import { noticeBubbleDefaultManager } from ...` instead
166
+ */
167
+ export default noticeBubbleDefaultManager;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/notice-bubble",
3
3
  "description": "Semrush NoticeBubble Component",
4
- "version": "5.55.0-prerelease.5",
4
+ "version": "5.55.0-prerelease.7",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,16 +14,16 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/button": "5.44.0-prerelease.5",
18
- "@semcore/utils": "4.49.0-prerelease.5",
19
- "@semcore/icon": "4.63.0-prerelease.5",
20
- "@semcore/portal": "3.42.0-prerelease.5",
21
- "@semcore/flex-box": "5.42.0-prerelease.5",
22
- "@semcore/animation": "2.42.0-prerelease.5",
23
- "@semcore/tooltip": "6.50.0-prerelease.5"
17
+ "@semcore/button": "5.44.0-prerelease.7",
18
+ "@semcore/utils": "4.49.0-prerelease.7",
19
+ "@semcore/icon": "4.63.0-prerelease.7",
20
+ "@semcore/portal": "3.42.0-prerelease.7",
21
+ "@semcore/flex-box": "5.42.0-prerelease.7",
22
+ "@semcore/animation": "2.42.0-prerelease.7",
23
+ "@semcore/tooltip": "6.50.0-prerelease.7"
24
24
  },
25
25
  "peerDependencies": {
26
- "@semcore/core": "^2.40.0-prerelease.5",
26
+ "@semcore/core": "^2.40.0-prerelease.7",
27
27
  "react": "16.8 - 18",
28
28
  "react-dom": "16.8 - 18"
29
29
  },
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=NoticeBubble.type.js.map
@@ -1 +0,0 @@
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?: HTMLElement | 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?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=NoticeBubble.type.js.map
@@ -1 +0,0 @@
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?: HTMLElement | 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?: HTMLElement;\n animationDuration: number;\n getI18nText: ReturnType<typeof useI18n>;\n styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;\n};\n\nexport type NoticeBubbleProps = BoxProps & {\n /** Notice type */\n type?: 'info' | 'warning';\n /**\n * Notice display duration. Set to 0 to disable auto-close.\n */\n duration?: number;\n /**\n * Enables animation on first rendering.\n * @default false\n */\n initialAnimation?: boolean;\n /**\n * Use it for complex notices with important controls.\n * If enabled, browser focus will be locked in the notice\n * until it's closed. After close focus should return to the element\n * where it was placed before notice appear.\n */\n focusLock?: boolean;\n /**\n * Notice visibility.\n */\n visible?: boolean;\n /**\n * Control under the notice children.\n * */\n action?: React.ReactNode;\n /**\n * Callback triggered by \"Close\" icon click.\n * */\n onClose?: (e?: React.SyntheticEvent) => void;\n /**\n * Notice content.\n * */\n children?: React.ReactNode;\n manager?: NoticeBubbleManagerClass;\n icon?: React.ReactElement;\n};\n\nexport type NoticeBubbleInfoProps = NoticeBubbleProps & {\n readonly type?: 'info';\n};\n\nexport type NoticeBubbleWarningProps = NoticeBubbleProps & {\n readonly type?: 'warning';\n};\n\nexport type AddedNoticeMeta = {\n uid: number;\n update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;\n remove: () => boolean;\n ref: RefObject<HTMLElement>;\n};\n\nexport type NoticeBubbleManagerClass = {\n /**\n * Creates and shows a notice.\n * */\n add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;\n /**\n * Removes notice by uid.\n * */\n remove: (uid: number) => boolean;\n /**\n * Replace notice by uid.\n */\n replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n /**\n * Replace last notice (if it is existing)\n */\n replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;\n};\n\nexport declare const NoticeBubbleContainer: Intergalactic.Component<\n 'div',\n NoticeBubbleContainerProps\n>;\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import type { Intergalactic } from '@semcore/core';
2
- import type { NoticeBubbleContainerProps } from './NoticeBubble.type';
3
- declare const NoticeBubbleContainer: Intergalactic.Component<"div", NoticeBubbleContainerProps>;
4
- export default NoticeBubbleContainer;
@@ -1,91 +0,0 @@
1
- import type { PortalProps, BoxProps } from '@semcore/base-components';
2
- import type { Intergalactic } from '@semcore/core';
3
- import type { useI18n } from '@semcore/core/lib/utils/enhances/WithI18n';
4
- import type { RefObject } from 'react';
5
- /**
6
- * @deprecated. Pass noticeBubbleContainer property from window.sm2.getNoticeBubbleContainer()
7
- */
8
- export type NoticeBubbleContainerPortalProps = PortalProps;
9
- export type NoticeBubbleContainerProps = BoxProps & NoticeBubbleContainerPortalProps & {
10
- /** Ref to mount bubbles in. You should use element form window.sm2.getNoticeBubbleContainer() */
11
- containerNode?: HTMLElement | null;
12
- /** Manager copy */
13
- manager?: NoticeBubbleManagerClass;
14
- /** Specifies the locale for i18n support */
15
- locale?: string;
16
- };
17
- export type NoticeBubbleViewItemProps = NoticeBubbleProps & {
18
- containerNode?: HTMLElement;
19
- animationDuration: number;
20
- getI18nText: ReturnType<typeof useI18n>;
21
- styles: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement> | undefined;
22
- };
23
- export type NoticeBubbleProps = BoxProps & {
24
- /** Notice type */
25
- type?: 'info' | 'warning';
26
- /**
27
- * Notice display duration. Set to 0 to disable auto-close.
28
- */
29
- duration?: number;
30
- /**
31
- * Enables animation on first rendering.
32
- * @default false
33
- */
34
- initialAnimation?: boolean;
35
- /**
36
- * Use it for complex notices with important controls.
37
- * If enabled, browser focus will be locked in the notice
38
- * until it's closed. After close focus should return to the element
39
- * where it was placed before notice appear.
40
- */
41
- focusLock?: boolean;
42
- /**
43
- * Notice visibility.
44
- */
45
- visible?: boolean;
46
- /**
47
- * Control under the notice children.
48
- * */
49
- action?: React.ReactNode;
50
- /**
51
- * Callback triggered by "Close" icon click.
52
- * */
53
- onClose?: (e?: React.SyntheticEvent) => void;
54
- /**
55
- * Notice content.
56
- * */
57
- children?: React.ReactNode;
58
- manager?: NoticeBubbleManagerClass;
59
- icon?: React.ReactElement;
60
- };
61
- export type NoticeBubbleInfoProps = NoticeBubbleProps & {
62
- readonly type?: 'info';
63
- };
64
- export type NoticeBubbleWarningProps = NoticeBubbleProps & {
65
- readonly type?: 'warning';
66
- };
67
- export type AddedNoticeMeta = {
68
- uid: number;
69
- update: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => Promise<AddedNoticeMeta>;
70
- remove: () => boolean;
71
- ref: RefObject<HTMLElement>;
72
- };
73
- export type NoticeBubbleManagerClass = {
74
- /**
75
- * Creates and shows a notice.
76
- * */
77
- add: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => AddedNoticeMeta;
78
- /**
79
- * Removes notice by uid.
80
- * */
81
- remove: (uid: number) => boolean;
82
- /**
83
- * Replace notice by uid.
84
- */
85
- replace: (uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;
86
- /**
87
- * Replace last notice (if it is existing)
88
- */
89
- replaceLast: (props: NoticeBubbleInfoProps | NoticeBubbleWarningProps) => void;
90
- };
91
- export declare const NoticeBubbleContainer: Intergalactic.Component<'div', NoticeBubbleContainerProps>;
@@ -1,22 +0,0 @@
1
- import type { RefObject } from 'react';
2
- import type { NoticeBubbleManagerClass, NoticeBubbleInfoProps, NoticeBubbleWarningProps, AddedNoticeMeta } from './NoticeBubble.type';
3
- export type NoticeItem = (NoticeBubbleInfoProps | NoticeBubbleWarningProps) & {
4
- uid: number;
5
- visible?: boolean;
6
- forwardRef: RefObject<HTMLElement>;
7
- onClose: () => void;
8
- };
9
- declare class NoticeBubbleManager implements NoticeBubbleManagerClass {
10
- private items;
11
- private emitter;
12
- private counter;
13
- addListener(fn: (items: NoticeItem[]) => void): () => void;
14
- private emit;
15
- add(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): AddedNoticeMeta;
16
- replace(uid: number, props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): Promise<AddedNoticeMeta>;
17
- replaceLast(props: NoticeBubbleInfoProps | NoticeBubbleWarningProps): Promise<AddedNoticeMeta>;
18
- remove(uid: number): boolean;
19
- }
20
- declare const noticeBubbleDefaultManager: NoticeBubbleManager;
21
- export { NoticeBubbleManager };
22
- export default noticeBubbleDefaultManager;
@@ -1,58 +0,0 @@
1
- export declare const localizedMessages: {
2
- de: {
3
- close: string;
4
- notification: string;
5
- };
6
- en: {
7
- close: string;
8
- notification: string;
9
- };
10
- es: {
11
- close: string;
12
- notification: string;
13
- };
14
- fr: {
15
- close: string;
16
- notification: string;
17
- };
18
- it: {
19
- close: string;
20
- notification: string;
21
- };
22
- ja: {
23
- close: string;
24
- notification: string;
25
- };
26
- ko: {
27
- close: string;
28
- notification: string;
29
- };
30
- nl: {
31
- close: string;
32
- notification: string;
33
- };
34
- pt: {
35
- close: string;
36
- notification: string;
37
- };
38
- tr: {
39
- close: string;
40
- notification: string;
41
- };
42
- vi: {
43
- close: string;
44
- notification: string;
45
- };
46
- zh: {
47
- close: string;
48
- notification: string;
49
- };
50
- pl: {
51
- close: string;
52
- notification: string;
53
- };
54
- sv: {
55
- close: string;
56
- notification: string;
57
- };
58
- };
@@ -1,14 +0,0 @@
1
- declare class Timer {
2
- private readonly delay;
3
- private readonly callback;
4
- private remaining;
5
- private timerId;
6
- private start;
7
- paused: boolean;
8
- constructor(callback: Function, delay: number);
9
- pause(): void;
10
- resume(): void;
11
- reset(): void;
12
- clear(): void;
13
- }
14
- export { Timer };