@abpjs/theme-shared 0.7.6
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/LICENSE +165 -0
- package/README.md +568 -0
- package/dist/components/confirmation/Confirmation.d.ts +27 -0
- package/dist/components/confirmation/index.d.ts +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/modal/Modal.d.ts +114 -0
- package/dist/components/modal/index.d.ts +1 -0
- package/dist/components/toast/Toast.d.ts +43 -0
- package/dist/components/toast/index.d.ts +1 -0
- package/dist/components/ui/Alert.d.ts +50 -0
- package/dist/components/ui/Button.d.ts +70 -0
- package/dist/components/ui/Checkbox.d.ts +64 -0
- package/dist/components/ui/FormField.d.ts +50 -0
- package/dist/components/ui/color-mode.d.ts +19 -0
- package/dist/components/ui/index.d.ts +16 -0
- package/dist/components/ui/provider.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts +3 -0
- package/dist/components/ui/tooltip.d.ts +11 -0
- package/dist/contexts/confirmation.context.d.ts +100 -0
- package/dist/contexts/index.d.ts +2 -0
- package/dist/contexts/toaster.context.d.ts +91 -0
- package/dist/handlers/error.handler.d.ts +110 -0
- package/dist/handlers/index.d.ts +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +1305 -0
- package/dist/index.mjs +1281 -0
- package/dist/models/confirmation.d.ts +21 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/toaster.d.ts +48 -0
- package/dist/providers/ThemeSharedProvider.d.ts +135 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/theme/index.d.ts +42 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/styles.d.ts +14 -0
- package/package.json +57 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirmation namespace containing types for confirmation dialogs.
|
|
3
|
+
* Translated from @abp/ng.theme.shared/lib/models/confirmation.ts
|
|
4
|
+
*/
|
|
5
|
+
import { Toaster } from './toaster';
|
|
6
|
+
export declare namespace Confirmation {
|
|
7
|
+
/**
|
|
8
|
+
* Options for configuring a confirmation dialog.
|
|
9
|
+
* Extends Toaster.Options with confirmation-specific properties.
|
|
10
|
+
*/
|
|
11
|
+
interface Options extends Toaster.Options {
|
|
12
|
+
/** Hide the cancel button */
|
|
13
|
+
hideCancelBtn?: boolean;
|
|
14
|
+
/** Hide the yes/confirm button */
|
|
15
|
+
hideYesBtn?: boolean;
|
|
16
|
+
/** Custom text for the cancel button (localization key) */
|
|
17
|
+
cancelCopy?: string;
|
|
18
|
+
/** Custom text for the yes button (localization key) */
|
|
19
|
+
yesCopy?: string;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toaster namespace containing types and interfaces for toast notifications.
|
|
3
|
+
* Translated from @abp/ng.theme.shared/lib/models/toaster.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace Toaster {
|
|
6
|
+
/**
|
|
7
|
+
* Options for configuring a toast notification.
|
|
8
|
+
*/
|
|
9
|
+
interface Options {
|
|
10
|
+
/** Unique identifier for the toast */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Whether the toast can be manually closed */
|
|
13
|
+
closable?: boolean;
|
|
14
|
+
/** Duration in milliseconds before auto-dismiss (default varies by implementation) */
|
|
15
|
+
life?: number;
|
|
16
|
+
/** If true, toast won't auto-dismiss */
|
|
17
|
+
sticky?: boolean;
|
|
18
|
+
/** Custom data to attach to the toast */
|
|
19
|
+
data?: unknown;
|
|
20
|
+
/** Parameters for localizing the message */
|
|
21
|
+
messageLocalizationParams?: string[];
|
|
22
|
+
/** Parameters for localizing the title */
|
|
23
|
+
titleLocalizationParams?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Severity levels for toast notifications.
|
|
27
|
+
*/
|
|
28
|
+
type Severity = 'success' | 'info' | 'warn' | 'error';
|
|
29
|
+
/**
|
|
30
|
+
* Status values for toast/confirmation interactions.
|
|
31
|
+
*/
|
|
32
|
+
enum Status {
|
|
33
|
+
confirm = "confirm",
|
|
34
|
+
reject = "reject",
|
|
35
|
+
dismiss = "dismiss"
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Complete message structure for a toast notification.
|
|
39
|
+
*/
|
|
40
|
+
interface Message extends Options {
|
|
41
|
+
/** The message content (can be a localization key) */
|
|
42
|
+
message: string;
|
|
43
|
+
/** The title (can be a localization key) */
|
|
44
|
+
title?: string;
|
|
45
|
+
/** Severity level of the message */
|
|
46
|
+
severity: Severity;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type ThemeOverride } from '../theme';
|
|
3
|
+
export interface ThemeSharedProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Whether to automatically render the ToastContainer.
|
|
7
|
+
* Set to false if you want to render it manually in a specific location.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
renderToasts?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to automatically render the ConfirmationDialog.
|
|
13
|
+
* Set to false if you want to render it manually in a specific location.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
renderConfirmation?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Custom theme overrides to merge with the default ABP theme.
|
|
19
|
+
* Use this to customize colors, fonts, component styles, etc.
|
|
20
|
+
*
|
|
21
|
+
* In Chakra v3, use defineConfig() to create overrides:
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { defineConfig } from '@abpjs/theme-shared';
|
|
26
|
+
*
|
|
27
|
+
* const customConfig = defineConfig({
|
|
28
|
+
* theme: {
|
|
29
|
+
* tokens: {
|
|
30
|
+
* colors: {
|
|
31
|
+
* brand: {
|
|
32
|
+
* 500: { value: '#ff0000' },
|
|
33
|
+
* },
|
|
34
|
+
* },
|
|
35
|
+
* },
|
|
36
|
+
* },
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* <ThemeSharedProvider themeOverrides={customConfig}>
|
|
40
|
+
* <App />
|
|
41
|
+
* </ThemeSharedProvider>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
themeOverrides?: ThemeOverride;
|
|
45
|
+
/**
|
|
46
|
+
* Position of toast notifications.
|
|
47
|
+
* @default 'bottom-right'
|
|
48
|
+
*/
|
|
49
|
+
toastPosition?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left';
|
|
50
|
+
/**
|
|
51
|
+
* Whether to enable color mode (light/dark theme switching).
|
|
52
|
+
* When enabled, the ColorModeProvider from next-themes is included.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
enableColorMode?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Default color mode when enableColorMode is true.
|
|
58
|
+
* @default 'light'
|
|
59
|
+
*/
|
|
60
|
+
defaultColorMode?: 'light' | 'dark' | 'system';
|
|
61
|
+
/**
|
|
62
|
+
* Locale for RTL support and accessibility.
|
|
63
|
+
* This is passed to Chakra's LocaleProvider for proper direction handling
|
|
64
|
+
* in Portal-based components (menus, modals, popovers, etc.).
|
|
65
|
+
*
|
|
66
|
+
* Examples: 'en-US', 'ar-SA', 'he-IL', 'fa-IR'
|
|
67
|
+
* @default 'en-US'
|
|
68
|
+
*/
|
|
69
|
+
locale?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* ThemeSharedProvider - Root provider for theme.shared functionality.
|
|
73
|
+
*
|
|
74
|
+
* This is the React equivalent of Angular's ThemeSharedModule.forRoot().
|
|
75
|
+
* Wrap your app with this provider to enable toast notifications,
|
|
76
|
+
* confirmation dialogs, and other theme.shared features.
|
|
77
|
+
*
|
|
78
|
+
* This provider should be nested inside AbpProvider from @abpjs/core.
|
|
79
|
+
*
|
|
80
|
+
* ## Theme Customization (Chakra v3)
|
|
81
|
+
*
|
|
82
|
+
* You can customize the Chakra UI theme by passing `themeOverrides`:
|
|
83
|
+
*
|
|
84
|
+
* ```tsx
|
|
85
|
+
* import { defineConfig } from '@abpjs/theme-shared';
|
|
86
|
+
*
|
|
87
|
+
* const customConfig = defineConfig({
|
|
88
|
+
* theme: {
|
|
89
|
+
* tokens: {
|
|
90
|
+
* colors: {
|
|
91
|
+
* brand: {
|
|
92
|
+
* 500: { value: '#your-brand-color' },
|
|
93
|
+
* },
|
|
94
|
+
* },
|
|
95
|
+
* fonts: {
|
|
96
|
+
* heading: { value: 'Your Font, sans-serif' },
|
|
97
|
+
* body: { value: 'Your Font, sans-serif' },
|
|
98
|
+
* },
|
|
99
|
+
* },
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* <ThemeSharedProvider themeOverrides={customConfig}>
|
|
104
|
+
* <App />
|
|
105
|
+
* </ThemeSharedProvider>
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* ## Color Mode (Optional, v3 feature)
|
|
109
|
+
*
|
|
110
|
+
* Enable dark mode support by setting `enableColorMode`:
|
|
111
|
+
*
|
|
112
|
+
* ```tsx
|
|
113
|
+
* <ThemeSharedProvider enableColorMode defaultColorMode="system">
|
|
114
|
+
* <App />
|
|
115
|
+
* </ThemeSharedProvider>
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```tsx
|
|
120
|
+
* import { AbpProvider } from '@abpjs/core';
|
|
121
|
+
* import { ThemeSharedProvider } from '@abpjs/theme-shared';
|
|
122
|
+
*
|
|
123
|
+
* function App() {
|
|
124
|
+
* return (
|
|
125
|
+
* <AbpProvider environment={env} requirements={req} routes={routes}>
|
|
126
|
+
* <ThemeSharedProvider>
|
|
127
|
+
* <YourApp />
|
|
128
|
+
* </ThemeSharedProvider>
|
|
129
|
+
* </AbpProvider>
|
|
130
|
+
* );
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function ThemeSharedProvider({ children, renderToasts, renderConfirmation, themeOverrides, toastPosition, enableColorMode, defaultColorMode, locale, }: ThemeSharedProviderProps): React.ReactElement;
|
|
135
|
+
export default ThemeSharedProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeSharedProvider';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineConfig } from '@chakra-ui/react';
|
|
2
|
+
/**
|
|
3
|
+
* Default ABP theme configuration for Chakra v3.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defaultAbpConfig: import("@chakra-ui/react").SystemConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Creates the ABP Chakra v3 system.
|
|
8
|
+
*
|
|
9
|
+
* @param overrides - Optional config overrides to merge with the default config
|
|
10
|
+
* @returns Chakra v3 system
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* // Use default system
|
|
15
|
+
* const system = createAbpSystem();
|
|
16
|
+
*
|
|
17
|
+
* // Override specific values
|
|
18
|
+
* const customSystem = createAbpSystem(defineConfig({
|
|
19
|
+
* theme: {
|
|
20
|
+
* tokens: {
|
|
21
|
+
* colors: {
|
|
22
|
+
* brand: {
|
|
23
|
+
* 500: { value: '#ff0000' }, // Custom brand color
|
|
24
|
+
* },
|
|
25
|
+
* },
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* }));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAbpSystem(overrides?: ReturnType<typeof defineConfig>): import("@chakra-ui/react").SystemContext;
|
|
32
|
+
/**
|
|
33
|
+
* Pre-built ABP system instance.
|
|
34
|
+
* Use this directly or use createAbpSystem() for customization.
|
|
35
|
+
*/
|
|
36
|
+
export declare const abpSystem: import("@chakra-ui/react").SystemContext;
|
|
37
|
+
/**
|
|
38
|
+
* Theme override type for consumers.
|
|
39
|
+
* Use this type when passing custom configurations.
|
|
40
|
+
*/
|
|
41
|
+
export type ThemeOverride = ReturnType<typeof defineConfig>;
|
|
42
|
+
export { defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './styles';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global CSS styles for theme.shared components.
|
|
3
|
+
* Translated from @abp/ng.theme.shared/lib/contants/styles.ts
|
|
4
|
+
*
|
|
5
|
+
* These are additional ABP-specific styles that complement Chakra UI.
|
|
6
|
+
* Most styling is handled by Chakra UI's style system.
|
|
7
|
+
*/
|
|
8
|
+
export declare const THEME_SHARED_STYLES = "\n/* Form validation styling */\n.is-invalid {\n border-color: var(--chakra-colors-red-500) !important;\n}\n\n.invalid-feedback {\n display: block;\n width: 100%;\n margin-top: var(--chakra-space-1);\n font-size: var(--chakra-fontSizes-sm);\n color: var(--chakra-colors-red-500);\n}\n\n/* Pointer cursor utility */\n.pointer {\n cursor: pointer;\n}\n\n/* Fade animations */\n@keyframes fadeInTop {\n from {\n opacity: 0;\n transform: translateY(-20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes fadeOutTop {\n from {\n opacity: 1;\n transform: translateY(0);\n }\n to {\n opacity: 0;\n transform: translateY(-20px);\n }\n}\n\n.fade-in-top {\n animation: fadeInTop 0.3s ease-out forwards;\n}\n\n.fade-out-top {\n animation: fadeOutTop 0.3s ease-out forwards;\n}\n";
|
|
9
|
+
/**
|
|
10
|
+
* Injects the ABP theme shared styles into the document head.
|
|
11
|
+
* This is optional since Chakra UI provides most styling.
|
|
12
|
+
* Only use this if you need ABP-specific utility classes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function injectThemeSharedStyles(): (() => void) | undefined;
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@abpjs/theme-shared",
|
|
3
|
+
"version": "0.7.6",
|
|
4
|
+
"description": "ABP Framework Theme Shared components for React - translated from @abp/ng.theme.shared",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"react-dom": "^18.2.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@chakra-ui/react": "^3.2.0",
|
|
25
|
+
"@emotion/react": "^11.11.0",
|
|
26
|
+
"lucide-react": "^0.400.0",
|
|
27
|
+
"next-themes": "^0.4.6",
|
|
28
|
+
"react-icons": "^5.5.0",
|
|
29
|
+
"@abpjs/core": "0.7.6"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@abp/ng.theme.shared": "0.7.6"
|
|
33
|
+
},
|
|
34
|
+
"author": "tekthar.com",
|
|
35
|
+
"license": "LGPL-3.0",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/abpjs/abp-react"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://docs.abpjs.io/docs/packages/theme-shared/overview",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/abpjs/abp-react/issues"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup src/index.ts --format cjs,esm --clean && tsc -p tsconfig.build.json",
|
|
49
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch",
|
|
50
|
+
"lint": "eslint src",
|
|
51
|
+
"lint:fix": "eslint src --fix",
|
|
52
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
|
|
53
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
|
|
54
|
+
"type-check": "tsc --noEmit",
|
|
55
|
+
"test": "vitest"
|
|
56
|
+
}
|
|
57
|
+
}
|