-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from lino-levan/feat-file-chooser
feat: file chooser api + `page.waitForEvent`
- Loading branch information
Showing
17 changed files
with
203 additions
and
124 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
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { ensureDirSync } from "https://deno.land/std@0.198.0/fs/ensure_dir.ts"; | ||
import { ensureDirSync } from "https://deno.land/std@0.201.0/fs/ensure_dir.ts"; | ||
import { launch } from "../../mod.ts"; | ||
import { type PageProps } from "https://deno.land/x/[email protected]/page.ts"; | ||
import { ensureFileSync } from "https://deno.land/std@0.198.0/fs/ensure_file.ts"; | ||
import { ensureFileSync } from "https://deno.land/std@0.201.0/fs/ensure_file.ts"; | ||
|
||
export const config = { | ||
title: "Showcase", | ||
|
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
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
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
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
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
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,35 @@ | ||
import { resolve } from "https://deno.land/[email protected]/path/resolve.ts"; | ||
|
||
import type { | ||
Celestial, | ||
Page_fileChooserOpened, | ||
} from "../bindings/celestial.ts"; | ||
|
||
/** | ||
* Dialog provides an api for managing a page's dialog events. | ||
*/ | ||
export class FileChooser { | ||
#celestial: Celestial; | ||
#backendNodeId: number; | ||
|
||
/** | ||
* Whether this file chooser accepts multiple files. | ||
*/ | ||
readonly multiple: boolean; | ||
|
||
constructor(celestial: Celestial, config: Required<Page_fileChooserOpened>) { | ||
this.multiple = config.mode === "selectMultiple"; | ||
this.#celestial = celestial; | ||
this.#backendNodeId = config.backendNodeId; | ||
} | ||
|
||
/** | ||
* Sets the value of the file input this chooser is associated with. If some of the filePaths are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files. | ||
*/ | ||
async setFiles(files: string[]) { | ||
await this.#celestial.DOM.setFileInputFiles({ | ||
files: files.map((file) => resolve(file)), | ||
backendNodeId: this.#backendNodeId, | ||
}); | ||
} | ||
} |
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
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
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
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
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
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
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