@redsift/charts 11.4.0-muiv5-alpha.1 → 11.4.0-muiv5-alpha.2

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/index.d.ts CHANGED
@@ -844,13 +844,16 @@ interface BarChartState extends ChartAxesProps, Required<Pick<RenderedLinearBarC
844
844
  sectionHeight?: number;
845
845
  xScaleType?: XScaleType;
846
846
  }
847
- interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {
847
+ interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role' | 'color'> {
848
848
  /** Starting point in percentage of the chart height. */
849
849
  from?: number;
850
850
  /** Ending point in percentage of the chart height. */
851
851
  to?: number;
852
- /** Background color */
853
- color?: string;
852
+ /** Color. */
853
+ color?: 'red' | 'green' | {
854
+ textColor: string;
855
+ backgroundColor?: string;
856
+ };
854
857
  /** Section title */
855
858
  title?: string;
856
859
  /** Title position relative to section */
@@ -861,7 +864,7 @@ interface BarChartSectionProps extends Omit<ComponentProps<'g'>, 'onClick' | 'ro
861
864
  }
862
865
  interface StyledBarChartSectionProps {
863
866
  $theme: Theme;
864
- $color: BarChartSectionProps['color'];
867
+ $textColor: string;
865
868
  }
866
869
  interface BarChartBarsProps extends Omit<ComponentProps<'g'>, 'onClick' | 'role'> {
867
870
  category?: string;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, scaleLinear, sum, scaleBand, extent, scaleUtc, scalePoint, utcParse, scaleLog, scaleTime, line, arc, pie, min, descending, scaleSqrt, max } from 'd3';
2
- import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationOrangeDefault, RedsiftColorPresentationGreenDark, RedsiftColorPresentationPinkDark, RedsiftColorPresentationAquaDark, RedsiftColorPresentationBrownDark, RedsiftColorPresentationRedDark, RedsiftColorPresentationYellowDark, RedsiftColorPresentationPurpleDark, RedsiftColorPresentationOrangeDark, RedsiftColorPresentationBlueDark, RedsiftColorPresentationGreenDarker, RedsiftColorPresentationPinkDarker, RedsiftColorPresentationAquaDarker, RedsiftColorPresentationBrownDarker, RedsiftColorPresentationRedDarker, RedsiftColorPresentationYellowDarker, RedsiftColorPresentationPurpleDarker, RedsiftColorPresentationOrangeDarker, RedsiftColorPresentationBlueDarker, RedsiftColorPresentationGreyDarker, RedsiftColorPresentationGreenDarkerer, RedsiftColorPresentationPinkDarkerer, RedsiftColorPresentationAquaDarkerer, RedsiftColorPresentationBrownDarkerer, RedsiftColorPresentationRedDarkerer, RedsiftColorPresentationYellowDarkerer, RedsiftColorPresentationPurpleDarkerer, RedsiftColorPresentationOrangeDarkerer, RedsiftColorPresentationBlueDarkerer, RedsiftColorPresentationGreyDarkerer, RedsiftColorPresentationGreenLight, RedsiftColorPresentationPinkLight, RedsiftColorPresentationAquaLight, RedsiftColorPresentationBrownLight, RedsiftColorPresentationRedLight, RedsiftColorPresentationYellowLight, RedsiftColorPresentationPurpleLight, RedsiftColorPresentationOrangeLight, RedsiftColorPresentationBlueLight, RedsiftColorPresentationGreyLight, RedsiftColorPresentationGreenLighter, RedsiftColorPresentationPinkLighter, RedsiftColorPresentationAquaLighter, RedsiftColorPresentationBrownLighter, RedsiftColorPresentationRedLighter, RedsiftColorPresentationYellowLighter, RedsiftColorPresentationPurpleLighter, RedsiftColorPresentationOrangeLighter, RedsiftColorPresentationBlueLighter, RedsiftColorPresentationGreyLighter, RedsiftColorPresentationGreenLighterer, RedsiftColorPresentationPinkLighterer, RedsiftColorPresentationAquaLighterer, RedsiftColorPresentationBrownLighterer, RedsiftColorPresentationRedLighterer, RedsiftColorPresentationYellowLighterer, RedsiftColorPresentationPurpleLighterer, RedsiftColorPresentationOrangeLighterer, RedsiftColorPresentationBlueLighterer, RedsiftColorPresentationGreyLighterer, Theme, useId, useTheme, Text, Number as Number$1, baseStyling, baseContainer, focusRing, Flexbox, warnIfNoAccessibleLabelFound, useMessageFormatter, ThemeProvider, Heading, Button, isComponent } from '@redsift/design-system';
2
+ import { RedsiftColorPresentationBlueDefault, RedsiftColorPresentationGreyDark, RedsiftColorPresentationAquaDefault, RedsiftColorPresentationPinkDefault, RedsiftColorPresentationGreyDefault, RedsiftColorPresentationYellowDefault, RedsiftColorPresentationPurpleDefault, RedsiftColorPresentationGreenDefault, RedsiftColorPresentationBrownDefault, RedsiftColorPresentationRedDefault, RedsiftColorPresentationOrangeDefault, RedsiftColorPresentationGreenDark, RedsiftColorPresentationPinkDark, RedsiftColorPresentationAquaDark, RedsiftColorPresentationBrownDark, RedsiftColorPresentationRedDark, RedsiftColorPresentationYellowDark, RedsiftColorPresentationPurpleDark, RedsiftColorPresentationOrangeDark, RedsiftColorPresentationBlueDark, RedsiftColorPresentationGreenDarker, RedsiftColorPresentationPinkDarker, RedsiftColorPresentationAquaDarker, RedsiftColorPresentationBrownDarker, RedsiftColorPresentationRedDarker, RedsiftColorPresentationYellowDarker, RedsiftColorPresentationPurpleDarker, RedsiftColorPresentationOrangeDarker, RedsiftColorPresentationBlueDarker, RedsiftColorPresentationGreyDarker, RedsiftColorPresentationGreenDarkerer, RedsiftColorPresentationPinkDarkerer, RedsiftColorPresentationAquaDarkerer, RedsiftColorPresentationBrownDarkerer, RedsiftColorPresentationRedDarkerer, RedsiftColorPresentationYellowDarkerer, RedsiftColorPresentationPurpleDarkerer, RedsiftColorPresentationOrangeDarkerer, RedsiftColorPresentationBlueDarkerer, RedsiftColorPresentationGreyDarkerer, RedsiftColorPresentationGreenLight, RedsiftColorPresentationPinkLight, RedsiftColorPresentationAquaLight, RedsiftColorPresentationBrownLight, RedsiftColorPresentationRedLight, RedsiftColorPresentationYellowLight, RedsiftColorPresentationPurpleLight, RedsiftColorPresentationOrangeLight, RedsiftColorPresentationBlueLight, RedsiftColorPresentationGreyLight, RedsiftColorPresentationGreenLighter, RedsiftColorPresentationPinkLighter, RedsiftColorPresentationAquaLighter, RedsiftColorPresentationBrownLighter, RedsiftColorPresentationRedLighter, RedsiftColorPresentationYellowLighter, RedsiftColorPresentationPurpleLighter, RedsiftColorPresentationOrangeLighter, RedsiftColorPresentationBlueLighter, RedsiftColorPresentationGreyLighter, RedsiftColorPresentationGreenLighterer, RedsiftColorPresentationPinkLighterer, RedsiftColorPresentationAquaLighterer, RedsiftColorPresentationBrownLighterer, RedsiftColorPresentationRedLighterer, RedsiftColorPresentationYellowLighterer, RedsiftColorPresentationPurpleLighterer, RedsiftColorPresentationOrangeLighterer, RedsiftColorPresentationBlueLighterer, RedsiftColorPresentationGreyLighterer, Theme, useId, useTheme, Text, Number as Number$1, baseStyling, baseContainer, focusRing, Flexbox, warnIfNoAccessibleLabelFound, useMessageFormatter, ThemeProvider, Heading, Button, isComponent, RedsiftColorGreenD1, RedsiftColorRedD1, RedsiftColorNeutralBlack } from '@redsift/design-system';
3
3
  import * as React from 'react';
