@tenorlab/react-dashboard 1.3.1 → 1.3.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/dist/index.d.ts CHANGED
@@ -1 +1,321 @@
1
- export * from './components/';
1
+ import { CSSProperties } from 'react';
2
+ import { default as default_2 } from 'react';
3
+ import { ForwardRefExoticComponent } from 'react';
4
+ import { IChildWidgetConfigEntry } from './interfaces/';
5
+ import { IDashboardConfig } from './interfaces/';
6
+ import { IDashboardGridPropsBase } from './interfaces/';
7
+ import { IDashboardSettingEntry } from './interfaces/';
8
+ import { IDashboardWidgetPropsBase } from './interfaces/';
9
+ import { IDynamicWidgetCatalogEntryBase } from './interfaces/';
10
+ import { JSX } from 'react';
11
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
12
+ import { ReactNode } from 'react';
13
+ import { RefAttributes } from 'react';
14
+ import { StoreApi } from 'zustand';
15
+ import { TDashboardUndoStatus } from './interfaces/';
16
+ import { TDashboardWidgetCatalogBase } from './interfaces/';
17
+ import { TDashboardWidgetKey } from './interfaces/';
18
+ import { TUndoHistoryEntry } from './interfaces/';
19
+ import { TWidgetFactoryBase } from './interfaces/';
20
+ import { TWidgetMetaInfoBase } from './interfaces/';
21
+ import { UseBoundStore } from 'zustand';
22
+
23
+ export declare function AddIcon({ className }: TIconProps): JSX_2.Element;
24
+
25
+ export declare function Button(props: IButtonProps): JSX_2.Element;
26
+
27
+ export declare function CircleQuestionMark({ className }: TIconProps): JSX_2.Element;
28
+
29
+ export declare function CrosshairIcon({ className }: TIconProps): JSX_2.Element;
30
+
31
+ export declare const DashboardGrid: ForwardRefExoticComponent<IDashboardGridProps & RefAttributes<HTMLDivElement>>;
32
+
33
+ export declare const DashboardWidgetBase: (props: IDashboardWidgetProps & {
34
+ ref?: React.ForwardedRef<HTMLDivElement>;
35
+ }) => React.ReactElement | null;
36
+
37
+ export declare function DeleteIcon({ className }: TIconProps): JSX_2.Element;
38
+
39
+ export declare const DraggablePanel: ForwardRefExoticComponent<DraggablePanelProps & RefAttributes<HTMLDivElement>>;
40
+
41
+ declare type DraggablePanelProps = {
42
+ testId?: string;
43
+ className: string;
44
+ style?: CSSProperties;
45
+ onDraggingChange?: (isDragging: boolean) => void;
46
+ children: React.ReactNode;
47
+ };
48
+
49
+ /**
50
+ * Component to safely load and render dynamic widgets.
51
+ * This ensures the widget component (and its hooks) is called consistently.
52
+ * @param {object} props
53
+ * @param {string} props.widgetKey
54
+ * @param {(key: string) => Promise<void>} props.onRemoveClick
55
+ */
56
+ export declare function DynamicWidgetLoader({ index, maxIndex, widgetKey, parentWidgetKey, targetContainerKey, childWidgetsConfig, widgetCatalog, isEditing, extraProps, onRemoveClick, onMoveClick, selectContainer, }: TDynamicWidgetLoaderProps): JSX_2.Element;
57
+
58
+ export declare function EditIcon({ className }: TIconProps): JSX_2.Element;
59
+
60
+ export declare function GridIcon({ className }: TIconProps): JSX_2.Element;
61
+
62
+ export declare function HandGrabIcon({ className }: TIconProps): JSX_2.Element;
63
+
64
+ export declare function HandIcon({ className }: TIconProps): JSX_2.Element;
65
+
66
+ export declare interface IButtonProps {
67
+ disabled?: boolean;
68
+ className?: string;
69
+ tooltip?: ITooltipProps;
70
+ isIconButton?: boolean;
71
+ buttonType?: TButtonType;
72
+ category?: string;
73
+ font?: string;
74
+ border?: number;
75
+ borderHover?: number;
76
+ borderColor?: string;
77
+ px?: number;
78
+ py?: number;
79
+ justifyCss?: TButtonJustifyCss;
80
+ shadow?: string;
81
+ shadowHover?: string;
82
+ addCss?: string;
83
+ onClick: () => any;
84
+ children: React.ReactNode;
85
+ }
86
+
87
+ export declare interface IButtonProps {
88
+ disabled?: boolean;
89
+ className?: string;
90
+ tooltip?: ITooltipProps;
91
+ }
92
+
93
+ export declare interface IDashboardGridProps extends IDashboardGridPropsBase {
94
+ children?: ReactNode;
95
+ }
96
+
97
+ export declare interface IDashboardWidget extends JSX.Element {
98
+ }
99
+
100
+ export declare interface IDashboardWidgetProps<TExtraProps = any> extends IDashboardWidgetPropsBase<TExtraProps> {
101
+ children?: ReactNode;
102
+ onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
103
+ onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
104
+ selectContainer?: (containerKey?: TDashboardWidgetKey) => void;
105
+ }
106
+
107
+ export declare interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
108
+ }
109
+
110
+ /**
111
+ * Compares two version strings (e.g., "19.2.0" and "19.2.3")
112
+ * Returns true if the widget version is compatible with the host.
113
+ * Logic: Host must be >= Widget version for major/minor.
114
+ */
115
+ export declare const _isVersionCompatible: (hostVer: string, widgetVer: string) => boolean;
116
+
117
+ export declare interface ITextFieldProps {
118
+ label: string;
119
+ size?: TSize;
120
+ value: string;
121
+ className?: string;
122
+ placeholder?: string;
123
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
124
+ onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
125
+ }
126
+
127
+ export declare interface ITooltipProps {
128
+ placement: string;
129
+ title: string;
130
+ }
131
+
132
+ export declare interface ITooltipProps {
133
+ placement: string;
134
+ title: string;
135
+ }
136
+
137
+ export declare const ListItem: ForwardRefExoticComponent<TStackProps & {
138
+ innerClass?: string;
139
+ } & RefAttributes<HTMLDivElement>>;
140
+
141
+ export declare const ListItemLeftChild: ForwardRefExoticComponent<TListItemChildProps & RefAttributes<HTMLDivElement>>;
142
+
143
+ export declare const ListItemMiddleChild: ForwardRefExoticComponent<TListItemChildProps & RefAttributes<HTMLDivElement>>;
144
+
145
+ export declare const ListItemRightChild: ForwardRefExoticComponent<TListItemChildProps & RefAttributes<HTMLDivElement>>;
146
+
147
+ export declare function MonitorIcon({ className }: TIconProps): JSX_2.Element;
148
+
149
+ export declare function MonitorSmartphoneIcon({ className }: TIconProps): JSX_2.Element;
150
+
151
+ export declare function MoveLeftIcon({ className }: TIconProps): JSX_2.Element;
152
+
153
+ export declare function MoveRightIcon({ className }: TIconProps): JSX_2.Element;
154
+
155
+ export declare function RedoIcon({ className }: TIconProps): JSX_2.Element;
156
+
157
+ export declare function SettingsIcon({ className }: TIconProps): JSX_2.Element;
158
+
159
+ export declare const showToast: (options: any) => void;
160
+
161
+ export declare function Stack(props: TStackProps): JSX_2.Element;
162
+
163
+ export declare function SvgBaseWrapper({ children, className, }: {
164
+ children: React.ReactNode;
165
+ className?: string;
166
+ }): JSX_2.Element;
167
+
168
+ export declare function TabletSmartphoneIcon({ className }: TIconProps): JSX_2.Element;
169
+
170
+ declare type TAddWidgetResponse = {
171
+ success: boolean;
172
+ message?: string;
173
+ updatedDashboardConfig: IDashboardConfig;
174
+ allUpdatedDashboardConfigs: IDashboardConfig[];
175
+ };
176
+
177
+ export declare function TargetIcon({ className }: TIconProps): JSX_2.Element;
178
+
179
+ export declare type TButtonJustifyCss = 'justify-start' | 'justify-center' | 'justify-end';
180
+
181
+ export declare type TButtonType = 'normal' | 'ghost';
182
+
183
+ declare type TDashboardSlice = {
184
+ isLoading: boolean;
185
+ isEditing: boolean;
186
+ allDashboardConfigs: IDashboardConfig[];
187
+ currentDashboardConfig: IDashboardConfig;
188
+ targetContainerKey?: TDashboardWidgetKey | undefined;
189
+ getNextContainerKey: (containerWidgetKey: TDashboardWidgetKey) => TDashboardWidgetKey;
190
+ setIsLoading: (value: boolean) => boolean;
191
+ setIsEditing: (value: boolean) => boolean;
192
+ setTargetContainerKey: (value: TDashboardWidgetKey | undefined) => TDashboardWidgetKey | undefined;
193
+ setAllDashboardConfigs: (value: IDashboardConfig[]) => IDashboardConfig[];
194
+ setCurrentDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
195
+ addDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
196
+ deleteDashboardConfigById: (value: string) => IDashboardConfig[];
197
+ selectDashboardById: (dashboardId: string) => IDashboardConfig | undefined;
198
+ addWidget: (params: {
199
+ widgetKey: TDashboardWidgetKey;
200
+ parentWidgetKey?: TDashboardWidgetKey;
201
+ noDuplicatedWidgets?: boolean;
202
+ }) => TAddWidgetResponse;
203
+ removeWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
204
+ moveWidget: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
205
+ };
206
+
207
+ export declare type TDashboardUndoService = ReturnType<typeof useDashboardUndoService>;
208
+
209
+ export declare type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
210
+
211
+ declare type TDynamicWidgetLoaderProps<TExtraProps = any> = {
212
+ index: number;
213
+ maxIndex: number;
214
+ widgetKey: TDashboardWidgetKey;
215
+ parentWidgetKey?: TDashboardWidgetKey;
216
+ targetContainerKey?: TDashboardWidgetKey;
217
+ childWidgetsConfig?: IChildWidgetConfigEntry[];
218
+ widgetCatalog: TDashboardWidgetCatalog;
219
+ isEditing: boolean;
220
+ extraProps?: TExtraProps;
221
+ onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
222
+ onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
223
+ selectContainer?: (containerKey: TDashboardWidgetKey) => void;
224
+ };
225
+
226
+ /**
227
+ * A reusable, styled TextField component built with Tailwind CSS.
228
+ */
229
+ export declare const TextField: default_2.FC<ITextFieldProps>;
230
+
231
+ declare type TFrameworkComponentType = React.ComponentType<any>;
232
+
233
+ declare type TFrameworkElementType = React.ElementType;
234
+
235
+ declare type TIconProps = {
236
+ className?: string;
237
+ };
238
+
239
+ export declare function TimerResetIcon({ className }: TIconProps): JSX_2.Element;
240
+
241
+ declare type TListItemChildProps = {
242
+ testId?: string;
243
+ className?: string;
244
+ children?: ReactNode;
245
+ };
246
+
247
+ declare type TProps = {
248
+ children: React.ReactNode;
249
+ addCssClasses?: string;
250
+ };
251
+
252
+ declare type TRemoveWidgetResponse = TAddWidgetResponse;
253
+
254
+ declare type TSize = 'small' | 'medium';
255
+
256
+ export declare type TStackProps = {
257
+ testId?: string;
258
+ classNames?: string;
259
+ direction?: 'row' | 'column';
260
+ style?: CSSProperties;
261
+ children: React.ReactNode;
262
+ };
263
+
264
+ export declare type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
265
+
266
+ export declare type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
267
+
268
+ export declare type TWidgetsCatalogFlyoutProps = {
269
+ targetContainerKey?: TDashboardWidgetKey;
270
+ widgetsCatalog: TDashboardWidgetCatalog;
271
+ currentDashboardConfig: IDashboardConfig;
272
+ undoStatus: TDashboardUndoStatus;
273
+ addWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => any;
274
+ addContainer: (widgetKey: TDashboardWidgetKey) => any;
275
+ onSettingItemsUpdated: (items: IDashboardSettingEntry[]) => any;
276
+ onResetToDefaultDashboardClick: () => any;
277
+ onUndoOrRedo: (operation: 'Undo' | 'Redo') => any;
278
+ onDoneClick: () => any;
279
+ };
280
+
281
+ export declare function UndoIcon({ className }: TIconProps): JSX_2.Element;
282
+
283
+ export declare const useDashboardStore: UseBoundStore<StoreApi<TDashboardSlice>>;
284
+
285
+ export declare const useDashboardUndoService: () => {
286
+ initializeHistoryForDashboard: (initialConfig: IDashboardConfig) => void;
287
+ resetAllHistory: () => void;
288
+ addUndoEntry: (newConfig: IDashboardConfig) => void;
289
+ removeUndoHistoryForDashboard: (dashboardId: string) => void;
290
+ undo: (currentDashboardId: string) => void;
291
+ redo: (currentDashboardId: string) => void;
292
+ getUndoStatus: (currentDashboardId: string) => TDashboardUndoStatus;
293
+ undoHistory: Record<string, TUndoHistoryEntry[]>;
294
+ historyIndex: Record<string, number>;
295
+ };
296
+
297
+ export declare function WidgetContainerColumn(props: IDashboardWidgetProps): IDashboardWidget;
298
+
299
+ export declare function WidgetContainerLarge(props: IDashboardWidgetProps): IDashboardWidget;
300
+
301
+ export declare function WidgetContainerRow(props: IDashboardWidgetProps): IDashboardWidget;
302
+
303
+ export declare function WidgetsCatalogFlyout(props: TWidgetsCatalogFlyoutProps): JSX_2.Element;
304
+
305
+ export declare function WrapperColumnContent({ children, addCssClasses }: TProps): JSX_2.Element;
306
+
307
+ export declare function WrapperColumnContentListItem({ children, addCssClasses }: TProps): JSX_2.Element;
308
+
309
+ export declare function XCircleIcon({ className }: TIconProps): JSX_2.Element;
310
+
311
+ export declare function ZoomInIcon({ className }: TIconProps): JSX_2.Element;
312
+
313
+ export declare function ZoomOutIcon({ className }: TIconProps): JSX_2.Element;
314
+
315
+
316
+ export * from "./dashboard-settings";
317
+ export * from "./interfaces/";
318
+ export * from "./storage-service";
319
+ export * from "./utils";
320
+
321
+ export { }
@@ -1,29 +1,7 @@
1
1
  import ae, { useState as se, useCallback as ce, useMemo as ot, forwardRef as le, useRef as wt, Suspense as Ct, useEffect as St } from "react";
