Merge pull request #47 from Microsoft/features/samples-ui-fabric-react2
Add new sample showing Office UI Fabric React
This commit is contained in:
Коммит
31afefdd1a
|
@ -1,5 +1,4 @@
|
|||
dist/
|
||||
typings/
|
||||
bower_components/
|
||||
node_modules/
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
dist/
|
||||
node_modules/
|
||||
scripts/**/*.js
|
||||
scripts/**/*.js.map
|
||||
*.vsix
|
||||
index.html
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "tsc",
|
||||
"isShellCommand": true,
|
||||
"args": ["-w", "-p", "."],
|
||||
"showOutput": "silent",
|
||||
"isWatching": true,
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
declare module "react" {
|
||||
export = React;
|
||||
}
|
||||
|
||||
declare module "react-dom" {
|
||||
export = ReactDOM;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
# Team Services Office UI Fabric React Sample
|
||||
|
||||
A sample extension for Visual Studio Team Services using [Office UI Fabric React](http://dev.office.com/fabric#/components).
|
||||
|
||||
It uses components like TextField, Button, Checkbox and DetailsList to search for work items and list the results.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
If you plan to build and install this extension, you need:
|
||||
|
||||
* [Node.js](https://nodejs.org) (install with npm)
|
||||
|
||||
## Try it
|
||||
|
||||
After cloning this sample extension, run:
|
||||
|
||||
* ```npm install``` (to pull down required dependencies)
|
||||
|
||||
### Packaging and publishing
|
||||
|
||||
To run the extension, you need to publish it. This requires having a publisher on the Visual Studio Marketplace that you can publish under.
|
||||
|
||||
1. [Get a publisher ID](https://www.visualstudio.com/en-us/docs/integrate/extensions/publish/overview)
|
||||
2. Update the `publisher` property in `manifests/base.json` with your publisher ID. For example:
|
||||
```"publisher": "my-publisher-id"```
|
||||
|
||||
### Packaging
|
||||
|
||||
You can run this sample in two modes:
|
||||
|
||||
* `bundled` scripts are bundled together and packaged with the extension
|
||||
* `local`: scripts are not bundled and served from a local web server)
|
||||
|
||||
Bundled is the easiest since it doesn't require a local web server. Local is faster to develop and debug since content is served from your machine and updates can be made without updating the extension package.
|
||||
|
||||
In both modes, the `--rev-version` package option is applied. This causes the third segment of the extension's version to be incremented on each package (and for the manifest file to be updated). See [TFX CLI extension commands](https://github.com/Microsoft/tfs-cli/blob/master/docs/extensions.md) for more information.
|
||||
|
||||
#### Bundled
|
||||
|
||||
To create a self-contained extension package (.vsix file) containing all the scripts and files needed by the extension run:
|
||||
|
||||
```node_modules/.bin/gulp```
|
||||
|
||||
This will create a extension package (.vsix file) in the `dist` folder.
|
||||
|
||||
#### Local web server
|
||||
|
||||
During development it can be faster to run your own web server on your local machine. To go this route:
|
||||
|
||||
1. Update the `baseUri` property in `manifests/local.json` to point to your local web server. For example: `http://mymachine:8080/ui-officefabric`.
|
||||
2. Run ```node_modules/.bin/gulp --local```
|
||||
|
||||
This will create a extension package (.vsix file) in the `dist` folder.
|
||||
|
||||
In local model, updates to HTML or CSS files do not require re-packaging or re-publishing the extension since content is served locally. Changes to TypeScript files requires compilation:
|
||||
|
||||
```node_modules/.bin/tsc```
|
||||
|
||||
To have TypeScript file changes get built automatically, run:
|
||||
|
||||
```node_modules/.bin/tsc -w```
|
||||
|
||||
### Publishing
|
||||
|
||||
To publish the packaged extension file (.vsix) to the Marketplace from the command line, run:
|
||||
|
||||
```node_modules/.bin/tfx extension publish --vsix dist/my-publisher-id.samples-ui-fabric-react-1.0.0.vsix```
|
||||
|
||||
Or upload via the web-based management portal. See [Publish the extension](https://www.visualstudio.com/en-us/docs/integrate/extensions/publish/overview) to the Visual Studio Marketplace (or your local Team Foundation Server)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
.filter-section {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.filter-section .filters {
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
.filter-section .filters .filter-check {
|
||||
margin-right: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.filter-section .actions {
|
||||
float:right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.filter-section .actions .action-button {
|
||||
margin-left: 10px;
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
const path = require("path");
|
||||
const gulp = require('gulp');
|
||||
const template = require('gulp-template');
|
||||
const webpack = require('gulp-webpack');
|
||||
const rename = require('gulp-rename');
|
||||
const ts = require("gulp-typescript");
|
||||
const yargs = require("yargs");
|
||||
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
const tsProject = ts.createProject('tsconfig.json', {
|
||||
typescript: require('typescript')
|
||||
});
|
||||
|
||||
var argv = yargs.string("publisher").argv;
|
||||
|
||||
const publisherIdOverride = argv.publisher || "";
|
||||
const isBundled = argv.local ? false : true;
|
||||
const distFolder = 'dist';
|
||||
const contentFolder = isBundled ? distFolder : '.';
|
||||
|
||||
var templateValues = {};
|
||||
|
||||
if (isBundled) {
|
||||
templateValues.head = `
|
||||
<link href="css/fabric.min.css" rel="stylesheet" />
|
||||
<link href="css/main.css" rel="stylesheet" />
|
||||
<script src="scripts/VSS.SDK.min.js"></script>
|
||||
`;
|
||||
|
||||
templateValues.init = `
|
||||
VSS.init({
|
||||
usePlatformScripts: true,
|
||||
usePlatformStyles: true
|
||||
});
|
||||
|
||||
VSS.require(["scripts/Bundle"], function (Bundle) {
|
||||
Bundle.init("work-item-search-view");
|
||||
});
|
||||
`;
|
||||
}
|
||||
else {
|
||||
templateValues.head = `
|
||||
<link href="node_modules/office-ui-fabric-react/dist/css/fabric.css" rel="stylesheet" />
|
||||
<link href="css/main.css" rel="stylesheet" />
|
||||
<script src="node_modules/vss-web-extension-sdk/lib/VSS.SDK.js"></script>
|
||||
`;
|
||||
|
||||
templateValues.init = `
|
||||
VSS.init({
|
||||
usePlatformScripts: true,
|
||||
usePlatformStyles: true,
|
||||
moduleLoaderConfig: {
|
||||
paths: {
|
||||
"OfficeFabric": "node_modules/office-ui-fabric-react/lib-amd",
|
||||
"@microsoft/load-themed-styles": "node_modules/office-ui-fabric-react/node_modules/@microsoft/load-themed-styles/lib-amd/index"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
VSS.require(["scripts/WorkItemSearchComponent"], function (WorkItemSearchComponent) {
|
||||
WorkItemSearchComponent.init("work-item-search-view");
|
||||
});
|
||||
`;
|
||||
}
|
||||
|
||||
gulp.task('template', () => {
|
||||
return gulp.src('index.html.template')
|
||||
.pipe(template(templateValues))
|
||||
.pipe(rename(function(path) {
|
||||
path.basename = 'index';
|
||||
path.extname = '.html';
|
||||
}))
|
||||
.pipe(gulp.dest(contentFolder));
|
||||
});
|
||||
|
||||
gulp.task('build', () => {
|
||||
var tsResult = gulp.src(['scripts/**/*.tsx', 'scripts/**/*.ts'])
|
||||
.pipe(tsProject());
|
||||
|
||||
return tsResult.js.pipe(gulp.dest('scripts'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('copy', ['build'], () => {
|
||||
if (isBundled) {
|
||||
gulp.src('node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js')
|
||||
.pipe(gulp.dest(contentFolder + '/scripts'));
|
||||
|
||||
return gulp.src(['node_modules/office-ui-fabric-react/dist/*css/*.min.css', '*css/*.css'])
|
||||
.pipe(gulp.dest(contentFolder));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('webpack', ['copy'], () => {
|
||||
if (isBundled) {
|
||||
return gulp.src('./scripts/WorkItemSearchComponent.js')
|
||||
.pipe(webpack(require('./webpack.config.js')))
|
||||
.pipe(gulp.dest(contentFolder + "/scripts"));
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('tfxpack', ['webpack'], ()=> {
|
||||
const rootArg = `--root ${contentFolder}`;
|
||||
const outputPathArg = `--output-path ${distFolder}`;
|
||||
const manifestsArg = `--manifests ${isBundled ? '../' : ''}manifests/base.json`;
|
||||
const overridesFileArg = `--overrides-file manifests/${isBundled ? 'bundled.json' : 'local.json'}`;
|
||||
const publisherOverrideArg = publisherIdOverride != "" ? `--publisher ${publisherIdOverride}` : '';
|
||||
|
||||
// run tfx
|
||||
exec(`${path.join(__dirname, "node_modules", ".bin", "tfx.cmd")} extension create ${rootArg} ${outputPathArg} ${manifestsArg} ${overridesFileArg} ${publisherOverrideArg} --rev-version`,
|
||||
(err, stdout, stderr) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
console.log(stdout);
|
||||
console.log(stderr);
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('default', ['template', 'tfxpack']);
|
|
@ -0,0 +1,24 @@
|
|||
<html dir="ltr">
|
||||
|
||||
<head>
|
||||
<title>Work Item Search</title>
|
||||
<%= head %>
|
||||
<style>
|
||||
body.my-extension {
|
||||
padding: 10px 20px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="my-extension">
|
||||
<script type="text/javascript">
|
||||
<%= init %>
|
||||
</script>
|
||||
|
||||
<h2>Work Item Search</h2>
|
||||
<div id="work-item-search-view"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"manifestVersion": 1,
|
||||
"id": "samples-ui-fabric-react",
|
||||
"version": "1.0.3",
|
||||
"publisher": "ms-samples",
|
||||
"name": "Office UI Fabric React Sample",
|
||||
"description": "Sample Team Services web extension using Office UI Fabric React",
|
||||
"public": false,
|
||||
"tags": [
|
||||
"samples",
|
||||
"fabric",
|
||||
"ui"
|
||||
],
|
||||
"scopes": ["vso.work_write"],
|
||||
"targets": [
|
||||
{
|
||||
"id": "Microsoft.VisualStudio.Services"
|
||||
}
|
||||
],
|
||||
"categories": [
|
||||
"Developer samples"
|
||||
],
|
||||
"contributions": [
|
||||
{
|
||||
"id": "samples",
|
||||
"type": "ms.vss-web.hub",
|
||||
"targets": [
|
||||
"ms.vss-work-web.work-hub-group"
|
||||
],
|
||||
"properties": {
|
||||
"name": "Search (Fabric)",
|
||||
"order": 1000,
|
||||
"uri": "index.html"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"files": [
|
||||
{
|
||||
"path": "../dist/css",
|
||||
"addressable": true
|
||||
},
|
||||
{
|
||||
"path": "../dist/scripts",
|
||||
"addressable": true
|
||||
},
|
||||
{
|
||||
"path": "../dist/index.html",
|
||||
"addressable": true
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"baseUri": "http://local-uri-for-development"
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "samples-ui-fabric-react",
|
||||
"version": "1.0.0",
|
||||
"description": "Sample Team Services web extension using Office UI Fabric React",
|
||||
"main": "index.html",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"vsts",
|
||||
"extension",
|
||||
"office-ui-fabric-react"
|
||||
],
|
||||
"author": "serkan-inci",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/react": "^0.14.48",
|
||||
"@types/react-dom": "^0.14.18",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-template": "^4.0.0",
|
||||
"gulp-typescript": "^3.1.3",
|
||||
"gulp-webpack": "^1.5.0",
|
||||
"tfx-cli": "^0.3.40",
|
||||
"typescript": "^2.0.10",
|
||||
"webpack": "^1.13.3",
|
||||
"yargs": "^6.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"office-ui-fabric-react": "^0.74.0",
|
||||
"vss-web-extension-sdk": "^1.108.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
/// <reference path='../@types/react-amd-module/index.d.ts' />
|
||||
/// <reference path='../typings/tsd.d.ts' />
|
||||
|
||||
import * as Q from 'q';
|
||||
import { getClient, WorkItemTrackingHttpClient } from 'TFS/WorkItemTracking/RestClient';
|
||||
import { WorkItem, WorkItemFieldReference } from 'TFS/WorkItemTracking/Contracts';
|
||||
import { ignoreCaseComparer } from 'VSS/Utils/String';
|
||||
|
||||
export interface IWiqlQueryResult {
|
||||
columns: WorkItemFieldReference[];
|
||||
workItems: WorkItem[];
|
||||
}
|
||||
|
||||
export interface IWorkItemSearchResult {
|
||||
queryResult?: IWiqlQueryResult;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface IWorkItemSearchFilter {
|
||||
keyword?: string;
|
||||
tags?: string[];
|
||||
assignedToMe?: boolean;
|
||||
hasAttachments?: boolean;
|
||||
hasLinks?: boolean;
|
||||
}
|
||||
|
||||
export interface IWorkItemSearch {
|
||||
begingetResult(filter: IWorkItemSearchFilter): IPromise<IWorkItemSearchResult>;
|
||||
filterValid(filter: IWorkItemSearchFilter): boolean;
|
||||
}
|
||||
|
||||
interface IWiqlResult {
|
||||
wiql?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
class WorkItemSearch implements IWorkItemSearch {
|
||||
private _httpClient: WorkItemTrackingHttpClient;
|
||||
|
||||
public get httpClient(): WorkItemTrackingHttpClient {
|
||||
if (!this._httpClient) {
|
||||
this._httpClient = getClient();
|
||||
}
|
||||
|
||||
return this._httpClient;
|
||||
}
|
||||
|
||||
public begingetResult(filter: IWorkItemSearchFilter): IPromise<IWorkItemSearchResult> {
|
||||
let wiqlResult = this.buildWiql(filter);
|
||||
if (wiqlResult.wiql) {
|
||||
return this.httpClient.queryByWiql({ query: wiqlResult.wiql }, VSS.getWebContext().project.id).then(
|
||||
queryResult => {
|
||||
// We got the work item ids, now get the field values
|
||||
if (queryResult.workItems.length > 0) {
|
||||
return this.httpClient.getWorkItems(queryResult.workItems.map(wi => wi.id), queryResult.columns.map(wiRef => wiRef.referenceName)).then(
|
||||
workItems => { return <IWorkItemSearchResult>{ queryResult: { columns: queryResult.columns, workItems: workItems } }; },
|
||||
err => { return <IWorkItemSearchResult>{ error: err.message }; });
|
||||
} else {
|
||||
return <IWorkItemSearchResult>{ queryResult: { columns: queryResult.columns, workItems: [] } };
|
||||
}
|
||||
},
|
||||
err => { return <IWorkItemSearchResult>{ error: err.message }; });
|
||||
}
|
||||
|
||||
return Q(<IWorkItemSearchResult>{ error: wiqlResult.error });
|
||||
}
|
||||
|
||||
public filterValid(filter: IWorkItemSearchFilter): boolean {
|
||||
return Boolean(this.buildWiql(filter).wiql);
|
||||
}
|
||||
|
||||
private buildWiql(filter: IWorkItemSearchFilter): IWiqlResult {
|
||||
if (filter && filter.keyword && filter.keyword.length >= 3) {
|
||||
let wiqlWhereClauses = [`([System.TeamProject] = @project)`];
|
||||
// Add keyword
|
||||
wiqlWhereClauses.push(`([System.Title] CONTAINS '${filter.keyword}' OR [System.Description] CONTAINS '${filter.keyword}')`);
|
||||
|
||||
if (filter.assignedToMe) {
|
||||
wiqlWhereClauses.push(`([System.AssignedTo] = @me)`);
|
||||
}
|
||||
|
||||
if (filter.hasAttachments) {
|
||||
wiqlWhereClauses.push(`([System.AttachedFileCount] > 0)`);
|
||||
}
|
||||
|
||||
if (filter.hasLinks) {
|
||||
wiqlWhereClauses.push(`([System.RelatedLinkCount] > 0)`);
|
||||
}
|
||||
|
||||
return {
|
||||
wiql: `SELECT [System.Id],
|
||||
[System.WorkItemType],
|
||||
[System.AssignedTo],
|
||||
[System.Title],
|
||||
[System.State],
|
||||
[System.AttachedFileCount],
|
||||
[System.RelatedLinkCount],
|
||||
[System.Tags]
|
||||
FROM WorkItems
|
||||
WHERE ${wiqlWhereClauses.join(" AND ")}
|
||||
ORDER BY [System.ChangedDate] DESC`};
|
||||
}
|
||||
|
||||
return { error: "Specify at least 3 chars for the keyword" };
|
||||
}
|
||||
}
|
||||
|
||||
export var Instance: IWorkItemSearch = new WorkItemSearch();
|
|
@ -0,0 +1,164 @@
|
|||
// react imports
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
|
||||
// office-ui-fabric-react imports
|
||||
import { TextField } from 'OfficeFabric/components/TextField/TextField';
|
||||
import { Checkbox } from 'OfficeFabric/components/Checkbox/Checkbox';
|
||||
import { Button } from 'OfficeFabric/components/Button/Button';
|
||||
import { ButtonType } from 'OfficeFabric/components/Button/Button.Props';
|
||||
import { Label } from 'OfficeFabric/components/Label/Label';
|
||||
import { MessageBar } from 'OfficeFabric/components/MessageBar/MessageBar';
|
||||
import { MessageBarType } from 'OfficeFabric/components/MessageBar/MessageBar.Props';
|
||||
import { DetailsList } from 'OfficeFabric/components/DetailsList/DetailsList';
|
||||
|
||||
// vsts imports
|
||||
import { WorkItemFormNavigationService } from "TFS/WorkItemTracking/Services";
|
||||
import { toDictionary } from "VSS/Utils/Array";
|
||||
|
||||
import {
|
||||
Instance as WorkItemSearch,
|
||||
IWorkItemSearchFilter,
|
||||
IWorkItemSearchResult,
|
||||
IWiqlQueryResult
|
||||
} from "./WorkItemSearch";
|
||||
|
||||
interface IWorkItemSearchProps {
|
||||
|
||||
}
|
||||
|
||||
interface IWorkItemSearchState {
|
||||
querying?: boolean;
|
||||
filter?: IWorkItemSearchFilter;
|
||||
result?: IWorkItemSearchResult;
|
||||
}
|
||||
|
||||
class WorkItemSearchComponent extends React.Component<IWorkItemSearchProps, IWorkItemSearchState> {
|
||||
private _widths = [50, 100, 150, 300, 150, 150, 200];
|
||||
|
||||
constructor(props?: IWorkItemSearchProps) {
|
||||
super(props);
|
||||
this.state = this._getDefaultState();
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
let filter = this.state.filter;
|
||||
let filterSection = <div className="filter-section">
|
||||
<TextField placeholder="Enter a keyword to search work items" className="keyword" onChanged={this._onKeywordChange.bind(this)} value={filter.keyword} onKeyPress={this._onKeywordKeypress.bind(this)} />
|
||||
<div className="filters">
|
||||
<Checkbox label='Assigned to me' onChange={this._onAssignedToMeChange.bind(this)} checked={filter.assignedToMe} className="filter-check" />
|
||||
<Checkbox label='Has attachments' onChange={this._onHasAttachmentsChange.bind(this)} checked={filter.hasAttachments} className="filter-check" />
|
||||
<Checkbox label='Has links' onChange={this._onHasLinksChange.bind(this)} checked={filter.hasLinks} className="filter-check" />
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button onClick={this._onClearClick.bind(this)} className="action-button">Clear</Button>
|
||||
<Button onClick={this._onSearchClick.bind(this)} buttonType={ButtonType.primary} disabled={!this._canSearch(this.state)} className="action-button">Search</Button>
|
||||
</div>
|
||||
</div>;
|
||||
|
||||
let result = this.state.result;
|
||||
let resultSection: JSX.Element = null;
|
||||
if (result.queryResult) {
|
||||
if (result.queryResult.workItems.length > 0) {
|
||||
resultSection = this._getWorkItemsList(result.queryResult);
|
||||
}
|
||||
else {
|
||||
resultSection = <MessageBar messageBarType={MessageBarType.info}>No work items found</MessageBar>
|
||||
}
|
||||
} else if (result.error) {
|
||||
resultSection = <MessageBar messageBarType={MessageBarType.error}>{result.error}</MessageBar>
|
||||
} else if (this.state.querying) {
|
||||
resultSection = <Label>Querying...</Label>;
|
||||
}
|
||||
|
||||
return <div className="work-item-search">
|
||||
{filterSection}
|
||||
{resultSection}
|
||||
</div>;
|
||||
}
|
||||
|
||||
private _canSearch(state: IWorkItemSearchState): boolean {
|
||||
return !state.querying && WorkItemSearch.filterValid(state.filter);
|
||||
}
|
||||
|
||||
private _getWorkItemsList(queryResult: IWiqlQueryResult): JSX.Element {
|
||||
let columns = queryResult.columns.map((c, i) => { return { key: c.referenceName, name: c.name, fieldName: c.referenceName, minWidth: this._widths[i] } });
|
||||
let items = queryResult.workItems.map(wi => wi.fields);
|
||||
|
||||
return <DetailsList
|
||||
columns={columns}
|
||||
items={items}
|
||||
setKey='set'
|
||||
onItemInvoked={(item) => {
|
||||
WorkItemFormNavigationService.getService().then(svc => {
|
||||
svc.openWorkItem(item["System.Id"]);
|
||||
});
|
||||
} }
|
||||
/>
|
||||
}
|
||||
|
||||
private _getDefaultState(): IWorkItemSearchState {
|
||||
return {
|
||||
querying: false,
|
||||
filter: {
|
||||
keyword: "",
|
||||
assignedToMe: false,
|
||||
hasAttachments: false,
|
||||
hasLinks: false
|
||||
},
|
||||
result: {}
|
||||
};
|
||||
}
|
||||
|
||||
private _onKeywordChange(newValue: string): void {
|
||||
this.state.filter.keyword = newValue;
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
private _onKeywordKeypress(ev: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (ev.which === 13 && this._canSearch(this.state)) { // Enter
|
||||
this.state.filter.keyword = ev.currentTarget.value;
|
||||
this._performSearch();
|
||||
}
|
||||
}
|
||||
|
||||
private _onAssignedToMeChange(ev: React.FormEvent<HTMLElement>, isChecked: boolean): void {
|
||||
this.state.filter.assignedToMe = isChecked;
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
private _onHasAttachmentsChange(ev: React.FormEvent<HTMLElement>, isChecked: boolean): void {
|
||||
this.state.filter.hasAttachments = isChecked;
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
private _onHasLinksChange(ev: React.FormEvent<HTMLElement>, isChecked: boolean): void {
|
||||
this.state.filter.hasLinks = isChecked;
|
||||
this.setState(this.state);
|
||||
}
|
||||
|
||||
private _onClearClick(ev: React.MouseEvent<HTMLButtonElement>): void {
|
||||
this.setState(this._getDefaultState());
|
||||
}
|
||||
|
||||
private _onSearchClick(ev: React.MouseEvent<HTMLButtonElement>): void {
|
||||
this._performSearch();
|
||||
}
|
||||
|
||||
private _performSearch(): void {
|
||||
this._setSearchResult(true, {});
|
||||
WorkItemSearch.begingetResult(this.state.filter).then((result: IWorkItemSearchResult) => {
|
||||
this._setSearchResult(false, result);
|
||||
});
|
||||
}
|
||||
|
||||
private _setSearchResult(querying: boolean, result: IWorkItemSearchResult): void {
|
||||
this.state.querying = querying;
|
||||
this.state.result = result;
|
||||
this.setState(this.state);
|
||||
}
|
||||
}
|
||||
|
||||
export function init(containerId: string): void {
|
||||
ReactDOM.render(<WorkItemSearchComponent />, document.getElementById(containerId));
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "amd",
|
||||
"moduleResolution": "classic",
|
||||
"target": "es5",
|
||||
"noImplicitAny": false,
|
||||
"jsx": "react",
|
||||
"sourceMap": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"OfficeFabric/*": ["node_modules/office-ui-fabric-react/lib-amd/*"]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"knockout/knockout.d.ts": {
|
||||
"commit": "f5ab2df94e1aabf0fc6d783ad01c4c4671760627"
|
||||
},
|
||||
"requirejs/require.d.ts": {
|
||||
"commit": "f5ab2df94e1aabf0fc6d783ad01c4c4671760627"
|
||||
},
|
||||
"q/Q.d.ts": {
|
||||
"commit": "f5ab2df94e1aabf0fc6d783ad01c4c4671760627"
|
||||
},
|
||||
"jquery/jquery.d.ts": {
|
||||
"commit": "f5ab2df94e1aabf0fc6d783ad01c4c4671760627"
|
||||
},
|
||||
"react/react.d.ts": {
|
||||
"commit": "f5ab2df94e1aabf0fc6d783ad01c4c4671760627"
|
||||
}
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,683 @@
|
|||
// Type definitions for Knockout v3.4.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/>, Matt Brooks <https://github.com/EnableSoftware>
|
||||
// Definitions: https://github.com/DefinitelyTyped/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: "beforeChange"): KnockoutSubscription;
|
||||
subscribe(callback: (newValue: T) => void, target?: any, event?: "change"): 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> {
|
||||
subscribe(callback: (newValue: KnockoutArrayChange<T>[]) => void, target: any, event: "arrayChange"): KnockoutSubscription;
|
||||
subscribe(callback: (newValue: T[]) => void, target: any, event: "beforeChange"): KnockoutSubscription;
|
||||
subscribe(callback: (newValue: T[]) => void, target?: any, event?: "change"): KnockoutSubscription;
|
||||
subscribe<TEvent>(callback: (newValue: TEvent) => void, target: any, event: string): KnockoutSubscription;
|
||||
|
||||
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: "added" | "deleted" | "retained";
|
||||
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;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
// tasks.js
|
||||
//////////////////////////////////
|
||||
|
||||
interface KnockoutTasks {
|
||||
scheduler: (callback: Function) => any;
|
||||
schedule(task: Function): number;
|
||||
cancel(handle: number): void;
|
||||
runEarly(): 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): instance is KnockoutSubscribable<any>;
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): instance is KnockoutObservable<any>;
|
||||
isWriteableObservable(instance: any): instance is KnockoutObservable<any>;
|
||||
isComputed(instance: any): instance is KnockoutComputed<any>;
|
||||
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[];
|
||||
twoWayBindings: any;
|
||||
parseObjectLiteral: (objectLiteralString: string) => any[];
|
||||
|
||||
/**
|
||||
Internal, private KO utility for updating model properties from within bindings
|
||||
property: If the property being updated is (or might be) an observable, pass it here
|
||||
If it turns out to be a writable observable, it will be written to directly
|
||||
allBindings: An object with a get method to retrieve bindings in the current execution context.
|
||||
This will be searched for a '_ko_property_writers' property in case you're writing to a non-observable
|
||||
(See note below)
|
||||
key: The key identifying the property to be written. Example: for { hasFocus: myValue }, write to 'myValue' by specifying the key 'hasFocus'
|
||||
value: The value to be written
|
||||
checkIfDifferent: If true, and if the property being written is a writable observable, the value will only be written if
|
||||
it is !== existing value on that writable observable
|
||||
|
||||
Note that if you need to write to the viewModel without an observable property,
|
||||
you need to set ko.expressionRewriting.twoWayBindings[key] = true; *before* the binding evaluation.
|
||||
*/
|
||||
writeValueToProperty: (property: KnockoutObservable<any> | any, allBindings: KnockoutAllBindingsAccessor, key: string, value: any, checkIfDifferent?: boolean) => void;
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
|
||||
bindingProvider: {
|
||||
instance: KnockoutBindingProvider;
|
||||
new (): KnockoutBindingProvider;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// selectExtensions.js
|
||||
/////////////////////////////////
|
||||
|
||||
selectExtensions: {
|
||||
|
||||
readValue(element: HTMLElement): any;
|
||||
|
||||
writeValue(element: HTMLElement, value: any): void;
|
||||
};
|
||||
|
||||
components: KnockoutComponents;
|
||||
|
||||
/////////////////////////////////
|
||||
// options.js
|
||||
/////////////////////////////////
|
||||
|
||||
options: {
|
||||
deferUpdates: boolean,
|
||||
|
||||
useOnlyNativeEvents: boolean
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
// tasks.js
|
||||
/////////////////////////////////
|
||||
|
||||
tasks: KnockoutTasks;
|
||||
}
|
||||
|
||||
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 namespace 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;
|
||||
}
|
|
@ -0,0 +1,361 @@
|
|||
// Type definitions for Q
|
||||
// Project: https://github.com/kriskowal/q
|
||||
// Definitions by: Barrie Nemetchek <https://github.com/bnemetchek>, Andrew Gaspar <https://github.com/AndrewGaspar/>, John Reilly <https://github.com/johnnyreilly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* If value is a Q promise, returns the promise.
|
||||
* If value is a promise from another library it is coerced into a Q promise (where possible).
|
||||
*/
|
||||
declare function Q<T>(promise: Q.IPromise<T>): Q.Promise<T>;
|
||||
/**
|
||||
* If value is not a promise, returns a promise that is fulfilled with value.
|
||||
*/
|
||||
declare function Q<T>(value: T): Q.Promise<T>;
|
||||
/**
|
||||
* Calling with nothing at all creates a void promise
|
||||
*/
|
||||
declare function Q(): Q.Promise<void>;
|
||||
|
||||
declare namespace Q {
|
||||
type IWhenable<T> = IPromise<T> | T;
|
||||
interface IPromise<T> {
|
||||
then<U>(onFulfill?: (value: T) => IWhenable<U>, onReject?: (error: any) => IWhenable<U>): IPromise<U>;
|
||||
}
|
||||
|
||||
interface Deferred<T> {
|
||||
promise: Promise<T>;
|
||||
resolve(value?: IWhenable<T>): void;
|
||||
reject(reason: any): void;
|
||||
notify(value: any): void;
|
||||
makeNodeResolver(): (reason: any, value: T) => void;
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
|
||||
|
||||
* finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
|
||||
*/
|
||||
fin(finallyCallback: () => any): Promise<T>;
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
|
||||
|
||||
* finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
|
||||
*/
|
||||
finally(finallyCallback: () => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill?: (value: T) => IWhenable<U>, onReject?: (error: any) => IWhenable<U>, onProgress?: Function): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
*
|
||||
* This is especially useful in conjunction with all
|
||||
*/
|
||||
spread<U>(onFulfill: (...args: any[]) => IWhenable<U>, onReject?: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
fail<U>(onRejected: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, onRejected).
|
||||
*/
|
||||
catch<U>(onRejected: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
|
||||
*/
|
||||
progress(onProgress: (progress: any) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
|
||||
*
|
||||
* This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
|
||||
*
|
||||
* Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
|
||||
*
|
||||
* The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
|
||||
*/
|
||||
done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void;
|
||||
|
||||
/**
|
||||
* If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise.
|
||||
*/
|
||||
nodeify(callback: (reason: any, value: any) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise to get the named property of an object. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return o[propertyName];
|
||||
* });
|
||||
*/
|
||||
get<U>(propertyName: String): Promise<U>;
|
||||
set<U>(propertyName: String, value: any): Promise<U>;
|
||||
delete<U>(propertyName: String): Promise<U>;
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return o[methodName].apply(o, args);
|
||||
* });
|
||||
*/
|
||||
post<U>(methodName: String, args: any[]): Promise<U>;
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
|
||||
*/
|
||||
invoke<U>(methodName: String, ...args: any[]): Promise<U>;
|
||||
fapply<U>(args: any[]): Promise<U>;
|
||||
fcall<U>(...args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for an array of the property names of an object. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return Object.keys(o);
|
||||
* });
|
||||
*/
|
||||
keys(): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(function () { return value; }).
|
||||
*/
|
||||
thenResolve<U>(value: U): Promise<U>;
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(function () { throw reason; }).
|
||||
*/
|
||||
thenReject(reason: any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for that same value, perhaps deferred but not replaced by the promise returned by the onFulfilled handler.
|
||||
*/
|
||||
tap(onFulfilled: (value: T) => any): Promise<T>;
|
||||
|
||||
timeout(ms: number, message?: string): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
delay(ms: number): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
valueOf(): any;
|
||||
|
||||
/**
|
||||
* Returns a "state snapshot" object, which will be in one of three forms:
|
||||
*
|
||||
* - { state: "pending" }
|
||||
* - { state: "fulfilled", value: <fulfllment value> }
|
||||
* - { state: "rejected", reason: <rejection reason> }
|
||||
*/
|
||||
inspect(): PromiseState<T>;
|
||||
}
|
||||
|
||||
interface PromiseState<T> {
|
||||
/**
|
||||
* "fulfilled", "rejected", "pending"
|
||||
*/
|
||||
state: string;
|
||||
value?: T;
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
// If no value provided, returned promise will be of void type
|
||||
export function when(): Promise<void>;
|
||||
|
||||
// if no fulfill, reject, or progress provided, returned promise will be of same type
|
||||
export function when<T>(value: IWhenable<T>): Promise<T>;
|
||||
|
||||
// If a non-promise value is provided, it will not reject or progress
|
||||
export function when<T, U>(value: IWhenable<T>, onFulfilled: (val: T) => IWhenable<U>, onRejected?: (reason: any) => IWhenable<U>, onProgress?: (progress: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now.
|
||||
* See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it.
|
||||
*/
|
||||
// export function try(method: Function, ...args: any[]): Promise<any>;
|
||||
|
||||
export function fbind<T>(method: (...args: any[]) => IWhenable<T>, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
export function fcall<T>(method: (...args: any[]) => T, ...args: any[]): Promise<T>;
|
||||
|
||||
export function send<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function invoke<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function mcall<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
export function denodeify<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nbind<T>(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfbind<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfcall<T>(nodeFunction: Function, ...args: any[]): Promise<T>;
|
||||
export function nfapply<T>(nodeFunction: Function, args: any[]): Promise<T>;
|
||||
|
||||
export function ninvoke<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function npost<T>(nodeModule: any, functionName: string, args: any[]): Promise<T>;
|
||||
export function nsend<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function nmcall<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<A, B, C, D, E, F>(promises: IWhenable<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>, IWhenable<E>, IWhenable<F>]>): Promise<[A, B, C, D, E, F]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<A, B, C, D, E>(promises: IWhenable<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>, IWhenable<E>]>): Promise<[A, B, C, D, E]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<A, B, C, D>(promises: IWhenable<[IWhenable<A>, IWhenable<B>, IWhenable<C>, IWhenable<D>]>): Promise<[A, B, C, D]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<A, B, C>(promises: IWhenable<[IWhenable<A>, IWhenable<B>, IWhenable<C>]>): Promise<[A, B, C]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<A, B>(promises: IWhenable<[IWhenable<A>, IWhenable<B>]>): Promise<[A, B]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<T>(promises: IWhenable<IWhenable<T>[]>): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the first of an array of promises to become settled.
|
||||
*/
|
||||
export function race<T>(promises: IWhenable<T>[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
||||
*/
|
||||
export function allSettled<T>(promises: IWhenable<IWhenable<T>[]>): Promise<PromiseState<T>[]>;
|
||||
|
||||
export function allResolved<T>(promises: IWhenable<IWhenable<T>[]>): Promise<Promise<T>[]>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: IWhenable<T>[], onFulfilled: (...args: T[]) => IWhenable<U>, onRejected?: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms".
|
||||
*/
|
||||
export function timeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay<T>(promise: Promise<T>, ms: number): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay<T>(value: T, ms: number): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay(ms: number): Promise <void>;
|
||||
/**
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
|
||||
*/
|
||||
export function isFulfilled(promise: Promise<any>): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isRejected(promise: Promise<any>): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isPending(promise: Promise<any>): boolean;
|
||||
|
||||
/**
|
||||
* Returns a "deferred" object with a:
|
||||
* promise property
|
||||
* resolve(value) method
|
||||
* reject(reason) method
|
||||
* notify(value) method
|
||||
* makeNodeResolver() method
|
||||
*/
|
||||
export function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is rejected with reason.
|
||||
*/
|
||||
export function reject<T>(reason?: any): Promise<T>;
|
||||
|
||||
export function Promise<T>(resolver: (resolve: (val: IWhenable<T>) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
|
||||
*
|
||||
* This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions.
|
||||
*/
|
||||
export function promised<T>(callback: (...args: any[]) => T): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether the given value is a Q promise.
|
||||
*/
|
||||
export function isPromise(object: any): boolean;
|
||||
/**
|
||||
* Returns whether the given value is a promise (i.e. it's an object with a then function).
|
||||
*/
|
||||
export function isPromiseAlike(object: any): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isPending(object: any): boolean;
|
||||
/**
|
||||
* If an object is not a promise, it is as "near" as possible.
|
||||
* If a promise is rejected, it is as "near" as possible too.
|
||||
* If it’s a fulfilled promise, the fulfillment value is nearer.
|
||||
* If it’s a deferred promise and the deferred has been resolved, the
|
||||
* resolution is "nearer".
|
||||
*/
|
||||
export function nearer<T>(promise: Promise<T>): T;
|
||||
|
||||
/**
|
||||
* This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield.
|
||||
*/
|
||||
export function async<T>(generatorFunction: any): (...args: any[]) => Promise<T>;
|
||||
export function nextTick(callback: Function): void;
|
||||
|
||||
/**
|
||||
* A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror.
|
||||
*/
|
||||
export var onerror: (reason: any) => void;
|
||||
/**
|
||||
* A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced.
|
||||
*/
|
||||
export var longStackSupport: boolean;
|
||||
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
|
||||
* Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
|
||||
* Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
|
||||
* Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
export function resolve<T>(object: IWhenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Resets the global "Q" variable to the value it has before Q was loaded.
|
||||
* This will either be undefined if there was no version or the version of Q which was already loaded before.
|
||||
* @returns { The last version of Q. }
|
||||
*/
|
||||
export function noConflict(): typeof Q;
|
||||
}
|
||||
|
||||
declare module "q" {
|
||||
export = Q;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// Temporarily left blank.
|
|
@ -0,0 +1,417 @@
|
|||
// Type definitions for RequireJS 2.1.20
|
||||
// Project: http://requirejs.org/
|
||||
// Definitions by: Josh Baldwin <https://github.com/jbaldwin/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/*
|
||||
require-2.1.8.d.ts may be freely distributed under the MIT license.
|
||||
|
||||
Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
declare module 'module' {
|
||||
var mod: {
|
||||
config: () => any;
|
||||
id: string;
|
||||
uri: string;
|
||||
}
|
||||
export = mod;
|
||||
}
|
||||
|
||||
interface RequireError extends Error {
|
||||
|
||||
/**
|
||||
* The error ID that maps to an ID on a web page.
|
||||
**/
|
||||
requireType: string;
|
||||
|
||||
/**
|
||||
* Required modules.
|
||||
**/
|
||||
requireModules: string[];
|
||||
|
||||
/**
|
||||
* The original error, if there is one (might be null).
|
||||
**/
|
||||
originalError: Error;
|
||||
}
|
||||
|
||||
interface RequireShim {
|
||||
|
||||
/**
|
||||
* List of dependencies.
|
||||
**/
|
||||
deps?: string[];
|
||||
|
||||
/**
|
||||
* Name the module will be exported as.
|
||||
**/
|
||||
exports?: string;
|
||||
|
||||
/**
|
||||
* Initialize function with all dependcies passed in,
|
||||
* if the function returns a value then that value is used
|
||||
* as the module export value instead of the object
|
||||
* found via the 'exports' string.
|
||||
* @param dependencies
|
||||
* @return
|
||||
**/
|
||||
init?: (...dependencies: any[]) => any;
|
||||
}
|
||||
|
||||
interface RequireConfig {
|
||||
|
||||
// The root path to use for all module lookups.
|
||||
baseUrl?: string;
|
||||
|
||||
// Path mappings for module names not found directly under
|
||||
// baseUrl.
|
||||
paths?: { [key: string]: any; };
|
||||
|
||||
|
||||
// Dictionary of Shim's.
|
||||
// does not cover case of key->string[]
|
||||
shim?: { [key: string]: RequireShim; };
|
||||
|
||||
/**
|
||||
* For the given module prefix, instead of loading the
|
||||
* module with the given ID, substitude a different
|
||||
* module ID.
|
||||
*
|
||||
* @example
|
||||
* requirejs.config({
|
||||
* map: {
|
||||
* 'some/newmodule': {
|
||||
* 'foo': 'foo1.2'
|
||||
* },
|
||||
* 'some/oldmodule': {
|
||||
* 'foo': 'foo1.0'
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
**/
|
||||
map?: {
|
||||
[id: string]: {
|
||||
[id: string]: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows pointing multiple module IDs to a module ID that contains a bundle of modules.
|
||||
*
|
||||
* @example
|
||||
* requirejs.config({
|
||||
* bundles: {
|
||||
* 'primary': ['main', 'util', 'text', 'text!template.html'],
|
||||
* 'secondary': ['text!secondary.html']
|
||||
* }
|
||||
* });
|
||||
**/
|
||||
bundles?: { [key: string]: string[]; };
|
||||
|
||||
/**
|
||||
* AMD configurations, use module.config() to access in
|
||||
* define() functions
|
||||
**/
|
||||
config?: { [id: string]: {}; };
|
||||
|
||||
/**
|
||||
* Configures loading modules from CommonJS packages.
|
||||
**/
|
||||
packages?: {};
|
||||
|
||||
/**
|
||||
* The number of seconds to wait before giving up on loading
|
||||
* a script. The default is 7 seconds.
|
||||
**/
|
||||
waitSeconds?: number;
|
||||
|
||||
/**
|
||||
* A name to give to a loading context. This allows require.js
|
||||
* to load multiple versions of modules in a page, as long as
|
||||
* each top-level require call specifies a unique context string.
|
||||
**/
|
||||
context?: string;
|
||||
|
||||
/**
|
||||
* An array of dependencies to load.
|
||||
**/
|
||||
deps?: string[];
|
||||
|
||||
/**
|
||||
* A function to pass to require that should be require after
|
||||
* deps have been loaded.
|
||||
* @param modules
|
||||
**/
|
||||
callback?: (...modules: any[]) => void;
|
||||
|
||||
/**
|
||||
* If set to true, an error will be thrown if a script loads
|
||||
* that does not call define() or have shim exports string
|
||||
* value that can be checked.
|
||||
**/
|
||||
enforceDefine?: boolean;
|
||||
|
||||
/**
|
||||
* If set to true, document.createElementNS() will be used
|
||||
* to create script elements.
|
||||
**/
|
||||
xhtml?: boolean;
|
||||
|
||||
/**
|
||||
* Extra query string arguments appended to URLs that RequireJS
|
||||
* uses to fetch resources. Most useful to cache bust when
|
||||
* the browser or server is not configured correctly.
|
||||
*
|
||||
* @example
|
||||
* urlArgs: "bust= + (new Date()).getTime()
|
||||
*
|
||||
* As of RequireJS 2.2.0, urlArgs can be a function. If a
|
||||
* function, it will receive the module ID and the URL as
|
||||
* parameters, and it should return a string that will be added
|
||||
* to the end of the URL. Return an empty string if no args.
|
||||
* Be sure to take care of adding the '?' or '&' depending on
|
||||
* the existing state of the URL.
|
||||
*
|
||||
* @example
|
||||
|
||||
* requirejs.config({
|
||||
* urlArgs: function(id, url) {
|
||||
* var args = 'v=1';
|
||||
* if (url.indexOf('view.html') !== -1) {
|
||||
* args = 'v=2'
|
||||
* }
|
||||
*
|
||||
* return (url.indexOf('?') === -1 ? '?' : '&') + args;
|
||||
* }
|
||||
* });
|
||||
**/
|
||||
urlArgs?: string | ((id: string, url: string) => string);
|
||||
|
||||
/**
|
||||
* Specify the value for the type="" attribute used for script
|
||||
* tags inserted into the document by RequireJS. Default is
|
||||
* "text/javascript". To use Firefox's JavasScript 1.8
|
||||
* features, use "text/javascript;version=1.8".
|
||||
**/
|
||||
scriptType?: string;
|
||||
|
||||
/**
|
||||
* If set to true, skips the data-main attribute scanning done
|
||||
* to start module loading. Useful if RequireJS is embedded in
|
||||
* a utility library that may interact with other RequireJS
|
||||
* library on the page, and the embedded version should not do
|
||||
* data-main loading.
|
||||
**/
|
||||
skipDataMain?: boolean;
|
||||
|
||||
/**
|
||||
* Allow extending requirejs to support Subresource Integrity
|
||||
* (SRI).
|
||||
**/
|
||||
onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void;
|
||||
}
|
||||
|
||||
// todo: not sure what to do with this guy
|
||||
interface RequireModule {
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
config(): {};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
interface RequireMap {
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
prefix: string;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
parentMap: RequireMap;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
originalName: string;
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
fullName: string;
|
||||
}
|
||||
|
||||
interface Require {
|
||||
|
||||
/**
|
||||
* Configure require.js
|
||||
**/
|
||||
config(config: RequireConfig): Require;
|
||||
|
||||
/**
|
||||
* CommonJS require call
|
||||
* @param module Module to load
|
||||
* @return The loaded module
|
||||
*/
|
||||
(module: string): any;
|
||||
|
||||
/**
|
||||
* Start the main app logic.
|
||||
* Callback is optional.
|
||||
* Can alternatively use deps and callback.
|
||||
* @param modules Required modules to load.
|
||||
**/
|
||||
(modules: string[]): void;
|
||||
|
||||
/**
|
||||
* @see Require()
|
||||
* @param ready Called when required modules are ready.
|
||||
**/
|
||||
(modules: string[], ready: Function): void;
|
||||
|
||||
/**
|
||||
* @see http://requirejs.org/docs/api.html#errbacks
|
||||
* @param ready Called when required modules are ready.
|
||||
**/
|
||||
(modules: string[], ready: Function, errback: Function): void;
|
||||
|
||||
/**
|
||||
* Generate URLs from require module
|
||||
* @param module Module to URL
|
||||
* @return URL string
|
||||
**/
|
||||
toUrl(module: string): string;
|
||||
|
||||
/**
|
||||
* Returns true if the module has already been loaded and defined.
|
||||
* @param module Module to check
|
||||
**/
|
||||
defined(module: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the module has already been requested or is in the process of loading and should be available at some point.
|
||||
* @param module Module to check
|
||||
**/
|
||||
specified(module: string): boolean;
|
||||
|
||||
/**
|
||||
* On Error override
|
||||
* @param err
|
||||
**/
|
||||
onError(err: RequireError, errback?: (err: RequireError) => void): void;
|
||||
|
||||
/**
|
||||
* Undefine a module
|
||||
* @param module Module to undefine.
|
||||
**/
|
||||
undef(module: string): void;
|
||||
|
||||
/**
|
||||
* Semi-private function, overload in special instance of undef()
|
||||
**/
|
||||
onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
|
||||
}
|
||||
|
||||
interface RequireDefine {
|
||||
|
||||
/**
|
||||
* Define Simple Name/Value Pairs
|
||||
* @param config Dictionary of Named/Value pairs for the config.
|
||||
**/
|
||||
(config: { [key: string]: any; }): void;
|
||||
|
||||
/**
|
||||
* Define function.
|
||||
* @param func: The function module.
|
||||
**/
|
||||
(func: () => any): void;
|
||||
|
||||
/**
|
||||
* Define function with dependencies.
|
||||
* @param deps List of dependencies module IDs.
|
||||
* @param ready Callback function when the dependencies are loaded.
|
||||
* callback param deps module dependencies
|
||||
* callback return module definition
|
||||
**/
|
||||
(deps: string[], ready: Function): void;
|
||||
|
||||
/**
|
||||
* Define module with simplified CommonJS wrapper.
|
||||
* @param ready
|
||||
* callback require requirejs instance
|
||||
* callback exports exports object
|
||||
* callback module module
|
||||
* callback return module definition
|
||||
**/
|
||||
(ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
|
||||
|
||||
/**
|
||||
* Define a module with a name and dependencies.
|
||||
* @param name The name of the module.
|
||||
* @param deps List of dependencies module IDs.
|
||||
* @param ready Callback function when the dependencies are loaded.
|
||||
* callback deps module dependencies
|
||||
* callback return module definition
|
||||
**/
|
||||
(name: string, deps: string[], ready: Function): void;
|
||||
|
||||
/**
|
||||
* Define a module with a name.
|
||||
* @param name The name of the module.
|
||||
* @param ready Callback function when the dependencies are loaded.
|
||||
* callback return module definition
|
||||
**/
|
||||
(name: string, ready: Function): void;
|
||||
|
||||
/**
|
||||
* Used to allow a clear indicator that a global define function (as needed for script src browser loading) conforms
|
||||
* to the AMD API, any global define function SHOULD have a property called "amd" whose value is an object.
|
||||
* This helps avoid conflict with any other existing JavaScript code that could have defined a define() function
|
||||
* that does not conform to the AMD API.
|
||||
* define.amd.jQuery is specific to jQuery and indicates that the loader is able to account for multiple version
|
||||
* of jQuery being loaded simultaneously.
|
||||
*/
|
||||
amd: Object;
|
||||
}
|
||||
|
||||
// Ambient declarations for 'require' and 'define'
|
||||
declare var requirejs: Require;
|
||||
declare var require: Require;
|
||||
declare var define: RequireDefine;
|
|
@ -0,0 +1,7 @@
|
|||
/// <reference path="jquery/jquery.d.ts" />
|
||||
/// <reference path="knockout/knockout.d.ts" />
|
||||
/// <reference path="q/Q.d.ts" />
|
||||
/// <reference path="requirejs/require.d.ts" />
|
||||
/// <reference path="../node_modules/vss-web-extension-sdk/typings/vss.d.ts" />
|
||||
/// <reference path="../node_modules/vss-web-extension-sdk/typings/tfs.d.ts" />
|
||||
/// <reference path="react/react.d.ts" />
|
|
@ -0,0 +1,29 @@
|
|||
const webpack = require('webpack');
|
||||
|
||||
module.exports = {
|
||||
output: {
|
||||
filename: "bundle.js",
|
||||
libraryTarget: "amd"
|
||||
},
|
||||
externals: [{
|
||||
"q": true,
|
||||
"react": true,
|
||||
"react-dom": true
|
||||
},
|
||||
/^TFS\//, // Ignore TFS/* since they are coming from VSTS host
|
||||
/^VSS\// // Ignore VSS/* since they are coming from VSTS host
|
||||
],
|
||||
resolve: {
|
||||
alias: { "OfficeFabric": "../node_modules/office-ui-fabric-react/lib-amd" }
|
||||
},
|
||||
plugins: [
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false,
|
||||
},
|
||||
output: {
|
||||
comments: false,
|
||||
},
|
||||
}),
|
||||
]
|
||||
};
|
Загрузка…
Ссылка в новой задаче