Fix some flow errors
This commit is contained in:
parent
9e45e7f398
commit
48e9572925
4 changed files with 24 additions and 22 deletions
|
|
@ -9,6 +9,8 @@ types/types.js
|
||||||
[options]
|
[options]
|
||||||
esproposal.export_star_as=enable
|
esproposal.export_star_as=enable
|
||||||
unsafe.enable_getters_and_setters=true
|
unsafe.enable_getters_and_setters=true
|
||||||
|
module.system.node.resolve_dirname=node_modules
|
||||||
|
module.system.node.resolve_dirname=src
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
all=warn
|
all=warn
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import parseIconName, { controlGetIcon } from "utils/parseIconName";
|
||||||
|
|
||||||
export type Point = [number, number];
|
export type Point = [number, number];
|
||||||
|
|
||||||
const convertPoint = (p: Point) => [-p[1], p[0]];
|
const convertPoint = ([y,x]: Point): Point => [-x, y];
|
||||||
|
|
||||||
export type ControlMapProps = {
|
export type ControlMapProps = {
|
||||||
width: number,
|
width: number,
|
||||||
|
|
@ -20,7 +20,7 @@ export type ControlMapProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class ControlMap extends React.Component<ControlMapProps> {
|
export default class ControlMap extends React.Component<ControlMapProps> {
|
||||||
constructor(props: SpaceMapProps) {
|
constructor(props: ControlMapProps) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,15 +57,15 @@ export default class ControlMap extends React.Component<ControlMapProps> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
iconColor(control: Control) {
|
iconColor(control: Control): string {
|
||||||
if (control.iconColor == null) {
|
if (control.iconColor != null) {
|
||||||
return "#000";
|
return control.iconColor(
|
||||||
|
_.mapValues(this.props.state, (x) => x.internal || x.actual),
|
||||||
|
_.mapValues(this.props.state, (x) => x.actual),
|
||||||
|
this.props.state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return control.iconColor(
|
return "#000";
|
||||||
_.mapValues(this.props.state, (x) => x.internal || x.actual),
|
|
||||||
_.mapValues(this.props.state, (x) => x.actual),
|
|
||||||
this.props.state
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderMarker(control: Control, key: string) {
|
renderMarker(control: Control, key: string) {
|
||||||
|
|
@ -97,7 +97,7 @@ export default class ControlMap extends React.Component<ControlMapProps> {
|
||||||
checked={layer.defaultVisibility === "visible"}>
|
checked={layer.defaultVisibility === "visible"}>
|
||||||
<ImageOverlay url={layer.image}
|
<ImageOverlay url={layer.image}
|
||||||
bounds={Object.values(layer.bounds).map(convertPoint)}
|
bounds={Object.values(layer.bounds).map(convertPoint)}
|
||||||
opacity={layer.opacity} />
|
opacity={layer.opacity || 1} />
|
||||||
</LayersControlType>
|
</LayersControlType>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export const renderIcon = (name: string, extraClass?: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const controlGetIcon = (control: Control, state: State): string => {
|
export const controlGetIcon = (control: Control, state: State): string => {
|
||||||
return !_.isFunction(control.icon) ? control.icon
|
return typeof control.icon !== "function" ? control.icon
|
||||||
: control.icon(
|
: control.icon(
|
||||||
_.mapValues(state, (x) => x.internal || x.actual),
|
_.mapValues(state, (x) => x.internal || x.actual),
|
||||||
_.mapValues(state, (x) => x.actual),
|
_.mapValues(state, (x) => x.actual),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ declare type Topic = {
|
||||||
declare type Topics = Map<string,Topic>;
|
declare type Topics = Map<string,Topic>;
|
||||||
|
|
||||||
declare type ControlUI = {
|
declare type ControlUI = {
|
||||||
type: "toggle" | "dropDown" | "slider" | "section",
|
type: "toggle" | "dropDown" | "slider" | "section" | "link",
|
||||||
text: string,
|
text: string,
|
||||||
topic?: string,
|
topic?: string,
|
||||||
icon?: string,
|
icon?: string,
|
||||||
|
|
@ -66,10 +66,15 @@ declare type Config = {
|
||||||
declare type Space = {
|
declare type Space = {
|
||||||
name: string,
|
name: string,
|
||||||
color: "red"|"pink"|"purple"|"deepPurple"|"indigo"|"blue"|"lightBlue"|"cyan"|"teal"|
|
color: "red"|"pink"|"purple"|"deepPurple"|"indigo"|"blue"|"lightBlue"|"cyan"|"teal"|
|
||||||
"green"|"lightgreen"|"lime"|"yellow"|"amber"|"orange"|"deepOrange"|"brown"|"grey"|"blueGrey"
|
"green"|"lightGreen"|"lime"|"yellow"|"amber"|"orange"|"deepOrange"|"brown"|"grey"|"blueGrey",
|
||||||
|
mqtt: string
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type State = Map<string,any>;
|
declare type StateValue = {
|
||||||
|
internal: string,
|
||||||
|
actual: any
|
||||||
|
};
|
||||||
|
declare type State = Map<string,StateValue>;
|
||||||
|
|
||||||
//declare type State = {
|
//declare type State = {
|
||||||
// mqtt: ?any,
|
// mqtt: ?any,
|
||||||
|
|
@ -89,16 +94,11 @@ declare type Point = [number, number];
|
||||||
declare type Layer = {
|
declare type Layer = {
|
||||||
image: string,
|
image: string,
|
||||||
name: string,
|
name: string,
|
||||||
baseLayer: boolean,
|
baseLayer?: boolean,
|
||||||
defaultVisibility: "visible" | "hidden",
|
defaultVisibility: "visible" | "hidden",
|
||||||
opacity: number,
|
opacity?: number,
|
||||||
bounds: {
|
bounds: {
|
||||||
topLeft: Point,
|
topLeft: Point,
|
||||||
bottomRight: Point
|
bottomRight: Point
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type StateAction = {
|
|
||||||
type: "DISCONNECT" | "CONNECT" | "MESSAGE" | "UI_POPUP",
|
|
||||||
payload?: any
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue