Skip to content

Commit 3199570

Browse files
authored
fix(legends): mark data and padding props as optional (#1545)
1 parent 77cbd6a commit 3199570

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

packages/legends/src/types.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ export type Datum = {
6161
}
6262

6363
type CommonLegendProps = {
64+
data?: Datum[]
6465
direction: LegendDirection
65-
padding: number | Record<'top' | 'right' | 'bottom' | 'left', number>
66+
padding?: number | Partial<Record<'top' | 'right' | 'bottom' | 'left', number>>
6667
justify?: boolean
6768

6869
itemWidth: number
@@ -77,8 +78,6 @@ type CommonLegendProps = {
7778
}
7879

7980
export type LegendProps = {
80-
data: Datum[]
81-
8281
translateX?: number
8382
translateY?: number
8483
anchor: LegendAnchor
@@ -89,14 +88,14 @@ export type LegendProps = {
8988
export type BoxLegendSvgProps = {
9089
containerWidth: number
9190
containerHeight: number
92-
} & LegendProps
91+
} & LegendProps &
92+
Required<Pick<LegendProps, 'data'>>
9393

9494
export type LegendSvgProps = {
95-
data: Datum[]
96-
9795
x: number
9896
y: number
9997
} & CommonLegendProps &
98+
Required<Pick<CommonLegendProps, 'data'>> &
10099
BoxLegendSymbolProps &
101100
InteractivityProps
102101

@@ -118,8 +117,6 @@ export type LegendSvgItemProps = {
118117
InteractivityProps
119118

120119
export type LegendCanvasProps = {
121-
data: Datum[]
122-
123120
containerWidth: number
124121
containerHeight: number
125122
translateX?: number
@@ -130,14 +127,15 @@ export type LegendCanvasProps = {
130127
symbolSpacing?: number
131128

132129
theme: CompleteTheme
133-
} & Pick<
134-
CommonLegendProps,
135-
| 'direction'
136-
| 'padding'
137-
| 'justify'
138-
| 'itemsSpacing'
139-
| 'itemWidth'
140-
| 'itemHeight'
141-
| 'itemDirection'
142-
| 'itemTextColor'
143-
>
130+
} & Required<Pick<CommonLegendProps, 'data'>> &
131+
Pick<
132+
CommonLegendProps,
133+
| 'direction'
134+
| 'padding'
135+
| 'justify'
136+
| 'itemsSpacing'
137+
| 'itemWidth'
138+
| 'itemHeight'
139+
| 'itemDirection'
140+
| 'itemTextColor'
141+
>

0 commit comments

Comments
 (0)