This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
103 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 19 additions & 20 deletions
39
packages/superset-ui-preset-chart-xy/src/components/legend/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import { Value } from 'vega-lite/build/src/channeldef'; | ||
import { CSSProperties } from 'react'; | ||
import { ObjectWithKeysFromAndValueType } from '../../encodeable/types/Base'; | ||
import { ChannelInput } from '../../encodeable/types/Channel'; | ||
|
||
export type LegendItemInfo<ChannelTypes> = { | ||
export type LegendItemInfo<Encoding> = { | ||
field: string; | ||
value: ChannelInput; | ||
encodedValues: Partial<ObjectWithKeysFromAndValueType<ChannelTypes, Value | undefined>>; | ||
encodedValues: Partial<Record<keyof Encoding, Value | undefined>>; | ||
}; | ||
|
||
export type LegendItemMarkRendererType<ChannelTypes> = React.ComponentType<{ | ||
item: LegendItemInfo<ChannelTypes>; | ||
export type LegendItemMarkRendererType<Encoding> = React.ComponentType<{ | ||
item: LegendItemInfo<Encoding>; | ||
}>; | ||
|
||
export type LegendItemLabelRendererType<ChannelTypes> = React.ComponentType<{ | ||
item: LegendItemInfo<ChannelTypes>; | ||
export type LegendItemLabelRendererType<Encoding> = React.ComponentType<{ | ||
item: LegendItemInfo<Encoding>; | ||
}>; | ||
|
||
export type LegendItemRendererProps<ChannelTypes> = { | ||
item: LegendItemInfo<ChannelTypes>; | ||
MarkRenderer?: LegendItemMarkRendererType<ChannelTypes>; | ||
LabelRenderer?: LegendItemLabelRendererType<ChannelTypes>; | ||
export type LegendItemRendererProps<Encoding> = { | ||
item: LegendItemInfo<Encoding>; | ||
MarkRenderer?: LegendItemMarkRendererType<Encoding>; | ||
LabelRenderer?: LegendItemLabelRendererType<Encoding>; | ||
}; | ||
|
||
export type LegendItemRendererType<ChannelTypes> = React.ComponentType< | ||
LegendItemRendererProps<ChannelTypes> | ||
export type LegendItemRendererType<Encoding> = React.ComponentType< | ||
LegendItemRendererProps<Encoding> | ||
>; | ||
|
||
export type LegendGroupRendererProps<ChannelTypes> = { | ||
items: LegendItemInfo<ChannelTypes>[]; | ||
ItemRenderer?: LegendItemRendererType<ChannelTypes>; | ||
ItemMarkRenderer?: LegendItemMarkRendererType<ChannelTypes>; | ||
ItemLabelRenderer?: LegendItemLabelRendererType<ChannelTypes>; | ||
export type LegendGroupRendererProps<Encoding> = { | ||
items: LegendItemInfo<Encoding>[]; | ||
ItemRenderer?: LegendItemRendererType<Encoding>; | ||
ItemMarkRenderer?: LegendItemMarkRendererType<Encoding>; | ||
ItemLabelRenderer?: LegendItemLabelRendererType<Encoding>; | ||
style?: CSSProperties; | ||
}; | ||
|
||
export type LegendGroupRendererType<ChannelTypes> = React.ComponentType< | ||
LegendGroupRendererProps<ChannelTypes> | ||
export type LegendGroupRendererType<Encoding> = React.ComponentType< | ||
LegendGroupRendererProps<Encoding> | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/superset-ui-preset-chart-xy/src/encodeable/AxisAgent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/superset-ui-preset-chart-xy/src/encodeable/types/Base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export type ObjectWithKeysFromAndValueType<T extends {}, V> = { [key in keyof T]: V }; | ||
|
||
export type Unarray<T> = T extends Array<infer U> ? U : T; | ||
export type MayBeArray<T> = T | T[]; | ||
|
||
export function isArray<T>(maybeArray: T | T[]): maybeArray is T[] { | ||
return Array.isArray(maybeArray); | ||
} | ||
|
||
export function isNotArray<T>(maybeArray: T | T[]): maybeArray is T { | ||
return !Array.isArray(maybeArray); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters