@tenorlab/react-dashboard 1.3.3 → 1.3.6

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.
@@ -1,39 +1,84 @@
1
1
  import { CSSProperties } from 'react';
2
2
  import { default as default_2 } from 'react';
3
3
  import { ForwardRefExoticComponent } from 'react';
4
- import { IChildWidgetConfigEntry } from './interfaces/';
5
- import { IDashboardConfig } from './interfaces/';
6
- import { IDashboardGridPropsBase } from './interfaces/';
7
- import { IDashboardSettingEntry } from './interfaces/';
8
- import { IDashboardWidgetPropsBase } from './interfaces/';
9
- import { IDynamicWidgetCatalogEntryBase } from './interfaces/';
10
4
  import { JSX } from 'react';
11
5
  import { JSX as JSX_2 } from 'react/jsx-runtime';
12
6
  import { ReactNode } from 'react';
13
7
  import { RefAttributes } from 'react';
14
8
  import { StoreApi } from 'zustand';
15
- import { TDashboardUndoStatus } from './interfaces/';
16
- import { TDashboardWidgetCatalogBase } from './interfaces/';
17
- import { TDashboardWidgetKey } from './interfaces/';
18
- import { TUndoHistoryEntry } from './interfaces/';
19
- import { TWidgetFactoryBase } from './interfaces/';
20
- import { TWidgetMetaInfoBase } from './interfaces/';
21
9
  import { UseBoundStore } from 'zustand';
22
10
 
23
11
  export declare function AddIcon({ className }: TIconProps): JSX_2.Element;
24
12
 
13
+ export declare const blankDashboardConfig: IDashboardConfig;
14
+
25
15
  export declare function Button(props: IButtonProps): JSX_2.Element;
26
16
 
27
17
  export declare function CircleQuestionMark({ className }: TIconProps): JSX_2.Element;
28
18
 
19
+ /**
20
+ * @name createDynamicEntry
21
+ * Helper function to create dynamic entries
22
+ * This helps keep the catalog registration clean
23
+ */
24
+ export declare const createDynamicEntry: (key: string, loader: TWidgetFactoryBase, metaData: TWidgetMetaInfoBase) => [string, IDynamicWidgetCatalogEntryBase];
25
+
26
+ /**
27
+ * @name createStaticEntry
28
+ * Helper function to create static entries
29
+ * This helps keep the catalog registration clean
30
+ */
31
+ export declare const createStaticEntry: <TFrameworkComponentType = any>(key: string, component: TFrameworkComponentType, metaData?: TWidgetMetaInfoBase) => [string, IDynamicWidgetCatalogEntryBase];
32
+
29
33
  export declare function CrosshairIcon({ className }: TIconProps): JSX_2.Element;
30
34
 
35
+ export declare const cssSettingsCatalog: IDashboardSettingEntry[];
36
+
37
+ /**
38
+ * @name cssVarsUtils
39
+ * @description Provides helpers method like getCssVariableValue, setCssVariableValue etc
40
+ */
41
+ export declare const cssVarsUtils: {
42
+ /**
43
+ * @name getCssVariableValue
44
+ * @description Return the value of a CSS custom property from the current HTML document
45
+ * @param cssPropertyName
46
+ * @returns
47
+ */
48
+ getCssVariableValue: (cssPropertyName: string) => string | null;
49
+ /**
50
+ * @name setCssVariableValue
51
+ * @description Sets the value of a CSS custom property on the current HTML document
52
+ * @param cssPropertyName
53
+ * @param value
54
+ */
55
+ setCssVariableValue: (cssPropertyName: string, value: string) => void;
56
+ /**
57
+ * @name restoreCssVarsFromSettings
58
+ * @description
59
+ * Sets the values of many CSS custom properties on the current HTML document
60
+ * from the list of dashboard settings provided
61
+ * @param settings, an array of IDashboardSettingEntry
62
+ */
63
+ restoreCssVarsFromSettings: (settings: IDashboardSettingEntry[]) => void;
64
+ };
65
+
31
66
  export declare const DashboardGrid: ForwardRefExoticComponent<IDashboardGridProps & RefAttributes<HTMLDivElement>>;
32
67
 
68
+ export declare const DashboardMaxZoomScale: 1;
69
+
70
+ export declare const DashboardMinZoomScale: 0.7;
71
+
72
+ export declare const dashboardSettingsUtils: {
73
+ incrementOrDecrementValue: (item: IDashboardSettingEntry, direction: -1 | 1) => IDashboardSettingEntry;
74
+ };
75
+
33
76
  export declare const DashboardWidgetBase: (props: IDashboardWidgetProps & {
34
77
  ref?: React.ForwardedRef<HTMLDivElement>;
35
78
  }) => React.ReactElement | null;
36
79
 