2
2
  import { jsxs as $, jsx as s } from "react/jsx-runtime";
3
3
  import st from "react-dom";
4
- const je = (e) => {
5
- let n;
6
- const t = /* @__PURE__ */ new Set(), r = (p, g) => {
7
- const c = typeof p == "function" ? p(n) : p;
8
- if (!Object.is(c, n)) {
9
- const b = n;
10
- n = g ?? (typeof c != "object" || c === null) ? c : Object.assign({}, n, c), t.forEach((v) => v(n, b));
11
- }
12
- }, a = () => n, u = { setState: r, getState: a, getInitialState: () => y, subscribe: (p) => (t.add(p), () => t.delete(p)) }, y = n = e(r, a, u);
13
- return u;
14
- }, Dt = ((e) => e ? je(e) : je), Tt = (e) => e;
15
- function Et(e, n = Tt) {
16
- const t = ae.useSyncExternalStore(
17
- e.subscribe,
18
- ae.useCallback(() => n(e.getState()), [e, n]),
19
- ae.useCallback(() => n(e.getInitialState()), [e, n])
20
- );
21
- return ae.useDebugValue(t), t;
22
- }
23
- const Nt = (e) => {
24
- const n = Dt(e), t = (r) => Et(n, r);
25
- return Object.assign(t, n), t;
26
- }, _t = ((e) => Nt), Mt = [
4
+ const Dt = [
27
5
  {
28
6
  key: "grid-gap",
29
7
  name: "Gap",
@@ -101,15 +79,15 @@ const Nt = (e) => {
101
79
  defaultValue: "1.0rem",
102
80
  value: "1.0rem"
103
81
  }
104
- ], Pt = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], $t = (e, n) => Pt.includes(e) ? n : 1, Wt = {
82
+ ], Tt = ["rem", "pc", "cm", "in", "em", "vh", "vw", "%"], Et = (e, n) => Tt.includes(e) ? n : 1, Nt = {
105
83
  incrementOrDecrementValue: (e, n) => {
106
- const t = e.value.match(/([\d.]+)/), r = t ? parseFloat(t[1]) : 0, a = e.value.match(/([^\d.]+)/), i = a ? a[1] : e.defaultUnit, o = $t(i, e.step) * n, u = `${Math.max(r + o, e.minValue).toFixed(1)}${i}`;
84
+ const t = e.value.match(/([\d.]+)/), r = t ? parseFloat(t[1]) : 0, a = e.value.match(/([^\d.]+)/), i = a ? a[1] : e.defaultUnit, o = Et(i, e.step) * n, u = `${Math.max(r + o, e.minValue).toFixed(1)}${i}`;
107
85
  return {
108
86
  ...e,
109
87
  value: u
110
88
  };
111
89
  }
112
- }, lt = (e, n) => `dashboards_${n}_${e}`, It = async (e, n, t, r) => {
90
+ }, lt = (e, n) => `dashboards_${n}_${e}`, _t = async (e, n, t, r) => {
113
91
  const a = localStorage.getItem(lt(e, n));
114
92
  if (a)
115
93
  try {
@@ -146,7 +124,7 @@ const Nt = (e) => {
146
124
  console.warn("Error parsing saved dashboard config:", i);
147
125
  }
148
126
  return [r];
149
- }, Rt = async (e, n, t, r) => {
127
+ }, Mt = async (e, n, t, r) => {
150
128
  t.forEach((i) => {
151
129
  if (i.userID = e, i.clientAppKey = n, i.responsiveGrid = i.responsiveGrid ?? !1, typeof i != "object")
152
130
  throw new Error("Invalid dashboard configuration");
@@ -158,10 +136,10 @@ const Nt = (e) => {
158
136
  });
159
137
  const a = JSON.stringify(t);
160
138
  return localStorage.setItem(lt(e, n), a), !0;
161
- }, Ot = {
162
- getSavedDashboards: It,
163
- saveDashboards: Rt
164
- }, Mn = () => Ot, we = {
139
+ }, Pt = {
140
+ getSavedDashboards: _t,
141
+ saveDashboards: Mt
142
+ }, Mn = () => Pt, we = {
165
143
  userID: 0,
166
144
  clientAppKey: "",
167
145
  dashboardId: "default",
@@ -170,15 +148,15 @@ const Nt = (e) => {
170
148
  responsiveGrid: !1,
171
149
  widgets: [],
172
150
  childWidgetsConfig: [],
173
- cssSettings: [...Mt]
151
+ cssSettings: [...Dt]
174
152
  }, dt = (e) => {
175
153
  const n = `${e}`.split("_");
176
154
  return n.length > 1 ? n[1].replace(/(\D)(\d+)/, "$1 $2") : "Container";
177
- }, Ae = 0.7, Fe = 1, kt = 0.05, ct = (e) => {
155
+ }, je = 0.7, Ae = 1, $t = 0.05, ct = (e) => {
178
156
  let n = Number(e || 0);
179
- return n < Ae && (n = Ae), n > Fe && (n = Fe), n;
157
+ return n < je && (n = je), n > Ae && (n = Ae), n;
180
158
  }, Pn = (e, n) => {
181
- let t = Number(Number((kt * n).toFixed(2)).toFixed(2)), r = Number((Number(e) + t).toFixed(2));
159
+ let t = Number(Number(($t * n).toFixed(2)).toFixed(2)), r = Number((Number(e) + t).toFixed(2));
182
160
  return ct(r);
183
161
  }, $n = (e) => {
184
162
  let n = {
@@ -196,7 +174,7 @@ const Nt = (e) => {
196
174
  }
197
175
  return !0;
198
176
  }), n;
199
- }, jt = (e) => {
177
+ }, Wt = (e) => {
200
178
  const n = e.widgets.filter(
201
179
  (r) => r.includes("WidgetContainer")
202
180
  ), t = {};
@@ -221,7 +199,7 @@ const Nt = (e) => {
221
199
  icon: void 0,
222
200
  externalDependencies: []
223
201
  };
224
- }, Wn = (e, n, t) => n[e] || he(e, t), At = (e, n) => n.get(e)?.meta || he(e), Ft = (e, n, t) => {
202
+ }, Wn = (e, n, t) => n[e] || he(e, t), It = (e, n) => n.get(e)?.meta || he(e), Rt = (e, n, t) => {
225
203
  const r = t || he(e);
226
204
  return [
227
205
  e,
@@ -245,7 +223,7 @@ const Nt = (e) => {
245
223
  loader: n
246
224
  }
247
225
  ];
248
- }, Lt = (e) => {
226
+ }, Ot = (e) => {
249
227
  const n = e.match(/\/widget-([a-zA-Z0-9-]+)\/index\.ts$/);
250
228
  if (n && n[1]) {
251
229
  const t = n[1], r = t.split("-"), a = `Widget${r.map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join("")}`, i = r.map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" ");
@@ -256,7 +234,7 @@ const Nt = (e) => {
256
234
  };
257
235
  }
258
236
  return null;
259
- }, Ut = (e, n, t, r) => {
237
+ }, kt = (e, n, t, r) => {
260
238
  const a = `${n}/widget-${t}/meta.ts`, i = e[a];
261
239
  if (!i)
262
240
  return;
@@ -296,10 +274,10 @@ const Nt = (e) => {
296
274
  }), Rn = (e, n, t, r = !0) => {
297
275
  const a = [];
298
276
  for (const i in n) {
299
- const o = n[i], u = Lt(i);
277
+ const o = n[i], u = Ot(i);
300
278
  if (u && o) {
301
279
  const { key: y, title: p, folder: g } = u;
302
- let c = Ut(t, e, g, y);
280
+ let c = kt(t, e, g, y);
303
281
  if (c || (c = he(y, {
304
282
  description: `Local ${r ? "dynamic" : "static"} widget`
305
283
  })), r)
@@ -308,7 +286,7 @@ const Nt = (e) => {
308
286
  );
309
287
  else {
310
288
  const b = o.default || o;
311
- a.push(Ft(y, b, c));
289
+ a.push(Rt(y, b, c));
312
290
  }
313
291
  }
314
292
  }
@@ -356,7 +334,29 @@ const Nt = (e) => {
356
334
  ...new Set(
357
335
  [e || "", ...n].join(" ").trim().replace(/\n+/gi, " ").replace(/\s+/gi, " ").split(" ")
358
336
  )
359
- ].join(" ").trim(), Vt = (e) => {
337
+ ].join(" ").trim(), Fe = (e) => {
338
+ let n;
339
+ const t = /* @__PURE__ */ new Set(), r = (p, g) => {
340
+ const c = typeof p == "function" ? p(n) : p;
341
+ if (!Object.is(c, n)) {
342
+ const b = n;
343
+ n = g ?? (typeof c != "object" || c === null) ? c : Object.assign({}, n, c), t.forEach((v) => v(n, b));
344
+ }
345
+ }, a = () => n, u = { setState: r, getState: a, getInitialState: () => y, subscribe: (p) => (t.add(p), () => t.delete(p)) }, y = n = e(r, a, u);
346
+ return u;
347
+ }, jt = ((e) => e ? Fe(e) : Fe), At = (e) => e;
348
+ function Ft(e, n = At) {
349
+ const t = ae.useSyncExternalStore(
350
+ e.subscribe,
351
+ ae.useCallback(() => n(e.getState()), [e, n]),
352
+ ae.useCallback(() => n(e.getInitialState()), [e, n])
353
+ );
354
+ return ae.useDebugValue(t), t;
355
+ }
356
+ const Lt = (e) => {
357
+ const n = jt(e), t = (r) => Ft(n, r);
358
+ return Object.assign(t, n), t;
359
+ }, Ut = ((e) => Lt), Vt = (e) => {
360
360
  const n = e.widgets.filter((r) => r.includes("WidgetContainer")).map((r) => Number(r.split("_")[1].replace("container", "")));
361
361
  return `container${n.length > 0 ? Math.max(...n) + 1 : 1}`;
362
362
  }, qt = (e, n) => {
@@ -412,7 +412,7 @@ const Nt = (e) => {
412
412
  ...e,
413
413
  childWidgetsConfig: i
414
414
  };
415
- return `${n}`.includes("Container") && (o = jt(o)), {
415
+ return `${n}`.includes("Container") && (o = Wt(o)), {
416
416
  success: !0,
417
417
  updatedDashboardConfig: o
418
418
  };
@@ -571,7 +571,7 @@ const Nt = (e) => {
571
571
  allUpdatedDashboardConfigs: u
572
572
  };
573
573
  }
574
- }), jn = _t()((...e) => ({
574
+ }), jn = Ut()((...e) => ({
575
575
  ...Bt(...e)
576
576
  })), An = () => {
577
577
  const [e, n] = se({}), [t, r] = se({}), a = ce((g) => {
@@ -3022,7 +3022,7 @@ function Tn({ item: e, onSettingItemChanged: n }) {
3022
3022
  const y = u.key;
3023
3023
  if (["ArrowUp", "ArrowDown"].includes(y)) {
3024
3024
  u.preventDefault();
3025
- const p = Wt.incrementOrDecrementValue(
3025
+ const p = Nt.incrementOrDecrementValue(
3026
3026
  e,
3027
3027
  y === "ArrowUp" ? 1 : -1
3028
3028
  );
@@ -3067,7 +3067,7 @@ function sr(e) {
3067
3067
  onDoneClick: o
3068
3068
  } = e, [u, y] = se("Editing"), [p, g] = se(0), [c, b] = se(""), T = Array.from(e.widgetsCatalog.keys()).map((f) => ({
3069
3069
  widgetKey: f,
3070
- metaData: At(f, e.widgetsCatalog)
3070
+ metaData: It(f, e.widgetsCatalog)
3071
3071
  })), m = !!e.targetContainerKey, x = (f) => {
3072
3072
  b(f.target.value);
3073
3073
  }, C = (f) => {
@@ -3255,10 +3255,10 @@ export {
3255
3255
  tn as CircleQuestionMark,
3256
3256
  en as CrosshairIcon,
3257
3257
  rr as DashboardGrid,
3258
- Fe as DashboardMaxZoomScale,
3259
- Ae as DashboardMinZoomScale,
3258
+ Ae as DashboardMaxZoomScale,
3259
+ je as DashboardMinZoomScale,
3260
3260
  at as DashboardWidgetBase,
3261
- kt as DashboardZoomStep,
3261
+ $t as DashboardZoomStep,
3262
3262
  Ln as DeleteIcon,
3263
3263
  vn as DraggablePanel,
3264
3264
  Dn as DynamicWidgetLoader,
@@ -3295,21 +3295,21 @@ export {
3295
3295
  Cn as _isVersionCompatible,
3296
3296
  we as blankDashboardConfig,
3297
3297
  ut as createDynamicEntry,
3298
- Ft as createStaticEntry,
3299
- Mt as cssSettingsCatalog,
3298
+ Rt as createStaticEntry,
3299
+ Dt as cssSettingsCatalog,
3300
3300
  kn as cssVarsUtils,
3301
- Wt as dashboardSettingsUtils,
3302
- jt as ensureContainersSequence,
3301
+ Nt as dashboardSettingsUtils,
3302
+ Wt as ensureContainersSequence,
3303
3303
  ct as ensureZoomScaleIsWithinRange,
3304
3304
  he as getDefaultWidgetMetaFromKey,
3305
3305
  Wn as getDefaultWidgetMetaFromMap,
3306
3306
  G as getDistinctCssClasses,
3307
- Ut as getMetaInfoFromFile,
3307
+ kt as getMetaInfoFromFile,
3308
3308
  Pn as getNewZoomScaleWithinRange,
3309
- At as getWidgetMetaFromCatalog,
3309
+ It as getWidgetMetaFromCatalog,
3310
3310
  Rn as localWidgetDiscovery,
3311
3311
  dt as parseContainerTitle,
3312
- Lt as parseKeyAndTitleFromFilePath,
3312
+ Ot as parseKeyAndTitleFromFilePath,
3313
3313
  In as remoteWidgetDiscovery,
3314
3314
  $n as removeEmptyContainers,
3315
3315
  On as resolveColorFromClass,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenorlab/react-dashboard",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Foundation components for creating user-configurable dashboards in React",
5
5
  "author": "Damiano Fusco",
6
6
  "type": "module",
@@ -18,8 +18,9 @@
18
18
  "scripts": {
19
19
  "dev": "vite",
20
20
  "clean": "rm -rf dist node_modules package-lock.json",
21
- "build-types": "tsc src/index.ts --jsx react-jsx --downlevelIteration --esModuleInterop --declaration --emitDeclarationOnly --outDir dist",
22
- "build": "npm run pretty; tsc --jsx react-jsx --esModuleInterop && vite build; npm run build-types",
21
+ "OLD-build-types": "tsc src/index.ts --jsx react-jsx --downlevelIteration --esModuleInterop --declaration --emitDeclarationOnly --outDir dist",
22
+ "OLD-build": "npm run pretty; tsc --jsx react-jsx --esModuleInterop && vite build; npm run build-types",
23
+ "build": "npm run pretty && vite build",
23
24
  "pub": "npm run build; npm publish --access public --otp=",
24
25
  "test": "TESTING=true vitest run",
25
26
  "test-watch": "TESTING=true vitest watch",
@@ -43,8 +44,7 @@
43
44
  "types": "./dist/index.d.ts",
44
45
  "default": "./dist/react-dashboard.umd.js"
45
46
  }
46
- },
47
- "./styles.css": "./dist/react-dashboard.css"
47
+ }
48
48
  },
49
49
  "types": "./dist/index.d.ts",
50
50
  "main": "./dist/react-dashboard.umd.js",
@@ -1,2 +0,0 @@
1
- import type { IDashboardGridProps } from './interfaces/core-react.interfaces';
2
- export declare const DashboardGrid: import("react").ForwardRefExoticComponent<IDashboardGridProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -1,4 +0,0 @@
1
- import type { IDashboardWidgetProps } from './interfaces/core-react.interfaces';
2
- export declare const DashboardWidgetBase: (props: IDashboardWidgetProps & {
3
- ref?: React.ForwardedRef<HTMLDivElement>;
4
- }) => React.ReactElement | null;
@@ -1,31 +0,0 @@
1
- import type { IChildWidgetConfigEntry, TDashboardWidgetKey } from '@tenorlab/dashboard-core';
2
- import type { TDashboardWidgetCatalog } from './interfaces';
3
- type TDynamicWidgetLoaderProps<TExtraProps = any> = {
4
- index: number;
5
- maxIndex: number;
6
- widgetKey: TDashboardWidgetKey;
7
- parentWidgetKey?: TDashboardWidgetKey;
8
- targetContainerKey?: TDashboardWidgetKey;
9
- childWidgetsConfig?: IChildWidgetConfigEntry[];
10
- widgetCatalog: TDashboardWidgetCatalog;
11
- isEditing: boolean;
12
- extraProps?: TExtraProps;
13
- onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
14
- onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
15
- selectContainer?: (containerKey: TDashboardWidgetKey) => void;
16
- };
17
- /**
18
- * Compares two version strings (e.g., "19.2.0" and "19.2.3")
19
- * Returns true if the widget version is compatible with the host.
20
- * Logic: Host must be >= Widget version for major/minor.
21
- */
22
- export declare const _isVersionCompatible: (hostVer: string, widgetVer: string) => boolean;
23
- /**
24
- * Component to safely load and render dynamic widgets.
25
- * This ensures the widget component (and its hooks) is called consistently.
26
- * @param {object} props
27
- * @param {string} props.widgetKey
28
- * @param {(key: string) => Promise<void>} props.onRemoveClick
29
- */
30
- export declare function DynamicWidgetLoader({ index, maxIndex, widgetKey, parentWidgetKey, targetContainerKey, childWidgetsConfig, widgetCatalog, isEditing, extraProps, onRemoveClick, onMoveClick, selectContainer, }: TDynamicWidgetLoaderProps): import("react/jsx-runtime").JSX.Element;
31
- export {};
@@ -1,4 +0,0 @@
1
- import type { IDashboardWidgetProps, IDashboardWidget } from './interfaces/';
2
- export declare function WidgetContainerColumn(props: IDashboardWidgetProps): IDashboardWidget;
3
- export declare function WidgetContainerLarge(props: IDashboardWidgetProps): IDashboardWidget;
4
- export declare function WidgetContainerRow(props: IDashboardWidgetProps): IDashboardWidget;
@@ -1,15 +0,0 @@
1
- import type { IDashboardConfig, IDashboardSettingEntry, TDashboardUndoStatus, TDashboardWidgetKey } from '@tenorlab/dashboard-core';
2
- import type { TDashboardWidgetCatalog } from './interfaces/';
3
- export type TWidgetsCatalogFlyoutProps = {
4
- targetContainerKey?: TDashboardWidgetKey;
5
- widgetsCatalog: TDashboardWidgetCatalog;
6
- currentDashboardConfig: IDashboardConfig;
7
- undoStatus: TDashboardUndoStatus;
8
- addWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => any;
9
- addContainer: (widgetKey: TDashboardWidgetKey) => any;
10
- onSettingItemsUpdated: (items: IDashboardSettingEntry[]) => any;
11
- onResetToDefaultDashboardClick: () => any;
12
- onUndoOrRedo: (operation: 'Undo' | 'Redo') => any;
13
- onDoneClick: () => any;
14
- };
15
- export declare function WidgetsCatalogFlyout(props: TWidgetsCatalogFlyoutProps): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import type { IButtonProps } from './interfaces';
2
- export declare function Button(props: IButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- type DraggablePanelProps = {
3
- testId?: string;
4
- className: string;
5
- style?: CSSProperties;
6
- onDraggingChange?: (isDragging: boolean) => void;
7
- children: React.ReactNode;
8
- };
9
- export declare const DraggablePanel: import("react").ForwardRefExoticComponent<DraggablePanelProps & import("react").RefAttributes<HTMLDivElement>>;
10
- export {};
@@ -1,14 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { type TStackProps } from './Stack';
3
- export declare const ListItem: import("react").ForwardRefExoticComponent<TStackProps & {
4
- innerClass?: string;
5
- } & import("react").RefAttributes<HTMLDivElement>>;
6
- type TListItemChildProps = {
7
- testId?: string;
8
- className?: string;
9
- children?: ReactNode;
10
- };
11
- export declare const ListItemLeftChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
12
- export declare const ListItemMiddleChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
13
- export declare const ListItemRightChild: import("react").ForwardRefExoticComponent<TListItemChildProps & import("react").RefAttributes<HTMLDivElement>>;
14
- export {};
@@ -1,9 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- export type TStackProps = {
3
- testId?: string;
4
- classNames?: string;
5
- direction?: 'row' | 'column';
6
- style?: CSSProperties;
7
- children: React.ReactNode;
8
- };
9
- export declare function Stack(props: TStackProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import type { ITextFieldProps } from './interfaces';
3
- /**
4
- * A reusable, styled TextField component built with Tailwind CSS.
5
- */
6
- export declare const TextField: React.FC<ITextFieldProps>;
@@ -1,7 +0,0 @@
1
- type TProps = {
2
- children: React.ReactNode;
3
- addCssClasses?: string;
4
- };
5
- export declare function WrapperColumnContent({ children, addCssClasses }: TProps): import("react/jsx-runtime").JSX.Element;
6
- export declare function WrapperColumnContentListItem({ children, addCssClasses }: TProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,29 +0,0 @@
1
- export declare function SvgBaseWrapper({ children, className, }: {
2
- children: React.ReactNode;
3
- className?: string;
4
- }): import("react/jsx-runtime").JSX.Element;
5
- type TIconProps = {
6
- className?: string;
7
- };
8
- export declare function AddIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
9
- export declare function DeleteIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
10
- export declare function EditIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
11
- export declare function GridIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
12
- export declare function MonitorIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
13
- export declare function MonitorSmartphoneIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
14
- export declare function MoveLeftIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
15
- export declare function MoveRightIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
16
- export declare function SettingsIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
17
- export declare function TabletSmartphoneIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
18
- export declare function XCircleIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
19
- export declare function ZoomInIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
20
- export declare function ZoomOutIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
21
- export declare function TimerResetIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
22
- export declare function UndoIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
23
- export declare function RedoIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
24
- export declare function HandIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
25
- export declare function HandGrabIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
26
- export declare function CrosshairIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
27
- export declare function TargetIcon({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
28
- export declare function CircleQuestionMark({ className }: TIconProps): import("react/jsx-runtime").JSX.Element;
29
- export {};
@@ -1,9 +0,0 @@
1
- export * from './interfaces';
2
- export * from './icons';
3
- export * from './TextField';
4
- export * from './Buttons';
5
- export * from './Stack';
6
- export * from './ListItem';
7
- export * from './DraggablePanel';
8
- export * from './Wrappers';
9
- export declare const showToast: (options: any) => void;
@@ -1,46 +0,0 @@
1
- export interface ITooltipProps {
2
- placement: string;
3
- title: string;
4
- }
5
- export type TButtonType = 'normal' | 'ghost';
6
- export type TButtonJustifyCss = 'justify-start' | 'justify-center' | 'justify-end';
7
- export interface IButtonProps {
8
- disabled?: boolean;
9
- className?: string;
10
- tooltip?: ITooltipProps;
11
- isIconButton?: boolean;
12
- buttonType?: TButtonType;
13
- category?: string;
14
- font?: string;
15
- border?: number;
16
- borderHover?: number;
17
- borderColor?: string;
18
- px?: number;
19
- py?: number;
20
- justifyCss?: TButtonJustifyCss;
21
- shadow?: string;
22
- shadowHover?: string;
23
- addCss?: string;
24
- onClick: () => any;
25
- children: React.ReactNode;
26
- }
27
- export interface ITooltipProps {
28
- placement: string;
29
- title: string;
30
- }
31
- export interface IButtonProps {
32
- disabled?: boolean;
33
- className?: string;
34
- tooltip?: ITooltipProps;
35
- }
36
- type TSize = 'small' | 'medium';
37
- export interface ITextFieldProps {
38
- label: string;
39
- size?: TSize;
40
- value: string;
41
- className?: string;
42
- placeholder?: string;
43
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
44
- onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
45
- }
46
- export {};
@@ -1,11 +0,0 @@
1
- export * from './interfaces/';
2
- export * from './use-dashboard-store';
3
- export * from './use-dashboard-undo-service';
4
- export * from './dashboard-primitives/';
5
- export * from './DashboardGrid';
6
- export * from './DynamicWidgetLoader';
7
- export * from './DashboardWidgetBase';
8
- export * from './WidgetContainer';
9
- export * from './WidgetsCatalogFlyout';
10
- export type * from '@tenorlab/dashboard-core';
11
- export * from '@tenorlab/dashboard-core';
@@ -1,21 +0,0 @@
1
- import type { TDashboardWidgetKey, TWidgetMetaInfoBase, IDashboardWidgetPropsBase, IDashboardGridPropsBase, TWidgetFactoryBase, IDynamicWidgetCatalogEntryBase, TDashboardWidgetCatalogBase } from '@tenorlab/dashboard-core';
2
- import type { ReactNode, JSX } from 'react';
3
- type TFrameworkComponentType = React.ComponentType<any>;
4
- type TFrameworkElementType = React.ElementType;
5
- export type TWidgetMetaInfo = TWidgetMetaInfoBase<TFrameworkElementType | undefined>;
6
- export interface IDashboardGridProps extends IDashboardGridPropsBase {
7
- children?: ReactNode;
8
- }
9
- export interface IDashboardWidgetProps<TExtraProps = any> extends IDashboardWidgetPropsBase<TExtraProps> {
10
- children?: ReactNode;
11
- onRemoveClick?: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
12
- onMoveClick?: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => void;
13
- selectContainer?: (containerKey?: TDashboardWidgetKey) => void;
14
- }
15
- export interface IDashboardWidget extends JSX.Element {
16
- }
17
- export type TWidgetFactory = TWidgetFactoryBase<TFrameworkComponentType>;
18
- export interface IDynamicWidgetCatalogEntry extends IDynamicWidgetCatalogEntryBase<TFrameworkElementType, TFrameworkComponentType> {
19
- }
20
- export type TDashboardWidgetCatalog = TDashboardWidgetCatalogBase<TFrameworkElementType, TFrameworkComponentType>;
21
- export {};
@@ -1 +0,0 @@
1
- export * from './core-react.interfaces';
@@ -1,33 +0,0 @@
1
- import type { IDashboardConfig, TDashboardWidgetKey } from '@tenorlab/dashboard-core';
2
- type TAddWidgetResponse = {
3
- success: boolean;
4
- message?: string;
5
- updatedDashboardConfig: IDashboardConfig;
6
- allUpdatedDashboardConfigs: IDashboardConfig[];
7
- };
8
- type TRemoveWidgetResponse = TAddWidgetResponse;
9
- type TDashboardSlice = {
10
- isLoading: boolean;
11
- isEditing: boolean;
12
- allDashboardConfigs: IDashboardConfig[];
13
- currentDashboardConfig: IDashboardConfig;
14
- targetContainerKey?: TDashboardWidgetKey | undefined;
15
- getNextContainerKey: (containerWidgetKey: TDashboardWidgetKey) => TDashboardWidgetKey;
16
- setIsLoading: (value: boolean) => boolean;
17
- setIsEditing: (value: boolean) => boolean;
18
- setTargetContainerKey: (value: TDashboardWidgetKey | undefined) => TDashboardWidgetKey | undefined;
19
- setAllDashboardConfigs: (value: IDashboardConfig[]) => IDashboardConfig[];
20
- setCurrentDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
21
- addDashboardConfig: (value: IDashboardConfig) => IDashboardConfig[];
22
- deleteDashboardConfigById: (value: string) => IDashboardConfig[];
23
- selectDashboardById: (dashboardId: string) => IDashboardConfig | undefined;
24
- addWidget: (params: {
25
- widgetKey: TDashboardWidgetKey;
26
- parentWidgetKey?: TDashboardWidgetKey;
27
- noDuplicatedWidgets?: boolean;
28
- }) => TAddWidgetResponse;
29
- removeWidget: (widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
30
- moveWidget: (direction: -1 | 1, widgetKey: TDashboardWidgetKey, parentWidgetKey?: TDashboardWidgetKey) => TRemoveWidgetResponse;
31
- };
32
- export declare const useDashboardStore: import("zustand").UseBoundStore<import("zustand").StoreApi<TDashboardSlice>>;
33
- export {};
@@ -1,13 +0,0 @@
1
- import type { IDashboardConfig, TUndoHistoryEntry, TDashboardUndoStatus } from '@tenorlab/dashboard-core';
2
- export declare const useDashboardUndoService: () => {
3
- initializeHistoryForDashboard: (initialConfig: IDashboardConfig) => void;
4
- resetAllHistory: () => void;
5
- addUndoEntry: (newConfig: IDashboardConfig) => void;
6
- removeUndoHistoryForDashboard: (dashboardId: string) => void;
7
- undo: (currentDashboardId: string) => void;
8
- redo: (currentDashboardId: string) => void;
9
- getUndoStatus: (currentDashboardId: string) => TDashboardUndoStatus;
10
- undoHistory: Record<string, TUndoHistoryEntry[]>;
11
- historyIndex: Record<string, number>;
12
- };
13
- export type TDashboardUndoService = ReturnType<typeof useDashboardUndoService>;