@tenorlab/react-dashboard 1.6.4 → 1.6.5
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/package.json +2 -2
- package/dist/core.d.ts +0 -591
- package/dist/core.es.js +0 -526
- package/dist/react-dashboard.d.ts +0 -719
- package/dist/react-dashboard.es.js +0 -3261
- package/dist/styles.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenorlab/react-dashboard",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Foundation components for creating user-configurable dashboards in React",
|
|
5
5
|
"author": "Damiano Fusco",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"zustand": "5.0.9"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@tenorlab/dashboard-core": "^1.6.
|
|
58
|
+
"@tenorlab/dashboard-core": "^1.6.4",
|
|
59
59
|
"@types/node": "^24.10.1",
|
|
60
60
|
"@types/react": "19.2.3",
|
|
61
61
|
"@types/react-dom": "19.2.3",
|
package/dist/core.d.ts
DELETED
|
@@ -1,591 +0,0 @@
|
|
|
1
|
-
export declare const blankDashboardConfig: IDashboardConfig;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @name createDynamicEntry
|
|
5
|
-
* Helper function to create dynamic entries
|
|
6
|
-
* This helps keep the catalog registration clean
|
|
7
|
-
*/
|
|
8
|
-
export declare const createDynamicEntry: (key: string, loader: TWidgetFactoryBase, isRemote: boolean, metaData: TWidgetMetaInfoBase) => [string, IDynamicWidgetCatalogEntryBase];
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @name createStaticEntry
|
|
12
|
-
* Helper function to create static entries
|
|
13
|
-
* This helps keep the catalog registration clean
|
|
14
|
-
*/
|
|
15
|
-
export declare const createStaticEntry: <TFrameworkComponentType = any>(key: string, component: TFrameworkComponentType, metaData?: TWidgetMetaInfoBase) => [string, IDynamicWidgetCatalogEntryBase];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @name cssSettingsCatalog
|
|
19
|
-
* @description Catalog of available dashboard settings (array of IDashboardSettingEntry)
|
|
20
|
-
* @see IDashboardSettingEntry
|
|
21
|
-
* @remarks step should never be less than 0.1 as we do some rounding in other places ...
|
|
22
|
-
*/
|
|
23
|
-
export declare const cssSettingsCatalog: IDashboardSettingEntry[];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @name cssVarsUtils
|
|
27
|
-
* @description Provides helpers method like getCssVariableValue, setCssVariableValue etc
|
|
28
|
-
*/
|
|
29
|
-
export declare const cssVarsUtils: {
|
|
30
|
-
/**
|
|
31
|
-
* @name getCssVariableValue
|
|
32
|
-
* @description Return the value of a CSS custom property from the current HTML document
|
|
33
|
-
* @param cssPropertyName
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
getCssVariableValue: (cssPropertyName: string) => string | null;
|
|
37
|
-
/**
|
|
38
|
-
* @name setCssVariableValue
|
|
39
|
-
* @description Sets the value of a CSS custom property on the current HTML document
|
|
40
|
-
* @param cssPropertyName
|
|
41
|
-
* @param value
|
|
42
|
-
*/
|
|
43
|
-
setCssVariableValue: (cssPropertyName: string, value: string) => void;
|
|
44
|
-
/**
|
|
45
|
-
* @name restoreCssVarsFromSettings
|
|
46
|
-
* @description
|
|
47
|
-
* Sets the values of many CSS custom properties on the current HTML document
|
|
48
|
-
* from the list of dashboard settings provided
|
|
49
|
-
* @param settings, an array of IDashboardSettingEntry
|
|
50
|
-
*/
|
|
51
|
-
restoreCssVarsFromSettings: (settings: IDashboardSettingEntry[]) => void;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export declare const DashboardMaxZoomScale: 1;
|
|
55
|
-
|
|
56
|
-
export declare const DashboardMinZoomScale: 0.7;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @name dashboardSettingsUtils
|
|
60
|
-
* @description Contains utils for the dashboard custom settings
|
|
61
|
-
*/
|
|
62
|
-
export declare const dashboardSettingsUtils: {
|
|
63
|
-
/**
|
|
64
|
-
* @name incrementOrDecrementValue
|
|
65
|
-
* @description Increments or decrement a value based on the direction parameter
|
|
66
|
-
* @param item: an instance of IDashboardSettingEntry
|
|
67
|
-
* @param direction: -1 (for decrement) or 1 (for increment)
|
|
68
|
-
* @returns the update item
|
|
69
|
-
*/
|
|
70
|
-
incrementOrDecrementValue: (item: IDashboardSettingEntry, direction: -1 | 1) => IDashboardSettingEntry;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @name dashboardStoreUtils
|
|
75
|
-
* @description
|
|
76
|
-
* Framework-agnostic helpers for managing dashboard state. These utilities
|
|
77
|
-
* are designed to be consumed by specific store implementations.
|
|
78
|
-
* @see {@link https://www.npmjs.com/package/@tenorlab/react-dashboard | @tenorlab/react-dashboard}
|
|
79
|
-
* @see {@link https://www.npmjs.com/package/@tenorlab/vue-dashboard | @tenorlab/vue-dashboard}
|
|
80
|
-
*/
|
|
81
|
-
export declare const dashboardStoreUtils: {
|
|
82
|
-
/**
|
|
83
|
-
* @name getNextContainerName
|
|
84
|
-
* @description Generates the next container name based on existing containers in the dashboard configuration
|
|
85
|
-
* @param dashboardConfig
|
|
86
|
-
* @returns {string} The next container name in the format 'containerX', where X is the next available number
|
|
87
|
-
*/
|
|
88
|
-
getNextContainerName: (dashboardConfig: IDashboardConfig) => string;
|
|
89
|
-
/**
|
|
90
|
-
* @name getNextContainerKey
|
|
91
|
-
* @description Generates the next container widget key based on the dashboard configuration and a given container widget key
|
|
92
|
-
* @param dashboardConfig
|
|
93
|
-
* @param containerWidgetKey
|
|
94
|
-
* @returns {TDashboardWidgetKey} The next container widget key
|
|
95
|
-
*/
|
|
96
|
-
getNextContainerKey: (dashboardConfig: IDashboardConfig, containerWidgetKey: TDashboardWidgetKey) => TDashboardWidgetKey;
|
|
97
|
-
/**
|
|
98
|
-
* @description Adds a widget to the configuration. Supports root-level and nested containers.
|
|
99
|
-
* @param params - Configuration object for adding a widget.
|
|
100
|
-
* @param params.dashboardConfig - The current {@link IDashboardConfig}.
|
|
101
|
-
* @param params.widgetKey - The {@link TDashboardWidgetKey} to add.
|
|
102
|
-
* @param params.parentWidgetKey - Optional parent container key.
|
|
103
|
-
* @param params.noDuplicatedWidgets - If true, prevents adding the same key twice.
|
|
104
|
-
* @returns A {@link TCoreResponse} containing the success status and updated config.
|
|
105
|
-
*/
|
|
106
|
-
addWidget: (params: {
|
|
107
|
-
dashboardConfig: IDashboardConfig;
|
|
108
|
-
widgetKey: TDashboardWidgetKey;
|
|
109
|
-
parentWidgetKey?: TDashboardWidgetKey;
|
|
110
|
-
noDuplicatedWidgets?: boolean;
|
|
111
|
-
}) => TCoreResponse<TAddWidgetResponse>;
|
|
112
|
-
/**
|
|
113
|
-
* @name removeWidget
|
|
114
|
-
* @description Removes a widget from the dashboard configuration, either from the root level or from a specified parent container
|
|
115
|
-
* @param dashboardConfig
|
|
116
|
-
* @param widgetKey
|
|
117
|
-
* @param parentWidgetKey
|
|
118
|
-
* @returns {TCoreResponse<TRemoveWidgetResponse>} The response indicating success or failure and the updated dashboard configuration
|
|
119
|
-
*/
|
|
120
|
-
removeWidget: (dashboardConfig: IDashboardConfig, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TCoreResponse<TRemoveWidgetResponse>;
|
|
121
|
-
/**
|
|
122
|
-
* @description Moves a widget's position within its current depth (root or container).
|
|
123
|
-
* @param dashboardConfig - The current {@link IDashboardConfig}.
|
|
124
|
-
* @param direction - Use `1` for forward/down and `-1` for backward/up.
|
|
125
|
-
* @param widgetKey - The {@link TDashboardWidgetKey} to move.
|
|
126
|
-
* @param parentWidgetKey - The container key if the widget is nested.
|
|
127
|
-
* @returns A {@link TCoreResponse} with the new array order.
|
|
128
|
-
*/
|
|
129
|
-
moveWidget: (dashboardConfig: IDashboardConfig, direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TCoreResponse<TMoveWidgetResponse>;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export declare const DashboardZoomStep: 0.05;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @name ensureContainersSequence
|
|
136
|
-
* @description
|
|
137
|
-
* Ensures that the container widgets are numbered sequentially in the dashboardConfig, but the original order is preserved.
|
|
138
|
-
*/
|
|
139
|
-
export declare const ensureContainersSequence: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
140
|
-
|
|
141
|
-
export declare const ensureZoomScaleIsWithinRange: (value: number) => number;
|
|
142
|
-
|
|
143
|
-
export declare const getDefaultWidgetMetaFromKey: TGetDefaultWidgetMetaFromKey;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @name getDefaultWidgetMetaFromMap
|
|
147
|
-
* @description Helper to get widget meta info from the catalog by key.
|
|
148
|
-
*/
|
|
149
|
-
export declare const getDefaultWidgetMetaFromMap: <TFrameworkElementType = any>(widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfoBase<TFrameworkElementType>>, options?: {
|
|
150
|
-
title?: string;
|
|
151
|
-
description?: string;
|
|
152
|
-
}) => TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* @name getDistinctCssClasses
|
|
156
|
-
* @description Ensures a distinct list off css classes, avoiding duplicates
|
|
157
|
-
* @param defaultClasses
|
|
158
|
-
* @param additionalClasses
|
|
159
|
-
* @returns the distinct list as a string
|
|
160
|
-
*/
|
|
161
|
-
export declare const getDistinctCssClasses: (defaultClasses: string, ...additionalClasses: string[]) => string;
|
|
162
|
-
|
|
163
|
-
export declare const getMetaInfoFromFile: (widgetMetaModules: Record<string, Record<string, TWidgetMetaInfoBase>>, baseSrcPath: string, folder: string, key: string) => TWidgetMetaInfoBase | undefined;
|
|
164
|
-
|
|
165
|
-
export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, direction: -1 | 1) => number;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* @name getWidgetMetaFromCatalog
|
|
169
|
-
* @description Helper to get widget meta info from the catalog by key.
|
|
170
|
-
*/
|
|
171
|
-
export declare const getWidgetMetaFromCatalog: <TFrameworkElementType = any, TFrameworkComponentType = any>(widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>) => TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @name IChildWidgetConfigEntry
|
|
175
|
-
* @description Interface for a child widget configuration entry
|
|
176
|
-
* @remarks Used in IDashboardConfig
|
|
177
|
-
* @see IDashboardConfig
|
|
178
|
-
*/
|
|
179
|
-
export declare interface IChildWidgetConfigEntry {
|
|
180
|
-
parentWidgetKey: TDashboardWidgetKey;
|
|
181
|
-
widgetKey: TDashboardWidgetKey;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @name IDashboardConfig
|
|
186
|
-
* @description Interface for the dashboard configuration
|
|
187
|
-
* @remarks Used to store the dashboard state
|
|
188
|
-
* @see IChildWidgetConfigEntry
|
|
189
|
-
* @see IDashboardSettingEntry
|
|
190
|
-
*/
|
|
191
|
-
export declare interface IDashboardConfig {
|
|
192
|
-
userID: number | string;
|
|
193
|
-
clientAppKey: string;
|
|
194
|
-
dashboardId: string;
|
|
195
|
-
dashboardName: string;
|
|
196
|
-
zoomScale: number;
|
|
197
|
-
responsiveGrid: boolean;
|
|
198
|
-
widgets: TDashboardWidgetKey[];
|
|
199
|
-
childWidgetsConfig: IChildWidgetConfigEntry[];
|
|
200
|
-
savedProps?: IWidgetSavedProps[];
|
|
201
|
-
cssSettings: IDashboardSettingEntry[];
|
|
202
|
-
_version?: number;
|
|
203
|
-
_stateDescription?: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @name IDashboardGridPropsBase
|
|
208
|
-
* @description Base interface for dashboard grid props passed to widgets.
|
|
209
|
-
* @remarks
|
|
210
|
-
* - `zoomScale` represents a uniform zoom applied to the dashboard UI. Default
|
|
211
|
-
* behavior in the runtime clamps this value to a minimum of `0.7` and default
|
|
212
|
-
* is `1` when not explicitly set.
|
|
213
|
-
* - `responsiveGrid` toggles responsive layout behaviors vs fixed grid sizing.
|
|
214
|
-
*/
|
|
215
|
-
export declare interface IDashboardGridPropsBase {
|
|
216
|
-
isEditing: boolean;
|
|
217
|
-
zoomScale: number;
|
|
218
|
-
responsiveGrid: boolean;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @name IDashboardSettingEntry
|
|
223
|
-
* @description Interface for a dashboard setting entry
|
|
224
|
-
* @see cssSettingsCatalog in dashboard-settings.ts
|
|
225
|
-
*/
|
|
226
|
-
export declare interface IDashboardSettingEntry {
|
|
227
|
-
key: string;
|
|
228
|
-
name: string;
|
|
229
|
-
description: string;
|
|
230
|
-
cssProperty: string;
|
|
231
|
-
step: number;
|
|
232
|
-
defaultUnit: string;
|
|
233
|
-
minValue: number;
|
|
234
|
-
defaultValue: string;
|
|
235
|
-
value: string;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* @name IDashboardStorageService
|
|
240
|
-
* @description Interface for the dashboard storage service
|
|
241
|
-
* @remarks Used to define the storage service methods
|
|
242
|
-
* @see TGetSavedDashboards
|
|
243
|
-
* @see TSaveDashboards
|
|
244
|
-
* @see IDashboardConfig
|
|
245
|
-
*/
|
|
246
|
-
export declare interface IDashboardStorageService {
|
|
247
|
-
getSavedDashboards: TGetSavedDashboards;
|
|
248
|
-
saveDashboards: TSaveDashboards;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @name IDashboardWidgetPropsBase
|
|
253
|
-
* @description Props provided to every widget instance rendered by the dashboard.
|
|
254
|
-
* @template TExtraProps - Additional, widget-specific props supplied by the
|
|
255
|
-
* dashboard or integrator via the dynamic loader.
|
|
256
|
-
* @remarks
|
|
257
|
-
* - `index` and `maxIndex` indicate the widget's position and the current
|
|
258
|
-
* maximum index used for ordering (zero-based indexing is typical).
|
|
259
|
-
* - `widgetKey` is the stable `TDashboardWidgetKey` identifying the widget
|
|
260
|
-
* type; `parentWidgetKey` is set for nested/child widgets.
|
|
261
|
-
* - Boolean flags like `hideTitle`, `noShadow`, `noBorder`, `noPadding` are
|
|
262
|
-
* layout/presentation hints; default behavior should be documented by the
|
|
263
|
-
* concrete widget implementation.
|
|
264
|
-
* - `direction` applies to container widgets only.
|
|
265
|
-
* - `extraProps` is merged into the widget props by the `DynamicWidgetLoader`.
|
|
266
|
-
*/
|
|
267
|
-
export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
268
|
-
index: number;
|
|
269
|
-
maxIndex: number;
|
|
270
|
-
widgetKey: TDashboardWidgetKey;
|
|
271
|
-
parentWidgetKey?: TDashboardWidgetKey;
|
|
272
|
-
isEditing: boolean;
|
|
273
|
-
highlight?: boolean;
|
|
274
|
-
testId?: string;
|
|
275
|
-
title?: string;
|
|
276
|
-
size?: TWidgetSize;
|
|
277
|
-
borderCssClasses?: string;
|
|
278
|
-
backgroundCssClasses?: string;
|
|
279
|
-
addCssClasses?: string;
|
|
280
|
-
overrideCssClasses?: string;
|
|
281
|
-
tags?: string[];
|
|
282
|
-
hideTitle?: boolean;
|
|
283
|
-
noShadow?: boolean;
|
|
284
|
-
noBorder?: boolean;
|
|
285
|
-
noPadding?: boolean;
|
|
286
|
-
noCollapse?: boolean;
|
|
287
|
-
direction?: TWidgetDirection;
|
|
288
|
-
widgetSavedProps?: IWidgetSavedProps;
|
|
289
|
-
meta?: TWidgetMetaInfoBase;
|
|
290
|
-
extraProps?: TExtraProps;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @name IDynamicWidgetCatalogEntryBase
|
|
295
|
-
* @description Catalog entry describing how to create or load a widget.
|
|
296
|
-
* @template TFrameworkElementType - Framework-specific element type (icon, element)
|
|
297
|
-
* @template TFrameworkComponentType - Framework-specific component type
|
|
298
|
-
* @remarks
|
|
299
|
-
* - `key` must be unique and stable across versions because it is stored in
|
|
300
|
-
* saved dashboard configurations.
|
|
301
|
-
* - `title` is the display name for catalogs and selection UIs.
|
|
302
|
-
* - `isContainer` indicates a widget that can host children.
|
|
303
|
-
* - `isRemote` marks entries that are expected to be loaded remotely (CDN,
|
|
304
|
-
* external script) and may require extra loading/initialization steps.
|
|
305
|
-
* - `meta` contains presentation metadata (see `TWidgetMetaInfoBase`).
|
|
306
|
-
* - `component` is a direct component reference (preferred for static/core widgets).
|
|
307
|
-
* - `loader` is an async factory used for dynamic/plugin widgets. When both
|
|
308
|
-
* `component` and `loader` are provided, loaders are typically used for
|
|
309
|
-
* dynamic initialization; concrete loaders/components precedence should be
|
|
310
|
-
* defined by the integrator.
|
|
311
|
-
*/
|
|
312
|
-
export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType = any, TFrameworkComponentType = any> {
|
|
313
|
-
key: TDashboardWidgetKey;
|
|
314
|
-
title: string;
|
|
315
|
-
isContainer?: boolean;
|
|
316
|
-
isRemote?: boolean;
|
|
317
|
-
meta?: TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
318
|
-
component?: TFrameworkComponentType;
|
|
319
|
-
loader?: TWidgetFactoryBase<TFrameworkComponentType>;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export declare interface IWidgetSavedProps {
|
|
323
|
-
parentWidgetKey?: TDashboardWidgetKey;
|
|
324
|
-
widgetKey: TDashboardWidgetKey;
|
|
325
|
-
isCollapsed?: boolean;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* @name localWidgetDiscovery
|
|
330
|
-
* @description Scans local directories for widgets.
|
|
331
|
-
* If lazy is true, it registers loaders. If false, it registers static components.
|
|
332
|
-
*/
|
|
333
|
-
export declare const localWidgetDiscovery: (baseSrcPath: string, // e.g., "/src/async-widgets" or "/src/bundled-widgets"
|
|
334
|
-
widgetModules: Record<string, any>, widgetMetaModules: Record<string, any>, lazy?: boolean) => [string, IDynamicWidgetCatalogEntryBase][];
|
|
335
|
-
|
|
336
|
-
export declare const parseContainerTitle: (containerWidgetKey: TDashboardWidgetKey) => string;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Enhanced helper to derive key and title from widget file paths.
|
|
340
|
-
* Handles:
|
|
341
|
-
* - widget-total-orders -> WidgetTotalOrders
|
|
342
|
-
* - widget-revenue-trends1 -> WidgetRevenueTrends1
|
|
343
|
-
* - widget-with-extraprops -> WidgetWithExtraprops
|
|
344
|
-
* - widget-revenue-trends-async -> WidgetRevenueTrendsAsync
|
|
345
|
-
*/
|
|
346
|
-
export declare const parseKeyAndTitleFromFilePath: (path: string) => {
|
|
347
|
-
key: TDashboardWidgetKey;
|
|
348
|
-
name: string;
|
|
349
|
-
folder: string;
|
|
350
|
-
} | null;
|
|
351
|
-
|
|
352
|
-
export declare const remoteWidgetDiscovery: (manifestUrl: string) => Promise<{
|
|
353
|
-
entries: [string, IDynamicWidgetCatalogEntryBase][];
|
|
354
|
-
message: string;
|
|
355
|
-
details: string;
|
|
356
|
-
}>;
|
|
357
|
-
|
|
358
|
-
export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* @name resolveColorFromClass
|
|
362
|
-
* @description Resolves the current computed color using your existing CSS classes
|
|
363
|
-
* @param classNames, i.e. 'bg-primary'
|
|
364
|
-
* @param property to resolve, i.e. 'backgroundColor'
|
|
365
|
-
* @returns
|
|
366
|
-
*/
|
|
367
|
-
export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* @name TAddWidgetResponse
|
|
371
|
-
* @description Type for the response of the addWidget mutation
|
|
372
|
-
* @property {boolean} success - Indicates if the widget was added successfully
|
|
373
|
-
* @property {string} [message] - Optional message providing additional information
|
|
374
|
-
* @property {IDashboardConfig} updatedDashboardConfig - The updated dashboard configuration after adding the widget
|
|
375
|
-
* @property {IDashboardConfig[]} allUpdatedDashboardConfigs - All updated dashboard configurations
|
|
376
|
-
*/
|
|
377
|
-
export declare type TAddWidgetResponse = {
|
|
378
|
-
success: boolean;
|
|
379
|
-
message?: string;
|
|
380
|
-
updatedDashboardConfig: IDashboardConfig;
|
|
381
|
-
allUpdatedDashboardConfigs: IDashboardConfig[];
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
declare type TCoreResponse<T> = Omit<T, 'allUpdatedDashboardConfigs'>;
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* @name TDashboardUndoStatus
|
|
388
|
-
* @description Type for the dashboard undo/redo status
|
|
389
|
-
* @remarks Used in dashboard undo/redo functionality
|
|
390
|
-
*/
|
|
391
|
-
export declare type TDashboardUndoStatus = {
|
|
392
|
-
isUndoDisabled: boolean;
|
|
393
|
-
isRedoDisabled: boolean;
|
|
394
|
-
_currentIndex?: number;
|
|
395
|
-
_historyLength?: number;
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* @name TDashboardWidgetCatalogBase
|
|
400
|
-
* @description Map of available widgets used by the dashboard at runtime.
|
|
401
|
-
* @template TFrameworkElementType - Framework-specific element type
|
|
402
|
-
* @template TFrameworkComponentType - Framework-specific component type
|
|
403
|
-
* @remarks Keys are `TDashboardWidgetKey` and values are catalog entries. The
|
|
404
|
-
* map is typically treated as a read-only registry; replace the map to update
|
|
405
|
-
* the available widget set rather than mutating entries in-place.
|
|
406
|
-
*/
|
|
407
|
-
export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* @name TDashboardWidgetKey
|
|
411
|
-
* @description Type for the unique key identifying a dashboard widget.
|
|
412
|
-
* @remarks
|
|
413
|
-
* This is a simple alias for `string` to allow flexibility in widget keys.
|
|
414
|
-
* Recommended formats: stable short strings (e.g. `myApp.ChartWidget`),
|
|
415
|
-
* namespaced identifiers or UUIDs. Consumers should avoid empty strings.
|
|
416
|
-
*/
|
|
417
|
-
export declare type TDashboardWidgetKey = string;
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* @name TGetDefaultWidgetMetaFromKey
|
|
421
|
-
* @description Function that returns default `TWidgetMetaInfoBase` metadata for a widget key.
|
|
422
|
-
* @remarks Implementations should return a new object (not a shared reference)
|
|
423
|
-
* so callers can safely mutate the result if needed.
|
|
424
|
-
* @see TWidgetMetaInfoBase
|
|
425
|
-
* @see TGetDefaultWidgetMetaFromKeyOptions
|
|
426
|
-
* @returns `TWidgetMetaInfoBase`
|
|
427
|
-
*/
|
|
428
|
-
export declare type TGetDefaultWidgetMetaFromKey = (widgetKey: TDashboardWidgetKey, options?: TGetDefaultWidgetMetaFromKeyOptions) => TWidgetMetaInfoBase<any>;
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* @name TGetDefaultWidgetMetaFromKeyOptions
|
|
432
|
-
* @description Optional overrides when generating default widget metadata.
|
|
433
|
-
* @remarks Fields provided here override the generated metadata's `title`
|
|
434
|
-
* and/or `description`.
|
|
435
|
-
*/
|
|
436
|
-
export declare type TGetDefaultWidgetMetaFromKeyOptions = {
|
|
437
|
-
name?: string;
|
|
438
|
-
description?: string;
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* @name TGetSavedDashboards
|
|
443
|
-
* @description Function type to get saved dashboards for a user
|
|
444
|
-
* @remarks Used in IDashboardStorageService
|
|
445
|
-
* @see IDashboardConfig
|
|
446
|
-
* @see TDashboardWidgetCatalogBase
|
|
447
|
-
* @return Promise<IDashboardConfig[]>
|
|
448
|
-
*/
|
|
449
|
-
export declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* @name TManifestEntry
|
|
453
|
-
* @description Entry describing a remote widget manifest or resource.
|
|
454
|
-
* @remarks
|
|
455
|
-
* - `url` should point to the resource or manifest (absolute URLs recommended).
|
|
456
|
-
* - `meta` contains widget metadata (see `TWidgetMetaInfoBase`) describing the
|
|
457
|
-
* remotely loaded widget.
|
|
458
|
-
*/
|
|
459
|
-
export declare type TManifestEntry = {
|
|
460
|
-
url: string;
|
|
461
|
-
meta: TWidgetMetaInfoBase;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
export declare type TMoveWidgetResponse = TAddWidgetResponse;
|
|
465
|
-
|
|
466
|
-
export declare type TRemoveWidgetResponse = TAddWidgetResponse;
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* @name TSaveDashboards
|
|
470
|
-
* @description Function type to save dashboards for a user
|
|
471
|
-
* @remarks Used in IDashboardStorageService
|
|
472
|
-
* @see IDashboardConfig
|
|
473
|
-
* @see TDashboardWidgetCatalogBase
|
|
474
|
-
* @return Promise<boolean>
|
|
475
|
-
*/
|
|
476
|
-
export declare type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* @name TUndoHistoryEntry
|
|
480
|
-
* @description Type for an undo history entry
|
|
481
|
-
* @remarks Used in dashboard undo/redo functionality
|
|
482
|
-
* @see IDashboardConfig
|
|
483
|
-
*/
|
|
484
|
-
export declare type TUndoHistoryEntry = {
|
|
485
|
-
undoIndex: number;
|
|
486
|
-
config: IDashboardConfig;
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* @name TWidgetCategory
|
|
491
|
-
* @description Type for widget categories used for grouping and UI filters.
|
|
492
|
-
* @remarks
|
|
493
|
-
* Typical usage: categorizing widgets in a palette, grouping by behavior
|
|
494
|
-
* (for instance `Container` widgets may host child widgets).
|
|
495
|
-
*/
|
|
496
|
-
export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
497
|
-
|
|
498
|
-
/**
|
|
499
|
-
* @name TWidgetDirection
|
|
500
|
-
* @description Direction for layout flow inside container widgets.
|
|
501
|
-
* @remarks Only meaningful for container-type widgets that arrange children in
|
|
502
|
-
* either `row` or `column` flow.
|
|
503
|
-
*/
|
|
504
|
-
export declare type TWidgetDirection = 'row' | 'column';
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* @name TWidgetFactoryBase
|
|
508
|
-
* @description Async factory used to lazily load a framework component for a widget.
|
|
509
|
-
* @template TFrameworkComponent - Framework-specific component type (e.g., React component)
|
|
510
|
-
* @returns Promise resolving to an object with a `default` export containing the component.
|
|
511
|
-
* @remarks Implementations should throw on unrecoverable load errors so callers
|
|
512
|
-
* can handle fallbacks; returning a stub is also acceptable when documented.
|
|
513
|
-
*/
|
|
514
|
-
export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
|
|
515
|
-
default: TFrameworkComponent;
|
|
516
|
-
}>;
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* @name TWidgetMetaInfoBase
|
|
520
|
-
* @description Base metadata for a widget used by catalogs and tooling.
|
|
521
|
-
* @template TFrameworkElementType - Framework-specific element type (e.g. React element, Vue component)
|
|
522
|
-
* @remarks
|
|
523
|
-
* Fields:
|
|
524
|
-
* - `name` (required): Human readable widget name.
|
|
525
|
-
* - `description` (required): Short description shown in tooltips or catalog lists.
|
|
526
|
-
* - `categories` (required): One or more `TWidgetCategory` values used for grouping.
|
|
527
|
-
* - `noDuplicatedWidgets` (optional): When true, dashboard UI should prevent
|
|
528
|
-
* adding multiple instances of this widget.
|
|
529
|
-
* - `icon` (optional): Framework-specific icon element or component. May be
|
|
530
|
-
* `undefined` when not provided.
|
|
531
|
-
* - `externalDependencies` (required): Array of package identifiers or CDN
|
|
532
|
-
* references (e.g. `react@19.2.3`, `https://cdn.example.com/widget.js`). Use
|
|
533
|
-
* semantic versions or absolute URLs as appropriate.
|
|
534
|
-
*
|
|
535
|
-
* Example:
|
|
536
|
-
* {
|
|
537
|
-
* name: 'Simple Chart',
|
|
538
|
-
* description: 'Displays a time series',
|
|
539
|
-
* categories: ['Chart'],
|
|
540
|
-
* noDuplicatedWidgets: false,
|
|
541
|
-
* icon: undefined,
|
|
542
|
-
* externalDependencies: ['d3@7.0.0']
|
|
543
|
-
* }
|
|
544
|
-
*/
|
|
545
|
-
export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
|
|
546
|
-
name: string;
|
|
547
|
-
description: string;
|
|
548
|
-
categories: TWidgetCategory[];
|
|
549
|
-
noDuplicatedWidgets?: boolean;
|
|
550
|
-
icon?: TFrameworkElementType | string | undefined;
|
|
551
|
-
externalDependencies: string[];
|
|
552
|
-
tags?: string[];
|
|
553
|
-
noCollapse?: boolean;
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* @name TWidgetSize
|
|
558
|
-
* @description Size hint for widgets that can affect layout or styling.
|
|
559
|
-
* @remarks 'default' represents the standard size; 'large' and 'xlarge' are
|
|
560
|
-
* larger variants where the dashboard may allocate more grid cells.
|
|
561
|
-
*/
|
|
562
|
-
export declare type TWidgetSize = 'default' | 'large' | 'xlarge';
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* @name useDashboardStorageService
|
|
566
|
-
* @description
|
|
567
|
-
* LocalStorage-backed implementation of `IDashboardStorageService`.
|
|
568
|
-
*
|
|
569
|
-
* Behavior:
|
|
570
|
-
* - Persists an array of `IDashboardConfig` objects under the key
|
|
571
|
-
* `dashboards_<clientAppKey>_<userID>` in `localStorage`.
|
|
572
|
-
* - `getSavedDashboards` performs lightweight validation and normalization when
|
|
573
|
-
* reading saved data: fills missing `dashboardId`/`dashboardName`, sanitizes
|
|
574
|
-
* CSS settings, filters unknown widget keys, and clamps `zoomScale`.
|
|
575
|
-
* - `saveDashboards` filters invalid widget keys, ensures required metadata
|
|
576
|
-
* (`userID`, `clientAppKey`, `responsiveGrid`, `zoomScale`) and writes the
|
|
577
|
-
* JSON-serialized dashboards to `localStorage`.
|
|
578
|
-
*
|
|
579
|
-
* Notes / limitations:
|
|
580
|
-
* - Uses synchronous browser `localStorage` with limited quota — not suitable
|
|
581
|
-
* for very large datasets or high-frequency writes.
|
|
582
|
-
* - Does not provide server-side persistence or multi-user synchronization. To
|
|
583
|
-
* persist dashboards centrally, implement a custom service that adheres to
|
|
584
|
-
* `IDashboardStorageService` and replace this implementation.
|
|
585
|
-
*
|
|
586
|
-
* @returns An object implementing `IDashboardStorageService` with
|
|
587
|
-
* `getSavedDashboards` and `saveDashboards` methods.
|
|
588
|
-
*/
|
|
589
|
-
export declare const useDashboardStorageService: () => IDashboardStorageService;
|
|
590
|
-
|
|
591
|
-
export { }
|