Initial commit of the search sample web part
This commit is contained in:
parent
4573e91fe6
commit
3e9f373878
|
@ -0,0 +1,25 @@
|
|||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
|
||||
# change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# we recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[{package,bower}.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1 @@
|
|||
* text=auto
|
|
@ -0,0 +1,35 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Yeoman configuration files
|
||||
.yo-rc.json
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
solution
|
||||
temp
|
||||
*.spapp
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
|
@ -0,0 +1,14 @@
|
|||
# Folders
|
||||
.vscode
|
||||
coverage
|
||||
node_modules
|
||||
solution
|
||||
src
|
||||
temp
|
||||
|
||||
# Files
|
||||
*.csproj
|
||||
.git*
|
||||
.yo-rc.json
|
||||
gulpfile.js
|
||||
tsconfig.json
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch localhost with sourcemaps",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"url": "http://localhost:4321/temp/workbench.html",
|
||||
"webRoot": "${workspaceRoot}/src",
|
||||
"sourceMaps": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
// The number of spaces a tab is equal to.
|
||||
"editor.tabSize": 4,
|
||||
|
||||
// When enabled, will trim trailing whitespace when you save a file.
|
||||
"files.trimTrailingWhitespace": true,
|
||||
|
||||
// Controls if the editor should automatically close brackets after opening them
|
||||
"editor.autoClosingBrackets": false,
|
||||
|
||||
// Configure glob patterns for excluding files and folders.
|
||||
"search.exclude": {
|
||||
"**/bower_components": true,
|
||||
"**/node_modules": true,
|
||||
"coverage": true,
|
||||
"dist": true,
|
||||
"lib-amd": true,
|
||||
"lib": true,
|
||||
"temp": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "gulp",
|
||||
"isShellCommand": true,
|
||||
"showOutput": "always",
|
||||
"args": [
|
||||
"--no-color"
|
||||
],
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "bundle",
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"taskName": "test",
|
||||
"isTestCommand": true,
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"taskName": "serve",
|
||||
"isWatching": true,
|
||||
"problemMatcher": [
|
||||
"$tsc"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2016 Elio Struyf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,69 @@
|
|||
# Search Client-Side Web Part built with React and Flux
|
||||
|
||||
## Summary
|
||||
|
||||
Sample Search Web Part with internal and external template support. This sample illustrates how you can use React and Flux within the SharePoint Framework.
|
||||
|
||||
![Sample of the search web part](./assets/preview.png)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Framework Developer Preview](http://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview)
|
||||
* [Office 365 developer tenant](http://dev.office.com/sharepoint/docs/spfx/set-up-your-developer-tenant)
|
||||
|
||||
## Solution
|
||||
|
||||
Solution|Author(s)
|
||||
--------|---------
|
||||
react-search-wp|Elio Struyf (MVP, Ventigrate, [@eliostruyf](https://twitter.com/eliostruyf))
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
0.0.4|September 08, 2016|Initial release
|
||||
|
||||
## Disclaimer
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
---
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
- Clone this repo
|
||||
- In the command line run:
|
||||
- `npm i`
|
||||
- `tsd install`
|
||||
- `gulp serve`
|
||||
- Open the *workbench* on your Office 365 Developer tenant
|
||||
- Test out the web part
|
||||
|
||||
## Features
|
||||
|
||||
The search web part is a sample client-side web part built on the SharePoint Framework. The web part makes use of React and the Flux pattern.
|
||||
|
||||
The web part has built in templating support for internal (created within the project) and external (loaded from a URL) templates.
|
||||
|
||||
**Internal templates**
|
||||
|
||||
Internal templates can be found in the [templates]('./src/webparts/templates') folder. You can start building your own templates by using one of the provided samples.
|
||||
|
||||
![Internal template settings](./assets/internal.png)
|
||||
|
||||
**External templates**
|
||||
|
||||
External templates can be loaded from an URL.
|
||||
|
||||
![External template settings](./assets/external.png)
|
||||
|
||||
If you want to test out this functionality, you can find a couple of sample templates in the [external templates]('./external_templates') folder. Upload one of these templates to your site, copy the file location and past it in the textbox.
|
||||
|
||||
This Web Part illustrates the following concepts on top of the SharePoint Framework:
|
||||
|
||||
- using React and the Flux pattern with TypeScript for building SharePoint Framework Client-Side Web Parts
|
||||
- loading CSS stylesheets from CDN
|
||||
- using non-reactive Web Part Property Pane
|
||||
- loading external templates to render
|
||||
- loading scripts and stylesheets which are required in the external template (example: loading jQuery or a custom stylesheet).
|
||||
|
||||
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-search-wp" />
|
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"entries": [
|
||||
{
|
||||
"entry": "./lib/webparts/searchSpfx/SearchSpfxWebPart.js",
|
||||
"manifest": "./src/webparts/searchSpfx/SearchSpfxWebPart.manifest.json",
|
||||
"outputPath": "./dist/search-spfx.bundle.js"
|
||||
}
|
||||
],
|
||||
"externals": {
|
||||
"@microsoft/sp-client-base": "node_modules/@microsoft/sp-client-base/dist/sp-client-base.js",
|
||||
"@microsoft/sp-client-preview": "node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js",
|
||||
"@microsoft/sp-lodash-subset": "node_modules/@microsoft/sp-lodash-subset/dist/sp-lodash-subset.js",
|
||||
"office-ui-fabric-react": "node_modules/office-ui-fabric-react/dist/office-ui-fabric-react.js",
|
||||
"react": "node_modules/react/dist/react.min.js",
|
||||
"react-dom": "node_modules/react-dom/dist/react-dom.min.js",
|
||||
"react-dom/server": "node_modules/react-dom/dist/react-dom-server.min.js",
|
||||
"moment": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"
|
||||
},
|
||||
"localizedResources": {
|
||||
"mystrings": "webparts/searchSpfx/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"workingDir": "./temp/deploy/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "search-wp-spfx",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"solution": {
|
||||
"name": "search-wp-spfx-client-side-solution",
|
||||
"id": "65493d61-9d21-46e7-bc08-23ea857b4c95",
|
||||
"version": "1.0.0.0"
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "search-wp-spfx.spapp"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"deployCdnPath": "temp/deploy"
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"port": 4321,
|
||||
"initialPage": "https://localhost:5432/workbench",
|
||||
"https": true,
|
||||
"api": {
|
||||
"port": 5432,
|
||||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
// Display errors as warnings
|
||||
"displayAsWarning": true,
|
||||
// The TSLint task may have been configured with several custom lint rules
|
||||
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
|
||||
// project). If true, this flag will deactivate any of these rules.
|
||||
"removeExistingRules": true,
|
||||
// When true, the TSLint task is configured with some default TSLint "rules.":
|
||||
"useDefaultConfigAsBase": false,
|
||||
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
|
||||
// which are active, other than the list of rules below.
|
||||
"lintConfig": {
|
||||
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
|
||||
"rules": {
|
||||
"class-name": false,
|
||||
"export-name": false,
|
||||
"forin": false,
|
||||
"label-position": false,
|
||||
"label-undefined": false,
|
||||
"member-access": true,
|
||||
"no-arg": false,
|
||||
"no-console": false,
|
||||
"no-construct": false,
|
||||
"no-duplicate-case": true,
|
||||
"no-duplicate-key": false,
|
||||
"no-duplicate-variable": true,
|
||||
"no-eval": false,
|
||||
"no-function-expression": true,
|
||||
"no-internal-module": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-semicolons": true,
|
||||
"no-unused-expression": true,
|
||||
"no-unused-imports": true,
|
||||
"no-unused-variable": true,
|
||||
"no-unreachable": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-with-statement": true,
|
||||
"semicolon": true,
|
||||
"trailing-comma": false,
|
||||
"typedef": false,
|
||||
"typedef-whitespace": false,
|
||||
"use-named-parameter": true,
|
||||
"valid-typeof": true,
|
||||
"variable-name": false,
|
||||
"whitespace": false,
|
||||
"prefer-const": true,
|
||||
"a11y-role": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
var externalTemplate = (function() {
|
||||
var properties = {
|
||||
key: 'SampleTemplate',
|
||||
text: 'Sample template',
|
||||
mappings: 'Path,Title,Filename'
|
||||
},
|
||||
component = React.createClass({
|
||||
displayName: 'Component',
|
||||
|
||||
render: function render() {
|
||||
console.log(this.props.results);
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"h1",
|
||||
null,
|
||||
"External sample template"
|
||||
),
|
||||
this.props.results.map(function (result, index) {
|
||||
return React.createElement(
|
||||
"p",
|
||||
null,
|
||||
React.createElement(
|
||||
"a",
|
||||
{ key: index, href: result.Path },
|
||||
result.Title
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
properties: properties,
|
||||
component: component
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,52 @@
|
|||
var externalTemplate = (function() {
|
||||
var properties = {
|
||||
key: 'CarouselTemplate',
|
||||
text: 'Carousel template',
|
||||
mappings: 'Path,Title,Filename,PictureThumbnailURL',
|
||||
scripts: [{
|
||||
url: 'https://code.jquery.com/jquery-1.12.4.min.js',
|
||||
funcName: 'jQuery'
|
||||
}, {
|
||||
url: 'https://cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/2.1.6/jquery.cycle2.min.js',
|
||||
funcName: 'cycle'
|
||||
}],
|
||||
styles: []
|
||||
},
|
||||
component = React.createClass({
|
||||
displayName: 'Component',
|
||||
|
||||
componentDidMount: function() {
|
||||
this._startCarousel();
|
||||
},
|
||||
|
||||
_startCarousel: function() {
|
||||
jQuery(function() {
|
||||
jQuery('.cycle-slideshow').cycle();
|
||||
});
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"h1",
|
||||
null,
|
||||
"Carousel template sample"
|
||||
),
|
||||
React.createElement(
|
||||
"div",
|
||||
{ className: "cycle-slideshow" },
|
||||
this.props.results.map(function (result, index) {
|
||||
return React.createElement("img", { src: result.PictureThumbnailURL, key: index });
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
properties: properties,
|
||||
component: component
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,52 @@
|
|||
var externalTemplate = (function() {
|
||||
var properties = {
|
||||
key: 'jQueryTemplate',
|
||||
text: 'jQuery template',
|
||||
mappings: 'Path,Title,Filename,ModifiedOWSDATE',
|
||||
scripts: [{
|
||||
url: 'https://code.jquery.com/jquery-3.1.0.js',
|
||||
name: 'jQuery'
|
||||
}],
|
||||
styles: [{
|
||||
url: '<your-site-url>/sample_style.css'
|
||||
}]
|
||||
},
|
||||
component = React.createClass({
|
||||
displayName: 'Component',
|
||||
|
||||
componentDidMount: function() {
|
||||
jQuery(function() {
|
||||
var elm = jQuery('h1');
|
||||
elm.text(elm.text() + ' - updated with jQuery').css('color', '#c00000');
|
||||
});
|
||||
},
|
||||
|
||||
render: function render() {
|
||||
return React.createElement(
|
||||
"div",
|
||||
null,
|
||||
React.createElement(
|
||||
"h1",
|
||||
null,
|
||||
"External sample template"
|
||||
),
|
||||
this.props.results.map(function (result, index) {
|
||||
return React.createElement(
|
||||
"p",
|
||||
{ key: index, className: "my-sample-template" },
|
||||
React.createElement(
|
||||
"a",
|
||||
{ href: result.Path },
|
||||
result.Title
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
properties: properties,
|
||||
component: component
|
||||
}
|
||||
})();
|
|
@ -0,0 +1,4 @@
|
|||
p.my-sample-template a {
|
||||
color: #003366;
|
||||
font-weight: bold;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const gulp = require('gulp');
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.initialize(gulp);
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "search-wp-spfx",
|
||||
"version": "0.0.4",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@microsoft/sp-client-base": "~0.2.0",
|
||||
"@microsoft/sp-client-preview": "~0.2.0",
|
||||
"flux": "^2.1.1",
|
||||
"moment": "^2.14.1",
|
||||
"office-ui-fabric-react": "0.36.0",
|
||||
"react": "0.14.8",
|
||||
"react-dom": "0.14.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/sp-build-web": "~0.5.0",
|
||||
"@microsoft/sp-module-interfaces": "~0.2.0",
|
||||
"@microsoft/sp-webpart-workbench": "~0.2.0",
|
||||
"expose-loader": "^0.7.1",
|
||||
"gulp": "~3.9.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp nuke",
|
||||
"test": "gulp test"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Gulp" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{65493d61-9d21-46e7-bc08-23ea857b4c95}</ProjectGuid>
|
||||
<ProjectHome />
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
<StartupFile>node_modules\gulp\bin\gulp.js</StartupFile>
|
||||
<WorkingDirectory>.</WorkingDirectory>
|
||||
<OutputPath>.</OutputPath>
|
||||
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
|
||||
<TypeScriptSourceMap>true</TypeScriptSourceMap>
|
||||
<TypeScriptModuleKind>CommonJS</TypeScriptModuleKind>
|
||||
<EnableTypeScript>false</EnableTypeScript>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
<ScriptArguments>serve</ScriptArguments>
|
||||
<StartWebBrowser>True</StartWebBrowser>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
|
||||
<Target Name="Gulp">
|
||||
<Message Text="Running gulp2vs.js" Importance="normal" />
|
||||
<Exec Command="CMD.EXE /c node $(MSBuildThisFileDirectory)\node_modules\gulp\bin\gulp.js bundle" />
|
||||
</Target>
|
||||
<ItemGroup>
|
||||
<Content Include="*.js" />
|
||||
<Content Include="*.json" />
|
||||
<Content Include="*.md" />
|
||||
<Content Include="config\**\*.json" />
|
||||
<Content Include="docs\*.md" />
|
||||
<Content Include="sharepoint\feature_xml\**\*.*" />
|
||||
<Content Include="src\**\*.html" />
|
||||
<Content Include="src\**\*.js" />
|
||||
<Content Include="src\**\*.json" />
|
||||
<Content Include="src\**\*.less" />
|
||||
<Content Include="src\**\*.resx" />
|
||||
<Content Include="src\**\*.scss" />
|
||||
<Content Include="src\**\*.ts" />
|
||||
<Content Include="src\**\*.tsx" />
|
||||
<Content Include="typings\**\*.ts" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<!--Do not delete the following Import Project. While this appears to do nothing it is a marker for setting TypeScript properties before our import that depends on them.-->
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="False" />
|
||||
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>False</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:48022/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://localhost:1337</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
|
||||
<WebProjectProperties>
|
||||
<StartPageUrl>
|
||||
</StartPageUrl>
|
||||
<StartAction>CurrentPage</StartAction>
|
||||
<AspNetDebugging>True</AspNetDebugging>
|
||||
<SilverlightDebugging>False</SilverlightDebugging>
|
||||
<NativeDebugging>False</NativeDebugging>
|
||||
<SQLDebugging>False</SQLDebugging>
|
||||
<ExternalProgram>
|
||||
</ExternalProgram>
|
||||
<StartExternalURL>
|
||||
</StartExternalURL>
|
||||
<StartCmdLineArguments>
|
||||
</StartCmdLineArguments>
|
||||
<StartWorkingDirectory>
|
||||
</StartWorkingDirectory>
|
||||
<EnableENC>False</EnableENC>
|
||||
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
|
@ -0,0 +1,5 @@
|
|||
var context = require.context('.', true, /.+\.test\.js?$/);
|
||||
|
||||
context.keys().forEach(context);
|
||||
|
||||
module.exports = context;
|
|
@ -0,0 +1,9 @@
|
|||
export interface ISearchSpfxWebPartProps {
|
||||
title: string;
|
||||
query?: string;
|
||||
sorting?: string;
|
||||
template?: string;
|
||||
maxResults?: number;
|
||||
external?: boolean;
|
||||
externalUrl?: string;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
.searchSpfx {
|
||||
.container {
|
||||
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
|
||||
max-width: 700px;
|
||||
margin: 0px auto;
|
||||
}
|
||||
|
||||
.templateTable {
|
||||
a {
|
||||
text-decoration: none;
|
||||
|
||||
&:visited {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
|
||||
|
||||
"id": "2b125755-159d-4799-8210-b091a3d967c3",
|
||||
"componentType": "WebPart",
|
||||
"version": "0.0.1",
|
||||
"manifestVersion": 2,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "2b125755-159d-4799-8210-b091a3d967c3",
|
||||
"group": { "default": "Under Development" },
|
||||
"title": { "default": "SearchSpfx" },
|
||||
"description": { "default": "Search web part built with SPFx" },
|
||||
"officeFabricIconFontName": "Search",
|
||||
"properties": {
|
||||
"title": "",
|
||||
"query": "*",
|
||||
"template": "DefaultTemplate",
|
||||
"maxResults": 10,
|
||||
"sorting": "",
|
||||
"external": false,
|
||||
"externalUrl": ""
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
import {
|
||||
BaseClientSideWebPart,
|
||||
IPropertyPaneSettings,
|
||||
IWebPartContext,
|
||||
PropertyPaneTextField,
|
||||
PropertyPaneDropdown,
|
||||
PropertyPaneSlider,
|
||||
PropertyPaneToggle
|
||||
} from '@microsoft/sp-client-preview';
|
||||
|
||||
import ModuleLoader from '@microsoft/sp-module-loader';
|
||||
|
||||
import * as strings from 'mystrings';
|
||||
import SearchSpfx, { ISearchSpfxProps } from './components/SearchSpfx';
|
||||
import { ISearchSpfxWebPartProps } from './ISearchSpfxWebPartProps';
|
||||
import { IExternalTemplate, IScripts, IStyles } from './utils/ITemplates';
|
||||
import { defer, IDeferred } from './utils/defer';
|
||||
import { allTemplates } from './templates/TemplateLoader';
|
||||
|
||||
// Expose React to window -> required for external template loading
|
||||
require("expose?React!react");
|
||||
|
||||
export default class SearchSpfxWebPart extends BaseClientSideWebPart<ISearchSpfxWebPartProps> {
|
||||
private crntExternalTemplateUrl: string = "";
|
||||
private crntExternalTemplate: IExternalTemplate = null;
|
||||
|
||||
public constructor(context: IWebPartContext) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the element to render
|
||||
*/
|
||||
private _getElement(externalTemplate?: IExternalTemplate): React.ReactElement<ISearchSpfxProps> {
|
||||
return React.createElement(SearchSpfx, {
|
||||
title: this.properties.title,
|
||||
query: this.properties.query,
|
||||
maxResults: this.properties.maxResults,
|
||||
sorting: this.properties.sorting,
|
||||
context: this.context,
|
||||
firstRender: this.renderedOnce,
|
||||
template: this.properties.template,
|
||||
externalTemplate: externalTemplate
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all scripts required to render the element
|
||||
*/
|
||||
private _loadScriptsBeforeRender(scriptsToLoad?: IScripts[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
this._loadScripts(scriptsToLoad).then(() => {
|
||||
resolve();
|
||||
}).catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Append the scripts to load
|
||||
*/
|
||||
private _loadScripts(scriptsToLoad: IScripts[], deferred?: IDeferred<any>): Promise<any> {
|
||||
if (!deferred) {
|
||||
deferred = defer();
|
||||
}
|
||||
if (scriptsToLoad.length > 0) {
|
||||
if (this.TypeofFullName(scriptsToLoad[0].funcName) === "function") {
|
||||
return this._loadScripts(scriptsToLoad.slice(1, scriptsToLoad.length), deferred);
|
||||
}
|
||||
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = scriptsToLoad[0].url;
|
||||
// Wait untin script is loaded
|
||||
script.onload = () => {
|
||||
// Load the next script
|
||||
return this._loadScripts(scriptsToLoad.slice(1, scriptsToLoad.length), deferred);
|
||||
};
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
} else {
|
||||
deferred.resolve(null);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the type of the function name
|
||||
*/
|
||||
private TypeofFullName(funcName: string): string {
|
||||
if (!Boolean(funcName)) {
|
||||
return "undefined";
|
||||
}
|
||||
const funcSplit: string[] = funcName.split(".");
|
||||
let scriptFunc: any = window;
|
||||
for (let i: number = 0; i < funcSplit.length; i++) {
|
||||
scriptFunc = scriptFunc[funcSplit[i]];
|
||||
if (typeof scriptFunc == "undefined")
|
||||
return "undefined";
|
||||
}
|
||||
return typeof scriptFunc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load stylesheets required for your element
|
||||
*/
|
||||
private _loadStyles(stylesToLoad: IStyles[]): void {
|
||||
stylesToLoad.forEach(style => {
|
||||
ModuleLoader.loadCss(style.url);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the element
|
||||
*/
|
||||
public render(): void {
|
||||
// Check if an external template needs to be loaded
|
||||
if (this.properties.external && this.properties.externalUrl !== "") {
|
||||
// Check if the external template URL has been changed (otherwise load from memory)
|
||||
if (this.crntExternalTemplateUrl !== this.properties.externalUrl) {
|
||||
// Loading external template
|
||||
ModuleLoader.loadScript(this.properties.externalUrl, "externalTemplate").then((externalTemplate: IExternalTemplate): void => {
|
||||
// Store the current template information
|
||||
this.crntExternalTemplate = externalTemplate;
|
||||
this.crntExternalTemplateUrl = this.properties.externalUrl;
|
||||
// Check if other scripts have to be loaded before rendering the component
|
||||
// Only do this the first time the web part loads
|
||||
if (typeof externalTemplate.properties.scripts !== 'undefined') {
|
||||
this._loadScriptsBeforeRender(externalTemplate.properties.scripts).then(() => {
|
||||
// Rendering from the external template
|
||||
const element = this._getElement(externalTemplate);
|
||||
ReactDom.render(element, this.domElement);
|
||||
});
|
||||
} else {
|
||||
// Rendering from the external template
|
||||
const element = this._getElement(externalTemplate);
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
// Check if their are any styles that need to be loaded
|
||||
if (typeof externalTemplate.properties.styles !== 'undefined') {
|
||||
this._loadStyles(externalTemplate.properties.styles);
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log('ERROR: ', error);
|
||||
});
|
||||
} else {
|
||||
// Rendering from the external template from memory
|
||||
const element = this._getElement(this.crntExternalTemplate);
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
} else {
|
||||
// Render from internal template
|
||||
const element = this._getElement();
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Property pane settings
|
||||
*/
|
||||
protected get propertyPaneSettings(): IPropertyPaneSettings {
|
||||
// Default template property
|
||||
let templateProperty: any = PropertyPaneDropdown('template', {
|
||||
label: strings.FieldsTemplateLabel,
|
||||
options: allTemplates
|
||||
});
|
||||
|
||||
// Check if you want to load an external template
|
||||
if (this.properties.external) {
|
||||
// Show the external URL property instead of the internal template property
|
||||
templateProperty = PropertyPaneTextField('externalUrl', {
|
||||
label: strings.FieldsExternalTempLabel
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
pages: [{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('title', {
|
||||
label: strings.FieldsTitleLabel
|
||||
}),
|
||||
PropertyPaneTextField('query', {
|
||||
label: strings.QueryFieldLabel,
|
||||
description: strings.QueryInfoDescription,
|
||||
multiline: true
|
||||
}),
|
||||
PropertyPaneSlider('maxResults', {
|
||||
label: strings.FieldsMaxResults,
|
||||
min: 1,
|
||||
max: 50
|
||||
}),
|
||||
PropertyPaneTextField('sorting', {
|
||||
label: strings.FieldsSorting
|
||||
}),
|
||||
PropertyPaneToggle('external', {
|
||||
label: strings.FieldsExternalLabel
|
||||
}),
|
||||
templateProperty
|
||||
]
|
||||
}]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent from changing the query on typing
|
||||
*/
|
||||
protected get disableReactivePropertyChanges(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
import * as React from 'react';
|
||||
import { ISearchSpfxWebPartProps } from '../ISearchSpfxWebPartProps';
|
||||
import { IWebPartContext } from '@microsoft/sp-client-preview';
|
||||
|
||||
import searchActions from '../flux/actions/searchActions';
|
||||
import searchStore from '../flux/stores/searchStore';
|
||||
|
||||
import { IExternalTemplate } from '../utils/ITemplates';
|
||||
|
||||
import TemplateLoader from '../templates/TemplateLoader';
|
||||
|
||||
export interface ISearchSpfxProps extends ISearchSpfxWebPartProps {
|
||||
context: IWebPartContext;
|
||||
firstRender: Boolean;
|
||||
externalTemplate?: IExternalTemplate;
|
||||
}
|
||||
|
||||
export interface ISearchState {
|
||||
results?: any[];
|
||||
loaded?: Boolean;
|
||||
component?: any;
|
||||
template?: string;
|
||||
}
|
||||
|
||||
export default class SearchSpfx extends React.Component<ISearchSpfxProps, ISearchState> {
|
||||
private loader: TemplateLoader = new TemplateLoader();
|
||||
|
||||
constructor(props: ISearchSpfxProps, context: IWebPartContext) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
results: [],
|
||||
loaded: false,
|
||||
component: null,
|
||||
template: ""
|
||||
};
|
||||
this._onChange = this._onChange.bind(this);
|
||||
};
|
||||
|
||||
public componentWillMount(): void {
|
||||
// Check if rendering is done from an external template
|
||||
if (typeof this.props.externalTemplate !== 'undefined') {
|
||||
// Loading internal template
|
||||
this.loader.getComponent(this.props.template).then((component) => {
|
||||
this.setState({
|
||||
template: this.props.template,
|
||||
component: component
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
searchStore.addChangeListener(this._onChange);
|
||||
this._getResults(this.props);
|
||||
}
|
||||
|
||||
public componentWillUnmount(): void {
|
||||
searchStore.removeChangeListener(this._onChange);
|
||||
}
|
||||
|
||||
public componentWillReceiveProps(nextProps: ISearchSpfxProps): void {
|
||||
// Get the new results
|
||||
this._getResults(nextProps);
|
||||
}
|
||||
|
||||
private _getResults(crntProps: ISearchSpfxProps): void {
|
||||
if (typeof crntProps.externalTemplate !== 'undefined') {
|
||||
searchActions.get(crntProps.context, crntProps.query, crntProps.maxResults, crntProps.sorting, crntProps.externalTemplate.properties.mappings);
|
||||
} else {
|
||||
searchActions.get(crntProps.context, crntProps.query, crntProps.maxResults, crntProps.sorting, this.loader.getTemplateMappings(crntProps.template));
|
||||
}
|
||||
}
|
||||
|
||||
private _onChange(): void {
|
||||
// Check if another template needs to be loaded
|
||||
if (typeof this.props.externalTemplate === 'undefined' && this.state.template !== this.props.template) {
|
||||
this.loader.getComponent(this.props.template).then((component) => {
|
||||
this.setState({
|
||||
template: this.props.template,
|
||||
component: component
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({
|
||||
results: searchStore.getSearchResults(),
|
||||
loaded: true
|
||||
});
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
if (this.props.firstRender || this.state.loaded) {
|
||||
if (this.state.results.length === 0) {
|
||||
return (
|
||||
<div>
|
||||
Sorry, no results found.
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
// Load the template
|
||||
if (typeof this.props.externalTemplate !== 'undefined') {
|
||||
/* tslint:disable:variable-name */
|
||||
const CrntComponent: any = this.props.externalTemplate.component;
|
||||
/* tslint:disable:variable-name */
|
||||
return <CrntComponent {...this.props} results={this.state.results} />;
|
||||
}
|
||||
else if (this.state.component !== null) {
|
||||
/* tslint:disable:variable-name */
|
||||
const CrntComponent: any = this.state.component;
|
||||
/* tslint:disable:variable-name */
|
||||
return <CrntComponent {...this.props} results={this.state.results} />;
|
||||
} else {
|
||||
return (<div />);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return (<div />);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import {IWebPartContext} from '@microsoft/sp-client-preview';
|
||||
export interface ISearchAction {
|
||||
actionType: Number;
|
||||
context?: IWebPartContext;
|
||||
query?: string;
|
||||
maxResults?: number;
|
||||
sorting?: string;
|
||||
fields?: string;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
enum searchActionIDs {
|
||||
SEARCH_GET
|
||||
}
|
||||
|
||||
export default searchActionIDs;
|
|
@ -0,0 +1,23 @@
|
|||
import appDispatcher from '../dispatcher/appDispatcher';
|
||||
import searchActionIDs from './searchActionIDs';
|
||||
import {IWebPartContext} from '@microsoft/sp-client-preview';
|
||||
|
||||
export class SearchActionsStatic {
|
||||
/**
|
||||
* @param {string} query
|
||||
* @param {string} fields
|
||||
*/
|
||||
public get(context: IWebPartContext, query: string, maxResults: number, sorting: string, fields?: string): void {
|
||||
appDispatcher.dispatch({
|
||||
actionType: searchActionIDs.SEARCH_GET,
|
||||
context: context,
|
||||
query: query,
|
||||
maxResults: maxResults,
|
||||
sorting: sorting,
|
||||
fields: fields
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const searchActions: SearchActionsStatic = new SearchActionsStatic();
|
||||
export default searchActions;
|
|
@ -0,0 +1,5 @@
|
|||
import * as flux from 'flux';
|
||||
import {ISearchAction} from '../actions/ISearchAction';
|
||||
|
||||
const appDispatcher: flux.Dispatcher<ISearchAction> = new flux.Dispatcher();
|
||||
export default appDispatcher;
|
|
@ -0,0 +1,145 @@
|
|||
import appDispatcher from '../dispatcher/appDispatcher';
|
||||
import searchActionIDs from '../actions/searchActionIDs';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { IWebPartContext } from '@microsoft/sp-client-preview';
|
||||
import { ISearchResults, ICells, ICellValue } from '../../utils/ISearchResults';
|
||||
import { IPageContext } from '../../utils/IPageContext';
|
||||
|
||||
declare const _spPageContextInfo: IPageContext;
|
||||
|
||||
const CHANGE_EVENT: string = 'change';
|
||||
|
||||
export class SearchStoreStatic extends EventEmitter {
|
||||
private _results: any[] = [];
|
||||
|
||||
/**
|
||||
* @param {function} callback
|
||||
*/
|
||||
public addChangeListener(callback: Function): void {
|
||||
this.on(CHANGE_EVENT, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function} callback
|
||||
*/
|
||||
public removeChangeListener(callback: Function): void {
|
||||
this.removeListener(CHANGE_EVENT, callback);
|
||||
}
|
||||
|
||||
public emitChange(): void {
|
||||
this.emit(CHANGE_EVENT);
|
||||
}
|
||||
|
||||
public getSearchResults(): ICells[] {
|
||||
return this._results;
|
||||
}
|
||||
|
||||
public setSearchResults(crntResults: ICells[], fields: string): void {
|
||||
const flds: string[] = fields.toLowerCase().split(',');
|
||||
if (crntResults.length > 0) {
|
||||
const temp: any[] = [];
|
||||
crntResults.forEach((result) => {
|
||||
// Create a temp value
|
||||
var val: Object = {};
|
||||
result.Cells.forEach((cell: ICellValue) => {
|
||||
if (flds.indexOf(cell.Key.toLowerCase()) !== -1) {
|
||||
// Add key and value to temp value
|
||||
val[cell.Key] = cell.Value;
|
||||
}
|
||||
});
|
||||
// Push this to the temp array
|
||||
temp.push(val);
|
||||
});
|
||||
this._results = temp;
|
||||
} else {
|
||||
this._results = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {IWebPartContext} context
|
||||
* @param {string} url
|
||||
*/
|
||||
public GetSearchData (context: IWebPartContext, url: string): Promise<ISearchResults> {
|
||||
return context.httpClient.get(url, {
|
||||
headers: {
|
||||
// Some users experience issues retrieving search results: https://github.com/SharePoint/sp-dev-docs/issues/44
|
||||
// Current fix is to set an empty odata-version header
|
||||
"odata-version": ""
|
||||
}
|
||||
}).then((res: Response) => {
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} query
|
||||
*/
|
||||
public ReplaceTokens (query: string, context: IWebPartContext): string {
|
||||
if (query.toLowerCase().indexOf("{site}") !== -1) {
|
||||
query = query.replace(/{site}/ig, context.pageContext.web.absoluteUrl);
|
||||
}
|
||||
if (query.toLowerCase().indexOf("{sitecollection}") !== -1) {
|
||||
query = query.replace(/{sitecollection}/ig, _spPageContextInfo.siteAbsoluteUrl);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
public isEmptyString (value: string): boolean {
|
||||
return value === null || typeof value === "undefined" || !value.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} value
|
||||
*/
|
||||
public isNull (value: any): boolean {
|
||||
return value === null || typeof value === "undefined";
|
||||
}
|
||||
}
|
||||
|
||||
const searchStore: SearchStoreStatic = new SearchStoreStatic();
|
||||
|
||||
appDispatcher.register((action) => {
|
||||
switch (action.actionType) {
|
||||
case searchActionIDs.SEARCH_GET:
|
||||
let url: string = action.context.pageContext.web.absoluteUrl + "/_api/search/query?querytext=";
|
||||
// Check if a query is provided
|
||||
url += !searchStore.isEmptyString(action.query) ? `'${searchStore.ReplaceTokens(action.query, action.context)}'` : "'*'";
|
||||
// Check if there are fields provided
|
||||
url += '&selectproperties=';
|
||||
url += !searchStore.isEmptyString(action.fields) ? `'${action.fields}'` : "'path,title'";
|
||||
// Add the rowlimit
|
||||
url += "&rowlimit=";
|
||||
url += !searchStore.isNull(action.maxResults) ? action.maxResults : 10;
|
||||
// Add sorting
|
||||
url += !searchStore.isEmptyString(action.sorting) ? `&sortlist='${action.sorting}'` : "";
|
||||
// Add the client type
|
||||
url += "&clienttype='ContentSearchRegular'";
|
||||
|
||||
searchStore.GetSearchData(action.context, url).then((res: ISearchResults) => {
|
||||
if (res !== null) {
|
||||
if (typeof res.PrimaryQueryResult !== 'undefined') {
|
||||
if (typeof res.PrimaryQueryResult.RelevantResults !== 'undefined') {
|
||||
if (typeof res.PrimaryQueryResult.RelevantResults !== 'undefined') {
|
||||
if (typeof res.PrimaryQueryResult.RelevantResults.Table !== 'undefined') {
|
||||
if (typeof res.PrimaryQueryResult.RelevantResults.Table.Rows !== 'undefined') {
|
||||
searchStore.setSearchResults(res.PrimaryQueryResult.RelevantResults.Table.Rows, action.fields);
|
||||
searchStore.emitChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default searchStore;
|
|
@ -0,0 +1,15 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Search SPFx Web Part with template functionality",
|
||||
"BasicGroupName": "Search query settings",
|
||||
"QueryFieldLabel": "Specify your search query",
|
||||
"FieldsTitleLabel": "Specify a title for your web part (you can leave it empty).",
|
||||
"FieldsFieldLabel": "Specify the fields you want to retrieve",
|
||||
"FieldsTemplateLabel": "Choose the template you want to use for rendering the results",
|
||||
"FieldsMaxResults": "Number of results to render",
|
||||
"FieldsSorting": "Sorting (MP:ascending or descending) - example: lastmodifiedtime:ascending,author:descending",
|
||||
"QueryInfoDescription": "You can make use of following tokens: {Site} - {SiteCollection}",
|
||||
"FieldsExternalLabel": "Do you want to use an external template?",
|
||||
"FieldsExternalTempLabel": "Specify the URL of the external template"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
declare interface IStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
QueryFieldLabel: string;
|
||||
FieldsTitleLabel: string;
|
||||
FieldsFieldLabel: string;
|
||||
FieldsTemplateLabel: string;
|
||||
FieldsMaxResults: string;
|
||||
FieldsSorting: string;
|
||||
QueryInfoDescription: string;
|
||||
FieldsExternalLabel: string;
|
||||
FieldsExternalTempLabel: string;
|
||||
}
|
||||
|
||||
declare module 'mystrings' {
|
||||
const strings: IStrings;
|
||||
export = strings;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import styles from '../SearchSpfx.module.scss';
|
||||
import { ISearchSpfxWebPartProps } from '../ISearchSpfxWebPartProps';
|
||||
|
||||
export interface IDefaultTemplate extends ISearchSpfxWebPartProps {
|
||||
results: any[];
|
||||
}
|
||||
|
||||
export default class DefaultTemplate extends React.Component<IDefaultTemplate, {}> {
|
||||
public render(): JSX.Element {
|
||||
return (
|
||||
<div className={styles.searchSpfx}>
|
||||
<div className={styles.searchSpfx}>
|
||||
<h1 className='ms-font-xxl'>Search results for query: {this.props.query}</h1>
|
||||
{
|
||||
this.props.results.map((result, index) => {
|
||||
return (<p key={index}>Result { index + 1 }: <a href={result.Path}>{result.Title}</a></p>);
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
import * as React from 'react';
|
||||
import { css } from 'office-ui-fabric-react';
|
||||
import ModuleLoader from '@microsoft/sp-module-loader';
|
||||
|
||||
import styles from '../SearchSpfx.module.scss';
|
||||
import { ISearchSpfxWebPartProps } from '../ISearchSpfxWebPartProps';
|
||||
|
||||
import * as moment from 'moment';
|
||||
|
||||
export interface ITableTemplate extends ISearchSpfxWebPartProps {
|
||||
results: any[];
|
||||
}
|
||||
|
||||
export default class TableTemplate extends React.Component<ITableTemplate, {}> {
|
||||
private iconUrl: string = "https://spoprod-a.akamaihd.net/files/odsp-next-prod_ship-2016-08-15_20160815.002/odsp-media/images/filetypes/16/";
|
||||
private unknown: string[] = ['aspx', 'null'];
|
||||
|
||||
private getAuthorDisplayName(author: string): string {
|
||||
if (author !== null) {
|
||||
const splits: string[] = author.split('|');
|
||||
return splits[1].trim();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private getDateFromString(retrievedDate: string): string {
|
||||
if (retrievedDate !== null) {
|
||||
return moment(retrievedDate).format('DD/MM/YYYY');
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
// Load the Office UI Fabrics components css file via the module loader
|
||||
ModuleLoader.loadCss('https://appsforoffice.microsoft.com/fabric/2.6.1/fabric.components.min.css');
|
||||
|
||||
return (
|
||||
<div className={styles.searchSpfx}>
|
||||
{
|
||||
(() => {
|
||||
// Check if you need to show a title
|
||||
if (this.props.title !== "") {
|
||||
return <h1 className='ms-font-xxl'>{this.props.title}</h1>;
|
||||
}
|
||||
})()
|
||||
}
|
||||
|
||||
<table className={css('ms-Table', styles.templateTable)}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Type</th>
|
||||
<th>Name</th>
|
||||
<th>Modified</th>
|
||||
<th>Modified by</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{
|
||||
this.props.results.map((result, index) => {
|
||||
return (<tr key={index}>
|
||||
<td>
|
||||
<a href={result.Path}><img src={`${this.iconUrl}${result.Fileextension !== null && this.unknown.indexOf(result.Fileextension) === -1 ? result.Fileextension : 'code'}.png`} /></a>
|
||||
</td>
|
||||
<td>
|
||||
<a href={result.Path}>{result.Filename !== null ? result.Filename.substring(0, result.Filename.lastIndexOf('.')) : ""}</a>
|
||||
</td>
|
||||
<td>{this.getDateFromString(result.ModifiedOWSDATE)}</td>
|
||||
<td>{this.getAuthorDisplayName(result.EditorOWSUSER)}</td>
|
||||
</tr>);
|
||||
})
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import { ITemplates } from '../utils/ITemplates';
|
||||
|
||||
export const allTemplates: ITemplates[] = [
|
||||
{ key: 'DefaultTemplate', text: 'Default template', mappings: 'Path,Title' },
|
||||
{ key: 'TableTemplate', text: 'Table template', mappings: 'Path,Title,Filename,Fileextension,ModifiedOWSDATE,EditorOWSUSER' }
|
||||
];
|
||||
|
||||
export default class TemplateLoader {
|
||||
public getComponent(templateToLoad: string): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(require("../templates/" + templateToLoad + ".js").default);
|
||||
});
|
||||
}
|
||||
|
||||
public getTemplateMappings(templateToLoad: string): string {
|
||||
// Retrieve the fields for the current template
|
||||
const fields: ITemplates[] = allTemplates.filter((t) => { if (t.key === templateToLoad) return true; });
|
||||
return fields.length > 0 ? fields[0].mappings : "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import * as assert from 'assert';
|
||||
|
||||
describe('SearchSpfxWebPart', () => {
|
||||
it('should do something', () => {
|
||||
assert.ok(true);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,81 @@
|
|||
export interface IPageContext {
|
||||
CorrelationId: string;
|
||||
ExpFeatures: Array<any>;
|
||||
MenuData: IMenuData;
|
||||
PreviewFeaturesEnabled: boolean;
|
||||
RecycleBinItemCount: number;
|
||||
alertsEnabled: boolean;
|
||||
allowSilverlightPrompt: boolean;
|
||||
blockDownloadExperienceEnabled: boolean;
|
||||
cdnPrefix: string;
|
||||
clientServerTimeDelta: number;
|
||||
crossDomainPhotosEnabled: boolean;
|
||||
currentCultureName: string;
|
||||
currentLanguage: number;
|
||||
currentUICultureName: string;
|
||||
disableAppViews: boolean;
|
||||
disableFlows: boolean;
|
||||
env: string;
|
||||
farmLabel: string;
|
||||
fid: number;
|
||||
groupColor: string;
|
||||
groupHasHomepage: boolean;
|
||||
groupId: string;
|
||||
groupType: string;
|
||||
guestsEnabled: boolean;
|
||||
hasManageWebPermissions: boolean;
|
||||
hideSyncButtonOnODB: boolean;
|
||||
isAnonymousGuestUser: boolean;
|
||||
isAppWeb: boolean;
|
||||
isNoScriptEnabled: boolean;
|
||||
isSPO: boolean;
|
||||
isSiteAdmin: boolean;
|
||||
killSwitches: any;
|
||||
layoutsUrl: string;
|
||||
listBaseTemplate: number;
|
||||
listId: string;
|
||||
listPermsMask: any;
|
||||
listTitle: string;
|
||||
listUrl: string;
|
||||
navigationInfo: any;
|
||||
nid: number;
|
||||
openInClient: boolean;
|
||||
pageItemId: number;
|
||||
pageListId: string;
|
||||
pagePersonalizationScope: number;
|
||||
serverRequestPath: string;
|
||||
serverTime: string;
|
||||
showNGSCDialogForSyncOnODB: boolean;
|
||||
siteAbsoluteUrl: string;
|
||||
siteClassification: string;
|
||||
siteClientTag: string;
|
||||
siteId: string;
|
||||
sitePagesEnabled: boolean;
|
||||
siteServerRelativeUrl: string;
|
||||
siteSubscriptionId: string;
|
||||
systemUserKey: string;
|
||||
tenantAppVersion: string;
|
||||
themeCacheToken: string;
|
||||
themedCssFolderUrl: string;
|
||||
themedImageFileNames: string;
|
||||
updateFormDigestPageLoaded: Date;
|
||||
userDisplayName: string;
|
||||
userId: number;
|
||||
userLoginName: string;
|
||||
viewId: string;
|
||||
viewOnlyExperienceEnabled: boolean;
|
||||
webAbsoluteUrl: string;
|
||||
webId: string;
|
||||
webLanguage: number;
|
||||
webLogoUrl: string;
|
||||
webPermMasks: any;
|
||||
webServerRelativeUrl: string;
|
||||
webTemplate: string;
|
||||
webTitle: string;
|
||||
webUIVersion: string;
|
||||
}
|
||||
|
||||
export interface IMenuData {
|
||||
SettingsData: Array<any>;
|
||||
SignOutUrl: string;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
export interface ISearchResults {
|
||||
PrimaryQueryResult: IPrimaryQueryResult;
|
||||
}
|
||||
|
||||
export interface IPrimaryQueryResult {
|
||||
RelevantResults: IRelevantResults;
|
||||
}
|
||||
|
||||
export interface IRelevantResults {
|
||||
Table: ITable;
|
||||
}
|
||||
|
||||
export interface ITable {
|
||||
Rows: Array<ICells>;
|
||||
}
|
||||
|
||||
export interface ICells {
|
||||
Cells: Array<ICellValue>;
|
||||
}
|
||||
|
||||
export interface ICellValue {
|
||||
Key: string;
|
||||
Value: string;
|
||||
ValueType: string;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
export interface ITemplates {
|
||||
key: string;
|
||||
text: string;
|
||||
mappings: string;
|
||||
scripts?: IScripts[];
|
||||
styles?: IStyles[];
|
||||
}
|
||||
|
||||
export interface IExternalTemplate {
|
||||
properties: ITemplates;
|
||||
component: Function;
|
||||
}
|
||||
|
||||
export interface IScripts {
|
||||
url: string;
|
||||
funcName: string;
|
||||
}
|
||||
|
||||
export interface IStyles {
|
||||
url: string;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
export interface IDeferred<T> {
|
||||
resolve: (result: T) => void;
|
||||
reject: (err: T) => void;
|
||||
promise: Promise<T>;
|
||||
}
|
||||
|
||||
export function defer<T>(): IDeferred<T> {
|
||||
let resolve: (result: T) => void;
|
||||
let reject: (err: T) => void;
|
||||
|
||||
const promise: Promise<T> = new Promise<T>((cbResolve, cbReject): void => {
|
||||
resolve = cbResolve;
|
||||
reject = cbReject;
|
||||
});
|
||||
|
||||
return {
|
||||
resolve: resolve,
|
||||
reject: reject,
|
||||
promise: promise
|
||||
};
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"combokeys/combokeys.d.ts": {
|
||||
"commit": "88c0d5f868bc184d70b6799d36b1946787beb48d"
|
||||
},
|
||||
"immutable/immutable.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"fbemitter/fbemitter.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"flux/flux.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-create-fragment.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-global.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-css-transition-group.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-transition-group.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-perf.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-linked-state-mixin.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-pure-render-mixin.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-dom.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-update.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
},
|
||||
"react/react-addons-test-utils.d.ts": {
|
||||
"commit": "f15deaa4ee778667791b2a25362e37d3cc10592d"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// Type definitions for webpack in Microsoft ODSP projects
|
||||
// Project: ODSP-WEBPACK
|
||||
|
||||
/*
|
||||
* This definition of webpack require overrides all other definitions of require in our toolchain
|
||||
* Make sure all other definitions of require are commented out e.g. in node.d.ts
|
||||
*/
|
||||
declare var require: {
|
||||
(path: string): any;
|
||||
(paths: string[], callback: (...modules: any[]) => void): void;
|
||||
resolve: (id: string) => string;
|
||||
ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void, path: string) => void;
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
// Type definitions for Microsoft ODSP projects
|
||||
// Project: ODSP
|
||||
|
||||
/// <reference path="odsp-webpack.d.ts" />
|
||||
|
||||
/* Global definition for DEBUG builds */
|
||||
declare const DEBUG: boolean;
|
||||
|
||||
/* Global definition for UNIT_TEST builds */
|
||||
declare const UNIT_TEST: boolean;
|
|
@ -0,0 +1,15 @@
|
|||
// Type definitions for assertion-error 1.0.0
|
||||
// Project: https://github.com/chaijs/assertion-error
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'assertion-error' {
|
||||
class AssertionError implements Error {
|
||||
constructor(message: string, props?: any, ssf?: Function);
|
||||
name: string;
|
||||
message: string;
|
||||
showDiff: boolean;
|
||||
stack: string;
|
||||
}
|
||||
export = AssertionError;
|
||||
}
|
|
@ -0,0 +1,388 @@
|
|||
// Type definitions for chai 3.2.0
|
||||
// Project: http://chaijs.com/
|
||||
// Definitions by: Jed Mao <https://github.com/jedmao/>,
|
||||
// Bart van der Schoor <https://github.com/Bartvds>,
|
||||
// Andrew Brown <https://github.com/AGBrown>,
|
||||
// Olivier Chevet <https://github.com/olivr70>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// <reference path="../assertion-error/assertion-error.d.ts"/>
|
||||
|
||||
declare module Chai {
|
||||
|
||||
interface ChaiStatic {
|
||||
expect: ExpectStatic;
|
||||
should(): Should;
|
||||
/**
|
||||
* Provides a way to extend the internals of Chai
|
||||
*/
|
||||
use(fn: (chai: any, utils: any) => void): any;
|
||||
assert: AssertStatic;
|
||||
config: Config;
|
||||
AssertionError: AssertionError;
|
||||
}
|
||||
|
||||
export interface ExpectStatic extends AssertionStatic {
|
||||
fail(actual?: any, expected?: any, message?: string, operator?: string): void;
|
||||
}
|
||||
|
||||
export interface AssertStatic extends Assert {
|
||||
}
|
||||
|
||||
export interface AssertionStatic {
|
||||
(target: any, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface ShouldAssertion {
|
||||
equal(value1: any, value2: any, message?: string): void;
|
||||
Throw: ShouldThrow;
|
||||
throw: ShouldThrow;
|
||||
exist(value: any, message?: string): void;
|
||||
}
|
||||
|
||||
interface Should extends ShouldAssertion {
|
||||
not: ShouldAssertion;
|
||||
fail(actual: any, expected: any, message?: string, operator?: string): void;
|
||||
}
|
||||
|
||||
interface ShouldThrow {
|
||||
(actual: Function): void;
|
||||
(actual: Function, expected: string|RegExp, message?: string): void;
|
||||
(actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void;
|
||||
}
|
||||
|
||||
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
||||
not: Assertion;
|
||||
deep: Deep;
|
||||
any: KeyFilter;
|
||||
all: KeyFilter;
|
||||
a: TypeComparison;
|
||||
an: TypeComparison;
|
||||
include: Include;
|
||||
includes: Include;
|
||||
contain: Include;
|
||||
contains: Include;
|
||||
ok: Assertion;
|
||||
true: Assertion;
|
||||
false: Assertion;
|
||||
null: Assertion;
|
||||
undefined: Assertion;
|
||||
NaN: Assertion;
|
||||
exist: Assertion;
|
||||
empty: Assertion;
|
||||
arguments: Assertion;
|
||||
Arguments: Assertion;
|
||||
equal: Equal;
|
||||
equals: Equal;
|
||||
eq: Equal;
|
||||
eql: Equal;
|
||||
eqls: Equal;
|
||||
property: Property;
|
||||
ownProperty: OwnProperty;
|
||||
haveOwnProperty: OwnProperty;
|
||||
ownPropertyDescriptor: OwnPropertyDescriptor;
|
||||
haveOwnPropertyDescriptor: OwnPropertyDescriptor;
|
||||
length: Length;
|
||||
lengthOf: Length;
|
||||
match: Match;
|
||||
matches: Match;
|
||||
string(string: string, message?: string): Assertion;
|
||||
keys: Keys;
|
||||
key(string: string): Assertion;
|
||||
throw: Throw;
|
||||
throws: Throw;
|
||||
Throw: Throw;
|
||||
respondTo: RespondTo;
|
||||
respondsTo: RespondTo;
|
||||
itself: Assertion;
|
||||
satisfy: Satisfy;
|
||||
satisfies: Satisfy;
|
||||
closeTo(expected: number, delta: number, message?: string): Assertion;
|
||||
members: Members;
|
||||
increase: PropertyChange;
|
||||
increases: PropertyChange;
|
||||
decrease: PropertyChange;
|
||||
decreases: PropertyChange;
|
||||
change: PropertyChange;
|
||||
changes: PropertyChange;
|
||||
extensible: Assertion;
|
||||
sealed: Assertion;
|
||||
frozen: Assertion;
|
||||
|
||||
}
|
||||
|
||||
interface LanguageChains {
|
||||
to: Assertion;
|
||||
be: Assertion;
|
||||
been: Assertion;
|
||||
is: Assertion;
|
||||
that: Assertion;
|
||||
which: Assertion;
|
||||
and: Assertion;
|
||||
has: Assertion;
|
||||
have: Assertion;
|
||||
with: Assertion;
|
||||
at: Assertion;
|
||||
of: Assertion;
|
||||
same: Assertion;
|
||||
}
|
||||
|
||||
interface NumericComparison {
|
||||
above: NumberComparer;
|
||||
gt: NumberComparer;
|
||||
greaterThan: NumberComparer;
|
||||
least: NumberComparer;
|
||||
gte: NumberComparer;
|
||||
below: NumberComparer;
|
||||
lt: NumberComparer;
|
||||
lessThan: NumberComparer;
|
||||
most: NumberComparer;
|
||||
lte: NumberComparer;
|
||||
within(start: number, finish: number, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface NumberComparer {
|
||||
(value: number, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface TypeComparison {
|
||||
(type: string, message?: string): Assertion;
|
||||
instanceof: InstanceOf;
|
||||
instanceOf: InstanceOf;
|
||||
}
|
||||
|
||||
interface InstanceOf {
|
||||
(constructor: Object, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Deep {
|
||||
equal: Equal;
|
||||
include: Include;
|
||||
property: Property;
|
||||
members: Members;
|
||||
}
|
||||
|
||||
interface KeyFilter {
|
||||
keys: Keys;
|
||||
}
|
||||
|
||||
interface Equal {
|
||||
(value: any, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Property {
|
||||
(name: string, value?: any, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface OwnProperty {
|
||||
(name: string, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface OwnPropertyDescriptor {
|
||||
(name: string, descriptor: PropertyDescriptor, message?: string): Assertion;
|
||||
(name: string, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Length extends LanguageChains, NumericComparison {
|
||||
(length: number, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Include {
|
||||
(value: Object, message?: string): Assertion;
|
||||
(value: string, message?: string): Assertion;
|
||||
(value: number, message?: string): Assertion;
|
||||
keys: Keys;
|
||||
members: Members;
|
||||
any: KeyFilter;
|
||||
all: KeyFilter;
|
||||
}
|
||||
|
||||
interface Match {
|
||||
(regexp: RegExp|string, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Keys {
|
||||
(...keys: string[]): Assertion;
|
||||
(keys: any[]): Assertion;
|
||||
(keys: Object): Assertion;
|
||||
}
|
||||
|
||||
interface Throw {
|
||||
(): Assertion;
|
||||
(expected: string, message?: string): Assertion;
|
||||
(expected: RegExp, message?: string): Assertion;
|
||||
(constructor: Error, expected?: string, message?: string): Assertion;
|
||||
(constructor: Error, expected?: RegExp, message?: string): Assertion;
|
||||
(constructor: Function, expected?: string, message?: string): Assertion;
|
||||
(constructor: Function, expected?: RegExp, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface RespondTo {
|
||||
(method: string, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Satisfy {
|
||||
(matcher: Function, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface Members {
|
||||
(set: any[], message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface PropertyChange {
|
||||
(object: Object, prop: string, msg?: string): Assertion;
|
||||
}
|
||||
|
||||
export interface Assert {
|
||||
/**
|
||||
* @param expression Expression to test for truthiness.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
(expression: any, message?: string): void;
|
||||
|
||||
fail(actual?: any, expected?: any, msg?: string, operator?: string): void;
|
||||
|
||||
ok(val: any, msg?: string): void;
|
||||
isOk(val: any, msg?: string): void;
|
||||
notOk(val: any, msg?: string): void;
|
||||
isNotOk(val: any, msg?: string): void;
|
||||
|
||||
equal(act: any, exp: any, msg?: string): void;
|
||||
notEqual(act: any, exp: any, msg?: string): void;
|
||||
|
||||
strictEqual(act: any, exp: any, msg?: string): void;
|
||||
notStrictEqual(act: any, exp: any, msg?: string): void;
|
||||
|
||||
deepEqual(act: any, exp: any, msg?: string): void;
|
||||
notDeepEqual(act: any, exp: any, msg?: string): void;
|
||||
|
||||
isTrue(val: any, msg?: string): void;
|
||||
isFalse(val: any, msg?: string): void;
|
||||
|
||||
isNull(val: any, msg?: string): void;
|
||||
isNotNull(val: any, msg?: string): void;
|
||||
|
||||
isUndefined(val: any, msg?: string): void;
|
||||
isDefined(val: any, msg?: string): void;
|
||||
|
||||
isNaN(val: any, msg?: string): void;
|
||||
isNotNaN(val: any, msg?: string): void;
|
||||
|
||||
isAbove(val: number, abv: number, msg?: string): void;
|
||||
isBelow(val: number, blw: number, msg?: string): void;
|
||||
|
||||
isFunction(val: any, msg?: string): void;
|
||||
isNotFunction(val: any, msg?: string): void;
|
||||
|
||||
isObject(val: any, msg?: string): void;
|
||||
isNotObject(val: any, msg?: string): void;
|
||||
|
||||
isArray(val: any, msg?: string): void;
|
||||
isNotArray(val: any, msg?: string): void;
|
||||
|
||||
isString(val: any, msg?: string): void;
|
||||
isNotString(val: any, msg?: string): void;
|
||||
|
||||
isNumber(val: any, msg?: string): void;
|
||||
isNotNumber(val: any, msg?: string): void;
|
||||
|
||||
isBoolean(val: any, msg?: string): void;
|
||||
isNotBoolean(val: any, msg?: string): void;
|
||||
|
||||
typeOf(val: any, type: string, msg?: string): void;
|
||||
notTypeOf(val: any, type: string, msg?: string): void;
|
||||
|
||||
instanceOf(val: any, type: Function, msg?: string): void;
|
||||
notInstanceOf(val: any, type: Function, msg?: string): void;
|
||||
|
||||
include(exp: string, inc: any, msg?: string): void;
|
||||
include(exp: any[], inc: any, msg?: string): void;
|
||||
|
||||
notInclude(exp: string, inc: any, msg?: string): void;
|
||||
notInclude(exp: any[], inc: any, msg?: string): void;
|
||||
|
||||
match(exp: any, re: RegExp, msg?: string): void;
|
||||
notMatch(exp: any, re: RegExp, msg?: string): void;
|
||||
|
||||
property(obj: Object, prop: string, msg?: string): void;
|
||||
notProperty(obj: Object, prop: string, msg?: string): void;
|
||||
deepProperty(obj: Object, prop: string, msg?: string): void;
|
||||
notDeepProperty(obj: Object, prop: string, msg?: string): void;
|
||||
|
||||
propertyVal(obj: Object, prop: string, val: any, msg?: string): void;
|
||||
propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
|
||||
|
||||
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void;
|
||||
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void;
|
||||
|
||||
lengthOf(exp: any, len: number, msg?: string): void;
|
||||
//alias frenzy
|
||||
throw(fn: Function, msg?: string): void;
|
||||
throw(fn: Function, regExp: RegExp): void;
|
||||
throw(fn: Function, errType: Function, msg?: string): void;
|
||||
throw(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
|
||||
throws(fn: Function, msg?: string): void;
|
||||
throws(fn: Function, regExp: RegExp): void;
|
||||
throws(fn: Function, errType: Function, msg?: string): void;
|
||||
throws(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
|
||||
Throw(fn: Function, msg?: string): void;
|
||||
Throw(fn: Function, regExp: RegExp): void;
|
||||
Throw(fn: Function, errType: Function, msg?: string): void;
|
||||
Throw(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
|
||||
doesNotThrow(fn: Function, msg?: string): void;
|
||||
doesNotThrow(fn: Function, regExp: RegExp): void;
|
||||
doesNotThrow(fn: Function, errType: Function, msg?: string): void;
|
||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
|
||||
operator(val: any, operator: string, val2: any, msg?: string): void;
|
||||
closeTo(act: number, exp: number, delta: number, msg?: string): void;
|
||||
|
||||
sameMembers(set1: any[], set2: any[], msg?: string): void;
|
||||
sameDeepMembers(set1: any[], set2: any[], msg?: string): void;
|
||||
includeMembers(superset: any[], subset: any[], msg?: string): void;
|
||||
|
||||
ifError(val: any, msg?: string): void;
|
||||
|
||||
isExtensible(obj: {}, msg?: string): void;
|
||||
extensible(obj: {}, msg?: string): void;
|
||||
isNotExtensible(obj: {}, msg?: string): void;
|
||||
notExtensible(obj: {}, msg?: string): void;
|
||||
|
||||
isSealed(obj: {}, msg?: string): void;
|
||||
sealed(obj: {}, msg?: string): void;
|
||||
isNotSealed(obj: {}, msg?: string): void;
|
||||
notSealed(obj: {}, msg?: string): void;
|
||||
|
||||
isFrozen(obj: Object, msg?: string): void;
|
||||
frozen(obj: Object, msg?: string): void;
|
||||
isNotFrozen(obj: Object, msg?: string): void;
|
||||
notFrozen(obj: Object, msg?: string): void;
|
||||
|
||||
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
includeStack: boolean;
|
||||
}
|
||||
|
||||
export class AssertionError {
|
||||
constructor(message: string, _props?: any, ssf?: Function);
|
||||
name: string;
|
||||
message: string;
|
||||
showDiff: boolean;
|
||||
stack: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare var chai: Chai.ChaiStatic;
|
||||
|
||||
declare module "chai" {
|
||||
export = chai;
|
||||
}
|
||||
|
||||
interface Object {
|
||||
should: Chai.Assertion;
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
// Type definitions for Combokeys v2.4.6
|
||||
// Project: https://github.com/PolicyStat/combokeys
|
||||
// Definitions by: Ian Clanton-Thuon <https://github.com/iclanton>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Combokeys {
|
||||
interface CombokeysStatic {
|
||||
new (element: Element): Combokeys;
|
||||
|
||||
/**
|
||||
* all instances of Combokeys
|
||||
*/
|
||||
instances: Combokeys[];
|
||||
|
||||
/**
|
||||
* reset all instances
|
||||
*/
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface Combokeys {
|
||||
element: Element;
|
||||
|
||||
/**
|
||||
* binds an event to Combokeys
|
||||
*
|
||||
* can be a single key, a combination of keys separated with +,
|
||||
* an array of keys, or a sequence of keys separated by spaces
|
||||
*
|
||||
* be sure to list the modifier keys first to make sure that the
|
||||
* correct key ends up getting bound (the last key in the pattern)
|
||||
*
|
||||
* @param {keys} key combination or combinations
|
||||
* @param {callback} callback function
|
||||
* @param {handler} optional - one of "keypress", "keydown", or "keyup"
|
||||
* @returns void
|
||||
*/
|
||||
bind(keys: string | string[], callback: () => void, action?: string): void;
|
||||
|
||||
|
||||
/**
|
||||
* binds multiple combinations to the same callback
|
||||
*
|
||||
* @param {keys} key combinations
|
||||
* @param {callback} callback function
|
||||
* @param {handler} optional - one of "keypress", "keydown", or "keyup"
|
||||
* @returns void
|
||||
*/
|
||||
bindMultiple(keys: string[], callback: () => void, action?: string): void;
|
||||
|
||||
/**
|
||||
* unbinds an event to Combokeys
|
||||
*
|
||||
* the unbinding sets the callback function of the specified key combo
|
||||
* to an empty function and deletes the corresponding key in the
|
||||
* directMap dict.
|
||||
*
|
||||
* the keycombo+action has to be exactly the same as
|
||||
* it was defined in the bind method
|
||||
*
|
||||
* @param {keys} key combination or combinations
|
||||
* @param {action} optional - one of "keypress", "keydown", or "keyup"
|
||||
* @returns void
|
||||
*/
|
||||
unbind(keys: string | string[], action?: string): void;
|
||||
|
||||
/**
|
||||
* triggers an event that has already been bound
|
||||
*
|
||||
* @param {keys} key combination
|
||||
* @param {action} optional - one of "keypress", "keydown", or "keyup"
|
||||
* @returns void
|
||||
*/
|
||||
trigger(keys: string, action?: string): void;
|
||||
|
||||
/**
|
||||
* resets the library back to its initial state. This is useful
|
||||
* if you want to clear out the current keyboard shortcuts and bind
|
||||
* new ones - for example if you switch to another page
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* should we stop this event before firing off callbacks
|
||||
*
|
||||
* @param {e} event
|
||||
* @param {element} bound element
|
||||
* @return {boolean}
|
||||
*/
|
||||
stopCallback(e: Event, element: Element): boolean;
|
||||
|
||||
/**
|
||||
* detach all listners from the bound element
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
detach(): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var combokeys: Combokeys.CombokeysStatic;
|
||||
|
||||
declare module "combokeys" {
|
||||
export = combokeys;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
// Type definitions for es6-collections v0.5.1
|
||||
// Project: https://github.com/WebReflection/es6-collections/
|
||||
// Definitions by: Ron Buckton <http://github.com/rbuckton>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/* *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value?: T;
|
||||
}
|
||||
|
||||
interface Iterator<T> {
|
||||
next(value?: any): IteratorResult<T>;
|
||||
return?(value?: any): IteratorResult<T>;
|
||||
throw?(e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
interface ForEachable<T> {
|
||||
forEach(callbackfn: (value: T) => void): void;
|
||||
}
|
||||
|
||||
interface Map<K, V> {
|
||||
clear(): void;
|
||||
delete(key: K): boolean;
|
||||
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): Map<K, V>;
|
||||
entries(): Iterator<[K, V]>;
|
||||
keys(): Iterator<K>;
|
||||
values(): Iterator<V>;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface MapConstructor {
|
||||
new <K, V>(): Map<K, V>;
|
||||
new <K, V>(iterable: ForEachable<[K, V]>): Map<K, V>;
|
||||
prototype: Map<any, any>;
|
||||
}
|
||||
|
||||
declare var Map: MapConstructor;
|
||||
|
||||
interface Set<T> {
|
||||
add(value: T): Set<T>;
|
||||
clear(): void;
|
||||
delete(value: T): boolean;
|
||||
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
|
||||
has(value: T): boolean;
|
||||
entries(): Iterator<[T, T]>;
|
||||
keys(): Iterator<T>;
|
||||
values(): Iterator<T>;
|
||||
size: number;
|
||||
}
|
||||
|
||||
interface SetConstructor {
|
||||
new <T>(): Set<T>;
|
||||
new <T>(iterable: ForEachable<T>): Set<T>;
|
||||
prototype: Set<any>;
|
||||
}
|
||||
|
||||
declare var Set: SetConstructor;
|
||||
|
||||
interface WeakMap<K, V> {
|
||||
delete(key: K): boolean;
|
||||
clear(): void;
|
||||
get(key: K): V;
|
||||
has(key: K): boolean;
|
||||
set(key: K, value?: V): WeakMap<K, V>;
|
||||
}
|
||||
|
||||
interface WeakMapConstructor {
|
||||
new <K, V>(): WeakMap<K, V>;
|
||||
new <K, V>(iterable: ForEachable<[K, V]>): WeakMap<K, V>;
|
||||
prototype: WeakMap<any, any>;
|
||||
}
|
||||
|
||||
declare var WeakMap: WeakMapConstructor;
|
||||
|
||||
interface WeakSet<T> {
|
||||
delete(value: T): boolean;
|
||||
clear(): void;
|
||||
add(value: T): WeakSet<T>;
|
||||
has(value: T): boolean;
|
||||
}
|
||||
|
||||
interface WeakSetConstructor {
|
||||
new <T>(): WeakSet<T>;
|
||||
new <T>(iterable: ForEachable<T>): WeakSet<T>;
|
||||
prototype: WeakSet<any>;
|
||||
}
|
||||
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
declare module "es6-collections" {
|
||||
var Map: MapConstructor;
|
||||
var Set: SetConstructor;
|
||||
var WeakMap: WeakMapConstructor;
|
||||
var WeakSet: WeakSetConstructor;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
// Type definitions for es6-promise
|
||||
// Project: https://github.com/jakearchibald/ES6-Promise
|
||||
// Definitions by: François de Campredon <https://github.com/fdecampredon/>, vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Thenable<R> {
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
|
||||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
}
|
||||
|
||||
declare class Promise<R> implements Thenable<R> {
|
||||
/**
|
||||
* If you call resolve in the body of the callback passed to the constructor,
|
||||
* your promise is fulfilled with result object passed to resolve.
|
||||
* If you call reject your promise is rejected with the object passed to reject.
|
||||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
|
||||
* Any errors thrown in the constructor callback will be implicitly passed to reject().
|
||||
*/
|
||||
constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void);
|
||||
|
||||
/**
|
||||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
|
||||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
|
||||
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
|
||||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
|
||||
* If an error is thrown in the callback, the returned promise rejects with that error.
|
||||
*
|
||||
* @param onFulfilled called when/if "promise" resolves
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
|
||||
|
||||
/**
|
||||
* Sugar for promise.then(undefined, onRejected)
|
||||
*
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
/**
|
||||
* Make a new promise from the thenable.
|
||||
* A thenable is promise-like in as far as it has a "then" method.
|
||||
*/
|
||||
function resolve<R>(value?: R | Thenable<R>): Promise<R>;
|
||||
|
||||
/**
|
||||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
|
||||
*/
|
||||
function reject(error: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
|
||||
* the array passed to all can be a mixture of promise-like objects and other objects.
|
||||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
|
||||
*/
|
||||
function all<R>(promises: (R | Thenable<R>)[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
|
||||
*/
|
||||
function race<R>(promises: (R | Thenable<R>)[]): Promise<R>;
|
||||
}
|
||||
|
||||
declare module 'es6-promise' {
|
||||
var foo: typeof Promise; // Temp variable to reference Promise in local context
|
||||
module rsvp {
|
||||
export var Promise: typeof foo;
|
||||
}
|
||||
export = rsvp;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
// Type definitions for Facebook's EventEmitter 2.0.0
|
||||
// Project: https://github.com/facebook/emitter
|
||||
// Definitions by: kmxz <https://github.com/kmxz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace FBEmitter {
|
||||
|
||||
export class EventSubscription {
|
||||
|
||||
listener: Function;
|
||||
context: any;
|
||||
|
||||
/**
|
||||
* Removes this subscription from the subscriber that controls it.
|
||||
*/
|
||||
remove(): void;
|
||||
|
||||
}
|
||||
|
||||
export class EventEmitter {
|
||||
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Adds a listener to be invoked when events of the specified type are
|
||||
* emitted. An optional calling context may be provided. The data arguments
|
||||
* emitted will be passed to the listener function.
|
||||
*/
|
||||
addListener(eventType: string, listener: Function, context?: any): EventSubscription;
|
||||
|
||||
/**
|
||||
* Similar to addListener, except that the listener is removed after it is
|
||||
* invoked once.
|
||||
*/
|
||||
once(eventType: string, listener: Function, context?: any): EventSubscription;
|
||||
|
||||
/**
|
||||
* Removes all of the registered listeners, including those registered as
|
||||
* listener maps.
|
||||
*/
|
||||
removeAllListeners(eventType?: string): void;
|
||||
|
||||
/**
|
||||
* Provides an API that can be called during an eventing cycle to remove the
|
||||
* last listener that was invoked. This allows a developer to provide an event
|
||||
* object that can remove the listener (or listener map) during the
|
||||
* invocation.
|
||||
*
|
||||
* If it is called when not inside of an emitting cycle it will throw.
|
||||
*/
|
||||
removeCurrentListener(): void;
|
||||
|
||||
/**
|
||||
* Returns an array of listeners that are currently registered for the given
|
||||
* event.
|
||||
*/
|
||||
listeners(eventType: string): Function[];
|
||||
|
||||
/**
|
||||
* Emits an event of the given type with the given data. All handlers of that
|
||||
* particular type will be notified.
|
||||
*/
|
||||
emit(eventType: string, ...data: any[]): void;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module 'fbemitter' {
|
||||
export = FBEmitter;
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
// Type definitions for Flux
|
||||
// Project: http://facebook.github.io/flux/
|
||||
// Definitions by: Steve Baker <https://github.com/stkb/>, Giedrius Grabauskas <https://github.com/GiedriusGrabauskas/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="../fbemitter/fbemitter.d.ts" />
|
||||
/// <reference path="../immutable/immutable.d.ts" />
|
||||
|
||||
declare namespace Flux {
|
||||
|
||||
/**
|
||||
* Dispatcher class
|
||||
* Create an instance to use throughout the application.
|
||||
* Or extend it to create a derived dispatcher class.
|
||||
*
|
||||
* Specify a type in the 'TPayload' generic argument to use strongly-typed payloads,
|
||||
* otherwise specify 'any'
|
||||
*
|
||||
* Examples:
|
||||
* var dispatcher = new flux.Dispatcher<any>()
|
||||
* var typedDispatcher = new flux.Dispatcher<MyCustomActionType>()
|
||||
* class DerivedDispatcher extends flux.Dispatcher<MyCustomActionType> { }
|
||||
*/
|
||||
export class Dispatcher<TPayload> {
|
||||
|
||||
/**
|
||||
* Create an instance of the Dispatcher class to use throughout the application.
|
||||
*
|
||||
* Specify a type in the 'TPayload' generic argument to use strongly-typed payloads,
|
||||
* otherwise specify 'any'
|
||||
*
|
||||
* Examples:
|
||||
* var dispatcher = new flux.Dispatcher<any>()
|
||||
* var typedDispatcher = new flux.Dispatcher<MyCustomActionType>()
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Registers a callback that will be invoked with every payload sent to the dispatcher.
|
||||
* Returns a string token to identify the callback to be used with waitFor() or unregister.
|
||||
*/
|
||||
register(callback: (payload: TPayload) => void): string;
|
||||
|
||||
/**
|
||||
* Unregisters a callback with the given ID token
|
||||
*/
|
||||
unregister(id: string): void;
|
||||
|
||||
/**
|
||||
* Waits for the callbacks with the specified IDs to be invoked before continuing execution
|
||||
* of the current callback. This method should only be used by a callback in response
|
||||
* to a dispatched payload.
|
||||
*/
|
||||
waitFor(IDs: string[]): void;
|
||||
|
||||
/**
|
||||
* Dispatches a payload to all registered callbacks
|
||||
*/
|
||||
dispatch(payload: TPayload): void;
|
||||
|
||||
/**
|
||||
* Gets whether the dispatcher is currently dispatching
|
||||
*/
|
||||
isDispatching(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "flux" {
|
||||
export = Flux;
|
||||
}
|
||||
|
||||
declare namespace FluxUtils {
|
||||
|
||||
import React = __React;
|
||||
import fbEmitter = FBEmitter;
|
||||
import immutable = Immutable;
|
||||
|
||||
/**
|
||||
* Default options to create a Container with
|
||||
*
|
||||
* @interface RealOptions
|
||||
*/
|
||||
interface RealOptions {
|
||||
/**
|
||||
* Default value: true
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
pure?: boolean;
|
||||
/**
|
||||
* Default value: false
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
withProps?: boolean;
|
||||
}
|
||||
|
||||
export class Container {
|
||||
constructor();
|
||||
/**
|
||||
* Create is used to transform a react class into a container
|
||||
* that updates its state when relevant stores change.
|
||||
* The provided base class must have static methods getStores() and calculateState().
|
||||
*/
|
||||
static create<TComponent>(base: React.ComponentClass<TComponent>, options?: RealOptions): React.ComponentClass<TComponent>;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class extends ReduceStore and defines the state as an immutable map.
|
||||
*/
|
||||
export class MapStore<K extends string | number, V, TPayload> extends ReduceStore<immutable.Map<K, V>, TPayload> {
|
||||
/**
|
||||
* Access the value at the given key.
|
||||
* Throws an error if the key does not exist in the cache.
|
||||
*/
|
||||
at(key: K): V;
|
||||
|
||||
/**
|
||||
* Check if the cache has a particular key
|
||||
*/
|
||||
has(key: K): boolean;
|
||||
|
||||
/**
|
||||
* Get the value of a particular key.
|
||||
* Returns undefined if the key does not exist in the cache.
|
||||
*/
|
||||
get(key: K): V;
|
||||
|
||||
/**
|
||||
* Gets an array of keys and puts the values in a map if they exist,
|
||||
* it allows providing a previous result to update instead of generating a new map.
|
||||
* Providing a previous result allows the possibility of keeping the same reference if the keys did not change.
|
||||
*/
|
||||
getAll(keys: immutable.Iterable.Indexed<K>, prev?: immutable.Map<K, V>): immutable.Map<K, V>;
|
||||
}
|
||||
|
||||
export class ReduceStore<T, TPayload> extends Store<TPayload> {
|
||||
/**
|
||||
* Getter that exposes the entire state of this store.
|
||||
* If your state is not immutable you should override this and not expose state directly.
|
||||
*/
|
||||
getState(): T;
|
||||
|
||||
/**
|
||||
* Constructs the initial state for this store.
|
||||
* This is called once during construction of the store.
|
||||
*/
|
||||
getInitialState(): T;
|
||||
|
||||
/**
|
||||
* Reduces the current state, and an action to the new state of this store.
|
||||
* All subclasses must implement this method.
|
||||
* This method should be pure and have no side-effects.
|
||||
*/
|
||||
reduce(state: T, action: TPayload): T;
|
||||
|
||||
/**
|
||||
* Checks if two versions of state are the same.
|
||||
* You do not need to override this if your state is immutable.
|
||||
*/
|
||||
areEqual(one: T, two: T): boolean;
|
||||
|
||||
}
|
||||
|
||||
export class Store<TPayload> {
|
||||
|
||||
/**
|
||||
* Constructs and registers an instance of this store with the given dispatcher.
|
||||
*/
|
||||
constructor(dispatcher: Flux.Dispatcher<TPayload>);
|
||||
|
||||
/**
|
||||
* Adds a listener to the store, when the store changes the given callback will be called.
|
||||
* A token is returned that can be used to remove the listener.
|
||||
* Calling the remove() function on the returned token will remove the listener.
|
||||
*/
|
||||
addListener(callback: Function): fbEmitter.EventSubscription;
|
||||
|
||||
/**
|
||||
* Returns the dispatcher this store is registered with.
|
||||
*/
|
||||
getDispatcher(): Flux.Dispatcher<TPayload>;
|
||||
|
||||
/**
|
||||
* Returns the dispatch token that the dispatcher recognizes this store by.
|
||||
* Can be used to waitFor() this store.
|
||||
*/
|
||||
getDispatchToken(): string;
|
||||
|
||||
/**
|
||||
* Ask if a store has changed during the current dispatch.
|
||||
* Can only be invoked while dispatching.
|
||||
* This can be used for constructing derived stores that depend on data from other stores.
|
||||
*/
|
||||
hasChanged(): boolean;
|
||||
|
||||
/**
|
||||
*Emit an event notifying all listeners that this store has changed.
|
||||
* This can only be invoked when dispatching.
|
||||
* Changes are de-duplicated and resolved at the end of this store's __onDispatch function.
|
||||
*/
|
||||
__emitChange(): void;
|
||||
|
||||
/**
|
||||
* Subclasses must override this method.
|
||||
* This is how the store receives actions from the dispatcher.
|
||||
* All state mutation logic must be done during this method.
|
||||
*/
|
||||
__onDispatch(payload: TPayload): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'flux/utils' {
|
||||
export = FluxUtils;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// Type definitions for form-data
|
||||
// Project: https://github.com/felixge/node-form-data
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, Leon Yu <https://github.com/leonyu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts
|
||||
|
||||
declare module "form-data" {
|
||||
class FormData {
|
||||
append(key: string, value: any, options?: any): void;
|
||||
getHeaders(): FormData.Dictionary<string>;
|
||||
// TODO expand pipe
|
||||
pipe(to: any): any;
|
||||
submit(params: string | Object, callback: (error: any, response: any) => void): any;
|
||||
getBoundary(): string;
|
||||
}
|
||||
|
||||
namespace FormData {
|
||||
interface Dictionary<T> {
|
||||
[key: string]: T;
|
||||
}
|
||||
}
|
||||
|
||||
export = FormData;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,631 @@
|
|||
// Type definitions for Knockout v3.2.0
|
||||
// Project: http://knockoutjs.com
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Igor Oleinikov <https://github.com/Igorbek/>, Clément Bourgeois <https://github.com/moonpyk/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface KnockoutSubscribableFunctions<T> {
|
||||
[key: string]: KnockoutBindingHandler;
|
||||
|
||||
notifySubscribers(valueToWrite?: T, event?: string): void;
|
||||
}
|
||||
|
||||
interface KnockoutComputedFunctions<T> {
|
||||
[key: string]: KnockoutBindingHandler;
|
||||
}
|
||||
|
||||
interface KnockoutObservableFunctions<T> {
|
||||
[key: string]: KnockoutBindingHandler;
|
||||
|
||||
equalityComparer(a: any, b: any): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayFunctions<T> {
|
||||
// General Array functions
|
||||
indexOf(searchElement: T, fromIndex?: number): number;
|
||||
slice(start: number, end?: number): T[];
|
||||
splice(start: number): T[];
|
||||
splice(start: number, deleteCount: number, ...items: T[]): T[];
|
||||
pop(): T;
|
||||
push(...items: T[]): void;
|
||||
shift(): T;
|
||||
unshift(...items: T[]): number;
|
||||
reverse(): KnockoutObservableArray<T>;
|
||||
sort(): KnockoutObservableArray<T>;
|
||||
sort(compareFunction: (left: T, right: T) => number): KnockoutObservableArray<T>;
|
||||
|
||||
// Ko specific
|
||||
[key: string]: KnockoutBindingHandler;
|
||||
|
||||
replace(oldItem: T, newItem: T): void;
|
||||
|
||||
remove(item: T): T[];
|
||||
remove(removeFunction: (item: T) => boolean): T[];
|
||||
removeAll(items: T[]): T[];
|
||||
removeAll(): T[];
|
||||
|
||||
destroy(item: T): void;
|
||||
destroy(destroyFunction: (item: T) => boolean): void;
|
||||
destroyAll(items: T[]): void;
|
||||
destroyAll(): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribableStatic {
|
||||
fn: KnockoutSubscribableFunctions<any>;
|
||||
|
||||
new <T>(): KnockoutSubscribable<T>;
|
||||
}
|
||||
|
||||
interface KnockoutSubscription {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribable<T> extends KnockoutSubscribableFunctions<T> {
|
||||
subscribe(callback: (newValue: T) => void, target?: any, event?: string): KnockoutSubscription;
|
||||
subscribe<TEvent>(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription;
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutSubscribable<T>;
|
||||
getSubscriptionsCount(): number;
|
||||
}
|
||||
|
||||
interface KnockoutComputedStatic {
|
||||
fn: KnockoutComputedFunctions<any>;
|
||||
|
||||
<T>(): KnockoutComputed<T>;
|
||||
<T>(func: () => T, context?: any, options?: any): KnockoutComputed<T>;
|
||||
<T>(def: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||
}
|
||||
|
||||
interface KnockoutComputed<T> extends KnockoutObservable<T>, KnockoutComputedFunctions<T> {
|
||||
fn: KnockoutComputedFunctions<any>;
|
||||
|
||||
dispose(): void;
|
||||
isActive(): boolean;
|
||||
getDependenciesCount(): number;
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutComputed<T>;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayStatic {
|
||||
fn: KnockoutObservableArrayFunctions<any>;
|
||||
|
||||
<T>(value?: T[]): KnockoutObservableArray<T>;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArray<T> extends KnockoutObservable<T[]>, KnockoutObservableArrayFunctions<T> {
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservableArray<T>;
|
||||
}
|
||||
|
||||
interface KnockoutObservableStatic {
|
||||
fn: KnockoutObservableFunctions<any>;
|
||||
|
||||
<T>(value?: T): KnockoutObservable<T>;
|
||||
}
|
||||
|
||||
interface KnockoutObservable<T> extends KnockoutSubscribable<T>, KnockoutObservableFunctions<T> {
|
||||
(): T;
|
||||
(value: T): void;
|
||||
|
||||
peek(): T;
|
||||
valueHasMutated?:{(): void;};
|
||||
valueWillMutate?:{(): void;};
|
||||
extend(requestedExtenders: { [key: string]: any; }): KnockoutObservable<T>;
|
||||
}
|
||||
|
||||
interface KnockoutComputedDefine<T> {
|
||||
read(): T;
|
||||
write? (value: T): void;
|
||||
disposeWhenNodeIsRemoved?: Node;
|
||||
disposeWhen? (): boolean;
|
||||
owner?: any;
|
||||
deferEvaluation?: boolean;
|
||||
pure?: boolean;
|
||||
}
|
||||
|
||||
interface KnockoutBindingContext {
|
||||
$parent: any;
|
||||
$parents: any[];
|
||||
$root: any;
|
||||
$data: any;
|
||||
$rawData: any | KnockoutObservable<any>;
|
||||
$index?: KnockoutObservable<number>;
|
||||
$parentContext?: KnockoutBindingContext;
|
||||
$component: any;
|
||||
$componentTemplateNodes: Node[];
|
||||
|
||||
extend(properties: any): any;
|
||||
createChildContext(dataItemOrAccessor: any, dataItemAlias?: any, extendCallback?: Function): any;
|
||||
}
|
||||
|
||||
interface KnockoutAllBindingsAccessor {
|
||||
(): any;
|
||||
get(name: string): any;
|
||||
has(name: string): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandler {
|
||||
after?: Array<string>;
|
||||
init?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void | { controlsDescendantBindings: boolean; };
|
||||
update?: (element: any, valueAccessor: () => any, allBindingsAccessor?: KnockoutAllBindingsAccessor, viewModel?: any, bindingContext?: KnockoutBindingContext) => void;
|
||||
options?: any;
|
||||
preprocess?: (value: string, name: string, addBindingCallback?: (name: string, value: string) => void) => string;
|
||||
}
|
||||
|
||||
interface KnockoutBindingHandlers {
|
||||
[bindingHandler: string]: KnockoutBindingHandler;
|
||||
|
||||
// Controlling text and appearance
|
||||
visible: KnockoutBindingHandler;
|
||||
text: KnockoutBindingHandler;
|
||||
html: KnockoutBindingHandler;
|
||||
css: KnockoutBindingHandler;
|
||||
style: KnockoutBindingHandler;
|
||||
attr: KnockoutBindingHandler;
|
||||
|
||||
// Control Flow
|
||||
foreach: KnockoutBindingHandler;
|
||||
if: KnockoutBindingHandler;
|
||||
ifnot: KnockoutBindingHandler;
|
||||
with: KnockoutBindingHandler;
|
||||
|
||||
// Working with form fields
|
||||
click: KnockoutBindingHandler;
|
||||
event: KnockoutBindingHandler;
|
||||
submit: KnockoutBindingHandler;
|
||||
enable: KnockoutBindingHandler;
|
||||
disable: KnockoutBindingHandler;
|
||||
value: KnockoutBindingHandler;
|
||||
textInput: KnockoutBindingHandler;
|
||||
hasfocus: KnockoutBindingHandler;
|
||||
checked: KnockoutBindingHandler;
|
||||
options: KnockoutBindingHandler;
|
||||
selectedOptions: KnockoutBindingHandler;
|
||||
uniqueName: KnockoutBindingHandler;
|
||||
|
||||
// Rendering templates
|
||||
template: KnockoutBindingHandler;
|
||||
|
||||
// Components (new for v3.2)
|
||||
component: KnockoutBindingHandler;
|
||||
}
|
||||
|
||||
interface KnockoutMemoization {
|
||||
memoize(callback: () => string): string;
|
||||
unmemoize(memoId: string, callbackParams: any[]): boolean;
|
||||
unmemoizeDomNodeAndDescendants(domNode: any, extraCallbackParamsArray: any[]): boolean;
|
||||
parseMemoText(memoText: string): string;
|
||||
}
|
||||
|
||||
interface KnockoutVirtualElement {}
|
||||
|
||||
interface KnockoutVirtualElements {
|
||||
allowedBindings: { [bindingName: string]: boolean; };
|
||||
emptyNode(node: KnockoutVirtualElement ): void;
|
||||
firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement;
|
||||
insertAfter( container: KnockoutVirtualElement, nodeToInsert: Node, insertAfter: Node ): void;
|
||||
nextSibling(node: KnockoutVirtualElement): Node;
|
||||
prepend(node: KnockoutVirtualElement, toInsert: Node ): void;
|
||||
setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: Node; } ): void;
|
||||
childNodes(node: KnockoutVirtualElement ): Node[];
|
||||
}
|
||||
|
||||
interface KnockoutExtenders {
|
||||
throttle(target: any, timeout: number): KnockoutComputed<any>;
|
||||
notify(target: any, notifyWhen: string): any;
|
||||
|
||||
rateLimit(target: any, timeout: number): any;
|
||||
rateLimit(target: any, options: { timeout: number; method?: string; }): any;
|
||||
|
||||
trackArrayChanges(target: any): any;
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE TO MAINTAINERS AND CONTRIBUTORS : pay attention to only include symbols that are
|
||||
// publicly exported in the minified version of ko, without that you can give the false
|
||||
// impression that some functions will be available in production builds.
|
||||
//
|
||||
interface KnockoutUtils {
|
||||
//////////////////////////////////
|
||||
// utils.domData.js
|
||||
//////////////////////////////////
|
||||
|
||||
domData: {
|
||||
get (node: Element, key: string): any;
|
||||
|
||||
set (node: Element, key: string, value: any): void;
|
||||
|
||||
getAll(node: Element, createIfNotFound: boolean): any;
|
||||
|
||||
clear(node: Element): boolean;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
// utils.domNodeDisposal.js
|
||||
//////////////////////////////////
|
||||
|
||||
domNodeDisposal: {
|
||||
addDisposeCallback(node: Element, callback: Function): void;
|
||||
|
||||
removeDisposeCallback(node: Element, callback: Function): void;
|
||||
|
||||
cleanNode(node: Node): Element;
|
||||
|
||||
removeNode(node: Node): void;
|
||||
};
|
||||
|
||||
addOrRemoveItem<T>(array: T[] | KnockoutObservable<T>, value: T, included: T): void;
|
||||
|
||||
arrayFilter<T>(array: T[], predicate: (item: T) => boolean): T[];
|
||||
|
||||
arrayFirst<T>(array: T[], predicate: (item: T) => boolean, predicateOwner?: any): T;
|
||||
|
||||
arrayForEach<T>(array: T[], action: (item: T, index: number) => void): void;
|
||||
|
||||
arrayGetDistinctValues<T>(array: T[]): T[];
|
||||
|
||||
arrayIndexOf<T>(array: T[], item: T): number;
|
||||
|
||||
arrayMap<T, U>(array: T[], mapping: (item: T) => U): U[];
|
||||
|
||||
arrayPushAll<T>(array: T[] | KnockoutObservableArray<T>, valuesToPush: T[]): T[];
|
||||
|
||||
arrayRemoveItem(array: any[], itemToRemove: any): void;
|
||||
|
||||
compareArrays<T>(a: T[], b: T[]): Array<KnockoutArrayChange<T>>;
|
||||
|
||||
extend(target: Object, source: Object): Object;
|
||||
|
||||
fieldsIncludedWithJsonPost: any[];
|
||||
|
||||
getFormFields(form: any, fieldName: string): any[];
|
||||
|
||||
objectForEach(obj: any, action: (key: any, value: any) => void): void;
|
||||
|
||||
parseHtmlFragment(html: string): any[];
|
||||
|
||||
parseJson(jsonString: string): any;
|
||||
|
||||
postJson(urlOrForm: any, data: any, options: any): void;
|
||||
|
||||
peekObservable<T>(value: KnockoutObservable<T>): T;
|
||||
|
||||
range(min: any, max: any): any;
|
||||
|
||||
registerEventHandler(element: any, eventType: any, handler: Function): void;
|
||||
|
||||
setHtml(node: Element, html: () => string): void;
|
||||
|
||||
setHtml(node: Element, html: string): void;
|
||||
|
||||
setTextContent(element: any, textContent: string | KnockoutObservable<string>): void;
|
||||
|
||||
stringifyJson(data: any, replacer?: Function, space?: string): string;
|
||||
|
||||
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void;
|
||||
|
||||
triggerEvent(element: any, eventType: any): void;
|
||||
|
||||
unwrapObservable<T>(value: KnockoutObservable<T> | T): T;
|
||||
|
||||
// NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670
|
||||
// forceRefresh(node: any): void;
|
||||
// ieVersion: number;
|
||||
// isIe6: boolean;
|
||||
// isIe7: boolean;
|
||||
// jQueryHtmlParse(html: string): any[];
|
||||
// makeArray(arrayLikeObject: any): any[];
|
||||
// moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
|
||||
// replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
|
||||
// setDomNodeChildren(domNode: any, childNodes: any[]): void;
|
||||
// setElementName(element: any, name: string): void;
|
||||
// setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void;
|
||||
// simpleHtmlParse(html: string): any[];
|
||||
// stringStartsWith(str: string, startsWith: string): boolean;
|
||||
// stringTokenize(str: string, delimiter: string): string[];
|
||||
// stringTrim(str: string): string;
|
||||
// tagNameLower(element: any): string;
|
||||
}
|
||||
|
||||
interface KnockoutArrayChange<T> {
|
||||
status: string;
|
||||
value: T;
|
||||
index: number;
|
||||
moved?: number;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// templateSources.js
|
||||
//////////////////////////////////
|
||||
|
||||
interface KnockoutTemplateSourcesDomElement {
|
||||
text(): any;
|
||||
text(value: any): void;
|
||||
|
||||
data(key: string): any;
|
||||
data(key: string, value: any): any;
|
||||
}
|
||||
|
||||
interface KnockoutTemplateAnonymous extends KnockoutTemplateSourcesDomElement {
|
||||
nodes(): any;
|
||||
nodes(value: any): void;
|
||||
}
|
||||
|
||||
interface KnockoutTemplateSources {
|
||||
|
||||
domElement: {
|
||||
prototype: KnockoutTemplateSourcesDomElement
|
||||
new (element: Element): KnockoutTemplateSourcesDomElement
|
||||
};
|
||||
|
||||
anonymousTemplate: {
|
||||
prototype: KnockoutTemplateAnonymous;
|
||||
new (element: Element): KnockoutTemplateAnonymous;
|
||||
};
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// nativeTemplateEngine.js
|
||||
//////////////////////////////////
|
||||
|
||||
interface KnockoutNativeTemplateEngine {
|
||||
|
||||
renderTemplateSource(templateSource: Object, bindingContext?: KnockoutBindingContext, options?: Object): any[];
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// templateEngine.js
|
||||
//////////////////////////////////
|
||||
|
||||
interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine {
|
||||
|
||||
createJavaScriptEvaluatorBlock(script: string): string;
|
||||
|
||||
makeTemplateSource(template: any, templateDocument?: Document): any;
|
||||
|
||||
renderTemplate(template: any, bindingContext: KnockoutBindingContext, options: Object, templateDocument: Document): any;
|
||||
|
||||
isTemplateRewritten(template: any, templateDocument: Document): boolean;
|
||||
|
||||
rewriteTemplate(template: any, rewriterCallback: Function, templateDocument: Document): void;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
interface KnockoutStatic {
|
||||
utils: KnockoutUtils;
|
||||
memoization: KnockoutMemoization;
|
||||
|
||||
bindingHandlers: KnockoutBindingHandlers;
|
||||
getBindingHandler(handler: string): KnockoutBindingHandler;
|
||||
|
||||
virtualElements: KnockoutVirtualElements;
|
||||
extenders: KnockoutExtenders;
|
||||
|
||||
applyBindings(viewModelOrBindingContext?: any, rootNode?: any): void;
|
||||
applyBindingsToDescendants(viewModelOrBindingContext: any, rootNode: any): void;
|
||||
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, bindingContext: KnockoutBindingContext): void;
|
||||
applyBindingAccessorsToNode(node: Node, bindings: {}, bindingContext: KnockoutBindingContext): void;
|
||||
applyBindingAccessorsToNode(node: Node, bindings: (bindingContext: KnockoutBindingContext, node: Node) => {}, viewModel: any): void;
|
||||
applyBindingAccessorsToNode(node: Node, bindings: {}, viewModel: any): void;
|
||||
applyBindingsToNode(node: Node, bindings: any, viewModelOrBindingContext?: any): any;
|
||||
|
||||
subscribable: KnockoutSubscribableStatic;
|
||||
observable: KnockoutObservableStatic;
|
||||
|
||||
computed: KnockoutComputedStatic;
|
||||
pureComputed<T>(evaluatorFunction: () => T, context?: any): KnockoutComputed<T>;
|
||||
pureComputed<T>(options: KnockoutComputedDefine<T>, context?: any): KnockoutComputed<T>;
|
||||
|
||||
observableArray: KnockoutObservableArrayStatic;
|
||||
|
||||
contextFor(node: any): any;
|
||||
isSubscribable(instance: any): boolean;
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): boolean;
|
||||
isWriteableObservable(instance: any): boolean;
|
||||
isComputed(instance: any): boolean;
|
||||
dataFor(node: any): any;
|
||||
removeNode(node: Element): void;
|
||||
cleanNode(node: Element): Element;
|
||||
renderTemplate(template: Function, viewModel: any, options?: any, target?: any, renderMode?: any): any;
|
||||
renderTemplate(template: string, viewModel: any, options?: any, target?: any, renderMode?: any): any;
|
||||
unwrap<T>(value: KnockoutObservable<T> | T): T;
|
||||
|
||||
computedContext: KnockoutComputedContext;
|
||||
|
||||
//////////////////////////////////
|
||||
// templateSources.js
|
||||
//////////////////////////////////
|
||||
|
||||
templateSources: KnockoutTemplateSources;
|
||||
|
||||
//////////////////////////////////
|
||||
// templateEngine.js
|
||||
//////////////////////////////////
|
||||
|
||||
templateEngine: {
|
||||
|
||||
prototype: KnockoutTemplateEngine;
|
||||
|
||||
new (): KnockoutTemplateEngine;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
// templateRewriting.js
|
||||
//////////////////////////////////
|
||||
|
||||
templateRewriting: {
|
||||
|
||||
ensureTemplateIsRewritten(template: Node, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
|
||||
ensureTemplateIsRewritten(template: string, templateEngine: KnockoutTemplateEngine, templateDocument: Document): any;
|
||||
|
||||
memoizeBindingAttributeSyntax(htmlString: string, templateEngine: KnockoutTemplateEngine): any;
|
||||
|
||||
applyMemoizedBindingsToNextSibling(bindings: any, nodeName: string): string;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
// nativeTemplateEngine.js
|
||||
//////////////////////////////////
|
||||
|
||||
nativeTemplateEngine: {
|
||||
|
||||
prototype: KnockoutNativeTemplateEngine;
|
||||
|
||||
new (): KnockoutNativeTemplateEngine;
|
||||
|
||||
instance: KnockoutNativeTemplateEngine;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
// jqueryTmplTemplateEngine.js
|
||||
//////////////////////////////////
|
||||
|
||||
jqueryTmplTemplateEngine: {
|
||||
|
||||
prototype: KnockoutTemplateEngine;
|
||||
|
||||
renderTemplateSource(templateSource: Object, bindingContext: KnockoutBindingContext, options: Object): Node[];
|
||||
|
||||
createJavaScriptEvaluatorBlock(script: string): string;
|
||||
|
||||
addTemplate(templateName: string, templateMarkup: string): void;
|
||||
};
|
||||
|
||||
//////////////////////////////////
|
||||
// templating.js
|
||||
//////////////////////////////////
|
||||
|
||||
setTemplateEngine(templateEngine: KnockoutNativeTemplateEngine): void;
|
||||
|
||||
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node, renderMode: string): any;
|
||||
renderTemplate(template: Function, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||
renderTemplate(template: any, dataOrBindingContext: KnockoutBindingContext, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||
renderTemplate(template: Function, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||
renderTemplate(template: any, dataOrBindingContext: any, options: Object, targetNodeOrNodeArray: Node[], renderMode: string): any;
|
||||
|
||||
renderTemplateForEach(template: Function, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
renderTemplateForEach(template: any, arrayOrObservableArray: any[], options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
renderTemplateForEach(template: Function, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
renderTemplateForEach(template: any, arrayOrObservableArray: KnockoutObservable<any>, options: Object, targetNode: Node, parentBindingContext: KnockoutBindingContext): any;
|
||||
|
||||
expressionRewriting: {
|
||||
bindingRewriteValidators: any;
|
||||
parseObjectLiteral: { (objectLiteralString: string): any[] }
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
bindingProvider: {
|
||||
instance: KnockoutBindingProvider;
|
||||
new (): KnockoutBindingProvider;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// selectExtensions.js
|
||||
/////////////////////////////////
|
||||
|
||||
selectExtensions: {
|
||||
|
||||
readValue(element: HTMLElement): any;
|
||||
|
||||
writeValue(element: HTMLElement, value: any): void;
|
||||
};
|
||||
|
||||
components: KnockoutComponents;
|
||||
}
|
||||
|
||||
interface KnockoutBindingProvider {
|
||||
nodeHasBindings(node: Node): boolean;
|
||||
getBindings(node: Node, bindingContext: KnockoutBindingContext): {};
|
||||
getBindingAccessors?(node: Node, bindingContext: KnockoutBindingContext): { [key: string]: string; };
|
||||
}
|
||||
|
||||
interface KnockoutComputedContext {
|
||||
getDependenciesCount(): number;
|
||||
isInitial: () => boolean;
|
||||
isSleeping: boolean;
|
||||
}
|
||||
|
||||
//
|
||||
// refactored types into a namespace to reduce global pollution
|
||||
// and used Union Types to simplify overloads (requires TypeScript 1.4)
|
||||
//
|
||||
declare module KnockoutComponentTypes {
|
||||
|
||||
interface Config {
|
||||
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
|
||||
template: string | Node[]| DocumentFragment | TemplateElement | AMDModule;
|
||||
synchronous?: boolean;
|
||||
}
|
||||
|
||||
interface ComponentConfig {
|
||||
viewModel?: ViewModelFunction | ViewModelSharedInstance | ViewModelFactoryFunction | AMDModule;
|
||||
template: any;
|
||||
createViewModel?: any;
|
||||
}
|
||||
|
||||
interface EmptyConfig {
|
||||
}
|
||||
|
||||
// common AMD type
|
||||
interface AMDModule {
|
||||
require: string;
|
||||
}
|
||||
|
||||
// viewmodel types
|
||||
interface ViewModelFunction {
|
||||
(params?: any): any;
|
||||
}
|
||||
|
||||
interface ViewModelSharedInstance {
|
||||
instance: any;
|
||||
}
|
||||
|
||||
interface ViewModelFactoryFunction {
|
||||
createViewModel: (params?: any, componentInfo?: ComponentInfo) => any;
|
||||
}
|
||||
|
||||
interface ComponentInfo {
|
||||
element: Node;
|
||||
templateNodes: Node[];
|
||||
}
|
||||
|
||||
interface TemplateElement {
|
||||
element: string | Node;
|
||||
}
|
||||
|
||||
interface Loader {
|
||||
getConfig? (componentName: string, callback: (result: ComponentConfig) => void): void;
|
||||
loadComponent? (componentName: string, config: ComponentConfig, callback: (result: Definition) => void): void;
|
||||
loadTemplate? (componentName: string, templateConfig: any, callback: (result: Node[]) => void): void;
|
||||
loadViewModel? (componentName: string, viewModelConfig: any, callback: (result: any) => void): void;
|
||||
suppressLoaderExceptions?: boolean;
|
||||
}
|
||||
|
||||
interface Definition {
|
||||
template: Node[];
|
||||
createViewModel? (params: any, options: { element: Node; }): any;
|
||||
}
|
||||
}
|
||||
|
||||
interface KnockoutComponents {
|
||||
// overloads for register method:
|
||||
register(componentName: string, config: KnockoutComponentTypes.Config | KnockoutComponentTypes.EmptyConfig): void;
|
||||
|
||||
isRegistered(componentName: string): boolean;
|
||||
unregister(componentName: string): void;
|
||||
get(componentName: string, callback: (definition: KnockoutComponentTypes.Definition) => void): void;
|
||||
clearCachedDefinition(componentName: string): void
|
||||
defaultLoader: KnockoutComponentTypes.Loader;
|
||||
loaders: KnockoutComponentTypes.Loader[];
|
||||
getComponentNameForNode(node: Node): string;
|
||||
}
|
||||
|
||||
declare var ko: KnockoutStatic;
|
||||
|
||||
declare module "knockout" {
|
||||
export = ko;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,214 @@
|
|||
// Type definitions for mocha 2.2.5
|
||||
// Project: http://mochajs.org/
|
||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface MochaSetupOptions {
|
||||
//milliseconds to wait before considering a test slow
|
||||
slow?: number;
|
||||
|
||||
// timeout in milliseconds
|
||||
timeout?: number;
|
||||
|
||||
// ui name "bdd", "tdd", "exports" etc
|
||||
ui?: string;
|
||||
|
||||
//array of accepted globals
|
||||
globals?: any[];
|
||||
|
||||
// reporter instance (function or string), defaults to `mocha.reporters.Spec`
|
||||
reporter?: any;
|
||||
|
||||
// bail on the first test failure
|
||||
bail?: boolean;
|
||||
|
||||
// ignore global leaks
|
||||
ignoreLeaks?: boolean;
|
||||
|
||||
// grep string or regexp to filter tests with
|
||||
grep?: any;
|
||||
}
|
||||
|
||||
interface MochaDone {
|
||||
(error?: Error): void;
|
||||
}
|
||||
|
||||
declare var mocha: Mocha;
|
||||
declare var describe: Mocha.IContextDefinition;
|
||||
declare var xdescribe: Mocha.IContextDefinition;
|
||||
// alias for `describe`
|
||||
declare var context: Mocha.IContextDefinition;
|
||||
// alias for `describe`
|
||||
declare var suite: Mocha.IContextDefinition;
|
||||
declare var it: Mocha.ITestDefinition;
|
||||
declare var xit: Mocha.ITestDefinition;
|
||||
// alias for `it`
|
||||
declare var test: Mocha.ITestDefinition;
|
||||
|
||||
declare function before(action: () => void): void;
|
||||
|
||||
declare function before(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function setup(action: () => void): void;
|
||||
|
||||
declare function setup(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function after(action: () => void): void;
|
||||
|
||||
declare function after(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function teardown(action: () => void): void;
|
||||
|
||||
declare function teardown(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function beforeEach(action: () => void): void;
|
||||
|
||||
declare function beforeEach(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function suiteSetup(action: () => void): void;
|
||||
|
||||
declare function suiteSetup(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function afterEach(action: () => void): void;
|
||||
|
||||
declare function afterEach(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare function suiteTeardown(action: () => void): void;
|
||||
|
||||
declare function suiteTeardown(action: (done: MochaDone) => void): void;
|
||||
|
||||
declare class Mocha {
|
||||
constructor(options?: {
|
||||
grep?: RegExp;
|
||||
ui?: string;
|
||||
reporter?: string;
|
||||
timeout?: number;
|
||||
bail?: boolean;
|
||||
});
|
||||
|
||||
/** Setup mocha with the given options. */
|
||||
setup(options: MochaSetupOptions): Mocha;
|
||||
bail(value?: boolean): Mocha;
|
||||
addFile(file: string): Mocha;
|
||||
/** Sets reporter by name, defaults to "spec". */
|
||||
reporter(name: string): Mocha;
|
||||
/** Sets reporter constructor, defaults to mocha.reporters.Spec. */
|
||||
reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha;
|
||||
ui(value: string): Mocha;
|
||||
grep(value: string): Mocha;
|
||||
grep(value: RegExp): Mocha;
|
||||
invert(): Mocha;
|
||||
ignoreLeaks(value: boolean): Mocha;
|
||||
checkLeaks(): Mocha;
|
||||
/** Enables growl support. */
|
||||
growl(): Mocha;
|
||||
globals(value: string): Mocha;
|
||||
globals(values: string[]): Mocha;
|
||||
useColors(value: boolean): Mocha;
|
||||
useInlineDiffs(value: boolean): Mocha;
|
||||
timeout(value: number): Mocha;
|
||||
slow(value: number): Mocha;
|
||||
enableTimeouts(value: boolean): Mocha;
|
||||
asyncOnly(value: boolean): Mocha;
|
||||
noHighlighting(value: boolean): Mocha;
|
||||
/** Runs tests and invokes `onComplete()` when finished. */
|
||||
run(onComplete?: (failures: number) => void): Mocha.IRunner;
|
||||
}
|
||||
|
||||
// merge the Mocha class declaration with a module
|
||||
declare module Mocha {
|
||||
/** Partial interface for Mocha's `Runnable` class. */
|
||||
interface IRunnable {
|
||||
title: string;
|
||||
fn: Function;
|
||||
async: boolean;
|
||||
sync: boolean;
|
||||
timedOut: boolean;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Suite` class. */
|
||||
interface ISuite {
|
||||
parent: ISuite;
|
||||
title: string;
|
||||
|
||||
fullTitle(): string;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Test` class. */
|
||||
interface ITest extends IRunnable {
|
||||
parent: ISuite;
|
||||
pending: boolean;
|
||||
|
||||
fullTitle(): string;
|
||||
}
|
||||
|
||||
/** Partial interface for Mocha's `Runner` class. */
|
||||
interface IRunner {}
|
||||
|
||||
interface IContextDefinition {
|
||||
(description: string, spec: () => void): ISuite;
|
||||
only(description: string, spec: () => void): ISuite;
|
||||
skip(description: string, spec: () => void): void;
|
||||
timeout(ms: number): void;
|
||||
}
|
||||
|
||||
interface ITestDefinition {
|
||||
(expectation: string, assertion?: () => void): ITest;
|
||||
(expectation: string, assertion?: (done: MochaDone) => void): ITest;
|
||||
only(expectation: string, assertion?: () => void): ITest;
|
||||
only(expectation: string, assertion?: (done: MochaDone) => void): ITest;
|
||||
skip(expectation: string, assertion?: () => void): void;
|
||||
skip(expectation: string, assertion?: (done: MochaDone) => void): void;
|
||||
timeout(ms: number): void;
|
||||
}
|
||||
|
||||
export module reporters {
|
||||
export class Base {
|
||||
stats: {
|
||||
suites: number;
|
||||
tests: number;
|
||||
passes: number;
|
||||
pending: number;
|
||||
failures: number;
|
||||
};
|
||||
|
||||
constructor(runner: IRunner);
|
||||
}
|
||||
|
||||
export class Doc extends Base {}
|
||||
export class Dot extends Base {}
|
||||
export class HTML extends Base {}
|
||||
export class HTMLCov extends Base {}
|
||||
export class JSON extends Base {}
|
||||
export class JSONCov extends Base {}
|
||||
export class JSONStream extends Base {}
|
||||
export class Landing extends Base {}
|
||||
export class List extends Base {}
|
||||
export class Markdown extends Base {}
|
||||
export class Min extends Base {}
|
||||
export class Nyan extends Base {}
|
||||
export class Progress extends Base {
|
||||
/**
|
||||
* @param options.open String used to indicate the start of the progress bar.
|
||||
* @param options.complete String used to indicate a complete test on the progress bar.
|
||||
* @param options.incomplete String used to indicate an incomplete test on the progress bar.
|
||||
* @param options.close String used to indicate the end of the progress bar.
|
||||
*/
|
||||
constructor(runner: IRunner, options?: {
|
||||
open?: string;
|
||||
complete?: string;
|
||||
incomplete?: string;
|
||||
close?: string;
|
||||
});
|
||||
}
|
||||
export class Spec extends Base {}
|
||||
export class TAP extends Base {}
|
||||
export class XUnit extends Base {
|
||||
constructor(runner: IRunner, options?: any);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "mocha" {
|
||||
export = Mocha;
|
||||
}
|
|
@ -0,0 +1,693 @@
|
|||
// Type definitions for Moment.js 2.11.1
|
||||
// Project: https://github.com/timrwood/moment
|
||||
// Definitions by: Michael Lakerveld <https://github.com/Lakerfield>, Aaron King <https://github.com/kingdango>, Hiroki Horiuchi <https://github.com/horiuchi>, Dick van den Brink <https://github.com/DickvdBrink>, Adi Dahiya <https://github.com/adidahiya>, Matt Brooks <https://github.com/EnableSoftware>, Gal Talmor <https://github.com/galtalmor>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace moment {
|
||||
|
||||
type MomentComparable = Moment | string | number | Date | number[];
|
||||
|
||||
interface MomentDateObject {
|
||||
years?: number;
|
||||
/* One digit */
|
||||
months?: number;
|
||||
/* Day of the month */
|
||||
date?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
seconds?: number;
|
||||
milliseconds?: number;
|
||||
}
|
||||
|
||||
interface MomentInput {
|
||||
/** Year */
|
||||
years?: number;
|
||||
/** Year */
|
||||
year?: number;
|
||||
/** Year */
|
||||
y?: number;
|
||||
|
||||
/** Month */
|
||||
months?: number;
|
||||
/** Month */
|
||||
month?: number;
|
||||
/** Month */
|
||||
M?: number;
|
||||
|
||||
/** Week */
|
||||
weeks?: number;
|
||||
/** Week */
|
||||
week?: number;
|
||||
/** Week */
|
||||
w?: number;
|
||||
|
||||
/** Day/Date */
|
||||
days?: number;
|
||||
/** Day/Date */
|
||||
day?: number;
|
||||
/** Day/Date */
|
||||
date?: number;
|
||||
/** Day/Date */
|
||||
d?: number;
|
||||
|
||||
/** Hour */
|
||||
hours?: number;
|
||||
/** Hour */
|
||||
hour?: number;
|
||||
/** Hour */
|
||||
h?: number;
|
||||
|
||||
/** Minute */
|
||||
minutes?: number;
|
||||
/** Minute */
|
||||
minute?: number;
|
||||
/** Minute */
|
||||
m?: number;
|
||||
|
||||
/** Second */
|
||||
seconds?: number;
|
||||
/** Second */
|
||||
second?: number;
|
||||
/** Second */
|
||||
s?: number;
|
||||
|
||||
/** Millisecond */
|
||||
milliseconds?: number;
|
||||
/** Millisecond */
|
||||
millisecond?: number;
|
||||
/** Millisecond */
|
||||
ms?: number;
|
||||
}
|
||||
|
||||
interface Duration {
|
||||
humanize(withSuffix?: boolean): string;
|
||||
|
||||
as(units: string): number;
|
||||
|
||||
milliseconds(): number;
|
||||
asMilliseconds(): number;
|
||||
|
||||
seconds(): number;
|
||||
asSeconds(): number;
|
||||
|
||||
minutes(): number;
|
||||
asMinutes(): number;
|
||||
|
||||
hours(): number;
|
||||
asHours(): number;
|
||||
|
||||
days(): number;
|
||||
asDays(): number;
|
||||
|
||||
weeks(): number;
|
||||
asWeeks(): number;
|
||||
|
||||
months(): number;
|
||||
asMonths(): number;
|
||||
|
||||
years(): number;
|
||||
asYears(): number;
|
||||
|
||||
add(n: number, p: string): Duration;
|
||||
add(n: number): Duration;
|
||||
add(d: Duration): Duration;
|
||||
|
||||
subtract(n: number, p: string): Duration;
|
||||
subtract(n: number): Duration;
|
||||
subtract(d: Duration): Duration;
|
||||
|
||||
toISOString(): string;
|
||||
toJSON(): string;
|
||||
}
|
||||
|
||||
interface MomentLocale {
|
||||
ordinal(n: number): string;
|
||||
}
|
||||
|
||||
interface MomentCreationData {
|
||||
input?: string;
|
||||
format?: string;
|
||||
locale: MomentLocale;
|
||||
isUTC: boolean;
|
||||
strict?: boolean;
|
||||
}
|
||||
|
||||
interface Moment {
|
||||
format(format: string): string;
|
||||
format(): string;
|
||||
|
||||
fromNow(withoutSuffix?: boolean): string;
|
||||
|
||||
startOf(unitOfTime: string): Moment;
|
||||
endOf(unitOfTime: string): Moment;
|
||||
|
||||
/**
|
||||
* Mutates the original moment by adding time. (deprecated in 2.8.0)
|
||||
*
|
||||
* @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
|
||||
* @param amount the amount you want to add
|
||||
*/
|
||||
add(unitOfTime: string, amount: number): Moment;
|
||||
/**
|
||||
* Mutates the original moment by adding time.
|
||||
*
|
||||
* @param amount the amount you want to add
|
||||
* @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
|
||||
*/
|
||||
add(amount: number, unitOfTime: string): Moment;
|
||||
/**
|
||||
* Mutates the original moment by adding time. Note that the order of arguments can be flipped.
|
||||
*
|
||||
* @param amount the amount you want to add
|
||||
* @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc)
|
||||
*/
|
||||
add(amount: string, unitOfTime: string): Moment;
|
||||
/**
|
||||
* Mutates the original moment by adding time.
|
||||
*
|
||||
* @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
|
||||
*/
|
||||
add(objectLiteral: MomentInput): Moment;
|
||||
/**
|
||||
* Mutates the original moment by adding time.
|
||||
*
|
||||
* @param duration a length of time
|
||||
*/
|
||||
add(duration: Duration): Moment;
|
||||
|
||||
/**
|
||||
* Mutates the original moment by subtracting time. (deprecated in 2.8.0)
|
||||
*
|
||||
* @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
|
||||
* @param amount the amount you want to subtract
|
||||
*/
|
||||
subtract(unitOfTime: string, amount: number): Moment;
|
||||
/**
|
||||
* Mutates the original moment by subtracting time.
|
||||
*
|
||||
* @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
|
||||
* @param amount the amount you want to subtract
|
||||
*/
|
||||
subtract(amount: number, unitOfTime: string): Moment;
|
||||
/**
|
||||
* Mutates the original moment by subtracting time. Note that the order of arguments can be flipped.
|
||||
*
|
||||
* @param amount the amount you want to add
|
||||
* @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc)
|
||||
*/
|
||||
subtract(amount: string, unitOfTime: string): Moment;
|
||||
/**
|
||||
* Mutates the original moment by subtracting time.
|
||||
*
|
||||
* @param objectLiteral an object literal that describes multiple time units {days:7,months:1}
|
||||
*/
|
||||
subtract(objectLiteral: MomentInput): Moment;
|
||||
/**
|
||||
* Mutates the original moment by subtracting time.
|
||||
*
|
||||
* @param duration a length of time
|
||||
*/
|
||||
subtract(duration: Duration): Moment;
|
||||
|
||||
calendar(): string;
|
||||
calendar(start: Moment): string;
|
||||
calendar(start: Moment, formats: MomentCalendar): string;
|
||||
|
||||
clone(): Moment;
|
||||
|
||||
/**
|
||||
* @return Unix timestamp, or milliseconds since the epoch.
|
||||
*/
|
||||
valueOf(): number;
|
||||
|
||||
local(): Moment; // current date/time in local mode
|
||||
|
||||
utc(): Moment; // current date/time in UTC mode
|
||||
|
||||
isValid(): boolean;
|
||||
invalidAt(): number;
|
||||
|
||||
year(y: number): Moment;
|
||||
year(): number;
|
||||
quarter(): number;
|
||||
quarter(q: number): Moment;
|
||||
month(M: number): Moment;
|
||||
month(M: string): Moment;
|
||||
month(): number;
|
||||
day(d: number): Moment;
|
||||
day(d: string): Moment;
|
||||
day(): number;
|
||||
date(d: number): Moment;
|
||||
date(): number;
|
||||
hour(h: number): Moment;
|
||||
hour(): number;
|
||||
hours(h: number): Moment;
|
||||
hours(): number;
|
||||
minute(m: number): Moment;
|
||||
minute(): number;
|
||||
minutes(m: number): Moment;
|
||||
minutes(): number;
|
||||
second(s: number): Moment;
|
||||
second(): number;
|
||||
seconds(s: number): Moment;
|
||||
seconds(): number;
|
||||
millisecond(ms: number): Moment;
|
||||
millisecond(): number;
|
||||
milliseconds(ms: number): Moment;
|
||||
milliseconds(): number;
|
||||
weekday(): number;
|
||||
weekday(d: number): Moment;
|
||||
isoWeekday(): number;
|
||||
isoWeekday(d: number): Moment;
|
||||
weekYear(): number;
|
||||
weekYear(d: number): Moment;
|
||||
isoWeekYear(): number;
|
||||
isoWeekYear(d: number): Moment;
|
||||
week(): number;
|
||||
week(d: number): Moment;
|
||||
weeks(): number;
|
||||
weeks(d: number): Moment;
|
||||
isoWeek(): number;
|
||||
isoWeek(d: number): Moment;
|
||||
isoWeeks(): number;
|
||||
isoWeeks(d: number): Moment;
|
||||
weeksInYear(): number;
|
||||
isoWeeksInYear(): number;
|
||||
dayOfYear(): number;
|
||||
dayOfYear(d: number): Moment;
|
||||
|
||||
from(f: MomentComparable, suffix?: boolean): string;
|
||||
to(f: MomentComparable, suffix?: boolean): string;
|
||||
toNow(withoutPrefix?: boolean): string;
|
||||
|
||||
diff(b: MomentComparable): number;
|
||||
diff(b: MomentComparable, unitOfTime: string): number;
|
||||
diff(b: MomentComparable, unitOfTime: string, round: boolean): number;
|
||||
|
||||
toArray(): number[];
|
||||
toDate(): Date;
|
||||
toISOString(): string;
|
||||
toJSON(): string;
|
||||
unix(): number;
|
||||
|
||||
isLeapYear(): boolean;
|
||||
zone(): number;
|
||||
zone(b: number): Moment;
|
||||
zone(b: string): Moment;
|
||||
utcOffset(): number;
|
||||
utcOffset(b: number): Moment;
|
||||
utcOffset(b: string): Moment;
|
||||
daysInMonth(): number;
|
||||
isDST(): boolean;
|
||||
|
||||
isBefore(): boolean;
|
||||
isBefore(b: MomentComparable, granularity?: string): boolean;
|
||||
|
||||
isAfter(): boolean;
|
||||
isAfter(b: MomentComparable, granularity?: string): boolean;
|
||||
|
||||
isSame(b: MomentComparable, granularity?: string): boolean;
|
||||
isBetween(a: MomentComparable, b: MomentComparable, granularity?: string, inclusivity?: string): boolean;
|
||||
|
||||
/**
|
||||
* @since 2.10.7+
|
||||
*/
|
||||
isSameOrBefore(b: MomentComparable, granularity?: string): boolean;
|
||||
isSameOrAfter(b: MomentComparable, granularity?: string): boolean;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.8.0
|
||||
*/
|
||||
lang(language: string): Moment;
|
||||
lang(reset: boolean): Moment;
|
||||
lang(): MomentLanguage;
|
||||
|
||||
locale(language: string): Moment;
|
||||
locale(reset: boolean): Moment;
|
||||
locale(): string;
|
||||
|
||||
/**
|
||||
* @since 2.12.0+
|
||||
*/
|
||||
locales() : string[];
|
||||
localeData(language: string): Moment;
|
||||
localeData(reset: boolean): Moment;
|
||||
localeData(): MomentLanguage;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.7.0
|
||||
*/
|
||||
max(date: Moment | string | number | Date | any[]): Moment;
|
||||
max(date: string, format: string): Moment;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.7.0
|
||||
*/
|
||||
min(date: Moment | string | number | Date | any[]): Moment;
|
||||
min(date: string, format: string): Moment;
|
||||
|
||||
get(unit: string): number;
|
||||
set(unit: string, value: number): Moment;
|
||||
set(objectLiteral: MomentInput): Moment;
|
||||
|
||||
/**
|
||||
* This returns an object containing year, month, day-of-month, hour, minute, seconds, milliseconds.
|
||||
* @since 2.10.5+
|
||||
*/
|
||||
toObject(): MomentDateObject;
|
||||
|
||||
/**
|
||||
* @since 2.10.7+
|
||||
*/
|
||||
creationData(): MomentCreationData;
|
||||
}
|
||||
|
||||
type formatFunction = () => string;
|
||||
|
||||
interface MomentCalendar {
|
||||
lastDay?: string | formatFunction;
|
||||
sameDay?: string | formatFunction;
|
||||
nextDay?: string | formatFunction;
|
||||
lastWeek?: string | formatFunction;
|
||||
nextWeek?: string | formatFunction;
|
||||
sameElse?: string | formatFunction;
|
||||
}
|
||||
|
||||
interface BaseMomentLanguage {
|
||||
months?: any;
|
||||
monthsShort?: any;
|
||||
weekdays?: any;
|
||||
weekdaysShort?: any;
|
||||
weekdaysMin?: any;
|
||||
relativeTime?: MomentRelativeTime;
|
||||
meridiem?: (hour: number, minute: number, isLowercase: boolean) => string;
|
||||
calendar?: MomentCalendar;
|
||||
ordinal?: (num: number) => string;
|
||||
week?: MomentLanguageWeek;
|
||||
}
|
||||
|
||||
interface MomentLanguage extends BaseMomentLanguage {
|
||||
longDateFormat?: MomentLongDateFormat;
|
||||
}
|
||||
|
||||
interface MomentLanguageWeek {
|
||||
dow?: number;
|
||||
doy?: number;
|
||||
}
|
||||
|
||||
interface MomentLanguageData {
|
||||
/**
|
||||
* Get the full localized month name of a moment object
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} full month name
|
||||
*/
|
||||
months(aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Get the short localized month name of a moment object
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} short month name
|
||||
*/
|
||||
monthsShort(aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Parses a month name and returns the month id (0-11)
|
||||
* @param {string} longOrShortMonthString string of month to parse
|
||||
* @return {number} month id (0 to 11) of input
|
||||
*/
|
||||
monthsParse(longOrShortMonthString: string): number;
|
||||
|
||||
/**
|
||||
* Gets the full weekday name of a moment object (eg. Monday)
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} full weekday name
|
||||
*/
|
||||
weekdays(aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Gets the short weekday name of a moment object (eg. Mon)
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} short weekday name
|
||||
*/
|
||||
weekdaysShort(aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Gets the min weekday name of a moment object (eg. Mo)
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} min weekday name
|
||||
*/
|
||||
weekdaysMin(aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Parses a weekday name and returns the weekday id (0-6)
|
||||
* @param {string} longOrShortMonthString string of weekday to parse
|
||||
* @return {number} weekday id (0 to 6) of input
|
||||
*/
|
||||
weekdaysParse(longOrShortMonthString: string): number;
|
||||
|
||||
/**
|
||||
* Returns the full format of abbreviated date-time formats
|
||||
* @param {string} dateFormat date-time format such as LT, L, LL and so on
|
||||
* @return {string} full date format string
|
||||
*/
|
||||
longDateFormat(dateFormat: string): string;
|
||||
|
||||
/**
|
||||
* Returns whether a string represents PM
|
||||
* @param {string} amPmString date string to check
|
||||
* @return {boolean} true if string represents PM
|
||||
*/
|
||||
isPM(amPmString: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns am/pm string for particular time-of-day in upper/lower case
|
||||
* @param {number} hour hour
|
||||
* @param {number} minute minute
|
||||
* @param {boolean} isLowercase whether to return in lowercase
|
||||
* @return {string} 'am' or 'pm'
|
||||
*/
|
||||
meridiem(hour: number, minute: number, isLowercase: boolean): string;
|
||||
|
||||
/**
|
||||
* Returns a format that would be used for calendar representation.
|
||||
* @param {string} key one of 'sameDay', 'nextDay', 'lastDay', 'nextWeek', 'prevWeek', 'sameElse'
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {string} date format string
|
||||
*/
|
||||
calendar(key: string, aMoment: Moment): string;
|
||||
|
||||
/**
|
||||
* Returns relative time string (eg. a year ago)
|
||||
* @param {number} number the relative number
|
||||
* @param {boolean} withoutSuffix whether to drop the suffix
|
||||
* @param {string} key one of 's', 'm', 'mm', 'h', 'hh', 'd', 'dd', 'M', 'MM', 'y', 'yy'. Single letter when number is 1.
|
||||
* @param {boolean} isFuture whether this represents a future date
|
||||
* @return {string} humanized representation of relative time
|
||||
*/
|
||||
relativeTime(number: number, withoutSuffix: boolean, key: string, isFuture: boolean): string;
|
||||
|
||||
/**
|
||||
* Converts relative time string to past or future string depending on difference
|
||||
* @param {number} diff positive or negative number
|
||||
* @param {string} relTime relative time string
|
||||
* @return {string} humanized representation of relative time
|
||||
*/
|
||||
pastFuture(diff: number, relTime: string): string;
|
||||
|
||||
/**
|
||||
* Convert number to ordinal string 1 -> 1st
|
||||
* @param {number} number the number
|
||||
* @return {string} ordinal string
|
||||
*/
|
||||
ordinal(number: number): string;
|
||||
|
||||
/**
|
||||
* Called before parsing every input string
|
||||
*/
|
||||
preparse(str: string): string;
|
||||
|
||||
/**
|
||||
* Called after formatting on every string
|
||||
*/
|
||||
postformat(str: string): string;
|
||||
|
||||
/**
|
||||
* Returns week-of-year of a moment object
|
||||
* @param {Moment} aMoment a moment object
|
||||
* @return {number} number of the week
|
||||
*/
|
||||
week(aMoment: Moment): number;
|
||||
|
||||
/**
|
||||
* Returns a translation of 'Invalid date'
|
||||
* @return {string} translation of 'Invalid date'
|
||||
*/
|
||||
invalidDate(): string;
|
||||
|
||||
/**
|
||||
* Returns the first day of the week (0-6, Sunday to Saturday)
|
||||
* @return {number} first day of the week
|
||||
*/
|
||||
firstDayOfWeek(): number;
|
||||
|
||||
/**
|
||||
* This and the first day of week are used to determine which is
|
||||
* the first week of the year. dow == 1 and doy == 4 means week starts
|
||||
* Monday and first week that has Thursday is the first week of the
|
||||
* year (but doy is NOT simply Thursday).
|
||||
* @return {number} number between 0-15
|
||||
*/
|
||||
firstDayOfYear(): number;
|
||||
}
|
||||
|
||||
interface MomentLongDateFormat {
|
||||
L: string;
|
||||
LL: string;
|
||||
LLL: string;
|
||||
LLLL: string;
|
||||
LT: string;
|
||||
LTS: string;
|
||||
l?: string;
|
||||
ll?: string;
|
||||
lll?: string;
|
||||
llll?: string;
|
||||
lt?: string;
|
||||
lts?: string;
|
||||
}
|
||||
|
||||
interface MomentRelativeTime {
|
||||
future: any;
|
||||
past: any;
|
||||
s: any;
|
||||
m: any;
|
||||
mm: any;
|
||||
h: any;
|
||||
hh: any;
|
||||
d: any;
|
||||
dd: any;
|
||||
M: any;
|
||||
MM: any;
|
||||
y: any;
|
||||
yy: any;
|
||||
}
|
||||
|
||||
interface MomentBuiltinFormat {
|
||||
__momentBuiltinFormatBrand: any;
|
||||
}
|
||||
|
||||
type MomentFormatSpecification = string | MomentBuiltinFormat | (string | MomentBuiltinFormat)[];
|
||||
|
||||
interface MomentStatic {
|
||||
version: string;
|
||||
fn: Moment;
|
||||
|
||||
(): Moment;
|
||||
(date: number): Moment;
|
||||
(date: number[]): Moment;
|
||||
(date: string, format?: MomentFormatSpecification, strict?: boolean): Moment;
|
||||
(date: string, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
|
||||
(date: Date): Moment;
|
||||
(date: Moment): Moment;
|
||||
(date: Object): Moment;
|
||||
|
||||
utc(): Moment;
|
||||
utc(date: number): Moment;
|
||||
utc(date: number[]): Moment;
|
||||
utc(date: string, format?: string, strict?: boolean): Moment;
|
||||
utc(date: string, format?: string, language?: string, strict?: boolean): Moment;
|
||||
utc(date: string, formats: string[], strict?: boolean): Moment;
|
||||
utc(date: string, formats: string[], language?: string, strict?: boolean): Moment;
|
||||
utc(date: Date): Moment;
|
||||
utc(date: Moment): Moment;
|
||||
utc(date: Object): Moment;
|
||||
|
||||
unix(timestamp: number): Moment;
|
||||
|
||||
invalid(parsingFlags?: Object): Moment;
|
||||
isMoment(): boolean;
|
||||
isMoment(m: any): m is Moment;
|
||||
isDate(m: any): m is Date;
|
||||
isDuration(): boolean;
|
||||
isDuration(d: any): d is Duration;
|
||||
|
||||
/**
|
||||
* @deprecated since version 2.8.0
|
||||
*/
|
||||
lang(language?: string): string;
|
||||
lang(language?: string, definition?: MomentLanguage): string;
|
||||
|
||||
locale(language?: string): string;
|
||||
locale(language?: string[]): string;
|
||||
locale(language?: string, definition?: MomentLanguage): string;
|
||||
|
||||
localeData(language?: string): MomentLanguageData;
|
||||
|
||||
longDateFormat: any;
|
||||
relativeTime: any;
|
||||
meridiem: (hour: number, minute: number, isLowercase: boolean) => string;
|
||||
calendar: any;
|
||||
ordinal: (num: number) => string;
|
||||
|
||||
duration(milliseconds: Number): Duration;
|
||||
duration(num: Number, unitOfTime: string): Duration;
|
||||
duration(input: MomentInput): Duration;
|
||||
duration(object: any): Duration;
|
||||
duration(): Duration;
|
||||
|
||||
parseZone(date: string): Moment;
|
||||
|
||||
months(): string[];
|
||||
months(index: number): string;
|
||||
months(format: string): string[];
|
||||
months(format: string, index: number): string;
|
||||
monthsShort(): string[];
|
||||
monthsShort(index: number): string;
|
||||
monthsShort(format: string): string[];
|
||||
monthsShort(format: string, index: number): string;
|
||||
|
||||
weekdays(): string[];
|
||||
weekdays(index: number): string;
|
||||
weekdays(format: string): string[];
|
||||
weekdays(format: string, index: number): string;
|
||||
weekdaysShort(): string[];
|
||||
weekdaysShort(index: number): string;
|
||||
weekdaysShort(format: string): string[];
|
||||
weekdaysShort(format: string, index: number): string;
|
||||
weekdaysMin(): string[];
|
||||
weekdaysMin(index: number): string;
|
||||
weekdaysMin(format: string): string[];
|
||||
weekdaysMin(format: string, index: number): string;
|
||||
|
||||
min(...moments: Moment[]): Moment;
|
||||
min(moments: Moment[]): Moment;
|
||||
max(...moments: Moment[]): Moment;
|
||||
max(moments: Moment[]): Moment;
|
||||
|
||||
normalizeUnits(unit: string): string;
|
||||
relativeTimeThreshold(threshold: string): number | boolean;
|
||||
relativeTimeThreshold(threshold: string, limit: number): boolean;
|
||||
|
||||
/**
|
||||
* @since 2.10.7+
|
||||
*/
|
||||
now(): number;
|
||||
|
||||
/**
|
||||
* Constant used to enable explicit ISO_8601 format parsing.
|
||||
*/
|
||||
ISO_8601: MomentBuiltinFormat;
|
||||
|
||||
defaultFormat: string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module 'moment' {
|
||||
var moment: moment.MomentStatic;
|
||||
export = moment;
|
||||
}
|
||||
|
||||
declare module 'moment/moment' {
|
||||
var moment: moment.MomentStatic;
|
||||
export = moment;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
// Type definitions for Moment.js 2.8.0
|
||||
// Project: https://github.com/timrwood/moment
|
||||
// Definitions by: Michael Lakerveld <https://github.com/Lakerfield>, Aaron King <https://github.com/kingdango>, Hiroki Horiuchi <https://github.com/horiuchi>, Dick van den Brink <https://github.com/DickvdBrink>, Adi Dahiya <https://github.com/adidahiya>, Matt Brooks <https://github.com/EnableSoftware>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="moment-node.d.ts" />
|
||||
|
||||
declare var moment: moment.MomentStatic;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,9 @@
|
|||
// Type definitions for object-assign 4.0.1
|
||||
// Project: https://github.com/sindresorhus/object-assign
|
||||
// Definitions by: Christopher Brown <https://github.com/chbrown>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "object-assign" {
|
||||
function objectAssign(target: any, ...sources: any[]): any;
|
||||
export = objectAssign;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
// Type definitions for React v0.14 (react-addons-create-fragment)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
namespace __Addons {
|
||||
export function createFragment(object: { [key: string]: ReactNode }): ReactFragment;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-create-fragment" {
|
||||
var createFragment: typeof __React.__Addons.createFragment;
|
||||
export = createFragment;
|
||||
}
|
40
samples/react-search-wp/typings/react/react-addons-css-transition-group.d.ts
vendored
Normal file
40
samples/react-search-wp/typings/react/react-addons-css-transition-group.d.ts
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Type definitions for React v0.14 (react-addons-css-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface CSSTransitionGroupTransitionName {
|
||||
enter: string;
|
||||
enterActive?: string;
|
||||
leave: string;
|
||||
leaveActive?: string;
|
||||
appear?: string;
|
||||
appearActive?: string;
|
||||
}
|
||||
|
||||
interface CSSTransitionGroupProps extends TransitionGroupProps {
|
||||
transitionName: string | CSSTransitionGroupTransitionName;
|
||||
transitionAppear?: boolean;
|
||||
transitionAppearTimeout?: number;
|
||||
transitionEnter?: boolean;
|
||||
transitionEnterTimeout?: number;
|
||||
transitionLeave?: boolean;
|
||||
transitionLeaveTimeout?: number;
|
||||
}
|
||||
|
||||
type CSSTransitionGroup = ComponentClass<CSSTransitionGroupProps>;
|
||||
|
||||
namespace __Addons {
|
||||
export var CSSTransitionGroup: __React.CSSTransitionGroup;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-css-transition-group" {
|
||||
var CSSTransitionGroup: __React.CSSTransitionGroup;
|
||||
type CSSTransitionGroup = __React.CSSTransitionGroup;
|
||||
export = CSSTransitionGroup;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Type definitions for React v0.14 (react-addons-linked-state-mixin)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface ReactLink<T> {
|
||||
value: T;
|
||||
requestChange(newValue: T): void;
|
||||
}
|
||||
|
||||
interface LinkedStateMixin extends Mixin<any, any> {
|
||||
linkState<T>(key: string): ReactLink<T>;
|
||||
}
|
||||
|
||||
interface HTMLAttributes {
|
||||
checkedLink?: ReactLink<boolean>;
|
||||
valueLink?: ReactLink<boolean | string | number>;
|
||||
}
|
||||
|
||||
namespace __Addons {
|
||||
export var LinkedStateMixin: LinkedStateMixin;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-linked-state-mixin" {
|
||||
var LinkedStateMixin: __React.LinkedStateMixin;
|
||||
type LinkedStateMixin = __React.LinkedStateMixin;
|
||||
export = LinkedStateMixin;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// Type definitions for React v15.1.0 (react-addons-perf)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface ComponentPerfContext {
|
||||
current: string;
|
||||
owner: string;
|
||||
}
|
||||
|
||||
interface NumericPerfContext {
|
||||
[key: string]: number;
|
||||
}
|
||||
|
||||
interface Measurements {
|
||||
exclusive: NumericPerfContext;
|
||||
inclusive: NumericPerfContext;
|
||||
render: NumericPerfContext;
|
||||
counts: NumericPerfContext;
|
||||
writes: NumericPerfContext;
|
||||
displayNames: {
|
||||
[key: string]: ComponentPerfContext;
|
||||
};
|
||||
totalTime: number;
|
||||
}
|
||||
|
||||
namespace __Addons {
|
||||
namespace Perf {
|
||||
export function start(): void;
|
||||
export function stop(): void;
|
||||
export function printInclusive(measurements?: Measurements[]): void;
|
||||
export function printExclusive(measurements?: Measurements[]): void;
|
||||
export function printWasted(measurements?: Measurements[]): void;
|
||||
export function printOperations(measurements?: Measurements[]): void;
|
||||
export function getLastMeasurements(): Measurements[];
|
||||
export function getExclusive(measurements?: Measurements[]): any;
|
||||
export function getInclusive(measurements?: Measurements[]): any;
|
||||
export function getWasted(measurements?: Measurements[]): any;
|
||||
export function getOperations(measurements?: Measurements[]): any;
|
||||
|
||||
// Renamed to printOperations(). Please use it instead.
|
||||
export function printDOM(measurements?: Measurements[]): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-perf" {
|
||||
import Perf = __React.__Addons.Perf;
|
||||
export = Perf;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// Type definitions for React v0.14 (react-addons-pure-render-mixin)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface PureRenderMixin extends Mixin<any, any> {}
|
||||
|
||||
namespace __Addons {
|
||||
export var PureRenderMixin: PureRenderMixin;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-pure-render-mixin" {
|
||||
var PureRenderMixin: __React.PureRenderMixin;
|
||||
type PureRenderMixin = __React.PureRenderMixin;
|
||||
export = PureRenderMixin;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Type definitions for React v0.14 (react-addons-css-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
namespace __Addons {
|
||||
export function shallowCompare<P, S>(
|
||||
component: __React.Component<P, S>,
|
||||
nextProps: P,
|
||||
nextState: S): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-shallow-compare" {
|
||||
export = __React.__Addons.shallowCompare;
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
// Type definitions for React v0.14 (react-addons-test-utils)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface OptionalEventProperties {
|
||||
bubbles?: boolean;
|
||||
cancelable?: boolean;
|
||||
currentTarget?: EventTarget;
|
||||
defaultPrevented?: boolean;
|
||||
eventPhase?: number;
|
||||
isTrusted?: boolean;
|
||||
nativeEvent?: Event;
|
||||
preventDefault?(): void;
|
||||
stopPropagation?(): void;
|
||||
target?: EventTarget;
|
||||
timeStamp?: Date;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface SyntheticEventData extends OptionalEventProperties {
|
||||
altKey?: boolean;
|
||||
button?: number;
|
||||
buttons?: number;
|
||||
clientX?: number;
|
||||
clientY?: number;
|
||||
changedTouches?: TouchList;
|
||||
charCode?: boolean;
|
||||
clipboardData?: DataTransfer;
|
||||
ctrlKey?: boolean;
|
||||
deltaMode?: number;
|
||||
deltaX?: number;
|
||||
deltaY?: number;
|
||||
deltaZ?: number;
|
||||
detail?: number;
|
||||
getModifierState?(key: string): boolean;
|
||||
key?: string;
|
||||
keyCode?: number;
|
||||
locale?: string;
|
||||
location?: number;
|
||||
metaKey?: boolean;
|
||||
pageX?: number;
|
||||
pageY?: number;
|
||||
relatedTarget?: EventTarget;
|
||||
repeat?: boolean;
|
||||
screenX?: number;
|
||||
screenY?: number;
|
||||
shiftKey?: boolean;
|
||||
targetTouches?: TouchList;
|
||||
touches?: TouchList;
|
||||
view?: AbstractView;
|
||||
which?: number;
|
||||
}
|
||||
|
||||
interface EventSimulator {
|
||||
(element: Element | Component<any, any>, eventData?: SyntheticEventData): void;
|
||||
}
|
||||
|
||||
interface MockedComponentClass {
|
||||
new(): any;
|
||||
}
|
||||
|
||||
class ShallowRenderer {
|
||||
getRenderOutput<E extends ReactElement<any>>(): E;
|
||||
getRenderOutput(): ReactElement<any>;
|
||||
render(element: ReactElement<any>, context?: any): void;
|
||||
unmount(): void;
|
||||
}
|
||||
|
||||
namespace __Addons {
|
||||
namespace TestUtils {
|
||||
namespace Simulate {
|
||||
export var blur: EventSimulator;
|
||||
export var change: EventSimulator;
|
||||
export var click: EventSimulator;
|
||||
export var copy: EventSimulator;
|
||||
export var cut: EventSimulator;
|
||||
export var doubleClick: EventSimulator;
|
||||
export var drag: EventSimulator;
|
||||
export var dragEnd: EventSimulator;
|
||||
export var dragEnter: EventSimulator;
|
||||
export var dragExit: EventSimulator;
|
||||
export var dragLeave: EventSimulator;
|
||||
export var dragOver: EventSimulator;
|
||||
export var dragStart: EventSimulator;
|
||||
export var drop: EventSimulator;
|
||||
export var focus: EventSimulator;
|
||||
export var input: EventSimulator;
|
||||
export var keyDown: EventSimulator;
|
||||
export var keyPress: EventSimulator;
|
||||
export var keyUp: EventSimulator;
|
||||
export var mouseDown: EventSimulator;
|
||||
export var mouseEnter: EventSimulator;
|
||||
export var mouseLeave: EventSimulator;
|
||||
export var mouseMove: EventSimulator;
|
||||
export var mouseOut: EventSimulator;
|
||||
export var mouseOver: EventSimulator;
|
||||
export var mouseUp: EventSimulator;
|
||||
export var paste: EventSimulator;
|
||||
export var scroll: EventSimulator;
|
||||
export var submit: EventSimulator;
|
||||
export var touchCancel: EventSimulator;
|
||||
export var touchEnd: EventSimulator;
|
||||
export var touchMove: EventSimulator;
|
||||
export var touchStart: EventSimulator;
|
||||
export var wheel: EventSimulator;
|
||||
}
|
||||
|
||||
export function renderIntoDocument<T extends Element>(
|
||||
element: DOMElement<any, T>): T;
|
||||
export function renderIntoDocument(
|
||||
element: SFCElement<any>): void;
|
||||
export function renderIntoDocument<T extends Component<any, any>>(
|
||||
element: CElement<any, T>): T;
|
||||
export function renderIntoDocument<P>(
|
||||
element: ReactElement<P>): Component<P, {}> | Element | void;
|
||||
|
||||
export function mockComponent(
|
||||
mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils;
|
||||
|
||||
export function isElementOfType<T extends HTMLElement>(
|
||||
element: ReactElement<any>, type: string): element is ReactHTMLElement<T>;
|
||||
export function isElementOfType<P extends DOMAttributes, T extends Element>(
|
||||
element: ReactElement<any>, type: string): element is DOMElement<P, T>;
|
||||
export function isElementOfType<P>(
|
||||
element: ReactElement<any>, type: SFC<P>): element is SFCElement<P>;
|
||||
export function isElementOfType<P, T extends Component<P, {}>, C extends ComponentClass<P>>(
|
||||
element: ReactElement<any>, type: ClassType<P, T, C>): element is CElement<P, T>;
|
||||
|
||||
export function isDOMComponent(instance: ReactInstance): instance is Element;
|
||||
export function isCompositeComponent(instance: ReactInstance): instance is Component<any, any>;
|
||||
export function isCompositeComponentWithType<T extends Component<any, any>, C extends ComponentClass<any>>(
|
||||
instance: ReactInstance, type: ClassType<any, T, C>): T;
|
||||
|
||||
export function findAllInRenderedTree(
|
||||
root: Component<any, any>,
|
||||
fn: (i: ReactInstance) => boolean): ReactInstance[];
|
||||
|
||||
export function scryRenderedDOMComponentsWithClass(
|
||||
root: Component<any, any>,
|
||||
className: string): Element[];
|
||||
export function findRenderedDOMComponentWithClass(
|
||||
root: Component<any, any>,
|
||||
className: string): Element;
|
||||
|
||||
export function scryRenderedDOMComponentsWithTag(
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element[];
|
||||
export function findRenderedDOMComponentWithTag(
|
||||
root: Component<any, any>,
|
||||
tagName: string): Element;
|
||||
|
||||
export function scryRenderedComponentsWithType<T extends Component<{}, {}>, C extends ComponentClass<{}>>(
|
||||
root: Component<any, any>,
|
||||
type: ClassType<any, T, C>): T[];
|
||||
|
||||
export function findRenderedComponentWithType<T extends Component<{}, {}>, C extends ComponentClass<{}>>(
|
||||
root: Component<any, any>,
|
||||
type: ClassType<any, T, C>): T;
|
||||
|
||||
export function createRenderer(): ShallowRenderer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-test-utils" {
|
||||
import TestUtils = __React.__Addons.TestUtils;
|
||||
export = TestUtils;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// Type definitions for React v0.14 (react-addons-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
|
||||
interface TransitionGroupProps extends HTMLAttributes {
|
||||
component?: ReactType;
|
||||
className?: string;
|
||||
childFactory?: (child: ReactElement<any>) => ReactElement<any>;
|
||||
}
|
||||
|
||||
type TransitionGroup = ComponentClass<TransitionGroupProps>;
|
||||
|
||||
namespace __Addons {
|
||||
export var TransitionGroup: __React.TransitionGroup;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-transition-group" {
|
||||
var TransitionGroup: __React.TransitionGroup;
|
||||
type TransitionGroup = __React.TransitionGroup;
|
||||
export = TransitionGroup;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Type definitions for React v0.14 (react-addons-update)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
interface UpdateSpecCommand {
|
||||
$set?: any;
|
||||
$merge?: {};
|
||||
$apply?(value: any): any;
|
||||
}
|
||||
|
||||
interface UpdateSpecPath {
|
||||
[key: string]: UpdateSpec;
|
||||
}
|
||||
|
||||
type UpdateSpec = UpdateSpecCommand | UpdateSpecPath;
|
||||
|
||||
interface UpdateArraySpec extends UpdateSpecCommand {
|
||||
$push?: any[];
|
||||
$unshift?: any[];
|
||||
$splice?: any[][];
|
||||
}
|
||||
|
||||
namespace __Addons {
|
||||
export function update(value: any[], spec: UpdateArraySpec): any[];
|
||||
export function update(value: {}, spec: UpdateSpec): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-addons-update" {
|
||||
export = __React.__Addons.update;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// Type definitions for React v0.14 (react-dom)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare namespace __React {
|
||||
namespace __DOM {
|
||||
function findDOMNode<E extends Element>(instance: ReactInstance): E;
|
||||
function findDOMNode(instance: ReactInstance): Element;
|
||||
|
||||
function render<P extends DOMAttributes, T extends Element>(
|
||||
element: DOMElement<P, T>,
|
||||
container: Element,
|
||||
callback?: (element: T) => any): T;
|
||||
function render<P>(
|
||||
element: SFCElement<P>,
|
||||
container: Element,
|
||||
callback?: () => any): void;
|
||||
function render<P, T extends Component<P, ComponentState>>(
|
||||
element: CElement<P, T>,
|
||||
container: Element,
|
||||
callback?: (component: T) => any): T;
|
||||
function render<P>(
|
||||
element: ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
|
||||
|
||||
function unmountComponentAtNode(container: Element): boolean;
|
||||
|
||||
var version: string;
|
||||
|
||||
function unstable_batchedUpdates<A, B>(callback: (a: A, b: B) => any, a: A, b: B): void;
|
||||
function unstable_batchedUpdates<A>(callback: (a: A) => any, a: A): void;
|
||||
function unstable_batchedUpdates(callback: () => any): void;
|
||||
|
||||
function unstable_renderSubtreeIntoContainer<P extends DOMAttributes, T extends Element>(
|
||||
parentComponent: Component<any, any>,
|
||||
element: DOMElement<P, T>,
|
||||
container: Element,
|
||||
callback?: (element: T) => any): T;
|
||||
function unstable_renderSubtreeIntoContainer<P, T extends Component<P, ComponentState>>(
|
||||
parentComponent: Component<any, any>,
|
||||
element: CElement<P, T>,
|
||||
container: Element,
|
||||
callback?: (component: T) => any): T;
|
||||
function render<P>(
|
||||
parentComponent: Component<any, any>,
|
||||
element: SFCElement<P>,
|
||||
container: Element,
|
||||
callback?: () => any): void;
|
||||
function unstable_renderSubtreeIntoContainer<P>(
|
||||
parentComponent: Component<any, any>,
|
||||
element: ReactElement<P>,
|
||||
container: Element,
|
||||
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
|
||||
}
|
||||
|
||||
namespace __DOMServer {
|
||||
function renderToString(element: ReactElement<any>): string;
|
||||
function renderToStaticMarkup(element: ReactElement<any>): string;
|
||||
var version: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-dom" {
|
||||
import DOM = __React.__DOM;
|
||||
export = DOM;
|
||||
}
|
||||
|
||||
declare module "react-dom/server" {
|
||||
import DOMServer = __React.__DOMServer;
|
||||
export = DOMServer;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Type definitions for React v0.14 (namespace)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
/// <reference path="react-dom.d.ts" />
|
||||
/// <reference path="react-addons-create-fragment.d.ts" />
|
||||
/// <reference path="react-addons-css-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-linked-state-mixin.d.ts" />
|
||||
/// <reference path="react-addons-perf.d.ts" />
|
||||
/// <reference path="react-addons-pure-render-mixin.d.ts" />
|
||||
/// <reference path="react-addons-test-utils.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-update.d.ts" />
|
||||
|
||||
import React = __React;
|
||||
import ReactDOM = __React.__DOM;
|
||||
|
||||
declare namespace __React {
|
||||
export import addons = __React.__Addons;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,21 @@
|
|||
// Type definitions for System.js 0.18.4
|
||||
// Project: https://github.com/systemjs/systemjs
|
||||
// Definitions by: Ludovic HENIN <https://github.com/ludohenin/>, Nathan Walker <https://github.com/NathanWalker/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface System {
|
||||
import(name: string): any;
|
||||
defined: any;
|
||||
amdDefine: () => void;
|
||||
amdRequire: () => void;
|
||||
baseURL: string;
|
||||
paths: { [key: string]: string };
|
||||
meta: { [key: string]: Object };
|
||||
config: any;
|
||||
}
|
||||
|
||||
declare var System: System;
|
||||
|
||||
declare module "systemjs" {
|
||||
export = System;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/// <reference path="@ms/odsp.d.ts" />
|
||||
/// <reference path="@ms/odsp-webpack.d.ts" />
|
||||
/// <reference path="assertion-error/assertion-error.d.ts" />
|
||||
/// <reference path="chai/chai.d.ts" />
|
||||
/// <reference path="es6-collections/es6-collections.d.ts" />
|
||||
/// <reference path="es6-promise/es6-promise.d.ts" />
|
||||
/// <reference path="lodash/lodash.d.ts" />
|
||||
/// <reference path="mocha/mocha.d.ts" />
|
||||
/// <reference path="node/node.d.ts" />
|
||||
/// <reference path="react/react.d.ts" />
|
||||
/// <reference path="react/react-addons-shallow-compare.d.ts" />
|
||||
/// <reference path="react/react-addons-test-utils.d.ts" />
|
||||
/// <reference path="react/react-addons-update.d.ts" />
|
||||
/// <reference path="react/react-dom.d.ts" />
|
||||
/// <reference path="systemjs/systemjs.d.ts" />
|
||||
/// <reference path="whatwg-fetch/whatwg-fetch.d.ts" />
|
||||
/// <reference path="knockout/knockout.d.ts" />
|
||||
/// <reference path="fbemitter/fbemitter.d.ts" />
|
||||
/// <reference path="flux/flux.d.ts" />
|
||||
/// <reference path="immutable/immutable.d.ts" />
|
||||
/// <reference path="object-assign/object-assign.d.ts" />
|
||||
/// <reference path="form-data/form-data.d.ts" />
|
||||
/// <reference path="combokeys/combokeys.d.ts" />
|
||||
/// <reference path="react/react-addons-create-fragment.d.ts" />
|
||||
/// <reference path="react/react-addons-css-transition-group.d.ts" />
|
||||
/// <reference path="react/react-addons-linked-state-mixin.d.ts" />
|
||||
/// <reference path="react/react-addons-perf.d.ts" />
|
||||
/// <reference path="react/react-addons-pure-render-mixin.d.ts" />
|
||||
/// <reference path="react/react-addons-transition-group.d.ts" />
|
||||
/// <reference path="react/react-global.d.ts" />
|
|
@ -0,0 +1,87 @@
|
|||
// Type definitions for fetch API
|
||||
// Project: https://github.com/github/fetch
|
||||
// Definitions by: Ryan Graham <https://github.com/ryan-codingintrigue>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
declare class Request extends Body {
|
||||
constructor(input: string|Request, init?:RequestInit);
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Headers;
|
||||
context: string|RequestContext;
|
||||
referrer: string;
|
||||
mode: string|RequestMode;
|
||||
credentials: string|RequestCredentials;
|
||||
cache: string|RequestCache;
|
||||
}
|
||||
|
||||
interface RequestInit {
|
||||
method?: string;
|
||||
headers?: HeaderInit|{ [index: string]: string };
|
||||
body?: BodyInit;
|
||||
mode?: string|RequestMode;
|
||||
credentials?: string|RequestCredentials;
|
||||
cache?: string|RequestCache;
|
||||
}
|
||||
|
||||
declare enum RequestContext {
|
||||
"audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch",
|
||||
"font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import",
|
||||
"internal", "location", "manifest", "object", "ping", "plugin", "prefetch", "script",
|
||||
"serviceworker", "sharedworker", "subresource", "style", "track", "video", "worker",
|
||||
"xmlhttprequest", "xslt"
|
||||
}
|
||||
declare enum RequestMode { "same-origin", "no-cors", "cors" }
|
||||
declare enum RequestCredentials { "omit", "same-origin", "include" }
|
||||
declare enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" }
|
||||
|
||||
declare class Headers {
|
||||
append(name: string, value: string): void;
|
||||
delete(name: string):void;
|
||||
get(name: string): string;
|
||||
getAll(name: string): Array<string>;
|
||||
has(name: string): boolean;
|
||||
set(name: string, value: string): void;
|
||||
}
|
||||
|
||||
declare class Body {
|
||||
bodyUsed: boolean;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
blob(): Promise<Blob>;
|
||||
formData(): Promise<FormData>;
|
||||
json(): Promise<any>;
|
||||
json<T>(): Promise<T>;
|
||||
text(): Promise<string>;
|
||||
}
|
||||
declare class Response extends Body {
|
||||
constructor(body?: BodyInit, init?: ResponseInit);
|
||||
error(): Response;
|
||||
redirect(url: string, status: number): Response;
|
||||
type: string|ResponseType;
|
||||
url: string;
|
||||
status: number;
|
||||
ok: boolean;
|
||||
statusText: string;
|
||||
headers: Headers;
|
||||
clone(): Response;
|
||||
}
|
||||
|
||||
declare enum ResponseType { "basic", "cors", "default", "error", "opaque" }
|
||||
|
||||
interface ResponseInit {
|
||||
status: number;
|
||||
statusText?: string;
|
||||
headers?: HeaderInit;
|
||||
}
|
||||
|
||||
declare type HeaderInit = Headers|Array<string>;
|
||||
declare type BodyInit = Blob|FormData|string;
|
||||
declare type RequestInfo = Request|string;
|
||||
|
||||
interface Window {
|
||||
fetch(url: string|Request, init?: RequestInit): Promise<Response>;
|
||||
}
|
||||
|
||||
declare var fetch: typeof window.fetch;
|
Loading…
Reference in New Issue