ecabs-components 1.2.0 → 1.2.1

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,21 +3,19 @@ export interface SidebarMenuItem<TEnv = unknown, TRole = unknown> {
3
3
  icon?: string;
4
4
  url?: string;
5
5
  expand?: boolean;
6
- subItems?: SidebarMenuItem[];
7
- permissions?: PermissionValueEnum<string>[];
6
+ subItems?: SidebarMenuItem<TEnv, TRole>[];
7
+ permissions?: string[];
8
8
  iconResource?: SidebarIconResource;
9
9
  badge?: string;
10
10
  isVisible?: (context: MenuItemVisibilityContext<TEnv, TRole>) => boolean;
11
+ isBadgeVisible?: (context: MenuItemVisibilityContext<TEnv, TRole>) => boolean;
11
12
  }
12
13
  export interface MenuItemVisibilityContext<TEnv, TRole> {
13
14
  environment: TEnv;
14
- role: TRole;
15
+ role?: TRole;
16
+ tenantFeatures?: string[];
15
17
  }
16
18
  export interface SidebarIconResource {
17
19
  path: string;
18
20
  name: string;
19
21
  }
20
- interface PermissionValueEnum<T extends string> {
21
- values: Record<T, string>;
22
- }
23
- export {};
@@ -1,2 +1,11 @@
1
- import { SidebarMenuItem } from '../models/sidebar.models';
1
+ import { MenuItemVisibilityContext, SidebarMenuItem } from '../models/sidebar.models';
2
2
  export declare function matchMenuToUrl(url: string, menu: SidebarMenuItem[]): SidebarMenuItem;
3
+ /**
4
+ * Returns copies of the menu items the user should see, never changing `menu`.
5
+ *
6
+ * Permissions are checked only when `permissions` is given: `undefined` skips the
7
+ * check, while `[]` checks against a user with no claims. An item shows when it has
8
+ * no `permissions`, includes `'allow'`, or the user holds any one of them.
9
+ * Then each item's `isVisible` and `isBadgeVisible` run, and groups left empty are removed.
10
+ */
11
+ export declare function filterMenuItems<TEnv, TRole>(menu: SidebarMenuItem<TEnv, TRole>[], context: MenuItemVisibilityContext<TEnv, TRole>, permissions?: string[]): SidebarMenuItem<TEnv, TRole>[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecabs-components",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^16.2.12",
6
6
  "@angular/common": "^16.2.12",
package/public-api.d.ts CHANGED
@@ -149,6 +149,7 @@ export * from './lib/base/utils/object-utils';
149
149
  export * from './lib/base/utils/phone-number.utils';
150
150
  export * from './lib/base/utils/icon.utils';
151
151
  export * from './lib/base/utils/select.utils';
152
+ export * from './lib/base/utils/menu-utils';
152
153
  export * from './lib/base/consts/badge.consts';
153
154
  export * from './lib/base/consts/status-badge.consts';
154
155
  export * from './lib/base/consts/icon.consts';