4
4
  import React__default, { useRef, useEffect, useMemo, useState, useLayoutEffect, forwardRef, useCallback, useContext, createContext } from 'react';
5
5
  import classNames from 'classnames';
@@ -1480,11 +1480,10 @@ const StyledBarChartSection = styled.g`
1480
1480
  text.colored {
1481
1481
  ${_ref => {
1482
1482
  let {
1483
- $theme,
1484
- $color
1483
+ $textColor
1485
1484
  } = _ref;
1486
1485
  return css`
1487
- fill: ${$color === 'green' ? '#029B57' : $color === 'red' ? '#CB0E0E' : `var(--redsift-color-neutral-${$theme === Theme.dark ? 'white' : 'x-dark-grey'})`};
1486
+ fill: ${$textColor};
1488
1487
  `;
1489
1488
  }}
1490
1489
  }
@@ -2845,6 +2844,28 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
2845
2844
  direction
2846
2845
  } = props,
2847
2846
  forwardedProps = _objectWithoutProperties(props, _excluded$f);
2847
+ const {
2848
+ textColor,
2849
+ backgroundColor
2850
+ } = useMemo(() => {
2851
+ if (color === 'green') {
2852
+ return {
2853
+ textColor: RedsiftColorGreenD1,
2854
+ backgroundColor: '#F7FBF9'
2855
+ };
2856
+ } else if (color === 'red') {
2857
+ return {
2858
+ textColor: RedsiftColorRedD1,
2859
+ backgroundColor: '#FFF7F7'
2860
+ };
2861
+ } else if (color === undefined) {
2862
+ return {
2863
+ textColor: RedsiftColorNeutralBlack,
2864
+ backgroundColor: undefined
2865
+ };
2866
+ }
2867
+ return color;
2868
+ }, [color]);
2848
2869
  const theme = useTheme();
2849
2870
  const context = useBarChartContext();
2850
2871
  const {
@@ -2916,13 +2937,13 @@ const BarChartSection = /*#__PURE__*/forwardRef((props, ref) => {
2916
2937
  transform: `translate(${margins.left},${(margins.top || 0) + sectionY})`,
2917
2938
  ref: ref,
2918
2939
  $theme: theme,
2919
- $color: color
2920
- }), color ? /*#__PURE__*/React__default.createElement("rect", {
2940
+ $textColor: textColor
2941
+ }), backgroundColor ? /*#__PURE__*/React__default.createElement("rect", {
2921
2942
  x: 0,
2922
2943
  y: 0,
2923
2944
  width: chartWidth,
2924
2945
  height: sectionHeight,
2925
- fill: color === 'green' ? '#F7FBF9' : color === 'red' ? '#FFF7F7' : 'transparent'
2946
+ fill: backgroundColor
2926
2947
  }) : null, title && /*#__PURE__*/React__default.createElement("text", {
2927
2948
  className: "title colored",
2928
2949
  x: titleX,