@tenorlab/vue-dashboard 1.0.0
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 +49 -0
- package/dist/core.d.ts +301 -0
- package/dist/core.es.js +367 -0
- package/dist/styles.css +1 -0
- package/dist/vue-dashboard.d.ts +748 -0
- package/dist/vue-dashboard.es.js +1936 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @tenorlab/react-dashboard
|
|
2
|
+
|
|
3
|
+
Foundation components for creating user-configurable, high-performance dashboards in React.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### Part of the Built With JavaScript Ecosystem
|
|
8
|
+
**Tenorlab** is the specialized software foundry for the [@builtwithjavascript](https://github.com/builtwithjavascript) ecosystem, focusing on modular, type-safe utilities and UI kits.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Quick Start
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
Install the package via npm or pnpm:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @tenorlab/react-dashboard
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @tenorlab/react-dashboard
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Basic Usage
|
|
25
|
+
Import the styles in your entry tsx file (usually main.tsx):
|
|
26
|
+
```typescript
|
|
27
|
+
import '@tenorlab/react-dashboard/styles.css'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
TODO:
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **Type-Safe:** Built with TypeScript for excellent IDE support and error catching.
|
|
36
|
+
- **Configurable:** Allow end-users to add/remove widgets.
|
|
37
|
+
- **Vite Optimized:** Tree-shakeable and lightweight for modern build pipelines.
|
|
38
|
+
- **Themeable:** Easy integration with Tailwind CSS or CSS Variables.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Licensing
|
|
43
|
+
|
|
44
|
+
This project is dual-licensed:
|
|
45
|
+
|
|
46
|
+
1. **Non-Commercial / Personal Use:** Licensed under the [Polyform Non-Commercial 1.0.0](https://polyformproject.org/licenses/non-commercial/1.0.0/). Free to use for students, hobbyists, and open-source projects.
|
|
47
|
+
2. **Commercial Use:** Requires a **Tenorlab Commercial License**.
|
|
48
|
+
|
|
49
|
+
If you are using this library to build a product that generates revenue, or within a commercial entity, please visit [tenorlab.com/license](https://tenorlab.com/license) to purchase a commercial seat.
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
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, 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
|
+
export declare const DashboardZoomStep: 0.05;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @name ensureContainersSequence
|
|
77
|
+
* @description
|
|
78
|
+
* Ensures that the container widgets are numbered sequentially in the dashboardConfig, but the original order is preserved.
|
|
79
|
+
*/
|
|
80
|
+
export declare const ensureContainersSequence: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
81
|
+
|
|
82
|
+
export declare const ensureZoomScaleIsWithinRange: (value: number) => number;
|
|
83
|
+
|
|
84
|
+
export declare const getDefaultWidgetMetaFromKey: TGetDefaultWidgetMetaFromKey;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @name getDefaultWidgetMetaFromMap
|
|
88
|
+
* @description Helper to get widget meta info from the catalog by key.
|
|
89
|
+
*/
|
|
90
|
+
export declare const getDefaultWidgetMetaFromMap: <TFrameworkElementType = any>(widgetKey: TDashboardWidgetKey, defaultWidgetMetaMap: Record<TDashboardWidgetKey, TWidgetMetaInfoBase<TFrameworkElementType>>, options?: {
|
|
91
|
+
title?: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
}) => TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @name getDistinctCssClasses
|
|
97
|
+
* @description Ensures a distinct list off css classes, avoiding duplicates
|
|
98
|
+
* @param defaultClasses
|
|
99
|
+
* @param additionalClasses
|
|
100
|
+
* @returns the distinct list as a string
|
|
101
|
+
*/
|
|
102
|
+
export declare const getDistinctCssClasses: (defaultClasses: string, ...additionalClasses: string[]) => string;
|
|
103
|
+
|
|
104
|
+
export declare const getMetaInfoFromFile: (widgetMetaModules: Record<string, Record<string, TWidgetMetaInfoBase>>, baseSrcPath: string, folder: string, key: string) => TWidgetMetaInfoBase | undefined;
|
|
105
|
+
|
|
106
|
+
export declare const getNewZoomScaleWithinRange: (currentZoomScale: number, direction: -1 | 1) => number;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @name getWidgetMetaFromCatalog
|
|
110
|
+
* @description Helper to get widget meta info from the catalog by key.
|
|
111
|
+
*/
|
|
112
|
+
export declare const getWidgetMetaFromCatalog: <TFrameworkElementType = any, TFrameworkComponentType = any>(widgetKey: TDashboardWidgetKey, widgetsCatalog: TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>) => TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
113
|
+
|
|
114
|
+
export declare interface IChildWidgetConfigEntry {
|
|
115
|
+
parentWidgetKey: TDashboardWidgetKey;
|
|
116
|
+
widgetKey: TDashboardWidgetKey;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare interface IDashboardConfig {
|
|
120
|
+
userID: number | string;
|
|
121
|
+
clientAppKey: string;
|
|
122
|
+
dashboardId: string;
|
|
123
|
+
dashboardName: string;
|
|
124
|
+
zoomScale: number;
|
|
125
|
+
responsiveGrid: boolean;
|
|
126
|
+
widgets: TDashboardWidgetKey[];
|
|
127
|
+
childWidgetsConfig: IChildWidgetConfigEntry[];
|
|
128
|
+
cssSettings: IDashboardSettingEntry[];
|
|
129
|
+
_version?: number;
|
|
130
|
+
_stateDescription?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export declare interface IDashboardGridPropsBase {
|
|
134
|
+
isEditing: boolean;
|
|
135
|
+
zoomScale: number;
|
|
136
|
+
responsiveGrid: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export declare interface IDashboardSettingEntry {
|
|
140
|
+
key: string;
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
cssProperty: string;
|
|
144
|
+
step: number;
|
|
145
|
+
defaultUnit: string;
|
|
146
|
+
minValue: number;
|
|
147
|
+
defaultValue: string;
|
|
148
|
+
value: string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export declare interface IDashboardStorageService {
|
|
152
|
+
getSavedDashboards: TGetSavedDashboards;
|
|
153
|
+
saveDashboards: TSaveDashboards;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare interface IDashboardWidgetPropsBase<TExtraProps = any> {
|
|
157
|
+
index: number;
|
|
158
|
+
maxIndex: number;
|
|
159
|
+
widgetKey: TDashboardWidgetKey;
|
|
160
|
+
parentWidgetKey?: TDashboardWidgetKey;
|
|
161
|
+
isEditing: boolean;
|
|
162
|
+
highlight?: boolean;
|
|
163
|
+
testId?: string;
|
|
164
|
+
title?: string;
|
|
165
|
+
size?: TWidgetSize;
|
|
166
|
+
borderCssClasses?: string;
|
|
167
|
+
backgroundCssClasses?: string;
|
|
168
|
+
hideTitle?: boolean;
|
|
169
|
+
noShadow?: boolean;
|
|
170
|
+
noBorder?: boolean;
|
|
171
|
+
noPadding?: boolean;
|
|
172
|
+
direction?: TWidgetDirection;
|
|
173
|
+
extraProps?: TExtraProps;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 2. Define the flexible Catalog Entry
|
|
178
|
+
* Definition of a single widget or container in the catalog.
|
|
179
|
+
* It must have EITHER a direct 'component' reference OR a 'loader' function.
|
|
180
|
+
*
|
|
181
|
+
* TFrameworkElementType: see TWidgetMetaInfoBase
|
|
182
|
+
* TFrameworkComponentType: i.e. React.ComponentType<any> (see TWidgetFactoryBase)
|
|
183
|
+
*/
|
|
184
|
+
export declare interface IDynamicWidgetCatalogEntryBase<TFrameworkElementType = any, TFrameworkComponentType = any> {
|
|
185
|
+
key: TDashboardWidgetKey;
|
|
186
|
+
title: string;
|
|
187
|
+
isContainer?: boolean;
|
|
188
|
+
meta?: TWidgetMetaInfoBase<TFrameworkElementType>;
|
|
189
|
+
component?: TFrameworkComponentType;
|
|
190
|
+
loader?: TWidgetFactoryBase<TFrameworkComponentType>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @name localWidgetDiscovery
|
|
195
|
+
* @description Scans local directories for widgets.
|
|
196
|
+
* If lazy is true, it registers loaders. If false, it registers static components.
|
|
197
|
+
*/
|
|
198
|
+
export declare const localWidgetDiscovery: (baseSrcPath: string, // e.g., "/src/async-widgets" or "/src/bundled-widgets"
|
|
199
|
+
widgetModules: Record<string, any>, widgetMetaModules: Record<string, any>, lazy?: boolean) => [string, IDynamicWidgetCatalogEntryBase][];
|
|
200
|
+
|
|
201
|
+
export declare const parseContainerTitle: (containerWidgetKey: TDashboardWidgetKey) => string;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Enhanced helper to derive key and title from widget file paths.
|
|
205
|
+
* Handles:
|
|
206
|
+
* - widget-revenue-trends1 -> WidgetRevenueTrends1
|
|
207
|
+
* - widget-with-extraprops -> WidgetWithExtraprops
|
|
208
|
+
* - widget-revenue-trends-async -> WidgetRevenueTrendsAsync
|
|
209
|
+
*/
|
|
210
|
+
export declare const parseKeyAndTitleFromFilePath: (path: string) => {
|
|
211
|
+
key: TDashboardWidgetKey;
|
|
212
|
+
title: string;
|
|
213
|
+
folder: string;
|
|
214
|
+
} | null;
|
|
215
|
+
|
|
216
|
+
export declare const remoteWidgetDiscovery: (manifestUrl: string) => Promise<{
|
|
217
|
+
entries: [string, IDynamicWidgetCatalogEntryBase][];
|
|
218
|
+
message: string;
|
|
219
|
+
details: string;
|
|
220
|
+
}>;
|
|
221
|
+
|
|
222
|
+
export declare const removeEmptyContainers: (dashboardConfig: IDashboardConfig) => IDashboardConfig;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* @name resolveColorFromClass
|
|
226
|
+
* @description Resolves the current computed color using your existing CSS classes
|
|
227
|
+
* @param classNames, i.e. 'bg-primary'
|
|
228
|
+
* @param property to resolve, i.e. 'backgroundColor'
|
|
229
|
+
* @returns
|
|
230
|
+
*/
|
|
231
|
+
export declare const resolveColorFromClass: (classNames: string | string[], property?: "color" | "backgroundColor") => string;
|
|
232
|
+
|
|
233
|
+
export declare type TDashboardUndoStatus = {
|
|
234
|
+
isUndoDisabled: boolean;
|
|
235
|
+
isRedoDisabled: boolean;
|
|
236
|
+
_currentIndex?: number;
|
|
237
|
+
_historyLength?: number;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export declare type TDashboardWidgetCatalogBase<TFrameworkElementType = any, TFrameworkComponentType = any> = Map<TDashboardWidgetKey, IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType>>;
|
|
241
|
+
|
|
242
|
+
export declare type TDashboardWidgetKey = string;
|
|
243
|
+
|
|
244
|
+
export declare type TGetDefaultWidgetMetaFromKey = (widgetKey: TDashboardWidgetKey, options?: TGetDefaultWidgetMetaFromKeyOptions) => TWidgetMetaInfoBase<any>;
|
|
245
|
+
|
|
246
|
+
export declare type TGetDefaultWidgetMetaFromKeyOptions = {
|
|
247
|
+
title?: string;
|
|
248
|
+
description?: string;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export declare type TGetSavedDashboards = (userID: number | string, clientAppKey: string, widgetCatalog: TDashboardWidgetCatalogBase, defaultDashboardConfig: IDashboardConfig) => Promise<IDashboardConfig[]>;
|
|
252
|
+
|
|
253
|
+
export declare type TManifestEntry = {
|
|
254
|
+
url: string;
|
|
255
|
+
meta: TWidgetMetaInfoBase;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export declare type TSaveDashboards = (userID: number | string, clientAppKey: string, dashboardConfigs: IDashboardConfig[], widgetCatalog: TDashboardWidgetCatalogBase) => Promise<boolean>;
|
|
259
|
+
|
|
260
|
+
export declare type TUndoHistoryEntry = {
|
|
261
|
+
undoIndex: number;
|
|
262
|
+
config: IDashboardConfig;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export declare type TWidgetCategory = 'Widget' | 'Chart' | 'Container';
|
|
266
|
+
|
|
267
|
+
export declare type TWidgetDirection = 'row' | 'column';
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 1. Define the Async Loader type
|
|
271
|
+
* Type for the function that performs the asynchronous dynamic import.
|
|
272
|
+
* It must return a promise that resolves to the module containing the widget component
|
|
273
|
+
* as its default export (or a named export if you change the loading strategy).
|
|
274
|
+
*
|
|
275
|
+
* TFrameworkComponent could be "React.ComponentType<any>"" or "VueComponent" etc
|
|
276
|
+
*/
|
|
277
|
+
export declare type TWidgetFactoryBase<TFrameworkComponent = any> = () => Promise<{
|
|
278
|
+
default: TFrameworkComponent;
|
|
279
|
+
}>;
|
|
280
|
+
|
|
281
|
+
export declare type TWidgetMetaInfoBase<TFrameworkElementType = any> = {
|
|
282
|
+
name: string;
|
|
283
|
+
description: string;
|
|
284
|
+
categories: TWidgetCategory[];
|
|
285
|
+
noDuplicatedWidgets?: boolean;
|
|
286
|
+
icon: TFrameworkElementType | undefined;
|
|
287
|
+
externalDependencies: string[];
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export declare type TWidgetSize = 'default' | 'large' | 'xlarge';
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @name useDashboardStorageService
|
|
294
|
+
* @description
|
|
295
|
+
* This implementation of IDashboardStorageService uses localStorage to store custom dashboard configurations.
|
|
296
|
+
* Developers can implement their own version of the dashboard storage service to store the data in a database or other way if needed.
|
|
297
|
+
* @returns An instance of IDashboardStorageService
|
|
298
|
+
*/
|
|
299
|
+
export declare const useDashboardStorageService: () => IDashboardStorageService;
|
|
300
|
+
|
|
301
|
+
export { }
|