@redsift/charts 8.0.0-alpha.2 → 8.0.0-alpha.3
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 +3 -3
- package/index.d.ts +25 -5
- package/index.js +206 -100
- package/index.js.map +1 -1
- package/package.json +2 -2
package/CONTRIBUTING.md
CHANGED
|
@@ -355,9 +355,9 @@ yarn dev:website
|
|
|
355
355
|
|
|
356
356
|
Then, open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
357
357
|
|
|
358
|
-
To add documentation for a component, a MDX file should be created in the `
|
|
358
|
+
To add documentation for a component, a MDX file should be created in the `apps/website/pages/` folder and more precisely inside the subfolder corresponding to the section the page belongs to (i.e. `apps/website/pages/forms/checkbox.mdx` for the `Checkbox` component inside the `Forms` section).
|
|
359
359
|
|
|
360
|
-
To appear in the website's Side Panel, the page should be listed in `
|
|
360
|
+
To appear in the website's Side Panel, the page should be listed in `apps/website/components/CustomAppSidePanel/CustomAppSidePanel.tsx`) under the corresponding section.
|
|
361
361
|
|
|
362
362
|
A component page should be structured as following:
|
|
363
363
|
|
|
@@ -380,7 +380,7 @@ To display a prop table, use the `PropsTable` component as following:
|
|
|
380
380
|
<PropsTable component="Button" />
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
To display a demo, first create a demo (a simple `tsx` file) in the demo folder (`
|
|
383
|
+
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:
|
|
384
384
|
|
|
385
385
|
```ts
|
|
386
386
|
<DemoBlock path="button/coloring" />
|
package/index.d.ts
CHANGED
|
@@ -55,6 +55,9 @@ type DotDatum = {
|
|
|
55
55
|
y: number;
|
|
56
56
|
r: number;
|
|
57
57
|
};
|
|
58
|
+
type LegendItemDatum = {
|
|
59
|
+
data: CategoryDatum;
|
|
60
|
+
};
|
|
58
61
|
|
|
59
62
|
/** TOOLTIP */
|
|
60
63
|
declare const TooltipVariant: {
|
|
@@ -483,11 +486,29 @@ declare const StyledDot: styled_components.StyledComponent<_redsift_design_syste
|
|
|
483
486
|
/**
|
|
484
487
|
* Component props.
|
|
485
488
|
*/
|
|
486
|
-
interface
|
|
489
|
+
interface LegendItemProps extends Pick<DataPointProps<LegendItemDatum>, 'color' | 'data' | 'id' | 'index' | 'isSelected' | 'labelDecorator' | 'onClick' | 'previousData' | 'role' | 'tooltipVariant'>, Omit<ComponentProps<'li'>, 'onClick' | 'role'> {
|
|
490
|
+
/** Total used to compute percentage. */
|
|
491
|
+
total?: number;
|
|
492
|
+
/** Variant. */
|
|
493
|
+
variant?: LabelVariant;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Component props.
|
|
498
|
+
*/
|
|
499
|
+
interface LegendProps extends Omit<ComponentProps<'ul'>, 'onClick'> {
|
|
487
500
|
/** Data. */
|
|
488
501
|
data: (CategoryDatum & {
|
|
489
502
|
color: string;
|
|
490
503
|
})[];
|
|
504
|
+
/** Method to determine whether a slice is selected or not. */
|
|
505
|
+
isLegendItemSelected?: (datum: LegendItemDatum) => void;
|
|
506
|
+
/** Method to override the data labels. */
|
|
507
|
+
labelDecorator?: (datum: LegendItemDatum) => string;
|
|
508
|
+
/** Method to be called on a click on a legend item. */
|
|
509
|
+
onLegendItemClick?: (datum: LegendItemDatum) => void;
|
|
510
|
+
/** LegendItem role. Used to indicate that legend items are to be considered buttons or links. If an onClick is provided, the legend items will have the role `button` unless specifically set to `link` with this prop. */
|
|
511
|
+
legendItemRole?: LegendItemProps['role'];
|
|
491
512
|
/** Variant. */
|
|
492
513
|
variant?: LabelVariant;
|
|
493
514
|
/** Width. */
|
|
@@ -505,9 +526,6 @@ declare const Legend: Comp<LegendProps, HTMLUListElement>;
|
|
|
505
526
|
declare const StyledLegend: styled_components.StyledComponent<"ul", any, Omit<LegendProps, "data"> & {
|
|
506
527
|
$width?: string | undefined;
|
|
507
528
|
}, never>;
|
|
508
|
-
declare const StyledLabel: styled_components.StyledComponent<"li", any, {
|
|
509
|
-
$color: string;
|
|
510
|
-
}, never>;
|
|
511
529
|
|
|
512
530
|
/**
|
|
513
531
|
* Component variant.
|
|
@@ -638,6 +656,8 @@ interface ScatterPlotProps extends ChartContainerProps {
|
|
|
638
656
|
labelDecorator?: (datum: DotDatum) => string;
|
|
639
657
|
/** Define whether the labels should be displayed inside or outside the charts and if they should contain raw or percentage values. */
|
|
640
658
|
labelVariant?: ScatterPlotLabelVariant;
|
|
659
|
+
/** Props to forward to the Legend block. Can be used to make the legend selectable. */
|
|
660
|
+
legendProps?: Omit<LegendProps, 'data' | 'ref' | 'variant' | 'width'>;
|
|
641
661
|
/** Labels and texts. */
|
|
642
662
|
localeText?: LocaleText;
|
|
643
663
|
/** Method called on brush. */
|
|
@@ -674,4 +694,4 @@ declare const StyledScatterPlotEmptyText: styled_components.StyledComponent<"div
|
|
|
674
694
|
$textSize: number;
|
|
675
695
|
}, never>;
|
|
676
696
|
|
|
677
|
-
export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendProps, NumericValue, PieChart, PieChartDimensions, PieChartLabelVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLabelVariant, ScatterPlotProps, ScatterPlotVariant, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps,
|
|
697
|
+
export { AnyScale, Arc, ArcDatum, ArcProps, Arcs, ArcsProps, Axis, AxisPosition, AxisProps, AxisVariant, Bar, BarChart, BarChartDimensions, BarChartProps, BarDatum, BarOrientation, BarProps, CategoryData, CategoryDatum, CategoryDim, ChartContainer, ChartContainerProps, ChartDimensions, ChartSize, ChartTheme, ColorTheme, Coordinates, CoordinatesCategoryData, CoordinatesCategoryDatum, CoordinatesCategoryDim, CustomColorTheme, DataPoint, DataPointProps, Datum, Dot, DotDatum, DotProps, JSONArray, JSONObject, JSONValue, LabelVariant, Legend, LegendItemDatum, LegendProps, NumericValue, PieChart, PieChartDimensions, PieChartLabelVariant, PieChartProps, PieChartVariant, Scale, ScaleBand, ScaleLinear, ScaleLog, ScalePoint, ScaleSymlog, ScaleTime, ScaleTypeToScale, ScaleValue, ScaleWithBandwidth, ScatterPlot, ScatterPlotDimensions, ScatterPlotLabelVariant, ScatterPlotProps, ScatterPlotVariant, StringValue, StyledArc, StyledArcProps, StyledArcs, StyledArcsProps, StyledAxis, StyledAxisProps, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledBarChartProps, StyledBarProps, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerProps, StyledChartContainerTitle, StyledDataPoint, StyledDataPointProps, StyledDot, StyledDotProps, StyledLegend, StyledLegendProps, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartProps, StyledScatterPlot, StyledScatterPlotEmptyText, StyledScatterPlotProps, SuccessDangerColorTheme, TicksSpec, TooltipVariant, UseBrushProps, UseColorProps, UseFormatCategoricalDataProps, UseZoomProps, empty, getColorScale, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|
package/index.js
CHANGED
|
@@ -317,7 +317,7 @@ var k=/^--/;function I(t,e){return e==null||typeof e=="boolean"||e===""?"":typeo
|
|
|
317
317
|
*/
|
|
318
318
|
const StyledDataPoint = styled(it.g)``;
|
|
319
319
|
|
|
320
|
-
const _excluded$
|
|
320
|
+
const _excluded$k = ["children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipVariant"];
|
|
321
321
|
const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
322
322
|
const {
|
|
323
323
|
children,
|
|
@@ -331,7 +331,7 @@ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
331
331
|
role,
|
|
332
332
|
tooltipVariant
|
|
333
333
|
} = props,
|
|
334
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
334
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$k);
|
|
335
335
|
const id = propsId !== null && propsId !== void 0 ? propsId : useId();
|
|
336
336
|
const text = labelDecorator ? labelDecorator(data) : data.data.key;
|
|
337
337
|
const hasText = text && tooltipVariant !== TooltipVariant.none;
|
|
@@ -433,10 +433,10 @@ const config = (() => ({
|
|
|
433
433
|
immediate: false
|
|
434
434
|
}))();
|
|
435
435
|
|
|
436
|
-
const _excluded$
|
|
437
|
-
const COMPONENT_NAME$
|
|
438
|
-
const CLASSNAME$
|
|
439
|
-
const DEFAULT_PROPS$
|
|
436
|
+
const _excluded$j = ["className", "createArc", "hasStroke", "previousData"];
|
|
437
|
+
const COMPONENT_NAME$a = 'Arc';
|
|
438
|
+
const CLASSNAME$a = 'redsift-arc';
|
|
439
|
+
const DEFAULT_PROPS$a = {
|
|
440
440
|
color: monochrome,
|
|
441
441
|
index: 0,
|
|
442
442
|
previousData: {
|
|
@@ -465,7 +465,7 @@ const Arc = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
465
465
|
hasStroke,
|
|
466
466
|
previousData
|
|
467
467
|
} = props,
|
|
468
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
468
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$j);
|
|
469
469
|
const interpolator = interpolate(previousData, data);
|
|
470
470
|
const isSelectable = role === 'option';
|
|
471
471
|
const isDeselected = isSelectable && propsIsSelected === false;
|
|
@@ -489,19 +489,19 @@ const Arc = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
489
489
|
fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color
|
|
490
490
|
}));
|
|
491
491
|
});
|
|
492
|
-
Arc.className = CLASSNAME$
|
|
493
|
-
Arc.defaultProps = DEFAULT_PROPS$
|
|
494
|
-
Arc.displayName = COMPONENT_NAME$
|
|
492
|
+
Arc.className = CLASSNAME$a;
|
|
493
|
+
Arc.defaultProps = DEFAULT_PROPS$a;
|
|
494
|
+
Arc.displayName = COMPONENT_NAME$a;
|
|
495
495
|
|
|
496
496
|
/**
|
|
497
497
|
* Component style.
|
|
498
498
|
*/
|
|
499
499
|
const StyledArcs = styled.g``;
|
|
500
500
|
|
|
501
|
-
const _excluded$
|
|
502
|
-
const COMPONENT_NAME$
|
|
503
|
-
const CLASSNAME$
|
|
504
|
-
const DEFAULT_PROPS$
|
|
501
|
+
const _excluded$i = ["arcs", "className", "color", "hasLabels", "hasStroke", "id", "labelDecorator", "onClick", "role", "tooltipVariant"];
|
|
502
|
+
const COMPONENT_NAME$9 = 'Arcs';
|
|
503
|
+
const CLASSNAME$9 = 'redsift-arcs';
|
|
504
|
+
const DEFAULT_PROPS$9 = {};
|
|
505
505
|
const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
506
506
|
const {
|
|
507
507
|
arcs,
|
|
@@ -515,7 +515,7 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
515
515
|
role,
|
|
516
516
|
tooltipVariant
|
|
517
517
|
} = props,
|
|
518
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
518
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$i);
|
|
519
519
|
const id = propsId !== null && propsId !== void 0 ? propsId : useId();
|
|
520
520
|
const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
521
521
|
to: async next => {
|
|
@@ -569,9 +569,9 @@ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
569
569
|
}, arcLabelDecorator ? arcLabelDecorator(arc.data) : arc.data.data.key);
|
|
570
570
|
})) : null);
|
|
571
571
|
});
|
|
572
|
-
Arcs.className = CLASSNAME$
|
|
573
|
-
Arcs.defaultProps = DEFAULT_PROPS$
|
|
574
|
-
Arcs.displayName = COMPONENT_NAME$
|
|
572
|
+
Arcs.className = CLASSNAME$9;
|
|
573
|
+
Arcs.defaultProps = DEFAULT_PROPS$9;
|
|
574
|
+
Arcs.displayName = COMPONENT_NAME$9;
|
|
575
575
|
|
|
576
576
|
/**
|
|
577
577
|
* Component variant.
|
|
@@ -605,6 +605,7 @@ const StyledAxis = styled(it.g)`
|
|
|
605
605
|
text {
|
|
606
606
|
font-family: var(--redsift-typography-font-family-source-code-pro);
|
|
607
607
|
font-size: 10px;
|
|
608
|
+
user-select: none;
|
|
608
609
|
}
|
|
609
610
|
`;
|
|
610
611
|
|
|
@@ -717,10 +718,10 @@ const computeTicks = _ref => {
|
|
|
717
718
|
};
|
|
718
719
|
};
|
|
719
720
|
|
|
720
|
-
const _excluded$
|
|
721
|
-
const COMPONENT_NAME$
|
|
722
|
-
const CLASSNAME$
|
|
723
|
-
const DEFAULT_PROPS$
|
|
721
|
+
const _excluded$h = ["className", "length", "legend", "legendOffset", "legendPosition", "position", "scale", "tickPadding", "tickRotation", "tickSize", "tickValues", "variant", "x", "y"];
|
|
722
|
+
const COMPONENT_NAME$8 = 'Axis';
|
|
723
|
+
const CLASSNAME$8 = 'redsift-axis';
|
|
724
|
+
const DEFAULT_PROPS$8 = {
|
|
724
725
|
position: AxisPosition.bottom,
|
|
725
726
|
legendOffset: -32,
|
|
726
727
|
legendPosition: 'end',
|
|
@@ -749,7 +750,7 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
749
750
|
x,
|
|
750
751
|
y
|
|
751
752
|
} = props,
|
|
752
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
753
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$h);
|
|
753
754
|
const axis = getAxisType(position);
|
|
754
755
|
const axisRef = ref || useRef();
|
|
755
756
|
const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
|
|
@@ -874,9 +875,9 @@ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
874
875
|
y2: config.immediate ? axis === 'x' ? 0 : length : animatedProps.lineY2
|
|
875
876
|
}) : null, legendNode);
|
|
876
877
|
});
|
|
877
|
-
Axis.className = CLASSNAME$
|
|
878
|
-
Axis.defaultProps = DEFAULT_PROPS$
|
|
879
|
-
Axis.displayName = COMPONENT_NAME$
|
|
878
|
+
Axis.className = CLASSNAME$8;
|
|
879
|
+
Axis.defaultProps = DEFAULT_PROPS$8;
|
|
880
|
+
Axis.displayName = COMPONENT_NAME$8;
|
|
880
881
|
|
|
881
882
|
/**
|
|
882
883
|
* Component variant.
|
|
@@ -920,10 +921,10 @@ const StyledBar = styled(DataPoint)`
|
|
|
920
921
|
}}}
|
|
921
922
|
`;
|
|
922
923
|
|
|
923
|
-
const _excluded$
|
|
924
|
-
const COMPONENT_NAME$
|
|
925
|
-
const CLASSNAME$
|
|
926
|
-
const DEFAULT_PROPS$
|
|
924
|
+
const _excluded$g = ["className", "gap", "height", "orientation", "previousData", "scale", "width"];
|
|
925
|
+
const COMPONENT_NAME$7 = 'Bar';
|
|
926
|
+
const CLASSNAME$7 = 'redsift-bar';
|
|
927
|
+
const DEFAULT_PROPS$7 = {
|
|
927
928
|
color: monochrome,
|
|
928
929
|
index: 0,
|
|
929
930
|
gap: 5,
|
|
@@ -957,7 +958,7 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
957
958
|
scale,
|
|
958
959
|
width
|
|
959
960
|
} = props,
|
|
960
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
961
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$g);
|
|
961
962
|
const interpolator = interpolate(((_data = previousData.data) === null || _data === void 0 ? void 0 : _data.value) || 0, data.data.value);
|
|
962
963
|
const text = labelDecorator ? labelDecorator(data) : data.data.key;
|
|
963
964
|
const isSelectable = role === 'option';
|
|
@@ -992,9 +993,9 @@ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
992
993
|
"aria-hidden": true
|
|
993
994
|
}, text) : null);
|
|
994
995
|
});
|
|
995
|
-
Bar.className = CLASSNAME$
|
|
996
|
-
Bar.defaultProps = DEFAULT_PROPS$
|
|
997
|
-
Bar.displayName = COMPONENT_NAME$
|
|
996
|
+
Bar.className = CLASSNAME$7;
|
|
997
|
+
Bar.defaultProps = DEFAULT_PROPS$7;
|
|
998
|
+
Bar.displayName = COMPONENT_NAME$7;
|
|
998
999
|
|
|
999
1000
|
var reset$1 = "Reset";
|
|
1000
1001
|
var enUS = {
|
|
@@ -1044,10 +1045,10 @@ const StyledChartContainerCaption = styled.p`
|
|
|
1044
1045
|
line-height: var(--redsift-typography-caption-line-height);
|
|
1045
1046
|
`;
|
|
1046
1047
|
|
|
1047
|
-
const _excluded$
|
|
1048
|
-
const COMPONENT_NAME$
|
|
1049
|
-
const CLASSNAME$
|
|
1050
|
-
const DEFAULT_PROPS$
|
|
1048
|
+
const _excluded$f = ["aria-label", "aria-labelledby", "caption", "children", "className", "id", "title", "onReset"];
|
|
1049
|
+
const COMPONENT_NAME$6 = 'ChartContainer';
|
|
1050
|
+
const CLASSNAME$6 = 'redsift-chart-container';
|
|
1051
|
+
const DEFAULT_PROPS$6 = {};
|
|
1051
1052
|
const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1052
1053
|
const {
|
|
1053
1054
|
'aria-label': propsAriaLabel,
|
|
@@ -1059,7 +1060,7 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1059
1060
|
title,
|
|
1060
1061
|
onReset
|
|
1061
1062
|
} = props,
|
|
1062
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1063
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$f);
|
|
1063
1064
|
const id = propsId !== null && propsId !== void 0 ? propsId : useId();
|
|
1064
1065
|
warnIfNoAccessibleLabelFound(props, [title]);
|
|
1065
1066
|
const stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
@@ -1089,9 +1090,9 @@ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1089
1090
|
className: `${ChartContainer.className}__caption`
|
|
1090
1091
|
}, caption) : null);
|
|
1091
1092
|
});
|
|
1092
|
-
ChartContainer.className = CLASSNAME$
|
|
1093
|
-
ChartContainer.defaultProps = DEFAULT_PROPS$
|
|
1094
|
-
ChartContainer.displayName = COMPONENT_NAME$
|
|
1093
|
+
ChartContainer.className = CLASSNAME$6;
|
|
1094
|
+
ChartContainer.defaultProps = DEFAULT_PROPS$6;
|
|
1095
|
+
ChartContainer.displayName = COMPONENT_NAME$6;
|
|
1095
1096
|
|
|
1096
1097
|
/**
|
|
1097
1098
|
* Component style.
|
|
@@ -1163,7 +1164,7 @@ const sizeToDimension$2 = size => {
|
|
|
1163
1164
|
}
|
|
1164
1165
|
};
|
|
1165
1166
|
|
|
1166
|
-
const _excluded$
|
|
1167
|
+
const _excluded$e = ["className", "emptyComponent", "size", "localeText"];
|
|
1167
1168
|
const EmptyBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1168
1169
|
const {
|
|
1169
1170
|
className,
|
|
@@ -1171,7 +1172,7 @@ const EmptyBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1171
1172
|
size,
|
|
1172
1173
|
localeText
|
|
1173
1174
|
} = props,
|
|
1174
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1175
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$e);
|
|
1175
1176
|
const chartDimensions = sizeToDimension$2(size);
|
|
1176
1177
|
const width = chartDimensions.width;
|
|
1177
1178
|
const height = chartDimensions.height;
|
|
@@ -1208,19 +1209,19 @@ const EmptyBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1208
1209
|
})))));
|
|
1209
1210
|
});
|
|
1210
1211
|
|
|
1211
|
-
const _excluded$
|
|
1212
|
+
const _excluded$d = ["className"];
|
|
1212
1213
|
const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1213
1214
|
const {
|
|
1214
1215
|
className
|
|
1215
1216
|
} = props,
|
|
1216
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1217
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$d);
|
|
1217
1218
|
return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
|
|
1218
1219
|
className: className,
|
|
1219
1220
|
ref: ref
|
|
1220
1221
|
}), "Loading...");
|
|
1221
1222
|
});
|
|
1222
1223
|
|
|
1223
|
-
const _excluded$
|
|
1224
|
+
const _excluded$c = ["areXLabelsRotated", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1224
1225
|
const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1225
1226
|
const {
|
|
1226
1227
|
areXLabelsRotated,
|
|
@@ -1237,7 +1238,7 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1237
1238
|
theme,
|
|
1238
1239
|
tooltipVariant
|
|
1239
1240
|
} = props,
|
|
1240
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1241
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$c);
|
|
1241
1242
|
const cache = useRef();
|
|
1242
1243
|
const {
|
|
1243
1244
|
data,
|
|
@@ -1321,10 +1322,10 @@ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1321
1322
|
}))));
|
|
1322
1323
|
});
|
|
1323
1324
|
|
|
1324
|
-
const _excluded$
|
|
1325
|
-
const COMPONENT_NAME$
|
|
1326
|
-
const CLASSNAME$
|
|
1327
|
-
const DEFAULT_PROPS$
|
|
1325
|
+
const _excluded$b = ["areXLabelsRotated", "caping", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
|
|
1326
|
+
const COMPONENT_NAME$5 = 'BarChart';
|
|
1327
|
+
const CLASSNAME$5 = 'redsift-barchart';
|
|
1328
|
+
const DEFAULT_PROPS$5 = {
|
|
1328
1329
|
isBarSelected: () => true,
|
|
1329
1330
|
others: true,
|
|
1330
1331
|
size: ChartSize.medium,
|
|
@@ -1352,7 +1353,7 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1352
1353
|
theme,
|
|
1353
1354
|
tooltipVariant
|
|
1354
1355
|
} = props,
|
|
1355
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1356
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$b);
|
|
1356
1357
|
const id = propsId !== null && propsId !== void 0 ? propsId : useId();
|
|
1357
1358
|
if (propsData === undefined || propsData === null) {
|
|
1358
1359
|
return /*#__PURE__*/React__default.createElement(LoadingBarChart, _extends({
|
|
@@ -1390,9 +1391,9 @@ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1390
1391
|
ref: ref
|
|
1391
1392
|
}));
|
|
1392
1393
|
});
|
|
1393
|
-
BarChart.className = CLASSNAME$
|
|
1394
|
-
BarChart.defaultProps = DEFAULT_PROPS$
|
|
1395
|
-
BarChart.displayName = COMPONENT_NAME$
|
|
1394
|
+
BarChart.className = CLASSNAME$5;
|
|
1395
|
+
BarChart.defaultProps = DEFAULT_PROPS$5;
|
|
1396
|
+
BarChart.displayName = COMPONENT_NAME$5;
|
|
1396
1397
|
|
|
1397
1398
|
/**
|
|
1398
1399
|
* Component style.
|
|
@@ -1426,10 +1427,10 @@ const StyledDot = styled(DataPoint)`
|
|
|
1426
1427
|
}}}
|
|
1427
1428
|
`;
|
|
1428
1429
|
|
|
1429
|
-
const _excluded$
|
|
1430
|
-
const COMPONENT_NAME$
|
|
1431
|
-
const CLASSNAME$
|
|
1432
|
-
const DEFAULT_PROPS$
|
|
1430
|
+
const _excluded$a = ["className", "scaleX", "scaleY"];
|
|
1431
|
+
const COMPONENT_NAME$4 = 'Dot';
|
|
1432
|
+
const CLASSNAME$4 = 'redsift-dot';
|
|
1433
|
+
const DEFAULT_PROPS$4 = {
|
|
1433
1434
|
color: monochrome,
|
|
1434
1435
|
index: 0,
|
|
1435
1436
|
labelDecorator: datum => {
|
|
@@ -1449,7 +1450,7 @@ const Dot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1449
1450
|
scaleX,
|
|
1450
1451
|
scaleY
|
|
1451
1452
|
} = props,
|
|
1452
|
-
forwardedProps = _objectWithoutProperties(props, _excluded$
|
|
1453
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$a);
|
|
1453
1454
|
const isSelectable = role === 'option';
|
|
1454
1455
|
const isDeselected = isSelectable && propsIsSelected === false;
|
|
1455
1456
|
return /*#__PURE__*/React__default.createElement(StyledDot, _extends({}, forwardedProps, {
|
|
@@ -1463,9 +1464,9 @@ const Dot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1463
1464
|
fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color
|
|
1464
1465
|
}));
|
|
1465
1466
|
});
|
|
1466
|
-
Dot.className = CLASSNAME$
|
|
1467
|
-
Dot.defaultProps = DEFAULT_PROPS$
|
|
1468
|
-
Dot.displayName = COMPONENT_NAME$
|
|
1467
|
+
Dot.className = CLASSNAME$4;
|
|
1468
|
+
Dot.defaultProps = DEFAULT_PROPS$4;
|
|
1469
|
+
Dot.displayName = COMPONENT_NAME$4;
|
|
1469
1470
|
|
|
1470
1471
|
/**
|
|
1471
1472
|
* Component style.
|
|
@@ -1481,7 +1482,11 @@ const StyledLegend = styled.ul`
|
|
|
1481
1482
|
` : null;
|
|
1482
1483
|
}}
|
|
1483
1484
|
`;
|
|
1484
|
-
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Component style.
|
|
1488
|
+
*/
|
|
1489
|
+
const StyledLegendItem = styled.li`
|
|
1485
1490
|
display: flex;
|
|
1486
1491
|
align-items: center;
|
|
1487
1492
|
gap: 8px;
|
|
@@ -1491,25 +1496,131 @@ const StyledLabel = styled.li`
|
|
|
1491
1496
|
height: 16px;
|
|
1492
1497
|
width: 16px;
|
|
1493
1498
|
min-width: 16px;
|
|
1494
|
-
background-color: ${
|
|
1499
|
+
background-color: ${_ref => {
|
|
1495
1500
|
let {
|
|
1496
|
-
|
|
1497
|
-
} =
|
|
1498
|
-
return
|
|
1501
|
+
color
|
|
1502
|
+
} = _ref;
|
|
1503
|
+
return color;
|
|
1499
1504
|
}};
|
|
1500
1505
|
}
|
|
1506
|
+
|
|
1507
|
+
${_ref2 => {
|
|
1508
|
+
let {
|
|
1509
|
+
$clickable
|
|
1510
|
+
} = _ref2;
|
|
1511
|
+
return $clickable ? css`
|
|
1512
|
+
cursor: pointer;
|
|
1513
|
+
|
|
1514
|
+
&:hover,
|
|
1515
|
+
&:focus {
|
|
1516
|
+
outline: none;
|
|
1517
|
+
> div {
|
|
1518
|
+
opacity: 0.7;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
&:focus-visible {
|
|
1523
|
+
> div {
|
|
1524
|
+
outline: 4px solid var(--redsift-color-default-primary);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
` : '';
|
|
1528
|
+
}}}
|
|
1501
1529
|
`;
|
|
1502
1530
|
|
|
1503
|
-
const _excluded$
|
|
1531
|
+
const _excluded$9 = ["className", "color", "data", "id", "total", "variant"];
|
|
1532
|
+
const COMPONENT_NAME$3 = 'LegendItem';
|
|
1533
|
+
const CLASSNAME$3 = 'redsift-legend-item';
|
|
1534
|
+
const DEFAULT_PROPS$3 = {
|
|
1535
|
+
color: monochrome,
|
|
1536
|
+
index: 0
|
|
1537
|
+
};
|
|
1538
|
+
const LegendItem = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1539
|
+
const {
|
|
1540
|
+
index,
|
|
1541
|
+
isSelected: propsIsSelected,
|
|
1542
|
+
labelDecorator,
|
|
1543
|
+
onClick,
|
|
1544
|
+
role
|
|
1545
|
+
} = props;
|
|
1546
|
+
const {
|
|
1547
|
+
className,
|
|
1548
|
+
color,
|
|
1549
|
+
data,
|
|
1550
|
+
id: propsId,
|
|
1551
|
+
total,
|
|
1552
|
+
variant
|
|
1553
|
+
} = props,
|
|
1554
|
+
forwardedProps = _objectWithoutProperties(props, _excluded$9);
|
|
1555
|
+
const id = propsId !== null && propsId !== void 0 ? propsId : useId();
|
|
1556
|
+
const text = labelDecorator ? labelDecorator(data) : data.data.key;
|
|
1557
|
+
const isEmpty = data.data.value === 0;
|
|
1558
|
+
const isSelectable = role === 'option';
|
|
1559
|
+
const isSelected = isSelectable && propsIsSelected === true;
|
|
1560
|
+
const isDeselected = isSelectable && propsIsSelected === false;
|
|
1561
|
+
const onKeyDown = event => {
|
|
1562
|
+
if (onClick) {
|
|
1563
|
+
event.stopPropagation();
|
|
1564
|
+
if (event.code === 'Enter' || event.code === 'Space') {
|
|
1565
|
+
event.preventDefault();
|
|
1566
|
+
onClick(data);
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
return /*#__PURE__*/React__default.createElement(StyledLegendItem, _extends({}, forwardedProps, {
|
|
1571
|
+
className: classNames(LegendItem.className, className, `_${index}`, {
|
|
1572
|
+
selected: isSelected,
|
|
1573
|
+
deselected: isDeselected
|
|
1574
|
+
}),
|
|
1575
|
+
color: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
|
|
1576
|
+
ref: ref,
|
|
1577
|
+
"aria-labelledby": !isEmpty ? `${id}-title` : undefined,
|
|
1578
|
+
"aria-selected": isSelected ? true : isDeselected ? false : undefined,
|
|
1579
|
+
id: id,
|
|
1580
|
+
onClick: onClick ? () => onClick(data) : undefined,
|
|
1581
|
+
onKeyDown: onClick ? e => onKeyDown(e) : undefined,
|
|
1582
|
+
role: role ? role : onClick ? 'button' : undefined,
|
|
1583
|
+
tabIndex: onClick ? 0 : undefined,
|
|
1584
|
+
$clickable: Boolean(onClick)
|
|
1585
|
+
}), /*#__PURE__*/React__default.createElement("div", null), variant === LabelVariant.value ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
|
|
1586
|
+
as: "b",
|
|
1587
|
+
maximumFractionDigits: 2,
|
|
1588
|
+
value: data.data.value,
|
|
1589
|
+
variant: "inherit"
|
|
1590
|
+
}), /*#__PURE__*/React__default.createElement(Text, {
|
|
1591
|
+
variant: "caption"
|
|
1592
|
+
}, text)) : variant === LabelVariant.percent && total ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
|
|
1593
|
+
as: "b",
|
|
1594
|
+
maximumFractionDigits: 2,
|
|
1595
|
+
type: "percent",
|
|
1596
|
+
value: data.data.value / total,
|
|
1597
|
+
variant: "inherit"
|
|
1598
|
+
}), /*#__PURE__*/React__default.createElement(Text, {
|
|
1599
|
+
variant: "caption"
|
|
1600
|
+
}, text)) : /*#__PURE__*/React__default.createElement(Text, {
|
|
1601
|
+
variant: "caption"
|
|
1602
|
+
}, text));
|
|
1603
|
+
});
|
|
1604
|
+
LegendItem.className = CLASSNAME$3;
|
|
1605
|
+
LegendItem.defaultProps = DEFAULT_PROPS$3;
|
|
1606
|
+
LegendItem.displayName = COMPONENT_NAME$3;
|
|
1607
|
+
|
|
1608
|
+
const _excluded$8 = ["className", "data", "isLegendItemSelected", "labelDecorator", "legendItemRole", "onLegendItemClick", "variant", "width"],
|
|
1609
|
+
_excluded2 = ["color"];
|
|
1504
1610
|
const COMPONENT_NAME$2 = 'Legend';
|
|
1505
1611
|
const CLASSNAME$2 = 'redsift-chart-legend';
|
|
1506
1612
|
const DEFAULT_PROPS$2 = {
|
|
1613
|
+
isLegendItemSelected: () => true,
|
|
1507
1614
|
variant: LabelVariant.label
|
|
1508
1615
|
};
|
|
1509
1616
|
const Legend = /*#__PURE__*/forwardRef((props, ref) => {
|
|
1510
1617
|
const {
|
|
1511
1618
|
className,
|
|
1512
1619
|
data,
|
|
1620
|
+
isLegendItemSelected,
|
|
1621
|
+
labelDecorator,
|
|
1622
|
+
legendItemRole,
|
|
1623
|
+
onLegendItemClick,
|
|
1513
1624
|
variant,
|
|
1514
1625
|
width
|
|
1515
1626
|
} = props,
|
|
@@ -1521,31 +1632,25 @@ const Legend = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
1521
1632
|
$width: width
|
|
1522
1633
|
}), data.map((_ref, index) => {
|
|
1523
1634
|
let {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
variant: "inherit"
|
|
1544
|
-
}), /*#__PURE__*/React__default.createElement(Text, {
|
|
1545
|
-
variant: "caption"
|
|
1546
|
-
}, key)) : /*#__PURE__*/React__default.createElement(Text, {
|
|
1547
|
-
variant: "caption"
|
|
1548
|
-
}, key));
|
|
1635
|
+
color
|
|
1636
|
+
} = _ref,
|
|
1637
|
+
datum = _objectWithoutProperties(_ref, _excluded2);
|
|
1638
|
+
return /*#__PURE__*/React__default.createElement(LegendItem, {
|
|
1639
|
+
data: {
|
|
1640
|
+
data: datum
|
|
1641
|
+
},
|
|
1642
|
+
color: color,
|
|
1643
|
+
total: total,
|
|
1644
|
+
variant: variant,
|
|
1645
|
+
index: index,
|
|
1646
|
+
isSelected: Boolean(isLegendItemSelected({
|
|
1647
|
+
data: datum
|
|
1648
|
+
})),
|
|
1649
|
+
key: `legend-item _${index}`,
|
|
1650
|
+
labelDecorator: labelDecorator,
|
|
1651
|
+
onClick: onLegendItemClick,
|
|
1652
|
+
role: legendItemRole
|
|
1653
|
+
});
|
|
1549
1654
|
}));
|
|
1550
1655
|
});
|
|
1551
1656
|
Legend.className = CLASSNAME$2;
|
|
@@ -2191,7 +2296,7 @@ const EmptyScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2191
2296
|
})))));
|
|
2192
2297
|
});
|
|
2193
2298
|
|
|
2194
|
-
const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "labelVariant", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "yAxisVariant"];
|
|
2299
|
+
const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "labelVariant", "legendProps", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant", "xAxisVariant", "yAxisVariant"];
|
|
2195
2300
|
const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
2196
2301
|
const {
|
|
2197
2302
|
isBrushable,
|
|
@@ -2202,6 +2307,7 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2202
2307
|
isDotSelected,
|
|
2203
2308
|
labelDecorator,
|
|
2204
2309
|
labelVariant,
|
|
2310
|
+
legendProps,
|
|
2205
2311
|
onBrush,
|
|
2206
2312
|
onBrushEnd,
|
|
2207
2313
|
onDotClick,
|
|
@@ -2244,7 +2350,7 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2244
2350
|
domain[1] += gap * 0.1;
|
|
2245
2351
|
return scaleLinear().domain(domain).range([chartHeight, 0]).nice();
|
|
2246
2352
|
})();
|
|
2247
|
-
const hasCategory = data[0] && data[0].key.length
|
|
2353
|
+
const hasCategory = data[0] && data[0].key.length >= 3 && data[0].key[2] !== null && data[0].key[2] !== undefined;
|
|
2248
2354
|
const countsByCategory = hasCategory ? countBy(data) : undefined;
|
|
2249
2355
|
const colorScale = useColor({
|
|
2250
2356
|
data: countsByCategory || data,
|
|
@@ -2356,13 +2462,13 @@ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
2356
2462
|
y: chartHeight,
|
|
2357
2463
|
tickValues: 8,
|
|
2358
2464
|
variant: yAxisVariant
|
|
2359
|
-
}))), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, {
|
|
2465
|
+
}))), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, _extends({
|
|
2360
2466
|
data: countsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
|
|
2361
2467
|
color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
|
|
2362
2468
|
})),
|
|
2363
2469
|
variant: labelVariant === ScatterPlotLabelVariant.externalLabelValue ? LabelVariant.value : labelVariant === ScatterPlotLabelVariant.externalLabelPercent ? LabelVariant.percent : LabelVariant.label,
|
|
2364
2470
|
width: legendWidth.current
|
|
2365
|
-
}) : null);
|
|
2471
|
+
}, legendProps)) : null);
|
|
2366
2472
|
});
|
|
2367
2473
|
|
|
2368
2474
|
const _excluded = ["className", "data", "dotRole", "emptyComponent", "id", "isDotSelected", "labelVariant", "localeText", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant"];
|
|
@@ -2443,5 +2549,5 @@ ScatterPlot.className = CLASSNAME;
|
|
|
2443
2549
|
ScatterPlot.defaultProps = DEFAULT_PROPS;
|
|
2444
2550
|
ScatterPlot.displayName = COMPONENT_NAME;
|
|
2445
2551
|
|
|
2446
|
-
export { Arc, Arcs, Axis, AxisPosition, AxisVariant, Bar, BarChart, BarOrientation, ChartContainer, ChartSize, ColorTheme, DataPoint, Dot, LabelVariant, Legend, PieChart, PieChartLabelVariant, PieChartVariant, ScatterPlot, ScatterPlotLabelVariant, ScatterPlotVariant, StyledArc, StyledArcs, StyledAxis, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle, StyledDataPoint, StyledDot,
|
|
2552
|
+
export { Arc, Arcs, Axis, AxisPosition, AxisVariant, Bar, BarChart, BarOrientation, ChartContainer, ChartSize, ColorTheme, DataPoint, Dot, LabelVariant, Legend, PieChart, PieChartLabelVariant, PieChartVariant, ScatterPlot, ScatterPlotLabelVariant, ScatterPlotVariant, StyledArc, StyledArcs, StyledAxis, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle, StyledDataPoint, StyledDot, StyledLegend, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledScatterPlot, StyledScatterPlotEmptyText, TooltipVariant, empty, getColorScale, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
|
|
2447
2553
|
//# sourceMappingURL=index.js.map
|