@abpjs/theme-shared 2.2.0 → 2.7.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.
- package/dist/components/errors/ErrorComponent.d.ts +27 -1
- package/dist/constants/append-content.d.ts +34 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/contexts/modal.context.d.ts +139 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.js +516 -271
- package/dist/index.mjs +426 -189
- package/dist/models/common.d.ts +10 -1
- package/dist/models/toaster.d.ts +1 -1
- package/dist/tokens/append-content.token.d.ts +7 -0
- package/dist/tokens/http-error.token.d.ts +70 -0
- package/dist/tokens/index.d.ts +8 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/validation-utils.d.ts +125 -0
- package/package.json +3 -3
|
@@ -9,11 +9,29 @@ export interface ErrorComponentProps {
|
|
|
9
9
|
showCloseButton?: boolean;
|
|
10
10
|
/** Custom close button text */
|
|
11
11
|
closeButtonText?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to show the home button.
|
|
14
|
+
* When true, shows a "Go Home" button alongside or instead of the close button.
|
|
15
|
+
* @since 2.7.0
|
|
16
|
+
*/
|
|
17
|
+
isHomeShow?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Callback when user clicks the home button.
|
|
20
|
+
* @since 2.7.0
|
|
21
|
+
*/
|
|
22
|
+
onHomeClick?: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Custom home button text.
|
|
25
|
+
* @since 2.7.0
|
|
26
|
+
*/
|
|
27
|
+
homeButtonText?: string;
|
|
12
28
|
}
|
|
13
29
|
/**
|
|
14
30
|
* A component for displaying error pages/messages.
|
|
15
31
|
* Can be used for HTTP errors (404, 500, etc.) or general error states.
|
|
16
32
|
*
|
|
33
|
+
* @since 2.7.0 - Added isHomeShow, onHomeClick, homeButtonText props
|
|
34
|
+
*
|
|
17
35
|
* @example
|
|
18
36
|
* ```tsx
|
|
19
37
|
* // Basic error display
|
|
@@ -29,7 +47,15 @@ export interface ErrorComponentProps {
|
|
|
29
47
|
* showCloseButton
|
|
30
48
|
* onDestroy={() => navigate('/')}
|
|
31
49
|
* />
|
|
50
|
+
*
|
|
51
|
+
* // With home button (v2.7.0)
|
|
52
|
+
* <ErrorComponent
|
|
53
|
+
* title="404"
|
|
54
|
+
* details="Page not found."
|
|
55
|
+
* isHomeShow
|
|
56
|
+
* onHomeClick={() => navigate('/')}
|
|
57
|
+
* />
|
|
32
58
|
* ```
|
|
33
59
|
*/
|
|
34
|
-
export declare function ErrorComponent({ title, details, onDestroy, showCloseButton, closeButtonText, }: ErrorComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
export declare function ErrorComponent({ title, details, onDestroy, showCloseButton, closeButtonText, isHomeShow, onHomeClick, homeButtonText, }: ErrorComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
35
61
|
export default ErrorComponent;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context for theme shared append content functionality.
|
|
3
|
+
* Used to append scripts or stylesheets to the document.
|
|
4
|
+
*
|
|
5
|
+
* This is the React equivalent of Angular's THEME_SHARED_APPEND_CONTENT InjectionToken.
|
|
6
|
+
*
|
|
7
|
+
* @since 2.4.0
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // Provide a custom append content function
|
|
12
|
+
* import { ThemeSharedAppendContentContext } from '@abpjs/theme-shared';
|
|
13
|
+
*
|
|
14
|
+
* function App() {
|
|
15
|
+
* const appendContent = async () => {
|
|
16
|
+
* // Custom logic to append scripts/styles
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <ThemeSharedAppendContentContext.Provider value={appendContent}>
|
|
21
|
+
* <YourApp />
|
|
22
|
+
* </ThemeSharedAppendContentContext.Provider>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const ThemeSharedAppendContentContext: import("react").Context<(() => Promise<void>) | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Token name constant for THEME_SHARED_APPEND_CONTENT.
|
|
30
|
+
* Matches the Angular InjectionToken name.
|
|
31
|
+
*
|
|
32
|
+
* @since 2.4.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const THEME_SHARED_APPEND_CONTENT = "THEME_SHARED_APPEND_CONTENT";
|
package/dist/contexts/index.d.ts
CHANGED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { type ReactNode, type ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Modal template render function type.
|
|
4
|
+
* @since 2.7.0
|
|
5
|
+
*/
|
|
6
|
+
export type ModalTemplateRender<T = unknown> = (context?: T) => ReactElement | null;
|
|
7
|
+
/**
|
|
8
|
+
* Modal state containing the current template and context.
|
|
9
|
+
* @since 2.7.0
|
|
10
|
+
*/
|
|
11
|
+
export interface ModalState<T = unknown> {
|
|
12
|
+
/** The render function for the modal content */
|
|
13
|
+
render: ModalTemplateRender<T>;
|
|
14
|
+
/** Context passed to the render function */
|
|
15
|
+
context?: T;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ModalService interface - matches the Angular service API.
|
|
19
|
+
*
|
|
20
|
+
* In Angular, ModalService uses ContentProjectionService to render templates
|
|
21
|
+
* in a container. In React, we use context and state to manage modal content.
|
|
22
|
+
*
|
|
23
|
+
* @since 2.7.0
|
|
24
|
+
*/
|
|
25
|
+
export interface ModalService {
|
|
26
|
+
/**
|
|
27
|
+
* Render a template in the modal container.
|
|
28
|
+
* @param render - Function that returns the modal content
|
|
29
|
+
* @param context - Optional context to pass to the render function
|
|
30
|
+
* @since 2.7.0
|
|
31
|
+
*/
|
|
32
|
+
renderTemplate<T = unknown>(render: ModalTemplateRender<T>, context?: T): void;
|
|
33
|
+
/**
|
|
34
|
+
* Clear the current modal.
|
|
35
|
+
* @since 2.7.0
|
|
36
|
+
*/
|
|
37
|
+
clearModal(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the container ref for the modal.
|
|
40
|
+
* In React, this returns a ref to the container element.
|
|
41
|
+
* @since 2.7.0
|
|
42
|
+
*/
|
|
43
|
+
getContainer(): React.RefObject<HTMLDivElement | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Trigger a re-render of the modal content.
|
|
46
|
+
* In React, this forces a state update.
|
|
47
|
+
* @since 2.7.0
|
|
48
|
+
*/
|
|
49
|
+
detectChanges(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Context value containing the service and current modal state.
|
|
53
|
+
* @since 2.7.0
|
|
54
|
+
*/
|
|
55
|
+
export interface ModalContextValue {
|
|
56
|
+
service: ModalService;
|
|
57
|
+
/** Current modal state */
|
|
58
|
+
modalState: ModalState | null;
|
|
59
|
+
}
|
|
60
|
+
export interface ModalProviderProps {
|
|
61
|
+
children: ReactNode;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* ModalProvider - Provides modal service functionality.
|
|
65
|
+
*
|
|
66
|
+
* This is the React equivalent of Angular's ModalService.
|
|
67
|
+
* Wrap your app with this provider to enable modal service functionality.
|
|
68
|
+
*
|
|
69
|
+
* @since 2.7.0
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <ModalProvider>
|
|
74
|
+
* <App />
|
|
75
|
+
* <ModalContainer />
|
|
76
|
+
* </ModalProvider>
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function ModalProvider({ children }: ModalProviderProps): ReactElement;
|
|
80
|
+
/**
|
|
81
|
+
* Hook to access the modal service.
|
|
82
|
+
*
|
|
83
|
+
* @returns ModalService with methods to manage modal content
|
|
84
|
+
* @throws Error if used outside of ModalProvider
|
|
85
|
+
*
|
|
86
|
+
* @since 2.7.0
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* function MyComponent() {
|
|
91
|
+
* const modal = useModal();
|
|
92
|
+
*
|
|
93
|
+
* const openModal = () => {
|
|
94
|
+
* modal.renderTemplate((context) => (
|
|
95
|
+
* <Dialog open onClose={() => modal.clearModal()}>
|
|
96
|
+
* <DialogContent>Hello {context?.name}</DialogContent>
|
|
97
|
+
* </Dialog>
|
|
98
|
+
* ), { name: 'World' });
|
|
99
|
+
* };
|
|
100
|
+
*
|
|
101
|
+
* return <button onClick={openModal}>Open Modal</button>;
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function useModal(): ModalService;
|
|
106
|
+
/**
|
|
107
|
+
* Hook to access the current modal state.
|
|
108
|
+
* This is typically used by the ModalContainer component.
|
|
109
|
+
*
|
|
110
|
+
* @returns Current modal state or null
|
|
111
|
+
* @since 2.7.0
|
|
112
|
+
*/
|
|
113
|
+
export declare function useModalState(): ModalState | null;
|
|
114
|
+
/**
|
|
115
|
+
* Hook to access the full modal context.
|
|
116
|
+
*
|
|
117
|
+
* @returns ModalContextValue with service and modal state
|
|
118
|
+
* @since 2.7.0
|
|
119
|
+
*/
|
|
120
|
+
export declare function useModalContext(): ModalContextValue;
|
|
121
|
+
/**
|
|
122
|
+
* ModalContainer component - renders the current modal content.
|
|
123
|
+
* Place this component once in your app to display modal content.
|
|
124
|
+
*
|
|
125
|
+
* @since 2.7.0
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* function App() {
|
|
130
|
+
* return (
|
|
131
|
+
* <ModalProvider>
|
|
132
|
+
* <MainContent />
|
|
133
|
+
* <ModalContainer />
|
|
134
|
+
* </ModalProvider>
|
|
135
|
+
* );
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function ModalContainer(): ReactElement | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,25 @@
|
|
|
2
2
|
* @abpjs/theme-shared
|
|
3
3
|
*
|
|
4
4
|
* ABP Framework Theme Shared components for React.
|
|
5
|
-
* Translated from @abp/ng.theme.shared v2.
|
|
5
|
+
* Translated from @abp/ng.theme.shared v2.7.0
|
|
6
6
|
*
|
|
7
7
|
* This package provides shared UI components, services, and utilities
|
|
8
8
|
* for theme/modal management in ABP Framework React applications.
|
|
9
9
|
*
|
|
10
|
+
* Changes in v2.7.0:
|
|
11
|
+
* - Added ModalService with renderTemplate, clearModal, getContainer, detectChanges
|
|
12
|
+
* - HttpErrorConfig: Added skipHandledErrorCodes, simplified forWhichErrors to array
|
|
13
|
+
* - HttpErrorWrapperComponent: Added isHomeShow property
|
|
14
|
+
* - Added validation-utils with getPasswordValidators function
|
|
15
|
+
* - Added tokens exports (HTTP_ERROR_CONFIG, httpErrorConfigFactory)
|
|
16
|
+
* - Dependency updates to @abp/ng.core v2.7.0
|
|
17
|
+
*
|
|
18
|
+
* Changes in v2.4.0:
|
|
19
|
+
* - Added THEME_SHARED_APPEND_CONTENT token for content appending
|
|
20
|
+
* - Updated Toaster.Status deprecation notice (removal now in v3.0 instead of v2.2)
|
|
21
|
+
* - Dependency updates to @abp/ng.core v2.4.0
|
|
22
|
+
* - appendScript function deprecated (to be deleted in v2.6)
|
|
23
|
+
*
|
|
10
24
|
* Changes in v2.2.0:
|
|
11
25
|
* - Dependency updates to @abp/ng.core v2.2.0
|
|
12
26
|
* - Dependency updates to @fortawesome/fontawesome-free v5.12.1
|
|
@@ -46,6 +60,7 @@
|
|
|
46
60
|
*/
|
|
47
61
|
export * from './models';
|
|
48
62
|
export * from './constants';
|
|
63
|
+
export * from './tokens';
|
|
49
64
|
export * from './contexts';
|
|
50
65
|
export * from './hooks';
|
|
51
66
|
export * from './components';
|