semaphor 0.0.21 → 0.0.23

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;
@@ -111,8 +127,28 @@ export declare type Bookmark = {
111
127
 
112
128
  export declare function cleanCard(card: TCard): TCard;
113
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
+
114
141
  export declare function Dashboard(props: DashboardProps): JSX_2.Element;
115
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
+
116
152
  export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
117
153
 
118
154
  declare type DashboardPlusProps = {
@@ -126,16 +162,22 @@ export declare type DashboardProps = {
126
162
  style?: TStyle;
127
163
  currentTheme?: 'light' | 'dark' | 'system';
128
164
  version?: string;
165
+ customCards?: CustomCard[];
129
166
  onEvent?: (event: TEvent) => void;
130
167
  onSave?: (dashboard: TDashboard) => void;
131
168
  LoadingComponent?: (props: LoadingProps) => React.ReactNode;
132
169
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
133
170
  };
134
171
 
135
- declare type DashboardStore = {
172
+ export declare function DashboardProvider({ children }: {
173
+ children: React.ReactNode;
174
+ }): JSX_2.Element;
175
+
176
+ export declare type DashboardStore = {
136
177
  authToken?: AuthToken;
137
178
  theme?: 'light' | 'dark' | 'system';
138
179
  themeStyle?: StyleProps;
180
+ filteringCards?: TCard[];
139
181
  bookmarkKey?: string;
140
182
  dashboard: TDashboard;
141
183
  selectedSheetId?: string | null | undefined;
@@ -230,6 +272,7 @@ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard)
230
272
  description?: string | undefined;
231
273
  style?: TStyle | undefined;
232
274
  filters?: TFilter[] | undefined;
275
+ customCards?: CustomCard[] | undefined;
233
276
  };
234
277
 
235
278
  export declare type LoadingProps = {
@@ -281,6 +324,7 @@ export declare type TCard = {
281
324
  sql?: string;
282
325
  data?: any[];
283
326
  cfg?: any;
327
+ childCards?: any[];
284
328
  customCfg?: any;
285
329
  preferences?: TCardPreferences;
286
330
  lastSelectedDatabase?: string;
@@ -299,9 +343,18 @@ export declare type TCardContext = {
299
343
  export declare type TCardPreferences = {
300
344
  filterOnClick?: boolean;
301
345
  filterOnClickField?: string;
346
+ formatNumber?: {
347
+ format?: string;
348
+ currency?: string;
349
+ locale?: string;
350
+ suffix?: string;
351
+ enabled?: boolean | string;
352
+ };
302
353
  };
303
354
 
304
- declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table';
355
+ declare type TChartConfiguration = ChartConfiguration;
356
+
357
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
305
358
 
306
359
  export declare type TDashboard = {
307
360
  id: string;
@@ -310,6 +363,7 @@ export declare type TDashboard = {
310
363
  sheets?: TSheet[];
311
364
  style?: TStyle;
312
365
  filters?: TFilter[];
366
+ customCards?: CustomCard[];
313
367
  };
314
368
 
315
369
  declare type TDataColumn = {
@@ -362,6 +416,35 @@ export declare function useActions(): {
362
416
  setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
363
417
  };
364
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
+
365
448
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
366
449
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
367
450
  authToken?: {
@@ -390,6 +473,33 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
390
473
  options?: any;
391
474
  } | undefined;
392
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;
393
503
  bookmarkKey?: string | undefined;
394
504
  dashboard: {
395
505
  id: string;
@@ -413,7 +523,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
413
523
  static?: boolean | undefined;
414
524
  isDraggable?: boolean | undefined;
415
525
  isResizable?: boolean | undefined;
416
- resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
526
+ resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
417
527
  isBounded?: boolean | undefined;
418
528
  }[] | undefined;
419
529
  cards?: {
@@ -425,10 +535,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
425
535
  sql?: string | undefined;
426
536
  data?: any[] | undefined;
427
537
  cfg?: any;
538
+ childCards?: any[] | undefined;
428
539
  customCfg?: any;
429
540
  preferences?: {
430
541
  filterOnClick?: boolean | undefined;
431
542
  filterOnClickField?: string | undefined;
543
+ formatNumber?: {
544
+ format?: string | undefined;
545
+ currency?: string | undefined;
546
+ locale?: string | undefined;
547
+ suffix?: string | undefined;
548
+ enabled?: string | boolean | undefined;
549
+ } | undefined;
432
550
  } | undefined;
433
551
  lastSelectedDatabase?: string | undefined;
434
552
  lastSelectedSchema?: string | undefined;
@@ -490,6 +608,16 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
490
608
  database: string;
491
609
  sql: string;
492
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;
493
621
  };
494
622
  selectedSheetId?: string | null | undefined;
495
623
  selectedCardId?: string | null | undefined;
@@ -502,10 +630,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
502
630
  sql?: string | undefined;
503
631
  data?: any[] | undefined;
504
632
  cfg?: any;
633
+ childCards?: any[] | undefined;
505
634
  customCfg?: any;
506
635
  preferences?: {
507
636
  filterOnClick?: boolean | undefined;
508
637
  filterOnClickField?: string | undefined;
638
+ formatNumber?: {
639
+ format?: string | undefined;
640
+ currency?: string | undefined;
641
+ locale?: string | undefined;
642
+ suffix?: string | undefined;
643
+ enabled?: string | boolean | undefined;
644
+ } | undefined;
509
645
  } | undefined;
510
646
  lastSelectedDatabase?: string | undefined;
511
647
  lastSelectedSchema?: string | undefined;
@@ -573,6 +709,9 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
573
709
  onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
574
710
  onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
575
711
  actions: {
712
+ addFilteringCard: (card: TCard) => void;
713
+ removeFilteringCard: (card: TCard) => void;
714
+ setCustomCards: (customCards: CustomCard[]) => void;
576
715
  setAuthToken: (authToken: AuthToken) => void;
577
716
  setThemeStyle: (themeStyle: StyleProps) => void;
578
717
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -607,6 +746,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
607
746
  setFilterValues: (filterValues: TFilterValue[] | undefined) => void;
608
747
  addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
609
748
  removeFilterValue: (filterId: string) => void;
749
+ replaceFilterValue: (filterValue: TFilterValue) => void;
610
750
  setStyle: (style: TStyle) => void;
611
751
  getStyle: () => TStyle | undefined;
612
752
  setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
@@ -617,12 +757,16 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
617
757
  getDashboard: () => TDashboard | undefined;
618
758
  getSelectedSheet: () => TSheet | undefined;
619
759
  getSelectedSheetCards: () => TCard[] | undefined;
760
+ getCard: (cardId: string) => TCard | undefined;
620
761
  getSelectedCard: () => TCard | undefined;
621
762
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
763
+ handleDataPointClickAction: (card: TCard, dataPoint: any) => void;
622
764
  };
623
765
  }) => void), shouldReplace?: boolean | undefined): void;
624
766
  }>;
625
767
 
768
+ export declare const useEditorActions: () => Actions_2;
769
+
626
770
  export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "setState"> & {
627
771
  setState(nextStateOrUpdater: EditorStore | Partial<EditorStore> | ((state: {
628
772
  isShowingVisual: boolean;
@@ -630,6 +774,7 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
630
774
  isSqlRunning: boolean;
631
775
  actions: {
632
776
  setCardRefreshInterval: (refreshInterval: string) => void;
777
+ setNumberFormat: (format: string, currency: string, locale: string, suffix: string) => void;
633
778
  setIsShowingVisual: (isShowingVisual: boolean) => void;
634
779
  setRunSql: (runSql: boolean) => void;
635
780
  setCardPreferences: (preferences: TCardPreferences) => void;
@@ -675,10 +820,18 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
675
820
  sql?: string | undefined;
676
821
  data?: any[] | undefined;
677
822
  cfg?: any;
823
+ childCards?: any[] | undefined;
678
824
  customCfg?: any;
679
825
  preferences?: {
680
826
  filterOnClick?: boolean | undefined;
681
827
  filterOnClickField?: string | undefined;
828
+ formatNumber?: {
829
+ format?: string | undefined;
830
+ currency?: string | undefined;
831
+ locale?: string | undefined;
832
+ suffix?: string | undefined;
833
+ enabled?: string | boolean | undefined;
834
+ } | undefined;
682
835
  } | undefined;
683
836
  lastSelectedDatabase?: string | undefined;
684
837
  lastSelectedSchema?: string | undefined;
@@ -754,4 +907,8 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
754
907
  }) => void), shouldReplace?: boolean | undefined): void;
755
908
  }>;
756
909
 
910
+ export declare type WritableDraft<T> = {
911
+ -readonly [K in keyof T]: Draft<T[K]>;
912
+ };
913
+
757
914
  export { }