@astral/features 3.192.0 → 3.194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/AutoSaveIndicatorService/constants.d.ts +2 -0
  2. package/AutoSaveIndicatorService/constants.js +4 -0
  3. package/AutoSaveIndicatorService/hooks/index.d.ts +1 -0
  4. package/AutoSaveIndicatorService/hooks/index.js +1 -0
  5. package/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/index.d.ts +1 -0
  6. package/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/index.js +1 -0
  7. package/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/useInitAutoSaveIndicatorStore.d.ts +4 -0
  8. package/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/useInitAutoSaveIndicatorStore.js +10 -0
  9. package/AutoSaveIndicatorService/index.d.ts +2 -0
  10. package/AutoSaveIndicatorService/index.js +2 -0
  11. package/AutoSaveIndicatorService/services/AutoSaveIndicatorService.d.ts +60 -0
  12. package/AutoSaveIndicatorService/services/AutoSaveIndicatorService.js +85 -0
  13. package/AutoSaveIndicatorService/services/enums.d.ts +6 -0
  14. package/AutoSaveIndicatorService/services/enums.js +7 -0
  15. package/AutoSaveIndicatorService/services/index.d.ts +1 -0
  16. package/AutoSaveIndicatorService/services/index.js +1 -0
  17. package/AutoSaveIndicatorService/services/types.d.ts +20 -0
  18. package/AutoSaveIndicatorService/services/types.js +1 -0
  19. package/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/AutoSaveIndicatorStore.d.ts +45 -0
  20. package/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/AutoSaveIndicatorStore.js +60 -0
  21. package/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/index.d.ts +1 -0
  22. package/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/index.js +1 -0
  23. package/AutoSaveIndicatorService/stores/index.d.ts +1 -0
  24. package/AutoSaveIndicatorService/stores/index.js +1 -0
  25. package/README.md +142 -0
  26. package/index.d.ts +1 -0
  27. package/index.js +1 -0
  28. package/node/AutoSaveIndicatorService/constants.d.ts +2 -0
  29. package/node/AutoSaveIndicatorService/constants.js +7 -0
  30. package/node/AutoSaveIndicatorService/hooks/index.d.ts +1 -0
  31. package/node/AutoSaveIndicatorService/hooks/index.js +17 -0
  32. package/node/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/index.d.ts +1 -0
  33. package/node/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/index.js +17 -0
  34. package/node/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/useInitAutoSaveIndicatorStore.d.ts +4 -0
  35. package/node/AutoSaveIndicatorService/hooks/useInitAutoSaveIndicatorStore/useInitAutoSaveIndicatorStore.js +14 -0
  36. package/node/AutoSaveIndicatorService/index.d.ts +2 -0
  37. package/node/AutoSaveIndicatorService/index.js +18 -0
  38. package/node/AutoSaveIndicatorService/services/AutoSaveIndicatorService.d.ts +60 -0
  39. package/node/AutoSaveIndicatorService/services/AutoSaveIndicatorService.js +89 -0
  40. package/node/AutoSaveIndicatorService/services/enums.d.ts +6 -0
  41. package/node/AutoSaveIndicatorService/services/enums.js +10 -0
  42. package/node/AutoSaveIndicatorService/services/index.d.ts +1 -0
  43. package/node/AutoSaveIndicatorService/services/index.js +5 -0
  44. package/node/AutoSaveIndicatorService/services/types.d.ts +20 -0
  45. package/node/AutoSaveIndicatorService/services/types.js +2 -0
  46. package/node/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/AutoSaveIndicatorStore.d.ts +45 -0
  47. package/node/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/AutoSaveIndicatorStore.js +64 -0
  48. package/node/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/index.d.ts +1 -0
  49. package/node/AutoSaveIndicatorService/stores/AutoSaveIndicatorStore/index.js +17 -0
  50. package/node/AutoSaveIndicatorService/stores/index.d.ts +1 -0
  51. package/node/AutoSaveIndicatorService/stores/index.js +17 -0
  52. package/node/index.d.ts +1 -0
  53. package/node/index.js +4 -1
  54. package/package.json +2 -2
