@imperium/layout 7.3.3 → 8.3.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.
Files changed (34) hide show
  1. package/README.md +0 -349
  2. package/dist/client.js +535 -325
  3. package/dist/client.min.js +1 -1
  4. package/dist/client.min.js.map +1 -1
  5. package/dist/commonItems.d.ts +2 -1
  6. package/dist/content/hooks/useBuildContentData.d.ts +3 -1
  7. package/dist/content/types.d.ts +2 -1
  8. package/dist/datahooks/DataHooks.d.ts +1 -1
  9. package/dist/datahooks/ExecutePermissionHook.d.ts +7 -0
  10. package/dist/datahooks/PermissionHooks.d.ts +7 -0
  11. package/dist/datahooks/types.d.ts +1 -1
  12. package/dist/hooks/useBuildData.d.ts +3 -2
  13. package/dist/hooks/useSelectPermission.d.ts +2 -0
  14. package/dist/layout/components/LayoutItemWrapper.d.ts +2 -2
  15. package/dist/layout/components/PlainItem.d.ts +2 -2
  16. package/dist/layout/types.d.ts +2 -1
  17. package/dist/state.d.ts +38 -0
  18. package/dist/types.d.ts +4 -0
  19. package/package.json +7 -6
  20. package/dist/content/components/ActionLinkSidebarItemComponent.d.ts +0 -9
  21. package/dist/content/components/ContentItemWrapper.d.ts +0 -12
  22. package/dist/content/components/dividerSidebarItem.d.ts +0 -2
  23. package/dist/hooks/DataHooks.d.ts +0 -12
  24. package/dist/hooks/ExecuteDataHook.d.ts +0 -7
  25. package/dist/hooks/types.d.ts +0 -19
  26. package/dist/layout/components/CustomItem.d.ts +0 -7
  27. package/dist/layout/components/CustomItemComponent.d.ts +0 -7
  28. package/dist/layout/components/ItemBar.d.ts +0 -15
  29. package/dist/layout/components/ItemWrapper.d.ts +0 -19
  30. package/dist/layout/components/SidebarToggleMenuItem.d.ts +0 -7
  31. package/dist/layout/hooks/useBuildData.d.ts +0 -3
  32. package/dist/layout/hooks/useIsActiveRoute.d.ts +0 -2
  33. package/dist/layout/hooks/useSelectState.d.ts +0 -2
  34. package/dist/layout/mergeItems.d.ts +0 -2
@@ -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": "7.3.3",
3
+ "version": "8.3.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": "^7.1.0",
36
- "@imperium/router": "^7.3.0",
37
- "@imperium/state": "^7.3.0",
38
- "@thx/controls": "^14.2.0",
35
+ "@imperium/auth-client": "^8.3.0",
36
+ "@imperium/client": "^8.3.0",
37
+ "@imperium/router": "^8.3.0",
38
+ "@imperium/state": "^8.3.0",
39
+ "@thx/controls": "^15.1.1",
39
40
  "debug": "^4.3.2",
40
41
  "history": "^5.0.1",
41
42
  "lodash": "^4.17.21",
@@ -57,5 +58,5 @@
57
58
  "publishConfig": {
58
59
  "access": "public"
59
60
  },
