Skip to content

Commit 91951b8

Browse files
authored
fix: types for dialog.addFiles (#339)
* fix: types for dialog.addFiles * chore: fix lint
1 parent dd2e75c commit 91951b8

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,13 @@ Set a function to be called whenever **progress state changes**.
289289

290290
Define a reference object to address the Dialog API wrapper.
291291

292+
[Dialog API reference][api-refs-dialog]
293+
<!-- TODO: * [Example][sandbox-ref] -->
294+
292295
```typescript
293296
interface DialogApi {
294-
addFiles(files: FileInfo[]): void;
297+
addFiles(type: string, files: any[]): void;
298+
addFiles(files: Array<JQuery.Deferred<FileInfo>>): void;
295299
switchTab(tab: string): void;
296300
getFileColl(): CollectionOfPromises<FileInfo>;
297301
hideTab(tab: string): void;
@@ -301,9 +305,6 @@ interface DialogApi {
301305
}
302306
```
303307

304-
* [Dialog API reference][api-refs-dialog]
305-
<!-- TODO: * [Example][sandbox-ref] -->
306-
307308
<br>
308309

309310
#### Those methods works exactly the same way as in `Widget` component:

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ interface CollectionOfPromises<T> extends UniqCollection<JQuery.Deferred<T>> {
299299
}
300300

301301
interface DialogApi {
302+
addFiles(type: string, files: any[]): void;
302303
addFiles(files: Array<JQuery.Deferred<FileInfo>>): void;
303304
switchTab(tab: string): void;
304305
getFileColl(): CollectionOfPromises<FileInfo>;

types/test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ const UnsplashCreator: CustomTabConstructor = (
134134
Random photo from unsplash:
135135
<br />
136136
<button
137-
onClick={() =>
137+
onClick={() => {
138138
dialog.addFiles([
139139
uploadcare.fileFrom(
140140
"url",
141141
"https://source.unsplash.com/random/800x600/",
142142
settings
143143
)
144-
])
144+
]);
145+
146+
dialog.addFiles('object', [new Blob(['test'])]);
147+
}
145148
}
146149
>
147150
{"Load ✨"}

0 commit comments

Comments
 (0)