Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jeff
2016-07-08 10:48:24 -07:00
28 changed files with 1342 additions and 21 deletions

View File

@@ -90,8 +90,8 @@ declare module "aws-sdk" {
export interface ClientConfigPartial extends Services {
credentials?: Credentials;
region?: string;
accessKeyId: string;
secretAccessKey: string;
accessKeyId?: string;
secretAccessKey?: string;
computeChecksums?: boolean;
convertResponseTypes?: boolean;
logger?: Logger;

View File

@@ -0,0 +1,45 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="./chai-enzyme.d.ts" />
/// <reference path="../enzyme/enzyme.d.ts" />
/// <reference path="../chai/chai.d.ts" />
import * as React from "react";
import * as chaiEnzyme from "chai-enzyme";
import { expect } from "chai";
import { shallow } from "enzyme";
const Test = () => <div/>;
class Test2 extends React.Component<{}, {}> {
render() {
return <div/>;
}
}
chai.use(chaiEnzyme());
const wrapper = shallow(<Test />);
expect(wrapper).to.be.checked();
expect(wrapper).to.have.className("test");
expect(wrapper).to.have.descendants({ a: "b" });
expect(wrapper).to.have.descendants(Test);
expect(wrapper).to.have.exactly(1).descendants(Test2);
expect(wrapper).to.have.descendants("div");
expect(wrapper).to.be.disabled();
expect(wrapper).to.be.blank();
expect(wrapper).to.be.present();
expect(wrapper).to.have.html("<div></div>");
expect(wrapper).to.have.id("test");
expect(wrapper).to.have.ref("test");
expect(wrapper).to.be.selected();
expect(wrapper).to.have.tagName("div");
expect(wrapper).to.have.text("");
expect(wrapper).to.have.value("test");
expect(wrapper).to.have.attr("test", "test");
expect(wrapper).to.have.data("test", "Test");
expect(wrapper).to.have.style("background", "green");
expect(wrapper).to.have.state("test", "test");
expect(wrapper).to.have.prop("test", 5);
expect(wrapper).to.contain(<Test/>);
expect(wrapper).to.match(<Test/>);

153
chai-enzyme/chai-enzyme.d.ts vendored Normal file
View File

@@ -0,0 +1,153 @@
// Type definitions for chai-enzyme 0.5.0
// Project: https://github.com/producthunt/chai-enzyme
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../enzyme/enzyme.d.ts" />
/// <reference path="../chai/chai.d.ts" />
/// <reference path="../react/react.d.ts" />
declare namespace Chai {
type EnzymeSelector = string | __React.StatelessComponent<any> | __React.ComponentClass<any> | { [key: string]: any };
interface Match {
/**
* Assert that the wrapper matches given selector:
* @param selector
*/
(selector: EnzymeSelector): Assertion;
}
interface Include {
/**
* Assert that the wrapper contains a given node:
* @param code
*/
(selector: EnzymeSelector): Assertion;
}
interface Assertion {
/**
* Assert that the given wrapper is checked:
*/
checked(): Assertion;
/**
* Assert that the wrapper has a given class:
* @param name
*/
className(name: string): Assertion;
/**
* Assert that the wrapper contains a descendant matching the given selector:
* @param selector
*/
descendants(selector?: EnzymeSelector): Assertion;
/**
* Assert that the wrapper contains an exact amount of descendants matching the given selector:
*/
exactly(count?: number): Assertion;
/**
* Assert that the given wrapper is disabled:
*/
disabled(): Assertion;
/**
* Assert that the given wrapper is empty:
*/
blank(): Assertion;
/**
* Assert that the given wrapper exists:
*/
present(): Assertion;
/**
* Assert that the wrapper has given html:
* @param str
*/
html(str?: string): Assertion;
/**
* Assert that the wrapper has given ID attribute:
* @param str
*/
id(str: string): Assertion;
/**
* Assert that the wrapper has a given ref
* @param key
*/
ref(key: string): Assertion;
/**
* Assert that the given wrapper is selected:
*/
selected(): Assertion;
/**
* Assert that the given wrapper has the tag name:
* @param str
*/
tagName(str: string): Assertion;
/**
* Assert that the given wrapper has the supplied text:
* @param str
*/
text(str?: string): Assertion;
/**
* Assert that the given wrapper has given value:
* @param str
*/
value(str: string): Assertion;
/**
* Assert that the wrapper has given attribute [with value]:
* @param key
* @param val
*/
attr(key: string, val?: string): Assertion;
/**
* Assert that the wrapper has a given data attribute [with value]:
* @param key
* @param val
*/
data(key: string, val?: string): Assertion;
/**
* Assert that the wrapper has given style:
* @param key
* @param val
*/
style(key: string, val?: string): Assertion;
/**
* Assert that the wrapper has given state [with value]:
* @param key
* @param val
*/
state(key: string, val?: any): Assertion;
/**
* Assert that the wrapper has given prop [with value]:
* @param key
* @param val
*/
prop(key: string, val?: any): Assertion;
}
}
declare module "chai-enzyme" {
import { ShallowWrapper, ReactWrapper, CheerioWrapper } from "enzyme";
type DebugWrapper = ShallowWrapper<any,any> | CheerioWrapper<any, any> | ReactWrapper<any, any>;
function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): (chai: any) => void;
module chaiEnzyMe {
}
export = chaiEnzyMe;
}

View File

@@ -93,6 +93,7 @@ declare namespace CryptoJS {
Base64: Encoder;
};
mode: {
CBC: Mode;
CFB: Mode;
CTR: Mode;
CTRGladman: Mode;

View File

@@ -38,6 +38,8 @@ declare module Elasticsearch {
create(params: IndicesCreateParams): PromiseLike<any>;
exists(params: IndicesIndexExitsParams, callback: (error: any, response: any, status: any) => void): void;
exists(params: IndicesIndexExitsParams): PromiseLike<any>;
existsType(params: IndicesIndexExitsParams & {type: string}, callback: (error: any, response: any, status: any) => void): void;
existsType(params: IndicesIndexExitsParams & {type: string}): PromiseLike<any>;
get(params: IndicesGetParams, callback: (error: any, response: any, status: any) => void): void;
get(params: IndicesGetParams): PromiseLike<any>;
getAlias(params: IndicesGetAliasParams, callback: (error: any, response: any, status: any) => void): void;
@@ -46,6 +48,8 @@ declare module Elasticsearch {
putAlias(params: IndicesPutAliasParams): PromiseLike<any>;
putTemplate(params: IndicesPutTemplateParams, callback: (error: any, response: any) => void): void;
putTemplate(params: IndicesPutTemplateParams): PromiseLike<any>;
putMapping(params: IndicesPutMappingParams, callback: (error: any, response: any) => void): void;
putMapping(params: IndicesPutMappingParams): PromiseLike<any>;
refresh(params: IndicesRefreshParams, callback: (error: any, response: any) => void): void;
refresh(params: IndicesRefreshParams): PromiseLike<any>;
}
@@ -125,10 +129,21 @@ declare module Elasticsearch {
body: string | any;
}
export interface IndicesPutMappingParams extends GenericParams {
timeout?: Date | number;
masterTimeout?: Date | number;
ignoreUnavailable?: boolean;
allowNoIndices?: boolean;
expandWildcards?: "open" | "closed" | "none" | "all";
updateAllTypes?: boolean;
index: string | string[] | boolean;
type: string;
}
export interface IndicesGetAliasParams extends GenericParams {
ignoreUnavailable?: boolean;
allowNoIndices?: boolean;
expandWildcards?: string;
expandWildcards?: "open" | "closed" | "none" | "all";
local?: boolean;
index?: string | string[] | boolean;
name: string | string[] | boolean;
@@ -260,7 +275,7 @@ declare module Elasticsearch {
export interface SuggestParams extends GenericParams {
ignoreUnavailable?: boolean;
allowNoIndices?: boolean;
expandWildcards?: string;
expandWildcards?: "open" | "closed" | "none" | "all";
preference?: string;
routing?: string;
source?: string;

View File

@@ -0,0 +1,15 @@
/// <reference path="./match-media-mock.d.ts" />
import { create } from "match-media-mock";
const matchMediaMock = create();
matchMediaMock.setConfig({type: 'screen', width: 1200})
matchMediaMock('(max-width: 991px)').matches // false
matchMediaMock('(max-width: 1240px)').matches // true
const mediaQueryList = matchMediaMock('(max-width: 991px)');
const listener = (mql: MediaQueryList) => { };
mediaQueryList.addListener(listener)
mediaQueryList.removeListener(listener)

35
match-media-mock/match-media-mock.d.ts vendored Normal file
View File

@@ -0,0 +1,35 @@
// Type definitions for match-media-mock 0.1.0
// Project: https://github.com/azazdeaz/match-media-mock
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "match-media-mock" {
/**
* Mock configuration options
*/
interface ConfigOptions {
/**
* Screen type
*/
type?: string;
/**
* Screen height
*/
height?: number;
/**
* Screen width
*/
width?: number;
}
interface MatchMediaMock {
/**
* Set configuration
*/
setConfig(config: ConfigOptions): void;
/**
* Execute query based on provided configuration
*/
(query: string): MediaQueryList;
}
export function create(): MatchMediaMock;
}

View File

@@ -257,14 +257,6 @@ interface ErrorConstructor {
//#endregion
}
interface Error {
/**
* Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types.
*/
popStackFrame(): void;
}
interface String {

View File

@@ -1,9 +1,254 @@
/// <reference path="./qs.d.ts" />
/// <reference path="../node/node.d.ts" />
import qs = require('qs');
import assert = require('assert');
qs.stringify({ a: 'b' });
qs.stringify({ a: 'b', c: 'd' }, { delimiter: '&' });
qs.parse('a=b');
qs.parse('a=b&c=d', { delimiter: '&' });
() => {
var obj = qs.parse('a=c');
assert.deepEqual(obj, { a: 'c' });
var str = qs.stringify(obj);
assert.equal(str, 'a=c');
}
() => {
var plainObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true });
assert.deepEqual(plainObject, { a: { hasOwnProperty: 'b' } });
}
() => {
var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true });
assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } });
}
() => {
assert.deepEqual(qs.parse('a%5Bb%5D=c'), {
a: { b: 'c' }
});
}
() => {
assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), {
foo: {
bar: {
baz: 'foobarbaz'
}
}
});
}
() => {
var expected = {
a: {
b: {
c: {
d: {
e: {
f: {
'[g][h][i]': 'j'
}
}
}
}
}
}
};
var string = 'a[b][c][d][e][f][g][h][i]=j';
assert.deepEqual(qs.parse(string), expected);
}
() => {
var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } });
}
() => {
var limited = qs.parse('a=b&c=d', { parameterLimit: 1 });
assert.deepEqual(limited, { a: 'b' });
}
() => {
var delimited = qs.parse('a=b;c=d', { delimiter: ';' });
assert.deepEqual(delimited, { a: 'b', c: 'd' });
}
() => {
var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });
assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' });
}
() => {
var withDots = qs.parse('a.b=c', { allowDots: true });
assert.deepEqual(withDots, { a: { b: 'c' } });
}
() => {
var withArray = qs.parse('a[]=b&a[]=c');
assert.deepEqual(withArray, { a: ['b', 'c'] });
}
() => {
var withIndexes = qs.parse('a[1]=c&a[0]=b');
assert.deepEqual(withIndexes, { a: ['b', 'c'] });
}
() => {
var noSparse = qs.parse('a[1]=b&a[15]=c');
assert.deepEqual(noSparse, { a: ['b', 'c'] });
}
() => {
var withEmptyString = qs.parse('a[]=&a[]=b');
assert.deepEqual(withEmptyString, { a: ['', 'b'] });
var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c');
assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
}
() => {
var withMaxIndex = qs.parse('a[100]=b');
assert.deepEqual(withMaxIndex, { a: { '100': 'b' } });
}
() => {
var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 });
assert.deepEqual(withArrayLimit, { a: { '1': 'b' } });
}
() => {
var noParsingArrays = qs.parse('a[]=b', { parseArrays: false });
assert.deepEqual(noParsingArrays, { a: { '0': 'b' } });
}
() => {
var mixedNotation = qs.parse('a[0]=b&a[b]=c');
assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } });
}
() => {
var arraysOfObjects = qs.parse('a[][b]=c');
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });
}
() => {
assert.equal(qs.stringify({ a: 'b' }), 'a=b');
assert.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
}
() => {
var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false });
assert.equal(unencoded, 'a[b]=c');
}
() => {
var encoded = qs.stringify({ a: { b: 'c' } }, {
encoder: function (str) {
// Passed in values `a`, `b`, `c`
return // Return encoded string
}
})
}
() => {
var decoded = qs.parse('x=z', {
decoder: function (str) {
// Passed in values `x`, `z`
return // Return decoded string
}
})
}
() => {
qs.stringify({ a: ['b', 'c', 'd'] });
// 'a[0]=b&a[1]=c&a[2]=d'
}
() => {
qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false });
// 'a=b&a=c&a=d'
}
() => {
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' })
// 'a[0]=b&a[1]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
// 'a[]=b&a[]=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'a=b&a=c'
}
() => {
assert.equal(qs.stringify({ a: '' }), 'a=');
}
() => {
assert.equal(qs.stringify({ a: null, b: undefined }), 'a=');
}
() => {
assert.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d');
}
() => {
qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: function (prefix, value) {
if (prefix == 'b') {
// Return an `undefined` value to omit a property.
return;
}
if (prefix == 'e[f]') {
return value.getTime();
}
if (prefix == 'e[g][0]') {
return value * 2;
}
return value;
} });
// 'a=b&c=d&e[f]=123&e[g][0]=4'
qs.stringify({ a: 'b', c: 'd', e: 'f' }, { filter: ['a', 'e'] });
// 'a=b&e=f'
qs.stringify({ a: ['b', 'c', 'd'], e: 'f' }, { filter: ['a', 0, 2] });
}
() => {
var withNull = qs.stringify({ a: null, b: '' });
assert.equal(withNull, 'a=&b=');
}
() => {
var equalsInsensitive = qs.parse('a&b=');
assert.deepEqual(equalsInsensitive, { a: '', b: '' });
}
() => {
var strictNull = qs.stringify({ a: null, b: '' }, { strictNullHandling: true });
assert.equal(strictNull, 'a&b=');
}
() => {
var parsedStrictNull = qs.parse('a&b=', { strictNullHandling: true });
assert.deepEqual(parsedStrictNull, { a: null, b: '' });
}
() => {
var nullsSkipped = qs.stringify({ a: 'b', c: null }, { skipNulls: true });
assert.equal(nullsSkipped, 'a=b');
}
() => {
var encoder = () => {};
var shiftJISEncoded = qs.stringify({ a: 'こんにちは!' }, { encoder: encoder });
assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I');
}
() => {
var decoder = () => {};
var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder });
assert.deepEqual(obj, { a: 'こんにちは!' });
}