80
+ export declare const DashboardZoomStep: 0.05;
81
+
37
82
  export declare function DeleteIcon({ className }: TIconProps): JSX_2.Element;
38
83
 
39
84
  export declare const DraggablePanel: ForwardRefExoticComponent<DraggablePanelProps & RefAttributes<HTMLDivElement>>;
@@ -57,6 +102,45 @@ export declare function DynamicWidgetLoader({ index, maxIndex, widgetKey, parent
57
102
 
58
103
  export declare function EditIcon({ className }: TIconProps): JSX_2.Element;
59
104
 
105
+ /**
106
+ * @name ensureContainersSequence
107
+ * @description
108
+ * Ensures that the container widgets are numbered sequentially in the dashboardConfig, but the original order is preserved.
109
+ */
110
+ export declare const ensureContainersSequence: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
111
+
112
+ export declare const ensureZoomScaleIsWithinRange: (value: number) => number;
113
+
114
+ export declare const getDefaultWidgetMetaFromKey: TGetDefaultWidgetMetaFromKey;
115
+
116
+ /**
117
+ * @name getDefaultWidgetMetaFromMap
118
+ * @description Helper to get widget meta info from the catalog by key.
119
+ */
120
+ export declare const getDefaultWidgetMetaFromMap: <TFrameworkElementType = any>(widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfoBase<TFrameworkElementType>>, options?: {
121
+ title?: string;
122
+ description?: string;
123
+ }) => TWidgetMetaInfoBase<TFrameworkElementType>;
124
+
125
+ /**
126
+ * @name getDistinctCssClasses
127
+ * @description Ensures a distinct list off css classes, avoiding duplicates
128
+ * @param defaultClasses
129
+ * @param additionalClasses
130
+ * @returns the distinct list as a string
131
+ */
132
+ export declare const getDistinctCssClasses: (defaultClasses: string, ...additionalClasses: string[]) => string;
133
+
134
+ export declare const getMetaInfoFromFile: (widgetMetaModules: Record<string, Record<string, TWidgetMetaInfoBase>>, baseSrcPath: string, folder: string, key: string) => TWidgetMetaInfoBase | undefined;
135
+
136
+ export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, direction: -1 | 1) => number;
137
+
138
+ /**
139
+ * @name getWidgetMetaFromCatalog
140
+ * @description Helper to get widget meta info from the catalog by key.
141
+ */
142
+ export declare const getWidgetMetaFromCatalog: <TFrameworkElementType = any, TFrameworkComponentType = any>(widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>) => TWidgetMetaInfoBase<TFrameworkElementType>;
143
+
60
144
  export declare function GridIcon({ className }: TIconProps): JSX_2.Element;
61
145
 
62
146
  export declare function HandGrabIcon({ className }: TIconProps): JSX_2.Element;
@@ -90,10 +174,52 @@ export declare interface IButtonProps {
90
174
  tooltip?: ITooltipProps;
91
175
  }
92
176
 
177
+ export declare interface IChildWidgetConfigEntry {
178
+ parentWidgetKey: TDashboardWidgetKey;
179
+ widgetKey: TDashboardWidgetKey;
180
+ }
181
+
182
+ export declare interface IDashboardConfig {
183
+ userID: number | string;
184
+ clientAppKey: string;
185
+ dashboardId: string;
186
+ dashboardName: string;
187
+ zoomScale: number;
188
+ responsiveGrid: boolean;
189
+ widgets: TDashboardWidgetKey[];
190
+ childWidgetsConfig: IChildWidgetConfigEntry[];
191
+ cssSettings: IDashboardSettingEntry[];
192
+ _version?: number;
193
+ _stateDescription?: string;
194
+ }
195
+
93
196
  export declare interface IDashboardGridProps extends IDashboardGridPropsBase {
94
197
  children?: ReactNode;
95
198
  }
96
199
 
200
+ export declare interface IDashboardGridPropsBase {
201
+ isEditing: boolean;
202
+ zoomScale: number;
203
+ responsiveGrid: boolean;
204
+ }
205
+
206
+ export declare interface IDashboardSettingEntry {
207
+ key: string;
208
+ name: string;
209
+ description: string;
210
+ cssProperty: string;
211
+ step: number;
212
+ defaultUnit: string;
213
+ minValue: number;
214
+ defaultValue: string;
215
+ value: string;
216
+ }
217
+
218
+ export declare interface IDashboardStorageService {
219
+ getSavedDashboards: TGetSavedDashboards;
220
+ saveDashboards: TSaveDashboards;
221
+ }
222
+
97
223
  export declare interface IDashboardWidget extends JSX.Element {
98
224
  }
99
225
 
@@ -104,9 +230,46 @@ export declare interface IDashboardWidgetProps<TExtraProps = any> extends IDashb
104
230
  selectContainer?: (containerKey?: TDashboardWidgetKey) => void;
105
231
  }
