react-semaphor 0.0.71 → 0.0.73

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,21 @@
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';
6
14
  import { StoreApi } from 'zustand';
7
15
  import { UseBoundStore } from 'zustand';
8
16
 
9
17
  declare type Actions = {
18
+ setCustomCards: (customCards: CustomCard[]) => void;
10
19
  setAuthToken: (authToken: AuthToken) => void;
11
20
  setThemeStyle: (themeStyle: StyleProps) => void;
12
21
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -51,12 +60,14 @@ declare type Actions = {
51
60
  getDashboard: () => TDashboard | undefined;
52
61
  getSelectedSheet: () => TSheet | undefined;
53
62
  getSelectedSheetCards: () => TCard[] | undefined;
63
+ getCard: (cardId: string) => TCard | undefined;
54
64
  getSelectedCard: () => TCard | undefined;
55
65
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
56
66
  };
57
67
 
58
68
  declare type Actions_2 = {
59
69
  setCardRefreshInterval: (refreshInterval: string) => void;
70
+ setNumberFormat: (format: string, currency: string, locale: string, suffix: string) => void;
60
71
  setIsShowingVisual: (isShowingVisual: boolean) => void;
61
72
  setRunSql: (runSql: boolean) => void;
62
73
  setCardPreferences: (preferences: TCardPreferences) => void;
@@ -111,6 +122,13 @@ export declare type Bookmark = {
111
122
 
112
123
  export declare function cleanCard(card: TCard): TCard;
113
124
 
125
+ export declare type CustomCard = {
126
+ cardId: string;
127
+ component: React.FC<{
128
+ card: TCard;
129
+ }>;
130
+ };
131
+
114
132
  export declare function Dashboard(props: DashboardProps): JSX_2.Element;
115
133
 
116
134
  export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
@@ -126,12 +144,17 @@ export declare type DashboardProps = {
126
144
  style?: TStyle;
127
145
  currentTheme?: 'light' | 'dark' | 'system';
128
146
  version?: string;
147
+ customCards?: CustomCard[];
129
148
  onEvent?: (event: TEvent) => void;
130
149
  onSave?: (dashboard: TDashboard) => void;
131
150
  LoadingComponent?: (props: LoadingProps) => React.ReactNode;
132
151
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
133
152
  };
134
153
 
154
+ export declare function DashboardProvider({ children }: {
155
+ children: React.ReactNode;
156
+ }): JSX_2.Element;
157
+
135
158
  declare type DashboardStore = {
136
159
  authToken?: AuthToken;
137
160
  theme?: 'light' | 'dark' | 'system';
@@ -230,6 +253,7 @@ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard)
230
253
  description?: string | undefined;
231
254
  style?: TStyle | undefined;
232
255
  filters?: TFilter[] | undefined;
256
+ customCards?: CustomCard[] | undefined;
233
257
  };
234
258
 
235
259
  export declare type LoadingProps = {
@@ -281,6 +305,7 @@ export declare type TCard = {
281
305
  sql?: string;
282
306
  data?: any[];
283
307
  cfg?: any;
308
+ childCards?: any[];
284
309
  customCfg?: any;
285
310
  preferences?: TCardPreferences;
286
311
  lastSelectedDatabase?: string;
@@ -299,9 +324,18 @@ export declare type TCardContext = {
299
324
  export declare type TCardPreferences = {
300
325
  filterOnClick?: boolean;
301
326
  filterOnClickField?: string;
327
+ formatNumber?: {
328
+ format?: string;
329
+ currency?: string;
330
+ locale?: string;
331
+ suffix?: string;
332
+ enabled?: boolean | string;
333
+ };
302
334
  };
303
335
 
304
- declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi';
336
+ declare type TChartConfiguration = ChartConfiguration;
337
+
338
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
305
339
 
306
340
  export declare type TDashboard = {
307
341
  id: string;
@@ -310,6 +344,7 @@ export declare type TDashboard = {
310
344
  sheets?: TSheet[];
311
345
  style?: TStyle;
312
346
  filters?: TFilter[];
347
+ customCards?: CustomCard[];
313
348
  };
314
349
 
315
350
  declare type TDataColumn = {
@@ -362,6 +397,34 @@ export declare function useActions(): {
362
397
  setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
363
398
  };
364
399
 
400
+ export declare function useCard(cardId: string): {
401
+ data: any;
402
+ isError: boolean;
403
+ isLoading: boolean;
404
+ isFetching: boolean;
405
+ visualKey: number;
406
+ handleDatapointClick: (chart: Chart_2<keyof ChartTypeRegistry, (number | [number, number] | Point | BubbleDataPoint | null)[], unknown>, datasetIndex: number, clickIndex: number, value: number) => void;
407
+ cfg: TChartConfiguration | undefined;
408
+ };
409
+
410
+ export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, customCards, }: UseDashboardProps): {
411
+ isLoading: boolean;
412
+ isError: boolean;
413
+ };
414
+
415
+ export declare const useDashboardActions: () => Actions;
416
+
417
+ declare type UseDashboardProps = {
418
+ id: string;
419
+ version?: string;
420
+ authToken: AuthToken | undefined;
421
+ customStyle?: TStyle;
422
+ currentTheme?: 'light' | 'dark' | 'system';
423
+ onSave?: (dashboard: TDashboard) => void;
424
+ onEvent?: (event: TEvent) => void;
425
+ customCards?: CustomCard[];
426
+ };
427
+
365
428
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
366
429
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
367
430
  authToken?: {
@@ -425,10 +488,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
425
488
  sql?: string | undefined;
426
489
  data?: any[] | undefined;
427
490
  cfg?: any;
491
+ childCards?: any[] | undefined;
428
492
  customCfg?: any;
429
493
  preferences?: {
430
494
  filterOnClick?: boolean | undefined;
431
495
  filterOnClickField?: string | undefined;
496
+ formatNumber?: {
497
+ format?: string | undefined;
498
+ currency?: string | undefined;
499
+ locale?: string | undefined;
500
+ suffix?: string | undefined;
501
+ enabled?: string | boolean | undefined;
502
+ } | undefined;
432
503
  } | undefined;
433
504
  lastSelectedDatabase?: string | undefined;
434
505
  lastSelectedSchema?: string | undefined;
@@ -490,6 +561,12 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
490
561
  database: string;
491
562
  sql: string;
492
563
  }[] | undefined;
564
+ customCards?: {
565
+ cardId: string;
566
+ component: FC<{
567
+ card: TCard;
568
+ }>;
569
+ }[] | undefined;
493
570
  };
494
571
  selectedSheetId?: string | null | undefined;
495
572
  selectedCardId?: string | null | undefined;
@@ -502,10 +579,18 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
502
579
  sql?: string | undefined;
503
580
  data?: any[] | undefined;
504
581
  cfg?: any;
582
+ childCards?: any[] | undefined;
505
583
  customCfg?: any;
506
584
  preferences?: {
507
585
  filterOnClick?: boolean | undefined;
508
586
  filterOnClickField?: string | undefined;
587
+ formatNumber?: {
588
+ format?: string | undefined;
589
+ currency?: string | undefined;
590
+ locale?: string | undefined;
591
+ suffix?: string | undefined;
592
+ enabled?: string | boolean | undefined;
593
+ } | undefined;
509
594
  } | undefined;
510
595
  lastSelectedDatabase?: string | undefined;
511
596
  lastSelectedSchema?: string | undefined;
@@ -573,6 +658,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
573
658
  onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
574
659
  onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
575
660
  actions: {
661
+ setCustomCards: (customCards: CustomCard[]) => void;
576
662
  setAuthToken: (authToken: AuthToken) => void;
577
663
  setThemeStyle: (themeStyle: StyleProps) => void;
578
664
  setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
@@ -617,12 +703,15 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
617
703
  getDashboard: () => TDashboard | undefined;
618
704
  getSelectedSheet: () => TSheet | undefined;
619
705
  getSelectedSheetCards: () => TCard[] | undefined;
706
+ getCard: (cardId: string) => TCard | undefined;
620
707
  getSelectedCard: () => TCard | undefined;
621
708
  getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
622
709
  };
623
710
  }) => void), shouldReplace?: boolean | undefined): void;
