semaphor 0.0.22 → 0.0.24

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,12 +64,15 @@ 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 = {
59
74
  setCardRefreshInterval: (refreshInterval: string) => void;
75
+ setNumberFormat: (format: string, currency: string, locale: string, suffix: string) => void;
60
76
  setIsShowingVisual: (isShowingVisual: boolean) => void;
61
77
  setRunSql: (runSql: boolean) => void;
62
78
  setCardPreferences: (preferences: TCardPreferences) => void;
@@ -94,6 +110,11 @@ export declare type AuthToken = {
94
110
  refreshToken: string;
95
111
  };
96
112
 
113
+ declare type BaseCustomCard = {
114
+ cardId: string;
115
+ replaceDefault?: boolean;
116
+ };
117
+
97
118
  declare type BaseFilter = {
98
119
  filterId: TFilter['id'];
99
120
  expression?: string;
@@ -109,10 +130,39 @@ export declare type Bookmark = {
109
130
  filterValues?: TFilterValue[];
110
131
  };
111
132
 
133
+ declare type CardWithContent = BaseCustomCard & {
134
+ content: React.FC<{
135
+ card: TCard;
136
+ }>;
137
+ footer?: React.FC<{
138
+ card: TCard;
139
+ }>;
140
+ };
141
+
142
+ declare type CardWithFooter = BaseCustomCard & {
143
+ content?: React.FC<{
144
+ card: TCard;
145
+ }>;
146
+ footer: React.FC<{
147
+ card: TCard;
148
+ }>;
149
+ };
150
+
112
151
  export declare function cleanCard(card: TCard): TCard;
113
152
 
153
+ export declare type CustomCard = CardWithContent | CardWithFooter;
154
+
114
155
  export declare function Dashboard(props: DashboardProps): JSX_2.Element;
115
156
 
157
+ export declare function DashboardCard({ card, footer, className, ...props }: DashboardCardProps): JSX_2.Element | null;
158
+
159
+ declare type DashboardCardProps = {
160
+ card: TCard;
161
+ footer?: React_2.ReactNode;
162
+ showControls?: boolean;
163
+ fetchCardData?: boolean;
164
+ } & React_2.HTMLAttributes<HTMLDivElement>;
165
+
116
166
  export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
117
167
 
118
168
  declare type DashboardPlusProps = {
@@ -126,16 +176,23 @@ export declare type DashboardProps = {
126
176
  style?: TStyle;
127
177
  currentTheme?: 'light' | 'dark' | 'system';
128
178
  version?: string;
179
+ customCards?: CustomCard[];
180
+ onChartElementClicked?: (card: TCard, fieldValues: any) => void;
129
181
  onEvent?: (event: TEvent) => void;
130
182
  onSave?: (dashboard: TDashboard) => void;
131
183
  LoadingComponent?: (props: LoadingProps) => React.ReactNode;
132
184
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
133
185
  };
134
186
 
135
- declare type DashboardStore = {
187
+ export declare function DashboardProvider({ children }: {
188
+ children: React.ReactNode;
189
+ }): JSX_2.Element;
190
+
191
+ export declare type DashboardStore = {
136
192
  authToken?: AuthToken;
137
193
  theme?: 'light' | 'dark' | 'system';
138
194
  themeStyle?: StyleProps;
195
+ filteringCards?: TCard[];
139
196
  bookmarkKey?: string;
140
197
  dashboard: TDashboard;
141
198
  selectedSheetId?: string | null | undefined;
@@ -230,6 +287,7 @@ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard)
230
287
  description?: string | undefined;
231
288
  style?: TStyle | undefined;
232
289
  filters?: TFilter[] | undefined;
290
+ customCards?: CustomCard[] | undefined;
233
291
  };
234
292
 
235
293
  export declare type LoadingProps = {
@@ -281,6 +339,7 @@ export declare type TCard = {
281
339
  sql?: string;
282
340
  data?: any[];
283
341
  cfg?: any;
342
+ childCards?: any[];
284
343
  customCfg?: any;
285
344
  preferences?: TCardPreferences;
286
345
  lastSelectedDatabase?: string;
@@ -299,9 +358,18 @@ export declare type TCardContext = {
299
358
  export declare type TCardPreferences = {
300
359
  filterOnClick?: boolean;
301
360
  filterOnClickField?: string;
361
+ formatNumber?: {
362
+ format?: string;
363
+ currency?: string;
364
+ locale?: string;
365
+ suffix?: string;
366
+ enabled?: boolean | string;
367
+ };
302
368
  };
303
369
 
304
- declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table';
370
+ declare type TChartConfiguration = ChartConfiguration;
371
+
372
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
305
373
 
306
374
  export declare type TDashboard = {
307
375
  id: string;
@@ -310,6 +378,7 @@ export declare type TDashboard = {
310
378
  sheets?: TSheet[];
311
379
  style?: TStyle;
312
380
  filters?: TFilter[];
381
+ customCards?: CustomCard[];
313
382
  };
314
383
 
315
384
  declare type TDataColumn = {
@@ -362,6 +431,35 @@ export declare function useActions(): {
362
431
  setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
363
432
  };
364
433
 
434
+ export declare function useCard(cardId: string): {
435
+ data: any;
436
+ card: TCard;
437
+ isError: boolean;
438
+ isLoading: boolean;
439
+ isFetching: boolean;
440
+ visualKey: number;
441
+ handleDatapointClick: (chart: Chart_2<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint | null)[], unknown>, datasetIndex: number, clickIndex: number, value: number) => void;
442
+ cfg: TChartConfiguration | undefined;
443
+ };
444
+
445
+ export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, }: UseDashboardProps): {
446
+ isLoading: boolean;
447
+ isError: boolean;
448
+ };
449
+
450
+ export declare const useDashboardActions: () => Actions;
451
+
452
+ declare type UseDashboardProps = {
453
+ id: string;
454
+ version?: string;
455
+ authToken: AuthToken | undefined;
456
+ customStyle?: TStyle;
457
+ currentTheme?: 'light' | 'dark' | 'system';
458
+ onSave?: (dashboard: TDashboard) => void;
459
+ onEvent?: (event: TEvent) => void;
460
+ customCards?: CustomCard[];
461
+ };
462
+
365
463
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
366
464
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
367
465
  authToken?: {
@@ -390,6 +488,33 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
390
488
  options?: any;
391
489
  } | undefined;
392
490
  } | undefined;
491
+ filteringCards?: {
492
+ id: string;
493
+ title: string;
494
+ description?: string | undefined;
495
+ connectionId?: string | undefined;
496
+ type: TChartType;
497
+ sql?: string | undefined;
498
+ data?: any[] | undefined;
499
+ cfg?: any;
500
+ childCards?: any[] | undefined;
501
+ customCfg?: any;
502
+ preferences?: {
503
+ filterOnClick?: boolean | undefined;
504
+ filterOnClickField?: string | undefined;
505
+ formatNumber?: {
506
+ format?: string | undefined;
507
+ currency?: string | undefined;
508
+ locale?: string | undefined;
509
+ suffix?: string | undefined;
510
+ enabled?: string | boolean | undefined;
511
+ } | undefined;
512
+ } | undefined;
513
+ lastSelectedDatabase?: string | undefined;
514
+ lastSelectedSchema?: string | undefined;
515
+ lastSelectedTable?: string | undefined;
516
+ refreshInterval?: string | undefined;
517
+ }[] | undefined;
393
518
  bookmarkKey?: string | undefined;
394
519
  dashboard: {
395
520
  id: string;
@@ -413,7 +538,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
413
538
  static?: boolean | undefined;
414
539
  isDraggable?: boolean | undefined;
415
540
  isResizable?: boolean | undefined;
416
- resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
541
+ resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
417
542
  isBounded?: boolean | undefined;
418
543
  }[] | undefined;
419
544
  cards?: {
@@ -425,10 +550,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
425
550
  sql?: string | undefined;
426
551
  data?: any[] | undefined;
427
552
  cfg?: any;
553
+ childCards?: any[] | undefined;
428
554
  customCfg?: any;
429
555
  preferences?: {
430
556
  filterOnClick?: boolean | undefined;
431
557
  filterOnClickField?: string | undefined;
558
+ formatNumber?: {
559
+ format?: string | undefined;
560
+ currency?: string | undefined;
561
+ locale?: string | undefined;
562
+ suffix?: string | undefined;
563
+ enabled?: string | boolean | undefined;
564
+ } | undefined;
432
565
  } | undefined;
433
566
  lastSelectedDatabase?: string | undefined;
434
567
  lastSelectedSchema?: string | undefined;
@@ -490,6 +623,25 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
490
623
  database: string;
491
624
  sql: string;
492
625
  }[] | undefined;
626
+ customCards?: ({
627
+ cardId: string;
628
+ replaceDefault?: boolean | undefined;
629
+ content: FC<{
630
+ card: TCard;
631
+ }>;
632
+ footer?: FC<{
633
+ card: TCard;
634
+ }> | undefined;
635
+ } | {
636
+ cardId: string;
637
+ replaceDefault?: boolean | undefined;
638
+ content?: FC<{
639
+ card: TCard;
640
+ }> | undefined;
641
+ footer: FC<{
642
+ card: TCard;
643
+ }>;
644
+ })[] | undefined;
493
645
  };
494
646
  selectedSheetId?: string | null | undefined;
495
647
  selectedCardId?: string | null | undefined;
@@ -502,10 +654,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
502
654
  sql?: string | undefined;
503
655
  data?: any[] | undefined;
504
656
  cfg?: any;
657
+ childCards?: any[] | undefined;
505
658
  customCfg?: any;
506
659
  preferences?: {
507
660
  filterOnClick?: boolean | undefined;
508
661
  filterOnClickField?: string | undefined;
662
+ formatNumber?: {
663
+ format?: string | undefined;
664
+ currency?: string | undefined;
665
+ locale?: string | undefined;
666
+ suffix?: string | undefined;
667
+ enabled?: string | boolean | undefined;
668
+ } | undefined;
509
669
  } | undefined;
510
670
  lastSelectedDatabase?: string | undefined;
511
671
  lastSelectedSchema?: string | undefined;
@@ -573,6 +733,9 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
573
733
  onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
574
734
  onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
575
735
  actions: {
736
+ addFilteringCard: (card: TCard) => void;
737
+ removeFilteringCard: (card: TCard) => void;
738
+ setCustomCards: (customCards: CustomCard[]) => void;
576
739
  setAuthToken: (authToken: AuthToken) => void;
577
740
  setThemeStyle: (themeStyle: StyleProps) => void;
578
741
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -607,6 +770,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
607
770
  setFilterValues: (filterValues: TFilterValue[] | undefined) => void;
608
771
  addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
609
772
  removeFilterValue: (filterId: string) => void;
773
+ replaceFilterValue: (filterValue: TFilterValue) => void;
610
774
  setStyle: (style: TStyle) => void;
611
775
  getStyle: () => TStyle | undefined;
612
776
  setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
@@ -617,12 +781,16 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
617
781
  getDashboard: () => TDashboard | undefined;
618
782
  getSelectedSheet: () => TSheet | undefined;
619
783
  getSelectedSheetCards: () => TCard[] | undefined;
784
+ getCard: (cardId: string) => TCard | undefined;
620
785
  getSelectedCard: () => TCard | undefined;
621
786
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
787
+ handleDataPointClickAction: (card: TCard, dataPoint: any) => void;
622
788
  };
623
789
  }) => void), shouldReplace?: boolean | undefined): void;
