sera-components 1.1.10 → 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.
@@ -0,0 +1,16 @@
1
+ type LinkComponent = React.FunctionComponent<{
2
+ to: any;
3
+ params: {
4
+ id: string | number;
5
+ };
6
+ openInNewPage?: boolean;
7
+ children: React.ReactNode;
8
+ }>;
9
+ export declare const ExternalComponentContext: import('react').Context<{
10
+ link: LinkComponent;
11
+ }>;
12
+ export declare const ExternalComponentProvider: ({ link, children, }: {
13
+ link: LinkComponent;
14
+ children: React.ReactNode;
15
+ }) => import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -1,11 +1,35 @@
1
- import { NoArgsPathDef } from 'sera-route';
2
1
  import { Trie } from '../misc';
2
+ import { Permission } from '../types';
3
3
  type MenuKey = string;
4
- export declare enum Permission {
5
- Allow = 0,
6
- Denied = 1,
7
- Pending = 2
4
+ export interface MenuRoute<R> {
5
+ route: {
6
+ to: any;
7
+ fullPath: string;
8
+ };
9
+ role: R;
8
10
  }
11
+ export interface SeraMenuItem<R> {
12
+ key: MenuKey;
13
+ label: React.ReactElement | string;
14
+ icon?: React.ReactElement;
15
+ route?: MenuRoute<R>;
16
+ children?: SeraMenuItem<R>[];
17
+ }
18
+ export declare function buildMenuItemIndex<R>(items: SeraMenuItem<R>[]): {
19
+ key2item: Record<MenuKey, SeraMenuItem<R>>;
20
+ key2fullpath: Record<MenuKey, MenuKey[]>;
21
+ key2route: {
22
+ [key: MenuKey]: MenuRoute<R>;
23
+ };
24
+ };
25
+ export declare function filterAllowedItems<R>(items: SeraMenuItem<R>[], checkPermission: (role: R) => Permission): SeraMenuItem<R>[];
26
+ export declare const SeraVerticalMenu: <R>(props: {
27
+ items: SeraMenuItem<R>[];
28
+ checkPermission: (role: R) => Permission;
29
+ navigate: (options: {
30
+ to: any;
31
+ }) => void;
32
+ }) => import("react/jsx-runtime").JSX.Element;
9
33
  /**
10
34
  * Specialized Trie data structure for efficient menu route matching and navigation.
11
35
  *
@@ -36,27 +60,4 @@ export declare class MenuTrie extends Trie {
36
60
  */
37
61
  findMatchingKey(route: string): string | undefined;
38
62
  }
39
- export interface MenuRoute<R> {
40
- path: NoArgsPathDef<any>;
41
- role: R;
42
- }
43
- export interface SeraMenuItem<R> {
44
- key: MenuKey;
45
- label: React.ReactElement | string;
46
- icon?: React.ReactElement;
47
- route?: MenuRoute<R>;
48
- children?: SeraMenuItem<R>[];
49
- }
50
- export declare function buildMenuItemIndex<R>(items: SeraMenuItem<R>[]): {
51
- key2item: Record<MenuKey, SeraMenuItem<R>>;
52
- key2fullpath: Record<MenuKey, MenuKey[]>;
53
- key2route: {
54
- [key: MenuKey]: MenuRoute<R>;
55
- };
56
- };
57
- export declare function filterAllowedItems<R>(items: SeraMenuItem<R>[], checkPermission: (role: R) => Permission): SeraMenuItem<R>[];
58
- export declare const SeraVerticalMenu: <R>(props: {
59
- items: SeraMenuItem<R>[];
60
- checkPermission: (role: R) => Permission;
61
- }) => import("react/jsx-runtime").JSX.Element;
62
63
  export {};
@@ -3,3 +3,4 @@ export * from './Language';
3
3
  export * from './Transition';
4
4
  export * from './Menu';
5
5
  export * from './Locale';
6
+ export * from './ExternalComponent';
@@ -1,10 +1,9 @@
1
1
  import { ClassName, DataProperty, DataType, DB, ObjectProperty } from 'sera-db';
2
- import { NoQueryArgsPathDef } from 'sera-route';
3
2
  import { DateDisplay, DateTimeDisplay, DateTimeHideTimeDisplay } from './DateTimeDisplay';
4
3
  export { SingleForeignKeyDisplay, MultiForeignKeyDisplay } from './ForeignKeyDisplay';
5
- export type EntityRoute = NoQueryArgsPathDef<{
6
- id: "string" | "number";
7
- }, any>;
4
+ export type EntityRoute = {
5
+ to: any;
6
+ };
8
7
  export type EntityRoutes = Record<ClassName, EntityRoute>;
9
8
  export type DisplayInterface<T> = {
10
9
  db: DB;
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './form';
4
4
  export * from './table';
5
5
  export * from './view';
6
6
  export * from './misc';
7
+ export * from './types';
7
8
  export type { EntityRoute, EntityRoutes } from './data/display';