624
711
  }>;
625
712
 
713
+ export declare const useEditorActions: () => Actions_2;
714
+
626
715
  export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "setState"> & {
627
716
  setState(nextStateOrUpdater: EditorStore | Partial<EditorStore> | ((state: {
628
717
  isShowingVisual: boolean;
@@ -630,6 +719,7 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
630
719
  isSqlRunning: boolean;
631
720
  actions: {
632
721
  setCardRefreshInterval: (refreshInterval: string) => void;
722
+ setNumberFormat: (format: string, currency: string, locale: string, suffix: string) => void;
633
723
  setIsShowingVisual: (isShowingVisual: boolean) => void;
634
724
  setRunSql: (runSql: boolean) => void;
635
725
  setCardPreferences: (preferences: TCardPreferences) => void;
@@ -675,10 +765,18 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
675
765
  sql?: string | undefined;
676
766
  data?: any[] | undefined;
677
767
  cfg?: any;
768
+ childCards?: any[] | undefined;
678
769
  customCfg?: any;
679
770
  preferences?: {
680
771
  filterOnClick?: boolean | undefined;
681
772
  filterOnClickField?: string | undefined;
773
+ formatNumber?: {
774
+ format?: string | undefined;
775
+ currency?: string | undefined;
776
+ locale?: string | undefined;
777
+ suffix?: string | undefined;
778
+ enabled?: string | boolean | undefined;
779
+ } | undefined;
682
780
  } | undefined;
683
781
  lastSelectedDatabase?: string | undefined;
684
782
  lastSelectedSchema?: string | undefined;
@@ -754,4 +852,8 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
754
852
  }) => void), shouldReplace?: boolean | undefined): void;
755
853
  }>;
756
854
 
855
+ export declare type WritableDraft<T> = {
856
+ -readonly [K in keyof T]: Draft<T[K]>;
857
+ };
858
+
757
859
  export { }