From 69368aeec6834a7def0e06f32ebfed1cfd09d8c7 Mon Sep 17 00:00:00 2001 From: ixrock Date: Sun, 26 Jun 2016 14:47:00 +0300 Subject: [PATCH] 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) --- index.d.ts | 126 +++++++++++++++--------------------- lib/app_bar/index.d.ts | 8 ++- lib/autocomplete/index.d.ts | 6 +- lib/avatar/index.d.ts | 6 +- lib/button/index.d.ts | 4 +- lib/checkbox/index.d.ts | 6 +- lib/chip/index.d.ts | 6 +- lib/date_picker/index.d.ts | 6 +- lib/dialog/index.d.ts | 6 +- lib/drawer/index.d.ts | 6 +- lib/dropdown/index.d.ts | 6 +- lib/font_icon/index.d.ts | 6 +- lib/input/index.d.ts | 6 +- lib/layout/index.d.ts | 43 ++++++++++++ lib/link/index.d.ts | 6 +- lib/navigation/index.d.ts | 9 ++- lib/overlay/index.d.ts | 6 +- lib/progress_bar/index.d.ts | 14 ++-- lib/radio/index.d.ts | 4 +- lib/ripple/index.d.ts | 20 ++++++ lib/slider/index.d.ts | 6 +- lib/snackbar/index.d.ts | 7 +- lib/switch/index.d.ts | 6 +- lib/table/index.d.ts | 6 +- lib/time_picker/index.d.ts | 6 +- 25 files changed, 209 insertions(+), 122 deletions(-) create mode 100644 lib/layout/index.d.ts create mode 100644 lib/ripple/index.d.ts diff --git a/index.d.ts b/index.d.ts index 1bdb9618..e66eb25c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 , , 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 , , 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 -} \ No newline at end of file +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' \ No newline at end of file diff --git a/lib/app_bar/index.d.ts b/lib/app_bar/index.d.ts index 9e59dce8..97e2fa34 100644 --- a/lib/app_bar/index.d.ts +++ b/lib/app_bar/index.d.ts @@ -47,10 +47,12 @@ export interface AppBarProps extends Props { fixed?: boolean, } /** - * The app bar is a special kind of toolbar that’s used for branding, navigation, search, and actions. + * The app bar is a special kind of toolbar that�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 { +export class AppBar extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default AppBar; \ No newline at end of file diff --git a/lib/autocomplete/index.d.ts b/lib/autocomplete/index.d.ts index ebfc3866..39452ebd 100644 --- a/lib/autocomplete/index.d.ts +++ b/lib/autocomplete/index.d.ts @@ -90,6 +90,8 @@ export interface AutocompleteProps extends Props, Conditional, Changeable { +export class Autocomplete extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Autocomplete; \ No newline at end of file diff --git a/lib/avatar/index.d.ts b/lib/avatar/index.d.ts index 474eb0b6..c30e43bb 100644 --- a/lib/avatar/index.d.ts +++ b/lib/avatar/index.d.ts @@ -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 { +export class Avatar extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Avatar; \ No newline at end of file diff --git a/lib/button/index.d.ts b/lib/button/index.d.ts index b712fdc4..ff8c4fa9 100644 --- a/lib/button/index.d.ts +++ b/lib/button/index.d.ts @@ -119,4 +119,6 @@ export class Button extends React.Component { export class IconButton extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Button; \ No newline at end of file diff --git a/lib/checkbox/index.d.ts b/lib/checkbox/index.d.ts index 284267d2..e266c3d2 100644 --- a/lib/checkbox/index.d.ts +++ b/lib/checkbox/index.d.ts @@ -75,6 +75,8 @@ export interface CheckboxProps extends Props, Changeable, Conditional { */ onFocus?: Function, } -export default class Checkbox extends React.Component { +export class Checkbox extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Checkbox; \ No newline at end of file diff --git a/lib/chip/index.d.ts b/lib/chip/index.d.ts index 3b982218..8c081ea2 100644 --- a/lib/chip/index.d.ts +++ b/lib/chip/index.d.ts @@ -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 { +export class Chip extends React.Component { render(): React.ReactElement; -} \ No newline at end of file +} + +export default Chip; \ No newline at end of file diff --git a/lib/date_picker/index.d.ts b/lib/date_picker/index.d.ts index ac43c6d7..b6a6425b 100644 --- a/lib/date_picker/index.d.ts +++ b/lib/date_picker/index.d.ts @@ -62,6 +62,8 @@ export interface DatePickerProps extends Props, Changeable { */ value?: Date, } -export default class DatePicker extends React.Component { +export class DatePicker extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default DatePicker; \ No newline at end of file diff --git a/lib/dialog/index.d.ts b/lib/dialog/index.d.ts index 63871438..72118a06 100644 --- a/lib/dialog/index.d.ts +++ b/lib/dialog/index.d.ts @@ -152,6 +152,8 @@ export interface DialogProps extends Props, Modal { */ type?: string, } -export default class Dialog extends React.Component { +export class Dialog extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Dialog; \ No newline at end of file diff --git a/lib/drawer/index.d.ts b/lib/drawer/index.d.ts index 3bcf15f2..478dec86 100644 --- a/lib/drawer/index.d.ts +++ b/lib/drawer/index.d.ts @@ -69,6 +69,8 @@ export interface DrawerProps extends Props, Modal { */ type?: string } -export default class Drawer extends React.Component { +export class Drawer extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Drawer; \ No newline at end of file diff --git a/lib/dropdown/index.d.ts b/lib/dropdown/index.d.ts index e70328c9..b9d90484 100644 --- a/lib/dropdown/index.d.ts +++ b/lib/dropdown/index.d.ts @@ -77,6 +77,8 @@ export interface DropdownProps extends Props, Changeable, Conditional { value: string, } -export default class Dropdown extends React.Component { +export class Dropdown extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Dropdown; \ No newline at end of file diff --git a/lib/font_icon/index.d.ts b/lib/font_icon/index.d.ts index 152fd130..8fc061fd 100644 --- a/lib/font_icon/index.d.ts +++ b/lib/font_icon/index.d.ts @@ -37,6 +37,8 @@ export interface Props { export interface FontIconProps extends Props { value: string } -export default class FontIcon extends React.Component { +export class FontIcon extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default FontIcon; \ No newline at end of file diff --git a/lib/input/index.d.ts b/lib/input/index.d.ts index 780ae6f5..67108330 100644 --- a/lib/input/index.d.ts +++ b/lib/input/index.d.ts @@ -117,6 +117,8 @@ export interface InputProps extends Props, Conditional, Changeable, Icon */ value?: string, } -export default class Input extends React.Component { +export class Input extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Input; \ No newline at end of file diff --git a/lib/layout/index.d.ts b/lib/layout/index.d.ts new file mode 100644 index 00000000..60d32a09 --- /dev/null +++ b/lib/layout/index.d.ts @@ -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 { + render():React.DOMElement; +} + +export class NavDrawer extends React.Component { + render():React.DOMElement; +} + +export class Panel extends React.Component { + render():React.DOMElement; +} + +export class Sidebar extends React.Component { + render():React.DOMElement; +} \ No newline at end of file diff --git a/lib/link/index.d.ts b/lib/link/index.d.ts index 8ee95642..565f80e4 100644 --- a/lib/link/index.d.ts +++ b/lib/link/index.d.ts @@ -51,6 +51,8 @@ export interface LinkProps extends Props, Iconic { */ count?: number, } -export default class Link extends React.Component { +export class Link extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Link; \ No newline at end of file diff --git a/lib/navigation/index.d.ts b/lib/navigation/index.d.ts index a1a3081b..6165fc76 100644 --- a/lib/navigation/index.d.ts +++ b/lib/navigation/index.d.ts @@ -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 { +export class Navigation extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Navigation; \ No newline at end of file diff --git a/lib/overlay/index.d.ts b/lib/overlay/index.d.ts index 3da68043..b2d35b7f 100644 --- a/lib/overlay/index.d.ts +++ b/lib/overlay/index.d.ts @@ -44,6 +44,8 @@ export interface OverlayProps extends Props { onClick?: Function; onEscKeyDown?: Function } -export default class Overlay extends React.Component { +export class Overlay extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Overlay; \ No newline at end of file diff --git a/lib/progress_bar/index.d.ts b/lib/progress_bar/index.d.ts index fb1494ef..44f44684 100644 --- a/lib/progress_bar/index.d.ts +++ b/lib/progress_bar/index.d.ts @@ -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 { +export class ProgressBar extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default ProgressBar; \ No newline at end of file diff --git a/lib/radio/index.d.ts b/lib/radio/index.d.ts index 9df815e4..e0222005 100644 --- a/lib/radio/index.d.ts +++ b/lib/radio/index.d.ts @@ -96,4 +96,6 @@ export interface RadioButtonProps extends Props, Conditional { } export class RadioButton extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default RadioButton; \ No newline at end of file diff --git a/lib/ripple/index.d.ts b/lib/ripple/index.d.ts new file mode 100644 index 00000000..78d4d73e --- /dev/null +++ b/lib/ripple/index.d.ts @@ -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 { + render():React.DOMElement; +} + +export default Ripple; \ No newline at end of file diff --git a/lib/slider/index.d.ts b/lib/slider/index.d.ts index 6e910ba6..89d9f884 100644 --- a/lib/slider/index.d.ts +++ b/lib/slider/index.d.ts @@ -67,6 +67,8 @@ export interface SliderProps extends Props { */ value: number, } -export default class Slider extends React.Component { +export class Slider extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Slider; \ No newline at end of file diff --git a/lib/snackbar/index.d.ts b/lib/snackbar/index.d.ts index 6530072f..6df9264f 100644 --- a/lib/snackbar/index.d.ts +++ b/lib/snackbar/index.d.ts @@ -92,6 +92,9 @@ export interface SnackbarProps extends Props, Modal, Iconic { */ type?: string, } -export default class Snackbar extends React.Component { + +export class Snackbar extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Snackbar; \ No newline at end of file diff --git a/lib/switch/index.d.ts b/lib/switch/index.d.ts index a072f82c..4f57f3ab 100644 --- a/lib/switch/index.d.ts +++ b/lib/switch/index.d.ts @@ -70,6 +70,8 @@ export interface SwitchProps extends Props, Conditional { */ onFocus?: Function, } -export default class Switch extends React.Component { +export class Switch extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Switch; \ No newline at end of file diff --git a/lib/table/index.d.ts b/lib/table/index.d.ts index e2dc73ff..6893b2b7 100644 --- a/lib/table/index.d.ts +++ b/lib/table/index.d.ts @@ -59,6 +59,8 @@ export interface TableProps extends Props { */ source?: Array<{ [key: string]: any }>, } -export default class Table extends React.Component { +export class Table extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default Table; \ No newline at end of file diff --git a/lib/time_picker/index.d.ts b/lib/time_picker/index.d.ts index ee141895..2a7a6291 100644 --- a/lib/time_picker/index.d.ts +++ b/lib/time_picker/index.d.ts @@ -54,6 +54,8 @@ export interface TimePickerProps extends Props, Changeable { */ value?: Date, } -export default class TimePicker extends React.Component { +export class TimePicker extends React.Component { render(): React.DOMElement; -} \ No newline at end of file +} + +export default TimePicker; \ No newline at end of file