react-semaphor 0.0.72 → 0.0.74

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.
@@ -1,12 +1,24 @@
1
+ /// <reference types="react" />
1
2
  /// <reference types="react-grid-layout" />
2
3
 
4
+ import { BubbleDataPoint } from 'chart.js';
5
+ import { Chart as Chart_2 } from 'chart.js';
6
+ import { ChartConfiguration } from 'chart.js';
7
+ import { ChartTypeRegistry } from 'chart.js';
8
+ import { Draft } from 'immer';
9
+ import { FC } from 'react';
3
10
  import { FontSpec } from 'chart.js';
4
11
  import { JSX as JSX_2 } from 'react/jsx-runtime';
5
12
  import { Layout } from 'react-grid-layout';
13
+ import { Point } from 'chart.js';
14
+ import { default as React_2 } from 'react';
6
15
  import { StoreApi } from 'zustand';
7
16
  import { UseBoundStore } from 'zustand';
8
17
 
9
18
  declare type Actions = {
19
+ addFilteringCard: (card: TCard) => void;
20
+ removeFilteringCard: (card: TCard) => void;
21
+ setCustomCards: (customCards: CustomCard[]) => void;
10
22
  setAuthToken: (authToken: AuthToken) => void;
11
23
  setThemeStyle: (themeStyle: StyleProps) => void;
12
24
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -41,6 +53,7 @@ declare type Actions = {
41
53
  setFilterValues: (filterValues: TFilterValue[] | undefined) => void;
42
54
  addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
43
55
  removeFilterValue: (filterId: string) => void;
56
+ replaceFilterValue: (filterValue: TFilterValue) => void;
44
57
  setStyle: (style: TStyle) => void;
45
58
  getStyle: () => TStyle | undefined;
46
59
  setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
@@ -51,8 +64,10 @@ declare type Actions = {
51
64
  getDashboard: () => TDashboard | undefined;
52
65
  getSelectedSheet: () => TSheet | undefined;
53
66
  getSelectedSheetCards: () => TCard[] | undefined;
67
+ getCard: (cardId: string) => TCard | undefined;
54
68
  getSelectedCard: () => TCard | undefined;
55
69
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
70
+ handleDataPointClickAction: (card: TCard, dataPoint: any) => void;
56
71
  };
57
72
 
58
73
  declare type Actions_2 = {
@@ -112,8 +127,28 @@ export declare type Bookmark = {
112
127
 
113
128
  export declare function cleanCard(card: TCard): TCard;
114
129
 
130
+ export declare type CustomCard = {
131
+ cardId: string;
132
+ content: React.FC<{
133
+ card: TCard;
134
+ }>;
135
+ footer?: React.FC<{
136
+ card: TCard;
137
+ }>;
138
+ replaceDefault?: boolean;
139
+ };
140
+
115
141
  export declare function Dashboard(props: DashboardProps): JSX_2.Element;
116
142
 
143
+ export declare function DashboardCard({ card, footer, className, ...props }: DashboardCardProps): JSX_2.Element | null;
144
+
145
+ declare type DashboardCardProps = {
146
+ card: TCard;
147
+ footer?: React_2.ReactNode;
148
+ showControls?: boolean;
149
+ fetchCardData?: boolean;
150
+ } & React_2.HTMLAttributes<HTMLDivElement>;
151
+
117
152
  export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
118
153
 
119
154
  declare type DashboardPlusProps = {
@@ -127,16 +162,22 @@ export declare type DashboardProps = {
127
162
  style?: TStyle;
128
163
  currentTheme?: 'light' | 'dark' | 'system';
129
164
  version?: string;
165
+ customCards?: CustomCard[];
130
166
  onEvent?: (event: TEvent) => void;
131
167
  onSave?: (dashboard: TDashboard) => void;
132
168
  LoadingComponent?: (props: LoadingProps) => React.ReactNode;
133
169
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
134
170
  };
135
171
 
136
- declare type DashboardStore = {
172
+ export declare function DashboardProvider({ children }: {
173
+ children: React.ReactNode;
174
+ }): JSX_2.Element;
175
+
176
+ export declare type DashboardStore = {
137
177
  authToken?: AuthToken;
138
178
  theme?: 'light' | 'dark' | 'system';
139
179
  themeStyle?: StyleProps;
180
+ filteringCards?: TCard[];
140
181
  bookmarkKey?: string;
141
182
  dashboard: TDashboard;
142
183
  selectedSheetId?: string | null | undefined;
@@ -231,6 +272,7 @@ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard)
231
272
  description?: string | undefined;
232
273
  style?: TStyle | undefined;
233
274
  filters?: TFilter[] | undefined;
275
+ customCards?: CustomCard[] | undefined;
234
276
  };
235
277
 
236
278
  export declare type LoadingProps = {
@@ -282,6 +324,7 @@ export declare type TCard = {
282
324
  sql?: string;
283
325
  data?: any[];
284
326
  cfg?: any;
327
+ childCards?: any[];
285
328
  customCfg?: any;
286
329
  preferences?: TCardPreferences;
287
330
  lastSelectedDatabase?: string;
@@ -309,7 +352,9 @@ export declare type TCardPreferences = {
309
352
  };
310
353
  };
311
354
 
312
- declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi';
355
+ declare type TChartConfiguration = ChartConfiguration;
356
+
357
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
313
358
 
314
359
  export declare type TDashboard = {
315
360
  id: string;
@@ -318,6 +363,7 @@ export declare type TDashboard = {
318
363
  sheets?: TSheet[];
319
364
  style?: TStyle;
320
365
  filters?: TFilter[];
366
+ customCards?: CustomCard[];
321
367
  };
322
368
 
323
369
  declare type TDataColumn = {
@@ -370,6 +416,35 @@ export declare function useActions(): {
370
416
  setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
371
417
  };
372
418
 
419
+ export declare function useCard(cardId: string): {
420
+ data: any;
421
+ card: TCard;
422
+ isError: boolean;
423
+ isLoading: boolean;
424
+ isFetching: boolean;
425
+ visualKey: number;
426
+ handleDatapointClick: (chart: Chart_2<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint | null)[], unknown>, datasetIndex: number, clickIndex: number, value: number) => void;
427
+ cfg: TChartConfiguration | undefined;
428
+ };
429
+
430
+ export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, }: UseDashboardProps): {
431
+ isLoading: boolean;
432
+ isError: boolean;
433
+ };
434
+
435
+ export declare const useDashboardActions: () => Actions;
436
+
437
+ declare type UseDashboardProps = {
438
+ id: string;
439
+ version?: string;
440
+ authToken: AuthToken | undefined;
441
+ customStyle?: TStyle;
442
+ currentTheme?: 'light' | 'dark' | 'system';
443
+ onSave?: (dashboard: TDashboard) => void;
444
+ onEvent?: (event: TEvent) => void;
445
+ customCards?: CustomCard[];
446
+ };
447
+
373
448
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
374
449
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
375
450
  authToken?: {
@@ -398,6 +473,33 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
398
473
  options?: any;
399
474
  } | undefined;
400
475
  } | undefined;
476
+ filteringCards?: {
477
+ id: string;
478
+ title: string;
479
+ description?: string | undefined;
480
+ connectionId?: string | undefined;
481
+ type: TChartType;
482
+ sql?: string | undefined;
483
+ data?: any[] | undefined;
484
+ cfg?: any;
485
+ childCards?: any[] | undefined;
486
+ customCfg?: any;
487
+ preferences?: {
488
+ filterOnClick?: boolean | undefined;
489
+ filterOnClickField?: string | undefined;
490
+ formatNumber?: {
491
+ format?: string | undefined;
492
+ currency?: string | undefined;
493
+ locale?: string | undefined;
494
+ suffix?: string | undefined;
495
+ enabled?: string | boolean | undefined;
496
+ } | undefined;
497
+ } | undefined;
498
+ lastSelectedDatabase?: string | undefined;
499
+ lastSelectedSchema?: string | undefined;
500
+ lastSelectedTable?: string | undefined;
501
+ refreshInterval?: string | undefined;
502
+ }[] | undefined;
401
503
  bookmarkKey?: string | undefined;
402
504
  dashboard: {
403
505
  id: string;
@@ -421,7 +523,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
421
523
  static?: boolean | undefined;
422
524
  isDraggable?: boolean | undefined;
423
525
  isResizable?: boolean | undefined;
424
- resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
526
+ resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
425
527
  isBounded?: boolean | undefined;
426
528
  }[] | undefined;
427
529
  cards?: {
@@ -433,6 +535,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
433
535
  sql?: string | undefined;
434
536
  data?: any[] | undefined;
435
537
  cfg?: any;
538
+ childCards?: any[] | undefined;
436
539
  customCfg?: any;
437
540
  preferences?: {
438
541
  filterOnClick?: boolean | undefined;
@@ -505,6 +608,16 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
505
608
  database: string;
506
609
  sql: string;
507
610
  }[] | undefined;
611
+ customCards?: {
612
+ cardId: string;
613
+ content: FC<{
614
+ card: TCard;
615
+ }>;
616
+ footer?: FC<{
617
+ card: TCard;
618
+ }> | undefined;
619
+ replaceDefault?: boolean | undefined;
620
+ }[] | undefined;
508
621
  };
509
622
  selectedSheetId?: string | null | undefined;
510
623
  selectedCardId?: string | null | undefined;
@@ -517,6 +630,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
517
630
  sql?: string | undefined;
518
631
  data?: any[] | undefined;
519
632
  cfg?: any;
633
+ childCards?: any[] | undefined;
520
634
  customCfg?: any;
521
635
  preferences?: {
522
636
  filterOnClick?: boolean | undefined;
@@ -595,6 +709,9 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
595
709
  onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
596
710
  onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
597
711
  actions: {
712
+ addFilteringCard: (card: TCard) => void;
713
+ removeFilteringCard: (card: TCard) => void;
714
+ setCustomCards: (customCards: CustomCard[]) => void;
598
715
  setAuthToken: (authToken: AuthToken) => void;
599
716
  setThemeStyle: (themeStyle: StyleProps) => void;
600
717
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -629,6 +746,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
629
746
  setFilterValues: (filterValues: TFilterValue[] | undefined) => void;
630
747
  addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
631
748
  removeFilterValue: (filterId: string) => void;
749
+ replaceFilterValue: (filterValue: TFilterValue) => void;
632
750
  setStyle: (style: TStyle) => void;
633
751
  getStyle: () => TStyle | undefined;
634
752
  setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
@@ -639,12 +757,16 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
639
757
  getDashboard: () => TDashboard | undefined;
640
758
  getSelectedSheet: () => TSheet | undefined;
641
759
  getSelectedSheetCards: () => TCard[] | undefined;
760
+ getCard: (cardId: string) => TCard | undefined;
642
761
  getSelectedCard: () => TCard | undefined;
643
762
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
763
+ handleDataPointClickAction: (card: TCard, dataPoint: any) => void;
644
764
  };
645
765
  }) => void), shouldReplace?: boolean | undefined): void;
646
766
  }>;
647
767
 
768
+ export declare const useEditorActions: () => Actions_2;
769
+
648
770
  export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "setState"> & {
649
771
  setState(nextStateOrUpdater: EditorStore | Partial<EditorStore> | ((state: {
650
772
  isShowingVisual: boolean;
@@ -698,6 +820,7 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
698
820
  sql?: string | undefined;
699
821
  data?: any[] | undefined;
700
822
  cfg?: any;
823
+ childCards?: any[] | undefined;
701
824
  customCfg?: any;
702
825
  preferences?: {
703
826
  filterOnClick?: boolean | undefined;
@@ -784,4 +907,8 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
784
907
  }) => void), shouldReplace?: boolean | undefined): void;
785
908
  }>;
786
909
 
910
+ export declare type WritableDraft<T> = {
911
+ -readonly [K in keyof T]: Draft<T[K]>;
912
+ };
913
+
787
914
  export { }