@abpjs/theme-shared 3.0.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.
@@ -44,6 +44,37 @@ export interface ErrorHandler {
44
44
  /** Clear the current error component */
45
45
  clearErrorComponent: () => void;
46
46
  }
47
+ /**
48
+ * Default error messages for common HTTP status codes.
49
+ */
50
+ export declare const DEFAULT_ERROR_MESSAGES: Record<number, string>;
51
+ /**
52
+ * Default error localizations with title and details.
53
+ * These are the localization keys used for error messages.
54
+ * @since 3.1.0
55
+ */
56
+ export declare const DEFAULT_ERROR_LOCALIZATIONS: {
57
+ readonly defaultError: {
58
+ readonly title: "AbpUi::DefaultErrorMessage";
59
+ readonly details: "AbpUi::DefaultErrorMessageDetail";
60
+ };
61
+ readonly defaultError401: {
62
+ readonly title: "AbpUi::DefaultErrorMessage401";
63
+ readonly details: "AbpUi::DefaultErrorMessage401Detail";
64
+ };
65
+ readonly defaultError403: {
66
+ readonly title: "AbpUi::DefaultErrorMessage403";
67
+ readonly details: "AbpUi::DefaultErrorMessage403Detail";
68
+ };
69
+ readonly defaultError404: {
70
+ readonly title: "AbpUi::DefaultErrorMessage404";
71
+ readonly details: "AbpUi::DefaultErrorMessage404Detail";
72
+ };
73
+ readonly defaultError500: {
74
+ readonly title: "AbpUi::DefaultErrorMessage500";
75
+ readonly details: "AbpUi::DefaultErrorMessage500Detail";
76
+ };
77
+ };
47
78
  export interface UseErrorHandlerOptions {
48
79
  /**
49
80
  * Custom navigate function. If not provided, navigation to login will be a no-op.
package/dist/index.js CHANGED
@@ -42,6 +42,8 @@ __export(index_exports, {
42
42
  Confirmation: () => Confirmation,
43
43
  ConfirmationDialog: () => ConfirmationDialog,
44
44
  ConfirmationProvider: () => ConfirmationProvider,
45
+ DEFAULT_ERROR_LOCALIZATIONS: () => DEFAULT_ERROR_LOCALIZATIONS,
46
+ DEFAULT_ERROR_MESSAGES: () => DEFAULT_ERROR_MESSAGES,
45
47
  DEFAULT_LAZY_STYLES: () => DEFAULT_LAZY_STYLES,
46
48
  DEFAULT_STYLES: () => DEFAULT_STYLES,
47
49
  ErrorComponent: () => ErrorComponent,
@@ -57,6 +59,7 @@ __export(index_exports, {
57
59
  ModalFooter: () => AbpModalFooter,
58
60
  ModalHeader: () => AbpModalHeader,
59
61
  ModalProvider: () => ModalProvider,
62
+ NavItem: () => NavItem,
60
63
  NavItemsService: () => NavItemsService,
61
64
  PASSWORD_SETTING_KEYS: () => PASSWORD_SETTING_KEYS,
62
65
  Profile: () => Profile,
@@ -115,6 +118,24 @@ var Confirmation;
115
118
  })(Status = Confirmation2.Status || (Confirmation2.Status = {}));
116
119
  })(Confirmation || (Confirmation = {}));
117
120
 
121
+ // src/models/nav-item.ts
122
+ var NavItem = class {
123
+ /**
124
+ * Create a new NavItem.
125
+ * @param props - Partial properties to initialize the nav item
126
+ * @since 3.1.0
127
+ */
128
+ constructor(props) {
129
+ this.id = props.id ?? "";
130
+ this.component = props.component;
131
+ this.html = props.html;
132
+ this.action = props.action;
133
+ this.order = props.order;
134
+ this.requiredPolicy = props.requiredPolicy;
135
+ this.visible = props.visible;
136
+ }
137
+ };
138
+
118
139
  // src/constants/styles.ts
119
140
  var BOOTSTRAP = "bootstrap-{{dir}}.min.css";
