@tenorlab/react-dashboard 1.4.7 → 1.5.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 +5 -3
- package/dist/core.d.ts +212 -18
- package/dist/core.es.js +12 -11
- package/dist/react-dashboard.d.ts +173 -13
- package/dist/react-dashboard.es.js +4 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ Import the base styles in your entry file (e.g., `main.tsx`):
|
|
|
37
37
|
TypeScript
|
|
38
38
|
|
|
39
39
|
```
|
|
40
|
-
import '@tenorlab/react-dashboard/
|
|
40
|
+
import '@tenorlab/react-dashboard/styles.css'
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
------
|
|
@@ -169,18 +169,20 @@ export const getWidgetCatalog = async (user: any | null): Promise<TDashboardWidg
|
|
|
169
169
|
catalogMapEntries.push(createStaticEntry('WidgetRecentPaymentInfo', WidgetRecentPaymentInfo))
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
// add bundled widgets (non-lazy)
|
|
172
173
|
catalogMapEntries.push(...localWidgetDiscovery(
|
|
173
174
|
bundledWidgetsSrcPath,
|
|
174
175
|
bundledWidgetModules,
|
|
175
176
|
allMetaModules,
|
|
176
|
-
false
|
|
177
|
+
false, // lazy: false
|
|
177
178
|
))
|
|
178
179
|
|
|
180
|
+
// add async-widgets (lazy)
|
|
179
181
|
catalogMapEntries.push(...localWidgetDiscovery(
|
|
180
182
|
asyncWidgetsSrcPath,
|
|
181
183
|
asyncWidgetModules,
|
|
182
184
|
allMetaModules,
|
|
183
|
-
true
|
|
185
|
+
true, // lazy: true
|
|
184
186
|
))
|
|
185
187
|
|
|
186
188
|
// Optional: Remote discovery of -pre-built widgets hosted on a CDN
|
package/dist/core.d.ts
CHANGED
|
@@ -111,11 +111,24 @@ export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, dire
|
|
|
111
111
|
*/
|
|
112
112
|
export declare const getWidgetMetaFromCatalog: <TFrameworkElementType = any, TFrameworkComponentType = any>(widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>) => TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* @name IChildWidgetConfigEntry
|
|
116
|
+
* @description Interface for a child widget configuration entry
|
|
117
|
+
* @remarks Used in IDashboardConfig
|
|
118
|
+
* @see IDashboardConfig
|
|
119
|
+
*/
|
|
114
120
|
export declare interface IChildWidgetConfigEntry {
|
|
115
121
|
parentWidgetKey: TDashboardWidgetKey;
|
|
116
122
|
widgetKey: TDashboardWidgetKey;
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @name IDashboardConfig
|
|
127
|
+
* @description Interface for the dashboard configuration
|
|
128
|
+
* @remarks Used to store the dashboard state
|
|
129
|
+
* @see IChildWidgetConfigEntry
|
|
130
|
+
* @see IDashboardSettingEntry
|
|
131
|
+
*/
|
|
119
132
|
export declare interface IDashboardConfig {
|
|
120
133
|
userID: number | string;
|
|
121
134
|
clientAppKey: string;
|
|
@@ -130,12 +143,26 @@ export declare interface IDashboardConfig {
|
|
|
130
143
|
_stateDescription?: string;
|
|
131
144
|
}
|
|
132
145
|
|
|
146
|
+
/**
|
|
147
|
+
* @name IDashboardGridPropsBase
|
|
148
|
+
* @description Base interface for dashboard grid props passed to widgets.
|
|
149
|
+
* @remarks
|
|
150
|
+
* - `zoomScale` represents a uniform zoom applied to the dashboard UI. Default
|
|
151
|
+
* behavior in the runtime clamps this value to a minimum of `0.7` and default
|
|
152
|
+
* is `1` when not explicitly set.
|
|
153
|
+
* - `responsiveGrid` toggles responsive layout behaviors vs fixed grid sizing.
|
|
154
|
+
*/
|
|
133
155
|
export declare interface IDashboardGridPropsBase {
|
|
134
156
|
isEditing: boolean;
|
|
135
157
|
zoomScale: number;
|
|
136
158
|
responsiveGrid: boolean;
|
|
137
159
|
}
|
|
138
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @name IDashboardSettingEntry
|
|
163
|
+
* @description Interface for a dashboard setting entry
|
|
164
|
+
* @see cssSettingsCatalog in dashboard-settings.ts
|
|
165
|
+
*/
|
|
139
166
|
export declare interface IDashboardSettingEntry {
|
|
140
167
|
key: string;
|
|
141
168
|
name: string;
|
|
@@ -148,11 +175,35 @@ export declare interface IDashboardSettingEntry {
|
|
|
148
175
|
value: string;
|
|
149
176
|
}
|
|
150
177
|
|
|
178
|
+
/**
|
|
179
|
+
* @name IDashboardStorageService
|
|
180
|
+
* @description Interface for the dashboard storage service
|
|
181
|
+
* @remarks Used to define the storage service methods
|
|
182
|
+
* @see TGetSavedDashboards
|
|
183
|
+
* @see TSaveDashboards
|
|
184
|
+
* @see IDashboardConfig
|
|
185
|
+
*/
|
|
151
186
|
export declare interface IDashboardStorageService {
|
|
152
187
|
getSavedDashboards: TGetSavedDashboards;
|
|
153
188
|
saveDashboards: TSaveDashboards;
|
|
154
189
|
}
|
|
155
190
|
|
|
191
|
+
/**
|
|
192
|
+
* @name IDashboardWidgetPropsBase
|
|
193
|
+
* @description Props provided to every widget instance rendered by the dashboard.
|
|
194
|
+
* @template TExtraProps - Additional, widget-specific props supplied by the
|
|
195
|
+
* dashboard or integrator via the dynamic loader.
|
|
196
|
+
* @remarks
|
|
197
|
+
* - `index` and `maxIndex` indicate the widget's position and the current
|
|
198
|
+
* maximum index used for ordering (zero-based indexing is typical).
|
|
199
|
+
* - `widgetKey` is the stable `TDashboardWidgetKey` identifying the widget
|
|
200
|
+
* type; `parentWidgetKey` is set for nested/child widgets.
|
|
201
|
+
* - Boolean flags like `hideTitle`, `noShadow`, `noBorder`, `noPadding` are
|
|
202
|
+
* layout/presentation hints; default behavior should be documented by the
|
|
203
|
+
* concrete widget implementation.
|
|
204
|
+
* - `direction` applies to container widgets only.
|
|
205
|
+
* - `extraProps` is merged into the widget props by the `DynamicWidgetLoader`.
|
|
206
|
+
*/
|
|
156
207
|
export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
157
208
|
index: number;
|
|
158
209
|
maxIndex: number;
|
|
@@ -174,12 +225,23 @@ export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
|
174
225
|
}
|
|
175
226
|
|
|
176
227
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
228
|
+
* @name IDynamicWidgetCatalogEntryBase
|
|
229
|
+
* @description Catalog entry describing how to create or load a widget.
|
|
230
|
+
* @template TFrameworkElementType - Framework-specific element type (icon, element)
|
|
231
|
+
* @template TFrameworkComponentType - Framework-specific component type
|
|
232
|
+
* @remarks
|
|
233
|
+
* - `key` must be unique and stable across versions because it is stored in
|
|
234
|
+
* saved dashboard configurations.
|
|
235
|
+
* - `title` is the display name for catalogs and selection UIs.
|
|
236
|
+
* - `isContainer` indicates a widget that can host children.
|
|
237
|
+
* - `isRemote` marks entries that are expected to be loaded remotely (CDN,
|
|
238
|
+
* external script) and may require extra loading/initialization steps.
|
|
239
|
+
* - `meta` contains presentation metadata (see `TWidgetMetaInfoBase`).
|
|
240
|
+
* - `component` is a direct component reference (preferred for static/core widgets).
|
|
241
|
+
* - `loader` is an async factory used for dynamic/plugin widgets. When both
|
|
242
|
+
* `component` and `loader` are provided, loaders are typically used for
|
|
243
|
+
* dynamic initialization; concrete loaders/components precedence should be
|
|
244
|
+
* defined by the integrator.
|
|
183
245
|
*/
|
|
184
246
|
export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType = any, TFrameworkComponentType = any> {
|
|
185
247
|
key: TDashboardWidgetKey;
|
|
@@ -204,13 +266,14 @@ export declare const parseContainerTitle: (containerWidgetKey: TDashboardWidgetK
|
|
|
204
266
|
/**
|
|
205
267
|
* Enhanced helper to derive key and title from widget file paths.
|
|
206
268
|
* Handles:
|
|
269
|
+
* - widget-total-orders -> WidgetTotalOrders
|
|
207
270
|
* - widget-revenue-trends1 -> WidgetRevenueTrends1
|
|
208
271
|
* - widget-with-extraprops -> WidgetWithExtraprops
|
|
209
272
|
* - widget-revenue-trends-async -> WidgetRevenueTrendsAsync
|
|
210
273
|
*/
|
|
211
274
|
export declare const parseKeyAndTitleFromFilePath: (path: string) => {
|
|
212
275
|
key: TDashboardWidgetKey;
|
|
213
|
-
|
|
276
|
+
name: string;
|
|
214
277
|
folder: string;
|
|
215
278
|
} | null;
|
|
216
279
|
|
|
@@ -231,6 +294,11 @@ export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig)
|
|
|
231
294
|
*/
|
|
232
295
|
export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
|
|
233
296
|
|
|
297
|
+
/**
|
|
298
|
+
* @name TDashboardUndoStatus
|
|
299
|
+
* @description Type for the dashboard undo/redo status
|
|
300
|
+
* @remarks Used in dashboard undo/redo functionality
|
|
301
|
+
*/
|
|
234
302
|
export declare type TDashboardUndoStatus = {
|
|
235
303
|
isUndoDisabled: boolean;
|
|
236
304
|
isRedoDisabled: boolean;
|
|
@@ -238,64 +306,190 @@ export declare type TDashboardUndoStatus = {
|
|
|
238
306
|
_historyLength?: number;
|
|
239
307
|
};
|
|
240
308
|
|
|
309
|
+
/**
|
|
310
|
+
* @name TDashboardWidgetCatalogBase
|
|
311
|
+
* @description Map of available widgets used by the dashboard at runtime.
|
|
312
|
+
* @template TFrameworkElementType - Framework-specific element type
|
|
313
|
+
* @template TFrameworkComponentType - Framework-specific component type
|
|
314
|
+
* @remarks Keys are `TDashboardWidgetKey` and values are catalog entries. The
|
|
315
|
+
* map is typically treated as a read-only registry; replace the map to update
|
|
316
|
+
* the available widget set rather than mutating entries in-place.
|
|
317
|
+
*/
|
|
241
318
|
export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
|
|
242
319
|
|
|
320
|
+
/**
|
|
321
|
+
* @name TDashboardWidgetKey
|
|
322
|
+
* @description Type for the unique key identifying a dashboard widget.
|
|
323
|
+
* @remarks
|
|
324
|
+
* This is a simple alias for `string` to allow flexibility in widget keys.
|
|
325
|
+
* Recommended formats: stable short strings (e.g. `myApp.ChartWidget`),
|
|
326
|
+
* namespaced identifiers or UUIDs. Consumers should avoid empty strings.
|
|
327
|
+
*/
|
|
243
328
|
export declare type TDashboardWidgetKey = string;
|
|
244
329
|
|
|
330
|
+
/**
|
|
331
|
+
* @name TGetDefaultWidgetMetaFromKey
|
|
332
|
+
* @description Function that returns default `TWidgetMetaInfoBase` metadata for a widget key.
|
|
333
|
+
* @remarks Implementations should return a new object (not a shared reference)
|
|
334
|
+
* so callers can safely mutate the result if needed.
|
|
335
|
+
* @see TWidgetMetaInfoBase
|
|
336
|
+
* @see TGetDefaultWidgetMetaFromKeyOptions
|
|
337
|
+
* @returns `TWidgetMetaInfoBase`
|
|
338
|
+
*/
|
|
245
339
|
export declare type TGetDefaultWidgetMetaFromKey = (widgetKey: TDashboardWidgetKey, options?: TGetDefaultWidgetMetaFromKeyOptions) => TWidgetMetaInfoBase<any>;
|
|
246
340
|
|
|
341
|
+
/**
|
|
342
|
+
* @name TGetDefaultWidgetMetaFromKeyOptions
|
|
343
|
+
* @description Optional overrides when generating default widget metadata.
|
|
344
|
+
* @remarks Fields provided here override the generated metadata's `title`
|
|
345
|
+
* and/or `description`.
|
|
346
|
+
*/
|
|
247
347
|
export declare type TGetDefaultWidgetMetaFromKeyOptions = {
|
|
248
|
-
|
|
348
|
+
name?: string;
|
|
249
349
|
description?: string;
|
|
250
350
|
};
|
|
251
351
|
|
|
352
|
+
/**
|
|
353
|
+
* @name TGetSavedDashboards
|
|
354
|
+
* @description Function type to get saved dashboards for a user
|
|
355
|
+
* @remarks Used in IDashboardStorageService
|
|
356
|
+
* @see IDashboardConfig
|
|
357
|
+
* @see TDashboardWidgetCatalogBase
|
|
358
|
+
* @return Promise<IDashboardConfig[]>
|
|
359
|
+
*/
|
|
252
360
|
export declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
253
361
|
|
|
362
|
+
/**
|
|
363
|
+
* @name TManifestEntry
|
|
364
|
+
* @description Entry describing a remote widget manifest or resource.
|
|
365
|
+
* @remarks
|
|
366
|
+
* - `url` should point to the resource or manifest (absolute URLs recommended).
|
|
367
|
+
* - `meta` contains widget metadata (see `TWidgetMetaInfoBase`) describing the
|
|
368
|
+
* remotely loaded widget.
|
|
369
|
+
*/
|
|
254
370
|
export declare type TManifestEntry = {
|
|
255
371
|
url: string;
|
|
256
372
|
meta: TWidgetMetaInfoBase;
|
|
257
373
|
};
|
|
258
374
|
|
|
375
|
+
/**
|
|
376
|
+
* @name TSaveDashboards
|
|
377
|
+
* @description Function type to save dashboards for a user
|
|
378
|
+
* @remarks Used in IDashboardStorageService
|
|
379
|
+
* @see IDashboardConfig
|
|
380
|
+
* @see TDashboardWidgetCatalogBase
|
|
381
|
+
* @return Promise<boolean>
|
|
382
|
+
*/
|
|
259
383
|
export declare type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
|
|
260
384
|
|
|
385
|
+
/**
|
|
386
|
+
* @name TUndoHistoryEntry
|
|
387
|
+
* @description Type for an undo history entry
|
|
388
|
+
* @remarks Used in dashboard undo/redo functionality
|
|
389
|
+
* @see IDashboardConfig
|
|
390
|
+
*/
|
|
261
391
|
export declare type TUndoHistoryEntry = {
|
|
262
392
|
undoIndex: number;
|
|
263
393
|
config: IDashboardConfig;
|
|
264
394
|
};
|
|
265
395
|
|
|
396
|
+
/**
|
|
397
|
+
* @name TWidgetCategory
|
|
398
|
+
* @description Type for widget categories used for grouping and UI filters.
|
|
399
|
+
* @remarks
|
|
400
|
+
* Typical usage: categorizing widgets in a palette, grouping by behavior
|
|
401
|
+
* (for instance `Container` widgets may host child widgets).
|
|
402
|
+
*/
|
|
266
403
|
export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
267
404
|
|
|
405
|
+
/**
|
|
406
|
+
* @name TWidgetDirection
|
|
407
|
+
* @description Direction for layout flow inside container widgets.
|
|
408
|
+
* @remarks Only meaningful for container-type widgets that arrange children in
|
|
409
|
+
* either `row` or `column` flow.
|
|
410
|
+
*/
|
|
268
411
|
export declare type TWidgetDirection = 'row' | 'column';
|
|
269
412
|
|
|
270
413
|
/**
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
414
|
+
* @name TWidgetFactoryBase
|
|
415
|
+
* @description Async factory used to lazily load a framework component for a widget.
|
|
416
|
+
* @template TFrameworkComponent - Framework-specific component type (e.g., React component)
|
|
417
|
+
* @returns Promise resolving to an object with a `default` export containing the component.
|
|
418
|
+
* @remarks Implementations should throw on unrecoverable load errors so callers
|
|
419
|
+
* can handle fallbacks; returning a stub is also acceptable when documented.
|
|
277
420
|
*/
|
|
278
421
|
export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
|
|
279
422
|
default: TFrameworkComponent;
|
|
280
423
|
}>;
|
|
281
424
|
|
|
425
|
+
/**
|
|
426
|
+
* @name TWidgetMetaInfoBase
|
|
427
|
+
* @description Base metadata for a widget used by catalogs and tooling.
|
|
428
|
+
* @template TFrameworkElementType - Framework-specific element type (e.g. React element, Vue component)
|
|
429
|
+
* @remarks
|
|
430
|
+
* Fields:
|
|
431
|
+
* - `name` (required): Human readable widget name.
|
|
432
|
+
* - `description` (required): Short description shown in tooltips or catalog lists.
|
|
433
|
+
* - `categories` (required): One or more `TWidgetCategory` values used for grouping.
|
|
434
|
+
* - `noDuplicatedWidgets` (optional): When true, dashboard UI should prevent
|
|
435
|
+
* adding multiple instances of this widget.
|
|
436
|
+
* - `icon` (optional): Framework-specific icon element or component. May be
|
|
437
|
+
* `undefined` when not provided.
|
|
438
|
+
* - `externalDependencies` (required): Array of package identifiers or CDN
|
|
439
|
+
* references (e.g. `react@19.2.3`, `https://cdn.example.com/widget.js`). Use
|
|
440
|
+
* semantic versions or absolute URLs as appropriate.
|
|
441
|
+
*
|
|
442
|
+
* Example:
|
|
443
|
+
* {
|
|
444
|
+
* name: 'Simple Chart',
|
|
445
|
+
* description: 'Displays a time series',
|
|
446
|
+
* categories: ['Chart'],
|
|
447
|
+
* noDuplicatedWidgets: false,
|
|
448
|
+
* icon: undefined,
|
|
449
|
+
* externalDependencies: ['d3@7.0.0']
|
|
450
|
+
* }
|
|
451
|
+
*/
|
|
282
452
|
export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
|
|
283
453
|
name: string;
|
|
284
454
|
description: string;
|
|
285
455
|
categories: TWidgetCategory[];
|
|
286
456
|
noDuplicatedWidgets?: boolean;
|
|
287
|
-
icon
|
|
457
|
+
icon?: TFrameworkElementType | undefined;
|
|
288
458
|
externalDependencies: string[];
|
|
289
459
|
};
|
|
290
460
|
|
|
461
|
+
/**
|
|
462
|
+
* @name TWidgetSize
|
|
463
|
+
* @description Size hint for widgets that can affect layout or styling.
|
|
464
|
+
* @remarks 'default' represents the standard size; 'large' and 'xlarge' are
|
|
465
|
+
* larger variants where the dashboard may allocate more grid cells.
|
|
466
|
+
*/
|
|
291
467
|
export declare type TWidgetSize = 'default' | 'large' | 'xlarge';
|
|
292
468
|
|
|
293
469
|
/**
|
|
294
470
|
* @name useDashboardStorageService
|
|
295
471
|
* @description
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
472
|
+
* LocalStorage-backed implementation of `IDashboardStorageService`.
|
|
473
|
+
*
|
|
474
|
+
* Behavior:
|
|
475
|
+
* - Persists an array of `IDashboardConfig` objects under the key
|
|
476
|
+
* `dashboards_<clientAppKey>_<userID>` in `localStorage`.
|
|
477
|
+
* - `getSavedDashboards` performs lightweight validation and normalization when
|
|
478
|
+
* reading saved data: fills missing `dashboardId`/`dashboardName`, sanitizes
|
|
479
|
+
* CSS settings, filters unknown widget keys, and clamps `zoomScale`.
|
|
480
|
+
* - `saveDashboards` filters invalid widget keys, ensures required metadata
|
|
481
|
+
* (`userID`, `clientAppKey`, `responsiveGrid`, `zoomScale`) and writes the
|
|
482
|
+
* JSON-serialized dashboards to `localStorage`.
|
|
483
|
+
*
|
|
484
|
+
* Notes / limitations:
|
|
485
|
+
* - Uses synchronous browser `localStorage` with limited quota — not suitable
|
|
486
|
+
* for very large datasets or high-frequency writes.
|
|
487
|
+
* - Does not provide server-side persistence or multi-user synchronization. To
|
|
488
|
+
* persist dashboards centrally, implement a custom service that adheres to
|
|
489
|
+
* `IDashboardStorageService` and replace this implementation.
|
|
490
|
+
*
|
|
491
|
+
* @returns An object implementing `IDashboardStorageService` with
|
|
492
|
+
* `getSavedDashboards` and `saveDashboards` methods.
|
|
299
493
|
*/
|
|
300
494
|
export declare const useDashboardStorageService: () => IDashboardStorageService;
|
|
301
495
|
|
package/dist/core.es.js
CHANGED
|
@@ -156,9 +156,9 @@ const w = [
|
|
|
156
156
|
}, U = (e) => {
|
|
157
157
|
const t = `${e}`.split("_");
|
|
158
158
|
return t.length > 1 ? t[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
|
|
159
|
-
},
|
|
159
|
+
}, u = 0.7, p = 1, V = 0.05, D = (e) => {
|
|
160
160
|
let t = Number(e || 0);
|
|
161
|
-
return t <
|
|
161
|
+
return t < u && (t = u), t > p && (t = p), t;
|
|
162
162
|
}, j = (e, t) => {
|
|
163
163
|
let a = Number(Number((V * t).toFixed(2)).toFixed(2)), i = Number((Number(e) + a).toFixed(2));
|
|
164
164
|
return D(i);
|
|
@@ -193,7 +193,7 @@ const w = [
|
|
|
193
193
|
parentWidgetKey: n || s
|
|
194
194
|
};
|
|
195
195
|
}), e;
|
|
196
|
-
},
|
|
196
|
+
}, m = (e, t) => {
|
|
197
197
|
const a = `${e}`.includes("Container"), i = a ? ["Container"] : ["Widget"], s = t?.name || e, n = t?.description || (a ? "Container" : "Unknown");
|
|
198
198
|
return {
|
|
199
199
|
name: s,
|
|
@@ -203,8 +203,8 @@ const w = [
|
|
|
203
203
|
icon: void 0,
|
|
204
204
|
externalDependencies: []
|
|
205
205
|
};
|
|
206
|
-
}, I = (e, t, a) => t[e] ||
|
|
207
|
-
const i = a ||
|
|
206
|
+
}, I = (e, t, a) => t[e] || m(e, a), M = (e, t) => t.get(e)?.meta || m(e), k = (e, t, a) => {
|
|
207
|
+
const i = a || m(e);
|
|
208
208
|
return [
|
|
209
209
|
e,
|
|
210
210
|
{
|
|
@@ -217,7 +217,7 @@ const w = [
|
|
|
217
217
|
}
|
|
218
218
|
];
|
|
219
219
|
}, h = (e, t, a, i) => {
|
|
220
|
-
const s = i ||
|
|
220
|
+
const s = i || m(e);
|
|
221
221
|
return [
|
|
222
222
|
e,
|
|
223
223
|
{
|
|
@@ -235,7 +235,7 @@ const w = [
|
|
|
235
235
|
const a = t[1], i = a.split("-"), s = `Widget${i.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join("")}`, n = i.map((r) => r.charAt(0).toUpperCase() + r.slice(1)).join(" ");
|
|
236
236
|
return {
|
|
237
237
|
key: s,
|
|
238
|
-
|
|
238
|
+
name: n,
|
|
239
239
|
folder: a
|
|
240
240
|
};
|
|
241
241
|
}
|
|
@@ -282,9 +282,10 @@ const w = [
|
|
|
282
282
|
for (const n in t) {
|
|
283
283
|
const r = t[n], c = F(n);
|
|
284
284
|
if (c && r) {
|
|
285
|
-
const { key: o,
|
|
285
|
+
const { key: o, name: d, folder: l } = c;
|
|
286
286
|
let g = $(a, e, l, o);
|
|
287
|
-
if (g || (g =
|
|
287
|
+
if (g || (g = m(o, {
|
|
288
|
+
name: d,
|
|
288
289
|
description: `Local ${i ? "dynamic" : "static"} widget`
|
|
289
290
|
})), i)
|
|
290
291
|
s.push(
|
|
@@ -343,7 +344,7 @@ const w = [
|
|
|
343
344
|
].join(" ").trim();
|
|
344
345
|
export {
|
|
345
346
|
p as DashboardMaxZoomScale,
|
|
346
|
-
|
|
347
|
+
u as DashboardMinZoomScale,
|
|
347
348
|
V as DashboardZoomStep,
|
|
348
349
|
z as blankDashboardConfig,
|
|
349
350
|
h as createDynamicEntry,
|
|
@@ -353,7 +354,7 @@ export {
|
|
|
353
354
|
E as dashboardSettingsUtils,
|
|
354
355
|
x as ensureContainersSequence,
|
|
355
356
|
D as ensureZoomScaleIsWithinRange,
|
|
356
|
-
|
|
357
|
+
m as getDefaultWidgetMetaFromKey,
|
|
357
358
|
I as getDefaultWidgetMetaFromMap,
|
|
358
359
|
Z as getDistinctCssClasses,
|
|
359
360
|
$ as getMetaInfoFromFile,
|
|
@@ -78,11 +78,24 @@ export declare interface IButtonProps {
|
|
|
78
78
|
tooltip?: ITooltipProps;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* @name IChildWidgetConfigEntry
|
|
83
|
+
* @description Interface for a child widget configuration entry
|
|
84
|
+
* @remarks Used in IDashboardConfig
|
|
85
|
+
* @see IDashboardConfig
|
|
86
|
+
*/
|
|
81
87
|
export declare interface IChildWidgetConfigEntry {
|
|
82
88
|
parentWidgetKey: TDashboardWidgetKey;
|
|
83
89
|
widgetKey: TDashboardWidgetKey;
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
/**
|
|
93
|
+
* @name IDashboardConfig
|
|
94
|
+
* @description Interface for the dashboard configuration
|
|
95
|
+
* @remarks Used to store the dashboard state
|
|
96
|
+
* @see IChildWidgetConfigEntry
|
|
97
|
+
* @see IDashboardSettingEntry
|
|
98
|
+
*/
|
|
86
99
|
export declare interface IDashboardConfig {
|
|
87
100
|
userID: number | string;
|
|
88
101
|
clientAppKey: string;
|
|
@@ -106,12 +119,26 @@ export declare interface IDashboardGridProps extends IDashboardGridPropsBase {
|
|
|
106
119
|
children?: ReactNode;
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
/**
|
|
123
|
+
* @name IDashboardGridPropsBase
|
|
124
|
+
* @description Base interface for dashboard grid props passed to widgets.
|
|
125
|
+
* @remarks
|
|
126
|
+
* - `zoomScale` represents a uniform zoom applied to the dashboard UI. Default
|
|
127
|
+
* behavior in the runtime clamps this value to a minimum of `0.7` and default
|
|
128
|
+
* is `1` when not explicitly set.
|
|
129
|
+
* - `responsiveGrid` toggles responsive layout behaviors vs fixed grid sizing.
|
|
130
|
+
*/
|
|
109
131
|
export declare interface IDashboardGridPropsBase {
|
|
110
132
|
isEditing: boolean;
|
|
111
133
|
zoomScale: number;
|
|
112
134
|
responsiveGrid: boolean;
|
|
113
135
|
}
|
|
114
136
|
|
|
137
|
+
/**
|
|
138
|
+
* @name IDashboardSettingEntry
|
|
139
|
+
* @description Interface for a dashboard setting entry
|
|
140
|
+
* @see cssSettingsCatalog in dashboard-settings.ts
|
|
141
|
+
*/
|
|
115
142
|
export declare interface IDashboardSettingEntry {
|
|
116
143
|
key: string;
|
|
117
144
|
name: string;
|
|
@@ -124,6 +151,14 @@ export declare interface IDashboardSettingEntry {
|
|
|
124
151
|
value: string;
|
|
125
152
|
}
|
|
126
153
|
|
|
154
|
+
/**
|
|
155
|
+
* @name IDashboardStorageService
|
|
156
|
+
* @description Interface for the dashboard storage service
|
|
157
|
+
* @remarks Used to define the storage service methods
|
|
158
|
+
* @see TGetSavedDashboards
|
|
159
|
+
* @see TSaveDashboards
|
|
160
|
+
* @see IDashboardConfig
|
|
161
|
+
*/
|
|
127
162
|
export declare interface IDashboardStorageService {
|
|
128
163
|
getSavedDashboards: TGetSavedDashboards;
|
|
129
164
|
saveDashboards: TSaveDashboards;
|
|
@@ -150,6 +185,22 @@ export declare interface IDashboardWidgetProps<TExtraProps = any> extends IDashb
|
|
|
150
185
|
selectContainer?: (containerKey?: TDashboardWidgetKey) => void;
|
|
151
186
|
}
|
|
152
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @name IDashboardWidgetPropsBase
|
|
190
|
+
* @description Props provided to every widget instance rendered by the dashboard.
|
|
191
|
+
* @template TExtraProps - Additional, widget-specific props supplied by the
|
|
192
|
+
* dashboard or integrator via the dynamic loader.
|
|
193
|
+
* @remarks
|
|
194
|
+
* - `index` and `maxIndex` indicate the widget's position and the current
|
|
195
|
+
* maximum index used for ordering (zero-based indexing is typical).
|
|
196
|
+
* - `widgetKey` is the stable `TDashboardWidgetKey` identifying the widget
|
|
197
|
+
* type; `parentWidgetKey` is set for nested/child widgets.
|
|
198
|
+
* - Boolean flags like `hideTitle`, `noShadow`, `noBorder`, `noPadding` are
|
|
199
|
+
* layout/presentation hints; default behavior should be documented by the
|
|
200
|
+
* concrete widget implementation.
|
|
201
|
+
* - `direction` applies to container widgets only.
|
|
202
|
+
* - `extraProps` is merged into the widget props by the `DynamicWidgetLoader`.
|
|
203
|
+
*/
|
|
153
204
|
export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
154
205
|
index: number;
|
|
155
206
|
maxIndex: number;
|
|
@@ -181,12 +232,23 @@ export declare interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalo
|
|
|
181
232
|
}
|
|
182
233
|
|
|
183
234
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
235
|
+
* @name IDynamicWidgetCatalogEntryBase
|
|
236
|
+
* @description Catalog entry describing how to create or load a widget.
|
|
237
|
+
* @template TFrameworkElementType - Framework-specific element type (icon, element)
|
|
238
|
+
* @template TFrameworkComponentType - Framework-specific component type
|
|
239
|
+
* @remarks
|
|
240
|
+
* - `key` must be unique and stable across versions because it is stored in
|
|
241
|
+
* saved dashboard configurations.
|
|
242
|
+
* - `title` is the display name for catalogs and selection UIs.
|
|
243
|
+
* - `isContainer` indicates a widget that can host children.
|
|
244
|
+
* - `isRemote` marks entries that are expected to be loaded remotely (CDN,
|
|
245
|
+
* external script) and may require extra loading/initialization steps.
|
|
246
|
+
* - `meta` contains presentation metadata (see `TWidgetMetaInfoBase`).
|
|
247
|
+
* - `component` is a direct component reference (preferred for static/core widgets).
|
|
248
|
+
* - `loader` is an async factory used for dynamic/plugin widgets. When both
|
|
249
|
+
* `component` and `loader` are provided, loaders are typically used for
|
|
250
|
+
* dynamic initialization; concrete loaders/components precedence should be
|
|
251
|
+
* defined by the integrator.
|
|
190
252
|
*/
|
|
191
253
|
export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType = any, TFrameworkComponentType = any> {
|
|
192
254
|
key: TDashboardWidgetKey;
|
|
@@ -297,6 +359,11 @@ declare type TDashboardSlice = {
|
|
|
297
359
|
|
|
298
360
|
export declare type TDashboardUndoService = ReturnType<typeof useDashboardUndoService>;
|
|
299
361
|
|
|
362
|
+
/**
|
|
363
|
+
* @name TDashboardUndoStatus
|
|
364
|
+
* @description Type for the dashboard undo/redo status
|
|
365
|
+
* @remarks Used in dashboard undo/redo functionality
|
|
366
|
+
*/
|
|
300
367
|
export declare type TDashboardUndoStatus = {
|
|
301
368
|
isUndoDisabled: boolean;
|
|
302
369
|
isRedoDisabled: boolean;
|
|
@@ -313,8 +380,25 @@ export declare type TDashboardUndoStatus = {
|
|
|
313
380
|
*/
|
|
314
381
|
export declare type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
|
|
315
382
|
|
|
383
|
+
/**
|
|
384
|
+
* @name TDashboardWidgetCatalogBase
|
|
385
|
+
* @description Map of available widgets used by the dashboard at runtime.
|
|
386
|
+
* @template TFrameworkElementType - Framework-specific element type
|
|
387
|
+
* @template TFrameworkComponentType - Framework-specific component type
|
|
388
|
+
* @remarks Keys are `TDashboardWidgetKey` and values are catalog entries. The
|
|
389
|
+
* map is typically treated as a read-only registry; replace the map to update
|
|
390
|
+
* the available widget set rather than mutating entries in-place.
|
|
391
|
+
*/
|
|
316
392
|
export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
|
|
317
393
|
|
|
394
|
+
/**
|
|
395
|
+
* @name TDashboardWidgetKey
|
|
396
|
+
* @description Type for the unique key identifying a dashboard widget.
|
|
397
|
+
* @remarks
|
|
398
|
+
* This is a simple alias for `string` to allow flexibility in widget keys.
|
|
399
|
+
* Recommended formats: stable short strings (e.g. `myApp.ChartWidget`),
|
|
400
|
+
* namespaced identifiers or UUIDs. Consumers should avoid empty strings.
|
|
401
|
+
*/
|
|
318
402
|
export declare type TDashboardWidgetKey = string;
|
|
319
403
|
|
|
320
404
|
declare type TDynamicWidgetLoaderProps<TExtraProps = any> = {
|
|
@@ -349,6 +433,14 @@ declare type TFrameworkComponentType = React.ComponentType<any>;
|
|
|
349
433
|
*/
|
|
350
434
|
declare type TFrameworkElementType = React.ElementType;
|
|
351
435
|
|
|
436
|
+
/**
|
|
437
|
+
* @name TGetSavedDashboards
|
|
438
|
+
* @description Function type to get saved dashboards for a user
|
|
439
|
+
* @remarks Used in IDashboardStorageService
|
|
440
|
+
* @see IDashboardConfig
|
|
441
|
+
* @see TDashboardWidgetCatalogBase
|
|
442
|
+
* @return Promise<IDashboardConfig[]>
|
|
443
|
+
*/
|
|
352
444
|
declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
353
445
|
|
|
354
446
|
declare type TIconProps = {
|
|
@@ -363,6 +455,14 @@ declare type TListItemChildProps = {
|
|
|
363
455
|
children?: ReactNode;
|
|
364
456
|
};
|
|
365
457
|
|
|
458
|
+
/**
|
|
459
|
+
* @name TManifestEntry
|
|
460
|
+
* @description Entry describing a remote widget manifest or resource.
|
|
461
|
+
* @remarks
|
|
462
|
+
* - `url` should point to the resource or manifest (absolute URLs recommended).
|
|
463
|
+
* - `meta` contains widget metadata (see `TWidgetMetaInfoBase`) describing the
|
|
464
|
+
* remotely loaded widget.
|
|
465
|
+
*/
|
|
366
466
|
export declare type TManifestEntry = {
|
|
367
467
|
url: string;
|
|
368
468
|
meta: TWidgetMetaInfoBase;
|
|
@@ -375,6 +475,14 @@ declare type TProps = {
|
|
|
375
475
|
|
|
376
476
|
declare type TRemoveWidgetResponse = TAddWidgetResponse;
|
|
377
477
|
|
|
478
|
+
/**
|
|
479
|
+
* @name TSaveDashboards
|
|
480
|
+
* @description Function type to save dashboards for a user
|
|
481
|
+
* @remarks Used in IDashboardStorageService
|
|
482
|
+
* @see IDashboardConfig
|
|
483
|
+
* @see TDashboardWidgetCatalogBase
|
|
484
|
+
* @return Promise<boolean>
|
|
485
|
+
*/
|
|
378
486
|
declare type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
|
|
379
487
|
|
|
380
488
|
declare type TSize = 'small' | 'medium';
|
|
@@ -387,13 +495,32 @@ export declare type TStackProps = {
|
|
|
387
495
|
children: React.ReactNode;
|
|
388
496
|
};
|
|
389
497
|
|
|
498
|
+
/**
|
|
499
|
+
* @name TUndoHistoryEntry
|
|
500
|
+
* @description Type for an undo history entry
|
|
501
|
+
* @remarks Used in dashboard undo/redo functionality
|
|
502
|
+
* @see IDashboardConfig
|
|
503
|
+
*/
|
|
390
504
|
export declare type TUndoHistoryEntry = {
|
|
391
505
|
undoIndex: number;
|
|
392
506
|
config: IDashboardConfig;
|
|
393
507
|
};
|
|
394
508
|
|
|
509
|
+
/**
|
|
510
|
+
* @name TWidgetCategory
|
|
511
|
+
* @description Type for widget categories used for grouping and UI filters.
|
|
512
|
+
* @remarks
|
|
513
|
+
* Typical usage: categorizing widgets in a palette, grouping by behavior
|
|
514
|
+
* (for instance `Container` widgets may host child widgets).
|
|
515
|
+
*/
|
|
395
516
|
export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
396
517
|
|
|
518
|
+
/**
|
|
519
|
+
* @name TWidgetDirection
|
|
520
|
+
* @description Direction for layout flow inside container widgets.
|
|
521
|
+
* @remarks Only meaningful for container-type widgets that arrange children in
|
|
522
|
+
* either `row` or `column` flow.
|
|
523
|
+
*/
|
|
397
524
|
export declare type TWidgetDirection = 'row' | 'column';
|
|
398
525
|
|
|
399
526
|
/**
|
|
@@ -405,12 +532,12 @@ export declare type TWidgetDirection = 'row' | 'column';
|
|
|
405
532
|
export declare type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
|
|
406
533
|
|
|
407
534
|
/**
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
535
|
+
* @name TWidgetFactoryBase
|
|
536
|
+
* @description Async factory used to lazily load a framework component for a widget.
|
|
537
|
+
* @template TFrameworkComponent - Framework-specific component type (e.g., React component)
|
|
538
|
+
* @returns Promise resolving to an object with a `default` export containing the component.
|
|
539
|
+
* @remarks Implementations should throw on unrecoverable load errors so callers
|
|
540
|
+
* can handle fallbacks; returning a stub is also acceptable when documented.
|
|
414
541
|
*/
|
|
415
542
|
export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
|
|
416
543
|
default: TFrameworkComponent;
|
|
@@ -423,12 +550,39 @@ export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promis
|
|
|
423
550
|
*/
|
|
424
551
|
export declare type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
|
|
425
552
|
|
|
553
|
+
/**
|
|
554
|
+
* @name TWidgetMetaInfoBase
|
|
555
|
+
* @description Base metadata for a widget used by catalogs and tooling.
|
|
556
|
+
* @template TFrameworkElementType - Framework-specific element type (e.g. React element, Vue component)
|
|
557
|
+
* @remarks
|
|
558
|
+
* Fields:
|
|
559
|
+
* - `name` (required): Human readable widget name.
|
|
560
|
+
* - `description` (required): Short description shown in tooltips or catalog lists.
|
|
561
|
+
* - `categories` (required): One or more `TWidgetCategory` values used for grouping.
|
|
562
|
+
* - `noDuplicatedWidgets` (optional): When true, dashboard UI should prevent
|
|
563
|
+
* adding multiple instances of this widget.
|
|
564
|
+
* - `icon` (optional): Framework-specific icon element or component. May be
|
|
565
|
+
* `undefined` when not provided.
|
|
566
|
+
* - `externalDependencies` (required): Array of package identifiers or CDN
|
|
567
|
+
* references (e.g. `react@19.2.3`, `https://cdn.example.com/widget.js`). Use
|
|
568
|
+
* semantic versions or absolute URLs as appropriate.
|
|
569
|
+
*
|
|
570
|
+
* Example:
|
|
571
|
+
* {
|
|
572
|
+
* name: 'Simple Chart',
|
|
573
|
+
* description: 'Displays a time series',
|
|
574
|
+
* categories: ['Chart'],
|
|
575
|
+
* noDuplicatedWidgets: false,
|
|
576
|
+
* icon: undefined,
|
|
577
|
+
* externalDependencies: ['d3@7.0.0']
|
|
578
|
+
* }
|
|
579
|
+
*/
|
|
426
580
|
export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
|
|
427
581
|
name: string;
|
|
428
582
|
description: string;
|
|
429
583
|
categories: TWidgetCategory[];
|
|
430
584
|
noDuplicatedWidgets?: boolean;
|
|
431
|
-
icon
|
|
585
|
+
icon?: TFrameworkElementType | undefined;
|
|
432
586
|
externalDependencies: string[];
|
|
433
587
|
};
|
|
434
588
|
|
|
@@ -445,6 +599,12 @@ export declare type TWidgetsCatalogFlyoutProps = {
|
|
|
445
599
|
onDoneClick: () => any;
|
|
446
600
|
};
|
|
447
601
|
|
|
602
|
+
/**
|
|
603
|
+
* @name TWidgetSize
|
|
604
|
+
* @description Size hint for widgets that can affect layout or styling.
|
|
605
|
+
* @remarks 'default' represents the standard size; 'large' and 'xlarge' are
|
|
606
|
+
* larger variants where the dashboard may allocate more grid cells.
|
|
607
|
+
*/
|
|
448
608
|
export declare type TWidgetSize = 'default' | 'large' | 'xlarge';
|
|
449
609
|
|
|
450
610
|
export declare function UndoIcon({ className }: TIconProps): JSX_2.Element;
|
|
@@ -2519,7 +2519,10 @@ function rn({
|
|
|
2519
2519
|
`${a.widgetKey}_${f}`
|
|
2520
2520
|
))
|
|
2521
2521
|
} : {};
|
|
2522
|
-
return C ? /* @__PURE__ */
|
|
2522
|
+
return C ? /* @__PURE__ */ $(xt, { fallback: /* @__PURE__ */ n(nn, { title: `Loading ${h.title}` }), children: [
|
|
2523
|
+
"]",
|
|
2524
|
+
/* @__PURE__ */ n(b, { ...l, ...M })
|
|
2525
|
+
] }) : /* @__PURE__ */ n(b, { ...l, ...M });
|
|
2523
2526
|
}
|
|
2524
2527
|
const ye = "size-5";
|
|
2525
2528
|
function Ie(e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenorlab/react-dashboard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Foundation components for creating user-configurable dashboards in React",
|
|
5
5
|
"author": "Damiano Fusco",
|
|
6
6
|
"type": "module",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"zustand": "^5.0.0 || ^5.0.9"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@tenorlab/dashboard-core": "^1.
|
|
57
|
+
"@tenorlab/dashboard-core": "^1.5.1",
|
|
58
58
|
"@types/node": "^24.10.1",
|
|
59
59
|
"@types/react": "19.2.3",
|
|
60
60
|
"@types/react-dom": "19.2.3",
|