624
790
  }>;
625
791
 
792
+ export declare const useEditorActions: () => Actions_2;
793
+
626
794
  export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "setState"> & {
627
795
  setState(nextStateOrUpdater: EditorStore | Partial<EditorStore> | ((state: {
628
796
  isShowingVisual: boolean;
@@ -630,6 +798,7 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
630
798
  isSqlRunning: boolean;
631
799
  actions: {
632
800
  setCardRefreshInterval: (refreshInterval: string) => void;
801
+ setNumberFormat: (format: string, currency: string, locale: string, suffix: string) => void;
633
802
  setIsShowingVisual: (isShowingVisual: boolean) => void;
634
803
  setRunSql: (runSql: boolean) => void;
635
804
  setCardPreferences: (preferences: TCardPreferences) => void;
@@ -675,10 +844,18 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
675
844
  sql?: string | undefined;
676
845
  data?: any[] | undefined;
677
846
  cfg?: any;
847
+ childCards?: any[] | undefined;
678
848
  customCfg?: any;
679
849
  preferences?: {
680
850
  filterOnClick?: boolean | undefined;
681
851
  filterOnClickField?: string | undefined;
852
+ formatNumber?: {
853
+ format?: string | undefined;
854
+ currency?: string | undefined;
855
+ locale?: string | undefined;
856
+ suffix?: string | undefined;
857
+ enabled?: string | boolean | undefined;
858
+ } | undefined;
682
859
  } | undefined;
683
860
  lastSelectedDatabase?: string | undefined;
684
861
  lastSelectedSchema?: string | undefined;
@@ -754,4 +931,8 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
754
931
  }) => void), shouldReplace?: boolean | undefined): void;
755
932
  }>;
756
933
 
934
+ export declare type WritableDraft<T> = {
935
+ -readonly [K in keyof T]: Draft<T[K]>;
936
+ };
937
+
757
938
  export { }