@redsift/charts 9.6.0 → 10.0.0-alpha.0

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/CONTRIBUTING.md CHANGED
@@ -311,7 +311,7 @@ export const StyledBadge = styled.div<StyledBadgeProps>`
311
311
  $color
312
312
  ? css`
313
313
  color: var(--redsift-color-neutral-white);
314
- background-color: var(--redsift-color-${$color}-primary);
314
+ background-color: var(--redsift-color-presentation-color-${$color}-standard);
315
315
  `
316
316
  : ''}
317
317
  `;
@@ -381,7 +381,7 @@ To display a prop table, use the `PropsTable` component as following:
381
381
  To display a demo, first create a demo (a simple `tsx` file) in the demo folder (`apps/website/demo/`) inside a subfolder with the name of the component (i.e. `apps/website/demo/button/coloring` for a coloring demo of the `Button` component). Then use the `DemoBlock` as following:
382
382
 
383
383
  ```ts
384
- <DemoBlock path="button/coloring" />
384
+ <DemoBlock withThemeSwitcher path="button/coloring" />
385
385
  ```
386
386
 
387
387
  To display simple code, use the `CodeBlock` as following:
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BrushBehavior, ScaleLinear as ScaleLinear$1, ScaleOrdinal, Arc as Arc$1, ScaleTime as ScaleTime$2, ScalePoint as ScalePoint$2, Line as Line$1 } from 'd3';
2
2
  import * as _redsift_design_system from '@redsift/design-system';
3
- import { ValueOf, Comp, ContainerProps } from '@redsift/design-system';
3
+ import { ValueOf, Theme, Comp, ContainerProps } from '@redsift/design-system';
4
4
  import { PieArcDatum } from 'd3-shape';
5
5
  import { MutableRefObject, ComponentProps, ReactElement, RefObject, ReactNode } from 'react';
6
6
  import * as d3_scale from 'd3-scale';
@@ -66,14 +66,18 @@ interface AxisProps extends Omit<ComponentProps<'g'>, 'scale'> {
66
66
  /** Y position. */
67
67
  y?: number;
68
68
  }
69
- type StyledAxisProps = Omit<AxisProps, 'areXLabelsRotated' | 'size' | 'scale'> & {};
69
+ type StyledAxisProps = Omit<AxisProps, 'areXLabelsRotated' | 'size' | 'scale'> & {
70
+ $theme: Theme;
71
+ };
70
72
 
71
73
  declare const Axis: Comp<AxisProps, SVGGElement>;
72
74
 
73
75
  /**
74
76
  * Component style.
75
77
  */
76
- declare const StyledAxis: styled_components.StyledComponent<_react_spring_web.AnimatedComponent<"g">, any, Omit<AxisProps, "size" | "scale" | "areXLabelsRotated">, never>;
78
+ declare const StyledAxis: styled_components.StyledComponent<_react_spring_web.AnimatedComponent<"g">, any, Omit<AxisProps, "size" | "scale" | "areXLabelsRotated"> & {
79
+ $theme: Theme;
80
+ }, never>;
77
81
 
