@imperium/layout 8.0.0 → 9.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,7 +3,7 @@ import type React from 'react';
3
3
  import type { SemanticCOLORS, SemanticICONS } from 'semantic-ui-react';
4
4
  import type { RouteItem, VisibilityItem, WeightedItem } from '../commonItems';
5
5
  import type { DataHookItem } from '../datahooks/types';
6
- import type { Data, StateSelectorHook } from '../types';
6
+ import type { Data, PermissionSelectorHook, StateSelectorHook } from '../types';
7
7
  export declare type RouteParameters<T extends readonly string[] | undefined> = T extends readonly string[] ? ParametersFromAssertion<T> : never;
8
8
  export interface ContentData<T extends DefineRouteOptions, K extends keyof T> extends Data {
9
9
  params: RouteParameters<T[K]['params']>;
@@ -46,6 +46,7 @@ export declare type ContentHeader<T extends DefineRouteOptions, K extends keyof
46
46
  export interface Page<T extends DefineRouteOptions, K extends keyof T> {
47
47
  dataHooks?: DataHookItem[];
48
48
  stateSelectorHook?: StateSelectorHook | StateSelectorHook[];
49
+ permissionSelectorHook?: PermissionSelectorHook | PermissionSelectorHook[];
49
50
  content: Content<T, K>;
50
51
  header?: ContentHeader<T, K>;
51
52
  sidebar?: SidebarItem<T, K>[];
@@ -4,7 +4,7 @@ interface DataHooksProps {
4
4
  dataHooks: DataHookItem[];
5
5
  }
6
6
  /**
7
- * Renders layout data hooks. These hooks should return nothing. All interaction should be in side-effects, usually retrieving data and setting Redux state.
7
+ * Renders layout data hooks. These hooks should return nothing. All interaction should be in side effects, usually retrieving data and setting Redux state.
8
8
  * @param dataHooks
9
9
  * @constructor
10
10
  */
@@ -0,0 +1,7 @@
1
+ import type { PermissionSelectorHook } from '../types';
2
+ interface ExecutePermissionHookProps {
3
+ permissionHook: PermissionSelectorHook;
4
+ routeParams?: any;
5
+ }
6
+ export declare function ExecutePermissionHook({ permissionHook, routeParams }: ExecutePermissionHookProps): null;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import type { PermissionSelectorHook } from '../types';
3
+ interface PermissionHooksProps {
4
+ permissionHooks: PermissionSelectorHook[];
5
+ }
6
+ export declare function PermissionHooks({ permissionHooks }: PermissionHooksProps): JSX.Element;
7
+ export {};
@@ -14,6 +14,6 @@ export declare type DataHookRoute = {
14
14
  dataHook: DataHook | DataHook[];
15
15
  };
16
16
  /**
17
- * A datahook can either be a simple hook, or one or more hooks dependant on one or more route match functions.
17
+ * A datahook can either be a simple hook, or one or more hooks dependent on one or more route match functions.
18
18
  */
19
19
  export declare type DataHookItem = DataHook | DataHookRoute;
@@ -1,7 +1,8 @@
1
- import type { Data, StateSelectorHook } from '../types';
1
+ import type { Data, PermissionSelectorHook, StateSelectorHook } from '../types';
2
2
  export interface UseBuildDataParams {
3
3
  data?: Data;
4
4
  routeItem?: any;
5
5
  stateSelectorHook?: StateSelectorHook | StateSelectorHook[];
6
+ permissionSelectorHook?: PermissionSelectorHook | PermissionSelectorHook[];
6
7
  }
7
- export declare function useBuildData({ stateSelectorHook, data, routeItem }: UseBuildDataParams): Data;
8
+ export declare function useBuildData({ stateSelectorHook, permissionSelectorHook, data, routeItem }: UseBuildDataParams): Data;
@@ -0,0 +1,2 @@
1
+ import type { Data, PermissionSelectorHook } from '../types';
2
+ export declare function useSelectPermission(data: Data, permissionSelectorHook?: PermissionSelectorHook | PermissionSelectorHook[]): import("../types").PermissionResults;
@@ -1,9 +1,9 @@
1
- import React from 'react';
1
+ import type { ComponentClass } from 'react';
2
2
  import type { Data } from '../../types';
3
3
  import type { LayoutItem } from '../types';
4
4
  interface ItemWrapperProps {
5
5
  item: LayoutItem;
6
- as?: React.ComponentClass;
6
+ as?: ComponentClass;
7
7
  vertical?: boolean;
8
8
  data?: Data;
9
9
  }
@@ -1,10 +1,10 @@
1
- import React from 'react';
1
+ import type { ComponentClass } from 'react';
2
2
  import type { Data } from '../../types';
3
3
  import type { CustomLayoutItem, DropdownLayoutItem, LayoutItem, MenuLayoutItem } from '../types';
4
4
  interface PlainItemProps {
5
5
  item: Exclude<LayoutItem, MenuLayoutItem | DropdownLayoutItem | CustomLayoutItem>;
6
6
  data: Data;
7
- as?: React.ComponentClass;
7
+ as?: ComponentClass;
8
8
  }
9
9
  export declare function PlainItem({ item, data, as }: PlainItemProps): JSX.Element;
10
10
  export {};
@@ -2,7 +2,7 @@
2
2
  import type { SemanticICONS } from 'semantic-ui-react';
3
3
  import type { HorizontalPositionedItem, RouteItem, VisibilityItem, WeightedItem } from '../commonItems';
4
4
  import type { DataHookItem } from '../datahooks/types';
5
- import type { Data } from '../types';
5
+ import type { Data, PermissionSelectorHook } from '../types';
6
6
  /**
7
7
  * Describes a basic weighted, possibly visible item
8
8
  */
@@ -34,6 +34,7 @@ export interface MenuLayoutItem extends BaseLayoutItem {
34
34
  */
35
35
  export declare type LayoutItem = (BaseLayoutItem & RouteItem<Data>) | DropdownLayoutItem | MenuLayoutItem | CustomLayoutItem;
36
36
  export interface LayoutData {
37
+ permissionSelectorHooks?: PermissionSelectorHook[];
37
38
  dataHooks?: DataHookItem[];
38
39
  primaryMenu?: (LayoutItem & HorizontalPositionedItem)[];
39
40
  statusbar?: (LayoutItem & HorizontalPositionedItem)[];
package/dist/state.d.ts CHANGED
@@ -1,20 +1,58 @@
1
1
  import { PayloadAction } from '@reduxjs/toolkit';
2
2
  export declare const state: import("@reduxjs/toolkit").Slice<{
3
3
  isMobile: boolean;
4
+ params: {};
5
+ permissions: Record<string, boolean>;
4
6
  }, {
5
7
  setMobile: (st: import("immer/dist/internal").WritableDraft<{
6
8
  isMobile: boolean;
9
+ params: {};
10
+ permissions: Record<string, boolean>;
7
11
  }>, action: PayloadAction<boolean>) => {
8
12
  isMobile: boolean;
13
+ params: import("immer/dist/internal").WritableDraft<{}>;
14
+ permissions: import("immer/dist/internal").WritableDraft<Record<string, boolean>>;
9
15
  };
16
+ setParams: (st: import("immer/dist/internal").WritableDraft<{
17
+ isMobile: boolean;
18
+ params: {};
19
+ permissions: Record<string, boolean>;
20
+ }>, action: PayloadAction<Record<string, string>>) => void;
21
+ setPermission: (st: import("immer/dist/internal").WritableDraft<{
22
+ isMobile: boolean;
23
+ params: {};
24
+ permissions: Record<string, boolean>;
25
+ }>, action: PayloadAction<{
26
+ permission: string;
27
+ result: boolean;
28
+ }>) => void;
10
29
  }, "imperiumLayout">;
11
30
  export declare const useLayoutState: () => {
12
31
  isMobile: boolean;
32
+ params: import("immer/dist/internal").WritableDraft<{}>;
33
+ permissions: import("immer/dist/internal").WritableDraft<Record<string, boolean>>;
13
34
  };
14
35
  export declare const actions: import("@reduxjs/toolkit").CaseReducerActions<{
15
36
  setMobile: (st: import("immer/dist/internal").WritableDraft<{
16
37
  isMobile: boolean;
38
+ params: {};
39
+ permissions: Record<string, boolean>;
17
40
  }>, action: PayloadAction<boolean>) => {
18
41
  isMobile: boolean;
42
+ params: import("immer/dist/internal").WritableDraft<{}>;
43
+ permissions: import("immer/dist/internal").WritableDraft<Record<string, boolean>>;
19
44
  };
45
+ setParams: (st: import("immer/dist/internal").WritableDraft<{
46
+ isMobile: boolean;
47
+ params: {};
48
+ permissions: Record<string, boolean>;
49
+ }>, action: PayloadAction<Record<string, string>>) => void;
50
+ setPermission: (st: import("immer/dist/internal").WritableDraft<{
51
+ isMobile: boolean;
52
+ params: {};
53
+ permissions: Record<string, boolean>;
54
+ }>, action: PayloadAction<{
55
+ permission: string;
56
+ result: boolean;
57
+ }>) => void;
20
58
  }>;
package/dist/types.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare type State = Record<string, any>;
6
6
  * A hook that selects from redux state.
7
7
  */
8
8
  export declare type StateSelectorHook = () => State;
9
+ export declare type PermissionResults = Record<string, boolean>;
10
+ export declare type PermissionSelectorHook = (data: Data) => PermissionResults;
9
11
  /**
10
12
  * The visibility query can either be a mingo query or a function that returns a boolean. The data is an object with the router path merged with any state selector hook data.
11
13
  */
@@ -19,6 +21,8 @@ export interface Data extends Record<string, unknown> {
19
21
  };
20
22
  state: State;
21
23
  active: boolean;
24
+ permissions: PermissionResults;
25
+ id?: string;
22
26
  }
23
27
  export interface ImperiumLayoutClientModule extends ImperiumClientModule {
24
28
  layout: LayoutData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imperium/layout",
3
- "version": "8.0.0",
3
+ "version": "9.0.0",
4
4
  "description": "Imperium Layout package",
5
5
  "bugs": {
6
6
  "url": "https://github.com/darkadept/imperium/issues"
@@ -32,10 +32,11 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@imperium/client": "^8.0.0",
36
- "@imperium/router": "^8.0.0",
37
- "@imperium/state": "^8.0.0",
38
- "@thx/controls": "^15.1.1",
35
+ "@imperium/auth-client": "^9.0.0",
36
+ "@imperium/client": "^9.0.0",
37
+ "@imperium/router": "^9.0.0",
38
+ "@imperium/state": "^9.0.0",
39
+ "@thx/controls": "^15.3.0",
39
40
  "debug": "^4.3.2",
40
41
  "history": "^5.0.1",
41
42
  "lodash": "^4.17.21",
@@ -46,7 +47,7 @@
46
47
  },
47
48
  "peerDependencies": {
48
49
  "@reduxjs/toolkit": "1.x",
49
- "mingo": "4.x",
50
+ "mingo": "5.x",
50
51
  "react": "17.x",
51
52
  "react-redux": "7.x",
52
53
  "react-router-dom": "5.x"
@@ -57,5 +58,5 @@
57
58
  "publishConfig": {
58
59
  "access": "public"
59
60
  },
60
- "gitHead": "e1234231615207615a284030e54137957b9e8411"
61
+ "gitHead": "20caa1ee2b655364a23063676005f859c3dad4dc"
61
62
  }