@economic/taco 2.45.0-alpha.2 → 2.45.0-alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/charts/components/Area/AreaChart.d.ts +19 -0
- package/dist/charts/components/Bar/BarChart.d.ts +20 -0
- package/dist/charts/components/Donut/ActiveShape.d.ts +8 -0
- package/dist/charts/components/Donut/CenteredLabel.d.ts +11 -0
- package/dist/charts/components/Donut/DonutChart.d.ts +21 -0
- package/dist/charts/components/Donut/Legend.d.ts +13 -0
- package/dist/charts/components/Donut/util.d.ts +2 -0
- package/dist/charts/components/Legend.d.ts +16 -0
- package/dist/charts/components/Line/LineChart.d.ts +18 -0
- package/dist/charts/components/ResponsiveContainer.d.ts +5 -0
- package/dist/charts/components/Tooltip.d.ts +10 -0
- package/dist/charts/components/types.d.ts +5 -0
- package/dist/charts/utils/color.d.ts +3 -0
- package/dist/charts/utils/common.d.ts +37 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +3 -3
- package/dist/components/Table3/components/Columns/Internal/EditingActionsMenu.d.ts +2 -2
- package/dist/components/Table3/features/useEditingState.d.ts +1 -1
- package/dist/components/Table3/features/useTableEditing.d.ts +4 -3
- package/dist/esm/index.css +18 -0
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js +67 -0
- package/dist/esm/packages/taco/src/charts/components/Area/AreaChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js +120 -0
- package/dist/esm/packages/taco/src/charts/components/Bar/BarChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js +47 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/ActiveShape.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js +27 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/CenteredLabel.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js +170 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +164 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js +5 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/util.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js +145 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js +65 -0
- package/dist/esm/packages/taco/src/charts/components/Line/LineChart.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js +10 -0
- package/dist/esm/packages/taco/src/charts/components/ResponsiveContainer.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js +44 -0
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js +24 -0
- package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js +34 -0
- package/dist/esm/packages/taco/src/charts/utils/common.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js +6 -14
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js +2 -4
- package/dist/esm/packages/taco/src/components/Header/components/AgreementSelector.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js +1 -7
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +0 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Internal/EditingActionsMenu.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -32
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +4 -4
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +32 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +7 -5
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +16 -4
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +4 -0
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Sortable/components/Item.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js +10 -5
- package/dist/esm/packages/taco/src/primitives/Table/Core/Table.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js +6 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Body/EmptyStateBody.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js +23 -16
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/BuiltIns/GroupedCell.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js +4 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Actions.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Drag.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js +7 -0
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Expansion.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js +4 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/DisplayRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js +3 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/RowContext.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +5 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/esm/packages/taco/tailwind.colors.js +122 -0
- package/dist/esm/packages/taco/tailwind.colors.js.map +1 -0
- package/dist/index.css +18 -0
- package/dist/index.d.ts +5 -0
- package/dist/primitives/Table/Core/components/Body/EmptyStateBody.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Row/RowContext.d.ts +2 -1
- package/dist/primitives/Table/Core/types.d.ts +1 -0
- package/dist/taco.cjs.development.js +942 -105
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +18 -16
- package/tailwind.colors.js +121 -0
- package/tailwind.config.js +3 -2
- package/dist/components/Table3/components/Row/Editing/CreateRowButton.d.ts +0 -11
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Color } from '../../utils/color';
|
3
|
+
import { CommonChartProps } from '../../utils/common';
|
4
|
+
declare type AreaChartBarProps<TType> = {
|
5
|
+
accessor: keyof TType & string;
|
6
|
+
color?: Color;
|
7
|
+
label?: string;
|
8
|
+
stackId?: string;
|
9
|
+
};
|
10
|
+
declare type AreaChartProps<TType> = CommonChartProps<TType> & {
|
11
|
+
children: React.ReactElement<AreaChartBarProps<TType>> | React.ReactElement<AreaChartBarProps<TType>>[];
|
12
|
+
data: TType[];
|
13
|
+
formatter?: (value: any) => string;
|
14
|
+
};
|
15
|
+
export declare const AreaChart: {
|
16
|
+
<TType = unknown>(externalProps: AreaChartProps<TType>): React.JSX.Element;
|
17
|
+
Area: (_: AreaChartBarProps<any>) => null;
|
18
|
+
};
|
19
|
+
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Color } from '../../utils/color';
|
3
|
+
import { CommonChartProps } from '../../utils/common';
|
4
|
+
declare type BarChartBarProps<TType> = {
|
5
|
+
accessor: keyof TType & string;
|
6
|
+
color?: Color;
|
7
|
+
label?: string;
|
8
|
+
stackId?: string;
|
9
|
+
};
|
10
|
+
declare type BarChartProps<TType> = CommonChartProps<TType> & {
|
11
|
+
children: React.ReactElement<BarChartBarProps<TType>> | React.ReactElement<BarChartBarProps<TType>>[];
|
12
|
+
data: TType[];
|
13
|
+
formatter?: (value: any) => string;
|
14
|
+
layout?: 'horizontal' | 'vertical';
|
15
|
+
};
|
16
|
+
export declare const BarChart: {
|
17
|
+
<TType = unknown>(externalProps: BarChartProps<TType>): React.JSX.Element;
|
18
|
+
Bar: (_: BarChartBarProps<any>) => null;
|
19
|
+
};
|
20
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { PieSectorDataItem } from 'recharts/types/polar/Pie';
|
3
|
+
declare type ActiveShapeProps = Omit<PieSectorDataItem, 'onClick'> & {
|
4
|
+
onClick: (id: string | undefined) => void;
|
5
|
+
pieColors: Record<string, string>;
|
6
|
+
};
|
7
|
+
export declare const ActiveShape: (props: ActiveShapeProps) => React.JSX.Element;
|
8
|
+
export {};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
declare type CenteredLabelProps = {
|
3
|
+
radius: number;
|
4
|
+
legendPosition: string;
|
5
|
+
label: string;
|
6
|
+
total: number;
|
7
|
+
formatter: ((value: number) => string) | undefined;
|
8
|
+
showLegend: boolean;
|
9
|
+
};
|
10
|
+
export declare const CenteredLabel: ({ radius, legendPosition, label, total, formatter, showLegend }: CenteredLabelProps) => React.JSX.Element;
|
11
|
+
export {};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Color } from '../../utils/color';
|
3
|
+
export declare type DonutChartSegmentProps = {
|
4
|
+
color: Color;
|
5
|
+
id: string;
|
6
|
+
label: string;
|
7
|
+
value: number;
|
8
|
+
};
|
9
|
+
export declare type SegmentIds = string[];
|
10
|
+
export declare type DonutChartProps = {
|
11
|
+
children: React.ReactElement<DonutChartSegmentProps> | React.ReactElement<DonutChartSegmentProps>[];
|
12
|
+
formatter?: (value: number) => string;
|
13
|
+
onClick?: (segment: DonutChartSegmentProps | DonutChartSegmentProps[]) => void;
|
14
|
+
showLegend?: boolean;
|
15
|
+
legendPosition?: string;
|
16
|
+
label: string;
|
17
|
+
};
|
18
|
+
export declare const DonutChart: {
|
19
|
+
({ children, formatter, onClick, showLegend, legendPosition, label, }: DonutChartProps): React.JSX.Element | null;
|
20
|
+
Segment: (_: DonutChartSegmentProps) => null;
|
21
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DonutChartProps, DonutChartSegmentProps, SegmentIds } from './DonutChart';
|
3
|
+
declare type LegendProps = Pick<DonutChartProps, 'formatter' | 'label' | 'legendPosition'> & {
|
4
|
+
data: DonutChartSegmentProps[];
|
5
|
+
hoveredItem: SegmentIds;
|
6
|
+
onClick: (entry: DonutChartSegmentProps | DonutChartSegmentProps[]) => void;
|
7
|
+
selectedItem: SegmentIds;
|
8
|
+
setHoveredItem: React.Dispatch<React.SetStateAction<SegmentIds>>;
|
9
|
+
total: number;
|
10
|
+
visibleItems: Record<string, boolean>;
|
11
|
+
};
|
12
|
+
export declare const Legend: ({ legendPosition, hoveredItem, selectedItem, data, onClick, setHoveredItem, formatter, total, visibleItems, label, }: LegendProps) => React.JSX.Element;
|
13
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ActiveChartItems, PayloadType } from './types';
|
3
|
+
declare type InternalProps<TType> = {
|
4
|
+
payload: PayloadType<TType>[];
|
5
|
+
layout: string;
|
6
|
+
activeIndex: number | undefined;
|
7
|
+
};
|
8
|
+
export declare type LegendProps<TType> = {
|
9
|
+
activeItems: ActiveChartItems<TType>;
|
10
|
+
onMouseEnter: (entry: PayloadType<TType>, index: number) => void;
|
11
|
+
onMouseLeave: () => void;
|
12
|
+
onClick: (entry: PayloadType<TType>) => void;
|
13
|
+
};
|
14
|
+
export declare type Props<TType> = LegendProps<TType> & InternalProps<TType>;
|
15
|
+
export declare function Legend<TType>(props: LegendProps<TType>): React.JSX.Element;
|
16
|
+
export {};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Color } from '../../utils/color';
|
3
|
+
import { CommonChartProps } from '../../utils/common';
|
4
|
+
declare type LineChartBarProps<TType> = {
|
5
|
+
accessor: keyof TType & string;
|
6
|
+
color?: Color;
|
7
|
+
label?: string;
|
8
|
+
};
|
9
|
+
declare type LineChartProps<TType> = CommonChartProps<TType> & {
|
10
|
+
children: React.ReactElement<LineChartBarProps<TType>> | React.ReactElement<LineChartBarProps<TType>>[];
|
11
|
+
data: TType[];
|
12
|
+
formatter?: (value: any) => string;
|
13
|
+
};
|
14
|
+
export declare const LineChart: {
|
15
|
+
<TType = unknown>(externalProps: LineChartProps<TType>): React.JSX.Element;
|
16
|
+
Line: (_: LineChartBarProps<any>) => null;
|
17
|
+
};
|
18
|
+
export {};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import React, { CSSProperties } from 'react';
|
2
|
+
declare type TooltipProps = {
|
3
|
+
active?: boolean;
|
4
|
+
formatter: (value: any) => any;
|
5
|
+
payload: any;
|
6
|
+
style?: CSSProperties;
|
7
|
+
singlePieDonutChart?: boolean;
|
8
|
+
};
|
9
|
+
export declare const Tooltip: ({ active, formatter, payload, style, singlePieDonutChart }: TooltipProps) => React.JSX.Element | null;
|
10
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { ScaleType } from 'recharts/types/util/types';
|
3
|
+
import { LegendProps } from '../components/Legend';
|
4
|
+
export declare type CommonChartProps<TType> = {
|
5
|
+
accessor: keyof TType & string;
|
6
|
+
xAxisScale?: ScaleType | Function;
|
7
|
+
xAxisTickFormat: (value: any) => string;
|
8
|
+
yAxisScale?: ScaleType | Function;
|
9
|
+
yAxisTickFormat: (value: any) => string;
|
10
|
+
};
|
11
|
+
export declare const getCartesianGridProps: () => {
|
12
|
+
vertical: boolean;
|
13
|
+
};
|
14
|
+
export declare const getXAxisProps: <TType>(props: CommonChartProps<TType>) => {
|
15
|
+
axisLine: boolean;
|
16
|
+
dataKey: keyof TType & string;
|
17
|
+
fontSize: number;
|
18
|
+
scale: Function | "auto" | "linear" | "pow" | "sqrt" | "log" | "identity" | "time" | "band" | "point" | "ordinal" | "quantile" | "quantize" | "utc" | "sequential" | "threshold" | undefined;
|
19
|
+
tickLine: boolean;
|
20
|
+
tickFormatter: (value: any) => string;
|
21
|
+
};
|
22
|
+
export declare const getYAxisProps: <TType>(props: CommonChartProps<TType>) => {
|
23
|
+
axisLine: boolean;
|
24
|
+
fontSize: number;
|
25
|
+
scale: Function | "auto" | "linear" | "pow" | "sqrt" | "log" | "identity" | "time" | "band" | "point" | "ordinal" | "quantile" | "quantize" | "utc" | "sequential" | "threshold" | undefined;
|
26
|
+
tickLine: boolean;
|
27
|
+
tickFormatter: (value: any) => string;
|
28
|
+
};
|
29
|
+
export declare const getLegendProps: <TType>(props: LegendProps<TType>) => {
|
30
|
+
content: React.JSX.Element;
|
31
|
+
};
|
32
|
+
export declare const getTooltipProps: (props?: any) => {
|
33
|
+
content: React.JSX.Element;
|
34
|
+
wrapperStyle: {
|
35
|
+
outline: string;
|
36
|
+
};
|
37
|
+
};
|
@@ -10,9 +10,9 @@ export declare type RadioGroupItemProps<T = HTMLButtonElement> = Omit<React.Butt
|
|
10
10
|
/** Value of the radio button */
|
11
11
|
value: RadioGroupItemValue;
|
12
12
|
};
|
13
|
-
declare type
|
14
|
-
declare type RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'
|
15
|
-
children:
|
13
|
+
declare type RadioGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;
|
14
|
+
declare type RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {
|
15
|
+
children: RadioGroupBaseChild[];
|
16
16
|
disabled?: boolean;
|
17
17
|
invalid?: boolean;
|
18
18
|
/** The name of the radio group, used when submitting an HTML form */
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
declare type
|
2
|
+
declare type EditingActionsMenuProps = {
|
3
3
|
hasChanges: boolean;
|
4
4
|
hasErrors: boolean;
|
5
5
|
onDiscard: () => void;
|
6
6
|
onEditingSave: () => Promise<void>;
|
7
7
|
isLastRow: boolean;
|
8
8
|
};
|
9
|
-
export declare function
|
9
|
+
export declare function EditingActionsMenu(props: EditingActionsMenuProps): React.JSX.Element;
|
10
10
|
export {};
|
@@ -23,7 +23,7 @@ export declare function usePendingChangesState<TType = unknown>(handleSave: Tabl
|
|
23
23
|
saveChanges: <T_7 extends TType>(table: ReactTable<T_7>, rowId?: string | undefined) => Promise<boolean>;
|
24
24
|
discardChanges: <T_8 extends TType>(rowId: string, table: ReactTable<T_8>) => void;
|
25
25
|
hasSaved: () => boolean;
|
26
|
-
|
26
|
+
insertTemporaryRow: <T_9 extends TType>(data: Partial<T_9>) => string;
|
27
27
|
temporaryRows: any;
|
28
28
|
};
|
29
29
|
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { Table as ReactTable } from '@tanstack/react-table';
|
3
|
-
import { Table3EditingChangeHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
|
4
|
-
export declare function useTableEditing<TType = unknown>(isEnabled: boolean | undefined, handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, rowIdentityAccessor: keyof TType | undefined, validator: Table3EditingValidatorFn<TType> | undefined): {
|
3
|
+
import { Table3EditingChangeHandler, Table3EditingCreateHandler, Table3EditingSaveHandler, Table3EditingValidatorFn } from '../types';
|
4
|
+
export declare function useTableEditing<TType = unknown>(isEnabled: boolean | undefined, handleSave: Table3EditingSaveHandler<TType> | undefined, handleChange: Table3EditingChangeHandler<TType> | undefined, handleCreate: Table3EditingCreateHandler<TType> | undefined, rowIdentityAccessor: keyof TType | undefined, validator: Table3EditingValidatorFn<TType> | undefined): {
|
5
5
|
setRowValue: <T extends TType>(rowId: string, original: T, value: Partial<T>) => Promise<void>;
|
6
6
|
getRowValue: (rowId: string) => any;
|
7
7
|
getRowMoveReason: (rowId: string) => unknown;
|
@@ -23,7 +23,7 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
|
|
23
23
|
saveChanges: <T_7 extends TType>(table: ReactTable<T_7>, rowId?: string | undefined) => Promise<boolean>;
|
24
24
|
discardChanges: <T_8 extends TType>(rowId: string, table: ReactTable<T_8>) => void;
|
25
25
|
hasSaved: () => boolean;
|
26
|
-
|
26
|
+
insertTemporaryRow: <T_9 extends TType>(data: Partial<T_9>) => string;
|
27
27
|
temporaryRows: any;
|
28
28
|
isEnabled: boolean;
|
29
29
|
isEditing: boolean;
|
@@ -32,5 +32,6 @@ export declare function useTableEditing<TType = unknown>(isEnabled: boolean | un
|
|
32
32
|
toggleEditing: <T_10 extends TType>(enabled: React.SetStateAction<boolean>, table: ReactTable<T_10>, scrollToIndex: (index: number) => void) => void;
|
33
33
|
lastFocusedCellIndex: number | undefined;
|
34
34
|
setLastFocusedCellIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
|
35
|
+
createRow: <T_11 extends TType>(table: ReactTable<T_11>, scrollToIndex: (index: number) => void, row?: Partial<T_11> | undefined) => Promise<void>;
|
35
36
|
createRowButtonRef: React.RefObject<HTMLButtonElement>;
|
36
37
|
};
|
package/dist/esm/index.css
CHANGED
@@ -180,6 +180,24 @@
|
|
180
180
|
}
|
181
181
|
}
|
182
182
|
|
183
|
+
.recharts-cartesian-axis line,
|
184
|
+
.recharts-cartesian-grid-horizontal line {
|
185
|
+
stroke: #efefef !important;
|
186
|
+
}
|
187
|
+
|
188
|
+
.recharts-tooltip-cursor {
|
189
|
+
fill: transparent !important;
|
190
|
+
}
|
191
|
+
|
192
|
+
.recharts-legend-wrapper {
|
193
|
+
left: 0 !important;
|
194
|
+
width: 100% !important;
|
195
|
+
}
|
196
|
+
|
197
|
+
.recharts-wrapper > svg g {
|
198
|
+
outline: none !important;
|
199
|
+
}
|
200
|
+
|
183
201
|
[data-taco='badge'] > [data-taco='spinner'] {
|
184
202
|
@apply ml-2 h-3 w-3;
|
185
203
|
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import React__default, { useState } from 'react';
|
2
|
+
import { AreaChart as AreaChart$1, CartesianGrid, XAxis, YAxis, Legend, Tooltip, Area as Area$1 } from 'recharts';
|
3
|
+
import { getThemeColor } from '../../utils/color.js';
|
4
|
+
import { getCartesianGridProps, getXAxisProps, getYAxisProps, getLegendProps, getTooltipProps } from '../../utils/common.js';
|
5
|
+
import { ResponsiveContainer } from '../ResponsiveContainer.js';
|
6
|
+
|
7
|
+
const Area = _ => null;
|
8
|
+
const AreaChart = function AreaChart(externalProps) {
|
9
|
+
const {
|
10
|
+
children,
|
11
|
+
data,
|
12
|
+
formatter,
|
13
|
+
...props
|
14
|
+
} = externalProps;
|
15
|
+
const [hoveredArea, setHoveredArea] = useState(null);
|
16
|
+
const [activeAreas, setActiveAreas] = useState(() => {
|
17
|
+
const areas = {};
|
18
|
+
React__default.Children.forEach(children, child => {
|
19
|
+
areas[child.props.accessor] = true;
|
20
|
+
});
|
21
|
+
return areas;
|
22
|
+
});
|
23
|
+
const handleLegendClick = entry => {
|
24
|
+
setHoveredArea(null);
|
25
|
+
setActiveAreas({
|
26
|
+
...activeAreas,
|
27
|
+
[entry.dataKey]: !activeAreas[entry.dataKey]
|
28
|
+
});
|
29
|
+
};
|
30
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(AreaChart$1, {
|
31
|
+
data: data,
|
32
|
+
margin: {
|
33
|
+
top: 10,
|
34
|
+
right: 0,
|
35
|
+
left: -25,
|
36
|
+
bottom: 0
|
37
|
+
}
|
38
|
+
}, /*#__PURE__*/React__default.createElement(CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(XAxis, Object.assign({}, getXAxisProps(props))), /*#__PURE__*/React__default.createElement(YAxis, Object.assign({}, getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, getLegendProps({
|
39
|
+
onClick: handleLegendClick,
|
40
|
+
onMouseEnter: entry => setHoveredArea(entry.dataKey),
|
41
|
+
onMouseLeave: () => setHoveredArea(null),
|
42
|
+
activeItems: activeAreas
|
43
|
+
}))), /*#__PURE__*/React__default.createElement(Tooltip, Object.assign({}, getTooltipProps(), {
|
44
|
+
formatter: formatter
|
45
|
+
})), React__default.Children.map(children, child => {
|
46
|
+
var _child$props$color, _child$props$color2, _child$props$color3;
|
47
|
+
return /*#__PURE__*/React__default.createElement(Area$1, {
|
48
|
+
activeDot: {
|
49
|
+
fill: getThemeColor((_child$props$color = child.props.color) !== null && _child$props$color !== void 0 ? _child$props$color : 'blue-300')
|
50
|
+
},
|
51
|
+
isAnimationActive: false,
|
52
|
+
dataKey: child.props.accessor,
|
53
|
+
dot: false,
|
54
|
+
fill: getThemeColor((_child$props$color2 = child.props.color) !== null && _child$props$color2 !== void 0 ? _child$props$color2 : 'grey-100'),
|
55
|
+
name: child.props.label,
|
56
|
+
strokeWidth: 2,
|
57
|
+
stroke: getThemeColor((_child$props$color3 = child.props.color) !== null && _child$props$color3 !== void 0 ? _child$props$color3 : 'grey-300'),
|
58
|
+
stackId: child.props.stackId,
|
59
|
+
hide: !activeAreas[child.props.accessor],
|
60
|
+
opacity: hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1
|
61
|
+
});
|
62
|
+
})));
|
63
|
+
};
|
64
|
+
AreaChart.Area = Area;
|
65
|
+
|
66
|
+
export { AreaChart };
|
67
|
+
//# sourceMappingURL=AreaChart.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"AreaChart.js","sources":["../../../../../../../../src/charts/components/Area/AreaChart.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport * as Recharts from 'recharts';\n\nimport { Color, getThemeColor } from '../../utils/color';\nimport {\n CommonChartProps,\n getCartesianGridProps,\n getXAxisProps,\n getYAxisProps,\n getLegendProps,\n getTooltipProps,\n} from '../../utils/common';\nimport { ResponsiveContainer } from '../ResponsiveContainer';\nimport { ActiveChartItems, PayloadType } from '../types';\n\ntype AreaChartBarProps<TType> = {\n accessor: keyof TType & string;\n color?: Color;\n label?: string;\n stackId?: string;\n};\n\nconst Area = (_: AreaChartBarProps<any>) => null;\n\ntype AreaChartProps<TType> = CommonChartProps<TType> & {\n children: React.ReactElement<AreaChartBarProps<TType>> | React.ReactElement<AreaChartBarProps<TType>>[];\n data: TType[];\n formatter?: (value: any) => string;\n};\n\nexport const AreaChart = function AreaChart<TType = unknown>(externalProps: AreaChartProps<TType>) {\n const { children, data, formatter, ...props } = externalProps;\n const [hoveredArea, setHoveredArea] = useState<(keyof TType & string) | null>(null);\n const [activeAreas, setActiveAreas] = useState<ActiveChartItems<TType>>(() => {\n const areas = {} as ActiveChartItems<TType>;\n\n React.Children.forEach(children, child => {\n areas[child.props.accessor] = true;\n });\n\n return areas;\n });\n\n const handleLegendClick = (entry: PayloadType<TType>): void => {\n setHoveredArea(null);\n setActiveAreas({ ...activeAreas, [entry.dataKey]: !activeAreas[entry.dataKey] });\n };\n\n return (\n <ResponsiveContainer>\n <Recharts.AreaChart data={data} margin={{ top: 10, right: 0, left: -25, bottom: 0 }}>\n <Recharts.CartesianGrid {...getCartesianGridProps()} />\n <Recharts.XAxis {...getXAxisProps<TType>(props)} />\n <Recharts.YAxis {...getYAxisProps<TType>(props)} />\n <Recharts.Legend\n {...getLegendProps({\n onClick: handleLegendClick,\n onMouseEnter: entry => setHoveredArea(entry.dataKey),\n onMouseLeave: () => setHoveredArea(null),\n activeItems: activeAreas,\n })}\n />\n <Recharts.Tooltip {...getTooltipProps()} formatter={formatter} />\n {React.Children.map(children, child => (\n <Recharts.Area\n activeDot={{\n fill: getThemeColor(child.props.color ?? 'blue-300'),\n }}\n isAnimationActive={false}\n dataKey={child.props.accessor}\n dot={false}\n fill={getThemeColor(child.props.color ?? 'grey-100')}\n name={child.props.label}\n strokeWidth={2}\n stroke={getThemeColor(child.props.color ?? 'grey-300')}\n stackId={child.props.stackId}\n hide={!activeAreas[child.props.accessor]}\n opacity={hoveredArea && child.props.accessor !== hoveredArea ? 0.3 : 1}\n />\n ))}\n </Recharts.AreaChart>\n </ResponsiveContainer>\n );\n};\nAreaChart.Area = Area;\n"],"names":["Area","_","AreaChart","externalProps","children","data","formatter","props","hoveredArea","setHoveredArea","useState","activeAreas","setActiveAreas","areas","React","Children","forEach","child","accessor","handleLegendClick","entry","dataKey","ResponsiveContainer","Recharts","margin","top","right","left","bottom","getCartesianGridProps","getXAxisProps","getYAxisProps","getLegendProps","onClick","onMouseEnter","onMouseLeave","activeItems","getTooltipProps","map","_child$props$color","_child$props$color2","_child$props$color3","activeDot","fill","getThemeColor","color","isAnimationActive","dot","name","label","strokeWidth","stroke","stackId","hide","opacity"],"mappings":";;;;;;AAsBA,MAAMA,IAAI,GAAIC,CAAyB,IAAK,IAAI;MAQnCC,SAAS,GAAG,SAASA,SAASA,CAAkBC,aAAoC;EAC7F,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,SAAS;IAAE,GAAGC;GAAO,GAAGJ,aAAa;EAC7D,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGC,QAAQ,CAAgC,IAAI,CAAC;EACnF,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGF,QAAQ,CAA0B;IACpE,MAAMG,KAAK,GAAG,EAA6B;IAE3CC,cAAK,CAACC,QAAQ,CAACC,OAAO,CAACZ,QAAQ,EAAEa,KAAK;MAClCJ,KAAK,CAACI,KAAK,CAACV,KAAK,CAACW,QAAQ,CAAC,GAAG,IAAI;KACrC,CAAC;IAEF,OAAOL,KAAK;GACf,CAAC;EAEF,MAAMM,iBAAiB,GAAIC,KAAyB;IAChDX,cAAc,CAAC,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AI,EAAEC,aAAa,EAAAJ,mBAAA,GAACvB,KAAK,CAACV,KAAK,CAACsC,KAAK,cAAAL,mBAAA,cAAAA,mBAAA,GAAI,UAAU,CAAC;MACpDQ,IAAI,EAAE/B,KAAK,CAACV,KAAK,CAAC0C,KAAK;MACvBC,WAAW,EAAE,CAAC;MACdC,MAAM,EAAEP,aAAa,EAAAH,mBAAA,GAACxB,KAAK,CAACV,KAAK,CAACsC,KAAK,cAAAJ,mBAAA,cAAAA,mBAAA,GAAI,UAAU,CAAC;MACtDW,OAAO,EAAEnC,KAAK,CAACV,KAAK,CAAC6C,OAAO;MAC5BC,IAAI,EAAE,CAAC1C,WAAW,CAACM,KAAK,CAACV,KAAK,CAACW,QAAQ,CAAC;MACxCoC,OAAO,EAAE9C,WAAW,IAAIS,KAAK,CAACV,KAAK,CAACW,QAAQ,KAAKV,WAAW,GAAG,GAAG,GAAG;MACvE;GACL,CAAC,CACe,CACH;AAE9B;AACAN,SAAS,CAACF,IAAI,GAAGA,IAAI;;;;"}
|
@@ -0,0 +1,120 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Legend, Tooltip, Bar as Bar$1, Cell } from 'recharts';
|
3
|
+
import { getThemeColor } from '../../utils/color.js';
|
4
|
+
import { getCartesianGridProps, getXAxisProps, getYAxisProps, getLegendProps, getTooltipProps } from '../../utils/common.js';
|
5
|
+
import { ResponsiveContainer } from '../ResponsiveContainer.js';
|
6
|
+
|
7
|
+
const Bar = _ => null;
|
8
|
+
const getXAxisVerticalProps = props => ({
|
9
|
+
...getXAxisProps(props),
|
10
|
+
...{
|
11
|
+
type: 'number',
|
12
|
+
dataKey: undefined
|
13
|
+
}
|
14
|
+
});
|
15
|
+
const getYAxisVerticalProps = props => ({
|
16
|
+
...getYAxisProps(props),
|
17
|
+
...{
|
18
|
+
dataKey: props.accessor,
|
19
|
+
type: 'category'
|
20
|
+
}
|
21
|
+
});
|
22
|
+
const BarChart = function BarChart(externalProps) {
|
23
|
+
const {
|
24
|
+
children,
|
25
|
+
data,
|
26
|
+
formatter,
|
27
|
+
layout = 'horizontal',
|
28
|
+
...props
|
29
|
+
} = externalProps;
|
30
|
+
const [activeIndex, setActiveIndex] = React__default.useState(undefined);
|
31
|
+
const [hoveredBar, setHoveredBar] = React__default.useState(null);
|
32
|
+
const [activeBars, setActiveBars] = React__default.useState(() => {
|
33
|
+
const keys = {};
|
34
|
+
React__default.Children.forEach(children, child => {
|
35
|
+
keys[child.props.accessor] = true;
|
36
|
+
});
|
37
|
+
return keys;
|
38
|
+
});
|
39
|
+
// Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,
|
40
|
+
// so we can't set proper radiuses without some "magic"
|
41
|
+
const stacks = {};
|
42
|
+
React__default.Children.forEach(children, child => {
|
43
|
+
if (child.props.stackId) {
|
44
|
+
if (!stacks[child.props.stackId]) {
|
45
|
+
stacks[child.props.stackId] = [child.props.accessor];
|
46
|
+
} else {
|
47
|
+
stacks[child.props.stackId].push(child.props.accessor);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
});
|
51
|
+
const handleLegendClick = entry => {
|
52
|
+
setHoveredBar(null);
|
53
|
+
setActiveBars({
|
54
|
+
...activeBars,
|
55
|
+
[entry.dataKey]: !activeBars[entry.dataKey]
|
56
|
+
});
|
57
|
+
};
|
58
|
+
const handleLegendHover = (entry, index) => {
|
59
|
+
setHoveredBar(entry.dataKey);
|
60
|
+
setActiveIndex(index);
|
61
|
+
};
|
62
|
+
return /*#__PURE__*/React__default.createElement(ResponsiveContainer, null, /*#__PURE__*/React__default.createElement(BarChart$1, {
|
63
|
+
layout: layout,
|
64
|
+
data: data,
|
65
|
+
margin: {
|
66
|
+
top: 10,
|
67
|
+
right: 0,
|
68
|
+
left: layout === 'vertical' ? 0 : -25,
|
69
|
+
bottom: 0
|
70
|
+
},
|
71
|
+
onMouseMove: chartState => setActiveIndex(chartState.activeTooltipIndex),
|
72
|
+
onMouseLeave: () => setActiveIndex(undefined)
|
73
|
+
}, /*#__PURE__*/React__default.createElement(CartesianGrid, Object.assign({}, getCartesianGridProps())), /*#__PURE__*/React__default.createElement(XAxis, Object.assign({}, layout === 'vertical' ? getXAxisVerticalProps(props) : getXAxisProps(props))), /*#__PURE__*/React__default.createElement(YAxis, Object.assign({}, layout === 'vertical' ? getYAxisVerticalProps(props) : getYAxisProps(props))), /*#__PURE__*/React__default.createElement(Legend, Object.assign({}, getLegendProps({
|
74
|
+
onClick: handleLegendClick,
|
75
|
+
onMouseEnter: handleLegendHover,
|
76
|
+
onMouseLeave: () => setHoveredBar(null),
|
77
|
+
activeItems: activeBars
|
78
|
+
}))), /*#__PURE__*/React__default.createElement(Tooltip, Object.assign({}, getTooltipProps(), {
|
79
|
+
formatter: formatter
|
80
|
+
})), React__default.Children.map(children, child => (/*#__PURE__*/React__default.createElement(Bar$1, {
|
81
|
+
isAnimationActive: false,
|
82
|
+
barSize: 16,
|
83
|
+
dataKey: child.props.accessor,
|
84
|
+
name: child.props.label,
|
85
|
+
onMouseEnter: (_, index) => setActiveIndex(index),
|
86
|
+
onMouseLeave: () => setActiveIndex(undefined),
|
87
|
+
fill: getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`),
|
88
|
+
radius: getBarRadius(stacks, child.props.accessor, child.props.stackId, activeBars),
|
89
|
+
stackId: child.props.stackId,
|
90
|
+
style: child.props.stackId ? {
|
91
|
+
stroke: '#fff',
|
92
|
+
strokeWidth: '2px'
|
93
|
+
} : undefined,
|
94
|
+
hide: !activeBars[child.props.accessor]
|
95
|
+
}, data.map((_, index) => (/*#__PURE__*/React__default.createElement(Cell, {
|
96
|
+
key: `cell-${index}`,
|
97
|
+
opacity: hoveredBar && child.props.accessor !== hoveredBar || activeIndex !== undefined && activeIndex !== index ? 0.3 : 1
|
98
|
+
}))))))));
|
99
|
+
};
|
100
|
+
BarChart.Bar = Bar;
|
101
|
+
const getBarRadius = (stacks, accessor, stackId, activeBars) => {
|
102
|
+
if (stackId && Array.isArray(stacks[stackId])) {
|
103
|
+
const length = stacks[stackId].length - 1;
|
104
|
+
const index = stacks[stackId].indexOf(accessor);
|
105
|
+
if (Object.entries(activeBars).filter(item => item[0] !== accessor).every(item => !item[1])) {
|
106
|
+
return [3, 3, 0, 0];
|
107
|
+
}
|
108
|
+
if (activeBars[stacks[stackId][index + 1]] === false) {
|
109
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];
|
110
|
+
}
|
111
|
+
if (index !== 0 && index !== length) {
|
112
|
+
return 0;
|
113
|
+
}
|
114
|
+
return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];
|
115
|
+
}
|
116
|
+
return 3;
|
117
|
+
};
|
118
|
+
|
119
|
+
export { BarChart };
|
120
|
+
//# sourceMappingURL=BarChart.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"BarChart.js","sources":["../../../../../../../../src/charts/components/Bar/BarChart.tsx"],"sourcesContent":["import React from 'react';\nimport * as Recharts from 'recharts';\n\nimport { Color, getThemeColor } from '../../utils/color';\nimport {\n CommonChartProps,\n getCartesianGridProps,\n getXAxisProps,\n getYAxisProps,\n getLegendProps,\n getTooltipProps,\n} from '../../utils/common';\nimport { ResponsiveContainer } from '../ResponsiveContainer';\nimport { ActiveChartItems, PayloadType } from '../types';\n\ntype StacksType<TType> = Record<string, Array<keyof TType & string>>;\n\ntype BarChartBarProps<TType> = {\n accessor: keyof TType & string;\n color?: Color;\n label?: string;\n stackId?: string;\n};\n\nconst Bar = (_: BarChartBarProps<any>) => null;\n\ntype BarChartProps<TType> = CommonChartProps<TType> & {\n children: React.ReactElement<BarChartBarProps<TType>> | React.ReactElement<BarChartBarProps<TType>>[];\n data: TType[];\n formatter?: (value: any) => string;\n layout?: 'horizontal' | 'vertical';\n};\n\nconst getXAxisVerticalProps = <TType,>(props: CommonChartProps<TType>) => ({\n ...getXAxisProps<TType>(props),\n ...{ type: 'number' as const, dataKey: undefined },\n});\n\nconst getYAxisVerticalProps = <TType,>(props: CommonChartProps<TType>) => ({\n ...getYAxisProps<TType>(props),\n ...{ dataKey: props.accessor, type: 'category' as const },\n});\n\nexport const BarChart = function BarChart<TType = unknown>(externalProps: BarChartProps<TType>) {\n const { children, data, formatter, layout = 'horizontal', ...props } = externalProps;\n const [activeIndex, setActiveIndex] = React.useState<number | undefined>(undefined);\n const [hoveredBar, setHoveredBar] = React.useState<(keyof TType & string) | null>(null);\n const [activeBars, setActiveBars] = React.useState<ActiveChartItems<TType>>(() => {\n const keys = {} as ActiveChartItems<TType>;\n\n React.Children.forEach(children, child => {\n keys[child.props.accessor] = true;\n });\n\n return keys;\n });\n\n // Recharts doesn't provide a way for us to know if a stacked bar is at the top or the bottom,\n // so we can't set proper radiuses without some \"magic\"\n const stacks = {} as StacksType<TType>;\n\n React.Children.forEach(children, child => {\n if (child.props.stackId) {\n if (!stacks[child.props.stackId]) {\n stacks[child.props.stackId] = [child.props.accessor];\n } else {\n stacks[child.props.stackId].push(child.props.accessor);\n }\n }\n });\n\n const handleLegendClick = (entry: PayloadType<TType>): void => {\n setHoveredBar(null);\n setActiveBars({ ...activeBars, [entry.dataKey]: !activeBars[entry.dataKey] });\n };\n\n const handleLegendHover = (entry: PayloadType<TType>, index: number): void => {\n setHoveredBar(entry.dataKey);\n setActiveIndex(index);\n };\n\n return (\n <ResponsiveContainer>\n <Recharts.BarChart\n layout={layout}\n data={data}\n margin={{ top: 10, right: 0, left: layout === 'vertical' ? 0 : -25, bottom: 0 }}\n onMouseMove={chartState => setActiveIndex(chartState.activeTooltipIndex)}\n onMouseLeave={() => setActiveIndex(undefined)}>\n <Recharts.CartesianGrid {...getCartesianGridProps()} />\n <Recharts.XAxis\n {...(layout === 'vertical' ? getXAxisVerticalProps<TType>(props) : getXAxisProps<TType>(props))}\n />\n <Recharts.YAxis\n {...(layout === 'vertical' ? getYAxisVerticalProps<TType>(props) : getYAxisProps<TType>(props))}\n />\n <Recharts.Legend\n {...getLegendProps({\n onClick: handleLegendClick,\n onMouseEnter: handleLegendHover,\n onMouseLeave: () => setHoveredBar(null),\n activeItems: activeBars,\n })}\n />\n <Recharts.Tooltip {...getTooltipProps()} formatter={formatter} />\n {React.Children.map(children, child => (\n <Recharts.Bar\n isAnimationActive={false}\n barSize={16}\n dataKey={child.props.accessor}\n name={child.props.label}\n onMouseEnter={(_, index) => setActiveIndex(index)}\n onMouseLeave={() => setActiveIndex(undefined)}\n fill={getThemeColor(child.props.color ? `${child.props.color}` : `blue-300`)}\n radius={getBarRadius<TType>(stacks, child.props.accessor, child.props.stackId, activeBars)}\n stackId={child.props.stackId}\n style={child.props.stackId ? { stroke: '#fff', strokeWidth: '2px' } : undefined}\n hide={!activeBars[child.props.accessor]}>\n {data.map((_, index) => (\n <Recharts.Cell\n key={`cell-${index}`}\n opacity={\n (hoveredBar && child.props.accessor !== hoveredBar) ||\n (activeIndex !== undefined && activeIndex !== index)\n ? 0.3\n : 1\n }\n />\n ))}\n </Recharts.Bar>\n ))}\n </Recharts.BarChart>\n </ResponsiveContainer>\n );\n};\nBarChart.Bar = Bar;\n\nconst getBarRadius = <TType,>(\n stacks: StacksType<TType>,\n accessor: keyof TType & string,\n stackId: string | undefined,\n activeBars: ActiveChartItems<TType>\n): number | [number, number, number, number] => {\n if (stackId && Array.isArray(stacks[stackId])) {\n const length = stacks[stackId].length - 1;\n const index: number = stacks[stackId].indexOf(accessor);\n\n if (\n Object.entries(activeBars)\n .filter(item => item[0] !== accessor)\n .every(item => !item[1])\n ) {\n return [3, 3, 0, 0];\n }\n\n if (activeBars[stacks[stackId][index + 1]] === false) {\n return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length - 1 ? 0 : 3, index === length - 1 ? 0 : 3];\n }\n\n if (index !== 0 && index !== length) {\n return 0;\n }\n\n return [index === 0 ? 0 : 3, index === 0 ? 0 : 3, index === length ? 0 : 3, index === length ? 0 : 3];\n }\n\n return 3;\n};\n"],"names":["Bar","_","getXAxisVerticalProps","props","getXAxisProps","type","dataKey","undefined","getYAxisVerticalProps","getYAxisProps","accessor","BarChart","externalProps","children","data","formatter","layout","activeIndex","setActiveIndex","React","useState","hoveredBar","setHoveredBar","activeBars","setActiveBars","keys","Children","forEach","child","stacks","stackId","push","handleLegendClick","entry","handleLegendHover","index","ResponsiveContainer","Recharts","margin","top","right","left","bottom","onMouseMove","chartState","activeTooltipIndex","onMouseLeave","getCartesianGridProps","getLegendProps","onClick","onMouseEnter","activeItems","getTooltipProps","map","isAnimationActive","barSize","name","label","fill","getThemeColor","color","radius","getBarRadius","style","stroke","strokeWidth","hide","key","opacity","Array","isArray","length","indexOf","Object","entries","filter","item","every"],"mappings":";;;;;;AAwBA,MAAMA,GAAG,GAAIC,CAAwB,IAAK,IAAI;AAS9C,MAAMC,qBAAqB,GAAYC,KAA8B,KAAM;EACvE,GAAGC,aAAa,CAAQD,KAAK,CAAC;EAC9B,GAAG;IAAEE,IAAI,EAAE,QAAiB;IAAEC,OAAO,EAAEC;;CAC1C,CAAC;AAEF,MAAMC,qBAAqB,GAAYL,KAA8B,KAAM;EACvE,GAAGM,aAAa,CAAQN,KAAK,CAAC;EAC9B,GAAG;IAAEG,OAAO,EAAEH,KAAK,CAACO,QAAQ;IAAEL,IAAI,EAAE;;CACvC,CAAC;MAEWM,QAAQ,GAAG,SAASA,QAAQA,CAAkBC,aAAmC;EAC1F,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM,GAAG,YAAY;IAAE,GAAGb;GAAO,GAAGS,aAAa;EACpF,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAqBb,SAAS,CAAC;EACnF,MAAM,CAACc,UAAU,EAAEC,aAAa,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAgC,IAAI,CAAC;EACvF,MAAM,CAACG,UAAU,EAAEC,aAAa,CAAC,GA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D,MAAM,CAACC,OAAO,CAACnD,UAAU,CAAC,CACrBoD,MAAM,CAACC,IAAI,IAAIA,IAAI,CAAC,CAAC,CAAC,KAAKlE,QAAQ,CAAC,CACpCmE,KAAK,CAACD,IAAI,IAAI,CAACA,IAAI,CAAC,CAAC,CAAC,CAAC,EAC9B;MACE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;;IAGvB,IAAIrD,UAAU,CAACM,MAAM,CAACC,OAAO,CAAC,CAACK,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE;MAClD,OAAO,CAACA,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEA,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEA,KAAK,KAAKoC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEpC,KAAK,KAAKoC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;;IAGjH,IAAIpC,KAAK,KAAK,CAAC,IAAIA,KAAK,KAAKoC,MAAM,EAAE;MACjC,OAAO,CAAC;;IAGZ,OAAO,CAACpC,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEA,KAAK,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAEA,KAAK,KAAKoC,MAAM,GAAG,CAAC,GAAG,CAAC,EAAEpC,KAAK,KAAKoC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC;;EAGzG,OAAO,CAAC;AACZ,CAAC;;;;"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import cn from 'clsx';
|
3
|
+
import { Sector } from 'recharts';
|
4
|
+
import { getThemeColor } from '../../utils/color.js';
|
5
|
+
import { HOVER_DONUT_WIDTH } from './util.js';
|
6
|
+
|
7
|
+
const ActiveShape = props => {
|
8
|
+
var _getThemeColor;
|
9
|
+
const {
|
10
|
+
cx,
|
11
|
+
cy,
|
12
|
+
id,
|
13
|
+
innerRadius,
|
14
|
+
onClick,
|
15
|
+
outerRadius = 0,
|
16
|
+
pieColors,
|
17
|
+
startAngle,
|
18
|
+
endAngle,
|
19
|
+
fill
|
20
|
+
} = props;
|
21
|
+
return /*#__PURE__*/React__default.createElement("g", {
|
22
|
+
onClick: () => onClick(id),
|
23
|
+
className: cn({
|
24
|
+
'cursor-pointer': !!onClick
|
25
|
+
})
|
26
|
+
}, /*#__PURE__*/React__default.createElement(Sector, {
|
27
|
+
cx: cx,
|
28
|
+
cy: cy,
|
29
|
+
innerRadius: innerRadius,
|
30
|
+
outerRadius: outerRadius,
|
31
|
+
startAngle: startAngle,
|
32
|
+
endAngle: endAngle,
|
33
|
+
fill: fill
|
34
|
+
}), /*#__PURE__*/React__default.createElement(Sector, {
|
35
|
+
cx: cx,
|
36
|
+
cy: cy,
|
37
|
+
startAngle: startAngle,
|
38
|
+
endAngle: endAngle,
|
39
|
+
innerRadius: outerRadius + 2,
|
40
|
+
outerRadius: outerRadius + HOVER_DONUT_WIDTH,
|
41
|
+
fill: id !== undefined ? (_getThemeColor = getThemeColor(pieColors[id])) !== null && _getThemeColor !== void 0 ? _getThemeColor : getThemeColor('blue-500') : getThemeColor('blue-500'),
|
42
|
+
opacity: 0.3
|
43
|
+
}));
|
44
|
+
};
|
45
|
+
|
46
|
+
export { ActiveShape };
|
47
|
+
//# sourceMappingURL=ActiveShape.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ActiveShape.js","sources":["../../../../../../../../src/charts/components/Donut/ActiveShape.tsx"],"sourcesContent":["import React from 'react';\nimport * as Recharts from 'recharts';\nimport cn from 'clsx';\n\nimport { getThemeColor } from '../../utils/color';\nimport { PieSectorDataItem } from 'recharts/types/polar/Pie';\nimport { HOVER_DONUT_WIDTH } from './util';\n\ntype ActiveShapeProps = Omit<PieSectorDataItem, 'onClick'> & {\n onClick: (id: string | undefined) => void;\n pieColors: Record<string, string>;\n};\n\nexport const ActiveShape = (props: ActiveShapeProps) => {\n const { cx, cy, id, innerRadius, onClick, outerRadius = 0, pieColors, startAngle, endAngle, fill } = props;\n\n return (\n <g onClick={() => onClick(id)} className={cn({ 'cursor-pointer': !!onClick })}>\n <Recharts.Sector\n cx={cx}\n cy={cy}\n innerRadius={innerRadius}\n outerRadius={outerRadius}\n startAngle={startAngle}\n endAngle={endAngle}\n fill={fill}\n />\n <Recharts.Sector\n cx={cx}\n cy={cy}\n startAngle={startAngle}\n endAngle={endAngle}\n innerRadius={outerRadius + 2}\n outerRadius={outerRadius + HOVER_DONUT_WIDTH}\n fill={id !== undefined ? getThemeColor(pieColors[id]) ?? getThemeColor('blue-500') : getThemeColor('blue-500')}\n opacity={0.3}\n />\n </g>\n );\n};\n"],"names":["ActiveShape","props","cx","cy","id","innerRadius","onClick","outerRadius","pieColors","startAngle","endAngle","fill","React","className","cn","Recharts","HOVER_DONUT_WIDTH","undefined","_getThemeColor","getThemeColor","opacity"],"mappings":";;;;;;MAaaA,WAAW,GAAIC,KAAuB;;EAC/C,MAAM;IAAEC,EAAE;IAAEC,EAAE;IAAEC,EAAE;IAAEC,WAAW;IAAEC,OAAO;IAAEC,WAAW,GAAG,CAAC;IAAEC,SAAS;IAAEC,UAAU;IAAEC,QAAQ;IAAEC;GAAM,GAAGV,KAAK;EAE1G,oBACIW;IAAGN,OAAO,EAAEA,MAAMA,OAAO,CAACF,EAAE,CAAC;IAAES,SAAS,EAAEC,EAAE,CAAC;MAAE,gBAAgB,EAAE,CAAC,CAACR;KAAS;kBACxEM,6BAACG,MAAe;IACZb,EAAE,EAAEA,EAAE;IACNC,EAAE,EAAEA,EAAE;IACNE,WAAW,EAAEA,WAAW;IACxBE,WAAW,EAAEA,WAAW;IACxBE,UAAU,EAAEA,UAAU;IACtBC,QAAQ,EAAEA,QAAQ;IAClBC,IAAI,EAAEA;IACR,eACFC,6BAACG,MAAe;IACZb,EAAE,EAAEA,EAAE;IACNC,EAAE,EAAEA,EAAE;IACNM,UAAU,EAAEA,UAAU;IACtBC,QAAQ,EAAEA,QAAQ;IAClBL,WAAW,EAAEE,WAAW,GAAG,CAAC;IAC5BA,WAAW,EAAEA,WAAW,GAAGS,iBAAiB;IAC5CL,IAAI,EAAEP,EAAE,KAAKa,SAAS,IAAAC,cAAA,GAAGC,aAAa,CAACX,SAAS,CAACJ,EAAE,CAAC,CAAC,cAAAc,cAAA,cAAAA,cAAA,GAAIC,aAAa,CAAC,UAAU,CAAC,GAAGA,aAAa,CAAC,UAAU,CAAC;IAC9GC,OAAO,EAAE;IACX,CACF;AAEZ;;;;"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import { HOVER_DONUT_WIDTH, DONUT_WIDTH } from './util.js';
|
3
|
+
|
4
|
+
const CenteredLabel = ({
|
5
|
+
radius,
|
6
|
+
legendPosition,
|
7
|
+
label,
|
8
|
+
total,
|
9
|
+
formatter,
|
10
|
+
showLegend
|
11
|
+
}) => {
|
12
|
+
const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;
|
13
|
+
const diameter = radius * 2;
|
14
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
15
|
+
className: "absolute mt-1 flex h-12 flex-col text-center",
|
16
|
+
style: {
|
17
|
+
top: `calc(${radius}px - (3rem / 2))`,
|
18
|
+
left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,
|
19
|
+
width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`
|
20
|
+
}
|
21
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
22
|
+
className: "w-full truncate text-lg font-bold"
|
23
|
+
}, formatter ? formatter(total) : total), label);
|
24
|
+
};
|
25
|
+
|
26
|
+
export { CenteredLabel };
|
27
|
+
//# sourceMappingURL=CenteredLabel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CenteredLabel.js","sources":["../../../../../../../../src/charts/components/Donut/CenteredLabel.tsx"],"sourcesContent":["import React from 'react';\nimport { HOVER_DONUT_WIDTH, DONUT_WIDTH } from './util';\n\ntype CenteredLabelProps = {\n radius: number;\n legendPosition: string;\n label: string;\n total: number;\n formatter: ((value: number) => string) | undefined;\n showLegend: boolean;\n};\n\nexport const CenteredLabel = ({ radius, legendPosition, label, total, formatter, showLegend }: CenteredLabelProps) => {\n const totalInset = HOVER_DONUT_WIDTH + DONUT_WIDTH + DONUT_WIDTH;\n const diameter = radius * 2;\n\n return (\n <div\n className=\"absolute mt-1 flex h-12 flex-col text-center\"\n style={{\n top: `calc(${radius}px - (3rem / 2))`, // h-12 is 3rem\n left: legendPosition === 'right' ? `${totalInset}px` : `calc(50%-${diameter - 2 * totalInset})`,\n width: showLegend ? `${diameter - 2 * totalInset}px` : `${diameter}px`,\n }}>\n <span className=\"w-full truncate text-lg font-bold\">{formatter ? formatter(total) : total}</span>\n {label}\n </div>\n );\n};\n"],"names":["CenteredLabel","radius","legendPosition","label","total","formatter","showLegend","totalInset","HOVER_DONUT_WIDTH","DONUT_WIDTH","diameter","React","className","style","top","left","width"],"mappings":";;;MAYaA,aAAa,GAAGA,CAAC;EAAEC,MAAM;EAAEC,cAAc;EAAEC,KAAK;EAAEC,KAAK;EAAEC,SAAS;EAAEC;CAAgC;EAC7G,MAAMC,UAAU,GAAGC,iBAAiB,GAAGC,WAAW,GAAGA,WAAW;EAChE,MAAMC,QAAQ,GAAGT,MAAM,GAAG,CAAC;EAE3B,oBACIU;IACIC,SAAS,EAAC,8CAA8C;IACxDC,KAAK,EAAE;MACHC,GAAG,EAAE,QAAQb,MAAM,kBAAkB;MACrCc,IAAI,EAAEb,cAAc,KAAK,OAAO,GAAG,GAAGK,UAAU,IAAI,GAAG,YAAYG,QAAQ,GAAG,CAAC,GAAGH,UAAU,GAAG;MAC/FS,KAAK,EAAEV,UAAU,GAAG,GAAGI,QAAQ,GAAG,CAAC,GAAGH,UAAU,IAAI,GAAG,GAAGG,QAAQ;;kBAEtEC;IAAMC,SAAS,EAAC;KAAqCP,SAAS,GAAGA,SAAS,CAACD,KAAK,CAAC,GAAGA,KAAK,CAAQ,EAChGD,KAAK,CACJ;AAEd;;;;"}
|