@abpjs/theme-shared 2.7.0 → 3.0.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.
@@ -3,8 +3,14 @@
3
3
  * Translated from @abp/ng.theme.shared/lib/models/common.ts
4
4
  * @since 1.1.0
5
5
  * @since 2.7.0 - Added skipHandledErrorCodes, simplified forWhichErrors type
6
+ * @since 2.9.0 - Added LocaleDirection type
6
7
  */
7
8
  import type { ComponentType } from 'react';
9
+ /**
10
+ * Locale direction for RTL/LTR support.
11
+ * @since 2.9.0
12
+ */
13
+ export type LocaleDirection = 'ltr' | 'rtl';
8
14
  /**
9
15
  * Root parameters for ThemeSharedModule configuration.
10
16
  * @since 1.1.0
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Confirmation namespace containing types for confirmation dialogs.
3
- * Translated from @abp/ng.theme.shared/lib/models/confirmation.ts
3
+ * Translated from @abp/ng.theme.shared/lib/models/confirmation.ts v3.0.0
4
4
  *
5
5
  * @since 2.0.0 - Major changes:
6
6
  * - Options no longer extends Toaster.Options
@@ -9,18 +9,24 @@
9
9
  * - Removed deprecated cancelCopy/yesCopy
10
10
  *
11
11
  * @since 2.1.0 - Added Status enum (confirmation-specific, replaces Toaster.Status usage)
12
+ * @since 2.9.0 - Added dismissible property, deprecated closable
13
+ * @since 3.0.0 - Removed closable property (use dismissible instead)
12
14
  */
13
15
  import type { Config } from '@abpjs/core';
