@redsift/charts 9.6.0 → 10.0.0-muiv5-alpha.1

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
  /**
@@ -746,7 +783,7 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
746
783
  /** Reference to the SVG tag. */
747
784
  svgRef?: MutableRefObject<SVGSVGElement>;
748
785
  /** 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;
786
+ colorTheme?: ChartTheme;
750
787
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
751
788
  tooltipDecorator?: (data: DotDatum, props?: {
752
789
  index?: number;
@@ -755,6 +792,8 @@ interface LineChartProps extends ChartContainerProps, ChartAxesProps {
755
792
  }) => string | ReactElement;
756
793
  /** Tooltip variant. */
757
794
  tooltipVariant?: TooltipVariant;
795
+ /** Theme. */
796
+ theme?: Theme;
758
797
  }
759
798
  type StyledLineChartProps = LineChartProps & {};
760
799
 
@@ -767,6 +806,7 @@ declare const StyledLineChart: styled_components.StyledComponent<_redsift_design
767
806
  declare const StyledLineChartEmptyText: styled_components.StyledComponent<"div", any, {
768
807
  $maxWidth: number;
769
808
  $textSize: number;
809
+ $theme: Theme;
770
810
  }, never>;
771
811
 
772
812
  /**
@@ -852,7 +892,7 @@ interface PieChartProps extends ChartContainerProps {
852
892
  /** Main text to be displayed in the middle of the chart. Recommended to be used with `donut` variants only. */
853
893
  text?: string | ReactElement | ((data: PieArcDatum<CategoryDatum>[], total: number) => string | ReactElement);
854
894
  /** 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;
895
+ colorTheme?: ChartTheme;
856
896
  /** PieChart variant. */
857
897
  variant?: PieChartVariant;
858
898
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
@@ -863,6 +903,8 @@ interface PieChartProps extends ChartContainerProps {
863
903
  }) => string | ReactElement;
864
904
  /** Tooltip variant. */
865
905
  tooltipVariant?: TooltipVariant;
906
+ /** Theme. */
907
+ theme?: Theme;
866
908
  }
867
909
  type StyledPieChartProps = PieChartProps & {};
868
910
 
@@ -876,11 +918,13 @@ declare const StyledPieChartCenterText: styled_components.StyledComponent<"div",
876
918
  $maxWidth: number;
877
919
  $textSize: number;
878
920
  $smallTextSize: number;
921
+ $theme: Theme;
879
922
  }, never>;
880
923
  declare const StyledPieChartEmptyText: styled_components.StyledComponent<"div", any, {
881
924
  $maxWidth: number;
882
925
  $textSize: number;
883
926
  $isDonut: boolean;
927
+ $theme: Theme;
884
928
  }, never>;
885
929
 
886
930
  /**
@@ -959,7 +1003,7 @@ interface ScatterPlotProps extends ChartContainerProps, ChartAxesProps {
959
1003
  /** Reference to the SVG tag. */
960
1004
  svgRef?: MutableRefObject<SVGSVGElement>;
961
1005
  /** 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;
1006
+ colorTheme?: ChartTheme;
963
1007
  /** Method modifying what's displayed within the tooltip when the tooltipVariant is "custom". */
964
1008
  tooltipDecorator?: (data: DotDatum, props?: {
965
1009
  index?: number;
@@ -970,6 +1014,8 @@ interface ScatterPlotProps extends ChartContainerProps, ChartAxesProps {
970
1014
  tooltipVariant?: TooltipVariant;
971
1015
  /** Variant. */
972
1016
  variant?: ScatterPlotVariant;
1017
+ /** Theme. */
1018
+ theme?: Theme;
973
1019
  }
974
1020
  type StyledScatterPlotProps = ScatterPlotProps & {};
975
1021
 
@@ -982,6 +1028,7 @@ declare const StyledScatterPlot: styled_components.StyledComponent<_redsift_desi
982
1028
  declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div", any, {
983
1029
  $maxWidth: number;
984
1030
  $textSize: number;
1031
+ $theme: Theme;
985
1032
  }, never>;
986
1033
 
987
1034
  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 };