From de8574d395843d0581c09b17e30046abf32354cb Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 19 Jan 2016 10:52:33 +0100 Subject: [PATCH 0001/1354] removed the KeyBinding constructor --- ace/ace.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/ace/ace.d.ts b/ace/ace.d.ts index 8fed295f20..b7ce4ebaa8 100644 --- a/ace/ace.d.ts +++ b/ace/ace.d.ts @@ -77,9 +77,6 @@ declare module AceAjax { onTextInput(text: any): void; } - var KeyBinding: { - new(editor: Editor): KeyBinding; - } export interface TextMode { From 7c5dbff213cb8a7f27200b1fa03af82b2c649c23 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 28 Mar 2016 13:55:13 -0400 Subject: [PATCH 0002/1354] TransitionGroup spreads HTMLAttribute props onto its component --- react/react-addons-transition-group.d.ts | 2 +- react/react-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts index ca7bb4c31e..b31d7a5d2d 100644 --- a/react/react-addons-transition-group.d.ts +++ b/react/react-addons-transition-group.d.ts @@ -7,7 +7,7 @@ declare namespace __React { - interface TransitionGroupProps { + interface TransitionGroupProps extends HTMLAttributes { component?: ReactType; childFactory?: (child: ReactElement) => ReactElement; } diff --git a/react/react-tests.ts b/react/react-tests.ts index e0d9bb7be7..ca289ebda5 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -480,7 +480,9 @@ React.createFactory(CSSTransitionGroup)({ transitionName: "transition", transitionAppear: false, transitionEnter: true, - transitionLeave: true + transitionLeave: true, + id: "some-id", + className: "some-class" }); React.createFactory(CSSTransitionGroup)({ From 53cb2ca2928aaa65c25734b8a974c9c336bfdfa6 Mon Sep 17 00:00:00 2001 From: Luke Venn Date: Thu, 21 Apr 2016 10:39:10 +0100 Subject: [PATCH 0003/1354] Added RegExp typing to 'path' argument descriptions --- nock/nock.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nock/nock.d.ts b/nock/nock.d.ts index 208aac9b31..3319456a5e 100644 --- a/nock/nock.d.ts +++ b/nock/nock.d.ts @@ -22,28 +22,45 @@ declare module "nock" { export interface Scope { get(path: string, data?: string): Scope; + get(path: RegExp, data?: string): Scope; post(path: string, data?: string): Scope; post(path: string, data?: Object): Scope; post(path: string, regex?: RegExp): Scope; + post(path: RegExp, data?: string): Scope; + post(path: RegExp, data?: Object): Scope; + post(path: RegExp, regex?: RegExp): Scope; patch(path: string, data?: string): Scope; patch(path: string, data?: Object): Scope; patch(path: string, regex?: RegExp): Scope; + patch(path: RegExp, data?: string): Scope; + patch(path: RegExp, data?: Object): Scope; + patch(path: RegExp, regex?: RegExp): Scope; put(path: string, data?: string): Scope; put(path: string, data?: Object): Scope; put(path: string, regex?: RegExp): Scope; + put(path: RegExp, data?: string): Scope; + put(path: RegExp, data?: Object): Scope; + put(path: RegExp, regex?: RegExp): Scope; head(path: string): Scope; + head(path: RegExp): Scope; delete(path: string, data?: string): Scope; delete(path: string, data?: Object): Scope; delete(path: string, regex?: RegExp): Scope; + delete(path: RegExp, data?: string): Scope; + delete(path: RegExp, data?: Object): Scope; + delete(path: RegExp, regex?: RegExp): Scope; merge(path: string, data?: string): Scope; merge(path: string, data?: Object): Scope; merge(path: string, regex?: RegExp): Scope; + merge(path: RegExp, data?: string): Scope; + merge(path: RegExp, data?: Object): Scope; + merge(path: RegExp, regex?: RegExp): Scope; query(params: any): Scope; query(acceptAnyParams: boolean): Scope; @@ -51,6 +68,9 @@ declare module "nock" { intercept(path: string, verb: string, body?: string, options?: any): Scope; intercept(path: string, verb: string, body?: Object, options?: any): Scope; intercept(path: string, verb: string, body?: RegExp, options?: any): Scope; + intercept(path: RegExp, verb: string, body?: string, options?: any): Scope; + intercept(path: RegExp, verb: string, body?: Object, options?: any): Scope; + intercept(path: RegExp, verb: string, body?: RegExp, options?: any): Scope; reply(responseCode: number, body?: string, headers?: Object): Scope; reply(responseCode: number, body?: Object, headers?: Object): Scope; From 634752a79ec35f607ecfd66b09bbf44470f174f1 Mon Sep 17 00:00:00 2001 From: microshine Date: Fri, 6 May 2016 02:00:31 +0300 Subject: [PATCH 0004/1354] xadesjs beta --- xadesjs/promise.d.ts | 14 + xadesjs/xadesjs.d.ts | 1075 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1089 insertions(+) create mode 100644 xadesjs/promise.d.ts create mode 100644 xadesjs/xadesjs.d.ts diff --git a/xadesjs/promise.d.ts b/xadesjs/promise.d.ts new file mode 100644 index 0000000000..96b926633b --- /dev/null +++ b/xadesjs/promise.d.ts @@ -0,0 +1,14 @@ +interface PromiseFunc { + (resolve: (...args: any[]) => void, reject: (...args: any[]) => void): void; +} + +declare class Promise { + constructor(func: PromiseFunc); + + then(resolve: (...args: any[]) => any): Promise; + then(resolve: (...args: any[]) => any, reject: (...args: any[]) => any): Promise; + catch(reject: (...args: any[]) => any): void; + + static resolve(...args: any[]): Promise; + static reject(...args: any[]): Promise; +} \ No newline at end of file diff --git a/xadesjs/xadesjs.d.ts b/xadesjs/xadesjs.d.ts new file mode 100644 index 0000000000..4eb7b6a1c5 --- /dev/null +++ b/xadesjs/xadesjs.d.ts @@ -0,0 +1,1075 @@ +/// + +declare namespace xadesjs { + + const APPLICATION_XML: string; + + class XmlError extends Error { + stack: any; + constructor(code: XE, ...args: any[]); + } + + enum XE { + NONE = 0, + NULL_REFERENCE = 1, + METHOD_NOT_IMPLEMENTED = 2, + METHOD_NOT_SUPPORTED = 3, + PARAM_REQUIRED = 4, + CONVERTER_UNSUPPORTED = 5, + ELEMENT_MALFORMED = 6, + CRYPTOGRAPHIC = 7, + CRYPTOGRAPHIC_NO_MODULE = 8, + CRYPTOGRAPHIC_UNKNOWN_TRANSFORM = 9, + ALGORITHM_NOT_SUPPORTED = 10, + ALGORITHM_WRONG_NAME = 11, + XML_EXCEPTION = 12, + } + + interface CryptoEx extends Crypto { + name: string; + } + + class Application { + /** + * Sets crypto engine for the current Application + * @param {string} name + * @param {Crypto} crypto + * @returns void + */ + static setEngine(name: string, crypto: Crypto): void; + /** + * Gets the crypto module from the Application + */ + static crypto: CryptoEx; + static isNodePlugin(): boolean; + } + + enum XmlNodeType { + None = 0, + Element = 1, + Attribute = 2, + Text = 3, + CDATA = 4, + EntityReference = 5, + Entity = 6, + ProcessingInstruction = 7, + Comment = 8, + Document = 9, + DocumentType = 10, + DocumentFragment = 11, + Notation = 12, + Whitespace = 13, + SignificantWhitespace = 14, + EndElement = 15, + EndEntity = 16, + XmlDeclaration = 17, + } + + interface IXmlSerializable { + Prefix: string; + /** + * Writes object to XML node + * @returns Node + */ + GetXml(): Node; + /** + * Reads XML from string + * @param {Node} node + * @returns void + */ + LoadXml(node: Node): void; + } + + abstract class XmlObject implements IXmlSerializable { + protected m_prefix: string; + Prefix: string; + protected GetPrefix(): string; + GetXml(): Node; + GetXml(document: Document): Node; + LoadXml(node: Node): void; + toString(): string; + protected getAttribute(xel: Element, attribute: string): string; + } + + const DEFAULT_ROOT_NAME: string; + function IsEqualsEmptyStrings(s1: string, s2: string): boolean; + /** + * Creates new instance of XmlDocument with given name of root element + * @param {string} root Name of root element + * @param {string} namespaceUri + * @param {string} prefix + * @returns Document + */ + function CreateDocument(root?: string, namespaceUri?: string, prefix?: string): Document; + /** + * Returns signle Node from given Node + * @param {Node} node + * @param {string} path + * @returns Node + */ + function SelectSingleNode(node: Node, path: string): Node; + + function findAttr(node: Node, localName: string, nameSpace?: string): Attr; + function findFirst(doc: Node, xpath: string): Node; + function findChilds(node: Node, localName: string, nameSpace?: string): Node[]; + interface IAssocArray { + [index: string]: string; + } + function encodeSpecialCharactersInAttribute(attributeValue: string): string; + function encodeSpecialCharactersInText(text: string): string; + function SelectNamespaces(node: Element): Node[]; + + class Convert { + static ToBase64UrlString(text: string): string; + static FromBase64UrlString(base64UrlText: string): string; + static ToBase64String(text: string): string; + static FromBase64String(base64Text: string): string; + static Base64UrlToBase64(base64url: string): string; + static Base64ToBase64Url(base64: string): string; + static ToBufferUtf8String(text: string): Uint8Array; + static FromBufferUtf8String(buffer: Uint8Array): string; + static ToBufferString(text: string): Uint8Array; + static FromBufferString(buffer: ArrayBuffer): string; + static FromBufferString(buffer: Uint8Array): string; + } + + interface IAlgorithm { + algorithm: Algorithm; + xmlNamespace: string; + getAlgorithmName(): string; + } + interface IHashAlgorithm extends IAlgorithm { + getHash(xml: string): Promise; + } + interface IHashAlgorithmConstructable { + new (): IHashAlgorithm; + } + abstract class XmlAlgorithm implements IAlgorithm { + algorithm: Algorithm; + xmlNamespace: string; + getAlgorithmName(): string; + } + abstract class HashAlgorithm extends XmlAlgorithm implements IHashAlgorithm { + getHash(xml: string): Promise; + } + interface ISignatureAlgorithm extends IAlgorithm { + getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise; + verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): Promise; + } + interface ISignatureAlgorithmConstructable { + new (): ISignatureAlgorithm; + } + abstract class SignatureAlgorithm extends XmlAlgorithm implements ISignatureAlgorithm { + /** + * Sign the given string using the given key + */ + getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise; + /** + * Verify the given signature of the given string using key + */ + verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): Promise; + } + + const SHA1: string; + const SHA224: string; + const SHA256: string; + const SHA384: string; + const SHA512: string; + const SHA1_NAMESPACE: string; + const SHA224_NAMESPACE: string; + const SHA256_NAMESPACE: string; + const SHA384_NAMESPACE: string; + const SHA512_NAMESPACE: string; + class Sha1 extends HashAlgorithm { + algorithm: { + name: string; + }; + xmlNamespace: string; + } + class Sha224 extends HashAlgorithm { + algorithm: { + name: string; + }; + xmlNamespace: string; + } + class Sha256 extends HashAlgorithm { + algorithm: { + name: string; + }; + xmlNamespace: string; + } + class Sha384 extends HashAlgorithm { + algorithm: { + name: string; + }; + xmlNamespace: string; + } + class Sha512 extends HashAlgorithm { + algorithm: { + name: string; + }; + xmlNamespace: string; + } + + // RSA PKCS1 + + const RSA_PKCS1: string; + const RSA_PKCS1_SHA1_NAMESPACE: string; + const RSA_PKCS1_SHA224_NAMESPACE: string; + const RSA_PKCS1_SHA256_NAMESPACE: string; + const RSA_PKCS1_SHA384_NAMESPACE: string; + const RSA_PKCS1_SHA512_NAMESPACE: string; + + class RsaPkcs1Sha1 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPkcs1Sha224 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPkcs1Sha256 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPkcs1Sha384 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPkcs1Sha512 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + + // RSA PSS + + const RSA_PSS: string; + const RSA_PSS_WITH_PARAMS_NAMESPACE: string; + const RSA_PSS_WITH_PARAMS_MGF1_NAMESPACE: string; + + class RsaPssSha1 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPssSha224 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPssSha256 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPssSha384 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class RsaPssSha512 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class PssAlgorithmParams extends XmlObject { + private m_digest_method; + private m_salt_length; + private m_mgf; + private element; + dsPrefix: string; + DigestMethod: string; + SaltLength: number; + MGF: string; + GetXml(): Element; + LoadXml(value: Element): void; + } + + // HMAC + + const HMAC_ALGORITHM: string; + const HMAC_SHA1_NAMESPACE: string; + const HMAC_SHA256_NAMESPACE: string; + const HMAC_SHA384_NAMESPACE: string; + const HMAC_SHA512_NAMESPACE: string; + + class HmacSha1 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class HmacSha256 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class HmacSha384 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class HmacSha512 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + + // ECDSA + + const ECDSA_SIGN_ALGORITHM: string; + const ECDSA_SHA1_NAMESPACE: string; + const ECDSA_SHA224_NAMESPACE: string; + const ECDSA_SHA256_NAMESPACE: string; + const ECDSA_SHA384_NAMESPACE: string; + const ECDSA_SHA512_NAMESPACE: string; + class EcdsaSha1 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class EcdsaSha224 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class EcdsaSha256 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class EcdsaSha384 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + class EcdsaSha512 extends SignatureAlgorithm { + algorithm: any; + xmlNamespace: string; + } + + /** + * Represents an element. + */ + class X509Certificate { + protected raw: Uint8Array; + protected cert_simpl: any; + protected publicKey: CryptoKey; + constructor(rawData?: Uint8Array); + /** + * Loads X509Certificate from DER data + * @param {Uint8Array} rawData + */ + protected LoadFromRawData(rawData: Uint8Array): void; + /** + * Gets the public key from the X509Certificate + */ + PublicKey: CryptoKey; + /** + * Returns DER raw of X509Certificate + */ + GetRawCertData(): Uint8Array; + /** + * Returns public key from X509Certificate + * @param {Algorithm} algorithm + * @returns Promise + */ + exportKey(algorithm: Algorithm): Promise; + } + + enum X509IncludeOption { + None = 0, + EndCertOnly = 1, + ExcludeRoot = 2, + WholeChain = 3, + } + interface X509IssuerSerial { + issuerName: string; + serialNumber: string; + } + /** + * Represents an subelement of an XMLDSIG or XML Encryption element. + */ + class KeyInfoX509Data extends XmlObject implements KeyInfoClause { + + constructor(); + constructor(rgbCert: Uint8Array); + constructor(cert: X509Certificate); + /** + * Gets public key of the X509Data + */ + Key: CryptoKey; + importKey(key: CryptoKey): Promise; + /** + * Exports key from X509Data object + * @param {Algorithm} alg + * @returns Promise + */ + exportKey(alg: Algorithm): Promise; + /** + * Gets a list of the X.509v3 certificates contained in the KeyInfoX509Data object. + */ + Certificates: X509Certificate[]; + /** + * Gets or sets the Certificate Revocation List (CRL) contained within the KeyInfoX509Data object. + */ + CRL: Uint8Array; + /** + * Gets a list of X509IssuerSerial structures that represent an issuer name and serial number pair. + */ + IssuerSerials: X509IssuerSerial[]; + /** + * Gets a list of the subject key identifiers (SKIs) contained in the KeyInfoX509Data object. + */ + SubjectKeyIds: Uint8Array[]; + /** + * Gets a list of the subject names of the entities contained in the KeyInfoX509Data object. + */ + SubjectNames: string[]; + /** + * Adds the specified X.509v3 certificate to the KeyInfoX509Data. + * @param {X509Certificate} certificate + * @returns void + */ + AddCertificate(certificate: X509Certificate): void; + /** + * Adds the specified issuer name and serial number pair to the KeyInfoX509Data object. + * @param {string} issuerName + * @param {string} serialNumber + * @returns void + */ + AddIssuerSerial(issuerName: string, serialNumber: string): void; + /** + * Adds the specified subject key identifier (SKI) to the KeyInfoX509Data object. + * @param {string | Uint8Array} subjectKeyId + * @returns void + */ + AddSubjectKeyId(subjectKeyId: string): void; + AddSubjectKeyId(subjectKeyId: Uint8Array): void; + /** + * Adds the subject name of the entity that was issued an X.509v3 certificate to the KeyInfoX509Data object. + * @param {string} subjectName + * @returns void + */ + AddSubjectName(subjectName: string): void; + /** + * Returns an XML representation of the KeyInfoX509Data object. + * @returns Element + */ + GetXml(): Element; + /** + * Parses the input XmlElement object and configures the internal state of the KeyInfoX509Data object to match. + * @param {Element} element + * @returns void + */ + LoadXml(element: Element): void; + } + + interface IJwkRsa { + alg: string; + kty: string; + e: string; + n: string; + ext: boolean; + } + /** + * Represents the element of an XML signature. + */ + class RsaKeyValue extends XmlObject implements KeyInfoClause { + /** + * Gets or sets the instance of RSA that holds the public key. + */ + Key: CryptoKey; + /** + * Gets the algorithm of the public key + */ + Algorithm: ISignatureAlgorithm; + /** + * Gets the Modulus of the public key + */ + Modulus: Uint8Array; + /** + * Gets the Exponent of the public key + */ + Exponent: Uint8Array; + constructor(); + /** + * Imports key to the RSAKeyValue object + * @param {CryptoKey} key + * @returns Promise + */ + importKey(key: CryptoKey): Promise; + /** + * Exports key from the RSAKeyValue object + * @param {Algorithm} alg + * @returns Promise + */ + exportKey(alg: Algorithm): Promise; + /** + * Returns the XML representation of the RSA key clause. + * @returns Element + */ + GetXml(): Element; + /** + * Loads an RSA key clause from an XML element. + * @param {Element} element + * @returns void + */ + LoadXml(element: Element): void; + } + + type NamedCurve = "P-256" | "P-384" | "P-521"; + + interface IJwkEcdsa { + crv: NamedCurve; + kty: "EC"; + x: string; + y: string; + ext: boolean; + } + + /** + * Represents the element of an XML signature. + */ + class EcdsaKeyValue extends XmlObject implements KeyInfoClause { + /** + * Gets or sets the instance of ECDSA that holds the public key. + */ + Key: CryptoKey; + /** + * Gets the algorithm of the public key + */ + Algorithm: ISignatureAlgorithm; + /** + * Gets the X point value of then public key + */ + X: Uint8Array; + /** + * Gets the Y point value of then public key + */ + Y: Uint8Array; + /** + * Gets the NamedCurve value of then public key + */ + NamedCurve: NamedCurve; + constructor(); + /** + * Imports key to the ECKeyValue object + * @param {CryptoKey} key + * @returns Promise + */ + importKey(key: CryptoKey): Promise; + /** + * Exports key from the ECKeyValue object + * @param {Algorithm} alg + * @returns Promise + */ + exportKey(alg: Algorithm): Promise; + /** + * Returns the XML representation of the ECDSA key clause. + * @returns Element + */ + GetXml(): Element; + /** + * Loads an ECDSA key clause from an XML element. + * @param {Element} element + * @returns void + */ + LoadXml(element: Element): void; + } + + type XmlNamespace = { + prefix: string; + namespace: string; + }; + + enum XmlCanonicalizerState { + BeforeDocElement = 0, + InsideDocElement = 1, + AfterDocElement = 2, + } + + class XmlCanonicalizer { + constructor(withComments: boolean, excC14N: boolean, propagatedNamespaces?: XmlNamespace[]); + InclusiveNamespacesPrefixList: string; + Canonicalize(node: Node): string; + } + + interface Transform extends IXmlSerializable { + Algorithm: string; + LoadInnerXml(node: Node): void; + GetInnerXml(): Node; + GetOutput(): string; + } + + interface ICanonicalizationAlgorithmConstructable { + new (): Transform; + } + /** + * Represents the abstract base class from which all elements + * that can be used in an XML digital signature derive. + */ + abstract class Transform extends XmlObject implements Transform { + protected innerXml: Node; + LoadXml(value: Node): void; + /** + * Returns the XML representation of the current Transform object. + * @returns Element + */ + GetXml(): Element; + } + + /** + * Represents the enveloped signature transform for an XML digital signature as defined by the W3C. + */ + class XmlDsigEnvelopedSignatureTransform extends Transform { + Algorithm: string; + /** + * Returns the output of the current XmlDsigEnvelopedSignatureTransform object. + * @returns string + */ + GetOutput(): string; + } + + /** + * Represents the C14N XML canonicalization transform for a digital signature + * as defined by the World Wide Web Consortium (W3C), without comments. + */ + class XmlDsigC14NTransform extends Transform { + protected xmlCanonicalizer: XmlCanonicalizer; + Algorithm: string; + /** + * Returns the output of the current XmlDsigC14NTransform object. + * @returns string + */ + GetOutput(): string; + } + /** + * Represents the C14N XML canonicalization transform for a digital signature + * as defined by the World Wide Web Consortium (W3C), with comments. + */ + class XmlDsigC14NWithCommentsTransform extends XmlDsigC14NTransform { + Algorithm: string; + protected xmlCanonicalizer: XmlCanonicalizer; + } + + /** + * Represents the exclusive C14N XML canonicalization transform for a digital signature + * as defined by the World Wide Web Consortium (W3C), without comments. + */ + class XmlDsigExcC14NTransform extends Transform { + protected xmlCanonicalizer: XmlCanonicalizer; + Algorithm: string; + /** + * Gets or sets a string that contains namespace prefixes to canonicalize + * using the standard canonicalization algorithm. + */ + InclusiveNamespacesPrefixList: string; + /** + * Returns the output of the current XmlDsigExcC14NTransform object + */ + GetOutput(): string; + } + /** + * Represents the exclusive C14N XML canonicalization transform for a digital signature + * as defined by the World Wide Web Consortium (W3C), with comments. + */ + class XmlDsigExcC14NWithCommentsTransform extends XmlDsigExcC14NTransform { + Algorithm: string; + protected xmlCanonicalizer: XmlCanonicalizer; + } + + class CryptoConfig { + static CreateFromName(name: string): Transform; + static CreateSignatureAlgorithm(namespace: string): SignatureAlgorithm; + static CreateHashAlgorithm(namespace: string): HashAlgorithm; + } + + /** + * Represents the object element of an XML signature that holds data to be signed. + */ + class DataObject extends XmlObject { + constructor(); + constructor(id?: string, mimeType?: string, encoding?: string, data?: Element); + /** + * Gets or sets the data value of the current DataObject object. + */ + Data: NodeList; + /** + * Gets or sets the encoding of the current DataObject object. + */ + Encoding: string; + /** + * Gets or sets the identification of the current DataObject object. + */ + Id: string; + /** + * Gets or sets the MIME type of the current DataObject object. + */ + MimeType: string; + /** + * Returns the XML representation of the DataObject object. + * @returns Element + */ + GetXml(): Element; + /** + * Loads a DataObject state from an XML element. + * @param {Element} value + * @returns void + */ + LoadXml(value: Element): void; + } + + /** + * Represents the element of an XML signature. + */ + class Reference extends XmlObject { + + constructor(p?: string); + /** + * Gets or sets the digest method Uniform Resource Identifier (URI) of the current + */ + DigestMethod: string; + /** + * Gets or sets the digest value of the current Reference. + */ + DigestValue: ArrayBuffer; + /** + * Gets or sets the ID of the current Reference. + */ + Id: string; + /** + * Gets the transform chain of the current Reference. + */ + TransformChain: Transform[]; + /** + * Gets or sets the type of the object being signed. + */ + Type: string; + /** + * Gets or sets the Uri of the current Reference. + */ + Uri: string; + /** + * Adds a Transform object to the list of transforms to be performed + * on the data before passing it to the digest algorithm. + * @param {Transform} transform The transform to be added to the list of transforms. + * @returns void + */ + AddTransform(transform: Transform): void; + /** + * Returns the XML representation of the Reference. + * @returns Element + */ + GetXml(): Element; + /** + * Loads a Reference state from an XML element. + * @param {Element} value + */ + LoadXml(value: Element): void; + } + + /** + * Represents an XML digital signature or XML encryption element. + */ + class KeyInfo extends XmlObject { + constructor(); + /** + * Gets the number of KeyInfoClause objects contained in the KeyInfo object. + */ + length: number; + /** + * Gets or sets the key information identity. + */ + Id: string; + /** + * Returns an enumerator of the KeyInfoClause objects in the KeyInfo object. + * @param {any} requestedObjectType? + */ + GetEnumerator(): Array; + GetEnumerator(requestedObjectType: any): Array; + /** + * Returns an enumerator of the KeyInfoClause objects in the KeyInfo object. + * @param {KeyInfoClause} clause The KeyInfoClause to add to the KeyInfo object. + * @returns void + */ + AddClause(clause: KeyInfoClause): void; + /** + * Returns the XML representation of the KeyInfo object. + * @returns Node + */ + GetXml(): Node; + /** + * Loads a KeyInfo state from an XML element. + * @param {Element} value + * @returns void + */ + LoadXml(value: Element): void; + } + interface KeyInfoClause extends IXmlSerializable { + Key: CryptoKey; + importKey(key: CryptoKey): Promise; + exportKey(alg: Algorithm): Promise; + } + + /** + * Represents the element of an XML signature. + */ + class Signature extends XmlObject { + + constructor(); + /** + * Gets or sets the ID of the current Signature. + */ + Id: string; + /** + * Gets or sets the KeyInfo of the current Signature. + */ + KeyInfo: KeyInfo; + /** + * Gets or sets a list of objects to be signed. + */ + ObjectList: Array; + /** + * Gets or sets the value of the digital signature. + */ + SignatureValue: Uint8Array; + /** + * Gets or sets the SignedInfo of the current Signature. + */ + SignedInfo: SignedInfo; + /** + * Adds a DataObject to the list of objects to be signed. + * @param {DataObject} dataObject The DataObject to be added to the list of objects to be signed. + * @returns void + */ + AddObject(dataObject: DataObject): void; + /** + * Returns the XML representation of the Signature. + * @returns Element + */ + GetXml(): Element; + /** + * Loads a Signature state from an XML element. + * @param {Element} value + * @returns void + */ + LoadXml(value: Element): void; + } + const XmlSignature: { + ElementNames: { + CanonicalizationMethod: string; + DigestMethod: string; + DigestValue: string; + DSAKeyValue: string; + EncryptedKey: string; + HMACOutputLength: string; + RSAPSSParams: string; + MaskGenerationFunction: string; + SaltLength: string; + KeyInfo: string; + KeyName: string; + KeyValue: string; + Modulus: string; + Exponent: string; + Manifest: string; + Object: string; + Reference: string; + RetrievalMethod: string; + RSAKeyValue: string; + ECKeyValue: string; + NamedCurve: string; + PublicKey: string; + Signature: string; + SignatureMethod: string; + SignatureValue: string; + SignedInfo: string; + Transform: string; + Transforms: string; + X509Data: string; + X509IssuerSerial: string; + X509IssuerName: string; + X509SerialNumber: string; + X509SKI: string; + X509SubjectName: string; + X509Certificate: string; + X509CRL: string; + }; + AttributeNames: { + Algorithm: string; + Encoding: string; + Id: string; + MimeType: string; + Type: string; + URI: string; + }; + AlgorithmNamespaces: { + XmlDsigBase64Transform: string; + XmlDsigC14NTransform: string; + XmlDsigC14NWithCommentsTransform: string; + XmlDsigEnvelopedSignatureTransform: string; + XmlDsigXPathTransform: string; + XmlDsigXsltTransform: string; + XmlDsigExcC14NTransform: string; + XmlDsigExcC14NWithCommentsTransform: string; + XmlDecryptionTransform: string; + XmlLicenseTransform: string; + }; + Uri: { + Manifest: string; + }; + NamespaceURI: string; + NamespaceURIMore: string; + NamespaceURIPss: string; + Prefix: string; + GetChildElement: (xel: Node, element: string, ns: string) => Element; + GetAttributeFromElement: (xel: Element, attribute: string, element: string) => string; + GetChildElements: (xel: Element, element: string) => Element[]; + }; + + /** + * The SignedInfo class represents the element + * of an XML signature defined by the XML digital signature specification + */ + class SignedInfo extends XmlObject { + + constructor(signedXml?: SignedXml); + /** + * Gets or sets the canonicalization algorithm that is used before signing + * for the current SignedInfo object. + */ + CanonicalizationMethod: string; + /** + * Gets a Transform object used for canonicalization. + * @returns Transform + */ + CanonicalizationMethodObject: Transform; + /** + * Gets the number of references in the current SignedInfo object. + */ + Count: number; + /** + * Gets or sets the ID of the current SignedInfo object. + */ + Id: string; + /** + * Gets a value that indicates whether the collection is read-only. + * @returns boolean + */ + IsReadOnly: boolean; + /** + * Gets a value that indicates whether the collection is synchronized. + * @returns boolean + */ + IsSynchronized: boolean; + /** + * Gets a list of the Reference objects of the current SignedInfo object. + */ + References: Reference[]; + /** + * Gets or sets the length of the signature for the current SignedInfo object. + */ + SignatureLength: string; + /** + * Gets or sets the name of the algorithm used for signature generation + * and validation for the current SignedInfo object. + */ + SignatureMethod: string; + SignatureParams: XmlObject; + /** + * Gets an object to use for synchronization. + */ + SyncRoot: any; + /** + * Adds a Reference object to the list of references to digest and sign. + * @param {Reference} reference The reference to add to the list of references. + * @returns void + */ + AddReference(reference: Reference): void; + /** + * Copies the elements of this instance into an Array object, starting at a specified index in the array. + * @param {any[]} array + * @param {number} index + * @returns void + */ + CopyTo(array: any[], index: number): void; + /** + * Returns the XML representation of the SignedInfo object. + * @returns Node + */ + GetXml(): Node; + /** + * Loads a SignedInfo state from an XML element. + * @param {Element} value + * @returns void + */ + LoadXml(value: Element): void; + } + + /** + * Provides a wrapper on a core XML signature object to facilitate creating XML signatures. + */ + class SignedXml extends XmlObject { + /** + * Gets or sets the KeyInfo object of the current SignedXml object. + */ + KeyInfo: KeyInfo; + /** + * Gets the Signature object of the current SignedXml object. + */ + Signature: Signature; + /** + * Gets or sets the prefix for the current SignedXml object. + */ + Prefix: string; + /** + * Gets the length of the signature for the current SignedXml object. + */ + SignatureLength: number; + SignatureMethod: string; + /** + * Gets the signature value of the current SignedXml object. + */ + SignatureValue: ArrayBuffer; + /** + * Gets the CanonicalizationMethod of the current SignedXml object. + */ + CanonicalizationMethod: string; + /** + * Gets the SignedInfo object of the current SignedXml object. + */ + SignedInfo: SignedInfo; + /** + * Gets or sets the asymmetric algorithm key used for signing a SignedXml object. + */ + SigningKey: CryptoKey; + /** + * Gets or sets the name of the installed key to be used for signing the SignedXml object. + */ + SigningKeyName: string; + /** + * @param {string} idMode. Value of "wssecurity" will create/validate id's with the ws-security namespace + */ + constructor(); + constructor(node: Document); + constructor(node: Element); + /** + * Adds a Reference object to the SignedXml object that describes a digest method, + * digest value, and transform to use for creating an XML digital signature. + * @param {Reference} reference The Reference object that describes a digest method, digest value, + * and transform to use for creating an XML digital signature. + * @returns void + */ + AddReference(reference: Reference): void; + /** + * Computes an XML digital signature using the specified algorithm. + * @param {Algorithm} algorithm Specified WebCrypto Algoriithm + * @returns Promise + */ + ComputeSignature(algorithm: Algorithm): Promise; + /** + * Determines whether the SignedXml.Signature property verifies using the public key in the signature. + * @returns Promise + */ + CheckSignature(): Promise; + CheckSignature(key: CryptoKey): Promise; + CheckSignature(cert: X509Certificate): Promise; + /** + * Loads a SignedXml state from an XML element. + * @param {Element} value The XML element to load the SignedXml state from. + * @returns void + */ + LoadXml(value: Element): void; + /** + * Returns the XML representation of a SignedXml object. + * @returns Element + */ + GetXml(): Element; + } +} From df611346ddf7a2a600e23fcd1e9fd3814769981a Mon Sep 17 00:00:00 2001 From: microshine Date: Mon, 9 May 2016 12:28:15 +0300 Subject: [PATCH 0005/1354] Add test & set version --- xadesjs/xadesjs-tests.ts | 47 ++++++++++++++++++++++++++++++++++++++++ xadesjs/xadesjs.d.ts | 10 +++++++++ 2 files changed, 57 insertions(+) create mode 100644 xadesjs/xadesjs-tests.ts diff --git a/xadesjs/xadesjs-tests.ts b/xadesjs/xadesjs-tests.ts new file mode 100644 index 0000000000..e83cb0cf6a --- /dev/null +++ b/xadesjs/xadesjs-tests.ts @@ -0,0 +1,47 @@ +/// + +let xmlString = ""; +let xmlDoc = new DOMParser().parseFromString(xmlString, "application/xml"); +let signedXml = new xadesjs.SignedXml(xmlDoc); + +let alg = { + name: "ECDSA", + namedCurve: "P-256" +}; +xadesjs.Application.crypto.subtle.generateKey( + alg, + false, + ["sign", "verify"] +) + .then((keys: CryptoKeyPair) => { + signedXml.SigningKey = keys.privateKey; + + // Add the key to the SignedXml document. + // Create a reference to be signed. + let reference = new xadesjs.Reference(); + reference.Uri = ""; + // Add an enveloped transformation to the reference. + reference.AddTransform(new xadesjs.XmlDsigEnvelopedSignatureTransform()); + // Add the reference to the SignedXml object. + signedXml.AddReference(reference); + // Set prefix for Signature namespace + signedXml.Prefix = "ds"; + + // Compute the signature. + return signedXml.ComputeSignature({ name: "ECDSA", hash: { name: "SHA-256" } } as any); + }) + .then(function () { + // Append signature + let xmlDigitalSignature = signedXml.GetXml(); + xmlDoc.documentElement.appendChild(xmlDigitalSignature); + + // Serialize XML document + let signedDocument = new XMLSerializer().serializeToString(xmlDoc); + return Promise.resolve(signedDocument); + }) + .then((doc: string) => { + console.log("Signed document:", doc); + }) + .catch((e) => { + console.error("Error", e); + }) \ No newline at end of file diff --git a/xadesjs/xadesjs.d.ts b/xadesjs/xadesjs.d.ts index 4eb7b6a1c5..9f89cab9f1 100644 --- a/xadesjs/xadesjs.d.ts +++ b/xadesjs/xadesjs.d.ts @@ -1,5 +1,15 @@ +// Type definitions for graphene-pk11 v2.0.0 +// Project: https://github.com/PeculiarVentures/graphene +// Definitions by: Stepan Miroshin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// +/** + * A pure Javascript implementation of XMLDSIG and XAdES based on Web Crypto https://xadesjs.com + * v1.0.0 + */ + declare namespace xadesjs { const APPLICATION_XML: string; From 7be1ff7f9e8a36bb368d580e018d4dafe47d0fa0 Mon Sep 17 00:00:00 2001 From: microshine Date: Mon, 9 May 2016 12:29:26 +0300 Subject: [PATCH 0006/1354] Fix def errors --- xadesjs/xadesjs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xadesjs/xadesjs.d.ts b/xadesjs/xadesjs.d.ts index 9f89cab9f1..fc7d1b4bd6 100644 --- a/xadesjs/xadesjs.d.ts +++ b/xadesjs/xadesjs.d.ts @@ -1,5 +1,5 @@ -// Type definitions for graphene-pk11 v2.0.0 -// Project: https://github.com/PeculiarVentures/graphene +// Type definitions for xadesjs v1.0.0 +// Project: https://github.com/PeculiarVentures/xadesjs // Definitions by: Stepan Miroshin // Definitions: https://github.com/borisyankov/DefinitelyTyped From 420c0d7ab551c4a938a32fabb11636d569c8a3d9 Mon Sep 17 00:00:00 2001 From: microshine Date: Mon, 9 May 2016 14:51:31 +0300 Subject: [PATCH 0007/1354] Change Promise to PromiseType --- xadesjs/promise.d.ts | 14 ----------- xadesjs/xadesjs.d.ts | 58 ++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 43 deletions(-) delete mode 100644 xadesjs/promise.d.ts diff --git a/xadesjs/promise.d.ts b/xadesjs/promise.d.ts deleted file mode 100644 index 96b926633b..0000000000 --- a/xadesjs/promise.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -interface PromiseFunc { - (resolve: (...args: any[]) => void, reject: (...args: any[]) => void): void; -} - -declare class Promise { - constructor(func: PromiseFunc); - - then(resolve: (...args: any[]) => any): Promise; - then(resolve: (...args: any[]) => any, reject: (...args: any[]) => any): Promise; - catch(reject: (...args: any[]) => any): void; - - static resolve(...args: any[]): Promise; - static reject(...args: any[]): Promise; -} \ No newline at end of file diff --git a/xadesjs/xadesjs.d.ts b/xadesjs/xadesjs.d.ts index fc7d1b4bd6..cad137db05 100644 --- a/xadesjs/xadesjs.d.ts +++ b/xadesjs/xadesjs.d.ts @@ -3,8 +3,6 @@ // Definitions by: Stepan Miroshin // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// - /** * A pure Javascript implementation of XMLDSIG and XAdES based on Web Crypto https://xadesjs.com * v1.0.0 @@ -12,6 +10,8 @@ declare namespace xadesjs { + type PromiseType = any; + const APPLICATION_XML: string; class XmlError extends Error { @@ -149,7 +149,7 @@ declare namespace xadesjs { getAlgorithmName(): string; } interface IHashAlgorithm extends IAlgorithm { - getHash(xml: string): Promise; + getHash(xml: string): PromiseType; } interface IHashAlgorithmConstructable { new (): IHashAlgorithm; @@ -160,11 +160,11 @@ declare namespace xadesjs { getAlgorithmName(): string; } abstract class HashAlgorithm extends XmlAlgorithm implements IHashAlgorithm { - getHash(xml: string): Promise; + getHash(xml: string): PromiseType; } interface ISignatureAlgorithm extends IAlgorithm { - getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise; - verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): Promise; + getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): PromiseType; + verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): PromiseType; } interface ISignatureAlgorithmConstructable { new (): ISignatureAlgorithm; @@ -173,11 +173,11 @@ declare namespace xadesjs { /** * Sign the given string using the given key */ - getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): Promise; + getSignature(signedInfo: string, signingKey: CryptoKey, algorithm: Algorithm): PromiseType; /** * Verify the given signature of the given string using key */ - verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): Promise; + verifySignature(signedInfo: string, key: CryptoKey, signatureValue: string, algorithm?: Algorithm): PromiseType; } const SHA1: string; @@ -368,9 +368,9 @@ declare namespace xadesjs { /** * Returns public key from X509Certificate * @param {Algorithm} algorithm - * @returns Promise + * @returns PromiseType */ - exportKey(algorithm: Algorithm): Promise; + exportKey(algorithm: Algorithm): PromiseType; } enum X509IncludeOption { @@ -395,13 +395,13 @@ declare namespace xadesjs { * Gets public key of the X509Data */ Key: CryptoKey; - importKey(key: CryptoKey): Promise; + importKey(key: CryptoKey): PromiseType; /** * Exports key from X509Data object * @param {Algorithm} alg - * @returns Promise + * @returns PromiseType */ - exportKey(alg: Algorithm): Promise; + exportKey(alg: Algorithm): PromiseType; /** * Gets a list of the X.509v3 certificates contained in the KeyInfoX509Data object. */ @@ -492,15 +492,15 @@ declare namespace xadesjs { /** * Imports key to the RSAKeyValue object * @param {CryptoKey} key - * @returns Promise + * @returns PromiseType */ - importKey(key: CryptoKey): Promise; + importKey(key: CryptoKey): PromiseType; /** * Exports key from the RSAKeyValue object * @param {Algorithm} alg - * @returns Promise + * @returns PromiseType */ - exportKey(alg: Algorithm): Promise; + exportKey(alg: Algorithm): PromiseType; /** * Returns the XML representation of the RSA key clause. * @returns Element @@ -552,15 +552,15 @@ declare namespace xadesjs { /** * Imports key to the ECKeyValue object * @param {CryptoKey} key - * @returns Promise + * @returns PromiseType */ - importKey(key: CryptoKey): Promise; + importKey(key: CryptoKey): PromiseType; /** * Exports key from the ECKeyValue object * @param {Algorithm} alg - * @returns Promise + * @returns PromiseType */ - exportKey(alg: Algorithm): Promise; + exportKey(alg: Algorithm): PromiseType; /** * Returns the XML representation of the ECDSA key clause. * @returns Element @@ -804,8 +804,8 @@ declare namespace xadesjs { } interface KeyInfoClause extends IXmlSerializable { Key: CryptoKey; - importKey(key: CryptoKey): Promise; - exportKey(alg: Algorithm): Promise; + importKey(key: CryptoKey): PromiseType; + exportKey(alg: Algorithm): PromiseType; } /** @@ -1060,16 +1060,16 @@ declare namespace xadesjs { /** * Computes an XML digital signature using the specified algorithm. * @param {Algorithm} algorithm Specified WebCrypto Algoriithm - * @returns Promise + * @returns PromiseType */ - ComputeSignature(algorithm: Algorithm): Promise; + ComputeSignature(algorithm: Algorithm): PromiseType; /** * Determines whether the SignedXml.Signature property verifies using the public key in the signature. - * @returns Promise + * @returns PromiseType */ - CheckSignature(): Promise; - CheckSignature(key: CryptoKey): Promise; - CheckSignature(cert: X509Certificate): Promise; + CheckSignature(): PromiseType; + CheckSignature(key: CryptoKey): PromiseType; + CheckSignature(cert: X509Certificate): PromiseType; /** * Loads a SignedXml state from an XML element. * @param {Element} value The XML element to load the SignedXml state from. From 2847bd521629b85a94dca5d74a8c74ea49952a3f Mon Sep 17 00:00:00 2001 From: microshine Date: Mon, 9 May 2016 15:29:18 +0300 Subject: [PATCH 0008/1354] Fix test error --- xadesjs/xadesjs-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xadesjs/xadesjs-tests.ts b/xadesjs/xadesjs-tests.ts index e83cb0cf6a..e36f903945 100644 --- a/xadesjs/xadesjs-tests.ts +++ b/xadesjs/xadesjs-tests.ts @@ -42,6 +42,6 @@ xadesjs.Application.crypto.subtle.generateKey( .then((doc: string) => { console.log("Signed document:", doc); }) - .catch((e) => { + .catch((e: any) => { console.error("Error", e); - }) \ No newline at end of file + }); \ No newline at end of file From 4e00b9e8dc11eef0b7ef4bd2f1bbfb91f3e2cc2f Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Thu, 12 May 2016 22:24:49 +0100 Subject: [PATCH 0009/1354] Update to version 2.20.4 Update methods from node-validator (https://github.com/chriso/validator.js) and update express-validator methods to adhere to the latest api. --- express-validator/express-validator-tests.ts | 14 +- express-validator/express-validator.d.ts | 136 ++++++++++++------- 2 files changed, 99 insertions(+), 51 deletions(-) diff --git a/express-validator/express-validator-tests.ts b/express-validator/express-validator-tests.ts index 74bd277e46..ebd61d6cfc 100644 --- a/express-validator/express-validator-tests.ts +++ b/express-validator/express-validator-tests.ts @@ -15,19 +15,23 @@ app.post('/:urlparam', function(req: express.Request, res: express.Response) { // Similarly checkParams only checks in req.params (URL params) and // checkQuery only checks req.query (GET params). req.checkBody('postparam', 'Invalid postparam').notEmpty().isInt(); - req.checkParams('urlparam', 'Invalid urlparam').isAlpha(); + req.checkParams('urlparam', 'Invalid urlparam').isAlpha().matches(/test?/i).matches('test?', 'i'); req.checkQuery('getparam', 'Invalid getparam').isInt(); - req.checkHeader('testHeader', 'Invalid testHeader').isLowercase().isUppercase(); - req.checkFiles('testFiles', 'Invalid testFiles').isUrl(); - + req.checkHeaders('testHeader', 'Invalid testHeader').isLowercase().isUppercase(); + req.checkFiles('testFiles', 'Invalid testFiles').isURL(); // OR assert can be used to check on all 3 types of params. // req.assert('postparam', 'Invalid postparam').notEmpty().isInt(); // req.assert('urlparam', 'Invalid urlparam').isAlpha(); // req.assert('getparam', 'Invalid getparam').isInt(); - req.sanitize('postparam').toBoolean(); req.filter('postparam').toBoolean(); + req.sanitize('postparam').blacklist('t').blacklist(['']).whitelist('hello').whitelist(['h', 'e', 'l']); + req.sanitizeBody('postvar').trim().stripLow().escape(); + req.sanitizeQuery('queryvar').toDate(); + req.sanitizeParams('urlparam').toFloat().toInt().toInt(10); + req.sanitizeHeaders('header').normalizeEmail(); + var errors = req.validationErrors(); var mappedErrors = req.validationErrors(true); diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index 52792a391f..cb15aebf8f 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -1,9 +1,10 @@ -// Type definitions for express-validator 2.9.0 +// Type definitions for express-validator 2.20.4 // Project: https://github.com/ctavan/express-validator -// Definitions by: Nathan Ridley , Jonathan Häberle +// Definitions by: Nathan Ridley , Jonathan Häberle , Peter Harris // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +/// // Add RequestValidation Interface on to Express's Request Interface. declare namespace Express { @@ -31,25 +32,33 @@ declare namespace ExpressValidator { param: string; } - interface ValidatorFunction { (item: string, message: string): Validator; } + interface ValidatorFunction { (item: string | {}, message?: string): Validator; } + interface ValidatorExtraFunction extends ValidatorFunction { (matchIndex: number, message?: string): Validator; }; interface SanitizerFunction { (item: string): Sanitizer; } interface Dictionary { [key: string]: T; } export interface RequestValidation { - assert: ValidatorFunction; - check: ValidatorFunction; + assert: ValidatorExtraFunction; + validate: ValidatorExtraFunction; + check: ValidatorExtraFunction; checkBody: ValidatorFunction; checkFiles: ValidatorFunction; - checkHeader: ValidatorFunction; + checkHeaders: ValidatorFunction; checkParams: ValidatorFunction; checkQuery: ValidatorFunction; - validate: ValidatorFunction; - + filter: SanitizerFunction; sanitize: SanitizerFunction; - + sanitizeBody: SanitizerFunction; + sanitizeQuery: SanitizerFunction; + sanitizeParams: SanitizerFunction; + sanitizeHeaders: SanitizerFunction; + onValidationError(errback: (msg: string) => void): void; - validationErrors(mapped?: boolean): Dictionary | any[]; + validationErrors(mapped?: boolean): Dictionary | MappedError[]; + validationErrors(mapped?: boolean): Dictionary | T[]; + asyncValidationErrors(mapped?: boolean): Promise>; + asyncValidationErrors(mapped?: boolean): Promise>; } export interface Validator { @@ -61,12 +70,13 @@ declare namespace ExpressValidator { * Alias for notRegex() */ not(): Validator; - isEmail(): Validator; + isEmail(options?:{}): Validator; /** * Accepts http, https, ftp */ - isUrl(): Validator; - + isURL(): Validator; + isFQDN(options?: MinMaxOptions): Validator; + /** * Combines isIPv4 and isIPv6 */ @@ -74,8 +84,21 @@ declare namespace ExpressValidator { isIPv4(): Validator; isIPv6(): Validator; isMACAddress(): Validator; - isAlpha(): Validator; - isAlphanumeric(): Validator; + isISBN(version?: number): Validator; + isISIN(): Validator; + isISO8601(): Validator; + isMobilePhone(locale: string): Validator; + isMongoId(): Validator; + isMultibyte(): Validator; + isAlpha(locale?: string): Validator; + isAlphanumeric(locale?: string): Validator; + isAscii(): Validator; + isBase64(): Validator; + isBoolean(): Validator; + isByteLength(options: MinMaxOptions): Validator; + isCurrency(options: {}): Validator; + isDataURI(): Validator; + isDivisibleBy(num: number): Validator; isNumeric(): Validator; isHexadecimal(): Validator; /** @@ -85,7 +108,7 @@ declare namespace ExpressValidator { /** * isNumeric accepts zero padded numbers, e.g. '001', isInt doesn't */ - isInt(): Validator; + isInt(options?: MinMaxOptions): Validator; isLowercase(): Validator; isUppercase(): Validator; isDecimal(): Validator; @@ -93,10 +116,13 @@ declare namespace ExpressValidator { * Alias for isDecimal */ isFloat(): Validator; + isFullWidth(): Validator; + isHalfWidth(): Validator; + isVariableWidth(): Validator; /** * Check if length is 0 */ - notNull(): Validator; + //notNull(): Validator; // I don't see this in the documentation or code anywhere. isNull(): Validator; /** * Not just whitespace (input.trim().length !== 0) @@ -104,12 +130,14 @@ declare namespace ExpressValidator { notEmpty(): Validator; equals(equals:any): Validator; contains(str:string): Validator; - notContains(str:string): Validator; + //notContains(str:string): Validator; // I don't see this in the documentation or code anywhere. + matches(pattern:string, modifiers?:string): Validator; + matches(pattern: RegExp): Validator; /** * Usage: regex(/[a-z]/i) or regex('[a-z]','i') */ - regex(pattern:string, modifiers:string): Validator; - notRegex(pattern:string, modifiers:string): Validator; + //regex(pattern:string, modifiers:string): Validator; // I don't see this in the documentation or code anywhere. + //notRegex(pattern:string, modifiers:string): Validator; // I don't see this in the documentation or code anywhere. /** * max is optional */ @@ -117,7 +145,7 @@ declare namespace ExpressValidator { /** * Version can be 3, 4 or 5 or empty, see http://en.wikipedia.org/wiki/Universally_unique_identifier */ - isUUID(version:number): Validator; + isUUID(version?:number): Validator; /** * Alias for isUUID(3) */ @@ -137,17 +165,20 @@ declare namespace ExpressValidator { /** * Argument is optional and defaults to today. Comparison is non-inclusive */ - isAfter(date:Date): Validator; + isAfter(date?:Date): Validator; /** * Argument is optional and defaults to today. Comparison is non-inclusive */ - isBefore(date:Date): Validator; + isBefore(date?:Date): Validator; isIn(options:string): Validator; isIn(options:string[]): Validator; notIn(options:string): Validator; notIn(options:string[]): Validator; max(val:string): Validator; min(val:string): Validator; + isJSON(): Validator; + isLength(options: MinMaxOptions): Validator; + isWhitelisted(chars: string); /** * Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats */ @@ -155,7 +186,10 @@ declare namespace ExpressValidator { /** * Check an input only when the input exists */ - optional(): Validator; + isSurrogatePar(): Validator; + + optional(options?: { checkFalsy?: boolean }): Validator; + withMessage(message: string): Validator; } interface Sanitizer { @@ -165,40 +199,50 @@ declare namespace ExpressValidator { trim(...chars:string[]): Sanitizer; ltrim(...chars:string[]): Sanitizer; rtrim(...chars:string[]): Sanitizer; - ifNull(replace:any): Sanitizer; + stripLow(keep_new_lines?: boolean): Sanitizer; + //ifNull(replace:any): Sanitizer; // I don't see this in the documentation or code anywhere. toFloat(): Sanitizer; - toInt(): Sanitizer; + toInt(radix?: number): Sanitizer; /** - * True unless str = '0', 'false', or str.length == 0 - */ - toBoolean(): Sanitizer; - /** - * False unless str = '1' or 'true' - */ - toBooleanStrict(): Sanitizer; - /** - * Decode HTML entities + * True unless str = '0', 'false', or str.length == 0. In strict mode only '1' and 'true' return true. */ + toBoolean(strict?: boolean): Sanitizer; /** - * Convert the input string to a date, or null if the input is not a date. - */ - toDate(): Sanitizer; - - entityDecode(): Sanitizer; - entityEncode(): Sanitizer; + * Convert the input string to a date, or null if the input is not a date. + */ + toDate(): Sanitizer; + /** * Escape &, <, >, and " */ escape(): Sanitizer; + /** - * Remove common XSS attack vectors from user-supplied HTML + * Replaces HTML encoded entities with <, >, &, ', " and /. */ - xss(): Sanitizer; + unescape(): Sanitizer; + + blacklist(chars: string): Sanitizer; + blacklist(chars: string[]): Sanitizer; + whitelist(chars: string): Sanitizer; + whitelist(chars: string[]): Sanitizer; + + normalizeEmail(options?: { lowercase?: boolean; remove_dots?: boolean; remove_extensions?: boolean }): Sanitizer; + /** - * Remove common XSS attack vectors from images + * !!! XSS sanitization was removed from the library (see: https://github.com/chriso/validator.js#xss-sanitization) */ - xss(fromImages:boolean): Sanitizer; } - + + interface MappedError { + param: string; + msg: string; + value: string; + } + + interface MinMaxOptions { + min?: number; + max?: number; + } } From 396e37eb8b17cace44ba2bce0f2aa59a88d17fd0 Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Thu, 12 May 2016 22:38:26 +0100 Subject: [PATCH 0010/1354] Remove ambient semicolon --- express-validator/express-validator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index cb15aebf8f..583ffbf6e8 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -33,7 +33,7 @@ declare namespace ExpressValidator { } interface ValidatorFunction { (item: string | {}, message?: string): Validator; } - interface ValidatorExtraFunction extends ValidatorFunction { (matchIndex: number, message?: string): Validator; }; + interface ValidatorExtraFunction extends ValidatorFunction { (matchIndex: number, message?: string): Validator; } interface SanitizerFunction { (item: string): Sanitizer; } interface Dictionary { [key: string]: T; } From 10bc473fe57df9c5acb2926faf785ece99beb37f Mon Sep 17 00:00:00 2001 From: CodeAnimal Date: Thu, 12 May 2016 22:44:39 +0100 Subject: [PATCH 0011/1354] Add return type to isWhitelisted method. --- express-validator/express-validator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/express-validator/express-validator.d.ts b/express-validator/express-validator.d.ts index 583ffbf6e8..71797efce2 100644 --- a/express-validator/express-validator.d.ts +++ b/express-validator/express-validator.d.ts @@ -178,7 +178,7 @@ declare namespace ExpressValidator { min(val:string): Validator; isJSON(): Validator; isLength(options: MinMaxOptions): Validator; - isWhitelisted(chars: string); + isWhitelisted(chars: string): Validator; /** * Will work against Visa, MasterCard, American Express, Discover, Diners Club, and JCB card numbering formats */ From c59c139444477fda75df8541cd8c7bcb5c93ec5b Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:16:47 +0200 Subject: [PATCH 0012/1354] Implemented Amplitude SDK type definition. --- amplitude/amplitude-tests.ts | 85 ++++++++++++++++++++++++++++++++++++ amplitude/amplitude.d.ts | 58 ++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 amplitude/amplitude-tests.ts create mode 100644 amplitude/amplitude.d.ts diff --git a/amplitude/amplitude-tests.ts b/amplitude/amplitude-tests.ts new file mode 100644 index 0000000000..c4ffb9e811 --- /dev/null +++ b/amplitude/amplitude-tests.ts @@ -0,0 +1,85 @@ +/// + +module Amplitude.Tests { + function all() { + amplitude.init('YOUR_API_KEY_HERE', null, { + // optional configuration options + saveEvents: true, + includeUtm: true, + includeReferrer: true, + batchEvents: true, + eventUploadThreshold: 50 + }); + amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {}); + + amplitude.logEvent('EVENT_IDENTIFIER_HERE'); + amplitude.setUserId('USER_ID_HERE'); + amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE'); + amplitude.setUserId(null); // not string 'null' + amplitude.setVersionName('VERSION_NAME_HERE'); + + amplitude.regenerateDeviceId(); + amplitude.setDeviceId('CUSTOM_DEVICE_ID'); + + amplitude.logEvent('EVENT_IDENTIFIER_HERE', { + 'color': 'blue', + 'age': 20, + 'key': 'value' + }); + amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { }); + + let identify = new amplitude.Identify().set('gender', 'female').set('age', 20); + amplitude.identify(identify); + + identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015'); + amplitude.identify(identify); + + identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015'); + amplitude.identify(identify); + + identify = new amplitude.Identify().unset('gender').unset('age'); + amplitude.identify(identify); + + identify = new amplitude.Identify().add('karma', 1).add('friends', 1); + amplitude.identify(identify); + + identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']); + amplitude.identify(identify); + + identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']); + amplitude.identify(identify); + + identify = new amplitude.Identify() + .set('karma', 10) + .add('karma', 1) + .unset('karma'); + amplitude.identify(identify); + + identify = new amplitude.Identify() + .set('colors', ['rose', 'gold']) + .append('ab-tests', 'campaign_a') + .append('existing_list', [4, 5]); + amplitude.identify(identify); + + amplitude.setUserProperties({ + gender: 'female', + age: 20 + }); + + amplitude.clearUserProperties(); + + amplitude.setOptOut(true); + amplitude.setOptOut(false); + + amplitude.setGroup('orgId', '15'); + amplitude.setGroup('sport', ['soccer', 'tennis']); + + // Still to implement: + /* + var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3); + amplitude.logRevenueV2(revenue); + + amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' }); + */ + } +} diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts new file mode 100644 index 0000000000..339153634d --- /dev/null +++ b/amplitude/amplitude.d.ts @@ -0,0 +1,58 @@ +declare module amplitude { + interface Config { + batchEvents?: boolean; + cookieExpiration?: number; + cookieName?: string; + deviceId?: string; + domain?: string; + eventUploadPeriodMillis?: number; + eventUploadThreshold?: number; + includeReferrer?: boolean; + includeUtm?: boolean; + language?: string; + optOut?: boolean; + platform?: string; + saveEvents?: boolean; + savedMaxCount?: number; + sessionTimeout?: number; + uploadBatchSize?: number; + } + + export class Identify { + set(key: string, value: any): Identify; + setOnce(key: string, value: any): Identify; + add(key: string, value: number): Identify; + append(key: string, value: any): Identify; + prepend(key: string, value: any): Identify; + + unset(key: string): Identify; + } + + export function init(apiKey: string): void; + export function init(apiKey: string, userId: string): void; + export function init(apiKey: string, userId: string, options: Config): void; + export function init(apiKey: string, userId: string, options: Config, callback: () => void): void; + + export function setVersionName(version: string): void; + export function setUserId(userId: string): void; + + export function setDeviceId(id: string): void; + export function regenerateDeviceId(): void; + + export function identify(identify: Identify): void; + + export function setUserProperties(properties: Object): void; + export function clearUserProperties(): void; + + export function setOptOut(optOut: boolean): void; + + export function setGroup(groupType: string, groupName: string | string[]); + + export function logEvent(event: string): void; + export function logEvent(event: string, data: Object): void; + export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void; + + export var options: Config; +} + +//declare var amplitude: AmplitudeStatic; From 9a055b462ad6465f999facbd3b7013e564bebfc2 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:37:31 +0200 Subject: [PATCH 0013/1354] Added required header comments to amplitude definition files. --- amplitude/amplitude-tests.ts | 2 ++ amplitude/amplitude.d.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/amplitude/amplitude-tests.ts b/amplitude/amplitude-tests.ts index c4ffb9e811..d60cf4bc7b 100644 --- a/amplitude/amplitude-tests.ts +++ b/amplitude/amplitude-tests.ts @@ -1,3 +1,5 @@ +// Tests for Amplitude SDK TypeScript definitions + /// module Amplitude.Tests { diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts index 339153634d..3955ae128a 100644 --- a/amplitude/amplitude.d.ts +++ b/amplitude/amplitude.d.ts @@ -1,3 +1,5 @@ +// Type definitions for Amplitude SDK 2.12.1 + declare module amplitude { interface Config { batchEvents?: boolean; From ed54ec0de6b1ef627fcfd9382ae1e91c9aa97180 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:38:02 +0200 Subject: [PATCH 0014/1354] amplitude.setGroup() return value is now void instead instead of implicit any. --- amplitude/amplitude.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts index 3955ae128a..d3ad99c890 100644 --- a/amplitude/amplitude.d.ts +++ b/amplitude/amplitude.d.ts @@ -48,7 +48,7 @@ declare module amplitude { export function setOptOut(optOut: boolean): void; - export function setGroup(groupType: string, groupName: string | string[]); + export function setGroup(groupType: string, groupName: string | string[]): void; export function logEvent(event: string): void; export function logEvent(event: string, data: Object): void; From 6b5953e8d06043c69d3be715cef78ba278827503 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:40:29 +0200 Subject: [PATCH 0015/1354] Added required 'Project' comment to amplitude definition file header. --- amplitude/amplitude.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts index d3ad99c890..b8b208bcdd 100644 --- a/amplitude/amplitude.d.ts +++ b/amplitude/amplitude.d.ts @@ -1,4 +1,5 @@ // Type definitions for Amplitude SDK 2.12.1 +// Project: https://github.com/amplitude/Amplitude-Javascript declare module amplitude { interface Config { From 233b6e31fe562202a1c08a3eb23635350ab672fe Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:43:33 +0200 Subject: [PATCH 0016/1354] Added required 'Definitions by' comment to amplitude definition file header. --- amplitude/amplitude.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts index b8b208bcdd..0e2c392e64 100644 --- a/amplitude/amplitude.d.ts +++ b/amplitude/amplitude.d.ts @@ -1,5 +1,6 @@ // Type definitions for Amplitude SDK 2.12.1 // Project: https://github.com/amplitude/Amplitude-Javascript +// Definitions by: Arvydas Sidorenko declare module amplitude { interface Config { From 759ae4713b69d6b96825c839472c0bf6c79662aa Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Sun, 22 May 2016 13:48:53 +0200 Subject: [PATCH 0017/1354] Added required 'Definitions' comment to amplitude definition file header. --- amplitude/amplitude.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/amplitude/amplitude.d.ts b/amplitude/amplitude.d.ts index 0e2c392e64..9a5df3d179 100644 --- a/amplitude/amplitude.d.ts +++ b/amplitude/amplitude.d.ts @@ -1,6 +1,7 @@ // Type definitions for Amplitude SDK 2.12.1 // Project: https://github.com/amplitude/Amplitude-Javascript // Definitions by: Arvydas Sidorenko +// Definitions: https://github.com/Asido/DefinitelyTyped declare module amplitude { interface Config { From beb9814807ffec927b1ef4eb74c735296ab33a63 Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Mon, 30 May 2016 10:11:37 +0200 Subject: [PATCH 0018/1354] Renamed amplitude to amplitude-js. --- .../amplitude-tests.ts => amplitude-js/amplitude-js-tests.ts | 4 ++-- amplitude/amplitude.d.ts => amplitude-js/amplitude-js.d.ts | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename amplitude/amplitude-tests.ts => amplitude-js/amplitude-js-tests.ts (97%) rename amplitude/amplitude.d.ts => amplitude-js/amplitude-js.d.ts (100%) diff --git a/amplitude/amplitude-tests.ts b/amplitude-js/amplitude-js-tests.ts similarity index 97% rename from amplitude/amplitude-tests.ts rename to amplitude-js/amplitude-js-tests.ts index d60cf4bc7b..66285f10dd 100644 --- a/amplitude/amplitude-tests.ts +++ b/amplitude-js/amplitude-js-tests.ts @@ -1,6 +1,6 @@ // Tests for Amplitude SDK TypeScript definitions -/// +/// module Amplitude.Tests { function all() { @@ -76,7 +76,7 @@ module Amplitude.Tests { amplitude.setGroup('orgId', '15'); amplitude.setGroup('sport', ['soccer', 'tennis']); - // Still to implement: + // TODO: Implement those. /* var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3); amplitude.logRevenueV2(revenue); diff --git a/amplitude/amplitude.d.ts b/amplitude-js/amplitude-js.d.ts similarity index 100% rename from amplitude/amplitude.d.ts rename to amplitude-js/amplitude-js.d.ts From 7cdeddfc0dc5188cafde9f2ff2e97f574028030e Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 19:26:06 +0200 Subject: [PATCH 0019/1354] Create chart2.d.ts Chart JS library has been updated to version 2.0 although no one has yet created the proper definitions files. For this reason I propose my file while being aware that still needs lots of work. In addition to the usual bug there are shortcomings in the definition of many functions, as the official guide does not specify the parameter's types. in the hope that this can help someone. --- chartjs/chart2.d.ts | 392 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 chartjs/chart2.d.ts diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts new file mode 100644 index 0000000000..7ae02a6ebf --- /dev/null +++ b/chartjs/chart2.d.ts @@ -0,0 +1,392 @@ +/* TYPES */ +declare enum ChartType { + line, bar, radar, doughnut, polarArea, bubble +} +declare enum TimeUnit { + millisecond, second, minute, + hour, day, week, + month, quarter, year +} +interface ChartLegendItem { + text?: string; + fillStyle?: string; + hidden?: boolean; + lineCap?: string; + lineDash?: number[]; + lineDashOffset?: number; + lineJoin?: string; + lineWidth?: number; + strokeStyle?: string; +} +interface ChartTooltipItem { + xLabel?: string; + yLabel?: string; + datasetIndex?: number; + index?: number; +} +interface ChartTooltipCallback { + beforeTitle?: (item?: ChartTooltipItem[], data?: any) => void; + title?: (item?: ChartTooltipItem[], data?: any) => void; + afterTitle?: (item?: ChartTooltipItem[], data?: any) => void; + beforeBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + label?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeFooter?: (item?: ChartTooltipItem[], data?: any) => void; + footer?: (item?: ChartTooltipItem[], data?: any) => void; + afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; +} +interface ChartAnimationParameter { + chartInstance?: any; + animationObject?: any; +} +interface ChartPoint { + x?: number; + y?: number; +} + +/* END */ + +/* Configuration */ +interface ChartConfiguration { + type?: string; + data?: ChartData; + options?: ChartOptions; +} + +/* END */ + +/* DATA */ +interface ChartData { + +} + +interface LinearChartData extends ChartData { + labels?: string[]; + datasets?: ChartDataSets[]; +} + +/* END */ + +/* Options */ +interface ChartOptions { + responsive?: boolean; + responsiveAnimationDuration?: number; + maintainAspectRatio?: boolean; + events?: string[]; + onClick?: (any?: any) => any; + title?: ChartTitleOptions; + legend?: ChartLegendOptions; + tooltip?: ChartTooltipOptions; + hover?: ChartHoverOptions; + animation?: ChartAnimationOptions; + elements?: ChartElementsOptions; + scales?: ChartScales; +} + +interface ChartFontOptions { + defaultFontColor?: string; + defaultFontFamily?: string; + defaultFontSize?: number; + defaultFontStyle?: string; +} + +interface ChartTitleOptions { + display?: boolean; + position?: string; + fullWdith?: boolean; + fontSize?: number; + fontFamily?: string; + fontColor?: string; + fontStyle?: string; + padding?: number; + text?: string; +} + +interface ChartLegendOptions { + display?: boolean; + position?: string; + fullWidth?: boolean; + onClick?: (event, legendItem) => void; + labels?: ChartLegendLabelOptions; +} + +interface ChartLegendLabelOptions { + boxWidth?: number; + fontSize?: number; + fontStyle?: number; + fontColor?: string; + fontFamily?: string; + padding?: number; + generateLabels?: (chart) => any; +} + +interface ChartTooltipOptions { + enabled?: boolean; + custom?: (a) => void; + mode?: string; + backgroundColor?: string; + titleFontFamily?: string; + titleFontSize?: number; + titleFontStyle?: string; + titleFontColor?: string; + titleSpacing?: number; + titleMarginBottom?: number; + bodyFontFamily?: string; + bodyFontSize?: number; + bodyFontStyle?: string; + bodyFontColor?: string; + bodySpacing?: number; + footerFontFamily?: string; + footerFontSize?: number; + footerFontStyle?: string; + footerFontColor?: string; + footerSpacing?: number; + footerMarginTop?: number; + xPadding?: number; + yPadding?: number; + caretSize?: number; + cornerRadius?: number; + multiKeyBackground?: string; + callbacks?: ChartTooltipCallback; +} + +interface ChartHoverOptions { + mode?: string; + animationDuration?: number; + onHover?: (active) => void; +} + +interface ChartAnimationObject { + currentStep?: number; + numSteps?: number; + easing?: string; + render?: (arg) => void; + onAnimationProgress?: (arg) => void; + onAnimationComplete?: (arg) => void; +} + +interface ChartAnimationOptions { + duration?: number; + easing?: string; + onProgress?: (chart) => void; + onComplete?: (chart) => void; +} + +interface ChartElementsOptions { + point?: ChartPointOptions; + line?: ChartLineOptions; + arg?: ChartArcOtpions; + rectangle?: ChartRectangleOptions; +} + +interface ChartArcOtpions { + backgroundColor?: string; + borderColor?: string; + borderWidth?: number; +} + +interface ChartLineOptions { + tension?: number; + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + borderCapStyle?: string; + borderDash?: any[]; + borderDashOffset?: number; + borderJoinStyle?: string; +} + +interface ChartPointOptions { + radius?: number; + pointStyle?: string; + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + hitRadius?: number; + hoverRadius?: number; + hoverBorderWidth?: number; +} + +interface ChartRectangleOptions { + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + borderSkipped?: string; +} +interface GridLineOptions { + display?: boolean; + color?: string; + lineWidth?: number; + drawBorder?: boolean; + drawOnChartArea?: boolean; + drawticks?: boolean; + tickMarkLength?: number; + zeroLineWidth?: number; + zeroLineColor?: string; + offsetGridLines?: boolean; +} + +interface ScaleTitleOptions { + display?: boolean; + labelString?: string; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; +} + +interface TickOptions { + autoSkip?: boolean; + callback?: (value, index, values) => string; + display?: boolean; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; + labelOffset?: number; + maxRotation?: number; + minRotation?: number; + mirror?: boolean; + padding?: number; + reverse?: boolean; + min?: any; + max?: any; +} +interface AngleLineOptions { + display?: boolean; + color?: string; + lineWidth?: number; +} + +interface PointLabelOptions { + callback?: (arg) => any; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; +} + +interface TickOptions { + backdropColor?: string; + backdropPaddingX?: number; + backdropPaddingY?: number; + maxTicksLimit?: number; + showLabelBackdrop?: boolean; +} +interface LinearTickOptions extends TickOptions { + beginAtZero?: boolean; + min?: number; + max?: number; + maxTicksLimit?: number; + stepSize?: number; + suggestedMin?: number; + suggestedMax?: number; +} + +interface LogarithmicTickOptions extends TickOptions { + min?: number; + max?: number; +} +/* END */ + +/* DATASETS */ +interface ChartDataSets { + backgroundColor?: string[]; + borderWidth?: number; + borderColor?: string[]; + borderCapStyle?: string; + borderDash?: number[]; + borderDashOffset?: number; + borderJoinStyle?: string; + data?: number[] | ChartPoint[]; + fill?: boolean; + label?: string; + lineTension?: number; + pointBorderColor?: string | string[]; + pointBackgroundColor?: string | string[]; + pointBorderWidth?: number | number[]; + pointRadius?: number | number[]; + pointHoverRadius?: number | number[]; + pointHitRadius?: number | number[]; + pointHoverBackgroundColor?: string | string[]; + pointHoverBorderColor?: string | string[]; + pointHoverBorderWidth?: number | number[]; + pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; + xAxisID?: string; + yAxisID?: string; +} +/* END */ + +/* SCALES */ +interface ChartScales { + type?: string; + display?: boolean; + position?: string; + beforeUpdate?: (scale?: any) => void; + beforeSetDimension?: (scale?: any) => void; + beforeDataLimits?: (scale?: any) => void; + beforeBuildTicks?: (scale?: any) => void; + beforeTickToLabelConversion?: (scale?: any) => void; + beforeCalculateTickRotation?: (scale?: any) => void; + beforeFit?: (scale?: any) => void; + afterUpdate?: (scale?: any) => void; + afterSetDimension?: (scale?: any) => void; + afterDataLimits?: (scale?: any) => void; + afterBuildTicks?: (scale?: any) => void; + afterTickToLabelConversion?: (scale?: any) => void; + afterCalculateTickRotation?: (scale?: any) => void; + afterFit?: (scale?: any) => void; + gridLines?: GridLineOptions; + scaleLabel?: ScaleTitleOptions; + ticks?: TickOptions; +} + +interface LinearScale extends ChartScales { + ticks?: LinearTickOptions; +} + + +interface LogarithmicScale extends ChartScales { + ticks?: LogarithmicTickOptions; +} + +interface TimeScale extends ChartScales { + displayFormats?: string; + isoWeekday?: boolean; + max?: string; + min?: string; + parser?: string | ((arg) => moment.MomentDateObject); + round?: string; + tooltipFormat?: string; + unit?: TimeUnit; + unitStepSize?: number; +} + +interface RadialLinearScale { + lineArc?: boolean; + angleLines?: AngleLineOptions; + pointLabels?: PointLabelOptions; + ticks?: TickOptions; +} +/* END */ + +declare var Chart: { + new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; + destroy: () => {}; + update: (duration, lazy) => {}; + render: (duration, lazy) => {}; + stop: () => {}; + resize: () => {}; + clear: () => {}; + toBase64: () => string; + generateLegend: () => {}; + getElementAtEvent: (e) => {}; + getElementsAtEvent: (e) => {}[]; + getDatasetAtEvent: (e) => {}[]; + + defaults: { + global: ChartOptions; + } +}; From 160f9f51a0662505e1671e87492097db9aedd1c3 Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 20:36:25 +0200 Subject: [PATCH 0020/1354] Update chart2.d.ts --- chartjs/chart2.d.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index 7ae02a6ebf..f80e8d9897 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -108,7 +108,7 @@ interface ChartLegendOptions { display?: boolean; position?: string; fullWidth?: boolean; - onClick?: (event, legendItem) => void; + onClick?: (event: any, legendItem: any) => void; labels?: ChartLegendLabelOptions; } @@ -119,12 +119,12 @@ interface ChartLegendLabelOptions { fontColor?: string; fontFamily?: string; padding?: number; - generateLabels?: (chart) => any; + generateLabels?: (chart: any) => any; } interface ChartTooltipOptions { enabled?: boolean; - custom?: (a) => void; + custom?: (a: any) => void; mode?: string; backgroundColor?: string; titleFontFamily?: string; @@ -155,23 +155,23 @@ interface ChartTooltipOptions { interface ChartHoverOptions { mode?: string; animationDuration?: number; - onHover?: (active) => void; + onHover?: (active: any) => void; } interface ChartAnimationObject { currentStep?: number; numSteps?: number; easing?: string; - render?: (arg) => void; - onAnimationProgress?: (arg) => void; - onAnimationComplete?: (arg) => void; + render?: (arg: any) => void; + onAnimationProgress?: (arg: any) => void; + onAnimationComplete?: (arg: any) => void; } interface ChartAnimationOptions { duration?: number; easing?: string; - onProgress?: (chart) => void; - onComplete?: (chart) => void; + onProgress?: (chart: any) => void; + onComplete?: (chart: any) => void; } interface ChartElementsOptions { @@ -239,7 +239,7 @@ interface ScaleTitleOptions { interface TickOptions { autoSkip?: boolean; - callback?: (value, index, values) => string; + callback?: (value: any, index: any, values: any) => string; display?: boolean; fontColor?: string; fontFamily?: string; @@ -261,7 +261,7 @@ interface AngleLineOptions { } interface PointLabelOptions { - callback?: (arg) => any; + callback?: (arg: any) => any; fontColor?: string; fontFamily?: string; fontSize?: number; @@ -357,7 +357,7 @@ interface TimeScale extends ChartScales { isoWeekday?: boolean; max?: string; min?: string; - parser?: string | ((arg) => moment.MomentDateObject); + parser?: string | ((arg: any) => moment.MomentDateObject); round?: string; tooltipFormat?: string; unit?: TimeUnit; @@ -375,16 +375,16 @@ interface RadialLinearScale { declare var Chart: { new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; destroy: () => {}; - update: (duration, lazy) => {}; - render: (duration, lazy) => {}; + update: (duration: any, lazy: any) => {}; + render: (duration: any, lazy: any) => {}; stop: () => {}; resize: () => {}; clear: () => {}; toBase64: () => string; generateLegend: () => {}; - getElementAtEvent: (e) => {}; - getElementsAtEvent: (e) => {}[]; - getDatasetAtEvent: (e) => {}[]; + getElementAtEvent: (e: any) => {}; + getElementsAtEvent: (e: any) => {}[]; + getDatasetAtEvent: (e: any) => {}[]; defaults: { global: ChartOptions; From cfafb5a2f70a744102cdc9b9ce6abaa9adfe4d7a Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 20:40:02 +0200 Subject: [PATCH 0021/1354] Update chart2.d.ts --- chartjs/chart2.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index f80e8d9897..b3ac83f33d 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -1,4 +1,4 @@ -/* TYPES */ +// TYPES declare enum ChartType { line, bar, radar, doughnut, polarArea, bubble } @@ -46,18 +46,18 @@ interface ChartPoint { y?: number; } -/* END */ +// END -/* Configuration */ +// Configuration interface ChartConfiguration { type?: string; data?: ChartData; options?: ChartOptions; } -/* END */ +// END -/* DATA */ +// DATA interface ChartData { } @@ -67,9 +67,9 @@ interface LinearChartData extends ChartData { datasets?: ChartDataSets[]; } -/* END */ +// END -/* Options */ +// Options interface ChartOptions { responsive?: boolean; responsiveAnimationDuration?: number; @@ -289,9 +289,9 @@ interface LogarithmicTickOptions extends TickOptions { min?: number; max?: number; } -/* END */ +// END -/* DATASETS */ +// DATASETS interface ChartDataSets { backgroundColor?: string[]; borderWidth?: number; @@ -317,9 +317,9 @@ interface ChartDataSets { xAxisID?: string; yAxisID?: string; } -/* END */ +// END -/* SCALES */ +// SCALES interface ChartScales { type?: string; display?: boolean; @@ -370,7 +370,7 @@ interface RadialLinearScale { pointLabels?: PointLabelOptions; ticks?: TickOptions; } -/* END */ +// END declare var Chart: { new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; From f74ae92ad0817dfc6c5170e19bc00b3957927a0b Mon Sep 17 00:00:00 2001 From: Leon Adler Date: Wed, 22 Jun 2016 13:47:46 +0200 Subject: [PATCH 0022/1354] Fix package name for sortablejs --- sortablejs/sortablejs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sortablejs/sortablejs.d.ts b/sortablejs/sortablejs.d.ts index 1348a57fbb..87ca56e7c3 100644 --- a/sortablejs/sortablejs.d.ts +++ b/sortablejs/sortablejs.d.ts @@ -202,7 +202,7 @@ declare namespace Sortablejs { import Sortable = Sortablejs.Sortable; -declare module 'Sortable' { +declare module 'sortablejs' { import Sortable = Sortablejs.Sortable; export = Sortable; } From 17ce7262df05a11e4cd4642f31f312ba1580760b Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:17:22 +0800 Subject: [PATCH 0023/1354] fix post function --- mongoose/mongoose.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 6d74a0e4b1..7a4d33c522 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -276,8 +276,7 @@ declare module "mongoose" { pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; + post(method: string, fn: (doc: Document, next?: HookNextFunction) => any ): Schema; requiredPaths(): string[]; set(key: string, value: any): void; From 60b5a415abb71c4f020ab8f2f148ae5360066cc1 Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:56:56 +0800 Subject: [PATCH 0024/1354] fix tests --- mongoose/mongoose-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index cd5f53c4d9..2f6467437c 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -369,7 +369,7 @@ schema.path('name'); schema.path('name', Number); schema.pathType('name'); schema.plugin(function() {}); -schema.post('save', function(next: () => void, doc: IActor) {}); +schema.post('save', function(doc: IActor) {}); schema.pre('save', function(next: () => void) {}); schema.requiredPaths(); schema.static('findByName', function(name: string, callback: () => void) {}); From ed6c1cf4e4abaad3526ba1c2b07521f76f42a8ed Mon Sep 17 00:00:00 2001 From: frogcjn Date: Wed, 29 Jun 2016 09:49:20 +0800 Subject: [PATCH 0025/1354] enhence callback type --- express-jwt/express-jwt.d.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/express-jwt/express-jwt.d.ts b/express-jwt/express-jwt.d.ts index 1aec6606fe..dadf833f67 100644 --- a/express-jwt/express-jwt.d.ts +++ b/express-jwt/express-jwt.d.ts @@ -12,21 +12,30 @@ declare module "express-jwt" { function jwt(options: jwt.Options): jwt.RequestHandler; - interface IDoneCallback { - (err: Error, result: T): void; - } - - type ICallback = (req: express.Request, payload: T, done: IDoneCallback) => void; - namespace jwt { + + export type secretType = string | Buffer + export interface SecretCallback { + (req: express.Request, header:any, payload: any, done: (err: any, secret?: boolean) => void): void; + (req: express.Request, payload: any, done: (err: any, secret?: secretType) => void):void; + } + + export interface IsRevokedCallback { + (req: express.Request, payload: any, done: (err: any, revoked?: boolean) => void): void; + } + + export interface GetTokenCallback { + (req: express.Request): any; + } + export interface Options { - secret: string|Buffer|ICallback; + secret: secretType|SecretCallback; userProperty?: string; skip?: string[]; credentialsRequired?: boolean; - isRevoked?: boolean; + isRevoked?: IsRevokedCallback; requestProperty?: string; - getToken?: ICallback; + getToken?: GetTokenCallback; [property: string]: any; } export interface RequestHandler extends express.RequestHandler { @@ -34,4 +43,4 @@ declare module "express-jwt" { } } export = jwt; -} +} \ No newline at end of file From c3c178dad936c9207ecce37fbd16d1ce51d488df Mon Sep 17 00:00:00 2001 From: Aleksandr Popitich Date: Wed, 29 Jun 2016 14:16:37 +0300 Subject: [PATCH 0026/1354] Fix return type for getRequestInfo method definition. --- adal-angular/adal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts index 76b86e7150..f181054ecf 100644 --- a/adal-angular/adal.d.ts +++ b/adal-angular/adal.d.ts @@ -133,7 +133,7 @@ declare namespace adal { * Gets requestInfo from given hash. * @returns {string} error message related to login */ - getRequestInfo(hash: string): string; + getRequestInfo(hash: string): RequestInfo; /** * Saves token from hash that is received from redirect. From 83b741116c2f23d2ec3ab3ef2e4ddc17e8d10d0b Mon Sep 17 00:00:00 2001 From: Aleksandr Popitich Date: Wed, 29 Jun 2016 14:32:47 +0300 Subject: [PATCH 0027/1354] Fix doc-string --- adal-angular/adal.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts index f181054ecf..1c60cbf6ef 100644 --- a/adal-angular/adal.d.ts +++ b/adal-angular/adal.d.ts @@ -131,7 +131,7 @@ declare namespace adal { /** * Gets requestInfo from given hash. - * @returns {string} error message related to login + * @returns {RequestInfo} for appropriate hash. */ getRequestInfo(hash: string): RequestInfo; From 48d8146a89e891e512f3021ed5f3af03f39a006a Mon Sep 17 00:00:00 2001 From: Jan Zak Date: Wed, 29 Jun 2016 23:18:47 +0200 Subject: [PATCH 0028/1354] Fix i18next default export --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 5e2f8dcd20..02efffbc87 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -125,5 +125,5 @@ declare namespace I18next { declare module 'i18next' { var i18n:I18next.I18n; - export = i18n; + export default i18n; } From cff418127d1d43ff431079cc40035c146496955e Mon Sep 17 00:00:00 2001 From: LionelB Date: Thu, 30 Jun 2016 09:39:50 +0200 Subject: [PATCH 0029/1354] update angular-websocket service paramters --- angular-websocket/angular-websocket-tests.ts | 26 +++++++++++++++++++- angular-websocket/angular-websocket.d.ts | 14 ++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/angular-websocket/angular-websocket-tests.ts b/angular-websocket/angular-websocket-tests.ts index 980e2001d3..e7cb30fe49 100644 --- a/angular-websocket/angular-websocket-tests.ts +++ b/angular-websocket/angular-websocket-tests.ts @@ -2,11 +2,35 @@ let dummySocket: ng.websocket.IWebSocket; let dummyPromise: ng.IPromise; +let dummyScope: ng.IScope; -let provider: ng.websocket.IWebSocketProvider = (url: string) => { +let provider: ng.websocket.IWebSocketProvider = (url: string, protocols?:string[] | ng.websocket.IWebSocketConfigOptions, options?: ng.websocket.IWebSocketConfigOptions) => { return dummySocket; } +let socketWithProtocol = provider("wss://localhost", "protocol"); +let socketWithProtocols = provider("wss://localhost", ["protocol-a", "protocol-b"]); + +let socketWithOptions = provider("wss://localhost", { + scope: dummyScope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" +}); + +let socketWithProtocolAndOptions = provider("wss://localhost", "protocol", { + scope: dummyScope, + rootScopeFailOver: true, + useApplyAsync: true, + initialTimeout: 100, + maxTimeout: 300000, + reconnectIfNotNormalClose: true, + binaryType: "blob" +}); + let socket = provider("wss://localhost"); socket.onOpen((event) => {}) diff --git a/angular-websocket/angular-websocket.d.ts b/angular-websocket/angular-websocket.d.ts index a01e5eab3e..6929561f9c 100644 --- a/angular-websocket/angular-websocket.d.ts +++ b/angular-websocket/angular-websocket.d.ts @@ -7,6 +7,18 @@ declare namespace angular.websocket { + /** + * Options available to be specified for IWebSocketProvider. + */ + type IWebSocketConfigOptions = { + scope?: ng.IScope; + rootScopeFailOver?: boolean; + useApplyAsync?: boolean; + initialTimeout?: number; + maxTimeout?: number; + binaryType?: "blob" | "arraybuffer"; + reconnectIfNotNormalClose?: boolean; + } interface IWebSocketProvider { /** * Creates and opens an IWebSocket instance. @@ -14,7 +26,7 @@ declare namespace angular.websocket { * @param url url to connect to * @return websocket instance */ - (url: string): IWebSocket; + (url: string, protocols?: string | string[] | IWebSocketConfigOptions, options?: IWebSocketConfigOptions): IWebSocket; } /** Options available to be specified for IWebSocket.onMessage */ From ce363be286e099ecb9395a473b92aa28c4620710 Mon Sep 17 00:00:00 2001 From: Casper Skydt Date: Thu, 30 Jun 2016 17:29:16 +0200 Subject: [PATCH 0030/1354] Added apigee-access --- apigee-access/apigee-access-tests.ts | 67 ++++++++++++++++++++++++++++ apigee-access/apigee-access.d.ts | 58 ++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 apigee-access/apigee-access-tests.ts create mode 100644 apigee-access/apigee-access.d.ts diff --git a/apigee-access/apigee-access-tests.ts b/apigee-access/apigee-access-tests.ts new file mode 100644 index 0000000000..99baec8021 --- /dev/null +++ b/apigee-access/apigee-access-tests.ts @@ -0,0 +1,67 @@ +/// +import apigee from "apigee-access"; + +//Sample code from +// https://www.npmjs.com/package/apigee-access + +var request: any = null; + +// Variables +var val1 = apigee.getVariable(request, 'TestVariable'); + +apigee.setIntVariable(request, 'TestVariable', '123'); +apigee.setIntVariable(request, 'TestVariable2', 42); + +apigee.deleteVariable(request, 'TestVariable'); + +// Mode +console.log('The deployment mode is ' + apigee.getMode()); + +// Cache +var cache = apigee.getCache('cache'); +var customCache = apigee.getCache('MyCustomCache', + { resource: 'MyCustomrResource' }); +cache.put('key2', 'Hello, World!', 120); +cache.put('key4', 'Hello, World!', function (err: any) { +}); + +cache.get('key', function (err: any, data: any) { +}); + +cache.remove('key'); + +// Secure Vault +var orgVault = apigee.getVault('vault1', 'organization'); +orgVault.get('key1', function (err: any, secretValue: any) { +}); + +// Quota Service +var quota = apigee.getQuota(); +quota.apply({ identifier: 'Foo', allow: 10, timeUnit: 'hour' }, + function (err: any, result: any) { + console.log('Quota applied: %j', result); + }); + +quota.apply({ + identifier: 'Foo', + timeUnit: 'hour', + allow: 100 +}, quotaResult); + +quota.apply({ + identifier: 'Bar', + timeUnit: 'minute', + interval: 5, + allow: 500 +}, quotaResult); + +quota.apply({ + identifier: 'Foo', + timeUnit: 'hour', + allow: 100, + weight: 10 +}, quotaResult); + +function quotaResult(err: any, r: any) { + if (err) { console.error('Quota failed'); } +} \ No newline at end of file diff --git a/apigee-access/apigee-access.d.ts b/apigee-access/apigee-access.d.ts new file mode 100644 index 0000000000..af34724023 --- /dev/null +++ b/apigee-access/apigee-access.d.ts @@ -0,0 +1,58 @@ +// Type definitions for apigee-access +// Project: https://www.npmjs.com/package/apigee-access +// Definitions by: Casper Skydt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module ApigeeAccess { + + function getVariable(request: any, name: string): string | number | boolean; + function setVariable(request: any, name: string, value: string | number | boolean ): void; + function setIntVariable(request: any, name: string, value: string | number): void; + function deleteVariable(request: any, name: string): void; + function getCache(name: string, options?: CacheOptions): any; + function getVault(name: string, scope?: "organization" | "environment"): SecureVault; + function getQuota(options?: any): QuotaService; + function getMode(): "apigee" | "standalone"; + + interface CacheOptions{ + resource?: string; + scope?: "global" | "application" | "exclusive"; + defaultTtl?: number; + timeout?: number; + } + + interface Cache{ + put(key: string, data: any, ttl?: number, callback?: (err: any) => void): void; + get(key: string, callback: (err: any, data: any) => void): void; + remove(key: string, callback?: (err: any) => void): void; + } + + interface SecureVault{ + getKeys(callback: (err: any, data: any) => void): void; + get(key: string, callback: (err: any, data: any) => void): void; + } + + interface QuotaService{ + apply(options?: QuotaServiceApplyOptions, callback?: (err: any, data: QuotaServiceApplyCallbackData) => void): void; + } + + interface QuotaServiceApplyOptions{ + identifier: string; + timeUnit: "minute" | "hour" | "day" | "week" | "month"; + allow: number; + interval?: number; + weight?: number; + } + + interface QuotaServiceApplyCallbackData{ + used: number; + allowed: number; + isAllowed: boolean; + expiryTime: number; + timestamp: number; + } +} + +declare module "apigee-access"{ + export default ApigeeAccess; +} \ No newline at end of file From 43c311427bb79ebbadfc37b31611552c943f4e24 Mon Sep 17 00:00:00 2001 From: dano-giftbit Date: Thu, 30 Jun 2016 14:13:17 -0700 Subject: [PATCH 0031/1354] Added Typing definitions for MaterialUI 0.15.1 and Moved 0.15.0 into legacy --- .../legacy/material-ui-0.15.0-tests.tsx | 4913 ++++++++++ .../material-ui-0.15.0-tests.tsx.tscparams | 1 + material-ui/legacy/material-ui-0.15.0.d.ts | 8414 +++++++++++++++++ material-ui/material-ui-tests.tsx | 40 +- material-ui/material-ui.d.ts | 31 +- 5 files changed, 13393 insertions(+), 6 deletions(-) create mode 100644 material-ui/legacy/material-ui-0.15.0-tests.tsx create mode 100644 material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams create mode 100644 material-ui/legacy/material-ui-0.15.0.d.ts diff --git a/material-ui/legacy/material-ui-0.15.0-tests.tsx b/material-ui/legacy/material-ui-0.15.0-tests.tsx new file mode 100644 index 0000000000..a0374db8b8 --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0-tests.tsx @@ -0,0 +1,4913 @@ +/// +/// +/// +/// + +import * as React from 'react'; +import {Component, PropTypes} from 'react'; +import * as ReactDOM from 'react-dom'; + +import getMuiTheme from 'material-ui/styles/getMuiTheme'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; +import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme'; +import muiThemeable from 'material-ui/styles/muiThemeable'; +import {MuiTheme} from 'material-ui/styles' + +import AppBar from 'material-ui/AppBar'; +import AutoComplete from 'material-ui/AutoComplete'; +import Avatar from 'material-ui/Avatar'; +import Badge from 'material-ui/Badge'; +import Checkbox from 'material-ui/Checkbox'; +import CircularProgress from 'material-ui/CircularProgress'; +import DatePicker from 'material-ui/DatePicker'; +import Dialog from 'material-ui/Dialog'; +import Divider from 'material-ui/Divider'; +import Drawer from 'material-ui/Drawer'; +import DropDownMenu from 'material-ui/DropDownMenu'; +import FlatButton from 'material-ui/FlatButton'; +import FloatingActionButton from 'material-ui/FloatingActionButton'; +import FontIcon from 'material-ui/FontIcon'; +import IconButton from 'material-ui/IconButton'; +import IconMenu from 'material-ui/IconMenu'; +import LinearProgress from 'material-ui/LinearProgress'; +import List from 'material-ui/List/List'; +import ListItem from 'material-ui/List/ListItem'; +import MenuItem from 'material-ui/MenuItem'; +import Paper from 'material-ui/Paper'; +import RaisedButton from 'material-ui/RaisedButton'; +import RefreshIndicator from 'material-ui/RefreshIndicator'; +import SelectField from 'material-ui/SelectField'; +import Slider from 'material-ui/Slider'; +import Snackbar from 'material-ui/Snackbar'; +import Subheader from 'material-ui/Subheader'; +import SvgIcon from 'material-ui/SvgIcon'; +import TextField from 'material-ui/TextField'; +import TimePicker from 'material-ui/TimePicker'; +import Toggle from 'material-ui/Toggle'; +import {Card, CardActions, CardHeader, CardMedia, CardTitle, CardText} from 'material-ui/Card'; +import {GridList, GridTile} from 'material-ui/GridList'; +import {MakeSelectable} from 'material-ui/List'; +import {Menu} from 'material-ui/Menu'; +import {Popover, PopoverAnimationVertical} from 'material-ui/Popover'; +import {RadioButton, RadioButtonGroup} from 'material-ui/RadioButton'; +import {Step, Stepper, StepLabel, StepContent, StepButton} from 'material-ui/Stepper'; +import {Table, TableBody, TableHeader, TableHeaderColumn, TableRow, TableRowColumn, TableFooter} from 'material-ui/Table'; +import {Tabs, Tab} from 'material-ui/Tabs'; +import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar'; + +import ActionAndroid from 'material-ui/svg-icons/action/android'; +import ActionAssignment from 'material-ui/svg-icons/action/assignment'; +import ActionFavorite from 'material-ui/svg-icons/action/favorite'; +import ActionFavoriteBorder from 'material-ui/svg-icons/action/favorite-border'; +import ActionFlightTakeoff from 'material-ui/svg-icons/action/flight-takeoff'; +import ActionGrade from 'material-ui/svg-icons/action/grade'; +import ActionHome from 'material-ui/svg-icons/action/home'; +import ActionInfo from 'material-ui/svg-icons/action/info'; +import ArrowDropRight from 'material-ui/svg-icons/navigation-arrow-drop-right'; +import CommunicationCall from 'material-ui/svg-icons/communication/call'; +import CommunicationChatBubble from 'material-ui/svg-icons/communication/chat-bubble'; +import CommunicationEmail from 'material-ui/svg-icons/communication/email'; +import ContentAdd from 'material-ui/svg-icons/content/add'; +import ContentCopy from 'material-ui/svg-icons/content/content-copy'; +import ContentDrafts from 'material-ui/svg-icons/content/drafts'; +import ContentFilter from 'material-ui/svg-icons/content/filter-list'; +import ContentInbox from 'material-ui/svg-icons/content/inbox'; +import ContentLink from 'material-ui/svg-icons/content/link'; +import ContentSend from 'material-ui/svg-icons/content/send'; +import Delete from 'material-ui/svg-icons/action/delete'; +import Download from 'material-ui/svg-icons/file/file-download'; +import EditorInsertChart from 'material-ui/svg-icons/editor/insert-chart'; +import FileCloudDownload from 'material-ui/svg-icons/file/cloud-download'; +import FileFileDownload from 'material-ui/svg-icons/file/file-download'; +import FileFolder from 'material-ui/svg-icons/file/folder'; +import FolderIcon from 'material-ui/svg-icons/file/folder-open'; +import HardwareVideogameAsset from 'material-ui/svg-icons/hardware/videogame-asset'; +import MapsPersonPin from 'material-ui/svg-icons/maps/person-pin'; +import MapsPlace from 'material-ui/svg-icons/maps/place'; +import MoreVertIcon from 'material-ui/svg-icons/navigation/more-vert'; +import NavigationClose from 'material-ui/svg-icons/navigation/close'; +import NavigationExpandMoreIcon from 'material-ui/svg-icons/navigation/expand-more'; +import NotificationsIcon from 'material-ui/svg-icons/social/notifications'; +import PersonAdd from 'material-ui/svg-icons/social/person-add'; +import RemoveRedEye from 'material-ui/svg-icons/image/remove-red-eye'; +import StarBorder from 'material-ui/svg-icons/toggle/star-border'; +import UploadIcon from 'material-ui/svg-icons/file/cloud-upload'; +import WarningIcon from 'material-ui/svg-icons/alert/warning'; + +import {cyan500, cyan700, + grey100, grey300, grey400, grey500, + pinkA200, + white, darkBlack, fullBlack, + blue300, + indigo900, + orange200, + deepOrange300, + pink400, + purple500, + fullWhite, + blue500, red500, greenA200, yellow500, + transparent, yellow600, indigo500, lightBlack, + orange500, +} from 'material-ui/styles/colors'; +import {fade} from 'material-ui/utils/colorManipulator'; + + +import injectTapEventPlugin = require('react-tap-event-plugin'); + +// Needed for onTouchTap +// Check this repo: +// https://github.com/zilverline/react-tap-event-plugin +injectTapEventPlugin(); + +function handleTouchTap() { + alert('onTouchTap triggered on the title component'); +} + +const styles = { + title: { + cursor: 'pointer', + }, + exampleImageInput: { + cursor: 'pointer', + position: 'absolute', + top: 0, + bottom: 0, + right: 0, + left: 0, + width: '100%', + opacity: 0, + }, + button: { + margin: 12, + }, + smallIcon: { + width: 36, + height: 36, + }, + mediumIcon: { + width: 48, + height: 48, + }, + largeIcon: { + width: 60, + height: 60, + }, + small: { + width: 72, + height: 72, + padding: 16, + }, + medium: { + width: 96, + height: 96, + padding: 24, + }, + large: { + width: 120, + height: 120, + padding: 30, + }, + radioButton: { + marginTop: 16, + }, + root: { + display: 'flex', + flexWrap: 'wrap', + justifyContent: 'space-around', + }, + gridList: { + width: 500, + height: 500, + overflowY: 'auto', + marginBottom: 24, + }, + paper: { + display: 'inline-block', + float: 'left', + margin: '16px 32px 16px 0', + }, + rightIcon: { + textAlign: 'center', + lineHeight: '24px', + }, + customWidth: { + width: 200, + }, + h3: { + marginTop: 20, + fontWeight: 400, + }, + block: { + display: 'flex', + maxWidth: 250, + }, + block2: { + margin: 10, + }, + container: { + position: 'relative', + }, + refresh: { + display: 'inline-block', + position: 'relative', + }, + checkbox: { + marginBottom: 16, + }, + toggle: { + marginBottom: 16, + }, + propContainer: { + width: 200, + overflow: 'hidden', + margin: '20px auto 0', + }, + propToggleHeader: { + margin: '20px auto 10px', + }, + headline: { + fontSize: 24, + paddingTop: 16, + marginBottom: 12, + fontWeight: 400, + }, + errorStyle: { + color: orange500, + }, + underlineStyle: { + borderColor: orange500, + }, + floatingLabelStyle: { + color: orange500, + }, + floatingLabelFocusStyle: { + color: blue500, + }, +}; + +const style = { + marginRight: 20, + marginLeft: 20, + display: 'inline-block', + margin: '16px 32px 16px 0', +}; + +const customContentStyle = { + width: '100%', + maxWidth: 'none', +}; + +const iconStyles = { + marginRight: 24, +}; + + +// "http://www.material-ui.com/#/customization/themes" + +// This replaces the textColor value on the palette +// and then update the keys for each component that depends on it. +// More on Colors: http://www.material-ui.com/#/customization/colors +const muiTheme = getMuiTheme({ + palette: { + textColor: cyan500, + }, + appBar: { + height: 50, + }, +}); + +const darkMuiTheme = getMuiTheme(darkBaseTheme); + +const lightBaseTheme = { + spacing: { + iconSize: 24, + desktopGutter: 24, + desktopGutterMore: 32, + desktopGutterLess: 16, + desktopGutterMini: 8, + desktopKeylineIncrement: 64, + desktopDropDownMenuItemHeight: 32, + desktopDropDownMenuFontSize: 15, + desktopDrawerMenuItemHeight: 48, + desktopSubheaderHeight: 48, + desktopToolbarHeight: 56, + }, + fontFamily: 'Roboto, sans-serif', + palette: { + primary1Color: cyan500, + primary2Color: cyan700, + primary3Color: grey400, + accent1Color: pinkA200, + accent2Color: grey100, + accent3Color: grey500, + textColor: darkBlack, + alternateTextColor: white, + canvasColor: white, + borderColor: grey300, + disabledColor: fade(darkBlack, 0.3), + pickerHeaderColor: cyan500, + clockCircleColor: fade(darkBlack, 0.07), + shadowColor: fullBlack, + }, +}; + +const lightMuiTheme = getMuiTheme(lightBaseTheme); + + +class DeepDownTheTree extends React.Component<{} & {muiTheme: MuiTheme}, {}> { + static propTypes: React.ValidationMap = { + muiTheme: React.PropTypes.object.isRequired, + }; + + render() { + return ( + + Hello World! + + ); + } +} + + +// "http://www.material-ui.com/#/customization/inline-styles" +const InlineStylesCheckbox = () => ( + +); + + +// "http://www.material-ui.com/#/components/app-bar" +const AppBarExampleIcon = () => ( + +); + +const AppBarExampleIconButton = () => ( + Title} + onTitleTouchTap={handleTouchTap} + iconElementLeft={} + iconElementRight={} + /> +); + +const AppBarExampleIconMenu = () => ( + } + iconElementRight={ + + } + targetOrigin={{horizontal: 'right', vertical: 'top'}} + anchorOrigin={{horizontal: 'right', vertical: 'top'}} + > + + + + + } + /> +); + +// "http://www.material-ui.com/#/components/auto-complete" +export class AutoCompleteExampleSimple extends React.Component<{}, {dataSource: string[]}> { + + constructor(props) { + super(props); + + this.state = { + dataSource: [], + }; + } + + handleUpdateInput = (value) => { + this.setState({ + dataSource: [ + value, + value + value, + value + value + value, + ], + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +const dataSource1 = [ + { + text: 'text-value1', + value: ( + + ), + }, + { + text: 'text-value2', + value: ( + + ), + }, +]; + +const dataSource2 = ['12345', '23456', '34567']; + +const dataSource3 = [ + {text: 'Some Text', value: 'someFirstValue'}, + {text: 'Some Text', value: 'someSecondValue'}, +]; + +const AutoCompleteExampleNoFilter = () => ( +
+
+
+ +
+); + +const colors = [ + 'Red', + 'Orange', + 'Yellow', + 'Green', + 'Blue', + 'Purple', + 'Black', + 'White', +]; + +const fruit = [ + 'Apple', 'Apricot', 'Avocado', + 'Banana', 'Bilberry', 'Blackberry', 'Blackcurrant', 'Blueberry', + 'Boysenberry', 'Blood Orange', + 'Cantaloupe', 'Currant', 'Cherry', 'Cherimoya', 'Cloudberry', + 'Coconut', 'Cranberry', 'Clementine', + 'Damson', 'Date', 'Dragonfruit', 'Durian', + 'Elderberry', + 'Feijoa', 'Fig', + 'Goji berry', 'Gooseberry', 'Grape', 'Grapefruit', 'Guava', + 'Honeydew', 'Huckleberry', + 'Jabouticaba', 'Jackfruit', 'Jambul', 'Jujube', 'Juniper berry', + 'Kiwi fruit', 'Kumquat', + 'Lemon', 'Lime', 'Loquat', 'Lychee', + 'Nectarine', + 'Mango', 'Marion berry', 'Melon', 'Miracle fruit', 'Mulberry', 'Mandarine', + 'Olive', 'Orange', + 'Papaya', 'Passionfruit', 'Peach', 'Pear', 'Persimmon', 'Physalis', 'Plum', 'Pineapple', + 'Pumpkin', 'Pomegranate', 'Pomelo', 'Purple Mangosteen', + 'Quince', + 'Raspberry', 'Raisin', 'Rambutan', 'Redcurrant', + 'Salal berry', 'Satsuma', 'Star fruit', 'Strawberry', 'Squash', 'Salmonberry', + 'Tamarillo', 'Tamarind', 'Tomato', 'Tangerine', + 'Ugli fruit', + 'Watermelon', +]; + +const AutoCompleteExampleFilters = () => ( +
+ +
+ +
+); + +// "http://www.material-ui.com/#/components/avatar" +const AvatarExampleSimple = () => ( + + + } + > + Image Avatar + + + } + > + Image Avatar with custom size + + } /> + } + > + FontIcon Avatar + + } + color={blue300} + backgroundColor={indigo900} + size={30} + style={style} + /> + } + > + FontIcon Avatar with custom colors and size + + } /> + } + > + SvgIcon Avatar + + } + color={orange200} + backgroundColor={pink400} + size={30} + style={style} + /> + } + > + SvgIcon Avatar with custom colors and size + + A} + > + Letter Avatar + + + A + + } + > + Letter Avatar with custom colors and size + + +); + + +// "http://www.material-ui.com/#/components/badge" +const BadgeExampleSimple = () => ( +
+ + + + + + + + +
+); + +const BadgeExampleContent = () => ( +
+ } + > + + + + Company Name + +
+); + + +// "http://www.material-ui.com/#/components/flat-button" +const FlatButtonExampleSimple = () => ( +
+ + + + +
+); + +const FlatButtonExampleComplex = () => ( +
+ + + + + } + /> + + } + /> + +
+); + +const FlatButtonExampleIcon = () => ( +
+ } + style={style} + /> + } + style={style} + /> + } + style={style} + /> +
+); + + +// "http://www.material-ui.com/#/components/raised-button" +const RaisedButtonExampleSimple = () => ( +
+ + + + +
+); + +const RaisedButtonExampleComplex = () => ( +
+ + + + } + style={styles.button} + /> + } + /> +
+); + +const RaisedButtonExampleIcon = () => ( +
+ } + style={style} + /> + } + style={style} + /> + } + style={style} + /> +
+); + + +// "http://www.material-ui.com/#/components/floating-action-button" +const FloatingActionButtonExampleSimple = () => ( +
+ + + + + + + + + + + + + + + + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/icon-button" +const IconButtonExampleSimple = () => ( +
+ + +
+); + +const IconButtonExampleComplex = () => ( +
+ + + + + + + + + + home + +
+); + +const IconButtonExampleSize = () => ( +
+ + + + + + + + + + + + + + + +
+); + +const IconButtonExampleTooltip = () => ( +
+ + + + + + +
+); + +const IconButtonExampleTouch = () => ( +
+ + + + + + + + + + + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/card" +const CardExampleWithAvatar = () => ( + + + } + > + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + +); + +const CardExampleWithoutAvatar = () => ( + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + +); + +class CardExampleControlled extends React.Component<{}, {expanded: boolean}> { + + constructor(props) { + super(props); + this.state = { + expanded: false, + }; + } + + handleExpandChange = (expanded) => { + this.setState({expanded: expanded}); + }; + + handleToggle = (event, toggle) => { + this.setState({expanded: toggle}); + }; + + handleExpand = () => { + this.setState({expanded: true}); + }; + + handleReduce = () => { + this.setState({expanded: false}); + }; + + render() { + return ( + + + + + + } + > + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. + Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. + Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. + + + + + + + ); + } +} + + +// "http://www.material-ui.com/#/components/date-picker" +const DatePickerExampleSimple = () => ( +
+ + + +
+); + +const DatePickerExampleInline = () => ( +
+ + +
+); + +const optionsStyle = { + maxWidth: 255, + marginRight: 'auto', +}; + +interface DatePickerExampleToggleState { + minDate?: Date; + maxDate?: Date; + autoOk?: boolean; + disableYearSelection?: boolean; +} + +class DatePickerExampleToggle extends React.Component<{}, DatePickerExampleToggleState> { + constructor(props) { + super(props); + + const minDate = new Date(); + const maxDate = new Date(); + minDate.setFullYear(minDate.getFullYear() - 1); + minDate.setHours(0, 0, 0, 0); + maxDate.setFullYear(maxDate.getFullYear() + 1); + maxDate.setHours(0, 0, 0, 0); + + this.state = { + minDate: minDate, + maxDate: maxDate, + autoOk: false, + disableYearSelection: false, + }; + } + + handleChangeMinDate = (event, date) => { + this.setState({ + minDate: date, + }); + }; + + handleChangeMaxDate = (event, date) => { + this.setState({ + maxDate: date, + }); + }; + + handleToggle = (event, toggled) => { + this.setState({ + [event.target.name]: toggled, + }); + }; + + render() { + return ( +
+ +
+ + + + +
+
+ ); + } +} + +class DatePickerExampleControlled extends React.Component<{}, {controlledDate?: Date}> { + + constructor(props) { + super(props); + + this.state = { + controlledDate: null, + }; + } + + handleChange = (event, date) => { + this.setState({ + controlledDate: date, + }); + }; + + render() { + return ( + + ); + } +} + +function disableWeekends(date) { + return date.getDay() === 0 || date.getDay() === 6; +} +function disableRandomDates() { + return Math.random() > 0.7; +} +const DatePickerExampleDisableDates = () => ( +
+ + +
+); + +let DateTimeFormat = new Intl.DateTimeFormat('fr'); +const DatePickerExampleInternational = () => ( +
+ + + +
+); + + + +// "http://material-ui.com/#/components/dialog" +class DialogExampleSimple extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + The actions in this window were passed in as an array of React objects. + +
+ ); + } +} + +class DialogExampleModal extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + Only actions can close this dialog. + +
+ ); + } +} + +class DialogExampleCustomWidth extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + This dialog spans the entire width of the screen. + +
+ ); + } +} + +class DialogExampleDialogDatePicker extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + ]; + + return ( +
+ + + Open a Date Picker dialog from within a dialog. + + +
+ ); + } +} + +class DialogExampleScrollable extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + const radios = []; + for (let i = 0; i < 30; i++) { + radios.push( + + ); + } + + return ( +
+ + + + {radios} + + +
+ ); + } +} + +class DialogExampleAlert extends React.Component<{}, {open?: boolean}> { + state = { + open: false, + }; + + handleOpen = () => { + this.setState({open: true}); + }; + + handleClose = () => { + this.setState({open: false}); + }; + + render() { + const actions = [ + , + , + ]; + + return ( +
+ + + Discard draft? + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/divider" +const DividerExampleForm = () => ( + + + + + + + + + + +); + +const DividerExampleList = () => ( + + + + + + + + + + + +); + +const DividerExampleMenu = () => ( + + + + + + +); + + +// "http://www.material-ui.com/#/components/drawer" +class DrawerSimpleExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + render() { + return ( +
+ + + Menu Item + Menu Item 2 + +
+ ); + } +} + +class DrawerUndockedExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + handleClose = () => this.setState({open: false}); + + render() { + return ( +
+ + this.setState({open})} + > + Menu Item + Menu Item 2 + +
+ ); + } +} + +class DrawerOpenRightExample extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = {open: false}; + } + + handleToggle = () => this.setState({open: !this.state.open}); + + render() { + return ( +
+ + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/grid-list" +const tilesData: {img: string, title: string, author: string, featured?: boolean}[] = [ + { + img: 'images/grid-list/00-52-29-429_640.jpg', + title: 'Breakfast', + author: 'jill111', + featured: true, + }, + { + img: 'images/grid-list/burger-827309_640.jpg', + title: 'Tasty burger', + author: 'pashminu', + }, + { + img: 'images/grid-list/camera-813814_640.jpg', + title: 'Camera', + author: 'Danson67', + }, + { + img: 'images/grid-list/morning-819362_640.jpg', + title: 'Morning', + author: 'fancycrave1', + }, + { + img: 'images/grid-list/hats-829509_640.jpg', + title: 'Hats', + author: 'Hans', + }, + { + img: 'images/grid-list/honey-823614_640.jpg', + title: 'Honey', + author: 'fancycravel', + }, + { + img: 'images/grid-list/vegetables-790022_640.jpg', + title: 'Vegetables', + author: 'jill111', + }, + { + img: 'images/grid-list/water-plant-821293_640.jpg', + title: 'Water plant', + author: 'BkrmadtyaKarki', + }, +]; + +const GridListExampleSimple = () => ( +
+ + December + {tilesData.map((tile) => ( + by {tile.author}} + actionIcon={} + > + + + ))} + +
+); + +const GridListExampleComplex = () => ( +
+ + {tilesData.map((tile) => ( + } + actionPosition="left" + titlePosition="top" + titleBackground="linear-gradient(to bottom, rgba(0,0,0,0.7) 0%,rgba(0,0,0,0.3) 70%,rgba(0,0,0,0) 100%)" + cols={tile.featured ? 2 : 1} + rows={tile.featured ? 2 : 1} + > + + + ))} + +
+); + + +// "http://www.material-ui.com/#/components/font-icon" +const FontIconExampleSimple = () => ( +
+ + + + + +
+); + +const FontIconExampleIcons = () => ( +
+ home + flight_takeoff + cloud_download + videogame_asset +
+); + + +// "http://www.material-ui.com/#/components/svg-icon" +const HomeIcon = (props) => ( + + + +); + +const SvgIconExampleSimple = () => ( +
+ + + +
+); + +const SvgIconExampleIcons = () => ( +
+ + + + +
+); + + +// "http://material-ui.com/#/components/lists" +const ListExampleSimple = () => ( + + + } /> + } /> + } /> + } /> + } /> + + + + } /> + } /> + } /> + } /> + + +); + +const ListExampleChat = () => ( + + + Recent chats + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + } + rightIcon={} + /> + + + + Previous chats + } + /> + } + /> + + +); + +const ListExampleContacts = () => ( + + + } + rightAvatar={} + /> + } + /> + } + /> + } + /> + + + + + A + + } + rightAvatar={} + /> + } + /> + } + /> + } + /> + + +); + +const ListExampleFolder = () => ( + + + Folders + } />} + rightIcon={} + primaryText="Photos" + secondaryText="Jan 9, 2014" + /> + } />} + rightIcon={} + primaryText="Recipes" + secondaryText="Jan 17, 2014" + /> + } />} + rightIcon={} + primaryText="Work" + secondaryText="Jan 28, 2014" + /> + + + + Files + } backgroundColor={blue500} />} + rightIcon={} + primaryText="Vacation itinerary" + secondaryText="Jan 20, 2014" + /> + } backgroundColor={yellow600} />} + rightIcon={} + primaryText="Kitchen remodel" + secondaryText="Jan 10, 2014" + /> + + +); + +const ListExampleNested = () => ( + + + Nested List Items + } /> + } /> + } + initiallyOpen={true} + primaryTogglesNestedList={true} + nestedItems={[ + } + />, + } + disabled={true} + nestedItems={[ + } />, + ]} + />, + ]} + /> + + +); + +const ListExampleSettings = () => ( +
+ + + General + + + + + + Hangout Notifications + } + primaryText="Notifications" + secondaryText="Allow notifications" + /> + } + primaryText="Sounds" + secondaryText="Hangouts message" + /> + } + primaryText="Video sounds" + secondaryText="Hangouts video call" + /> + + + + + + + + + Priority Interruptions + } /> + } /> + } /> + + + + Hangout Notifications + } /> + } /> + } /> + + +
+); + +const ListExamplePhone = () => ( + + + } + rightIcon={} + primaryText="(650) 555 - 1234" + secondaryText="Mobile" + /> + } + primaryText="(323) 555 - 6789" + secondaryText="Work" + /> + + + + } + primaryText="aliconnors@example.com" + secondaryText="Personal" + /> + + + +); + +const iconButtonElement = ( + + + +); + +const rightIconMenu = ( + + Reply + Forward + Delete + +); + +const ListExampleMessages = () => ( +
+ + + Today + } + primaryText="Brunch this weekend?" + secondaryText={ +

+ Brendan Lim -- + I'll be in your neighborhood doing errands this weekend. Do you want to grab brunch? +

+ } + secondaryTextLines={2} + /> + + } + primaryText={ +

Summer BBQ  4

+ } + secondaryText={ +

+ to me, Scott, Jennifer -- + Wish I could come, but I'm out of town this weekend. +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Oui oui" + secondaryText={ +

+ Grace Ng -- + Do you have Paris recommendations? Have you ever been? +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Birdthday gift" + secondaryText={ +

+ Kerem Suer -- + Do you have any ideas what we can get Heidi for her birthday? How about a pony? +

+ } + secondaryTextLines={2} + /> + + } + primaryText="Recipe to try" + secondaryText={ +

+ Raquel Parrado -- + We should eat this: grated squash. Corn and tomatillo tacos. +

+ } + secondaryTextLines={2} + /> +
+
+ + + Today + } + rightIconButton={rightIconMenu} + primaryText="Brendan Lim" + secondaryText={ +

+ Brunch this weekend?
+ I'll be in your neighborhood doing errands this weekend. Do you want to grab brunch? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="me, Scott, Jennifer" + secondaryText={ +

+ Summer BBQ
+ Wish I could come, but I'm out of town this weekend. +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Grace Ng" + secondaryText={ +

+ Oui oui
+ Do you have any Paris recs? Have you ever been? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Kerem Suer" + secondaryText={ +

+ Birthday gift
+ Do you have any ideas what we can get Heidi for her birthday? How about a pony? +

+ } + secondaryTextLines={2} + /> + + } + rightIconButton={rightIconMenu} + primaryText="Raquel Parrado" + secondaryText={ +

+ Recipe to try
+ We should eat this: grated squash. Corn and tomatillo tacos. +

+ } + secondaryTextLines={2} + /> +
+
+
+); + +function wrapState(ComposedComponent: React.ComponentClass<__MaterialUI.List.SelectableProps>) { + return class SelectableList extends Component<{defaultValue: number}, {selectedIndex: number}> { + static propTypes = { + children: PropTypes.node.isRequired, + defaultValue: PropTypes.number.isRequired, + }; + + componentWillMount() { + this.setState({ + selectedIndex: this.props.defaultValue, + }); + } + + handleRequestChange = (event, index) => { + this.setState({ + selectedIndex: index, + }); + }; + + render() { + return ( + + {this.props.children} + + ); + } + }; +} + +let SelectableList = wrapState(MakeSelectable(List)); + +const ListExampleSelectable = () => ( + + + Selectable Contacts + } + nestedItems={[ + } + />, + ]} + /> + } + /> + } + /> + } + /> + + +); + + +// "http://www.material-ui.com/#/components/menu" +const MenuExampleSimple = () => ( +
+ + + + + + + + + + + + + + + + +
+); + +const MenuExampleDisable = () => ( +
+ + + + + + + + + + + + + + + + + + + + +
+); + +const MenuExampleIcons = () => ( +
+ + + } /> + } /> + } /> + + } /> + } /> + + } /> + + + + + + } /> + settings} /> + settings + } + /> + ¶} /> + §} /> + + +
+); + +const MenuExampleSecondary = () => ( +
+ + + + + + + + + + } /> + } /> + } /> + } /> + } /> + + + + + + + + + + + + + + + + + + +
+); + +const MenuExampleNested = () => ( +
+ + + + + + } + menuItems={[ + } + menuItems={[ + , + , + , + , + ]} + />, + , + , + , + ]} + /> + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/icon-menu" +const IconMenuExampleSimple = () => ( +
+ } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'left', vertical: 'bottom'}} + targetOrigin={{horizontal: 'left', vertical: 'bottom'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'right', vertical: 'bottom'}} + targetOrigin={{horizontal: 'right', vertical: 'bottom'}} + > + + + + + + + } + anchorOrigin={{horizontal: 'right', vertical: 'top'}} + targetOrigin={{horizontal: 'right', vertical: 'top'}} + > + + + + + + +
+); + +interface IconMenuExampleControlledState { + valueSingle?: string; + valueMultiple?: string[]; + openMenu?: boolean; +} + +class IconMenuExampleControlled extends React.Component<{}, IconMenuExampleControlledState> { + constructor(props) { + super(props); + + this.state = { + valueSingle: '3', + valueMultiple: ['3', '5'], + }; + } + + handleChangeSingle = (event, value) => { + this.setState({ + valueSingle: value, + }); + }; + + handleChangeMultiple = (event, value) => { + this.setState({ + valueMultiple: value, + }); + }; + + handleOpenMenu = () => { + this.setState({ + openMenu: true, + }); + } + + handleOnRequestChange = (value) => { + this.setState({ + openMenu: value, + }); + } + + render() { + return ( +
+ } + onChange={this.handleChangeSingle} + value={this.state.valueSingle} + > + + + + + + + } + onChange={this.handleChangeMultiple} + value={this.state.valueMultiple} + multiple={true} + > + + + + + + + + } + open={this.state.openMenu} + onRequestChange={this.handleOnRequestChange} + > + + + + + + +
+ ); + } +} + +const IconMenuExampleScrollable = () => ( + } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + maxHeight={272} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +const IconMenuExampleNested = () => ( +
+ } + anchorOrigin={{horizontal: 'left', vertical: 'top'}} + targetOrigin={{horizontal: 'left', vertical: 'top'}} + > + } + menuItems={[ + , + , + , + , + ]} + /> + + } + menuItems={[ + , + , + , + , + ]} + /> + + } /> + + + + +
+); + + +// "http://www.material-ui.com/#/components/dropdown-menu" +class DropDownMenuSimpleExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + + + + + + +
+ + + + + + + +
+ ); + } +} + +class DropDownMenuOpenImmediateExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 2}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + + ); + } +} + +const items: React.ReactElement<__MaterialUI.Menus.MenuItemProps>[] = []; +for (let i = 0; i < 100; i++ ) { + items.push(); +} + +class DropDownMenuLongMenuExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 10}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + {items} + + ); + } +} + +class DropDownMenuLabeledExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 2}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + ); + } +} + + +// "http://material-ui.com/#/components/paper" +const PaperExampleSimple = () => ( +
+ + + + + +
+); + +const PaperExampleRounded = () => ( +
+ + + + + +
+); + +const PaperExampleCircle = () => ( +
+ + + + + +
+); + + +// "http://www.material-ui.com/#/components/popover" +class PopoverExampleSimple extends React.Component<{}, {open?: boolean, anchorEl?: React.ReactInstance}> { + + constructor(props) { + super(props); + + this.state = { + open: false, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + + + + + + + + +
+ ); + } +} + +class PopoverExampleAnimation extends React.Component<{}, {open?: boolean, anchorEl?: React.ReactInstance}> { + + constructor(props) { + super(props); + + this.state = { + open: false, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + + + + + + + + +
+ ); + } +} + +interface PopoverExampleConfigurableState { + open?: boolean; + anchorOrigin?: __MaterialUI.propTypes.origin; + targetOrigin?: __MaterialUI.propTypes.origin; + anchorEl?: React.ReactInstance; +} + +class PopoverExampleConfigurable extends React.Component<{}, PopoverExampleConfigurableState> { + + constructor(props) { + super(props); + + this.state = { + open: false, + anchorOrigin: { + horizontal: 'left', + vertical: 'bottom', + }, + targetOrigin: { + horizontal: 'left', + vertical: 'top', + }, + }; + } + + handleTouchTap = (event) => { + // This prevents ghost click. + event.preventDefault(); + this.setState({ + open: true, + anchorEl: event.currentTarget, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + setAnchor = (positionElement, position) => { + const {anchorOrigin} = this.state; + anchorOrigin[positionElement] = position; + + this.setState({ + anchorOrigin: anchorOrigin, + }); + }; + + setTarget = (positionElement, position) => { + const {targetOrigin} = this.state; + targetOrigin[positionElement] = position; + + this.setState({ + targetOrigin: targetOrigin, + }); + }; + + render() { + return ( +
+ +

Current Settings

+
+          anchorOrigin: {JSON.stringify(this.state.anchorOrigin)}
+          
+ targetOrigin: {JSON.stringify(this.state.targetOrigin)} +
+

Position Options

+

Use the settings below to toggle the positioning of the popovers above

+

Anchor Origin

+
+
+ Vertical + + + +
+
+ Horizontal + + + +
+
+

Target Origin

+
+
+ Vertical + + + +
+
+ Horizontal + + + +
+
+ + + + + + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/circular-progress" +const CircularProgressExampleSimple = () => ( +
+ + + +
+); + +class CircularProgressExampleDeterminate extends React.Component<{}, {completed?: number}> { + private timer: number; + + constructor(props) { + super(props); + + this.state = { + completed: 0, + }; + } + + componentDidMount() { + this.timer = setTimeout(() => this.progress(5), 1000); + } + + componentWillUnmount() { + clearTimeout(this.timer); + } + + progress(completed) { + if (completed > 100) { + this.setState({completed: 100}); + } else { + this.setState({completed}); + const diff = Math.random() * 10; + this.timer = setTimeout(() => this.progress(completed + diff), 1000); + } + } + + render() { + return ( +
+ + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/linear-progress" +const LinearProgressExampleSimple = () => ( + +); + +class LinearProgressExampleDeterminate extends React.Component<{}, {completed?: number}> { + private timer: number; + + constructor(props) { + super(props); + + this.state = { + completed: 0, + }; + } + + componentDidMount() { + this.timer = setTimeout(() => this.progress(5), 1000); + } + + componentWillUnmount() { + clearTimeout(this.timer); + } + + progress(completed) { + if (completed > 100) { + this.setState({completed: 100}); + } else { + this.setState({completed}); + const diff = Math.random() * 10; + this.timer = setTimeout(() => this.progress(completed + diff), 1000); + } + } + + render() { + return ( + + ); + } +} + + +// "http://www.material-ui.com/#/components/refresh-indicator" +const RefreshIndicatorExampleSimple = () => ( +
+ + + + +
+); + +const RefreshIndicatorExampleLoading = () => ( +
+ + +
+); + + +// "http://www.material-ui.com/#/components/select-field" +class SelectFieldExampleSimple extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + + + + + + +
+ + + + +
+ + + + + + + +
+ + + + + + + +
+ ); + } +} + +class SelectFieldLongMenuExample extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 10}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + {items} + + ); + } +} + +class SelectFieldExampleCustomLabel extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: 1}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + ); + } +} + +const itemsPeriod = [ + , + , + , + , + , +]; + +export default class SelectFieldExampleFloatingLabel extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: null}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( +
+ + {itemsPeriod} + +
+ + {itemsPeriod} + +
+ ); + } +} + +class SelectFieldExampleError extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = {value: null}; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + const {value} = this.state; + + const night = value === 2 || value === 3; + + return ( +
+ + {itemsPeriod} + +
+ + {itemsPeriod} + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/slider" +const SliderExampleSimple = () => ( +
+ + + +
+); + +const SliderExampleDisabled = () => ( +
+ + + +
+); + +const SliderExampleStep = () => ( + +); + +class SliderExampleControlled extends React.Component<{}, {firstSlider?: number, secondSlider?: number}> { + + state = { + firstSlider: 0.5, + secondSlider: 50, + } + + handleFirstSlider(event, value) { + this.setState({firstSlider: value}); + } + + handleSecondSlider(event, value) { + this.setState({secondSlider: value}); + } + + render() { + return ( +
+ +

+ {'The value of this slider is: '} + {this.state.firstSlider} + {' from a range of 0 to 1 inclusive'} +

+ +

+ {'The value of this slider is: '} + {this.state.secondSlider} + {' from a range of 0 to 100 inclusive'} +

+
+ ); + } +} + + +// "http://www.material-ui.com/#/components/checkbox" +const CheckboxExampleSimple = () => ( +
+ + + } + uncheckedIcon={} + label="Custom icon" + style={styles.checkbox} + /> + + + +
+); + + +// "http://www.material-ui.com/#/components/radio-button" +const RadioButtonExampleSimple = () => ( +
+ + + + } + uncheckedIcon={} + style={styles.radioButton} + /> + + + + + + + + +
+); + + +// "http://www.material-ui.com/#/components/toggle" +const ToggleExampleSimple = () => ( +
+ + + + +
+); + + +// "http://material-ui.com/#/components/snackbar" +class SnackbarExampleSimple extends React.Component<{}, {open?: boolean}> { + + constructor(props) { + super(props); + this.state = { + open: false, + }; + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +class SnackbarExampleAction extends React.Component<{}, {open?: boolean, autoHideDuration?: number, message?: string}> { + + constructor(props) { + super(props); + this.state = { + autoHideDuration: 4000, + message: 'Event added to your calendar', + open: false, + }; + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + }; + + handleActionTouchTap = () => { + this.setState({ + open: false, + }); + alert('Event removed from your calendar.'); + }; + + handleChangeDuration = (event) => { + const value = event.target.value; + this.setState({ + autoHideDuration: value.length > 0 ? parseInt(value) : 0, + }); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ +
+ + +
+ ); + } +} + +class SnackbarExampleTwice extends React.Component<{}, {open?: boolean, message?: string}> { + + private timer: number; + + constructor(props) { + super(props); + this.state = { + message: 'Event 1 added to your calendar', + open: false, + }; + this.timer = undefined; + } + + componentWillUnMount() { + clearTimeout(this.timer); + } + + handleTouchTap = () => { + this.setState({ + open: true, + }); + + this.timer = setTimeout(() => { + this.setState({ + message: `Event ${Math.round(Math.random() * 100)} added to your calendar`, + }); + }, 1500); + }; + + handleRequestClose = () => { + this.setState({ + open: false, + }); + }; + + render() { + return ( +
+ + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/stepper" +class HorizontalLinearStepper extends React.Component<{}, {stepIndex?: number, finished?: boolean}> { + + state = { + finished: false, + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + const {finished, stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + return ( +
+ + + Select campaign settings + + + Create an ad group + + + Create an ad + + +
+ {finished ? ( +

+ { + event.preventDefault(); + this.setState({stepIndex: 0, finished: false}); + }} + > + Click here + to reset the example. +

+ ) : ( +
+

{this.getStepContent(stepIndex)}

+
+ + +
+
+ )} +
+
+ ); + } +} + +class VerticalLinearStepper extends React.Component<{}, {stepIndex?: number, finished?: boolean}> { + + state = { + finished: false, + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + this.setState({ + stepIndex: stepIndex + 1, + finished: stepIndex >= 2, + }); + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + renderStepActions(step) { + const {stepIndex} = this.state; + + return ( +
+ + {step > 0 && ( + + )} +
+ ); + } + + render() { + const {finished, stepIndex} = this.state; + + return ( +
+ + + Select campaign settings + +

+ For each ad campaign that you create, you can control how much + you're willing to spend on clicks and conversions, which networks + and geographical locations you want your ads to show on, and more. +

+ {this.renderStepActions(0)} +
+
+ + Create an ad group + +

An ad group contains one or more ads which target a shared set of keywords.

+ {this.renderStepActions(1)} +
+
+ + Create an ad + +

+ Try out different ad text to see what brings in the most customers, + and learn how to enhance your ads using features like ad extensions. + If you run into any problems with your ads, find out how to tell if + they're running and how to resolve approval issues. +

+ {this.renderStepActions(2)} +
+
+
+ {finished && ( +

+ { + event.preventDefault(); + this.setState({stepIndex: 0, finished: false}); + }} + > + Click here + to reset the example. +

+ )} +
+ ); + } +} + +class HorizontalNonLinearStepper extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + const {stepIndex} = this.state; + const contentStyle = {margin: '0 16px'}; + + return ( +
+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + + + this.setState({stepIndex: 1})}> + Create an ad group + + + + this.setState({stepIndex: 2})}> + Create an ad + + + +
+

