@greatapps/common 1.1.257 → 1.1.258

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 (32) hide show
  1. package/dist/components/account/AccountModals.mjs.map +1 -1
  2. package/dist/components/account/ConfigurationsMyAccountModal.mjs +1 -1
  3. package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
  4. package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -1
  5. package/dist/components/modals/ModalManager.mjs.map +1 -1
  6. package/dist/components/modals/Modals.mjs.map +1 -1
  7. package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -1
  8. package/dist/hooks/useDebounce.mjs.map +1 -1
  9. package/dist/hooks/useDebounceState.mjs.map +1 -1
  10. package/dist/hooks/useDebouncedEffect.mjs.map +1 -1
  11. package/dist/infra/utils/clsx.mjs.map +1 -1
  12. package/dist/infra/utils/parser.mjs.map +1 -1
  13. package/dist/infra/utils/percentage.mjs.map +1 -1
  14. package/dist/modules/users/services/messages.service.mjs.map +1 -1
  15. package/dist/store/useAccountModals.mjs.map +1 -1
  16. package/dist/store/useModalManager.mjs.map +1 -1
  17. package/package.json +1 -1
  18. package/src/components/account/AccountModals.tsx +17 -17
  19. package/src/components/account/ConfigurationsMyAccountModal.tsx +1 -1
  20. package/src/components/handlers/SearchParamsHandler.tsx +61 -61
  21. package/src/components/modals/ModalManager.tsx +29 -29
  22. package/src/components/modals/Modals.tsx +26 -26
  23. package/src/components/widgets/notifications/NotificationCard.tsx +68 -68
  24. package/src/hooks/useDebounce.ts +26 -26
  25. package/src/hooks/useDebounceState.ts +11 -11
  26. package/src/hooks/useDebouncedEffect.ts +69 -69
  27. package/src/infra/utils/clsx.ts +6 -6
  28. package/src/infra/utils/parser.ts +52 -52
  29. package/src/infra/utils/percentage.ts +42 -42
  30. package/src/modules/users/services/messages.service.ts +48 -48
  31. package/src/store/useAccountModals.ts +55 -55
  32. package/src/store/useModalManager.ts +104 -104
