Skip to content

Commit

Permalink
refactor(react-scheduler): migrate to TS (#1844)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyAlexeev authored and MaximKudriavtsev committed May 21, 2019
1 parent 2ee3c94 commit bde0299
Show file tree
Hide file tree
Showing 103 changed files with 2,296 additions and 1,422 deletions.
2 changes: 2 additions & 0 deletions packages/dx-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ export type MemoizedFunction<TArg extends any[], T extends (...args: any[]) => a
export type MemoizedComputed<TArg, T extends (...args: any[]) => any> =
(arg: TArg) =>
(...args: [Getters, Actions]) => ReturnType<T>;

export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
2 changes: 1 addition & 1 deletion packages/dx-core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"outDir": "dist"
},
"include": [
"./src"
Expand Down
13 changes: 10 additions & 3 deletions packages/dx-react-core/api/dx-react-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
```ts

import { Mutable } from '@devexpress/dx-core';
import * as React from 'react';

// @public (undocumented)
Expand All @@ -17,9 +18,12 @@ export interface ActionProps {

// @public (undocumented)
export type Actions = {
[actionName: string]: (payload?: any) => void;
[actionName: string]: (payload?: any) => void;
};

// @public (undocumented)
export type ComputedFn = (getters: Getters, actions: Actions) => void;

// @public
export const connectProps: (WrappedComponent: React.ComponentType<any>, getAdditionalProps: () => object) => (React.ComponentClass<any, any> & {
update(): void;
Expand All @@ -32,14 +36,14 @@ export const Getter: React.ComponentType<GetterProps>;

// @public (undocumented)
export interface GetterProps {
computed?: (getters: Getters, actions: Actions) => any;
computed?: ComputedFn;
name: string;
value?: any;
}

// @public (undocumented)
export type Getters = {
readonly [getterName: string]: any;
readonly [getterName: string]: any;
};

// @public (undocumented)
Expand Down Expand Up @@ -99,6 +103,9 @@ export interface TemplateProps {
predicate?: (params: object) => boolean;
}

// @public (undocumented)
export type WritableRefObject<T> = Mutable<React.RefObject<T>>;


// (No @packageDocumentation comment for this package)

Expand Down
4 changes: 1 addition & 3 deletions packages/dx-react-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export { Plugin } from './plugin-based/plugin';
export { PluginHost } from './plugin-based/plugin-host';
export { Action } from './plugin-based/action';
export { Getter, Actions } from './plugin-based/getter';
export { Getter } from './plugin-based/getter';
export { Template } from './plugin-based/template';
export { TemplatePlaceholder } from './plugin-based/template-placeholder';
export { TemplateConnector } from './plugin-based/template-connector';

/** @internal */
export { Getters } from './plugin-based/getter';
/** @internal */
export { Draggable } from './draggable';

Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-core/src/plugin-based/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { PLUGIN_HOST_CONTEXT, POSITION_CONTEXT } from './constants';
import { withHostAndPosition } from '../utils/with-props-from-context';
import { PluginContextProps } from './plugin-context-prop-types';
import { Actions, Getters } from './getter';
import { Getters, Actions } from '../types';

export interface ActionProps {
/** The action name. */
Expand Down
8 changes: 2 additions & 6 deletions packages/dx-react-core/src/plugin-based/getter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { UPDATE_CONNECTION_EVENT, PLUGIN_HOST_CONTEXT, POSITION_CONTEXT } from '
import { withHostAndPosition } from '../utils/with-props-from-context';
import { InnerPlugin } from '@devexpress/dx-core';
import { PluginContextProps } from './plugin-context-prop-types';
import { ComputedFn } from '../types';

export interface GetterProps {
/** The Getter's name. */
Expand All @@ -18,13 +19,8 @@ export interface GetterProps {
* The value is computed each time a related Getter's value changes.
* Applies only if `value` is not defined.
*/
computed?: (
getters: Getters,
actions: Actions,
) => any;
computed?: ComputedFn;
}
export type Getters = { readonly [getterName: string]: any };
export type Actions = { [actionName: string]: (payload?: any) => void };

class GetterBase extends React.PureComponent<GetterProps & PluginContextProps> {
plugin: InnerPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getAvailableActions,
} from './helpers';
import { PluginHostContext } from './contexts';
import { Getters, Actions } from './getter';
import { Getters, Actions } from '../types';

export interface TemplateConnectorProps {
/** A function that renders a markup using Getters and Actions passed as arguments. */
Expand Down
8 changes: 7 additions & 1 deletion packages/dx-react-core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PureReducer, PureComputed } from '@devexpress/dx-core';
import { PureReducer, PureComputed, Mutable } from '@devexpress/dx-core';

export { IDependency } from '../../dx-core/src';

Expand Down Expand Up @@ -31,3 +31,9 @@ export type SizerProps = {
containerComponent?: any;
style?: object;
};

export type WritableRefObject<T> = Mutable<React.RefObject<T>>;

export type Getters = { readonly [getterName: string]: any };
export type Actions = { [actionName: string]: (payload?: any) => void };
export type ComputedFn = (getters: Getters, actions: Actions) => void;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
Appointments,
Toolbar,
ViewSwitcher,
MonthView,
DayView,
AllDayPanel,
} from '@devexpress/dx-react-scheduler-material-ui';

import { appointments } from '../../../demo-data/month-appointments';
Expand Down Expand Up @@ -48,6 +51,10 @@ export default class Demo extends React.PureComponent {
startDayHour={9}
endDayHour={19}
/>
<MonthView />
<DayView />

<AllDayPanel />

<Toolbar />
<ViewSwitcher />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export const Scheduler: React.ComponentType<SchedulerProps> & {
// @public (undocumented)
export interface SchedulerProps {
data?: Array<AppointmentModel>;
locale?: string;
locale?: string | Array<string>;
rootComponent?: React.ComponentType<Scheduler_2.RootProps>;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/dx-react-scheduler-material-ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"compilerOptions": {
"downlevelIteration": true,
"esModuleInterop": true,
},
"include": [
"./dist"
]
Expand Down
23 changes: 0 additions & 23 deletions packages/dx-react-scheduler/.eslintrc.json

This file was deleted.

Loading

0 comments on commit bde0299

Please sign in to comment.