106
232
 
233
+ export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
234
+ index: number;
235
+ maxIndex: number;
236
+ widgetKey: TDashboardWidgetKey;
237
+ parentWidgetKey?: TDashboardWidgetKey;
238
+ isEditing: boolean;
239
+ highlight?: boolean;
240
+ testId?: string;
241
+ title?: string;
242
+ size?: TWidgetSize;
243
+ borderCssClasses?: string;
244
+ backgroundCssClasses?: string;
245
+ hideTitle?: boolean;
246
+ noShadow?: boolean;
247
+ noBorder?: boolean;
248
+ noPadding?: boolean;
249
+ direction?: TWidgetDirection;
250
+ extraProps?: TExtraProps;
251
+ }
252
+
107
253
  export declare interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
108
254
  }
109
255
 
256
+ /**
257
+ * 2. Define the flexible Catalog Entry
258
+ * Definition of a single widget or container in the catalog.
259
+ * It must have EITHER a direct 'component' reference OR a 'loader' function.
260
+ *
261
+ * TFrameworkElementType: see TWidgetMetaInfoBase
262
+ * TFrameworkComponentType: i.e. React.ComponentType<any> (see TWidgetFactoryBase)
263
+ */
264
+ export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType = any, TFrameworkComponentType = any> {
265
+ key: TDashboardWidgetKey;
266
+ title: string;
267
+ isContainer?: boolean;
268
+ meta?: TWidgetMetaInfoBase<TFrameworkElementType>;
269
+ component?: TFrameworkComponentType;
270
+ loader?: TWidgetFactoryBase<TFrameworkComponentType>;
271
+ }
272
+
110
273
  /**
111
274
  * Compares two version strings (e.g., "19.2.0" and "19.2.3")
112
275
  * Returns true if the widget version is compatible with the host.
@@ -144,6 +307,14 @@ export declare const ListItemMiddleChild: ForwardRefExoticComponent<TListItemChi
144
307
 
145
308
  export declare const ListItemRightChild: ForwardRefExoticComponent<TListItemChildProps & RefAttributes<HTMLDivElement>>;
146
309
 
310
+ /**
311
+ * @name localWidgetDiscovery
312
+ * @description Scans local directories for widgets.
313
+ * If lazy is true, it registers loaders. If false, it registers static components.
314
+ */
315
+ export declare const localWidgetDiscovery: (baseSrcPath: string, // e.g., "/src/async-widgets" or "/src/bundled-widgets"
316
+ widgetModules: Record<string, any>, widgetMetaModules: Record<string, any>, lazy?: boolean) => [string, IDynamicWidgetCatalogEntryBase][];
317
+
147
318
  export declare function MonitorIcon({ className }: TIconProps): JSX_2.Element;
148
319
 
149
320
  export declare function MonitorSmartphoneIcon({ className }: TIconProps): JSX_2.Element;
@@ -152,8 +323,40 @@ export declare function MoveLeftIcon({ className }: TIconProps): JSX_2.Element;
152
323
 
153
324
  export declare function MoveRightIcon({ className }: TIconProps): JSX_2.Element;
154
325
 
326
+ export declare const parseContainerTitle: (containerWidgetKey: TDashboardWidgetKey) => string;
327
+
328
+ /**
329
+ * Enhanced helper to derive key and title from widget file paths.
330
+ * Handles:
331
+ * - widget-revenue-trends1 -> WidgetRevenueTrends1
332
+ * - widget-with-extraprops -> WidgetWithExtraprops
333
+ * - widget-revenue-trends-async -> WidgetRevenueTrendsAsync
334
+ */
335
+ export declare const parseKeyAndTitleFromFilePath: (path: string) => {
336
+ key: TDashboardWidgetKey;
337
+ title: string;
338
+ folder: string;
339
+ } | null;
340
+
155
341
  export declare function RedoIcon({ className }: TIconProps): JSX_2.Element;
156
342
 
343
+ export declare const remoteWidgetDiscovery: (manifestUrl: string) => Promise<{
344
+ entries: [string, IDynamicWidgetCatalogEntryBase][];
345
+ message: string;
346
+ details: string;
347
+ }>;
348
+
349
+ export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
350
+
351
+ /**
352
+ * @name resolveColorFromClass
353
+ * @description Resolves the current computed color using your existing CSS classes
354
+ * @param classNames, i.e. 'bg-primary'
355
+ * @param property to resolve, i.e. 'backgroundColor'
356
+ * @returns
357
+ */
358
+ export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
359
+
157
360
  export declare function SettingsIcon({ className }: TIconProps): JSX_2.Element;
158
361
 
159
362
  export declare const showToast: (options: any) => void;