120
141
  var DEFAULT_STYLES = `
@@ -652,6 +673,28 @@ var DEFAULT_ERROR_MESSAGES = {
652
673
  500: "AbpUi::DefaultErrorMessage500",
653
674
  503: "AbpUi::DefaultErrorMessage503"
654
675
  };
676
+ var DEFAULT_ERROR_LOCALIZATIONS = {
677
+ defaultError: {
678
+ title: "AbpUi::DefaultErrorMessage",
679
+ details: "AbpUi::DefaultErrorMessageDetail"
680
+ },
681
+ defaultError401: {
682
+ title: "AbpUi::DefaultErrorMessage401",
683
+ details: "AbpUi::DefaultErrorMessage401Detail"
684
+ },
685
+ defaultError403: {
686
+ title: "AbpUi::DefaultErrorMessage403",
687
+ details: "AbpUi::DefaultErrorMessage403Detail"
688
+ },
689
+ defaultError404: {
690
+ title: "AbpUi::DefaultErrorMessage404",
691
+ details: "AbpUi::DefaultErrorMessage404Detail"
692
+ },
693
+ defaultError500: {
694
+ title: "AbpUi::DefaultErrorMessage500",
695
+ details: "AbpUi::DefaultErrorMessage500Detail"
696
+ }
697
+ };
655
698
  function useErrorHandler(options = {}) {
656
699
  const { navigate, loginPath = "/account/login" } = options;
657
700
  const confirmation = useConfirmation();
@@ -791,13 +834,14 @@ var _NavItemsService = class _NavItemsService {
791
834
  * Add one or more items.
792
835
  * Items are automatically sorted by order.
793
836
  *
794
- * @param items - Array of items to add
837
+ * @param newItems - Array of items to add
795
838
  * @since 3.0.0
839
+ * @since 3.1.0 - Renamed parameter from items to newItems
796
840
  */
797
- addItems(items) {
841
+ addItems(newItems) {
798
842
  const existingIds = new Set(this._items.map((item) => item.id));
799
- const newItems = items.filter((item) => !existingIds.has(item.id));
800
- this._items = [...this._items, ...newItems];
843
+ const itemsToAdd = newItems.filter((item) => !existingIds.has(item.id)).map((item) => item instanceof NavItem ? item : new NavItem(item));
844
+ this._items = [...this._items, ...itemsToAdd];
801
845
  this.notify();
802
846
  }
803
847
  /**
@@ -2545,6 +2589,8 @@ function getPasswordValidationRules(store) {
2545
2589
  Confirmation,
2546
2590
  ConfirmationDialog,
2547
2591
  ConfirmationProvider,
2592
+ DEFAULT_ERROR_LOCALIZATIONS,
2593
+ DEFAULT_ERROR_MESSAGES,
2548
2594
  DEFAULT_LAZY_STYLES,
2549
2595
  DEFAULT_STYLES,
2550
2596
  ErrorComponent,
@@ -2560,6 +2606,7 @@ function getPasswordValidationRules(store) {
2560
2606
  ModalFooter,
2561
2607
  ModalHeader,
2562
2608
  ModalProvider,
2609
+ NavItem,
2563
2610
  NavItemsService,
2564
2611
  PASSWORD_SETTING_KEYS,
2565
2612
  Profile,
package/dist/index.mjs CHANGED
@@ -9,6 +9,24 @@ var Confirmation;
9
9
  })(Status = Confirmation2.Status || (Confirmation2.Status = {}));
10
10
  })(Confirmation || (Confirmation = {}));
11
11
 
12
+ // src/models/nav-item.ts
13
+ var NavItem = class {
14
+ /**
15
+ * Create a new NavItem.
16
+ * @param props - Partial properties to initialize the nav item
17
+ * @since 3.1.0
18
+ */
19
+ constructor(props) {
20
+ this.id = props.id ?? "";
21
+ this.component = props.component;
22
+ this.html = props.html;
23
+ this.action = props.action;
24
+ this.order = props.order;
25
+ this.requiredPolicy = props.requiredPolicy;
26
+ this.visible = props.visible;
27
+ }
28
+ };
29
+
12
30
  // src/constants/styles.ts
13
31
  var BOOTSTRAP = "bootstrap-{{dir}}.min.css";
14
32
  var DEFAULT_STYLES = `
@@ -569,6 +587,28 @@ var DEFAULT_ERROR_MESSAGES = {
569
587
  500: "AbpUi::DefaultErrorMessage500",
570
588
  503: "AbpUi::DefaultErrorMessage503"
571
589
  };
