Skip to content

Commit

Permalink
Revert "Fix: Test a fix for #7"
Browse files Browse the repository at this point in the history
This reverts commit 4677204.
  • Loading branch information
forabi committed Jul 4, 2019
1 parent 93275e8 commit 91b3f36
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 28 deletions.
4 changes: 1 addition & 3 deletions demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import startOfWeek from 'date-fns/start_of_week';
import humanizeDuration from 'humanize-duration';
import mapValues from 'lodash/mapValues';
import 'pepjs';
import * as React from 'react';
import React, { Fragment, useEffect, useMemo, useState } from 'react';
import CustomProperties from 'react-custom-properties';
import ReactDOM from 'react-dom';
import 'resize-observer-polyfill/dist/ResizeObserver.global';
Expand All @@ -32,8 +32,6 @@ import DeleteIcon from './assets/outline-delete-24px.svg';
import { Key } from './components/Key/Key';
import demoClasses from './index.module.scss';

const { Fragment, useEffect, useMemo, useState } = React;

const locales = {
ja,
en,
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"name": "@remotelock/react-week-scheduler",
"version": "0.0.0-development",
"publishConfig": {
"tag": "next"
},
"license": "MIT",
"description": "",
"homepage": "https://remotelock.github.io/react-week-scheduler/",
Expand Down
4 changes: 2 additions & 2 deletions src/components/EventContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-ignore
import VisuallyHidden from '@reach/visually-hidden';
import * as React from 'react';
import React, { useContext } from 'react';
import { SchedulerContext } from '../context';
import { ClassNames } from '../types';
import {
Expand All @@ -25,7 +25,7 @@ export const EventContent = React.memo(function EventContent({
isStart,
isEnd,
}: EventContentProps) {
const { locale } = React.useContext(SchedulerContext);
const { locale } = useContext(SchedulerContext);
const [start, end] = getFormattedComponentsForDateRange({
dateRange,
locale,
Expand Down
10 changes: 7 additions & 3 deletions src/components/RangeBox.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import classcat from 'classcat';
import invariant from 'invariant';
import Resizable, { ResizeCallback } from 're-resizable';
import * as React from 'react';
import React, {
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import Draggable, { DraggableEventHandler } from 'react-draggable';
import { useMousetrap } from '../hooks/useMousetrap';
import { CellInfo } from '../types';
import { DefaultEventRootComponent } from './DefaultEventRootComponent';
import { EventContent } from './EventContent';
import { ScheduleProps } from './Schedule';

const { useCallback, useEffect, useMemo, useRef, useState } = React;

export const RangeBox = React.memo(function RangeBox({
classes,
grid,
Expand Down
11 changes: 8 additions & 3 deletions src/components/TimeGridScheduler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import startOfDay from 'date-fns/start_of_day';
import invariant from 'invariant';
import isEqual from 'lodash/isEqual';
import times from 'lodash/times';
import * as React from 'react';
import React, {
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import scrollIntoView from 'scroll-into-view-if-needed';
import { SchedulerContext } from '../context';
import { useClickAndDrag } from '../hooks/useClickAndDrag';
Expand All @@ -33,8 +40,6 @@ import { mergeEvents, mergeRanges } from '../utils/mergeEvents';
import { Cell } from './Cell';
import { Schedule, ScheduleProps } from './Schedule';

const { useCallback, useContext, useEffect, useMemo, useRef, useState } = React;

const MINS_IN_DAY = 24 * 60;
const horizontalPrecision = 1;
const toDay = (x: number): number => x * horizontalPrecision;
Expand Down
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import en from 'date-fns/locale/en';
import * as React from 'react';
import { createContext } from 'react';

export const SchedulerContext = React.createContext({ locale: en });
export const SchedulerContext = createContext({ locale: en });
18 changes: 11 additions & 7 deletions src/hooks/useClickAndDrag.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import * as React from 'react';
import * as rxjs from 'rxjs';
import * as operators from 'rxjs/operators';
import React, { useCallback, useEffect, useState } from 'react';
import { fromEvent, merge, of } from 'rxjs';
import {
delay,
filter,
map,
mergeMap,
startWith,
takeUntil,
tap,
} from 'rxjs/operators';
import { Rect } from '../types';
import { createPageMapCoordsToContainer } from '../utils/createPageMapCoordsToContainer';

const { useCallback, useEffect, useState } = React;
const { fromEvent, merge, of } = rxjs;
const { delay, filter, map, mergeMap, startWith, takeUntil, tap } = operators;

const prevent = tap((e: TouchEvent) => {
e.preventDefault();
e.stopPropagation();
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useEventListener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import { useEffect } from 'react';

export function useEventListener<
K extends keyof HTMLElementEventMap,
Expand All @@ -12,7 +12,7 @@ export function useEventListener<
) {
const { current } = ref;

React.useEffect(() => {
useEffect(() => {
if (current === null) {
return;
}
Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useMousetrap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import Mousetrap from 'mousetrap';
import * as React from 'react';

const { useEffect, useRef } = React;
import { useEffect, useRef } from 'react';

/**
* Use mousetrap hook
Expand Down

0 comments on commit 91b3f36

Please sign in to comment.