78
82
  type ChartAxesProps = {
79
83
  /** String to Date. */
@@ -282,12 +286,14 @@ type ChartTheme = ColorTheme | SuccessDangerColorTheme | CustomColorTheme;
282
286
  interface UseColorProps {
283
287
  /** Dataset to use to generate the chart. */
284
288
  data: JSONArray;
285
- /** Theme. */
286
- theme: ChartTheme;
289
+ /** Color palette to use. */
290
+ colorTheme: ChartTheme;
287
291
  /** Name of the field that will be used to categorize the data. */
288
292
  category: string | ((d: JSONObject) => string);
293
+ /** Theme */
294
+ theme: Theme;
289
295
  }
290
- declare const useColor: ({ data, theme, category }: UseColorProps) => ScaleOrdinal<string, string, never>;
296
+ declare const useColor: ({ data, colorTheme, category, theme }: UseColorProps) => ScaleOrdinal<string, string, never>;
291
297
 
292
298
  type SortingMethod = 'none' | 'asc-key' | 'desc-key' | 'asc-value' | 'desc-value' | string[] | ((a: CategoryDatum, b: CategoryDatum) => 1 | -1);
293
299
  declare const getSortingMethod: (sortingMethod: SortingMethod) => (a: CategoryDatum, b: CategoryDatum) => 1 | -1;
@@ -295,16 +301,18 @@ declare const getSortingMethod: (sortingMethod: SortingMethod) => (a: CategoryDa
295
301
  interface UseFormatCategoricalDataProps {
296
302
  /** Dataset to use to generate the chart, should be a list of objects containing a key and a value. */
297
303
  data: CategoryData;
298
- /** Theme. */
299
- theme: ChartTheme;
304
+ /** Color palette to use. */
305
+ colorTheme: ChartTheme;
300
306
  /** Define how to sort categories. */
301
307
  sortingMethod: SortingMethod;
302
308
  /** Number of categories to use, the rest being put into a new category called "Others". */
303
309
  caping?: number;
304
310
  /** Whether a category should be displayed for categories that has been removed by the caping option. Optionaly, this prop can be used to change the label of this category. */
305
311
  others?: boolean | string;
312
+ /** Theme */
313
+ theme: Theme;
306
314
  }
307
- declare const useFormatCategoricalData: ({ data, caping, sortingMethod, others, theme, }: UseFormatCategoricalDataProps) => {
315
+ declare const useFormatCategoricalData: ({ data, caping, sortingMethod, others, colorTheme, theme, }: UseFormatCategoricalDataProps) => {
308
316
  data: CategoryData;
309
317
  colorScale: d3_scale.ScaleOrdinal<string, string, never>;
310
318
  };
@@ -348,9 +356,15 @@ declare const successDangerScheme: {
348
356
  success: string;
349
357
  warning: string;
350
358
  danger: string;
351
- neutral: string;
359
+ neutralLight: string;
360
+ neutralDark: string;
352
361
  };
353
- declare const getColorScale: (theme: ChartTheme, domain?: string[], isEmpty?: boolean) => ScaleOrdinal<string, string>;
362
+ declare const getColorScale: ({ colorTheme, domain, isEmpty, theme, }: {
363
+ colorTheme: ChartTheme;
364
+ domain?: string[] | undefined;
365
+ isEmpty?: boolean | undefined;
366
+ theme: Theme;
367
+ }) => ScaleOrdinal<string, string>;
354
368
 
355
369
  /**
356
370
  * Component props.
@@ -378,6 +392,8 @@ interface DataPointProps<T> extends Omit<ComponentProps<'g'>, 'onClick' | 'scale
378
392
  previousData?: T;
379
393
  /** Role. Will be set to 'button' if onClick is provided. If 'option', then the component becomes selectable. */
380
394
  role?: 'button' | 'link' | 'option';
395
+ /** Theme. */
396
+ theme?: Theme;
381
397
  /** Tooltip variant. */
382
398
  tooltipVariant?: TooltipVariant;
383
399
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
@@ -411,6 +427,7 @@ interface ArcProps extends DataPointProps<ArcDatum> {
411
427
  }
412
428
  type StyledArcProps = StyledDataPointProps & Omit<ArcProps, 'createArc'> & {
413
429
  $hasStroke: ArcProps['hasStroke'];
430
+ $theme: Theme;
414
431
  };
415
432
 
416
433
  declare const Arc: Comp<ArcProps, SVGGElement>;
@@ -422,6 +439,7 @@ declare const StyledArc: styled_components.StyledComponent<_redsift_design_syste
422
439
  $clickable: boolean;
423
440
  } & Omit<ArcProps, "createArc"> & {
424
441
  $hasStroke: boolean | undefined;
442
+ $theme: Theme;
425
443
  }, never>;
426
444
 
427
445
  /**
@@ -469,7 +487,9 @@ interface BarProps extends DataPointProps<BarDatum> {
469
487
  /** Width of the bar in vertical orientation. */
470
488
  width?: number;
471
489
  }
472
- type StyledBarProps = StyledDataPointProps & Omit<BarProps, 'scale'>;
490
+ type StyledBarProps = StyledDataPointProps & Omit<BarProps, 'scale'> & {
491
+ $theme: Theme;
492
+ };
473
493
 
474
494
  declare const Bar: Comp<BarProps, SVGGElement>;
475
495
 
@@ -478,7 +498,9 @@ declare const Bar: Comp<BarProps, SVGGElement>;
478
498
  */
479
499
  declare const StyledBar: styled_components.StyledComponent<_redsift_design_system.Comp<DataPointProps<any>, SVGGElement>, any, Omit<DataPointProps<any>, "data"> & {
480
500
  $clickable: boolean;
481
- } & Omit<BarProps, "scale">, never>;
501
+ } & Omit<BarProps, "scale"> & {
502
+ $theme: Theme;
503
+ }, never>;
482
504
 
483
505
  /**
484
506
  * Component props.
@@ -496,17 +518,27 @@ interface ChartContainerProps extends Omit<ComponentProps<'div'>, 'title'>, Cont
496
518
  onReset?: () => void;
497
519
  /** Title. */
498
520
  title?: string | ReactElement;
521
+ /** Theme. */
522
+ theme?: Theme;
499
523
  }
500
- type StyledChartContainerProps = ChartContainerProps & {};
524
+ type StyledChartContainerProps = Omit<ChartContainerProps, 'theme'> & {
525
+ $theme: Theme;
526
+ };
501
527
 