@@ -206,8 +409,19 @@ declare type TDashboardSlice = {
206
409
 
207
410
  export declare type TDashboardUndoService = ReturnType<typeof useDashboardUndoService>;
208
411
 
412
+ export declare type TDashboardUndoStatus = {
413
+ isUndoDisabled: boolean;
414
+ isRedoDisabled: boolean;
415
+ _currentIndex?: number;
416
+ _historyLength?: number;
417
+ };
418
+
209
419
  export declare type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
210
420
 
421
+ export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
422
+
423
+ export declare type TDashboardWidgetKey = string;
424
+
211
425
  declare type TDynamicWidgetLoaderProps<TExtraProps = any> = {
212
426
  index: number;
213
427
  maxIndex: number;
@@ -232,6 +446,15 @@ declare type TFrameworkComponentType = React.ComponentType<any>;
232
446
 
233
447
  declare type TFrameworkElementType = React.ElementType;
234
448
 
449
+ export declare type TGetDefaultWidgetMetaFromKey = (widgetKey: TDashboardWidgetKey, options?: TGetDefaultWidgetMetaFromKeyOptions) => TWidgetMetaInfoBase<any>;
450
+
451
+ export declare type TGetDefaultWidgetMetaFromKeyOptions = {
452
+ title?: string;
453
+ description?: string;
454
+ };
455
+
456
+ export declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
457
+
235
458
  declare type TIconProps = {
236
459
  className?: string;
237
460
  };
@@ -244,6 +467,11 @@ declare type TListItemChildProps = {
244
467
  children?: ReactNode;
245
468
  };
246
469
 
470
+ export declare type TManifestEntry = {
471
+ url: string;
472
+ meta: TWidgetMetaInfoBase;
473
+ };
474
+
247
475
  declare type TProps = {
248
476
  children: React.ReactNode;
249
477
  addCssClasses?: string;
@@ -251,6 +479,8 @@ declare type TProps = {
251
479
 
252
480
  declare type TRemoveWidgetResponse = TAddWidgetResponse;
253
481
 
482
+ export declare type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
483
+
254
484
  declare type TSize = 'small' | 'medium';
255
485
 
256
486
  export declare type TStackProps = {
@@ -261,10 +491,40 @@ export declare type TStackProps = {
261
491
  children: React.ReactNode;
262
492
  };
263
493
 
494
+ export declare type TUndoHistoryEntry = {
495
+ undoIndex: number;
496
+ config: IDashboardConfig;
497
+ };
498
+
499
+ export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
500
+
501
+ export declare type TWidgetDirection = 'row' | 'column';
502
+
264
503
  export declare type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
265
504
 
505
+ /**
506
+ * 1. Define the Async Loader type
507
+ * Type for the function that performs the asynchronous dynamic import.
508
+ * It must return a promise that resolves to the module containing the widget component
509
+ * as its default export (or a named export if you change the loading strategy).
510
+ *
511
+ * TFrameworkComponent could be "React.ComponentType<any>"" or "VueComponent" etc
512
+ */
513
+ export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
514
+ default: TFrameworkComponent;
515
+ }>;
516
+
266
517
  export declare type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
267
518
 
519
+ export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
520
+ name: string;
521
+ description: string;
522
+ categories: TWidgetCategory[];
523
+ noDuplicatedWidgets?: boolean;
524
+ icon: TFrameworkElementType | undefined;
525
+ externalDependencies: string[];
526
+ };
527
+
268
528
  export declare type TWidgetsCatalogFlyoutProps = {
269
529
  targetContainerKey?: TDashboardWidgetKey;
270
530
  widgetsCatalog: TDashboardWidgetCatalog;
@@ -278,8 +538,12 @@ export declare type TWidgetsCatalogFlyoutProps = {
278
538
  onDoneClick: () => any;
279
539
  };
280
540
 
541
+ export declare type TWidgetSize = 'default' | 'large' | 'xlarge';
542
+
281
543
  export declare function UndoIcon({ className }: TIconProps): JSX_2.Element;
282
544
 
545
+ export declare const useDashboardStorageService: () => IDashboardStorageService;
546
+
283
547
  export declare const useDashboardStore: UseBoundStore<StoreApi<TDashboardSlice>>;
284
548
 
285
549
  export declare const useDashboardUndoService: () => {
@@ -312,10 +576,4 @@ export declare function ZoomInIcon({ className }: TIconProps): JSX_2.Element;
312
576
 
313
577
  export declare function ZoomOutIcon({ className }: TIconProps): JSX_2.Element;
314
578
 
315
-
316
- export * from "./dashboard-settings";
317
- export * from "./interfaces/";
318
- export * from "./storage-service";
319
- export * from "./utils";
320
-
321
579
  export { }