mirror of
https://github.com/FullScreenShenanigans/UserWrappr.git
synced 2026-08-12 02:18:31 -07:00
Fixed new lint complaints
This commit is contained in:
@@ -2,6 +2,7 @@ import { expect } from "chai";
|
||||
|
||||
import { stubClassNames, stubStyles } from "../fakes.test";
|
||||
import { IAbsoluteSizeSchema } from "../Sizing";
|
||||
|
||||
import { stubAreasFaker, stubContainerSize } from "./fakes.test";
|
||||
|
||||
describe("AreasFaker", () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { stubClassNames, stubStyles } from "../fakes.test";
|
||||
import { IAbsoluteSizeSchema } from "../Sizing";
|
||||
|
||||
import { AreasFaker, IAreasFakerDependencies } from "./AreasFaker";
|
||||
import { createElement } from "./CreateElement";
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { stubWrappingViewDependencies } from "./fakes.test";
|
||||
import { initializeMenus } from "./InitializeMenus";
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { action, observable } from "mobx";
|
||||
|
||||
import { IClassNames } from "../Bootstrapping/ClassNames";
|
||||
import { IStyles } from "../Bootstrapping/Styles";
|
||||
|
||||
import { MenuTitleStore } from "./MenuTitleStore";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IClassNames } from "../Bootstrapping/ClassNames";
|
||||
import { IStyles } from "../Bootstrapping/Styles";
|
||||
import { IAbsoluteSizeSchema } from "../Sizing";
|
||||
|
||||
import { IMenuSchema } from "./MenuSchemas";
|
||||
import { MenuStore } from "./MenuStore";
|
||||
import { OptionsStore } from "./Options/OptionsStore";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { IMultiSelectSchema } from "./OptionSchemas";
|
||||
import { SaveableStore } from "./SaveableStore";
|
||||
|
||||
@observer
|
||||
export class MultiSelectOption extends React.Component<{ store: SaveableStore<IMultiSelectSchema, string[]> }> {
|
||||
export class MultiSelectOption extends React.Component<{ store: SaveableStore<IMultiSelectSchema> }> {
|
||||
public render(): JSX.Element {
|
||||
const { store } = this.props;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { INumberSchema } from "./OptionSchemas";
|
||||
import { SaveableStore } from "./SaveableStore";
|
||||
|
||||
@observer
|
||||
export class NumberOption extends React.Component<{ store: SaveableStore<INumberSchema, number> }> {
|
||||
export class NumberOption extends React.Component<{ store: SaveableStore<INumberSchema> }> {
|
||||
public render(): JSX.Element {
|
||||
const { store } = this.props;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IClassNames } from "../../Bootstrapping/ClassNames";
|
||||
import { IStyles } from "../../Bootstrapping/Styles";
|
||||
|
||||
import { IBasicSchema } from "./OptionSchemas";
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ import { observer } from "mobx-react";
|
||||
import * as React from "react";
|
||||
|
||||
import { MenuTitle } from "../MenuTitle";
|
||||
|
||||
import { ActionOption } from "./ActionOption";
|
||||
import { BooleanOption } from "./BooleanOption";
|
||||
import { MultiSelectOption } from "./MultiSelectOption";
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IClassNames } from "../../Bootstrapping/ClassNames";
|
||||
import { IStyles } from "../../Bootstrapping/Styles";
|
||||
import { IAbsoluteSizeSchema } from "../../Sizing";
|
||||
import { MenuTitleStore } from "../MenuTitleStore";
|
||||
|
||||
import { ActionStore } from "./ActionStore";
|
||||
import { IOptionSchema, OptionType } from "./OptionSchemas";
|
||||
import { IOptionStoreDependencies } from "./OptionStore";
|
||||
@@ -31,11 +32,11 @@ type IOptionStoreCreator<TOptionStore extends IOptionStore> = new (dependencies:
|
||||
*/
|
||||
const optionStoreCreators: IOptionStoreCreators = {
|
||||
[OptionType.Action]: ActionStore as IOptionStoreCreator<ActionStore>,
|
||||
[OptionType.Boolean]: SaveableStore as IOptionStoreCreator<SaveableStore>,
|
||||
[OptionType.MultiSelect]: SaveableStore as IOptionStoreCreator<SaveableStore>,
|
||||
[OptionType.Number]: SaveableStore as IOptionStoreCreator<SaveableStore>,
|
||||
[OptionType.Select]: SaveableStore as IOptionStoreCreator<SaveableStore>,
|
||||
[OptionType.String]: SaveableStore as IOptionStoreCreator<SaveableStore>,
|
||||
[OptionType.Boolean]: SaveableStore,
|
||||
[OptionType.MultiSelect]: SaveableStore,
|
||||
[OptionType.Number]: SaveableStore,
|
||||
[OptionType.Select]: SaveableStore,
|
||||
[OptionType.String]: SaveableStore,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,24 +3,28 @@ import { action, computed, observable } from "mobx";
|
||||
import { ISaveableSchema } from "./OptionSchemas";
|
||||
import { OptionStore } from "./OptionStore";
|
||||
|
||||
export type GetSchemaValue<TSchema> = TSchema extends ISaveableSchema<infer U> ? U : never;
|
||||
|
||||
/**
|
||||
* Store for a state whose value is saved locally.
|
||||
*
|
||||
* @template TSchema Type of the parent option schema.
|
||||
* @template TValue Type of the value.
|
||||
* @template TSchema Type of the parent option schema.
|
||||
*/
|
||||
export class SaveableStore<TSchema extends ISaveableSchema<TValue> = ISaveableSchema<TValue>, TValue = {}> extends OptionStore<TSchema> {
|
||||
export class SaveableStore<
|
||||
TSchema extends ISaveableSchema<any> = ISaveableSchema<unknown>,
|
||||
> extends OptionStore<TSchema> {
|
||||
/**
|
||||
* Current state of the value.
|
||||
*/
|
||||
@observable
|
||||
private currentValue: TValue = this.schema.getInitialValue();
|
||||
private currentValue = this.schema.getInitialValue();
|
||||
|
||||
/**
|
||||
* Gets the current state of the value.
|
||||
*/
|
||||
@computed
|
||||
public get value(): TValue {
|
||||
public get value(): GetSchemaValue<TSchema> {
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
@@ -30,7 +34,7 @@ export class SaveableStore<TSchema extends ISaveableSchema<TValue> = ISaveableSc
|
||||
* @param newValue New state for the value.
|
||||
*/
|
||||
@action
|
||||
public setValue = (newValue: TValue): void => {
|
||||
public setValue = (newValue: GetSchemaValue<TSchema>): void => {
|
||||
const oldValue = this.currentValue;
|
||||
this.currentValue = newValue;
|
||||
this.schema.saveValue(newValue, oldValue);
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ISelectSchema } from "./OptionSchemas";
|
||||
import { SaveableStore } from "./SaveableStore";
|
||||
|
||||
@observer
|
||||
export class SelectOption extends React.Component<{ store: SaveableStore<ISelectSchema, string> }> {
|
||||
export class SelectOption extends React.Component<{ store: SaveableStore<ISelectSchema> }> {
|
||||
public render(): JSX.Element {
|
||||
const { store } = this.props;
|
||||
const selectStyle = {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { IStringSchema } from "./OptionSchemas";
|
||||
import { SaveableStore } from "./SaveableStore";
|
||||
|
||||
@observer
|
||||
export class StringOption extends React.Component<{ store: SaveableStore<IStringSchema, string> }> {
|
||||
export class StringOption extends React.Component<{ store: SaveableStore<IStringSchema> }> {
|
||||
public render(): JSX.Element {
|
||||
const { store } = this.props;
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import { stubClassNames, stubStyles } from "../../fakes.test";
|
||||
|
||||
import { ActionStore } from "./ActionStore";
|
||||
import { OptionType } from "./OptionSchemas";
|
||||
import { SaveableStore } from "./SaveableStore";
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BrowserClock, createClock, LolexClock } from "lolex";
|
||||
|
||||
import { createElement } from "../Bootstrapping/CreateElement";
|
||||
import { stubClassNames, stubStyles } from "../fakes.test";
|
||||
|
||||
import { IWrappingViewDependencies } from "./InitializeMenus";
|
||||
import { IMenuStoreDependencies, MenuStore } from "./MenuStore";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user