502
528
  declare const ChartContainer: Comp<ChartContainerProps, HTMLDivElement>;
503
529
 
504
530
  /**
505
531
  * Component style.
506
532
  */
507
- declare const StyledChartContainer: styled_components.StyledComponent<"div", any, ChartContainerProps, never>;
508
- declare const StyledChartContainerTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, ChartContainerProps, never>;
509
- declare const StyledChartContainerCaption: styled_components.StyledComponent<"p", any, ChartContainerProps, never>;
533
+ declare const StyledChartContainer: styled_components.StyledComponent<"div", any, Omit<ChartContainerProps, "theme"> & {
534
+ $theme: Theme;
535
+ }, never>;
536
+ declare const StyledChartContainerTitle: styled_components.StyledComponent<_redsift_design_system.Comp<_redsift_design_system.FlexboxProps, HTMLDivElement>, any, Omit<ChartContainerProps, "theme"> & {
537
+ $theme: Theme;
538
+ }, never>;
539
+ declare const StyledChartContainerCaption: styled_components.StyledComponent<"p", any, Omit<ChartContainerProps, "theme"> & {
540
+ $theme: Theme;
541
+ }, never>;
510
542
 
511
543
  interface LocaleText$3 {
512
544
  emptyChartText: string;
@@ -553,7 +585,7 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
553
585
  /** Bar role. Used to indicate that bars are to be considered buttons or links. If an onClick is provided, the bars will have the role `button` unless specifically set to `link` with this prop. */
554
586
  barRole?: BarProps['role'];
555
587
  /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
556
- theme?: ChartTheme;
588
+ colorTheme?: ChartTheme;
557
589
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
558
590
  tooltipDecorator?: (data: BarDatum, props?: {
559
591
  index?: number;
@@ -562,6 +594,8 @@ interface BarChartProps extends ChartContainerProps, ChartAxesProps {
562
594
  }) => string | ReactElement;
563
595
  /** Tooltip variant. */
564
596
  tooltipVariant?: TooltipVariant;
597
+ /** Theme. */
598
+ theme?: Theme;
565
599
  }
566
600
  type StyledBarChartProps = BarChartProps & {};
567
601
 
@@ -574,6 +608,7 @@ declare const StyledBarChart: styled_components.StyledComponent<_redsift_design_
574
608
  declare const StyledBarChartEmptyText: styled_components.StyledComponent<"div", any, {
575
609
  $maxWidth: number;
576
610
  $textSize: number;
611
+ $theme: Theme;
577
612
  }, never>;
578
613
 
579
614
  /**
@@ -597,6 +632,7 @@ interface DotProps extends DataPointProps<DotDatum> {
597
632
  }
598
633
  type StyledDotProps = StyledDataPointProps & Omit<DotProps, 'scaleX' | 'scaleY'> & {
599
634
  $variant: DotProps['variant'];
635
+ $theme: Theme;
600
636
  };
601
637
 
602
638
  declare const Dot: Comp<DotProps, SVGGElement>;
@@ -608,6 +644,7 @@ declare const StyledDot: styled_components.StyledComponent<_redsift_design_syste
608
644
  $clickable: boolean;
609
645
  } & Omit<DotProps, "scaleX" | "scaleY"> & {
610
646
  $variant: DotVariant | undefined;
647
+ $theme: _redsift_design_system.Theme;
611
648
  }, never>;
612
649
 
613
650
  /**
@@ -727,8 +764,6 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
727
764
  isSelected?: boolean;
728
765
  color?: string;
729
766
  }) => string | ReactElement;
730
- /** @deprecated Use legendVariant instead. */
731
- labelVariant?: LineChartLegendVariant;
732
767
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
733
768
  legendVariant?: LineChartLegendVariant;
734
769
  /** Props to forward to the Legend block. Can be used to make the legend selectable. */
@@ -746,7 +781,7 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
746
781
  /** Reference to the SVG tag. */
747
782
  svgRef?: MutableRefObject<SVGSVGElement>;
748
783
  /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
749
- theme?: ChartTheme;
784
+ colorTheme?: ChartTheme;
750
785
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
751
786
  tooltipDecorator?: (data: DotDatum, props?: {
752
787
  index?: number;
@@ -755,6 +790,8 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
755
790
  }) => string | ReactElement;
756
791
  /** Tooltip variant. */
757
792
  tooltipVariant?: TooltipVariant;
793
+ /** Theme. */
794
+ theme?: Theme;
758
795
  }
759
796
  type StyledLineChartProps = LineChartProps & {};
760
797
 
@@ -767,6 +804,7 @@ declare const StyledLineChart: styled_components.StyledComponent<_redsift_design
767
804
  declare const StyledLineChartEmptyText: styled_components.StyledComponent<"div", any, {
768
805
  $maxWidth: number;
769
806
  $textSize: number;
807
+ $theme: Theme;
770
808
  }, never>;