14
16
  export declare namespace Confirmation {
15
17
  /**
16
18
  * Options for configuring a confirmation dialog.
17
19
  * @since 2.0.0 - No longer extends Toaster.Options
20
+ * @since 3.0.0 - Removed closable (use dismissible instead)
18
21
  */
19
22
  interface Options {
20
23
  /** Unique identifier for the confirmation */
21
24
  id?: string | number;
22
- /** Whether the confirmation can be closed by clicking outside or pressing escape */
23
- closable?: boolean;
25
+ /**
26
+ * Whether the confirmation can be dismissed by clicking outside or pressing escape.
27
+ * @since 2.9.0
28
+ */
29
+ dismissible?: boolean;
24
30
  /** Parameters for localizing the message */
25
31
  messageLocalizationParams?: string[];
26
32
  /** Parameters for localizing the title */
@@ -1,5 +1,10 @@
1
+ /**
2
+ * Models barrel export
3
+ * @since 3.0.0 - Removed setting-management (now in @abpjs/core SettingTabsService)
4
+ * @since 3.0.0 - Added nav-item model
5
+ */
1
6
  export * from './common';
2
- export * from './toaster';
3
7
  export * from './confirmation';
4
- export * from './setting-management';
8
+ export * from './nav-item';
5
9
  export * from './statistics';
10
+ export * from './toaster';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Nav Item Model
3
+ * Translated from @abp/ng.theme.shared/lib/models/nav-item.ts v3.0.0
4
+ *
5
+ * @since 3.0.0 - Added id property, changed permission to requiredPolicy
6
+ */
7
+ import type { ComponentType } from 'react';
8
+ /**
9
+ * Navigation item configuration.
10
+ * @since 3.0.0 - Added id property, changed permission to requiredPolicy
11
+ */
12
+ export interface NavItem {
13
+ /**
14
+ * Unique identifier for the nav item.
15
+ * @since 3.0.0
16
+ */
17
+ id: string | number;
18
+ /**
19
+ * React component to render for this nav item.
20
+ */
21
+ component?: ComponentType<any>;
22
+ /**
23
+ * Raw HTML string to render (use with caution for XSS).
24
+ */
25
+ html?: string;
26
+ /**
27
+ * Action to execute when the nav item is clicked.
28
+ */
29
+ action?: () => void;
30
+ /**
31
+ * Order for sorting nav items. Lower numbers appear first.
32
+ */
33
+ order?: number;
34
+ /**
35
+ * Required policy to show this nav item.
36
+ * @since 3.0.0 - Renamed from permission
37
+ */
38
+ requiredPolicy?: string;
39
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Config } from '@abpjs/core';
2
2
  /**
3
3
  * Toaster namespace containing types and interfaces for toast notifications.
4
- * Translated from @abp/ng.theme.shared/lib/models/toaster.ts
4
+ * Translated from @abp/ng.theme.shared/lib/models/toaster.ts v3.0.0
5
5
  *
6
6
  * @since 2.0.0 - Major changes:
7
7
  * - `Options` renamed to `ToastOptions`
@@ -9,7 +9,7 @@ import type { Config } from '@abpjs/core';
9
9
  * - `Severity` type changed: 'warn' → 'warning', added 'neutral'
10
10
  * - ToasterService methods now return number (toast ID) instead of Observable
11
11
  *
12
- * @since 2.1.0 - Status enum deprecated, use Confirmation.Status instead
12
+ * @since 3.0.0 - Status enum removed, use Confirmation.Status instead
13
13
  */
14
14
  export declare namespace Toaster {
15
15
  /**
@@ -53,46 +53,4 @@ export declare namespace Toaster {
53
53
  * @since 2.0.0 - Changed 'warn' to 'warning', added 'neutral'
54
54
  */
55
55
  type Severity = 'neutral' | 'success' | 'info' | 'warning' | 'error';
56
- /**
57
- * Status values for toast/confirmation interactions.
58
- * @deprecated Status will be removed from toaster model in v3.0. Use Confirmation.Status instead.
59
- * @since 2.1.0 - Deprecated in favor of Confirmation.Status
60
- */
61
- enum Status {
62
- confirm = "confirm",
63
- reject = "reject",
64
- dismiss = "dismiss"
65
- }
66
- /**
67
- * @deprecated Use ToastOptions instead. Scheduled for removal in v3.0.0
68
- * Preserved for backward compatibility.
69
- */
70
- interface Options {
71
- /** Unique identifier for the toast */
72
- id?: string;
73
- /** Whether the toast can be manually closed */
74
- closable?: boolean;
75
- /** Duration in milliseconds before auto-dismiss (default varies by implementation) */
76
- life?: number;
77
- /** If true, toast won't auto-dismiss */
78
- sticky?: boolean;
79
- /** Custom data to attach to the toast */
80
- data?: unknown;
81
- /** Parameters for localizing the message */
82
- messageLocalizationParams?: string[];
83
- /** Parameters for localizing the title */
84
- titleLocalizationParams?: string[];
85
- }
86
- /**
87
- * @deprecated Use Toast instead. Scheduled for removal in v3.0.0
88
- * Preserved for backward compatibility.
89
- */
90
- interface Message extends Options {
91
- /** The message content (can be a localization key) */
92
- message: string;
93
- /** The title (can be a localization key) */
94
- title?: string;
95
- /** Severity level of the message */
96
- severity: Severity;
97
- }
98
56
  }
@@ -131,5 +131,5 @@ export interface ThemeSharedProviderProps {
131
131
  * }
132
132
  * ```
133
133
  */
134
- export declare function ThemeSharedProvider({ children, renderToasts, renderConfirmation, themeOverrides, toastPosition, enableColorMode, defaultColorMode, locale, }: ThemeSharedProviderProps): React.ReactElement;
134
+ export declare function ThemeSharedProvider({ children, renderToasts, renderConfirmation, themeOverrides, toastPosition: _toastPosition, enableColorMode, defaultColorMode, locale, }: ThemeSharedProviderProps): React.ReactElement;
135
135
  export default ThemeSharedProvider;
@@ -1 +1,2 @@
1
1
  export * from './ThemeSharedProvider';
2
+ export * from './route.provider';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Route Provider
3
+ * Translated from @abp/ng.theme.shared/lib/providers/route.provider.ts v3.0.0
4
+ *
5
+ * Provides route configuration for the theme-shared module.
6
+ *
7
+ * @since 3.0.0
8
+ */
9
+ import { RoutesService } from '@abpjs/core';
10
+ /**
11
+ * Configures the theme shared routes.
12
+ * This function is called during app initialization to register
13
+ * the Administration route that other modules can use as a parent.
14
+ *
15
+ * @param routes - The RoutesService instance
16
+ * @returns A function that performs the route configuration
17
+ * @since 3.0.0
18
+ */
19
+ export declare function configureRoutes(routes: RoutesService): () => void;
20
+ /**
21
+ * Theme shared route providers for initialization.
22
+ * Use this in your app setup to configure theme-shared routes.
23
+ *
24
+ * In React, you typically call this during app initialization:
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { initializeThemeSharedRoutes } from '@abpjs/theme-shared';
29
+ *
30
+ * // In your app initialization
31
+ * initializeThemeSharedRoutes();
32
+ * ```
33
+ *
34
+ * @since 3.0.0
35
+ */
36
+ export declare const THEME_SHARED_ROUTE_PROVIDERS: {
37
+ configureRoutes: typeof configureRoutes;
38
+ };
39
+ /**
40
+ * Initialize theme shared routes.
41
+ * Call this function during app initialization to register the Administration route.
42
+ *
43
+ * @since 3.0.0
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * import { initializeThemeSharedRoutes } from '@abpjs/theme-shared';
48
+ *
49
+ * // Call once during app initialization
50
+ * initializeThemeSharedRoutes();
51
+ * ```
52
+ */
53
+ export declare function initializeThemeSharedRoutes(): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Services barrel export
3
+ * @since 3.0.0
4
+ */
5
+ export * from './nav-items.service';
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Nav Items Service
3
+ * Translated from @abp/ng.theme.shared/lib/services/nav-items.service.ts v3.0.0
4
+ *
5
+ * Provides a service-based approach to managing navigation items,
6
+ * replacing the utility functions approach from v2.9.0.
7
+ *
8
+ * @since 3.0.0
9
+ */
10
+ import type { NavItem } from '../models/nav-item';
11
+ /**
12
+ * NavItemsService manages navigation items with reactive updates.
13
+ * This is a singleton service that provides methods to add, remove, and patch nav items.
14
+ *
15
+ * @since 3.0.0 - Replaces the nav-items utility functions
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * const navItemsService = NavItemsService.getInstance();
20
+ *
21
+ * // Add items
22
+ * navItemsService.addItems([
23
+ * { id: 'profile', component: ProfileComponent, order: 1 },
24
+ * { id: 'settings', component: SettingsComponent, order: 2 },
25
+ * ]);
26
+ *
27
+ * // Subscribe to changes
28
+ * const unsubscribe = navItemsService.subscribe((items) => {
29
+ * console.log('Items changed:', items);
30
+ * });
31
+ *
32
+ * // Remove an item
33
+ * navItemsService.removeItem('profile');
34
+ *
35
+ * // Patch an item
36
+ * navItemsService.patchItem('settings', { order: 10 });
37
+ * ```
38
+ */
39
+ export declare class NavItemsService {
40
+ private static _instance;
41
+ private _items;
42
+ private _listeners;
43
+ /**
44
+ * Get singleton instance
45
+ * @since 3.0.0
46
+ */
47
+ static getInstance(): NavItemsService;
48
+ /**
49
+ * Reset the singleton instance (useful for testing)
50
+ * @internal
51
+ */
52
+ static resetInstance(): void;
53
+ /**
54
+ * Get current items (sorted by order)
55
+ * @since 3.0.0
56
+ */
57
+ get items(): NavItem[];
58
+ /**
59
+ * Subscribe to item changes.
60
+ * Returns an unsubscribe function.
61
+ *
62
+ * @param listener - Callback function to receive item updates
63
+ * @returns Unsubscribe function
64
+ * @since 3.0.0
65
+ */
66
+ subscribe(listener: (items: NavItem[]) => void): () => void;
67
+ /**
68
+ * Get items as an observable-like interface.
69
+ * Compatible with Angular's Observable pattern.
70
+ *
71
+ * @returns Object with subscribe method
72
+ * @since 3.0.0
73
+ */
74
+ get items$(): {
75
+ subscribe: (callback: (items: NavItem[]) => void) => {
76
+ unsubscribe: () => void;
77
+ };
78
+ };
79
+ /**
80
+ * Add one or more items.
81
+ * Items are automatically sorted by order.
82
+ *
83
+ * @param items - Array of items to add
84
+ * @since 3.0.0
85
+ */
86
+ addItems(items: NavItem[]): void;
87
+ /**
88
+ * Remove an item by id.
89
+ *
90
+ * @param id - The id of the item to remove
91
+ * @since 3.0.0
92
+ */
93
+ removeItem(id: string | number): void;
94
+ /**
95
+ * Patch an existing item by id.
96
+ * Updates only the specified properties.
97
+ *
98
+ * @param id - The id of the item to patch
99
+ * @param patch - Partial item data to merge
100
+ * @since 3.0.0
101
+ */
102
+ patchItem(id: string | number, patch: Partial<Omit<NavItem, 'id'>>): void;
103
+ /**
104
+ * Clear all items.
105
+ * @since 3.0.0
106
+ */
107
+ clear(): void;
108
+ /**
109
+ * Notify all listeners of changes.
110
+ */
111
+ private notify;
112
+ }
113
+ /**
114
+ * Get the NavItemsService singleton.
115
+ * @since 3.0.0
116
+ */
117
+ export declare function getNavItemsService(): NavItemsService;
@@ -3,6 +3,8 @@
3
3
  * Translated from @abp/ng.theme.shared/lib/tokens
4
4
  *
5
5
  * @since 2.7.0
6
+ * @since 2.9.0 - Added LAZY_STYLES token
6
7
  */
7
8
  export * from './append-content.token';
8
9
  export * from './http-error.token';
10
+ export * from './lazy-styles.token';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Lazy Styles Token
3
+ * Translated from @abp/ng.theme.shared/lib/tokens/lazy-styles.token.ts
4
+ *
5
+ * Provides configuration for lazy-loaded stylesheets with RTL/LTR support.
6
+ *
7
+ * @since 2.9.0
8
+ */
9
+ /**
10
+ * Default lazy styles configuration.
11
+ * @since 2.9.0
12
+ */
13
+ export declare const DEFAULT_LAZY_STYLES: string[];
14
+ /**
15
+ * Context for lazy styles configuration.
16
+ * @since 2.9.0
17
+ */
18
+ export declare const LazyStylesContext: import("react").Context<string[]>;
19
+ /**
20
+ * Hook to get lazy styles configuration.
21
+ * @returns Array of style patterns with {{dir}} placeholder
22
+ * @since 2.9.0
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * function MyComponent() {
27
+ * const lazyStyles = useLazyStyles();
28
+ * // lazyStyles = ['bootstrap-{{dir}}.min.css']
29
+ * }
30
+ * ```
31
+ */
32
+ export declare function useLazyStyles(): string[];
33
+ /**
34
+ * LAZY_STYLES constant for backwards compatibility.
35
+ * In React, use LazyStylesContext or useLazyStyles() hook instead.
36
+ * @since 2.9.0
37
+ */
38
+ export declare const LAZY_STYLES: string[];
@@ -1,2 +1,6 @@
1
+ /**
2
+ * Utils barrel export
3
+ * @since 3.0.0 - Removed nav-items (use NavItemsService from services instead)
4
+ */
1
5
  export * from './styles';
2
6
  export * from './validation-utils';
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Nav Items Utility
3
+ * Translated from @abp/ng.theme.shared/lib/utils/nav-items.ts
4
+ *
5
+ * Provides functions for managing navigation items dynamically.
6
+ *
7
+ * @since 2.9.0
8
+ */
9
+ import { ComponentType } from 'react';
10
+ /**
11
+ * Navigation item configuration.
12
+ * @since 2.9.0
13
+ */
14
+ export interface NavItem {
15
+ /**
16
+ * React component to render for this nav item.
17
+ */
18
+ component?: ComponentType<any>;
19
+ /**
20
+ * Raw HTML string to render (use with caution for XSS).
21
+ */
22
+ html?: string;
23
+ /**
24
+ * Action to execute when the nav item is clicked.
25
+ */
26
+ action?: () => void;
27
+ /**
28
+ * Order for sorting nav items. Lower numbers appear first.
29
+ */
30
+ order?: number;
31
+ /**
32
+ * Permission required to show this nav item.
33
+ */
34
+ permission?: string;
35
+ }
36
+ type NavItemSubscriber = (items: NavItem[]) => void;
37
+ /**
38
+ * Add a navigation item.
39
+ * @param item - The nav item to add
40
+ * @since 2.9.0
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * addNavItem({
45
+ * component: MyComponent,
46
+ * order: 10,
47
+ * permission: 'AbpIdentity.Users',
48
+ * });
49
+ * ```
50
+ */
51
+ export declare function addNavItem(item: NavItem): void;
52
+ /**
53
+ * Remove a navigation item.
54
+ * @param item - The nav item to remove
55
+ * @since 2.9.0
56
+ */
57
+ export declare function removeNavItem(item: NavItem): void;
58
+ /**
59
+ * Clear all navigation items.
60
+ * @since 2.9.0
61
+ */
62
+ export declare function clearNavItems(): void;
63
+ /**
64
+ * Get current navigation items.
65
+ * @returns Array of nav items
66
+ * @since 2.9.0
67
+ */
68
+ export declare function getNavItemsSync(): NavItem[];
69
+ /**
70
+ * Subscribe to navigation item changes.
71
+ * Returns an unsubscribe function.
72
+ *
73
+ * @param callback - Function to call when nav items change
74
+ * @returns Unsubscribe function
75
+ * @since 2.9.0
76
+ *
77
+ * @example
78
+ * ```tsx
79
+ * const unsubscribe = subscribeToNavItems((items) => {
80
+ * console.log('Nav items changed:', items);
81
+ * });
82
+ *
83
+ * // Later, to unsubscribe:
84
+ * unsubscribe();
85
+ * ```
86
+ */
87
+ export declare function subscribeToNavItems(callback: NavItemSubscriber): () => void;
88
+ /**
89
+ * Get navigation items as an observable-like interface.
90
+ * Compatible with Angular's Observable pattern.
91
+ *
92
+ * @returns Object with subscribe method
93
+ * @since 2.9.0
94
+ *
95
+ * @example
96
+ * ```tsx
97
+ * const subscription = getNavItems().subscribe((items) => {
98
+ * console.log('Nav items:', items);
99
+ * });
100
+ *
101
+ * // Later, to unsubscribe:
102
+ * subscription.unsubscribe();
103
+ * ```
104
+ */
105
+ export declare function getNavItems(): {
106
+ subscribe: (callback: NavItemSubscriber) => {
107
+ unsubscribe: () => void;
108
+ };
109
+ };
110
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/theme-shared",
3
- "version": "2.7.0",
3
+ "version": "3.0.0",
4
4
  "description": "ABP Framework Theme Shared components for React - translated from @abp/ng.theme.shared",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,11 +27,12 @@
27
27
  "next-themes": "^0.4.6",
28
28
  "react-hook-form": "^7.48.0",
29
29
  "react-icons": "^5.5.0",
30
- "@abpjs/core": "2.7.0"
30
+ "@abpjs/core": "3.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@abp/ng.theme.shared": "2.7.0",
34
- "@vitest/coverage-v8": "^3.2.0"
33
+ "@abp/ng.theme.shared": "3.0.0",
34
+ "@vitest/coverage-v8": "^1.6.0",
35
+ "vitest": "^1.6.0"
35
36
  },
36
37
  "author": "tekthar.com",
37
38
  "license": "LGPL-3.0",