@tenorlab/react-dashboard 1.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.
- package/README.md +44 -0
- package/dist/components/DashboardGrid.d.ts +2 -0
- package/dist/components/DashboardWidgetBase.d.ts +4 -0
- package/dist/components/DynamicWidgetLoader.d.ts +23 -0
- package/dist/components/WidgetContainer.d.ts +4 -0
- package/dist/components/WidgetsCatalogFlyout.d.ts +14 -0
- package/dist/components/dashboard-primitives/Buttons.d.ts +2 -0
- package/dist/components/dashboard-primitives/DraggablePanel.d.ts +10 -0
- package/dist/components/dashboard-primitives/ListItem.d.ts +14 -0
- package/dist/components/dashboard-primitives/Stack.d.ts +9 -0
- package/dist/components/dashboard-primitives/TextField.d.ts +6 -0
- package/dist/components/dashboard-primitives/color-utils.d.ts +12 -0
- package/dist/components/dashboard-primitives/css-vars-utils.d.ts +6 -0
- package/dist/components/dashboard-primitives/icons/index.d.ts +29 -0
- package/dist/components/dashboard-primitives/index.d.ts +12 -0
- package/dist/components/dashboard-primitives/interfaces.d.ts +46 -0
- package/dist/components/dashboard-primitives/parse-container-title.d.ts +2 -0
- package/dist/components/dashboard-primitives/use-distinct-css-classes.d.ts +1 -0
- package/dist/components/dashboard-settings/dashboard-settings-utils.d.ts +4 -0
- package/dist/components/dashboard-settings/dashboard-settings.d.ts +2 -0
- package/dist/components/dashboard-settings/index.d.ts +2 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/interfaces/core-react.interfaces.d.ts +20 -0
- package/dist/components/interfaces/core.base.d.ts +62 -0
- package/dist/components/interfaces/core.interfaces.d.ts +40 -0
- package/dist/components/interfaces/core.utils.d.ts +28 -0
- package/dist/components/interfaces/index.d.ts +7 -0
- package/dist/components/interfaces/storage-service.interfaces.d.ts +7 -0
- package/dist/components/use-dashboard-storage-service.d.ts +2 -0
- package/dist/components/use-dashboard-store.d.ts +33 -0
- package/dist/components/use-dashboard-undo-service.d.ts +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/react-dashboard.es.js +3146 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @tenorlab/react-dashboard
|
|
2
|
+
|
|
3
|
+
Foundation components for creating user-configurable, high-performance dashboards in React.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### Part of the Built With JavaScript Ecosystem
|
|
8
|
+
**Tenorlab** is the specialized software foundry for the [@builtwithjavascript](https://github.com/builtwithjavascript) ecosystem, focusing on modular, type-safe utilities and UI kits.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Quick Start
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
Install the package via npm or pnpm:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @tenorlab/react-dashboard
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @tenorlab/react-dashboard
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Basic Usage
|
|
25
|
+
TODO
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- **Type-Safe:** Built with TypeScript for excellent IDE support and error catching.
|
|
31
|
+
- **Configurable:** Allow end-users to add/remove widgets.
|
|
32
|
+
- **Vite Optimized:** Tree-shakeable and lightweight for modern build pipelines.
|
|
33
|
+
- **Themeable:** Easy integration with Tailwind CSS or CSS Variables.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Licensing
|
|
38
|
+
|
|
39
|
+
This project is dual-licensed:
|
|
40
|
+
|
|
41
|
+
1. **Non-Commercial / Personal Use:** Licensed under the [Polyform Non-Commercial 1.0.0](https://polyformproject.org/licenses/non-commercial/1.0.0/). Free to use for students, hobbyists, and open-source projects.
|
|
42
|
+
2. **Commercial Use:** Requires a **Tenorlab Commercial License**.
|
|
43
|
+
|
|
44
|
+
If you are using this library to build a product that generates revenue, or within a commercial entity, please visit [tenorlab.com/license](https://tenorlab.com/license) to purchase a commercial seat.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IChildWidgetConfigEntry, TDashboardWidgetCatalog, TDashboardWidgetKey } from './interfaces';
|
|
2
|
+
type TDynamicWidgetLoaderProps = {
|
|
3
|
+
index: number;
|
|
4
|
+
maxIndex: number;
|
|
5
|
+
widgetKey: TDashboardWidgetKey;
|
|
6
|
+
parentWidgetKey?: TDashboardWidgetKey;
|
|
7
|
+
targetContainerKey?: TDashboardWidgetKey;
|
|
8
|
+
childWidgetsConfig?: IChildWidgetConfigEntry[];
|
|
9
|
+
widgetCatalog: TDashboardWidgetCatalog;
|
|
10
|
+
isEditing: boolean;
|
|
11
|
+
onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
|
|
12
|
+
onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
|
|
13
|
+
selectContainer?: (containerKey: TDashboardWidgetKey) => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Component to safely load and render dynamic widgets.
|
|
17
|
+
* This ensures the widget component (and its hooks) is called consistently.
|
|
18
|
+
* @param {object} props
|
|
19
|
+
* @param {string} props.widgetKey
|
|
20
|
+
* @param {(key: string) => Promise<void>} props.onRemoveClick
|
|
21
|
+
*/
|
|
22
|
+
export declare function DynamicWidgetLoader({ index, maxIndex, widgetKey, parentWidgetKey, targetContainerKey, childWidgetsConfig, widgetCatalog, isEditing, onRemoveClick, onMoveClick, selectContainer, }: TDynamicWidgetLoaderProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IDashboardWidgetProps, IDashboardWidget } from './interfaces';
|
|
2
|
+
export declare function WidgetContainerColumn(props: IDashboardWidgetProps): IDashboardWidget;
|
|
3
|
+
export declare function WidgetContainerLarge(props: IDashboardWidgetProps): IDashboardWidget;
|
|
4
|
+
export declare function WidgetContainerRow(props: IDashboardWidgetProps): IDashboardWidget;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IDashboardConfig, IDashboardSettingEntry, TDashboardUndoStatus, TDashboardWidgetCatalog, TDashboardWidgetKey } from './interfaces/';
|
|
2
|
+
export type TWidgetsCatalogFlyoutProps = {
|
|
3
|
+
targetContainerKey?: TDashboardWidgetKey;
|
|
4
|
+
widgetsCatalog: TDashboardWidgetCatalog;
|
|
5
|
+
currentDashboardConfig: IDashboardConfig;
|
|
6
|
+
undoStatus: TDashboardUndoStatus;
|
|
7
|
+
addWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => any;
|
|
8
|
+
addContainer: (widgetKey: TDashboardWidgetKey) => any;
|
|
9
|
+
onSettingItemsUpdated: (items: IDashboardSettingEntry[]) => any;
|
|
10
|
+
onResetToDefaultDashboardClick: () => any;
|
|
11
|
+
onUndoOrRedo: (operation: 'Undo' | 'Redo') => any;
|
|
12
|
+
onDoneClick: () => any;
|
|
13
|
+
};
|
|
14
|
+
export declare function WidgetsCatalogFlyout({ targetContainerKey, widgetsCatalog, currentDashboardConfig, undoStatus, addWidget, addContainer, onSettingItemsUpdated, onResetToDefaultDashboardClick, onUndoOrRedo, onDoneClick, }: TWidgetsCatalogFlyoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
type DraggablePanelProps = {
|
|
3
|
+
testId?: string;
|
|
4
|
+
className: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
onDraggingChange?: (isDragging: boolean) => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare const DraggablePanel: import("react").ForwardRefExoticComponent<DraggablePanelProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TStackProps } from './Stack';
|
|
3
|
+
export declare const ListItem: import("react").ForwardRefExoticComponent<TStackProps & {
|
|
4
|
+
innerClass?: string;
|
|
5
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
6
|
+
type TListItemChildProps = {
|
|
7
|
+
testId?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const ListItemLeftChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export declare const ListItemMiddleChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export declare const ListItemRightChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export type TStackProps = {
|
|
3
|
+
testId?: string;
|
|
4
|
+
classNames?: string;
|
|
5
|
+
direction?: 'row' | 'column';
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function Stack(props: TStackProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
|
|
2
|
+
export declare const resolvedColors: {
|
|
3
|
+
primary: string;
|
|
4
|
+
secondary: string;
|
|
5
|
+
success: string;
|
|
6
|
+
danger: string;
|
|
7
|
+
warning: string;
|
|
8
|
+
info: string;
|
|
9
|
+
disabled: string;
|
|
10
|
+
neutral: string;
|
|
11
|
+
body: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IDashboardSettingEntry } from '../interfaces';
|
|
2
|
+
export declare const cssVarsUtils: {
|
|
3
|
+
getCssVariableValue: (cssPropertyName: string) => string | null;
|
|
4
|
+
setCssVariableValue: (cssPropertyName: string, value: string) => void;
|
|
5
|
+
restoreCssVarsFromSettings: (settings: IDashboardSettingEntry[]) => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare function SvgBaseWrapper({ children, className, }: {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
className?: string;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
type TIconProps = {
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function AddIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function DeleteIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function EditIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function GridIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function MonitorIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function MonitorSmartphoneIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function MoveLeftIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function MoveRightIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function SettingsIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare function TabletSmartphoneIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function XCircleIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function ZoomInIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export declare function ZoomOutIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function TimerResetIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function UndoIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function RedoIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function HandIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function HandGrabIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function CrosshairIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function TargetIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare function CircleQuestionMark({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
2
|
+
export * from './icons';
|
|
3
|
+
export * from './use-distinct-css-classes';
|
|
4
|
+
export * from './color-utils';
|
|
5
|
+
export * from './css-vars-utils';
|
|
6
|
+
export * from './parse-container-title';
|
|
7
|
+
export * from './TextField';
|
|
8
|
+
export * from './Buttons';
|
|
9
|
+
export * from './Stack';
|
|
10
|
+
export * from './ListItem';
|
|
11
|
+
export * from './DraggablePanel';
|
|
12
|
+
export declare const showToast: (options: any) => void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface ITooltipProps {
|
|
2
|
+
placement: string;
|
|
3
|
+
title: string;
|
|
4
|
+
}
|
|
5
|
+
export type TButtonType = 'normal' | 'ghost';
|
|
6
|
+
export type TButtonJustifyCss = 'justify-start' | 'justify-center' | 'justify-end';
|
|
7
|
+
export interface IButtonProps {
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
tooltip?: ITooltipProps;
|
|
11
|
+
isIconButton?: boolean;
|
|
12
|
+
buttonType?: TButtonType;
|
|
13
|
+
category?: string;
|
|
14
|
+
font?: string;
|
|
15
|
+
border?: number;
|
|
16
|
+
borderHover?: number;
|
|
17
|
+
borderColor?: string;
|
|
18
|
+
px?: number;
|
|
19
|
+
py?: number;
|
|
20
|
+
justifyCss?: TButtonJustifyCss;
|
|
21
|
+
shadow?: string;
|
|
22
|
+
shadowHover?: string;
|
|
23
|
+
addCss?: string;
|
|
24
|
+
onClick: () => any;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export interface ITooltipProps {
|
|
28
|
+
placement: string;
|
|
29
|
+
title: string;
|
|
30
|
+
}
|
|
31
|
+
export interface IButtonProps {
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
className?: string;
|
|
34
|
+
tooltip?: ITooltipProps;
|
|
35
|
+
}
|
|
36
|
+
type TSize = 'small' | 'medium';
|
|
37
|
+
export interface ITextFieldProps {
|
|
38
|
+
label: string;
|
|
39
|
+
size?: TSize;
|
|
40
|
+
value: string;
|
|
41
|
+
className?: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
44
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDistinctCssClasses: (defaultClasses: string, ...additionalClasses: string[]) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './interfaces';
|
|
2
|
+
export * from './dashboard-settings';
|
|
3
|
+
export * from './use-dashboard-store';
|
|
4
|
+
export * from './use-dashboard-storage-service';
|
|
5
|
+
export * from './use-dashboard-undo-service';
|
|
6
|
+
export * from './dashboard-primitives/';
|
|
7
|
+
export * from './DashboardGrid';
|
|
8
|
+
export * from './DynamicWidgetLoader';
|
|
9
|
+
export * from './DashboardWidgetBase';
|
|
10
|
+
export * from './WidgetContainer';
|
|
11
|
+
export * from './WidgetsCatalogFlyout';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TDashboardWidgetKey, TWidgetMetaInfoBase, IDashboardWidgetPropsBase, IDashboardGridPropsBase, TWidgetFactoryBase, IDynamicWidgetCatalogEntryBase } from './core.base';
|
|
2
|
+
import type { ReactNode, ElementType, JSX } from 'react';
|
|
3
|
+
export type TWidgetMetaInfo = TWidgetMetaInfoBase<ElementType | undefined>;
|
|
4
|
+
export interface IDashboardGridProps extends IDashboardGridPropsBase {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export interface IDashboardWidgetProps extends IDashboardWidgetPropsBase {
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
|
|
10
|
+
onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
|
|
11
|
+
selectContainer?: (containerKey?: TDashboardWidgetKey) => void;
|
|
12
|
+
}
|
|
13
|
+
export interface IDashboardWidget extends JSX.Element {
|
|
14
|
+
}
|
|
15
|
+
type TFrameworkComponentType = React.ComponentType<any>;
|
|
16
|
+
export type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
|
|
17
|
+
export interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TWidgetMetaInfo, TWidgetFactory, TFrameworkComponentType> {
|
|
18
|
+
}
|
|
19
|
+
export type TDashboardWidgetCatalog = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntry>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type TDashboardWidgetKey = string;
|
|
2
|
+
export type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
3
|
+
export type TWidgetMetaInfoBase<T> = {
|
|
4
|
+
displayName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
categories: TWidgetCategory[];
|
|
7
|
+
noDuplicatedWidgets?: boolean;
|
|
8
|
+
icon: T | undefined;
|
|
9
|
+
};
|
|
10
|
+
export interface IDashboardGridPropsBase {
|
|
11
|
+
isEditing: boolean;
|
|
12
|
+
zoomScale: number;
|
|
13
|
+
responsiveGrid: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type TWidgetSize = 'default' | 'large' | 'xlarge';
|
|
16
|
+
export type TWidgetDirection = 'row' | 'column';
|
|
17
|
+
export interface IDashboardWidgetPropsBase {
|
|
18
|
+
index: number;
|
|
19
|
+
maxIndex: number;
|
|
20
|
+
widgetKey: TDashboardWidgetKey;
|
|
21
|
+
parentWidgetKey?: TDashboardWidgetKey;
|
|
22
|
+
isEditing: boolean;
|
|
23
|
+
highlight?: boolean;
|
|
24
|
+
testId?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
size?: TWidgetSize;
|
|
27
|
+
borderCssClasses?: string;
|
|
28
|
+
backgroundCssClasses?: string;
|
|
29
|
+
hideTitle?: boolean;
|
|
30
|
+
noShadow?: boolean;
|
|
31
|
+
noBorder?: boolean;
|
|
32
|
+
noPadding?: boolean;
|
|
33
|
+
direction?: TWidgetDirection;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 1. Define the Async Loader type
|
|
37
|
+
* Type for the function that performs the asynchronous dynamic import.
|
|
38
|
+
* It must return a promise that resolves to the module containing the widget component
|
|
39
|
+
* as its default export (or a named export if you change the loading strategy).
|
|
40
|
+
*
|
|
41
|
+
* T could be "React.ComponentType<any>"" or "VueComponent" etc
|
|
42
|
+
*/
|
|
43
|
+
export type TWidgetFactoryBase<T> = () => Promise<{
|
|
44
|
+
default: T;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* 2. Define the flexible Catalog Entry
|
|
48
|
+
* Definition of a single widget or container in the catalog.
|
|
49
|
+
* It must have EITHER a direct 'component' reference OR a 'loader' function.
|
|
50
|
+
*
|
|
51
|
+
* TWidgetMetaInfo: see TWidgetMetaInfoBase
|
|
52
|
+
* TWidgetFactory: see TWidgetFactoryBase
|
|
53
|
+
* TComponent: i.e. React.ComponentType<any>
|
|
54
|
+
*/
|
|
55
|
+
export interface IDynamicWidgetCatalogEntryBase<TMeta, TFactory, TComponent> {
|
|
56
|
+
key: TDashboardWidgetKey;
|
|
57
|
+
title: string;
|
|
58
|
+
isContainer?: boolean;
|
|
59
|
+
meta?: TMeta;
|
|
60
|
+
component?: TComponent;
|
|
61
|
+
loader?: TFactory;
|
|
62
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export * from './core-react.interfaces';
|
|
2
|
+
import type { TDashboardWidgetKey } from './core.base';
|
|
3
|
+
export interface IChildWidgetConfigEntry {
|
|
4
|
+
parentWidgetKey: TDashboardWidgetKey;
|
|
5
|
+
widgetKey: TDashboardWidgetKey;
|
|
6
|
+
}
|
|
7
|
+
export interface IDashboardSettingEntry {
|
|
8
|
+
key: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
description: string;
|
|
11
|
+
cssProperty: string;
|
|
12
|
+
step: number;
|
|
13
|
+
defaultUnit: string;
|
|
14
|
+
minValue: number;
|
|
15
|
+
defaultValue: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IDashboardConfig {
|
|
19
|
+
userID: number | string;
|
|
20
|
+
clientAppKey: string;
|
|
21
|
+
dashboardId: string;
|
|
22
|
+
dashboardName: string;
|
|
23
|
+
zoomScale: number;
|
|
24
|
+
responsiveGrid: boolean;
|
|
25
|
+
widgets: TDashboardWidgetKey[];
|
|
26
|
+
childWidgetsConfig: IChildWidgetConfigEntry[];
|
|
27
|
+
cssSettings: IDashboardSettingEntry[];
|
|
28
|
+
_version?: number;
|
|
29
|
+
_stateDescription?: string;
|
|
30
|
+
}
|
|
31
|
+
export type TUndoHistoryEntry = {
|
|
32
|
+
undoIndex: number;
|
|
33
|
+
config: IDashboardConfig;
|
|
34
|
+
};
|
|
35
|
+
export type TDashboardUndoStatus = {
|
|
36
|
+
isUndoDisabled: boolean;
|
|
37
|
+
isRedoDisabled: boolean;
|
|
38
|
+
_currentIndex?: number;
|
|
39
|
+
_historyLength?: number;
|
|
40
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TDashboardWidgetKey } from './core.base';
|
|
2
|
+
import type { IDashboardConfig, TWidgetMetaInfo, TDashboardWidgetCatalog } from './core.interfaces';
|
|
3
|
+
export declare const blankDashboardConfig: IDashboardConfig;
|
|
4
|
+
export declare const DashboardMinZoomScale: 0.7;
|
|
5
|
+
export declare const DashboardMaxZoomScale: 1;
|
|
6
|
+
export declare const DashboardZoomStep: 0.05;
|
|
7
|
+
export declare const ensureZoomScaleIsWithinRange: (value: number) => number;
|
|
8
|
+
export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, direction: -1 | 1) => number;
|
|
9
|
+
/**
|
|
10
|
+
* @name getDefaultWidgetMetaFromMap
|
|
11
|
+
* @description Helper to get widget meta info from the catalog by key.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getDefaultWidgetMetaFromMap: (widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfo>, options?: {
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}) => TWidgetMetaInfo;
|
|
17
|
+
/**
|
|
18
|
+
* @name getWidgetMetaFromCatalog
|
|
19
|
+
* @description Helper to get widget meta info from the catalog by key.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getWidgetMetaFromCatalog: (widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalog) => TWidgetMetaInfo;
|
|
22
|
+
export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
23
|
+
/**
|
|
24
|
+
* @name ensureContainersSequence
|
|
25
|
+
* @description
|
|
26
|
+
* Ensures that the container widgets are numbered sequentially in the dashboardConfig, but the original order is preserved.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ensureContainersSequence: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './core.base';
|
|
2
|
+
export * from './core.interfaces';
|
|
3
|
+
export * from './storage-service.interfaces';
|
|
4
|
+
export * from './core.utils';
|
|
5
|
+
import type { TDashboardWidgetKey } from './core.base';
|
|
6
|
+
import type { IDynamicWidgetCatalogEntry } from './core-react.interfaces';
|
|
7
|
+
export type TDashboardWidgetCatalog = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntry>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TDashboardWidgetCatalog, IDashboardConfig } from './core.interfaces';
|
|
2
|
+
export type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalog, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
3
|
+
export type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalog) => Promise<boolean>;
|
|
4
|
+
export interface IDashboardStorageService {
|
|
5
|
+
getSavedDashboards: TGetSavedDashboards;
|
|
6
|
+
saveDashboards: TSaveDashboards;
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IDashboardConfig, TDashboardWidgetKey } from './interfaces';
|
|
2
|
+
type TAddWidgetResponse = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message?: string;
|
|
5
|
+
updatedDashboardConfig: IDashboardConfig;
|
|
6
|
+
allUpdatedDashboardConfigs: IDashboardConfig[];
|
|
7
|
+
};
|
|
8
|
+
type TRemoveWidgetResponse = TAddWidgetResponse;
|
|
9
|
+
type TDashboardSlice = {
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
isEditing: boolean;
|
|
12
|
+
allDashboardConfigs: IDashboardConfig[];
|
|
13
|
+
currentDashboardConfig: IDashboardConfig;
|
|
14
|
+
targetContainerKey?: TDashboardWidgetKey | undefined;
|
|
15
|
+
getNextContainerKey: (containerWidgetKey: TDashboardWidgetKey) => TDashboardWidgetKey;
|
|
16
|
+
setIsLoading: (value: boolean) => boolean;
|
|
17
|
+
setIsEditing: (value: boolean) => boolean;
|
|
18
|
+
setTargetContainerKey: (value: TDashboardWidgetKey | undefined) => TDashboardWidgetKey | undefined;
|
|
19
|
+
setAllDashboardConfigs: (value: IDashboardConfig[]) => IDashboardConfig[];
|
|
20
|
+
setCurrentDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
|
|
21
|
+
addDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
|
|
22
|
+
deleteDashboardConfigById: (value: string) => IDashboardConfig[];
|
|
23
|
+
selectDashboardById: (dashboardId: string) => IDashboardConfig | undefined;
|
|
24
|
+
addWidget: (params: {
|
|
25
|
+
widgetKey: TDashboardWidgetKey;
|
|
26
|
+
parentWidgetKey?: TDashboardWidgetKey;
|
|
27
|
+
noDuplicatedWidgets?: boolean;
|
|
28
|
+
}) => TAddWidgetResponse;
|
|
29
|
+
removeWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
|
|
30
|
+
moveWidget: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
|
|
31
|
+
};
|
|
32
|
+
export declare const useDashboardStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TDashboardSlice>>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IDashboardConfig, TUndoHistoryEntry, TDashboardUndoStatus } from './interfaces';
|
|
2
|
+
export declare const useDashboardUndoService: () => {
|
|
3
|
+
initializeHistoryForDashboard: (initialConfig: IDashboardConfig) => void;
|
|
4
|
+
resetAllHistory: () => void;
|
|
5
|
+
addUndoEntry: (newConfig: IDashboardConfig) => void;
|
|
6
|
+
removeUndoHistoryForDashboard: (dashboardId: string) => void;
|
|
7
|
+
undo: (currentDashboardId: string) => void;
|
|
8
|
+
redo: (currentDashboardId: string) => void;
|
|
9
|
+
getUndoStatus: (currentDashboardId: string) => TDashboardUndoStatus;
|
|
10
|
+
undoHistory: Record<string, TUndoHistoryEntry[]>;
|
|
11
|
+
historyIndex: Record<string, number>;
|
|
12
|
+
};
|
|
13
|
+
export type TDashboardUndoService = ReturnType<typeof useDashboardUndoService>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/';
|