Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pie): use readonly arrays for props as the library does not modif… #2431

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/pie/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useNormalizedData = <RawDatum extends MayHaveLabel>({
Omit<ComputedDatum<RawDatum>, 'arc' | 'color' | 'fill'>
>,
}: Pick<CompletePieSvgProps<RawDatum>, 'id' | 'value' | 'valueFormat' | 'colors'> & {
data: RawDatum[]
data: readonly RawDatum[]
}): Omit<ComputedDatum<RawDatum>, 'arc' | 'fill'>[] => {
const getId = usePropertyAccessor<RawDatum, DatumId>(id)
const getValue = usePropertyAccessor<RawDatum, number>(value)
Expand Down
10 changes: 5 additions & 5 deletions packages/pie/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface ComputedDatum<RawDatum> {
}

export interface DataProps<RawDatum> {
data: RawDatum[]
data: readonly RawDatum[]
}

export interface PieTooltipProps<RawDatum> {
Expand All @@ -73,7 +73,7 @@ export type MouseEventHandler<RawDatum, ElementType = HTMLCanvasElement> = (
export type PieLayerId = 'arcLinkLabels' | 'arcs' | 'arcLabels' | 'legends'

export interface PieCustomLayerProps<RawDatum> {
dataWithArc: ComputedDatum<RawDatum>[]
dataWithArc: readonly ComputedDatum<RawDatum>[]
centerX: number
centerY: number
radius: number
Expand Down Expand Up @@ -114,7 +114,7 @@ export type CommonPieProps<RawDatum> = {
isInteractive: boolean
tooltip: React.FC<PieTooltipProps<RawDatum>>

legends: LegendProps[]
legends: readonly LegendProps[]

role: string
renderWrapper: boolean
Expand All @@ -137,7 +137,7 @@ export type PieSvgProps<RawDatum> = DataProps<RawDatum> &
Partial<CommonPieProps<RawDatum>> &
SvgDefsAndFill<ComputedDatum<RawDatum>> &
PieHandlers<RawDatum, SVGPathElement> & {
layers?: PieLayer<RawDatum>[]
layers?: readonly PieLayer<RawDatum>[]
animate?: boolean
motionConfig?: MotionProps['motionConfig']
transitionMode?: ArcTransitionMode
Expand All @@ -148,7 +148,7 @@ export type CompletePieSvgProps<RawDatum> = DataProps<RawDatum> &
CommonPieProps<RawDatum> &
SvgDefsAndFill<ComputedDatum<RawDatum>> &
PieHandlers<RawDatum, SVGPathElement> & {
layers: PieLayer<RawDatum>[]
layers: readonly PieLayer<RawDatum>[]
animate: boolean
motionConfig: MotionProps['motionConfig']
transitionMode: ArcTransitionMode
Expand Down
Loading