forked from DefinitelyTyped/DefinitelyTyped
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add types for frappe-gantt (DefinitelyTyped#41561)
* Add frappe-gantt types * Add refresh method * Update index.d.ts
- Loading branch information
1 parent
33fa63b
commit c56c683
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Gantt from 'frappe-gantt'; | ||
|
||
const tasks = [ | ||
{ | ||
id: 'Task 1', | ||
name: 'Redesign website', | ||
start: '2016-12-28', | ||
end: '2016-12-31', | ||
progress: 20, | ||
dependencies: 'Task 2, Task 3' | ||
} | ||
]; | ||
const gantt1 = new Gantt('#gantt', tasks); | ||
|
||
gantt1.change_view_mode('Week'); | ||
gantt1.refresh(tasks); | ||
|
||
new Gantt('#gantt', tasks, { | ||
on_click: (task) => { }, | ||
on_date_change: (task, start, end) => { }, | ||
on_progress_change: (task, progress) => { }, | ||
on_view_change: (mode) => { } | ||
}); | ||
|
||
new Gantt('#gantt', tasks, { | ||
custom_popup_html: (task) => { | ||
const end_date = task._end.format('MMM D'); | ||
return ` | ||
<div class="details-container"> | ||
<h5>${task.name}</h5> | ||
<p>Expected to finish by ${end_date}</p> | ||
<p>${task.progress}% completed!</p> | ||
</div> | ||
`; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Type definitions for frappe-gantt 0.3 | ||
// Project: https://github.com/frappe/gantt | ||
// Definitions by: Sam Alexander <https://github.com/samalexander> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
export = Gantt; | ||
|
||
declare class Gantt { | ||
constructor(wrapper: string, tasks: Gantt.Task[], options?: Gantt.Options); | ||
|
||
change_view_mode(mode: Gantt.viewMode): void; | ||
refresh(tasks: Gantt.Task[]): void; | ||
} | ||
|
||
declare namespace Gantt { | ||
interface Task { | ||
id: string; | ||
name: string; | ||
start: string; | ||
end: string; | ||
progress: number; | ||
dependencies: string; | ||
custom_class?: string; | ||
} | ||
|
||
interface Options { | ||
header_height?: number; | ||
column_width?: number; | ||
step?: number; | ||
view_modes?: viewMode[]; | ||
bar_height?: number; | ||
bar_corner_radius?: number; | ||
arrow_curve?: number; | ||
padding?: number; | ||
view_mode?: viewMode; | ||
date_format?: string; | ||
custom_popup_html?: string | ((task: any) => string); | ||
on_click?: (task: any) => void; | ||
on_date_change?: (task: any, start: string, end: string) => void; | ||
on_progress_change?: (task: any, progress: number) => void; | ||
on_view_change?: (mode: viewMode) => void; | ||
} | ||
|
||
type viewMode = 'Quarter Day' | 'Half Day' | 'Day' | 'Week' | 'Month'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictFunctionTypes": true, | ||
"strictNullChecks": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"esModuleInterop": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"frappe-gantt-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "dtslint/dt.json" } |