@tenorlab/react-dashboard 1.0.1 → 1.0.2

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 CHANGED
@@ -22,7 +22,12 @@ pnpm add @tenorlab/react-dashboard
22
22
  ```
23
23
 
24
24
  ## Basic Usage
25
- TODO
25
+ Import the styles in your entry tsx file (usually main.tsx):
26
+ ```typescript
27
+ import '@tenorlab/react-dashboard/styles.css'
28
+ ```
29
+
30
+ TODO:
26
31
 
27
32
 
28
33
  ## Features
@@ -1,2 +1,2 @@
1
- import { IDashboardGridProps } from './interfaces';
1
+ import type { IDashboardGridProps } from './interfaces/core-react.interfaces';
2
2
  export declare const DashboardGrid: import("react").ForwardRefExoticComponent<IDashboardGridProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- import { IDashboardWidgetProps } from './interfaces';
1
+ import type { IDashboardWidgetProps } from './interfaces/core-react.interfaces';
2
2
  export declare const DashboardWidgetBase: (props: IDashboardWidgetProps & {
3
3
  ref?: React.ForwardedRef<HTMLDivElement>;
4
4
  }) => React.ReactElement | null;
@@ -1,4 +1,4 @@
1
- import { IDashboardWidgetProps, IDashboardWidget } from './interfaces';
1
+ import type { IDashboardWidgetProps, IDashboardWidget } from './interfaces/core-react.interfaces';
2
2
  export declare function WidgetContainerColumn(props: IDashboardWidgetProps): IDashboardWidget;
3
3
  export declare function WidgetContainerLarge(props: IDashboardWidgetProps): IDashboardWidget;
4
4
  export declare function WidgetContainerRow(props: IDashboardWidgetProps): IDashboardWidget;
@@ -1,4 +1,4 @@
1
- import { IDashboardConfig, IDashboardSettingEntry, TDashboardUndoStatus, TDashboardWidgetCatalog, TDashboardWidgetKey } from './interfaces/';
1
+ import type { IDashboardConfig, IDashboardSettingEntry, TDashboardUndoStatus, TDashboardWidgetCatalog, TDashboardWidgetKey } from './interfaces/';
2
2
  export type TWidgetsCatalogFlyoutProps = {
3
3
  targetContainerKey?: TDashboardWidgetKey;
4
4
  widgetsCatalog: TDashboardWidgetCatalog;
@@ -1,2 +1,2 @@
1
- import { IButtonProps } from './interfaces';
1
+ import type { IButtonProps } from './interfaces';
2
2
  export declare function Button(props: IButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { TStackProps } from './Stack';
2
+ import { type TStackProps } from './Stack';
3
3
  export declare const ListItem: import("react").ForwardRefExoticComponent<TStackProps & {
4
4
  innerClass?: string;
5
5
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ITextFieldProps } from './interfaces';
2
+ import type { ITextFieldProps } from './interfaces';
3
3
  /**
4
4
  * A reusable, styled TextField component built with Tailwind CSS.
5
5
  */
@@ -1,4 +1,4 @@
1
- import { IDashboardSettingEntry } from '../interfaces';
1
+ import type { IDashboardSettingEntry } from '../interfaces';
2
2
  export declare const cssVarsUtils: {
3
3
  getCssVariableValue: (cssPropertyName: string) => string | null;
4
4
  setCssVariableValue: (cssPropertyName: string, value: string) => void;
@@ -1,2 +1,2 @@
1
- import { TDashboardWidgetKey } from '../interfaces';
1
+ import type { TDashboardWidgetKey } from '../interfaces';
2
2
  export declare const parseContainerTitle: (containerWidgetKey: TDashboardWidgetKey) => string;
@@ -1,4 +1,4 @@
1
- import { IDashboardSettingEntry } from '../interfaces';
1
+ import type { IDashboardSettingEntry } from '../interfaces';
2
2
  export declare const dashboardSettingsUtils: {
3
3
  incrementOrDecrementValue: (item: IDashboardSettingEntry, direction: -1 | 1) => IDashboardSettingEntry;
4
4
  };
@@ -1,2 +1,2 @@
1
- import { IDashboardSettingEntry } from '../interfaces';
1
+ import type { IDashboardSettingEntry } from '../interfaces';
2
2
  export declare const cssSettingsCatalog: IDashboardSettingEntry[];
@@ -1,6 +1,8 @@
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>;
1
+ import type { ReactNode, JSX } from 'react';
2
+ import type { TDashboardWidgetKey, TWidgetMetaInfoBase, IDashboardWidgetPropsBase, IDashboardGridPropsBase, TWidgetFactoryBase, IDynamicWidgetCatalogEntryBase, TDashboardWidgetCatalogBase } from './core.base';
3
+ type TFrameworkComponentType = React.ComponentType<any>;
4
+ type TFrameworkElementType = React.ElementType;
5
+ export type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
4
6
  export interface IDashboardGridProps extends IDashboardGridPropsBase {
5
7
  children?: ReactNode;
6
8
  }
@@ -12,9 +14,8 @@ export interface IDashboardWidgetProps extends IDashboardWidgetPropsBase {
12
14
  }
13
15
  export interface IDashboardWidget extends JSX.Element {
14
16
  }
15
- type TFrameworkComponentType = React.ComponentType<any>;
16
17
  export type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
17
- export interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TWidgetMetaInfo, TWidgetFactory, TFrameworkComponentType> {
18
+ export interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
18
19
  }
19
- export type TDashboardWidgetCatalog = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntry>;
20
+ export type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
20
21
  export {};
@@ -1,11 +1,11 @@
1
1
  export type TDashboardWidgetKey = string;
2
2
  export type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
3
- export type TWidgetMetaInfoBase<T> = {
3
+ export type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
4
4
  displayName: string;
5
5
  description: string;
6
6
  categories: TWidgetCategory[];
7
7
  noDuplicatedWidgets?: boolean;
8
- icon: T | undefined;
8
+ icon: TFrameworkElementType | undefined;
9
9
  };
10
10
  export interface IDashboardGridPropsBase {
11
11
  isEditing: boolean;
@@ -38,10 +38,10 @@ export interface IDashboardWidgetPropsBase {
38
38
  * It must return a promise that resolves to the module containing the widget component
39
39
  * as its default export (or a named export if you change the loading strategy).
40
40
  *
41
- * T could be "React.ComponentType<any>"" or "VueComponent" etc
41
+ * TFrameworkComponent could be "React.ComponentType<any>"" or "VueComponent" etc
42
42
  */
43
- export type TWidgetFactoryBase<T> = () => Promise<{
44
- default: T;
43
+ export type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
44
+ default: TFrameworkComponent;
45
45
  }>;
46
46
  /**
47
47
  * 2. Define the flexible Catalog Entry
@@ -52,11 +52,25 @@ export type TWidgetFactoryBase<T> = () => Promise<{
52
52
  * TWidgetFactory: see TWidgetFactoryBase
53
53
  * TComponent: i.e. React.ComponentType<any>
54
54
  */
55
- export interface IDynamicWidgetCatalogEntryBase<TMeta, TFactory, TComponent> {
55
+ /**
56
+ * 2. Define the flexible Catalog Entry
57
+ * Definition of a single widget or container in the catalog.
58
+ * It must have EITHER a direct 'component' reference OR a 'loader' function.
59
+ *
60
+ * TFrameworkElementType: see TWidgetMetaInfoBase
61
+ * TFrameworkComponentType: i.e. React.ComponentType<any> (see TWidgetFactoryBase)
62
+ */
63
+ export interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
56
64
  key: TDashboardWidgetKey;
57
65
  title: string;
58
66
  isContainer?: boolean;
59
- meta?: TMeta;
60
- component?: TComponent;
61
- loader?: TFactory;
67
+ meta?: TWidgetMetaInfoBase<TFrameworkElementType>;
68
+ component?: TFrameworkComponentType;
69
+ loader?: TWidgetFactoryBase<TFrameworkComponentType>;
62
70
  }
71
+ export type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
72
+ export type TGetDefaultWidgetMetaFromKeyOptions = {
73
+ title?: string;
74
+ description?: string;
75
+ };
76
+ export type TGetDefaultWidgetMetaFromKey = (widgetKey: TDashboardWidgetKey, options?: TGetDefaultWidgetMetaFromKeyOptions) => TWidgetMetaInfoBase<any>;
@@ -1,4 +1,3 @@
1
- export * from './core-react.interfaces';
2
1
  import type { TDashboardWidgetKey } from './core.base';
3
2
  export interface IChildWidgetConfigEntry {
4
3
  parentWidgetKey: TDashboardWidgetKey;
@@ -1,24 +1,25 @@
1
- import type { TDashboardWidgetKey } from './core.base';
2
- import type { IDashboardConfig, TWidgetMetaInfo, TDashboardWidgetCatalog } from './core.interfaces';
1
+ import type { TDashboardWidgetKey, TWidgetMetaInfoBase, TDashboardWidgetCatalogBase, TGetDefaultWidgetMetaFromKey } from './core.base';
2
+ import type { IDashboardConfig } from './core.interfaces';
3
3
  export declare const blankDashboardConfig: IDashboardConfig;
4
4
  export declare const DashboardMinZoomScale: 0.7;
5
5
  export declare const DashboardMaxZoomScale: 1;
6
6
  export declare const DashboardZoomStep: 0.05;
7
7
  export declare const ensureZoomScaleIsWithinRange: (value: number) => number;
8
8
  export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, direction: -1 | 1) => number;
9
+ export declare const getDefaultWidgetMetaFromKey: TGetDefaultWidgetMetaFromKey;
9
10
  /**
10
11
  * @name getDefaultWidgetMetaFromMap
11
12
  * @description Helper to get widget meta info from the catalog by key.
12
13
  */
13
- export declare const getDefaultWidgetMetaFromMap: (widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfo>, options?: {
14
+ export declare const getDefaultWidgetMetaFromMap: <TFrameworkElementType = any>(widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfoBase<TFrameworkElementType>>, options?: {
14
15
  title?: string;
15
16
  description?: string;
16
- }) => TWidgetMetaInfo;
17
+ }) => TWidgetMetaInfoBase<TFrameworkElementType>;
17
18
  /**
18
19
  * @name getWidgetMetaFromCatalog
19
20
  * @description Helper to get widget meta info from the catalog by key.
20
21
  */
21
- export declare const getWidgetMetaFromCatalog: (widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalog) => TWidgetMetaInfo;
22
+ export declare const getWidgetMetaFromCatalog: <TFrameworkElementType = any, TFrameworkComponentType = any>(widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>) => TWidgetMetaInfoBase<TFrameworkElementType>;
22
23
  export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
23
24
  /**
24
25
  * @name ensureContainersSequence
@@ -1,6 +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>;
1
+ import type { TDashboardWidgetCatalogBase } from './core.base';
2
+ import type { IDashboardConfig } from './core.interfaces';
3
+ export type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
4
+ export type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
4
5
  export interface IDashboardStorageService {
5
6
  getSavedDashboards: TGetSavedDashboards;
6
7
  saveDashboards: TSaveDashboards;
@@ -1,2 +1,2 @@
1
- import { IDashboardStorageService } from './interfaces';
1
+ import type { IDashboardStorageService } from './interfaces';
2
2
  export declare const useDashboardStorageService: () => IDashboardStorageService;
@@ -1,4 +1,4 @@
1
- import { IDashboardConfig, TDashboardWidgetKey } from './interfaces';
1
+ import type { IDashboardConfig, TDashboardWidgetKey } from './interfaces';
2
2
  type TAddWidgetResponse = {
3
3
  success: boolean;
4
4
  message?: string;
@@ -1,4 +1,4 @@
1
- import { IDashboardConfig, TUndoHistoryEntry, TDashboardUndoStatus } from './interfaces';
1
+ import type { IDashboardConfig, TUndoHistoryEntry, TDashboardUndoStatus } from './interfaces';
2
2
  export declare const useDashboardUndoService: () => {
3
3
  initializeHistoryForDashboard: (initialConfig: IDashboardConfig) => void;
4
4
  resetAllHistory: () => void;
@@ -3131,6 +3131,7 @@ export {
3131
3131
  Nt as dashboardSettingsUtils,
3132
3132
  Mt as ensureContainersSequence,
3133
3133
  st as ensureZoomScaleIsWithinRange,
3134
+ lt as getDefaultWidgetMetaFromKey,
3134
3135
  Nn as getDefaultWidgetMetaFromMap,
3135
3136
  Z as getDistinctCssClasses,
3136
3137
  Tn as getNewZoomScaleWithinRange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenorlab/react-dashboard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Foundation components for creating user-configurable dashboards in React",
5
5
  "author": "Damiano Fusco",
6
6
  "type": "module",