{this.getStepContent(stepIndex)}

+
+ + +
+
+
+ ); + } +} + +class VerticalNonLinear extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + renderStepActions(step) { + return ( +
+ + {step > 0 && ( + + )} +
+ ); + } + + render() { + const {stepIndex} = this.state; + + return ( +
+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + +

+ For each ad campaign that you create, you can control how much + you're willing to spend on clicks and conversions, which networks + and geographical locations you want your ads to show on, and more. +

+ {this.renderStepActions(0)} +
+
+ + this.setState({stepIndex: 1})}> + Create an ad group + + +

An ad group contains one or more ads which target a shared set of keywords.

+ {this.renderStepActions(1)} +
+
+ + this.setState({stepIndex: 2})}> + Create an ad + + +

+ Try out different ad text to see what brings in the most customers, + and learn how to enhance your ads using features like ad extensions. + If you run into any problems with your ads, find out how to tell if + they're running and how to resolve approval issues. +

+ {this.renderStepActions(2)} +
+
+
+
+ ); + } +} + +const getStyles = () => { + return { + root: { + width: '100%', + maxWidth: 700, + margin: 'auto', + }, + content: { + margin: '0 16px', + }, + actions: { + marginTop: 12, + }, + backButton: { + marginRight: 12, + }, + }; +}; + +class GranularControlStepper extends React.Component<{}, {stepIndex?: number, visited?: number[]}> { + + state = { + stepIndex: null, + visited: [], + }; + + componentWillMount() { + const {stepIndex, visited} = this.state; + this.setState({visited: visited.concat(stepIndex)}); + } + + componentWillUpdate(nextProps, nextState) { + const {stepIndex, visited} = nextState; + if (visited.indexOf(stepIndex) === -1) { + this.setState({visited: visited.concat(stepIndex)}); + } + } + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'Click a step to get started.'; + } + } + + render() { + const {stepIndex, visited} = this.state; + const styles = getStyles(); + + return ( +
+

+ { + event.preventDefault(); + this.setState({stepIndex: null, visited: []}); + }} + > + Click here + to reset the example. +

+ + + this.setState({stepIndex: 0})}> + Select campaign settings + + + + this.setState({stepIndex: 1})}> + Create an ad group + + + + this.setState({stepIndex: 2})}> + Create an ad + + + +
+

{this.getStepContent(stepIndex)}

+ {stepIndex !== null && ( +
+ + +
+ )} +
+
+ ); + } +} + +class CustomIcon extends React.Component<{}, {stepIndex?: number}> { + + state = { + stepIndex: 0, + }; + + handleNext = () => { + const {stepIndex} = this.state; + if (stepIndex < 2) { + this.setState({stepIndex: stepIndex + 1}); + } + }; + + handlePrev = () => { + const {stepIndex} = this.state; + if (stepIndex > 0) { + this.setState({stepIndex: stepIndex - 1}); + } + }; + + getStepContent(stepIndex) { + switch (stepIndex) { + case 0: + return 'Select campaign settings...'; + case 1: + return 'What is an ad group anyways?'; + case 2: + return 'This is the bit I really care about!'; + default: + return 'You\'re a long way from home sonny jim!'; + } + } + + render() { + return ( +
+ + + + Select campaign settings + + + + } + style={{color: red500}} + > + Create an ad group + + + + + Create an ad + + + +
+ ); + } +} + + +// "http://www.material-ui.com/#/components/subheader" +// Included in ListExampleChat and ListExampleFolder + +// "http://www.material-ui.com/#/components/table" +const TableExampleSimple = () => ( + + + + ID + Name + Status + + + + + 1 + John Smith + Employed + + + 2 + Randal White + Unemployed + + + 3 + Stephanie Sanders + Employed + + + 4 + Steve Brown + Employed + + +
+); + +const tableData: {name: string, status: string, selected?: boolean}[] = [ + { + name: 'John Smith', + status: 'Employed', + selected: true, + }, + { + name: 'Randal White', + status: 'Unemployed', + }, + { + name: 'Stephanie Sanders', + status: 'Employed', + selected: true, + }, + { + name: 'Steve Brown', + status: 'Employed', + }, + { + name: 'Joyce Whitten', + status: 'Employed', + }, + { + name: 'Samuel Roberts', + status: 'Employed', + }, + { + name: 'Adam Moore', + status: 'Employed', + }, +]; + +interface TableExampleComplexState { + fixedHeader?: boolean, + fixedFooter?: boolean, + stripedRows?: boolean, + showRowHover?: boolean, + selectable?: boolean, + multiSelectable?: boolean, + enableSelectAll?: boolean, + deselectOnClickaway?: boolean, + showCheckboxes?: boolean, + height?: string, +} + +class TableExampleComplex extends React.Component<{}, TableExampleComplexState> { + + constructor(props) { + super(props); + + this.state = { + fixedHeader: true, + fixedFooter: true, + stripedRows: false, + showRowHover: false, + selectable: true, + multiSelectable: false, + enableSelectAll: false, + deselectOnClickaway: true, + showCheckboxes: true, + height: '300px', + }; + } + + handleToggle = (event, toggled) => { + this.setState({ + [event.target.name]: toggled, + }); + }; + + handleChange = (event) => { + this.setState({height: event.target.value}); + }; + + render() { + return ( +
+ + + + + Super Header + + + + ID + Name + Status + + + + {tableData.map( (row, index) => ( + + {index} + {row.name} + {row.status} + + ))} + + + + ID + Name + Status + + + + Super Footer + + + +
+ +
+

Table Properties

+ + + + + + +

TableBody Properties

+ + + +

Multiple Properties

+ +
+
+ ); + } +} + +// "http://www.material-ui.com/#/components/tabs" +function handleActive(tab) { + alert(`A tab with this value property ${tab.props.value} was activated.`); +} + +const TabsExampleSimple = () => ( + + +
+

Tab One

+

+ This is an example tab. +

+

+ You can put any sort of HTML or react component in here. It even keeps the component state! +

+ +
+
+ +
+

Tab Two

+

+ This is another example tab. +

+
+
+ +
+

Tab Three

+

+ This is a third example tab. +

+
+
+
+); + +class TabsExampleControlled extends React.Component<{}, {value?: string}> { + + constructor(props) { + super(props); + this.state = { + value: 'a', + }; + } + + handleChange = (value) => { + this.setState({ + value: value, + }); + }; + + render() { + return ( + + +
+

Controllable Tab A

+

+ Tabs are also controllable if you want to programmatically pass them their values. + This allows for more functionality in Tabs such as not + having any Tab selected or assigning them different values. +

+
+
+ +
+

Controllable Tab B

+

+ This is another example of a controllable tab. Remember, if you + use controllable Tabs, you need to give all of your tabs values or else + you wont be able to select them. +

+
+
+
+ ); + } +} + +const TabsExampleIcon = () => ( + + } /> + } /> + favorite} /> + +); + +const TabsExampleIconText = () => ( + + phone} + label="RECENTS" + /> + favorite} + label="FAVORITES" + /> + } + label="NEARBY" + /> + +); + + +// "http://www.material-ui.com/#/components/text-field" +const TextFieldExampleSimple = () => ( +
+
+
+
+
+
+
+
+
+
+ +
+); + +const TextFieldExampleError = () => ( +
+
+
+
+
+
+); + +const TextFieldExampleCustomize = () => ( +
+
+
+
+
+ +
+); + +const TextFieldExampleDisabled = () => ( +
+
+
+
+ +
+); + +class TextFieldExampleControlled extends React.Component<{}, {value?: string}> { + + constructor(props) { + super(props); + + this.state = { + value: 'Property Value', + }; + } + + handleChange = (event) => { + this.setState({ + value: event.target.value, + }); + }; + + render() { + return ( +
+ +
+ ); + } +} + +// "http://www.material-ui.com/#/components/time-picker" +const TimePickerExampleSimple = () => ( +
+ + + +
+); + +class TimePickerExampleComplex extends React.Component<{}, {value24?: Date, value12?: Date}> { + + constructor(props) { + super(props); + this.state = {value24: null, value12: null}; + } + + handleChangeTimePicker24 = (event, date) => { + this.setState({value24: date}); + }; + + handleChangeTimePicker12 = (event, date) => { + this.setState({value12: date}); + }; + + render() { + return ( +
+ + +
+ ); + } +} + +const TimePickerInternational = () => ( +
+ +
+); + + +// "http://www.material-ui.com/#/components/toolbar" +class ToolbarExamplesSimple extends React.Component<{}, {value?: number}> { + + constructor(props) { + super(props); + this.state = { + value: 3, + }; + } + + handleChange = (event, index, value) => this.setState({value}); + + render() { + return ( + + + + + + + + + + + + + + + + + + + + + } + > + + + + + + ); + } +} + + +interface MaterialUiTestsState { +} + +class MaterialUiTests extends React.Component<{}, MaterialUiTestsState> { + + render () { + return ( + + + + + ); + } +} + +// "http://www.material-ui.com/#/get-started/usage" +ReactDOM.render( + , + document.getElementById('app') +); \ No newline at end of file diff --git a/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams b/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams new file mode 100644 index 0000000000..855355b85f --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0-tests.tsx.tscparams @@ -0,0 +1 @@ +--experimentalDecorators \ No newline at end of file diff --git a/material-ui/legacy/material-ui-0.15.0.d.ts b/material-ui/legacy/material-ui-0.15.0.d.ts new file mode 100644 index 0000000000..d566c16a46 --- /dev/null +++ b/material-ui/legacy/material-ui-0.15.0.d.ts @@ -0,0 +1,8414 @@ +// Type definitions for material-ui v0.15.0 +// Project: https://github.com/callemall/material-ui +// Definitions by: Nathan Brown , Oliver Herrmann +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "material-ui" { + export import AppBar = __MaterialUI.AppBar; + export import AutoComplete = __MaterialUI.AutoComplete; + export import Avatar = __MaterialUI.Avatar; + export import Badge = __MaterialUI.Badge; + export import Card = __MaterialUI.Card.Card; + export import CardActions = __MaterialUI.Card.CardActions; + export import CardHeader = __MaterialUI.Card.CardHeader; + export import CardMedia = __MaterialUI.Card.CardMedia; + export import CardText = __MaterialUI.Card.CardText; + export import CardTitle = __MaterialUI.Card.CardTitle; + export import Checkbox = __MaterialUI.Switches.Checkbox; + export import CircularProgress = __MaterialUI.CircularProgress; + export import DatePicker = __MaterialUI.DatePicker.DatePicker; + export import Dialog = __MaterialUI.Dialog; + export import Divider = __MaterialUI.Divider; + export import Drawer = __MaterialUI.Drawer; + export import DropDownMenu = __MaterialUI.Menus.DropDownMenu; + export import FlatButton = __MaterialUI.FlatButton; + export import FloatingActionButton = __MaterialUI.FloatingActionButton; + export import FontIcon = __MaterialUI.FontIcon; + export import GridList = __MaterialUI.GridList.GridList; + export import GridTile = __MaterialUI.GridList.GridTile; + export import IconButton = __MaterialUI.IconButton; + export import IconMenu = __MaterialUI.Menus.IconMenu; + export import LinearProgress = __MaterialUI.LinearProgress; + export import List = __MaterialUI.List.List; + export import ListItem = __MaterialUI.List.ListItem; + export import MakeSelectable = __MaterialUI.List.MakeSelectable; + export import Menu = __MaterialUI.Menus.Menu; + export import MenuItem = __MaterialUI.Menus.MenuItem; + export import Paper = __MaterialUI.Paper; + export import Popover = __MaterialUI.Popover.Popover; + export import RadioButton = __MaterialUI.Switches.RadioButton; + export import RadioButtonGroup = __MaterialUI.Switches.RadioButtonGroup; + export import RaisedButton = __MaterialUI.RaisedButton; + export import RefreshIndicator = __MaterialUI.RefreshIndicator; + export import SelectField = __MaterialUI.SelectField; + export import Slider = __MaterialUI.Slider; + export import Subheader = __MaterialUI.Subheader; + export import SvgIcon = __MaterialUI.SvgIcon; + export import Step = __MaterialUI.Stepper.Step; + export import StepButton = __MaterialUI.Stepper.StepButton; + export import StepContent = __MaterialUI.Stepper.StepContent; + export import StepLabel = __MaterialUI.Stepper.StepLabel; + export import Stepper = __MaterialUI.Stepper; + export import Snackbar = __MaterialUI.Snackbar; + export import Tab = __MaterialUI.Tabs.Tab; + export import Tabs = __MaterialUI.Tabs.Tabs; + export import Table = __MaterialUI.Table.Table; + export import TableBody = __MaterialUI.Table.TableBody; + export import TableFooter = __MaterialUI.Table.TableFooter; + export import TableHeader = __MaterialUI.Table.TableHeader; + export import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; + export import TableRow = __MaterialUI.Table.TableRow; + export import TableRowColumn = __MaterialUI.Table.TableRowColumn; + export import TextField = __MaterialUI.TextField; + export import TimePicker = __MaterialUI.TimePicker; + export import Toggle = __MaterialUI.Switches.Toggle; + export import Toolbar = __MaterialUI.Toolbar.Toolbar; + export import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; + export import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; + export import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; + + // export type definitions + export type TouchTapEvent = __MaterialUI.TouchTapEvent; + export type TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; +} + +declare namespace __MaterialUI { + export import React = __React; + + // ReactLink is from "react/addons" + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + // What's common between React.TouchEvent and React.MouseEvent + interface TouchTapEvent extends React.SyntheticEvent { + altKey: boolean; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + } + + // What's common between React.TouchEventHandler and React.MouseEventHandler + interface TouchTapEventHandler extends React.EventHandler { } + + interface ThemeWrapperProps extends React.Props { + theme: Styles.MuiTheme; + } + export class ThemeWrapper extends React.Component { + } + + export namespace Styles { + interface Spacing { + iconSize?: number; + + desktopGutter?: number; + desktopGutterMore?: number; + desktopGutterLess?: number; + desktopGutterMini?: number; + desktopKeylineIncrement?: number; + desktopDropDownMenuItemHeight?: number; + desktopDropDownMenuFontSize?: number; + desktopLeftNavMenuItemHeight?: number; + desktopSubheaderHeight?: number; + desktopToolbarHeight?: number; + } + export var Spacing: Spacing; + + interface ThemePalette { + primary1Color?: string; + primary2Color?: string; + primary3Color?: string; + accent1Color?: string; + accent2Color?: string; + accent3Color?: string; + textColor?: string; + alternateTextColor?: string; + canvasColor?: string; + borderColor?: string; + disabledColor?: string; + pickerHeaderColor?: string; + clockCircleColor?: string; + shadowColor?: string; + } + interface MuiTheme { + spacing?: Spacing; + fontFamily?: string; + palette?: ThemePalette; + isRtl?: boolean; + userAgent?: string; + zIndex?: zIndex; + baseTheme?: RawTheme; + rawTheme?: RawTheme; + appBar?: { + color?: string; + textColor?: string; + height?: number; + titleFontWeight?: number; + padding?: number; + }; + avatar?: { + color?: string; + backgroundColor?: string; + borderColor?: string; + }; + badge?: { + color?: string; + textColor?: string; + primaryColor?: string; + primaryTextColor?: string; + secondaryColor?: string; + secondaryTextColor?: string; + fontWeight?: number; + }; + button?: { + height?: number; + minWidth?: number; + iconButtonSize?: number; + }; + card?: { + titleColor?: string; + subtitleColor?: string; + fontWeight?: number; + }; + cardMedia?: { + color?: string; + overlayContentBackground?: string; + titleColor?: string; + subtitleColor?: string; + }; + cardText?: { + textColor?: string; + }; + checkbox?: { + boxColor?: string; + checkedColor?: string; + requiredColor?: string; + disabledColor?: string; + labelColor?: string; + labelDisabledColor?: string; + }; + chip?: { + backgroundColor?: string; + deleteIconColor?: string; + textColor?: string; + fontSize?: number; + fontWeight?: number; + shadow?: string; + }; + datePicker?: { + color?: string; + textColor?: string; + calendarTextColor?: string; + selectColor?: string; + selectTextColor?: string; + calendarYearBackgroundColor?: string; + }; + dialog?: { + titleFontSize?: number; + bodyFontSize?: number; + bodyColor?: string; + }; + dropDownMenu?: { + accentColor?: string; + }; + enhancedButton?: { + tapHighlightColor?: string; + }; + flatButton?: { + color?: string; + buttonFilterColor?: string; + disabledTextColor?: string; + textColor?: string; + primaryTextColor?: string; + secondaryTextColor?: string; + fontSize?: number; + fontWeight?: number; + }; + floatingActionButton?: { + buttonSize?: number; + miniSize?: number; + color?: string; + iconColor?: string; + secondaryColor?: string; + secondaryIconColor?: string; + disabledTextColor?: string; + disabledColor?: string; + }; + gridTile?: { + textColor?: string; + }; + icon?: { + color?: string; + backgroundColor?: string; + }; + inkBar?: { + backgroundColor?: string; + }; + navDrawer?: { + width?: number; + color?: string; + }; + listItem?: { + nestedLevelDepth?: number; + secondaryTextColor?: string; + leftIconColor?: string; + rightIconColor?: string; + }; + menu?: { + backgroundColor?: string; + containerBackgroundColor?: string; + }; + menuItem?: { + dataHeight?: number; + height?: number; + hoverColor?: string; + padding?: number; + selectedTextColor?: string; + rightIconDesktopFill?: string; + }; + menuSubheader?: { + padding?: number; + borderColor?: string; + textColor?: string; + }; + overlay?: { + backgroundColor?: string; + }; + paper?: { + color?: string; + backgroundColor?: string; + zDepthShadows?: string[]; + }; + radioButton?: { + borderColor?: string; + backgroundColor?: string; + checkedColor?: string; + requiredColor?: string; + disabledColor?: string; + size?: number; + labelColor?: string; + labelDisabledColor?: string; + }; + raisedButton?: { + color?: string; + textColor?: string; + primaryColor?: string; + primaryTextColor?: string; + secondaryColor?: string; + secondaryTextColor?: string; + disabledColor?: string; + disabledTextColor?: string; + fontSize?: number; + fontWeight?: number; + }; + refreshIndicator?: { + strokeColor?: string; + loadingStrokeColor?: string; + }; + ripple?: { + color?: string; + }; + slider?: { + trackSize?: number; + trackColor?: string; + trackColorSelected?: string; + handleSize?: number; + handleSizeDisabled?: number; + handleSizeActive?: number; + handleColorZero?: string; + handleFillColor?: string; + selectionColor?: string; + rippleColor?: string; + }; + snackbar?: { + textColor?: string; + backgroundColor?: string; + actionColor?: string; + }; + subheader?: { + color?: string; + fontWeight?: number; + }; + stepper?: { + backgroundColor?: string; + hoverBackgroundColor?: string; + iconColor?: string; + hoveredIconColor?: string; + inactiveIconColor?: string; + textColor?: string; + disabledTextColor?: string; + connectorLineColor?: string; + }; + table?: { + backgroundColor?: string; + }; + tableFooter?: { + borderColor?: string; + textColor?: string; + }; + tableHeader?: { + borderColor?: string; + }; + tableHeaderColumn?: { + textColor?: string; + height?: number; + spacing?: number; + }; + tableRow?: { + hoverColor?: string; + stripeColor?: string; + selectedColor?: string; + textColor?: string; + borderColor?: string; + height?: number; + }; + tableRowColumn?: { + height?: number; + spacing?: number; + }; + tabs?: { + backgroundColor?: string; + textColor?: string; + selectedTextColor?: string; + }; + textField?: { + textColor?: string; + hintColor?: string; + floatingLabelColor?: string; + disabledTextColor?: string; + errorColor?: string; + focusColor?: string; + backgroundColor?: string; + borderColor?: string; + }; + timePicker?: { + color?: string; + textColor?: string; + accentColor?: string; + clockColor?: string; + clockCircleColor?: string; + headerColor?: string; + selectColor?: string; + selectTextColor?: string; + }; + toggle?: { + thumbOnColor?: string; + thumbOffColor?: string; + thumbDisabledColor?: string; + thumbRequiredColor?: string; + trackOnColor?: string; + trackOffColor?: string; + trackDisabledColor?: string; + labelColor?: string; + labelDisabledColor?: string; + trackRequiredColor?: string; + }; + toolbar?: { + color?: string; + hoverColor?: string; + backgroundColor?: string; + height?: number; + titleFontSize?: number; + iconColor?: string; + separatorColor?: string; + menuHoverColor?: string; + }; + tooltip?: { + color?: string; + rippleBackgroundColor?: string; + }; + } + + interface zIndex { + menu: number; + appBar: number; + drawerOverlay: number; + navDrawer: number; + dialogOverlay: number; + dialog: number; + layer: number; + popover: number; + snackbar: number; + tooltip: number; + } + export var zIndex: zIndex; + + interface RawTheme { + spacing?: Spacing; + fontFamily?: string; + palette?: ThemePalette; + } + var lightBaseTheme: RawTheme; + var darkBaseTheme: RawTheme; + + export function muiThemeable, P, S>(): (component: TComponent) => TComponent; + + //** @deprecated use MuiThemeProvider instead **/ + export function themeDecorator(muiTheme: Styles.MuiTheme): (Component: TFunction) => TFunction; + + interface MuiThemeProviderProps extends React.Props { + muiTheme: Styles.MuiTheme; + } + export class MuiThemeProvider extends React.Component{ + } + + export function getMuiTheme(...muiTheme: MuiTheme[]): MuiTheme; + + interface ThemeManager { + //** @deprecated ThemeManager is deprecated. please import getMuiTheme directly from "material-ui/styles/getMuiTheme" **/ + getMuiTheme(baseTheme: RawTheme, muiTheme?: MuiTheme): MuiTheme; + + //** @deprecated modifyRawThemeSpacing is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemeSpacing(muiTheme: MuiTheme, newSpacing: Spacing): MuiTheme; + + //** @deprecated modifyRawThemePalette is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemePalette(muiTheme: MuiTheme, newPaletteKeys: ThemePalette): MuiTheme; + + //** @deprecated modifyRawThemeFontFamily is deprecated. please use getMuiTheme to modify your theme directly. http://www.material-ui.com/#/customization/themes **/ + modifyRawThemeFontFamily(muiTheme: MuiTheme, newFontFamily: string): MuiTheme; + } + export var ThemeManager: ThemeManager; + + interface Transitions { + easeOut(duration?: string, property?: string | string[], delay?: string, easeFunction?: string): string; + create(duration?: string, property?: string, delay?: string, easeFunction?: string): string; + easeOutFunction: string; + easeInOutFunction: string; + } + export var Transitions: Transitions; + + interface Typography { + textFullBlack: string; + textDarkBlack: string; + textLightBlack: string; + textMinBlack: string; + textFullWhite: string; + textDarkWhite: string; + textLightWhite: string; + + // font weight + fontWeightLight: number; + fontWeightNormal: number; + fontWeightMedium: number; + + fontStyleButtonFontSize: number; + } + export var Typography: Typography; + + //** @deprecated use darkBaseTheme instead **/ + export var DarkRawTheme: RawTheme; + + //** @deprecated use lightBaseTheme instead **/ + export var LightRawTheme: RawTheme; + } + + interface AppBarProps extends React.Props { + className?: string; + iconClassNameLeft?: string; + iconClassNameRight?: string; + iconElementLeft?: React.ReactElement; + iconElementRight?: React.ReactElement; + iconStyleRight?: string; + onLeftIconButtonTouchTap?: TouchTapEventHandler; + onRightIconButtonTouchTap?: TouchTapEventHandler; + onTitleTouchTap?: TouchTapEventHandler; + showMenuIconButton?: boolean; + style?: React.CSSProperties; + title?: React.ReactNode; + titleStyle?: React.CSSProperties; + zDepth?: number; + } + export class AppBar extends React.Component{ + } + + interface AppCanvasProps extends React.Props { + } + export class AppCanvas extends React.Component { + } + + namespace propTypes { + type horizontal = 'left' | 'middle' | 'right'; + type vertical = 'top' | 'center' | 'bottom'; + + interface origin { + horizontal: horizontal; + vertical: vertical; + } + + type corners = 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'; + type cornersAndCenter = 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right'; + } + + type AutoCompleteDataItem = { text: string, value: React.ReactNode } | string; + type AutoCompleteDataSource = { text: string, value: React.ReactNode }[] | string[]; + interface AutoCompleteProps extends React.Props { + anchorOrigin?: propTypes.origin; + animated?: boolean; + dataSource: AutoCompleteDataSource; + disableFocusRipple?: boolean; + errorStyle?: React.CSSProperties; + errorText?: string; + filter?: (searchText: string, key: string, item: AutoCompleteDataItem) => boolean; + floatingLabelText?: string; + fullWidth?: boolean; + hintText?: string; + listStyle?: React.CSSProperties; + maxSearchResults?: number; + menuCloseDelay?: number; + menuProps?: any; + menuStyle?: React.CSSProperties; + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + onKeyDown?: React.KeyboardEventHandler; + onNewRequest?: (chosenRequest: string, index: number) => void; + onUpdateInput?: (searchText: string, dataSource: AutoCompleteDataSource) => void; + open?: boolean; + openOnFocus?: boolean; + searchText?: string; + style?: React.CSSProperties; + targetOrigin?: propTypes.origin; + /** @deprecated Instead, use openOnFocus */ + triggerUpdateOnFocus?: boolean; + } + export class AutoComplete extends React.Component { + static noFilter: () => boolean; + static defaultFilter: (searchText: string, key: string) => boolean; + static caseSensitiveFilter: (searchText: string, key: string) => boolean; + static caseInsensitiveFilter: (searchText: string, key: string) => boolean; + static levenshteinDistanceFilter(distanceLessThan: number): (searchText: string, key: string) => boolean; + static fuzzyFilter: (searchText: string, key: string) => boolean; + static Item: Menus.MenuItem; + static Divider: Divider; + } + + interface AvatarProps extends React.Props { + backgroundColor?: string; + className?: string; + color?: string; + icon?: React.ReactElement; + size?: number; + src?: string; + style?: React.CSSProperties; + } + export class Avatar extends React.Component { + } + + interface BadgeProps extends React.Props { + badgeContent: React.ReactNode; + badgeStyle?: React.CSSProperties; + className?: string; + primary?: boolean; + secondary?: boolean; + style?: React.CSSProperties; + } + export class Badge extends React.Component { + } + + interface BeforeAfterWrapperProps extends React.Props { + afterElementType?: string; + afterStyle?: React.CSSProperties; + beforeElementType?: string; + beforeStyle?: React.CSSProperties; + elementType?: string; + style?: React.CSSProperties; + } + export class BeforeAfterWrapper extends React.Component { + } + + // non generally overridden elements of EnhancedButton + interface SharedEnhancedButtonProps extends React.Props { + centerRipple?: boolean; + disableFocusRipple?: boolean; + disableKeyboardFocus?: boolean; + disableTouchRipple?: boolean; + focusRippleColor?: string; + focusRippleOpacity?: number; + keyboardFocused?: boolean; + linkButton?: boolean; + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + onKeyboardFocus?: (e: React.FocusEvent, isKeyboardFocused: boolean) => void; + onKeyDown?: React.KeyboardEventHandler; + onKeyUp?: React.KeyboardEventHandler; + onTouchTap?: TouchTapEventHandler; + onClick?: React.MouseEventHandler; + style?: React.CSSProperties; + tabIndex?: number; + touchRippleColor?: string; + touchRippleOpacity?: number; + type?: string; + containerElement?: React.ReactNode | string; + } + + interface EnhancedButtonProps extends React.HTMLAttributes, SharedEnhancedButtonProps { + // container element,