diff options
| author | Shulhan <ms@kilabit.info> | 2024-02-05 01:09:49 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-02-05 02:32:51 +0700 |
| commit | 7e0b412323db013e225cc8122c83cc765e561229 (patch) | |
| tree | b948f4f80dcd6bc5df0864cb2ba2774935ac848f /input/example.ts | |
| parent | ef954b5aae36934165103c398b783bac1fb4c911 (diff) | |
| download | pakakeh.ts-7e0b412323db013e225cc8122c83cc765e561229.tar.xz | |
input: implement component for inputing file
Diffstat (limited to 'input/example.ts')
| -rw-r--r-- | input/example.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/input/example.ts b/input/example.ts index 2fbd5ad..473c4a1 100644 --- a/input/example.ts +++ b/input/example.ts @@ -1,11 +1,26 @@ // SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> // SPDX-License-Identifier: GPL-3.0-or-later +import { WuiInputFile } from "./file.js"; import { WuiInputString, WuiInputStringOpts } from "./string.js"; import { WuiInputNumber, WuiInputNumberOpts } from "./number.js"; import { WuiInputSelect, WuiInputSelectOpts } from "./select.js"; import { WuiInputCheckboxes, WuiInputCheckboxesOpts } from "./checkboxes.js"; +function exampleInputFile() { + const inputFile = new WuiInputFile(); + + inputFile.label = "Input file"; + inputFile.hint = "Select file to be uploaded."; + inputFile.accept = "image/*"; + inputFile.onChange = (file: File) => { + console.log( + `Uploading ${file.name} with size ${file.size}, type ${file.type}, and last modified at ${file.lastModified}.`, + ); + }; + document.body.appendChild(inputFile.element()); +} + function exampleInputString() { const elExample = document.createElement("div"); @@ -236,6 +251,7 @@ function exampleInputCheckboxes() { elExample.appendChild(elLog); } +exampleInputFile(); exampleInputString(); exampleInputNumber(); exampleInputSelect(); |