771
809
 
772
810
  /**
@@ -825,8 +863,6 @@ interface PieChartProps extends ChartContainerProps {
825
863
  isSelected?: boolean;
826
864
  color?: string;
827
865
  }) => string | ReactElement;
828
- /** @deprecated Use legendVariant instead. */
829
- labelVariant?: PieChartLegendVariant;
830
866
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
831
867
  legendVariant?: PieChartLegendVariant;
832
868
  /** Props to forward to the Legend block. Can be used to make the legend selectable. */
@@ -852,7 +888,7 @@ interface PieChartProps extends ChartContainerProps {
852
888
  /** Main text to be displayed in the middle of the chart. Recommended to be used with `donut` variants only. */
853
889
  text?: string | ReactElement | ((data: PieArcDatum<CategoryDatum>[], total: number) => string | ReactElement);
854
890
  /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
855
- theme?: ChartTheme;
891
+ colorTheme?: ChartTheme;
856
892
  /** PieChart variant. */
857
893
  variant?: PieChartVariant;
858
894
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
@@ -863,6 +899,8 @@ interface PieChartProps extends ChartContainerProps {
863
899
  }) => string | ReactElement;
864
900
  /** Tooltip variant. */
865
901
  tooltipVariant?: TooltipVariant;
902
+ /** Theme. */
903
+ theme?: Theme;
866
904
  }
867
905
  type StyledPieChartProps = PieChartProps & {};
868
906
 
@@ -876,11 +914,13 @@ declare const StyledPieChartCenterText: styled_components.StyledComponent<"div",
876
914
  $maxWidth: number;
877
915
  $textSize: number;
878
916
  $smallTextSize: number;
917
+ $theme: Theme;
879
918
  }, never>;
880
919
  declare const StyledPieChartEmptyText: styled_components.StyledComponent<"div", any, {
881
920
  $maxWidth: number;
882
921
  $textSize: number;
883
922
  $isDonut: boolean;
923
+ $theme: Theme;
884
924
  }, never>;
885
925
 
886
926
  /**
@@ -936,8 +976,6 @@ interface ScatterPlotProps extends ChartContainerProps, ChartAxesProps {
936
976
  isSelected?: boolean;
937
977
  color?: string;
938
978
  }) => string | ReactElement;
939
- /** @deprecated Use legendVariant instead. */
940
- labelVariant?: ScatterPlotLegendVariant;
941
979
  /** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. If set to "custom", use `legendDecorator` to customize it. */
942
980
  legendVariant?: ScatterPlotLegendVariant;
943
981
  /** Props to forward to the Legend block. Can be used to make the legend selectable. */
@@ -959,7 +997,7 @@ interface ScatterPlotProps extends ChartContainerProps, ChartAxesProps {
959
997
  /** Reference to the SVG tag. */
960
998
  svgRef?: MutableRefObject<SVGSVGElement>;
961
999
  /** Color palette to use. You can choose among the list of available color palette or also choose to use the success/warning/danger theme for which you have to specify which key corresponds to which status. */
962
- theme?: ChartTheme;
1000
+ colorTheme?: ChartTheme;
963
1001
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
964
1002
  tooltipDecorator?: (data: DotDatum, props?: {
965
1003
  index?: number;
@@ -970,6 +1008,8 @@ interface ScatterPlotProps extends ChartContainerProps, ChartAxesProps {
970
1008
  tooltipVariant?: TooltipVariant;
971
1009
  /** Variant. */
972
1010
  variant?: ScatterPlotVariant;
1011
+ /** Theme. */
1012
+ theme?: Theme;
973
1013
  }
974
1014
  type StyledScatterPlotProps = ScatterPlotProps & {};
975
1015
 
@@ -982,6 +1022,7 @@ declare const StyledScatterPlot: styled_components.StyledComponent<_redsift_desi
982
1022
  declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div", any, {
983
1023
  $maxWidth: number;
984
1024
  $textSize: number;
1025
+ $theme: Theme;
985
1026
  }, never>;
986
1027
 
987
1028
  export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartAxesProps, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, DotVariant, EmptyDatum, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, LegendVariant, Line, LineChart, LineChartDimensions, LineChartLegendVariant, LineChartProps, LinePointDatum, LineProps, MarginProps, NumericValue, PieChart, PieChartDimensions, PieChartLegendVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLegendVariant, ScatterPlotProps, ScatterPlotVariant, SortingMethod, Statistic, Statistics, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledLine, StyledLineChart, StyledLineChartEmptyText, StyledLineChartProps, StyledLineProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, TwoCategoryData, TwoCategoryDatum, TwoCategoryDim, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, getSortingMethod, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };