mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge branch 'types-2.0' into merge_28dec
This commit is contained in:
@@ -38,7 +38,7 @@ or just look for any ".d.ts" files in the package and manually include them with
|
||||
These can be used by TypeScript 1.0.
|
||||
|
||||
* [Typings](https://github.com/typings/typings)
|
||||
* [NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)
|
||||
* ~~[NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)~~ (use preferred alternatives, nuget DT type publishing has been turned off)
|
||||
* Manually download from the `master` branch of this repository
|
||||
|
||||
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
|
||||
|
||||
1
actioncable/index.d.ts
vendored
1
actioncable/index.d.ts
vendored
@@ -7,6 +7,7 @@ declare module ActionCable {
|
||||
interface Channel {
|
||||
unsubscribe(): void;
|
||||
perform(action: string, data: {}): void;
|
||||
send(data: Object): boolean;
|
||||
}
|
||||
|
||||
interface Subscriptions {
|
||||
|
||||
@@ -38,6 +38,7 @@ testApp.config((
|
||||
$datepickerConfig.formatMonth = 'M';
|
||||
$datepickerConfig.formatMonthTitle = 'yy';
|
||||
$datepickerConfig.formatYear = 'y';
|
||||
$datepickerConfig.initDate = '1389586124979';
|
||||
$datepickerConfig.maxDate = '1389586124979';
|
||||
$datepickerConfig.maxMode = 'month';
|
||||
$datepickerConfig.minDate = '1389586124979';
|
||||
|
||||
9
angular-ui-bootstrap/index.d.ts
vendored
9
angular-ui-bootstrap/index.d.ts
vendored
@@ -42,7 +42,6 @@ declare module 'angular' {
|
||||
closeOthers?: boolean;
|
||||
}
|
||||
|
||||
|
||||
interface IButtonConfig {
|
||||
/**
|
||||
* @default: 'active'
|
||||
@@ -55,7 +54,6 @@ declare module 'angular' {
|
||||
toggleEvent?: string;
|
||||
}
|
||||
|
||||
|
||||
interface IDatepickerConfig {
|
||||
/**
|
||||
* Format of day in month.
|
||||
@@ -155,6 +153,13 @@ declare module 'angular' {
|
||||
*/
|
||||
maxDate?: any;
|
||||
|
||||
/**
|
||||
* Defines the initial date, when no model value is specified.
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
initDate?: any;
|
||||
|
||||
/**
|
||||
* An option to disable or enable shortcut's event propagation
|
||||
*
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import * as angular from "angular";
|
||||
import { ui } from "angular";
|
||||
|
||||
angular.module("test", [
|
||||
"ui.router",
|
||||
"ui.router.default"
|
||||
])
|
||||
.config(function($stateProvider: ui.IStateProvider) {
|
||||
.config(function($stateProvider: angular.ui.IStateProvider) {
|
||||
$stateProvider
|
||||
.state('concrete', {
|
||||
// no abstract or default
|
||||
|
||||
11
arcgis-rest-api/arcgis-rest-api-tests.ts
Normal file
11
arcgis-rest-api/arcgis-rest-api-tests.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Point } from "arcgis-rest-api";
|
||||
|
||||
let point: Point;
|
||||
|
||||
point = {
|
||||
x: -122.6764,
|
||||
y: 45.5165,
|
||||
spatialReference: {
|
||||
wkid: 4326
|
||||
}
|
||||
};
|
||||
219
arcgis-rest-api/index.d.ts
vendored
Normal file
219
arcgis-rest-api/index.d.ts
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
// Type definitions for arcgis-to-geojson-utils 10.4
|
||||
// Project: http://resources.arcgis.com/en/help/arcgis-rest-api/
|
||||
// Definitions by: Jeff Jacobson <https://github.com/JeffJacobson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Feature {
|
||||
geometry: Geometry;
|
||||
attributes: any;
|
||||
}
|
||||
|
||||
export interface Field {
|
||||
name: string;
|
||||
type: string;
|
||||
alias?: string;
|
||||
length?: number;
|
||||
}
|
||||
|
||||
export interface FeatureSet extends HasZM {
|
||||
objectIdFieldName?: string; // optional
|
||||
globalIdFieldName?: string; // optional
|
||||
displayFieldName?: string; // optional
|
||||
geometryType?: esriGeometryType; // for feature layers only
|
||||
spatialReference?: SpatialReference; // for feature layers only.
|
||||
fields?: Field[];
|
||||
features: Feature[];
|
||||
}
|
||||
|
||||
export type Position2D = [number, number];
|
||||
export type Position = Position2D | [number, number, number] | [number, number, number, number];
|
||||
|
||||
export interface CircularArc {
|
||||
"c": [Position, Position2D];
|
||||
}
|
||||
|
||||
export interface Arc {
|
||||
"a": [
|
||||
Position, // End point: x, y, <z>, <m>
|
||||
Position2D, // Center point: center_x, center_y
|
||||
number, // minor
|
||||
number, // clockwise
|
||||
number, // rotation
|
||||
number, // axis
|
||||
number // ratio
|
||||
];
|
||||
}
|
||||
|
||||
export type ElipticArc = Arc;
|
||||
|
||||
export interface OldCircularArc {
|
||||
"a": [
|
||||
Position, // End point: x, y, <z>, <m>
|
||||
Position2D, // Center point: center_x, center_y
|
||||
number, // minor
|
||||
number // clockwise
|
||||
];
|
||||
}
|
||||
|
||||
export interface BezierCurve {
|
||||
"b": [
|
||||
Position,
|
||||
Position2D,
|
||||
Position2D
|
||||
];
|
||||
}
|
||||
|
||||
export type JsonCurve = CircularArc | Arc | OldCircularArc | BezierCurve;
|
||||
|
||||
|
||||
export interface SpatialReferenceWkid {
|
||||
wkid?: number;
|
||||
latestWkid?: number;
|
||||
vcsWkid?: number;
|
||||
latestVcsWkid?: number;
|
||||
}
|
||||
|
||||
export interface SpatialReferenceWkt {
|
||||
wkt?: string;
|
||||
latestWkt?: string;
|
||||
}
|
||||
|
||||
export type SpatialReference = SpatialReferenceWkt | SpatialReferenceWkid;
|
||||
|
||||
export interface Geometry {
|
||||
spatialReference?: SpatialReference;
|
||||
}
|
||||
|
||||
export interface HasZM {
|
||||
hasZ?: boolean;
|
||||
hasM?: boolean;
|
||||
}
|
||||
|
||||
export interface Point extends Geometry {
|
||||
x: number;
|
||||
y: number;
|
||||
z?: number;
|
||||
m?: number;
|
||||
}
|
||||
|
||||
export interface Polyline extends HasZM, Geometry {
|
||||
paths: Position[][];
|
||||
}
|
||||
|
||||
export interface PolylineWithCurves extends HasZM, Geometry {
|
||||
curvePaths: Array<Array<(Position | JsonCurve)>>;
|
||||
}
|
||||
|
||||
export interface Polygon extends HasZM, Geometry {
|
||||
rings: Position[][];
|
||||
}
|
||||
|
||||
export interface PolygonWithCurves extends HasZM, Geometry {
|
||||
curveRings: Array<Array<(Position | JsonCurve)>>;
|
||||
}
|
||||
|
||||
export interface Multipoint extends HasZM, Geometry {
|
||||
points: Position[];
|
||||
}
|
||||
|
||||
export interface Envelope extends Geometry {
|
||||
xmin: number;
|
||||
xmax: number;
|
||||
ymin: number;
|
||||
ymax: number;
|
||||
|
||||
zmin?: number;
|
||||
zmax?: number;
|
||||
|
||||
mmin?: number;
|
||||
mmax?: number;
|
||||
}
|
||||
|
||||
export type esriGeometryType = "esriGeometryPoint" | "esriGeometryMultipoint" | "esriGeometryPolyline" | "esriGeometryPolygon" | "esriGeometryEnvelope";
|
||||
|
||||
|
||||
export type Color = [number, number, number, number];
|
||||
export type SimpleMarkerSymbolStyle = "esriSMSCircle" | "esriSMSCross" | "esriSMSDiamond" | "esriSMSSquare" | "esriSMSX" | "esriSMSTriangle";
|
||||
export type SimpleLineSymbolStyle = "esriSLSDash" | "esriSLSDashDot" | "esriSLSDashDotDot" | "esriSLSDot" | "esriSLSNull" | "esriSLSSolid";
|
||||
export type SimpleFillSymbolStyle = "esriSFSBackwardDiagonal" | "esriSFSCross" | "esriSFSDiagonalCross" | "esriSFSForwardDiagonal" | "esriSFSHorizontal" | "esriSFSNull" | "esriSFSSolid" | "esriSFSVertical";
|
||||
export type SymbolType = "esriSLS" | "esriSMS" | "esriSFS" | "esriPMS" | "esriPFS" | "esriTS";
|
||||
|
||||
export interface Symbol {
|
||||
"type": SymbolType;
|
||||
"style"?: string;
|
||||
}
|
||||
|
||||
export interface SimpleLineSymbol extends Symbol {
|
||||
"type": "esriSLS";
|
||||
"style"?: SimpleLineSymbolStyle;
|
||||
"color"?: Color;
|
||||
"width"?: number;
|
||||
}
|
||||
|
||||
export interface MarkerSymbol extends Symbol {
|
||||
"angle"?: number;
|
||||
"xoffset"?: number;
|
||||
"yoffset"?: number;
|
||||
}
|
||||
|
||||
export interface SimpleMarkerSymbol extends MarkerSymbol {
|
||||
"type": "esriSMS";
|
||||
"style"?: SimpleMarkerSymbolStyle;
|
||||
"color"?: Color;
|
||||
"size"?: number;
|
||||
"outline"?: SimpleLineSymbol;
|
||||
}
|
||||
|
||||
export interface SimpleFillSymbol extends Symbol {
|
||||
"type": "esriSFS";
|
||||
"style"?: SimpleFillSymbolStyle;
|
||||
"color"?: Color;
|
||||
"outline"?: SimpleLineSymbol; //if outline has been specified
|
||||
}
|
||||
|
||||
export interface PictureSourced {
|
||||
"url"?: string; //Relative URL for static layers and full URL for dynamic layers. Access relative URL using http://<mapservice-url>/<layerId1>/images/<imageUrl11>
|
||||
"imageData"?: string; //"<base64EncodedImageData>";
|
||||
"contentType"?: string;
|
||||
"width"?: number;
|
||||
"height"?: number;
|
||||
"angle"?: number;
|
||||
"xoffset"?: number;
|
||||
"yoffset"?: number;
|
||||
|
||||
}
|
||||
|
||||
export interface PictureMarkerSymbol extends MarkerSymbol, PictureSourced {
|
||||
"type": "esriPMS";
|
||||
}
|
||||
|
||||
export interface PictureFillSymbol extends Symbol, PictureSourced {
|
||||
"type": "esriPFS";
|
||||
"outline"?: SimpleLineSymbol; //if outline has been specified
|
||||
"xscale"?: number;
|
||||
"yscale"?: number;
|
||||
}
|
||||
|
||||
export interface Font {
|
||||
"family"?: string; //"<fontFamily>";
|
||||
"size"?: number; //<fontSize>;
|
||||
"style"?: "italic" | "normal" | "oblique";
|
||||
"weight"?: "bold" | "bolder" | "lighter" | "normal";
|
||||
"decoration"?: "line-through" | "underline" | "none";
|
||||
}
|
||||
|
||||
export interface TextSymbol extends MarkerSymbol {
|
||||
"type": "esriTS";
|
||||
"color"?: Color;
|
||||
"backgroundColor"?: Color;
|
||||
"borderLineSize"?: number; // <size>;
|
||||
"borderLineColor"?: Color;
|
||||
"haloSize"?: number; // <size>;
|
||||
"haloColor"?: Color;
|
||||
"verticalAlignment"?: "baseline" | "top" | "middle" | "bottom";
|
||||
"horizontalAlignment"?: "left" | "right" | "center" | "justify";
|
||||
"rightToLeft"?: boolean;
|
||||
"kerning"?: boolean;
|
||||
"font"?: Font;
|
||||
"text"?: string; //only applicable when specified as a client-side graphic.
|
||||
}
|
||||
20
arcgis-rest-api/tsconfig.json
Normal file
20
arcgis-rest-api/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"arcgis-rest-api-tests.ts"
|
||||
]
|
||||
}
|
||||
3
arcgis-rest-api/tslint.json
Normal file
3
arcgis-rest-api/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
20
arcgis-to-geojson-utils/arcgis-to-geojson-utils-tests.ts
Normal file
20
arcgis-to-geojson-utils/arcgis-to-geojson-utils-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import utils = require("arcgis-to-geojson-utils");
|
||||
import arcgisApi = require("arcgis-rest-api");
|
||||
|
||||
let arcgisPoint: arcgisApi.Point = {
|
||||
x: -122.6764,
|
||||
y: 45.5165,
|
||||
spatialReference: {
|
||||
wkid: 4326
|
||||
}
|
||||
};
|
||||
let geojsonPoint: GeoJSON.Point = {
|
||||
type: "Point",
|
||||
coordinates: [45.5165, -122.6764]
|
||||
};
|
||||
|
||||
// parse ArcGIS JSON, convert it to GeoJSON
|
||||
var geojson = utils.arcgisToGeoJSON(arcgisPoint);
|
||||
|
||||
// take GeoJSON and convert it to ArcGIS JSON
|
||||
var arcgis = utils.geojsonToArcGIS(geojsonPoint);
|
||||
18
arcgis-to-geojson-utils/index.d.ts
vendored
Normal file
18
arcgis-to-geojson-utils/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for arcgis-to-geojson-utils 1.0
|
||||
// Project: https://github.com/Esri/arcgis-to-geojson-utils
|
||||
// Definitions by: Jeff Jacobson <https://github.com/JeffJacobson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="geojson" />
|
||||
|
||||
import * as ArcGis from "arcgis-rest-api";
|
||||
|
||||
/**
|
||||
* Converts an ArcGIS geometry into a GeoJSON geometry.
|
||||
*/
|
||||
export function arcgisToGeoJSON<T extends ArcGis.Geometry>(arcgis: T): GeoJSON.GeometryObject;
|
||||
|
||||
/**
|
||||
* Converts a GeoJSON geometry into a ArcGIS geometry.
|
||||
*/
|
||||
export function geojsonToArcGIS(geojson: GeoJSON.GeometryObject): ArcGis.Geometry;
|
||||
19
arcgis-to-geojson-utils/tsconfig.json
Normal file
19
arcgis-to-geojson-utils/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"arcgis-to-geojson-utils-tests.ts"
|
||||
]
|
||||
}
|
||||
3
arcgis-to-geojson-utils/tslint.json
Normal file
3
arcgis-to-geojson-utils/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
56
chai-json-schema/chai-json-schema-tests.ts
Normal file
56
chai-json-schema/chai-json-schema-tests.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
|
||||
import { expect } from 'chai';
|
||||
import { assert } from 'chai';
|
||||
|
||||
import chai = require('chai');
|
||||
import ChaiJsonSchema = require('chai-json-schema');
|
||||
|
||||
chai.use(ChaiJsonSchema);
|
||||
chai.should();
|
||||
|
||||
let goodApple = {
|
||||
skin: 'thin',
|
||||
colors: ['red', 'green', 'yellow'],
|
||||
taste: 10
|
||||
};
|
||||
|
||||
let badApple = {
|
||||
colors: ['brown'],
|
||||
taste: 0,
|
||||
worms: 2
|
||||
};
|
||||
|
||||
let fruitSchema = {
|
||||
title: 'fresh fruit schema v1',
|
||||
type: 'object',
|
||||
required: ['skin', 'colors', 'taste'],
|
||||
properties: {
|
||||
colors: {
|
||||
type: 'array',
|
||||
minItems: 1,
|
||||
uniqueItems: true,
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
skin: {
|
||||
type: 'string'
|
||||
},
|
||||
taste: {
|
||||
type: 'number',
|
||||
minimum: 5
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//bdd style
|
||||
expect(goodApple).to.be.jsonSchema(fruitSchema);
|
||||
expect(badApple).to.not.be.jsonSchema(fruitSchema);
|
||||
|
||||
goodApple.should.be.jsonSchema(fruitSchema);
|
||||
badApple.should.not.be.jsonSchema(fruitSchema);
|
||||
|
||||
//tdd style
|
||||
assert.jsonSchema(goodApple, fruitSchema);
|
||||
assert.notJsonSchema(badApple, fruitSchema);
|
||||
24
chai-json-schema/index.d.ts
vendored
Normal file
24
chai-json-schema/index.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Type definitions for chai-json-schema 1.4
|
||||
// Project: https://github.com/chaijs/chai-json-schema/
|
||||
// Definitions by: Ulrich Heiniger <https://github.com/ulrichheiniger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// <reference types="node"/>
|
||||
// <reference types="chai" />
|
||||
|
||||
declare namespace Chai {
|
||||
export interface Assert {
|
||||
jsonSchema(value: any, schema: any, msg?: string): void;
|
||||
notJsonSchema(value: any, schema: any, msg?: string): void;
|
||||
}
|
||||
|
||||
export interface LanguageChains {
|
||||
jsonSchema(schema: any, msg?: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "chai-json-schema" {
|
||||
function chaiJsonSchema(chai: any, utils: any): void;
|
||||
namespace chaiJsonSchema {}
|
||||
export = chaiJsonSchema;
|
||||
}
|
||||
19
chai-json-schema/tsconfig.json
Normal file
19
chai-json-schema/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"chai-json-schema-tests.ts"
|
||||
]
|
||||
}
|
||||
5
chai-json-schema/tslint.json
Normal file
5
chai-json-schema/tslint.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{ "extends": "../tslint.json",
|
||||
"rules": {
|
||||
"no-single-declare-module": false
|
||||
}
|
||||
}
|
||||
5
chart.js/index.d.ts
vendored
5
chart.js/index.d.ts
vendored
@@ -172,11 +172,11 @@ interface ChartAnimationOptions {
|
||||
interface ChartElementsOptions {
|
||||
point?: ChartPointOptions;
|
||||
line?: ChartLineOptions;
|
||||
arg?: ChartArcOtpions;
|
||||
arc?: ChartArcOptions;
|
||||
rectangle?: ChartRectangleOptions;
|
||||
}
|
||||
|
||||
interface ChartArcOtpions {
|
||||
interface ChartArcOptions {
|
||||
backgroundColor?: ChartColor;
|
||||
borderColor?: ChartColor;
|
||||
borderWidth?: number;
|
||||
@@ -394,6 +394,7 @@ interface RadialLinearScale {
|
||||
declare class Chart {
|
||||
constructor (context: CanvasRenderingContext2D | HTMLCanvasElement, options: ChartConfiguration);
|
||||
config: ChartConfiguration;
|
||||
data: ChartData;
|
||||
destroy: () => {};
|
||||
update: (duration?: any, lazy?: any) => {};
|
||||
render: (duration?: any, lazy?: any) => {};
|
||||
|
||||
403
chrome/chrome-app.d.ts
vendored
403
chrome/chrome-app.d.ts
vendored
@@ -355,6 +355,14 @@ declare namespace chrome.sockets.tcp {
|
||||
var onReceiveError: chrome.events.Event<(args: ReceiveErrorEventArgs) => void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the chrome.sockets.udp API to send and receive data over the network
|
||||
* using UDP connections. This API supersedes the UDP functionality previously
|
||||
* found in the "socket" API.
|
||||
*
|
||||
* @since Chrome 33
|
||||
* @see https://developer.chrome.com/apps/sockets_udp
|
||||
*/
|
||||
declare namespace chrome.sockets.udp {
|
||||
interface CreateInfo {
|
||||
socketId: number;
|
||||
@@ -377,43 +385,278 @@ declare namespace chrome.sockets.udp {
|
||||
resultCode: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#type-SocketProperties
|
||||
*/
|
||||
interface SocketProperties {
|
||||
/**
|
||||
* Flag indicating if the socket is left open when the event page of the
|
||||
* application is unloaded. The default value is "false." When the
|
||||
* application is loaded, any sockets previously opened with
|
||||
* persistent=true can be fetched with getSockets.
|
||||
* @see http://developer.chrome.com/apps/app_lifecycle.html
|
||||
*/
|
||||
persistent?: boolean;
|
||||
|
||||
/** An application-defined string associated with the socket. */
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The size of the buffer used to receive data. If the buffer is too
|
||||
* small to receive the UDP packet, data is lost. The default value is
|
||||
* 4096.
|
||||
*/
|
||||
bufferSize?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#type-SocketInfo
|
||||
*/
|
||||
interface SocketInfo {
|
||||
/** The socket identifier. */
|
||||
socketId: number;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the socket is left open when the application
|
||||
* is suspended (see SocketProperties.persistent).
|
||||
*/
|
||||
persistent: boolean;
|
||||
|
||||
/** Application-defined string associated with the socket. */
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* The size of the buffer used to receive data. If no buffer size ha
|
||||
* been specified explictly, the value is not provided.
|
||||
*/
|
||||
bufferSize?: number;
|
||||
|
||||
/**
|
||||
* Flag indicating whether the socket is blocked from firing onReceive
|
||||
* events.
|
||||
*/
|
||||
paused: boolean;
|
||||
|
||||
/**
|
||||
* If the underlying socket is bound, contains its local IPv4/6 address.
|
||||
*/
|
||||
localAddress?: string;
|
||||
|
||||
/**
|
||||
* If the underlying socket is bound, contains its local port.
|
||||
*/
|
||||
localPort?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UDP socket with default properties.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-create
|
||||
* @param createInfo.socketId The ID of the newly created socket.
|
||||
*/
|
||||
export function create(callback: (createInfo: CreateInfo) => void): void;
|
||||
export function create(properties: SocketProperties,
|
||||
callback: (createInfo: CreateInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Creates a UDP socket with the given properties.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-create
|
||||
* @param properties The socket properties.
|
||||
* @param createInfo.socketId The ID of the newly created socket.
|
||||
*/
|
||||
export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Updates the socket properties.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-update
|
||||
* @param socketId The socket ID.
|
||||
* @param properties The properties to update.
|
||||
* @param callback Called when the properties are updated.
|
||||
*/
|
||||
export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Pauses or unpauses a socket. A paused socket is blocked from firing
|
||||
* onReceive events.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-setPaused
|
||||
* @param socketId The socket ID.
|
||||
* @param paused Flag to indicate whether to pause or unpause.
|
||||
* @param callback Called when the socket has been successfully paused or
|
||||
* unpaused.
|
||||
*/
|
||||
export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Binds the local address and port for the socket. For a client socket, it
|
||||
* is recommended to use port 0 to let the platform pick a free port.
|
||||
*
|
||||
* Once the bind operation completes successfully, onReceive events are
|
||||
* raised when UDP packets arrive on the address/port specified -- unless
|
||||
* the socket is paused.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-bind
|
||||
* @param socketId The socket ID.
|
||||
* @param address The address of the local machine. DNS name, IPv4 and IPv6
|
||||
* formats are supported. Use "0.0.0.0" to accept packets
|
||||
* from all local available network interfaces.
|
||||
* @param port The port of the local machine. Use "0" to bind to a free
|
||||
* port.
|
||||
* @param callback Called when the bind operation completes.
|
||||
*/
|
||||
export function bind(socketId: number, address: string, port: number, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Sends data on the given socket to the given address and port. The socket
|
||||
* must be bound to a local port before calling this method.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-send
|
||||
* @param socketId The socket ID.
|
||||
* @param data The data to send.
|
||||
* @param address The address of the remote machine.
|
||||
* @param port The port of the remote machine.
|
||||
* @param callback Called when the send operation completes.
|
||||
*/
|
||||
export function send(socketId: number, data: ArrayBuffer, address: string, port: number, callback: (sendInfo: SendInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Closes the socket and releases the address/port the socket is bound to.
|
||||
* Each socket created should be closed after use. The socket id is no
|
||||
* longer valid as soon at the function is called. However, the socket is
|
||||
* guaranteed to be closed only when the callback is invoked.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-close
|
||||
* @param socketId The socket ID.
|
||||
* @param callback Called when the close operation completes.
|
||||
*/
|
||||
export function close(socketId: number, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Retrieves the state of the given socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-getInfo
|
||||
* @param socketId The socket ID.
|
||||
* @param callback Called when the socket state is available.
|
||||
*/
|
||||
export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Retrieves the list of currently opened sockets owned by the application.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-getSockets
|
||||
* @param callback Called when the list of sockets is available.
|
||||
*/
|
||||
export function getSockets(callback: (socketInfos: SocketInfo[]) => void): void;
|
||||
|
||||
/**
|
||||
* Joins the multicast group and starts to receive packets from that group.
|
||||
* The socket must be bound to a local port before calling this method.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-joinGroup
|
||||
* @param socketId The socket ID.
|
||||
* @param address The group address to join. Domain names are not supported.
|
||||
* @param callback Called when the joinGroup operation completes.
|
||||
*/
|
||||
export function joinGroup(socketId: number, address: string, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Leaves the multicast group previously joined using joinGroup. This is
|
||||
* only necessary to call if you plan to keep using the socket afterwards,
|
||||
* since it will be done automatically by the OS when the socket is closed.
|
||||
*
|
||||
* Leaving the group will prevent the router from sending multicast
|
||||
* datagrams to the local host, presuming no other process on the host is
|
||||
* still joined to the group.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-leaveGroup
|
||||
* @param socketId The socket ID.
|
||||
* @param address The group address to leave. Domain names are not
|
||||
* supported.
|
||||
* @param callback Called when the leaveGroup operation completes.
|
||||
*/
|
||||
export function leaveGroup(socketId: number, address: string, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Sets the time-to-live of multicast packets sent to the multicast group.
|
||||
*
|
||||
* Calling this method does not require multicast permissions.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-setMulticastTimeToLive
|
||||
* @param socketId The socket ID.
|
||||
* @param ttl The time-to-live value.
|
||||
* @param callback Called when the configuration operation completes.
|
||||
*/
|
||||
export function setMulticastTimeToLive(socketId: number, ttl: number, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Sets whether multicast packets sent from the host to the multicast group
|
||||
* will be looped back to the host.
|
||||
*
|
||||
* Note: the behavior of setMulticastLoopbackMode is slightly different
|
||||
* between Windows and Unix-like systems. The inconsistency happens only
|
||||
* when there is more than one application on the same host joined to the
|
||||
* same multicast group while having different settings on multicast
|
||||
* loopback mode. On Windows, the applications with loopback off will not
|
||||
* RECEIVE the loopback packets; while on Unix-like systems, the
|
||||
* applications with loopback off will not SEND the loopback packets to
|
||||
* other applications on the same host.
|
||||
* @see MSDN: http://goo.gl/6vqbj
|
||||
*
|
||||
* Calling this method does not require multicast permissions.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-setMulticastLoopbackMode
|
||||
* @param socketId The socket ID.
|
||||
* @param enabled Indicate whether to enable loopback mode.
|
||||
* @param callback Called when the configuration operation completes.
|
||||
*/
|
||||
export function setMulticastLoopbackMode(socketId: number, enabled: boolean, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Gets the multicast group addresses the socket is currently joined to.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-getJoinedGroups
|
||||
* @param socketId The socket ID.
|
||||
* @param callback Called with an array of strings of the result.
|
||||
*/
|
||||
export function getJoinedGroups(socketId: number, callback: (groups: string[]) => void): void;
|
||||
|
||||
/**
|
||||
* Enables or disables broadcast packets on this socket.
|
||||
*
|
||||
* @since Chrome 44
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#method-setBroadcast
|
||||
* @param socketId The socket ID.
|
||||
* @param enabled true to enable broadcast packets, false to disable them.
|
||||
* @param callback Callback from the setBroadcast method.
|
||||
*/
|
||||
export function setBroadcast(socketId: number, enabled: boolean, callback?: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Event raised when a UDP packet has been received for the given socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#event-onReceive
|
||||
*/
|
||||
var onReceive: chrome.events.Event<(args: ReceiveEventArgs) => void>;
|
||||
|
||||
/**
|
||||
* Event raised when a network error occured while the runtime was waiting
|
||||
* for data on the socket address and port. Once this event is raised, the
|
||||
* socket is paused and no more onReceive events will be raised for this
|
||||
* socket until the socket is resumed.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_udp#event-onReceiveError
|
||||
*/
|
||||
var onReceiveError: chrome.events.Event<(args: ReceiveErrorEventArgs) => void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the chrome.sockets.tcpServer API to create server applications using TCP
|
||||
* connections. This API supersedes the TCP functionality previously found in
|
||||
* the chrome.socket API.
|
||||
*
|
||||
* @since Chrome 33
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer
|
||||
*/
|
||||
declare namespace chrome.sockets.tcpServer {
|
||||
interface CreateInfo {
|
||||
socketId: number;
|
||||
@@ -429,36 +672,180 @@ declare namespace chrome.sockets.tcpServer {
|
||||
resultCode: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#type-SocketProperties
|
||||
*/
|
||||
interface SocketProperties {
|
||||
/**
|
||||
* Flag indicating if the socket remains open when the event page of the
|
||||
* application is unloaded. The default value is "false." When the
|
||||
* application is loaded, any sockets previously opened with
|
||||
* persistent=true can be fetched with getSockets.
|
||||
*
|
||||
* @see http://developer.chrome.com/apps/app_lifecycle.html
|
||||
*/
|
||||
persistent?: boolean;
|
||||
|
||||
/** An application-defined string associated with the socket. */
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#type-SocketInfo
|
||||
*/
|
||||
interface SocketInfo {
|
||||
/** The socket identifier. */
|
||||
socketId: number;
|
||||
|
||||
/**
|
||||
* Flag indicating if the socket remains open when the event page of the
|
||||
* application is unloaded (see SocketProperties.persistent). The
|
||||
* default value is "false".
|
||||
*/
|
||||
persistent: boolean;
|
||||
|
||||
/** Application-defined string associated with the socket. */
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Flag indicating whether connection requests on a listening socket are
|
||||
* dispatched through the onAccept event or queued up in the listen
|
||||
* queue backlog. See setPaused. The default value is "false"
|
||||
*/
|
||||
paused: boolean;
|
||||
|
||||
/** If the socket is listening, contains its local IPv4/6 address. */
|
||||
localAddress?: string;
|
||||
|
||||
/** If the socket is listening, contains its local port. */
|
||||
localPort?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a TCP server socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-create
|
||||
* @param callback Called when the socket has been created.
|
||||
*/
|
||||
export function create(callback: (createInfo: CreateInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Creates a TCP server socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-create
|
||||
* @param properties The socket properties.
|
||||
* @param callback Called when the socket has been created.
|
||||
*/
|
||||
export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Updates the socket properties.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-update
|
||||
* @param socketId The socket identifier.
|
||||
* @param properties The properties to update.
|
||||
* @param callback Called when the properties are updated.
|
||||
*/
|
||||
export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Enables or disables a listening socket from accepting new connections.
|
||||
* When paused, a listening socket accepts new connections until its backlog
|
||||
* (see listen function) is full then refuses additional connection
|
||||
* requests. onAccept events are raised only when the socket is un-paused.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-setPaused
|
||||
* @param callback Callback from the setPaused method.
|
||||
*/
|
||||
export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
|
||||
|
||||
export function listen(socketId: number, address: string,
|
||||
port: number, backlog: number, callback: (result: number) => void): void;
|
||||
export function listen(socketId: number, address: string,
|
||||
port: number, callback: (result: number) => void): void;
|
||||
/**
|
||||
* Listens for connections on the specified port and address. If the
|
||||
* port/address is in use, the callback indicates a failure.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-listen
|
||||
* @param socketId The socket identifier.
|
||||
* @param address The address of the local machine.
|
||||
* @param port The port of the local machine. When set to 0, a free port
|
||||
* is chosen dynamically. The dynamically allocated port can
|
||||
* be found by calling getInfo.
|
||||
* @param backlog Length of the socket's listen queue. The default value
|
||||
* depends on the Operating System (SOMAXCONN), which
|
||||
* ensures a reasonable queue length for most applications.
|
||||
* @param callback Called when listen operation completes.
|
||||
*/
|
||||
export function listen(socketId: number, address: string, port: number, backlog: number, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Listens for connections on the specified port and address. If the
|
||||
* port/address is in use, the callback indicates a failure.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-listen
|
||||
* @param socketId The socket identifier.
|
||||
* @param address The address of the local machine.
|
||||
* @param port The port of the local machine. When set to 0, a free port
|
||||
* is chosen dynamically. The dynamically allocated port can
|
||||
* be found by calling getInfo.
|
||||
* @param callback Called when listen operation completes.
|
||||
*/
|
||||
export function listen(socketId: number, address: string, port: number, callback: (result: number) => void): void;
|
||||
|
||||
/**
|
||||
* Disconnects the listening socket, i.e. stops accepting new connections
|
||||
* and releases the address/port the socket is bound to. The socket
|
||||
* identifier remains valid, e.g. it can be used with listen to accept
|
||||
* connections on a new port and address.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-disconnect
|
||||
* @param socketId The socket identifier.
|
||||
* @param callback Called when the disconnect attempt is complete.
|
||||
*/
|
||||
export function disconnect(socketId: number, callback?: () => void): void;
|
||||
export function close(socketId: number, callback?: () => void): void;
|
||||
export function getInfo(socketId: number, callback: (socketInfos: SocketInfo[]) => void): void;
|
||||
|
||||
/**
|
||||
* Disconnects and destroys the socket. Each socket created should be closed
|
||||
* after use. The socket id is no longer valid as soon at the function is
|
||||
* called. However, the socket is guaranteed to be closed only when the
|
||||
* callback is invoked.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-close
|
||||
* @param socketId The socket identifier.
|
||||
* @param callback Called when the close operation completes.
|
||||
*/
|
||||
export function close(socketId: number, callback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Retrieves the state of the given socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-getInfo
|
||||
* @param socketId The socket identifier.
|
||||
* @param callback Called when the socket state is available.
|
||||
*/
|
||||
export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
|
||||
|
||||
/**
|
||||
* Retrieves the list of currently opened sockets owned by the application.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#method-getSockets
|
||||
* @param callback Called when the list of sockets is available.
|
||||
*/
|
||||
export function getSockets(callback: (socketInfos: SocketInfo[]) => void): void;
|
||||
|
||||
/**
|
||||
* Event raised when a connection has been made to the server socket.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#event-onAccept
|
||||
*/
|
||||
var onAccept: chrome.events.Event<(args: AcceptEventArgs) => void>;
|
||||
|
||||
/**
|
||||
* Event raised when a network error occured while the runtime was waiting
|
||||
* for new connections on the socket address and port. Once this event is
|
||||
* raised, the socket is set to paused and no more onAccept events are
|
||||
* raised for this socket until the socket is resumed.
|
||||
*
|
||||
* @see https://developer.chrome.com/apps/sockets_tcpServer#event-onAcceptError
|
||||
*/
|
||||
var onAcceptError: chrome.events.Event<(args: AcceptErrorEventArgs) => void>;
|
||||
}
|
||||
|
||||
|
||||
7
codemirror/index.d.ts
vendored
7
codemirror/index.d.ts
vendored
@@ -178,6 +178,13 @@ declare namespace CodeMirror {
|
||||
class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */
|
||||
removeLineClass(line: any, where: string, class_: string): CodeMirror.LineHandle;
|
||||
|
||||
/**
|
||||
* Compute the line at the given pixel height.
|
||||
*
|
||||
* `mode` is the relative element to use to compute this line - defaults to 'page' if not specified
|
||||
*/
|
||||
lineAtHeight(height: number, mode?: 'window' | 'page' | 'local'): number
|
||||
|
||||
/** Returns the line number, text content, and marker status of the given line, which can be either a number or a line handle. */
|
||||
lineInfo(line: any): {
|
||||
line: any;
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
import colors = require("colors");
|
||||
import { zalgo } from "colors/safe";
|
||||
|
||||
let str: string;
|
||||
|
||||
str = zalgo("");
|
||||
|
||||
colors.enabled = true;
|
||||
|
||||
console.log(colors.black.underline('test'));
|
||||
console.log(colors.rainbow.black.blue.gray('test'));
|
||||
console.log(colors.random.reset.bgWhite.dim('test'));
|
||||
console.log(colors.random.reset.bgWhite.strip('test'));
|
||||
console.log('test'.black.underline);
|
||||
console.log('test'.rainbow.black.blue.gray);
|
||||
console.log('test'.random.reset.bgWhite.dim);
|
||||
console.log('test'.random.reset.bgWhite.dim.stripColors);
|
||||
str = colors.black.underline('test');
|
||||
str = colors.rainbow.black.blue.gray('test');
|
||||
str = colors.random.reset.bgWhite.dim('test');
|
||||
str = colors.random.reset.bgWhite.strip('test');
|
||||
str = 'test'.black.underline;
|
||||
str = 'test'.rainbow.black.blue.gray;
|
||||
str = 'test'.random.reset.bgWhite.dim;
|
||||
str = 'test'.random.reset.bgWhite.dim.stripColors;
|
||||
|
||||
colors.enabled = false;
|
||||
|
||||
console.log(colors.black.underline('test'));
|
||||
str = colors.black.underline('test');
|
||||
|
||||
242
colors/index.d.ts
vendored
242
colors/index.d.ts
vendored
@@ -1,137 +1,133 @@
|
||||
// Type definitions for Colors.js 0.6.0-1
|
||||
// Type definitions for Colors.js 1.1
|
||||
// Project: https://github.com/Marak/colors.js
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "colors" {
|
||||
interface Color {
|
||||
(text: string): string;
|
||||
interface Color {
|
||||
(text: string): string;
|
||||
|
||||
strip: Color;
|
||||
stripColors: Color;
|
||||
strip: Color;
|
||||
stripColors: Color;
|
||||
|
||||
black: Color;
|
||||
red: Color;
|
||||
green: Color;
|
||||
yellow: Color;
|
||||
blue: Color;
|
||||
magenta: Color;
|
||||
cyan: Color;
|
||||
white: Color;
|
||||
gray: Color;
|
||||
grey: Color;
|
||||
black: Color;
|
||||
red: Color;
|
||||
green: Color;
|
||||
yellow: Color;
|
||||
blue: Color;
|
||||
magenta: Color;
|
||||
cyan: Color;
|
||||
white: Color;
|
||||
gray: Color;
|
||||
grey: Color;
|
||||
|
||||
bgBlack: Color;
|
||||
bgRed: Color;
|
||||
bgGreen: Color;
|
||||
bgYellow: Color;
|
||||
bgBlue: Color;
|
||||
bgMagenta: Color;
|
||||
bgCyan: Color;
|
||||
bgWhite: Color;
|
||||
bgBlack: Color;
|
||||
bgRed: Color;
|
||||
bgGreen: Color;
|
||||
bgYellow: Color;
|
||||
bgBlue: Color;
|
||||
bgMagenta: Color;
|
||||
bgCyan: Color;
|
||||
bgWhite: Color;
|
||||
|
||||
reset: Color;
|
||||
bold: Color;
|
||||
dim: Color;
|
||||
italic: Color;
|
||||
underline: Color;
|
||||
inverse: Color;
|
||||
hidden: Color;
|
||||
strikethrough: Color;
|
||||
reset: Color;
|
||||
bold: Color;
|
||||
dim: Color;
|
||||
italic: Color;
|
||||
underline: Color;
|
||||
inverse: Color;
|
||||
hidden: Color;
|
||||
strikethrough: Color;
|
||||
|
||||
rainbow: Color;
|
||||
zebra: Color;
|
||||
america: Color;
|
||||
trap: Color;
|
||||
random: Color;
|
||||
zalgo: Color;
|
||||
}
|
||||
|
||||
namespace e {
|
||||
export function setTheme(theme:any): void;
|
||||
|
||||
export var enabled: boolean;
|
||||
|
||||
export var strip: Color;
|
||||
export var stripColors: Color;
|
||||
|
||||
export var black: Color;
|
||||
export var red: Color;
|
||||
export var green: Color;
|
||||
export var yellow: Color;
|
||||
export var blue: Color;
|
||||
export var magenta: Color;
|
||||
export var cyan: Color;
|
||||
export var white: Color;
|
||||
export var gray: Color;
|
||||
export var grey: Color;
|
||||
|
||||
export var bgBlack: Color;
|
||||
export var bgRed: Color;
|
||||
export var bgGreen: Color;
|
||||
export var bgYellow: Color;
|
||||
export var bgBlue: Color;
|
||||
export var bgMagenta: Color;
|
||||
export var bgCyan: Color;
|
||||
export var bgWhite: Color;
|
||||
|
||||
export var reset: Color;
|
||||
export var bold: Color;
|
||||
export var dim: Color;
|
||||
export var italic: Color;
|
||||
export var underline: Color;
|
||||
export var inverse: Color;
|
||||
export var hidden: Color;
|
||||
export var strikethrough: Color;
|
||||
|
||||
export var rainbow: Color;
|
||||
export var zebra: Color;
|
||||
export var america: Color;
|
||||
export var trap: Color;
|
||||
export var random: Color;
|
||||
export var zalgo: Color;
|
||||
}
|
||||
|
||||
export = e;
|
||||
rainbow: Color;
|
||||
zebra: Color;
|
||||
america: Color;
|
||||
trap: Color;
|
||||
random: Color;
|
||||
zalgo: Color;
|
||||
}
|
||||
|
||||
interface String {
|
||||
strip: string;
|
||||
stripColors: string;
|
||||
export function setTheme(theme: any): void;
|
||||
|
||||
black: string;
|
||||
red: string;
|
||||
green: string;
|
||||
yellow: string;
|
||||
blue: string;
|
||||
magenta: string;
|
||||
cyan: string;
|
||||
white: string;
|
||||
gray: string;
|
||||
grey: string;
|
||||
export var enabled: boolean;
|
||||
|
||||
bgBlack: string;
|
||||
bgRed: string;
|
||||
bgGreen: string;
|
||||
bgYellow: string;
|
||||
bgBlue: string;
|
||||
bgMagenta: string;
|
||||
bgCyan: string;
|
||||
bgWhite: string;
|
||||
export var strip: Color;
|
||||
export var stripColors: Color;
|
||||
|
||||
reset: string;
|
||||
bold: string;
|
||||
dim: string;
|
||||
italic: string;
|
||||
underline: string;
|
||||
inverse: string;
|
||||
hidden: string;
|
||||
strikethrough: string;
|
||||
export var black: Color;
|
||||
export var red: Color;
|
||||
export var green: Color;
|
||||
export var yellow: Color;
|
||||
export var blue: Color;
|
||||
export var magenta: Color;
|
||||
export var cyan: Color;
|
||||
export var white: Color;
|
||||
export var gray: Color;
|
||||
export var grey: Color;
|
||||
|
||||
rainbow: string;
|
||||
zebra: string;
|
||||
america: string;
|
||||
trap: string;
|
||||
random: string;
|
||||
zalgo: string;
|
||||
}
|
||||
export var bgBlack: Color;
|
||||
export var bgRed: Color;
|
||||
export var bgGreen: Color;
|
||||
export var bgYellow: Color;
|
||||
export var bgBlue: Color;
|
||||
export var bgMagenta: Color;
|
||||
export var bgCyan: Color;
|
||||
export var bgWhite: Color;
|
||||
|
||||
export var reset: Color;
|
||||
export var bold: Color;
|
||||
export var dim: Color;
|
||||
export var italic: Color;
|
||||
export var underline: Color;
|
||||
export var inverse: Color;
|
||||
export var hidden: Color;
|
||||
export var strikethrough: Color;
|
||||
|
||||
export var rainbow: Color;
|
||||
export var zebra: Color;
|
||||
export var america: Color;
|
||||
export var trap: Color;
|
||||
export var random: Color;
|
||||
export var zalgo: Color;
|
||||
|
||||
declare global {
|
||||
interface String {
|
||||
strip: string;
|
||||
stripColors: string;
|
||||
|
||||
black: string;
|
||||
red: string;
|
||||
green: string;
|
||||
yellow: string;
|
||||
blue: string;
|
||||
magenta: string;
|
||||
cyan: string;
|
||||
white: string;
|
||||
gray: string;
|
||||
grey: string;
|
||||
|
||||
bgBlack: string;
|
||||
bgRed: string;
|
||||
bgGreen: string;
|
||||
bgYellow: string;
|
||||
bgBlue: string;
|
||||
bgMagenta: string;
|
||||
bgCyan: string;
|
||||
bgWhite: string;
|
||||
|
||||
reset: string;
|
||||
bold: string;
|
||||
dim: string;
|
||||
italic: string;
|
||||
underline: string;
|
||||
inverse: string;
|
||||
hidden: string;
|
||||
strikethrough: string;
|
||||
|
||||
rainbow: string;
|
||||
zebra: string;
|
||||
america: string;
|
||||
trap: string;
|
||||
random: string;
|
||||
zalgo: string;
|
||||
}
|
||||
}
|
||||
40
colors/safe.d.ts
vendored
Normal file
40
colors/safe.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
export var enabled: boolean;
|
||||
|
||||
export function strip(str: string): string;
|
||||
export function stripColors(str: string): string;
|
||||
|
||||
export function black(str: string): string;
|
||||
export function red(str: string): string;
|
||||
export function green(str: string): string;
|
||||
export function yellow(str: string): string;
|
||||
export function blue(str: string): string;
|
||||
export function magenta(str: string): string;
|
||||
export function cyan(str: string): string;
|
||||
export function white(str: string): string;
|
||||
export function gray(str: string): string;
|
||||
export function grey(str: string): string;
|
||||
|
||||
export function bgBlack(str: string): string;
|
||||
export function bgRed(str: string): string;
|
||||
export function bgGreen(str: string): string;
|
||||
export function bgYellow(str: string): string;
|
||||
export function bgBlue(str: string): string;
|
||||
export function bgMagenta(str: string): string;
|
||||
export function bgCyan(str: string): string;
|
||||
export function bgWhite(str: string): string;
|
||||
|
||||
export function reset(str: string): string;
|
||||
export function bold(str: string): string;
|
||||
export function dim(str: string): string;
|
||||
export function italic(str: string): string;
|
||||
export function underline(str: string): string;
|
||||
export function inverse(str: string): string;
|
||||
export function hidden(str: string): string;
|
||||
export function strikethrough(str: string): string;
|
||||
|
||||
export function rainbow(str: string): string;
|
||||
export function zebra(str: string): string;
|
||||
export function america(str: string): string;
|
||||
export function trap(str: string): string;
|
||||
export function random(str: string): string;
|
||||
export function zalgo(str: string): string;
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
1
colors/tslint.json
Normal file
1
colors/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -1,7 +1 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
// https://github.com/Microsoft/types-publisher/issues/241
|
||||
"void-return": false
|
||||
}
|
||||
}
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -1,6 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import stringify = require("csv-stringify");
|
||||
|
||||
let stream: stringify.Stringifier;
|
||||
|
||||
stringify([["1", "2", "3"], ["4", "5", "6"]], (error: Error, output: string): void => {
|
||||
// nothing
|
||||
@@ -13,9 +15,10 @@ stringify([["1", "2", "3"], ["4", "5", "6"]], {
|
||||
});
|
||||
|
||||
|
||||
var s = stringify({ delimiter: "," });
|
||||
s.write(["1", "2", "3"]);
|
||||
|
||||
stream = stringify({ delimiter: "," });
|
||||
|
||||
stream.write(["1", "2", "3"]);
|
||||
|
||||
let transform: NodeJS.ReadWriteStream = stream;
|
||||
|
||||
stream = stringify();
|
||||
|
||||
28
csv-stringify/index.d.ts
vendored
28
csv-stringify/index.d.ts
vendored
@@ -1,12 +1,10 @@
|
||||
// Type definitions for csv-stringify 0.0.6
|
||||
// Type definitions for csv-stringify 1.0
|
||||
// Project: https://github.com/wdavidw/node-csv-stringify
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
|
||||
declare namespace stringify {
|
||||
interface StringifyOpts {
|
||||
/**
|
||||
@@ -57,26 +55,24 @@ declare namespace stringify {
|
||||
}
|
||||
|
||||
interface Stringifier extends NodeJS.ReadWriteStream {
|
||||
|
||||
// Stringifier stream takes array of strings or Object
|
||||
write(line: string[] | Object): boolean;
|
||||
// Stringifier stream takes array of strings or Object
|
||||
write(line: string[] | any): boolean;
|
||||
|
||||
// repeat declarations from NodeJS.WritableStream to avoid compile error
|
||||
write(buffer: Buffer, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
write(buffer: string | Buffer, cb?: () => void): boolean;
|
||||
write(str: string, encoding?: string, cb?: () => void): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback version: string in --> callback with string out
|
||||
*/
|
||||
declare function stringify(input: any[][], opts: stringify.StringifyOpts, callback: (error: Error, output: string) => void): void;
|
||||
declare function stringify(input: any[][], callback: (error: Error, output: string) => void): void;
|
||||
|
||||
/**
|
||||
* Streaming stringifier
|
||||
*/
|
||||
declare function stringify(opts: stringify.StringifyOpts): stringify.Stringifier;
|
||||
declare function stringify(opts?: stringify.StringifyOpts): stringify.Stringifier;
|
||||
|
||||
/**
|
||||
* Callback version: string in --> callback with string out
|
||||
*/
|
||||
declare function stringify(input: any[][], opts: stringify.StringifyOpts, callback: (error: Error | undefined, output: string) => void): void;
|
||||
declare function stringify(input: any[][], callback: (error: Error | undefined, output: string) => void): void;
|
||||
|
||||
export = stringify;
|
||||
|
||||
1
csv-stringify/tslint.json
Normal file
1
csv-stringify/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -5,7 +5,7 @@ function test_abstract_chart() {
|
||||
chart: d3kit.AbstractChart,
|
||||
options: d3kit.ChartOptions,
|
||||
margins: d3kit.ChartMargin,
|
||||
offsets: d3kit.ChartOffset,
|
||||
offsets: [number, number],
|
||||
defopts: d3kit.ChartOptions,
|
||||
fitopts: d3kit.FitOptions,
|
||||
watchop: d3kit.WatchOptions,
|
||||
@@ -17,7 +17,7 @@ function test_abstract_chart() {
|
||||
|
||||
// create examples of margins, offsets, options, fit options, watch options
|
||||
margins = { top: 20, right: 20, bottom: 20, left: 20};
|
||||
offsets = { x: 0.5, y: 0.5 };
|
||||
offsets = [0.5, 0.5];
|
||||
options = { initialWidth: 400, initialHeight: 300, margin: margins, offset: offsets };
|
||||
fitopts = { mode: 'basic', width: '90%', ratio: 4/3 };
|
||||
watchop = { mode: 'window', target: null, interval: 500 };
|
||||
@@ -85,7 +85,7 @@ function test_svgchart() {
|
||||
chart: d3kit.SvgChart,
|
||||
options: d3kit.ChartOptions,
|
||||
margins: d3kit.ChartMargin,
|
||||
offsets: d3kit.ChartOffset,
|
||||
offsets: [number, number],
|
||||
svg: d3.Selection<d3.BaseType, any, d3.BaseType, any>,
|
||||
rootg: d3.Selection<d3.BaseType, any, d3.BaseType, any>,
|
||||
layers: d3kit.LayerOrganizer;
|
||||
@@ -95,7 +95,7 @@ function test_svgchart() {
|
||||
|
||||
// create examples of margins, offsets, options, fit options, watch options
|
||||
margins = { top: 20, right: 20, bottom: 20, left: 20};
|
||||
offsets = { x: 0.5, y: 0.5 };
|
||||
offsets = [0.5, 0.5];
|
||||
options = { initialWidth: 400, initialHeight: 300, margin: margins, offset: offsets };
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ function test_canvaschart() {
|
||||
chart: d3kit.CanvasChart,
|
||||
options: d3kit.ChartOptions,
|
||||
margins: d3kit.ChartMargin,
|
||||
offsets: d3kit.ChartOffset,
|
||||
offsets: [number, number],
|
||||
context: CanvasRenderingContext2D;
|
||||
|
||||
// create a div, append to body, return Node as type Element
|
||||
@@ -127,7 +127,7 @@ function test_canvaschart() {
|
||||
|
||||
// create examples of margins, offsets, options, fit options, watch options
|
||||
margins = { top: 20, right: 20, bottom: 20, left: 20};
|
||||
offsets = { x: 0.5, y: 0.5 };
|
||||
offsets = [0.5, 0.5];
|
||||
options = { initialWidth: 400, initialHeight: 300, margin: margins, offset: offsets, pixelRatio: 1 };
|
||||
|
||||
/**
|
||||
|
||||
27
d3kit/index.d.ts
vendored
27
d3kit/index.d.ts
vendored
@@ -26,8 +26,8 @@ export class AbstractChart {
|
||||
data(): any;
|
||||
margin(margins: ChartMargin): this;
|
||||
margin(): ChartMargin;
|
||||
offset(offset: ChartOffset): this;
|
||||
offset(): ChartOffset;
|
||||
offset(offset: [number, number]): this;
|
||||
offset(): [number, number];
|
||||
options(options: ChartOptions): this;
|
||||
options(): ChartOptions;
|
||||
updateDimensionNow(): this;
|
||||
@@ -47,16 +47,11 @@ export interface ChartMargin {
|
||||
left?: number;
|
||||
}
|
||||
|
||||
export interface ChartOffset {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface ChartOptions {
|
||||
initialWidth?: number;
|
||||
initialHeight?: number;
|
||||
margin?: ChartMargin;
|
||||
offset?: ChartOffset;
|
||||
offset?: [number, number];
|
||||
pixelRatio?: number;
|
||||
}
|
||||
|
||||
@@ -93,23 +88,23 @@ export class CanvasChart extends AbstractChart {
|
||||
|
||||
export class LayerOrganizer {
|
||||
constructor(container: d3.Selection<d3.BaseType, any, d3.BaseType, any>, defaultTag?: string);
|
||||
create(layerNames: string|Array<string>|LayerConfig|Array<LayerConfig>): d3.Selection<d3.BaseType, any, d3.BaseType, any>|Array<d3.Selection<d3.BaseType, any, d3.BaseType, any>>;
|
||||
create(layerNames: string|string[]|LayerConfig|LayerConfig[]): d3.Selection<d3.BaseType, any, d3.BaseType, any>|Array<d3.Selection<d3.BaseType, any, d3.BaseType, any>>;
|
||||
get(name: string): d3.Selection<d3.BaseType, any, d3.BaseType, any>;
|
||||
has(name: string): boolean;
|
||||
}
|
||||
|
||||
export interface LayerConfig {
|
||||
[layerName: string]: string|string[]|LayerConfig|Array<LayerConfig>;
|
||||
[layerName: string]: string|string[]|LayerConfig|LayerConfig[];
|
||||
}
|
||||
|
||||
export namespace helper {
|
||||
function debounce(fn: (...args: Array<any>) => void, delay: number): (...args: Array<any>) => void;
|
||||
function deepExtend(dest: Object, ...args: Object[]): Object;
|
||||
function extend(dest: Object, ...args: Object[]): Object;
|
||||
function functor(value: any): (...args: Array<any>) => any;
|
||||
function rebind(target: Object, source: Object): Object;
|
||||
function debounce(fn: (...args: any[]) => void, delay: number): (...args: any[]) => void;
|
||||
function deepExtend(dest: any, ...args: any[]): any;
|
||||
function extend(dest: any, ...args: any[]): any;
|
||||
function functor(value: any): (...args: any[]) => any;
|
||||
function rebind(target: any, source: any): any;
|
||||
function isFunction(value: any): boolean;
|
||||
function isObject(value: any): boolean;
|
||||
function kebabCase(str: string): string;
|
||||
function throttle(fn: (...args: Array<any>) => void, delay: number): (...args: Array<any>) => void;
|
||||
function throttle(fn: (...args: any[]) => void, delay: number): (...args: any[]) => void;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables" />
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var config: DataTables.Settings = {
|
||||
// FixedHeader extension options
|
||||
fixedHeader: {
|
||||
footer: true,
|
||||
footerOffset: 4,
|
||||
header: true,
|
||||
headerOffset: 3
|
||||
}
|
||||
};
|
||||
});
|
||||
40
datatables.net-fixedheader/index.d.ts
vendored
Normal file
40
datatables.net-fixedheader/index.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Type definitions for datatables.net-fixedheader 3.1
|
||||
// Project: https://datatables.net/extensions/fixedheader/
|
||||
// Definitions by: Jared Szechy <https://github.com/szechyjs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables"/>
|
||||
|
||||
declare namespace DataTables {
|
||||
export interface Settings {
|
||||
/*
|
||||
* FixedHeader extension options
|
||||
*/
|
||||
fixedHeader?: boolean | FixedHeaderSettings;
|
||||
}
|
||||
|
||||
/*
|
||||
* FixedHeader extension options
|
||||
*/
|
||||
interface FixedHeaderSettings {
|
||||
/*
|
||||
* Enable / disable fixed footer
|
||||
*/
|
||||
footer?: boolean;
|
||||
|
||||
/*
|
||||
* Offset the table's fixed footer
|
||||
*/
|
||||
footerOffset?: number;
|
||||
|
||||
/*
|
||||
* Enable / disable fixed header
|
||||
*/
|
||||
header?: boolean;
|
||||
|
||||
/*
|
||||
* Offset the table's fixed header
|
||||
*/
|
||||
headerOffset?: number;
|
||||
}
|
||||
}
|
||||
19
datatables.net-fixedheader/tsconfig.json
Normal file
19
datatables.net-fixedheader/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"datatables.net-fixedheader-tests.ts"
|
||||
]
|
||||
}
|
||||
1
datatables.net-fixedheader/tslint.json
Normal file
1
datatables.net-fixedheader/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
17
datatables.net-select/datatables.net-select-tests.ts
Normal file
17
datatables.net-select/datatables.net-select-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables" />
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var config: DataTables.Settings = {
|
||||
// Select extension options
|
||||
select: {
|
||||
blurable: true,
|
||||
className: "selectClass",
|
||||
info: true,
|
||||
items: "row",
|
||||
selector: "td:first-child",
|
||||
style: "os"
|
||||
}
|
||||
};
|
||||
});
|
||||
47
datatables.net-select/index.d.ts
vendored
Normal file
47
datatables.net-select/index.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Type definitions for datatables.net-select 1.2
|
||||
// Project: https://datatables.net/extensions/select/
|
||||
// Definitions by: Jared Szechy <https://github.com/szechyjs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="jquery.dataTables"/>
|
||||
|
||||
declare namespace DataTables {
|
||||
export interface Settings {
|
||||
/*
|
||||
* Select extension options
|
||||
*/
|
||||
select?: boolean | string | SelectSettings;
|
||||
}
|
||||
|
||||
interface SelectSettings {
|
||||
/*
|
||||
* Indicate if the selected items will be removed when clicking outside of the table
|
||||
*/
|
||||
blurable?: boolean;
|
||||
|
||||
/*
|
||||
* Set the class name that will be applied to selected items
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
/*
|
||||
* Enable / disable the display for item selection information in the table summary
|
||||
*/
|
||||
info?: boolean;
|
||||
|
||||
/*
|
||||
* Set which table items to select (rows, columns or cells)
|
||||
*/
|
||||
items?: string;
|
||||
|
||||
/*
|
||||
* Set the element selector used for mouse event capture to select items
|
||||
*/
|
||||
selector?: string;
|
||||
|
||||
/*
|
||||
* Set the selection style for end user interaction with the table
|
||||
*/
|
||||
style?: string;
|
||||
}
|
||||
}
|
||||
19
datatables.net-select/tsconfig.json
Normal file
19
datatables.net-select/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"datatables.net-select-tests.ts"
|
||||
]
|
||||
}
|
||||
1
datatables.net-select/tslint.json
Normal file
1
datatables.net-select/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -62,6 +62,8 @@ fs.mkdirsSync(dir);
|
||||
fs.mkdirp(dir, errorCallback);
|
||||
fs.mkdirpSync(dir);
|
||||
|
||||
fs.move(src, dest, errorCallback);
|
||||
|
||||
fs.outputFile(file, data, errorCallback);
|
||||
fs.outputFileSync(file, data);
|
||||
fs.outputJson(file, data, errorCallback);
|
||||
|
||||
4
fs-extra-promise/index.d.ts
vendored
4
fs-extra-promise/index.d.ts
vendored
@@ -10,7 +10,7 @@
|
||||
import * as stream from 'stream';
|
||||
import { Stats } from 'fs';
|
||||
import * as Promise from 'bluebird';
|
||||
import { CopyFilter, CopyOptions, OpenOptions, MkdirOptions } from 'fs-extra';
|
||||
import { CopyFilter, CopyOptions, OpenOptions, MkdirOptions, MoveOptions } from 'fs-extra';
|
||||
|
||||
export * from 'fs-extra';
|
||||
|
||||
@@ -24,6 +24,8 @@ export declare function createFileAsync(file: string): Promise<void>;
|
||||
export declare function mkdirsAsync(dir: string, options?: MkdirOptions): Promise<void>;
|
||||
export declare function mkdirpAsync(dir: string, options?: MkdirOptions): Promise<void>;
|
||||
|
||||
export declare function moveAsync(src: string, dest: string, options?: MoveOptions): Promise<void>;
|
||||
|
||||
export declare function outputFileAsync(file: string, data: any): Promise<void>;
|
||||
|
||||
export declare function outputJsonAsync(file: string, data: any): Promise<void>;
|
||||
|
||||
35
googlemaps/index.d.ts
vendored
35
googlemaps/index.d.ts
vendored
@@ -31,7 +31,7 @@ declare namespace google.maps {
|
||||
/***** Map *****/
|
||||
export class Map extends MVCObject {
|
||||
constructor(mapDiv: Element, opts?: MapOptions);
|
||||
fitBounds(bounds: LatLngBounds): void;
|
||||
fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
getBounds(): LatLngBounds;
|
||||
getCenter(): LatLng;
|
||||
getDiv(): Element;
|
||||
@@ -43,7 +43,7 @@ declare namespace google.maps {
|
||||
getZoom(): number;
|
||||
panBy(x: number, y: number): void;
|
||||
panTo(latLng: LatLng|LatLngLiteral): void;
|
||||
panToBounds(latLngBounds: LatLngBounds): void;
|
||||
panToBounds(latLngBounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
setCenter(latlng: LatLng|LatLngLiteral): void;
|
||||
setHeading(heading: number): void;
|
||||
setMapTypeId(mapTypeId: MapTypeId|string): void;
|
||||
@@ -394,7 +394,7 @@ declare namespace google.maps {
|
||||
*/
|
||||
icon?: string|Icon|Symbol;
|
||||
/**
|
||||
* Adds a label to the marker. The label can either be a string, or a MarkerLabel object.
|
||||
* Adds a label to the marker. The label can either be a string, or a MarkerLabel object.
|
||||
* Only the first character of the string will be displayed.
|
||||
* @type {(string|MarkerLabel)}
|
||||
*/
|
||||
@@ -489,7 +489,7 @@ declare namespace google.maps {
|
||||
/** The text to be displayed in the label. Only the first character of this string will be shown. */
|
||||
text?: string;
|
||||
}
|
||||
|
||||
|
||||
export interface MarkerShape {
|
||||
coords?: number[];
|
||||
type?: string;
|
||||
@@ -769,7 +769,7 @@ declare namespace google.maps {
|
||||
getEditable(): boolean;
|
||||
getMap(): Map;
|
||||
getVisible(): boolean;
|
||||
setBounds(bounds: LatLngBounds): void;
|
||||
setBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
setDraggable(draggable: boolean): void;
|
||||
setEditable(editable: boolean): void;
|
||||
setMap(map: Map): void;
|
||||
@@ -844,7 +844,7 @@ declare namespace google.maps {
|
||||
}
|
||||
|
||||
export class GroundOverlay extends MVCObject {
|
||||
constructor(url: string, bounds: LatLngBounds, opts?: GroundOverlayOptions);
|
||||
constructor(url: string, bounds: LatLngBounds|LatLngBoundsLiteral, opts?: GroundOverlayOptions);
|
||||
getBounds(): LatLngBounds;
|
||||
getMap(): Map;
|
||||
getOpacity(): number;
|
||||
@@ -895,7 +895,7 @@ declare namespace google.maps {
|
||||
|
||||
export interface GeocoderRequest {
|
||||
address?: string;
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
componentRestrictions?: GeocoderComponentRestrictions;
|
||||
location?: LatLng|LatLngLiteral;
|
||||
placeId?: string;
|
||||
@@ -1801,7 +1801,7 @@ declare namespace google.maps {
|
||||
/** Returns a string of the form "lat,lng". We round the lat/lng values to 6 decimal places by default. */
|
||||
toUrlValue(precision?: number): string;
|
||||
/** Converts to JSON representation. This function is intended to be used via JSON.stringify. */
|
||||
toJSON(): LatLngLiteral;
|
||||
toJSON(): LatLngLiteral;
|
||||
}
|
||||
|
||||
export type LatLngLiteral = { lat: number; lng: number }
|
||||
@@ -1817,6 +1817,7 @@ declare namespace google.maps {
|
||||
getSouthWest(): LatLng;
|
||||
intersects(other: LatLngBounds|LatLngBoundsLiteral): boolean;
|
||||
isEmpty(): boolean;
|
||||
toJSON(): LatLngBoundsLiteral;
|
||||
toSpan(): LatLng;
|
||||
toString(): string;
|
||||
toUrlValue(precision?: number): string;
|
||||
@@ -2004,13 +2005,13 @@ declare namespace google.maps {
|
||||
constructor(inputField: HTMLInputElement, opts?: AutocompleteOptions);
|
||||
getBounds(): LatLngBounds;
|
||||
getPlace(): PlaceResult;
|
||||
setBounds(bounds: LatLngBounds): void;
|
||||
setBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
setComponentRestrictions(restrictions: ComponentRestrictions): void;
|
||||
setTypes(types: string[]): void;
|
||||
}
|
||||
|
||||
export interface AutocompleteOptions {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
componentRestrictions?: ComponentRestrictions;
|
||||
types?: string[];
|
||||
}
|
||||
@@ -2040,7 +2041,7 @@ declare namespace google.maps {
|
||||
}
|
||||
|
||||
export interface AutocompletionRequest {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
componentRestrictions?: ComponentRestrictions;
|
||||
input: string;
|
||||
location?: LatLng;
|
||||
@@ -2115,7 +2116,7 @@ declare namespace google.maps {
|
||||
}
|
||||
|
||||
export interface PlaceSearchRequest {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
keyword?: string;
|
||||
location?: LatLng|LatLngLiteral;
|
||||
maxPriceLevel?: number;
|
||||
@@ -2153,7 +2154,7 @@ declare namespace google.maps {
|
||||
}
|
||||
|
||||
export interface QueryAutocompletionRequest {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
input?: string;
|
||||
location?: LatLng;
|
||||
offset?: number;
|
||||
@@ -2161,7 +2162,7 @@ declare namespace google.maps {
|
||||
}
|
||||
|
||||
export interface RadarSearchRequest {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
keyword?: string;
|
||||
location?: LatLng|LatLngLiteral;
|
||||
name?: string;
|
||||
@@ -2179,15 +2180,15 @@ declare namespace google.maps {
|
||||
constructor(inputField: HTMLInputElement, opts?: SearchBoxOptions);
|
||||
getBounds(): LatLngBounds;
|
||||
getPlaces(): PlaceResult[];
|
||||
setBounds(bounds: LatLngBounds): void;
|
||||
setBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
}
|
||||
|
||||
export interface SearchBoxOptions {
|
||||
bounds: LatLngBounds;
|
||||
bounds: LatLngBounds|LatLngBoundsLiteral;
|
||||
}
|
||||
|
||||
export interface TextSearchRequest {
|
||||
bounds?: LatLngBounds;
|
||||
bounds?: LatLngBounds|LatLngBoundsLiteral;
|
||||
location?: LatLng|LatLngLiteral;
|
||||
query: string;
|
||||
radius?: number;
|
||||
|
||||
7
graphql/index.d.ts
vendored
7
graphql/index.d.ts
vendored
@@ -319,6 +319,7 @@ declare module "graphql/language/ast" {
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
| BooleanValueNode
|
||||
| NullValueNode
|
||||
| EnumValueNode
|
||||
| ListValueNode
|
||||
| ObjectValueNode
|
||||
@@ -450,6 +451,7 @@ declare module "graphql/language/ast" {
|
||||
| FloatValueNode
|
||||
| StringValueNode
|
||||
| BooleanValueNode
|
||||
| NullValueNode
|
||||
| EnumValueNode
|
||||
| ListValueNode
|
||||
| ObjectValueNode
|
||||
@@ -478,6 +480,11 @@ declare module "graphql/language/ast" {
|
||||
value: boolean;
|
||||
}
|
||||
|
||||
export type NullValueNode = {
|
||||
kind: 'NullValue';
|
||||
loc?: Location;
|
||||
}
|
||||
|
||||
export type EnumValueNode = {
|
||||
kind: 'EnumValue';
|
||||
loc?: Location;
|
||||
|
||||
11
highcharts/highstock.d.ts
vendored
11
highcharts/highstock.d.ts
vendored
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as Highcharts from "highcharts";
|
||||
|
||||
declare namespace __Highstock {
|
||||
declare namespace Highstock {
|
||||
interface ChartObject extends Highcharts.ChartObject {
|
||||
options: Options;
|
||||
}
|
||||
@@ -100,14 +100,14 @@ declare namespace __Highstock {
|
||||
|
||||
declare global {
|
||||
interface JQuery {
|
||||
highcharts(type: "StockChart"): __Highstock.ChartObject;
|
||||
highcharts(type: "StockChart"): Highstock.ChartObject;
|
||||
/**
|
||||
* Creates a new Highcharts.Chart for the current JQuery selector; usually
|
||||
* a div selected by $('#container')
|
||||
* @param {Highcharts.Options} options Options for this chart
|
||||
* @return current {JQuery} selector the current JQuery selector
|
||||
**/
|
||||
highcharts(type: "StockChart", options: __Highstock.Options): JQuery;
|
||||
highcharts(type: "StockChart", options: Highstock.Options): JQuery;
|
||||
/**
|
||||
* Creates a new Highcharts.Chart for the current JQuery selector; usually
|
||||
* a div selected by $('#container')
|
||||
@@ -115,7 +115,7 @@ declare global {
|
||||
* @param callback Callback function used to manipulate the constructed chart instance
|
||||
* @return current {JQuery} selector the current JQuery selector
|
||||
**/
|
||||
highcharts(type: "StockChart", options: __Highstock.Options, callback: (chart: __Highstock.ChartObject) => void): JQuery;
|
||||
highcharts(type: "StockChart", options: Highstock.Options, callback: (chart: Highstock.ChartObject) => void): JQuery;
|
||||
|
||||
|
||||
highcharts(type: string): Highcharts.ChartObject;
|
||||
@@ -124,3 +124,6 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
declare var Highstock: Highstock.Static;
|
||||
export = Highstock;
|
||||
export as namespace Highstock;
|
||||
3
ioredis/index.d.ts
vendored
3
ioredis/index.d.ts
vendored
@@ -338,6 +338,7 @@ declare module IORedis {
|
||||
|
||||
scanStream(options?: IORedis.ScanStreamOption): NodeJS.EventEmitter;
|
||||
hscanStream(key: string, options?: IORedis.ScanStreamOption): NodeJS.EventEmitter;
|
||||
zscanStream(key: string, options?: IORedis.ScanStreamOption): NodeJS.EventEmitter;
|
||||
}
|
||||
|
||||
interface Pipeline {
|
||||
@@ -719,4 +720,4 @@ declare module IORedis {
|
||||
retryDelayOnTryAgain?: number;
|
||||
redisOptions?: RedisOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
8
is-windows/index.d.ts
vendored
Normal file
8
is-windows/index.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Type definitions for is-windows 0.2
|
||||
// Project: https://github.com/jonschlinkert/is-windows
|
||||
// Definitions by: Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function isWindows(): boolean;
|
||||
declare namespace isWindows {}
|
||||
export = isWindows;
|
||||
3
is-windows/is-windows-tests.ts
Normal file
3
is-windows/is-windows-tests.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as isWindows from 'is-windows';
|
||||
|
||||
var bool: boolean = isWindows();
|
||||
19
is-windows/tsconfig.json
Normal file
19
is-windows/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"is-windows-tests.ts"
|
||||
]
|
||||
}
|
||||
1
is-windows/tslint.json
Normal file
1
is-windows/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
40
jade/index.d.ts
vendored
40
jade/index.d.ts
vendored
@@ -3,13 +3,39 @@
|
||||
// Definitions by: Panu Horsmalahti <https://github.com/panuhorsmalahti>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type JadeCustomFilterFunction = (text: string, options: {
|
||||
[key: string]: boolean;
|
||||
}) => string;
|
||||
|
||||
export declare function compile(template: string, options?: any): (locals?: any) => string;
|
||||
export declare function compileFile(path: string, options?: any): (locals?: any) => string;
|
||||
export declare function compileClient(template: string, options?: any): (locals?: any) => string;
|
||||
export declare function compileClientWithDependenciesTracked(template: string, options?: any): {
|
||||
body: (locals?: any) => string;
|
||||
export interface JadeOptions {
|
||||
filename?: string;
|
||||
basedir?: string;
|
||||
doctype?: string;
|
||||
pretty?: boolean | string;
|
||||
filters?: {
|
||||
[key: string]: JadeCustomFilterFunction
|
||||
};
|
||||
self?: boolean;
|
||||
debug?: boolean;
|
||||
compileDebug?: boolean;
|
||||
globals?: string[];
|
||||
cache?: boolean;
|
||||
inlineRuntimeFunctions?: boolean;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface TemplateLocals {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type JadeGenerationFunction = (locals?: TemplateLocals) => string;
|
||||
|
||||
export declare function compile(template: string, options?: JadeOptions): JadeGenerationFunction;
|
||||
export declare function compileFile(path: string, options?: JadeOptions): JadeGenerationFunction;
|
||||
export declare function compileClient(template: string, options?: JadeOptions): JadeGenerationFunction;
|
||||
export declare function compileClientWithDependenciesTracked(template: string, options?: JadeOptions): {
|
||||
body: JadeGenerationFunction;
|
||||
dependencies: string[];
|
||||
};
|
||||
export declare function render(template: string, options?: any): string;
|
||||
export declare function renderFile(path: string, options?: any): string;
|
||||
export declare function render(template: string, options?: JadeOptions): string;
|
||||
export declare function renderFile(path: string, options?: JadeOptions): string;
|
||||
|
||||
@@ -4,5 +4,5 @@ jade.compile("b")();
|
||||
jade.compileFile("foo.jade", {})();
|
||||
jade.compileClient("a")({ a: 1 });
|
||||
jade.compileClientWithDependenciesTracked("test").body();
|
||||
jade.render("h1",{});
|
||||
jade.render("h1", {});
|
||||
jade.renderFile("foo.jade");
|
||||
|
||||
55
leaflet-draw/index.d.ts
vendored
55
leaflet-draw/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for leaflet-draw 0.2.4
|
||||
// Type definitions for leaflet-draw 0.4.6
|
||||
// Project: https://github.com/Leaflet/Leaflet.draw
|
||||
// Definitions by: Matt Guest <https://github.com/matt-guest>
|
||||
// Definitions by: Matt Guest <https://github.com/matt-guest>, Ryan Blace <https://github.com/reblace>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="leaflet" />
|
||||
@@ -10,17 +10,9 @@ declare namespace L {
|
||||
drawControl?: boolean;
|
||||
}
|
||||
|
||||
export interface ControlStatic {
|
||||
Draw: Control.DrawStatic;
|
||||
}
|
||||
|
||||
namespace Control {
|
||||
|
||||
export interface DrawStatic {
|
||||
new (options?: IDrawConstructorOptions): Draw;
|
||||
}
|
||||
|
||||
export interface IDrawConstructorOptions {
|
||||
export interface DrawConstructorOptions {
|
||||
|
||||
/**
|
||||
* The initial position of the control (one of the map corners).
|
||||
@@ -91,7 +83,7 @@ declare namespace L {
|
||||
*
|
||||
* Default value: null
|
||||
*/
|
||||
featureGroup: FeatureGroup<ILayer>;
|
||||
featureGroup: FeatureGroup;
|
||||
|
||||
/**
|
||||
* Edit handler options. Set to false to disable handler.
|
||||
@@ -108,9 +100,14 @@ declare namespace L {
|
||||
remove?: DrawOptions.DeleteHandlerOptions;
|
||||
}
|
||||
|
||||
export interface Draw extends IControl {
|
||||
|
||||
export interface Draw extends Control {
|
||||
setDrawingOptions(options: DrawOptions): void;
|
||||
}
|
||||
|
||||
export class Draw {
|
||||
constructor(options?: DrawConstructorOptions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +249,28 @@ declare namespace L {
|
||||
|
||||
}
|
||||
|
||||
namespace Draw {
|
||||
|
||||
namespace Event {
|
||||
|
||||
export const CREATED: string;
|
||||
export const EDITED: string;
|
||||
export const DELETED: string;
|
||||
export const DRAWSTART: string;
|
||||
export const DRAWSTOP: string;
|
||||
export const DRAWVERTEX: string;
|
||||
export const EDITSTART: string;
|
||||
export const EDITMOVE: string;
|
||||
export const EDITRESIZE: string;
|
||||
export const EDITVERTEX: string;
|
||||
export const EDITSTOP: string;
|
||||
export const DELETESTART: string;
|
||||
export const DELETESTOP: string;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace DrawEvents {
|
||||
|
||||
export interface Created {
|
||||
@@ -259,7 +278,7 @@ declare namespace L {
|
||||
/**
|
||||
* Layer that was just created.
|
||||
*/
|
||||
layer: ILayer;
|
||||
layer: Layer;
|
||||
|
||||
/**
|
||||
* The type of layer this is. One of: polyline, polygon, rectangle, circle, marker.
|
||||
@@ -272,7 +291,7 @@ declare namespace L {
|
||||
/**
|
||||
* List of all layers just edited on the map.
|
||||
*/
|
||||
layers: LayerGroup<ILayer>;
|
||||
layers: LayerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,7 +302,7 @@ declare namespace L {
|
||||
/**
|
||||
* List of all layers just removed from the map.
|
||||
*/
|
||||
layers: LayerGroup<ILayer>;
|
||||
layers: LayerGroup;
|
||||
}
|
||||
|
||||
export interface DrawStart {
|
||||
@@ -302,7 +321,7 @@ declare namespace L {
|
||||
layerType: string;
|
||||
}
|
||||
|
||||
export interface EditStart {
|
||||
export interface EditStart {
|
||||
/**
|
||||
* The type of edit this is. One of: edit
|
||||
*/
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
||||
osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
|
||||
map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 });
|
||||
map = L.map('map', {layers: [osm], center: L.latLng(-37.7772, 175.2756), zoom: 15 });
|
||||
|
||||
var drawnItems = new L.FeatureGroup();
|
||||
var drawnItems = L.featureGroup();
|
||||
map.addLayer(drawnItems);
|
||||
|
||||
var drawControl = new L.Control.Draw({
|
||||
@@ -37,9 +37,10 @@ var drawControl = new L.Control.Draw({
|
||||
});
|
||||
map.addControl(drawControl);
|
||||
|
||||
map.on('draw:created', function (e: L.DrawEvents.Created) {
|
||||
var type = e.layerType,
|
||||
layer = e.layer;
|
||||
map.on('draw:created', function (e: any) {
|
||||
var drawEvent = (e as L.DrawEvents.Created);
|
||||
var type = drawEvent.layerType,
|
||||
layer = drawEvent.layer;
|
||||
|
||||
drawnItems.addLayer(layer);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@types/leaflet": "^0.7"
|
||||
"@types/leaflet": "^1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"lodash": ">=4.14.0"
|
||||
}
|
||||
}
|
||||
7
lodash/fb/index.d.ts
vendored
7
lodash/fb/index.d.ts
vendored
@@ -1,7 +1,2 @@
|
||||
// Type definitions for Lo-Dash 4.14
|
||||
// Project: http://lodash.com/
|
||||
// Definitions by: Brian Zengel <https://github.com/bczengel>, Ilya Mochalov <https://github.com/chrootsu>, Stepan Mikhaylyuk <https://github.com/stepancar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as _ from "../index"
|
||||
import * as _ from "../index";
|
||||
export = _;
|
||||
|
||||
@@ -66,6 +66,7 @@ function allModuleNames() {
|
||||
"every",
|
||||
"extend",
|
||||
"extendWith",
|
||||
"fb",
|
||||
"fill",
|
||||
"filter",
|
||||
"find",
|
||||
@@ -168,6 +169,7 @@ function allModuleNames() {
|
||||
"max",
|
||||
"maxBy",
|
||||
"mean",
|
||||
"meanBy",
|
||||
"memoize",
|
||||
"merge",
|
||||
"mergeWith",
|
||||
|
||||
1108
lodash/index.d.ts
vendored
1108
lodash/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
7
lodash/meanBy/index.d.ts
vendored
7
lodash/meanBy/index.d.ts
vendored
@@ -1,8 +1,3 @@
|
||||
// Type definitions for Lo-Dash 4.14
|
||||
// Project: http://lodash.com/
|
||||
// Definitions by: Brian Zengel <https://github.com/bczengel>, Ilya Mochalov <https://github.com/chrootsu>, Stepan Mikhaylyuk <https://github.com/stepancar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as _ from "../index"
|
||||
import * as _ from "../index";
|
||||
declare const meanBy: typeof _.meanBy;
|
||||
export = meanBy;
|
||||
|
||||
8
lodash/tslint.json
Normal file
8
lodash/tslint.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"forbidden-types": false,
|
||||
"no-empty-interface": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
45
markdown-it/index.d.ts
vendored
45
markdown-it/index.d.ts
vendored
@@ -1,14 +1,14 @@
|
||||
// Type definitions for markdown-it
|
||||
// Project: https://github.com/markdown-it/markdown-it
|
||||
// Definitions by: York Yao <https://github.com/plantain-00/>
|
||||
// Definitions by: York Yao <https://github.com/plantain-00/>, Robert Coie <https://github.com/rapropos/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface MarkdownItStatic {
|
||||
new (): MarkdownIt.MarkdownIt;
|
||||
new (presetName: "commonmark" | "zero" | "default"): MarkdownIt.MarkdownIt;
|
||||
new (presetName: "commonmark" | "zero" | "default", options?: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
new (options: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
(): MarkdownIt.MarkdownIt;
|
||||
(presetName: "commonmark" | "zero" | "default"): MarkdownIt.MarkdownIt;
|
||||
(presetName: "commonmark" | "zero" | "default", options ?: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
(options: MarkdownIt.Options): MarkdownIt.MarkdownIt;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ declare module MarkdownIt {
|
||||
interface MarkdownIt {
|
||||
render(md: string, env?: any): string;
|
||||
renderInline(md: string, env?: any): string;
|
||||
parse(src: string, env: any): Token[];
|
||||
parseInline(src: string, env: any): Token[];
|
||||
use(plugin: any, ...params: any[]): MarkdownIt;
|
||||
utils: {
|
||||
assign(obj: any): any;
|
||||
@@ -43,10 +45,10 @@ declare module MarkdownIt {
|
||||
normalizeLink(url: string): string;
|
||||
normalizeLinkText(url: string): string;
|
||||
validateLink(url: string): boolean;
|
||||
block: any;
|
||||
core: any;
|
||||
block: ParserBlock;
|
||||
core: Core;
|
||||
helpers: any;
|
||||
inline: any;
|
||||
inline: ParserInline;
|
||||
linkify: LinkifyIt;
|
||||
renderer: Renderer;
|
||||
}
|
||||
@@ -92,4 +94,35 @@ declare module MarkdownIt {
|
||||
}
|
||||
|
||||
type TokenRender = (tokens: Token[], index: number, options: any, env: any, self: Renderer) => void;
|
||||
|
||||
interface Rule {
|
||||
(state: any): void;
|
||||
}
|
||||
|
||||
interface Ruler {
|
||||
after(afterName: string, ruleName: string, rule: Rule, options?: any): void;
|
||||
at(name: string, rule: Rule, options?: any): void;
|
||||
before(beforeName: string, ruleName: string, rule: Rule, options?: any): void;
|
||||
disable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enable(rules: string | string[], ignoreInvalid?: boolean): string[];
|
||||
enableOnly(rule: string, ignoreInvalid?: boolean): void;
|
||||
getRules(chain: string): Rule[];
|
||||
push(ruleName: string, rule: Rule, options?: any): void;
|
||||
}
|
||||
|
||||
interface ParserBlock {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
ruler: Ruler;
|
||||
}
|
||||
|
||||
interface Core {
|
||||
process(state: any): void;
|
||||
ruler: Ruler;
|
||||
}
|
||||
|
||||
interface ParserInline {
|
||||
parse(src: string, md: MarkdownIt, env: any, outTokens: Token[]): void;
|
||||
ruler: Ruler;
|
||||
ruler2: Ruler;
|
||||
}
|
||||
}
|
||||
|
||||
2
material-ui/index.d.ts
vendored
2
material-ui/index.d.ts
vendored
@@ -1494,7 +1494,7 @@ declare namespace __MaterialUI {
|
||||
contentStyle?: React.CSSProperties;
|
||||
message: React.ReactNode;
|
||||
onActionTouchTap?: React.TouchEventHandler<{}>;
|
||||
onRequestClose: (reason: string) => void;
|
||||
onRequestClose?: (reason: string) => void;
|
||||
open: boolean;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
80
minimist/index.d.ts
vendored
80
minimist/index.d.ts
vendored
@@ -1,33 +1,89 @@
|
||||
// Type definitions for minimist 1.1.3
|
||||
// Type definitions for minimist 1.2.0
|
||||
// Project: https://github.com/substack/minimist
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Necroskillz <https://github.com/Necroskillz>
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Necroskillz <https://github.com/Necroskillz>, kamranayub <https://github.com/kamranayub>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
/**
|
||||
* Return an argument object populated with the array arguments from args
|
||||
*
|
||||
* @param args An optional argument array (typically `process.argv.slice(2)`)
|
||||
* @param opts An optional options object to customize the parsing
|
||||
*/
|
||||
declare function minimist(args?: string[], opts?: minimist.Opts): minimist.ParsedArgs;
|
||||
|
||||
/**
|
||||
* Return an argument object populated with the array arguments from args. Strongly-typed
|
||||
* to be the intersect of type T with minimist.ParsedArgs.
|
||||
*
|
||||
* @type T The type that will be intersected with minimist.ParsedArgs to represent the argument object
|
||||
* @param args An optional argument array (typically `process.argv.slice(2)`)
|
||||
* @param opts An optional options object to customize the parsing
|
||||
*/
|
||||
declare function minimist<T>(args?: string[], opts?: minimist.Opts): T & minimist.ParsedArgs;
|
||||
|
||||
/**
|
||||
* Return an argument object populated with the array arguments from args. Strongly-typed
|
||||
* to be the the type T which should extend minimist.ParsedArgs
|
||||
*
|
||||
* @type T The type that extends minimist.ParsedArgs and represents the argument object
|
||||
* @param args An optional argument array (typically `process.argv.slice(2)`)
|
||||
* @param opts An optional options object to customize the parsing
|
||||
*/
|
||||
declare function minimist<T extends minimist.ParsedArgs>(args?: string[], opts?: minimist.Opts): T;
|
||||
|
||||
declare namespace minimist {
|
||||
export interface Opts {
|
||||
// a string or array of strings argument names to always treat as strings
|
||||
/**
|
||||
* A string or array of strings argument names to always treat as strings
|
||||
*/
|
||||
string?: string | string[];
|
||||
// a string or array of strings to always treat as booleans
|
||||
|
||||
/**
|
||||
* A boolean, string or array of strings to always treat as booleans. If true will treat
|
||||
* all double hyphenated arguments without equals signs as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
|
||||
*/
|
||||
boolean?: boolean | string | string[];
|
||||
// an object mapping string names to strings or arrays of string argument names to use
|
||||
|
||||
/**
|
||||
* An object mapping string names to strings or arrays of string argument names to use as aliases
|
||||
*/
|
||||
alias?: { [key: string]: string | string[] };
|
||||
// an object mapping string argument names to default values
|
||||
|
||||
/**
|
||||
* An object mapping string argument names to default values
|
||||
*/
|
||||
default?: { [key: string]: any };
|
||||
// when true, populate argv._ with everything after the first non-option
|
||||
|
||||
/**
|
||||
* When true, populate argv._ with everything after the first non-option
|
||||
*/
|
||||
stopEarly?: boolean;
|
||||
// a function which is invoked with a command line parameter not defined in the opts configuration object.
|
||||
// If the function returns false, the unknown option is not added to argv
|
||||
|
||||
/**
|
||||
* A function which is invoked with a command line parameter not defined in the opts
|
||||
* configuration object. If the function returns false, the unknown option is not added to argv
|
||||
*/
|
||||
unknown?: (arg: string) => boolean;
|
||||
// when true, populate argv._ with everything before the -- and argv['--'] with everything after the --
|
||||
|
||||
/**
|
||||
* When true, populate argv._ with everything before the -- and argv['--'] with everything after the --.
|
||||
* Note that with -- set, parsing for arguments still stops after the `--`.
|
||||
*/
|
||||
'--'?: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedArgs {
|
||||
[arg: string]: any;
|
||||
_: string[];
|
||||
|
||||
/**
|
||||
* If opts['--'] is true, populated with everything after the --
|
||||
*/
|
||||
'--'?: string[];
|
||||
|
||||
/**
|
||||
* Contains all the arguments that didn't have an option associated with them
|
||||
*/
|
||||
_: string[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,21 @@
|
||||
import minimist = require('minimist');
|
||||
import Opts = minimist.Opts;
|
||||
|
||||
interface CustomArgs {
|
||||
foo: boolean;
|
||||
}
|
||||
|
||||
interface CustomArgs2 extends minimist.ParsedArgs {
|
||||
foo: boolean;
|
||||
}
|
||||
|
||||
var num: string;
|
||||
var str: string;
|
||||
var strArr: string[];
|
||||
var args: string[];
|
||||
var obj: minimist.ParsedArgs;
|
||||
var iobj: minimist.ParsedArgs & CustomArgs;
|
||||
var eobj: CustomArgs2;
|
||||
var opts: Opts;
|
||||
var arg: any;
|
||||
|
||||
@@ -40,6 +50,18 @@ opts['--'] = true;
|
||||
obj = minimist();
|
||||
obj = minimist(strArr);
|
||||
obj = minimist(strArr, opts);
|
||||
iobj = minimist<CustomArgs>();
|
||||
iobj = minimist<CustomArgs>(strArr);
|
||||
iobj = minimist<CustomArgs>(strArr, opts);
|
||||
eobj = minimist<CustomArgs2>();
|
||||
eobj = minimist<CustomArgs2>(strArr);
|
||||
eobj = minimist<CustomArgs2>(strArr, opts);
|
||||
var remainingArgCount = obj._.length;
|
||||
|
||||
arg = obj['foo'];
|
||||
|
||||
arg = iobj.foo;
|
||||
remainingArgCount = iobj._.length;
|
||||
|
||||
arg = eobj.foo;
|
||||
remainingArgCount = eobj._.length;
|
||||
2
nanomsg/index.d.ts
vendored
2
nanomsg/index.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
// Type definitions for nanomsg 3.2
|
||||
// Project: https://github.com/nickdesaulniers/node-nanomsg
|
||||
// Definitions by: Titan <https://github.com/titan>
|
||||
// Definitions: https://github.com/DefinitelyTyped/nanomsg
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
14
ng-file-upload/index.d.ts
vendored
14
ng-file-upload/index.d.ts
vendored
@@ -106,20 +106,6 @@ declare module 'angular' {
|
||||
width?: number;
|
||||
}
|
||||
|
||||
interface ResizeIfFunction {
|
||||
(width: number, height: number): boolean;
|
||||
}
|
||||
|
||||
interface FileResizeOptions {
|
||||
centerCrop?: boolean;
|
||||
height?: number;
|
||||
ratio?: number;
|
||||
resizeIf?: ResizeIfFunction;
|
||||
restoreExif?: boolean;
|
||||
quality?: number;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
interface IUploadService {
|
||||
/**
|
||||
* Convert a single file or array of files to a single or array of
|
||||
|
||||
32
node-fetch/index.d.ts
vendored
32
node-fetch/index.d.ts
vendored
@@ -5,6 +5,8 @@
|
||||
|
||||
///<reference types="node" />
|
||||
|
||||
import { Agent } from "http";
|
||||
|
||||
export class Request extends Body {
|
||||
constructor(input: string | Request, init?: RequestInit);
|
||||
method: string;
|
||||
@@ -12,20 +14,35 @@ export class Request extends Body {
|
||||
headers: Headers;
|
||||
context: RequestContext;
|
||||
referrer: string;
|
||||
mode: RequestMode;
|
||||
redirect: RequestRedirect;
|
||||
credentials: RequestCredentials;
|
||||
cache: RequestCache;
|
||||
|
||||
//node-fetch extensions to the whatwg/fetch spec
|
||||
compress: boolean;
|
||||
agent?: Agent;
|
||||
counter: number;
|
||||
follow: number;
|
||||
hostname: string;
|
||||
protocol: string;
|
||||
port?: number;
|
||||
timeout: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface RequestInit {
|
||||
//whatwg/fetch standard options
|
||||
method?: string;
|
||||
headers?: HeaderInit | { [index: string]: string };
|
||||
body?: BodyInit;
|
||||
mode?: RequestMode;
|
||||
redirect?: RequestRedirect;
|
||||
credentials?: RequestCredentials;
|
||||
cache?: RequestCache;
|
||||
|
||||
//node-fetch extensions
|
||||
timeout?: number; //=0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
|
||||
compress?: boolean; //=true support gzip/deflate content encoding. false to disable
|
||||
size?: number; //=0 maximum response body size in bytes. 0 to disable
|
||||
agent?: Agent; //=null http.Agent instance, allows custom proxy, certificate etc.
|
||||
follow?: number; //=20 maximum redirect count. 0 to not follow redirect
|
||||
|
||||
//node-fetch does not support mode, cache or credentials options
|
||||
}
|
||||
|
||||
type RequestContext =
|
||||
@@ -56,7 +73,6 @@ export class Headers {
|
||||
export class Body {
|
||||
bodyUsed: boolean;
|
||||
body: NodeJS.ReadableStream;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
json(): Promise<any>;
|
||||
json<T>(): Promise<T>;
|
||||
text(): Promise<string>;
|
||||
@@ -71,7 +87,9 @@ export class Response extends Body {
|
||||
url: string;
|
||||
status: number;
|
||||
ok: boolean;
|
||||
size: number;
|
||||
statusText: string;
|
||||
timeout: number;
|
||||
headers: Headers;
|
||||
clone(): Response;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fetch, { Headers, Request, RequestInit, Response } from 'node-fetch';
|
||||
import { Agent } from "http";
|
||||
|
||||
function test_fetchUrlWithOptions() {
|
||||
var headers = new Headers();
|
||||
@@ -6,10 +7,11 @@ function test_fetchUrlWithOptions() {
|
||||
var requestOptions: RequestInit = {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
mode: 'same-origin',
|
||||
credentials: 'omit',
|
||||
cache: 'default',
|
||||
redirect: 'manual'
|
||||
compress: true,
|
||||
follow: 10,
|
||||
redirect: 'manual',
|
||||
size: 100,
|
||||
timeout: 5000
|
||||
};
|
||||
handlePromise(fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions));
|
||||
}
|
||||
@@ -36,6 +38,11 @@ function test_fetchUrlWithRequestObject() {
|
||||
}
|
||||
};
|
||||
var request: Request = new Request("http://www.andlabs.net/html5/uCOR.php", requestOptions);
|
||||
var timeout: number = request.timeout;
|
||||
var size: number = request.size;
|
||||
var agent: Agent = request.agent;
|
||||
var protocol: string = request.protocol
|
||||
|
||||
handlePromise(fetch(request));
|
||||
}
|
||||
|
||||
|
||||
4
node/index.d.ts
vendored
4
node/index.d.ts
vendored
@@ -2073,8 +2073,8 @@ declare module "dgram" {
|
||||
setMulticastLoopback(flag: boolean): void;
|
||||
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
||||
ref(): void;
|
||||
unref(): void;
|
||||
ref(): this;
|
||||
unref(): this;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
"asOfVersion": "2.0.18"
|
||||
},
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"libraryName": "camel-case",
|
||||
"typingsPackageName": "camel-case",
|
||||
"sourceRepoURL": "https://github.com/blakeembrey/camel-case",
|
||||
|
||||
104
passport/index.d.ts
vendored
104
passport/index.d.ts
vendored
@@ -26,64 +26,63 @@ declare module 'passport' {
|
||||
import express = require('express');
|
||||
|
||||
namespace passport {
|
||||
interface AuthenticateOptions {
|
||||
authInfo?: boolean;
|
||||
assignProperty?: string;
|
||||
failureFlash?: string|boolean|any;
|
||||
failureMessage?: boolean|string;
|
||||
failureRedirect?: string;
|
||||
failWithError?: boolean;
|
||||
session?: boolean;
|
||||
scope?: string|string[];
|
||||
successFlash?: string|boolean|any;
|
||||
successMessage?: boolean|string;
|
||||
successRedirect?: string;
|
||||
successReturnToOrRedirect?: string;
|
||||
pauseStream?: boolean;
|
||||
userProperty?: string;
|
||||
}
|
||||
|
||||
interface AuthenticateOptions {
|
||||
authInfo?: boolean;
|
||||
assignProperty?: string;
|
||||
failureFlash?: string|boolean|any;
|
||||
failureMessage?: boolean|string;
|
||||
failureRedirect?: string;
|
||||
failWithError?: boolean;
|
||||
session?: boolean;
|
||||
scope?: string|string[];
|
||||
successFlash?: string|boolean|any;
|
||||
successMessage?: boolean|string;
|
||||
successRedirect?: string;
|
||||
successReturnToOrRedirect?: string;
|
||||
pauseStream?: boolean;
|
||||
userProperty?: string;
|
||||
}
|
||||
interface Passport {
|
||||
use(strategy: passport.Strategy): this;
|
||||
use(name: string, strategy: passport.Strategy): this;
|
||||
unuse(name: string): this;
|
||||
framework(fw: passport.Framework): this;
|
||||
initialize(options?: { userProperty: string; }): express.Handler;
|
||||
session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
|
||||
interface Passport {
|
||||
use(strategy: passport.Strategy): Passport;
|
||||
use(name: string, strategy: passport.Strategy): Passport;
|
||||
unuse(name: string): Passport;
|
||||
framework(fw: passport.Framework): Passport;
|
||||
initialize(options?: { userProperty: string; }): express.Handler;
|
||||
session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
authenticate(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authenticate(strategy: string|string[], options: AuthenticateOptions, callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], options: any, callback?: Function): express.Handler;
|
||||
serializeUser<TUser, TID>(fn: (user: TUser, done: (err: any, id: TID) => void) => void): void;
|
||||
deserializeUser<TUser, TID>(fn: (id: TID, done: (err: any, user: TUser) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
}
|
||||
|
||||
authenticate(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authenticate(strategy: string|string[], options: AuthenticateOptions, callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], callback?: Function): express.Handler;
|
||||
authorize(strategy: string|string[], options: any, callback?: Function): express.Handler;
|
||||
serializeUser<TUser, TID>(fn: (user: TUser, done: (err: any, id: TID) => void) => void): void;
|
||||
deserializeUser<TUser, TID>(fn: (id: TID, done: (err: any, user: TUser) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
}
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: any): void;
|
||||
}
|
||||
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: any): void;
|
||||
}
|
||||
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
username?: string;
|
||||
name?: {
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: Array<{
|
||||
value: string;
|
||||
type?: string;
|
||||
}>;
|
||||
photos?: Array<{
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: Array<{
|
||||
value: string;
|
||||
type?: string;
|
||||
}>;
|
||||
photos?: Array<{
|
||||
value: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface Framework {
|
||||
initialize(passport: Passport, options?: any): Function;
|
||||
@@ -95,3 +94,4 @@ declare module 'passport' {
|
||||
const passport: passport.Passport;
|
||||
export = passport;
|
||||
}
|
||||
|
||||
|
||||
2
pdfkit/index.d.ts
vendored
2
pdfkit/index.d.ts
vendored
@@ -160,7 +160,7 @@ declare namespace PDFKit.Mixins {
|
||||
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): TDocument;
|
||||
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): TDocument;
|
||||
rect(x: number, y: number, w: number, h: number): TDocument;
|
||||
roundRect(x: number, y: number, w: number, h: number, r?: number): TDocument;
|
||||
roundedRect(x: number, y: number, w: number, h: number, r?: number): TDocument;
|
||||
ellipse(x: number, y: number, r1: number, r2?: number): TDocument;
|
||||
circle(x: number, y: number, raduis: number): TDocument;
|
||||
polygon(...points: number[][]): TDocument;
|
||||
|
||||
@@ -52,6 +52,8 @@ doc.path("M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90"
|
||||
|
||||
//Rectangle shape helper sample
|
||||
doc.rect(100,200,100,100);
|
||||
// Rounded rectangle
|
||||
doc.roundedRect(150,250,150,150,10);
|
||||
|
||||
//polygon
|
||||
doc.polygon([100,0],[50,100],[50,100]);
|
||||
|
||||
391
raygun4js/index.d.ts
vendored
391
raygun4js/index.d.ts
vendored
@@ -1,96 +1,311 @@
|
||||
// Type definitions for raygun4js 1.18.3
|
||||
// Type definitions for raygun4js 2.4.2
|
||||
// Project: https://github.com/MindscapeHQ/raygun4js
|
||||
// Definitions by: Brian Surowiec <https://github.com/xt0rted>
|
||||
// Definitions by: Brian Surowiec <https://github.com/xt0rted>, Benjamin Harding <https://github.com/BenjaminHarding>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace raygun {
|
||||
|
||||
// https://github.com/MindscapeHQ/raygun4js/blob/c7d8880045214ab6d403d5cc613c207f696a3cdd/src/raygun.js#L533-539
|
||||
interface IStackTrace {
|
||||
LineNumber: number;
|
||||
ColumnNumber: number;
|
||||
ClassName: string;
|
||||
FileName: string;
|
||||
MethodName: string;
|
||||
}
|
||||
|
||||
// https://github.com/MindscapeHQ/raygun4js/blob/c7d8880045214ab6d403d5cc613c207f696a3cdd/src/raygun.js#L598-637
|
||||
interface IPayload {
|
||||
OccurredOn: Date;
|
||||
Details: {
|
||||
Error: {
|
||||
ClassName: string;
|
||||
Message: string;
|
||||
StackTrace: IStackTrace[];
|
||||
};
|
||||
Environment: {
|
||||
UtcOffset: number;
|
||||
'User-Language': string;
|
||||
'Document-Mode': number;
|
||||
'Browser-Width': number;
|
||||
'Browser-Height': number;
|
||||
'Screen-Width': number;
|
||||
'Screen-Height': number;
|
||||
'Color-Depth': number;
|
||||
Browser: string;
|
||||
'Browser-Name': string;
|
||||
'Browser-Version': string;
|
||||
Platform: string;
|
||||
};
|
||||
Client: {
|
||||
Name: string;
|
||||
Version: string;
|
||||
};
|
||||
UserCustomData: any;
|
||||
Tags: string[];
|
||||
Request: {
|
||||
Url: string;
|
||||
QueryString: string;
|
||||
Headers: {
|
||||
'User-Agent': string;
|
||||
Referer: string;
|
||||
Host: string;
|
||||
};
|
||||
};
|
||||
Version: string;
|
||||
};
|
||||
}
|
||||
|
||||
// https://github.com/MindscapeHQ/raygun4js/blob/c7d8880045214ab6d403d5cc613c207f696a3cdd/src/raygun.js#L61-82
|
||||
interface IRaygunOptions {
|
||||
allowInsecureSubmissions?: boolean;
|
||||
ignoreAjaxAbort?: boolean;
|
||||
ignoreAjaxError?: boolean;
|
||||
disableAnonymousUserTracking?: boolean;
|
||||
excludedHostnames?: (string|RegExp)[];
|
||||
excludedUserAgents?: (string|RegExp)[];
|
||||
wrapAsynchronousCallbacks?: boolean;
|
||||
debugMode?: boolean;
|
||||
ignore3rdPartyErrors?: boolean;
|
||||
}
|
||||
|
||||
interface RaygunStatic {
|
||||
noConflict(): RaygunStatic;
|
||||
constructNewRaygun(): RaygunStatic;
|
||||
init(apiKey: string, options?: IRaygunOptions, customdata?: any): RaygunStatic;
|
||||
withCustomData(customdata: any): RaygunStatic;
|
||||
withTags(tags: string[]): RaygunStatic;
|
||||
attach(): RaygunStatic;
|
||||
detach(): RaygunStatic;
|
||||
send(e: Error, customData?: any, tags?: string[]): RaygunStatic;
|
||||
setUser(user: string, isAnonymous?: boolean, email?: string, fullName?: string, firstName?: string, uuid?: string): RaygunStatic;
|
||||
resetAnonymousUser(): void;
|
||||
setVersion(version: string): RaygunStatic;
|
||||
saveIfOffline(enableOffline: boolean): RaygunStatic;
|
||||
filterSensitiveData(filteredKeys: string[]): RaygunStatic;
|
||||
setFilterScope(scope: string): RaygunStatic;
|
||||
whitelistCrossOriginDomains(whitelist: string[]): RaygunStatic;
|
||||
onBeforeSend(callback: (payload: IPayload) => IPayload): RaygunStatic;
|
||||
}
|
||||
|
||||
interface TracekitStackTrace {
|
||||
message: string;
|
||||
mode: string;
|
||||
name: string;
|
||||
stack: TracekitStack[];
|
||||
url: string;
|
||||
useragent: string;
|
||||
}
|
||||
|
||||
declare var Raygun: raygun.RaygunStatic;
|
||||
interface TracekitStack {
|
||||
column: number;
|
||||
context: any;
|
||||
func: string;
|
||||
line: number;
|
||||
url: string;
|
||||
}
|
||||
|
||||
|
||||
interface RaygunStackTrace {
|
||||
LineNumber: number;
|
||||
ColumnNumber: number;
|
||||
ClassName: string;
|
||||
FileName: string;
|
||||
MethodName: string;
|
||||
}
|
||||
|
||||
interface RaygunOptions {
|
||||
/**
|
||||
* Posts error payloads over HTTP. This allows IE8 to send JS errors.
|
||||
*/
|
||||
allowInsecureSubmissions?: boolean;
|
||||
|
||||
/**
|
||||
* User-aborted Ajax calls result in errors. If this option is true, these errors will not be sent.
|
||||
*/
|
||||
ignoreAjaxAbort?: boolean;
|
||||
|
||||
/**
|
||||
* Ajax requests that return error codes will not be sent as errors to Raygun if this options is true.
|
||||
*/
|
||||
ignoreAjaxError?: boolean;
|
||||
|
||||
/**
|
||||
* Disabling anonymous user tracking.
|
||||
*/
|
||||
disableAnonymousUserTracking?: boolean;
|
||||
|
||||
/**
|
||||
* Prevent uncaught errors from being sent.
|
||||
*/
|
||||
disableErrorTracking?: boolean;
|
||||
|
||||
/**
|
||||
* Prevent Pulse real user monitoring events from being sent.
|
||||
*/
|
||||
disablePulse?: boolean;
|
||||
|
||||
/**
|
||||
* Prevents errors from being sent from certain hostnames (domains) by providing an array of strings or RegExp objects (for partial matches). Each should match the hostname or TLD that you want to exclude. Note that protocols are not tested.
|
||||
*/
|
||||
excludedHostnames?: (string|RegExp)[];
|
||||
|
||||
/**
|
||||
* Prevents errors from being sent from certain user agents by providing an array of strings. This is very helpful to exclude errors reported by certain browsers or test automation with CasperJS, PhantomJS or any other testing utility that sends a custom user agent. If a part of the client's navigator.userAgent matches one of the given strings in the array, then the client will be excluded from error reporting.
|
||||
*/
|
||||
excludedUserAgents?: (string|RegExp)[];
|
||||
|
||||
/**
|
||||
* The maximum time a virtual page can be considered viewed, in milliseconds (defaults to 30 minutes).
|
||||
*/
|
||||
pulseMaxVirtualPageDuration?: number;
|
||||
|
||||
/**
|
||||
* Ignore URL casing when sending data to Pulse.
|
||||
*/
|
||||
pulseIgnoreUrlCasing?: boolean;
|
||||
|
||||
/**
|
||||
* A string URI containing the protocol, domain and port (optional) where all payloads will be sent to. This can be used to proxy payloads to the Raygun API through your own server. When not set this defaults internally to the Raygun API, and for most usages you won't need to set this.
|
||||
*/
|
||||
apiUrl?: string;
|
||||
|
||||
/**
|
||||
* If false, async callback functions triggered by setTimeout/setInterval will not be wrapped when attach() is called. Defaults to true
|
||||
*/
|
||||
wrapAsynchronousCallbacks?: boolean;
|
||||
|
||||
/**
|
||||
* Raygun4JS will log to the console when sending errors.
|
||||
*/
|
||||
debugMode?: boolean;
|
||||
|
||||
/**
|
||||
* Ignores any errors that have no stack trace information. This will discard any errors that occur completely within 3rd party scripts - if code loaded from the current domain called the 3rd party function, it will have at least one stack line and will still be sent.
|
||||
*/
|
||||
ignore3rdPartyErrors?: boolean;
|
||||
|
||||
/**
|
||||
* A string URI containing the protocol, domain and port (optional) where all payloads will be sent to. This can be used to proxy payloads to the Raygun API through your own server. When not set this defaults internally to the Raygun API, and for most usages you won't need to set this.
|
||||
*/
|
||||
apiEndpoint?: string;
|
||||
}
|
||||
|
||||
interface RaygunPayload {
|
||||
OccurredOn: Date;
|
||||
Details: {
|
||||
Error: {
|
||||
ClassName: string;
|
||||
Message: string;
|
||||
StackTrace: RaygunStackTrace[];
|
||||
};
|
||||
Environment: {
|
||||
UtcOffset: number;
|
||||
'User-Language': string;
|
||||
'Document-Mode': number;
|
||||
'Browser-Width': number;
|
||||
'Browser-Height': number;
|
||||
'Screen-Width': number;
|
||||
'Screen-Height': number;
|
||||
'Color-Depth': number;
|
||||
Browser: string;
|
||||
'Browser-Name': string;
|
||||
'Browser-Version': string;
|
||||
Platform: string;
|
||||
};
|
||||
Client: {
|
||||
Name: string;
|
||||
Version: string;
|
||||
};
|
||||
UserCustomData: any;
|
||||
Tags: string[];
|
||||
Request: {
|
||||
Url: string;
|
||||
QueryString: string;
|
||||
Headers: {
|
||||
'User-Agent': string;
|
||||
Referer: string;
|
||||
Host: string;
|
||||
};
|
||||
};
|
||||
Version: string;
|
||||
User: {
|
||||
Identifier?: string;
|
||||
IsAnonymous?: boolean;
|
||||
Email?: string;
|
||||
FullName?: string;
|
||||
FirstName?: string;
|
||||
UUID?: any;
|
||||
};
|
||||
GroupingKey?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface RaygunStatic {
|
||||
|
||||
/**
|
||||
* Prevents Raygun from overwriting anything bound to `window.Raygun`.
|
||||
*/
|
||||
noConflict(): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Creates a new Raygun object. Allows the sending of errors to different applications.
|
||||
*/
|
||||
constructNewRaygun(): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Configures the Raygun provider.
|
||||
*/
|
||||
init(apiKey: string, options?: RaygunOptions, customdata?: any): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Attaches custom data to any errors sent to Raygun.
|
||||
*/
|
||||
withCustomData(customdata: any): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Allows errors to be filtered by tag in the Raygun Dashboard.
|
||||
*/
|
||||
withTags(tags: string[]): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Attaches to the `window.onerror` handler. Enables unhandled errors to be automatically tracked.
|
||||
*/
|
||||
attach(): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Detaches the handler from the window.onerror method. Unhandled errors will no longer be tracked.
|
||||
*/
|
||||
detach(): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Sends an error/exception to the Raygun Api.
|
||||
*/
|
||||
send(ex: Error, customData?: any, tags?: string[]): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Provides additional information about the current user.
|
||||
*/
|
||||
setUser(user: string, isAnonymous?: boolean, email?: string, fullName?: string, firstName?: string, uuid?: string): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Resets the information about the current user.
|
||||
*/
|
||||
resetAnonymousUser(): void;
|
||||
|
||||
/**
|
||||
* Allows errors to be filtered by version in the Raygun Dashboard. Versions should be in the format `x.x.x`
|
||||
*/
|
||||
setVersion(version: string): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Whether caught errors should be saved in Local Storage when there is no network activity. Saved errors will be send when another error occurs, and activity is regained. Disabled by default.
|
||||
*/
|
||||
saveIfOffline(enableOffline: boolean): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Blacklist keys to prevent their values from being sent to Raygun.
|
||||
*/
|
||||
filterSensitiveData(filteredKeys: (string|RegExp)[]): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Change the scope at which filters are applied. Defaults to `customData` by default.
|
||||
*/
|
||||
setFilterScope(scope: "all"|"customData"): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Whitelist damains which should transmit errors to Raygun.
|
||||
*/
|
||||
whitelistCrossOriginDomains(whitelist: string[]): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Executed before the payload is sent. If a truthy object is returned, Raygun will attempt to use that as the payload. Raygun will abort the send if `false` is returned.
|
||||
*/
|
||||
onBeforeSend(callback: (payload: RaygunPayload) => RaygunPayload|boolean): RaygunStatic;
|
||||
|
||||
/**
|
||||
* Overrides the default automatic grouping and instead group errors together by the string returned by the callback.
|
||||
*/
|
||||
groupingKey(callback: (payload: RaygunPayload, stackTrace: TracekitStackTrace, options: any) => string|void): RaygunStatic;
|
||||
onBeforeXHR(callback: (xhr: XMLHttpRequest) => void): RaygunStatic;
|
||||
onAfterSend(callback: (response: XMLHttpRequest) => void): RaygunStatic;
|
||||
endSession(): void;
|
||||
|
||||
/**
|
||||
* Track Single Page Application route events.
|
||||
*/
|
||||
trackEvent(type: "pageView", options: { path: string }): void;
|
||||
}
|
||||
|
||||
interface RaygunV2UserDetails {
|
||||
/**
|
||||
* Uniquely identifies the user within Raygun.
|
||||
*/
|
||||
identifier: string;
|
||||
|
||||
/**
|
||||
* Indicates whether the user is anonymous or has a user account. Even if this is set to true, you should still give the user a unique identifier of some kind.
|
||||
*/
|
||||
isAnonymous?: string;
|
||||
|
||||
/**
|
||||
* The user's email address.
|
||||
*/
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The user's full name.
|
||||
*/
|
||||
fullName?: string;
|
||||
|
||||
/**
|
||||
* The user's first or preferred name.
|
||||
*/
|
||||
firstName?: string;
|
||||
|
||||
/**
|
||||
* Identifier of the device the app is running on. This could be used to correlate user accounts over multiple machines.
|
||||
*/
|
||||
uuid?: string;
|
||||
}
|
||||
|
||||
|
||||
interface RaygunV2 {
|
||||
(key: "options", value:RaygunOptions):void;
|
||||
(key: "setUser", value: RaygunV2UserDetails):void;
|
||||
(key: "onBeforeSend", callback: (payload: RaygunPayload) => RaygunPayload|boolean):void;
|
||||
(key: "onBeforeXHR"|"onAfterSend", callback: (xhr: XMLHttpRequest) => void): void;
|
||||
(key: "groupingKey", value:(payload: RaygunPayload, stackTrace: TracekitStackTrace, options: any) => string|void):void;
|
||||
(key: "trackEvent", value: { type: string, path: string }): void;
|
||||
(key: "apiKey"|"setVersion"|"setFilterScope", value:string):void;
|
||||
(key: "attach"|"enableCrashReporting"|"enablePulse"|"noConflict"|"saveIfOffline", value: boolean):void;
|
||||
(key: "filterSensitiveData"|"whitelistCrossOriginDomains"|"withTags", values: string[]): void;
|
||||
(key: "send"|"withCustomData", value: any): void;
|
||||
(key: "getRaygunInstance"):RaygunStatic;
|
||||
(key: "detach"): void;
|
||||
(key: string):void;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
Raygun: RaygunStatic;
|
||||
}
|
||||
|
||||
declare var Raygun: RaygunStatic;
|
||||
|
||||
declare module 'raygun4js' {
|
||||
export = Raygun;
|
||||
|
||||
@@ -1,19 +1,38 @@
|
||||
var client: raygun.RaygunStatic = Raygun.noConflict();
|
||||
// V2 Api
|
||||
|
||||
var newClient: raygun.RaygunStatic = client.constructNewRaygun();
|
||||
// To use the V2 api you will need to declare a `rg4js` variable
|
||||
// This is because `rg4js` name is configurable by users
|
||||
declare var rg4js: RaygunV2;
|
||||
|
||||
rg4js("apiKey", "api-key");
|
||||
rg4js("enableCrashReporting", true);
|
||||
rg4js("enablePulse", true);
|
||||
rg4js('setUser', {
|
||||
identifier: "username",
|
||||
firstName: "Robert",
|
||||
fullName: "Robert Raygun"
|
||||
});
|
||||
|
||||
// V1 Api
|
||||
var client: RaygunStatic = Raygun.noConflict();
|
||||
var newClient: RaygunStatic = client.constructNewRaygun();
|
||||
|
||||
client.init('api-key');
|
||||
client.init('api-key', { allowInsecureSubmissions: true });
|
||||
client.init('api-key', { allowInsecureSubmissions: true }, { some: 'data' });
|
||||
client.init('api-key', { allowInsecureSubmissions: true, disablePulse: false });
|
||||
client.init('api-key', { allowInsecureSubmissions: true, disablePulse: false }, { some: 'data' });
|
||||
|
||||
client.withCustomData({ some: 'data' });
|
||||
client.withCustomData(function() {
|
||||
return { some: 'data' };
|
||||
});
|
||||
|
||||
client.withTags(['tag1', 'tag2']);
|
||||
|
||||
client.attach().detach();
|
||||
|
||||
client.send(new Error('a error'));
|
||||
client.send(new Error('a error'), ['tag1', 'tag2']);
|
||||
client.send(new Error('a error'), { some: 'data' });
|
||||
client.send(new Error('a error'), { some: 'data' }, ['tag1', 'tag2']);
|
||||
|
||||
try {
|
||||
throw new Error('oops');
|
||||
@@ -24,14 +43,12 @@ catch (e) {
|
||||
|
||||
client.setUser('username');
|
||||
client.setUser('username', true);
|
||||
client.setUser('username', false, 'user@email.com', 'Robbie Robot');
|
||||
client.setUser('username', false, 'user@email.com', 'Robbie Robot', 'Robbie');
|
||||
client.setUser('username', false, 'user@email.com', 'Robbie Robot', 'Robbie', '8ae89fc9-1144-42d6-9629-bf085dab18d2');
|
||||
client.setUser('username', false, 'user@email.com', 'Robert Raygun');
|
||||
client.setUser('username', false, 'user@email.com', 'Robert Raygun', 'Robert');
|
||||
client.setUser('username', false, 'user@email.com', 'Robert Raygun', 'Robert', '8ae89fc9-1144-42d6-9629-bf085dab18d2');
|
||||
|
||||
client.resetAnonymousUser();
|
||||
|
||||
client.setVersion('1.2.3.4');
|
||||
|
||||
client.saveIfOffline(true);
|
||||
|
||||
client.filterSensitiveData(['field1', 'field2']);
|
||||
@@ -43,4 +60,22 @@ client.whitelistCrossOriginDomains(['domain1', 'domain2']);
|
||||
client.onBeforeSend(payload=> {
|
||||
payload.OccurredOn = new Date();
|
||||
return payload;
|
||||
});
|
||||
});
|
||||
|
||||
client.groupingKey(payload => {
|
||||
return payload.Details.Error.Message;
|
||||
});
|
||||
|
||||
client.onBeforeXHR(xhr => {
|
||||
console.log(xhr.response);
|
||||
});
|
||||
|
||||
client.onAfterSend(xhr => {
|
||||
console.log(xhr.response);
|
||||
});
|
||||
|
||||
client.endSession();
|
||||
|
||||
client.trackEvent('pageView', {
|
||||
path: '/url'
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -17,4 +17,4 @@
|
||||
"index.d.ts",
|
||||
"raygun4js-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
43
react-bootstrap-table/index.d.ts
vendored
43
react-bootstrap-table/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for react-bootstrap-table v2.3.0
|
||||
// Type definitions for react-bootstrap-table v2.6.0
|
||||
// Project: https://github.com/AllenFang/react-bootstrap-table
|
||||
// Definitions by: Frank Laub <https://github.com/flaub>
|
||||
// Definitions by: Frank Laub <https://github.com/flaub>, Aleksander Lode <https://github.com/alelode>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="react" />
|
||||
@@ -115,12 +115,18 @@ export interface BootstrapTableProps extends Props<BootstrapTable> {
|
||||
*/
|
||||
options?: Options;
|
||||
fetchInfo?: FetchInfo;
|
||||
|
||||
printable?: boolean;
|
||||
tableStyle?: any;
|
||||
containerStyle?: any;
|
||||
headerStyle?: any;
|
||||
bodyStyle?: any;
|
||||
ignoreSinglePage?: boolean;
|
||||
containerClass?: string;
|
||||
tableContainerClass?: string
|
||||
headerContainerClass?: string;
|
||||
bodyContainerClass?: string;
|
||||
expandableRow?: (row: any) => boolean;
|
||||
expandComponent?: (row: any) => any;
|
||||
}
|
||||
|
||||
export type SelectRowMode = 'none' | 'radio' | 'checkbox';
|
||||
@@ -166,7 +172,7 @@ export interface SelectRow {
|
||||
`row`: is the row data which you wanted to select or unselect.
|
||||
`isSelected`: it's a boolean value means "whether or not that row will be selected?".
|
||||
`event`: The event target object.
|
||||
If return value of this function is false, the select or deselect action will not be applied.
|
||||
If return value of this (function) is false, the select or deselect action will not be applied.
|
||||
*/
|
||||
onSelect?: (row: any, isSelected: Boolean, event: any) => boolean;
|
||||
/**
|
||||
@@ -178,6 +184,10 @@ export interface SelectRow {
|
||||
*/
|
||||
onSelectAll?: (isSelected: boolean, currentSelectedAndDisplayData: any) => boolean;
|
||||
|
||||
/**
|
||||
* Provide a list of unselectable row keys.
|
||||
*/
|
||||
unselectable?: number[];
|
||||
}
|
||||
|
||||
export type CellEditClickMode = 'none' | 'click' | 'dbclick';
|
||||
@@ -293,6 +303,10 @@ export interface Options {
|
||||
/**
|
||||
To define the pagination bar length, default is 5.
|
||||
*/
|
||||
/**
|
||||
To define where to start counting the pages.
|
||||
*/
|
||||
pageStartIndex?: string;
|
||||
paginationSize?: number;
|
||||
/**
|
||||
Assign a callback function which will be called after page changed.
|
||||
@@ -333,6 +347,15 @@ export interface Options {
|
||||
This function taking one argument: row which is the row data which you click on.
|
||||
*/
|
||||
onRowClick?: (row: any) => void;
|
||||
/**
|
||||
Assign a callback function which will be called after a row double click.
|
||||
This function taking one argument: row which is the row data which you double click on.
|
||||
*/
|
||||
onRowDoubleClick?: (row:any)=>void;
|
||||
/**
|
||||
Background color on expanded rows.
|
||||
*/
|
||||
expandRowBgColor?: string;
|
||||
/**
|
||||
Assign a callback function which will be called when mouse enter into the table.
|
||||
*/
|
||||
@@ -362,7 +385,7 @@ export interface Options {
|
||||
`rowKeys` is the row keys which been deleted, you can call next function to apply this deletion.
|
||||
*/
|
||||
handleConfirmDeleteRow?: (next: Function, rowKeys: any[]) => void;
|
||||
paginationShowsTotal?: boolean;
|
||||
paginationShowsTotal?: boolean | ReactElement<any>;
|
||||
onSearchChange?: Function;
|
||||
onAddRow?: Function;
|
||||
onExportToCSV?: Function;
|
||||
@@ -442,6 +465,10 @@ export interface TableHeaderColumnProps extends Props<TableHeaderColumn> {
|
||||
True to enable table sorting. Default is disabled.
|
||||
*/
|
||||
dataSort?: boolean;
|
||||
/**
|
||||
Default search string.
|
||||
*/
|
||||
defaultSearch?: string;
|
||||
/**
|
||||
Allow user to render a custom sort caret. You should give a function and should return a JSX.
|
||||
This function taking one arguments: order which present the sort order currently.
|
||||
@@ -460,6 +487,10 @@ export interface TableHeaderColumnProps extends Props<TableHeaderColumn> {
|
||||
True to hide column.
|
||||
*/
|
||||
hidden?: boolean;
|
||||
/**
|
||||
True to hide the dropdown for sizePerPage.
|
||||
*/
|
||||
hideSizePerPage?: boolean
|
||||
/**
|
||||
False to disable search functionality on column, default is true.
|
||||
*/
|
||||
@@ -557,7 +588,7 @@ export interface Filter {
|
||||
/**
|
||||
* Only work on NumberFilter. Accept an array which conatin the filter condition, like: ['<','>','=']
|
||||
*/
|
||||
numberComparators: string[];
|
||||
numberComparators?: string[];
|
||||
}
|
||||
|
||||
export interface TableHeaderColumn extends ComponentClass<TableHeaderColumnProps> { }
|
||||
|
||||
2
react-dropzone/index.d.ts
vendored
2
react-dropzone/index.d.ts
vendored
@@ -36,5 +36,5 @@ declare module "react-dropzone" {
|
||||
}
|
||||
|
||||
let Dropzone: React.ClassicComponentClass<DropzoneProps>;
|
||||
export default Dropzone;
|
||||
export = Dropzone;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
///<reference types="react" />
|
||||
///<reference types="react-dropzone" />
|
||||
import * as React from 'react';
|
||||
import Dropzone from 'react-dropzone';
|
||||
import * as Dropzone from 'react-dropzone';
|
||||
|
||||
class Test extends React.Component<any, any> {
|
||||
constructor(props: any) {
|
||||
|
||||
3
react-modal/index.d.ts
vendored
3
react-modal/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for react-modal v1.3.0
|
||||
// Type definitions for react-modal v1.6.1
|
||||
// Project: https://github.com/reactjs/react-modal
|
||||
// Definitions by: Rajab Shakirov <https://github.com/radziksh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -24,6 +24,7 @@ declare module "react-modal" {
|
||||
shouldCloseOnOverlayClick?: boolean,
|
||||
overlayClassName?: string,
|
||||
className?: string
|
||||
contentLabel?: string
|
||||
}
|
||||
let ReactModal: React.ClassicComponentClass<ReactModal>;
|
||||
export = ReactModal;
|
||||
|
||||
65
react-native/index.d.ts
vendored
65
react-native/index.d.ts
vendored
@@ -741,10 +741,57 @@ declare module "react" {
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
interface PerpectiveTransform {
|
||||
perspective: number;
|
||||
}
|
||||
|
||||
interface RotateTransform {
|
||||
rotate: string;
|
||||
}
|
||||
|
||||
interface RotateXTransform {
|
||||
rotateX: string;
|
||||
}
|
||||
|
||||
interface RotateYTransform {
|
||||
rotateY: string;
|
||||
}
|
||||
|
||||
interface RotateZTransform {
|
||||
rotateZ: string;
|
||||
}
|
||||
|
||||
interface ScaleTransform {
|
||||
scale: number;
|
||||
}
|
||||
|
||||
interface ScaleXTransform {
|
||||
scaleX: number;
|
||||
}
|
||||
|
||||
interface ScaleYTransform {
|
||||
scaleY: number;
|
||||
}
|
||||
|
||||
interface TranslateXTransform {
|
||||
translateX: number;
|
||||
}
|
||||
|
||||
interface TranslateYTransform {
|
||||
translateY: number;
|
||||
}
|
||||
|
||||
interface SkewXTransform {
|
||||
skewX: string;
|
||||
}
|
||||
|
||||
interface SkewYTransform {
|
||||
skewY: string;
|
||||
}
|
||||
|
||||
export interface TransformsStyle {
|
||||
|
||||
transform?: [{ perspective: number }, { rotate: string }, { rotateX: string }, { rotateY: string }, { rotateZ: string }, { scale: number }, { scaleX: number }, { scaleY: number }, { translateX: number }, { translateY: number }, { skewX: string }, { skewY: string }]
|
||||
transform?: (PerpectiveTransform|RotateTransform|RotateXTransform|RotateYTransform|RotateZTransform|ScaleTransform|ScaleXTransform|ScaleYTransform|TranslateXTransform|TranslateYTransform|SkewXTransform|SkewYTransform)[]
|
||||
transformMatrix?: Array<number>
|
||||
rotation?: number
|
||||
scaleX?: number
|
||||
@@ -3772,13 +3819,13 @@ declare module "react" {
|
||||
* On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
|
||||
* @platform ios
|
||||
*/
|
||||
supportedOrientations: ('portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right')[]
|
||||
supportedOrientations?: ('portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right')[]
|
||||
/**
|
||||
* The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
|
||||
* The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
|
||||
* @platform ios
|
||||
*/
|
||||
onOrientationChange: () => void,
|
||||
onOrientationChange?: () => void
|
||||
}
|
||||
|
||||
export interface ModalStatic extends React.ComponentClass<ModalProperties> {
|
||||
@@ -5576,7 +5623,17 @@ declare module "react" {
|
||||
* Fires at most once per frame during scrolling.
|
||||
* The frequency of the events can be contolled using the scrollEventThrottle prop.
|
||||
*/
|
||||
onScroll?: (event?: { nativeEvent: NativeScrollEvent }) => void
|
||||
onScroll?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void
|
||||
|
||||
/**
|
||||
* Fires if a user initiates a scroll gesture.
|
||||
*/
|
||||
onScrollBeginDrag?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void
|
||||
|
||||
/**
|
||||
* Fires when a user has finished scrolling.
|
||||
*/
|
||||
onScrollEndDrag?: (event?: NativeSyntheticEvent<NativeScrollEvent>) => void
|
||||
|
||||
/**
|
||||
* When true the scroll view stops on multiples of the scroll view's size
|
||||
|
||||
486
redux-form/index.d.ts
vendored
486
redux-form/index.d.ts
vendored
@@ -1,476 +1,38 @@
|
||||
// Type definitions for redux-form v4.0.3
|
||||
// Type definitions for redux-form v6.3.1
|
||||
// Project: https://github.com/erikras/redux-form
|
||||
// Definitions by: Daniel Lytkin <https://github.com/aikoven>
|
||||
// Definitions by: Carson Full <https://github.com/carsonf>, Daniel Lytkin <https://github.com/aikoven>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as React from 'react';
|
||||
import { Component, SyntheticEvent, FormEventHandler } from 'react';
|
||||
import { Dispatch, ActionCreator, Reducer } from 'redux';
|
||||
///<reference types="react" />
|
||||
|
||||
export const actionTypes: {[actionName:string]: string};
|
||||
import {
|
||||
ComponentClass,
|
||||
StatelessComponent,
|
||||
} from 'react';
|
||||
|
||||
export type FieldValue = any;
|
||||
|
||||
export type FormData = { [fieldName: string]: FieldValue };
|
||||
export type FieldType = 'Field' | 'FieldArray';
|
||||
|
||||
export interface FieldProp<T> {
|
||||
/**
|
||||
* true if this field currently has focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
active: boolean;
|
||||
export type DataShape = {[fieldName:string]: FieldValue};
|
||||
|
||||
/**
|
||||
* An alias for value only when value is a boolean. Provided for
|
||||
* convenience of destructuring the whole field object into the props of a
|
||||
* form element.
|
||||
*/
|
||||
checked?: boolean;
|
||||
export type FormErrors<FormData extends DataShape> = FormData & { _error?: string };
|
||||
|
||||
/**
|
||||
* true if the field value has changed from its initialized value.
|
||||
* Opposite of pristine.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The error for this field if its value is not passing validation. Both
|
||||
* synchronous and asynchronous validation errors will be reported here.
|
||||
*/
|
||||
error?: any;
|
||||
|
||||
/**
|
||||
* The value for this field as supplied in initialValues to the form.
|
||||
*/
|
||||
initialValue: FieldValue;
|
||||
|
||||
/**
|
||||
* true if the field value fails validation (has a validation error).
|
||||
* Opposite of valid.
|
||||
*/
|
||||
invalid: boolean;
|
||||
|
||||
/**
|
||||
* The name of the field. It will be the same as the key in the fields
|
||||
* Object, but useful if bundling up a field to send down to a specialized
|
||||
* input component.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A function to call when the form field loses focus. It expects to
|
||||
* either receive the React SyntheticEvent or the current value of the
|
||||
* field.
|
||||
*/
|
||||
onBlur(eventOrValue: SyntheticEvent<T> | FieldValue): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field is changed. It expects to either
|
||||
* receive the React SyntheticEvent or the new value of the field.
|
||||
* @param eventOrValue
|
||||
*/
|
||||
onChange(eventOrValue: SyntheticEvent<T> | FieldValue): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a 'dragStart' event.
|
||||
* Saves the field value in the event for giving the field it is dropped
|
||||
* into.
|
||||
*/
|
||||
onDragStart(): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a drop event.
|
||||
*/
|
||||
onDrop(): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives focus.
|
||||
*/
|
||||
onFocus(): void;
|
||||
|
||||
/**
|
||||
* An alias for onChange. Provided for convenience of destructuring the
|
||||
* whole field object into the props of a form element. Added to provide
|
||||
* out-of-the-box support for Belle components' onUpdate API.
|
||||
*/
|
||||
onUpdate(): void;
|
||||
|
||||
/**
|
||||
* true if the field value is the same as its initialized value. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* true if the field has been touched. By default this will be set when
|
||||
* the field is blurred.
|
||||
*/
|
||||
touched: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value passes validation (has no validation errors).
|
||||
* Opposite of invalid.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* The value of this form field. It will be a boolean for checkboxes, and
|
||||
* a string for all other input types.
|
||||
*/
|
||||
value: FieldValue;
|
||||
|
||||
/**
|
||||
* true if this field has ever had focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
visited: boolean;
|
||||
}
|
||||
|
||||
export interface ReduxFormProps<T> {
|
||||
/**
|
||||
* The name of the currently active (with focus) field.
|
||||
*/
|
||||
active?: string;
|
||||
|
||||
/**
|
||||
* A function that may be called to initiate asynchronous validation if
|
||||
* asynchronous validation is enabled.
|
||||
*/
|
||||
asyncValidate?: Function;
|
||||
|
||||
/**
|
||||
* true if the asynchronous validation function has been called but has not
|
||||
* yet returned.
|
||||
*/
|
||||
asyncValidating?: boolean;
|
||||
|
||||
/**
|
||||
* Destroys the form state in the Redux store. By default, this will be
|
||||
* called for you in componentWillUnmount().
|
||||
*/
|
||||
destroyForm?(): void;
|
||||
|
||||
/**
|
||||
* true if the form data has changed from its initialized values. Opposite
|
||||
* of pristine.
|
||||
*/
|
||||
dirty?: boolean;
|
||||
|
||||
/**
|
||||
* A generic error for the entire form given by the _error key in the
|
||||
* result from the synchronous validation function, the asynchronous
|
||||
* validation, or the rejected promise from onSubmit.
|
||||
*/
|
||||
error?: any;
|
||||
|
||||
/**
|
||||
* The form data, in the form { field1: <Object>, field2: <Object> }. The
|
||||
* field objects are meant to be destructured into your input component as
|
||||
* props, e.g. <input type="text" {...field.name}/>. Each field Object has
|
||||
* the following properties:
|
||||
*/
|
||||
fields?: { [field: string]: FieldProp<T> };
|
||||
|
||||
/**
|
||||
* A function meant to be passed to <form onSubmit={handleSubmit}> or to
|
||||
* <button onClick={handleSubmit}>. It will run validation, both sync and
|
||||
* async, and, if the form is valid, it will call
|
||||
* this.props.onSubmit(data) with the contents of the form data.
|
||||
* Optionally, you may also pass your onSubmit function to handleSubmit
|
||||
* which will take the place of the onSubmit prop. For example: <form
|
||||
* onSubmit={handleSubmit(this.save.bind(this))}> If your onSubmit
|
||||
* function returns a promise, the submitting property will be set to true
|
||||
* until the promise has been resolved or rejected. If it is rejected with
|
||||
* an object matching { field1: 'error', field2: 'error' } then the
|
||||
* submission errors will be added to each field (to the error prop) just
|
||||
* like async validation errors are. If there is an error that is not
|
||||
* specific to any field, but applicable to the entire form, you may pass
|
||||
* that as if it were the error for a field called _error, and it will be
|
||||
* given as the error prop.
|
||||
*/
|
||||
handleSubmit?(event: SyntheticEvent<T>): void;
|
||||
handleSubmit?(event: React.MouseEvent<HTMLButtonElement>): void;
|
||||
handleSubmit?(submit: (data: FormData, dispatch?: Dispatch<any>) => Promise<any> | void): FormEventHandler<T>;
|
||||
|
||||
/**
|
||||
* Initializes the form data to the given values. All dirty and pristine
|
||||
* state will be determined by comparing the current data with these
|
||||
* initialized values.
|
||||
* @param data
|
||||
*/
|
||||
initializeForm?(data: FormData): void;
|
||||
|
||||
/**
|
||||
* true if the form has validation errors. Opposite of valid.
|
||||
*/
|
||||
invalid?: boolean;
|
||||
|
||||
/**
|
||||
* true if the form data is the same as its initialized values. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine?: boolean;
|
||||
|
||||
/**
|
||||
* Resets all the values in the form to the initialized state, making it
|
||||
* pristine again.
|
||||
*/
|
||||
resetForm?(): void;
|
||||
|
||||
/**
|
||||
* The same formKey prop that was passed in. See Editing Multiple Records.
|
||||
*/
|
||||
formKey?: string;
|
||||
|
||||
/**
|
||||
* Whether or not your form is currently submitting. This prop will only
|
||||
* work if you have passed an onSubmit function that returns a promise. It
|
||||
* will be true until the promise is resolved or rejected.
|
||||
*/
|
||||
submitting?: boolean;
|
||||
|
||||
/**
|
||||
* Starts as false. If onSubmit is called, and fails to submit for any
|
||||
* reason, submitFailed will be set to true. A subsequent successful
|
||||
* submit will set it back to false.
|
||||
*/
|
||||
submitFailed?: boolean;
|
||||
|
||||
/**
|
||||
* Marks the given fields as "touched" to show errors.
|
||||
* @param field
|
||||
*/
|
||||
touch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* Marks all fields as "touched" to show errors. This will automatically
|
||||
* happen on form submission.
|
||||
*/
|
||||
touchAll?(): void;
|
||||
|
||||
/**
|
||||
* Clears the "touched" flag for the given fields
|
||||
* @param field
|
||||
*/
|
||||
untouch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* Clears the "touched" flag for the all fields
|
||||
*/
|
||||
untouchAll?(): void;
|
||||
|
||||
/**
|
||||
* true if the form passes validation (has no validation errors). Opposite
|
||||
* of invalid.
|
||||
*/
|
||||
valid?: boolean;
|
||||
|
||||
/**
|
||||
* All of your values in the form { field1: <string>, field2: <string> }.
|
||||
*/
|
||||
values?: FormData;
|
||||
}
|
||||
|
||||
declare class ElementClass extends Component<any, any> {
|
||||
}
|
||||
interface ClassDecorator {
|
||||
<T extends (typeof ElementClass)>(component: T): T;
|
||||
}
|
||||
|
||||
interface MapStateToProps {
|
||||
(state: any, ownProps?: any): any;
|
||||
}
|
||||
|
||||
interface MapDispatchToPropsFunction {
|
||||
(dispatch: Dispatch<any>, ownProps?: any): any;
|
||||
}
|
||||
|
||||
interface MapDispatchToPropsObject {
|
||||
[name: string]: ActionCreator<any>;
|
||||
}
|
||||
|
||||
export declare function reduxForm(config: ReduxFormConfig,
|
||||
mapStateToProps?: MapStateToProps,
|
||||
mapDispatchToProps?: MapDispatchToPropsFunction | MapDispatchToPropsObject): ClassDecorator;
|
||||
|
||||
export interface ReduxFormConfig {
|
||||
/**
|
||||
* a list of all your fields in your form. You may change these dynamically
|
||||
* at runtime.
|
||||
*/
|
||||
fields: string[];
|
||||
|
||||
/**
|
||||
* the name of your form and the key to where your form's state will be
|
||||
* mounted under the redux-form reducer
|
||||
*/
|
||||
form: string;
|
||||
|
||||
/**
|
||||
* By default, async blur validation is only triggered if synchronous
|
||||
* validation passes, and the form is dirty or was never initialized (or if
|
||||
* submitting). Sometimes it may be desirable to trigger asynchronous
|
||||
* validation even in these cases, for example if all validation is performed
|
||||
* asynchronously and you want to display validation messages if a user does
|
||||
* not change a field, but does touch and blur it. Setting
|
||||
* alwaysAsyncValidate to true will always run asynchronous validation on
|
||||
* blur, even if the form is pristine or sync validation fails.
|
||||
*/
|
||||
alwaysAsyncValidate?: boolean;
|
||||
|
||||
/**
|
||||
* field names for which onBlur should trigger a call to the asyncValidate
|
||||
* function. Defaults to [].
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncBlurFields?: string[];
|
||||
|
||||
/**
|
||||
* a function that takes all the form values, the dispatch function, and
|
||||
* the props given to your component, and returns a Promise that will
|
||||
* resolve if the validation is passed, or will reject with an object of
|
||||
* validation errors in the form { field1: <String>, field2: <String> }.
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncValidate?(values: FormData, dispatch: Dispatch<any>, props: Object): Promise<any>;
|
||||
|
||||
/**
|
||||
* Whether or not to automatically destroy your form's state in the Redux
|
||||
* store when your component is unmounted. Defaults to true.
|
||||
*/
|
||||
destroyOnUnmount?: boolean;
|
||||
|
||||
/**
|
||||
* The key for your sub-form.
|
||||
*
|
||||
* See Multirecord Example for more details.
|
||||
*/
|
||||
formKey?: string;
|
||||
|
||||
/**
|
||||
* A function that takes the entire Redux state and the reduxMountPoint
|
||||
* (which defaults to "form"). It defaults to:
|
||||
* (state, reduxMountPoint) => state[reduxMountPoint].
|
||||
* The only reason you should provide this is if you are keeping your Redux
|
||||
* state as something other than plain javascript objects, e.g. an
|
||||
* Immutable.Map.
|
||||
*/
|
||||
getFormState?(state: any, reduxMountPoint: string): any;
|
||||
|
||||
/**
|
||||
* The values with which to initialize your form in componentWillMount().
|
||||
* Particularly useful when Editing Multiple Records, but can also be used
|
||||
* with single-record forms. The values should be in the form
|
||||
* { field1: 'value1', field2: 'value2' }.
|
||||
*/
|
||||
initialValues?: { [field: string]: FieldValue };
|
||||
|
||||
/**
|
||||
* The function to call with the form data when the handleSubmit() is fired
|
||||
* from within the form component. If you do not specify it as a prop here,
|
||||
* you must pass it as a parameter to handleSubmit() inside your form
|
||||
* component.
|
||||
*/
|
||||
onSubmit?(values: FormData, dispatch?: Dispatch<any>): any;
|
||||
|
||||
/**
|
||||
* If true, the form values will be overwritten whenever the initialValues
|
||||
* prop changes. If false, the values will not be overwritten if the form has
|
||||
* previously been initialized. Defaults to true.
|
||||
*/
|
||||
overwriteOnInitialValuesChange?: boolean;
|
||||
|
||||
/**
|
||||
* If specified, all the props normally passed into your decorated
|
||||
* component directly will be passed under the key specified. Useful if
|
||||
* using other decorator libraries on the same component to avoid prop
|
||||
* namespace collisions.
|
||||
*/
|
||||
propNamespace?: string;
|
||||
|
||||
/**
|
||||
* if true, the decorated component will not be passed any of the onX
|
||||
* functions as props that will allow it to mutate the state. Useful for
|
||||
* decorating another component that is not your form, but that needs to
|
||||
* know about the state of your form.
|
||||
*/
|
||||
readonly?: boolean;
|
||||
|
||||
/**
|
||||
* The use of this property is highly discouraged, but if you absolutely
|
||||
* need to mount your redux-form reducer at somewhere other than form in
|
||||
* your Redux state, you will need to specify the key you mounted it under
|
||||
* with this property. Defaults to 'form'.
|
||||
*
|
||||
* See Alternate Mount Point Example for more details.
|
||||
*/
|
||||
reduxMountPoint?: string;
|
||||
|
||||
/**
|
||||
* If set to true, a failed submit will return a rejected promise. Defaults
|
||||
* to false. Only use this if you need to detect submit failures and run
|
||||
* some code when a submit fails.
|
||||
*/
|
||||
returnRejectedSubmitPromise?: boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the blur action is fired. Defaults to true.
|
||||
*/
|
||||
touchOnBlur?: boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the change action is fired. Defaults to
|
||||
* false.
|
||||
*/
|
||||
touchOnChange?: boolean;
|
||||
|
||||
/**
|
||||
* a synchronous validation function that takes the form values and props
|
||||
* passed into your component. If validation passes, it should return {}.
|
||||
* If validation fails, it should return the validation errors in the form
|
||||
* { field1: <String>, field2: <String> }.
|
||||
* Defaults to (values, props) => ({}).
|
||||
*/
|
||||
validate?(values: FormData, props: { [fieldName: string]: FieldProp<any> }): Object;
|
||||
}
|
||||
export type FormWarnings<FormData extends DataShape> = FormData & { _warning?: string };
|
||||
|
||||
/**
|
||||
* @param value The current value of the field.
|
||||
* @param previousValue The previous value of the field before the current
|
||||
* action was dispatched.
|
||||
* @param allValues All the values of the current form.
|
||||
* @param previousAllValues All the values of the form before the current
|
||||
* change. Useful to change one field based on a change in another.
|
||||
* A component class or stateless function component.
|
||||
* Workaround for: ComponentClass<P> | SFC<P> which does
|
||||
* not resolve due to a bug in TypeScript.
|
||||
* https://github.com/Microsoft/TypeScript/pull/8674
|
||||
*/
|
||||
export type Normalizer =
|
||||
(value: FieldValue, previousValue: FieldValue,
|
||||
allValues: FormData, previousAllValues: FormData) => any;
|
||||
|
||||
export declare const reducer: {
|
||||
(state: any, action: any): any;
|
||||
|
||||
/**
|
||||
* Returns a form reducer that will also pass each form value through the
|
||||
* normalizing functions provided. The parameter is an object mapping from
|
||||
* formName to an object mapping from fieldName to a normalizer function.
|
||||
* The normalizer function is given four parameters and expected to return
|
||||
* the normalized value of the field.
|
||||
*/
|
||||
normalize(normalizers: {
|
||||
[formName: string]: {
|
||||
[fieldName: string]: Normalizer
|
||||
}
|
||||
}): Reducer<any>;
|
||||
|
||||
/**
|
||||
* Returns a form reducer that will also pass each action through
|
||||
* additional reducers specified. The parameter should be an object mapping
|
||||
* from formName to a (state, action) => nextState reducer. The state
|
||||
* passed to each reducer will only be the slice that pertains to that
|
||||
* form.
|
||||
*/
|
||||
plugin(reducers: { [formName: string]: Reducer<any> }): Reducer<any>;
|
||||
}
|
||||
export type ComponentConstructor = ComponentClass<any> | StatelessComponent<any>;
|
||||
|
||||
export * from "./lib/reduxForm";
|
||||
export * from "./lib/Field";
|
||||
export * from "./lib/Fields";
|
||||
export * from "./lib/FieldArray";
|
||||
export * from "./lib/FormSection";
|
||||
export * from "./lib/actions";
|
||||
export * from "./lib/reducer";
|
||||
export * from "./lib/selectors";
|
||||
|
||||
313
redux-form/lib/Field.d.ts
vendored
Normal file
313
redux-form/lib/Field.d.ts
vendored
Normal file
@@ -0,0 +1,313 @@
|
||||
import {
|
||||
Component,
|
||||
ReactElement,
|
||||
DragEventHandler,
|
||||
FocusEventHandler,
|
||||
FormEventHandler,
|
||||
} from "react";
|
||||
import { Dispatch } from "redux";
|
||||
import { ComponentConstructor, DataShape, FieldValue } from "../index";
|
||||
|
||||
/**
|
||||
* These are the props to give to `Field`.
|
||||
* Any others will be passed through to your component.
|
||||
*/
|
||||
interface BaseFieldProps {
|
||||
/**
|
||||
* A string path, in dot-and-bracket notation, corresponding to a value
|
||||
* in the form values. It may be as simple as 'firstName' or as complicated
|
||||
* as contact.billing.address[2].phones[1].areaCode.
|
||||
*
|
||||
* Required but made optional so interface can be used on decorated components.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* A Component, stateless function, or string corresponding to a default
|
||||
* JSX element.
|
||||
*
|
||||
* Required but made optional so interface can be used on decorated components.
|
||||
*/
|
||||
component?: ComponentConstructor | "input" | "select" | "textarea",
|
||||
// component?: ComponentClass<P> | SFC<P> | "input" | "select" | "textarea",
|
||||
|
||||
/**
|
||||
* If true, the rendered component will be available with the
|
||||
* getRenderedComponent() method. Defaults to false. Cannot be used if your
|
||||
* component is a stateless function component.
|
||||
*/
|
||||
withRef?: boolean;
|
||||
|
||||
/**
|
||||
* Formats the value from the Redux store to be displayed in the field input.
|
||||
* Common use cases are to format Numbers into currencies or Dates into a
|
||||
* localized date format.
|
||||
*/
|
||||
format?: Formatter | null;
|
||||
|
||||
/**
|
||||
* A function to convert whatever value the user has entered into the value that you
|
||||
* want stored in the Redux store for the field.
|
||||
*
|
||||
* For instance, if you want the value to be in all uppercase, you would pass
|
||||
* value => value.toUpperCase()
|
||||
*/
|
||||
normalize?: Normalizer;
|
||||
|
||||
/**
|
||||
* Don't use.
|
||||
*/
|
||||
props?: Object;
|
||||
|
||||
/**
|
||||
* Parses the value given from the field input component to the type that you want
|
||||
* stored in the Redux store. Common use cases are to parse currencies into Numbers into
|
||||
* currencies or localized date formats into Dates.
|
||||
*/
|
||||
parse?: Parser;
|
||||
|
||||
/**
|
||||
* Allows you to to provide a field-level validation rule. The function will be given the
|
||||
* current value of the field and all the other form values. If the field is valid, it
|
||||
* should return `undefined`, if the field is invalid, it should return an error
|
||||
* (usually, but not necessarily, a `String`).
|
||||
*/
|
||||
validate?: Validator|Validator[];
|
||||
|
||||
/**
|
||||
* Allows you to to provide a field-level warning rule. The function will be given the
|
||||
* current value of the field and all the other form values. If the field needs a warning,
|
||||
* it should return the warning (usually, but not necessarily, a `String`). If the field
|
||||
* does not need a warning, it should return `undefined`.
|
||||
*/
|
||||
warn?: Validator|Validator[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The value entered by the user.
|
||||
* @param previousValue The previous value for the field.
|
||||
* @param allValues All the values in the entire form with the new value.
|
||||
* This will be an Immutable Map if you are using Immutable JS.
|
||||
* @param previousAllValues All the values in the entire form before the current change.
|
||||
* This will be an Immutable Map if you are using Immutable JS.
|
||||
*/
|
||||
export type Normalizer = (value: FieldValue, previousValue?: FieldValue, allValues?: Object, previousAllValues?: Object) => FieldValue;
|
||||
|
||||
export type Formatter = (value: FieldValue, name: string) => FieldValue;
|
||||
|
||||
export type Parser = (value: FieldValue, name: string) => FieldValue;
|
||||
|
||||
export type Validator = (value: FieldValue, allValues?: Object) => undefined | string;
|
||||
|
||||
/**
|
||||
* Declare Field as this interface to specify the generic.
|
||||
*/
|
||||
export interface GenericField<FieldCustomProps, S> extends Component<BaseFieldProps & FieldCustomProps, {}> {
|
||||
/**
|
||||
* true if the current value is different from the initialized value,
|
||||
* false otherwise.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The name prop that you passed in.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* true if the current value is the same as the initialized value,
|
||||
* false otherwise.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* The current value of the field.
|
||||
*/
|
||||
value: FieldValue;
|
||||
|
||||
/**
|
||||
* Returns the instance of the rendered component. For this to work, you must
|
||||
* provide a withRef prop, and your component must not be a stateless function
|
||||
* component.
|
||||
*/
|
||||
getRenderedComponent(): Component<WrappedFieldProps<S> & FieldCustomProps, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Field Instance API.
|
||||
*/
|
||||
export class Field extends Component<any, {}> implements GenericField<any, any> {
|
||||
/**
|
||||
* true if the current value is different from the initialized value,
|
||||
* false otherwise.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The name prop that you passed in.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* true if the current value is the same as the initialized value,
|
||||
* false otherwise.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* The current value of the field.
|
||||
*/
|
||||
value: FieldValue;
|
||||
|
||||
/**
|
||||
* Returns the instance of the rendered component. For this to work, you must
|
||||
* provide a withRef prop, and your component must not be a stateless function
|
||||
* component.
|
||||
*/
|
||||
getRenderedComponent(): Component<any, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* These are props that `Field` will pass to your wrapped component (not including custom props).
|
||||
*/
|
||||
interface WrappedFieldProps<S> {
|
||||
/**
|
||||
* An object containing all the props that you will normally want to pass to
|
||||
* your input component.
|
||||
*/
|
||||
input: WrappedFieldInputProps;
|
||||
|
||||
/**
|
||||
* An object containing all the metadata props.
|
||||
*/
|
||||
meta: WrappedFieldMetaProps<S>;
|
||||
}
|
||||
|
||||
/**
|
||||
* These props are meant to be destructured into your <input/> component.
|
||||
*/
|
||||
interface WrappedFieldInputProps {
|
||||
/**
|
||||
* An alias for value only when value is a boolean. Provided for
|
||||
* convenience of destructuring the whole field object into the props of a
|
||||
* form element.
|
||||
*/
|
||||
checked?: boolean;
|
||||
|
||||
/**
|
||||
* The name prop passed in.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A function to call when the form field loses focus.
|
||||
*/
|
||||
onBlur: FocusEventHandler<any>;
|
||||
|
||||
/**
|
||||
* A function to call when the form field is changed.
|
||||
*/
|
||||
onChange: FormEventHandler<any>;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a 'dragStart' event.
|
||||
* Saves the field value in the event for giving the field it is dropped
|
||||
* into.
|
||||
*/
|
||||
onDragStart: DragEventHandler<any>;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a drop event.
|
||||
*/
|
||||
onDrop: DragEventHandler<any>;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives focus.
|
||||
*/
|
||||
onFocus: FocusEventHandler<any>;
|
||||
|
||||
/**
|
||||
* The value of this form field. It will be a boolean for checkboxes, and
|
||||
* a string for all other input types. If there is no value in the Redux
|
||||
* state for this field, it will default to ''. This is to
|
||||
* ensure that the input is controlled.
|
||||
*/
|
||||
value: FieldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* These props are metadata about the state of this field that redux-form is tracking for you.
|
||||
*/
|
||||
interface WrappedFieldMetaProps<S> {
|
||||
|
||||
/**
|
||||
* true if this field currently has focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
active?: boolean;
|
||||
|
||||
/**
|
||||
* true if this field has been set with the AUTOFILL action and has not since been changed
|
||||
* with a CHANGE action. This is useful to render the field in a way that the user can tell
|
||||
* that the value was autofilled for them.
|
||||
*/
|
||||
autofilled: boolean;
|
||||
|
||||
/**
|
||||
* true if the form is currently running asynchronous validation because this
|
||||
* field was blurred.
|
||||
*/
|
||||
asyncValidating: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value has changed from its initialized value.
|
||||
* Opposite of pristine.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The Redux dispatch function.
|
||||
*/
|
||||
dispatch: Dispatch<S>;
|
||||
|
||||
/**
|
||||
* The error for this field if its value is not passing validation. Both
|
||||
* synchronous, asynchronous, and submit validation errors will be reported here.
|
||||
*/
|
||||
error?: string;
|
||||
|
||||
/**
|
||||
* true if the field value fails validation (has a validation error).
|
||||
* Opposite of valid.
|
||||
*/
|
||||
invalid: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value is the same as its initialized value. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* true if the field has been touched. By default this will be set when
|
||||
* the field is blurred.
|
||||
*/
|
||||
touched: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value passes validation (has no validation errors).
|
||||
* Opposite of invalid.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* true if this field has ever had focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
visited?: boolean;
|
||||
|
||||
/**
|
||||
* The warning for this field if its value is not passing warning validation.
|
||||
*/
|
||||
warning?: string;
|
||||
}
|
||||
214
redux-form/lib/FieldArray.d.ts
vendored
Normal file
214
redux-form/lib/FieldArray.d.ts
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
import { Component } from "react";
|
||||
import { ComponentConstructor, Validator } from "../index";
|
||||
|
||||
/**
|
||||
* These are the props to give to `FieldArray`.
|
||||
* Any others will be passed through to your component.
|
||||
*/
|
||||
interface BaseFieldArrayProps {
|
||||
/**
|
||||
* A string path, in dot-and-bracket notation, corresponding to a value
|
||||
* in the form values. It may be as simple as 'firstName' or as complicated
|
||||
* as contact.billing.address[2].phones[1].areaCode.
|
||||
*
|
||||
* Required but made optional so interface can be used on decorated components.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* A Component or stateless function to render the field array.
|
||||
*
|
||||
* Required but made optional so interface can be used on decorated components.
|
||||
*/
|
||||
component?: ComponentConstructor,
|
||||
// component?: Component<P, any> | StatelessComponent<P>,
|
||||
|
||||
/**
|
||||
* Allows you to to provide a field-level validation rule. The function will be given the
|
||||
* current value of the field and all the other form values. If the field is valid, it
|
||||
* should return `undefined`, if the field is invalid, it should return an error
|
||||
* (usually, but not necessarily, a `String`).
|
||||
*/
|
||||
validate?: Validator|Validator[];
|
||||
|
||||
/**
|
||||
* Allows you to to provide a field-level warning rule. The function will be given the
|
||||
* current value of the field and all the other form values. If the field needs a warning,
|
||||
* it should return the warning (usually, but not necessarily, a `String`). If the field
|
||||
* does not need a warning, it should return `undefined`.
|
||||
*/
|
||||
warn?: Validator|Validator[];
|
||||
|
||||
/**
|
||||
* If true, the rendered component will be available with the
|
||||
* getRenderedComponent() method. Defaults to false. Cannot be used if your
|
||||
* component is a stateless function component.
|
||||
*/
|
||||
withRef?: boolean;
|
||||
|
||||
props?: Object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare FieldArray as this interface to specify the generics.
|
||||
*/
|
||||
export interface GenericFieldArray<T, FieldCustomProps> extends Component<BaseFieldArrayProps & FieldCustomProps, {}> {
|
||||
|
||||
/**
|
||||
* The name prop that you passed in.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* true if this field passes validation, false otherwise.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* Returns the instance of the rendered component. For this to work, you must
|
||||
* provide a withRef prop, and your component must not be a stateless function
|
||||
* component.
|
||||
*/
|
||||
getRenderedComponent(): Component<WrappedFieldArrayProps<T> & FieldCustomProps, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FieldArray Instance API.
|
||||
*/
|
||||
export class FieldArray extends Component<any, {}> implements GenericFieldArray<any, any> {
|
||||
|
||||
/**
|
||||
* The name prop that you passed in.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* true if this field passes validation, false otherwise.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* Returns the instance of the rendered component. For this to work, you must
|
||||
* provide a withRef prop, and your component must not be a stateless function
|
||||
* component.
|
||||
*/
|
||||
getRenderedComponent(): Component<any, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* These are props that `FieldArray` will pass to your wrapped component.
|
||||
*/
|
||||
interface WrappedFieldArrayProps<T> {
|
||||
fields: FieldsProps<T>;
|
||||
|
||||
meta: FieldArrayMetaProps;
|
||||
}
|
||||
|
||||
interface FieldsProps<T> {
|
||||
/**
|
||||
* A method to iterate over each value of the array.
|
||||
*/
|
||||
forEach(callback: (name: string, index: number, fields: FieldsProps<T>) => void): void;
|
||||
|
||||
/**
|
||||
* A method to get a single value from the array value.
|
||||
*/
|
||||
get(index: number): T;
|
||||
|
||||
/**
|
||||
* A method to get all the values in the array.
|
||||
*/
|
||||
getAll(): T[];
|
||||
|
||||
/**
|
||||
* A function to insert a new value into the array at any arbitrary index.
|
||||
*/
|
||||
insert(index: number, value: T): void;
|
||||
|
||||
/**
|
||||
* The current length of the array.
|
||||
*/
|
||||
length: number;
|
||||
|
||||
/**
|
||||
* A method to iterate over each value of the array. Returns an array of the
|
||||
* results of each call to the callback.
|
||||
*/
|
||||
map(callback: (name: string, index: number, fields: FieldsProps<T>) => any): any;
|
||||
|
||||
/**
|
||||
* Removes an item from the end of the array. Returns the item removed.
|
||||
*/
|
||||
pop(): T;
|
||||
|
||||
/**
|
||||
* Adds a value to the end of the array.
|
||||
*/
|
||||
push(value: T): void;
|
||||
|
||||
/**
|
||||
* Removes an item from the array at an arbitrary index.
|
||||
*/
|
||||
remove(index: number): void;
|
||||
|
||||
/**
|
||||
* Removes an item from beginning of the array. Returns the item removed.
|
||||
*/
|
||||
shift(): T;
|
||||
|
||||
/**
|
||||
* Swaps two items in the array at the given indexes.
|
||||
*/
|
||||
swap(indexA: number, indexB: number): void;
|
||||
|
||||
/**
|
||||
* Adds an item to the beginning of the array.
|
||||
*/
|
||||
unshift(value: T): void;
|
||||
}
|
||||
|
||||
interface FieldArrayMetaProps {
|
||||
/**
|
||||
* true if the any of the fields in the field array have changed from their
|
||||
* initialized value. Opposite of pristine.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The error for this field array if its value is not passing validation. Both
|
||||
* synchronous, asynchronous, and submit validation errors will be reported here.
|
||||
* Array-specific errors should be returned from the validation function as an
|
||||
* _error key on the array.
|
||||
*/
|
||||
error?: string;
|
||||
|
||||
/**
|
||||
* true if the field array value fails validation (has a validation error).
|
||||
* Opposite of valid.
|
||||
*/
|
||||
invalid: boolean;
|
||||
|
||||
/**
|
||||
* true if the all of the fields in the field array are the same as their
|
||||
* initialized value. Opposite of dirty.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* true if any of the fields have been touched.
|
||||
*/
|
||||
touched: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value passes validation (has no validation errors).
|
||||
* Opposite of invalid.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* The warning for this field array if its values are not passing warning validation.
|
||||
* Array-specific errors should be returned from the validation function as an
|
||||
* `_warning` key on the array.
|
||||
*/
|
||||
warning?: string;
|
||||
}
|
||||
112
redux-form/lib/Fields.d.ts
vendored
Normal file
112
redux-form/lib/Fields.d.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
import { Component } from "react";
|
||||
import { ComponentConstructor, Formatter, Parser, FieldValue } from "../index";
|
||||
|
||||
/**
|
||||
* These are the props to give to `Field`.
|
||||
* Any others will be passed through to your component.
|
||||
*/
|
||||
interface BaseFieldsProps {
|
||||
/**
|
||||
* An array of strings (or the pseudo-array fields provided by FieldArray),
|
||||
* in dot-and-bracket notation, corresponding to form values.
|
||||
* They may be as simple as 'firstName' or as complicated as
|
||||
* 'contact.billing.address[2].phones[1].areaCode'.
|
||||
*/
|
||||
names: string[];
|
||||
|
||||
/**
|
||||
* A Component or stateless function that will be given all the props necessary
|
||||
* to render the field inputs.
|
||||
*/
|
||||
component?: ComponentConstructor | 'input' | 'select' | 'textarea';
|
||||
|
||||
/**
|
||||
* Formats the value from the Redux store to be displayed in the field input.
|
||||
* Common use cases are to format Numbers into currencies or Dates into a localized date format.
|
||||
*
|
||||
* format is called with the field value and name as arguments and should return the new formatted
|
||||
* value to be displayed in the field input.
|
||||
*
|
||||
* To respect React 15 input behavior there is defaultFormat = value => value == null ? '' : value
|
||||
* internally used. To disable that you can pass null as format prop.
|
||||
*/
|
||||
format?: Formatter | null;
|
||||
|
||||
/**
|
||||
* Don't use.
|
||||
*/
|
||||
props?: Object;
|
||||
|
||||
/**
|
||||
* Parses the value given from the field input component to the type that you want stored in the Redux store.
|
||||
* Common use cases are to parse currencies into Numbers into currencies or localized date formats into Dates.
|
||||
*
|
||||
* parse is called with the field value and name as arguments and should return the new parsed value to be
|
||||
* stored in the Redux store.
|
||||
*/
|
||||
parse?: Parser;
|
||||
|
||||
/**
|
||||
* If true, the rendered component will be available with the getRenderedComponent() method.
|
||||
* Defaults to false. Cannot be used if your component is a stateless function component.
|
||||
*/
|
||||
withRef?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare Fields as this interface to specify the generics.
|
||||
*/
|
||||
export interface GenericFields<T, FieldsCustomProps> extends Component<BaseFieldsProps & FieldsCustomProps, {}> {
|
||||
/**
|
||||
* true if the current value of any of the fields is different from the initialized value, false otherwise.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The names prop that you passed in.
|
||||
*/
|
||||
names: string[];
|
||||
|
||||
/**
|
||||
* true if the all of the current values are the same as the initialized values, false otherwise.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* The current values of the fields. If they are nested, the values will duplicate the structure.
|
||||
* For example, if your names are [ 'name.first', 'name.last', 'email' ], the values will be
|
||||
* { name: { first: 'John', last: 'Smith' }, email: 'john@email.com' }
|
||||
*/
|
||||
values: {[name: string]: FieldValue};
|
||||
|
||||
getRenderedComponent(): Component<BaseFieldsProps & FieldsCustomProps, any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Fields Instance API.
|
||||
*/
|
||||
export class Fields extends Component<any, {}> implements GenericFields<any, any> {
|
||||
/**
|
||||
* true if the current value of any of the fields is different from the initialized value, false otherwise.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The names prop that you passed in.
|
||||
*/
|
||||
names: string[];
|
||||
|
||||
/**
|
||||
* true if the all of the current values are the same as the initialized values, false otherwise.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* The current values of the fields. If they are nested, the values will duplicate the structure.
|
||||
* For example, if your names are [ 'name.first', 'name.last', 'email' ], the values will be
|
||||
* { name: { first: 'John', last: 'Smith' }, email: 'john@email.com' }
|
||||
*/
|
||||
values: {[name: string]: FieldValue};
|
||||
|
||||
getRenderedComponent(): Component<any, any>;
|
||||
}
|
||||
17
redux-form/lib/FormSection.d.ts
vendored
Normal file
17
redux-form/lib/FormSection.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Component } from "react";
|
||||
|
||||
interface FormSectionProps {
|
||||
/**
|
||||
* The name all child fields should be prefixed with.
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FormSection component makes it easy to split forms into smaller components that are resuable across
|
||||
* multiple forms. It does this by prefixing the name of Field, Fields and FieldArray children, at any depth,
|
||||
* with the value specified in the name prop.
|
||||
*/
|
||||
export class FormSection extends Component<FormSectionProps, any> {
|
||||
|
||||
}
|
||||
144
redux-form/lib/actions.d.ts
vendored
Normal file
144
redux-form/lib/actions.d.ts
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
import { Action } from "redux";
|
||||
import { FormErrors, FormWarnings, FieldType } from "../index";
|
||||
|
||||
/**
|
||||
* Inserts an item into a field array at the specified index
|
||||
*/
|
||||
export function arrayInsert(form: string, field: string, index: number, value: any): Action;
|
||||
|
||||
/**
|
||||
* Moves an item from one index in the array to another. In effect, it performs a remove and an
|
||||
* insert, so the item already at the `to` position will be bumped to a higher index, not overwritten.
|
||||
*/
|
||||
export function arrayMove(form: string, field: string, from: number, to: number): Action;
|
||||
|
||||
/**
|
||||
* Removes an item from the end of a field array
|
||||
*/
|
||||
export function arrayPop(form: string, field: string): Action;
|
||||
|
||||
/**
|
||||
* Appends an item to the end of a field array
|
||||
*/
|
||||
export function arrayPush(form: string, field: string, value: any): Action;
|
||||
|
||||
/**
|
||||
* Removes an item at the specified index from a field array
|
||||
*/
|
||||
export function arrayRemove(form: string, field: string, index: number): Action;
|
||||
|
||||
/**
|
||||
* Removes all items from a field array
|
||||
*/
|
||||
export function arrayRemoveAll(form: string, field: string): Action;
|
||||
|
||||
/**
|
||||
* Removes an item from the beginning of a field array
|
||||
*/
|
||||
export function arrayShift(form: string, field: string): Action;
|
||||
|
||||
/**
|
||||
* ADVANCED USAGE - Inserts and/or removes items from a field array. Works similarly to Array.splice.
|
||||
*/
|
||||
export function arraySplice(form: string, field: string, index: number, removeNum: number, value: any): Action;
|
||||
|
||||
/**
|
||||
* Swaps two items at the specified indexes in a field array
|
||||
*/
|
||||
export function arraySwap(form: string, field: string, indexA: number, indexB: number): Action;
|
||||
|
||||
/**
|
||||
* Inserts an item at the beginning of a field array
|
||||
*/
|
||||
export function arrayUnshift(form: string, field: string, value: any): Action;
|
||||
|
||||
/**
|
||||
* Saves the value to the field and sets its `autofilled` property to `true`.
|
||||
*/
|
||||
export function autofill(form: string, field: string, value: any): Action;
|
||||
|
||||
/**
|
||||
* Saves the value to the field
|
||||
*/
|
||||
export function blur(form: string, field: string, value: any): Action;
|
||||
|
||||
/**
|
||||
* Saves the value to the field
|
||||
*/
|
||||
export function change(form: string, field: string, value: any): Action;
|
||||
|
||||
/**
|
||||
* Destroys the form, removing all it's state
|
||||
*/
|
||||
export function destroy(form: string): Action;
|
||||
|
||||
/**
|
||||
* Marks the given field as active and visited
|
||||
*/
|
||||
export function focus(form: string, field: string): Action;
|
||||
|
||||
/**
|
||||
* Sets the initial values in the form with which future data values will be compared to calculate dirty and pristine.
|
||||
* The data parameter may contain deep nested array and object values that match the shape of your form fields.
|
||||
* If the keepDirty parameter is true, the values of the currently dirty fields will be retained to avoid overwriting
|
||||
* user edits.
|
||||
*/
|
||||
export function initialize(form: string, data: Object, keepDirty: boolean): Action;
|
||||
|
||||
/**
|
||||
* Registers a field with the form.
|
||||
*/
|
||||
export function registerField(form: string, name: string, type: FieldType): Action;
|
||||
|
||||
/**
|
||||
* Resets the values in the form back to the values past in with the most recent initialize action.
|
||||
*/
|
||||
export function reset(form: string): Action;
|
||||
|
||||
/**
|
||||
* Flips the asyncValidating flag true
|
||||
*/
|
||||
export function startAsyncValidation(form: string): Action;
|
||||
|
||||
/**
|
||||
* Flips the submitting flag true.
|
||||
*/
|
||||
export function startSubmit(form: string): Action;
|
||||
|
||||
/**
|
||||
* Flips the submitting flag false and populates submitError for each field.
|
||||
*/
|
||||
export function stopSubmit(form: string, errors?: Object): Action;
|
||||
|
||||
/**
|
||||
* Flips the asyncValidating flag false and populates asyncError for each field.
|
||||
*/
|
||||
export function stopAsyncValidation(form: string, errors?: Object): Action;
|
||||
|
||||
export function setSubmitFailed(form: string, ...fields: string[]): Action;
|
||||
|
||||
export function setSubmitSucceeded(form: string, ...fields: string[]): Action;
|
||||
|
||||
/**
|
||||
* Triggers a submission of the specified form.
|
||||
*/
|
||||
export function submit(form: string): Action;
|
||||
|
||||
/**
|
||||
* Marks all the fields passed in as touched.
|
||||
*/
|
||||
export function touch(form: string, ...fields: string[]): Action;
|
||||
|
||||
/**
|
||||
* Unregisters a field with the form.
|
||||
*/
|
||||
export function unregisterField(form: string, name: string): Action;
|
||||
|
||||
/**
|
||||
* Resets the 'touched' flag for all the fields passed in.
|
||||
*/
|
||||
export function untouch(form: string, ...fields: string[]): Action;
|
||||
|
||||
export function updateSyncErrors(from: string, syncErrors: FormErrors<FormData>, error: any): Action;
|
||||
|
||||
export function updateSyncWarnings(form: string, syncWarnings: FormWarnings<FormData>, warning: any): Action;
|
||||
49
redux-form/lib/reducer.d.ts
vendored
Normal file
49
redux-form/lib/reducer.d.ts
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Action, Reducer } from "redux";
|
||||
import { FieldType } from "../index";
|
||||
|
||||
export function reducer(state: FormStateMap, action: Action): FormStateMap & FormReducer;
|
||||
|
||||
export interface FormReducer {
|
||||
/**
|
||||
* Returns a form reducer that will also pass each action through
|
||||
* additional reducers specified. The parameter should be an object mapping
|
||||
* from formName to a (state, action) => nextState reducer. The state
|
||||
* passed to each reducer will only be the slice that pertains to that
|
||||
* form.
|
||||
*/
|
||||
plugin(reducers: FormReducerMapObject): Reducer<any>;
|
||||
}
|
||||
|
||||
export interface FormReducerMapObject {
|
||||
[formName: string]: Reducer<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store state
|
||||
*/
|
||||
|
||||
export interface FormStateMap {
|
||||
[formName: string]: FormState;
|
||||
}
|
||||
|
||||
export interface FormState {
|
||||
registeredFields: RegisteredFieldState[];
|
||||
fields?: {[name: string]: FieldState};
|
||||
values?: { [fieldName: string]: string };
|
||||
active?: string;
|
||||
anyTouched?: boolean;
|
||||
submitting?: boolean;
|
||||
submitErrors?: { [fieldName: string]: string };
|
||||
submitFailed?: boolean;
|
||||
}
|
||||
|
||||
export interface RegisteredFieldState {
|
||||
name: string;
|
||||
type: FieldType;
|
||||
}
|
||||
|
||||
export interface FieldState {
|
||||
active?: boolean;
|
||||
touched?: boolean;
|
||||
visited?: boolean;
|
||||
}
|
||||
551
redux-form/lib/reduxForm.d.ts
vendored
Normal file
551
redux-form/lib/reduxForm.d.ts
vendored
Normal file
@@ -0,0 +1,551 @@
|
||||
import {
|
||||
Component,
|
||||
ReactElement,
|
||||
SyntheticEvent,
|
||||
ReactEventHandler,
|
||||
} from "react";
|
||||
import { Dispatch } from "redux";
|
||||
import { DataShape, FieldValue, FormErrors, FormWarnings, RegisteredFieldState } from "../index";
|
||||
|
||||
export function reduxForm<FormData extends DataShape, P, S>(
|
||||
config: Config<FormData, P, S>
|
||||
): FormDecorator<FormData, P, S>;
|
||||
|
||||
export function reduxForm<FormData extends DataShape, P>(
|
||||
config: Config<FormData, P, any>
|
||||
): FormDecorator<FormData, P, any>;
|
||||
|
||||
export function reduxForm(
|
||||
config: Config<any, any, any>
|
||||
): FormDecorator<any, any, any>;
|
||||
|
||||
export interface FormDecorator<FormData extends DataShape, P, S> {
|
||||
<T extends (typeof Component)>(component: T): T & Form<FormData, P, S>;
|
||||
}
|
||||
|
||||
export interface Config<FormData extends DataShape, P, S> {
|
||||
/**
|
||||
* the name of your form and the key to where your form's state will be
|
||||
* mounted under the redux-form reducer
|
||||
*/
|
||||
form: string;
|
||||
|
||||
/**
|
||||
* An adapter function that will render a component based on a string component
|
||||
* type and the props given to a Field. Remember that all you really need to hook
|
||||
* up to your custom component's value and onChange. Defaults to [].
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
adapter?: (component: string, props: Object) => ReactElement<any>;
|
||||
|
||||
/**
|
||||
* field names for which onBlur should trigger a call to the asyncValidate
|
||||
* function. Defaults to [].
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncBlurFields?: string[];
|
||||
|
||||
/**
|
||||
* a function that takes all the form values, the dispatch function, and
|
||||
* the props given to your component, and returns a Promise that will
|
||||
* resolve if the validation is passed, or will reject with an object of
|
||||
* validation errors in the form { field1: <String>, field2: <String> }.
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncValidate?(values: FormData, dispatch: Dispatch<S>, props: P): Promise<any>;
|
||||
|
||||
/**
|
||||
* Whether or not to automatically destroy your form's state in the Redux
|
||||
* store when your component is unmounted. Defaults to true.
|
||||
*/
|
||||
destroyOnUnmount?: boolean;
|
||||
|
||||
/**
|
||||
* A function that takes the entire Redux state and returns the state slice
|
||||
* which corresponds to where the redux-form reducer was mounted. This
|
||||
* functionality is rarely needed, and defaults to assuming that the reducer
|
||||
* is mounted under the "form" key.
|
||||
*/
|
||||
getFormState?(state: S): any;
|
||||
|
||||
/**
|
||||
* When set to true and enableReinitialize is also set, the form will retain the value of dirty fields when
|
||||
* reinitializing. When this option is not set (the default), reinitializing the form replaces all field values.
|
||||
* This option is useful in situations where the form has live updates or continues to be editable after
|
||||
* form submission; it prevents reinitialization from overwriting user changes. Defaults to false.
|
||||
*/
|
||||
keepDirtyOnReinitialize?: boolean;
|
||||
|
||||
/**
|
||||
* If true, implements `shouldComponentUpdate` and shallowly compares _only_
|
||||
* the Redux-connected props that are needed to manage the form state. This
|
||||
* prevents unnecessary updates, but assumes the component is a "pure"
|
||||
* component and does not rely on any input or state other than its props and
|
||||
* the selected Redux store's state. Defaults to true.
|
||||
*/
|
||||
pure?: boolean;
|
||||
|
||||
/**
|
||||
* The values with which to initialize your form in componentWillMount().
|
||||
* Particularly useful when Editing Multiple Records, but can also be used
|
||||
* with single-record forms. The values should be in the form
|
||||
* { field1: 'value1', field2: 'value2' }.
|
||||
*/
|
||||
initialValues?: FormData;
|
||||
|
||||
/**
|
||||
* Reinitialize the form every time the initialValues prop changes.
|
||||
* Defaults to false.
|
||||
*/
|
||||
enableReinitialize?: boolean;
|
||||
|
||||
/**
|
||||
* The function to call with the form data when the handleSubmit() is fired
|
||||
* from within the form component. If you do not specify it as a prop here,
|
||||
* you must pass it as a parameter to handleSubmit() inside your form
|
||||
* component.
|
||||
*/
|
||||
onSubmit?: SubmitHandler<FormData, P, S>;
|
||||
|
||||
/**
|
||||
* A callback function that will be called when a submission fails for whatever reason.
|
||||
*
|
||||
* @param errors The errors that caused the submission to fail.
|
||||
* @param dispatch The Redux `dispatch` function.
|
||||
* @param submitError The error object that caused the submission to fail. If `errors` is set this will be most
|
||||
* likely a `SubmissionError`, otherwise it can be any error or null.
|
||||
*/
|
||||
onSubmitFail?(errors: FormErrors<FormData>, dispatch: Dispatch<S>, submitError: any): void;
|
||||
|
||||
/**
|
||||
* A callback function that will be called when a submission succeeds.
|
||||
*/
|
||||
onSubmitSuccess?(result: any, dispatch: Dispatch<S>): void;
|
||||
|
||||
/**
|
||||
* Do not remove submit errors when the change action is fired. Defaults to false.
|
||||
*/
|
||||
persistentSubmitErrors?: boolean;
|
||||
|
||||
/**
|
||||
* If specified, all the props normally passed into your decorated
|
||||
* component directly will be passed under the key specified. Useful if
|
||||
* using other decorator libraries on the same component to avoid prop
|
||||
* namespace collisions.
|
||||
*/
|
||||
propNamespace?: string;
|
||||
|
||||
/**
|
||||
* The use of this property is highly discouraged, but if you absolutely
|
||||
* need to mount your redux-form reducer at somewhere other than form in
|
||||
* your Redux state, you will need to specify the key you mounted it under
|
||||
* with this property. Defaults to 'form'.
|
||||
*
|
||||
* See Alternate Mount Point Example for more details.
|
||||
*/
|
||||
reduxMountPoint?: string;
|
||||
|
||||
/**
|
||||
* An optional function you may provide to have full control over when sync validation happens.
|
||||
*/
|
||||
shouldValidate?(params: ValidateCallback<FormData>): boolean;
|
||||
|
||||
/**
|
||||
* An optional function you may provide to have full control over when async
|
||||
* validation happens.
|
||||
*/
|
||||
shouldAsyncValidate?(params: AsyncValidateCallback<FormData>): boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the blur action is fired. Defaults to true.
|
||||
*/
|
||||
touchOnBlur?: boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the change action is fired. Defaults to
|
||||
* false.
|
||||
*/
|
||||
touchOnChange?: boolean;
|
||||
|
||||
/**
|
||||
* a synchronous validation function that takes the form values and props
|
||||
* passed into your component. If validation passes, it should return {}.
|
||||
* If validation fails, it should return the validation errors in the form
|
||||
* { field1: <String>, field2: <String> }.
|
||||
* Defaults to (values, props) => ({}).
|
||||
*/
|
||||
validate?(values: FormData, props: FormProps<FormData, P, S> & P): FormErrors<FormData>;
|
||||
|
||||
/**
|
||||
* A synchronous warning function that takes the form values and props passed into your component.
|
||||
* Warnings work the same as validations, but do not mark a form as invalid. If the warning check passes,
|
||||
* it should return {}. If the check fails, it should return the warnings in the form
|
||||
* { field1: <String>, field2: <String> }. Defaults to (values, props) => ({}).
|
||||
*/
|
||||
warn?(values: FormData, props: FormProps<FormData, P, S> & P): FormWarnings<FormData>;
|
||||
}
|
||||
|
||||
/**
|
||||
* If your onSubmit function returns a promise, the submitting property will be set to true
|
||||
* until the promise has been resolved or rejected. If it is rejected with a redux-form
|
||||
* SubmissionError containing errors in the form { field1: 'error', field2: 'error' } then
|
||||
* the submission errors will be added to each field (to the error prop) just like async
|
||||
* validation errors are. If there is an error that is not specific to any field, but applicable
|
||||
* to the entire form, you may pass that as if it were the error for a field called _error,
|
||||
* and it will be given as the error prop.
|
||||
*/
|
||||
export interface SubmitHandler<FormData extends DataShape, P, S> {
|
||||
(values: FormData, dispatch: Dispatch<S>, props: FormProps<FormData, P, S> & P): void | FormErrors<FormData> | Promise<any>;
|
||||
}
|
||||
|
||||
interface ValidateCallback<FormData extends DataShape> {
|
||||
/**
|
||||
* The values.
|
||||
*/
|
||||
values: FormData;
|
||||
|
||||
/**
|
||||
* The next props.
|
||||
*/
|
||||
nextProps: Object;
|
||||
|
||||
/**
|
||||
* The current props.
|
||||
*/
|
||||
props: Object;
|
||||
|
||||
/**
|
||||
* true if the form is being initially rendered.
|
||||
*/
|
||||
initialRender: boolean;
|
||||
|
||||
/**
|
||||
* The structure object being used internally for values. You may wish to use 'deepEqual' from the structure.
|
||||
*/
|
||||
structure: Object;
|
||||
}
|
||||
|
||||
interface AsyncValidateCallback<FormData extends DataShape> {
|
||||
/**
|
||||
* Any existing asynchronous validation errors
|
||||
*/
|
||||
asyncErrors?: FormErrors<FormData>;
|
||||
|
||||
/**
|
||||
* true if the form has ever been initialized with initial values
|
||||
*/
|
||||
initialized: boolean;
|
||||
|
||||
/**
|
||||
* The reason to possibly run async validation. It will either be: 'blur' or
|
||||
* 'submit', depending on whether an async blur field had triggered the async
|
||||
* validation or if submitting the form has triggered it, respectively.
|
||||
*/
|
||||
trigger: 'blur' | 'submit';
|
||||
|
||||
/**
|
||||
* The name of the field that has triggered the async validation. May be undefined.
|
||||
*/
|
||||
blurredField?: string;
|
||||
|
||||
/**
|
||||
* true if the form is pristine, false if it is dirty
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* true if synchronous validation is passing, false if it is failing.
|
||||
*/
|
||||
syncValidationPasses: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A throwable error that is used to return submit validation errors from onSubmit.
|
||||
* The purpose being to distinguish promise rejection because of validation errors
|
||||
* from promise rejection because of AJAX I/O problems or other server errors.
|
||||
*/
|
||||
export class SubmissionError<FormData extends DataShape> extends Error {
|
||||
errors: FormErrors<FormData>;
|
||||
|
||||
constructor(errors?: FormErrors<FormData>);
|
||||
}
|
||||
|
||||
/**
|
||||
* The following are methods or properties that you can access on an instance
|
||||
* of your decorated form component (outermost component named "ReduxForm").
|
||||
*/
|
||||
export interface Form<FormData extends DataShape, P, S> extends Component<P, any> {
|
||||
/**
|
||||
* true if the form data has changed from its initialized values. Opposite
|
||||
* of pristine.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* true if the form has validation errors. Opposite of valid.
|
||||
*/
|
||||
invalid: boolean;
|
||||
|
||||
/**
|
||||
* true if the form data is the same as its initialized values. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* An array of objects with fields `name` and `type` for each field
|
||||
* representing all the fields in the form. Mainly useful for testing.
|
||||
*/
|
||||
registeredFields: RegisteredFieldState[];
|
||||
|
||||
/**
|
||||
* Resets all the values in the form to the initialized state, making it
|
||||
* pristine again.
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Submits the form. Returns a promise that will be resolved when the form
|
||||
* is submitted successfully, or rejected if the submission fails.
|
||||
*/
|
||||
submit(): Promise<any>;
|
||||
|
||||
/**
|
||||
* true if the form passes validation (has no validation errors). Opposite
|
||||
* of invalid.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* The current values of all the fields in the form.
|
||||
*/
|
||||
values: FormData;
|
||||
|
||||
/**
|
||||
* A reference to the instance of the component you decorated with reduxForm().
|
||||
* Mainly useful for testing.
|
||||
*/
|
||||
wrappedInstance: ReactElement<P & FormProps<FormData, P, S>>
|
||||
}
|
||||
|
||||
/**
|
||||
* These are the props that will be passed to your form component.
|
||||
* Your form component's props can extend this interface.
|
||||
*/
|
||||
export interface FormProps<FormData extends DataShape, P, S> {
|
||||
/**
|
||||
* true if any of the fields have been marked as touched, false otherwise.
|
||||
*/
|
||||
anyTouched?: boolean;
|
||||
|
||||
/**
|
||||
* A set of pre-bound action creators for you to operate on array fields in your form.
|
||||
*/
|
||||
array?: {
|
||||
/**
|
||||
* Inserts a value into the given array field in your form.
|
||||
*/
|
||||
insert(field: string, index: number, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Moves a value at the given from index to the given to index in
|
||||
* the given array field in your form.
|
||||
*/
|
||||
move(field: string, from: number, to: number): void;
|
||||
|
||||
/**
|
||||
* Pops a value off of the end of a given array field in your form.
|
||||
*/
|
||||
pop(field: string): void;
|
||||
|
||||
/**
|
||||
* Pushes the given value onto the end of the given array field in your form.
|
||||
*/
|
||||
push(field: string, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Removes a value at the given index from the given array field in your form.
|
||||
*/
|
||||
remove(field: string, index: number): void;
|
||||
|
||||
/**
|
||||
* Removes all the values from the given array field in your form.
|
||||
*/
|
||||
removeAll(field: string): void;
|
||||
|
||||
/**
|
||||
* Shifts a value out of the beginning of the given array in your form.
|
||||
*/
|
||||
shift(field: string): void;
|
||||
|
||||
/**
|
||||
* Performs an Array.splice operation on the given array in your form.
|
||||
*/
|
||||
splice(field: string, index: number, removeNum: number, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Swaps two values at the given indexes of the given array field in your form.
|
||||
*/
|
||||
swap(field: string, indexA: number, indexB: number): void;
|
||||
|
||||
/**
|
||||
* Unshifts the given value into the beginning of the given array field in your form.
|
||||
*/
|
||||
unshift(field: string, value: FieldValue): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that may be called to initiate asynchronous validation if
|
||||
* asynchronous validation is enabled.
|
||||
*/
|
||||
asyncValidate?: () => void;
|
||||
|
||||
/**
|
||||
* This value will be either:
|
||||
* - false - No asynchronous validation is currently happening
|
||||
* - true - Asynchronous validation is currently running in preparation to submit a form
|
||||
* - a string - The name of the field that just blurred to trigger asynchronous validation
|
||||
*/
|
||||
asyncValidating?: string | boolean;
|
||||
|
||||
/**
|
||||
* Sets the value and marks the field as autofilled in the Redux Store. This is useful when a field
|
||||
* needs to be set programmatically, but in a way that lets the user know (via a styling change using
|
||||
* the autofilled prop in Field) that it has been autofilled for them programmatically.
|
||||
*/
|
||||
autofill?(field: string, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Marks a field as blurred in the Redux store.
|
||||
*/
|
||||
blur?(field: string, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Changes the value of a field in the Redux store.
|
||||
*/
|
||||
change?(field: string, value: FieldValue): void;
|
||||
|
||||
/**
|
||||
* Clear async error of a field in the Redux store.
|
||||
*/
|
||||
clearAsyncError?(field: string): void;
|
||||
|
||||
/**
|
||||
* Destroys the form state in the Redux store. By default, this will be
|
||||
* called for you in componentWillUnmount().
|
||||
*/
|
||||
destroy?(): void;
|
||||
|
||||
/**
|
||||
* true if the form data has changed from its initialized values. Opposite
|
||||
* of pristine.
|
||||
*/
|
||||
dirty?: boolean;
|
||||
|
||||
/**
|
||||
* A generic error for the entire form given by the _error key in the
|
||||
* result from the synchronous validation function, the asynchronous
|
||||
* validation, or the rejected promise from onSubmit.
|
||||
*/
|
||||
error?: string;
|
||||
|
||||
/**
|
||||
* The form name that you gave to the reduxForm() decorator or the prop you
|
||||
* passed in to your decorated form component.
|
||||
*/
|
||||
form?: string;
|
||||
|
||||
/**
|
||||
* A function meant to be passed to <form onSubmit={handleSubmit}> or to
|
||||
* <button onClick={handleSubmit}>. It will run validation, both sync and
|
||||
* async, and, if the form is valid, it will call
|
||||
* this.props.onSubmit(data) with the contents of the form data.
|
||||
*
|
||||
* Optionally, you may also pass your onSubmit function to handleSubmit
|
||||
* which will take the place of the onSubmit prop. For example: <form
|
||||
* onSubmit={handleSubmit(this.save.bind(this))}>
|
||||
*
|
||||
* If your onSubmit function returns a promise, the submitting property
|
||||
* will be set to true until the promise has been resolved or rejected.
|
||||
* If it is rejected with an object like
|
||||
* new SubmissionError({ field1: 'error', field2: 'error' })
|
||||
* then the submission errors will be added to each field (to the error
|
||||
* prop) just like async validation errors are. If there is an error that
|
||||
* is not specific to any field, but applicable to the entire form, you
|
||||
* may pass that as if it were the error for a field called _error, and
|
||||
* it will be given as the error prop.
|
||||
*/
|
||||
handleSubmit?(event: SyntheticEvent<any>): void; // same as ReactEventHandler
|
||||
|
||||
handleSubmit?(submit: SubmitHandler<FormData, P, S>): ReactEventHandler<any>;
|
||||
|
||||
/**
|
||||
* Initializes the form data to the given values. All dirty and pristine
|
||||
* state will be determined by comparing the current data with these
|
||||
* initialized values.
|
||||
*/
|
||||
initialize?(data: FormData): void;
|
||||
|
||||
/**
|
||||
* true if the form has validation errors. Opposite of valid.
|
||||
*/
|
||||
invalid?: boolean;
|
||||
|
||||
/**
|
||||
* true if the form data is the same as its initialized values. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine?: boolean;
|
||||
|
||||
/**
|
||||
* Resets all the values in the form to the initialized state, making it
|
||||
* pristine again.
|
||||
*/
|
||||
reset?(): void;
|
||||
|
||||
/**
|
||||
* Whether or not your form is currently submitting. This prop will only
|
||||
* work if you have passed an onSubmit function that returns a promise. It
|
||||
* will be true until the promise is resolved or rejected.
|
||||
*/
|
||||
submitting?: boolean;
|
||||
|
||||
/**
|
||||
* Starts as false. If onSubmit is called, and fails to submit for any
|
||||
* reason, submitFailed will be set to true. A subsequent successful
|
||||
* submit will set it back to false.
|
||||
*/
|
||||
submitFailed?: boolean;
|
||||
|
||||
/**
|
||||
* Starts as false. If onSubmit is called, and succeed to submit,
|
||||
* submitSucceeded will be set to true. A subsequent unsuccessful
|
||||
* submit will set it back to false.
|
||||
*/
|
||||
submitSucceeded?: boolean;
|
||||
|
||||
/**
|
||||
* Marks the given fields as "touched" to show errors.
|
||||
*/
|
||||
touch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* Clears the "touched" flag for the given fields
|
||||
*/
|
||||
untouch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* true if the form passes validation (has no validation errors). Opposite
|
||||
* of invalid.
|
||||
*/
|
||||
valid?: boolean;
|
||||
|
||||
/**
|
||||
* A generic warning for the entire form given by the `_warning` key in the result from the
|
||||
* synchronous warning function.
|
||||
*/
|
||||
warning?: string;
|
||||
}
|
||||
74
redux-form/lib/selectors.d.ts
vendored
Normal file
74
redux-form/lib/selectors.d.ts
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
import { DataShape, FormErrors } from "../index";
|
||||
|
||||
/**
|
||||
* A "selector" API to make it easier to connect() to form values. Creates a selector
|
||||
* function for your form that can be used with your field names.
|
||||
*/
|
||||
export function formValueSelector<State>(form: string, getFormState?: () => State): Selector<State>;
|
||||
|
||||
export interface Selector<State> {
|
||||
(state: State, ...field: string[]): Object
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets form data.
|
||||
*/
|
||||
export interface DataSelector {
|
||||
<FormData extends DataShape, State>(formName: string): (state: State) => FormData;
|
||||
<FormData extends DataShape>(formName: string): (state: any) => FormData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets form errors.
|
||||
*/
|
||||
export interface ErrorSelector {
|
||||
<FormData extends DataShape, State>(formName: string): (state: State) => FormErrors<FormData>;
|
||||
<FormData extends DataShape>(formName: string): (state: any) => FormErrors<FormData>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets boolean info from form.
|
||||
*/
|
||||
export interface BooleanSelector {
|
||||
<State>(formName: string): (state: State) => boolean;
|
||||
(formName: string): (state: any) => boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the form values. Shocking, right?
|
||||
*/
|
||||
export const getFormValues: DataSelector;
|
||||
|
||||
/**
|
||||
* Returns the form synchronous validation errors.
|
||||
*/
|
||||
export const getFormSyncErrors: ErrorSelector;
|
||||
|
||||
/**
|
||||
* Returns the form submit validation errors.
|
||||
*/
|
||||
export const getFormSubmitErrors: ErrorSelector;
|
||||
|
||||
/**
|
||||
* Returns true if the form is dirty, i.e. the values have been altered
|
||||
* from the original initialValues provided. The opposite of isPristine.
|
||||
*/
|
||||
export const isDirty: BooleanSelector;
|
||||
|
||||
/**
|
||||
* Returns true if the form is pristine, i.e. the values have NOT been altered
|
||||
* from the original initialValues provided. The opposite of isDirty.
|
||||
*/
|
||||
export const isPristine: BooleanSelector;
|
||||
|
||||
/**
|
||||
* Returns true if the form is valid, i.e. has no sync, async, or submission
|
||||
* errors. The opposite of isInvalid.
|
||||
*/
|
||||
export const isValid: BooleanSelector;
|
||||
|
||||
/**
|
||||
* Returns true if the form is invalid, i.e. has sync, async, or submission
|
||||
* errors. The opposite of isValid.
|
||||
*/
|
||||
export const isInvalid: BooleanSelector;
|
||||
331
redux-form/redux-form-4.0-tests.tsx
Normal file
331
redux-form/redux-form-4.0-tests.tsx
Normal file
@@ -0,0 +1,331 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import {Component, PropTypes} from 'react';
|
||||
import {createStore, combineReducers} from 'redux';
|
||||
import {reduxForm, reducer as reduxFormReducer, ReduxFormProps} from 'redux-form';
|
||||
|
||||
|
||||
namespace SimpleForm {
|
||||
export const fields = ['firstName', 'lastName', 'email', 'sex', 'favoriteColor', 'employed', 'notes'];
|
||||
|
||||
class SimpleForm extends Component<ReduxFormProps<SimpleForm & HTMLFormElement>, void> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
fields: {firstName, lastName, email, sex, favoriteColor, employed, notes},
|
||||
handleSubmit,
|
||||
resetForm,
|
||||
submitting
|
||||
} = this.props;
|
||||
return (<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>First Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="First Name" {...firstName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Last Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Last Name" {...lastName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Email</label>
|
||||
<div>
|
||||
<input type="email" placeholder="Email" {...email}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Sex</label>
|
||||
<div>
|
||||
<label>
|
||||
<input type="radio" {...sex} value="male" checked={sex.value === 'male'}/> Male
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" {...sex} value="female" checked={sex.value === 'female'}/> Female
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Favorite Color</label>
|
||||
<div>
|
||||
<select {...favoriteColor}>
|
||||
<option></option>
|
||||
<option value="ff0000">Red</option>
|
||||
<option value="00ff00">Green</option>
|
||||
<option value="0000ff">Blue</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" {...employed}/> Employed
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>Notes</label>
|
||||
<div>
|
||||
<textarea
|
||||
{...notes}
|
||||
value={notes.value || ''}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Connected = reduxForm({
|
||||
form: 'simple',
|
||||
fields
|
||||
})(SimpleForm);
|
||||
}
|
||||
|
||||
|
||||
namespace SynchronousValidation {
|
||||
export const fields = ['username', 'email', 'age'];
|
||||
|
||||
const validate = (values:any) => {
|
||||
const errors:any = {};
|
||||
if (!values.username) {
|
||||
errors.username = 'Required';
|
||||
} else if (values.username.length > 15) {
|
||||
errors.username = 'Must be 15 characters or less';
|
||||
}
|
||||
if (!values.email) {
|
||||
errors.email = 'Required';
|
||||
} else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
|
||||
errors.email = 'Invalid email address';
|
||||
}
|
||||
if (!values.age) {
|
||||
errors.age = 'Required';
|
||||
} else if (isNaN(Number(values.age))) {
|
||||
errors.age = 'Must be a number';
|
||||
} else if (Number(values.age) < 18) {
|
||||
errors.age = 'Sorry, you must be at least 18 years old';
|
||||
}
|
||||
return errors;
|
||||
};
|
||||
|
||||
class SynchronousValidationForm extends Component<ReduxFormProps<SynchronousValidationForm & HTMLFormElement>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const {fields: {username, email, age}, resetForm, handleSubmit, submitting} = this.props;
|
||||
return (<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>Username</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Username" {...username}/>
|
||||
</div>
|
||||
{username.touched && username.error && <div>{username.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Email</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Email" {...email}/>
|
||||
</div>
|
||||
{email.touched && email.error && <div>{email.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Age</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Age" {...age}/>
|
||||
</div>
|
||||
{age.touched && age.error && <div>{age.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'synchronousValidation',
|
||||
fields,
|
||||
validate
|
||||
})(SynchronousValidationForm);
|
||||
}
|
||||
|
||||
|
||||
namespace SumbitValidation {
|
||||
export const fields = ['username', 'password'];
|
||||
|
||||
const submit = (values:any, dispatch:any) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if (['john', 'paul', 'george', 'ringo'].indexOf(values.username) === -1) {
|
||||
reject({username: 'User does not exist', _error: 'Login failed!'});
|
||||
} else if (values.password !== 'redux-form') {
|
||||
reject({password: 'Wrong password', _error: 'Login failed!'});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}, 1000); // simulate server latency
|
||||
});
|
||||
};
|
||||
|
||||
class SubmitValidationForm extends Component<ReduxFormProps<SubmitValidationForm>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
error: PropTypes.string,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const {fields: {username, password}, error, resetForm, handleSubmit, submitting} = this.props;
|
||||
return (<form onSubmit={submit => handleSubmit(submit as any)}>
|
||||
<div>
|
||||
<label>Username</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Username" {...username}/>
|
||||
</div>
|
||||
{username.touched && username.error && <div>{username.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Password</label>
|
||||
<div>
|
||||
<input type="password" placeholder="Password" {...password}/>
|
||||
</div>
|
||||
{password.touched && password.error && <div>{password.error}</div>}
|
||||
</div>
|
||||
{error && <div>{error}</div>}
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Log In
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'submitValidation',
|
||||
fields
|
||||
})(SubmitValidationForm);
|
||||
}
|
||||
|
||||
|
||||
namespace InitializingFromState {
|
||||
const LOAD = 'redux-form-examples/account/LOAD';
|
||||
const loadAccount = (data:any) => ({type: LOAD, data});
|
||||
export const fields = ['firstName', 'lastName', 'age', 'bio'];
|
||||
const data = { // used to populate "account" reducer when "Load" is clicked
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
age: '42',
|
||||
bio: 'Born to write amazing Redux code.'
|
||||
};
|
||||
|
||||
interface Props<T> extends ReduxFormProps<T> {
|
||||
load: Function;
|
||||
}
|
||||
|
||||
class InitializingFromStateForm extends Component<Props<InitializingFromStateForm & HTMLFormElement>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
load: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const {fields: {firstName, lastName, age, bio}, handleSubmit, load, submitting} = this.props;
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<button onClick={() => load(data)}>Load Account</button>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>First Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="First Name" {...firstName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Last Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Last Name" {...lastName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Age</label>
|
||||
<div>
|
||||
<input type="number" placeholder="Age" {...age}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Occupation</label>
|
||||
<div>
|
||||
<textarea placeholder="Biography" {...bio}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'initializing',
|
||||
fields
|
||||
},
|
||||
(state:any) => ({ // mapStateToProps
|
||||
initialValues: state.account.data // will pull state into form's initialValues
|
||||
}),
|
||||
{load: loadAccount} // mapDispatchToProps (will bind action creator to dispatch)
|
||||
)(InitializingFromStateForm);
|
||||
}
|
||||
|
||||
|
||||
namespace NormalizingFormData {
|
||||
const reducer = combineReducers({
|
||||
// other reducers
|
||||
form: reduxFormReducer.normalize({
|
||||
normalizing: { // <--- name of the form
|
||||
upper: value => value && value.toUpperCase(), // normalizer for 'upper' field
|
||||
}
|
||||
})
|
||||
});
|
||||
const store = createStore(reducer);
|
||||
}
|
||||
476
redux-form/redux-form-4.0.d.ts
vendored
Normal file
476
redux-form/redux-form-4.0.d.ts
vendored
Normal file
@@ -0,0 +1,476 @@
|
||||
// Type definitions for redux-form v4.0.3
|
||||
// Project: https://github.com/erikras/redux-form
|
||||
// Definitions by: Daniel Lytkin <https://github.com/aikoven>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as React from 'react';
|
||||
import { Component, SyntheticEvent, FormEventHandler } from 'react';
|
||||
import { Dispatch, ActionCreator, Reducer } from 'redux';
|
||||
|
||||
export const actionTypes: {[actionName:string]: string};
|
||||
|
||||
export type FieldValue = any;
|
||||
|
||||
export type FormData = { [fieldName: string]: FieldValue };
|
||||
|
||||
export interface FieldProp<T> {
|
||||
/**
|
||||
* true if this field currently has focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
active: boolean;
|
||||
|
||||
/**
|
||||
* An alias for value only when value is a boolean. Provided for
|
||||
* convenience of destructuring the whole field object into the props of a
|
||||
* form element.
|
||||
*/
|
||||
checked?: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value has changed from its initialized value.
|
||||
* Opposite of pristine.
|
||||
*/
|
||||
dirty: boolean;
|
||||
|
||||
/**
|
||||
* The error for this field if its value is not passing validation. Both
|
||||
* synchronous and asynchronous validation errors will be reported here.
|
||||
*/
|
||||
error?: any;
|
||||
|
||||
/**
|
||||
* The value for this field as supplied in initialValues to the form.
|
||||
*/
|
||||
initialValue: FieldValue;
|
||||
|
||||
/**
|
||||
* true if the field value fails validation (has a validation error).
|
||||
* Opposite of valid.
|
||||
*/
|
||||
invalid: boolean;
|
||||
|
||||
/**
|
||||
* The name of the field. It will be the same as the key in the fields
|
||||
* Object, but useful if bundling up a field to send down to a specialized
|
||||
* input component.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* A function to call when the form field loses focus. It expects to
|
||||
* either receive the React SyntheticEvent or the current value of the
|
||||
* field.
|
||||
*/
|
||||
onBlur(eventOrValue: SyntheticEvent<T> | FieldValue): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field is changed. It expects to either
|
||||
* receive the React SyntheticEvent or the new value of the field.
|
||||
* @param eventOrValue
|
||||
*/
|
||||
onChange(eventOrValue: SyntheticEvent<T> | FieldValue): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a 'dragStart' event.
|
||||
* Saves the field value in the event for giving the field it is dropped
|
||||
* into.
|
||||
*/
|
||||
onDragStart(): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives a drop event.
|
||||
*/
|
||||
onDrop(): void;
|
||||
|
||||
/**
|
||||
* A function to call when the form field receives focus.
|
||||
*/
|
||||
onFocus(): void;
|
||||
|
||||
/**
|
||||
* An alias for onChange. Provided for convenience of destructuring the
|
||||
* whole field object into the props of a form element. Added to provide
|
||||
* out-of-the-box support for Belle components' onUpdate API.
|
||||
*/
|
||||
onUpdate(): void;
|
||||
|
||||
/**
|
||||
* true if the field value is the same as its initialized value. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine: boolean;
|
||||
|
||||
/**
|
||||
* true if the field has been touched. By default this will be set when
|
||||
* the field is blurred.
|
||||
*/
|
||||
touched: boolean;
|
||||
|
||||
/**
|
||||
* true if the field value passes validation (has no validation errors).
|
||||
* Opposite of invalid.
|
||||
*/
|
||||
valid: boolean;
|
||||
|
||||
/**
|
||||
* The value of this form field. It will be a boolean for checkboxes, and
|
||||
* a string for all other input types.
|
||||
*/
|
||||
value: FieldValue;
|
||||
|
||||
/**
|
||||
* true if this field has ever had focus. It will only work if you are
|
||||
* passing onFocus to your input element.
|
||||
*/
|
||||
visited: boolean;
|
||||
}
|
||||
|
||||
export interface ReduxFormProps<T> {
|
||||
/**
|
||||
* The name of the currently active (with focus) field.
|
||||
*/
|
||||
active?: string;
|
||||
|
||||
/**
|
||||
* A function that may be called to initiate asynchronous validation if
|
||||
* asynchronous validation is enabled.
|
||||
*/
|
||||
asyncValidate?: Function;
|
||||
|
||||
/**
|
||||
* true if the asynchronous validation function has been called but has not
|
||||
* yet returned.
|
||||
*/
|
||||
asyncValidating?: boolean;
|
||||
|
||||
/**
|
||||
* Destroys the form state in the Redux store. By default, this will be
|
||||
* called for you in componentWillUnmount().
|
||||
*/
|
||||
destroyForm?(): void;
|
||||
|
||||
/**
|
||||
* true if the form data has changed from its initialized values. Opposite
|
||||
* of pristine.
|
||||
*/
|
||||
dirty?: boolean;
|
||||
|
||||
/**
|
||||
* A generic error for the entire form given by the _error key in the
|
||||
* result from the synchronous validation function, the asynchronous
|
||||
* validation, or the rejected promise from onSubmit.
|
||||
*/
|
||||
error?: any;
|
||||
|
||||
/**
|
||||
* The form data, in the form { field1: <Object>, field2: <Object> }. The
|
||||
* field objects are meant to be destructured into your input component as
|
||||
* props, e.g. <input type="text" {...field.name}/>. Each field Object has
|
||||
* the following properties:
|
||||
*/
|
||||
fields?: { [field: string]: FieldProp<T> };
|
||||
|
||||
/**
|
||||
* A function meant to be passed to <form onSubmit={handleSubmit}> or to
|
||||
* <button onClick={handleSubmit}>. It will run validation, both sync and
|
||||
* async, and, if the form is valid, it will call
|
||||
* this.props.onSubmit(data) with the contents of the form data.
|
||||
* Optionally, you may also pass your onSubmit function to handleSubmit
|
||||
* which will take the place of the onSubmit prop. For example: <form
|
||||
* onSubmit={handleSubmit(this.save.bind(this))}> If your onSubmit
|
||||
* function returns a promise, the submitting property will be set to true
|
||||
* until the promise has been resolved or rejected. If it is rejected with
|
||||
* an object matching { field1: 'error', field2: 'error' } then the
|
||||
* submission errors will be added to each field (to the error prop) just
|
||||
* like async validation errors are. If there is an error that is not
|
||||
* specific to any field, but applicable to the entire form, you may pass
|
||||
* that as if it were the error for a field called _error, and it will be
|
||||
* given as the error prop.
|
||||
*/
|
||||
handleSubmit?(event: SyntheticEvent<T>): void;
|
||||
handleSubmit?(event: React.MouseEvent<HTMLButtonElement>): void;
|
||||
handleSubmit?(submit: (data: FormData, dispatch?: Dispatch<any>) => Promise<any> | void): FormEventHandler<T>;
|
||||
|
||||
/**
|
||||
* Initializes the form data to the given values. All dirty and pristine
|
||||
* state will be determined by comparing the current data with these
|
||||
* initialized values.
|
||||
* @param data
|
||||
*/
|
||||
initializeForm?(data: FormData): void;
|
||||
|
||||
/**
|
||||
* true if the form has validation errors. Opposite of valid.
|
||||
*/
|
||||
invalid?: boolean;
|
||||
|
||||
/**
|
||||
* true if the form data is the same as its initialized values. Opposite
|
||||
* of dirty.
|
||||
*/
|
||||
pristine?: boolean;
|
||||
|
||||
/**
|
||||
* Resets all the values in the form to the initialized state, making it
|
||||
* pristine again.
|
||||
*/
|
||||
resetForm?(): void;
|
||||
|
||||
/**
|
||||
* The same formKey prop that was passed in. See Editing Multiple Records.
|
||||
*/
|
||||
formKey?: string;
|
||||
|
||||
/**
|
||||
* Whether or not your form is currently submitting. This prop will only
|
||||
* work if you have passed an onSubmit function that returns a promise. It
|
||||
* will be true until the promise is resolved or rejected.
|
||||
*/
|
||||
submitting?: boolean;
|
||||
|
||||
/**
|
||||
* Starts as false. If onSubmit is called, and fails to submit for any
|
||||
* reason, submitFailed will be set to true. A subsequent successful
|
||||
* submit will set it back to false.
|
||||
*/
|
||||
submitFailed?: boolean;
|
||||
|
||||
/**
|
||||
* Marks the given fields as "touched" to show errors.
|
||||
* @param field
|
||||
*/
|
||||
touch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* Marks all fields as "touched" to show errors. This will automatically
|
||||
* happen on form submission.
|
||||
*/
|
||||
touchAll?(): void;
|
||||
|
||||
/**
|
||||
* Clears the "touched" flag for the given fields
|
||||
* @param field
|
||||
*/
|
||||
untouch?(...field: string[]): void;
|
||||
|
||||
/**
|
||||
* Clears the "touched" flag for the all fields
|
||||
*/
|
||||
untouchAll?(): void;
|
||||
|
||||
/**
|
||||
* true if the form passes validation (has no validation errors). Opposite
|
||||
* of invalid.
|
||||
*/
|
||||
valid?: boolean;
|
||||
|
||||
/**
|
||||
* All of your values in the form { field1: <string>, field2: <string> }.
|
||||
*/
|
||||
values?: FormData;
|
||||
}
|
||||
|
||||
declare class ElementClass extends Component<any, any> {
|
||||
}
|
||||
interface ClassDecorator {
|
||||
<T extends (typeof ElementClass)>(component: T): T;
|
||||
}
|
||||
|
||||
interface MapStateToProps {
|
||||
(state: any, ownProps?: any): any;
|
||||
}
|
||||
|
||||
interface MapDispatchToPropsFunction {
|
||||
(dispatch: Dispatch<any>, ownProps?: any): any;
|
||||
}
|
||||
|
||||
interface MapDispatchToPropsObject {
|
||||
[name: string]: ActionCreator<any>;
|
||||
}
|
||||
|
||||
export declare function reduxForm(config: ReduxFormConfig,
|
||||
mapStateToProps?: MapStateToProps,
|
||||
mapDispatchToProps?: MapDispatchToPropsFunction | MapDispatchToPropsObject): ClassDecorator;
|
||||
|
||||
export interface ReduxFormConfig {
|
||||
/**
|
||||
* a list of all your fields in your form. You may change these dynamically
|
||||
* at runtime.
|
||||
*/
|
||||
fields: string[];
|
||||
|
||||
/**
|
||||
* the name of your form and the key to where your form's state will be
|
||||
* mounted under the redux-form reducer
|
||||
*/
|
||||
form: string;
|
||||
|
||||
/**
|
||||
* By default, async blur validation is only triggered if synchronous
|
||||
* validation passes, and the form is dirty or was never initialized (or if
|
||||
* submitting). Sometimes it may be desirable to trigger asynchronous
|
||||
* validation even in these cases, for example if all validation is performed
|
||||
* asynchronously and you want to display validation messages if a user does
|
||||
* not change a field, but does touch and blur it. Setting
|
||||
* alwaysAsyncValidate to true will always run asynchronous validation on
|
||||
* blur, even if the form is pristine or sync validation fails.
|
||||
*/
|
||||
alwaysAsyncValidate?: boolean;
|
||||
|
||||
/**
|
||||
* field names for which onBlur should trigger a call to the asyncValidate
|
||||
* function. Defaults to [].
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncBlurFields?: string[];
|
||||
|
||||
/**
|
||||
* a function that takes all the form values, the dispatch function, and
|
||||
* the props given to your component, and returns a Promise that will
|
||||
* resolve if the validation is passed, or will reject with an object of
|
||||
* validation errors in the form { field1: <String>, field2: <String> }.
|
||||
*
|
||||
* See Asynchronous Blur Validation Example for more details.
|
||||
*/
|
||||
asyncValidate?(values: FormData, dispatch: Dispatch<any>, props: Object): Promise<any>;
|
||||
|
||||
/**
|
||||
* Whether or not to automatically destroy your form's state in the Redux
|
||||
* store when your component is unmounted. Defaults to true.
|
||||
*/
|
||||
destroyOnUnmount?: boolean;
|
||||
|
||||
/**
|
||||
* The key for your sub-form.
|
||||
*
|
||||
* See Multirecord Example for more details.
|
||||
*/
|
||||
formKey?: string;
|
||||
|
||||
/**
|
||||
* A function that takes the entire Redux state and the reduxMountPoint
|
||||
* (which defaults to "form"). It defaults to:
|
||||
* (state, reduxMountPoint) => state[reduxMountPoint].
|
||||
* The only reason you should provide this is if you are keeping your Redux
|
||||
* state as something other than plain javascript objects, e.g. an
|
||||
* Immutable.Map.
|
||||
*/
|
||||
getFormState?(state: any, reduxMountPoint: string): any;
|
||||
|
||||
/**
|
||||
* The values with which to initialize your form in componentWillMount().
|
||||
* Particularly useful when Editing Multiple Records, but can also be used
|
||||
* with single-record forms. The values should be in the form
|
||||
* { field1: 'value1', field2: 'value2' }.
|
||||
*/
|
||||
initialValues?: { [field: string]: FieldValue };
|
||||
|
||||
/**
|
||||
* The function to call with the form data when the handleSubmit() is fired
|
||||
* from within the form component. If you do not specify it as a prop here,
|
||||
* you must pass it as a parameter to handleSubmit() inside your form
|
||||
* component.
|
||||
*/
|
||||
onSubmit?(values: FormData, dispatch?: Dispatch<any>): any;
|
||||
|
||||
/**
|
||||
* If true, the form values will be overwritten whenever the initialValues
|
||||
* prop changes. If false, the values will not be overwritten if the form has
|
||||
* previously been initialized. Defaults to true.
|
||||
*/
|
||||
overwriteOnInitialValuesChange?: boolean;
|
||||
|
||||
/**
|
||||
* If specified, all the props normally passed into your decorated
|
||||
* component directly will be passed under the key specified. Useful if
|
||||
* using other decorator libraries on the same component to avoid prop
|
||||
* namespace collisions.
|
||||
*/
|
||||
propNamespace?: string;
|
||||
|
||||
/**
|
||||
* if true, the decorated component will not be passed any of the onX
|
||||
* functions as props that will allow it to mutate the state. Useful for
|
||||
* decorating another component that is not your form, but that needs to
|
||||
* know about the state of your form.
|
||||
*/
|
||||
readonly?: boolean;
|
||||
|
||||
/**
|
||||
* The use of this property is highly discouraged, but if you absolutely
|
||||
* need to mount your redux-form reducer at somewhere other than form in
|
||||
* your Redux state, you will need to specify the key you mounted it under
|
||||
* with this property. Defaults to 'form'.
|
||||
*
|
||||
* See Alternate Mount Point Example for more details.
|
||||
*/
|
||||
reduxMountPoint?: string;
|
||||
|
||||
/**
|
||||
* If set to true, a failed submit will return a rejected promise. Defaults
|
||||
* to false. Only use this if you need to detect submit failures and run
|
||||
* some code when a submit fails.
|
||||
*/
|
||||
returnRejectedSubmitPromise?: boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the blur action is fired. Defaults to true.
|
||||
*/
|
||||
touchOnBlur?: boolean;
|
||||
|
||||
/**
|
||||
* marks fields as touched when the change action is fired. Defaults to
|
||||
* false.
|
||||
*/
|
||||
touchOnChange?: boolean;
|
||||
|
||||
/**
|
||||
* a synchronous validation function that takes the form values and props
|
||||
* passed into your component. If validation passes, it should return {}.
|
||||
* If validation fails, it should return the validation errors in the form
|
||||
* { field1: <String>, field2: <String> }.
|
||||
* Defaults to (values, props) => ({}).
|
||||
*/
|
||||
validate?(values: FormData, props: { [fieldName: string]: FieldProp<any> }): Object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The current value of the field.
|
||||
* @param previousValue The previous value of the field before the current
|
||||
* action was dispatched.
|
||||
* @param allValues All the values of the current form.
|
||||
* @param previousAllValues All the values of the form before the current
|
||||
* change. Useful to change one field based on a change in another.
|
||||
*/
|
||||
export type Normalizer =
|
||||
(value: FieldValue, previousValue: FieldValue,
|
||||
allValues: FormData, previousAllValues: FormData) => any;
|
||||
|
||||
export declare const reducer: {
|
||||
(state: any, action: any): any;
|
||||
|
||||
/**
|
||||
* Returns a form reducer that will also pass each form value through the
|
||||
* normalizing functions provided. The parameter is an object mapping from
|
||||
* formName to an object mapping from fieldName to a normalizer function.
|
||||
* The normalizer function is given four parameters and expected to return
|
||||
* the normalized value of the field.
|
||||
*/
|
||||
normalize(normalizers: {
|
||||
[formName: string]: {
|
||||
[fieldName: string]: Normalizer
|
||||
}
|
||||
}): Reducer<any>;
|
||||
|
||||
/**
|
||||
* Returns a form reducer that will also pass each action through
|
||||
* additional reducers specified. The parameter should be an object mapping
|
||||
* from formName to a (state, action) => nextState reducer. The state
|
||||
* passed to each reducer will only be the slice that pertains to that
|
||||
* form.
|
||||
*/
|
||||
plugin(reducers: { [formName: string]: Reducer<any> }): Reducer<any>;
|
||||
}
|
||||
|
||||
@@ -1,331 +1,52 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import {Component, PropTypes} from 'react';
|
||||
import {createStore, combineReducers} from 'redux';
|
||||
import {reduxForm, reducer as reduxFormReducer, ReduxFormProps} from 'redux-form';
|
||||
import { Component } from 'react';
|
||||
import { Field, GenericField, reduxForm, WrappedFieldProps, BaseFieldProps } from "redux-form";
|
||||
|
||||
interface CustomComponentProps {
|
||||
customProp: string;
|
||||
}
|
||||
|
||||
namespace SimpleForm {
|
||||
export const fields = ['firstName', 'lastName', 'email', 'sex', 'favoriteColor', 'employed', 'notes'];
|
||||
|
||||
class SimpleForm extends Component<ReduxFormProps<SimpleForm & HTMLFormElement>, void> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
class CustomComponent extends Component<WrappedFieldProps<any> & CustomComponentProps, {}> {
|
||||
render() {
|
||||
const {
|
||||
fields: {firstName, lastName, email, sex, favoriteColor, employed, notes},
|
||||
handleSubmit,
|
||||
resetForm,
|
||||
submitting
|
||||
} = this.props;
|
||||
return (<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>First Name</label>
|
||||
return (
|
||||
<div>
|
||||
<input type="text" placeholder="First Name" {...firstName}/>
|
||||
<span>{this.props.customProp}</span>
|
||||
<p>Field: {this.props.meta.touched ? 'touched' : 'pristine'}</p>
|
||||
<input {...this.props.input} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Last Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Last Name" {...lastName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Email</label>
|
||||
<div>
|
||||
<input type="email" placeholder="Email" {...email}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Sex</label>
|
||||
<div>
|
||||
<label>
|
||||
<input type="radio" {...sex} value="male" checked={sex.value === 'male'}/> Male
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" {...sex} value="female" checked={sex.value === 'female'}/> Female
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Favorite Color</label>
|
||||
<div>
|
||||
<select {...favoriteColor}>
|
||||
<option></option>
|
||||
<option value="ff0000">Red</option>
|
||||
<option value="00ff00">Green</option>
|
||||
<option value="0000ff">Blue</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
<input type="checkbox" {...employed}/> Employed
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>Notes</label>
|
||||
<div>
|
||||
<textarea
|
||||
{...notes}
|
||||
value={notes.value || ''}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Connected = reduxForm({
|
||||
form: 'simple',
|
||||
fields
|
||||
})(SimpleForm);
|
||||
}
|
||||
|
||||
|
||||
namespace SynchronousValidation {
|
||||
export const fields = ['username', 'email', 'age'];
|
||||
|
||||
const validate = (values:any) => {
|
||||
const errors:any = {};
|
||||
if (!values.username) {
|
||||
errors.username = 'Required';
|
||||
} else if (values.username.length > 15) {
|
||||
errors.username = 'Must be 15 characters or less';
|
||||
}
|
||||
if (!values.email) {
|
||||
errors.email = 'Required';
|
||||
} else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(values.email)) {
|
||||
errors.email = 'Invalid email address';
|
||||
}
|
||||
if (!values.age) {
|
||||
errors.age = 'Required';
|
||||
} else if (isNaN(Number(values.age))) {
|
||||
errors.age = 'Must be a number';
|
||||
} else if (Number(values.age) < 18) {
|
||||
errors.age = 'Sorry, you must be at least 18 years old';
|
||||
}
|
||||
return errors;
|
||||
};
|
||||
|
||||
class SynchronousValidationForm extends Component<ReduxFormProps<SynchronousValidationForm & HTMLFormElement>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
class CustomField extends Component<BaseFieldProps & CustomComponentProps, {}> {
|
||||
render() {
|
||||
const {fields: {username, email, age}, resetForm, handleSubmit, submitting} = this.props;
|
||||
return (<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>Username</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Username" {...username}/>
|
||||
</div>
|
||||
{username.touched && username.error && <div>{username.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Email</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Email" {...email}/>
|
||||
</div>
|
||||
{email.touched && email.error && <div>{email.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Age</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Age" {...age}/>
|
||||
</div>
|
||||
{age.touched && age.error && <div>{age.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
const F = Field as new () => GenericField<CustomComponentProps, any>;
|
||||
return <F component={CustomComponent} {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'synchronousValidation',
|
||||
fields,
|
||||
validate
|
||||
})(SynchronousValidationForm);
|
||||
}
|
||||
|
||||
interface FormData {
|
||||
foo: string;
|
||||
custom: string;
|
||||
}
|
||||
|
||||
namespace SumbitValidation {
|
||||
export const fields = ['username', 'password'];
|
||||
|
||||
const submit = (values:any, dispatch:any) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if (['john', 'paul', 'george', 'ringo'].indexOf(values.username) === -1) {
|
||||
reject({username: 'User does not exist', _error: 'Login failed!'});
|
||||
} else if (values.password !== 'redux-form') {
|
||||
reject({password: 'Wrong password', _error: 'Login failed!'});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}, 1000); // simulate server latency
|
||||
});
|
||||
};
|
||||
|
||||
class SubmitValidationForm extends Component<ReduxFormProps<SubmitValidationForm>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
error: PropTypes.string,
|
||||
resetForm: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
@reduxForm<FormData, any, any>({
|
||||
form: 'myForm'
|
||||
})
|
||||
class MyForm extends Component<{}, {}> {
|
||||
render() {
|
||||
const {fields: {username, password}, error, resetForm, handleSubmit, submitting} = this.props;
|
||||
return (<form onSubmit={submit => handleSubmit(submit as any)}>
|
||||
<div>
|
||||
<label>Username</label>
|
||||
return (
|
||||
<div>
|
||||
<input type="text" placeholder="Username" {...username}/>
|
||||
<Field
|
||||
name='foo'
|
||||
component='input'
|
||||
placeholder='Foo bar'
|
||||
/>
|
||||
<CustomField
|
||||
name='custom'
|
||||
customProp='Hello'
|
||||
/>
|
||||
</div>
|
||||
{username.touched && username.error && <div>{username.error}</div>}
|
||||
</div>
|
||||
<div>
|
||||
<label>Password</label>
|
||||
<div>
|
||||
<input type="password" placeholder="Password" {...password}/>
|
||||
</div>
|
||||
{password.touched && password.error && <div>{password.error}</div>}
|
||||
</div>
|
||||
{error && <div>{error}</div>}
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Log In
|
||||
</button>
|
||||
<button disabled={submitting} onClick={resetForm}>
|
||||
Clear Values
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'submitValidation',
|
||||
fields
|
||||
})(SubmitValidationForm);
|
||||
}
|
||||
|
||||
|
||||
namespace InitializingFromState {
|
||||
const LOAD = 'redux-form-examples/account/LOAD';
|
||||
const loadAccount = (data:any) => ({type: LOAD, data});
|
||||
export const fields = ['firstName', 'lastName', 'age', 'bio'];
|
||||
const data = { // used to populate "account" reducer when "Load" is clicked
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
age: '42',
|
||||
bio: 'Born to write amazing Redux code.'
|
||||
};
|
||||
|
||||
interface Props<T> extends ReduxFormProps<T> {
|
||||
load: Function;
|
||||
}
|
||||
|
||||
class InitializingFromStateForm extends Component<Props<InitializingFromStateForm & HTMLFormElement>, any> {
|
||||
static propTypes = {
|
||||
fields: PropTypes.object.isRequired,
|
||||
handleSubmit: PropTypes.func.isRequired,
|
||||
load: PropTypes.func.isRequired,
|
||||
submitting: PropTypes.bool.isRequired
|
||||
};
|
||||
|
||||
render() {
|
||||
const {fields: {firstName, lastName, age, bio}, handleSubmit, load, submitting} = this.props;
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<button onClick={() => load(data)}>Load Account</button>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div>
|
||||
<label>First Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="First Name" {...firstName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Last Name</label>
|
||||
<div>
|
||||
<input type="text" placeholder="Last Name" {...lastName}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Age</label>
|
||||
<div>
|
||||
<input type="number" placeholder="Age" {...age}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label>Occupation</label>
|
||||
<div>
|
||||
<textarea placeholder="Biography" {...bio}/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button disabled={submitting} onClick={handleSubmit}>
|
||||
{submitting ? <i/> : <i/>} Submit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const Connected = reduxForm({
|
||||
form: 'initializing',
|
||||
fields
|
||||
},
|
||||
(state:any) => ({ // mapStateToProps
|
||||
initialValues: state.account.data // will pull state into form's initialValues
|
||||
}),
|
||||
{load: loadAccount} // mapDispatchToProps (will bind action creator to dispatch)
|
||||
)(InitializingFromStateForm);
|
||||
}
|
||||
|
||||
|
||||
namespace NormalizingFormData {
|
||||
const reducer = combineReducers({
|
||||
// other reducers
|
||||
form: reduxFormReducer.normalize({
|
||||
normalizing: { // <--- name of the form
|
||||
upper: value => value && value.toUpperCase(), // normalizer for 'upper' field
|
||||
}
|
||||
})
|
||||
});
|
||||
const store = createStore(reducer);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
@@ -18,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"redux-form-tests.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
4
request/index.d.ts
vendored
4
request/index.d.ts
vendored
@@ -50,6 +50,10 @@ declare namespace request {
|
||||
del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
del(uri: string, callback?: RequestCallback): TRequest;
|
||||
del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
delete(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
delete(uri: string, callback?: RequestCallback): TRequest;
|
||||
delete(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
forever(agentOptions: any, optionsArg: any): TRequest;
|
||||
jar(): CookieJar;
|
||||
|
||||
@@ -203,6 +203,13 @@ req = request.del(uri, callback);
|
||||
req = request.del(options);
|
||||
req = request.del(options, callback);
|
||||
|
||||
req = request.delete(uri);
|
||||
req = request.delete(uri, options);
|
||||
req = request.delete(uri, options, callback);
|
||||
req = request.delete(uri, callback);
|
||||
req = request.delete(options);
|
||||
req = request.delete(options, callback);
|
||||
|
||||
req = request.forever(value, value);
|
||||
jar = request.jar();
|
||||
cookie = request.cookie(str);
|
||||
@@ -560,6 +567,7 @@ request.patch(url);
|
||||
request.post(url);
|
||||
request.head(url);
|
||||
request.del(url);
|
||||
request.delete(url);
|
||||
request.get(url);
|
||||
request.cookie('key1=value1');
|
||||
request.jar();
|
||||
|
||||
1
restify/index.d.ts
vendored
1
restify/index.d.ts
vendored
@@ -456,6 +456,7 @@ interface ServerOptions {
|
||||
interface ClientOptions {
|
||||
accept?: string;
|
||||
connectTimeout?: number;
|
||||
requestTimeout?: number;
|
||||
dtrace?: Object;
|
||||
gzip?: Object;
|
||||
headers?: Object;
|
||||
|
||||
22
rx/index.d.ts
vendored
22
rx/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for RxJS v2.5.3
|
||||
// Type definitions for RxJS 4.1
|
||||
// Project: http://rx.codeplex.com/
|
||||
// Definitions by: gsino <http://www.codeplex.com/site/users/view/gsino>, Igor Oleinikov <https://github.com/Igorbek>
|
||||
// Definitions by: gsino <http://www.codeplex.com/site/users/view/gsino>, Igor Oleinikov <https://github.com/Igorbek>, Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="rx-lite.d.ts"/>
|
||||
@@ -29,10 +29,8 @@ declare namespace Rx {
|
||||
observeOn(scheduler: IScheduler): Observable<T>;
|
||||
subscribeOn(scheduler: IScheduler): Observable<T>;
|
||||
|
||||
amb(rightSource: Observable<T>): Observable<T>;
|
||||
amb(rightSource: IPromise<T>): Observable<T>;
|
||||
onErrorResumeNext(second: Observable<T>): Observable<T>;
|
||||
onErrorResumeNext(second: IPromise<T>): Observable<T>;
|
||||
amb(rightSource: IPromise<T> | Observable<T>): Observable<T>;
|
||||
onErrorResumeNext(second: IPromise<T> | Observable<T>): Observable<T>;
|
||||
bufferWithCount(count: number, skip?: number): Observable<T[]>;
|
||||
windowWithCount(count: number, skip?: number): Observable<Observable<T>>;
|
||||
defaultIfEmpty(defaultValue?: T): Observable<T>;
|
||||
@@ -46,14 +44,12 @@ declare namespace Rx {
|
||||
|
||||
interface ObservableStatic {
|
||||
using<TSource, TResource extends IDisposable>(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable<TSource>): Observable<TSource>;
|
||||
amb<T>(...sources: Observable<T>[]): Observable<T>;
|
||||
amb<T>(...sources: IPromise<T>[]): Observable<T>;
|
||||
amb<T>(sources: Observable<T>[]): Observable<T>;
|
||||
amb<T>(sources: IPromise<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(...sources: Observable<T>[]): Observable<T>;
|
||||
amb<T>(...sources: Observable<T>[]): Observable<T>;
|
||||
amb<T>(sources: IPromise<T>[] | Observable<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(...sources: IPromise<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(sources: Observable<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(sources: IPromise<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(...sources: Observable<T>[]): Observable<T>;
|
||||
onErrorResumeNext<T>(sources: IPromise<T>[] | Observable<T>[]): Observable<T>;
|
||||
}
|
||||
|
||||
interface GroupedObservable<TKey, TElement> extends Observable<TElement> {
|
||||
@@ -63,5 +59,5 @@ declare namespace Rx {
|
||||
}
|
||||
|
||||
declare module "rx" {
|
||||
export = Rx
|
||||
export = Rx;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user