590
+ var DEFAULT_ERROR_LOCALIZATIONS = {
591
+ defaultError: {
592
+ title: "AbpUi::DefaultErrorMessage",
593
+ details: "AbpUi::DefaultErrorMessageDetail"
594
+ },
595
+ defaultError401: {
596
+ title: "AbpUi::DefaultErrorMessage401",
597
+ details: "AbpUi::DefaultErrorMessage401Detail"
598
+ },
599
+ defaultError403: {
600
+ title: "AbpUi::DefaultErrorMessage403",
601
+ details: "AbpUi::DefaultErrorMessage403Detail"
602
+ },
603
+ defaultError404: {
604
+ title: "AbpUi::DefaultErrorMessage404",
605
+ details: "AbpUi::DefaultErrorMessage404Detail"
606
+ },
607
+ defaultError500: {
608
+ title: "AbpUi::DefaultErrorMessage500",
609
+ details: "AbpUi::DefaultErrorMessage500Detail"
610
+ }
611
+ };
572
612
  function useErrorHandler(options = {}) {
573
613
  const { navigate, loginPath = "/account/login" } = options;
574
614
  const confirmation = useConfirmation();
@@ -708,13 +748,14 @@ var _NavItemsService = class _NavItemsService {
708
748
  * Add one or more items.
709
749
  * Items are automatically sorted by order.
710
750
  *
711
- * @param items - Array of items to add
751
+ * @param newItems - Array of items to add
712
752
  * @since 3.0.0
753
+ * @since 3.1.0 - Renamed parameter from items to newItems
713
754
  */
714
- addItems(items) {
755
+ addItems(newItems) {
715
756
  const existingIds = new Set(this._items.map((item) => item.id));
716
- const newItems = items.filter((item) => !existingIds.has(item.id));
717
- this._items = [...this._items, ...newItems];
757
+ const itemsToAdd = newItems.filter((item) => !existingIds.has(item.id)).map((item) => item instanceof NavItem ? item : new NavItem(item));
758
+ this._items = [...this._items, ...itemsToAdd];
718
759
  this.notify();
719
760
  }
720
761
  /**
@@ -2507,6 +2548,8 @@ export {
2507
2548
  Confirmation,
2508
2549
  ConfirmationDialog,
2509
2550
  ConfirmationProvider,
2551
+ DEFAULT_ERROR_LOCALIZATIONS,
2552
+ DEFAULT_ERROR_MESSAGES,
2510
2553
  DEFAULT_LAZY_STYLES,
2511
2554
  DEFAULT_STYLES,
2512
2555
  ErrorComponent,
@@ -2522,6 +2565,7 @@ export {
2522
2565
  AbpModalFooter as ModalFooter,
2523
2566
  AbpModalHeader as ModalHeader,
2524
2567
  ModalProvider,
2568
+ NavItem,
2525
2569
  NavItemsService,
2526
2570
  PASSWORD_SETTING_KEYS,
2527
2571
  Profile,
@@ -1,15 +1,54 @@
1
1
  /**
2
2
  * Nav Item Model
3
- * Translated from @abp/ng.theme.shared/lib/models/nav-item.ts v3.0.0
3
+ * Translated from @abp/ng.theme.shared/lib/models/nav-item.ts v3.1.0
4
4
  *
5
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
6
7
  */
7
8
  import type { ComponentType } from 'react';
8
9
  /**
9
- * Navigation item configuration.
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.
10
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
11
50
  */
12
- export interface NavItem {
51
+ export declare class NavItem implements NavItemProps {
13
52
  /**
14
53
  * Unique identifier for the nav item.
15
54
  * @since 3.0.0
@@ -36,4 +75,15 @@ export interface NavItem {
36
75
  * @since 3.0.0 - Renamed from permission
37
76
  */
38
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>);
39
89
  }
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * Nav Items Service
3
- * Translated from @abp/ng.theme.shared/lib/services/nav-items.service.ts v3.0.0
3
+ * Translated from @abp/ng.theme.shared/lib/services/nav-items.service.ts v3.1.0
4
4
  *
5
5
  * Provides a service-based approach to managing navigation items,
6
6
  * replacing the utility functions approach from v2.9.0.
7
7
  *
8
8
  * @since 3.0.0
9
+ * @since 3.1.0 - Updated addItems parameter name to newItems for clarity
9
10
  */
10
- import type { NavItem } from '../models/nav-item';
11
+ import { NavItem, NavItemProps } from '../models/nav-item';
11
12
  /**
12
13
  * NavItemsService manages navigation items with reactive updates.
13
14
  * This is a singleton service that provides methods to add, remove, and patch nav items.
@@ -80,10 +81,11 @@ export declare class NavItemsService {
80
81
  * Add one or more items.
81
82
  * Items are automatically sorted by order.
82
83
  *
83
- * @param items - Array of items to add
84
+ * @param newItems - Array of items to add
84
85
  * @since 3.0.0
86
+ * @since 3.1.0 - Renamed parameter from items to newItems
85
87
  */
86
- addItems(items: NavItem[]): void;
88
+ addItems(newItems: (NavItem | NavItemProps)[]): void;
87
89
  /**
88
90
  * Remove an item by id.
89
91
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abpjs/theme-shared",
3
- "version": "3.0.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,10 +27,10 @@
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": "3.0.0"
30
+ "@abpjs/core": "3.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@abp/ng.theme.shared": "3.0.0",
33
+ "@abp/ng.theme.shared": "3.1.0",
34
34
  "@vitest/coverage-v8": "^1.6.0",
35
35
  "vitest": "^1.6.0"
36
36
  },