diff options
| author | Shulhan <ms@kilabit.info> | 2021-09-05 16:09:55 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-09-05 18:36:42 +0700 |
| commit | 2df99a87e652db2c82383b59307b6016ae2ba4f4 (patch) | |
| tree | ddca74b85f61962dae505e404706b5f2336ed901 /input/example.ts | |
| parent | 437cee56693f69b2a58f37f8a5ff5b931ea803a2 (diff) | |
| download | pakakeh.ts-2df99a87e652db2c82383b59307b6016ae2ba4f4.tar.xz | |
input: implement class WuiInputString
The WuiInputString create an HTML input for string with predefined
options.
The required options are "label" and "value".
Diffstat (limited to 'input/example.ts')
| -rw-r--r-- | input/example.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/input/example.ts b/input/example.ts index 3e68451..aa26d2d 100644 --- a/input/example.ts +++ b/input/example.ts @@ -1,5 +1,50 @@ +import { WuiInputString, WuiInputStringOpts } from "./string.js" import { WuiInputNumber, WuiInputNumberOpts } from "./number.js" +function exampleInputString() { + let el_example = document.createElement("div") + + let el_title = document.createElement("h3") + el_title.innerText = "Input string" + el_example.appendChild(el_title) + + let opts: WuiInputStringOpts = { + id: "my_input_string", + label: "Input string with ID", + value: "Hello, input string", + hint: "The input ID is 'my_input_string'", + onChangeHandler: (new_value: string) => { + console.log("input string new value: ", new_value) + } + } + let el_input_string = new WuiInputString(opts) + el_example.appendChild(el_input_string.el) + + opts = { + label: "Input string disabled", + value: "Hello, disabled input string", + is_disabled: true, + hint: "The input string is disabled", + onChangeHandler: (new_value: string) => { + console.log("input string new value: ", new_value) + } + } + el_input_string = new WuiInputString(opts) + el_example.appendChild(el_input_string.el) + + opts = { + label: "Input string without hint", + value: "Hello, input string without hint", + onChangeHandler: (new_value: string) => { + console.log("input string without hint: new value: ", new_value) + } + } + el_input_string = new WuiInputString(opts) + el_example.appendChild(el_input_string.el) + + document.body.appendChild(el_example) +} + function exampleInputNumber() { let el_example = document.createElement("div") @@ -66,4 +111,5 @@ function exampleInputNumber() { document.body.appendChild(el_example) } +exampleInputString() exampleInputNumber() |
