better support in typescript:

- added export from components by name (as provided in source files)
- added missing exports: Layout, Ripple
- fixed navigation definition (ButtonProps and LinkProps was used without referencing)
old
ixrock 2016-06-26 14:47:00 +03:00
parent 8d65961be2
commit 69368aeec6
25 changed files with 209 additions and 122 deletions

126
index.d.ts vendored
View File

@ -1,81 +1,57 @@
// Type definitions for react-toolbox 0.16.2
// Project: http://react-toolbox.com/
// Definitions by: @xogeny (Michael M. Tiller), @hsrobflavorus (Robert Parker)
// Definitions by: @xogeny (Michael M. Tiller), @hsrobflavorus (Robert Parker), @ixrock (Roman Karlov)
/* CHANGES
* 06/05/2016: Refactor into external module declarations (no more 'declare module ...')
* 04/27/2016: Updates for 0.16.2, added <Chip>, <Overlay>, and ActivableRendererFactory definitions, misc. tweaks and fixes.
* 02/03/2016:
* Fixed for TypeScript 1.8.0 stricter var declaration requirements (move `declare var ...` inside each individual module).
* Removed triple-slash reference to React to fix npm install compatibility (you'll need to make sure you're referencing react.d.ts somewhere in your project!).
* Hopefully fixed the default exports where applicable
* 01/13/2016: Minor changes, add a few missing props, add IconButton to react-toolbox/lib/button
* 12/21/2015: Fix "import * as Input from 'react-toolbox/lib/input'" style imports, which now correctly import only the necessary component(s).
* NOTE that you must use "import * as {Component Name}" not just "import {Component Name}" for this to work.
* 12/20/2015: Should be compatible with 0.14.0. Refactor modules into 'react-toolbox/lib/*' format.
Unfortunately importing them directly in that manner doesn't seem to work
i.e. "import Input from 'react-toolbox/lib/input'" resolves to undefined, whereas "import { Input } from 'react-toolbox'" works fine!
... Any ideas welcome!
* 12/20/2015: Add AppBar, Avatar, and refactor Card and its child Components to match the documentation.
* 12/18/2015: Update to react-toolbox 0.13.1 (from 0.12.11)
* 12/18/2015: Use JSDoc-style comments to provide Intellisense where supported
*/
* 26/05/2015 Export components by names (not only defaults), added missing components exports
* 06/05/2016: Refactor into external module declarations (no more 'declare module ...')
* 04/27/2016: Updates for 0.16.2, added <Chip>, <Overlay>, and ActivableRendererFactory definitions, misc. tweaks and fixes.
* 02/03/2016:
* Fixed for TypeScript 1.8.0 stricter var declaration requirements (move `declare var ...` inside each individual module).
* Removed triple-slash reference to React to fix npm install compatibility (you'll need to make sure you're referencing react.d.ts somewhere in your project!).
* Hopefully fixed the default exports where applicable
* 01/13/2016: Minor changes, add a few missing props, add IconButton to react-toolbox/lib/button
* 12/21/2015: Fix "import * as Input from 'react-toolbox/lib/input'" style imports, which now correctly import only the necessary component(s).
* NOTE that you must use "import * as {Component Name}" not just "import {Component Name}" for this to work.
* 12/20/2015: Should be compatible with 0.14.0. Refactor modules into 'react-toolbox/lib/*' format.
Unfortunately importing them directly in that manner doesn't seem to work
i.e. "import Input from 'react-toolbox/lib/input'" resolves to undefined, whereas "import { Input } from 'react-toolbox'" works fine!
... Any ideas welcome!
* 12/20/2015: Add AppBar, Avatar, and refactor Card and its child Components to match the documentation.
* 12/18/2015: Update to react-toolbox 0.13.1 (from 0.12.11)
* 12/18/2015: Use JSDoc-style comments to provide Intellisense where supported
*/
/*
MISSING COMPONENTS (Contributions welcome)
* Ripple HOC
*/
MISSING COMPONENTS (Contributions welcome)
* Ripple HOC
*/
import ActivableRendererFactory from 'react-toolbox/lib/hoc/ActivableRenderer';
import AppBar from 'react-toolbox/lib/app_bar';
import Autocomplete from 'react-toolbox/lib/autocomplete';
import Avatar from 'react-toolbox/lib/avatar';
import { Button }from 'react-toolbox/lib/button';
import { Card, CardActions, CardMedia, CardText, CardTitle} from 'react-toolbox/lib/card';
import Checkbox from 'react-toolbox/lib/checkbox';
import DatePicker from 'react-toolbox/lib/date_picker';
import Dialog from 'react-toolbox/lib/dialog';
import Drawer from 'react-toolbox/lib/drawer';
import Dropdown from 'react-toolbox/lib/dropdown';
import FontIcon from 'react-toolbox/lib/font_icon';
import Input from 'react-toolbox/lib/input';
import Link from 'react-toolbox/lib/link';
import {List, ListItem, ListCheckbox, ListSubHeader, ListDivider} from 'react-toolbox/lib/list';
import {Menu, IconMenu, MenuItem, MenuDivider} from 'react-toolbox/lib/menu';
import Navigation from 'react-toolbox/lib/navigation';
import Overlay from 'react-toolbox/lib/overlay';
import ProgressBar from 'react-toolbox/lib/progress_bar';
import {RadioGroup, RadioButton} from 'react-toolbox/lib/radio';
import Slider from 'react-toolbox/lib/slider';
import Snackbar from 'react-toolbox/lib/snackbar';
import Switch from 'react-toolbox/lib/switch';
import { Tab, Tabs } from 'react-toolbox/lib/tabs';
import TimePicker from 'react-toolbox/lib/time_picker';
import Tooltip from 'react-toolbox/lib/tooltip';
export { default as ActivableRendererFactory } from 'react-toolbox/lib/hoc/ActivableRenderer';
export {
ActivableRendererFactory,
AppBar,
Autocomplete,
Avatar,
Button,
Card, CardActions, CardMedia, CardText, CardTitle,
Checkbox,
DatePicker,
Dialog,
Drawer,
Dropdown,
FontIcon,
Input,
Link,
List, ListItem, ListCheckbox, ListSubHeader, ListDivider,
Menu, IconMenu, MenuItem, MenuDivider,
Navigation,
Overlay,
ProgressBar,
RadioGroup, RadioButton,
Slider,
Snackbar,
Switch,
Tab, Tabs,
TimePicker,
Tooltip
}
export { AppBar } from 'react-toolbox/lib/app_bar'
export { Autocomplete } from 'react-toolbox/lib/autocomplete'
export { Avatar } from 'react-toolbox/lib/avatar'
export { Button, IconButton } from 'react-toolbox/lib/button'
export { Card, CardTitle, CardMedia, CardText, CardActions } from 'react-toolbox/lib/card'
export { Checkbox } from 'react-toolbox/lib/checkbox'
export { Chip } from 'react-toolbox/lib/chip'
export { DatePicker } from 'react-toolbox/lib/date_picker'
export { Dialog } from 'react-toolbox/lib/dialog'
export { Drawer } from 'react-toolbox/lib/drawer'
export { Dropdown } from 'react-toolbox/lib/dropdown'
export { FontIcon } from 'react-toolbox/lib/font_icon'
export { Input } from 'react-toolbox/lib/input'
export { Layout, Panel, NavDrawer, Sidebar } from 'react-toolbox/lib/layout'
export { Link } from 'react-toolbox/lib/link'
export { List, ListCheckbox, ListItem, ListDivider, ListSubHeader } from 'react-toolbox/lib/list'
export { Menu, MenuDivider, MenuItem, IconMenu } from 'react-toolbox/lib/menu'
export { Navigation } from 'react-toolbox/lib/navigation'
export { Overlay } from 'react-toolbox/lib/overlay'
export { ProgressBar } from 'react-toolbox/lib/progress_bar'
export { RadioButton, RadioGroup } from 'react-toolbox/lib/radio'
export { Ripple } from 'react-toolbox/lib/ripple'
export { Slider } from 'react-toolbox/lib/slider'
export { Snackbar } from 'react-toolbox/lib/snackbar'
export { Switch } from 'react-toolbox/lib/switch'
export { Tabs, Tab } from 'react-toolbox/lib/tabs'
export { TimePicker } from 'react-toolbox/lib/time_picker'
export { default as Tooltip } from 'react-toolbox/lib/tooltip'