@@ -0,0 +1,2 @@
1
+ import { type AutoSaveIndicatorErrorState } from './services/types';
2
+ export declare const AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE: AutoSaveIndicatorErrorState;
@@ -0,0 +1,4 @@
1
+ export const AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE = {
2
+ message: '',
3
+ onRetry: () => { },
4
+ };
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1,4 @@
1
+ import { type AutoSaveIndicatorStore } from '../../stores/AutoSaveIndicatorStore';
2
+ type UseInitAutoSaveIndicatorStoreParams = AutoSaveIndicatorStore;
3
+ export declare const useInitAutoSaveIndicatorStore: (store: UseInitAutoSaveIndicatorStoreParams) => void;
4
+ export {};
@@ -0,0 +1,10 @@
1
+ import { useEffect } from 'react';
2
+ export const useInitAutoSaveIndicatorStore = (store) => {
3
+ useEffect(() => {
4
+ store.show();
5
+ return () => {
6
+ store.hide();
7
+ store.reset();
8
+ };
9
+ }, []);
10
+ };
@@ -0,0 +1,2 @@
1
+ export * from './stores/AutoSaveIndicatorStore';
2
+ export * from './hooks/useInitAutoSaveIndicatorStore';
@@ -0,0 +1,2 @@
1
+ export * from './stores/AutoSaveIndicatorStore';
2
+ export * from './hooks/useInitAutoSaveIndicatorStore';
@@ -0,0 +1,60 @@
1
+ import { type AutoSaveIndicatorErrorState, type IAutoSaveIndicatorService } from './types';
2
+ /**
3
+ * Сервис, предоставляющий API для более декларативной и централизованной работы с компонентом AutoSaveIndicator
4
+ */
5
+ export declare class AutoSaveIndicatorService implements IAutoSaveIndicatorService {
6
+ /**
7
+ * Текущий статус.
8
+ */
9
+ private status;
10
+ /**
11
+ * Состояние видимости
12
+ */
13
+ private isShouldBeVisible;
14
+ /**
15
+ * Объект с сообщением об ошибке и функцией обратного вызова
16
+ */
17
+ private error;
18
+ /**
19
+ * Отображает компонента
20
+ */
21
+ show: () => void;
22
+ /**
23
+ * Сбрасывает состояние до изначального
24
+ */
25
+ reset: () => void;
26
+ /**
27
+ * Скрывает компонент
28
+ */
29
+ hide: () => void;
30
+ /**
31
+ * Отображает состояния загрузки во время сохранения
32
+ */
33
+ progress: () => void;
34
+ /**
35
+ * Отображает состояния успеха
36
+ */
37
+ success: () => void;
38
+ /**
39
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
40
+ */
41
+ setError: (error: AutoSaveIndicatorErrorState) => void;
42
+ /**
43
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
44
+ */
45
+ get isVisible(): boolean;
46
+ /**
47
+ * Вспомогательный метод для проверки текущего статуса
48
+ */
49
+ private checkStatus;
50
+ /**
51
+ * Пропсы для компонента AutoSaveIndicator
52
+ */
53
+ get values(): {
54
+ isLoading: boolean;
55
+ errorMsg: string;
56
+ isError: boolean;
57
+ onRetry: () => void;
58
+ isSuccess: boolean;
59
+ };
60
+ }
@@ -0,0 +1,85 @@
1
+ import { AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE } from '../constants';
2
+ import { AutoSaveIndicatorStatus } from './enums';
3
+ /**
4
+ * Сервис, предоставляющий API для более декларативной и централизованной работы с компонентом AutoSaveIndicator
5
+ */
6
+ export class AutoSaveIndicatorService {
7
+ constructor() {
8
+ /**
9
+ * Текущий статус.
10
+ */
11
+ this.status = AutoSaveIndicatorStatus.Idle;
12
+ /**
13
+ * Состояние видимости
14
+ */
15
+ this.isShouldBeVisible = false;
16
+ /**
17
+ * Объект с сообщением об ошибке и функцией обратного вызова
18
+ */
19
+ this.error = AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
20
+ /**
21
+ * Отображает компонента
22
+ */
23
+ this.show = () => {
24
+ this.isShouldBeVisible = true;
25
+ };
26
+ /**
27
+ * Сбрасывает состояние до изначального
28
+ */
29
+ this.reset = () => {
30
+ this.status = AutoSaveIndicatorStatus.Idle;
31
+ this.error = AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
32
+ };
33
+ /**
34
+ * Скрывает компонент
35
+ */
36
+ this.hide = () => {
37
+ this.isShouldBeVisible = false;
38
+ this.reset();
39
+ };
40
+ /**
41
+ * Отображает состояния загрузки во время сохранения
42
+ */
43
+ this.progress = () => {
44
+ this.status = AutoSaveIndicatorStatus.Progress;
45
+ };
46
+ /**
47
+ * Отображает состояния успеха
48
+ */
49
+ this.success = () => {
50
+ this.status = AutoSaveIndicatorStatus.Success;
51
+ this.error = AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
52
+ };
53
+ /**
54
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
55
+ */
56
+ this.setError = (error) => {
57
+ this.status = AutoSaveIndicatorStatus.Error;
58
+ this.error = error;
59
+ };
60
+ /**
61
+ * Вспомогательный метод для проверки текущего статуса
62
+ */
63
+ this.checkStatus = (status) => {
64
+ return this.status === status;
65
+ };
66
+ }
67
+ /**
68
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
69
+ */
70
+ get isVisible() {
71
+ return this.isShouldBeVisible;
72
+ }
73
+ /**
74
+ * Пропсы для компонента AutoSaveIndicator
75
+ */
76
+ get values() {
77
+ return {
78
+ isLoading: this.checkStatus(AutoSaveIndicatorStatus.Progress),
79
+ errorMsg: this.error.message,
80
+ isError: this.checkStatus(AutoSaveIndicatorStatus.Error),
81
+ onRetry: this.error.onRetry,
82
+ isSuccess: this.checkStatus(AutoSaveIndicatorStatus.Success),
83
+ };
84
+ }
85
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum AutoSaveIndicatorStatus {
2
+ Idle = "idle",
3
+ Progress = "progress",
4
+ Success = "success",
5
+ Error = "error"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var AutoSaveIndicatorStatus;
2
+ (function (AutoSaveIndicatorStatus) {
3
+ AutoSaveIndicatorStatus["Idle"] = "idle";
4
+ AutoSaveIndicatorStatus["Progress"] = "progress";
5
+ AutoSaveIndicatorStatus["Success"] = "success";
6
+ AutoSaveIndicatorStatus["Error"] = "error";
7
+ })(AutoSaveIndicatorStatus || (AutoSaveIndicatorStatus = {}));
@@ -0,0 +1 @@
1
+ export { AutoSaveIndicatorService } from './AutoSaveIndicatorService';
@@ -0,0 +1 @@
1
+ export { AutoSaveIndicatorService } from './AutoSaveIndicatorService';
@@ -0,0 +1,20 @@
1
+ export type AutoSaveIndicatorErrorState = {
2
+ onRetry: () => void;
3
+ message: string;
4
+ };
5
+ export interface IAutoSaveIndicatorService {
6
+ show: () => void;
7
+ reset: () => void;
8
+ hide: () => void;
9
+ progress: () => void;
10
+ success: () => void;
11
+ setError: (error: AutoSaveIndicatorErrorState) => void;
12
+ readonly isVisible: boolean;
13
+ readonly values: {
14
+ isLoading: boolean;
15
+ errorMsg: string;
16
+ isError: boolean;
17
+ onRetry: () => void;
18
+ isSuccess: boolean;
19
+ };
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Mobx-Store для декларативной работы с компонентом AutoSaveIndicator
3
+ */
4
+ export declare class AutoSaveIndicatorStore {
5
+ private readonly autoSaveIndicatorService;
6
+ constructor();
7
+ /**
8
+ * Скрывает компонент
9
+ */
10
+ get hide(): () => void;
11
+ /**
12
+ * Отображает компонента
13
+ */
14
+ get show(): () => void;
15
+ /**
16
+ * Отображает состояния загрузки во время сохранения
17
+ */
18
+ get progress(): () => void;
19
+ /**
20
+ * Отображает состояния успеха
21
+ */
22
+ get success(): () => void;
23
+ /**
24
+ * Сбрасывает состояние всех значений до изначального
25
+ */
26
+ get reset(): () => void;
27
+ /**
28
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
29
+ */
30
+ get setError(): (error: import("../../services/types").AutoSaveIndicatorErrorState) => void;
31
+ /**
32
+ * Пропсы для компонента AutoSaveIndicator
33
+ */
34
+ get values(): {
35
+ isLoading: boolean;
36
+ errorMsg: string;
37
+ isError: boolean;
38
+ onRetry: () => void;
39
+ isSuccess: boolean;
40
+ };
41
+ /**
42
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
43
+ */
44
+ get isVisible(): boolean;
45
+ }
@@ -0,0 +1,60 @@
1
+ import { makeAutoObservable } from 'mobx';
2
+ import { AutoSaveIndicatorService } from '../../services';
3
+ /**
4
+ * Mobx-Store для декларативной работы с компонентом AutoSaveIndicator
5
+ */
6
+ export class AutoSaveIndicatorStore {
7
+ constructor() {
8
+ this.autoSaveIndicatorService = new AutoSaveIndicatorService();
9
+ makeAutoObservable(this, {}, { autoBind: true });
10
+ makeAutoObservable(this.autoSaveIndicatorService, {}, { autoBind: true });
11
+ }
12
+ /**
13
+ * Скрывает компонент
14
+ */
15
+ get hide() {
16
+ return this.autoSaveIndicatorService.hide;
17
+ }
18
+ /**
19
+ * Отображает компонента
20
+ */
21
+ get show() {
22
+ return this.autoSaveIndicatorService.show;
23
+ }
24
+ /**
25
+ * Отображает состояния загрузки во время сохранения
26
+ */
27
+ get progress() {
28
+ return this.autoSaveIndicatorService.progress;
29
+ }
30
+ /**
31
+ * Отображает состояния успеха
32
+ */
33
+ get success() {
34
+ return this.autoSaveIndicatorService.success;
35
+ }
36
+ /**
37
+ * Сбрасывает состояние всех значений до изначального
38
+ */
39
+ get reset() {
40
+ return this.autoSaveIndicatorService.reset;
41
+ }
42
+ /**
43
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
44
+ */
45
+ get setError() {
46
+ return this.autoSaveIndicatorService.setError;
47
+ }
48
+ /**
49
+ * Пропсы для компонента AutoSaveIndicator
50
+ */
51
+ get values() {
52
+ return this.autoSaveIndicatorService.values;
53
+ }
54
+ /**
55
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
56
+ */
57
+ get isVisible() {
58
+ return this.autoSaveIndicatorService.isVisible;
59
+ }
60
+ }
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
package/README.md CHANGED
@@ -1,3 +1,145 @@
1
1
  # @astral/features
2
2
 
3
3
  Сущности общей предметной области Астрал.Софт.
4
+
5
+ ## Сервисы
6
+
7
+ ### AutoSaveIndicator
8
+ **Цель сервиса**: предоставить централизованное и декларативное управление компонентом [AutoSaveIndicator](https://main--61baeff6f06230003a88ef8a.chromatic.com/?path=/docs/components-autosaveindicator--docs)
9
+
10
+ **Область применения**: screens с автоматическим сохранением изменений на ней
11
+ (пример: форма с сохранением при вводе)
12
+
13
+ #### Составные части
14
+ **AutoSaveIndicatorStore** - mobx-стор, использующий внутри **AutoSaveIndicatorService** и дающий публичное API
15
+ для использования.
16
+
17
+ **useInitAutoSaveIndicatorStore** - хук для инициализации стора.
18
+
19
+ #### API AutoSaveIndicatorStore
20
+ Свойства:
21
+
22
+ - ``values`` - пропсы, необходимые для работы компонента
23
+ - ``isVisible`` - флаг, определяющий видимость индикатора на странице
24
+
25
+ Методы:
26
+
27
+ ``show`` - Установка значения ``isVisible`` в true
28
+
29
+ ``hide`` - Установка значения ``isVisible`` в false
30
+
31
+ ``progress`` - Установка индикации автосохранения (аналог ``setIsLoading``)
32
+
33
+ ``success`` - Установка успешного состояния автосохранения
34
+
35
+ ``setError`` - Установка состояния ошибки.
36
+
37
+ Параметры метода:
38
+ - ``message`` - сообщение об ошибке, которое будет отображаться над кнопкой повторения запроса
39
+ - ``onRetry`` - коллбэк, который будет выполнен при нажатии на кнопку повторения запроса.
40
+
41
+ ``reset`` - Сброс состояния стора до изначального.
42
+
43
+ #### Инициализация
44
+
45
+ 1. Необходимо создать инстанс AutoSaveIndicatorStore,
46
+
47
+ ```
48
+ shared/stores
49
+
50
+ import { AutoSaveIndicatorStore } from "@astral/features"
51
+
52
+ export const autoSaveIndicatorInstance = new AutoSaveIndicatorStore();
53
+ ```
54
+
55
+ 2. Вызвать хук на скрине, где предполагается использование индикатора автосохранения и передать в него созданный инстанс
56
+
57
+ Внутри данного хука содержится следующая логика:
58
+ - При монтировании вызывается метод ``show``.
59
+ - При размонтировании вызывается метод ``hide`` и ``reset``. Вызов последнего необходим, так как предполагается использование
60
+ данного стора в качестве синглтона
61
+
62
+ ``` ts
63
+ screen
64
+
65
+ import { autoSaveIndicatorInstance } from "@example/shared"
66
+
67
+ export const ExampleScreen = observer(() => {
68
+ const [autoSaveIndicatorStore] = useState(autoSaveIndicatorStoreInstance);
69
+
70
+ useInitAutoSaveIndicatorStore(autoSaveIndicatorStore);
71
+
72
+ return (
73
+ <PageLayout
74
+ header={{ title: 'Example Screen' }}
75
+ content={{ children: null, isPaddingDisabled: false }}
76
+ />
77
+ );
78
+ });
79
+ ```
80
+
81
+ Пример использования AutoSaveIndicator на лэйауте будет выглядеть следующим образом:
82
+
83
+ ``` tsx
84
+ modules/layout/features/MainLayout/Header
85
+
86
+ import { autoSaveIndicatorStoreInstance } from "@example/shared"
87
+
88
+ export const Header = observer(() => {
89
+ const [autoSaveIndicatorStore] = useState(autoSaveIndicatorStoreInstance);
90
+
91
+ return (
92
+ autoSaveIndicatorStore.isVisible && (
93
+ <AutoSaveIndicator {...autoSaveIndicatorStore.values} />
94
+ )
95
+ );
96
+ });
97
+ ```
98
+
99
+ #### Использование
100
+
101
+ ``` ts
102
+ import {
103
+ type AutoSaveIndicatorStore,
104
+ autoSaveIndicatorStoreInstance,
105
+ } from '@example/shared';
106
+
107
+ class UIStore {
108
+ constructor(
109
+ private readonly repository: Repository,
110
+ private readonly autosaveIndicatorStore: AutoSaveIndicatorStore,
111
+ ) {
112
+ makeAutoObservable(
113
+ this,
114
+ {},
115
+ {
116
+ autoBind: true,
117
+ },
118
+ );
119
+ }
120
+
121
+ public makeMutation = (requestParam: string) => {
122
+ this.autosaveIndicatorStore.progress();
123
+
124
+ this.repository.makeMutation
125
+ .async({
126
+ requestParam,
127
+ })
128
+ .then(() => {
129
+ this.autosaveIndicatorStore.success()
130
+ })
131
+ .catch((e) => {
132
+ this.autosaveIndicatorStore.setError({
133
+ message: 'Что-то пошло не так',
134
+ onRetry: () => {
135
+ this.makeMutation(requestParam);
136
+ },
137
+ });
138
+ });
139
+ };
140
+ }
141
+
142
+ export const createUIStore = (repository: Repository) =>
143
+ new UIStore(repository, autoSaveIndicatorStoreInstance);
144
+
145
+ ```
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './cryproPro';
2
2
  export { IdentityProductSwitcher, AstralProductSwitcher, } from './productSwitcher';
3
+ export { AutoSaveIndicatorStore, useInitAutoSaveIndicatorStore, } from './AutoSaveIndicatorService';
package/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './cryproPro';
2
2
  export { IdentityProductSwitcher, AstralProductSwitcher, } from './productSwitcher';
3
+ export { AutoSaveIndicatorStore, useInitAutoSaveIndicatorStore, } from './AutoSaveIndicatorService';
@@ -0,0 +1,2 @@
1
+ import { type AutoSaveIndicatorErrorState } from './services/types';
2
+ export declare const AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE: AutoSaveIndicatorErrorState;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE = void 0;
4
+ exports.AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE = {
5
+ message: '',
6
+ onRetry: () => { },
7
+ };
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useInitAutoSaveIndicatorStore"), exports);
@@ -0,0 +1 @@
1
+ export * from './useInitAutoSaveIndicatorStore';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useInitAutoSaveIndicatorStore"), exports);
@@ -0,0 +1,4 @@
1
+ import { type AutoSaveIndicatorStore } from '../../stores/AutoSaveIndicatorStore';
2
+ type UseInitAutoSaveIndicatorStoreParams = AutoSaveIndicatorStore;
3
+ export declare const useInitAutoSaveIndicatorStore: (store: UseInitAutoSaveIndicatorStoreParams) => void;
4
+ export {};
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useInitAutoSaveIndicatorStore = void 0;
4
+ const react_1 = require("react");
5
+ const useInitAutoSaveIndicatorStore = (store) => {
6
+ (0, react_1.useEffect)(() => {
7
+ store.show();
8
+ return () => {
9
+ store.hide();
10
+ store.reset();
11
+ };
12
+ }, []);
13
+ };
14
+ exports.useInitAutoSaveIndicatorStore = useInitAutoSaveIndicatorStore;
@@ -0,0 +1,2 @@
1
+ export * from './stores/AutoSaveIndicatorStore';
2
+ export * from './hooks/useInitAutoSaveIndicatorStore';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./stores/AutoSaveIndicatorStore"), exports);
18
+ __exportStar(require("./hooks/useInitAutoSaveIndicatorStore"), exports);
@@ -0,0 +1,60 @@
1
+ import { type AutoSaveIndicatorErrorState, type IAutoSaveIndicatorService } from './types';
2
+ /**
3
+ * Сервис, предоставляющий API для более декларативной и централизованной работы с компонентом AutoSaveIndicator
4
+ */
5
+ export declare class AutoSaveIndicatorService implements IAutoSaveIndicatorService {
6
+ /**
7
+ * Текущий статус.
8
+ */
9
+ private status;
10
+ /**
11
+ * Состояние видимости
12
+ */
13
+ private isShouldBeVisible;
14
+ /**
15
+ * Объект с сообщением об ошибке и функцией обратного вызова
16
+ */
17
+ private error;
18
+ /**
19
+ * Отображает компонента
20
+ */
21
+ show: () => void;
22
+ /**
23
+ * Сбрасывает состояние до изначального
24
+ */
25
+ reset: () => void;
26
+ /**
27
+ * Скрывает компонент
28
+ */
29
+ hide: () => void;
30
+ /**
31
+ * Отображает состояния загрузки во время сохранения
32
+ */
33
+ progress: () => void;
34
+ /**
35
+ * Отображает состояния успеха
36
+ */
37
+ success: () => void;
38
+ /**
39
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
40
+ */
41
+ setError: (error: AutoSaveIndicatorErrorState) => void;
42
+ /**
43
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
44
+ */
45
+ get isVisible(): boolean;
46
+ /**
47
+ * Вспомогательный метод для проверки текущего статуса
48
+ */
49
+ private checkStatus;
50
+ /**
51
+ * Пропсы для компонента AutoSaveIndicator
52
+ */
53
+ get values(): {
54
+ isLoading: boolean;
55
+ errorMsg: string;
56
+ isError: boolean;
57
+ onRetry: () => void;
58
+ isSuccess: boolean;
59
+ };
60
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoSaveIndicatorService = void 0;
4
+ const constants_1 = require("../constants");
5
+ const enums_1 = require("./enums");
6
+ /**
7
+ * Сервис, предоставляющий API для более декларативной и централизованной работы с компонентом AutoSaveIndicator
8
+ */
9
+ class AutoSaveIndicatorService {
10
+ constructor() {
11
+ /**
12
+ * Текущий статус.
13
+ */
14
+ this.status = enums_1.AutoSaveIndicatorStatus.Idle;
15
+ /**
16
+ * Состояние видимости
17
+ */
18
+ this.isShouldBeVisible = false;
19
+ /**
20
+ * Объект с сообщением об ошибке и функцией обратного вызова
21
+ */
22
+ this.error = constants_1.AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
23
+ /**
24
+ * Отображает компонента
25
+ */
26
+ this.show = () => {
27
+ this.isShouldBeVisible = true;
28
+ };
29
+ /**
30
+ * Сбрасывает состояние до изначального
31
+ */
32
+ this.reset = () => {
33
+ this.status = enums_1.AutoSaveIndicatorStatus.Idle;
34
+ this.error = constants_1.AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
35
+ };
36
+ /**
37
+ * Скрывает компонент
38
+ */
39
+ this.hide = () => {
40
+ this.isShouldBeVisible = false;
41
+ this.reset();
42
+ };
43
+ /**
44
+ * Отображает состояния загрузки во время сохранения
45
+ */
46
+ this.progress = () => {
47
+ this.status = enums_1.AutoSaveIndicatorStatus.Progress;
48
+ };
49
+ /**
50
+ * Отображает состояния успеха
51
+ */
52
+ this.success = () => {
53
+ this.status = enums_1.AutoSaveIndicatorStatus.Success;
54
+ this.error = constants_1.AUTO_SAVE_INDICATOR_DEFAULT_ERROR_STATE;
55
+ };
56
+ /**
57
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
58
+ */
59
+ this.setError = (error) => {
60
+ this.status = enums_1.AutoSaveIndicatorStatus.Error;
61
+ this.error = error;
62
+ };
63
+ /**
64
+ * Вспомогательный метод для проверки текущего статуса
65
+ */
66
+ this.checkStatus = (status) => {
67
+ return this.status === status;
68
+ };
69
+ }
70
+ /**
71
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
72
+ */
73
+ get isVisible() {
74
+ return this.isShouldBeVisible;
75
+ }
76
+ /**
77
+ * Пропсы для компонента AutoSaveIndicator
78
+ */
79
+ get values() {
80
+ return {
81
+ isLoading: this.checkStatus(enums_1.AutoSaveIndicatorStatus.Progress),
82
+ errorMsg: this.error.message,
83
+ isError: this.checkStatus(enums_1.AutoSaveIndicatorStatus.Error),
84
+ onRetry: this.error.onRetry,
85
+ isSuccess: this.checkStatus(enums_1.AutoSaveIndicatorStatus.Success),
86
+ };
87
+ }
88
+ }
89
+ exports.AutoSaveIndicatorService = AutoSaveIndicatorService;
@@ -0,0 +1,6 @@
1
+ export declare enum AutoSaveIndicatorStatus {
2
+ Idle = "idle",
3
+ Progress = "progress",
4
+ Success = "success",
5
+ Error = "error"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoSaveIndicatorStatus = void 0;
4
+ var AutoSaveIndicatorStatus;
5
+ (function (AutoSaveIndicatorStatus) {
6
+ AutoSaveIndicatorStatus["Idle"] = "idle";
7
+ AutoSaveIndicatorStatus["Progress"] = "progress";
8
+ AutoSaveIndicatorStatus["Success"] = "success";
9
+ AutoSaveIndicatorStatus["Error"] = "error";
10
+ })(AutoSaveIndicatorStatus || (exports.AutoSaveIndicatorStatus = AutoSaveIndicatorStatus = {}));
@@ -0,0 +1 @@
1
+ export { AutoSaveIndicatorService } from './AutoSaveIndicatorService';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoSaveIndicatorService = void 0;
4
+ var AutoSaveIndicatorService_1 = require("./AutoSaveIndicatorService");
5
+ Object.defineProperty(exports, "AutoSaveIndicatorService", { enumerable: true, get: function () { return AutoSaveIndicatorService_1.AutoSaveIndicatorService; } });
@@ -0,0 +1,20 @@
1
+ export type AutoSaveIndicatorErrorState = {
2
+ onRetry: () => void;
3
+ message: string;
4
+ };
5
+ export interface IAutoSaveIndicatorService {
6
+ show: () => void;
7
+ reset: () => void;
8
+ hide: () => void;
9
+ progress: () => void;
10
+ success: () => void;
11
+ setError: (error: AutoSaveIndicatorErrorState) => void;
12
+ readonly isVisible: boolean;
13
+ readonly values: {
14
+ isLoading: boolean;
15
+ errorMsg: string;
16
+ isError: boolean;
17
+ onRetry: () => void;
18
+ isSuccess: boolean;
19
+ };
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Mobx-Store для декларативной работы с компонентом AutoSaveIndicator
3
+ */
4
+ export declare class AutoSaveIndicatorStore {
5
+ private readonly autoSaveIndicatorService;
6
+ constructor();
7
+ /**
8
+ * Скрывает компонент
9
+ */
10
+ get hide(): () => void;
11
+ /**
12
+ * Отображает компонента
13
+ */
14
+ get show(): () => void;
15
+ /**
16
+ * Отображает состояния загрузки во время сохранения
17
+ */
18
+ get progress(): () => void;
19
+ /**
20
+ * Отображает состояния успеха
21
+ */
22
+ get success(): () => void;
23
+ /**
24
+ * Сбрасывает состояние всех значений до изначального
25
+ */
26
+ get reset(): () => void;
27
+ /**
28
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
29
+ */
30
+ get setError(): (error: import("../../services/types").AutoSaveIndicatorErrorState) => void;
31
+ /**
32
+ * Пропсы для компонента AutoSaveIndicator
33
+ */
34
+ get values(): {
35
+ isLoading: boolean;
36
+ errorMsg: string;
37
+ isError: boolean;
38
+ onRetry: () => void;
39
+ isSuccess: boolean;
40
+ };
41
+ /**
42
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
43
+ */
44
+ get isVisible(): boolean;
45
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AutoSaveIndicatorStore = void 0;
4
+ const mobx_1 = require("mobx");
5
+ const services_1 = require("../../services");
6
+ /**
7
+ * Mobx-Store для декларативной работы с компонентом AutoSaveIndicator
8
+ */
9
+ class AutoSaveIndicatorStore {
10
+ constructor() {
11
+ this.autoSaveIndicatorService = new services_1.AutoSaveIndicatorService();
12
+ (0, mobx_1.makeAutoObservable)(this, {}, { autoBind: true });
13
+ (0, mobx_1.makeAutoObservable)(this.autoSaveIndicatorService, {}, { autoBind: true });
14
+ }
15
+ /**
16
+ * Скрывает компонент
17
+ */
18
+ get hide() {
19
+ return this.autoSaveIndicatorService.hide;
20
+ }
21
+ /**
22
+ * Отображает компонента
23
+ */
24
+ get show() {
25
+ return this.autoSaveIndicatorService.show;
26
+ }
27
+ /**
28
+ * Отображает состояния загрузки во время сохранения
29
+ */
30
+ get progress() {
31
+ return this.autoSaveIndicatorService.progress;
32
+ }
33
+ /**
34
+ * Отображает состояния успеха
35
+ */
36
+ get success() {
37
+ return this.autoSaveIndicatorService.success;
38
+ }
39
+ /**
40
+ * Сбрасывает состояние всех значений до изначального
41
+ */
42
+ get reset() {
43
+ return this.autoSaveIndicatorService.reset;
44
+ }
45
+ /**
46
+ * Устанавливает текст ошибки и callback, который должен сработать при клике на кнопку
47
+ */
48
+ get setError() {
49
+ return this.autoSaveIndicatorService.setError;
50
+ }
51
+ /**
52
+ * Пропсы для компонента AutoSaveIndicator
53
+ */
54
+ get values() {
55
+ return this.autoSaveIndicatorService.values;
56
+ }
57
+ /**
58
+ * Флаг, отражающий состояние видимости AutoSaveIndicator
59
+ */
60
+ get isVisible() {
61
+ return this.autoSaveIndicatorService.isVisible;
62
+ }
63
+ }
64
+ exports.AutoSaveIndicatorStore = AutoSaveIndicatorStore;
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AutoSaveIndicatorStore"), exports);
@@ -0,0 +1 @@
1
+ export * from './AutoSaveIndicatorStore';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AutoSaveIndicatorStore"), exports);
package/node/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './cryproPro';
2
2
  export { IdentityProductSwitcher, AstralProductSwitcher, } from './productSwitcher';
3
+ export { AutoSaveIndicatorStore, useInitAutoSaveIndicatorStore, } from './AutoSaveIndicatorService';
package/node/index.js CHANGED
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.AstralProductSwitcher = exports.IdentityProductSwitcher = void 0;
17
+ exports.useInitAutoSaveIndicatorStore = exports.AutoSaveIndicatorStore = exports.AstralProductSwitcher = exports.IdentityProductSwitcher = void 0;
18
18
  __exportStar(require("./cryproPro"), exports);
19
19
  var productSwitcher_1 = require("./productSwitcher");
20
20
  Object.defineProperty(exports, "IdentityProductSwitcher", { enumerable: true, get: function () { return productSwitcher_1.IdentityProductSwitcher; } });
21
21
  Object.defineProperty(exports, "AstralProductSwitcher", { enumerable: true, get: function () { return productSwitcher_1.AstralProductSwitcher; } });
22
+ var AutoSaveIndicatorService_1 = require("./AutoSaveIndicatorService");
23
+ Object.defineProperty(exports, "AutoSaveIndicatorStore", { enumerable: true, get: function () { return AutoSaveIndicatorService_1.AutoSaveIndicatorStore; } });
24
+ Object.defineProperty(exports, "useInitAutoSaveIndicatorStore", { enumerable: true, get: function () { return AutoSaveIndicatorService_1.useInitAutoSaveIndicatorStore; } });
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@astral/features",
3
3
  "browser": "./index.js",
4
4
  "main": "./node/index.js",
5
- "version": "3.192.0",
5
+ "version": "3.194.0",
6
6
  "dependencies": {
7
- "@astral/ui": "3.192.0",
7
+ "@astral/ui": "3.194.0",
8
8
  "mobx": "^6.8.0",
9
9
  "mobx-react-lite": "^3.4.0",
10
10
  "@astral/cryptopro-cades": "^1.5.1"