14
qs/qs.d.ts vendored
View File

@@ -1,6 +1,6 @@
// Type definitions for qs
// Type definitions for qs 6.2.0
// Project: https://github.com/hapijs/qs
// Definitions by: Roman Korneev <https://github.com/RWander>
// Definitions by: Roman Korneev <https://github.com/RWander>, Leon Yu <https://github.com/leonyu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace QueryString {
@@ -9,14 +9,16 @@ declare namespace QueryString {
strictNullHandling?: boolean;
skipNulls?: boolean;
encode?: boolean;
filter?: any;
arrayFormat?: any;
indices?: string;
encoder?: (str: string) => any;
filter?: Array<string | number> | ((prefix: string, value: any) => any);
arrayFormat?: 'indices' | 'brackets' | 'repeat';
indices?: boolean;
}
interface IParseOptions {
delimiter?: string;
delimiter?: string | RegExp;
depth?: number;
decoder?: (str: string) => any;
arrayLimit?: number;
parseArrays?: boolean;
allowDots?: boolean;

View File

@@ -35,3 +35,14 @@ ReactDOM.render(
</Tooltip>,
document.querySelector('.another-app')
);
ReactDOM.render(
<Tooltip
placement="bottomRight"
trigger={['click', 'focus']}
overlay={() => <span>tooltip</span>}
>
<a href='#'>hover</a>
</Tooltip>,
document.querySelector('.another-app')
);

View File

@@ -1,4 +1,4 @@
// Type definitions for rc-tooltip v3.3.2
// Type definitions for rc-tooltip v3.4.2
// Project: https://github.com/react-component/tooltip
// Definitions by: rhysd <https://rhysd.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -27,7 +27,7 @@ declare namespace Tooltip {
placement?: Placement | Object;
align?: Object;
onPopupAlign?: (popupDomNode: Element, align: Object) => void;
overlay: React.ReactElement<any>;
overlay: React.ReactElement<any> | (() => React.ReactElement<any>);
arrowContent?: React.ReactNode;
getTooltipContainer?: () => Element;
destroyTooltipOnHide?: boolean;

View File

@@ -0,0 +1,39 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="./react-measure.d.ts" />
import * as React from "react";
import * as Measure from "react-measure";
class Test extends React.Component<{}, {}> {
render() {
return (
<Measure accurate
whitelist={["height", "width"]}
onMeasure={this.onMeasure.bind(this) }
>
<div>test</div>
</Measure>
);
}
onMeasure(dimensions: Measure.Dimensions): void {
dimensions.width;
dimensions.height;
}
}
class Test2 extends React.Component<{}, {}> {
render() {
return (
<Measure accurate
whitelist={["height", "width"]}
>
{(dimensions: Measure.Dimensions) =>
<div>
<div>Height: {dimensions.height}</div>
</div>
}
</Measure>
);
}
}

56
react-measure/react-measure.d.ts vendored Normal file
View File

@@ -0,0 +1,56 @@
// Type definitions for react-measure 0.4.0
// Project: https://github.com/souporserious/react-measure
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
declare module "react-measure" {
import * as React from "react";
class Measure extends React.Component<Measure.MeasureProps, {}> { }
namespace Measure {
type MeasurementType = "width" | "height" | "top" | "right" | "bottom" | "left";
interface Dimensions {
width?: number;
height?: number;
top?: number;
right?: number;
bottom?: number;
left?: number;
}
type MeasureChildren = React.ReactElement<any> | { (dimension: Dimensions): React.ReactElement<any> };
interface MeasureProps {
/**
* Tries to give the most accurate measure. Currently only works with height.
* Measures the content rather than the actual box of the element.
*/
accurate?: boolean;
/**
* Provide a list of properties to fire a callback for.
*/
whitelist?: MeasurementType[];
/**
* Like whitelist, but will not fire a callback for the specified properties.
*/
blacklist?: MeasurementType[];
/**
* Determines whether or not a measurement should occur.
* @default true
*/
shouldMeasure?: boolean;
/**
* Callback when the component has been mutated. Receives dimensions, mutations, and anything passed to shouldMeasure.
*/
onMeasure?: (dimensions: Dimensions) => void;
/**
* Children, ordinary JSX element or function. Leaving it for reference here
*/
children?: MeasureChildren;
}
}
export = Measure;
}

View File

@@ -0,0 +1,28 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="./react-motion-slider.d.ts" />
import * as React from "react";
import Slider from "react-motion-slider";
class Test extends React.Component<{}, {}> {
protected slider: Slider;
public render() {
return (
<div onMouseEnter={this.onMouseEnter.bind(this) }>
<Slider currentIndex={1}
autoHeight
align="center"
ref={ref => this.slider = ref}
>
<div key="slide1"/>
<div key="slide2"/>
</Slider>
</div>
);
}
protected onMouseEnter(): void {
this.slider.next();
}
}

View File

@@ -0,0 +1,85 @@
// Type definitions for react-motion-slider 0.4.1
// Project: https://github.com/souporserious/react-motion-slider
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
/// <reference path="../react-motion/react-motion.d.ts" />
declare module "react-motion-slider" {
import * as React from "react";
import { OpaqueConfig } from "react-motion";
export interface SliderProps {
/**
* Move to a slide by its key.
*/
currentKey?: string | number;
/**
* Move to a slide by its index.
*/
currentIndex?: number;
/**
* The amount of slides shown in view
* @default 1
*/
slidesToShow?: number;
/**
* The amount of slides to move upon using prev and next methods.
* @default 1
*/
slidesToMove?: number;
/**
* Animates the wrapper height to fit the current slide.
* @default false
*/
autoHeight?: boolean;
/**
* Offsets the slide to align either left, center, or right.
* @default "left"
*/
align?: "left" | "center" | "right";
/**
* Enable touch and/or mouse dragging
* @default true
*/
swipe?: boolean | "touch" | "mouse";
/**
* The amount the user must swipe to advance slides. (sliderWidth * swipeThreshold)
* @default 0.5
*/
swipeThreshold?: number;
/**
* The amount of time in milliseconds that determines if a swipe was a flick or not.
*/
flickTimeout?: number;
/**
* Accepts a React Motion spring config.
*/
springConfig?: OpaqueConfig;
/**
* Prop callback fired before slide change.
* @param currentIndex
* @param nextIndex
*/
beforeSlide?: (currentIndex: number, nextIndex: number) => void;
/**
* Prop callback fired after slide change.
* @param currentIndex
*/
afterSlide?: (currentIndex: number) => void;
}
export default class Slider extends React.Component<SliderProps, {}> {
/**
* Moves to next slide
*/
public next(): void;
/**
* Move to previous slide
*/
public prev(): void;
}
}

View File

@@ -277,4 +277,3 @@ class SomeClass extends Component<any, any> {
public bar: number;
}
let bar: number = new (connect()(SomeClass))("foo").bar;

View File

@@ -0,0 +1,45 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="./react-responsive.d.ts" />
import * as React from "react";
import * as MediaQuery from "react-responsive";
class Test extends React.Component<{}, {}> {
render() {
return (
<div>
<div>Device Test!</div>
<MediaQuery minDeviceWidth={1224}>
<div>You are a desktop or laptop</div>
<MediaQuery minDeviceWidth={1824}>
<div>You also have a huge screen</div>
</MediaQuery>
<MediaQuery maxWidth={1224}>
<div>You are sized like a tablet or mobile phone though</div>
</MediaQuery>
</MediaQuery>
<MediaQuery maxDeviceWidth={1224}>
<div>You are a tablet or mobile phone</div>
</MediaQuery>
<MediaQuery orientation="portrait">
<div>You are portrait</div>
</MediaQuery>
<MediaQuery orientation="landscape">
<div>You are landscape</div>
</MediaQuery>
<MediaQuery minResolution="2dppx">
<div>You are retina</div>
</MediaQuery>
<MediaQuery query="(min-device-width: 1224px)">
<div>You are a desktop or laptop</div>
<MediaQuery query="(min-device-width: 1824px)">
<div>You also have a huge screen</div>
</MediaQuery>
<MediaQuery query="(max-width: 1224px)">
<div>You are sized like a tablet or mobile phone though</div>
</MediaQuery>
</MediaQuery>
</div>
)
}
}

66
react-responsive/react-responsive.d.ts vendored Normal file
View File

@@ -0,0 +1,66 @@
// Type definitions for react-responsive 1.1.3
// Project: https://github.com/contra/react-responsive
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
declare module "react-responsive" {
import * as React from "react";
namespace MediaQuery {
export interface MediaQueryProps {
query?: string;
// matchers
orientation?: "portrait" | "landscape";
scan?: "progressive" | "interlace";
aspectRatio?: string;
deviceAspectRatio?: string;
height?: number | string;
deviceHeight?: number | string;
width?: number | string;
deviceWidth?: number | string;
color?: boolean;
colorIndex?: boolean;
monochrome?: boolean;
resolution?: number | string;
// types
minAspectRatio?: string;
maxAspectRatio?: string;
minDeviceAspectRatio?: string;
maxDeviceAspectRatio?: string;
minHeight?: number | string;
maxHeight?: number | string;
minDeviceHeight?: number | string;
maxDeviceHeight?: number | string;
minDeviceWidth?: number | string;
maxDeviceWidth?: number | string;
minWidth?: number | string;
maxWidth?: number | string;
minColor?: number;
maxColor?: number;
minColorIndex?: number;
maxColorIndex?: number;
minMonochrome?: number;
maxMonochrome?: number;
minResolution?: number | string;
maxResolution?: number | string;
// types
all?: boolean;
grid?: boolean;
aural?: boolean;
braille?: boolean;
handheld?: boolean;
print?: boolean;
projection?: boolean;
screen?: boolean;
tty?: boolean;
tv?: boolean;
embossed?: boolean;
}
}
class MediaQuery extends React.Component<MediaQuery.MediaQueryProps, any> { }
export = MediaQuery;
}

View File

@@ -0,0 +1,17 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="./react-textarea-autosize.d.ts" />
import * as React from "react";
import Textarea from "react-textarea-autosize";
class Test extends React.Component<{}, {}> {
public render() {
return (
<Textarea minRows={5} maxRows={8}
value="test"
useCacheForDOMMeasurements
className="test"
id="test"/>
);
}
}

View File

@@ -0,0 +1,58 @@
// Type definitions for react-textarea-autosize 4.0.3
// Project: https://github.com/andreypopp/react-textarea-autosize
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
declare module "react-textarea-autosize" {
import * as React from "react";
/**
* <TextareaAutosize/> properties
*/
export interface TextareaAutosizeProps extends React.HTMLProps<HTMLTextAreaElement> {
/**
* Current textarea value
*/
value?: string;
/**
* Callback on value change
* @param event
*/
onChange?: (event: React.FormEvent) => void;
/**
* Callback on height change
* @param height
*/
onHeightChange?: (height: number) => void;
/**
* Try to cache DOM measurements performed by component so that we don't
* touch DOM when it's not needed.
*
* This optimization doesn't work if we dynamically style <textarea />
* component.
* @default false
*/
useCacheForDOMMeasurements?: boolean;
/**
* Minimal number of rows to show.
*/
rows?: number;
/**
* Alias for `rows`.
*/
minRows?: number;
/**
* Maximum number of rows to show.
*/
maxRows?: number;
}
/**
* <TextareaAutosize/>
*/
export default class TextareaAutosize extends React.Component<TextareaAutosizeProps, any> { }
}

View File

@@ -0,0 +1,55 @@
// Tests for type definitions for react-user-tour
// Project: https://github.com/socialtables/react-user-tour
// Definitions by: Carlo Cancellieri <https://github.com/ccancellieri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path='react-user-tour.d.ts' />
/// <reference path='../react/react.d.ts' />
/// <reference path='../react/react-dom.d.ts' />
import React = require('react');
import ReactDOM = require('react-dom');
import ReactUserTour from 'react-user-tour';
interface State {
tourStep:number;
isTourActive:boolean;
}
class TestApp extends React.Component<{}, State> {
constructor(p:any){
super(p);
this.setState({
isTourActive:true,
tourStep:1
});
}
render() {
const Tour = <ReactUserTour active={this.state.isTourActive}
step={this.state.tourStep}
onNext={(step:number) => this.setState({tourStep: step, isTourActive: true})}
onBack={(step:number) => this.setState({tourStep: step, isTourActive: true})}
onCancel={() => this.setState({tourStep: this.state.tourStep, isTourActive: false})}
steps={[
{
step: 1,
selector: '.MyClass',
title: <div>React User Tour</div>,
body: <div>Provide a simple guided tour around a website utilizing css selectors.</div>,
position: 'bottom'
}
]}
/>;
return <div id='test-app' class='.MyClass'>
{Tour}
</div>;
}
}
ReactDOM.render(React.createElement(TestApp, {}), document.getElementById('test-app'));

View File

@@ -0,0 +1 @@
--noImplicitAny --jsx react

133
react-user-tour/react-user-tour.d.ts vendored Normal file
View File

@@ -0,0 +1,133 @@
// Type definitions for react-user-tour
// Project: https://github.com/socialtables/react-user-tour
// Definitions by: Carlo Cancellieri <https://github.com/ccancellieri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path='../react/react.d.ts' />
declare module 'react-user-tour' {
// Import React
import { HTMLAttributes, ComponentClass } from 'react';
interface TourStep {
/**
Index number of the step in the tour
*/
step: number;
/**
CSS selector to be passed to document.querySelector()
*/
selector: string;
/**
a react element representing the header of the current step
*/
title: string;
/**
a react element representing the main body message of the tour step
*/
body: string;
/**
Optional properties horizontalOffset and verticalOffset values allow to move tooltip around pointed element.
*/
horizontalOffset?: number;
/**
Optional properties horizontalOffset and verticalOffset values allow to move tooltip around pointed element.
*/
verticalOffset?: number;
/**
Each step can also take an optional argument, position which will override the position of the tour component in relation to the selector that is determined by the application.
*/
position?: 'left' | 'right' | 'top' | 'topLeft' | 'bottom' | 'bottomLeft';
}
interface TourProps extends HTMLAttributes {
/**
A boolean value representing whether or not the tour should currently be displayed
*/
active: boolean;
/**
An integer representing the current active step of the tour
*/
step: number;
/**
function that fires when user clicks the Next button.
Receives the next step integer as a callback.
For example, if current step is 1 and user clicks the Next button, onNext(2) will be called.
*/
onNext: Function;
/**
function that fires when user clicks the Back button.
Receives the previous step integer as a callback.
For example, if current step is 2 and user clicks the Back button, onBack(1) will be called.
*/
onBack: Function;
/**
function that fires when user clicks the X button or the Done Button.
*/
onCancel: Function;
/**
An array of TourStep.
*/
steps: TourStep[];
/**
Optional style object.
*/
style?: any;
/**
Optional style object for buttons displayed on component.
*/
buttonStyle?: any;
/**
Optional style object for the container div around the buttons.
*/
buttonContainerStyle?: any;
/**
We provide an arrow that points to the selector, but you may optionally pass in your own React element in the place of the arrow provided.
*/
arrow?: any;
/**
If you choose to use the provided arrow, you can set the pixel size here with an integer value.
*/
arrowSize?: number;
/**
If you choose to use the provided arrow, you can set the color here by passing in a hex value.
*/
arrowColor?: string;
/**
Text that will appear on the button that moves the tour forward.
Defaults to Next
*/
nextButtonText?: string;
/**
Text that will appear on the button that moves the tour backwards.
Defaults to Back
*/
backButtonText?: string;
/**
Text that will appear on the button that finishes the tour.
Defaults to Done
*/
doneButtonText?: string;
/**
Text that will appear on the button that closes the tour.
Defaults to Close
*/
closeButtonText?: string;
/**
Boolean to disable the showing of next/back/done buttons.
Set this to true if you want to insert your own buttons in the body.
*/
hideButtons?: boolean;
/**
Boolean to disable the showing of the close text in the upper left of
the component. Set this to true if you want to insert your own close
functionality or if you would like to disable the ability for the user
to prematurely exit the tour.
*/
hideClose?: boolean;
}
var ReactUserTour: ComponentClass<TourProps>;
export default ReactUserTour;
}

View File

@@ -0,0 +1,31 @@
/// <reference path="../redux/redux.d.ts" />
/// <reference path="./redux-storage.d.ts" />
import { Action, createStore, applyMiddleware } from "redux";
import { reducer, createMiddleware, createLoader } from "redux-storage";
import reduxStorageImmutableMerger from "redux-storage-merger-immutablejs";
import filter from "redux-storage-decorator-filter";
import createEngine from "redux-storage-engine-localstorage";
interface TestState {
a: number;
b: string;
}
function rootReducer(state: TestState, action: Action): TestState {
return state;
}
const enhancedReducer = reducer(rootReducer, reduxStorageImmutableMerger);
const storageEngine = createEngine("test");
const initialStateLoader = createLoader(storageEngine);
const storageMiddleware = createMiddleware(storageEngine, [], []);
const store = applyMiddleware(storageMiddleware)(createStore)(enhancedReducer);
initialStateLoader(store).then(() => {
// render app
})

104
redux-storage/redux-storage.d.ts vendored Normal file
View File

@@ -0,0 +1,104 @@
// Type definitions for redux-storage 4.0.1
// Project: https://github.com/michaelcontento/redux-storage
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../redux/redux.d.ts" />
declare module "redux-storage" {
import { Reducer, Store, Middleware } from "redux";
/**
* Action constants
*/
export const LOAD: string;
export const SAVE: string;
/**
* Storage engine interface
*/
export interface StorageEngine {
/**
* Load
*/
load(): PromiseLike<any>;
/**
* Save
* @param state
*/
save(state: any): PromiseLike<any>
}
export interface StateMerger {
(oldState: any, newState: any): any;
}
/**
* Storage reducer
* @param reducer
* @param merger
*/
export function reducer<TState>(reducer: Reducer<TState>, merger?: StateMerger): Reducer<TState>;
/**
* Create storage middleware
* @param engine
* @param actionBlacklist
* @param actionWhitelist
*/
export function createMiddleware(engine: StorageEngine, actionBlacklist?: string[], actionWhitelist?: string[]): Middleware;
/**
* Loader interface
*/
interface Loader<TState> {
(store: Store<TState>): PromiseLike<any>;
}
/**
* Create state loader
* @param engine
*/
export function createLoader<TState>(engine: StorageEngine): Loader<TState>;
}
declare module "redux-storage-decorator-filter" {
import { StorageEngine } from "redux-storage";
interface WhitelistArg {
[key: number]: string | string[];
}
/**
* Filter decorator for redux-storage to only store a subset of the whole state tree.
* @param engine
* @param whitelist
* @example
* engine = filter(engine, [
* 'simple-key',
* ['nested', 'key'],
* ['another', 'very', 'nested', 'key']
* ]);
*/
export default function(engine: StorageEngine, whitelist?: WhitelistArg): StorageEngine;
}
declare module "redux-storage-engine-localstorage" {
import { StorageEngine } from "redux-storage";
export interface LocalStorageEngine extends StorageEngine {}
/**
* Create local storage
* @param key localstorage key
*/
export default function createEngine(key: string): LocalStorageEngine;
}
declare module "redux-storage-merger-immutablejs" {
import { StateMerger } from "redux-storage";
const immutableStateMerger: StateMerger;
export default immutableStateMerger;
}

View File

@@ -0,0 +1,35 @@
///<reference path="redux-ui.d.ts" />
/// <reference path="../react/react.d.ts"/>
import * as React from 'react'
import ui, { ReduxUIProps, reducer } from 'redux-ui'
type UIShape = {
s: string;
};
@ui<UIShape>({
key: 'Root',
persist: true,
state: {
s: '',
},
mergeProps: () => ({}),
options: {}
})
class Root extends React.Component<ReduxUIProps<UIShape>, {}> {
componentWillMount() {
console.info(
this.props.ui.s,
this.props.uiKey
);
this.props.updateUI('s', 'a');
this.props.updateUI({s: 'a'});
this.props.resetUI();
}
}
Redux.combineReducers({
ui: reducer,
});

55
redux-ui/redux-ui.d.ts vendored Normal file
View File

@@ -0,0 +1,55 @@
// Type definitions for redux-ui 0.0.15
// Project: https://github.com/tonyhb/redux-ui
// Definitions by: Andy Shu Xin <https://github.com/andyshuxin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../redux/redux.d.ts"/>
declare module "redux-ui" {
import * as Redux from 'redux';
export interface uiParams<UIStateShape> {
// optional key which is used to determine the UI path in which state will
// be stored. if omitted this is randomly generated.
key?: string;
// optional persist, defaults to false. if set to true persist will keep UI
// state for this component after it unmounts. if set to false the UI state
// will be deleted and recreated when the component remounts
persist?: boolean;
// **required**: UI state for the component
state: UIStateShape;
// optional mergeProps passed to react-redux' @connect
mergeProps?: (stateProps: any, dispatchProps: any, ownProps: any) => any;
// optional `options` passed to react-redux @connect
options?: {
pure?: boolean;
withRef?: boolean;
};
}
export interface ReduxUIProps<UIStateShape> {
// The key passed to the decorator from the decorator
// (eg. 'some-decorator' with `@ui('some-decorator')`
uiKey: string;
// The UI state for the component's `uiKey`
ui: UIStateShape;
// A function accepting either a name/value pair or object which updates
// state within `uiKey`
updateUI(obj: UIStateShape): void;
updateUI(key: string, value: any): void;
// A function which resets the state within `uiKey` to its default
resetUI(): void;
}
export const reducer: Redux.Reducer<any>;
export default function ui<UIStateShape>(params: uiParams<UIStateShape>): <T>(component: T) => T;
}