60
- "gitHead": "bc48db7ffd908835b9a06dedc0d5b7e1470799c8"
61
+ "gitHead": "8aae7cb8dde6e416f79a614bdf7f57101c2946e0"
61
62
  }
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import type { DefineRouteOptions } from '@imperium/router';
3
- import type { BaseSidebarItem, ContentData } from '../types';
4
- interface ActionLinkSidebarItemProps<T extends DefineRouteOptions, K extends keyof T> {
5
- item: BaseSidebarItem<T, K>;
6
- data: ContentData<T, K>;
7
- }
8
- export declare function ActionLinkSidebarItemComponent<T extends DefineRouteOptions, K extends keyof T>({ item, data }: ActionLinkSidebarItemProps<T, K>): JSX.Element;
9
- export {};
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import type { DefineRouteOptions } from '@imperium/router';
3
- import type { ContentData, RouteParameters, SidebarItem } from '../types';
4
- interface ContentItemWrapperProps<T extends DefineRouteOptions, K extends keyof T> {
5
- item: SidebarItem<T, K>;
6
- as?: React.ComponentClass;
7
- vertical?: boolean;
8
- data?: ContentData<T, K>;
9
- params: RouteParameters<T[K]['params']>;
10
- }
11
- export declare function ContentItemWrapper<T extends DefineRouteOptions, K extends keyof T>({ item, data: parentData, params }: ContentItemWrapperProps<T, K>): JSX.Element | null;
12
- export {};
@@ -1,2 +0,0 @@
1
- import type { DividerSidebarItem } from '../types';
2
- export declare const dividerSidebarItem: DividerSidebarItem<any, any>;
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import type { DataHookItem } from './types';
3
- interface DataHooksProps {
4
- dataHooks: DataHookItem[];
5
- }
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.
8
- * @param dataHooks
9
- * @constructor
10
- */
11
- export declare function DataHooks({ dataHooks }: DataHooksProps): JSX.Element;
12
- export {};
@@ -1,7 +0,0 @@
1
- import type { DataHook } from './types';
2
- interface ExecuteDataHookProps {
3
- dataHook: DataHook;
4
- routeParams?: any;
5
- }
6
- export declare function ExecuteDataHook({ dataHook, routeParams }: ExecuteDataHookProps): null;
7
- export {};
@@ -1,19 +0,0 @@
1
- /**
2
- * A simple hook, that doesn't return anything. If used together with a route match function, the returned route parameters are passed in.
3
- */
4
- export declare type DataHook = (routeParams?: any) => void;
5
- /**
6
- * A route match function that can be used by data hooks. Usually is the @imperium/router `routes.match.x()` functions.
7
- */
8
- export declare type DataHookRouteMatchFn = (route: string) => any;
9
- /**
10
- * An object that can specify one or more data hooks that can receive route parameters from one or more route match functions.
11
- */
12
- export declare type DataHookRoute = {
13
- routeMatch: DataHookRouteMatchFn | DataHookRouteMatchFn[];
14
- dataHook: DataHook | DataHook[];
15
- };
16
- /**
17
- * A datahook can either be a simple hook, or one or more hooks dependant on one or more route match functions.
18
- */
19
- export declare type DataHookItem = DataHook | DataHookRoute;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import type { CustomItem } from '../../commonItems';
3
- interface CustomItemComponentProps {
4
- item: CustomItem;
5
- }
6
- export declare function CustomItemComponent({ item }: CustomItemComponentProps): JSX.Element | null;
7
- export {};
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import type { CustomLayoutItem } from '../types';
3
- interface CustomItemComponentProps {
4
- item: CustomLayoutItem;
5
- }
6
- export declare function CustomItemComponent({ item }: CustomItemComponentProps): JSX.Element | null;
7
- export {};
@@ -1,15 +0,0 @@
1
- /// <reference types="react" />
2
- import type { MenuProps } from 'semantic-ui-react';
3
- import type { LayoutItem } from '../types';
4
- interface ItemBarProps extends MenuProps {
5
- items: LayoutItem[];
6
- }
7
- /**
8
- * Renders a horizontal or vertical bar of menu items.
9
- * @param name
10
- * @param items
11
- * @param rest
12
- * @constructor
13
- */
14
- export declare function ItemBar({ items, ...rest }: ItemBarProps): JSX.Element;
15
- export {};
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import type { LayoutItem } from '../types';
3
- import type { Data } from '../../types';
4
- interface ItemWrapperProps {
5
- item: LayoutItem;
6
- as?: React.ComponentClass;
7
- vertical?: boolean;
8
- data?: Data;
9
- }
10
- /**
11
- * Renders any type of Item. Gathers state, route and other data and checks for visibility.
12
- * @param item
13
- * @param as
14
- * @param vertical
15
- * @param parentData
16
- * @constructor
17
- */
18
- export declare function ItemWrapper({ item, as, vertical, data: parentData }: ItemWrapperProps): JSX.Element | null;
19
- export {};
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- interface SidebarToggleMenuItemProps {
3
- menuOpen: boolean;
4
- setMenuOpen: (open: boolean) => void;
5
- }
6
- export declare function SidebarToggleMenuItem({ menuOpen, setMenuOpen }: SidebarToggleMenuItemProps): JSX.Element;
7
- export {};
@@ -1,3 +0,0 @@
1
- import type { LayoutItem } from '../types';
2
- import type { Data } from '../../types';
3
- export declare function useBuildData(item: LayoutItem, data?: Data): Data;
@@ -1,2 +0,0 @@
1
- import type { Data } from '../../types';
2
- export declare function useIsActiveRoute(data: Data, item?: any): boolean;
@@ -1,2 +0,0 @@
1
- import type { StateSelectorHook } from '../../types';
2
- export declare function useSelectState(stateSelectorHook?: StateSelectorHook | StateSelectorHook[]): any;
@@ -1,2 +0,0 @@
1
- import type { LayoutItem } from './types';
2
- export declare function mergeItems(items: LayoutItem[]): LayoutItem[];