View File

@ -47,10 +47,12 @@ export interface AppBarProps extends Props {
fixed?: boolean,
}
/**
* The app bar is a special kind of toolbar thats used for branding, navigation, search, and actions.
* The app bar is a special kind of toolbar that<EFBFBD>s used for branding, navigation, search, and actions.
* Usually it contains controls on the right and left side and a title with the current section or app name.
* You should give the content with children elements.
*/
export default class AppBar extends React.Component<AppBarProps, {}> {
export class AppBar extends React.Component<AppBarProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default AppBar;

View File

@ -90,6 +90,8 @@ export interface AutocompleteProps extends Props, Conditional, Changeable<string
* They can be simple or multiple depending on the amount of values that can be selected.
* The opening direction is determined at opening time depending on the current position.
*/
export default class Autocomplete extends React.Component<AutocompleteProps, {}> {
export class Autocomplete extends React.Component<AutocompleteProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Autocomplete;

View File

@ -50,6 +50,8 @@ export interface AvatarProps extends Props, Iconic {
* As users may choose not to personalize an avatar, provide delightful defaults.
* When used with a specific logo, avatars can also be used to represent brand.
*/
export default class Avatar extends React.Component<AvatarProps, {}> {
export class Avatar extends React.Component<AvatarProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Avatar;

View File

@ -119,4 +119,6 @@ export class Button extends React.Component<ButtonProps, {}> {
export class IconButton extends React.Component<ButtonProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Button;

View File

@ -75,6 +75,8 @@ export interface CheckboxProps extends Props, Changeable<boolean>, Conditional {
*/
onFocus?: Function,
}
export default class Checkbox extends React.Component<CheckboxProps, {}> {
export class Checkbox extends React.Component<CheckboxProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Checkbox;

6
lib/chip/index.d.ts vendored
View File

@ -61,6 +61,8 @@ export interface ChipProps extends Props {
* As users may choose not to personalize an avatar, provide delightful defaults.
* When used with a specific logo, avatars can also be used to represent brand.
*/
export default class Chip extends React.Component<ChipProps, {}> {
export class Chip extends React.Component<ChipProps, {}> {
render(): React.ReactElement<any>;
}
}
export default Chip;

View File

@ -62,6 +62,8 @@ export interface DatePickerProps extends Props, Changeable<Date> {
*/
value?: Date,
}
export default class DatePicker extends React.Component<DatePickerProps, {}> {
export class DatePicker extends React.Component<DatePickerProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default DatePicker;

View File

@ -152,6 +152,8 @@ export interface DialogProps extends Props, Modal {
*/
type?: string,
}
export default class Dialog extends React.Component<DialogProps, {}> {
export class Dialog extends React.Component<DialogProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Dialog;

View File

@ -69,6 +69,8 @@ export interface DrawerProps extends Props, Modal {
*/
type?: string
}
export default class Drawer extends React.Component<DrawerProps, {}> {
export class Drawer extends React.Component<DrawerProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Drawer;

View File

@ -77,6 +77,8 @@ export interface DropdownProps extends Props, Changeable<any>, Conditional {
value: string,
}
export default class Dropdown extends React.Component<DropdownProps, {}> {
export class Dropdown extends React.Component<DropdownProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Dropdown;

View File

@ -37,6 +37,8 @@ export interface Props {
export interface FontIconProps extends Props {
value: string
}
export default class FontIcon extends React.Component<FontIconProps, {}> {
export class FontIcon extends React.Component<FontIconProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default FontIcon;

View File

@ -117,6 +117,8 @@ export interface InputProps extends Props, Conditional, Changeable<string>, Icon
*/
value?: string,
}
export default class Input extends React.Component<InputProps, {}> {
export class Input extends React.Component<InputProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Input;

43
lib/layout/index.d.ts vendored Normal file
View File

@ -0,0 +1,43 @@
import * as React from 'react';
export interface LayoutProps {
className?:string
}
export interface NavDrawerProps {
width?:'normal' | 'wide',
active?:boolean,
pinned?:boolean,
permanentAt?:'sm'|'md'|'lg'|'xl'|'xxl'|'xxxl',
onOverlayClick?:() => void,
scrollY?:boolean,
className?:string
}
export interface PanelProps {
scrollY?:boolean,
className?:string
}
export interface SidebarProps {
width?:'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10'|'11'|'12'|'25'|'33'|'50'|'66'|'75'|'100'
pinned?:boolean,
scrollY?:boolean,
className?:string
}
export class Layout extends React.Component<LayoutProps, {}> {
render():React.DOMElement<any, any>;
}
export class NavDrawer extends React.Component<NavDrawerProps, {}> {
render():React.DOMElement<any, any>;
}
export class Panel extends React.Component<PanelProps, {}> {
render():React.DOMElement<any, any>;
}
export class Sidebar extends React.Component<SidebarProps, {}> {
render():React.DOMElement<any, any>;
}

6
lib/link/index.d.ts vendored
View File

@ -51,6 +51,8 @@ export interface LinkProps extends Props, Iconic {
*/
count?: number,
}
export default class Link extends React.Component<LinkProps, {}> {
export class Link extends React.Component<LinkProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Link;

View File

@ -1,4 +1,7 @@
import * as React from 'react';
import { ButtonProps } from '../button'
import { LinkProps } from '../link'
export interface Props {
/**
* Sets a CSS class on the component.
@ -48,6 +51,8 @@ export interface NavigationProps extends Props {
*/
type?: string,
}
export default class Navigation extends React.Component<NavigationProps, {}> {
export class Navigation extends React.Component<NavigationProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Navigation;

View File

@ -44,6 +44,8 @@ export interface OverlayProps extends Props {
onClick?: Function;
onEscKeyDown?: Function
}
export default class Overlay extends React.Component<OverlayProps, {}> {
export class Overlay extends React.Component<OverlayProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Overlay;

View File

@ -41,19 +41,19 @@ export interface ProgressBarProps extends Props {
/**
* Maximum value permitted.
*/
max?: number, //
max?: number, //
/**
* minimum value permitted.
*/
min?: number, //
min?: number, //
/**
* Mode of the progress bar, it can be determinate or indeterminate.
*/
mode?: string, //
mode?: string, //
/**
* If true, the circular progress bar will be changing its color.
*/
multicolor?: boolean, //
multicolor?: boolean, //
/**
* Type of the progress bar, it can be circular or linear.
* @default linear
@ -64,6 +64,8 @@ export interface ProgressBarProps extends Props {
*/
value?: number,
}
export default class ProgressBar extends React.Component<ProgressBarProps, {}> {
export class ProgressBar extends React.Component<ProgressBarProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default ProgressBar;

View File

@ -96,4 +96,6 @@ export interface RadioButtonProps extends Props, Conditional {
}
export class RadioButton extends React.Component<RadioButtonProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default RadioButton;

20
lib/ripple/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
import * as React from 'react';
export interface RippleProps {
centered?:boolean,
className?:boolean,
onRippleEnded:() => void,
spread?:number,
theme?:{
ripple?:string,
rippleActive?:string,
rippleRestarting?:string,
rippleWrapper?:string
}
}
export class Ripple extends React.Component<RippleProps, {}> {
render():React.DOMElement<any, any>;
}
export default Ripple;

View File

@ -67,6 +67,8 @@ export interface SliderProps extends Props {
*/
value: number,
}
export default class Slider extends React.Component<SliderProps, {}> {
export class Slider extends React.Component<SliderProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Slider;

View File

@ -92,6 +92,9 @@ export interface SnackbarProps extends Props, Modal, Iconic {
*/
type?: string,
}
export default class Snackbar extends React.Component<SnackbarProps, {}> {
export class Snackbar extends React.Component<SnackbarProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Snackbar;

View File

@ -70,6 +70,8 @@ export interface SwitchProps extends Props, Conditional {
*/
onFocus?: Function,
}
export default class Switch extends React.Component<SwitchProps, {}> {
export class Switch extends React.Component<SwitchProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Switch;

View File

@ -59,6 +59,8 @@ export interface TableProps extends Props {
*/
source?: Array<{ [key: string]: any }>,
}
export default class Table extends React.Component<TableProps, {}> {
export class Table extends React.Component<TableProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default Table;

View File

@ -54,6 +54,8 @@ export interface TimePickerProps extends Props, Changeable<Date> {
*/
value?: Date,
}
export default class TimePicker extends React.Component<TimePickerProps, {}> {
export class TimePicker extends React.Component<TimePickerProps, {}> {
render(): React.DOMElement<any, any>;
}
}
export default TimePicker;