@imperium/layout 13.0.5 → 13.0.7
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.
- package/README.md +5 -5
- package/dist/types/content/components/ActionForm.d.ts +0 -1
- package/dist/types/content/components/ActionFormSidebarItemComponent.d.ts +0 -1
- package/dist/types/content/components/ActionSidebarItemComponent.d.ts +0 -1
- package/dist/types/content/components/ContentComponent.d.ts +0 -1
- package/dist/types/content/components/CustomSidebarItemComponent.d.ts +0 -1
- package/dist/types/content/components/Header.d.ts +0 -1
- package/dist/types/content/components/PlainSidebarItem.d.ts +0 -1
- package/dist/types/content/components/SidebarItemWrapper.d.ts +0 -1
- package/dist/types/content/hooks/useBuildContentData.d.ts +1 -1
- package/dist/types/content/types.d.ts +5 -5
- package/dist/types/content/utils.d.ts +1 -2
- package/dist/types/datahooks/DataHooks.d.ts +0 -1
- package/dist/types/datahooks/PermissionHooks.d.ts +0 -1
- package/dist/types/datahooks/types.d.ts +4 -4
- package/dist/types/layout/components/CustomLayoutItemComponent.d.ts +0 -1
- package/dist/types/layout/components/DropdownItem.d.ts +0 -1
- package/dist/types/layout/components/Layout.d.ts +1 -1
- package/dist/types/layout/components/LayoutItemBar.d.ts +0 -1
- package/dist/types/layout/components/MenuItem.d.ts +0 -1
- package/dist/types/layout/components/SecondaryMenuToggleItem.d.ts +0 -1
- package/dist/types/layout/types.d.ts +3 -5
- package/dist/types/layout/utils.d.ts +1 -2
- package/dist/types/state.d.ts +1 -1
- package/dist/types/types.d.ts +6 -6
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @imperium/layout
|
|
2
2
|
|
|
3
3
|
[](assets/coverage/layout/index.html)
|
|
4
|
-
[](https://github.com/
|
|
5
|
-
[](https://github.com/
|
|
6
|
-
[](https://
|
|
4
|
+
[](https://github.com/thr-consulting/imperium/tags/)
|
|
5
|
+
[](https://github.com/thr-consulting/imperium/issues/)
|
|
6
|
+
[](https://github.com/thr-consulting/imperium/pull/)
|
|
7
7
|
|
|
8
|
-
[](https://github.com/
|
|
9
|
-
[](https://github.com/
|
|
8
|
+
[](https://github.com/thr-consulting/imperium/blob/master/LICENSE)
|
|
9
|
+
[](https://github.com/thr-consulting/imperium/graphs/contributors/)
|
|
10
10
|
|
|
11
11
|
# About
|
|
12
12
|
This is an Imperium client module providing an abstraction for page layout, menu items, and content.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { DefineRouteOptions } from '@imperium/router';
|
|
3
2
|
import type { ActionFormSidebarItem, ActionSidebarItem, ContentData, CustomSidebarItem, DividerSidebarItem, SidebarItem } from '../types';
|
|
4
3
|
interface PlainSidebarItemProps<T extends DefineRouteOptions, K extends keyof T> {
|
|
@@ -4,11 +4,11 @@ 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
6
|
import type { Data, PermissionSelectorHook, StateSelectorHook } from '../types';
|
|
7
|
-
export
|
|
7
|
+
export 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']>;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type Content<T extends DefineRouteOptions, K extends keyof T> = (data: ContentData<T, K>) => JSX.Element;
|
|
12
12
|
export interface BaseSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends WeightedItem, VisibilityItem {
|
|
13
13
|
text: string | ((data: ContentData<T, K>) => string);
|
|
14
14
|
icon?: SemanticICONS | ((data: ContentData<T, K>) => SemanticICONS);
|
|
@@ -35,14 +35,14 @@ export interface ActionFormSidebarItem<T extends DefineRouteOptions, K extends k
|
|
|
35
35
|
export interface CustomSidebarItem<T extends DefineRouteOptions, K extends keyof T> extends WeightedItem, VisibilityItem {
|
|
36
36
|
render: (data: ContentData<T, K>) => JSX.Element | null;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
38
|
+
export type SidebarItem<T extends DefineRouteOptions, K extends keyof T> = (BaseSidebarItem<T, K> & RouteItem<ContentData<T, K>>) | ActionSidebarItem<T, K> | CustomSidebarItem<T, K> | ActionFormSidebarItem<T, K> | DividerSidebarItem<T, K>;
|
|
39
39
|
export interface ContentHeaderObject {
|
|
40
40
|
title: string;
|
|
41
41
|
icon?: string;
|
|
42
42
|
size?: 'tiny' | 'small' | 'medium' | 'large' | 'huge';
|
|
43
43
|
}
|
|
44
44
|
export declare function isContentHeaderObject(value: any): value is ContentHeaderObject;
|
|
45
|
-
export
|
|
45
|
+
export type ContentHeader<T extends DefineRouteOptions, K extends keyof T> = string | ContentHeaderObject | ((data: ContentData<T, K>) => ContentHeaderObject) | JSX.Element | ((data: ContentData<T, K>) => JSX.Element) | undefined;
|
|
46
46
|
export interface Page<T extends DefineRouteOptions, K extends keyof T> {
|
|
47
47
|
dataHooks?: DataHookItem[];
|
|
48
48
|
stateSelectorHook?: StateSelectorHook | StateSelectorHook[];
|
|
@@ -52,7 +52,7 @@ export interface Page<T extends DefineRouteOptions, K extends keyof T> {
|
|
|
52
52
|
sidebar?: SidebarItem<T, K>[];
|
|
53
53
|
full?: boolean;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type Pages<T extends DefineRouteOptions> = {
|
|
56
56
|
[key in keyof T]: Page<T, key> | Content<T, key>;
|
|
57
57
|
};
|
|
58
58
|
export declare function isPage<T extends DefineRouteOptions, K extends keyof T>(value: any): value is Page<T, K>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { DefineRouteOptions } from '@imperium/router';
|
|
3
|
-
import { SemanticCOLORS } from 'semantic-ui-react';
|
|
2
|
+
import { type SemanticCOLORS } from 'semantic-ui-react';
|
|
4
3
|
import type { RouteItem } from '../commonItems';
|
|
5
4
|
import type { BaseSidebarItem, ContentData } from './types';
|
|
6
5
|
export declare function getIcon<T extends DefineRouteOptions, K extends keyof T>(item: BaseSidebarItem<T, K>, data: ContentData<T, K>): JSX.Element | null;
|
|
@@ -5,19 +5,19 @@ export interface DataHookParams {
|
|
|
5
5
|
/**
|
|
6
6
|
* A simple hook, that doesn't return anything. If used together with a route match function, the returned route parameters are passed in.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type DataHook = (params: DataHookParams) => void;
|
|
9
9
|
/**
|
|
10
10
|
* A route match function that can be used by data hooks. Usually is the @imperium/router `routes.match.x()` functions.
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type DataHookRouteMatchFn = (route: string) => any;
|
|
13
13
|
/**
|
|
14
14
|
* An object that can specify one or more data hooks that can receive route parameters from one or more route match functions.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type DataHookRoute = {
|
|
17
17
|
routeMatch: DataHookRouteMatchFn;
|
|
18
18
|
dataHook: DataHook | DataHook[];
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* A datahook can either be a simple hook, or one or more hooks dependent on one or more route match functions.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type DataHookItem = DataHook | DataHookRoute;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { SemanticICONS } from 'semantic-ui-react';
|
|
3
2
|
import type { HorizontalPositionedItem, RouteItem, VisibilityItem, WeightedItem } from '../commonItems';
|
|
4
3
|
import type { DataHookItem } from '../datahooks/types';
|
|
5
|
-
import type { Data, PermissionSelector, PermissionSelectorHook
|
|
4
|
+
import type { Data, PermissionSelector, PermissionSelectorHook } from '../types';
|
|
6
5
|
/**
|
|
7
6
|
* Describes a basic weighted, possibly visible item
|
|
8
7
|
*/
|
|
9
8
|
export interface BaseLayoutItem extends WeightedItem, VisibilityItem {
|
|
10
|
-
text
|
|
9
|
+
text?: string | ((data: Data) => string);
|
|
11
10
|
icon?: SemanticICONS | ((data: Data) => SemanticICONS);
|
|
12
11
|
moveToKey?: string;
|
|
13
12
|
}
|
|
@@ -32,10 +31,9 @@ export interface MenuLayoutItem extends BaseLayoutItem {
|
|
|
32
31
|
/**
|
|
33
32
|
* Describes a horizontal menu item which is either a route item or dropdown menu
|
|
34
33
|
*/
|
|
35
|
-
export
|
|
34
|
+
export type LayoutItem = (BaseLayoutItem & RouteItem<Data>) | DropdownLayoutItem | MenuLayoutItem | CustomLayoutItem;
|
|
36
35
|
export interface LayoutData {
|
|
37
36
|
permissionSelectorHooks?: PermissionSelectorHook[];
|
|
38
|
-
stateSelectorHooks?: StateSelectorHook[];
|
|
39
37
|
permissions?: PermissionSelector;
|
|
40
38
|
dataHooks?: DataHookItem[];
|
|
41
39
|
primaryMenu?: (LayoutItem & HorizontalPositionedItem)[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Link } from 'react-router-dom';
|
|
3
2
|
import type { RouteItem } from '../commonItems';
|
|
4
3
|
import type { Data } from '../types';
|
|
@@ -20,5 +19,5 @@ export declare function linkParameters(item: BaseLayoutItem & RouteItem<Data>, d
|
|
|
20
19
|
active?: undefined;
|
|
21
20
|
to?: undefined;
|
|
22
21
|
};
|
|
23
|
-
export declare function getText(item: BaseLayoutItem, data: Data): string;
|
|
22
|
+
export declare function getText(item: BaseLayoutItem, data: Data): string | undefined;
|
|
24
23
|
export declare function getIcon(item: BaseLayoutItem, data: Data): JSX.Element | null;
|
package/dist/types/state.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { ImperiumClientModule } from '@imperium/client';
|
|
2
2
|
import type { Location } from 'history';
|
|
3
3
|
import type { LayoutData } from './layout/types';
|
|
4
|
-
export
|
|
4
|
+
export type State = Record<string, any>;
|
|
5
5
|
/**
|
|
6
6
|
* A hook that selects from redux state.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
8
|
+
export type StateSelectorHook = () => State;
|
|
9
|
+
export type PermissionResults = Record<string, boolean>;
|
|
10
|
+
export type PermissionSelectorHook = (data: Data) => PermissionResults;
|
|
11
|
+
export type PermissionSelector = string[];
|
|
12
12
|
/**
|
|
13
13
|
* 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.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type VisibilityQueryFn = (data: Data) => boolean;
|
|
16
16
|
export interface Data extends Record<string, unknown> {
|
|
17
17
|
loc: Location;
|
|
18
18
|
route: {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imperium/layout",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.7",
|
|
4
4
|
"description": "Imperium Layout package",
|
|
5
5
|
"bugs": {
|
|
6
|
-
"url": "https://github.com/
|
|
6
|
+
"url": "https://github.com/thr-consulting/imperium/issues"
|
|
7
7
|
},
|
|
8
8
|
"repository": "darkadept/imperium",
|
|
9
9
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@imperium/auth-client": "^13.0.
|
|
35
|
-
"@imperium/client": "^13.0.
|
|
36
|
-
"@imperium/router": "^13.0.
|
|
37
|
-
"@imperium/state": "^13.0.
|
|
34
|
+
"@imperium/auth-client": "^13.0.7",
|
|
35
|
+
"@imperium/client": "^13.0.7",
|
|
36
|
+
"@imperium/router": "^13.0.7",
|
|
37
|
+
"@imperium/state": "^13.0.7",
|
|
38
38
|
"@thx/controls": "^17.0.1",
|
|
39
39
|
"debug": "^4.4.0",
|
|
40
40
|
"history": "^5.0.1",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "baf0440e1d1f0b95cfd0f5ea7753845aab2aa489"
|
|
64
64
|
}
|