@abpjs/theme-shared 2.9.0 → 3.1.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.
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Nav Item Model
3
+ * Translated from @abp/ng.theme.shared/lib/models/nav-item.ts v3.1.0
4
+ *
5
+ * @since 3.0.0 - Added id property, changed permission to requiredPolicy
6
+ * @since 3.1.0 - Changed from interface to class, added visible callback
7
+ */
8
+ import type { ComponentType } from 'react';
9
+ /**
10
+ * Navigation item properties interface.
11
+ * @since 3.1.0
12
+ */
13
+ export interface NavItemProps {
14
+ /**
15
+ * Unique identifier for the nav item.
16
+ * @since 3.0.0
17
+ */
18
+ id: string | number;
19
+ /**
20
+ * React component to render for this nav item.
21
+ */
22
+ component?: ComponentType<any>;
23
+ /**
24
+ * Raw HTML string to render (use with caution for XSS).
25
+ */
26
+ html?: string;
27
+ /**
28
+ * Action to execute when the nav item is clicked.
29
+ */
30
+ action?: () => void;
31
+ /**
32
+ * Order for sorting nav items. Lower numbers appear first.
33
+ */
34
+ order?: number;
35
+ /**
36
+ * Required policy to show this nav item.
37
+ * @since 3.0.0 - Renamed from permission
38
+ */
39
+ requiredPolicy?: string;
40
+ /**
41
+ * Callback to determine visibility of the nav item.
42
+ * @since 3.1.0
43
+ */
44
+ visible?: () => boolean;
45
+ }
46
+ /**
47
+ * Navigation item class.
48
+ * @since 3.0.0 - Added id property, changed permission to requiredPolicy
49
+ * @since 3.1.0 - Changed from interface to class, added visible callback
50
+ */
51
+ export declare class NavItem implements NavItemProps {
52
+ /**
53
+ * Unique identifier for the nav item.
54
+ * @since 3.0.0
55
+ */
56
+ id: string | number;
57
+ /**
58
+ * React component to render for this nav item.
59
+ */
60
+ component?: ComponentType<any>;
61
+ /**
62
+ * Raw HTML string to render (use with caution for XSS).
63
+ */
64
+ html?: string;
65
+ /**
66
+ * Action to execute when the nav item is clicked.
67
+ */
68
+ action?: () => void;
69
+ /**
70
+ * Order for sorting nav items. Lower numbers appear first.
71
+ */
72
+ order?: number;
73
+ /**
74
+ * Required policy to show this nav item.
75
+ * @since 3.0.0 - Renamed from permission
76
+ */
77
+ requiredPolicy?: string;
78
+ /**
79
+ * Callback to determine visibility of the nav item.
80
+ * @since 3.1.0
81
+ */
82
+ visible?: () => boolean;
83
+ /**
84
+ * Create a new NavItem.
85
+ * @param props - Partial properties to initialize the nav item
86
+ * @since 3.1.0
87
+ */
88
+ constructor(props: Partial<NavItemProps>);
89
+ }
@@ -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,119 @@
1
+ /**
2
+ * Nav Items Service
3
+ * Translated from @abp/ng.theme.shared/lib/services/nav-items.service.ts v3.1.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
+ * @since 3.1.0 - Updated addItems parameter name to newItems for clarity
10
+ */
11
+ import { NavItem, NavItemProps } from '../models/nav-item';
12
+ /**
13
+ * NavItemsService manages navigation items with reactive updates.
14
+ * This is a singleton service that provides methods to add, remove, and patch nav items.
15
+ *
16
+ * @since 3.0.0 - Replaces the nav-items utility functions
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const navItemsService = NavItemsService.getInstance();
21
+ *
22
+ * // Add items
23
+ * navItemsService.addItems([
24
+ * { id: 'profile', component: ProfileComponent, order: 1 },
25
+ * { id: 'settings', component: SettingsComponent, order: 2 },
26
+ * ]);
27
+ *
28
+ * // Subscribe to changes
29
+ * const unsubscribe = navItemsService.subscribe((items) => {
30
+ * console.log('Items changed:', items);
31
+ * });
32
+ *
33
+ * // Remove an item
34
+ * navItemsService.removeItem('profile');
35
+ *
36
+ * // Patch an item
37
+ * navItemsService.patchItem('settings', { order: 10 });
38
+ * ```
39
+ */
40
+ export declare class NavItemsService {
41
+ private static _instance;
42
+ private _items;
43
+ private _listeners;
44
+ /**
45
+ * Get singleton instance
46
+ * @since 3.0.0
47
+ */
48
+ static getInstance(): NavItemsService;
49
+ /**
50
+ * Reset the singleton instance (useful for testing)
51
+ * @internal
52
+ */
53
+ static resetInstance(): void;
54
+ /**
55
+ * Get current items (sorted by order)
56
+ * @since 3.0.0
57
+ */
58
+ get items(): NavItem[];
59
+ /**
60
+ * Subscribe to item changes.
61
+ * Returns an unsubscribe function.
62
+ *
63
+ * @param listener - Callback function to receive item updates
64
+ * @returns Unsubscribe function
65
+ * @since 3.0.0
66
+ */
67
+ subscribe(listener: (items: NavItem[]) => void): () => void;
68
+ /**
69
+ * Get items as an observable-like interface.
70
+ * Compatible with Angular's Observable pattern.
71
+ *
72
+ * @returns Object with subscribe method
73
+ * @since 3.0.0
74
+ */
75
+ get items$(): {
76
+ subscribe: (callback: (items: NavItem[]) => void) => {
77
+ unsubscribe: () => void;
78
+ };
79
+ };
80
+ /**
81
+ * Add one or more items.
82
+ * Items are automatically sorted by order.
83
+ *
84
+ * @param newItems - Array of items to add
85
+ * @since 3.0.0
86
+ * @since 3.1.0 - Renamed parameter from items to newItems
87
+ */
88
+ addItems(newItems: (NavItem | NavItemProps)[]): void;
89
+ /**
90
+ * Remove an item by id.
91
+ *
92
+ * @param id - The id of the item to remove
93
+ * @since 3.0.0
94
+ */
95
+ removeItem(id: string | number): void;
96
+ /**
97
+ * Patch an existing item by id.
98
+ * Updates only the specified properties.
99
+ *
100
+ * @param id - The id of the item to patch
101
+ * @param patch - Partial item data to merge
102
+ * @since 3.0.0
103
+ */
104
+ patchItem(id: string | number, patch: Partial<Omit<NavItem, 'id'>>): void;
105
+ /**
106
+ * Clear all items.
107
+ * @since 3.0.0
108
+ */
109
+ clear(): void;
110
+ /**
111
+ * Notify all listeners of changes.
112
+ */
113
+ private notify;
114
+ }
115
+ /**
116
+ * Get the NavItemsService singleton.
117
+ * @since 3.0.0
118
+ */
119
+ export declare function getNavItemsService(): NavItemsService;
@@ -1,3 +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
- export * from './nav-items';
3
6
  export * from './validation-utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/theme-shared",
3
- "version": "2.9.0",
3
+ "version": "3.1.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.9.0"
30
+ "@abpjs/core": "3.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@abp/ng.theme.shared": "2.9.0",
34
- "@vitest/coverage-v8": "^3.2.0"
33
+ "@abp/ng.theme.shared": "3.1.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",