@tenorlab/react-dashboard 1.5.26 → 1.5.42

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
@@ -373,3 +373,10 @@ This project is dual-licensed:
373
373
  2. **Commercial Use:** Requires a **Tenorlab Commercial License**.
374
374
 
375
375
  If you are using this library to build a revenue-generating product or within a commercial entity, please visit [https://payhip.com/b/gPBpo](https://payhip.com/b/gPBpo) to purchase a license.
376
+
377
+ ------
378
+
379
+ ## Links
380
+ [Official Website](https://www.tenorlab.com)
381
+ [Buy a icense](https://payhip.com/b/gPBpo)
382
+ [BlueSky](https://bsky.app/profile/tenorlab.bsky.social)
package/dist/core.d.ts CHANGED
@@ -70,6 +70,65 @@ export declare const dashboardSettingsUtils: {
70
70
  incrementOrDecrementValue: (item: IDashboardSettingEntry, direction: -1 | 1) => IDashboardSettingEntry;
71
71
  };
72
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
+
73
132
  export declare const DashboardZoomStep: 0.05;
74
133
 
75
134
  /**
@@ -294,6 +353,23 @@ export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig)
294
353
  */
295
354
  export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
296
355
 
356
+ /**
357
+ * @name TAddWidgetResponse
358
+ * @description Type for the response of the addWidget mutation
359
+ * @property {boolean} success - Indicates if the widget was added successfully
360
+ * @property {string} [message] - Optional message providing additional information
361
+ * @property {IDashboardConfig} updatedDashboardConfig - The updated dashboard configuration after adding the widget
362
+ * @property {IDashboardConfig[]} allUpdatedDashboardConfigs - All updated dashboard configurations
363
+ */
364
+ export declare type TAddWidgetResponse = {
365
+ success: boolean;
366
+ message?: string;
367
+ updatedDashboardConfig: IDashboardConfig;
368
+ allUpdatedDashboardConfigs: IDashboardConfig[];
369
+ };
370
+
371
+ declare type TCoreResponse<T> = Omit<T, 'allUpdatedDashboardConfigs'>;
372
+
297
373
  /**
298
374
  * @name TDashboardUndoStatus
299
375
  * @description Type for the dashboard undo/redo status
@@ -372,6 +448,10 @@ export declare type TManifestEntry = {
372
448
  meta: TWidgetMetaInfoBase;
373
449
  };
374
450
 
451
+ export declare type TMoveWidgetResponse = TAddWidgetResponse;
452
+
453
+ export declare type TRemoveWidgetResponse = TAddWidgetResponse;
454
+
375
455
  /**
376
456
  * @name TSaveDashboards
377
457
  * @description Function type to save dashboards for a user