@@ -1,55 +1,55 @@
1
- 'use client';
2
-
3
- import { create } from 'zustand';
4
- import type { AccountSectionType } from '../enums/AccountSectionType';
5
-
6
- type AccountModalType =
7
- | 'configurations'
8
- | 'deleteAccount'
9
- | 'isntPossibleDelete'
10
- | 'confirmDelete';
11
-
12
- export interface AccountModalsConfig {
13
- hasActiveSubscription?: boolean;
14
- onGoToSubscription?: () => void;
15
- }
16
-
17
- interface AccountModalsState {
18
- activeModal: AccountModalType | null;
19
- config: AccountModalsConfig;
20
- initialSection?: AccountSectionType;
21
- pagesCount: number;
22
-
23
- /** Called by <AccountModals> to keep app-level config in sync */
24
- updateConfig: (config: AccountModalsConfig) => void;
25
-
26
- openConfigurations: (initialSection?: AccountSectionType) => void;
27
- openDeleteAccount: (pagesCount?: number) => void;
28
- openIsntPossibleDelete: () => void;
29
- openConfirmDelete: (pagesCount?: number) => void;
30
- close: () => void;
31
- }
32
-
33
- export const useAccountModals = create<AccountModalsState>((set) => ({
34
- activeModal: null,
35
- config: {},
36
- initialSection: undefined,
37
- pagesCount: 0,
38
-
39
- updateConfig: (config) => set({ config }),
40
-
41
- openConfigurations: (initialSection) =>
42
- set({ activeModal: 'configurations', initialSection }),
43
-
44
- openDeleteAccount: (pagesCount = 0) =>
45
- set({ activeModal: 'deleteAccount', pagesCount }),
46
-
47
- openIsntPossibleDelete: () =>
48
- set({ activeModal: 'isntPossibleDelete' }),
49
-
50
- openConfirmDelete: (pagesCount = 0) =>
51
- set({ activeModal: 'confirmDelete', pagesCount }),
52
-
53
- close: () =>
54
- set({ activeModal: null, initialSection: undefined }),
55
- }));
1
+ 'use client';
2
+
3
+ import { create } from 'zustand';
4
+ import type { AccountSectionType } from '../enums/AccountSectionType';
5
+
6
+ type AccountModalType =
7
+ | 'configurations'
8
+ | 'deleteAccount'
9
+ | 'isntPossibleDelete'
10
+ | 'confirmDelete';
11
+
12
+ export interface AccountModalsConfig {
13
+ hasActiveSubscription?: boolean;
14
+ onGoToSubscription?: () => void;
15
+ }
16
+
17
+ interface AccountModalsState {
18
+ activeModal: AccountModalType | null;
19
+ config: AccountModalsConfig;
20
+ initialSection?: AccountSectionType;
21
+ pagesCount: number;
22
+
23
+ /** Called by <AccountModals> to keep app-level config in sync */
24
+ updateConfig: (config: AccountModalsConfig) => void;
25
+
26
+ openConfigurations: (initialSection?: AccountSectionType) => void;
27
+ openDeleteAccount: (pagesCount?: number) => void;
28
+ openIsntPossibleDelete: () => void;
29
+ openConfirmDelete: (pagesCount?: number) => void;
30
+ close: () => void;
31
+ }
32
+
33
+ export const useAccountModals = create<AccountModalsState>((set) => ({
34
+ activeModal: null,
35
+ config: {},
36
+ initialSection: undefined,
37
+ pagesCount: 0,
38
+
39
+ updateConfig: (config) => set({ config }),
40
+
41
+ openConfigurations: (initialSection) =>
42
+ set({ activeModal: 'configurations', initialSection }),
43
+
44
+ openDeleteAccount: (pagesCount = 0) =>
45
+ set({ activeModal: 'deleteAccount', pagesCount }),
46
+
47
+ openIsntPossibleDelete: () =>
48
+ set({ activeModal: 'isntPossibleDelete' }),
49
+
50
+ openConfirmDelete: (pagesCount = 0) =>
51
+ set({ activeModal: 'confirmDelete', pagesCount }),
52
+
53
+ close: () =>
54
+ set({ activeModal: null, initialSection: undefined }),
55
+ }));
@@ -1,104 +1,104 @@
1
- 'use client';
2
-
3
- import { create } from 'zustand';
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- export type ModalData = Record<string, any>;
7
-
8
- interface ModalStackItem {
9
- key: string;
10
- data: ModalData;
11
- }
12
-
13
- interface ModalState {
14
- modalStack: ModalStackItem[];
15
- activeModal: string | null;
16
- modalData: ModalData;
17
- openModal: (key: string, data?: ModalData) => void;
18
- /** Closes the top modal in the stack */
19
- closeModal: () => void;
20
- /** Closes a specific modal by key */
21
- closeModalByKey: (key: string) => void;
22
- updateModalData: (data: ModalData) => void;
23
- isModalOpen: (key: string) => boolean;
24
- getModalData: (key: string) => ModalData;
25
- }
26
-
27
- export const useModalManager = create<ModalState>((set, get) => ({
28
- modalStack: [],
29
- activeModal: null,
30
- modalData: {},
31
-
32
- openModal: (key, data = {}) => {
33
- set((state) => {
34
- const existingIndex = state.modalStack.findIndex((item) => item.key === key);
35
- if (existingIndex !== -1) {
36
- const newStack = [...state.modalStack];
37
- newStack[existingIndex] = { key, data };
38
- return {
39
- modalStack: newStack,
40
- activeModal: newStack[newStack.length - 1]?.key ?? null,
41
- modalData: newStack[newStack.length - 1]?.data ?? {},
42
- };
43
- }
44
-
45
- const newStack = [...state.modalStack, { key, data }];
46
- return {
47
- modalStack: newStack,
48
- activeModal: key,
49
- modalData: data,
50
- };
51
- });
52
- },
53
-
54
- closeModal: () => {
55
- set((state) => {
56
- const newStack = state.modalStack.slice(0, -1);
57
- const topModal = newStack[newStack.length - 1];
58
- return {
59
- modalStack: newStack,
60
- activeModal: topModal?.key ?? null,
61
- modalData: topModal?.data ?? {},
62
- };
63
- });
64
- },
65
-
66
- closeModalByKey: (key: string) => {
67
- set((state) => {
68
- const newStack = state.modalStack.filter((item) => item.key !== key);
69
- const topModal = newStack[newStack.length - 1];
70
- return {
71
- modalStack: newStack,
72
- activeModal: topModal?.key ?? null,
73
- modalData: topModal?.data ?? {},
74
- };
75
- });
76
- },
77
-
78
- updateModalData: (data) => {
79
- set((state) => {
80
- if (state.modalStack.length === 0) return state;
81
-
82
- const newStack = [...state.modalStack];
83
- const lastIndex = newStack.length - 1;
84
- newStack[lastIndex] = {
85
- ...newStack[lastIndex],
86
- data: { ...newStack[lastIndex].data, ...data },
87
- };
88
-
89
- return {
90
- modalStack: newStack,
91
- modalData: newStack[lastIndex].data,
92
- };
93
- });
94
- },
95
-
96
- isModalOpen: (key: string) => {
97
- return get().modalStack.some((item) => item.key === key);
98
- },
99
-
100
- getModalData: (key: string) => {
101
- const item = get().modalStack.find((item) => item.key === key);
102
- return item?.data ?? {};
103
- },
104
- }));
1
+ 'use client';
2
+
3
+ import { create } from 'zustand';
4
+
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ export type ModalData = Record<string, any>;
7
+
8
+ interface ModalStackItem {
9
+ key: string;
10
+ data: ModalData;
11
+ }
12
+
13
+ interface ModalState {
14
+ modalStack: ModalStackItem[];
15
+ activeModal: string | null;
16
+ modalData: ModalData;
17
+ openModal: (key: string, data?: ModalData) => void;
18
+ /** Closes the top modal in the stack */
19
+ closeModal: () => void;
20
+ /** Closes a specific modal by key */
21
+ closeModalByKey: (key: string) => void;
22
+ updateModalData: (data: ModalData) => void;
23
+ isModalOpen: (key: string) => boolean;
24
+ getModalData: (key: string) => ModalData;
25
+ }
26
+
27
+ export const useModalManager = create<ModalState>((set, get) => ({
28
+ modalStack: [],
29
+ activeModal: null,
30
+ modalData: {},
31
+
32
+ openModal: (key, data = {}) => {
33
+ set((state) => {
34
+ const existingIndex = state.modalStack.findIndex((item) => item.key === key);
35
+ if (existingIndex !== -1) {
36
+ const newStack = [...state.modalStack];
37
+ newStack[existingIndex] = { key, data };
38
+ return {
39
+ modalStack: newStack,
40
+ activeModal: newStack[newStack.length - 1]?.key ?? null,
41
+ modalData: newStack[newStack.length - 1]?.data ?? {},
42
+ };
43
+ }
44
+
45
+ const newStack = [...state.modalStack, { key, data }];
46
+ return {
47
+ modalStack: newStack,
48
+ activeModal: key,
49
+ modalData: data,
50
+ };
51
+ });
52
+ },
53
+
54
+ closeModal: () => {
55
+ set((state) => {
56
+ const newStack = state.modalStack.slice(0, -1);
57
+ const topModal = newStack[newStack.length - 1];
58
+ return {
59
+ modalStack: newStack,
60
+ activeModal: topModal?.key ?? null,
61
+ modalData: topModal?.data ?? {},
62
+ };
63
+ });
64
+ },
65
+
66
+ closeModalByKey: (key: string) => {
67
+ set((state) => {
68
+ const newStack = state.modalStack.filter((item) => item.key !== key);
69
+ const topModal = newStack[newStack.length - 1];
70
+ return {
71
+ modalStack: newStack,
72
+ activeModal: topModal?.key ?? null,
73
+ modalData: topModal?.data ?? {},
74
+ };
75
+ });
76
+ },
77
+
78
+ updateModalData: (data) => {
79
+ set((state) => {
80
+ if (state.modalStack.length === 0) return state;
81
+
82
+ const newStack = [...state.modalStack];
83
+ const lastIndex = newStack.length - 1;
84
+ newStack[lastIndex] = {
85
+ ...newStack[lastIndex],
86
+ data: { ...newStack[lastIndex].data, ...data },
87
+ };
88
+
89
+ return {
90
+ modalStack: newStack,
91
+ modalData: newStack[lastIndex].data,
92
+ };
93
+ });
94
+ },
95
+
96
+ isModalOpen: (key: string) => {
97
+ return get().modalStack.some((item) => item.key === key);
98
+ },
99
+
100
+ getModalData: (key: string) => {
101
+ const item = get().modalStack.find((item) => item.key === key);
102
+ return item?.data ?? {};
103
+ },
104
+ }));