From 103097edbd38581714c32afee7adfca0ddc4feac Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 8 Jan 2020 12:51:19 +0700 Subject: [PATCH] fixed imports --- src/_modules/Sticker.tsx | 4 +- src/components/Cursor.tsx | 2 +- src/components/Fills.tsx | 2 +- src/components/Scroll.tsx | 2 +- src/components/StickerDesc.tsx | 2 +- src/components/StickerIcon.tsx | 2 +- src/components/Switch.tsx | 2 +- src/components/UserLocation.tsx | 2 +- src/components/dialogs/AppInfoDialog.tsx | 2 +- src/components/dialogs/CancelDialog.tsx | 2 +- src/components/dialogs/LogoDialog.tsx | 2 +- src/components/dialogs/MapListDialog.tsx | 276 ++++++++++-------- src/components/dialogs/ProviderDialog.tsx | 2 +- src/components/dialogs/RouterDialog.tsx | 2 +- src/components/dialogs/SaveDialog.tsx | 2 +- src/components/dialogs/ShotPrefetchDialog.tsx | 21 +- src/components/dialogs/StickersDialog.tsx | 2 +- src/components/dialogs/TitleDialog.tsx | 2 +- src/components/dialogs/TrashDialog.tsx | 2 +- src/components/logo/LogoPreview.tsx | 2 +- src/components/maps/RouteRowDrop.tsx | 2 +- src/components/maps/RouteRowEditor.tsx | 2 +- src/components/maps/RouteRowView.tsx | 2 +- src/components/maps/RouteRowWrapper.tsx | 2 +- src/components/panels/DistanceBar.tsx | 4 +- src/components/panels/EditorDialog.tsx | 4 +- src/components/panels/EditorPanel.tsx | 2 +- src/components/panels/Icon.tsx | 2 +- src/components/panels/RendererPanel.tsx | 2 +- src/components/panels/Tooltip.tsx | 2 +- src/components/panels/TopLeftPanel.tsx | 2 +- src/components/panels/TopRightPanel.tsx | 2 +- src/components/panels/UserPanel.tsx | 2 +- src/components/renderer/Renderer.tsx | 4 +- src/components/user/GuestButton.tsx | 2 +- src/components/user/UserButton.tsx | 2 +- src/components/user/UserMenu.tsx | 2 +- src/components/user/UserPicture.tsx | 2 +- src/containers/App.tsx | 46 +-- src/containers/LeftDialog.tsx | 43 +-- src/containers/map/Map/index.tsx | 2 +- src/containers/map/Sticker/index.tsx | 2 +- src/containers/map/Stickers/index.tsx | 2 +- src/containers/map/TileLayer/index.tsx | 2 +- src/index.tsx | 4 +- src/redux/user/selectors.ts | 3 +- src/utils/context.ts | 2 +- src/utils/gpx.ts | 2 +- src/utils/renderer.ts | 2 +- tsconfig.json | 2 + 50 files changed, 260 insertions(+), 229 deletions(-) diff --git a/src/_modules/Sticker.tsx b/src/_modules/Sticker.tsx index ef33651..07133dd 100644 --- a/src/_modules/Sticker.tsx +++ b/src/_modules/Sticker.tsx @@ -1,9 +1,9 @@ import { Map, Marker, marker } from 'leaflet'; -import * as React from 'react'; +import React from 'react'; import { DomMarker } from '$utils/DomMarker'; import { STICKERS } from '$constants/stickers'; -import * as ReactDOM from 'react-dom'; +import ReactDOM from 'react-dom'; import { StickerDesc } from '$components/StickerDesc'; import classnames from 'classnames'; import { getLabelDirection } from '$utils/geom'; diff --git a/src/components/Cursor.tsx b/src/components/Cursor.tsx index eb0afeb..4d1c3e8 100644 --- a/src/components/Cursor.tsx +++ b/src/components/Cursor.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; import { MODES } from '$constants/modes'; import { IStickerPack, STICKERS } from '$constants/stickers'; diff --git a/src/components/Fills.tsx b/src/components/Fills.tsx index 70b511f..b68d6cd 100644 --- a/src/components/Fills.tsx +++ b/src/components/Fills.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; export const Fills = () => ( diff --git a/src/components/Scroll.tsx b/src/components/Scroll.tsx index 97ef45e..79c31f0 100644 --- a/src/components/Scroll.tsx +++ b/src/components/Scroll.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Scrollbars } from 'tt-react-custom-scrollbars'; export const Scroll = props => ( diff --git a/src/components/StickerDesc.tsx b/src/components/StickerDesc.tsx index 835ea52..d2e90db 100644 --- a/src/components/StickerDesc.tsx +++ b/src/components/StickerDesc.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import classnames from 'classnames'; interface Props { diff --git a/src/components/StickerIcon.tsx b/src/components/StickerIcon.tsx index 27e499b..a2c7c2f 100644 --- a/src/components/StickerIcon.tsx +++ b/src/components/StickerIcon.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { STICKERS } from '$constants/stickers'; type Props = { diff --git a/src/components/Switch.tsx b/src/components/Switch.tsx index 9d15685..2ece529 100644 --- a/src/components/Switch.tsx +++ b/src/components/Switch.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from 'react'; +import React from 'react'; import classnames from 'classnames'; type Props = { diff --git a/src/components/UserLocation.tsx b/src/components/UserLocation.tsx index 7dd0e7f..73f96db 100644 --- a/src/components/UserLocation.tsx +++ b/src/components/UserLocation.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; // import { marker } from 'leaflet'; // import { DomMarker } from '$utils/DomMarker'; // import { Icon } from '$components/panels/Icon'; diff --git a/src/components/dialogs/AppInfoDialog.tsx b/src/components/dialogs/AppInfoDialog.tsx index 0363352..65b897b 100644 --- a/src/components/dialogs/AppInfoDialog.tsx +++ b/src/components/dialogs/AppInfoDialog.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from 'react'; +import React from 'react'; import { Scroll } from '$components/Scroll'; import { APP_INFO } from '$constants/app_info'; diff --git a/src/components/dialogs/CancelDialog.tsx b/src/components/dialogs/CancelDialog.tsx index 48f3ed1..393deb6 100644 --- a/src/components/dialogs/CancelDialog.tsx +++ b/src/components/dialogs/CancelDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { MODES } from '$constants/modes'; import { Icon } from '$components/panels/Icon'; diff --git a/src/components/dialogs/LogoDialog.tsx b/src/components/dialogs/LogoDialog.tsx index 2fb26e5..b7b5514 100644 --- a/src/components/dialogs/LogoDialog.tsx +++ b/src/components/dialogs/LogoDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { LOGOS } from '$constants/logos'; import { Icon } from '$components/panels/Icon'; import classnames from 'classnames'; diff --git a/src/components/dialogs/MapListDialog.tsx b/src/components/dialogs/MapListDialog.tsx index fb6d94b..ce2ea6f 100644 --- a/src/components/dialogs/MapListDialog.tsx +++ b/src/components/dialogs/MapListDialog.tsx @@ -1,5 +1,4 @@ -import * as React from 'react'; -import { bindActionCreators } from 'redux'; +import React from 'react'; import { connect } from 'react-redux'; import { RouteRowWrapper } from '$components/maps/RouteRowWrapper'; import { Scroll } from '$components/Scroll'; @@ -10,44 +9,46 @@ import { setDialogActive, mapsLoadMore, dropRoute, - modifyRoute, toggleRouteStarred, + modifyRoute, + toggleRouteStarred, } from '$redux/user/actions'; import { isMobile } from '$utils/window'; import classnames from 'classnames'; -import * as Range from 'rc-slider/lib/Range'; +import Range from 'rc-slider/lib/Range'; import { TABS, TABS_TITLES } from '$constants/dialogs'; import { Icon } from '$components/panels/Icon'; import { pushPath } from '$utils/history'; import { IRootState, IRouteListItem } from '$redux/user'; -import { ROLES } from "$constants/auth"; +import { ROLES } from '$constants/auth'; +import { IState } from '$redux/store'; export interface IMapListDialogProps extends IRootState { - marks: { [x: number]: string }, - routes_sorted: Array, - routes: IRootState['routes'], - ready: IRootState['ready'], - role: IRootState['user']['role'], + marks: { [x: number]: string }; + routes_sorted: Array; + routes: IRootState['routes']; + ready: IRootState['ready']; + role: IRootState['user']['role']; - mapsLoadMore: typeof mapsLoadMore, - searchSetDistance: typeof searchSetDistance, - searchSetTitle: typeof searchSetTitle, - searchSetTab: typeof searchSetTab, - setDialogActive: typeof setDialogActive, - dropRoute: typeof dropRoute, - modifyRoute: typeof modifyRoute, - toggleRouteStarred: typeof toggleRouteStarred, + mapsLoadMore: typeof mapsLoadMore; + searchSetDistance: typeof searchSetDistance; + searchSetTitle: typeof searchSetTitle; + searchSetTab: typeof searchSetTab; + setDialogActive: typeof setDialogActive; + dropRoute: typeof dropRoute; + modifyRoute: typeof modifyRoute; + toggleRouteStarred: typeof toggleRouteStarred; } export interface IMapListDialogState { - menu_target: IRouteListItem['address'], - editor_target: IRouteListItem['address'], + menu_target: IRouteListItem['address']; + editor_target: IRouteListItem['address']; - is_editing: boolean, - is_dropping: boolean, + is_editing: boolean; + is_dropping: boolean; } -class Component extends React.Component { +class MapListDialogUnconnected extends React.Component { state = { menu_target: null, editor_target: null, @@ -56,33 +57,37 @@ class Component extends React.Component this.setState({ - editor_target, - menu_target: null, - is_editing: true, - is_dropping: false, - }); + startEditing = (editor_target: IRouteListItem['address']): void => + this.setState({ + editor_target, + menu_target: null, + is_editing: true, + is_dropping: false, + }); - showMenu = (menu_target: IRouteListItem['address']): void => this.setState({ - menu_target, - }); + showMenu = (menu_target: IRouteListItem['address']): void => + this.setState({ + menu_target, + }); - hideMenu = (): void => this.setState({ - menu_target: null, - }); + hideMenu = (): void => + this.setState({ + menu_target: null, + }); - showDropCard = (editor_target: IRouteListItem['address']): void => this.setState({ - editor_target, - menu_target: null, - is_editing: false, - is_dropping: true, - }); + showDropCard = (editor_target: IRouteListItem['address']): void => + this.setState({ + editor_target, + menu_target: null, + is_editing: false, + is_dropping: true, + }); stopEditing = (): void => { this.setState({ editor_target: null }); }; - setTitle = ({ target: { value } }: { target: { value: string }}): void => { + setTitle = ({ target: { value } }: { target: { value: string } }): void => { this.props.searchSetTitle(value); }; @@ -97,8 +102,12 @@ class Component extends React.Component { - const { target: { scrollHeight, scrollTop, clientHeight }} = e; + onScroll = (e: { + target: { scrollHeight: number; scrollTop: number; clientHeight: number }; + }): void => { + const { + target: { scrollHeight, scrollTop, clientHeight }, + } = e; const delta = scrollHeight - scrollTop - clientHeight; if ( @@ -114,7 +123,15 @@ class Component extends React.Component { + modifyRoute = ({ + address, + title, + is_public, + }: { + address: string; + title: string; + is_public: boolean; + }): void => { this.props.modifyRoute(address, { title, is_public }); this.stopEditing(); }; @@ -128,13 +145,7 @@ class Component extends React.Component - { list.length === 0 && loading && + {list.length === 0 && loading && (
- } - { ready && !loading && list.length === 0 && + )} + {ready && !loading && list.length === 0 && (
- ТУТ ПУСТО
- И ОДИНОКО + ТУТ ПУСТО
И ОДИНОКО
- } + )}
- { - Object.values(TABS).map(item => (role === ROLES.admin || item !== TABS.PENDING) && ( -
this.props.searchSetTab(item)} - key={item} - > - {TABS_TITLES[item]} -
- )) - } + {Object.values(TABS).map( + item => + (role === ROLES.admin || item !== TABS.PENDING) && ( +
this.props.searchSetTab(item)} + key={item} + > + {TABS_TITLES[item]} +
+ ) + )}
@@ -181,57 +192,50 @@ class Component extends React.Component
- { - ready && Object.keys(marks).length > 2 - ? - = max} - /> - :
- } - + {ready && Object.keys(marks).length > 2 ? ( + = max} + /> + ) : ( +
+ )}
- +
- { - list.map(route => ( - - )) - } + {list.map(route => ( + + ))}
@@ -241,28 +245,42 @@ class Component extends React.Component { +const mapStateToProps = ({ + user: { + editing, + routes, + user: { role }, + }, +}: IState) => { if (routes.filter.max >= 9999) { return { - routes, editing, marks: {}, ready: false, role, + routes, + editing, + marks: {}, + ready: false, + role, }; } - return ({ + return { role, routes, editing, ready: true, - marks: [...new Array(Math.floor((routes.filter.max - routes.filter.min) / 25) + 1)].reduce((obj, el, i) => ({ - ...obj, - [routes.filter.min + (i * 25)]: - ` ${routes.filter.min + (i * 25)}${(routes.filter.min + (i * 25) >= 200) ? '+' : ''} + marks: [...new Array(Math.floor((routes.filter.max - routes.filter.min) / 25) + 1)].reduce( + (obj, el, i) => ({ + ...obj, + [routes.filter.min + i * 25]: ` ${routes.filter.min + i * 25}${ + routes.filter.min + i * 25 >= 200 ? '+' : '' + } `, - }), {}), - }); + }), + {} + ), + }; }; -const mapDispatchToProps = dispatch => bindActionCreators({ +const mapDispatchToProps = { searchSetDistance, searchSetTitle, searchSetTab, @@ -271,6 +289,8 @@ const mapDispatchToProps = dispatch => bindActionCreators({ dropRoute, modifyRoute, toggleRouteStarred, -}, dispatch); +}; -export const MapListDialog = connect(mapStateToProps, mapDispatchToProps)(Component); +const MapListDialog = connect(mapStateToProps, mapDispatchToProps)(MapListDialogUnconnected); + +export { MapListDialog }; diff --git a/src/components/dialogs/ProviderDialog.tsx b/src/components/dialogs/ProviderDialog.tsx index 3a870c2..b6237c1 100644 --- a/src/components/dialogs/ProviderDialog.tsx +++ b/src/components/dialogs/ProviderDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { PROVIDERS, replaceProviderUrl } from '$constants/providers'; import { Icon } from '$components/panels/Icon'; import classnames from 'classnames'; diff --git a/src/components/dialogs/RouterDialog.tsx b/src/components/dialogs/RouterDialog.tsx index b24b695..6d2bcd9 100644 --- a/src/components/dialogs/RouterDialog.tsx +++ b/src/components/dialogs/RouterDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; import { routerCancel as routerCancelAction, diff --git a/src/components/dialogs/SaveDialog.tsx b/src/components/dialogs/SaveDialog.tsx index aa1f521..7f66b14 100644 --- a/src/components/dialogs/SaveDialog.tsx +++ b/src/components/dialogs/SaveDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { copyToClipboard, getUrlData } from '$utils/history'; import { toTranslit, parseDesc } from '$utils/format'; import { TIPS } from '$constants/tips'; diff --git a/src/components/dialogs/ShotPrefetchDialog.tsx b/src/components/dialogs/ShotPrefetchDialog.tsx index 7e2f62d..487b378 100644 --- a/src/components/dialogs/ShotPrefetchDialog.tsx +++ b/src/components/dialogs/ShotPrefetchDialog.tsx @@ -1,13 +1,14 @@ -import * as React from 'react'; +import React from 'react'; +import { connect } from 'react-redux'; +import { selectUserRenderer } from '$redux/user/selectors'; -interface Props { - renderer: { - info: string, - progress: number, - } -} +const mapStateToProps = state => ({ + renderer: selectUserRenderer(state), +}); -export const ShotPrefetchDialog = ({ renderer: { info, progress }}: Props) => ( +type Props = ReturnType & {}; + +const ShotPrefetchDialogUnconnected = ({ renderer: { info, progress }}: Props) => (
{info}
@@ -19,3 +20,7 @@ export const ShotPrefetchDialog = ({ renderer: { info, progress }}: Props) => (
); + +const ShotPrefetchDialog = connect(mapStateToProps)(ShotPrefetchDialogUnconnected); + +export { ShotPrefetchDialog } \ No newline at end of file diff --git a/src/components/dialogs/StickersDialog.tsx b/src/components/dialogs/StickersDialog.tsx index 694ec83..db31f3c 100644 --- a/src/components/dialogs/StickersDialog.tsx +++ b/src/components/dialogs/StickersDialog.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from 'react'; +import React from 'react'; import { STICKERS } from '$constants/stickers'; import { setActiveSticker as setActiveStickerAction } from "$redux/user/actions"; diff --git a/src/components/dialogs/TitleDialog.tsx b/src/components/dialogs/TitleDialog.tsx index 0f74e63..ae8d990 100644 --- a/src/components/dialogs/TitleDialog.tsx +++ b/src/components/dialogs/TitleDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { bindActionCreators } from "redux"; import { connect } from 'react-redux'; diff --git a/src/components/dialogs/TrashDialog.tsx b/src/components/dialogs/TrashDialog.tsx index c545a39..09f0e96 100644 --- a/src/components/dialogs/TrashDialog.tsx +++ b/src/components/dialogs/TrashDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; type Props = { diff --git a/src/components/logo/LogoPreview.tsx b/src/components/logo/LogoPreview.tsx index 5a6f212..7950c2f 100644 --- a/src/components/logo/LogoPreview.tsx +++ b/src/components/logo/LogoPreview.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { LOGOS } from '$constants/logos'; import { connect } from 'react-redux'; import { IRootState } from '$redux/user'; diff --git a/src/components/maps/RouteRowDrop.tsx b/src/components/maps/RouteRowDrop.tsx index 71acdc4..1f7c097 100644 --- a/src/components/maps/RouteRowDrop.tsx +++ b/src/components/maps/RouteRowDrop.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; import { MapListDialog } from "$components/dialogs/MapListDialog"; import { Tooltip } from "$components/panels/Tooltip"; diff --git a/src/components/maps/RouteRowEditor.tsx b/src/components/maps/RouteRowEditor.tsx index d8471db..00466ee 100644 --- a/src/components/maps/RouteRowEditor.tsx +++ b/src/components/maps/RouteRowEditor.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; import { Switch } from '$components/Switch'; import { MapListDialog } from "$components/dialogs/MapListDialog"; diff --git a/src/components/maps/RouteRowView.tsx b/src/components/maps/RouteRowView.tsx index 85c0811..8a113be 100644 --- a/src/components/maps/RouteRowView.tsx +++ b/src/components/maps/RouteRowView.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from "react"; +import React from "react"; import { Icon } from "$components/panels/Icon"; import { MapListDialog } from "$components/dialogs/MapListDialog"; import { Tooltip } from "$components/panels/Tooltip"; diff --git a/src/components/maps/RouteRowWrapper.tsx b/src/components/maps/RouteRowWrapper.tsx index a681974..24e44cc 100644 --- a/src/components/maps/RouteRowWrapper.tsx +++ b/src/components/maps/RouteRowWrapper.tsx @@ -1,4 +1,4 @@ -import * as React from "react"; +import React from "react"; import classnames from "classnames"; import { MapListDialog } from "$components/dialogs/MapListDialog"; import { RouteRowView } from "$components/maps/RouteRowView"; diff --git a/src/components/panels/DistanceBar.tsx b/src/components/panels/DistanceBar.tsx index 3360226..5531835 100644 --- a/src/components/panels/DistanceBar.tsx +++ b/src/components/panels/DistanceBar.tsx @@ -1,10 +1,10 @@ // flow -import * as React from 'react'; +import React from 'react'; import { toHours } from '$utils/format'; import { Icon } from '$components/panels/Icon'; import { connect } from 'react-redux'; // import Slider from 'rc-slider'; -import * as Slider from 'rc-slider/lib/Slider'; +import Slider from 'rc-slider/lib/Slider'; import { bindActionCreators } from 'redux'; import { setSpeed } from '$redux/user/actions'; import { IRootState } from "$redux/user"; diff --git a/src/components/panels/EditorDialog.tsx b/src/components/panels/EditorDialog.tsx index 8cfe48f..6edb3c7 100644 --- a/src/components/panels/EditorDialog.tsx +++ b/src/components/panels/EditorDialog.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React, { createElement } from 'react'; import { MODES } from '$constants/modes'; import { RouterDialog } from '$components/dialogs/RouterDialog'; @@ -52,7 +52,7 @@ const DIALOG_CONTENTS: { [x: string]: any } = { export const Component = (props: Props) => props.mode && DIALOG_CONTENTS[props.mode] - ? React.createElement(DIALOG_CONTENTS[props.mode]) + ? createElement(DIALOG_CONTENTS[props.mode]) : null; export const EditorDialog = connect( diff --git a/src/components/panels/EditorPanel.tsx b/src/components/panels/EditorPanel.tsx index 4b4af05..decdc94 100644 --- a/src/components/panels/EditorPanel.tsx +++ b/src/components/panels/EditorPanel.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { MODES } from '$constants/modes'; import classnames from 'classnames'; diff --git a/src/components/panels/Icon.tsx b/src/components/panels/Icon.tsx index edf7377..5cad4a3 100644 --- a/src/components/panels/Icon.tsx +++ b/src/components/panels/Icon.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; export const Icon = ({ icon, size = 32 }: { icon: string, size?: number }) => ( diff --git a/src/components/panels/RendererPanel.tsx b/src/components/panels/RendererPanel.tsx index 0534edb..dc9ff90 100644 --- a/src/components/panels/RendererPanel.tsx +++ b/src/components/panels/RendererPanel.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; type Props = { diff --git a/src/components/panels/Tooltip.tsx b/src/components/panels/Tooltip.tsx index dd75408..663f5f8 100644 --- a/src/components/panels/Tooltip.tsx +++ b/src/components/panels/Tooltip.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import classnames from 'classnames'; export const Tooltip = ({ children, position = 'bottom' }: { children: string, position?: string }) => ( diff --git a/src/components/panels/TopLeftPanel.tsx b/src/components/panels/TopLeftPanel.tsx index ae1f8c6..ee8a829 100644 --- a/src/components/panels/TopLeftPanel.tsx +++ b/src/components/panels/TopLeftPanel.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { UserLocation } from '$components/UserLocation'; import { DistanceBar } from '$components/panels/DistanceBar'; diff --git a/src/components/panels/TopRightPanel.tsx b/src/components/panels/TopRightPanel.tsx index e376b77..246dc0e 100644 --- a/src/components/panels/TopRightPanel.tsx +++ b/src/components/panels/TopRightPanel.tsx @@ -1,5 +1,5 @@ // flow -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; import { PROVIDERS } from '$constants/providers'; import { LOGOS } from '$constants/logos'; diff --git a/src/components/panels/UserPanel.tsx b/src/components/panels/UserPanel.tsx index 4d497b7..8c494af 100644 --- a/src/components/panels/UserPanel.tsx +++ b/src/components/panels/UserPanel.tsx @@ -1,4 +1,4 @@ -import * as React from "react"; +import React from "react"; import { GuestButton } from "$components/user/GuestButton"; import { DEFAULT_USER, IUser, ROLES } from "$constants/auth"; diff --git a/src/components/renderer/Renderer.tsx b/src/components/renderer/Renderer.tsx index aa2d69d..c3f7a5a 100644 --- a/src/components/renderer/Renderer.tsx +++ b/src/components/renderer/Renderer.tsx @@ -1,9 +1,9 @@ -import * as React from 'react'; +import React from 'react'; import { hideRenderer, cropAShot } from '$redux/user/actions'; import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import * as Croppr from 'croppr'; +import Croppr from 'croppr'; import 'croppr/dist/croppr.css'; import { LOGOS } from '$constants/logos'; import { RendererPanel } from '$components/panels/RendererPanel'; diff --git a/src/components/user/GuestButton.tsx b/src/components/user/GuestButton.tsx index d894480..65e920e 100644 --- a/src/components/user/GuestButton.tsx +++ b/src/components/user/GuestButton.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Icon } from '$components/panels/Icon'; type Props = { diff --git a/src/components/user/UserButton.tsx b/src/components/user/UserButton.tsx index e444e00..e09c13d 100644 --- a/src/components/user/UserButton.tsx +++ b/src/components/user/UserButton.tsx @@ -1,5 +1,5 @@ // @flow -import * as React from "react"; +import React from "react"; import { UserPicture } from "$components/user/UserPicture"; import { IUser } from "$constants/auth"; diff --git a/src/components/user/UserMenu.tsx b/src/components/user/UserMenu.tsx index fc63909..1be22dc 100644 --- a/src/components/user/UserMenu.tsx +++ b/src/components/user/UserMenu.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { APP_INFO } from '$constants/app_info'; import { userLogout } from "$redux/user/actions"; diff --git a/src/components/user/UserPicture.tsx b/src/components/user/UserPicture.tsx index cf2fc3f..326992e 100644 --- a/src/components/user/UserPicture.tsx +++ b/src/components/user/UserPicture.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; export const UserPicture = ({ photo }) => (
(
@@ -41,9 +41,6 @@ const Component = (props: Props) => ( - - - ( setDialogActive={props.setDialogActive} /> + + - { props.renderer_active && - - } + {props.renderer_active && }
); const mapStateToProps = ({ user: { - mode, dialog, dialog_active, renderer, activeSticker: { sticker = null, set = null } - } + mode, + dialog, + dialog_active, + renderer, + activeSticker: { sticker = null, set = null }, + }, }) => ({ renderer_active: renderer.renderer_active, mode, @@ -72,5 +73,6 @@ const mapStateToProps = ({ set, }); -const mapDispatchToProps = dispatch => bindActionCreators({ hideRenderer, setDialogActive }, dispatch); +const mapDispatchToProps = dispatch => + bindActionCreators({ hideRenderer, setDialogActive }, dispatch); export const App = connect(mapStateToProps, mapDispatchToProps)(hot(module)(Component)); diff --git a/src/containers/LeftDialog.tsx b/src/containers/LeftDialog.tsx index 31ea341..16fb58a 100644 --- a/src/containers/LeftDialog.tsx +++ b/src/containers/LeftDialog.tsx @@ -1,17 +1,15 @@ -// @flow -import * as React from 'react'; +import React, { createElement } from 'react'; import { DIALOGS, IDialogs } from '$constants/dialogs'; -import * as classnames from 'classnames'; +import classnames from 'classnames'; import { AppInfoDialog } from '$components/dialogs/AppInfoDialog'; import { Icon } from '$components/panels/Icon'; import { MapListDialog } from '$components/dialogs/MapListDialog'; -import * as ActionCreators from "$redux/user/actions"; -import { StatelessComponent } from "react"; +import * as USER_ACTIONS from '$redux/user/actions'; interface Props { - dialog: keyof IDialogs, - dialog_active: Boolean, - setDialogActive: typeof ActionCreators.setDialogActive, + dialog: keyof IDialogs; + dialog_active: Boolean; + setDialogActive: typeof USER_ACTIONS.setDialogActive; } const LEFT_DIALOGS = { @@ -19,22 +17,25 @@ const LEFT_DIALOGS = { [DIALOGS.APP_INFO]: AppInfoDialog, }; -export const LeftDialog = ({ dialog, dialog_active, setDialogActive }: Props) => ( +const LeftDialog = ({ dialog, dialog_active, setDialogActive }: Props) => ( - { - Object.keys(LEFT_DIALOGS).map(item => ( -
- { dialog && LEFT_DIALOGS[item] && React.createElement(LEFT_DIALOGS[item]) } -
setDialogActive(false)}> - -
+ {Object.keys(LEFT_DIALOGS).map(item => ( +
+ {dialog && LEFT_DIALOGS[item] && createElement(LEFT_DIALOGS[item], {})} -
setDialogActive(false)}> - -
+
setDialogActive(false)}> +
- )) - } + +
setDialogActive(false)}> + +
+
+ ))} ); +export { LeftDialog }; diff --git a/src/containers/map/Map/index.tsx b/src/containers/map/Map/index.tsx index fc493ff..a99f856 100644 --- a/src/containers/map/Map/index.tsx +++ b/src/containers/map/Map/index.tsx @@ -1,5 +1,5 @@ import { Map as MapInterface, map } from "leaflet"; -import * as React from "react"; +import React from "react"; import { createPortal } from "react-dom"; import { selectMapProvider, diff --git a/src/containers/map/Sticker/index.tsx b/src/containers/map/Sticker/index.tsx index 6bea62e..c37d505 100644 --- a/src/containers/map/Sticker/index.tsx +++ b/src/containers/map/Sticker/index.tsx @@ -1,4 +1,4 @@ -import * as React from "react"; +import React from "react"; import { Map, marker, Marker } from "leaflet"; import { IStickerDump } from "$redux/map/types"; import { STICKERS } from "$constants/stickers"; diff --git a/src/containers/map/Stickers/index.tsx b/src/containers/map/Stickers/index.tsx index c832b6f..20d5b3d 100644 --- a/src/containers/map/Stickers/index.tsx +++ b/src/containers/map/Stickers/index.tsx @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { IStickerDump } from '$redux/map/types'; import { FeatureGroup, Map } from 'leaflet'; import { Sticker } from '$containers/map/Sticker'; diff --git a/src/containers/map/TileLayer/index.tsx b/src/containers/map/TileLayer/index.tsx index e684c11..ff430fe 100644 --- a/src/containers/map/TileLayer/index.tsx +++ b/src/containers/map/TileLayer/index.tsx @@ -1,4 +1,4 @@ -import * as React from "react"; +import React from "react"; import { TileContext } from "../../../utils/context"; import { TileLayer as TileLayerInterface, tileLayer, Map } from "leaflet"; import { DEFAULT_PROVIDER, PROVIDERS } from "$constants/providers"; diff --git a/src/index.tsx b/src/index.tsx index 726e861..c695bbe 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -73,8 +73,8 @@ done stickers drag on rotate bug */ -import * as React from 'react'; -import * as ReactDOM from 'react-dom'; +import React from 'react'; +import ReactDOM from 'react-dom'; import { App } from '$containers/App'; import '$styles/main.less'; diff --git a/src/redux/user/selectors.ts b/src/redux/user/selectors.ts index b656f50..7c157c9 100644 --- a/src/redux/user/selectors.ts +++ b/src/redux/user/selectors.ts @@ -4,4 +4,5 @@ export const selectUser = (state: IState) => state.user; export const selectUserUser = (state: IState) => state.user.user; export const selectUserEditing = (state: IState) => state.user.editing; export const selectUserMode = (state: IState) => state.user.mode; -export const selectUserActiveSticker = (state: IState) => state.user.activeSticker; \ No newline at end of file +export const selectUserActiveSticker = (state: IState) => state.user.activeSticker; +export const selectUserRenderer = (state: IState) => state.user.renderer; \ No newline at end of file diff --git a/src/utils/context.ts b/src/utils/context.ts index 3f25d78..6631da9 100644 --- a/src/utils/context.ts +++ b/src/utils/context.ts @@ -1,4 +1,4 @@ -import * as React from 'react'; +import React from 'react'; import { Map, TileLayer } from 'leaflet'; export const MapContext = React.createContext(null); diff --git a/src/utils/gpx.ts b/src/utils/gpx.ts index 28d4df2..66fd29b 100644 --- a/src/utils/gpx.ts +++ b/src/utils/gpx.ts @@ -1,4 +1,4 @@ -import * as saveAs from 'file-saver'; +import saveAs from 'file-saver'; export interface IRoutePoint { lat: number, diff --git a/src/utils/renderer.ts b/src/utils/renderer.ts index 784f6bb..f5ecbdf 100644 --- a/src/utils/renderer.ts +++ b/src/utils/renderer.ts @@ -1,6 +1,6 @@ // import { editor } from '$modules/Editor'; import { COLORS, CLIENT } from '$config/frontend'; -import * as saveAs from 'file-saver'; +import saveAs from 'file-saver'; import { replaceProviderUrl } from '$constants/providers'; import { STICKERS } from '$constants/stickers'; import { ILatLng } from '$redux/map/types'; diff --git a/tsconfig.json b/tsconfig.json index 4344f6f..d283ce8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,8 @@ "target": "es6", "jsx": "react", "lib": [ "es2015", "DOM", "es6" ], + "esModuleInterop": true, + "isolatedModules": true, "baseUrl": ".", "paths": { "$components/*": [ "src/components/*" ],